2013-08-27 72 views
1

假設我有以下幾點:GNU使:後綴規則與自定義規則結合

myfile.xyz: myfile.abc 
     mycommand 

.SUFFIXES: 
.SUFFIXES: .xyz .abc 

.abc.xyz: 
     flip -e abc "$<" > "logs/$*.log" 

現在假設我想有mycommand是一個自定義規則(因爲它是目前),但的後綴規則之後(或之前)運行。也就是說,我不希望我的自定義規則替換後綴規則。

回答

2

你想要做的事情在gnu make中是不可能的。有雙冒號規則允許一個目標的多個配方,但它們不適用於後綴規則或模式規則。有關更多信息,請參閱the make manual about double colon rules

這裏是一個解決辦法:

.SUFFIXES:   # Delete the default suffixes 
.SUFFIXES: .xyz .abC# Define our suffix list 

.abc.xyz: 
     flip -e abc "$<" > "logs/$*.log" 
     if [ myfile.abc = "$<" ]; then mycommand; fi 

這裏是使用的圖案相同的makefile規則,而不是後綴規則:

%.xyz: %.abc 
     flip -e abc "$<" > "logs/$*.log" 
     if [ myfile.abc = "$<" ]; then mycommand; fi 

make manual about pattern rulesold-fashioned suffix rules以獲取更多信息。