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) # ==========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) # Building
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) # ==========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) src := $(obj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) PHONY := __build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) __build:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) # Init all relevant variables used in kbuild files so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) # 1) they have correct type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) # 2) they do not inherit any value from the environment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) obj-y :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) obj-m :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) lib-y :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) lib-m :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) always :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) always-y :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) always-m :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) targets :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) subdir-y :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) subdir-m :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) EXTRA_AFLAGS   :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) EXTRA_CFLAGS   :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) EXTRA_CPPFLAGS :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) EXTRA_LDFLAGS  :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) asflags-y  :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) ccflags-y  :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) cppflags-y :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) ldflags-y  :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) subdir-asflags-y :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) subdir-ccflags-y :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) # Read auto.conf if it exists, otherwise ignore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) -include include/config/auto.conf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) include scripts/Kbuild.include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) # The filename Kbuild has precedence over Makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) include $(kbuild-file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) include scripts/Makefile.lib
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) # Do not include hostprogs rules unless needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) # $(sort ...) is used here to remove duplicated words and excessive spaces.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) hostprogs := $(sort $(hostprogs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) ifneq ($(hostprogs),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) include scripts/Makefile.host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) # Do not include userprogs rules unless needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) # $(sort ...) is used here to remove duplicated words and excessive spaces.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) userprogs := $(sort $(userprogs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) ifneq ($(userprogs),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) include scripts/Makefile.userprogs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) ifndef obj
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) $(warning kbuild: Makefile.build is included improperly)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) ifeq ($(need-modorder),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) ifneq ($(obj-m),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) $(warning $(patsubst %.o,'%.ko',$(obj-m)) will not be built even though obj-m is specified.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) $(warning You cannot use subdir-y/m to visit a module Makefile. Use obj-y/m instead.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) # ===========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) # subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) subdir-modorder := $(sort $(filter %/modules.order, $(obj-m)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) targets-for-builtin := $(extra-y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) targets-for-builtin += $(obj)/lib.a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) ifdef need-builtin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) targets-for-builtin += $(obj)/built-in.a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) targets-for-modules := $(patsubst %.o, %.mod, $(filter %.o, $(obj-m)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) ifdef need-modorder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) targets-for-modules += $(obj)/modules.order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) targets += $(targets-for-builtin) $(targets-for-modules)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) # Linus' kernel sanity checking tool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) ifeq ($(KBUILD_CHECKSRC),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)   quiet_cmd_checksrc       = CHECK   $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)         cmd_checksrc       = $(CHECK) $(CHECKFLAGS) $(c_flags) $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) else ifeq ($(KBUILD_CHECKSRC),2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)   quiet_cmd_force_checksrc = CHECK   $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)         cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) ifneq ($(KBUILD_EXTRA_WARN),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)   cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) # Compile C sources (.c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) quiet_cmd_cc_s_c = CC $(quiet_modtag)  $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)       cmd_cc_s_c = $(CC) -fverbose-asm $(filter-out $(DEBUG_CFLAGS) $(CC_FLAGS_LTO), $(c_flags)) -S -o $@ $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) $(obj)/%.s: $(src)/%.c FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	$(call if_changed_dep,cc_s_c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) quiet_cmd_cpp_i_c = CPP $(quiet_modtag) $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) cmd_cpp_i_c       = $(CPP) $(c_flags) -o $@ $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) $(obj)/%.i: $(src)/%.c FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	$(call if_changed_dep,cpp_i_c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) # These mirror gensymtypes_S and co below, keep them in synch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) cmd_gensymtypes_c =                                                         \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)     $(CPP) -D__GENKSYMS__ $(c_flags) $< |                                   \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)     scripts/genksyms/genksyms $(if $(1), -T $(2))                           \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)      $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS))                             \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)      $(if $(KBUILD_PRESERVE),-p)                                            \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)      -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) cmd_cc_symtypes_c =                                                         \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)     $(call cmd_gensymtypes_c,true,$@) >/dev/null;                           \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)     test -s $@ || rm -f $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) $(obj)/%.symtypes : $(src)/%.c FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	$(call cmd,cc_symtypes_c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) # LLVM assembly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) # Generate .ll files from .c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) quiet_cmd_cc_ll_c = CC $(quiet_modtag)  $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)       cmd_cc_ll_c = $(CC) $(c_flags) -emit-llvm -S -o $@ $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) $(obj)/%.ll: $(src)/%.c FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	$(call if_changed_dep,cc_ll_c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) # C (.c) files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) # The C file is compiled and updated dependency information is generated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) # (See cmd_cc_o_c + relevant part of rule_cc_o_c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)       cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) ifdef CONFIG_MODVERSIONS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) # When module versioning is enabled the following steps are executed:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) # o compile a <file>.o from <file>.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) # o if <file>.o doesn't contain a __ksymtab version, i.e. does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) #   not export symbols, it's done.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) # o otherwise, we calculate symbol versions using the good old
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) #   genksyms on the preprocessed source and postprocess them in a way
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #   that they are usable as a linker script
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) # o generate .tmp_<file>.o from <file>.o using the linker to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #   replace the unresolved symbols __crc_exported_symbol with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) #   the actual value of the checksum generated by genksyms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) # o remove .tmp_<file>.o to <file>.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) ifdef CONFIG_LTO_CLANG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) # Generate .o.symversions files for each .o with exported symbols, and link these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) # to the kernel and/or modules at the end.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) cmd_modversions_c =								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		$(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes))	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		    > $@.symversions;						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	fi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) cmd_modversions_c =								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	if $(OBJDUMP) -h $@ | grep -q __ksymtab; then				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		$(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes))	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		    > $(@D)/.tmp_$(@F:.o=.ver);					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 										\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		$(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ 		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 			-T $(@D)/.tmp_$(@F:.o=.ver);				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		mv -f $(@D)/.tmp_$(@F) $@;					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		rm -f $(@D)/.tmp_$(@F:.o=.ver);					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) # compiler will not generate __mcount_loc use recordmcount or recordmcount.pl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) ifdef BUILD_C_RECORDMCOUNT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)   RECORDMCOUNT_FLAGS = -w
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) # Due to recursion, we must skip empty.o.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) # The empty.o file is created in the make process in order to determine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) # the target endianness and word size. It is made before all other C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) # files, including recordmcount.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) sub_cmd_record_mcount =					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	if [ $(@) != "scripts/mod/empty.o" ]; then	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		$(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)";	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	fi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) recordmcount_source := $(srctree)/scripts/recordmcount.c \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		    $(srctree)/scripts/recordmcount.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) sub_cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	"$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	"$(if $(CONFIG_64BIT),64,32)" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	"$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	"$(LD) $(KBUILD_LDFLAGS)" "$(NM)" "$(RM)" "$(MV)" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	"$(if $(part-of-module),1,0)" "$(@)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) recordmcount_source := $(srctree)/scripts/recordmcount.pl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) endif # BUILD_C_RECORDMCOUNT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)),	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	$(sub_cmd_record_mcount))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) ifdef CONFIG_STACK_VALIDATION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) ifndef CONFIG_LTO_CLANG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) ifneq ($(SKIP_STACK_VALIDATION),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) __objtool_obj := $(objtree)/tools/objtool/objtool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) # 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) cmd_objtool = $(if $(patsubst y%,, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	$(__objtool_obj) $(objtool_args) $@)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) objtool_obj = $(if $(patsubst y%,, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	$(__objtool_obj))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) endif # SKIP_STACK_VALIDATION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) endif # CONFIG_LTO_CLANG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) endif # CONFIG_STACK_VALIDATION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) # Rebuild all objects when objtool changes, or is enabled/disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) objtool_dep = $(objtool_obj)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	      $(wildcard include/config/orc/unwinder.h		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 			 include/config/stack/validation.h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) ifdef CONFIG_TRIM_UNUSED_KSYMS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) cmd_gen_ksymdeps = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	$(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) # List module undefined symbols
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) undefined_syms = $(NM) $< | $(AWK) '$$1 == "U" { printf("%s%s", x++ ? " " : "", $$2) }';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) define rule_cc_o_c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	$(call cmd_and_fixdep,cc_o_c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	$(call cmd,gen_ksymdeps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	$(call cmd,checksrc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	$(call cmd,checkdoc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	$(call cmd,objtool)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	$(call cmd,modversions_c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	$(call cmd,record_mcount)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) define rule_as_o_S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	$(call cmd_and_fixdep,as_o_S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	$(call cmd,gen_ksymdeps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	$(call cmd,objtool)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	$(call cmd,modversions_S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) # Built-in and composite module parts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) .SECONDEXPANSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) $(obj)/%.o: $(src)/%.c $(recordmcount_source) $$(objtool_dep) FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	$(call if_changed_rule,cc_o_c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	$(call cmd,force_checksrc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) cmd_mod = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	echo $(if $($*-objs)$($*-y)$($*-m), $(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), $(@:.mod=.o)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	$(undefined_syms) echo; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	} > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) $(obj)/%.mod: $(obj)/%.o FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	$(call if_changed,mod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) quiet_cmd_cc_lst_c = MKLST   $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)       cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		     $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 				     System.map $(OBJDUMP) > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) $(obj)/%.lst: $(src)/%.c FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	$(call if_changed_dep,cc_lst_c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) # Compile assembler sources (.S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) # .S file exports must have their C prototypes defined in asm/asm-prototypes.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) # or a file that it includes, in order to get versioned symbols. We build a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) # dummy C file that includes asm-prototypes and the EXPORT_SYMBOL lines from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) # the .S file (with trailing ';'), and run genksyms on that, to extract vers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) # This is convoluted. The .S file must first be preprocessed to run guards and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) # expand names, then the resulting exports must be constructed into plain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) # EXPORT_SYMBOL(symbol); to build our dummy C file, and that gets preprocessed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) # to make the genksyms input.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) # These mirror gensymtypes_c and co above, keep them in synch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) cmd_gensymtypes_S =                                                         \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)    { echo "\#include <linux/kernel.h>" ;                                    \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)      echo "\#include <asm/asm-prototypes.h>" ;                              \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)     $(CPP) $(a_flags) $< |                                                  \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)      grep "\<___EXPORT_SYMBOL\>" |                                          \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)      sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ; } | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)     $(CPP) -D__GENKSYMS__ $(c_flags) -xc - |                                \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)     scripts/genksyms/genksyms $(if $(1), -T $(2))                           \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)      $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS))                             \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)      $(if $(KBUILD_PRESERVE),-p)                                            \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)      -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) cmd_cc_symtypes_S =                                                         \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)     $(call cmd_gensymtypes_S,true,$@) >/dev/null;                           \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)     test -s $@ || rm -f $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) $(obj)/%.symtypes : $(src)/%.S FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	$(call cmd,cc_symtypes_S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) quiet_cmd_cpp_s_S = CPP $(quiet_modtag) $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) cmd_cpp_s_S       = $(CPP) $(a_flags) -o $@ $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) $(obj)/%.s: $(src)/%.S FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	$(call if_changed_dep,cpp_s_S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) quiet_cmd_as_o_S = AS $(quiet_modtag)  $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)       cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) ifdef CONFIG_ASM_MODVERSIONS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) # versioning matches the C process described above, with difference that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) # we parse asm-prototypes.h C header to get function definitions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) cmd_modversions_S =								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	if $(OBJDUMP) -h $@ | grep -q __ksymtab; then				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		$(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes))	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		    > $(@D)/.tmp_$(@F:.o=.ver);					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 										\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		$(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ 		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 			-T $(@D)/.tmp_$(@F:.o=.ver);				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		mv -f $(@D)/.tmp_$(@F) $@;					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		rm -f $(@D)/.tmp_$(@F:.o=.ver);					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) $(obj)/%.o: $(src)/%.S $$(objtool_dep) FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	$(call if_changed_rule,as_o_S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) targets += $(filter-out $(subdir-builtin), $(real-obj-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) targets += $(filter-out $(subdir-modorder), $(real-obj-m))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) targets += $(lib-y) $(always-y) $(MAKECMDGOALS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) # Linker scripts preprocessor (.lds.S -> .lds)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) quiet_cmd_cpp_lds_S = LDS     $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)       cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -U$(ARCH) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	                     -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) $(obj)/%.lds: $(src)/%.lds.S FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	$(call if_changed_dep,cpp_lds_S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) # ASN.1 grammar
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) quiet_cmd_asn1_compiler = ASN.1   $(basename $@).[ch]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)       cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 				$(basename $@).c $(basename $@).h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	$(call cmd,asn1_compiler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) # Build the compiled-in targets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) # To build objects in subdirs, we need to descend into the directories
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) $(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) # combine symversions for later processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) quiet_cmd_update_lto_symversions = SYMVER  $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) ifeq ($(CONFIG_LTO_CLANG) $(CONFIG_MODVERSIONS),y y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)       cmd_update_lto_symversions =					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	rm -f $@.symversions						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	$(foreach n, $(filter-out FORCE,$^),				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		$(if $(wildcard $(n).symversions),			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 			; cat $(n).symversions >> $@.symversions))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)       cmd_update_lto_symversions = echo >/dev/null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) # Rule to compile a set of .o files into one .a file (without symbol table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) quiet_cmd_ar_builtin = AR      $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)       cmd_ar_builtin = rm -f $@; $(AR) cDPrST $@ $(real-prereqs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) quiet_cmd_ar_and_symver = AR      $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)       cmd_ar_and_symver = $(cmd_update_lto_symversions); $(cmd_ar_builtin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) $(obj)/built-in.a: $(real-obj-y) FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	$(call if_changed,ar_and_symver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) # Rule to create modules.order file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) # Create commands to either record .ko file or cat modules.order from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) # a subdirectory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) # Add $(obj-m) as the prerequisite to avoid updating the timestamp of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) # modules.order unless contained modules are updated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) cmd_modules_order = { $(foreach m, $(real-prereqs), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	$(if $(filter %/modules.order, $m), cat $m, echo $(patsubst %.o,%.ko,$m));) :; } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	| $(AWK) '!x[$$0]++' - > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) $(obj)/modules.order: $(obj-m) FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	$(call if_changed,modules_order)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) # Rule to compile a set of .o files into one .a file (with symbol table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) quiet_cmd_ar_lib = AR      $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)       cmd_ar_lib = $(cmd_update_lto_symversions); $(cmd_ar)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) $(obj)/lib.a: $(lib-y) FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	$(call if_changed,ar_lib)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) # NOTE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) # Do not replace $(filter %.o,^) with $(real-prereqs). When a single object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) # module is turned into a multi object module, $^ will contain header file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) # dependencies recorded in the .*.cmd file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) ifdef CONFIG_LTO_CLANG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) quiet_cmd_link_multi-m = AR [M]  $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) cmd_link_multi-m =						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	$(cmd_update_lto_symversions);				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	rm -f $@; 						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	$(AR) cDPrsT $@ $(filter %.o %.a,$^)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) quiet_cmd_link_multi-m = LD [M]  $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)       cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) $(multi-used-m): FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	$(call if_changed,link_multi-m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) $(call multi_depend, $(multi-used-m), .o, -objs -y -m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) targets += $(multi-used-m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) targets := $(filter-out $(PHONY), $(targets))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) # Add intermediate targets:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) # When building objects with specific suffix patterns, add intermediate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) # targets that the final targets are derived from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) intermediate_targets = $(foreach sfx, $(2), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 				$(patsubst %$(strip $(1)),%$(sfx), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 					$(filter %$(strip $(1)), $(targets))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) # %.asn1.o <- %.asn1.[ch] <- %.asn1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) # %.dtb.o <- %.dtb.S <- %.dtb <- %.dts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) # %.lex.o <- %.lex.c <- %.l
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) # %.tab.o <- %.tab.[ch] <- %.y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	   $(call intermediate_targets, .dtb.o, .dtb.S .dtb) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	   $(call intermediate_targets, .lex.o, .lex.c) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	   $(call intermediate_targets, .tab.o, .tab.c .tab.h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) # Build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) ifdef single-build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) KBUILD_SINGLE_TARGETS := $(filter $(obj)/%, $(KBUILD_SINGLE_TARGETS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) curdir-single := $(sort $(foreach x, $(KBUILD_SINGLE_TARGETS), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 			$(if $(filter $(x) $(basename $(x)).o, $(targets)), $(x))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) # Handle single targets without any rule: show "Nothing to be done for ..." or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) # "No rule to make target ..." depending on whether the target exists.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) unknown-single := $(filter-out $(addsuffix /%, $(subdir-ym)), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 			$(filter-out $(curdir-single), $(KBUILD_SINGLE_TARGETS)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) single-subdirs := $(foreach d, $(subdir-ym), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 			$(if $(filter $(d)/%, $(KBUILD_SINGLE_TARGETS)), $(d)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) __build: $(curdir-single) $(single-subdirs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) ifneq ($(unknown-single),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	$(Q)$(MAKE) -f /dev/null $(unknown-single)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	@:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) ifeq ($(curdir-single),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) # Nothing to do in this directory. Do not include any .*.cmd file for speed-up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) targets :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) targets += $(curdir-single)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) __build: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	 $(if $(KBUILD_MODULES), $(targets-for-modules)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	 $(subdir-ym) $(always-y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	@:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) # Descending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) PHONY += $(subdir-ym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) $(subdir-ym):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	$(Q)$(MAKE) $(build)=$@ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	$(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	need-modorder=$(if $(filter $@/modules.order, $(subdir-modorder)),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) # Add FORCE to the prequisites of a target to force it to be always rebuilt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) PHONY += FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) FORCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) # Read all saved command lines and dependencies for the $(targets) we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) # may be building above, using $(if_changed{,_dep}). As an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) # optimization, we don't need to read them if the target does not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) # exist, we will rebuild anyway in that case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) existing-targets := $(wildcard $(sort $(targets)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) # Create directories for object files if they do not exist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) obj-dirs := $(sort $(patsubst %/,%, $(dir $(targets))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) # If targets exist, their directories apparently exist. Skip mkdir.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) existing-dirs := $(sort $(patsubst %/,%, $(dir $(existing-targets))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) obj-dirs := $(strip $(filter-out $(existing-dirs), $(obj-dirs)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) ifneq ($(obj-dirs),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) $(shell mkdir -p $(obj-dirs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) .PHONY: $(PHONY)