Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) # Backward compatibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) asflags-y  += $(EXTRA_AFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) ccflags-y  += $(EXTRA_CFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) cppflags-y += $(EXTRA_CPPFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) ldflags-y  += $(EXTRA_LDFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) ifneq ($(always),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) $(warning 'always' is deprecated. Please use 'always-y' instead)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) always-y   += $(always)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) ifneq ($(hostprogs-y),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) $(warning 'hostprogs-y' is deprecated. Please use 'hostprogs' instead)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) hostprogs  += $(hostprogs-y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) ifneq ($(hostprogs-m),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) $(warning 'hostprogs-m' is deprecated. Please use 'hostprogs' instead)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) hostprogs  += $(hostprogs-m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) # flags that take effect in current and sub directories
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) KBUILD_AFLAGS += $(subdir-asflags-y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) KBUILD_CFLAGS += $(subdir-ccflags-y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) # Figure out what we need to build from the various variables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) # ===========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) # When an object is listed to be built compiled-in and modular,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) # only build the compiled-in version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) obj-m := $(filter-out $(obj-y),$(obj-m))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) # Libraries are always collected in one lib file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) # Filter out objects already built-in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) # Subdirectories we need to descend into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) subdir-ym := $(sort $(subdir-y) $(subdir-m) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 			$(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) # Handle objects in subdirs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) # - If we encounter foo/ in $(obj-y), replace it by foo/built-in.a and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #   foo/modules.order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) # - If we encounter foo/ in $(obj-m), replace it by foo/modules.order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) # Generate modules.order to determine modorder. Unfortunately, we don't have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) # information about ordering between -y and -m subdirs. Just put -y's first.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) ifdef need-modorder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) obj-m := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) obj-m := $(filter-out %/, $(obj-m))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) ifdef need-builtin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) obj-y		:= $(patsubst %/, %/built-in.a, $(obj-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) obj-y		:= $(filter-out %/, $(obj-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) # Expand $(foo-objs) $(foo-y) by calling $(call suffix-search,foo.o,-objs -y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) suffix-search = $(foreach s,$(2),$($(1:.o=$s)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) # If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) # Do this recursively to find nested composite objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) # foo-y may contain foo.o bar.o . For backwards compatibility, don't treat this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) # foo.o as a nested object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) multi-search = $(sort $(foreach m,$(1),$(if $(strip $(call suffix-search,$(m),$(2) -)),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	$(if $(filter $(m),$(strip $(call suffix-search,$(m),$(2) -))),,\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	$(m) $(call multi-search,$(call suffix-search,$(m),$(2)),$(2))))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) multi-used-y := $(call multi-search,$(obj-y),-objs -y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) multi-used-m := $(call multi-search,$(obj-m),-objs -y -m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) multi-used   := $(multi-used-y) $(multi-used-m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) # Replace multi-part objects by their individual parts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) # including built-in.a from subdirectories
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) # Recursively search for real files. For backwards compatibility,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) # foo-y may contain foo.o bar.o . foo.o in this context is a real object, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) # shouldn't be recursed into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) real-search = $(foreach m,$(1), $(if $(strip $(call suffix-search,$(m),$(2) -)), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	$(filter $(m),$(call suffix-search,$(m),$(2))) $(call real-search,$(filter-out $(m),$(call suffix-search,$(m),$(2))),$(2)),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	$(m)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) real-obj-y := $(call real-search, $(obj-y),-objs -y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) real-obj-m := $(call real-search, $(obj-m),-objs -y -m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) always-y += $(always-m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) # hostprogs-always-y += foo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) # ... is a shorthand for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) # hostprogs += foo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) # always-y  += foo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) hostprogs += $(hostprogs-always-y) $(hostprogs-always-m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) always-y += $(hostprogs-always-y) $(hostprogs-always-m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) # userprogs-always-y is likewise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) userprogs += $(userprogs-always-y) $(userprogs-always-m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) always-y += $(userprogs-always-y) $(userprogs-always-m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) # DTB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) extra-y				+= $(dtb-y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) extra-$(CONFIG_OF_ALL_DTBS)	+= $(dtb-)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) ifneq ($(CHECK_DTBS),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) extra-y += $(patsubst %.dtbo,%.dt.yaml, $(dtb-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtbo,%.dt.yaml, $(dtb-))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) # Add subdir path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) extra-y		:= $(addprefix $(obj)/,$(extra-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) always-y	:= $(addprefix $(obj)/,$(always-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) targets		:= $(addprefix $(obj)/,$(targets))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) obj-m		:= $(addprefix $(obj)/,$(obj-m))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) lib-y		:= $(addprefix $(obj)/,$(lib-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) real-obj-y	:= $(addprefix $(obj)/,$(real-obj-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) real-obj-m	:= $(addprefix $(obj)/,$(real-obj-m))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) multi-used-m	:= $(addprefix $(obj)/,$(multi-used-m))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) subdir-ym	:= $(addprefix $(obj)/,$(subdir-ym))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) # Finds the multi-part object the current object will be linked into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) # If the object belongs to two or more multi-part objects, list them all.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) modname-multi = $(sort $(foreach m,$(multi-used),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		$(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) __modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) modname = $(subst $(space),:,$(__modname))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) modfile = $(addprefix $(obj)/,$(__modname))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) # target with $(obj)/ and its suffix stripped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) target-stem = $(basename $(patsubst $(obj)/%,%,$@))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) # These flags are needed for modversions and compiling, so we define them here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) # $(modname_flags) defines KBUILD_MODNAME as the name of the module it will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) # end up in (or would, if it gets compiled in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) name-fix-token = $(subst $(comma),_,$(subst -,_,$1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) name-fix = $(call stringify,$(call name-fix-token,$1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) modname_flags  = -DKBUILD_MODNAME=$(call name-fix,$(modname)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		 -D__KBUILD_MODNAME=kmod_$(call name-fix-token,$(modname))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) modfile_flags  = -DKBUILD_MODFILE=$(call stringify,$(modfile))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) _c_flags       = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)                      $(filter-out $(ccflags-remove-y), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)                          $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(ccflags-y)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)                      $(CFLAGS_$(target-stem).o))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) _a_flags       = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)                      $(filter-out $(asflags-remove-y), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)                          $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(asflags-y)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)                      $(AFLAGS_$(target-stem).o))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) _cpp_flags     = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) # Enable gcov profiling flags for a file, directory or for all files depending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) # on variables GCOV_PROFILE_obj.o, GCOV_PROFILE and CONFIG_GCOV_PROFILE_ALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) # (in this order)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) ifeq ($(CONFIG_GCOV_KERNEL),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) _c_flags += $(if $(patsubst n%,, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		$(GCOV_PROFILE_$(basetarget).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		$(CFLAGS_GCOV))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) # Enable address sanitizer flags for kernel except some files or directories
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) # we don't want to check (depends on variables KASAN_SANITIZE_obj.o, KASAN_SANITIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) ifeq ($(CONFIG_KASAN),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) ifneq ($(CONFIG_KASAN_HW_TAGS),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) _c_flags += $(if $(patsubst n%,, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		$(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		$(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) ifeq ($(CONFIG_UBSAN),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) _c_flags += $(if $(patsubst n%,, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		$(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		$(CFLAGS_UBSAN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) ifeq ($(CONFIG_KCOV),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) _c_flags += $(if $(patsubst n%,, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	$(KCOV_INSTRUMENT_$(basetarget).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRUMENT_ALL)), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	$(CFLAGS_KCOV))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) # Enable KCSAN flags except some files or directories we don't want to check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) # (depends on variables KCSAN_SANITIZE_obj.o, KCSAN_SANITIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) ifeq ($(CONFIG_KCSAN),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) _c_flags += $(if $(patsubst n%,, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	$(KCSAN_SANITIZE_$(basetarget).o)$(KCSAN_SANITIZE)y), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	$(CFLAGS_KCSAN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) # $(srctree)/$(src) for including checkin headers from generated source files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) # $(objtree)/$(obj) for including generated headers from checkin source files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) ifeq ($(KBUILD_EXTMOD),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) ifdef building_out_of_srctree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) _c_flags   += -I $(srctree)/$(src) -I $(objtree)/$(obj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) _a_flags   += -I $(srctree)/$(src) -I $(objtree)/$(obj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) _cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) quiet_modtag = $(if $(part-of-module),[M],   )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) modkern_cflags =                                          \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	$(if $(part-of-module),                           \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		$(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) modkern_aflags = $(if $(part-of-module),				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 			$(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE),	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 			$(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) c_flags        = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		 -include $(srctree)/include/linux/compiler_types.h       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		 $(_c_flags) $(modkern_cflags)                           \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		 $(basename_flags) $(modname_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) a_flags        = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		 $(_a_flags) $(modkern_aflags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) cpp_flags      = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		 $(_cpp_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) ld_flags       = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) DTC_INCLUDE    := $(srctree)/scripts/dtc/include-prefixes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) dtc_cpp_flags  = -Wp,-MMD,$(depfile).pre.tmp -nostdinc                    \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		 $(addprefix -I,$(DTC_INCLUDE))                          \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		 -undef -D__DTS__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) # Objtool arguments are also needed for modfinal with LTO, so we define
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) # then here to avoid duplication.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) objtool_args =								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	$(if $(CONFIG_UNWINDER_ORC),orc generate,check)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	$(if $(part-of-module), --module,)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	$(if $(CONFIG_FRAME_POINTER),, --no-fp)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	$(if $(or $(CONFIG_GCOV_KERNEL),$(CONFIG_LTO_CLANG)), 		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		--no-unreachable,)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	$(if $(CONFIG_RETPOLINE), --retpoline,)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	$(if $(CONFIG_X86_SMAP), --uaccess,)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	$(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount,)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) # Useful for describing the dependency of composite objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) # Usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) #   $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) define multi_depend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) $(foreach m, $(notdir $1), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	$(eval $(obj)/$m: \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	$(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) quiet_cmd_copy = COPY    $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)       cmd_copy = cp $< $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) # Shipped files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) # ===========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) quiet_cmd_shipped = SHIPPED $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) cmd_shipped = cat $< > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) $(obj)/%: $(src)/%_shipped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	$(call cmd,shipped)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) # Commands useful for building a boot image
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) # ===========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) #	Use as following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) #	target: source(s) FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) #		$(if_changed,ld/objcopy/gzip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) #	and add target to extra-y so that we know we have to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) #	read in the saved command line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) # Linking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) quiet_cmd_ld = LD      $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)       cmd_ld = $(LD) $(ld_flags) $(real-prereqs) -o $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) # Archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) quiet_cmd_ar = AR      $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)       cmd_ar = rm -f $@; $(AR) cDPrsT $@ $(real-prereqs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) # Objcopy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) quiet_cmd_objcopy = OBJCOPY $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) # Gzip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) quiet_cmd_gzip = GZIP    $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)       cmd_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9 > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) # DTC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) ifeq ("$(origin DTC)", "command line")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) PHONY += $(DTC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) dtc-option = $(call try-run, $(DTC) $1 -v,$1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) # Just add the flag. DTC is compiled later as a prerequisite, so there's no dtc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) # to test the flag against. This is okay because we're not testing flags which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) # aren't supported by in-kernel dtc to begin with.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) dtc-option = $1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) DTC ?= $(objtree)/scripts/dtc/dtc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) DTC_FLAGS += $(call dtc-option,-Wno-interrupt_provider)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) # Generation of symbols for Android
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) ifeq ($(CONFIG_DTC_SYMBOLS),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) DTC_FLAGS += -@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) ifeq ($(CONFIG_DTC_OMIT_DISABLED),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) DTC_FLAGS += -Wnode_disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) ifeq ($(CONFIG_DTC_OMIT_EMPTY),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) DTC_FLAGS += -Wnode_empty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) # Overlay support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) DTC_FLAGS += -@ -Wno-unit_address_format -Wno-simple_bus_reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) # Disable noisy checks by default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) DTC_FLAGS += $(call dtc-option,-Wno-unit_address_vs_reg) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	$(call dtc-option,-Wno-unit_address_format) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	$(call dtc-option,-Wno-avoid_unnecessary_addr_size) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	$(call dtc-option,-Wno-alias_paths) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	$(call dtc-option,-Wno-graph_child_address) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	$(call dtc-option,-Wno-simple_bus_reg) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	$(call dtc-option,-Wno-unique_unit_address) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	$(call dtc-option,-Wno-pci_device_reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) DTC_FLAGS += $(call dtc-option,-Wnode_name_chars_strict) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	$(call dtc-option,-Wproperty_name_chars_strict) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	$(call dtc-option,-Winterrupt_provider)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) # Generate an assembly file to wrap the output of the device tree compiler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) quiet_cmd_dt_S_dtb= DTB     $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) cmd_dt_S_dtb=						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) {							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	echo '\#include <asm-generic/vmlinux.lds.h>'; 	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	echo '.section .dtb.init.rodata,"a"';		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	echo '.balign STRUCT_ALIGNMENT';		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	echo '.global __dtb_$(subst -,_,$(*F))_begin';	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	echo '__dtb_$(subst -,_,$(*F))_begin:';		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	echo '.incbin "$<" ';				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	echo '__dtb_$(subst -,_,$(*F))_end:';		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	echo '.global __dtb_$(subst -,_,$(*F))_end';	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	echo '.balign STRUCT_ALIGNMENT'; 		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) } > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	$(call if_changed,dt_S_dtb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) quiet_cmd_dtc = DTC     $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	$(DTC) -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 		$(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		-d $(depfile).dtc.tmp $(dtc-tmp) ; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	$(call if_changed_dep,dtc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) $(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	$(call if_changed_dep,dtc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) quiet_cmd_scr = MKIMAGE $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) cmd_scr = mkimage -C none -A $(ARCH) -T script -d $< $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) $(obj)/%.scr: $(src)/%.scr-cmd FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	$(call if_changed,scr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) DT_CHECKER ?= dt-validate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) DT_BINDING_DIR := Documentation/devicetree/bindings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) # DT_TMP_SCHEMA may be overridden from Documentation/devicetree/bindings/Makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) DT_TMP_SCHEMA ?= $(objtree)/$(DT_BINDING_DIR)/processed-schema.json
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) quiet_cmd_dtb_check =	CHECK   $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)       cmd_dtb_check =	$(DT_CHECKER) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) define rule_dtc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	$(call cmd_and_fixdep,dtc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	$(call cmd,dtb_check)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) $(obj)/%.dt.yaml: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	$(call if_changed_rule,dtc,yaml)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) quiet_cmd_dtco = DTCO    $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) cmd_dtco = mkdir -p $(dir ${dtc-tmp}) ; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	$(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	$(DTC) -O dtb -o $@ -b 0 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		-i $(dir $<) $(DTC_FLAGS) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		-d $(depfile).dtc.tmp $(dtc-tmp) ; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) $(obj)/%.dtbo: $(src)/%.dts FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	$(call if_changed_dep,dtco)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) # Bzip2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) # Bzip2 and LZMA do not include size in file... so we have to fake that;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) # append the size as a 32-bit littleendian number as gzip does.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) size_append = printf $(shell						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) dec_size=0;								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) for F in $(real-prereqs); do					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	dec_size=$$(expr $$dec_size + $$fsize);				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) done;									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) printf "%08x\n" $$dec_size |						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	sed 's/\(..\)/\1 /g' | {					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 		read ch0 ch1 ch2 ch3;					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		for ch in $$ch3 $$ch2 $$ch1 $$ch0; do			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 			printf '%s%03o' '\\' $$((0x$$ch)); 		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 		done;							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	}								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) quiet_cmd_bzip2 = BZIP2   $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)       cmd_bzip2 = { cat $(real-prereqs) | $(KBZIP2) -9; $(size_append); } > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) # Lzma
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) quiet_cmd_lzma = LZMA    $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)       cmd_lzma = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) quiet_cmd_lzo = LZO     $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)       cmd_lzo = { cat $(real-prereqs) | $(KLZOP) -9; $(size_append); } > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) quiet_cmd_lz4 = LZ4     $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)       cmd_lz4 = { cat $(real-prereqs) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)                   $(LZ4) -l -12 --favor-decSpeed stdin stdout; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)                   $(size_append); } > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) quiet_cmd_lz4c = LZ4C    $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)       cmd_lz4c = { cat $(real-prereqs) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)                    $(LZ4) -12 --favor-decSpeed stdin stdout; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)                    $(size_append); } > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) # U-Boot mkimage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) MKIMAGE := $(srctree)/scripts/mkuboot.sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) # SRCARCH just happens to match slightly more than ARCH (on sparc), so reduces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) # the number of overrides in arch makefiles
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) UIMAGE_ARCH ?= $(SRCARCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) UIMAGE_COMPRESSION ?= $(if $(2),$(2),none)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) UIMAGE_OPTS-y ?=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) UIMAGE_TYPE ?= kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) UIMAGE_LOADADDR ?= arch_must_set_this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) quiet_cmd_uimage = UIMAGE  $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)       cmd_uimage = $(BASH) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 			-C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 			-T $(UIMAGE_TYPE) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 			-a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 			-n $(UIMAGE_NAME) -d $< $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) # XZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) # Use xzkern to compress the kernel image and xzmisc to compress other things.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) # xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) # of the kernel decompressor. A BCJ filter is used if it is available for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) # the target architecture. xzkern also appends uncompressed size of the data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) # using size_append. The .xz format has the size information available at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) # the end of the file too, but it's in more complex format and it's good to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) # avoid changing the part of the boot code that reads the uncompressed size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) # Note that the bytes added by size_append will make the xz tool think that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) # the file is corrupt. This is expected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) # xzmisc doesn't use size_append, so it can be used to create normal .xz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) # files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) # big dictionary would increase the memory usage too much in the multi-call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) # decompression mode. A BCJ filter isn't used either.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) quiet_cmd_xzkern = XZKERN  $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)       cmd_xzkern = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)                      $(size_append); } > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) quiet_cmd_xzmisc = XZMISC  $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)       cmd_xzmisc = cat $(real-prereqs) | $(XZ) --check=crc32 --lzma2=dict=1MiB > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) # ZSTD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) # Appends the uncompressed size of the data using size_append. The .zst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) # format has the size information available at the beginning of the file too,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) # but it's in a more complex format and it's good to avoid changing the part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) # of the boot code that reads the uncompressed size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) # Note that the bytes added by size_append will make the zstd tool think that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) # the file is corrupt. This is expected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) # zstd uses a maximum window size of 8 MB. zstd22 uses a maximum window size of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) # 128 MB. zstd22 is used for kernel compression because it is decompressed in a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) # single pass, so zstd doesn't need to allocate a window buffer. When streaming
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) # decompression is used, like initramfs decompression, zstd22 should likely not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) # be used because it would require zstd to allocate a 128 MB buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) quiet_cmd_zstd = ZSTD    $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)       cmd_zstd = { cat $(real-prereqs) | $(ZSTD) -19; $(size_append); } > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) quiet_cmd_zstd22 = ZSTD22  $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)       cmd_zstd22 = { cat $(real-prereqs) | $(ZSTD) -22 --ultra; $(size_append); } > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) # ASM offsets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) # Default sed regexp - multiline due to syntax constraints
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) # Use [:space:] because LLVM's integrated assembler inserts <tab> around
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) # the .ascii directive whereas GCC keeps the <space> as-is.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) define sed-offsets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 	/^->/{s:->#\(.*\):/* \1 */:; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	s:->::; p;}'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) # Use filechk to avoid rebuilds when a header changes, but the resulting file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) # does not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) define filechk_offsets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	 echo "#ifndef $2"; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	 echo "#define $2"; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	 echo "/*"; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	 echo " * DO NOT MODIFY."; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	 echo " *"; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	 echo " * This file was generated by Kbuild"; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	 echo " */"; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	 echo ""; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	 sed -ne $(sed-offsets) < $<; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	 echo ""; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	 echo "#endif"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) endef