【四】makfile輸出除錯資訊
阿新 • • 發佈:2018-11-10
語法
makefile可以輸出三個級別的除錯資訊,error,warning和info
$(error ...)
$(warning ...)
$(info ...)
例如:
$(info Makefile Start ......)
var= abc
$(info $$var is $(var));
輸出:
Makefile Start ......
$var is abc
其中error、warning、info均為makefile函式。$$表示輸出一個$符號
示例
使用除錯資訊,測試遞迴賦值和直接賦值的區別
$(info Makefile Start ......) #recursively expanded variables var_rev = $(info info: expanded 1)abc123 var2_rev = $(info info: expanded 2)$(var_rev) #simply expanded variables var_sev := $(info info: myvar_1 assign to myvar)myvar_1 var_sev := $(info info: myvar_2 assign to myvar)myvar_2 shell_info := $(shell echo echo_message) all: $(info $$var2_rev is ${var2_rev}) $(info $$var_sev is ${var_sev}) $(info $$var_sev is $(var_sev)) $(info $$shell_info is $(shell_info))
執行make,輸出內容:
Makefile Start ......
info: myvar_1 assign to myvar
info: myvar_2 assign to myvar
info: expanded 2
info: expanded 1
$var2_rev is abc123
$var_sev is myvar_2
$var_sev is myvar_2
$shell_info is echo_message
分析:
- var_sev是直接賦值,所以輸出b,c的兩句除錯資訊
- var2_rev是遞迴賦值會延遲展開,在執行目標all的第一句時中引用${var2_rev},這時展開var2_rev輸出的語句d;
- var2_rev賦值過程中又引用了var_rev,這時展開var_rev輸出語句e。