kbuild: fix single target build for external module

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>
This commit is contained in:
Ilias Apalodimas 2025-06-11 23:24:40 +03:00 committed by Tom Rini
parent 45acf56e59
commit 070b81458a

View File

@ -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