linux 内核模块makefile通用模板

ifneq ($(KERNELRELEASE),)
# 在 mylist 后面添加需要编译的模块数量 mylist
=hello.o a.o
# 为每一个模块添加所需的文件 hello
-objs := main.o a.o b.o
a-objs:= a.o
obj
-m:=$(mylist) else #generate the path CURRENT_PATH:=$(shell pwd) #the absolute path LINUX_KERNEL_PATH:=/lib/modules/$(shell uname -r)/build #complie object default: make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules clean: make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) clean endif
原文地址:https://www.cnblogs.com/schips/p/10584760.html