根据输入的位置定制目标
是否有像 $@ 这样的变量,它包含需要当前目标的目标而不是当前目标?下面是我正在寻找的功能类型的简单示例。基本上,“make foo”将创建一个目录 foo,“make bar”将创建 bar 并“make Both”。到目前为止,我还没有找到任何可以实现这种定制的东西。
foo: foobar
do stuff
bar: foobar
do other stuff
both: foo bar
....
foobar:
mkdir <foo or bar>
找到了一种解决方案,模式规则。
foo: from_foo
@echo "This is foo"
from_%:
@echo "Called from $(lastword $(subst _, ,$@))"
@echo "Simpler version... $*"
Is there a variable like $@ which would contain instead of current target the target which required current target? Below is a simple example of what kind of functionality I am looking for. Basically "make foo" would create a directory foo, "make bar" would create bar and "make both" both. So far I haven't found anything which would enable this kind of customization.
foo: foobar
do stuff
bar: foobar
do other stuff
both: foo bar
....
foobar:
mkdir <foo or bar>
Found one solution, pattern rules.
foo: from_foo
@echo "This is foo"
from_%:
@echo "Called from $(lastword $(subst _, ,$@))"
@echo "Simpler version... $*"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论