为什么make会忽略这个规则,而是触发一个隐含的规则呢?

时间:2014-02-24 18:11:31

标签: makefile

我的makefile中有以下规则:

$(TESTDIR)/%.test.out:$(TESTDIR)/%.test $(TESTDIR)/%.in
        $< < $(patsubst %.out, %.in, $@) 2>&1 > $@

我希望,当我调用make

make testing/Candidate.test.out

(其中TESTDIR =在makefile中测试),make应该用

响应
testing/Candidate.test < Candidate.test.in 2>&1 >Candidate.test.out

相反,请使用

进行回复
cp testing/Candidate.test testing/Candidate.test.out

和make -d yield:

Considering target file 'testing/Candidate.test.out'.
 File 'testing/Candidate.test.out' does not exist.
 Looking for an implicit rule for 'testing/Candidate.test.out'.
 Trying pattern rule with stem 'Candidate'.
 Trying implicit prerequisite 'testing/Candidate.test'.
 Trying implicit prerequisite 'testing/Candidate.in'.
 Trying pattern rule with stem 'Candidate.test'.
 Trying implicit prerequisite 'testing/Candidate.test'.
 Found an implicit rule for 'testing/Candidate.test.out'.

使用make -r构建:

make -r testing/Candidate.test.out
make: *** No rule to make target 'testing/Candidate.test.out'.  Stop.

表示make绝对不能识别我的规则,但我不明白为什么不这样做。显然,根据cp输出,相信$(TESTDIR)=测试。显然,它还将testing / Candidate.test.out识别为有效目标,因为它试图构建它(而它无法测试/ blah.test.out)。

这里有什么显而易见的东西吗?

1 个答案:

答案 0 :(得分:2)

规则中的一个目标(%。in)不正确(应该是%.test.in)。