Makefile.lib 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. #
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # Backward compatibility
  5. asflags-y += $(EXTRA_AFLAGS)
  6. ccflags-y += $(EXTRA_CFLAGS)
  7. cppflags-y += $(EXTRA_CPPFLAGS)
  8. ldflags-y += $(EXTRA_LDFLAGS)
  9. #
  10. # flags that take effect in sub directories
  11. export KBUILD_SUBDIR_ASFLAGS := $(KBUILD_SUBDIR_ASFLAGS) $(subdir-asflags-y)
  12. export KBUILD_SUBDIR_CCFLAGS := $(KBUILD_SUBDIR_CCFLAGS) $(subdir-ccflags-y)
  13. # Figure out what we need to build from the various variables
  14. # ===========================================================================
  15. # When an object is listed to be built compiled-in and modular,
  16. # only build the compiled-in version
  17. obj-m := $(filter-out $(obj-y),$(obj-m))
  18. # Libraries are always collected in one lib file.
  19. # Filter out objects already built-in
  20. lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
  21. # Handle objects in subdirs
  22. # ---------------------------------------------------------------------------
  23. # o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o
  24. # and add the directory to the list of dirs to descend into: $(subdir-y)
  25. # o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
  26. # and add the directory to the list of dirs to descend into: $(subdir-m)
  27. # Determine modorder.
  28. # Unfortunately, we don't have information about ordering between -y
  29. # and -m subdirs. Just put -y's first.
  30. modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko))
  31. __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
  32. subdir-y += $(__subdir-y)
  33. __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
  34. subdir-m += $(__subdir-m)
  35. obj-y := $(patsubst %/, %/built-in.o, $(obj-y))
  36. obj-m := $(filter-out %/, $(obj-m))
  37. # Subdirectories we need to descend into
  38. subdir-ym := $(sort $(subdir-y) $(subdir-m))
  39. # if $(foo-objs) exists, foo.o is a composite object
  40. multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
  41. multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
  42. multi-used := $(multi-used-y) $(multi-used-m)
  43. single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
  44. # Build list of the parts of our composite objects, our composite
  45. # objects depend on those (obviously)
  46. multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y)))
  47. multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
  48. multi-objs := $(multi-objs-y) $(multi-objs-m)
  49. # $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
  50. # tell kbuild to descend
  51. subdir-obj-y := $(filter %/built-in.o, $(obj-y))
  52. # $(obj-dirs) is a list of directories that contain object files
  53. obj-dirs := $(dir $(multi-objs) $(obj-y))
  54. # Replace multi-part objects by their individual parts, look at local dir only
  55. real-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)
  56. real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
  57. # Add subdir path
  58. extra-y := $(addprefix $(obj)/,$(extra-y))
  59. always := $(addprefix $(obj)/,$(always))
  60. targets := $(addprefix $(obj)/,$(targets))
  61. modorder := $(addprefix $(obj)/,$(modorder))
  62. obj-y := $(addprefix $(obj)/,$(obj-y))
  63. obj-m := $(addprefix $(obj)/,$(obj-m))
  64. lib-y := $(addprefix $(obj)/,$(lib-y))
  65. subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
  66. real-objs-y := $(addprefix $(obj)/,$(real-objs-y))
  67. real-objs-m := $(addprefix $(obj)/,$(real-objs-m))
  68. single-used-m := $(addprefix $(obj)/,$(single-used-m))
  69. multi-used-y := $(addprefix $(obj)/,$(multi-used-y))
  70. multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
  71. multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
  72. multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
  73. subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
  74. obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
  75. # These flags are needed for modversions and compiling, so we define them here
  76. # already
  77. # $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will
  78. # end up in (or would, if it gets compiled in)
  79. # Note: Files that end up in two or more modules are compiled without the
  80. # KBUILD_MODNAME definition. The reason is that any made-up name would
  81. # differ in different configs.
  82. name-fix = $(subst $(comma),_,$(subst -,_,$1))
  83. basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
  84. modname_flags = $(if $(filter 1,$(words $(modname))),\
  85. -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
  86. orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
  87. $(ccflags-y) $(CFLAGS_$(basetarget).o)
  88. _c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
  89. orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \
  90. $(asflags-y) $(AFLAGS_$(basetarget).o)
  91. _a_flags = $(filter-out $(AFLAGS_REMOVE_$(basetarget).o), $(orig_a_flags))
  92. _cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
  93. #
  94. # Enable gcov profiling flags for a file, directory or for all files depending
  95. # on variables GCOV_PROFILE_obj.o, GCOV_PROFILE and CONFIG_GCOV_PROFILE_ALL
  96. # (in this order)
  97. #
  98. ifeq ($(CONFIG_GCOV_KERNEL),y)
  99. _c_flags += $(if $(patsubst n%,, \
  100. $(GCOV_PROFILE_$(basetarget).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)), \
  101. $(CFLAGS_GCOV))
  102. endif
  103. #
  104. # Enable address sanitizer flags for kernel except some files or directories
  105. # we don't want to check (depends on variables KASAN_SANITIZE_obj.o, KASAN_SANITIZE)
  106. #
  107. ifeq ($(CONFIG_KASAN),y)
  108. _c_flags += $(if $(patsubst n%,, \
  109. $(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \
  110. $(CFLAGS_KASAN))
  111. endif
  112. # If building the kernel in a separate objtree expand all occurrences
  113. # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
  114. ifeq ($(KBUILD_SRC),)
  115. __c_flags = $(_c_flags)
  116. __a_flags = $(_a_flags)
  117. __cpp_flags = $(_cpp_flags)
  118. else
  119. # -I$(obj) locates generated .h files
  120. # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
  121. # and locates generated .h files
  122. # FIXME: Replace both with specific CFLAGS* statements in the makefiles
  123. __c_flags = $(call addtree,-I$(obj)) $(call flags,_c_flags)
  124. __a_flags = $(call flags,_a_flags)
  125. __cpp_flags = $(call flags,_cpp_flags)
  126. endif
  127. # Modified for U-Boot: LINUXINCLUDE -> UBOOTINCLUDE
  128. c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \
  129. $(__c_flags) $(modkern_cflags) \
  130. -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
  131. a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \
  132. $(__a_flags) $(modkern_aflags)
  133. cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \
  134. $(__cpp_flags)
  135. ld_flags = $(LDFLAGS) $(ldflags-y)
  136. dts_dir = $(srctree)/arch/$(ARCH)/dts
  137. # Try these files in order to find the U-Boot-specific .dtsi include file
  138. u_boot_dtsi_options = $(wildcard $(dts_dir)/$(basename $(notdir $<))-u-boot.dtsi) \
  139. $(wildcard $(dts_dir)/$(subst $\",,$(CONFIG_SYS_SOC))-u-boot.dtsi) \
  140. $(wildcard $(dts_dir)/$(subst $\",,$(CONFIG_SYS_CPU))-u-boot.dtsi) \
  141. $(wildcard $(dts_dir)/$(subst $\",,$(CONFIG_SYS_VENDOR))-u-boot.dtsi) \
  142. $(wildcard $(dts_dir)/u-boot.dtsi)
  143. # Uncomment for debugging
  144. # $(warning u_boot_dtsi_options: $(u_boot_dtsi_options))
  145. # We use the first match
  146. u_boot_dtsi = $(firstword $(u_boot_dtsi_options))
  147. # Modified for U-Boot
  148. dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \
  149. -I$(srctree)/arch/$(ARCH)/dts \
  150. -I$(srctree)/arch/$(ARCH)/dts/include \
  151. -Iinclude \
  152. -I$(srctree)/include \
  153. -I$(srctree)/arch/$(ARCH)/include \
  154. -include $(srctree)/include/linux/kconfig.h \
  155. -D__ASSEMBLY__ \
  156. -undef -D__DTS__
  157. # Finds the multi-part object the current object will be linked into
  158. modname-multi = $(sort $(foreach m,$(multi-used),\
  159. $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
  160. # Useful for describing the dependency of composite objects
  161. # Usage:
  162. # $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
  163. define multi_depend
  164. $(foreach m, $(notdir $1), \
  165. $(eval $(obj)/$m: \
  166. $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
  167. endef
  168. ifdef REGENERATE_PARSERS
  169. # GPERF
  170. # ---------------------------------------------------------------------------
  171. quiet_cmd_gperf = GPERF $@
  172. cmd_gperf = gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $<
  173. .PRECIOUS: $(src)/%.hash.c_shipped
  174. $(src)/%.hash.c_shipped: $(src)/%.gperf
  175. $(call cmd,gperf)
  176. # LEX
  177. # ---------------------------------------------------------------------------
  178. LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy)
  179. quiet_cmd_flex = LEX $@
  180. cmd_flex = flex -o$@ -L -P $(LEX_PREFIX) $<
  181. .PRECIOUS: $(src)/%.lex.c_shipped
  182. $(src)/%.lex.c_shipped: $(src)/%.l
  183. $(call cmd,flex)
  184. # YACC
  185. # ---------------------------------------------------------------------------
  186. YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy)
  187. quiet_cmd_bison = YACC $@
  188. cmd_bison = bison -o$@ -t -l -p $(YACC_PREFIX) $<
  189. .PRECIOUS: $(src)/%.tab.c_shipped
  190. $(src)/%.tab.c_shipped: $(src)/%.y
  191. $(call cmd,bison)
  192. quiet_cmd_bison_h = YACC $@
  193. cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $<
  194. .PRECIOUS: $(src)/%.tab.h_shipped
  195. $(src)/%.tab.h_shipped: $(src)/%.y
  196. $(call cmd,bison_h)
  197. endif
  198. # Shipped files
  199. # ===========================================================================
  200. quiet_cmd_shipped = SHIPPED $@
  201. cmd_shipped = cat $< > $@
  202. $(obj)/%: $(src)/%_shipped
  203. $(call cmd,shipped)
  204. # Commands useful for building a boot image
  205. # ===========================================================================
  206. #
  207. # Use as following:
  208. #
  209. # target: source(s) FORCE
  210. # $(if_changed,ld/objcopy/gzip)
  211. #
  212. # and add target to extra-y so that we know we have to
  213. # read in the saved command line
  214. # Linking
  215. # ---------------------------------------------------------------------------
  216. quiet_cmd_ld = LD $@
  217. cmd_ld = $(LD) $(LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) \
  218. $(filter-out FORCE,$^) -o $@
  219. # Objcopy
  220. # ---------------------------------------------------------------------------
  221. quiet_cmd_objcopy = OBJCOPY $@
  222. cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
  223. # Gzip
  224. # ---------------------------------------------------------------------------
  225. quiet_cmd_gzip = GZIP $@
  226. cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
  227. (rm -f $@ ; false)
  228. # DTC
  229. # ---------------------------------------------------------------------------
  230. # Generate an assembly file to wrap the output of the device tree compiler
  231. quiet_cmd_dt_S_dtb= DTB $@
  232. # Modified for U-Boot
  233. cmd_dt_S_dtb= \
  234. ( \
  235. echo '.section .dtb.init.rodata,"a"'; \
  236. echo '.balign 16'; \
  237. echo '.global __dtb_$(subst -,_,$(*F))_begin'; \
  238. echo '__dtb_$(subst -,_,$(*F))_begin:'; \
  239. echo '.incbin "$<" '; \
  240. echo '__dtb_$(subst -,_,$(*F))_end:'; \
  241. echo '.global __dtb_$(subst -,_,$(*F))_end'; \
  242. echo '.balign 16'; \
  243. ) > $@
  244. $(obj)/%.dtb.S: $(obj)/%.dtb
  245. $(call cmd,dt_S_dtb)
  246. quiet_cmd_dtc = DTC $@
  247. # Modified for U-Boot
  248. # Bring in any U-Boot-specific include after the '/dts-v1/;' header
  249. cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
  250. cat $< $(if $(u_boot_dtsi),\
  251. | sed 's%^/ {$$%\#include \"$(u_boot_dtsi)\"\n&%') | \
  252. $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \
  253. $(DTC) -O dtb -o $@ -b 0 \
  254. -i $(dir $<) $(DTC_FLAGS) \
  255. -d $(depfile).dtc.tmp $(dtc-tmp) ; \
  256. cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
  257. $(obj)/%.dtb: $(src)/%.dts FORCE
  258. $(call if_changed_dep,dtc)
  259. dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
  260. # Fonts
  261. # ---------------------------------------------------------------------------
  262. # Generate an assembly file to wrap the font data
  263. quiet_cmd_S_ttf= TTF $@
  264. # Modified for U-Boot
  265. cmd_S_ttf= \
  266. ( \
  267. echo '.section .rodata.ttf.init,"a"'; \
  268. echo '.balign 16'; \
  269. echo '.global __ttf_$(*F)_begin'; \
  270. echo '__ttf_$(*F)_begin:'; \
  271. echo '.incbin "$<" '; \
  272. echo '__ttf_$(*F)_end:'; \
  273. echo '.global __ttf_$(*F)_end'; \
  274. echo '.balign 16'; \
  275. ) > $@
  276. $(obj)/%.S: $(src)/%.ttf
  277. $(call cmd,S_ttf)
  278. # EFI Hello World application
  279. # ---------------------------------------------------------------------------
  280. # Generate an assembly file to wrap the EFI app
  281. cmd_S_efi= \
  282. ( \
  283. echo '.section .rodata.efi.init,"a"'; \
  284. echo '.balign 16'; \
  285. echo '.global __efi_hello_world_begin'; \
  286. echo '__efi_hello_world_begin:'; \
  287. echo '.incbin "$<" '; \
  288. echo '__efi_hello_world_end:'; \
  289. echo '.global __efi_hello_world_end'; \
  290. echo '.balign 16'; \
  291. ) > $@
  292. $(obj)/%_efi.S: $(obj)/%.efi
  293. $(call cmd,S_efi)
  294. $(obj)/%.efi: $(obj)/%.so
  295. $(OBJCOPY) -j .header -j .text -j .sdata -j .data -j .dynamic \
  296. -j .dynsym -j .rel* -j .rela* -j .reloc \
  297. $(if $(EFI_TARGET),$(EFI_TARGET),-O binary) $^ $@
  298. EFI_LDS_PATH = $(srctree)/arch/$(ARCH)/lib/$(EFI_LDS)
  299. $(obj)/helloworld.so: $(EFI_LDS_PATH)
  300. $(obj)/helloworld.so: $(obj)/helloworld.o arch/$(ARCH)/lib/$(EFI_CRT0) \
  301. arch/$(ARCH)/lib/$(EFI_RELOC)
  302. $(LD) -nostdlib -znocombreloc -T $(EFI_LDS_PATH) -shared -Bsymbolic \
  303. $^ -o $@
  304. # ACPI
  305. # ---------------------------------------------------------------------------
  306. quiet_cmd_acpi_c_asl= ASL $<
  307. cmd_acpi_c_asl= \
  308. $(CPP) -x assembler-with-cpp -D__ASSEMBLY__ -P $(UBOOTINCLUDE) -o $<.tmp $<; \
  309. iasl -p $< -tc $<.tmp $(if $(KBUILD_VERBOSE:1=), >/dev/null); \
  310. mv $(patsubst %.asl,%.hex,$<) $@
  311. $(obj)/dsdt.c: $(src)/dsdt.asl
  312. $(call cmd,acpi_c_asl)
  313. # Bzip2
  314. # ---------------------------------------------------------------------------
  315. # Bzip2 and LZMA do not include size in file... so we have to fake that;
  316. # append the size as a 32-bit littleendian number as gzip does.
  317. size_append = printf $(shell \
  318. dec_size=0; \
  319. for F in $1; do \
  320. fsize=$$(stat -c "%s" $$F); \
  321. dec_size=$$(expr $$dec_size + $$fsize); \
  322. done; \
  323. printf "%08x\n" $$dec_size | \
  324. sed 's/\(..\)/\1 /g' | { \
  325. read ch0 ch1 ch2 ch3; \
  326. for ch in $$ch3 $$ch2 $$ch1 $$ch0; do \
  327. printf '%s%03o' '\\' $$((0x$$ch)); \
  328. done; \
  329. } \
  330. )
  331. quiet_cmd_bzip2 = BZIP2 $@
  332. cmd_bzip2 = (cat $(filter-out FORCE,$^) | \
  333. bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
  334. (rm -f $@ ; false)
  335. # Lzma
  336. # ---------------------------------------------------------------------------
  337. quiet_cmd_lzma = LZMA $@
  338. cmd_lzma = (cat $(filter-out FORCE,$^) | \
  339. lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
  340. (rm -f $@ ; false)
  341. quiet_cmd_lzo = LZO $@
  342. cmd_lzo = (cat $(filter-out FORCE,$^) | \
  343. lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
  344. (rm -f $@ ; false)
  345. quiet_cmd_lz4 = LZ4 $@
  346. cmd_lz4 = (cat $(filter-out FORCE,$^) | \
  347. lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
  348. (rm -f $@ ; false)
  349. # U-Boot mkimage
  350. # ---------------------------------------------------------------------------
  351. MKIMAGE := $(srctree)/scripts/mkuboot.sh
  352. # SRCARCH just happens to match slightly more than ARCH (on sparc), so reduces
  353. # the number of overrides in arch makefiles
  354. UIMAGE_ARCH ?= $(SRCARCH)
  355. UIMAGE_COMPRESSION ?= $(if $(2),$(2),none)
  356. UIMAGE_OPTS-y ?=
  357. UIMAGE_TYPE ?= kernel
  358. UIMAGE_LOADADDR ?= arch_must_set_this
  359. UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR)
  360. UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)'
  361. UIMAGE_IN ?= $<
  362. UIMAGE_OUT ?= $@
  363. quiet_cmd_uimage = UIMAGE $(UIMAGE_OUT)
  364. cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
  365. -C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \
  366. -T $(UIMAGE_TYPE) \
  367. -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \
  368. -n $(UIMAGE_NAME) -d $(UIMAGE_IN) $(UIMAGE_OUT)
  369. # XZ
  370. # ---------------------------------------------------------------------------
  371. # Use xzkern to compress the kernel image and xzmisc to compress other things.
  372. #
  373. # xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage
  374. # of the kernel decompressor. A BCJ filter is used if it is available for
  375. # the target architecture. xzkern also appends uncompressed size of the data
  376. # using size_append. The .xz format has the size information available at
  377. # the end of the file too, but it's in more complex format and it's good to
  378. # avoid changing the part of the boot code that reads the uncompressed size.
  379. # Note that the bytes added by size_append will make the xz tool think that
  380. # the file is corrupt. This is expected.
  381. #
  382. # xzmisc doesn't use size_append, so it can be used to create normal .xz
  383. # files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very
  384. # big dictionary would increase the memory usage too much in the multi-call
  385. # decompression mode. A BCJ filter isn't used either.
  386. quiet_cmd_xzkern = XZKERN $@
  387. cmd_xzkern = (cat $(filter-out FORCE,$^) | \
  388. sh $(srctree)/scripts/xz_wrap.sh && \
  389. $(call size_append, $(filter-out FORCE,$^))) > $@ || \
  390. (rm -f $@ ; false)
  391. quiet_cmd_xzmisc = XZMISC $@
  392. cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
  393. xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
  394. (rm -f $@ ; false)
  395. # Additional commands for U-Boot
  396. #
  397. # mkimage
  398. # ---------------------------------------------------------------------------
  399. MKIMAGEOUTPUT ?= /dev/null
  400. quiet_cmd_mkimage = MKIMAGE $@
  401. cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \
  402. $(if $(KBUILD_VERBOSE:1=), >$(MKIMAGEOUTPUT))