2012-06-20 45 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

相關問題