-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (62 loc) · 2.95 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# All source files
# Figures:
ALLDOT := $(wildcard *.dot)
ALLBIGDOT := $(wildcard *.bigdot)
ALLFDPDOT := $(wildcard *.fdpdot)
ALLFIG := $(subst .dot,,$(ALLDOT)) $(subst .bigdot,,$(ALLBIGDOT)) $(subst .fdpdot,,$(ALLFDPDOT))
ALLFIGPNG := $(addsuffix .png,$(ALLFIG))
ALLFIGPDF := $(addsuffix -fig.pdf,$(ALLFIG))
ALLFIGJUNK := $(addsuffix .tex,$(ALLFIG)) $(addsuffix .aux,$(ALLFIG)) $(addsuffix .log,$(ALLFIG)) $(addsuffix -pics.pdf,$(ALLFIG))
# The following source files currently only render properly as PNGs
BAD := condensed-emission fanned-emission fanned-indel fanned-match mf-generator liv-small transitions fork3-tkf91liv-tkf91mf-tkf91cs root-fork-tkf91liv-tkf91mf viterbi-root-fork-tkf91liv-tkf91mf forward2-root-fork-tkf91liv-tkf91mf fork-tkf91forward2-tkf91cs
BADPNG := $(addsuffix .png,$(BAD))
GOODPDF := $(addsuffix -fig.pdf,$(filter-out $(BAD),$(ALLFIG)))
FIGURES := $(BADPNG) $(GOODPDF)
# Papers:
ALLTEX := $(filter-out $(ALLFIGJUNK),$(wildcard *.tex))
ALLTEXPDF := $(subst .tex,.pdf,$(ALLTEX))
ALLTEXJUNK := $(addsuffix .aux,$(ALLTEX)) $(addsuffix .log,$(ALLTEX))
# Top-level rules
all: $(FIGURES) $(ALLTEXPDF)
open: $(ALLTEXPDF)
open $(ALLTEXPDF)
tidy:
rm -f $(ALLFIGJUNK) $(ALLTEXJUNK) *~
clean: tidy
rm -f $(ALLTEXPDF) $(ALLFIGPDF) $(ALLFIGPNG)
# General rules:
%.open: %
open $<
# Paper rules:
%.pdf: %.tex $(FIGURES)
test -e $*.aux && rm $*.aux || eval
pdflatex -shell-escape $*
bibtex $*
pdflatex -shell-escape $*
pdflatex -shell-escape $*
# Figure rules:
# PDFs (requires dot2tex + graphviz + pyparsing)
# Landscape orientation, letter paper
%.tex: %.dot
dot2tex --autosize --crop --format pstricks --texmode raw $< | perl -ne 'if(/documentclass/){print"\\documentclass{article}\n\\usepackage[x11names,rgb]{xcolor}\n\\usepackage{auto-pst-pdf}\n\\usepackage[landscape]{geometry}\n"}else{print unless /usepackage.*xcolor/}' >$@
# Landscape orientation, A1 paper (workaround to avoid cropping big graphs)
%.tex: %.bigdot
dot2tex --autosize --crop --format pstricks --texmode raw $< | perl -ne 'if(/documentclass/){print"\\documentclass[a1paper]{article}\n\\usepackage[x11names,rgb]{xcolor}\n\\usepackage{auto-pst-pdf}\n\\usepackage[landscape]{geometry}\n"}else{print unless /usepackage.*xcolor/}' >$@
# Using TikZ instead of PSTricks (some problems with this, e.g. TikZ doesn't have same node shapes as normal GraphViz...)
%.tikz.tex: %.dot
cat $*.dot | perl -pe 's/invhouse/pentagon/g;s/house/triangle/g' >$*.tmpdot
dot2tex --autosize --format tikz --texmode raw $*.tmpdot | perl -ne 'if(/documentclass/){print"\\documentclass{article}\n\\usepackage[x11names,rgb]{xcolor}\n\\usepackage{auto-pst-pdf}\n\\usepackage[landscape]{geometry}\n"}else{print unless /usepackage.*xcolor/}' >$@
# LaTeX -> PDF
%-fig.pdf: %.tex
pdflatex -shell-escape $*.tex
pdfcrop $*.pdf $*-fig.pdf
rm $*.pdf
# PNGs (requires graphviz only)
%.png: %.dot
dot -Tpng $< >$@
%.png: %.bigdot
dot -Tpng $< >$@
%.png: %.fdpdot
dot -Tpng -Kfdp $< >$@
# hey make! don't delete all my stuff
.SECONDARY: