meson setup --native-file build-dev.ini builddir/
+The testsuite can be executed with:
+
+ meson test -C builddir
+
+It builds test kernel modules, so kernel headers need to be pre-installed. By
+default it tries to use the kernel header for the currently running kernel.
+`KDIR=any` environment variable can be used to tell it to use any installed
+kernel header or `KDIR=/path/to/specific/headers` when a specific one is
+needed. Example:
+
+ KDIR=any meson test -C builddir
+
Make sure to read [our contributing guide](CONTRIBUTING.md) and the other
READMEs: [libkmod](libkmod/README) and [testsuite](testsuite/README).
# 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.
+# sources/headers of the currently running kernel 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.
+#
+# KDIR=any can also be used to use any installed headers, not necessarily the
+# currently running one. This makes it easier to handle distros that
+# install modules in a different dir even for minor updates.
+
+MODULE_DIRECTORY := $(shell pkg-config --variable module_directory kmod)
+ifeq ($(MODULE_DIRECTORY),)
+ MODULE_DIRECTORY := /lib/modules
+endif
+
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
+else ifeq ($(KDIR),any)
+ KDIR := $(shell find $(MODULE_DIRECTORY) -maxdepth 1 -mindepth 1 -type d | sort -V | tail -n1)/build
endif
ARCH_SPECIFIC_MODULES := mod-simple-x86_64.ko mod-simple-i386.ko mod-simple-sparc64.ko