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

 

posted @ 2019-03-23 17:29  schips  阅读(643)  评论(0编辑  收藏  举报