Skip to contentSkip to conversation

Makefile: Add make 'modules' target

PATCH New Petr Vorel 1 participant 1 message Aug 1, 2025 Kbuild

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 Makefile: Add make 'modules' target

LTP contains few kernel modules and tests which are using them. These require to be built with the same kernel headers as the running kernel (SUT). Sometimes the best way to achieve this is to compile them on the SUT. Add make 'modules' target to make it easier to build them.

---
Hi all,

We build these modules in openQA during testing. Hope you don't mind to keep the list of directories with kernel modules in LTP (instead of maintaining it outside). And hopefully it helps others which might face the same problem.

I tempted to add also 'make install' to the target to shortcut 'make modules && make modules install' to just 'make modules', but that would not be a clean and consistent approach.

Kind regards,
Petr

 INSTALL  |  8 ++++++++
 Makefile | 14 ++++++++++++++
 2 files changed, 22 insertions(+)
INSTALL +8 -0
index cbe27f32ea..a7d48a45b3 100644
@@ -165,6 +165,14 @@ PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig CFLAGS=-m32 LDFLAGS=-m32 ./c
 * Arch Linux
 PKG_CONFIG_LIBDIR=/usr/lib32/pkgconfig CFLAGS=-m32 LDFLAGS=-m32 ./configure
 
+Kernel modules
+--------------
+
+LTP contains few kernel modules and tests which are using them.
+These require to be built with the same kernel headers as the running kernel (SUT).
+Sometimes the best way to achieve this is to compile them on the SUT.
+'make modules' target is a shortcut to build these kernel modules and tests.
+
 Android Users
 -------------
 
Makefile +14 -0
index eab40da8a6..9042bdc945 100644
@@ -212,6 +212,20 @@ endif
 test-metadata: metadata-all
 	$(MAKE) -C $(abs_srcdir)/metadata test
 
+MODULE_DIRS := commands/insmod \
+	testcases/kernel/firmware \
+	testcases/kernel/device-drivers \
+	testcases/kernel/syscalls/delete_module \
+	testcases/kernel/syscalls/finit_module \
+	testcases/kernel/syscalls/init_module
+
+.PHONY: modules
+modules:
+	@$(foreach dir,$(MODULE_DIRS),\
+		echo "Build $(dir)";\
+		$(MAKE) -C $(abs_srcdir)/$(dir); \
+)
+
 ## Help
 .PHONY: help
 help:
Signature · 5 lines
2.50.1


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