diff mbox series

[3/4] kbuild: error out if $(KBUILD_EXTMOD) contains % or :

Message ID 20220714050243.16411-3-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series [1/4] kbuild: rpm-pkg: fix build error when _arch is undefined | expand

Commit Message

Masahiro Yamada July 14, 2022, 5:02 a.m. UTC
If the directory pass given to KBUILD_EXTMOD (or M=) contains % or :,
the module fails to build.

% is used in pattern rules, and : as the separator of dependencies.

Bail out with a clearer error message.

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

 Makefile | 3 +++
 1 file changed, 3 insertions(+)

Comments

Nicolas Schier July 15, 2022, 9:17 a.m. UTC | #1
On Thu, Jul 14, 2022 at 02:02:42PM +0900, Masahiro Yamada wrote:
> If the directory pass given to KBUILD_EXTMOD (or M=) contains % or :,
> the module fails to build.
> 
> % is used in pattern rules, and : as the separator of dependencies.
> 
> Bail out with a clearer error message.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---

Reviewed-by: Nicolas Schier <n.schier@avm.de>
Masahiro Yamada July 16, 2022, 3:38 p.m. UTC | #2
On Thu, Jul 14, 2022 at 2:03 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> If the directory pass given to KBUILD_EXTMOD (or M=) contains % or :,

This is a typo.

directory pass -> directory path




> the module fails to build.
>
> % is used in pattern rules, and : as the separator of dependencies.
>
> Bail out with a clearer error message.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
>  Makefile | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index faa4880f25f7..ecda62e27553 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -129,6 +129,9 @@ endif
>  $(if $(word 2, $(KBUILD_EXTMOD)), \
>         $(error building multiple external modules is not supported))
>
> +$(foreach x, % :, $(if $(findstring $x, $(KBUILD_EXTMOD)), \
> +       $(error module directory path cannot contain '$x')))
> +
>  # Remove trailing slashes
>  ifneq ($(filter %/, $(KBUILD_EXTMOD)),)
>  KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).)
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index faa4880f25f7..ecda62e27553 100644
--- a/Makefile
+++ b/Makefile
@@ -129,6 +129,9 @@  endif
 $(if $(word 2, $(KBUILD_EXTMOD)), \
 	$(error building multiple external modules is not supported))
 
+$(foreach x, % :, $(if $(findstring $x, $(KBUILD_EXTMOD)), \
+	$(error module directory path cannot contain '$x')))
+
 # Remove trailing slashes
 ifneq ($(filter %/, $(KBUILD_EXTMOD)),)
 KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).)