1

我想要一个 makefile 从另一个目录复制文件并更改它们的名称。目前,我做这样的事情:

ALL: figure1.eps figure2.eps figure3.eps

figure1.eps: ../other_directory/a_nice_graph.eps
        cp $< $@

figure2.eps: ../other_directory/a_beautiful_graph.eps
        cp $< $@

figure3.eps: ../other_directory/an_ugly_graph.eps
        cp $< $@

我想避免为每一行编写相同的规则(cp $< $@)。我不能使用标准通配符 (%.eps),因为文件名不匹配。有没有办法做到这一点?

4

1 回答 1

3

试试这个:

ALL: figure1.eps figure2.eps figure3.eps

%.eps:
        cp $< $@

figure1.eps: ../other_directory/a_nice_graph.eps

figure2.eps: ../other_directory/a_beautiful_graph.eps

figure3.eps: ../other_directory/an_ugly_graph.eps
于 2012-06-20T01:52:00.447 回答