-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·117 lines (90 loc) · 2.84 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/make -f
#
# Makefile for pdflatex projects using bibtex for references
#
# Timothy Brooks 2012 <[email protected]>
#
SHELL = /bin/bash
latexfile = report
pdffile = technicalreport2015
tex_dir = tex_src
bib_dir = bib
fig_dir = figures
img_dir = img
img_src_dir = img_src
bibstyle = styles/my-lim-num.bst
TEX = pdflatex -halt-on-error -file-line-error
BIB = bibtex -terse
GLS = makeglossaries
HAVE_RUBBER = "$(shell rubber --version 2> /dev/null)"
tex = $(wildcard $(tex_dir)/*.tex) $(latexfile).tex
tex += $(wildcard $(fig_dir)/*.tex)
bib = $(wildcard $(bib_dir)/*.bib)
img = $(patsubst $(img_src_dir)/%.svg, $(img_dir)/%.png, $(wildcard $(img_src_dir)/*.svg))
img += $(patsubst $(img_src_dir)/%.eps, $(img_dir)/%.pdf, $(wildcard $(img_src_dir)/*.eps))
img += $(patsubst $(img_src_dir)/%.png, $(img_dir)/%.png, $(wildcard $(img_src_dir)/*.png))
img += $(patsubst $(img_src_dir)/%.pdf, $(img_dir)/%.pdf, $(wildcard $(img_src_dir)/*.pdf))
ifneq ($(HAVE_RUBBER), "")
deps = $(tex) $(bib) $(img)
else
deps = $(latexfile).aux $(latexfile).bbl $(latexfile).gls
endif
.PHONY: all, rubber, pdflatex, latex
all: $(pdffile).pdf
test: test_figures.pdf
ifneq ($(HAVE_RUBBER),"")
$(pdffile).pdf: rubber
else
$(pdffile).pdf: pdflatex
endif
rubber: $(deps)
rubber --pdf $(latexfile).tex
rubber-info --check $(latexfile).tex
mv $(latexfile).pdf $(pdffile).pdf
pdflatex: $(deps)
PDFwords="NONE" ;\
while [ "$${oldPDFwords}" != "$${PDFwords}" ] ; do \
oldPDFwords=$${PDFwords} ;\
$(TEX) $(latexfile) ;\
PDFwords=`tail -n2 have_gls.log | head -n1 | cut -d" " -f2` ;\
done
mv $(latexfile).pdf $(pdffile).pdf
# $(MAKE) tmpclean
latex: $(deps)
latex $(latexfile)
dvipdf $(latexfile)
test_figures.pdf: test_figures.tex $(tex) images
ifneq ($(HAVE_RUBBER),"")
rubber --pdf -f $<
rubber-info --check $<
else
$(TEX) $<
endif
$(latexfile).aux: $(img) $(tex)
$(TEX) $(latexfile)
$(latexfile).bbl: $(bib) | $(latexfile).aux $(bibstyle)
$(BIB) $(latexfile)
$(latexfile).glo: $(tex) | $(latexfile).bbl
$(TEX) $(latexfile)
$(latexfile).gls: $(tex) | $(latexfile).glo
$(GLS) $(latexfile)
$(img_dir)/%.png: $(img_src_dir)/%.svg | $(img_dir)
inkscape --without-gui --file=$< --export-png=$@ --export-area-drawing
$(img_dir)/%.pdf: $(img_src_dir)/%.eps | $(img_dir)
epstopdf $< -o $@
$(img_dir)/%.png: $(img_src_dir)/%.png | $(img_dir)
ln -fs ../$< $@
$(img_dir)/%.pdf: $(img_src_dir)/%.pdf | $(img_dir)
ln -fs ../$< $@
$(img_dir):
mkdir -p $(img_dir)
images: $(img)
clean: tmpclean
rm -f $(latexfile).aux $(latexfile).bbl $(latexfile).glo $(latexfile).gls $(latexfile).brf
rm -f $(pdffile).pdf
tmpclean: logclean
rm -f $(latexfile).lof $(latexfile).lot $(latexfile).nav $(latexfile).out $(latexfile).snm $(latexfile).toc $(latexfile).xdy
logclean:
rm -f $(latexfile).log $(latexfile).blg $(latexfile).glg
imgclean:
rm -f $(img)