2011-08-31 56 views
3

我有一些定義一個definitions.mk文件:附加價值變量make文件

define some-method 

if [ ! -f <some file> ] ; then 
    MYVAR += text_to_append 

它與MYVAR行這是我的問題。它認爲MYVAR是一個命令。我怎麼能意識到它是我所指的變量MYVAR(它也存在於其他make文件中)?

在此先感謝您的任何意見!

回答

5

您不能在Makefile中使用shell風格的「if」語句。您需要使用GNU make conditional syntax

喜歡的東西:

ifneq ($(wildcard some_file),) 
# File exists 
MYVAR += text_to_append 
endif 

另外,不要使用標籤在你的Makefile壓痕,他們有特殊的意義之作。