它們都是有效的,你可以通過將它們放入Makefile並運行它來告訴它們。如果你想知道什麼樣的價值觀,他們居然拿,你可以嘗試
$(info $(AAA))
(需要注意的是,真正的問題是,在BBB_NAME
的(c)
,如果你傳遞到其他功能也可能會出現問題。)
一個棘手的部分是=
和:=
(和其他賦值運算符)之間的差異。全部細節在the manual中,但基本上:=
一次評估右側,而=
一直持續下去,直到評估左側爲止。考慮
CCC = value
DDD := Some other $(CCC) xxx
EEE = Some other $(CCC) xxx
的DDD
的值現在爲Some other value xxx
,而EEE的值是Some other $(CCC) xxx
。如果你的地方使用它們:
$(info $(DDD))
$(info $(EEE))
製作擴展$(DDD)
和$(EEE)
以同樣的事情,你看
Some other value xxx
Some other value xxx
但也有不同之處:
CCC = value
DDD := Some other $(CCC) xxx
EEE = Some other $(CCC) xxx
DDD := $(DDD) and yyy # This is perfectly legal.
EEE := $(EEE) and yyy # Infinite recursion. Make will not allow this.
CCC = dimension
$(info $(DDD)) # Produces "Some other value xxx and yyy"
$(info $(EEE)) # Produces "Some other dimension xxx"
它更準確的使用$ (value ...)函數,如'$(info $(value AAA))'。這將顯示'AAA'變量的內容,而不是先嚐試擴展它。使用類似'$(AAA)'的引用將在顯示值之前展開該值。 – MadScientist