Skip to content

Commit 3d57e1b

Browse files
committed
kbuild: refactor the prerequisites of the modpost rule
The prerequisites of modpost are cluttered. The variables *-if-present and *-if-needed are unreadable. It is cleaner to append them into modpost-deps. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent f65a486 commit 3d57e1b

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

scripts/Makefile.modpost

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ __modpost:
3838
include include/config/auto.conf
3939
include $(srctree)/scripts/Kbuild.include
4040

41+
MODPOST = scripts/mod/modpost
42+
4143
modpost-args = \
4244
$(if $(CONFIG_MODVERSIONS),-m) \
4345
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \
@@ -46,6 +48,8 @@ modpost-args = \
4648
$(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) \
4749
-o $@
4850

51+
modpost-deps := $(MODPOST)
52+
4953
# 'make -i -k' ignores compile errors, and builds as many modules as possible.
5054
ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
5155
modpost-args += -n
@@ -78,12 +82,13 @@ targets += .vmlinux.objs
7882
.vmlinux.objs: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
7983
$(call if_changed,vmlinux_objs)
8084

81-
vmlinux.o-if-present := $(wildcard vmlinux.o)
82-
output-symdump := vmlinux.symvers
83-
84-
ifdef KBUILD_MODULES
85-
output-symdump := $(if $(vmlinux.o-if-present), Module.symvers, modules-only.symvers)
86-
missing-input := $(filter-out $(vmlinux.o-if-present),vmlinux.o)
85+
ifeq ($(wildcard vmlinux.o),)
86+
missing-input := vmlinux.o
87+
output-symdump := modules-only.symvers
88+
else
89+
modpost-args += vmlinux.o
90+
modpost-deps += vmlinux.o
91+
output-symdump := $(if $(KBUILD_MODULES), Module.symvers, vmlinux.symvers)
8792
endif
8893

8994
else
@@ -95,11 +100,16 @@ src := $(obj)
95100
# Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS
96101
include $(kbuild-file)
97102

98-
module.symvers-if-present := $(wildcard Module.symvers)
99103
output-symdump := $(KBUILD_EXTMOD)/Module.symvers
100-
missing-input := $(filter-out $(module.symvers-if-present), Module.symvers)
101104

102-
modpost-args += -e $(addprefix -i ,$(module.symvers-if-present) $(KBUILD_EXTRA_SYMBOLS))
105+
ifeq ($(wildcard Module.symvers),)
106+
missing-input := Module.symvers
107+
else
108+
modpost-args += -i Module.symvers
109+
modpost-deps += Module.symvers
110+
endif
111+
112+
modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS))
103113

104114
endif # ($(KBUILD_EXTMOD),)
105115

@@ -108,12 +118,10 @@ modpost-args += -w
108118
endif
109119

110120
ifdef KBUILD_MODULES
111-
modorder-if-needed := $(MODORDER)
112121
modpost-args += -T $(MODORDER)
122+
modpost-deps += $(MODORDER)
113123
endif
114124

115-
MODPOST = scripts/mod/modpost
116-
117125
# Read out modules.order to pass in modpost.
118126
# Otherwise, allmodconfig would fail with "Argument list too long".
119127
quiet_cmd_modpost = MODPOST $@
@@ -122,10 +130,10 @@ quiet_cmd_modpost = MODPOST $@
122130
echo >&2 "WARNING: $(missing-input) is missing."; \
123131
echo >&2 " Modules may not have dependencies or modversions."; \
124132
echo >&2 " You may get many unresolved symbol warnings.";) \
125-
$(MODPOST) $(modpost-args) $(vmlinux.o-if-present)
133+
$(MODPOST) $(modpost-args)
126134

127135
targets += $(output-symdump)
128-
$(output-symdump): $(modorder-if-needed) $(vmlinux.o-if-present) $(module.symvers-if-present) $(MODPOST) FORCE
136+
$(output-symdump): $(modpost-deps) FORCE
129137
$(call if_changed,modpost)
130138

131139
__modpost: $(output-symdump)

0 commit comments

Comments
 (0)