* [PATCH] kbuild: Add $(strip ...) before compare make variable with string
@ 2020-04-25 6:07 Wang Nan
2020-04-25 11:33 ` Masahiro Yamada
0 siblings, 1 reply; 2+ messages in thread
From: Wang Nan @ 2020-04-25 6:07 UTC (permalink / raw)
To: wangnan0, Masahiro Yamada, Michal Marek
Cc: linux-kbuild, linux-kernel, Wang Nan
Some of ifneq in Makefile.build works improperly:
ifneq ($(a)$(b)$(c),)
...
endif
Because some make vairable contains unintended spaces introduced by:
a := $(x) $(y)
This commit adds $(strip ...) to some potentially buggy ifneq.
Signed-off-by: Wang Nan <pi3orama@163.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Michal Marek <michal.lkml@markovi.net>
---
scripts/Makefile.build | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 9fcbfac..b2bc0db 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -46,7 +46,7 @@ include $(kbuild-file)
include scripts/Makefile.lib
# Do not include host rules unless needed
-ifneq ($(hostprogs)$(hostcxxlibs-y)$(hostcxxlibs-m),)
+ifneq ($(strip $(hostprogs) $(hostcxxlibs-y) $(hostcxxlibs-m)),)
include scripts/Makefile.host
endif
@@ -55,7 +55,7 @@ $(warning kbuild: Makefile.build is included improperly)
endif
ifeq ($(need-modorder),)
-ifneq ($(obj-m),)
+ifneq ($(strip $(obj-m)),)
$(warning $(patsubst %.o,'%.ko',$(obj-m)) will not be built even though obj-m is specified.)
$(warning You cannot use subdir-y/m to visit a module Makefile. Use obj-y/m instead.)
endif
@@ -512,7 +512,7 @@ obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets))))
# If targets exist, their directories apparently exist. Skip mkdir.
existing-dirs := $(sort $(patsubst %/,%, $(dir $(existing-targets))))
obj-dirs := $(strip $(filter-out $(existing-dirs), $(obj-dirs)))
-ifneq ($(obj-dirs),)
+ifneq ($(strip $(obj-dirs)),)
$(shell mkdir -p $(obj-dirs))
endif
endif
--
2.7.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] kbuild: Add $(strip ...) before compare make variable with string
2020-04-25 6:07 [PATCH] kbuild: Add $(strip ...) before compare make variable with string Wang Nan
@ 2020-04-25 11:33 ` Masahiro Yamada
0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2020-04-25 11:33 UTC (permalink / raw)
To: Wang Nan
Cc: Wang Nan, Michal Marek, Linux Kbuild mailing list,
Linux Kernel Mailing List
On Sat, Apr 25, 2020 at 3:09 PM Wang Nan <pi3orama@163.com> wrote:
>
> Some of ifneq in Makefile.build works improperly:
>
> ifneq ($(a)$(b)$(c),)
> ...
> endif
>
> Because some make vairable contains unintended spaces introduced by:
>
> a := $(x) $(y)
Right.
I made a mistake in commit 5f2fb52fac15a
$(hostprogs) always contains a space due to this line:
hostprogs += $(hostprogs-y) $(hostprogs-m)
This line will go away soon, though.
>
> This commit adds $(strip ...) to some potentially buggy ifneq.
>
> Signed-off-by: Wang Nan <pi3orama@163.com>
> Cc: Masahiro Yamada <masahiroy@kernel.org>
> Cc: Michal Marek <michal.lkml@markovi.net>
> ---
> scripts/Makefile.build | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 9fcbfac..b2bc0db 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -46,7 +46,7 @@ include $(kbuild-file)
> include scripts/Makefile.lib
>
> # Do not include host rules unless needed
> -ifneq ($(hostprogs)$(hostcxxlibs-y)$(hostcxxlibs-m),)
> +ifneq ($(strip $(hostprogs) $(hostcxxlibs-y) $(hostcxxlibs-m)),)
Only this one is correct.
> include scripts/Makefile.host
> endif
>
> @@ -55,7 +55,7 @@ $(warning kbuild: Makefile.build is included improperly)
> endif
>
> ifeq ($(need-modorder),)
> -ifneq ($(obj-m),)
> +ifneq ($(strip $(obj-m)),)
obj-m := $(addprefix $(obj)/,$(obj-m))
has always stripped away spaces.
> $(warning $(patsubst %.o,'%.ko',$(obj-m)) will not be built even though obj-m is specified.)
> $(warning You cannot use subdir-y/m to visit a module Makefile. Use obj-y/m instead.)
> endif
> @@ -512,7 +512,7 @@ obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets))))
> # If targets exist, their directories apparently exist. Skip mkdir.
> existing-dirs := $(sort $(patsubst %/,%, $(dir $(existing-targets))))
> obj-dirs := $(strip $(filter-out $(existing-dirs), $(obj-dirs)))
> -ifneq ($(obj-dirs),)
The previous line has $(strip )
> +ifneq ($(strip $(obj-dirs)),)
> $(shell mkdir -p $(obj-dirs))
> endif
> endif
> --
> 2.7.4
>
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-25 11:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-25 6:07 [PATCH] kbuild: Add $(strip ...) before compare make variable with string Wang Nan
2020-04-25 11:33 ` Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®