常用 ################ 命令:: make [ -f makefile ] [ options ] ... [ targets ] ... 指定Makefile文件:: $ make -f rules.txt # 或者 $ make --file=rules.txt Makefile文件默认顺序:: 1. GNUmakefile 2. makefile 3. Makefile 常用options参数:: // 在读取makefile前先切换路径 -C dir, --directory=dir Special Built-in Target Names:: // 当执行make 时,如找不到就执行它 .DEFAULT // 可以设定指定目标为伪目标 .PHONY // 当前makefile内支持文件后缀的类型列表 .SUFFIXES 例: .SUFFIXES: # 删除缺省的后缀列表 .SUFFIXES: .cpp .obj #把.cpp和.obj添加到后缀列表中 // 导出所有的Makefile中的变量(即:有多少变量就执行多少次export xxxx) .EXPORT_ALL_VARIABLES 打印&调试 ========= 1. 使用info/warning/error增加调试信息:: 方法1: $(info, "here add the debug info") 但是此不能打印出.mk的行号 方法2: $(warning, "here add the debug info") 方法3: $(error "error: this will stop the compile") 这个可以停止当前makefile的编译 方法4: 打印变量的值 $(info, $(TARGET_DEVICE) ) 2. 使用echo增加调试信息(echo只能在target:后面的语句中使用,且前面是个TAB):: 方法1: @echo "start the compilexxxxxxxxxxxxxxxxxxxxxxx" 方法2: @echo $(files) 参考 ==== * Make 命令教程: http://www.ruanyifeng.com/blog/2015/02/make.html * 【极客时间】最常用的 Makefile 核心语法: https://time.geekbang.org/column/article/389115 * GNU make: https://www.gnu.org/software/make/manual/html_node/index.html * [书]Learn Makefiles: https://makefiletutorial.com/