我想我可以使用make中的define指令来创建多个相似的规则
define TESTPRG
${1}:
echo Build ${1}
endef
$(call TESTPRG,x)但是我得到了这个输出
$ make
make: *** No rule to make target 'echo', needed by '
x'. Stop.看起来我的定义中的换行符丢失了
$ make -n -p | grep echo
make: *** No rule to make target 'echo', needed by '
x'. Stop.
echo Build ${1}
x: echo Build x
echo:我是不是在尝试做一些define不应该被使用的事情。
Kjeld
发布于 2020-01-23 07:44:16
这正是define应该被使用的地方。您只需要记住将其作为Makefile的一部分进行$(eval):
$ cat Makefile
define TESTPRG
${1}:
echo Build ${1}
endef
$(eval $(call TESTPRG,x))
$ make
echo Build x
Build xhttps://stackoverflow.com/questions/59855637
复制相似问题