Makefile.lib (6120681bdf1a1c648e8c555704b71e04abe2e899) | Makefile.lib (dfd402a4c4baae42398ce9180ff424d589b8bffc) |
---|---|
1# SPDX-License-Identifier: GPL-2.0 2# Backward compatibility 3asflags-y += $(EXTRA_AFLAGS) 4ccflags-y += $(EXTRA_CFLAGS) 5cppflags-y += $(EXTRA_CPPFLAGS) 6ldflags-y += $(EXTRA_LDFLAGS) | 1# SPDX-License-Identifier: GPL-2.0 2# Backward compatibility 3asflags-y += $(EXTRA_AFLAGS) 4ccflags-y += $(EXTRA_CFLAGS) 5cppflags-y += $(EXTRA_CPPFLAGS) 6ldflags-y += $(EXTRA_LDFLAGS) |
7always-y += $(always) 8hostprogs += $(hostprogs-y) $(hostprogs-m) | |
9 10# flags that take effect in current and sub directories 11KBUILD_AFLAGS += $(subdir-asflags-y) 12KBUILD_CFLAGS += $(subdir-ccflags-y) 13 14# Figure out what we need to build from the various variables 15# =========================================================================== 16 --- 15 unchanged lines hidden (view full) --- 32# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a 33# and add the directory to the list of dirs to descend into: $(subdir-y) 34# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) 35# and add the directory to the list of dirs to descend into: $(subdir-m) 36__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) 37subdir-y += $(__subdir-y) 38__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) 39subdir-m += $(__subdir-m) | 7 8# flags that take effect in current and sub directories 9KBUILD_AFLAGS += $(subdir-asflags-y) 10KBUILD_CFLAGS += $(subdir-ccflags-y) 11 12# Figure out what we need to build from the various variables 13# =========================================================================== 14 --- 15 unchanged lines hidden (view full) --- 30# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a 31# and add the directory to the list of dirs to descend into: $(subdir-y) 32# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) 33# and add the directory to the list of dirs to descend into: $(subdir-m) 34__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) 35subdir-y += $(__subdir-y) 36__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) 37subdir-m += $(__subdir-m) |
40ifdef need-builtin | |
41obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) | 38obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) |
42else 43obj-y := $(filter-out %/, $(obj-y)) 44endif | |
45obj-m := $(filter-out %/, $(obj-m)) 46 47# Subdirectories we need to descend into 48subdir-ym := $(sort $(subdir-y) $(subdir-m)) 49 50# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object 51multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))), $(m)))) 52multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))), $(m)))) 53multi-used := $(multi-used-y) $(multi-used-m) 54 55# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to 56# tell kbuild to descend 57subdir-obj-y := $(filter %/built-in.a, $(obj-y)) 58 59# Replace multi-part objects by their individual parts, 60# including built-in.a from subdirectories 61real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) 62real-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))) 63 | 39obj-m := $(filter-out %/, $(obj-m)) 40 41# Subdirectories we need to descend into 42subdir-ym := $(sort $(subdir-y) $(subdir-m)) 43 44# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object 45multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))), $(m)))) 46multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))), $(m)))) 47multi-used := $(multi-used-y) $(multi-used-m) 48 49# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to 50# tell kbuild to descend 51subdir-obj-y := $(filter %/built-in.a, $(obj-y)) 52 53# Replace multi-part objects by their individual parts, 54# including built-in.a from subdirectories 55real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) 56real-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))) 57 |
64always-y += $(always-m) 65 | |
66# DTB 67# If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built 68extra-y += $(dtb-y) 69extra-$(CONFIG_OF_ALL_DTBS) += $(dtb-) 70 71ifneq ($(CHECK_DTBS),) 72extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y)) 73extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) 74endif 75 | 58# DTB 59# If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built 60extra-y += $(dtb-y) 61extra-$(CONFIG_OF_ALL_DTBS) += $(dtb-) 62 63ifneq ($(CHECK_DTBS),) 64extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y)) 65extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) 66endif 67 |
68# Test self-contained headers 69 70# Wildcard searches in $(srctree)/$(src)/, but not in $(objtree)/$(obj)/. 71# Stale generated headers are often left over, so pattern matching should 72# be avoided. Please notice $(srctree)/$(src)/ and $(objtree)/$(obj) point 73# to the same location for in-tree building. So, header-test-pattern-y should 74# be used with care. 75header-test-y += $(filter-out $(header-test-), \ 76 $(patsubst $(srctree)/$(src)/%, %, \ 77 $(wildcard $(addprefix $(srctree)/$(src)/, \ 78 $(header-test-pattern-y))))) 79 80extra-$(CONFIG_HEADER_TEST) += $(addsuffix .s, $(header-test-y) $(header-test-m)) 81 |
|
76# Add subdir path 77 78extra-y := $(addprefix $(obj)/,$(extra-y)) | 82# Add subdir path 83 84extra-y := $(addprefix $(obj)/,$(extra-y)) |
79always-y := $(addprefix $(obj)/,$(always-y)) | 85always := $(addprefix $(obj)/,$(always)) |
80targets := $(addprefix $(obj)/,$(targets)) 81modorder := $(addprefix $(obj)/,$(modorder)) 82obj-m := $(addprefix $(obj)/,$(obj-m)) 83lib-y := $(addprefix $(obj)/,$(lib-y)) 84subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) 85real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) 86real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) 87multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) 88subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) 89 90# Finds the multi-part object the current object will be linked into. | 86targets := $(addprefix $(obj)/,$(targets)) 87modorder := $(addprefix $(obj)/,$(modorder)) 88obj-m := $(addprefix $(obj)/,$(obj-m)) 89lib-y := $(addprefix $(obj)/,$(lib-y)) 90subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) 91real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) 92real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) 93multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) 94subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) 95 96# Finds the multi-part object the current object will be linked into. |
91# If the object belongs to two or more multi-part objects, list them all. 92modname-multi = $(sort $(foreach m,$(multi-used),\ 93 $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))) | 97# If the object belongs to two or more multi-part objects, all of them are 98# concatenated with a colon separator. 99modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\ 100 $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=))))) |
94 | 101 |
95__modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) | 102modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) |
96 | 103 |
97modname = $(subst $(space),:,$(__modname)) 98modfile = $(addprefix $(obj)/,$(__modname)) 99 | |
100# target with $(obj)/ and its suffix stripped 101target-stem = $(basename $(patsubst $(obj)/%,%,$@)) 102 103# These flags are needed for modversions and compiling, so we define them here 104# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will 105# end up in (or would, if it gets compiled in) | 104# target with $(obj)/ and its suffix stripped 105target-stem = $(basename $(patsubst $(obj)/%,%,$@)) 106 107# These flags are needed for modversions and compiling, so we define them here 108# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will 109# end up in (or would, if it gets compiled in) |
106name-fix = $(call stringify,$(subst $(comma),_,$(subst -,_,$1))) | 110name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) |
107basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) 108modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) | 111basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) 112modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) |
109modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile)) | |
110 111orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ 112 $(ccflags-y) $(CFLAGS_$(target-stem).o) 113_c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), $(orig_c_flags)) 114orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \ 115 $(asflags-y) $(AFLAGS_$(target-stem).o) 116_a_flags = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), $(orig_a_flags)) 117_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds) --- 26 unchanged lines hidden (view full) --- 144endif 145 146ifeq ($(CONFIG_KCOV),y) 147_c_flags += $(if $(patsubst n%,, \ 148 $(KCOV_INSTRUMENT_$(basetarget).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRUMENT_ALL)), \ 149 $(CFLAGS_KCOV)) 150endif 151 | 113 114orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ 115 $(ccflags-y) $(CFLAGS_$(target-stem).o) 116_c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), $(orig_c_flags)) 117orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \ 118 $(asflags-y) $(AFLAGS_$(target-stem).o) 119_a_flags = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), $(orig_a_flags)) 120_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds) --- 26 unchanged lines hidden (view full) --- 147endif 148 149ifeq ($(CONFIG_KCOV),y) 150_c_flags += $(if $(patsubst n%,, \ 151 $(KCOV_INSTRUMENT_$(basetarget).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRUMENT_ALL)), \ 152 $(CFLAGS_KCOV)) 153endif 154 |
155# 156# Enable KCSAN flags except some files or directories we don't want to check 157# (depends on variables KCSAN_SANITIZE_obj.o, KCSAN_SANITIZE) 158# 159ifeq ($(CONFIG_KCSAN),y) 160_c_flags += $(if $(patsubst n%,, \ 161 $(KCSAN_SANITIZE_$(basetarget).o)$(KCSAN_SANITIZE)y), \ 162 $(CFLAGS_KCSAN)) 163endif 164 |
|
152# $(srctree)/$(src) for including checkin headers from generated source files 153# $(objtree)/$(obj) for including generated headers from checkin source files 154ifeq ($(KBUILD_EXTMOD),) 155ifdef building_out_of_srctree 156_c_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) 157_a_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) 158_cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) 159endif 160endif 161 162part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y) 163quiet_modtag = $(if $(part-of-module),[M], ) 164 165modkern_cflags = \ 166 $(if $(part-of-module), \ 167 $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ | 165# $(srctree)/$(src) for including checkin headers from generated source files 166# $(objtree)/$(obj) for including generated headers from checkin source files 167ifeq ($(KBUILD_EXTMOD),) 168ifdef building_out_of_srctree 169_c_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) 170_a_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) 171_cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) 172endif 173endif 174 175part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y) 176quiet_modtag = $(if $(part-of-module),[M], ) 177 178modkern_cflags = \ 179 $(if $(part-of-module), \ 180 $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ |
168 $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags)) | 181 $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) |
169 170modkern_aflags = $(if $(part-of-module), \ 171 $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \ 172 $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)) 173 174c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 175 -include $(srctree)/include/linux/compiler_types.h \ 176 $(_c_flags) $(modkern_cflags) \ --- 118 unchanged lines hidden (view full) --- 295$(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE 296 $(call if_changed_dep,dtc,dtb) 297 298DT_CHECKER ?= dt-validate 299DT_BINDING_DIR := Documentation/devicetree/bindings 300DT_TMP_SCHEMA := $(objtree)/$(DT_BINDING_DIR)/processed-schema.yaml 301 302quiet_cmd_dtb_check = CHECK $@ | 182 183modkern_aflags = $(if $(part-of-module), \ 184 $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \ 185 $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)) 186 187c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 188 -include $(srctree)/include/linux/compiler_types.h \ 189 $(_c_flags) $(modkern_cflags) \ --- 118 unchanged lines hidden (view full) --- 308$(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE 309 $(call if_changed_dep,dtc,dtb) 310 311DT_CHECKER ?= dt-validate 312DT_BINDING_DIR := Documentation/devicetree/bindings 313DT_TMP_SCHEMA := $(objtree)/$(DT_BINDING_DIR)/processed-schema.yaml 314 315quiet_cmd_dtb_check = CHECK $@ |
303 cmd_dtb_check = $(DT_CHECKER) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ | 316 cmd_dtb_check = $(DT_CHECKER) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ ; |
304 | 317 |
305define rule_dtc | 318define rule_dtc_dt_yaml |
306 $(call cmd_and_fixdep,dtc,yaml) 307 $(call cmd,dtb_check) 308endef 309 310$(obj)/%.dt.yaml: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE | 319 $(call cmd_and_fixdep,dtc,yaml) 320 $(call cmd,dtb_check) 321endef 322 323$(obj)/%.dt.yaml: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE |
311 $(call if_changed_rule,dtc) | 324 $(call if_changed_rule,dtc_dt_yaml) |
312 313dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) 314 315# Bzip2 316# --------------------------------------------------------------------------- 317 318# Bzip2 and LZMA do not include size in file... so we have to fake that; 319# append the size as a 32-bit littleendian number as gzip does. --- 106 unchanged lines hidden --- | 325 326dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) 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. --- 106 unchanged lines hidden --- |