驱动Makefile
test-objs := *.o //需要编译的.c文件
hello-objs := *.o
obj-m := test.o hello.o
KERNEL_DIR := /usr/local/$(shell uname -r)/build
all:
make -C $(KERNEL_DIR) M=$(shell pwd) modules
make -C $(KERNEL_DIR) SUBDIRS=$(PWD) modules
clean:
make -C $(KERNEL_DIR) M=$(PWD) clean
rm *.o *.ko *.mod.c
.PHONY:clean
uname -r会得到正在使用的完整内核版本号
make -C会进入KERNEL_DIR目录执行此目录下的Makefile