Skip to content

Commit 74ee585

Browse files
committed
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 ccae4cf ("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]/ Fixes: ccae4cf ("kbuild: refactor scripts/Makefile.modinst") Reported-by: Johannes Berg <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent c7c90e1 commit 74ee585

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ endif
129129
$(if $(word 2, $(KBUILD_EXTMOD)), \
130130
$(error building multiple external modules is not supported))
131131

132+
# Remove trailing slashes
133+
ifneq ($(filter %/, $(KBUILD_EXTMOD)),)
134+
KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).)
135+
endif
136+
132137
export KBUILD_EXTMOD
133138

134139
# Kbuild will save output files in the current working directory.

0 commit comments

Comments
 (0)