Blame view
scripts/Makefile.lib
14.9 KB
b24413180
|
1 |
# SPDX-License-Identifier: GPL-2.0 |
f77bf0142
|
2 3 4 5 6 |
# Backward compatibility asflags-y += $(EXTRA_AFLAGS) ccflags-y += $(EXTRA_CFLAGS) cppflags-y += $(EXTRA_CPPFLAGS) ldflags-y += $(EXTRA_LDFLAGS) |
5f2fb52fa
|
7 8 |
always-y += $(always) hostprogs += $(hostprogs-y) $(hostprogs-m) |
f77bf0142
|
9 |
|
8fdc3fbbd
|
10 |
# flags that take effect in current and sub directories |
4e13d47c5
|
11 12 |
KBUILD_AFLAGS += $(subdir-asflags-y) KBUILD_CFLAGS += $(subdir-ccflags-y) |
720097d89
|
13 |
|
1da177e4c
|
14 15 16 17 18 |
# Figure out what we need to build from the various variables # =========================================================================== # When an object is listed to be built compiled-in and modular, # only build the compiled-in version |
1da177e4c
|
19 20 21 22 |
obj-m := $(filter-out $(obj-y),$(obj-m)) # Libraries are always collected in one lib file. # Filter out objects already built-in |
1da177e4c
|
23 |
lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) |
8fdc3fbbd
|
24 25 26 27 |
# Determine modorder. # Unfortunately, we don't have information about ordering between -y # and -m subdirs. Just put -y's first. modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko)) |
1da177e4c
|
28 29 30 |
# Handle objects in subdirs # --------------------------------------------------------------------------- |
f49821ee3
|
31 |
# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a |
1da177e4c
|
32 |
# and add the directory to the list of dirs to descend into: $(subdir-y) |
38385f8f0
|
33 |
# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) |
1da177e4c
|
34 |
# and add the directory to the list of dirs to descend into: $(subdir-m) |
1da177e4c
|
35 36 37 38 |
__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) subdir-y += $(__subdir-y) __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) subdir-m += $(__subdir-m) |
56d589361
|
39 |
ifdef need-builtin |
f49821ee3
|
40 |
obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) |
56d589361
|
41 42 43 |
else obj-y := $(filter-out %/, $(obj-y)) endif |
1da177e4c
|
44 45 46 |
obj-m := $(filter-out %/, $(obj-m)) # Subdirectories we need to descend into |
1da177e4c
|
47 |
subdir-ym := $(sort $(subdir-y) $(subdir-m)) |
33e84f2e7
|
48 49 50 |
# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))), $(m)))) multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))), $(m)))) |
1da177e4c
|
51 |
multi-used := $(multi-used-y) $(multi-used-m) |
1da177e4c
|
52 |
|
f5fb97652
|
53 54 |
# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to # tell kbuild to descend |
f49821ee3
|
55 |
subdir-obj-y := $(filter %/built-in.a, $(obj-y)) |
1da177e4c
|
56 |
|
f98fe47ce
|
57 58 |
# Replace multi-part objects by their individual parts, # including built-in.a from subdirectories |
33e84f2e7
|
59 60 |
real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m))) |
1da177e4c
|
61 |
|
5f2fb52fa
|
62 |
always-y += $(always-m) |
7e7962dd1
|
63 64 65 66 |
# DTB # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built extra-y += $(dtb-y) extra-$(CONFIG_OF_ALL_DTBS) += $(dtb-) |
4f0e3a57d
|
67 68 69 70 |
ifneq ($(CHECK_DTBS),) extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y)) extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) endif |
1da177e4c
|
71 72 73 |
# Add subdir path extra-y := $(addprefix $(obj)/,$(extra-y)) |
5f2fb52fa
|
74 |
always-y := $(addprefix $(obj)/,$(always-y)) |
1da177e4c
|
75 |
targets := $(addprefix $(obj)/,$(targets)) |
551559e13
|
76 |
modorder := $(addprefix $(obj)/,$(modorder)) |
1da177e4c
|
77 78 79 |
obj-m := $(addprefix $(obj)/,$(obj-m)) lib-y := $(addprefix $(obj)/,$(lib-y)) subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) |
f5f336812
|
80 81 |
real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) |
1da177e4c
|
82 |
multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) |
1da177e4c
|
83 |
subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) |
1da177e4c
|
84 |
|
c0152e9a6
|
85 |
# Finds the multi-part object the current object will be linked into. |
1664a3779
|
86 87 88 |
# If the object belongs to two or more multi-part objects, list them all. modname-multi = $(sort $(foreach m,$(multi-used),\ $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))) |
c0152e9a6
|
89 |
|
1664a3779
|
90 91 92 93 |
__modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) modname = $(subst $(space),:,$(__modname)) modfile = $(addprefix $(obj)/,$(__modname)) |
c0152e9a6
|
94 |
|
54b8ae66a
|
95 96 |
# target with $(obj)/ and its suffix stripped target-stem = $(basename $(patsubst $(obj)/%,%,$@)) |
1da177e4c
|
97 |
# These flags are needed for modversions and compiling, so we define them here |
8fdc3fbbd
|
98 |
# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will |
1da177e4c
|
99 |
# end up in (or would, if it gets compiled in) |
7e826c44f
|
100 |
name-fix = $(call stringify,$(subst $(comma),_,$(subst -,_,$1))) |
b42841b7b
|
101 |
basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) |
aeacb019b
|
102 |
modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) |
1664a3779
|
103 |
modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile)) |
1da177e4c
|
104 |
|
4e13d47c5
|
105 |
orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ |
54b8ae66a
|
106 107 |
$(ccflags-y) $(CFLAGS_$(target-stem).o) _c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), $(orig_c_flags)) |
4e13d47c5
|
108 |
orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \ |
54b8ae66a
|
109 110 111 |
$(asflags-y) $(AFLAGS_$(target-stem).o) _a_flags = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), $(orig_a_flags)) _cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds) |
1da177e4c
|
112 |
|
2521f2c22
|
113 114 115 116 117 118 119 120 121 122 |
# # Enable gcov profiling flags for a file, directory or for all files depending # on variables GCOV_PROFILE_obj.o, GCOV_PROFILE and CONFIG_GCOV_PROFILE_ALL # (in this order) # ifeq ($(CONFIG_GCOV_KERNEL),y) _c_flags += $(if $(patsubst n%,, \ $(GCOV_PROFILE_$(basetarget).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)), \ $(CFLAGS_GCOV)) endif |
0b24becc8
|
123 124 125 126 127 128 129 |
# # Enable address sanitizer flags for kernel except some files or directories # we don't want to check (depends on variables KASAN_SANITIZE_obj.o, KASAN_SANITIZE) # ifeq ($(CONFIG_KASAN),y) _c_flags += $(if $(patsubst n%,, \ $(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \ |
0e410e158
|
130 |
$(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE)) |
0b24becc8
|
131 |
endif |
c6d308534
|
132 133 134 135 136 |
ifeq ($(CONFIG_UBSAN),y) _c_flags += $(if $(patsubst n%,, \ $(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \ $(CFLAGS_UBSAN)) endif |
5c9a8750a
|
137 138 |
ifeq ($(CONFIG_KCOV),y) _c_flags += $(if $(patsubst n%,, \ |
a4691deab
|
139 |
$(KCOV_INSTRUMENT_$(basetarget).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRUMENT_ALL)), \ |
5c9a8750a
|
140 141 |
$(CFLAGS_KCOV)) endif |
cdd750bfb
|
142 143 |
# $(srctree)/$(src) for including checkin headers from generated source files # $(objtree)/$(obj) for including generated headers from checkin source files |
58156ba44
|
144 |
ifeq ($(KBUILD_EXTMOD),) |
051f278e9
|
145 |
ifdef building_out_of_srctree |
cdd750bfb
|
146 147 148 |
_c_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) _a_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) _cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) |
1da177e4c
|
149 |
endif |
58156ba44
|
150 |
endif |
1da177e4c
|
151 |
|
eb27ea5ce
|
152 153 154 155 156 157 |
part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y) quiet_modtag = $(if $(part-of-module),[M], ) modkern_cflags = \ $(if $(part-of-module), \ $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ |
1664a3779
|
158 |
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags)) |
eb27ea5ce
|
159 160 161 162 |
modkern_aflags = $(if $(part-of-module), \ $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \ $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)) |
d8672b40d
|
163 |
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
a95b37e20
|
164 |
-include $(srctree)/include/linux/compiler_types.h \ |
cdd750bfb
|
165 |
$(_c_flags) $(modkern_cflags) \ |
b42841b7b
|
166 |
$(basename_flags) $(modname_flags) |
1da177e4c
|
167 |
|
d8672b40d
|
168 |
a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
cdd750bfb
|
169 |
$(_a_flags) $(modkern_aflags) |
1da177e4c
|
170 |
|
d8672b40d
|
171 |
cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
cdd750bfb
|
172 |
$(_cpp_flags) |
1da177e4c
|
173 |
|
d503ac531
|
174 |
ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) |
1da177e4c
|
175 |
|
50f9ddaf6
|
176 |
DTC_INCLUDE := $(srctree)/scripts/dtc/include-prefixes |
b0a4d8b3c
|
177 |
dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ |
50f9ddaf6
|
178 |
$(addprefix -I,$(DTC_INCLUDE)) \ |
e570d7c15
|
179 |
-undef -D__DTS__ |
c8589d1e9
|
180 181 182 183 184 185 186 187 |
# Useful for describing the dependency of composite objects # Usage: # $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add) define multi_depend $(foreach m, $(notdir $1), \ $(eval $(obj)/$m: \ $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s))))))) endef |
1da177e4c
|
188 189 190 191 192 |
# Shipped files # =========================================================================== quiet_cmd_shipped = SHIPPED $@ cmd_shipped = cat $< > $@ |
991d76c95
|
193 |
$(obj)/%: $(src)/%_shipped |
1da177e4c
|
194 195 196 197 |
$(call cmd,shipped) # Commands useful for building a boot image # =========================================================================== |
38385f8f0
|
198 |
# |
1da177e4c
|
199 200 201 202 203 |
# Use as following: # # target: source(s) FORCE # $(if_changed,ld/objcopy/gzip) # |
836caba77
|
204 |
# and add target to extra-y so that we know we have to |
1da177e4c
|
205 206 207 208 209 210 |
# read in the saved command line # Linking # --------------------------------------------------------------------------- quiet_cmd_ld = LD $@ |
afa974b77
|
211 |
cmd_ld = $(LD) $(ld_flags) $(real-prereqs) -o $@ |
1da177e4c
|
212 |
|
898f5a009
|
213 214 215 216 |
# Archive # --------------------------------------------------------------------------- quiet_cmd_ar = AR $@ |
13dc8c029
|
217 |
cmd_ar = rm -f $@; $(AR) cDPrsT $@ $(real-prereqs) |
898f5a009
|
218 |
|
1da177e4c
|
219 220 221 222 223 224 225 226 227 228 |
# Objcopy # --------------------------------------------------------------------------- quiet_cmd_objcopy = OBJCOPY $@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ # Gzip # --------------------------------------------------------------------------- quiet_cmd_gzip = GZIP $@ |
afa974b77
|
229 |
cmd_gzip = cat $(real-prereqs) | gzip -n -f -9 > $@ |
1da177e4c
|
230 |
|
aab94339c
|
231 232 |
# DTC # --------------------------------------------------------------------------- |
6b22b3d16
|
233 |
DTC ?= $(objtree)/scripts/dtc/dtc |
aab94339c
|
234 |
|
bc553986a
|
235 |
# Disable noisy checks by default |
e27128db6
|
236 |
ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),) |
8654cb8d0
|
237 |
DTC_FLAGS += -Wno-unit_address_vs_reg \ |
8654cb8d0
|
238 |
-Wno-unit_address_format \ |
4fd98e374
|
239 240 |
-Wno-avoid_unnecessary_addr_size \ -Wno-alias_paths \ |
74656b682
|
241 |
-Wno-graph_child_address \ |
70523a3ce
|
242 |
-Wno-simple_bus_reg \ |
74656b682
|
243 |
-Wno-unique_unit_address \ |
8654cb8d0
|
244 |
-Wno-pci_device_reg |
bc553986a
|
245 |
endif |
e27128db6
|
246 |
ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),) |
8654cb8d0
|
247 248 |
DTC_FLAGS += -Wnode_name_chars_strict \ -Wproperty_name_chars_strict |
bc553986a
|
249 |
endif |
331f74167
|
250 |
DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) |
aab94339c
|
251 |
# Generate an assembly file to wrap the output of the device tree compiler |
1c00a47e4
|
252 |
quiet_cmd_dt_S_dtb= DTB $@ |
aab94339c
|
253 |
cmd_dt_S_dtb= \ |
b79c6aa6a
|
254 |
{ \ |
aab94339c
|
255 256 257 |
echo '\#include <asm-generic/vmlinux.lds.h>'; \ echo '.section .dtb.init.rodata,"a"'; \ echo '.balign STRUCT_ALIGNMENT'; \ |
55fe6da9e
|
258 259 |
echo '.global __dtb_$(subst -,_,$(*F))_begin'; \ echo '__dtb_$(subst -,_,$(*F))_begin:'; \ |
aab94339c
|
260 |
echo '.incbin "$<" '; \ |
55fe6da9e
|
261 262 |
echo '__dtb_$(subst -,_,$(*F))_end:'; \ echo '.global __dtb_$(subst -,_,$(*F))_end'; \ |
aab94339c
|
263 |
echo '.balign STRUCT_ALIGNMENT'; \ |
b79c6aa6a
|
264 |
} > $@ |
aab94339c
|
265 |
|
a7f924190
|
266 267 |
$(obj)/%.dtb.S: $(obj)/%.dtb FORCE $(call if_changed,dt_S_dtb) |
aab94339c
|
268 269 |
quiet_cmd_dtc = DTC $@ |
77479b38e
|
270 |
cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ |
37c8a5faf
|
271 |
$(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ |
4f0e3a57d
|
272 |
$(DTC) -O $(2) -o $@ -b 0 \ |
50f9ddaf6
|
273 |
$(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \ |
b0a4d8b3c
|
274 275 |
-d $(depfile).dtc.tmp $(dtc-tmp) ; \ cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) |
1da177e4c
|
276 |
|
b8fc5b215
|
277 |
$(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE |
4f0e3a57d
|
278 279 280 281 282 283 284 |
$(call if_changed_dep,dtc,dtb) DT_CHECKER ?= dt-validate DT_BINDING_DIR := Documentation/devicetree/bindings DT_TMP_SCHEMA := $(objtree)/$(DT_BINDING_DIR)/processed-schema.yaml quiet_cmd_dtb_check = CHECK $@ |
fd63fab48
|
285 |
cmd_dtb_check = $(DT_CHECKER) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ |
4f0e3a57d
|
286 |
|
7a0496056
|
287 |
define rule_dtc |
f5688663d
|
288 289 |
$(call cmd_and_fixdep,dtc,yaml) $(call cmd,dtb_check) |
4f0e3a57d
|
290 291 292 |
endef $(obj)/%.dt.yaml: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE |
7a0496056
|
293 |
$(call if_changed_rule,dtc) |
90b335fbb
|
294 |
|
b0a4d8b3c
|
295 |
dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) |
22435f383
|
296 |
|
bc22c17e1
|
297 298 |
# Bzip2 # --------------------------------------------------------------------------- |
d3dd3b5a2
|
299 300 |
# Bzip2 and LZMA do not include size in file... so we have to fake that; # append the size as a 32-bit littleendian number as gzip does. |
4a2ff67c8
|
301 |
size_append = printf $(shell \ |
d3dd3b5a2
|
302 |
dec_size=0; \ |
afa974b77
|
303 |
for F in $(real-prereqs); do \ |
a670b0b4a
|
304 |
fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \ |
d3dd3b5a2
|
305 306 |
dec_size=$$(expr $$dec_size + $$fsize); \ done; \ |
1373411ae
|
307 308 309 310 311 312 313 314 |
printf "%08x " $$dec_size | \ sed 's/\(..\)/\1 /g' | { \ read ch0 ch1 ch2 ch3; \ for ch in $$ch3 $$ch2 $$ch1 $$ch0; do \ printf '%s%03o' '\\' $$((0x$$ch)); \ done; \ } \ |
d3dd3b5a2
|
315 316 317 |
) quiet_cmd_bzip2 = BZIP2 $@ |
b956c7a6d
|
318 |
cmd_bzip2 = { cat $(real-prereqs) | bzip2 -9; $(size_append); } > $@ |
bc22c17e1
|
319 320 321 322 323 |
# Lzma # --------------------------------------------------------------------------- quiet_cmd_lzma = LZMA $@ |
b956c7a6d
|
324 |
cmd_lzma = { cat $(real-prereqs) | lzma -9; $(size_append); } > $@ |
7dd65feb6
|
325 |
|
2d74b2c62
|
326 |
quiet_cmd_lzo = LZO $@ |
b956c7a6d
|
327 |
cmd_lzo = { cat $(real-prereqs) | lzop -9; $(size_append); } > $@ |
d61931d89
|
328 |
|
e76e1fdfa
|
329 |
quiet_cmd_lz4 = LZ4 $@ |
b956c7a6d
|
330 |
cmd_lz4 = { cat $(real-prereqs) | lz4c -l -c1 stdin stdout; \ |
b79c6aa6a
|
331 |
$(size_append); } > $@ |
e76e1fdfa
|
332 |
|
e33936451
|
333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
# U-Boot mkimage # --------------------------------------------------------------------------- MKIMAGE := $(srctree)/scripts/mkuboot.sh # SRCARCH just happens to match slightly more than ARCH (on sparc), so reduces # the number of overrides in arch makefiles UIMAGE_ARCH ?= $(SRCARCH) UIMAGE_COMPRESSION ?= $(if $(2),$(2),none) UIMAGE_OPTS-y ?= UIMAGE_TYPE ?= kernel UIMAGE_LOADADDR ?= arch_must_set_this UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR) UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)' |
e33936451
|
347 |
|
786ac51a4
|
348 |
quiet_cmd_uimage = UIMAGE $@ |
858805b33
|
349 |
cmd_uimage = $(BASH) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \ |
e33936451
|
350 351 352 |
-C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \ -T $(UIMAGE_TYPE) \ -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \ |
786ac51a4
|
353 |
-n $(UIMAGE_NAME) -d $< $@ |
e33936451
|
354 |
|
24fa0402a
|
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# 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 $@ |
b956c7a6d
|
373 |
cmd_xzkern = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh; \ |
b79c6aa6a
|
374 |
$(size_append); } > $@ |
24fa0402a
|
375 376 |
quiet_cmd_xzmisc = XZMISC $@ |
b79c6aa6a
|
377 |
cmd_xzmisc = cat $(real-prereqs) | xz --check=crc32 --lzma2=dict=1MiB > $@ |
ebf003f0c
|
378 379 380 381 382 |
# ASM offsets # --------------------------------------------------------------------------- # Default sed regexp - multiline due to syntax constraints |
cf0c3e68a
|
383 384 385 |
# # Use [:space:] because LLVM's integrated assembler inserts <tab> around # the .ascii directive whereas GCC keeps the <space> as-is. |
ebf003f0c
|
386 |
define sed-offsets |
cf0c3e68a
|
387 388 |
's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \ /^->/{s:->#\(.*\):/* \1 */:; \ |
ebf003f0c
|
389 |
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ |
cf0c3e68a
|
390 |
s:->::; p;}' |
ebf003f0c
|
391 392 393 394 395 |
endef # Use filechk to avoid rebuilds when a header changes, but the resulting file # does not define filechk_offsets |
ebf003f0c
|
396 397 398 399 400 401 402 403 |
echo "#ifndef $2"; \ echo "#define $2"; \ echo "/*"; \ echo " * DO NOT MODIFY."; \ echo " *"; \ echo " * This file was generated by Kbuild"; \ echo " */"; \ echo ""; \ |
43fee2b23
|
404 |
sed -ne $(sed-offsets) < $<; \ |
ebf003f0c
|
405 |
echo ""; \ |
ad7740863
|
406 |
echo "#endif" |
ebf003f0c
|
407 |
endef |