2011-06-28 37 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