Makefile.lib 16.7 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0
2 3 4 5 6
# Backward compatibility
asflags-y  += $(EXTRA_AFLAGS)
ccflags-y  += $(EXTRA_CFLAGS)
cppflags-y += $(EXTRA_CPPFLAGS)
ldflags-y  += $(EXTRA_LDFLAGS)
7 8
ifneq ($(always),)
$(warning 'always' is deprecated. Please use 'always-y' instead)
9
always-y   += $(always)
10 11 12 13 14 15 16 17 18
endif
ifneq ($(hostprogs-y),)
$(warning 'hostprogs-y' is deprecated. Please use 'hostprogs' instead)
hostprogs  += $(hostprogs-y)
endif
ifneq ($(hostprogs-m),)
$(warning 'hostprogs-m' is deprecated. Please use 'hostprogs' instead)
hostprogs  += $(hostprogs-m)
endif
19

20
# flags that take effect in current and sub directories
21 22
KBUILD_AFLAGS += $(subdir-asflags-y)
KBUILD_CFLAGS += $(subdir-ccflags-y)
23

Linus Torvalds's avatar
Linus Torvalds committed
24 25 26 27 28 29 30 31 32 33 34
# 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
obj-m := $(filter-out $(obj-y),$(obj-m))

# Libraries are always collected in one lib file.
# Filter out objects already built-in
lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))

35 36 37 38
# Subdirectories we need to descend into
subdir-ym := $(sort $(subdir-y) $(subdir-m) \
			$(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m))))

39 40 41 42 43 44 45 46 47 48 49 50 51 52
# Handle objects in subdirs:
# - If we encounter foo/ in $(obj-y), replace it by foo/built-in.a and
#   foo/modules.order
# - If we encounter foo/ in $(obj-m), replace it by foo/modules.order
#
# Generate modules.order to determine modorder. Unfortunately, we don't have
# information about ordering between -y and -m subdirs. Just put -y's first.

ifdef need-modorder
obj-m := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m))
else
obj-m := $(filter-out %/, $(obj-m))
endif

53
ifdef need-builtin
54
obj-y		:= $(patsubst %/, %/built-in.a, $(obj-y))
55 56 57
else
obj-y		:= $(filter-out %/, $(obj-y))
endif
Linus Torvalds's avatar
Linus Torvalds committed
58

59 60 61
# 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))))
Linus Torvalds's avatar
Linus Torvalds committed
62 63
multi-used   := $(multi-used-y) $(multi-used-m)

64 65
# Replace multi-part objects by their individual parts,
# including built-in.a from subdirectories
66 67
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)))
Linus Torvalds's avatar
Linus Torvalds committed
68

69 70
always-y += $(always-m)

71 72 73 74 75 76 77 78 79 80 81
# hostprogs-always-y += foo
# ... is a shorthand for
# hostprogs += foo
# always-y  += foo
hostprogs += $(hostprogs-always-y) $(hostprogs-always-m)
always-y += $(hostprogs-always-y) $(hostprogs-always-m)

# userprogs-always-y is likewise.
userprogs += $(userprogs-always-y) $(userprogs-always-m)
always-y += $(userprogs-always-y) $(userprogs-always-m)

82 83 84 85 86
# DTB
# If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
extra-y				+= $(dtb-y)
extra-$(CONFIG_OF_ALL_DTBS)	+= $(dtb-)

87 88 89 90 91
ifneq ($(CHECK_DTBS),)
extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y))
extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-))
endif

Linus Torvalds's avatar
Linus Torvalds committed
92 93 94
# Add subdir path

extra-y		:= $(addprefix $(obj)/,$(extra-y))
95
always-y	:= $(addprefix $(obj)/,$(always-y))
Linus Torvalds's avatar
Linus Torvalds committed
96 97 98
targets		:= $(addprefix $(obj)/,$(targets))
obj-m		:= $(addprefix $(obj)/,$(obj-m))
lib-y		:= $(addprefix $(obj)/,$(lib-y))
99 100
real-obj-y	:= $(addprefix $(obj)/,$(real-obj-y))
real-obj-m	:= $(addprefix $(obj)/,$(real-obj-m))
Linus Torvalds's avatar
Linus Torvalds committed
101 102 103
multi-used-m	:= $(addprefix $(obj)/,$(multi-used-m))
subdir-ym	:= $(addprefix $(obj)/,$(subdir-ym))

104
# Finds the multi-part object the current object will be linked into.
105 106 107
# 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=))))
108

109 110 111 112
__modname = $(if $(modname-multi),$(modname-multi),$(basetarget))

modname = $(subst $(space),:,$(__modname))
modfile = $(addprefix $(obj)/,$(__modname))
113

114 115 116
# target with $(obj)/ and its suffix stripped
target-stem = $(basename $(patsubst $(obj)/%,%,$@))

Linus Torvalds's avatar
Linus Torvalds committed
117
# These flags are needed for modversions and compiling, so we define them here
118
# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will
Linus Torvalds's avatar
Linus Torvalds committed
119
# end up in (or would, if it gets compiled in)
120
name-fix = $(call stringify,$(subst $(comma),_,$(subst -,_,$1)))
Michal Marek's avatar
Michal Marek committed
121
basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
122
modname_flags  = -DKBUILD_MODNAME=$(call name-fix,$(modname))
123
modfile_flags  = -DKBUILD_MODFILE=$(call stringify,$(modfile))
Linus Torvalds's avatar
Linus Torvalds committed
124

125 126 127 128 129 130 131 132
_c_flags       = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), \
                     $(filter-out $(ccflags-remove-y), \
                         $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(ccflags-y)) \
                     $(CFLAGS_$(target-stem).o))
_a_flags       = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), \
                     $(filter-out $(asflags-remove-y), \
                         $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(asflags-y)) \
                     $(AFLAGS_$(target-stem).o))
133
_cpp_flags     = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds)
Linus Torvalds's avatar
Linus Torvalds committed
134

135 136 137 138 139 140 141 142 143 144 145
#
# 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

146 147 148 149 150 151 152
#
# 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), \
153
		$(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE))
154 155
endif

156 157 158 159 160 161
ifeq ($(CONFIG_UBSAN),y)
_c_flags += $(if $(patsubst n%,, \
		$(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \
		$(CFLAGS_UBSAN))
endif

162 163
ifeq ($(CONFIG_KCOV),y)
_c_flags += $(if $(patsubst n%,, \
164
	$(KCOV_INSTRUMENT_$(basetarget).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRUMENT_ALL)), \
165 166 167
	$(CFLAGS_KCOV))
endif

168 169 170 171 172 173 174 175 176
#
# Enable KCSAN flags except some files or directories we don't want to check
# (depends on variables KCSAN_SANITIZE_obj.o, KCSAN_SANITIZE)
#
ifeq ($(CONFIG_KCSAN),y)
_c_flags += $(if $(patsubst n%,, \
	$(KCSAN_SANITIZE_$(basetarget).o)$(KCSAN_SANITIZE)y), \
	$(CFLAGS_KCSAN))
endif
177

178 179
# $(srctree)/$(src) for including checkin headers from generated source files
# $(objtree)/$(obj) for including generated headers from checkin source files
180
ifeq ($(KBUILD_EXTMOD),)
181
ifdef building_out_of_srctree
182 183 184
_c_flags   += -I $(srctree)/$(src) -I $(objtree)/$(obj)
_a_flags   += -I $(srctree)/$(src) -I $(objtree)/$(obj)
_cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
Linus Torvalds's avatar
Linus Torvalds committed
185
endif
186
endif
Linus Torvalds's avatar
Linus Torvalds committed
187

188 189 190 191 192 193
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), \
194
		$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags))
195 196 197 198 199

modkern_aflags = $(if $(part-of-module),				\
			$(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE),	\
			$(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL))

200
c_flags        = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
201
		 -include $(srctree)/include/linux/compiler_types.h       \
202
		 $(_c_flags) $(modkern_cflags)                           \
Michal Marek's avatar
Michal Marek committed
203
		 $(basename_flags) $(modname_flags)
Linus Torvalds's avatar
Linus Torvalds committed
204

205
a_flags        = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
206
		 $(_a_flags) $(modkern_aflags)
Linus Torvalds's avatar
Linus Torvalds committed
207

208
cpp_flags      = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
209
		 $(_cpp_flags)
Linus Torvalds's avatar
Linus Torvalds committed
210

211
ld_flags       = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F))
Linus Torvalds's avatar
Linus Torvalds committed
212

213 214
DTC_INCLUDE    := $(srctree)/scripts/dtc/include-prefixes

215
dtc_cpp_flags  = -Wp,-MMD,$(depfile).pre.tmp -nostdinc                    \
216
		 $(addprefix -I,$(DTC_INCLUDE))                          \
217 218
		 -undef -D__DTS__

219 220 221 222 223 224 225 226 227
# 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

228 229 230
quiet_cmd_copy = COPY    $@
      cmd_copy = cp $< $@

Linus Torvalds's avatar
Linus Torvalds committed
231 232 233 234 235 236
# Shipped files
# ===========================================================================

quiet_cmd_shipped = SHIPPED $@
cmd_shipped = cat $< > $@

237
$(obj)/%: $(src)/%_shipped
Linus Torvalds's avatar
Linus Torvalds committed
238 239 240 241
	$(call cmd,shipped)

# Commands useful for building a boot image
# ===========================================================================
242
#
Linus Torvalds's avatar
Linus Torvalds committed
243 244 245 246 247
#	Use as following:
#
#	target: source(s) FORCE
#		$(if_changed,ld/objcopy/gzip)
#
248
#	and add target to extra-y so that we know we have to
Linus Torvalds's avatar
Linus Torvalds committed
249 250 251 252 253 254
#	read in the saved command line

# Linking
# ---------------------------------------------------------------------------

quiet_cmd_ld = LD      $@
255
      cmd_ld = $(LD) $(ld_flags) $(real-prereqs) -o $@
Linus Torvalds's avatar
Linus Torvalds committed
256

257 258 259 260
# Archive
# ---------------------------------------------------------------------------

quiet_cmd_ar = AR      $@
261
      cmd_ar = rm -f $@; $(AR) cDPrsT $@ $(real-prereqs)
262

Linus Torvalds's avatar
Linus Torvalds committed
263 264 265 266 267 268 269 270 271 272
# Objcopy
# ---------------------------------------------------------------------------

quiet_cmd_objcopy = OBJCOPY $@
cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@

# Gzip
# ---------------------------------------------------------------------------

quiet_cmd_gzip = GZIP    $@
273
      cmd_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9 > $@
Linus Torvalds's avatar
Linus Torvalds committed
274

275 276
# DTC
# ---------------------------------------------------------------------------
277
DTC ?= $(objtree)/scripts/dtc/dtc
278
DTC_FLAGS += -Wno-interrupt_provider
279

280
# Disable noisy checks by default
281
ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
282 283
DTC_FLAGS += -Wno-unit_address_vs_reg \
	-Wno-unit_address_format \
284 285
	-Wno-avoid_unnecessary_addr_size \
	-Wno-alias_paths \
286
	-Wno-graph_child_address \
287
	-Wno-simple_bus_reg \
288
	-Wno-unique_unit_address \
289
	-Wno-pci_device_reg
290 291
endif

292
ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),)
293
DTC_FLAGS += -Wnode_name_chars_strict \
294 295
	-Wproperty_name_chars_strict \
	-Winterrupt_provider
296 297
endif

298 299
DTC_FLAGS += $(DTC_FLAGS_$(basetarget))

300
# Generate an assembly file to wrap the output of the device tree compiler
301
quiet_cmd_dt_S_dtb= DTB     $@
302
cmd_dt_S_dtb=						\
303
{							\
304 305 306
	echo '\#include <asm-generic/vmlinux.lds.h>'; 	\
	echo '.section .dtb.init.rodata,"a"';		\
	echo '.balign STRUCT_ALIGNMENT';		\
307 308
	echo '.global __dtb_$(subst -,_,$(*F))_begin';	\
	echo '__dtb_$(subst -,_,$(*F))_begin:';		\
309
	echo '.incbin "$<" ';				\
310 311
	echo '__dtb_$(subst -,_,$(*F))_end:';		\
	echo '.global __dtb_$(subst -,_,$(*F))_end';	\
312
	echo '.balign STRUCT_ALIGNMENT'; 		\
313
} > $@
314

315 316
$(obj)/%.dtb.S: $(obj)/%.dtb FORCE
	$(call if_changed,dt_S_dtb)
317 318

quiet_cmd_dtc = DTC     $@
319
cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
320
	$(DTC) -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \
321
		$(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
322 323
		-d $(depfile).dtc.tmp $(dtc-tmp) ; \
	cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
Linus Torvalds's avatar
Linus Torvalds committed
324

325
$(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE
326
	$(call if_changed_dep,dtc)
327 328 329

DT_CHECKER ?= dt-validate
DT_BINDING_DIR := Documentation/devicetree/bindings
330 331
# DT_TMP_SCHEMA may be overridden from Documentation/devicetree/bindings/Makefile
DT_TMP_SCHEMA ?= $(objtree)/$(DT_BINDING_DIR)/processed-schema.yaml
332 333

quiet_cmd_dtb_check =	CHECK   $@
334
      cmd_dtb_check =	$(DT_CHECKER) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@
335

336
define rule_dtc
337
	$(call cmd_and_fixdep,dtc)
338
	$(call cmd,dtb_check)
339 340 341
endef

$(obj)/%.dt.yaml: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE
342
	$(call if_changed_rule,dtc,yaml)
343

344
dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
345

346 347 348
# Bzip2
# ---------------------------------------------------------------------------

349 350
# 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.
351
size_append = printf $(shell						\
352
dec_size=0;								\
353
for F in $(real-prereqs); do					\
354
	fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F);	\
355 356
	dec_size=$$(expr $$dec_size + $$fsize);				\
done;									\
357 358 359 360 361 362 363
printf "%08x\n" $$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;							\
	}								\
364 365 366
)

quiet_cmd_bzip2 = BZIP2   $@
367
      cmd_bzip2 = { cat $(real-prereqs) | $(KBZIP2) -9; $(size_append); } > $@
368 369 370 371 372

# Lzma
# ---------------------------------------------------------------------------

quiet_cmd_lzma = LZMA    $@
373
      cmd_lzma = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@
374

375
quiet_cmd_lzo = LZO     $@
376
      cmd_lzo = { cat $(real-prereqs) | $(KLZOP) -9; $(size_append); } > $@
377

378
quiet_cmd_lz4 = LZ4     $@
379
      cmd_lz4 = { cat $(real-prereqs) | $(LZ4) -l -c1 stdin stdout; \
380
                  $(size_append); } > $@
381

382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
# 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)'

397
quiet_cmd_uimage = UIMAGE  $@
398
      cmd_uimage = $(BASH) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
399 400 401
			-C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \
			-T $(UIMAGE_TYPE) \
			-a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \
402
			-n $(UIMAGE_NAME) -d $< $@
403

404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
# 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  $@
422
      cmd_xzkern = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh; \
423
                     $(size_append); } > $@
424 425

quiet_cmd_xzmisc = XZMISC  $@
426
      cmd_xzmisc = cat $(real-prereqs) | $(XZ) --check=crc32 --lzma2=dict=1MiB > $@
427

428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
# ZSTD
# ---------------------------------------------------------------------------
# Appends the uncompressed size of the data using size_append. The .zst
# format has the size information available at the beginning of the file too,
# but it's in a 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 zstd tool think that
# the file is corrupt. This is expected.
#
# zstd uses a maximum window size of 8 MB. zstd22 uses a maximum window size of
# 128 MB. zstd22 is used for kernel compression because it is decompressed in a
# single pass, so zstd doesn't need to allocate a window buffer. When streaming
# decompression is used, like initramfs decompression, zstd22 should likely not
# be used because it would require zstd to allocate a 128 MB buffer.

quiet_cmd_zstd = ZSTD    $@
      cmd_zstd = { cat $(real-prereqs) | $(ZSTD) -19; $(size_append); } > $@

quiet_cmd_zstd22 = ZSTD22  $@
      cmd_zstd22 = { cat $(real-prereqs) | $(ZSTD) -22 --ultra; $(size_append); } > $@

450 451 452 453
# ASM offsets
# ---------------------------------------------------------------------------

# Default sed regexp - multiline due to syntax constraints
454 455 456
#
# Use [:space:] because LLVM's integrated assembler inserts <tab> around
# the .ascii directive whereas GCC keeps the <space> as-is.
457
define sed-offsets
458 459
	's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
	/^->/{s:->#\(.*\):/* \1 */:; \
460
	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
461
	s:->::; p;}'
462 463 464 465 466 467 468 469 470 471 472 473 474
endef

# Use filechk to avoid rebuilds when a header changes, but the resulting file
# does not
define filechk_offsets
	 echo "#ifndef $2"; \
	 echo "#define $2"; \
	 echo "/*"; \
	 echo " * DO NOT MODIFY."; \
	 echo " *"; \
	 echo " * This file was generated by Kbuild"; \
	 echo " */"; \
	 echo ""; \
475
	 sed -ne $(sed-offsets) < $<; \
476
	 echo ""; \
477
	 echo "#endif"
478
endef