[PATCH 2/5] kbuild: clean up modname calculation
From: Masahiro Yamada
Date: Tue Aug 06 2019 - 02:40:47 EST
'multi-used' is used for computing the modname. Improve the code
readability by removing the .o suffix before the foreach loop.
I renamed multi-used-m to modules-multi.
No functional change intended.
Signed-off-by: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>
---
scripts/Makefile.build | 6 +++---
scripts/Makefile.lib | 15 +++++++++------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 0d434d0afc0b..b0ff60ac0c42 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -460,11 +460,11 @@ endif
quiet_cmd_link_multi-m = LD [M] $@
cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^)
-$(multi-used-m): FORCE
+$(modules-multi): FORCE
$(call if_changed,link_multi-m)
-$(call multi_depend, $(multi-used-m), .o, -objs -y -m)
+$(call multi_depend, $(modules-multi), .o, -objs -y -m)
-targets += $(multi-used-m)
+targets += $(modules-multi)
targets := $(filter-out $(PHONY), $(targets))
# Add intermediate targets:
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 0a540599823e..e503f12e8e9c 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -41,10 +41,13 @@ obj-m := $(filter-out %/, $(obj-m))
# Subdirectories we need to descend into
subdir-ym := $(sort $(subdir-y) $(subdir-m))
-# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
-multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))), $(m))))
-multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))), $(m))))
-multi-used := $(multi-used-y) $(multi-used-m)
+# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo is multi-used
+multi-used-y := $(sort $(foreach m, $(patsubst %.o,%,$(obj-y)), $(if $(strip $($(m)-objs) $($(m)-y) $($(m)-)), $(m))))
+multi-used-m := $(sort $(foreach m, $(patsubst %.o,%,$(obj-m)), $(if $(strip $($(m)-objs) $($(m)-y) $($(m)-m) $($(m)-)), $(m))))
+
+modules-multi := $(addsuffix .o, $(multi-used-m))
+
+multi-used := $(multi-used-y) $(multi-used-m)
# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
# tell kbuild to descend
@@ -90,14 +93,14 @@ lib-y := $(addprefix $(obj)/,$(lib-y))
subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
real-obj-y := $(addprefix $(obj)/,$(real-obj-y))
real-obj-m := $(addprefix $(obj)/,$(real-obj-m))
-multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
+modules-multi := $(addprefix $(obj)/,$(modules-multi))
subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
# Finds the multi-part object the current object will be linked into.
# If the object belongs to two or more multi-part objects, all of them are
# concatenated with a colon separator.
modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\
- $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))))
+ $(if $(filter $*.o, $($(m)-objs) $($(m)-y) $($(m)-m)),$(m)))))
modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
--
2.17.1