summaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-10-17 15:36:39 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-11-04 12:18:55 +0100
commitccb281647704d6857d3491dc71746d2f7ce38fa7 (patch)
tree174abba08cfce552c97535d9c0abd1f8b32a99f5 /scripts/Makefile.lib
parent2f81d316d21113ab4288fbd3e84c03bf6f0c08ed (diff)
downloadbarebox-ccb281647704d6857d3491dc71746d2f7ce38fa7.tar.gz
barebox-ccb281647704d6857d3491dc71746d2f7ce38fa7.tar.xz
Add xz decompression support
This adds xz decompression support from the kernel. Both compressing the barebox binary with xz and decompressing xz files on the commandline is supported. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts/Makefile.lib')
-rw-r--r--scripts/Makefile.lib31
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 05387b235b..934ee07809 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -205,6 +205,37 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
%.gz: %
$(call if_changed,gzip)
+# XZ
+# ---------------------------------------------------------------------------
+# Use xzkern to compress the kernel image and xzmisc to compress other things.
+#
+# xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage
+# of the kernel decompressor. A BCJ filter is used if it is available for
+# the target architecture. xzkern also appends uncompressed size of the data
+# using size_append. The .xz format has the size information available at
+# the end of the file too, but it's in more complex format and it's good to
+# avoid changing the part of the boot code that reads the uncompressed size.
+# Note that the bytes added by size_append will make the xz tool think that
+# the file is corrupt. This is expected.
+#
+# xzmisc doesn't use size_append, so it can be used to create normal .xz
+# files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very
+# big dictionary would increase the memory usage too much in the multi-call
+# decompression mode. A BCJ filter isn't used either.
+quiet_cmd_xzkern = XZKERN $@
+cmd_xzkern = (cat $(filter-out FORCE,$^) | \
+ sh $(srctree)/scripts/xz_wrap.sh && \
+ $(call size_append, $(filter-out FORCE,$^))) > $@ || \
+ (rm -f $@ ; false)
+
+quiet_cmd_xzmisc = XZMISC $@
+cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
+ xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
+ (rm -f $@ ; false)
+
+%.xzkern: %
+ $(call if_changed,xzkern)
+
# DTC
# ---------------------------------------------------------------------------