问题描述
在我的Makefile中调用GREP的两种方式有什么区别吗?有什么原因我应该使用另一个?两者似乎产生相同的结果.
Is there any difference in the two ways GREP is invoked in my Makefile? Any reason I should use one or the other? Both seem to produce the same result.
define GREP
$(word 3,$(shell echo "#define FOO 0xfff00100"))
endef
all:
@echo $(GREP)
@echo $(call GREP)
推荐答案
您使用它的方式没有什么区别.但是,如果您的GREP宏是带有参数的函数,则必须使用$(call)将参数传递给它.例如:
The way you are using it, there is no difference. However, if your GREP macro were a function that took parameters, you would have to use $(call) to pass parameters to it. For example:
define GREP
$(shell grep $1 $2)
endef
FOO:=$(call GREP,abc,words.txt)
这将导致将 $ 1
替换为"abc",并将 $ 2
替换为"words.txt".
This causes $1
to be replaced with "abc", and $2
with "words.txt".
在此处查看有关用户定义函数的GNU make手册中的更多内容: http://www.gnu.org/software/make/manual/make.html#Call-Function
See more in the GNU make manual on user-defined functions here: http://www.gnu.org/software/make/manual/make.html#Call-Function
这篇关于如何调用使用define创建的GNU make宏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!