diff mbox series

[1/3] kbuild: parameterize the .o part of suffix-search

Message ID 20210502180957.3419490-1-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series [1/3] kbuild: parameterize the .o part of suffix-search | expand

Commit Message

Masahiro Yamada May 2, 2021, 6:09 p.m. UTC
The suffix-search macro hard-codes the suffix, '.o'.

Make it a parameter so that the multi-search and real-search macros
can be reused for foo-dtbs syntax introduced by commit 15d16d6dadf6
("kbuild: Add generic rule to apply fdtoverlay").

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/Makefile.lib | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

Comments

Masahiro Yamada May 5, 2021, 5:51 p.m. UTC | #1
On Mon, May 3, 2021 at 3:10 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> The suffix-search macro hard-codes the suffix, '.o'.
>
> Make it a parameter so that the multi-search and real-search macros
> can be reused for foo-dtbs syntax introduced by commit 15d16d6dadf6
> ("kbuild: Add generic rule to apply fdtoverlay").
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---


Applied to linux-kbuild.


>  scripts/Makefile.lib | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 64daf37e874b..88b446ed6532 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -44,19 +44,22 @@ else
>  obj-y          := $(filter-out %/, $(obj-y))
>  endif
>
> -# Expand $(foo-objs) $(foo-y) by calling $(call suffix-search,foo.o,-objs -y)
> -suffix-search = $(strip $(foreach s, $2, $($(1:.o=$s))))
> +# Expand $(foo-objs) $(foo-y) etc. by replacing their individuals
> +suffix-search = $(strip $(foreach s, $3, $($(1:%$(strip $2)=%$s))))
> +# List composite targets that are constructed by combining other targets
> +multi-search = $(sort $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -), $m)))
> +# List primitive targets that are compiled from source files
> +real-search = $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -), $(call suffix-search, $m, $2, $3), $m))
> +
>  # If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
> -multi-search = $(sort $(foreach m, $1, $(if $(call suffix-search, $m, $2 -), $m)))
> -multi-obj-y := $(call multi-search,$(obj-y),-objs -y)
> -multi-obj-m := $(call multi-search,$(obj-m),-objs -y -m)
> +multi-obj-y := $(call multi-search, $(obj-y), .o, -objs -y)
> +multi-obj-m := $(call multi-search, $(obj-m), .o, -objs -y -m)
>  multi-obj-ym := $(multi-obj-y) $(multi-obj-m)
>
>  # Replace multi-part objects by their individual parts,
>  # including built-in.a from subdirectories
> -real-search = $(foreach m, $1, $(if $(call suffix-search, $m, $2 -), $(call suffix-search, $m, $2), $m))
> -real-obj-y := $(call real-search, $(obj-y),-objs -y)
> -real-obj-m := $(call real-search, $(obj-m),-objs -y -m)
> +real-obj-y := $(call real-search, $(obj-y), .o, -objs -y)
> +real-obj-m := $(call real-search, $(obj-m), .o, -objs -y -m)
>
>  always-y += $(always-m)
>
> --
> 2.27.0
>
diff mbox series

Patch

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 64daf37e874b..88b446ed6532 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -44,19 +44,22 @@  else
 obj-y		:= $(filter-out %/, $(obj-y))
 endif
 
-# Expand $(foo-objs) $(foo-y) by calling $(call suffix-search,foo.o,-objs -y)
-suffix-search = $(strip $(foreach s, $2, $($(1:.o=$s))))
+# Expand $(foo-objs) $(foo-y) etc. by replacing their individuals
+suffix-search = $(strip $(foreach s, $3, $($(1:%$(strip $2)=%$s))))
+# List composite targets that are constructed by combining other targets
+multi-search = $(sort $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -), $m)))
+# List primitive targets that are compiled from source files
+real-search = $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -), $(call suffix-search, $m, $2, $3), $m))
+
 # If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
-multi-search = $(sort $(foreach m, $1, $(if $(call suffix-search, $m, $2 -), $m)))
-multi-obj-y := $(call multi-search,$(obj-y),-objs -y)
-multi-obj-m := $(call multi-search,$(obj-m),-objs -y -m)
+multi-obj-y := $(call multi-search, $(obj-y), .o, -objs -y)
+multi-obj-m := $(call multi-search, $(obj-m), .o, -objs -y -m)
 multi-obj-ym := $(multi-obj-y) $(multi-obj-m)
 
 # Replace multi-part objects by their individual parts,
 # including built-in.a from subdirectories
-real-search = $(foreach m, $1, $(if $(call suffix-search, $m, $2 -), $(call suffix-search, $m, $2), $m))
-real-obj-y := $(call real-search, $(obj-y),-objs -y)
-real-obj-m := $(call real-search, $(obj-m),-objs -y -m)
+real-obj-y := $(call real-search, $(obj-y), .o, -objs -y)
+real-obj-m := $(call real-search, $(obj-m), .o, -objs -y -m)
 
 always-y += $(always-m)