Support compiling the module against a different kernel version than the currently running one by allowing to set either KVER or KDIR variables on the make commandline. Also modernize the makefile slightly and make use of the kernel's 'clean' target to ensure to remove all generated files. Signed-off-by: Mathias Krause <minipli@xxxxxxxxxxxxxx> --- v2: - test kernel build directory existence first to avoid generating spurious error messages memory_driver/Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/memory_driver/Makefile b/memory_driver/Makefile index b494aa3cd184..269a41cfc2ae 100644 --- a/memory_driver/Makefile +++ b/memory_driver/Makefile @@ -8,8 +8,13 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # +ifneq ($(KERNELRELEASE),) obj-m := crash.o +else +KVER ?= $(shell uname -r) +KDIR ?= /lib/modules/${KVER}/build all: - make -C /lib/modules/`uname -r`/build M=${PWD} SUBDIRS=${PWD} modules + ${MAKE} -C ${KDIR} M=${PWD} SUBDIRS=${PWD} modules clean: - rm -f *.mod.c *.ko *.o Module.* + test -e ${KDIR}/Makefile && ${MAKE} -C ${KDIR} M=${PWD} SUBDIRS=${PWD} clean || ${RM} *.mod.c *.ko *.o Module.* +endif -- 2.30.2 -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/crash-utility Contribution Guidelines: https://github.com/crash-utility/crash/wiki