Makefile为
PWD = $(shell pwd)
KERNEL_SRC =/usr/src/linux-3.0/
obj-m :=test.o
module-objs : =test.o
all:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules
clean:
rm *.ko
rm *.o
运行make看到类似的输出
make[1]:Entering directory /usr/src/linux-3.0
CC [M] /home/vmeth/hello.o
Building modules,stage 2.
MDPOST
CC /home/vmeth/hello.mod.o
LD [M] /home/vmeth/hello.ko
make[1]:Leaving directory /usr/src/linux-3.0
make - C $(KERNEL_SRC)指定跳转到内核源目录下读取那里的Makefile:M=$(PWD)表明然后返回到当前目录继续读入,执行当前的Makefile.