kbuild: fix single target build for external module
authorIlias Apalodimas <ilias.apalodimas@linaro.org>
Wed, 11 Jun 2025 20:24:40 +0000 (23:24 +0300)
committerTom Rini <trini@konsulko.com>
Wed, 11 Jun 2025 22:21:36 +0000 (16:21 -0600)
Backported from kernel
commit e07db28eea38 ("kbuild: fix single target build for external module")

It's worth noting that crmodverdir is empty for U-Boot.
Just backport it to make diffing easier

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Makefile

index af8129c..a9cba5b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -230,6 +230,9 @@ ifeq ($(KBUILD_EXTMOD),)
 _all: all
 else
 _all: modules
+PHONY += prepare
+prepare:
+       $(cmd_crmodverdir)
 endif
 
 ifeq ($(KBUILD_SRC),)
@@ -2503,15 +2506,12 @@ endif
 
 # Modules
 /: prepare FORCE
-       $(cmd_crmodverdir)
        $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
        $(build)=$(build-dir)
 %/: prepare FORCE
-       $(cmd_crmodverdir)
        $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
        $(build)=$(build-dir)
 %.ko: prepare FORCE
-       $(cmd_crmodverdir)
        $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1)   \
        $(build)=$(build-dir) $(@:.ko=.o)
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost