`/bin/bash: -c: line 13: syntax error: unexpected end of file` obscure error when changing variable in a Makefile

`/bin/bash: -c: line 13: syntax error: unexpected end of file` obscure error when changing variable in a Makefile

我遇到了一件奇怪的事情,这似乎与我后来遇到的错误完全无关。

我的 AutoTools 构建系统工作得很好,但是如果我在我的 Makefile 中更改 this line,使用 $(top_builddir) 而不是 $(top_srcdir),那么构建就会开始失败:

...
/usr/bin/mcs -r:/usr/lib/pkgconfig/../../lib/cli/glib-sharp-3.0/glib-sharp.dll -out:gobject-intptr-ctor-verifier.exe GObjectIntPtrCtorVerifier.cs
Making all in Hyena
/bin/bash: -c: line 13: syntax error: unexpected end of file

这个单一的更改到底是怎么导致这个问题的?如何调试这个问题?如何知道 bash 试图解释什么文件?我在这里不知所措。

我会尝试跟踪执行的命令。也许 make 可以修改得更冗长。否则我建议 strace:

original_command='make all' # or whatever it was you executed

strace -s2000 -eexecve -o/tmp/make.commands -f $original_command

然后查看文件 /tmp/make.commands,搜索 bash,特别是搜索 13 行长的内联 shell 脚本。

很高兴您解决了问题。在更一般的情况下,此错误和其他类似错误通常是由 Automake 文件中进入 Makefile 的语法错误引起的。有时会报告 Makefile 中的行号,因此您可以检查生成的 Makefile;在你的情况下它不是。

make -n 可以提供帮助,打印出 make 将执行的每个命令,而不实际执行它。