@@ -44,32 +44,35 @@ include include/config/auto.conf
4444include scripts/Kbuild.include
4545
4646kernelsymfile := $(objtree)/Module.symvers
47- modulesymfile := $(KBUILD_EXTMOD)/Module.symvers
4847
4948MODPOST = scripts/mod/modpost \
5049 $(if $(CONFIG_MODVERSIONS),-m) \
5150 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \
52- $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
51+ $(if $(KBUILD_EXTMOD),-i $(kernelsymfile) ) \
5352 $(if $(KBUILD_EXTMOD),$(addprefix -i ,$(KBUILD_EXTRA_SYMBOLS))) \
54- $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
5553 $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \
56- $(if $(KBUILD_MODPOST_WARN),-w)
54+ $(if $(KBUILD_MODPOST_WARN),-w) \
55+ -o $@
5756
5857ifdef MODPOST_VMLINUX
5958
60- quiet_cmd_modpost = MODPOST vmlinux.o
61- cmd_modpost = $(MODPOST) vmlinux.o
59+ quiet_cmd_modpost = MODPOST $@
60+ cmd_modpost = $(MODPOST) $<
6261
63- __modpost:
62+ Module.symvers: vmlinux.o
6463 $(call cmd,modpost)
6564
65+ __modpost: Module.symvers
66+
6667else
6768
6869MODPOST += -s \
6970 $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS))
7071
7172ifeq ($(KBUILD_EXTMOD),)
7273MODPOST += $(wildcard vmlinux)
74+ output-symdump := Module.symvers
75+
7376else
7477
7578# set src + obj - they may be used in the modules's Makefile
@@ -83,6 +86,8 @@ include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \
8386# modpost option for external modules
8487MODPOST += -e
8588
89+ output-symdump := $(KBUILD_EXTMOD)/Module.symvers
90+
8691endif
8792
8893# modpost options for modules (both in-kernel and external)
@@ -94,20 +99,22 @@ ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
9499MODPOST += -n
95100endif
96101
97- # find all modules listed in modules.order
98- modules := $(sort $(shell cat $(MODORDER)))
99-
100- # Read out modules.order instead of expanding $(modules) to pass in modpost.
102+ # Read out modules.order to pass in modpost.
101103# Otherwise, allmodconfig would fail with "Argument list too long".
102- quiet_cmd_modpost = MODPOST $(words $(modules)) modules
104+ quiet_cmd_modpost = MODPOST $@
103105 cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST) -T -
104106
105- __modpost:
107+ $(output-symdump): FORCE
106108 $(call cmd,modpost)
109+
110+ __modpost: $(output-symdump)
107111ifneq ($(KBUILD_MODPOST_NOFINAL),1)
108112 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
109113endif
110114
115+ PHONY += FORCE
116+ FORCE:
117+
111118endif
112119
113120.PHONY: $(PHONY)
0 commit comments