我正在尝试练习 makefile 中的 if 语句,但它一直说文件过早结束。 代码:
test_rule:
if [ yes ]
echo "if works"
endif
输出:
make test_rule
/bin/sh: -c: line 1: syntax error : premature end of file
make: *** [Makefile:13: test_rule] Error 1
网上试了很多代码(比如把[]换成(),或者在echo前面加@)都没有用。
最佳答案
其他答案/评论表明您的“制表符”不正确——这可能是真的——但查看错误消息...
make test_rule
/bin/sh: -c: line 1: syntax error : premature end of file
make: *** [Makefile:13: test_rule] Error 1
我认为这只是命令中 shell 语法不正确的情况。请记住,一般来说,make 配方的命令部分中的每一行都将在其自己的 shell 中运行。尝试以下操作(记住我不是 shell 专家)...
test_rule:
if [ yes ]; then \
echo "it works"; \
fi
关于c - GNU makefile 中的 "premature end of file"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57946124/