32
32
# Step 4 is solely used to allow module versioning in external modules,
33
33
# where the CRC of each module is retrieved from the Module.symvers file.
34
34
35
- # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
36
- # This is solely useful to speed up test compiles
37
-
38
35
PHONY := __modpost
39
36
__modpost:
40
37
@@ -45,24 +42,23 @@ MODPOST = scripts/mod/modpost \
45
42
$(if $(CONFIG_MODVERSIONS),-m) \
46
43
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \
47
44
$(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \
45
+ $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \
46
+ $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) \
48
47
-o $@
49
48
50
- ifdef MODPOST_VMLINUX
51
-
52
- quiet_cmd_modpost = MODPOST $@
53
- cmd_modpost = $(MODPOST) $<
54
-
55
- vmlinux.symvers: vmlinux.o
56
- $(call cmd,modpost)
49
+ # 'make -i -k' ignores compile errors, and builds as many modules as possible.
50
+ ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
51
+ MODPOST += -n
52
+ endif
57
53
58
- __modpost: vmlinux.symvers
54
+ ifeq ($(KBUILD_EXTMOD),)
59
55
60
56
# Generate the list of in-tree objects in vmlinux
61
57
# ---------------------------------------------------------------------------
62
58
63
59
# This is used to retrieve symbol versions generated by genksyms.
64
60
ifdef CONFIG_MODVERSIONS
65
- vmlinux.symvers: .vmlinux.objs
61
+ vmlinux.symvers Module.symvers : .vmlinux.objs
66
62
endif
67
63
68
64
# Ignore libgcc.a
@@ -83,24 +79,12 @@ targets += .vmlinux.objs
83
79
.vmlinux.objs: $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
84
80
$(call if_changed,vmlinux_objs)
85
81
86
- else
87
-
88
- ifeq ($(KBUILD_EXTMOD),)
89
-
90
- input-symdump := vmlinux.symvers
91
- output-symdump := modules-only.symvers
92
-
93
- quiet_cmd_cat = GEN $@
94
- cmd_cat = cat $(real-prereqs) > $@
95
-
96
- ifneq ($(wildcard vmlinux.symvers),)
97
-
98
- __modpost: Module.symvers
99
- Module.symvers: vmlinux.symvers modules-only.symvers FORCE
100
- $(call if_changed,cat)
101
-
102
- targets += Module.symvers
82
+ vmlinux.o-if-present := $(wildcard vmlinux.o)
83
+ output-symdump := vmlinux.symvers
103
84
85
+ ifdef KBUILD_MODULES
86
+ output-symdump := $(if $(vmlinux.o-if-present), Module.symvers, modules-only.symvers)
87
+ missing-input := $(filter-out $(vmlinux.o-if-present),vmlinux.o)
104
88
endif
105
89
106
90
else
@@ -112,56 +96,35 @@ src := $(obj)
112
96
# Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS
113
97
include $(or $(wildcard $(src)/Kbuild), $(src)/Makefile)
114
98
115
- # modpost option for external modules
116
- MODPOST += -e
117
-
118
- input-symdump := Module.symvers $(KBUILD_EXTRA_SYMBOLS)
99
+ module.symvers-if-present := $(wildcard Module.symvers)
119
100
output-symdump := $(KBUILD_EXTMOD)/Module.symvers
101
+ missing-input := $(filter-out $(module.symvers-if-present), Module.symvers)
120
102
121
- endif
122
-
123
- existing-input-symdump := $(wildcard $(input-symdump))
124
-
125
- # modpost options for modules (both in-kernel and external)
126
- MODPOST += \
127
- $(addprefix -i ,$(existing-input-symdump)) \
128
- $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \
129
- $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N)
130
-
131
- # 'make -i -k' ignores compile errors, and builds as many modules as possible.
132
- ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
133
- MODPOST += -n
134
- endif
103
+ MODPOST += -e $(addprefix -i ,$(module.symvers-if-present) $(KBUILD_EXTRA_SYMBOLS))
135
104
136
- # Clear VPATH to not search for *.symvers in $(srctree). Check only $(objtree).
137
- VPATH :=
138
- $(input-symdump):
139
- @echo >&2 'WARNING: Symbol version dump "$@" is missing.'
140
- @echo >&2 ' Modules may not have dependencies or modversions.'
141
- @echo >&2 ' You may get many unresolved symbol warnings.'
105
+ endif # ($(KBUILD_EXTMOD),)
142
106
143
- # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined symbols
144
- ifneq ($(KBUILD_MODPOST_WARN)$(filter-out $(existing-input-symdump), $(input-symdump)),)
107
+ ifneq ($(KBUILD_MODPOST_WARN)$(missing-input),)
145
108
MODPOST += -w
146
109
endif
147
110
111
+ modorder-if-needed := $(if $(KBUILD_MODULES), $(MODORDER))
112
+
148
113
# Read out modules.order to pass in modpost.
149
114
# Otherwise, allmodconfig would fail with "Argument list too long".
150
115
quiet_cmd_modpost = MODPOST $@
151
- cmd_modpost = sed 's/ko$$/o/' $< | $(MODPOST) -T -
152
-
153
- $(output-symdump): $(MODORDER) $(input-symdump) FORCE
154
- $(call if_changed,modpost)
116
+ cmd_modpost = \
117
+ $(if $(missing-input), \
118
+ echo >&2 "WARNING: $(missing-input) is missing."; \
119
+ echo >&2 " Modules may not have dependencies or modversions."; \
120
+ echo >&2 " You may get many unresolved symbol warnings.";) \
121
+ sed 's/ko$$/o/' $(or $(modorder-if-needed), /dev/null) | $(MODPOST) $(vmlinux.o-if-present) -T -
155
122
156
123
targets += $(output-symdump)
124
+ $(output-symdump): $(modorder-if-needed) $(vmlinux.o-if-present) $(moudle.symvers-if-present) FORCE
125
+ $(call if_changed,modpost)
157
126
158
127
__modpost: $(output-symdump)
159
- ifneq ($(KBUILD_MODPOST_NOFINAL),1)
160
- $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
161
- endif
162
-
163
- endif
164
-
165
128
PHONY += FORCE
166
129
FORCE:
167
130
0 commit comments