c - GNU makefile 中的 "premature end of file"是什么意思?

标签 c linux makefile gnu-make

我正在尝试练习 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/

相关文章:

makefile - 使 : how to continue after a command fails?

c - 共享对象的实际用途

c - 如何将结构显式对齐为 4 个字节

c - 什么时候执行类型转换计算?

linux - 修改socket结构将数据包发送到另一个IP

linux - 向进程组的所有成员发送信号的最佳方式是什么?

c++ - 如何将混合(asm、C++)源代码编译成 32 位程序?

c++ - 在 C++ 上获取对 Perl 的 undefined reference

c - 如果我们将静态变量定义为全局变量,那么它的作用域应该在该文件内,但在这里我得到了不同的结果

linux - RabbitMQ 管理插件 - 连接超时