2016-09-20 35 views
1

作爲從乳膠文件生成PDF的一部分,我從tex.stackexchange.com得到了一個makefile。dotfile文件(graphviz)

# You want latexmk to *always* run, because make does not have all the info. 
# Also, include non-file targets in .PHONY so they are run regardless of any 
# file of the given name existing. 
.PHONY: paper-1.pdf all clean 

# The first rule in a Makefile is the one executed by default ("make"). It 
# should always be the "all" rule, so that "make" and "make all" are identical. 
all: paper-1.pdf 

# CUSTOM BUILD RULES 

# In case you didn't know, '[email protected]' is a variable holding the name of the target, 
# and '$<' is a variable holding the (first) dependency of a rule. 
# "raw2tex" and "dat2tex" are just placeholders for whatever custom steps 
# you might have. 

%.tex: %.raw 
    ./raw2tex $< > [email protected] 

%.tex: %.dat 
    ./dat2tex $< > [email protected] 

# MAIN LATEXMK RULE 

# -pdf tells latexmk to generate PDF directly (instead of DVI). 
# -pdflatex="" tells latexmk to call a specific backend with specific options. 
# -use-make tells latexmk to call make for generating missing files. 

# -interaction=nonstopmode keeps the pdflatex backend from stopping at a 
# missing file reference and interactively asking you for an alternative. 

paper-1.pdf: paper-1.tex 
    latexmk -bibtex -pdf -pdflatex="pdflatex -interaction=nonstopmode" -use-make paper-1.tex 

clean: 
    latexmk -bibtex -CA 

我的數字是.dot文件,我把它變成PNG文件。我可以使用一些基本的shell命令製作PNG,但是使用shell腳本沒有意義,因爲您失去了make的優勢。

這是我一直在閱讀一些文檔後一直在嘗試。

%.png: %.dot 
    dot -Tpng $(.SOURCE) -o $(.TARGET) 

.dot.png: 
    dot -Tpng $(.SOURCE) -o $(.TARGET) 

然而,每當我試圖運行目標直接在終端打印是:

dot -Tpng -o 

,並持有,因爲它等待輸入來自STDIN,因爲有沒有輸入文件。

如果我試圖通過運行make *.dot調用規則,我得到的輸出:

make: Nothing to be done for `figure-1a.dot'. 
make: Nothing to be done for `figure-1b.dot'. 

我顯然沒有理解什麼是我需要做的。每次運行PDF創建時,如何獲取makefile以獲取所有.dot文件並創建.png文件?

更新:這裏是另一種嘗試我試圖

graphs := $(wildcard *.dot) 
.dot.png: $(graphs) 
    dot -Tpng $(.SOURCE) -o $(.TARGET).png 

回答

1

GNU make用$<[email protected],不.SOURCE.TARGET,配方應該是

.PHONY: all 

all: $(patsubst %.dot,%.png,$(wildcard *.dot)) 

%.png: %.dot 
    dot -Tpng $< -o [email protected] 
+0

'.SOURCE'和'.TARGET'來自我在線閱讀的內容(源代碼現在可以逃脫我,但不管它是否有錯) 如何調用規則? –

+0

@BCqrstoO更新。 – user657267

+0

非常感謝。我有點失落,我很感激! –