【发布时间】:2021-10-01 09:19:34
【问题描述】:
为了更好地理解 Makefile 中的字符串变量,我尝试做这个例子:
KEYWORD=Nothing
test:
$(call myFunc)
define myFunc
ifeq ($(KEYWORD), "Apple")
echo "You have found the key"
else
echo "Try again"
endif
endef
但是当我打字的时候
make test KEYWORD="Fork"
打印错误
syntax error near unexpected token `Fork,'
`ifeq (Fork, "Apple")'
我也试过了:
- 将 Apple 或 'Apple' 放入 ifeq
- 在 "," 之后是否加空格:ifeq ($(KEYWORD), "Apple")
- 使用 KEYWORD=Fork 运行命令
- 使用 shell 做到了吗(如果 [ ${KEYWORD} -eq "Apple" ])
我的想法已经用完了,因为我不明白 Makefille / Shell 如何解释分配 KEYWORD="Fork"
谢谢
【问题讨论】:
-
顺便说一句,你应该用
KEYWORD=Nothing替换$KEYWORD=Nothing -
是的,打错了,我没有把$放到我的文件里,sy(在帖子中编辑)