在makefile中存在一些预定义的变量,它们大体可以分为两类,一类是自动变量,另一类是特殊变量。

自动变量的意义分别如下:

编写如下的makefile程序对自动变量进行测试:

执行make命令,输出结果如下:

小知识:

make中的一些特殊变量如下:

编写makefile进行测试:

执行make all out,输出结果如下:

继续分析如下特殊变量:

编写如下的makefile程序:

执行make,输出结果如下:

makefile中还可以执行函数的调用,例如改写makefile如下:用伪目标first、second、third来实现伪目标test的功能。

执行make test,结果如下:

在实际的大型项目中,makefile程序可能由多个makefile文件构成,$(MAKE) first,$(MAKE) second,$(MAKE) third正是模拟了makefile的调用。
参考如下:
狄泰软件教程与课件
GUN make手册
专业嵌入式软件开发
<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">