1# SPDX-License-Identifier: GPL-2.0 2 3# Finds the multi-part object the current object will be linked into. 4# If the object belongs to two or more multi-part objects, list them all. 5modname-multi = $(sort $(foreach m,$(multi-obj-ym),\ 6 $(if $(filter $*.o, $(call suffix-search, $m, .o, -objs -y -m)),$(m:.o=)))) 7 8__modname = $(or $(modname-multi),$(basetarget)) 9 10modname = $(subst $(space),:,$(__modname)) 11modfile = $(addprefix $(obj)/,$(__modname)) 12 13# target with $(obj)/ and its suffix stripped 14target-stem = $(basename $(patsubst $(obj)/%,%,$@)) 15 16# These flags are needed for modversions and compiling, so we define them here 17# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will 18# end up in (or would, if it gets compiled in) 19name-fix-token = $(subst $(comma),_,$(subst -,_,$1)) 20name-fix = $(call stringify,$(call name-fix-token,$1)) 21basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) 22modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) \ 23 -D__KBUILD_MODNAME=$(call name-fix-token,$(modname)) 24modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile)) 25 26_c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), \ 27 $(filter-out $(ccflags-remove-y), \ 28 $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(ccflags-y)) \ 29 $(CFLAGS_$(target-stem).o)) 30_rust_flags = $(filter-out $(RUSTFLAGS_REMOVE_$(target-stem).o), \ 31 $(filter-out $(rustflags-remove-y), \ 32 $(KBUILD_RUSTFLAGS) $(rustflags-y)) \ 33 $(RUSTFLAGS_$(target-stem).o)) 34_a_flags = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), \ 35 $(filter-out $(asflags-remove-y), \ 36 $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(asflags-y)) \ 37 $(AFLAGS_$(target-stem).o)) 38_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds) 39 40# 41# Enable gcov profiling flags for a file, directory or for all files depending 42# on variables GCOV_PROFILE_obj.o, GCOV_PROFILE and CONFIG_GCOV_PROFILE_ALL 43# (in this order) 44# 45ifeq ($(CONFIG_GCOV_KERNEL),y) 46_c_flags += $(if $(patsubst n%,, \ 47 $(GCOV_PROFILE_$(target-stem).o)$(GCOV_PROFILE)$(if $(is-kernel-object),$(CONFIG_GCOV_PROFILE_ALL))), \ 48 $(CFLAGS_GCOV)) 49endif 50 51# 52# Enable address sanitizer flags for kernel except some files or directories 53# we don't want to check (depends on variables KASAN_SANITIZE_obj.o, KASAN_SANITIZE) 54# 55ifeq ($(CONFIG_KASAN),y) 56ifneq ($(CONFIG_KASAN_HW_TAGS),y) 57_c_flags += $(if $(patsubst n%,, \ 58 $(KASAN_SANITIZE_$(target-stem).o)$(KASAN_SANITIZE)$(is-kernel-object)), \ 59 $(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE)) 60_rust_flags += $(if $(patsubst n%,, \ 61 $(KASAN_SANITIZE_$(target-stem).o)$(KASAN_SANITIZE)$(is-kernel-object)), \ 62 $(RUSTFLAGS_KASAN)) 63endif 64endif 65 66ifeq ($(CONFIG_KMSAN),y) 67_c_flags += $(if $(patsubst n%,, \ 68 $(KMSAN_SANITIZE_$(target-stem).o)$(KMSAN_SANITIZE)$(is-kernel-object)), \ 69 $(CFLAGS_KMSAN)) 70_c_flags += $(if $(patsubst n%,, \ 71 $(KMSAN_ENABLE_CHECKS_$(target-stem).o)$(KMSAN_ENABLE_CHECKS)$(is-kernel-object)), \ 72 , -mllvm -msan-disable-checks=1) 73endif 74 75ifeq ($(CONFIG_UBSAN),y) 76_c_flags += $(if $(patsubst n%,, \ 77 $(UBSAN_SANITIZE_$(target-stem).o)$(UBSAN_SANITIZE)$(is-kernel-object)), \ 78 $(CFLAGS_UBSAN)) 79_c_flags += $(if $(patsubst n%,, \ 80 $(UBSAN_INTEGER_WRAP_$(target-stem).o)$(UBSAN_SANITIZE_$(target-stem).o)$(UBSAN_INTEGER_WRAP)$(UBSAN_SANITIZE)$(is-kernel-object)), \ 81 $(CFLAGS_UBSAN_INTEGER_WRAP)) 82endif 83 84ifeq ($(CONFIG_KCOV),y) 85_c_flags += $(if $(patsubst n%,, \ 86 $(KCOV_INSTRUMENT_$(target-stem).o)$(KCOV_INSTRUMENT)$(if $(is-kernel-object),$(CONFIG_KCOV_INSTRUMENT_ALL))), \ 87 $(CFLAGS_KCOV)) 88_rust_flags += $(if $(patsubst n%,, \ 89 $(KCOV_INSTRUMENT_$(target-stem).o)$(KCOV_INSTRUMENT)$(if $(is-kernel-object),$(CONFIG_KCOV_INSTRUMENT_ALL))), \ 90 $(RUSTFLAGS_KCOV)) 91endif 92 93# 94# Enable KCSAN flags except some files or directories we don't want to check 95# (depends on variables KCSAN_SANITIZE_obj.o, KCSAN_SANITIZE) 96# 97ifeq ($(CONFIG_KCSAN),y) 98_c_flags += $(if $(patsubst n%,, \ 99 $(KCSAN_SANITIZE_$(target-stem).o)$(KCSAN_SANITIZE)$(is-kernel-object)), \ 100 $(CFLAGS_KCSAN)) 101# Some uninstrumented files provide implied barriers required to avoid false 102# positives: set KCSAN_INSTRUMENT_BARRIERS for barrier instrumentation only. 103_c_flags += $(if $(patsubst n%,, \ 104 $(KCSAN_INSTRUMENT_BARRIERS_$(target-stem).o)$(KCSAN_INSTRUMENT_BARRIERS)n), \ 105 -D__KCSAN_INSTRUMENT_BARRIERS__) 106endif 107 108# 109# Enable context analysis flags only where explicitly opted in. 110# (depends on variables CONTEXT_ANALYSIS_obj.o, CONTEXT_ANALYSIS) 111# 112ifeq ($(CONFIG_WARN_CONTEXT_ANALYSIS),y) 113_c_flags += $(if $(patsubst n%,, \ 114 $(CONTEXT_ANALYSIS_$(target-stem).o)$(CONTEXT_ANALYSIS)$(if $(is-kernel-object),$(CONFIG_WARN_CONTEXT_ANALYSIS_ALL))), \ 115 $(CFLAGS_CONTEXT_ANALYSIS)) 116endif 117 118# 119# Enable AutoFDO build flags except some files or directories we don't want to 120# enable (depends on variables AUTOFDO_PROFILE_obj.o and AUTOFDO_PROFILE). 121# 122ifeq ($(CONFIG_AUTOFDO_CLANG),y) 123_c_flags += $(if $(patsubst n%,, \ 124 $(AUTOFDO_PROFILE_$(target-stem).o)$(AUTOFDO_PROFILE)$(is-kernel-object)), \ 125 $(CFLAGS_AUTOFDO_CLANG)) 126endif 127 128# 129# Enable Propeller build flags except some files or directories we don't want to 130# enable (depends on variables AUTOFDO_PROPELLER_obj.o and PROPELLER_PROFILE). 131# 132ifdef CONFIG_PROPELLER_CLANG 133_c_flags += $(if $(patsubst n%,, \ 134 $(AUTOFDO_PROFILE_$(target-stem).o)$(AUTOFDO_PROFILE)$(PROPELLER_PROFILE))$(is-kernel-object), \ 135 $(CFLAGS_PROPELLER_CLANG)) 136endif 137 138# $(src) for including checkin headers from generated source files 139# $(obj) for including generated headers from checkin source files 140ifdef building_out_of_srctree 141_c_flags += $(addprefix -I, $(src) $(obj)) 142_a_flags += $(addprefix -I, $(src) $(obj)) 143_cpp_flags += $(addprefix -I, $(src) $(obj)) 144endif 145 146# If $(is-kernel-object) is 'y', this object will be linked to vmlinux or modules 147is-kernel-object = $(or $(part-of-builtin),$(part-of-module)) 148 149part-of-builtin = $(if $(filter $(basename $@).o, $(real-obj-y) $(lib-y)),y) 150part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y) 151quiet_modtag = $(if $(part-of-module),[M], ) 152 153modkern_cflags = \ 154 $(if $(part-of-module), \ 155 $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ 156 $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags)) 157 158modkern_rustflags = \ 159 $(if $(part-of-module), \ 160 $(KBUILD_RUSTFLAGS_MODULE) $(RUSTFLAGS_MODULE), \ 161 $(KBUILD_RUSTFLAGS_KERNEL) $(RUSTFLAGS_KERNEL)) 162 163modkern_aflags = $(if $(part-of-module), \ 164 $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \ 165 $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) $(modfile_flags)) 166 167c_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 168 -include $(srctree)/include/linux/compiler_types.h \ 169 $(_c_flags) $(modkern_cflags) \ 170 $(basename_flags) $(modname_flags) 171 172rust_flags = $(_rust_flags) $(modkern_rustflags) @$(objtree)/include/generated/rustc_cfg 173 174a_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 175 $(_a_flags) $(modkern_aflags) $(modname_flags) 176 177cpp_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 178 $(_cpp_flags) 179 180ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) 181 182ifdef CONFIG_OBJTOOL 183 184objtool := $(objtree)/tools/objtool/objtool 185 186objtool-args-$(CONFIG_HAVE_JUMP_LABEL_HACK) += --hacks=jump_label 187objtool-args-$(CONFIG_HAVE_NOINSTR_HACK) += --hacks=noinstr 188objtool-args-$(CONFIG_MITIGATION_CALL_DEPTH_TRACKING) += --hacks=skylake 189objtool-args-$(CONFIG_X86_KERNEL_IBT) += --ibt 190objtool-args-$(CONFIG_FINEIBT) += --cfi 191objtool-args-$(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL) += --mcount 192ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL 193objtool-args-$(CONFIG_HAVE_OBJTOOL_NOP_MCOUNT) += --mnop 194endif 195objtool-args-$(CONFIG_UNWINDER_ORC) += --orc 196objtool-args-$(CONFIG_MITIGATION_RETPOLINE) += --retpoline 197objtool-args-$(CONFIG_MITIGATION_RETHUNK) += --rethunk 198objtool-args-$(CONFIG_MITIGATION_SLS) += --sls 199objtool-args-$(CONFIG_STACK_VALIDATION) += --stackval 200objtool-args-$(CONFIG_HAVE_STATIC_CALL_INLINE) += --static-call 201objtool-args-$(CONFIG_HAVE_UACCESS_VALIDATION) += --uaccess 202objtool-args-$(or $(CONFIG_GCOV_KERNEL),$(CONFIG_KCOV)) += --no-unreachable 203objtool-args-$(CONFIG_PREFIX_SYMBOLS) += --prefix=$(CONFIG_FUNCTION_PADDING_BYTES) 204objtool-args-$(CONFIG_OBJTOOL_WERROR) += --werror 205 206objtool-args = $(objtool-args-y) \ 207 $(if $(delay-objtool), --link) \ 208 $(if $(part-of-module), --module) 209 210delay-objtool := $(or $(CONFIG_LTO_CLANG),$(CONFIG_X86_KERNEL_IBT),$(CONFIG_KLP_BUILD)) 211 212cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool-args) $@) 213cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd) 214 215objtool-enabled := y 216 217endif # CONFIG_OBJTOOL 218 219# Useful for describing the dependency of composite objects 220# Usage: 221# $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add) 222define multi_depend 223$(foreach m, $1, \ 224 $(eval $m: \ 225 $(addprefix $(obj)/, $(call suffix-search, $(patsubst $(obj)/%,%,$m), $2, $3)))) 226endef 227 228# Remove ".." and "." from a path, without using "realpath" 229# Usage: 230# $(call normalize_path,path/to/../file) 231define normalize_path 232$(strip $(eval elements :=) \ 233$(foreach elem,$(subst /, ,$1), \ 234 $(if $(filter-out .,$(elem)), \ 235 $(if $(filter ..,$(elem)), \ 236 $(eval elements := $(wordlist 2,$(words $(elements)),x $(elements))), \ 237 $(eval elements := $(elements) $(elem))))) \ 238$(subst $(space),/,$(elements))) 239endef 240 241# Build commands 242# =========================================================================== 243# These are shared by some Makefile.* files. 244 245ifdef CONFIG_LTO_CLANG 246# Run $(LD) here to convert LLVM IR to ELF in the following cases: 247# - when this object needs objtool processing, as objtool cannot process LLVM IR 248# - when this is a single-object module, as modpost cannot process LLVM IR 249cmd_ld_single = $(if $(objtool-enabled)$(is-single-obj-m), ; $(LD) $(ld_flags) -r -o $(tmp-target) $@; mv $(tmp-target) $@) 250endif 251 252quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ 253 cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< \ 254 $(cmd_ld_single) \ 255 $(cmd_objtool) 256 257define rule_cc_o_c 258 $(call cmd_and_fixdep,cc_o_c) 259 $(call cmd,checksrc) 260 $(call cmd,checkdoc) 261 $(call cmd,gen_objtooldep) 262 $(call cmd,gen_symversions_c) 263 $(call cmd,record_mcount) 264 $(call cmd,warn_shared_object) 265endef 266 267quiet_cmd_as_o_S = AS $(quiet_modtag) $@ 268 cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< $(cmd_objtool) 269 270define rule_as_o_S 271 $(call cmd_and_fixdep,as_o_S) 272 $(call cmd,gen_objtooldep) 273 $(call cmd,gen_symversions_S) 274 $(call cmd,warn_shared_object) 275endef 276 277# Copy a file 278# =========================================================================== 279# 'cp' preserves permissions. If you use it to copy a file in read-only srctree, 280# the copy would be read-only as well, leading to an error when executing the 281# rule next time. Use 'cat' instead in order to generate a writable file. 282quiet_cmd_copy = COPY $@ 283 cmd_copy = cat $< > $@ 284 285$(obj)/%: $(src)/%_shipped 286 $(call cmd,copy) 287 288# Touch a file 289# =========================================================================== 290quiet_cmd_touch = TOUCH $(call normalize_path,$@) 291 cmd_touch = touch $@ 292 293# Commands useful for building a boot image 294# =========================================================================== 295# 296# Use as following: 297# 298# target: source(s) FORCE 299# $(if_changed,ld/objcopy/gzip) 300# 301# and add target to 'targets' so that we know we have to 302# read in the saved command line 303 304# Linking 305# --------------------------------------------------------------------------- 306 307quiet_cmd_ld = LD $@ 308 cmd_ld = $(LD) $(ld_flags) $(real-prereqs) -o $@ 309 310# Archive 311# --------------------------------------------------------------------------- 312 313quiet_cmd_ar = AR $@ 314 cmd_ar = rm -f $@; $(AR) cDPrsT $@ $(real-prereqs) 315 316# Objcopy 317# --------------------------------------------------------------------------- 318 319quiet_cmd_objcopy = OBJCOPY $@ 320cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ 321 322# Gzip 323# --------------------------------------------------------------------------- 324 325quiet_cmd_gzip = GZIP $@ 326 cmd_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9 > $@ 327 328# Bzip2 329# --------------------------------------------------------------------------- 330 331# Bzip2 and LZMA do not include size in file... so we have to fake that; 332# append the size as a 32-bit littleendian number as gzip does. 333size_append = printf $(shell \ 334dec_size=0; \ 335for F in $(real-prereqs); do \ 336 fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \ 337 dec_size=$$(expr $$dec_size + $$fsize); \ 338done; \ 339printf "%08x\n" $$dec_size | \ 340 sed 's/\(..\)/\1 /g' | { \ 341 read ch0 ch1 ch2 ch3; \ 342 for ch in $$ch3 $$ch2 $$ch1 $$ch0; do \ 343 printf '%s%03o' '\\' $$((0x$$ch)); \ 344 done; \ 345 } \ 346) 347 348quiet_cmd_file_size = GEN $@ 349 cmd_file_size = $(size_append) > $@ 350 351quiet_cmd_bzip2 = BZIP2 $@ 352 cmd_bzip2 = cat $(real-prereqs) | $(KBZIP2) -9 > $@ 353 354quiet_cmd_bzip2_with_size = BZIP2 $@ 355 cmd_bzip2_with_size = { cat $(real-prereqs) | $(KBZIP2) -9; $(size_append); } > $@ 356 357# Lzma 358# --------------------------------------------------------------------------- 359 360quiet_cmd_lzma = LZMA $@ 361 cmd_lzma = cat $(real-prereqs) | $(LZMA) -9 > $@ 362 363quiet_cmd_lzma_with_size = LZMA $@ 364 cmd_lzma_with_size = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@ 365 366quiet_cmd_lzo = LZO $@ 367 cmd_lzo = cat $(real-prereqs) | $(KLZOP) -9 > $@ 368 369quiet_cmd_lzo_with_size = LZO $@ 370 cmd_lzo_with_size = { cat $(real-prereqs) | $(KLZOP) -9; $(size_append); } > $@ 371 372quiet_cmd_lz4 = LZ4 $@ 373 cmd_lz4 = cat $(real-prereqs) | $(LZ4) -l -9 - - > $@ 374 375quiet_cmd_lz4_with_size = LZ4 $@ 376 cmd_lz4_with_size = { cat $(real-prereqs) | $(LZ4) -l -9 - -; \ 377 $(size_append); } > $@ 378 379# U-Boot mkimage 380# --------------------------------------------------------------------------- 381 382MKIMAGE := $(srctree)/scripts/mkuboot.sh 383 384# SRCARCH just happens to match slightly more than ARCH (on sparc), so reduces 385# the number of overrides in arch makefiles 386UIMAGE_ARCH ?= $(SRCARCH) 387UIMAGE_COMPRESSION ?= $(or $(2),none) 388UIMAGE_OPTS-y ?= 389UIMAGE_TYPE ?= kernel 390UIMAGE_LOADADDR ?= arch_must_set_this 391UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR) 392UIMAGE_NAME ?= Linux-$(KERNELRELEASE) 393 394quiet_cmd_uimage = UIMAGE $@ 395 cmd_uimage = $(BASH) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \ 396 -C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \ 397 -T $(UIMAGE_TYPE) \ 398 -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \ 399 -n '$(UIMAGE_NAME)' -d $< $@ 400 401# Flat Image Tree (FIT) 402# This allows for packaging of a kernel and all devicetrees files, using 403# compression. 404# --------------------------------------------------------------------------- 405 406MAKE_FIT := $(srctree)/scripts/make_fit.py 407 408# Use this to override the compression algorithm 409FIT_COMPRESSION ?= gzip 410 411quiet_cmd_fit = FIT $@ 412 cmd_fit = $(MAKE_FIT) -o $@ --arch $(UIMAGE_ARCH) --os linux \ 413 --name '$(UIMAGE_NAME)' $(FIT_EXTRA_ARGS) \ 414 $(if $(findstring 1,$(KBUILD_VERBOSE)),-v) \ 415 $(if $(FIT_DECOMPOSE_DTBS),--decompose-dtbs) \ 416 --compress $(FIT_COMPRESSION) -k $< @$(word 2,$^) 417 418# XZ 419# --------------------------------------------------------------------------- 420# Use xzkern or xzkern_with_size to compress the kernel image and xzmisc to 421# compress other things. 422# 423# xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage 424# of the kernel decompressor. A BCJ filter is used if it is available for 425# the target architecture. 426# 427# xzkern_with_size also appends uncompressed size of the data using 428# size_append. The .xz format has the size information available at the end 429# of the file too, but it's in more complex format and it's good to avoid 430# changing the part of the boot code that reads the uncompressed size. 431# Note that the bytes added by size_append will make the xz tool think that 432# the file is corrupt. This is expected. 433# 434# xzmisc doesn't use size_append, so it can be used to create normal .xz 435# files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very 436# big dictionary would increase the memory usage too much in the multi-call 437# decompression mode. A BCJ filter isn't used either. 438quiet_cmd_xzkern = XZKERN $@ 439 cmd_xzkern = cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh > $@ 440 441quiet_cmd_xzkern_with_size = XZKERN $@ 442 cmd_xzkern_with_size = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh; \ 443 $(size_append); } > $@ 444 445quiet_cmd_xzmisc = XZMISC $@ 446 cmd_xzmisc = cat $(real-prereqs) | $(XZ) --check=crc32 --lzma2=dict=1MiB > $@ 447 448# ZSTD 449# --------------------------------------------------------------------------- 450# Appends the uncompressed size of the data using size_append. The .zst 451# format has the size information available at the beginning of the file too, 452# but it's in a more complex format and it's good to avoid changing the part 453# of the boot code that reads the uncompressed size. 454# 455# Note that the bytes added by size_append will make the zstd tool think that 456# the file is corrupt. This is expected. 457# 458# zstd uses a maximum window size of 8 MB. zstd22 uses a maximum window size of 459# 128 MB. zstd22 is used for kernel compression because it is decompressed in a 460# single pass, so zstd doesn't need to allocate a window buffer. When streaming 461# decompression is used, like initramfs decompression, zstd22 should likely not 462# be used because it would require zstd to allocate a 128 MB buffer. 463 464quiet_cmd_zstd = ZSTD $@ 465 cmd_zstd = cat $(real-prereqs) | $(ZSTD) -19 > $@ 466 467quiet_cmd_zstd22 = ZSTD22 $@ 468 cmd_zstd22 = cat $(real-prereqs) | $(ZSTD) -22 --ultra > $@ 469 470quiet_cmd_zstd22_with_size = ZSTD22 $@ 471 cmd_zstd22_with_size = { cat $(real-prereqs) | $(ZSTD) -22 --ultra; $(size_append); } > $@ 472 473# ASM offsets 474# --------------------------------------------------------------------------- 475 476# Default sed regexp - multiline due to syntax constraints 477# 478# Use [:space:] because LLVM's integrated assembler inserts <tab> around 479# the .ascii directive whereas GCC keeps the <space> as-is. 480define sed-offsets 481 's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \ 482 /^->/{s:->#\(.*\):/* \1 */:; \ 483 s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ 484 s:->::; p;}' 485endef 486 487# Use filechk to avoid rebuilds when a header changes, but the resulting file 488# does not 489define filechk_offsets 490 echo "#ifndef $2"; \ 491 echo "#define $2"; \ 492 echo "/*"; \ 493 echo " * DO NOT MODIFY."; \ 494 echo " *"; \ 495 echo " * This file was generated by Kbuild"; \ 496 echo " */"; \ 497 echo ""; \ 498 sed -ne $(sed-offsets) < $<; \ 499 echo ""; \ 500 echo "#endif" 501endef 502