2016-04-25 47 views
0

我有一個makefile運行數據分析,我正在爲大量數據集製作具有通用工作流的數據分析。我有一些像這樣的規則...通過重複通配符製作目標和依賴關係

data/a/a.tax : code/a.sh code/a.x 
    bash $< 

data/b/b.tax : code/b.sh code/b.x 
    bash $< 

data/c/c.tax : code/c.sh code/c.x 
    bash $< 

我願意認爲我可以做...

data/%/%.tax : code/%.sh code/%.x 
    bash $< 

但是,這似乎並沒有工作(make: *** No rule to make target data/a/a.tax'. Stop

有什麼建議工作?

回答

0

模式規則的目標只能包含一個%.SECONDEXPANSION可以解決此

.SECONDEXPANSION: 
data/%.tax: code/$$(notdir $$*).sh code/$$(notdir $$*).x 
    bash $< 

這就是說,除非你絕對需要特定的樹結構,它會是簡單的改變先決條件code/a/a.sh

data/%.tax : code/%.sh code/%.x 
    bash $<