多个C源文件编译成一个内核模块之makefile模板

Sometimes it makes sense to divide a kernel module between several source files. Lets say you have 2 source files :
start.c and stop.c
you can create a Makefile like this :

obj-m += startstop.o
startstop-objs := start.o stop.o

all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

posted on 2017-07-24 15:49  echo5  阅读(225)  评论(0编辑  收藏  举报