2011-06-28 36 views
0

的Makefile:問題與Makefile文件執行shell腳本

$(shell ./test.sh) 

實驗1:test.sh

echo "hi" 

錯誤,我得到:

Makefile:1: *** missing separator. Stop. 

實驗2: test.sh

echo("hi") 

錯誤,我得到:

./test.sh: line 1: syntax error near unexpected token `"hi"' 
./test.sh: line 1: `echo("hi")' 

沒有任何意義......它看起來好像「製作」試圖強加給它的外殼語法腳本,但shell腳本也需要它自己的腳本。

回答

5

嘗試./test.sh

在第一個實驗中,其結果是

hi 

當您運行make,行$(shell ./test.sh)評估爲hi,這讓不知道如何解釋。

在第二個實驗中,

./test.sh: line 1: syntax error near unexpected token `"hi"' 
./test.sh: line 1: `echo("hi")' 

你已經寫了沒有正確的shell語法一個shell腳本,因此它失敗。無論您運行它還是使其運行,它都會失敗。

+0

我試過了,但它說:「Makefile:1:*** missing separator。Stop。」以及。我不知道該怎麼做.. – Blub

+0

哦,該死的,顯然我不能把這條線放在任何地方,它必須是一個配方。謝謝你的幫助! – Blub

+3

不完全是,你可以使用$(警告$(shell ...)),警告保證產生空輸出,然後你可以使用(假)賦值AAA:= $(shell ...) - 這一切都取決於您的特殊需求。 – pmod