0
我有一個包含另一個makefile的Makefile,比如CommonMakefile。有一個變量,我想用一個值作爲前綴(參見附加使用+=
)保持值的其餘值不變。如何爲gmake變量加上前綴
V = value1 # set in CommonMakefile that is included
V = value0 $(V) # I want to prefix value0 to V
# rule defined in CommonMakefile that is included
whatsV:
echo $V # first char is a <TAB> here
我該怎麼做?
期待:
$ gmake whatsV
value0 value1
實際:
$ gmake whatsV
Makefile:3: *** Recursive variable `V' references itself (eventually). Stop.
PS:我而不是/拒收要換CommonMakefile。
感謝@Beta的答案和鏈接。另外,從鏈接中,[Reading Makefiles](http://www.gnu.org/software/make/manual/make.html#Reading-Makefiles)部分有一個註釋:對於附加運算符'+ = ',如果變量先前被設置爲簡單變量(':='),則右側被視爲立即數,否則爲延遲。 – vapace