This repository has been archived by the owner on Mar 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
318 lines (283 loc) · 9.12 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
VERSION=
LATEXTARGET=dissertation$(VERSION)
all: proposal.pdf dissertation.pdf
prop: proposal.pdf
diss: dissertation.pdf
#
# LaTeX Makefile
# --------------
#
# Author : [email protected] (Stefan van den Oord)
# Date : March 18, 1999, second version of today.
#
# This Makefile is a generic makefile for LaTeX documents. Distribute it
# as you wish, but please don't edit or remove this initial comment.
#
# The Makefile can be used by setting the environment variable "MAKEFILES",
# e.g. export MAKEFILES=~/data/TeX/Makefile.
# It requires GNU Make and bash or better, like zsh. Simply sh is not
# sufficient, I believe. The first few lines of the Makefile contains
# the executables that are used, edit them to point to the executables
# on your system.
#
# DISCLAIMER: Using this Makefile is fully at your own risk. I am not
# responsible for anything! So if crucial files are removed
# by the Makefile, it is your own problem. But you should
# have backups anyway. :-)
#
# Usage
# -----
# The Makefile can do the following things for you:
# - generate PostScript equivalents of XFig figures;
# - run makeindex and BibTeX, but only if necessary;
# - compile the .dvi file, running LaTeX as many times as needed;
# - run XDvi with the compiled .dvi file;
# - create a PostScript equivalent of the .dvi file;
# - generate a HTML equivalent of the .dvi file (if Latex2HTML is
# installed);
# - remove all generated output.
# The Makefile is in some points even RCS aware.
#
# In many cases, you don't even have to tell the Makefile which LaTeX
# file it has to compile. The Makefile uses the following strategy:
# 1. Check if the environment variable LATEXTARGET is set; if it is,
# generate $LATEXTARGET.dvi.
# 2. If there is only one .tex file, use that one.
# 3. Check if there is a LaTeX file that has the same basename as the
# directory. For example, if the directory is named "Thesis" and
# there is a file "Thesis.tex", "Thesis.dvi" is generated.
#
# Invocation
# ----------
# When the MAKEFILES environment variable is set, you can use the
# following commands:
# - make latexhelp
# Prints an overview of the available commands.
# - make latexfigures
# Only generate the PostScript equivalents of XFig figures.
# - make file.dvi
# Generates the specified DVI file.
# - make file.ps
# Generates the DVI file and then runs dvips.
# - make latex
# Use the above explained strategy to find out what has to be
# generated, and generate it.
# - make view
# Do a make latex and then run XDvi.
# - make latexps
# Do a make latex and then run dvips.
# - make html
# Do a make latex and then use LaTeX2HTML to create the HTML equivalent.
# To do this, the following environment variables are used:
# * HTMLDIR : the base dir in which the output is written. For example,
# if HTMLDIR=~/public_html/LaTeX, and the file that is
# generated is "Thesis", the output will be written in the
# directory ~/public_html/LaTeX/Thesis.
# * LATEX2HTML_OPTS : if you want to pass options to LaTeX2HTML, put
# them in this variable.
# - make latexclean
# This command removes all generated output. CAUTION: the files that are
# removed are thought out pretty well, but it is possible that files are
# removed that you wanted to keep! Check below what files are removed if
# you want to be certain!
# Note that a file figure.eps is only removed if a file figure.fig exists.
# (Even if the file figure.fig exists, but is checked in using RCS, the
# file figure.eps will be removed.)
#
# Tip
# ---
# For some projects it is useful to have a separate Makefile in the project's
# directory. For example, when you use RCS, you could add functionality for
# automatic checkouts of the right files (adding dependencies is sufficient;
# GNU Make rocks :-).
# The command "latexclean" is declared so that you can add your own
# functionality in the project's Makefile; instead of one colon, declare it
# with two colons if you want to do that.
# For example:
# latexclean::
# rm -f foo.bar
# This way both the origional definition in this Makefile and your own are
# used.
#.SILENT:
# SHELL=/usr/local/bin/bash
LATEX=latex
PDFLATEX=pdflatex
BIBTEX=bibtex
DVIPS=dvips
MAKEINDEX=makeindex
DVIVIEWER=xdvi -geometry 710x950-0+10
LATEX2HTML=latex2html
FIGURES=$(wildcard *.fig)
FIGUREOBJS=$(FIGURES:.fig=.eps)
TEXFILES=$(wildcard *.tex)
# Disable standard pattern rule:
%.dvi: %.tex
# Do not delete the following targets:
.PRECIOUS: %.aux %.bbl %.eps %.ind
%.aux: %.tex $(FIGUREOBJS) $(TEXFILES)
@$(LATEX) $*
# Look for citations. Make sure grep never returns an error code.
@grep "^\\\\citation" *.aux > .btmp.new || true
# If the citations are not changed, don't do anything. Otherwise replace
# the .btmp file to make sure Bibtex will be run.
@if ( diff .btmp.new .btmp >& /dev/null ); then \
rm .btmp.new; \
else \
mv .btmp.new .btmp; \
fi
@if [ -f $*.idx ]; then cp $*.idx .itmp.new; else touch .itmp.new; fi
@if ( diff .itmp.new .itmp >& /dev/null ); then \
rm .itmp.new; \
else \
mv .itmp.new .itmp; \
fi
.btmp:
%.bbl: $(BIBFILES) .btmp
# Only use BibTeX if \bibliography occurs in the document. In that case,
# run BibTeX and recompile. .btmp is touched to prevent useless making
# next time.
@if ( grep "^\\\\bibliography{" $*.tex > /dev/null ); then \
$(BIBTEX) $*; \
touch .rerun; \
fi
@touch .btmp
.itmp:
%.ind: .itmp
@if [ -f $*.idx ]; then \
$(MAKEINDEX) $*; \
touch .rerun; \
touch .itmp; \
fi
%.eps:%.fig
@echo Generating figure $@...
@fig2dev -L ps $< $@
%.dvi: %.aux %.ind %.bbl
# Make sure the dvi-file exists; if not: recompile.
@if [ ! -f $*.dvi ]; then \
touch .rerun; \
fi
@if [ -f .rerun ]; then \
rm .rerun; \
$(LATEX) $*; \
else \
$(MAKE) $*.aux; \
fi
# While references et al. are changed: recompile.
@while ( grep Rerun $*.log > /dev/null ); do \
$(LATEX) $*; \
done
# Touch the figureobjects to prevent making next time
@if [ -n "$(FIGUREOBJS)" ]; then \
touch $(FIGUREOBJS); \
touch $*.aux; \
fi
@if [ -f $*.ind ]; then \
touch $*.ind; \
fi
# @$(MAKEINDEX) -s nomencl.ist -o $*.nls $*.nlo
latex:
# Below the 'true' is included to prevent unnecessarily many errors.
@if [ -n "${LATEXTARGET}" ]; then \
$(MAKE) ${LATEXTARGET}.dvi; \
true; \
else \
if [ `ls *.tex | wc -l` = "1" ]; then \
$(MAKE) `basename \`ls *.tex\` .tex`.dvi; \
true; \
else \
$(MAKE) `echo $$PWD|tr '/' '\n'|tail -1`.dvi; \
true; \
fi; \
fi
latexfigures:
@for i in $(FIGUREOBJS); do \
$(MAKE) $$i; \
done
view:
# Below the 'true' is included to prevent unnecessarily many errors.
@if [ -n "${LATEXTARGET}" ]; then \
$(MAKE) ${LATEXTARGET}.dvi && \
$(DVIVIEWER) ${LATEXTARGET}.dvi ; \
true; \
else \
if [ `ls *.tex | wc -l` = "1" ]; then \
$(MAKE) `basename \`ls *.tex\` .tex`.dvi && \
$(DVIVIEWER) `basename \`ls *.tex\` .tex`.dvi; \
true; \
else \
$(MAKE) `echo $$PWD|tr '/' '\n'|tail -1`.dvi && \
$(DVIVIEWER) `echo $$PWD|tr '/' '\n'|tail -1`.dvi; \
true; \
fi; \
fi
%.ps: %.dvi
$(DVIPS) -o $*.ps $<
# @$(MAKEINDEX) -s nomencl.ist -o $*.nls $*.nlo
$(DVIPS) -o $*.ps $<
%.pdf: %.tex
$(PDFLATEX) $<
# @$(MAKEINDEX) -s nomencl.ist -o $*.nls $*.nlo
# $(BIBTEX) $*
$(PDFLATEX) $<
$(PDFLATEX) $<
latexps:
@if [ -n "${LATEXTARGET}" ]; then \
$(MAKE) ${LATEXTARGET}.ps && \
true; \
else \
if [ `ls *.tex | wc -l` = "1" ]; then \
$(MAKE) `basename \`ls *.tex\` .tex`.ps && \
true; \
else \
$(MAKE) `echo $$PWD|tr '/' '\n'|tail -1`.ps && \
true; \
fi; \
fi
html: .html
.html:
@if [ -n "${LATEXTARGET}" ]; then \
if [ -n "${HTMLDIR}" ]; then \
$(MAKE) ${LATEXTARGET}.dvi; \
$(LATEX2HTML) $(LATEX2HTML_OPTS) -dir $(HTMLDIR)/$(LATEXTARGET) $(LATEXTARGET) && \
chmod a+rx $(HTMLDIR)/$(LATEXTARGET) && \
chmod a+r $(HTMLDIR)/$(LATEXTARGET)/* && \
touch .html; \
else \
echo Set variable HTMLDIR\!; \
fi; \
else \
echo Set variable LATEXTARGET\!; \
fi
latexhelp:
@echo "LaTeX Makefile Options"
@echo "----------------------"
@echo ""
@echo "Environment variables:"
@echo " LATEXTARGET Filename to make (without extension)"
@echo " HTMLDIR Directory for HTML-output"
@echo " FIGURES Figures that have to be compiled"
@echo ""
@echo "Targets:"
@echo " all Make the LATEXTARGET or <dirname>.dvi"
@echo " <name>.dvi Make the given dvi file"
@echo " latex Make the LATEXTARGET or <dirname>.dvi"
@echo " view Make and view the LATEXTARGET or <dirname>.dvi"
@echo " html Make the LATEXTARGET or <dirname>.dvi and generate HTML output"
@echo " latexhelp This overview"
@echo " latexclean Remove all generated files"
clean latexclean::
@rm -f *.log *.aux *.dvi *.bbl *.blg *.ilg *.toc *.lof *.lot *.idx *.ind *.out *.brf *.html *.btmp *.itmp *.rerun *.glo *.gls *.nlo *.nls
@epsfiles=`find * -maxdepth 0 -name "*.eps" `; \
if [ -n "$$epsfiles" ]; then \
for i in *.eps; do \
if [ -f `basename $$i .eps`.fig ]; then \
rm -f $$i; \
elif ( rcs `basename $$i .eps`.fig >& /dev/null ); then \
rm -f $$i; \
fi \
done \
fi
cleanpspdf : clean
@rm -f *.ps *.pdf
clobber : cleanpspdf
@rm -f *~