3

我试图将 $(all_possible_inputs) 限制为 $(relevant_inputs)。$(all_possible_inputs) 是来自其他包含的 makefile 的多个文件的串联。以下功能正确(perl 脚本知道如何忽略额外的输入),但如果单个输入发生更改,一切都会重新构建:

$(step2_outputs): $(data)/%.step2: $(routines)/step2.%.pl $(all_possible_inputs)
        perl $^ > $@

更新:过滤器必须匹配多个 *.step1 文件。如果第 1 步产生:

A.foo.step1
A.bar.step1
B.foo.step1
B.bar.step1
B.baz.step1

那么 step2 的规则应该扩展为:

A.step2: routines/step2.A.pl A.foo.step1 A.bar.step1
B.step2: routines/step2.B.pl B.foo.step1 B.bar.step1 B.baz.step1

从逻辑上讲,这就是我想要的工作:

$(step2_outputs): $(data)/%.step2: $(routines)/step2.%.pl $(filter $(data)/%.*.step1,$(all_possible_inputs))
        perl $^ > $@

% 应该与静态模式规则词干相匹配。* 应该是通配符(我知道这不起作用)。我认为问题在于过滤器重新使用了“%”,因此过滤器表达式失败。我认为它可能可以通过二次扩展来解决,但我尝试了这个,过滤器仍然返回空字符串:

更新:根据 Beta 的好建议,我将示例切换为使用 $$*:

.SECONDEXPANSION:
$(step2_outputs): $(data)/%.step2: $(routines)/step2.%.pl $$(filter $(data)/$$*.%.step1,$(all_possible_inputs))
        perl $^ > $@

这是在 linux 环境中的 gnu make 3.81 上运行的。

4

1 回答 1

3

你的第三种方法对我有用,但你可以试试这个:而不是%(在第一阶段扩展)使用$$*

.SECONDEXPANSION:
$(step2_outputs): $(data)/%.step2: $(routines)/step2.%.pl $$(filter $(data)/$$*.step1,$(all_possible_inputs))
    perl $^ > $@
于 2012-06-28T12:12:55.667 回答