我想从另一个目录中获取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 $&lt; $ @)。我不能使用标准通配符(%.eps),因为文件名不匹配。有没有办法做到这一点?
答案 0 :(得分: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