aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.lib28
-rw-r--r--scripts/xz_wrap.sh23
2 files changed, 51 insertions, 0 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 396da16aabf8..1c702ca8aac8 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -262,6 +262,34 @@ cmd_lzo = (cat $(filter-out FORCE,$^) | \
262 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ 262 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
263 (rm -f $@ ; false) 263 (rm -f $@ ; false)
264 264
265# XZ
266# ---------------------------------------------------------------------------
267# Use xzkern to compress the kernel image and xzmisc to compress other things.
268#
269# xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage
270# of the kernel decompressor. A BCJ filter is used if it is available for
271# the target architecture. xzkern also appends uncompressed size of the data
272# using size_append. The .xz format has the size information available at
273# the end of the file too, but it's in more complex format and it's good to
274# avoid changing the part of the boot code that reads the uncompressed size.
275# Note that the bytes added by size_append will make the xz tool think that
276# the file is corrupt. This is expected.
277#
278# xzmisc doesn't use size_append, so it can be used to create normal .xz
279# files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very
280# big dictionary would increase the memory usage too much in the multi-call
281# decompression mode. A BCJ filter isn't used either.
282quiet_cmd_xzkern = XZKERN $@
283cmd_xzkern = (cat $(filter-out FORCE,$^) | \
284 sh $(srctree)/scripts/xz_wrap.sh && \
285 $(call size_append, $(filter-out FORCE,$^))) > $@ || \
286 (rm -f $@ ; false)
287
288quiet_cmd_xzmisc = XZMISC $@
289cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
290 xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
291 (rm -f $@ ; false)
292
265# misc stuff 293# misc stuff
266# --------------------------------------------------------------------------- 294# ---------------------------------------------------------------------------
267quote:=" 295quote:="
diff --git a/scripts/xz_wrap.sh b/scripts/xz_wrap.sh
new file mode 100644
index 000000000000..17a5798c29da
--- /dev/null
+++ b/scripts/xz_wrap.sh
@@ -0,0 +1,23 @@
1#!/bin/sh
2#
3# This is a wrapper for xz to compress the kernel image using appropriate
4# compression options depending on the architecture.
5#
6# Author: Lasse Collin <lasse.collin@tukaani.org>
7#
8# This file has been put into the public domain.
9# You can do whatever you want with this file.
10#
11
12BCJ=
13LZMA2OPTS=
14
15case $ARCH in
16 x86|x86_64) BCJ=--x86 ;;
17 powerpc) BCJ=--powerpc ;;
18 ia64) BCJ=--ia64; LZMA2OPTS=pb=4 ;;
19 arm) BCJ=--arm ;;
20 sparc) BCJ=--sparc ;;
21esac
22
23exec xz --check=crc32 $BCJ --lzma2=$LZMA2OPTS,dict=32MiB