2017-04-11 106 views
0

我試着讓一件事或其他根據文件是否已擴展p.mdmd根據文件擴展名讓事情

$(DST)/%.md.html: $(SRC)/%.md $(TMPHTML5) 
    $(eval EXT := $(suffix $<)) 
    ifeq('$(EXT)','.p.md') 
     $(PANDOC_MD_HTML) -o [email protected] $< -V filename=$(<F) -V otherformatspresentations=true 
    else 
     $(PANDOC_MD_HTML) -o [email protected] $< -V filename=$(<F) 
    endif 

,但我得到:

make site/ESPA4.Dia-0-presentacio.p.md.html -B 
ifeq('.md','.p.md') 
/bin/sh: -c: line 0: syntax error near unexpected token `'.md','.p.md'' 
/bin/sh: -c: line 0: `ifeq('.md','.p.md')' 
make: *** [Makefile:103: site/ESPA4.Dia-0-presentacio.p.md.html] Error 1 
+0

命令由shell中運行的構建,不化妝,所以你需要使用shell命令,而不是命令。 – melpomene

回答

3

你爲什麼不只是使用每種類型的文件創建一個模式,因爲make有意使用?

$(DST)/%.p.md : $(SRC)/%.md $(TMPHTML5) 
     $(PANDOC_MD_HTML) -o [email protected] $< -V filename=$(<F) -V otherformatspresentations=true 
$(DST)/%.md : $(SRC)/%.md $(TMPHTML5) 
     $(PANDOC_MD_HTML) -o [email protected] $< -V filename=$(<F) 

需要注意的是,這取決於GNU版本讓你使用的順序可能是也可能不是重要的,但是這將與所有版本。

如果你想這樣做的一個規則,你不能使用ifeq等等。這是一個命令,在配方的一切傳遞給外殼。 shell不知道任何關於ifeq因此你的錯誤。你必須要麼使用$(if ...)功能或其他完全使用shell語法:

$(DST)/%.md.html: $(SRC)/%.md $(TMPHTML5) 
     $(PANDOC_MD_HTML) -o [email protected] $< -V filename=$(<F) $(if $(filter %.p.md,$<),-V otherformatspresentations=true) 

或者:

$(DST)/%.md.html: $(SRC)/%.md $(TMPHTML5) 
     other=; case $< in (*.p.md) other="-V otherformatspresentations=true" ;; esac; \ 
     $(PANDOC_MD_HTML) -o [email protected] $< -V filename=$(<F) $$other 
+0

你的意思是「請注意,取決於你使用的是哪個版本的GNU命令,可能或者可能不重要,但是這將適用於所有版本。」?最好的訂單是什麼? – somenxavier

+0

最後的解決方案不起作用:'pandoc ... -o site/activitat.Phone-Home.p.md.html src/activitat.Phone-Home.p.md -V filename = activitat.Phone-Home.p。 md $ other' – somenxavier

+0

倒數第二個解決方案既不是:'pandoc ... -o site/activitat.Phone-Home.p.md.html src/activitat.Phone-Home.p.md -V filename = activitat.Phone-Home .p.md' – somenxavier