ifneq ($(KERNELRELEASE),)
obj-m := CharDevM.o
CharDevM-objs = CharDev.o CDBuffer.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
clean:
rm -rf *.o *~core .depend .* .cmd *.ko *.mod.c .rmp_versions
以上Makefile将工作目录下CharDve.c和CDBuffer.c编译为CharDve.和CDBuffer.o后,再合并为CharDevM.o文件,最后生成CharDevM.ko。