mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-25 11:11:35 +01:00
0
This commit is contained in:
33
host/Makefile
Normal file
33
host/Makefile
Normal file
@@ -0,0 +1,33 @@
|
||||
OUT_EXT := .ko
|
||||
OBJ_EXT := .o
|
||||
RUN := hello
|
||||
RUN_EXT := $(RUN)$(OUT_EXT)
|
||||
|
||||
obj-m += hello.o
|
||||
ccflags-y := -Wno-declaration-after-statement -std=gnu99
|
||||
|
||||
.PHONY: clean ins log rm run my-ins
|
||||
|
||||
all: $(RUN_EXT) ins_rm_mod.out
|
||||
|
||||
hello.ko: hello.c
|
||||
make -C /lib/modules/$(shell uname -r)/build M="$(PWD)" modules
|
||||
|
||||
clean:
|
||||
make -C /lib/modules/$(shell uname -r)/build M="$(PWD)" clean
|
||||
rm -f *.out
|
||||
|
||||
ins: all
|
||||
sudo insmod '$(RUN_EXT)'
|
||||
|
||||
log:
|
||||
dmesg
|
||||
|
||||
rm:
|
||||
if lsmod | grep -Eq '^$(RUN) '; then sudo rmmod '$(RUN_EXT)'; fi
|
||||
|
||||
ins_rm_mod.out: ins_rm_mod.c
|
||||
gcc -Wall -std=gnu99 -o '$@' '$<'
|
||||
|
||||
ins_rm_run: ins_rm_mod.out $(RUN_EXT)
|
||||
sudo ./ins_rm_mod.out
|
||||
Reference in New Issue
Block a user