diff options
Diffstat (limited to 'scripts/Makefile.lib')
-rw-r--r-- | scripts/Makefile.lib | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 979619574f70..f8cf938dde98 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
@@ -183,20 +183,34 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ | |||
183 | # --------------------------------------------------------------------------- | 183 | # --------------------------------------------------------------------------- |
184 | 184 | ||
185 | quiet_cmd_gzip = GZIP $@ | 185 | quiet_cmd_gzip = GZIP $@ |
186 | cmd_gzip = gzip -f -9 < $< > $@ | 186 | cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \ |
187 | (rm -f $@ ; false) | ||
187 | 188 | ||
188 | 189 | ||
189 | # Bzip2 | 190 | # Bzip2 |
190 | # --------------------------------------------------------------------------- | 191 | # --------------------------------------------------------------------------- |
191 | 192 | ||
192 | # Bzip2 does not include size in file... so we have to fake that | 193 | # Bzip2 and LZMA do not include size in file... so we have to fake that; |
193 | size_append=$(CONFIG_SHELL) $(srctree)/scripts/bin_size | 194 | # append the size as a 32-bit littleendian number as gzip does. |
194 | 195 | size_append = echo -ne $(shell \ | |
195 | quiet_cmd_bzip2 = BZIP2 $@ | 196 | dec_size=0; \ |
196 | cmd_bzip2 = (bzip2 -9 < $< && $(size_append) $<) > $@ || (rm -f $@ ; false) | 197 | for F in $1; do \ |
198 | fsize=$$(stat -c "%s" $$F); \ | ||
199 | dec_size=$$(expr $$dec_size + $$fsize); \ | ||
200 | done; \ | ||
201 | printf "%08x" $$dec_size | \ | ||
202 | sed 's/\(..\)\(..\)\(..\)\(..\)/\\\\x\4\\\\x\3\\\\x\2\\\\x\1/g' \ | ||
203 | ) | ||
204 | |||
205 | quiet_cmd_bzip2 = BZIP2 $@ | ||
206 | cmd_bzip2 = (cat $(filter-out FORCE,$^) | \ | ||
207 | bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ | ||
208 | (rm -f $@ ; false) | ||
197 | 209 | ||
198 | # Lzma | 210 | # Lzma |
199 | # --------------------------------------------------------------------------- | 211 | # --------------------------------------------------------------------------- |
200 | 212 | ||
201 | quiet_cmd_lzma = LZMA $@ | 213 | quiet_cmd_lzma = LZMA $@ |
202 | cmd_lzma = (lzma -9 -c $< && $(size_append) $<) >$@ || (rm -f $@ ; false) | 214 | cmd_lzma = (cat $(filter-out FORCE,$^) | \ |
215 | lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ | ||
216 | (rm -f $@ ; false) | ||