makefile可以写得很复杂,也可以很简单
1. 最简单的,只需要一句:
[root@localhost hello]# cat Makefile
obj-m := hello.o
编译时执行:
make -C /usr/src/linux-2.6.15.5 M=$(pwd) modules
2. 也可以稍微复杂点:
[root@localhost hello]# cat Makefile
KERNELDIR ?= /lib/modules/2.6.18-92.el5xen/build/ //链接库目录
PWD := $(shell pwd) //当前目录
obj-m := hello.o
//target,生成hello.ko
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules // 执行的语句
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules // 执行的语句