为ifeq出错:意外令牌附近的语法错误 [英] Make error for ifeq: syntax error near unexpected token
问题描述
我正在编写一个Makefile,该文件在一个位置进行字符串匹配,代码如下:
I'm writing a Makefile that does string matching at one place, the code is like:
if test ...; \
then \
shell scripts... \
fi
ifeq ($(DIST_TYPE),nightly)
shell scripts ...
endif
第一个if
是shell脚本,第二个ifeq
是GNU Make的条件脚本.但是,会产生以下错误:
Here the first if
is shell script, the second ifeq
is GNU Make's conditional. However the following error generates:
ifeq(每晚,每晚)
ifeq (nightly,nightly)
/bin/sh:-c:第0行:语法标记为每晚,每晚"的意外错误附近
/bin/sh: -c: line 0: syntax error near unexpected token `nightly,nightly'
/bin/sh:-c:第0行:"ifeq(每晚,每晚)"
/bin/sh: -c: line 0: `ifeq (nightly,nightly)'
这是怎么回事?似乎Make正在尝试调用Shell.
What's happening here? It seems that Make is trying to call the shell.
谢谢.
推荐答案
我在代码旁玩耍,发现条件语句应该不缩进地编写,这解决了我的问题.
I played around the code and found that the conditional statements should be written without indentation, and this solved my problem.
如果没有缩进,Make会将其视为自身的指令;否则,它将被视为shell脚本.
If there is no indentation, Make will treat it as a directive for itself; otherwise, it's regarded as a shell script.
错误:
target:
ifeq (foo, bar)
...
endif
正确:
target:
ifeq (foo, bar)
...
endif
这篇关于为ifeq出错:意外令牌附近的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!