kbuild: remove trailing slashes from $(KBUILD_EXTMOD)
PATCH v2 1/1 kbuild: remove trailing slashes from $(KBUILD_EXTMOD)
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/[email protected]/
---
Changes in v2:
- Use $(filter %/, ) so that the shell invocation is avoided if M= is already good.
Makefile | 5 +++++ 1 file changed, 5 insertions(+)
Makefile +5 -0
@@ -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.
Signature · 1 line
2.27.0
Quoted 27 lines · Masahiro Yamada
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_installSince commit
ccae4cfa7bfb("kbuild: refactorscripts/Makefile.modinst"), a problem happens if you add a trailing slash only formodules_install.$ make M=a/b/c modules $ sudo make M=a/b/c/ modules_installNo 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.
Quoted 6 lines
[1]: https://lore.kernel.org/lkml/[email protected]/
Fixes ccae4cfa7bfb ("kbuild: refactor scripts/Makefile.modinst")Reported-by Johannes Berg <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>---
Applied to linux-kbuild.
Quoted 26 lines
Changes in v2:
- Use $(filter %/, ) so that the shell invocation is avoided if M= is already good.Makefile | 5 +++++ 1 file changed, 5 insertions(+)Makefile +5
-1@@ -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
Signature · 2 lines
Best Regards Masahiro Yamada