【问题标题】:Gnu Make: how to use the pattern ruleGnu Make:如何使用模式规则
【发布时间】:2022-12-02 23:39:56
【问题描述】:

我有这个示例(简化)makefile

all: a a.e b b.e

.SUFFIXES:

a a.e:
    touch $@

b: a
    ln -sf $(notdir $<) $@

b.e: a.e
    ln -sf $(notdir $<) $@

clean:
    rm -f a* b*

它有效。

我想使用 Pattern Rules 如下:

all: a a.e b b.e

.SUFFIXES:

a a.e:
    touch $@

b%: a%
    ln -sf $(notdir $<) $@

clean:
    rm -f a* b*

但它失败了:

$ make
touch a
touch a.e
make: *** No rule to make target 'b', needed by 'all'.  Stop.

我不知道为什么,也不知道如何让它发挥作用

【问题讨论】:

    标签: makefile gnu-make


    【解决方案1】:

    手册中的此信息是否为您提供了答案:

    目标是匹配文件名的模式; '%' 匹配任何非空子字符串,而其他字符只匹配它们自己。

    (强调)?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-05
      • 1970-01-01
      • 2017-09-26
      相关资源
      最近更新 更多