makefile -- part 1
1. 变量的定义
a = "hello" // 前面变量可以使用后面变量,有死锁问题
a := "hello" // 前面变量不能使用后面变量
a ?= "hello" // 如果a没有被赋值过,则a 赋值为hello
b+= test1
b+= test2 // 连续b追加赋值多次,结合$@ 或者$< 使用
a = hello
b += "a"
b += "a"
b += "a"
b += "a".PHONY : all all:echo $(a)echo $(b)@echo "---------------------"@echo $(a)@echo $(b)rm -r fff.txt-rm -r aaa.txt
执行语句前使用 " @ " 不打印语句本身输出
执行语句前使用 " - " 语句执行失败不报错
2. 条件判断
ifdef
ifndef
ifeq
ifneq
.PHONY : all ifeq ($(a),hello)rst_eq = "pass"
elserst_eq = "fail"
endifname ?= ryzifdef name rst_def = "pass"
elserst_def = "fail"
endififneq ($(a),hello)rst_neq=pass
else rst_neq=fail
endififndef name rst_ndef = "pass"
elserst_ndef = "fail"
endifall:@echo $(rst_eq)@echo $(rst_neq)@echo $(rst_def)@echo $(rst_ndef)
3. 函数
一般语法
function是函数名称,argument 是函数参数,多个参数使用" , "分隔。
$( <fnction> <arguments> )
${ <fnction> <arguments> }
subst
$(subst <from?,<to>,<text>)
名称: 字符串替换函数;
功能: 将字符串 <te