【发布时间】:2017-07-25 06:34:14
【问题描述】:
GNU make 手册说 eval 函数扩展参数,然后将扩展结果提供给 make 解析器。以下内容引用自 GNU make 手册。
The argument to the eval function is expanded, then the results of that expansion are parsed as makefile syntax.
我不太明白 make 解析器如何处理 eval 输入的文本,所以 我写了下面的makefile来测试。
define myprint
echo "this is a line"
endef
goal:
$(eval $(call myprint))
gcc -o goal test.c
我知道myprint的正确调用应该只使用调用函数:$(call myprint)并在回显之前删除'Tab'字符。我以这种形式编写makefile只是为了测试eval函数。
我的期望:首先eval函数扩展myprint,这是一个回显命令,前面有一个'Tab','Tab'用于使扩展文本成为合法的配方。然后 eval 将扩展的文本提供给 maker 解析器,后者将识别文本为配方并运行它。由于该命令是合法的,makefile 应该可以正常运行。
但是,我遇到了这样一个错误:
Makefile:6: *** recipe commences before first target. Stop.
有人能解释一下为什么 make 会产生这样的错误吗?
【问题讨论】:
标签: makefile