【问题标题】:Makefile without explicit targets没有明确目标的 Makefile
【发布时间】:2012-03-14 10:55:15
【问题描述】:

如果我有一组文件 *.foo 使用 foo2bar some.foo“编译器”“编译”为一组 *.bar,我可以这样编写 Makefile:

  %.bar: %.foo
    <tab>foo2bar $<

但是,如果还没有 *.bar,我不能只输入 make all 之类的内容并生成所有 *.bar。

我如何告诉 make 创建所有匹配 *.bar 的缺失目标?

【问题讨论】:

    标签: makefile


    【解决方案1】:

    假设你使用的是 GNU make(你似乎是因为你已经使用了 %-notation):

    all: $(patsubst %.foo,%.bar,$(wildcard *.foo))
    

    【讨论】:

    • BSD make 有 %(至少我上次检查时在 FreeBSD 上是这样)。
    猜你喜欢
    • 1970-01-01
    • 2013-04-11
    • 1970-01-01
    • 1970-01-01
    • 2020-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多