makefile 中的条件构造中出现意外的 EOF
Unexpected EOF in conditional construct in makefile
我的 makefile 中有以下目标
omp: main_omp.c omp_impl.o
if [[ ! -e ../bin/ ]]; then mkdir ../bin/ fi
gcc $(CFLAGS) ... # compilation et cetera
在同一目录中执行 make omp
会导致 make 终止并出现以下错误
if [[ ! -e ../bin ]]; then mkdir ../bin fi
/bin/sh: 1: Syntax error: end of file unexpected (expecting "fi")
make: *** [makefile:10: omp] Error 2
在终端中执行 if ... fi
语句按预期工作。我尝试了双引号的不同组合,分成不同的行等,但没有任何效果。
如何解决这个问题?为什么在这里 make 运行 变成 EOF?
您说:
Executing the if ... fi statement in the terminal works as intended.
我对此表示怀疑。如果我剪切并粘贴您的示例,我会从 shell:
得到继续提示
if [[ ! -e ../bin/ ]]; then mkdir ../bin/ fi
>
这是合乎逻辑的。您的 shell(通过提示或通过 make
)看到您想要使用两个参数 ../bin
和 fi
执行 mkdir
。解决方案当然是确保 shell 将 fi
视为下一个“命令”。为此,您需要在 fi
.
之前添加 ;
我的 makefile 中有以下目标
omp: main_omp.c omp_impl.o
if [[ ! -e ../bin/ ]]; then mkdir ../bin/ fi
gcc $(CFLAGS) ... # compilation et cetera
在同一目录中执行 make omp
会导致 make 终止并出现以下错误
if [[ ! -e ../bin ]]; then mkdir ../bin fi
/bin/sh: 1: Syntax error: end of file unexpected (expecting "fi")
make: *** [makefile:10: omp] Error 2
在终端中执行 if ... fi
语句按预期工作。我尝试了双引号的不同组合,分成不同的行等,但没有任何效果。
如何解决这个问题?为什么在这里 make 运行 变成 EOF?
您说:
Executing the if ... fi statement in the terminal works as intended.
我对此表示怀疑。如果我剪切并粘贴您的示例,我会从 shell:
得到继续提示if [[ ! -e ../bin/ ]]; then mkdir ../bin/ fi
>
这是合乎逻辑的。您的 shell(通过提示或通过 make
)看到您想要使用两个参数 ../bin
和 fi
执行 mkdir
。解决方案当然是确保 shell 将 fi
视为下一个“命令”。为此,您需要在 fi
.
;