blob: e8feba82c4368f5c7a8ee2d0a7ec320b2298d5e9 [file] [log] [blame]
#!/bin/sh
#
# This is a wrapper for xz to compress the kernel image using appropriate
# compression options depending on the architecture.
#
# Author: Lasse Collin <lasse.collin@tukaani.org>
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
#
BLOCK_SIZE=2621440
DICT_SIZE=2097152
PRESET=6
BCJ=
LZMA2OPTS=
case $SRCARCH in
x86) BCJ=--x86 ;;
powerpc) BCJ=--powerpc ;;
ia64) BCJ=--ia64; LZMA2OPTS=pb=4 ;;
arm) BCJ=--arm ;;
sparc) BCJ=--sparc ;;
esac
if [ "$BCJ" = "--arm" ] && grep -Fq CONFIG_ARM_THUMB=y "$srctree/$KCONFIG_CONFIG"; then
BCJ=--armthumb
fi
:<<EOF
exec $XZ --check=crc32 $BCJ --lzma2=$LZMA2OPTS,dict=32MiB
EOF
set -e
LZMA2OPTS=$LZMA2OPTS,preset=$PRESET,dict=$DICT_SIZE
if [ -n "$TMP_DIR" ]; then
export TMPDIR=$TMP_DIR
fi
TMPF=`mktemp`
split -b $BLOCK_SIZE - $TMPF.part
$XZ --check=crc32 $BCJ --lzma2=$LZMA2OPTS $TMPF.part??
cat $TMPF.part??.xz
rm -f $TMPF $TMPF.part?? $TMPF.part??.xz