Debian Codegraph @

scripts/Makefile.modfinal

raw ◀ ▶
1 Debian patch touch this file
1 # SPDX-License-Identifier: GPL-2.0-only
2 # ===========================================================================
3 # Module final link
4 # ===========================================================================
5
6 PHONY := __modfinal
7 __modfinal:
8
9 include $(objtree)/include/config/auto.conf
10 include $(srctree)/scripts/Kbuild.include
11 include $(srctree)/scripts/Makefile.lib
12
13 # find all modules listed in modules.order
14 modules := $(call read-file, modules.order)
15
16 __modfinal: $(modules:%.o=%.ko)
17 @:
18
19 # modname and part-of-module are set to make c_flags define proper module flags
20 modname = $(notdir $(@:.mod.o=))
21 part-of-module = y
22 GCOV_PROFILE := n
23 ccflags-remove-y := $(CC_FLAGS_CFI)
24
25 %.mod.o: %.mod.c FORCE
26 $(call if_changed_rule,cc_o_c)
27
28 .module-common.o: $(srctree)/scripts/module-common.c FORCE
29 $(call if_changed_rule,cc_o_c)
30
31 ifneq ($(WARN_ON_UNUSED_TRACEPOINTS),)
32 cmd_check_tracepoint = $(objtree)/scripts/tracepoint-update --module $<;
33 endif
34
•35 ARCH_MODULE_LDS := $(word 1,$(wildcard $(objtree)/scripts/module.lds $(objtree)/arch/$(SRCARCH)/module.lds))
36
37 quiet_cmd_ld_ko_o = LD [M] $@
38 cmd_ld_ko_o = \
39 $(LD) -r $(KBUILD_LDFLAGS) \
40 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
•41 -T $(ARCH_MODULE_LDS) -o $@ $(filter %.o, $^)
42
43 quiet_cmd_btf_ko = BTF [M] $@
44 cmd_btf_ko = \
45 if [ ! -f $(objtree)/vmlinux ]; then \
46 printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \
47 else \
48 $(CONFIG_SHELL) $(srctree)/scripts/gen-btf.sh --btf_base $(objtree)/vmlinux $@; \
49 fi;
50
51 # Same as newer-prereqs, but allows to exclude specified extra dependencies
52 newer_prereqs_except = $(filter-out $(PHONY) $(1),$?)
53
54 # Same as if_changed, but allows to exclude specified extra dependencies
55 if_changed_except = $(if $(call newer_prereqs_except,$(2))$(cmd-check), \
56 $(cmd); \
57 printf '%s\n' 'savedcmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
58
59 # Re-generate module BTFs if either module's .ko or vmlinux changed
60 %.ko: %.o %.mod.o .module-common.o $(ARCH_MODULE_LDS) $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),$(objtree)/vmlinux) FORCE
•61 +$(call if_changed_except,ld_ko_o,$(objtree)/vmlinux)
62 ifdef CONFIG_DEBUG_INFO_BTF_MODULES
63 +$(if $(newer-prereqs),$(call cmd,btf_ko))
64 endif
65 +$(call cmd,check_tracepoint)
66
67 targets += $(modules:%.o=%.ko) $(modules:%.o=%.mod.o) .module-common.o
68
69 # Add FORCE to the prerequisites of a target to force it to be always rebuilt.
70 # ---------------------------------------------------------------------------
71
72 PHONY += FORCE
73 FORCE:
74
75 # Read all saved command lines and dependencies for the $(targets) we
76 # may be building above, using $(if_changed{,_dep}). As an
77 # optimization, we don't need to read them if the target does not
78 # exist, we will rebuild anyway in that case.
79
80 existing-targets := $(wildcard $(sort $(targets)))
81
82 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
83
84 .PHONY: $(PHONY)