2012-06-20 46 views
1

我想从另一个目录生成一个makefile文件并更改它们的名称。目前,我做这样的事情:使用make复制具有不同文件名的文件

ALL: figure1.eps figure2.eps figure3.eps 

figure1.eps: ../other_directory/a_nice_graph.eps 
     cp $< [email protected] 

figure2.eps: ../other_directory/a_beautiful_graph.eps 
     cp $< [email protected] 

figure3.eps: ../other_directory/an_ugly_graph.eps 
     cp $< [email protected] 

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

回答

3

试试这个:

ALL: figure1.eps figure2.eps figure3.eps 

%.eps: 
     cp $< [email protected] 

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

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

figure3.eps: ../other_directory/an_ugly_graph.eps 
+0

是的,谢谢,这工作。我从来没有想过只有一个%.eps – Jason

相关问题