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文件的执行过程如下:

Hello World 的makefile模板及其分析

相关文章:

  • 2021-08-22
  • 2021-11-11
  • 2022-02-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-12-24
猜你喜欢
  • 2022-01-26
  • 2022-01-27
  • 2022-01-24
  • 2021-10-24
  • 2022-12-23
  • 2021-08-20
  • 2022-02-21
相关资源
相似解决方案