Skip to content

Commit 1664a37

Browse files
committed
kbuild: pass KBUILD_MODFILE when compiling builtin objects
When compiling, Kbuild passes KBUILD_BASENAME (basename of the object) and KBUILD_MODNAME (basename of the module). This commit adds another one, KBUILD_MODFILE, which is the path of the module. (or, the path of the module it would end up in if it were compiled as a module.) The next commit will use this to generate modules.builtin without tristate.conf. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 7e826c4 commit 1664a37

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

‎scripts/Makefile.lib‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,14 @@ multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
8484
subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
8585

8686
# Finds the multi-part object the current object will be linked into.
87-
# If the object belongs to two or more multi-part objects, all of them are
88-
# concatenated with a colon separator.
89-
modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\
90-
$(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))))
87+
# If the object belongs to two or more multi-part objects, list them all.
88+
modname-multi = $(sort $(foreach m,$(multi-used),\
89+
$(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=))))
9190

92-
modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
91+
__modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
92+
93+
modname = $(subst $(space),:,$(__modname))
94+
modfile = $(addprefix $(obj)/,$(__modname))
9395

9496
# target with $(obj)/ and its suffix stripped
9597
target-stem = $(basename $(patsubst $(obj)/%,%,$@))
@@ -100,6 +102,7 @@ target-stem = $(basename $(patsubst $(obj)/%,%,$@))
100102
name-fix = $(call stringify,$(subst $(comma),_,$(subst -,_,$1)))
101103
basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
102104
modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname))
105+
modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile))
103106

104107
orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
105108
$(ccflags-y) $(CFLAGS_$(target-stem).o)
@@ -158,7 +161,7 @@ quiet_modtag = $(if $(part-of-module),[M], )
158161
modkern_cflags = \
159162
$(if $(part-of-module), \
160163
$(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
161-
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
164+
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags))
162165

163166
modkern_aflags = $(if $(part-of-module), \
164167
$(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \

0 commit comments

Comments
 (0)