| .. | .. |
|---|
| 4 | 4 | ccflags-y += $(EXTRA_CFLAGS) |
|---|
| 5 | 5 | cppflags-y += $(EXTRA_CPPFLAGS) |
|---|
| 6 | 6 | ldflags-y += $(EXTRA_LDFLAGS) |
|---|
| 7 | +ifneq ($(always),) |
|---|
| 8 | +$(warning 'always' is deprecated. Please use 'always-y' instead) |
|---|
| 9 | +always-y += $(always) |
|---|
| 10 | +endif |
|---|
| 11 | +ifneq ($(hostprogs-y),) |
|---|
| 12 | +$(warning 'hostprogs-y' is deprecated. Please use 'hostprogs' instead) |
|---|
| 13 | +hostprogs += $(hostprogs-y) |
|---|
| 14 | +endif |
|---|
| 15 | +ifneq ($(hostprogs-m),) |
|---|
| 16 | +$(warning 'hostprogs-m' is deprecated. Please use 'hostprogs' instead) |
|---|
| 17 | +hostprogs += $(hostprogs-m) |
|---|
| 18 | +endif |
|---|
| 7 | 19 | |
|---|
| 8 | 20 | # flags that take effect in current and sub directories |
|---|
| 9 | 21 | KBUILD_AFLAGS += $(subdir-asflags-y) |
|---|
| .. | .. |
|---|
| 20 | 32 | # Filter out objects already built-in |
|---|
| 21 | 33 | lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) |
|---|
| 22 | 34 | |
|---|
| 23 | | -# Determine modorder. |
|---|
| 24 | | -# Unfortunately, we don't have information about ordering between -y |
|---|
| 25 | | -# and -m subdirs. Just put -y's first. |
|---|
| 26 | | -modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko)) |
|---|
| 27 | | - |
|---|
| 28 | | -# Handle objects in subdirs |
|---|
| 29 | | -# --------------------------------------------------------------------------- |
|---|
| 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))) |
|---|
| 35 | | -subdir-y += $(__subdir-y) |
|---|
| 36 | | -__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) |
|---|
| 37 | | -subdir-m += $(__subdir-m) |
|---|
| 38 | | -obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) |
|---|
| 39 | | -obj-m := $(filter-out %/, $(obj-m)) |
|---|
| 40 | | - |
|---|
| 41 | 35 | # Subdirectories we need to descend into |
|---|
| 42 | | -subdir-ym := $(sort $(subdir-y) $(subdir-m)) |
|---|
| 36 | +subdir-ym := $(sort $(subdir-y) $(subdir-m) \ |
|---|
| 37 | + $(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m)))) |
|---|
| 43 | 38 | |
|---|
| 44 | | -# if $(foo-objs), $(foo-y), or $(foo-m) exists, foo.o is a composite object |
|---|
| 45 | | -multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) |
|---|
| 46 | | -multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m)))) |
|---|
| 39 | +# Handle objects in subdirs: |
|---|
| 40 | +# - If we encounter foo/ in $(obj-y), replace it by foo/built-in.a and |
|---|
| 41 | +# foo/modules.order |
|---|
| 42 | +# - If we encounter foo/ in $(obj-m), replace it by foo/modules.order |
|---|
| 43 | +# |
|---|
| 44 | +# Generate modules.order to determine modorder. Unfortunately, we don't have |
|---|
| 45 | +# information about ordering between -y and -m subdirs. Just put -y's first. |
|---|
| 46 | + |
|---|
| 47 | +ifdef need-modorder |
|---|
| 48 | +obj-m := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m)) |
|---|
| 49 | +else |
|---|
| 50 | +obj-m := $(filter-out %/, $(obj-m)) |
|---|
| 51 | +endif |
|---|
| 52 | + |
|---|
| 53 | +ifdef need-builtin |
|---|
| 54 | +obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) |
|---|
| 55 | +else |
|---|
| 56 | +obj-y := $(filter-out %/, $(obj-y)) |
|---|
| 57 | +endif |
|---|
| 58 | + |
|---|
| 59 | +# Expand $(foo-objs) $(foo-y) by calling $(call suffix-search,foo.o,-objs -y) |
|---|
| 60 | +suffix-search = $(foreach s,$(2),$($(1:.o=$s))) |
|---|
| 61 | +# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object |
|---|
| 62 | +# Do this recursively to find nested composite objects. |
|---|
| 63 | +# foo-y may contain foo.o bar.o . For backwards compatibility, don't treat this |
|---|
| 64 | +# foo.o as a nested object |
|---|
| 65 | +multi-search = $(sort $(foreach m,$(1),$(if $(strip $(call suffix-search,$(m),$(2) -)),\ |
|---|
| 66 | + $(if $(filter $(m),$(strip $(call suffix-search,$(m),$(2) -))),,\ |
|---|
| 67 | + $(m) $(call multi-search,$(call suffix-search,$(m),$(2)),$(2)))))) |
|---|
| 68 | +multi-used-y := $(call multi-search,$(obj-y),-objs -y) |
|---|
| 69 | +multi-used-m := $(call multi-search,$(obj-m),-objs -y -m) |
|---|
| 47 | 70 | multi-used := $(multi-used-y) $(multi-used-m) |
|---|
| 48 | | -single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m))) |
|---|
| 49 | | - |
|---|
| 50 | | -# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to |
|---|
| 51 | | -# tell kbuild to descend |
|---|
| 52 | | -subdir-obj-y := $(filter %/built-in.a, $(obj-y)) |
|---|
| 53 | 71 | |
|---|
| 54 | 72 | # Replace multi-part objects by their individual parts, |
|---|
| 55 | 73 | # including built-in.a from subdirectories |
|---|
| 56 | | -real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) |
|---|
| 57 | | -real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m))) |
|---|
| 74 | +# Recursively search for real files. For backwards compatibility, |
|---|
| 75 | +# foo-y may contain foo.o bar.o . foo.o in this context is a real object, and |
|---|
| 76 | +# shouldn't be recursed into. |
|---|
| 77 | +real-search = $(foreach m,$(1), $(if $(strip $(call suffix-search,$(m),$(2) -)), \ |
|---|
| 78 | + $(filter $(m),$(call suffix-search,$(m),$(2))) $(call real-search,$(filter-out $(m),$(call suffix-search,$(m),$(2))),$(2)),\ |
|---|
| 79 | + $(m))) |
|---|
| 80 | +real-obj-y := $(call real-search, $(obj-y),-objs -y) |
|---|
| 81 | +real-obj-m := $(call real-search, $(obj-m),-objs -y -m) |
|---|
| 82 | + |
|---|
| 83 | +always-y += $(always-m) |
|---|
| 84 | + |
|---|
| 85 | +# hostprogs-always-y += foo |
|---|
| 86 | +# ... is a shorthand for |
|---|
| 87 | +# hostprogs += foo |
|---|
| 88 | +# always-y += foo |
|---|
| 89 | +hostprogs += $(hostprogs-always-y) $(hostprogs-always-m) |
|---|
| 90 | +always-y += $(hostprogs-always-y) $(hostprogs-always-m) |
|---|
| 91 | + |
|---|
| 92 | +# userprogs-always-y is likewise. |
|---|
| 93 | +userprogs += $(userprogs-always-y) $(userprogs-always-m) |
|---|
| 94 | +always-y += $(userprogs-always-y) $(userprogs-always-m) |
|---|
| 58 | 95 | |
|---|
| 59 | 96 | # DTB |
|---|
| 60 | 97 | # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built |
|---|
| 61 | 98 | extra-y += $(dtb-y) |
|---|
| 62 | 99 | extra-$(CONFIG_OF_ALL_DTBS) += $(dtb-) |
|---|
| 63 | 100 | |
|---|
| 101 | +ifneq ($(CHECK_DTBS),) |
|---|
| 102 | +extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y)) |
|---|
| 103 | +extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) |
|---|
| 104 | +endif |
|---|
| 105 | + |
|---|
| 64 | 106 | # Add subdir path |
|---|
| 65 | 107 | |
|---|
| 66 | 108 | extra-y := $(addprefix $(obj)/,$(extra-y)) |
|---|
| 67 | | -always := $(addprefix $(obj)/,$(always)) |
|---|
| 109 | +always-y := $(addprefix $(obj)/,$(always-y)) |
|---|
| 68 | 110 | targets := $(addprefix $(obj)/,$(targets)) |
|---|
| 69 | | -modorder := $(addprefix $(obj)/,$(modorder)) |
|---|
| 70 | 111 | obj-m := $(addprefix $(obj)/,$(obj-m)) |
|---|
| 71 | 112 | lib-y := $(addprefix $(obj)/,$(lib-y)) |
|---|
| 72 | | -subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) |
|---|
| 73 | 113 | real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) |
|---|
| 74 | 114 | real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) |
|---|
| 75 | | -single-used-m := $(addprefix $(obj)/,$(single-used-m)) |
|---|
| 76 | 115 | multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) |
|---|
| 77 | 116 | subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) |
|---|
| 78 | 117 | |
|---|
| 79 | 118 | # Finds the multi-part object the current object will be linked into. |
|---|
| 80 | | -# If the object belongs to two or more multi-part objects, all of them are |
|---|
| 81 | | -# concatenated with a colon separator. |
|---|
| 82 | | -modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\ |
|---|
| 83 | | - $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=))))) |
|---|
| 119 | +# If the object belongs to two or more multi-part objects, list them all. |
|---|
| 120 | +modname-multi = $(sort $(foreach m,$(multi-used),\ |
|---|
| 121 | + $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))) |
|---|
| 84 | 122 | |
|---|
| 85 | | -modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) |
|---|
| 123 | +__modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) |
|---|
| 124 | + |
|---|
| 125 | +modname = $(subst $(space),:,$(__modname)) |
|---|
| 126 | +modfile = $(addprefix $(obj)/,$(__modname)) |
|---|
| 127 | + |
|---|
| 128 | +# target with $(obj)/ and its suffix stripped |
|---|
| 129 | +target-stem = $(basename $(patsubst $(obj)/%,%,$@)) |
|---|
| 86 | 130 | |
|---|
| 87 | 131 | # These flags are needed for modversions and compiling, so we define them here |
|---|
| 88 | 132 | # $(modname_flags) defines KBUILD_MODNAME as the name of the module it will |
|---|
| 89 | 133 | # end up in (or would, if it gets compiled in) |
|---|
| 90 | | -name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) |
|---|
| 134 | +name-fix-token = $(subst $(comma),_,$(subst -,_,$1)) |
|---|
| 135 | +name-fix = $(call stringify,$(call name-fix-token,$1)) |
|---|
| 91 | 136 | basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) |
|---|
| 92 | | -modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) |
|---|
| 137 | +modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) \ |
|---|
| 138 | + -D__KBUILD_MODNAME=kmod_$(call name-fix-token,$(modname)) |
|---|
| 139 | +modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile)) |
|---|
| 93 | 140 | |
|---|
| 94 | | -orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ |
|---|
| 95 | | - $(ccflags-y) $(CFLAGS_$(basetarget).o) |
|---|
| 96 | | -_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) |
|---|
| 97 | | -orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \ |
|---|
| 98 | | - $(asflags-y) $(AFLAGS_$(basetarget).o) |
|---|
| 99 | | -_a_flags = $(filter-out $(AFLAGS_REMOVE_$(basetarget).o), $(orig_a_flags)) |
|---|
| 100 | | -_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F)) |
|---|
| 141 | +_c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), \ |
|---|
| 142 | + $(filter-out $(ccflags-remove-y), \ |
|---|
| 143 | + $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(ccflags-y)) \ |
|---|
| 144 | + $(CFLAGS_$(target-stem).o)) |
|---|
| 145 | +_a_flags = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), \ |
|---|
| 146 | + $(filter-out $(asflags-remove-y), \ |
|---|
| 147 | + $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(asflags-y)) \ |
|---|
| 148 | + $(AFLAGS_$(target-stem).o)) |
|---|
| 149 | +_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds) |
|---|
| 101 | 150 | |
|---|
| 102 | 151 | # |
|---|
| 103 | 152 | # Enable gcov profiling flags for a file, directory or for all files depending |
|---|
| .. | .. |
|---|
| 115 | 164 | # we don't want to check (depends on variables KASAN_SANITIZE_obj.o, KASAN_SANITIZE) |
|---|
| 116 | 165 | # |
|---|
| 117 | 166 | ifeq ($(CONFIG_KASAN),y) |
|---|
| 167 | +ifneq ($(CONFIG_KASAN_HW_TAGS),y) |
|---|
| 118 | 168 | _c_flags += $(if $(patsubst n%,, \ |
|---|
| 119 | 169 | $(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \ |
|---|
| 120 | 170 | $(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE)) |
|---|
| 171 | +endif |
|---|
| 121 | 172 | endif |
|---|
| 122 | 173 | |
|---|
| 123 | 174 | ifeq ($(CONFIG_UBSAN),y) |
|---|
| .. | .. |
|---|
| 132 | 183 | $(CFLAGS_KCOV)) |
|---|
| 133 | 184 | endif |
|---|
| 134 | 185 | |
|---|
| 135 | | -# If building the kernel in a separate objtree expand all occurrences |
|---|
| 136 | | -# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). |
|---|
| 137 | | - |
|---|
| 138 | | -ifeq ($(KBUILD_SRC),) |
|---|
| 139 | | -__c_flags = $(_c_flags) |
|---|
| 140 | | -__a_flags = $(_a_flags) |
|---|
| 141 | | -__cpp_flags = $(_cpp_flags) |
|---|
| 142 | | -else |
|---|
| 143 | | - |
|---|
| 144 | | -# -I$(obj) locates generated .h files |
|---|
| 145 | | -# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files |
|---|
| 146 | | -# and locates generated .h files |
|---|
| 147 | | -# FIXME: Replace both with specific CFLAGS* statements in the makefiles |
|---|
| 148 | | -__c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \ |
|---|
| 149 | | - $(call flags,_c_flags) |
|---|
| 150 | | -__a_flags = $(call flags,_a_flags) |
|---|
| 151 | | -__cpp_flags = $(call flags,_cpp_flags) |
|---|
| 186 | +# |
|---|
| 187 | +# Enable KCSAN flags except some files or directories we don't want to check |
|---|
| 188 | +# (depends on variables KCSAN_SANITIZE_obj.o, KCSAN_SANITIZE) |
|---|
| 189 | +# |
|---|
| 190 | +ifeq ($(CONFIG_KCSAN),y) |
|---|
| 191 | +_c_flags += $(if $(patsubst n%,, \ |
|---|
| 192 | + $(KCSAN_SANITIZE_$(basetarget).o)$(KCSAN_SANITIZE)y), \ |
|---|
| 193 | + $(CFLAGS_KCSAN)) |
|---|
| 152 | 194 | endif |
|---|
| 153 | 195 | |
|---|
| 154 | | -c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
|---|
| 196 | +# $(srctree)/$(src) for including checkin headers from generated source files |
|---|
| 197 | +# $(objtree)/$(obj) for including generated headers from checkin source files |
|---|
| 198 | +ifeq ($(KBUILD_EXTMOD),) |
|---|
| 199 | +ifdef building_out_of_srctree |
|---|
| 200 | +_c_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) |
|---|
| 201 | +_a_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) |
|---|
| 202 | +_cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) |
|---|
| 203 | +endif |
|---|
| 204 | +endif |
|---|
| 205 | + |
|---|
| 206 | +part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y) |
|---|
| 207 | +quiet_modtag = $(if $(part-of-module),[M], ) |
|---|
| 208 | + |
|---|
| 209 | +modkern_cflags = \ |
|---|
| 210 | + $(if $(part-of-module), \ |
|---|
| 211 | + $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ |
|---|
| 212 | + $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags)) |
|---|
| 213 | + |
|---|
| 214 | +modkern_aflags = $(if $(part-of-module), \ |
|---|
| 215 | + $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \ |
|---|
| 216 | + $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)) |
|---|
| 217 | + |
|---|
| 218 | +c_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
|---|
| 155 | 219 | -include $(srctree)/include/linux/compiler_types.h \ |
|---|
| 156 | | - $(__c_flags) $(modkern_cflags) \ |
|---|
| 220 | + $(_c_flags) $(modkern_cflags) \ |
|---|
| 157 | 221 | $(basename_flags) $(modname_flags) |
|---|
| 158 | 222 | |
|---|
| 159 | | -a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
|---|
| 160 | | - $(__a_flags) $(modkern_aflags) |
|---|
| 223 | +a_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
|---|
| 224 | + $(_a_flags) $(modkern_aflags) |
|---|
| 161 | 225 | |
|---|
| 162 | | -cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
|---|
| 163 | | - $(__cpp_flags) |
|---|
| 226 | +cpp_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
|---|
| 227 | + $(_cpp_flags) |
|---|
| 164 | 228 | |
|---|
| 165 | 229 | ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) |
|---|
| 166 | 230 | |
|---|
| 167 | 231 | DTC_INCLUDE := $(srctree)/scripts/dtc/include-prefixes |
|---|
| 168 | 232 | |
|---|
| 169 | | -dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ |
|---|
| 233 | +dtc_cpp_flags = -Wp,-MMD,$(depfile).pre.tmp -nostdinc \ |
|---|
| 170 | 234 | $(addprefix -I,$(DTC_INCLUDE)) \ |
|---|
| 171 | 235 | -undef -D__DTS__ |
|---|
| 236 | + |
|---|
| 237 | +# Objtool arguments are also needed for modfinal with LTO, so we define |
|---|
| 238 | +# then here to avoid duplication. |
|---|
| 239 | +objtool_args = \ |
|---|
| 240 | + $(if $(CONFIG_UNWINDER_ORC),orc generate,check) \ |
|---|
| 241 | + $(if $(part-of-module), --module,) \ |
|---|
| 242 | + $(if $(CONFIG_FRAME_POINTER),, --no-fp) \ |
|---|
| 243 | + $(if $(or $(CONFIG_GCOV_KERNEL),$(CONFIG_LTO_CLANG)), \ |
|---|
| 244 | + --no-unreachable,) \ |
|---|
| 245 | + $(if $(CONFIG_RETPOLINE), --retpoline,) \ |
|---|
| 246 | + $(if $(CONFIG_RETHUNK), --rethunk,) \ |
|---|
| 247 | + $(if $(CONFIG_X86_SMAP), --uaccess,) \ |
|---|
| 248 | + $(if $(CONFIG_SLS), --sls,) \ |
|---|
| 249 | + $(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount,) |
|---|
| 172 | 250 | |
|---|
| 173 | 251 | # Useful for describing the dependency of composite objects |
|---|
| 174 | 252 | # Usage: |
|---|
| .. | .. |
|---|
| 179 | 257 | $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s))))))) |
|---|
| 180 | 258 | endef |
|---|
| 181 | 259 | |
|---|
| 182 | | -# LEX |
|---|
| 183 | | -# --------------------------------------------------------------------------- |
|---|
| 184 | | -quiet_cmd_flex = LEX $@ |
|---|
| 185 | | - cmd_flex = $(LEX) -o$@ -L $< |
|---|
| 186 | | - |
|---|
| 187 | | -$(obj)/%.lex.c: $(src)/%.l FORCE |
|---|
| 188 | | - $(call if_changed,flex) |
|---|
| 189 | | - |
|---|
| 190 | | -# YACC |
|---|
| 191 | | -# --------------------------------------------------------------------------- |
|---|
| 192 | | -quiet_cmd_bison = YACC $@ |
|---|
| 193 | | - cmd_bison = $(YACC) -o$@ -t -l $< |
|---|
| 194 | | - |
|---|
| 195 | | -$(obj)/%.tab.c: $(src)/%.y FORCE |
|---|
| 196 | | - $(call if_changed,bison) |
|---|
| 197 | | - |
|---|
| 198 | | -quiet_cmd_bison_h = YACC $@ |
|---|
| 199 | | - cmd_bison_h = $(YACC) -o/dev/null --defines=$@ -t -l $< |
|---|
| 200 | | - |
|---|
| 201 | | -$(obj)/%.tab.h: $(src)/%.y FORCE |
|---|
| 202 | | - $(call if_changed,bison_h) |
|---|
| 260 | +quiet_cmd_copy = COPY $@ |
|---|
| 261 | + cmd_copy = cp $< $@ |
|---|
| 203 | 262 | |
|---|
| 204 | 263 | # Shipped files |
|---|
| 205 | 264 | # =========================================================================== |
|---|
| .. | .. |
|---|
| 225 | 284 | # --------------------------------------------------------------------------- |
|---|
| 226 | 285 | |
|---|
| 227 | 286 | quiet_cmd_ld = LD $@ |
|---|
| 228 | | -cmd_ld = $(LD) $(ld_flags) $(filter-out FORCE,$^) -o $@ |
|---|
| 287 | + cmd_ld = $(LD) $(ld_flags) $(real-prereqs) -o $@ |
|---|
| 288 | + |
|---|
| 289 | +# Archive |
|---|
| 290 | +# --------------------------------------------------------------------------- |
|---|
| 291 | + |
|---|
| 292 | +quiet_cmd_ar = AR $@ |
|---|
| 293 | + cmd_ar = rm -f $@; $(AR) cDPrsT $@ $(real-prereqs) |
|---|
| 229 | 294 | |
|---|
| 230 | 295 | # Objcopy |
|---|
| 231 | 296 | # --------------------------------------------------------------------------- |
|---|
| .. | .. |
|---|
| 237 | 302 | # --------------------------------------------------------------------------- |
|---|
| 238 | 303 | |
|---|
| 239 | 304 | quiet_cmd_gzip = GZIP $@ |
|---|
| 240 | | -cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \ |
|---|
| 241 | | - (rm -f $@ ; false) |
|---|
| 305 | + cmd_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9 > $@ |
|---|
| 242 | 306 | |
|---|
| 243 | 307 | # DTC |
|---|
| 244 | 308 | # --------------------------------------------------------------------------- |
|---|
| 309 | +ifeq ("$(origin DTC)", "command line") |
|---|
| 310 | +PHONY += $(DTC) |
|---|
| 311 | +dtc-option = $(call try-run, $(DTC) $1 -v,$1) |
|---|
| 312 | +else |
|---|
| 313 | +# Just add the flag. DTC is compiled later as a prerequisite, so there's no dtc |
|---|
| 314 | +# to test the flag against. This is okay because we're not testing flags which |
|---|
| 315 | +# aren't supported by in-kernel dtc to begin with. |
|---|
| 316 | +dtc-option = $1 |
|---|
| 317 | +endif |
|---|
| 318 | + |
|---|
| 245 | 319 | DTC ?= $(objtree)/scripts/dtc/dtc |
|---|
| 320 | +DTC_FLAGS += $(call dtc-option,-Wno-interrupt_provider) |
|---|
| 246 | 321 | |
|---|
| 247 | 322 | # Generation of symbols for Android |
|---|
| 248 | 323 | ifeq ($(CONFIG_DTC_SYMBOLS),y) |
|---|
| .. | .. |
|---|
| 258 | 333 | endif |
|---|
| 259 | 334 | |
|---|
| 260 | 335 | # Disable noisy checks by default |
|---|
| 261 | | -ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) |
|---|
| 262 | | -DTC_FLAGS += -Wno-unit_address_vs_reg \ |
|---|
| 263 | | - -Wno-unit_address_format \ |
|---|
| 264 | | - -Wno-avoid_unnecessary_addr_size \ |
|---|
| 265 | | - -Wno-alias_paths \ |
|---|
| 266 | | - -Wno-graph_child_address \ |
|---|
| 267 | | - -Wno-graph_port \ |
|---|
| 268 | | - -Wno-simple_bus_reg \ |
|---|
| 269 | | - -Wno-unique_unit_address \ |
|---|
| 270 | | - -Wno-pci_device_reg |
|---|
| 336 | +ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),) |
|---|
| 337 | +DTC_FLAGS += $(call dtc-option,-Wno-unit_address_vs_reg) \ |
|---|
| 338 | + $(call dtc-option,-Wno-unit_address_format) \ |
|---|
| 339 | + $(call dtc-option,-Wno-avoid_unnecessary_addr_size) \ |
|---|
| 340 | + $(call dtc-option,-Wno-alias_paths) \ |
|---|
| 341 | + $(call dtc-option,-Wno-graph_child_address) \ |
|---|
| 342 | + $(call dtc-option,-Wno-simple_bus_reg) \ |
|---|
| 343 | + $(call dtc-option,-Wno-unique_unit_address) \ |
|---|
| 344 | + $(call dtc-option,-Wno-pci_device_reg) |
|---|
| 271 | 345 | endif |
|---|
| 272 | 346 | |
|---|
| 273 | | -ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) |
|---|
| 274 | | -DTC_FLAGS += -Wnode_name_chars_strict \ |
|---|
| 275 | | - -Wproperty_name_chars_strict |
|---|
| 347 | +ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),) |
|---|
| 348 | +DTC_FLAGS += $(call dtc-option,-Wnode_name_chars_strict) \ |
|---|
| 349 | + $(call dtc-option,-Wproperty_name_chars_strict) \ |
|---|
| 350 | + $(call dtc-option,-Winterrupt_provider) |
|---|
| 276 | 351 | endif |
|---|
| 277 | 352 | |
|---|
| 278 | 353 | DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) |
|---|
| .. | .. |
|---|
| 280 | 355 | # Generate an assembly file to wrap the output of the device tree compiler |
|---|
| 281 | 356 | quiet_cmd_dt_S_dtb= DTB $@ |
|---|
| 282 | 357 | cmd_dt_S_dtb= \ |
|---|
| 283 | | -( \ |
|---|
| 358 | +{ \ |
|---|
| 284 | 359 | echo '\#include <asm-generic/vmlinux.lds.h>'; \ |
|---|
| 285 | 360 | echo '.section .dtb.init.rodata,"a"'; \ |
|---|
| 286 | 361 | echo '.balign STRUCT_ALIGNMENT'; \ |
|---|
| .. | .. |
|---|
| 290 | 365 | echo '__dtb_$(subst -,_,$(*F))_end:'; \ |
|---|
| 291 | 366 | echo '.global __dtb_$(subst -,_,$(*F))_end'; \ |
|---|
| 292 | 367 | echo '.balign STRUCT_ALIGNMENT'; \ |
|---|
| 293 | | -) > $@ |
|---|
| 368 | +} > $@ |
|---|
| 294 | 369 | |
|---|
| 295 | 370 | $(obj)/%.dtb.S: $(obj)/%.dtb FORCE |
|---|
| 296 | 371 | $(call if_changed,dt_S_dtb) |
|---|
| 297 | 372 | |
|---|
| 298 | 373 | quiet_cmd_dtc = DTC $@ |
|---|
| 299 | | -cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ |
|---|
| 300 | | - $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ |
|---|
| 301 | | - $(DTC) -O dtb -o $@ -b 0 \ |
|---|
| 374 | +cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ |
|---|
| 375 | + $(DTC) -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \ |
|---|
| 302 | 376 | $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \ |
|---|
| 303 | 377 | -d $(depfile).dtc.tmp $(dtc-tmp) ; \ |
|---|
| 304 | 378 | cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) |
|---|
| 305 | 379 | |
|---|
| 306 | 380 | $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE |
|---|
| 307 | 381 | $(call if_changed_dep,dtc) |
|---|
| 382 | + |
|---|
| 383 | +DT_CHECKER ?= dt-validate |
|---|
| 384 | +DT_BINDING_DIR := Documentation/devicetree/bindings |
|---|
| 385 | +# DT_TMP_SCHEMA may be overridden from Documentation/devicetree/bindings/Makefile |
|---|
| 386 | +DT_TMP_SCHEMA ?= $(objtree)/$(DT_BINDING_DIR)/processed-schema.json |
|---|
| 387 | + |
|---|
| 388 | +quiet_cmd_dtb_check = CHECK $@ |
|---|
| 389 | + cmd_dtb_check = $(DT_CHECKER) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ |
|---|
| 390 | + |
|---|
| 391 | +define rule_dtc |
|---|
| 392 | + $(call cmd_and_fixdep,dtc) |
|---|
| 393 | + $(call cmd,dtb_check) |
|---|
| 394 | +endef |
|---|
| 395 | + |
|---|
| 396 | +$(obj)/%.dt.yaml: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE |
|---|
| 397 | + $(call if_changed_rule,dtc,yaml) |
|---|
| 308 | 398 | |
|---|
| 309 | 399 | dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) |
|---|
| 310 | 400 | |
|---|
| .. | .. |
|---|
| 315 | 405 | # append the size as a 32-bit littleendian number as gzip does. |
|---|
| 316 | 406 | size_append = printf $(shell \ |
|---|
| 317 | 407 | dec_size=0; \ |
|---|
| 318 | | -for F in $1; do \ |
|---|
| 408 | +for F in $(real-prereqs); do \ |
|---|
| 319 | 409 | fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \ |
|---|
| 320 | 410 | dec_size=$$(expr $$dec_size + $$fsize); \ |
|---|
| 321 | 411 | done; \ |
|---|
| .. | .. |
|---|
| 329 | 419 | ) |
|---|
| 330 | 420 | |
|---|
| 331 | 421 | quiet_cmd_bzip2 = BZIP2 $@ |
|---|
| 332 | | -cmd_bzip2 = (cat $(filter-out FORCE,$^) | \ |
|---|
| 333 | | - bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ |
|---|
| 334 | | - (rm -f $@ ; false) |
|---|
| 422 | + cmd_bzip2 = { cat $(real-prereqs) | $(KBZIP2) -9; $(size_append); } > $@ |
|---|
| 335 | 423 | |
|---|
| 336 | 424 | # Lzma |
|---|
| 337 | 425 | # --------------------------------------------------------------------------- |
|---|
| 338 | 426 | |
|---|
| 339 | 427 | quiet_cmd_lzma = LZMA $@ |
|---|
| 340 | | -cmd_lzma = (cat $(filter-out FORCE,$^) | \ |
|---|
| 341 | | - lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ |
|---|
| 342 | | - (rm -f $@ ; false) |
|---|
| 428 | + cmd_lzma = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@ |
|---|
| 343 | 429 | |
|---|
| 344 | 430 | quiet_cmd_lzo = LZO $@ |
|---|
| 345 | | -cmd_lzo = (cat $(filter-out FORCE,$^) | \ |
|---|
| 346 | | - lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ |
|---|
| 347 | | - (rm -f $@ ; false) |
|---|
| 431 | + cmd_lzo = { cat $(real-prereqs) | $(KLZOP) -9; $(size_append); } > $@ |
|---|
| 348 | 432 | |
|---|
| 349 | 433 | quiet_cmd_lz4 = LZ4 $@ |
|---|
| 350 | | -cmd_lz4 = (cat $(filter-out FORCE,$^) | \ |
|---|
| 351 | | - lz4 -l -12 --favor-decSpeed stdin stdout && \ |
|---|
| 352 | | - $(call size_append, $(filter-out FORCE,$^))) > $@ || \ |
|---|
| 353 | | - (rm -f $@ ; false) |
|---|
| 434 | + cmd_lz4 = { cat $(real-prereqs) | \ |
|---|
| 435 | + $(LZ4) -l -12 --favor-decSpeed stdin stdout; \ |
|---|
| 436 | + $(size_append); } > $@ |
|---|
| 354 | 437 | |
|---|
| 355 | 438 | quiet_cmd_lz4c = LZ4C $@ |
|---|
| 356 | | -cmd_lz4c = (cat $(filter-out FORCE,$^) | \ |
|---|
| 357 | | - lz4c -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ |
|---|
| 358 | | - (rm -f $@ ; false) |
|---|
| 439 | + cmd_lz4c = { cat $(real-prereqs) | \ |
|---|
| 440 | + $(LZ4) -12 --favor-decSpeed stdin stdout; \ |
|---|
| 441 | + $(size_append); } > $@ |
|---|
| 359 | 442 | |
|---|
| 360 | 443 | # U-Boot mkimage |
|---|
| 361 | 444 | # --------------------------------------------------------------------------- |
|---|
| .. | .. |
|---|
| 371 | 454 | UIMAGE_LOADADDR ?= arch_must_set_this |
|---|
| 372 | 455 | UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR) |
|---|
| 373 | 456 | UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)' |
|---|
| 374 | | -UIMAGE_IN ?= $< |
|---|
| 375 | | -UIMAGE_OUT ?= $@ |
|---|
| 376 | 457 | |
|---|
| 377 | | -quiet_cmd_uimage = UIMAGE $(UIMAGE_OUT) |
|---|
| 378 | | - cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \ |
|---|
| 458 | +quiet_cmd_uimage = UIMAGE $@ |
|---|
| 459 | + cmd_uimage = $(BASH) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \ |
|---|
| 379 | 460 | -C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \ |
|---|
| 380 | 461 | -T $(UIMAGE_TYPE) \ |
|---|
| 381 | 462 | -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \ |
|---|
| 382 | | - -n $(UIMAGE_NAME) -d $(UIMAGE_IN) $(UIMAGE_OUT) |
|---|
| 463 | + -n $(UIMAGE_NAME) -d $< $@ |
|---|
| 383 | 464 | |
|---|
| 384 | 465 | # XZ |
|---|
| 385 | 466 | # --------------------------------------------------------------------------- |
|---|
| .. | .. |
|---|
| 399 | 480 | # big dictionary would increase the memory usage too much in the multi-call |
|---|
| 400 | 481 | # decompression mode. A BCJ filter isn't used either. |
|---|
| 401 | 482 | quiet_cmd_xzkern = XZKERN $@ |
|---|
| 402 | | -cmd_xzkern = (cat $(filter-out FORCE,$^) | \ |
|---|
| 403 | | - sh $(srctree)/scripts/xz_wrap.sh && \ |
|---|
| 404 | | - $(call size_append, $(filter-out FORCE,$^))) > $@ || \ |
|---|
| 405 | | - (rm -f $@ ; false) |
|---|
| 483 | + cmd_xzkern = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh; \ |
|---|
| 484 | + $(size_append); } > $@ |
|---|
| 406 | 485 | |
|---|
| 407 | 486 | quiet_cmd_xzmisc = XZMISC $@ |
|---|
| 408 | | -cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ |
|---|
| 409 | | - xz --check=crc32 --lzma2=dict=1MiB) > $@ || \ |
|---|
| 410 | | - (rm -f $@ ; false) |
|---|
| 487 | + cmd_xzmisc = cat $(real-prereqs) | $(XZ) --check=crc32 --lzma2=dict=1MiB > $@ |
|---|
| 488 | + |
|---|
| 489 | +# ZSTD |
|---|
| 490 | +# --------------------------------------------------------------------------- |
|---|
| 491 | +# Appends the uncompressed size of the data using size_append. The .zst |
|---|
| 492 | +# format has the size information available at the beginning of the file too, |
|---|
| 493 | +# but it's in a more complex format and it's good to avoid changing the part |
|---|
| 494 | +# of the boot code that reads the uncompressed size. |
|---|
| 495 | +# |
|---|
| 496 | +# Note that the bytes added by size_append will make the zstd tool think that |
|---|
| 497 | +# the file is corrupt. This is expected. |
|---|
| 498 | +# |
|---|
| 499 | +# zstd uses a maximum window size of 8 MB. zstd22 uses a maximum window size of |
|---|
| 500 | +# 128 MB. zstd22 is used for kernel compression because it is decompressed in a |
|---|
| 501 | +# single pass, so zstd doesn't need to allocate a window buffer. When streaming |
|---|
| 502 | +# decompression is used, like initramfs decompression, zstd22 should likely not |
|---|
| 503 | +# be used because it would require zstd to allocate a 128 MB buffer. |
|---|
| 504 | + |
|---|
| 505 | +quiet_cmd_zstd = ZSTD $@ |
|---|
| 506 | + cmd_zstd = { cat $(real-prereqs) | $(ZSTD) -19; $(size_append); } > $@ |
|---|
| 507 | + |
|---|
| 508 | +quiet_cmd_zstd22 = ZSTD22 $@ |
|---|
| 509 | + cmd_zstd22 = { cat $(real-prereqs) | $(ZSTD) -22 --ultra; $(size_append); } > $@ |
|---|
| 411 | 510 | |
|---|
| 412 | 511 | # ASM offsets |
|---|
| 413 | 512 | # --------------------------------------------------------------------------- |
|---|
| .. | .. |
|---|
| 426 | 525 | # Use filechk to avoid rebuilds when a header changes, but the resulting file |
|---|
| 427 | 526 | # does not |
|---|
| 428 | 527 | define filechk_offsets |
|---|
| 429 | | - (set -e; \ |
|---|
| 430 | 528 | echo "#ifndef $2"; \ |
|---|
| 431 | 529 | echo "#define $2"; \ |
|---|
| 432 | 530 | echo "/*"; \ |
|---|
| .. | .. |
|---|
| 437 | 535 | echo ""; \ |
|---|
| 438 | 536 | sed -ne $(sed-offsets) < $<; \ |
|---|
| 439 | 537 | echo ""; \ |
|---|
| 440 | | - echo "#endif" ) |
|---|
| 538 | + echo "#endif" |
|---|
| 441 | 539 | endef |
|---|