xref: /linux/scripts/Makefile.lib (revision 7373f4f83c71d50f0aece6d94309ab7fde42180f)
1f77bf014SSam Ravnborg# Backward compatibility
2f77bf014SSam Ravnborgasflags-y  += $(EXTRA_AFLAGS)
3f77bf014SSam Ravnborgccflags-y  += $(EXTRA_CFLAGS)
4f77bf014SSam Ravnborgcppflags-y += $(EXTRA_CPPFLAGS)
5f77bf014SSam Ravnborgldflags-y  += $(EXTRA_LDFLAGS)
6f77bf014SSam Ravnborg
7720097d8SSam Ravnborg#
8720097d8SSam Ravnborg# flags that take effect in sub directories
9720097d8SSam Ravnborgexport KBUILD_SUBDIR_ASFLAGS := $(KBUILD_SUBDIR_ASFLAGS) $(subdir-asflags-y)
10720097d8SSam Ravnborgexport KBUILD_SUBDIR_CCFLAGS := $(KBUILD_SUBDIR_CCFLAGS) $(subdir-ccflags-y)
11720097d8SSam Ravnborg
121da177e4SLinus Torvalds# Figure out what we need to build from the various variables
131da177e4SLinus Torvalds# ===========================================================================
141da177e4SLinus Torvalds
151da177e4SLinus Torvalds# When an object is listed to be built compiled-in and modular,
161da177e4SLinus Torvalds# only build the compiled-in version
171da177e4SLinus Torvalds
181da177e4SLinus Torvaldsobj-m := $(filter-out $(obj-y),$(obj-m))
191da177e4SLinus Torvalds
201da177e4SLinus Torvalds# Libraries are always collected in one lib file.
211da177e4SLinus Torvalds# Filter out objects already built-in
221da177e4SLinus Torvalds
231da177e4SLinus Torvaldslib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
241da177e4SLinus Torvalds
251da177e4SLinus Torvalds
261da177e4SLinus Torvalds# Handle objects in subdirs
271da177e4SLinus Torvalds# ---------------------------------------------------------------------------
281da177e4SLinus Torvalds# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o
291da177e4SLinus Torvalds#   and add the directory to the list of dirs to descend into: $(subdir-y)
301da177e4SLinus Torvalds# o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
311da177e4SLinus Torvalds#   and add the directory to the list of dirs to descend into: $(subdir-m)
321da177e4SLinus Torvalds
33551559e1STejun Heo# Determine modorder.
34551559e1STejun Heo# Unfortunately, we don't have information about ordering between -y
35551559e1STejun Heo# and -m subdirs.  Just put -y's first.
36551559e1STejun Heomodorder	:= $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko))
37551559e1STejun Heo
381da177e4SLinus Torvalds__subdir-y	:= $(patsubst %/,%,$(filter %/, $(obj-y)))
391da177e4SLinus Torvaldssubdir-y	+= $(__subdir-y)
401da177e4SLinus Torvalds__subdir-m	:= $(patsubst %/,%,$(filter %/, $(obj-m)))
411da177e4SLinus Torvaldssubdir-m	+= $(__subdir-m)
421da177e4SLinus Torvaldsobj-y		:= $(patsubst %/, %/built-in.o, $(obj-y))
431da177e4SLinus Torvaldsobj-m		:= $(filter-out %/, $(obj-m))
441da177e4SLinus Torvalds
451da177e4SLinus Torvalds# Subdirectories we need to descend into
461da177e4SLinus Torvalds
471da177e4SLinus Torvaldssubdir-ym	:= $(sort $(subdir-y) $(subdir-m))
481da177e4SLinus Torvalds
491da177e4SLinus Torvalds# if $(foo-objs) exists, foo.o is a composite object
501da177e4SLinus Torvaldsmulti-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
511da177e4SLinus Torvaldsmulti-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
521da177e4SLinus Torvaldsmulti-used   := $(multi-used-y) $(multi-used-m)
531da177e4SLinus Torvaldssingle-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
541da177e4SLinus Torvalds
551da177e4SLinus Torvalds# Build list of the parts of our composite objects, our composite
561da177e4SLinus Torvalds# objects depend on those (obviously)
571da177e4SLinus Torvaldsmulti-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y)))
581da177e4SLinus Torvaldsmulti-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
591da177e4SLinus Torvaldsmulti-objs   := $(multi-objs-y) $(multi-objs-m)
601da177e4SLinus Torvalds
61f5fb9765SSam Ravnborg# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
62f5fb9765SSam Ravnborg# tell kbuild to descend
63f5fb9765SSam Ravnborgsubdir-obj-y := $(filter %/built-in.o, $(obj-y))
641da177e4SLinus Torvalds
651da177e4SLinus Torvalds# $(obj-dirs) is a list of directories that contain object files
661da177e4SLinus Torvaldsobj-dirs := $(dir $(multi-objs) $(subdir-obj-y))
671da177e4SLinus Torvalds
681da177e4SLinus Torvalds# Replace multi-part objects by their individual parts, look at local dir only
691da177e4SLinus Torvaldsreal-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
701da177e4SLinus Torvaldsreal-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
711da177e4SLinus Torvalds
721da177e4SLinus Torvalds# Add subdir path
731da177e4SLinus Torvalds
741da177e4SLinus Torvaldsextra-y		:= $(addprefix $(obj)/,$(extra-y))
751da177e4SLinus Torvaldsalways		:= $(addprefix $(obj)/,$(always))
761da177e4SLinus Torvaldstargets		:= $(addprefix $(obj)/,$(targets))
77551559e1STejun Heomodorder	:= $(addprefix $(obj)/,$(modorder))
781da177e4SLinus Torvaldsobj-y		:= $(addprefix $(obj)/,$(obj-y))
791da177e4SLinus Torvaldsobj-m		:= $(addprefix $(obj)/,$(obj-m))
801da177e4SLinus Torvaldslib-y		:= $(addprefix $(obj)/,$(lib-y))
811da177e4SLinus Torvaldssubdir-obj-y	:= $(addprefix $(obj)/,$(subdir-obj-y))
821da177e4SLinus Torvaldsreal-objs-y	:= $(addprefix $(obj)/,$(real-objs-y))
831da177e4SLinus Torvaldsreal-objs-m	:= $(addprefix $(obj)/,$(real-objs-m))
841da177e4SLinus Torvaldssingle-used-m	:= $(addprefix $(obj)/,$(single-used-m))
851da177e4SLinus Torvaldsmulti-used-y	:= $(addprefix $(obj)/,$(multi-used-y))
861da177e4SLinus Torvaldsmulti-used-m	:= $(addprefix $(obj)/,$(multi-used-m))
871da177e4SLinus Torvaldsmulti-objs-y	:= $(addprefix $(obj)/,$(multi-objs-y))
881da177e4SLinus Torvaldsmulti-objs-m	:= $(addprefix $(obj)/,$(multi-objs-m))
891da177e4SLinus Torvaldssubdir-ym	:= $(addprefix $(obj)/,$(subdir-ym))
901da177e4SLinus Torvaldsobj-dirs	:= $(addprefix $(obj)/,$(obj-dirs))
911da177e4SLinus Torvalds
921da177e4SLinus Torvalds# These flags are needed for modversions and compiling, so we define them here
931da177e4SLinus Torvalds# already
941da177e4SLinus Torvalds# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will
951da177e4SLinus Torvalds# end up in (or would, if it gets compiled in)
961da177e4SLinus Torvalds# Note: It's possible that one object gets potentially linked into more
971da177e4SLinus Torvalds#       than one module. In that case KBUILD_MODNAME will be set to foo_bar,
981da177e4SLinus Torvalds#       where foo and bar are the name of the modules.
99f83b5e32SUstyugov Romanname-fix = $(subst $(comma),_,$(subst -,_,$1))
1005e8d780dSSam Ravnborgbasename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
101f83b5e32SUstyugov Romanmodname_flags  = $(if $(filter 1,$(words $(modname))),\
102f83b5e32SUstyugov Roman                 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
1031da177e4SLinus Torvalds
104720097d8SSam Ravnborgorig_c_flags   = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
105d8672b40SSam Ravnborg                 $(ccflags-y) $(CFLAGS_$(basetarget).o)
106656ee82cSSteven Rostedt_c_flags       = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
107720097d8SSam Ravnborg_a_flags       = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \
108d8672b40SSam Ravnborg                 $(asflags-y) $(AFLAGS_$(basetarget).o)
109f77bf014SSam Ravnborg_cpp_flags     = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
1101da177e4SLinus Torvalds
1112521f2c2SPeter Oberparleiter#
1122521f2c2SPeter Oberparleiter# Enable gcov profiling flags for a file, directory or for all files depending
1132521f2c2SPeter Oberparleiter# on variables GCOV_PROFILE_obj.o, GCOV_PROFILE and CONFIG_GCOV_PROFILE_ALL
1142521f2c2SPeter Oberparleiter# (in this order)
1152521f2c2SPeter Oberparleiter#
1162521f2c2SPeter Oberparleiterifeq ($(CONFIG_GCOV_KERNEL),y)
1172521f2c2SPeter Oberparleiter_c_flags += $(if $(patsubst n%,, \
1182521f2c2SPeter Oberparleiter		$(GCOV_PROFILE_$(basetarget).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)), \
1192521f2c2SPeter Oberparleiter		$(CFLAGS_GCOV))
1202521f2c2SPeter Oberparleiterendif
1212521f2c2SPeter Oberparleiter
1229e1b9b80SAlan Jenkinsifdef CONFIG_SYMBOL_PREFIX
123d63f6d1bSMike Frysinger_sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
124d63f6d1bSMike Frysinger_cpp_flags += $(_sym_flags)
125d63f6d1bSMike Frysinger_a_flags += $(_sym_flags)
1269e1b9b80SAlan Jenkinsendif
1279e1b9b80SAlan Jenkins
1289e1b9b80SAlan Jenkins
1291da177e4SLinus Torvalds# If building the kernel in a separate objtree expand all occurrences
1301da177e4SLinus Torvalds# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
1311da177e4SLinus Torvalds
1321da177e4SLinus Torvaldsifeq ($(KBUILD_SRC),)
1331da177e4SLinus Torvalds__c_flags	= $(_c_flags)
1341da177e4SLinus Torvalds__a_flags	= $(_a_flags)
1351da177e4SLinus Torvalds__cpp_flags     = $(_cpp_flags)
1361da177e4SLinus Torvaldselse
1371da177e4SLinus Torvalds
1381da177e4SLinus Torvalds# -I$(obj) locates generated .h files
1391da177e4SLinus Torvalds# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
1401da177e4SLinus Torvalds#   and locates generated .h files
1411da177e4SLinus Torvalds# FIXME: Replace both with specific CFLAGS* statements in the makefiles
1421da177e4SLinus Torvalds__c_flags	= $(call addtree,-I$(obj)) $(call flags,_c_flags)
1431da177e4SLinus Torvalds__a_flags	=                          $(call flags,_a_flags)
1441da177e4SLinus Torvalds__cpp_flags     =                          $(call flags,_cpp_flags)
1451da177e4SLinus Torvaldsendif
1461da177e4SLinus Torvalds
147d8672b40SSam Ravnborgc_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
1481da177e4SLinus Torvalds		 $(__c_flags) $(modkern_cflags)                           \
14952159d98SJason Baron		 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
1501da177e4SLinus Torvalds
151d8672b40SSam Ravnborga_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
1521da177e4SLinus Torvalds		 $(__a_flags) $(modkern_aflags)
1531da177e4SLinus Torvalds
154d8672b40SSam Ravnborgcpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
155d8672b40SSam Ravnborg		 $(__cpp_flags)
1561da177e4SLinus Torvalds
157f77bf014SSam Ravnborgld_flags       = $(LDFLAGS) $(ldflags-y)
1581da177e4SLinus Torvalds
1591da177e4SLinus Torvalds# Finds the multi-part object the current object will be linked into
1601da177e4SLinus Torvaldsmodname-multi = $(sort $(foreach m,$(multi-used),\
1611da177e4SLinus Torvalds		$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
1621da177e4SLinus Torvalds
163*7373f4f8SArnaud Lacombeifdef REGENERATE_PARSERS
164*7373f4f8SArnaud Lacombe
165*7373f4f8SArnaud Lacombe# GPERF
166*7373f4f8SArnaud Lacombe# ---------------------------------------------------------------------------
167*7373f4f8SArnaud Lacombequiet_cmd_gperf = GPERF $@
168*7373f4f8SArnaud Lacombe      cmd_gperf = gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $<
169*7373f4f8SArnaud Lacombe
170*7373f4f8SArnaud Lacombe$(src)/%.hash.c_shipped: $(src)/%.gperf
171*7373f4f8SArnaud Lacombe	$(call cmd,gperf)
172*7373f4f8SArnaud Lacombe
173*7373f4f8SArnaud Lacombe# LEX
174*7373f4f8SArnaud Lacombe# ---------------------------------------------------------------------------
175*7373f4f8SArnaud LacombeLEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy)
176*7373f4f8SArnaud Lacombe
177*7373f4f8SArnaud Lacombequiet_cmd_flex = LEX     $@
178*7373f4f8SArnaud Lacombe      cmd_flex = flex -o$@ -L -P $(LEX_PREFIX) $<
179*7373f4f8SArnaud Lacombe
180*7373f4f8SArnaud Lacombe$(src)/%.lex.c_shipped: $(src)/%.l
181*7373f4f8SArnaud Lacombe	$(call cmd,flex)
182*7373f4f8SArnaud Lacombe
183*7373f4f8SArnaud Lacombe# YACC
184*7373f4f8SArnaud Lacombe# ---------------------------------------------------------------------------
185*7373f4f8SArnaud LacombeYACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy)
186*7373f4f8SArnaud Lacombe
187*7373f4f8SArnaud Lacombequiet_cmd_bison = YACC    $@
188*7373f4f8SArnaud Lacombe      cmd_bison = bison -o$@ -t -l -p $(YACC_PREFIX) $<
189*7373f4f8SArnaud Lacombe
190*7373f4f8SArnaud Lacombe$(src)/%.tab.c_shipped: $(src)/%.y
191*7373f4f8SArnaud Lacombe	$(call cmd,bison)
192*7373f4f8SArnaud Lacombe
193*7373f4f8SArnaud Lacombequiet_cmd_bison_h = YACC    $@
194*7373f4f8SArnaud Lacombe      cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $<
195*7373f4f8SArnaud Lacombe
196*7373f4f8SArnaud Lacombe$(src)/%.tab.h_shipped: $(src)/%.y
197*7373f4f8SArnaud Lacombe	$(call cmd,bison_h)
198*7373f4f8SArnaud Lacombe
199*7373f4f8SArnaud Lacombeendif
200*7373f4f8SArnaud Lacombe
2011da177e4SLinus Torvalds# Shipped files
2021da177e4SLinus Torvalds# ===========================================================================
2031da177e4SLinus Torvalds
2041da177e4SLinus Torvaldsquiet_cmd_shipped = SHIPPED $@
2051da177e4SLinus Torvaldscmd_shipped = cat $< > $@
2061da177e4SLinus Torvalds
2071da177e4SLinus Torvalds$(obj)/%:: $(src)/%_shipped
2081da177e4SLinus Torvalds	$(call cmd,shipped)
2091da177e4SLinus Torvalds
2101da177e4SLinus Torvalds# Commands useful for building a boot image
2111da177e4SLinus Torvalds# ===========================================================================
2121da177e4SLinus Torvalds#
2131da177e4SLinus Torvalds#	Use as following:
2141da177e4SLinus Torvalds#
2151da177e4SLinus Torvalds#	target: source(s) FORCE
2161da177e4SLinus Torvalds#		$(if_changed,ld/objcopy/gzip)
2171da177e4SLinus Torvalds#
218836caba7SSam Ravnborg#	and add target to extra-y so that we know we have to
2191da177e4SLinus Torvalds#	read in the saved command line
2201da177e4SLinus Torvalds
2211da177e4SLinus Torvalds# Linking
2221da177e4SLinus Torvalds# ---------------------------------------------------------------------------
2231da177e4SLinus Torvalds
2241da177e4SLinus Torvaldsquiet_cmd_ld = LD      $@
225f77bf014SSam Ravnborgcmd_ld = $(LD) $(LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) \
2261da177e4SLinus Torvalds	       $(filter-out FORCE,$^) -o $@
2271da177e4SLinus Torvalds
2281da177e4SLinus Torvalds# Objcopy
2291da177e4SLinus Torvalds# ---------------------------------------------------------------------------
2301da177e4SLinus Torvalds
2311da177e4SLinus Torvaldsquiet_cmd_objcopy = OBJCOPY $@
2321da177e4SLinus Torvaldscmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
2331da177e4SLinus Torvalds
2341da177e4SLinus Torvalds# Gzip
2351da177e4SLinus Torvalds# ---------------------------------------------------------------------------
2361da177e4SLinus Torvalds
2371da177e4SLinus Torvaldsquiet_cmd_gzip = GZIP    $@
2386ae9ecb8SMichal Marekcmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
239d3dd3b5aSH. Peter Anvin	(rm -f $@ ; false)
2401da177e4SLinus Torvalds
241aab94339SDirk Brandewie# DTC
242aab94339SDirk Brandewie# ---------------------------------------------------------------------------
243aab94339SDirk Brandewie
244aab94339SDirk Brandewie# Generate an assembly file to wrap the output of the device tree compiler
245aab94339SDirk Brandewiequiet_cmd_dt_S_dtb= DTB    $@
246aab94339SDirk Brandewiecmd_dt_S_dtb=						\
247aab94339SDirk Brandewie(							\
248aab94339SDirk Brandewie	echo '\#include <asm-generic/vmlinux.lds.h>'; 	\
249aab94339SDirk Brandewie	echo '.section .dtb.init.rodata,"a"';		\
250aab94339SDirk Brandewie	echo '.balign STRUCT_ALIGNMENT';		\
251aab94339SDirk Brandewie	echo '.global __dtb_$(*F)_begin';		\
252aab94339SDirk Brandewie	echo '__dtb_$(*F)_begin:';			\
253aab94339SDirk Brandewie	echo '.incbin "$<" ';				\
254aab94339SDirk Brandewie	echo '__dtb_$(*F)_end:';			\
255aab94339SDirk Brandewie	echo '.global __dtb_$(*F)_end';			\
256aab94339SDirk Brandewie	echo '.balign STRUCT_ALIGNMENT'; 		\
257aab94339SDirk Brandewie) > $@
258aab94339SDirk Brandewie
259aab94339SDirk Brandewie$(obj)/%.dtb.S: $(obj)/%.dtb
260aab94339SDirk Brandewie	$(call cmd,dt_S_dtb)
261aab94339SDirk Brandewie
262aab94339SDirk Brandewiequiet_cmd_dtc = DTC     $@
263aab94339SDirk Brandewiecmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $<
2641da177e4SLinus Torvalds
265bc22c17eSAlain Knaff# Bzip2
266bc22c17eSAlain Knaff# ---------------------------------------------------------------------------
267bc22c17eSAlain Knaff
268d3dd3b5aSH. Peter Anvin# Bzip2 and LZMA do not include size in file... so we have to fake that;
269d3dd3b5aSH. Peter Anvin# append the size as a 32-bit littleendian number as gzip does.
2704a2ff67cSMichael Tokarevsize_append = printf $(shell						\
271d3dd3b5aSH. Peter Anvindec_size=0;								\
272d3dd3b5aSH. Peter Anvinfor F in $1; do								\
273d3dd3b5aSH. Peter Anvin	fsize=$$(stat -c "%s" $$F);					\
274d3dd3b5aSH. Peter Anvin	dec_size=$$(expr $$dec_size + $$fsize);				\
275d3dd3b5aSH. Peter Anvindone;									\
2761373411aSJonathan Niederprintf "%08x\n" $$dec_size |						\
2771373411aSJonathan Nieder	sed 's/\(..\)/\1 /g' | {					\
2781373411aSJonathan Nieder		read ch0 ch1 ch2 ch3;					\
2791373411aSJonathan Nieder		for ch in $$ch3 $$ch2 $$ch1 $$ch0; do			\
2801373411aSJonathan Nieder			printf '%s%03o' '\\' $$((0x$$ch)); 		\
2811373411aSJonathan Nieder		done;							\
2821373411aSJonathan Nieder	}								\
283d3dd3b5aSH. Peter Anvin)
284bc22c17eSAlain Knaff
285bc22c17eSAlain Knaffquiet_cmd_bzip2 = BZIP2   $@
286d3dd3b5aSH. Peter Anvincmd_bzip2 = (cat $(filter-out FORCE,$^) | \
287d3dd3b5aSH. Peter Anvin	bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
288d3dd3b5aSH. Peter Anvin	(rm -f $@ ; false)
289bc22c17eSAlain Knaff
290bc22c17eSAlain Knaff# Lzma
291bc22c17eSAlain Knaff# ---------------------------------------------------------------------------
292bc22c17eSAlain Knaff
293bc22c17eSAlain Knaffquiet_cmd_lzma = LZMA    $@
294d3dd3b5aSH. Peter Anvincmd_lzma = (cat $(filter-out FORCE,$^) | \
295d3dd3b5aSH. Peter Anvin	lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
296d3dd3b5aSH. Peter Anvin	(rm -f $@ ; false)
2977dd65febSAlbin Tonnerre
2987dd65febSAlbin Tonnerrequiet_cmd_lzo = LZO     $@
2997dd65febSAlbin Tonnerrecmd_lzo = (cat $(filter-out FORCE,$^) | \
3007dd65febSAlbin Tonnerre	lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
3017dd65febSAlbin Tonnerre	(rm -f $@ ; false)
302d61931d8SBorislav Petkov
30324fa0402SLasse Collin# XZ
30424fa0402SLasse Collin# ---------------------------------------------------------------------------
30524fa0402SLasse Collin# Use xzkern to compress the kernel image and xzmisc to compress other things.
30624fa0402SLasse Collin#
30724fa0402SLasse Collin# xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage
30824fa0402SLasse Collin# of the kernel decompressor. A BCJ filter is used if it is available for
30924fa0402SLasse Collin# the target architecture. xzkern also appends uncompressed size of the data
31024fa0402SLasse Collin# using size_append. The .xz format has the size information available at
31124fa0402SLasse Collin# the end of the file too, but it's in more complex format and it's good to
31224fa0402SLasse Collin# avoid changing the part of the boot code that reads the uncompressed size.
31324fa0402SLasse Collin# Note that the bytes added by size_append will make the xz tool think that
31424fa0402SLasse Collin# the file is corrupt. This is expected.
31524fa0402SLasse Collin#
31624fa0402SLasse Collin# xzmisc doesn't use size_append, so it can be used to create normal .xz
31724fa0402SLasse Collin# files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very
31824fa0402SLasse Collin# big dictionary would increase the memory usage too much in the multi-call
31924fa0402SLasse Collin# decompression mode. A BCJ filter isn't used either.
32024fa0402SLasse Collinquiet_cmd_xzkern = XZKERN  $@
32124fa0402SLasse Collincmd_xzkern = (cat $(filter-out FORCE,$^) | \
32224fa0402SLasse Collin	sh $(srctree)/scripts/xz_wrap.sh && \
32324fa0402SLasse Collin	$(call size_append, $(filter-out FORCE,$^))) > $@ || \
32424fa0402SLasse Collin	(rm -f $@ ; false)
32524fa0402SLasse Collin
32624fa0402SLasse Collinquiet_cmd_xzmisc = XZMISC  $@
32724fa0402SLasse Collincmd_xzmisc = (cat $(filter-out FORCE,$^) | \
32824fa0402SLasse Collin	xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
32924fa0402SLasse Collin	(rm -f $@ ; false)
33024fa0402SLasse Collin
331d61931d8SBorislav Petkov# misc stuff
332d61931d8SBorislav Petkov# ---------------------------------------------------------------------------
333d61931d8SBorislav Petkovquote:="
334