23 lines
482 B
Makefile
23 lines
482 B
Makefile
BINARY := kl_char_driver
|
|
KERNEL := /lib/modules/$(shell uname -r)/build
|
|
KMOD_DIR := $(shell pwd)
|
|
|
|
ccflags-y += -Wall
|
|
obj-m += $(BINARY).o
|
|
$(BINARY)-y := main.o
|
|
|
|
$(BINARY).ko: main.c
|
|
make -C $(KERNEL) M=$(KMOD_DIR) modules
|
|
|
|
showlog:
|
|
tail -n10 /var/log/messages
|
|
enable: $(BINARY).ko
|
|
-insmod $(BINARY).ko
|
|
disable:
|
|
-rmmod $(BINARY)
|
|
check: disable enable
|
|
echo wolf228 > /dev/kl_char_dev-0 && head -1 /dev/kl_char_dev-0 && make showlog
|
|
|
|
clean:
|
|
make -C $(KERNEL) M=$(KMOD_DIR) clean
|