linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] kbuild: remove trailing slashes from $(KBUILD_EXTMOD)
@ 2021-06-02 14:02 Masahiro Yamada
  2021-06-17  1:37 ` Masahiro Yamada
  0 siblings, 1 reply; 2+ messages in thread
From: Masahiro Yamada @ 2021-06-02 14:02 UTC (permalink / raw)
  To: linux-kbuild; +Cc: linux-kernel, Johannes Berg, Masahiro Yamada, Michal Marek

M= (or KBUILD_EXTMOD) generally expects a directory path without any
trailing slashes, like M=a/b/c.

If you add a trailing slash, like M=a/b/c/, you will get ugly build
logs (two slashes in a series), but it still works fine as long as it
is consistent between 'make modules' and 'make modules_install'.

The following commands correctly build and install the modules.

  $ make M=a/b/c/ modules
  $ sudo make M=a/b/c/ modules_install

Since commit ccae4cfa7bfb ("kbuild: refactor scripts/Makefile.modinst"),
a problem happens if you add a trailing slash only for modules_install.

  $ make M=a/b/c modules
  $ sudo make M=a/b/c/ modules_install

No module is installed in this case, Johannes Berg reported. [1]

Trim any trailing slashes from $(KBUILD_EXTMOD).

I used the 'dirname' command to remove all the trailing slashes in
case someone adds more slashes like M=a/b/c/////. The Make's built-in
function, $(dir ...) cannot take care of such a case.

[1]: https://lore.kernel.org/lkml/10cc8522b27a051e6a9c3e158a4c4b6414fd04a0.camel@sipsolutions.net/

Fixes: ccae4cfa7bfb ("kbuild: refactor scripts/Makefile.modinst")
Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

Changes in v2:
  - Use $(filter %/, ) so that the shell invocation is avoided
    if M= is already good.

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

diff --git a/Makefile b/Makefile
index b79e0e8acbe3..8018b8adbcaf 100644
--- a/Makefile
+++ b/Makefile
@@ -129,6 +129,11 @@ endif
 $(if $(word 2, $(KBUILD_EXTMOD)), \
 	$(error building multiple external modules is not supported))
 
+# Remove trailing slashes
+ifneq ($(filter %/, $(KBUILD_EXTMOD)),)
+KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).)
+endif
+
 export KBUILD_EXTMOD
 
 # Kbuild will save output files in the current working directory.
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] kbuild: remove trailing slashes from $(KBUILD_EXTMOD)
  2021-06-02 14:02 [PATCH v2] kbuild: remove trailing slashes from $(KBUILD_EXTMOD) Masahiro Yamada
@ 2021-06-17  1:37 ` Masahiro Yamada
  0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2021-06-17  1:37 UTC (permalink / raw)
  To: Linux Kbuild mailing list
  Cc: Linux Kernel Mailing List, Johannes Berg, Michal Marek

On Wed, Jun 2, 2021 at 11:02 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> M= (or KBUILD_EXTMOD) generally expects a directory path without any
> trailing slashes, like M=a/b/c.
>
> If you add a trailing slash, like M=a/b/c/, you will get ugly build
> logs (two slashes in a series), but it still works fine as long as it
> is consistent between 'make modules' and 'make modules_install'.
>
> The following commands correctly build and install the modules.
>
>   $ make M=a/b/c/ modules
>   $ sudo make M=a/b/c/ modules_install
>
> Since commit ccae4cfa7bfb ("kbuild: refactor scripts/Makefile.modinst"),
> a problem happens if you add a trailing slash only for modules_install.
>
>   $ make M=a/b/c modules
>   $ sudo make M=a/b/c/ modules_install
>
> No module is installed in this case, Johannes Berg reported. [1]
>
> Trim any trailing slashes from $(KBUILD_EXTMOD).
>
> I used the 'dirname' command to remove all the trailing slashes in
> case someone adds more slashes like M=a/b/c/////. The Make's built-in
> function, $(dir ...) cannot take care of such a case.
>
> [1]: https://lore.kernel.org/lkml/10cc8522b27a051e6a9c3e158a4c4b6414fd04a0.camel@sipsolutions.net/
>
> Fixes: ccae4cfa7bfb ("kbuild: refactor scripts/Makefile.modinst")
> Reported-by: Johannes Berg <johannes@sipsolutions.net>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---

Applied to linux-kbuild.



> Changes in v2:
>   - Use $(filter %/, ) so that the shell invocation is avoided
>     if M= is already good.
>
>  Makefile | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index b79e0e8acbe3..8018b8adbcaf 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -129,6 +129,11 @@ endif
>  $(if $(word 2, $(KBUILD_EXTMOD)), \
>         $(error building multiple external modules is not supported))
>
> +# Remove trailing slashes
> +ifneq ($(filter %/, $(KBUILD_EXTMOD)),)
> +KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).)
> +endif
> +
>  export KBUILD_EXTMOD
>
>  # Kbuild will save output files in the current working directory.
> --
> 2.27.0
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-17  1:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 14:02 [PATCH v2] kbuild: remove trailing slashes from $(KBUILD_EXTMOD) Masahiro Yamada
2021-06-17  1:37 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).