Hello World 的makefile模板及其分析

makefile模板:

ifeq ($(KERNELRELEASE),)   //判断KERNELRELEASE是否为空,只有执行make的当前目录为内核源代码目录时,该变量才不为空。

KERNELDIR ?=/linux-2.6.29.4/linux-2.6.29.4

PWD := $(shell pwd)

modules:
     $(MAKE) -C $(KERNELDIR) M=$(PWD) modules  //make -C 内核路径 M=模块路径 modules

modules_install:
     $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install

clean:
     rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions *.order Module*

.PHONY: modules modules_install clean

else
    obj-m := hello.o
endif

 

makefile文件的执行过程如下:

posted on 2013-10-11 20:00  熊猫酒仙是也  阅读(269)  评论(0编辑  收藏  举报

导航