diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-05-06 00:17:15 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-05-08 20:16:22 -0400 |
commit | d3dd3b5a29bb9582957451531fed461628dfc834 (patch) | |
tree | 1c9961963861552a1a4759c27cc624a3098da860 | |
parent | 0b4eb462da10f832b28d518abffa4d77805928a0 (diff) |
kbuild: allow compressors (gzip, bzip2, lzma) to take multiple inputs
Allow the compression commands in Kbuild (i.e. gzip, bzip2, lzma) to
take multiple input files and emit the concatenated compressed
output. This avoids an intermediate step when a kernel image is built
from multiple components, such as the relocatable x86-32 kernel.
Sam Ravnborg integrated the bin_size script into the Makefile.
[ Impact: new build feature, not yet used ]
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
-rw-r--r-- | scripts/Makefile.lib | 28 | ||||
-rw-r--r-- | scripts/bin_size | 10 |
2 files changed, 21 insertions, 17 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) | ||
diff --git a/scripts/bin_size b/scripts/bin_size deleted file mode 100644 index 43e1b360cee6..000000000000 --- a/scripts/bin_size +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | if [ $# = 0 ] ; then | ||
4 | echo Usage: $0 file | ||
5 | fi | ||
6 | |||
7 | size_dec=`stat -c "%s" $1` | ||
8 | size_hex_echo_string=`printf "%08x" $size_dec | | ||
9 | sed 's/\(..\)\(..\)\(..\)\(..\)/\\\\x\4\\\\x\3\\\\x\2\\\\x\1/g'` | ||
10 | /bin/echo -ne $size_hex_echo_string | ||