Skip to contentSkip to conversation

Makefile: Fix module dirs search

PATCH In review Martin Doucha 2 participants 2 messages Aug 20, 2025 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Makefile: Fix module dirs search

Module dirs search runs relative to current working directory instead of the source directory. In an out-of-tree build, the search for makefiles will come up empty and grep will try to read from standard input, blocking indefinitely. Search for makefiles relative to the source directory to fix the issue.

Fixes e3e1fa0e78 ("Makefile: Add kernel modules related make targets")

---

Changes since v1: Removed $(abs_srcdir) from module targets because now it's already included in $(dir)

 Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Makefile +4 -4
index 77270bc7c..d47b2528e 100644
@@ -213,24 +213,24 @@ test-metadata: metadata-all
 	$(MAKE) -C $(abs_srcdir)/metadata test
 
 MODULE_DIRS :=  $(shell \
-	dirname $$(grep -l 'include.*module\.mk' $$(find testcases/ -type f -name 'Makefile')))
+	dirname $$(grep -l 'include.*module\.mk' $$(find $(abs_srcdir)/testcases/ -type f -name 'Makefile')))
 
 
 .PHONY: modules modules-clean modules-install
 modules:
 	@$(foreach dir,$(MODULE_DIRS),\
 		echo "Build $(dir)";\
-		$(MAKE) -C $(abs_srcdir)/$(dir) || exit $$?; \
+		$(MAKE) -C $(dir) || exit $$?; \
 )
 modules-clean:
 	@$(foreach dir,$(MODULE_DIRS),\
 		echo "Build $(dir)";\
-		$(MAKE) -C $(abs_srcdir)/$(dir) clean || exit $$?; \
+		$(MAKE) -C $(dir) clean || exit $$?; \
 )
 modules-install: modules
 	@$(foreach dir,$(MODULE_DIRS),\
 		echo "Build $(dir)";\
-		$(MAKE) -C $(abs_srcdir)/$(dir) install || exit $$?; \
+		$(MAKE) -C $(dir) install || exit $$?; \
 )
 
 ## Help
Signature · 5 lines
2.50.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Martin Doucha <[email protected]> wrote:

Module dirs search runs relative to current working directory instead

Quoted 5 lines

of the source directory. In an out-of-tree build, the search for makefiles will come up empty and grep will try to read from standard input, blocking indefinitely. Search for makefiles relative to the source directory to fix the issue.

Patch merged, thanks for the fix!

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp