Makefile 模式规则引用依赖项中的主干
我想要一个模式规则,其依赖关系是从主干和使用通配符构建的,即类似
$(FILES): %.o: %.c $(wildcard %*.c)
这似乎不起作用:主干 % 未在通配符函数中扩展(请参阅 http://www.gnu.org/software/make/manual/html_node/Pattern-Rules.html),而在列出依赖项时,自动变量 $* 似乎无法被识别。
有没有一种(不太笨拙)的方法来做这样的事情?
I want a pattern rule with dependencies constructed both from the stem and using wildcards, i.e. something like
$(FILES): %.o: %.c $(wildcard %*.c)
This doesn't seem to work: the stem % is not expanded within the wildcard function (see http://www.gnu.org/software/make/manual/html_node/Pattern-Rules.html), while the automatic variable $* seems not to be recognized when listing dependencies.
Is there a (not too kludgy) way of doing something like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如GNU make手册第10.5.3节所述,自动变量(即
$*
)在先决条件中不可用,但它也提到了一种解决方法,即二次扩展。如果我(和你)正确理解它,类似这样的事情应该做你想要的:
As is stated in section 10.5.3 of the GNU make manual, automatic variables (which is what
$*
is) are not available in prerequisites, but it also refers to a work-around, namely secondary expansion.If I understand it (and you) correctly, something like this should do what you want: