From: Lucas De Marchi Date: Wed, 11 Sep 2024 13:51:23 +0000 (-0500) Subject: build: Fix KDIR again X-Git-Tag: v34~371 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=aa9f6d89e7e226abc79978d5e7f69e27501bad45;p=thirdparty%2Fkmod.git build: Fix KDIR again KDIR is not related to the what we configure in kmod's build. It's only used in kmod to locate where the distro's kernel source/headers is, which may be different from what we are configuring the (under development) kmod with. Remove the setting from meson/autotools and figure it out inside the module-playground Makefile what should be used. For advanced use cases, KDIR= can be passed to override the location. For our own tests, which includes testing with a different module_directory, scripts/setup-rootfs.sh will copy the module to the desired location according to the map defined in the script. Fixes: 27ff72732666 ("testsuite: correct the default KDIR") Signed-off-by: Lucas De Marchi Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/125 --- diff --git a/Makefile.am b/Makefile.am index 37026009..6bbe23d0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -178,7 +178,7 @@ EXTRA_DIST += scripts/setup-modules.sh EXTRA_DIST += scripts/setup-rootfs.sh MODULE_PLAYGROUND = testsuite/module-playground -BUILD_MODULES = $(AM_V_GEN) $(top_srcdir)/scripts/setup-modules.sh $(top_srcdir) $(top_builddir) $(MODULE_PLAYGROUND) $(module_directory) +BUILD_MODULES = $(AM_V_GEN) $(top_srcdir)/scripts/setup-modules.sh $(top_srcdir) $(top_builddir) $(MODULE_PLAYGROUND) ROOTFS = testsuite/rootfs ROOTFS_PRISTINE = $(top_srcdir)/testsuite/rootfs-pristine CREATE_ROOTFS = $(AM_V_GEN) $(top_srcdir)/scripts/setup-rootfs.sh $(ROOTFS_PRISTINE) $(ROOTFS) $(MODULE_PLAYGROUND) $(top_builddir)/config.h $(sysconfdir) $(module_directory) diff --git a/scripts/setup-modules.sh b/scripts/setup-modules.sh index f3c8a7c3..89f34d9c 100755 --- a/scripts/setup-modules.sh +++ b/scripts/setup-modules.sh @@ -5,8 +5,6 @@ set -euo pipefail SRCDIR=$1 BUILDDIR=$2 MODULE_PLAYGROUND=$3 -# shellcheck disable=SC2034 # used by the Makefile -export MODULE_DIRECTORY=$4 # TODO: meson allows only out of tree builds if test "$SRCDIR" != "$BUILDDIR"; then diff --git a/testsuite/meson.build b/testsuite/meson.build index 9b69f345..643c259b 100644 --- a/testsuite/meson.build +++ b/testsuite/meson.build @@ -9,7 +9,6 @@ build_module_playground = custom_target( meson.project_source_root(), meson.project_build_root(), 'testsuite/module-playground', # do not prepend source/build root - moduledir, ], output : 'bb-rootfs', console : true, diff --git a/testsuite/module-playground/Makefile b/testsuite/module-playground/Makefile index b9d9e1f4..191f7458 100644 --- a/testsuite/module-playground/Makefile +++ b/testsuite/module-playground/Makefile @@ -1,4 +1,15 @@ -KDIR ?= $(MODULE_DIRECTORY)/$$(uname -r)/build +# When KDIR is not manually set, use the MODULE_DIRECTORY for the pre-existent +# kmod, not the one being built, to figure out how to get to the kernel +# sources/headers for building our own dummy kernel modules. The final +# location of the modules may change later by scripts/setup-rootfs.sh that +# assembles a per-test-rootfs. +ifndef KDIR + MODULE_DIRECTORY := $(shell pkg-config --variable module_directory kmod) + ifeq ($(MODULE_DIRECTORY),) + MODULE_DIRECTORY := /lib/modules + endif + KDIR := $(MODULE_DIRECTORY)/$$(uname -r)/build +endif ARCH_SPECIFIC_MODULES := mod-simple-x86_64.ko mod-simple-i386.ko mod-simple-sparc64.ko