Skip to content

Commit 1c3fae7

Browse files
eberman-quicmasahir0y
authored andcommitted
Kbuild: Make composite object searching more generic
Reduce repeated logic around expanding composite objects. Signed-off-by: Elliot Berman <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 2047ace commit 1c3fae7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

scripts/Makefile.lib

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,19 @@ else
5656
obj-y := $(filter-out %/, $(obj-y))
5757
endif
5858

59+
# Expand $(foo-objs) $(foo-y) by calling $(call suffix-search,foo.o,-objs -y)
60+
suffix-search = $(foreach s,$(2),$($(1:.o=$s)))
5961
# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
60-
multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))), $(m))))
61-
multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))), $(m))))
62+
multi-search = $(sort $(foreach m,$(1), $(if $(strip $(call suffix-search,$(m),$(2) -)), $(m))))
63+
multi-used-y := $(call multi-search,$(obj-y),-objs -y)
64+
multi-used-m := $(call multi-search,$(obj-m),-objs -y -m)
6265
multi-used := $(multi-used-y) $(multi-used-m)
6366

6467
# Replace multi-part objects by their individual parts,
6568
# including built-in.a from subdirectories
66-
real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
67-
real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
69+
real-search = $(foreach m,$(1), $(if $(strip $(call suffix-search,$(m),$(2) -)),$(call suffix-search,$(m),$(2)),$(m)))
70+
real-obj-y := $(call real-search, $(obj-y),-objs -y)
71+
real-obj-m := $(call real-search, $(obj-m),-objs -y -m)
6872

6973
always-y += $(always-m)
7074

0 commit comments

Comments
 (0)