-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
181 lines (137 loc) · 4.18 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# Makefile for agda2lagda generated pdfs
# Disable built-in rules
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:
destdir=$(HOME)/public_html
# commands
bibtool=bibtool -- 'preserve.key.case = ON' \
-- 'print.use.tab = OFF' \
-- 'check.double = ON' \
-- 'check.double.delete = ON' \
-- 'delete.field = { abstract }' \
-- 'delete.field = { dvi }' \
-- 'delete.field = { postscript }' \
-- 'delete.field = { pdf }' \
-- 'delete.field = { month }' \
-- 'delete.field = { isbn }' \
-- 'delete.field = { doi }' \
-- 'delete.field = { note }'
# -- 'delete.field = { editor }'
catcfg=sed -e "s/%.*//g" <
latex=latex
pdflatex=xelatex
bibliography=medium.bib
files=Makefile \
Applicative.lagda.tex \
latex/agda.sty \
latex/Applicative.tex
.PRECIOUS : %.pdf %.tex # %.dvi %.ps %.gz
.PHONY: html
html: html/index.html html/Applicative.pdf
html/Applicative.pdf : Applicative.tex template.tex
tectonic -o html/ $<
# html/index.html: index.md
# pandoc --from=markdown --to=html5 --standalone --output=$@ $<
.PHONY: default
default : Applicative.pdf
.PHONY: ship-Applicative
ship-Applicative : $(destdir)/agda/Applicative.pdf
# The generic rule does somehow not work
.PHONY: ship-%
ship-% : $(destdir)/agda/%.pdf
.PHONY: pack
pack : Applicative.zip
Applicative.zip : Applicative.pdf $(files) Applicative.bbl auto-Applicative.bib
zip $@ $^
%.lagda.tex : src/%.agda
agda2lagda --force -o $@ $<
latex/%.tex : %.lagda.tex
agda --latex $<
# arXiv
##################################################################
.PHONY: arxiv
arxiv: arXiv.zip
arXiv.zip : main.tex auto-main.bib main.bbl
zip $@ $^
main.tex : Applicative.tex template.tex
sed '/input{template}/Q' Applicative.tex > $@
cat template.tex >> $@
# Applicative
##################################################################
# Applicative.pdf: Applicative.tex $(files)
# latexmk -f -pdf Applicative.tex
# initially, run latex once to create an .aux file
# mark .aux file as fresh by creating a stamp _aux
Applicative_aux : Applicative.tex template.tex # latex/Applicative.tex
-$(pdflatex) $<;
touch $@;
# then, run bibtex
Applicative.bbl : Applicative_aux auto-Applicative.bib
-bibtex Applicative;
# finally, finish by running latex twice again
# this will update .aux, but leave the stamp _aux intact
# (otherwise we would not converge and make would never
# return a "Nothing to do")
Applicative.pdf : Applicative.bbl
-$(pdflatex) Applicative.tex;
$(pdflatex) Applicative.tex;
# auto-Applicative.bib is only defined if bibtool is present and all.bib exists
ifneq ($(shell which bibtool),)
ifneq ($(shell ls $(bibliography)),)
auto-Applicative.bib : Applicative_aux $(bibliography)
echo "%%%% WARNING! AUTOMATICALLY CREATED BIBFILE" > $@;
echo "%%%% DO NOT EDIT! ALL CHANGES WILL BE LOST!" >> $@ ;
echo "" >> $@ ;
$(bibtool) -x Applicative.aux -i $(bibliography) >> $@;
endif
endif
# Templates for the LaTeX build
# initially, run latex once to create an .aux file
# mark .aux file as fresh by creating a stamp _aux
%_aux : %.tex
-$(pdflatex) $<;
touch $@;
# then, run bibtex
%.bbl : %_aux auto-%.bib
-bibtex $*;
# finally, finish by running latex twice again
# this will update .aux, but leave the stamp _aux intact
# (otherwise we would not converge and make would never
# return a "Nothing to do")
%.pdf : %.bbl
-$(pdflatex) $*.tex;
$(pdflatex) $*.tex;
# auto-%.bib is only defined if bibtool is present and $(bibliography) exists
ifneq ($(shell which bibtool),)
ifneq ($(shell ls $(bibliography)),)
auto-%.bib : %_aux $(bibliography)
echo "%%%% WARNING! AUTOMATICALLY CREATED BIBFILE" > $@;
echo "%%%% DO NOT EDIT! ALL CHANGES WILL BE LOST!" >> $@ ;
echo "" >> $@ ;
$(bibtool) -x $*.aux -i $(bibliography) >> $@;
endif
endif
# Templates
$(destdir)/agda/% : %
cp -p $< $@
talk% : talk%.pdf
cp -p $? $(destdir)/;
touch $@;
talk%.pdf : talk%.tex
pdflatex $<;
# %.tex : %.lhs
# lhs2TeX --poly -i lhs2TeX.fmt $< > $@
# # /usr/local/share/lhs2tex-1.13/
% : %.pdf # %.dvi %.ps.gz # %.tar.gz
cp -p $? $(destdir)/;
touch $@;
# %.pdf : %.dvi
# pdflatex $*.tex;
# %.ps : %.dvi
# dvips -o $@ $<;
# %.gz : %
# cat $< | gzip > $@
## does not work since $ is evaluated before %
#%.tar : %.cfg $(shell cat %.cfg)
# echo $?
#EOF