Skip to content

Commit

Permalink
memory_driver: Support overriding kernel directory
Browse files Browse the repository at this point in the history
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@grsecurity.net>
  • Loading branch information
minipli-oss authored and k-hagio committed Oct 10, 2023
1 parent 1cfd513 commit 578fc08
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions memory_driver/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
ifneq ($(KERNELRELEASE),)
obj-m := crash.o
else
PWD := $(shell pwd)
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

0 comments on commit 578fc08

Please sign in to comment.