/articles/bio

To get this branch, use:
bzr branch http://darksoft.org/webbzr/articles/bio
1 by Suren A. Chilingaryan
First draft
1
# Copyright 2004 Chris Monson (shiblon@gmail.com)
2
#           2011 Andrew McNabb
3
#           2013 Krishna Kumar
4
#           2017 Holger Nahrstaedt
5
# Latest version available at http://www.bouncingchairs.net/oss
6
#
7
#    This file is part of ``Chris Monson's Free Software''.
8
#
9
#    ``Chris Monson's Free Software'' is free software; you can redistribute it
10
#    and/or modify it under the terms of the GNU General Public License as
11
#    published by the Free Software Foundation, Version 2.
12
#
13
#    ``Chris Monson's Free Software'' is distributed in the hope that it will
14
#    be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
16
#    Public License for more details.
17
#
18
#    You should have received a copy of the GNU General Public License along
19
#    with ``Chris Monson's Free Software''; if not, write to the Free Software
20
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
#
22
#    It is also available on the web at http://www.gnu.org/copyleft/gpl.html
23
#
24
#    Note that using this makefile to build your documents does NOT place them
25
#    under the GPL unless you, the author, specifically do so.  In other words,
26
#    I, Chris Monson, the copyright holder and author of this makefile,
27
#    consider it impossible to ``link'' to this makefile in any way covered by
28
#    the GPL.
29
#
30
#
31
# TO OBTAIN INSTRUCTIONS FOR USING THIS FILE, RUN:
32
#    make help
33
#
34
fileinfo	:= LaTeX Makefile
35
author		:= Chris Monson
36
version		:= 2.2.1-alpha10
37
#
38
.DEFAULT_GOAL	:= all
39
# Note that the user-global version is imported *after* the source directory,
40
# so that you can use stuff like ?= to get proper override behavior.
41
.PHONY: Makefile GNUmakefile Makefile.ini $(HOME)/.latex-makefile/Makefile.ini
42
-include Makefile.ini
43
-include $(HOME)/.latex-makefile/Makefile.ini
44
# Better names for these things
45
.PHONY: Variables.ini $(HOME)/.latex-makefile/Variables.ini
46
-include Variables.ini
47
-include $(HOME)/.latex-makefile/Variables.ini
48
#
49
# This can be pdflatex or latex - you can change this by adding the following line to your Makefile.ini:
50
# BUILD_STRATEGY := latex
51
#BUILD_STRATEGY		?= pdflatex
52
BUILD_STRATEGY		?= xelatex
53
BIB_STRATEGY		?= biblatex
54
#BIB_STRATEGY		?= bibtex
55
# This can be used to pass extra options to latex.
56
LATEX_OPTS		?=
57
#
58
# Sets LC_ALL=C, by default, so that the locale-aware tools, like sort, be
59
# # immune to changes to the locale in the user environment.
60
export LC_ALL		?= en_US.UTF-8
61
#
62
#
63
# If you specify sources here, all other files with the same suffix
64
# will be treated as if they were _include_ files.
65
#onlysources.tex	?= main.tex
66
#onlysources.lhs	?=
67
#onlysources.tex.sh	?=
68
#onlysources.tex.pl	?=
69
#onlysources.tex.py	?=
70
#onlysources.rst	?=
71
#onlysources.mp		?=
72
#onlysources.fig	?=
73
#onlysources.gpi	?=
74
#onlysources.dot	?=
75
#onlysources.xvg	?=
76
#onlysources.svg	?=
77
#onlysources.eps.gz	?=
78
#onlysources.eps	?=
79
#
80
# If you list files here, they will be treated as _include_ files
81
#includes.tex		?= file1.tex file2.tex
82
#includes.lhs		?=
83
#includes.tex.sh	?=
84
#includes.tex.pl	?=
85
#includes.tex.py	?=
86
#includes.rst		?=
87
#includes.mp		?=
88
#includes.fig		?=
89
#includes.gpi		?=
90
#includes.dot		?=
91
#includes.xvg		?=
92
#includes.svg		?=
93
#includes.eps.gz	?=
94
#includes.eps		?=
95
#
96
# If you list files or wildcards here, they will *not* be cleaned - default is
97
# to allow everything to be cleaned.
98
#neverclean		?= *.pdf
99
#
100
# Alternatively (recommended), you can add those lines to a Makefile.ini file
101
# and it will get picked up automatically without your having to edit this
102
# Makefile.
103
#
104
# KNOWN ISSUES:
105
# * The following occurs:
106
#   file with: \usepackage{named}\bibliographystyle{named}
107
#   Compile
108
#   change to: \usepackage{apalike}\bibliographystyle{apalike}
109
#   Compile again -- BARF!
110
#
111
#   The workaround: make clean-nographics; make
112
#
113
#   Note that we may not be able to fix this.  LaTeX itself barfs
114
#   on this, not the makefile.  The very first invocation of LaTeX
115
#   (when something like this has happened) reads the existing .aux
116
#   file and discovers invalid commands like \citeauthoryear that
117
#   are only valid in the package that was just removed.  It then
118
#   tries to parse them and explodes.  It's not at all clear to me
119
#   how to fix this.  I tried removing the .aux files on the first
120
#   run of LaTeX, but that necessarily requires more subsequent
121
#   rebuilds on common edits.  There does not appear to be a
122
#   graceful solution to this issue.
123
#
124
#
125
# CHANGES:
126
# Holger Nahrstaedt (2017-09-25):
127
# * Bumped version to 2.2.1-alpha10
128
# * Added XELATEX and LUALATEX to BUILD_STRATEGY
129
# * New option BIB_STRATEGY, can be biblatex or bibtex
130
# * Added all Authors to Copyright section
131
# * Added asymptote file generation
132
# * Added shell-escape to pdflatex, xelatex and lualatex
133
# Krishna Kumar (2013-11-27):
134
# * Added PS to rm_ext to remove PS files generated during LaTeX output
135
# Krishna Kumar (2013-11-26):
136
# * Changed PS_EMBED_OPTION ?= -dPDFSETTINGS=/prepress from /printer
137
#
138
# Chris Monson (2012-06-25):
139
# * Bumped version to 2.2.1-alpha9
140
# * Built with Holger Dell's changes to fix multiple unnecessary compilations.
141
# Chris Monson (2011-11-10):
142
# * Issue 144: Help patch from girard.nicolas applied
143
# Andrew McNabb (2011-09-30):
144
# * Bumped version to 2.2.1-alpha8
145
# * Issue 141: No font embedding for gnuplot when not doing pdf
146
# * Syntax error fixed for gpi handling code
147
# Chris Monson (2011-09-06):
148
# * Issue 140: clean mlt*, mlf*, and mtc* files
149
# * Issue 136: initial support for metapost files
150
# Chris Monson (2011-08-09):
151
# * Bumped version to 2.2.1-alpha7
152
# * Issue 138: existing .eps files now included correctly
153
# * Issue 139: added missing backslash to ps build rule
154
# Chris Monson (2011-07-20):
155
# * Added LATEX_OPTS
156
# Chris Monson (2011-06-23):
157
# * Bumped version to 2.2.1-alpha6
158
# * Issue 133: Set jobname to fix .fls generation to always have the source name
159
# * Removed unnecessary (?) double-invocation of cygpath
160
# Chris Monson (2011-06-16):
161
# * Added support for keeping .rst and .lhs tex intermediates around.
162
# * Separated scripts from source generation files (rst and lhs)
163
# * Fixed run-script problem for lhs2tex (was invoked incorrectly)
164
# * Issue 133: Fixed typo from literate Haskell support
165
# Chris Monson (2011-06-13):
166
# * Bumped version to 2.2.1-alpha5
167
# * Fixed problems with detecting graphics for very long source names.
168
# Chris Monson (2011-06-13):
169
# * Issue 134: name of self corrected for dependency graph
170
# * Issue 133: Added literate Haskell support (lhs2tex)
171
# Chris Monson (2011-05-31):
172
# * Rewrote specials (%%COMMENTS) to be easier to extend and parse.
173
# Chris Monson (2011-05-11):
174
# * Bumped version to 2.2.1-alpha4
175
# * Issue 129: nomenclature dependency fix
176
# Chris Monson (2011-05-09):
177
# * Bumped version to 2.2.1-alpha3
178
# * Issue 112: Cygpath fixes
179
# Chris Monson (2011-04-27):
180
# * Bumped version to 2.2.1-alpha2
181
# * Issue 126: Broken log parsing for latex pipeline
182
# * Fixed month in recent changes (had May, should be April)
183
# * Noticed problems with some existing parsing (colorizing errors, notably) and
184
#     fixed them.
185
# * New test case for specified graphic extensions.
186
# * Added .bb generation for .eps files (when extensionless in latex pipeline)
187
# Chris Monson (2011-04-22):
188
# * Bumped version to 2.2.1-alpha1
189
# * Issue 105: add support for format file detection and compilation
190
# Chris Monson (2011-04-20):
191
# * Bumped version to 2.2.0 (release!)
192
# Chris Monson (2011-04-19):
193
# * Bumped version to 2.2.0-rc15
194
# * Issue 125: infinite recursion with nomenclature files
195
# * Issue 125: removed .d as a target for .nls in get-log-index
196
# * Cleaned up invocation of run-makeindex to take an optional .ist instead of flags.
197
# Chris Monson (2011-04-06):
198
# * Bumped version to 2.2.0-rc14
199
# * Issue 121: Added Targets.ini and corresponding help text for it.
200
# * Issue 121: Added Variables.ini (Makefile.ini still works, though).
201
# * Issue 121: Added .DEFAULT_GOAL optional setting.
202
# * Issue 120: xindy compatibility
203
# Chris Monson (2011-03-16):
204
# * Bumped version to 2.2.0-rc13
205
# * Fixed a bug in kspewhich invocation - random characters and a missing pipe.
206
# * Added font embedding to gnuplot output.
207
# Chris Monson (2011-03-15):
208
# * Bumped version to 2.2.0-rc12
209
# * Issue 119: Annoying warning from which if Gnuplot not installed.
210
# * Fixed catchall error output to show more info from the log.  Cutting off the
211
#     first line is too jarring.
212
# * Issue 118: Better glossary support
213
# Chris Monson (2011-03-03):
214
# * Bumped version to 2.2.0-rc11
215
# * Issue 112: Fixed regression introduced by use of cygpath (ugly warnings)
216
# Chris Monson (2011-02-03):
217
# * Bumped version to 2.2.0-rc10
218
# * Issue 112: Added path normalization for cygwin systems
219
# * Fixed a bug in get-missing-inputs where we weren't specifying target files
220
# Chris Monson (2011-01-24):
221
# * Issue 111: Added .jpeg as a possible image extension
222
# Chris Monson (2011-01-21):
223
# * Issue 110: Long filenames not produced correctly in .d file
224
# * Fixed problem with unknown control sequence error parsing
225
# * Fixed problem with \r in fatal output (was interpreted as LF by echo)
226
# * Removed a spurious "hi"
227
# Chris Monson (2011-01-14):
228
# * Bumped version to 2.2.0-rc8
229
# * Issue 107: Removed comment with embedded newline, fixing MinGW on Windows 7.
230
# Chris Monson (2011-01-07):
231
# * Emit an error if .gpi.d files have dependencies with : in the name
232
# Chris Monson (2011-01-05):
233
# * Bumped version to 2.2.0-rc7
234
# * Issue 106: existing graphic dependencies not generated correctly
235
# Chris Monson (2011-01-04):
236
# * Issue 106: not cleaning eps log files properly
237
# * Issue 106: not rebuilding after creating .pdf graphics from .eps
238
# * Issue 94: svg going unnecessarily through eps (can't reproduce)
239
# Chris Monson (2010-12-31):
240
# * Issue 100: make hanging because of faulty graphics detection (sed bug)
241
# * Issue 108: do not ignore fatal errors from pdftex
242
# Chris Monson (2010-12-23):
243
# * Added gpi_global to gnuplot dependencies so that changes are detected
244
# Chris Monson (2010-12-20):
245
# * Updated build file to be smarter about Python version detection
246
# * Created a bunch of test files and supporting scripts
247
# * Issue 72: added apacite capaability (thanks to matkarat)
248
# Chris Monson (2010-11-23):
249
# * Changed to multi-part makefile build (split out sed scripts)
250
# * Added build script and supporting infrastructure
251
# * Updated test directory format
252
# * Added notes about needed test cases
253
# * Changed to use -file-line-error and fixed multiple inclusion/error bugs
254
# * Added run_sed.py to allow easy testing of sed scripts outside of make
255
# Chris Monson (2010-11-11):
256
# * Bumped version to 2.2.0-rc7
257
# * issue 92: broken hyperref driver detection fixed
258
# * issue 101: Broken inkscape conversion
259
# * issue 102: Broken specification of font size for gnuplot pdfcairo
260
# * Added KEEP_TEMP so that we can avoid deleting useful temporaries for debugging
261
# * Restructured gnuplot code to be easier to follow
262
# * Fixed a bug in convert-gpi where we were using $< instead of $1
263
# Chris Monson (2010-11-03):
264
# * Bumped version to 2.2.0-rc6
265
# * issue 96: Fix sed errors when using make variables in substitutions
266
# Chris Monson (2010-07-28):
267
# * Bumped version to 2.2.0-rc5 (rc4 is broken)
268
# * Bail out when we find the use of the import.sty package
269
# * Issue 90: Add -z to dvips invocation
270
# * Issue 67: Add xelatex support (thanks to Nikolai Prokoschenko for the patch!)
271
# * Issue 85: Add warning about make 3.80
272
# Chris Monson (2010-06-20):
273
# * Bumped version to 2.2.0-rc3
274
# * Attempt to fix bug with ! error detection (issue 88)
275
# * Added svg->pdf direct support (issue 89)
276
# Chris Monson (2010-04-28):
277
# * Bumped version to 2.2.0-rc2
278
# * Fixed %._show target
279
# Chris Monson (2010-04-08):
280
# * Bumped version to 2.2.0-rc1
281
# * Added back in the rst_style_file stuff that got broken when switching
282
#     rst -> tex to use the script mechanism
283
# Chris Monson (2010-03-23):
284
# * Bumped version to 2.2.0-beta8
285
# * Work on issue 76: bad backtick escape for some sed versions, failure
286
#     to clear out the hold buffer when outputting MISSING comment.
287
#     - Backed out 2>&1 to &> (doesn't work in sh)
288
#     - Backed out using . to source variables
289
# Chris Monson (2010-03-22):
290
# * Bumped version to 2.2.0-beta7
291
# * Issue 72: Fix latex/bibtex invocation order for annotated bib styles
292
# * Fixed informational output to reflect which LaTeX run we're on
293
# * Fixed graphic detection to include graphics that are already there in
294
#     .d files
295
# * Tightened up the .d file output to only make .d depend on graphic
296
#     *source* files.  This means that building foo.d no longer
297
#     builds all of the graphics files on which foo.tex depends.
298
#     Had to use .SECONDEXPANSION trickery to make it work.
299
# * Changed get-graphics to only accept a stem.
300
# * Fixed build-once logic for scripted .tex to work better
301
# * Made get-inputs sed script more maintainable.
302
# * Moved Makefile.ini import up higher.
303
# * Changed bare stems to not recursively invoke make
304
# * Updated diff output to be more silent everywhere
305
# * Added a MISSING comment to the .d file if stuff isn't found - forces
306
#     removal of .1st.make file, which often forces it to try again.
307
# * Fixed broken graphics-target function
308
# * Added sleep to .d file generation when stuff is missing - if it
309
#     builds too fast, make doesn't realize it needs to be reloaded,
310
#     and thus never discovers some deeper dependencies (especially
311
#     evident when graphics are included from scripted include
312
#     files).
313
# Chris Monson (2010-03-17):
314
# * Bumped version to 2.2.0-beta6
315
# * Fixed bareword builds to actually work (requires static patterns)
316
# * Fixed colorization to work with new paragraph stuff
317
# Chris Monson (2010-03-17):
318
# * Bumped version to 2.2.0-beta5
319
# * Fixed graphic detection to be much more focused - splits log file
320
#     into paragraphs before doing pattern matching.
321
# * Fixed make foo to work properly (recursively calls make foo.pdf)
322
# * Fixed gpi -> pdf generation to not waste time building .eps *after*
323
#     the pdf already exists.
324
# * Changed log copies to include MAKE_RESTARTS as part of the name.
325
# * Fixed missing include file detection (also makes use of the paragraph
326
#     stuff) to detect missing scripted include files.
327
# Chris Monson (2010-03-16):
328
# * Bumped version to 2.2.0-beta4
329
# * issue 70: .pdf not moved out of the way properly on first
330
#     compilation, resulting in early error detection failure.
331
# * issue 74: fixed broken error on missing .aux files: the
332
#     implementation was masking real errors.
333
# Chris Monson (2010-03-15):
334
# * Bumped version to 2.2.0-beta3
335
# * issue 71: Made the tput dependency optional
336
# * issue 73: Made .tex targets not pull in .d files (building them from
337
#     scripts should not require a .d)
338
# * issue 74: Output a much saner error when a .aux file is not produced
339
#     (e.g., when you are typing "make" without arguments in a
340
#     directory with included .tex files that are not named with
341
#     ._include_.)
342
# Chris Monson (2010-03-11):
343
# * Bumped version to 2.2.0-beta2
344
# * Fixed clean-graphics to get rid of intermediate .eps files that may
345
#     be hanging around
346
# * Added an automatic setting to use eps terminals in pdflatex mode for
347
#     gnuplot if it doesn't understand pdf.
348
# * issue 66: Removed grayscale generation via magic suffix.  Grayscale
349
#     generation is now only available via GRAY=1
350
# * issue 68: Added explicit handling of LC_ALL for locale-aware tools
351
#     like "sort"
352
# Chris Monson (2010-03-10):
353
# * Bumped version to 2.2.0-beta1
354
# * Fixed success message to handle output message in different places
355
# * Added name of produced file to success message
356
# Chris Monson (2010-03-10):
357
# * Bumped version to 2.2.0-alpha3
358
# * Added meaningful error message for wrong hyperref options
359
# * Added meaningful error message for incorrect graphics extensions
360
# Chris Monson (2010-03-09):
361
# * Bumped version to 2.2.0-alpha2
362
# * Updated graphics handling (gnuplot and fig generate pdf natively)
363
# * Changed xmgrace to output monochrome natively
364
# Chris Monson (2010-03-09):
365
# * Bumped version to 2.2.0-alpha1 - major change!
366
# * Support pdflatex natively and by default (issue 6 - a long time coming)
367
# * Add ability to have a single $HOME/.latex-makefile/Makefile.ini for
368
#     all invocations
369
# * Reworked graphic inclusion detection so that extensions need not be
370
#     specified for either build strategy (e.g.,
371
#     \includegraphics{test1.eps} -> \includegrahpics{test1})
372
# * Changed log format to include filenames and line numbers
373
# Chris Monson (2010-02-04):
374
# * Bumped version to 2.1.43
375
# * All of the following are for issue 63 (thanks to mojoh81):
376
# * Added documentation about fixing Makefile.ini default target
377
# * Added perl and python script targets
378
# * Fixed run logic to allow included .tex files to be scripted (the
379
#     run-again logic now detects missing .tex files, and the MV
380
#     command has been switched out for a command that only invokes
381
#     MV if the files exist)
382
# * Changed scripted generation to only run once per make invocation
383
# * Added dependency on expr
384
# Chris Monson (2010-01-19):
385
# * Bumped version to 2.1.42
386
# * issue 62: Added .brf extension to cleanable files (backrefs)
387
# Chris Monson (2010-01-07):
388
# * Bumped version to 2.1.41
389
# * issue 60: bad makeindex runs now error out on subsequent tries
390
# Chris Monson (2009-12-01):
391
# * Bumped version to 2.1.40
392
# * issue 36: build all indices (for e.g., splitidx usage)
393
# * issue 59: clean up all generated files (including indices)
394
# Chris Monson (2009-11-23):
395
# * Bumped version to 2.1.39
396
# * issue 57: change ps2pdf invocations to just use gs directly
397
# Chris Monson (2009-11-19):
398
# * Bumped version to 2.1.38
399
# * issue 57: Added some limited support for Cygwin (spaces in filenames)
400
# Chris Monson (2009-11-15):
401
# * Bumped version to 2.1.37
402
# * Removed svninfo, since this is now managed by mercurial
403
# * Fixed typo in changelist
404
# * Issue 52: added jpg->eps conversion (thanks to brubakee)
405
# * Issue 54: fix missing Overfull colorization due to lack of a blank
406
#     line preceding the first error.
407
# * Issue 51: remove head.tmp and body.tmp in make clean invocation
408
# * Issue 56: maintain multiple versions of log files (for debugging)
409
# Chris Monson (2009-11-14):
410
# * Bumped version to 2.1.36
411
# * Issues 53 and 49: added .brf, .mtc, and .maf to the cleanables
412
# Chris Monson (2009-11-05):
413
# * Bumped version to 2.1.35
414
# * Added nomenclature support (see issue 48)
415
# Chris Monson (2009-10-29):
416
# * Bumped version to 2.1.34
417
# * Fixed _out_ creation bug introduced in 2.1.33 (it was always created)
418
# * Fixed erroneous help output for $HOME in BINARY_TARGET_DIR
419
# * Changed contact email address - bring on the spam!
420
# Chris Monson (2009-10-21):
421
# * Bumped version to 2.1.33
422
# * Fixed issue 46, adding support for dot2tex (thanks to fdemesmay)
423
# * Made all_files.* settable in Makefile.ini (using ?= instead of :=)
424
# * Fixed issue 47, thanks to fdemesmay: add binary copy directory, copy
425
#     dvi, pdf, and ps if it exists
426
# Chris Monson (2009-09-25):
427
# * Bumped version to 2.1.32
428
# * Fixed so that a changed lol file will cause a rebuild
429
# * Added .lol files to the cleanable list
430
# Chris Monson (2009-09-08):
431
# * Bumped version to 2.1.31
432
# * Closed issue 43: evince doesn't notice pdf change w/out touch
433
# Chris Monson (2009-08-28):
434
# * Bumped version to 2.1.30
435
# * Closed issue 39: Capture multi-line log warnings/errors to output
436
# Chris Monson (2009-08-26):
437
# * Bumped version to 2.1.29
438
# * Closed issue 42: add svg support using inkscape
439
# Chris Monson (2009-08-17):
440
# * Bumped version to 2.1.28
441
# * Patch from paul.biggar for issue 38: package warnings are overlooked
442
# Chris Monson (2009-08-07):
443
# * Bumped version to 2.1.27
444
# * Included patch for issue 37 - removes pdf/ps files before copying,
445
#     allowing some broken viewers to see changes properly.
446
# Chris Monson (2009-05-15):
447
# * Bumped version to 2.1.26
448
# * Included patch for issue 9 from favonia - detects .fig changes for
449
#     pstex files during regular compilation, so long as the pstex
450
#     has been built at least once with make all-pstex.
451
# Chris Monson (2009-03-27):
452
# * Bumped version to 2.1.25
453
# * Cleaned up a bunch of variable setting stuff - more stuff is now
454
#     settable from Makefile.ini
455
# * Cleaned up documentation for various features, especially settable
456
#     variables.
457
# * issue 28: support for png -> eps conversion (it even looks good!)
458
# * issue 29: support for "neverclean" files in Makefile.ini
459
# * issue 30: make ps2pdf14 the default - fall back when not there
460
# Chris Monson (2009-03-09):
461
# * Bumped version to 2.1.24
462
# * issue 27: xmgrace support (thanks to rolandschulzhd)
463
# Chris Monson (2008-10-23):
464
# * Bumped version to 2.1.23
465
# * issue 23: fixed _check_programs to not use bash string subs
466
# Chris Monson (2008-09-02):
467
# * Bumped version to 2.1.22
468
# * Appled patch from Holger <yllohy@googlemail.com> to add include
469
#     sources and some documentation updates.
470
# * Updated backup_patterns to be a bit more aggressive (also thanks to
471
#     Holger)
472
# Chris Monson (2008-08-30):
473
# * Bumped version to 2.1.21
474
# * Added ability to specify onlysources.* variables to indicate the only
475
#     files that should *not* be considered includes.  Thanks to Holger
476
#     <yllohy@googlemail.com> for this patch.
477
# * Added an automatic include of Makefile.ini if it exists.  Allows
478
#     settings to be made outside of this makefile.
479
# Chris Monson (2008-05-21):
480
# * Bumped version to 2.1.20
481
# * Added manual pstex compilation support (run make all-pstex first)
482
# * Removed all automatic pstex support.  It was totally breaking
483
#     everything and is very hard to incorporate into the makefile
484
#     concept because it requires LaTeX to *fail* before it can
485
#     determine that it needs the files.
486
# Chris Monson (2008-04-17):
487
# * Bumped version to 2.1.19
488
# * Changed the pstex build hack to be on by default
489
# Chris Monson (2008-04-09):
490
# * Bumped version to 2.1.18
491
# * issue 16: fixed pstex build problems, seems nondeterministic.  Added
492
#     gratuitious hack for testing: set PSTEX_BUILD_ALL_HACK=1.
493
# Chris Monson (2008-04-09):
494
# * Bumped version to 2.1.17
495
# * issue 20: fixed accumulation of <pid>*.make files - wildcard was
496
#     refusing to work on files that are very recently created.
497
# Chris Monson (2008-04-02):
498
# * Bumped version to 2.1.16
499
# * issue 19: Removed the use of "type" to fix broken "echo" settings
500
# Chris Monson (2008-03-27):
501
# * Bumped version to 2.1.15
502
# * issue 18: Favors binary echo over builtin, as binary understands -n
503
# * issue 16: Fixed handling of missing pstex_t files in the log
504
# * issue 9: Added .SECONDARY target for .pstex files
505
# Chris Monson (2008-03-21):
506
# * Bumped version to 2.1.14
507
# * Fixed broken aux file flattening, which caused included bibs to be
508
#     missed.
509
# Chris Monson (2008-03-20):
510
# * Bumped version to 2.1.13
511
# * Changed error output colorization to show errors for missing files
512
#     that are not graphics files.
513
# Chris Monson (2008-03-20):
514
# * Bumped version to 2.1.12
515
# * Fixed a regression introduced in r28 that makes bibtex fail when
516
#     there is no index file present
517
# Chris Monson (2008-03-03):
518
# * Bumped version to 2.1.11
519
# * Fixed issue 11 (handle index files, reported by abachn)
520
# * Cleaned up some comments and help text
521
# Chris Monson (2008-01-24):
522
# * Bumped version to 2.1.10
523
# * Fixed to work when 'sh' is a POSIX shell like 'dash'
524
# Chris Monson (2007-12-12):
525
# * Bumped version to 2.1.9
526
# * Fixed documentation and dependency graph for pstex files
527
# Chris Monson (2007-12-12):
528
# * Bumped version to 2.1.8
529
# * Added basic pstex_t support for fig files (Issue 9 by favonia)
530
#     I still suggest that psfrag be used instead.
531
# Chris Monson (2007-10-16):
532
# * Bumped version to 2.1.7
533
# * Removed todo item: allow other comment directives for rst conversion
534
# * Added ability to use global rst style file _rststyle_._include_.tex
535
# * Added help text to that effect
536
# Chris Monson (2007-05-20):
537
# * Bumped version to 2.1.6
538
# * Changed default paper size for rst files
539
# * Added todo item: fix paper size for rst files
540
# * Added todo item: allow other comment directives for rst conversion
541
# Chris Monson (2007-04-02):
542
# * Bumped version to 2.1.5
543
# * Addressed Issue 7, incorrect .gpi.d generation in subdirectories
544
# Chris Monson (2007-03-28):
545
# * Bumped version to 2.1.4
546
# * Fixed syntax error in dot output
547
# Chris Monson (2007-03-01):
548
# * Bumped version to 2.1.3
549
# * Added reST to the included documentation
550
# * Fixed graphics and script generation to be settable in the
551
#     environment.
552
# Chris Monson (2007-02-23):
553
# * Bumped version to 2.1.2
554
# * Added the ability to generate .tex files from .rst files
555
# Chris Monson (2006-10-17):
556
# * Bumped version to 2.1.1
557
# * Fixed includes from subdirectories (sed-to-sed slash escape problem)
558
# Chris Monson (2006-10-05):
559
# * Bumped version to 2.1.0 (pretty serious new feature added)
560
# * New feature: bib files can now be anywhere on the BIBINPUTS path
561
# * New programs: kpsewhich (with tetex) and xargs (BSD)
562
# Chris Monson (2006-09-28):
563
# * Bumped version to 2.0.9
564
# * Added ability to parse more than one bibliography
565
# Chris Monson (2006-06-01):
566
# * Bumped version to 2.0.8
567
# * Added .vrb to the list of cleaned files
568
# Chris Monson (2006-04-26):
569
# * Bumped version to 2.0.7
570
# * Fixed so that clean-nographics does not remove .gpi.d files
571
# * Removed jpg -> eps hack (not working properly -- just pre-convert)
572
# * Fixed so that postscript grayscale can be done with BSD sed
573
# Chris Monson (2006-04-25):
574
# * Bumped version to 2.0.6
575
# * Fixed so that changed toc, lot, lof, or out causes a rebuild
576
# Chris Monson (2006-04-17):
577
# * Bumped version to 2.0.5
578
# * Added jpg -> eps conversion target
579
# Chris Monson (2006-04-12):
580
# * Bumped version to 2.0.4
581
# * Fixed BSD sed invocation to not use \| as a branch delimiter
582
# * Added a comment section on what is and is not allowed in BSD sed
583
# * Made paper size handling more robust while I was at it
584
# * Fixed postscript RGB grayscale to use a weighted average
585
# * Fixed postscript HSB grayscale to convert to RGB first
586
# * Fixed a problem with rebuilding .bbl files
587
# Chris Monson (2006-04-11):
588
# * Bumped version to 2.0.3
589
# * Fixed some BSD sed problems: can't use \n in substitutions
590
# Chris Monson (2006-04-10):
591
# * Bumped version to 2.0.2
592
# * Once again removed ability to create .tex files from scripts
593
# * \includeonly works again
594
# Chris Monson (2006-04-09):
595
# * Bumped version to 2.0.1
596
# * Fixed grayscale postscript handling to be more robust
597
# * Added ability to generate ._gray_. files from eps and eps.gz
598
# * Added ability to clean ._gray_.eps files created from .eps files
599
# Chris Monson (2006-04-07):
600
# * Bumped version to 2.0.0
601
# * Removed clunky ability to create included .tex files from scripts
602
# * Added note in the help about included tex scripting not working
603
# * Fixed the .eps generation to delete %.gpihead.make when finished
604
# * Abandoned designs to use shell variables to create sed scripts
605
# * Abandoned __default__.tex.sh idea: it causes recursion with %: .
606
# * Removed web page to-do.  All items are now complete.
607
# * Added better grayscale conversion for dot figures (direct ps fixup).
608
# * Include files can now be scripted (at the expense of \includeonly).
609
# * Updated dependency graph to contain better node names.
610
# Chris Monson (2006-04-06):
611
# * Bumped version to 2.0b3
612
# * Top level includes now fail if there is no rule to build them
613
# * A helpful message is printed when they do fail
614
# * Grayscale has been changed to be ._gray_, other phonies use _ now, too
615
# * Grayscale handling has been completed
616
# * Changed _include_stems target to _includes target.
617
# * Fixed _includes target to be useful by itself.
618
# * Removed the ability to specify clean and build targets at once
619
# * Verified that epsfig works fine with current code
620
# * Fixed included scripts so that they are added to the dep files
621
# * Fixed so that graphics includes don't happen if they aren't for gpi
622
# * Fixed dot output to allow grayscale.
623
# Chris Monson (2006-04-05):
624
# * Bumped version to 2.0b2
625
# * Removed automatic -gray output.  It needs fixing in a bad way.
626
# * Revamped dependency creation completely.
627
# * Fixed conditional inclusion to actually work (test.nobuild.d, test.d).
628
# * Fixed clean target to remove log targets
629
# * Added the 'monochrome' word for gray gpi output
630
# * Added a _check_gpi_files target that checks for common problems
631
# * Changed the _version target into the version target (no _)
632
# * Added better handling of grayscale files.  Use the .gray.pdf target.
633
# * Fixed testing for rebuilds
634
# Chris Monson (2006-04-04):
635
# * Bumped version to 2.0b1
636
# * Changed colorization of output
637
# * Made .auxbbl and .auxtex .make files secondary targets
638
# * Shortened and simplified the final latex invocation loop
639
# * Added version-specific output ($$i vs. $$$$i) in latex loop
640
# * Added a build message for the first .dvi run (Building .dvi (0))
641
# * Removed some build messages that most people don't care about.
642
# * Simplified procedure for user-set colors -- simple text specification
643
# * Fixed diff output to...not output.
644
# * Fixed rerun bug -- detect not only when preceded with LaTeX Warning
645
# * Sped up gpi plotting
646
# * Added error handling and colorized output for gpi failure
647
# * Documented color changing stuff.
648
# * Now sort the flattened aux file to avoid false recompilation needs
649
# * Added clean-nographics target
650
# * Don't remove self.dvi file if self.aux is missing in the log
651
# * Clarified some code.  Did some very minor adjusting.
652
# Chris Monson (2006-04-03):
653
# * Bumped version to 2.0a7
654
# * Added .dvi and .ps files as secondary files.
655
# * Fixed handling of multiple run detection when includeonly is in use.
656
# * Added code to flatten .aux files.
657
# * Added more files as .SECONDARY prerequisites to avoid recompilation.
658
# * Fixed the inputs generation to be much simpler and to use pipes.
659
# * Added the dependency graph directly into the makefile.
660
# * Changed flatten-aux to remove \@writefile \relax \newlabel, etc.
661
# * Undid pipe changes with sed usage (BSD sed doesn't know -f-).
662
# * Added a _check_programs target that tells you what your system has.
663
# * Fixed an error in colorization that made unnecessary errors appear
664
# * Added view targets.
665
# * Updated help text.
666
# * Augmented cookies so that .aux can trigger .bbl and .dvi rebuilds
667
# * Added more informative error handling for dvips and ps2pdf
668
# Chris Monson (2006-04-02):
669
# * Bumped version to 2.0a6
670
# * Added indirection to .bbl dependencies to avoid rebuilding .bbl files
671
# * Streamlined the diff invocation to eliminate an existence test
672
# * Removed special shell quote escape variables
673
# * Moved includes to a more prominent location
674
# * Fixed .inputs.make to not contain .aux files
675
# * Fixed embedding to use a file instead of always grepping.
676
# * Added *.make.temp to the list of cleanable files
677
# * Fixed Ruby.  It should now be supported properly.
678
# * Now differentiate between all, default, and buildable files.
679
# * Fixed to bail out on serious errors.
680
# * Revised the handling of includable files.  Still working on it.
681
# Chris Monson (2006-03-31):
682
# * Bumped version to 2.0a5
683
# * Fixed a bug with LaTeX error detection (there can be spaces)
684
# * Added .bbl support, simplifying everything and making it more correct
685
# * Refactored some tests that muddy the code
686
# * Did a little cleanup of some shell loops that can safely be make loops
687
# * Added support for graphviz .dot files
688
# * Made _all_programs output easier to read
689
# * Added the ruby support that has long been advertised
690
# * Font embedding was screwed up for PostScript -- now implicit
691
# * Changed the generation of -gray.gpi files to a single command
692
# * Changed any make-generated file that is not included from .d to .make
693
# Chris Monson (2006-03-30):
694
# * Bumped version to 2.0a4
695
# * Fixed a bug with very long graphics file names
696
# * Added a todo entry for epsfig support
697
# * Fixed a bug paper size bug: sometimes more than one entry appears
698
# * Fixed DVI build echoing to display the number instead of process ID
699
# * DVI files are now removed on first invocation if ANY file is missing
700
# * Added a simple grayscale approach: if a file ends with -gray.gpi, it
701
#     is created from the corresponding .gpi file with a special
702
#     comment ##GRAY in its header, which causes coloring to be
703
#     turned off.
704
# * Fixed a bug in the handling of .tex.sh files.  For some reason I had
705
#     neglected to define file stems for scripted output.
706
# * Removed a trailing ; from the %.graphics dependencies
707
# * Added dvips embedding (I think it works, anyway)
708
# Chris Monson (2006-03-29):
709
# * Bumped version to 2.0a3
710
# * Fixed error in make 3.79 with MAKEFILE_LIST usage
711
# * Added the presumed filename to the _version output
712
# * Added a vim macro for converting sed scripts to make commands
713
# * Added gpi dependency support (plotting external files and loading gpi)
714
# * Allow .gpi files to be ignored if called .include.gpi or .nobuild.gpi
715
# * Fixed sed invocations where \+ was used.  BSD sed uses \{1,\}.
716
# Chris Monson (2006-03-28):
717
# * Bumped version to 2.0a2
718
# * Added SHELL_DEBUG and VERBOSE options
719
# * Changed the default shell back to /bin/sh (unset, in other words)
720
# * Moved .PHONY declarations closer to their targets
721
# * Moved help text into its own define block to obtain better formatting
722
# * Removed need for double-entry when adding a new program invocation
723
# * Moved .SECONDARY declaration closer to its relevant occurrence
724
# * Commented things more heavily
725
# * Added help text about setting terminal and output in gnuplot
726
# * Created more fine-grained clean targets
727
# * Added a %.graphics target that generates all of %'s graphics
728
# * Killed backward-compatible graphics generation (e.g., eps.gpi=gpi.eps)
729
# * For now, we're just GPL 2, not 3.  Maybe it will change later
730
# * Made the version and svninfo into variables
731
# Chris Monson (2006-03-27):
732
# * Bumped version to 2.0a1
733
# * Huge, sweeping changes -- automatic dependencies
734
#
735
736
# IMPORTANT!
737
#
738
# When adding to the following list, do not introduce any blank lines.  The
739
# list is extracted for documentation using sed and is terminated by a blank
740
# line.
741
#
742
# EXTERNAL PROGRAMS:
743
# = ESSENTIAL PROGRAMS =
744
# == Basic Shell Utilities ==
745
CAT		?= cat
746
CP		?= cp -f
747
DIFF		?= diff
748
ECHO		?= echo
749
EGREP		?= egrep
750
ENV		?= env
751
EXPR		?= expr
752
MV		?= mv -f
753
SED		?= sed
754
SORT		?= sort
755
TOUCH		?= touch
756
UNIQ		?= uniq
757
WHICH		?= which
758
XARGS		?= xargs
759
SLEEP		?= sleep
760
# == LaTeX (tetex-provided) ==
761
BIBTEX		?= bibtex
762
BIBER		?= biber
763
DVIPS		?= dvips
764
LATEX		?= latex
765
PDFLATEX	?= pdflatex --shell-escape
766
XELATEX		?= xelatex --shell-escape
767
LUALATEX    ?= lualatex --shell-escape
768
EPSTOPDF	?= epstopdf
769
MAKEINDEX	?= makeindex
770
XINDY		?= xindy
771
KPSEWHICH	?= kpsewhich
772
GS		?= gs
773
# = OPTIONAL PROGRAMS =
774
# == For MikTex under Cygwin, to get path names right
775
CYGPATH		?= cygpath
776
# == Makefile Color Output ==
777
TPUT		?= tput
778
# == TeX Generation ==
779
PERL		?= perl
780
PYTHON		?= python
781
RST2LATEX	?= rst2latex.py
782
LHS2TEX		?= lhs2tex
783
# == EPS Generation ==
784
CONVERT		?= convert	# ImageMagick
785
DOT		?= dot		# GraphViz
786
DOT2TEX		?= dot2tex	# dot2tex - add options (not -o) as needed
787
MPOST		?= mpost	# MetaPost
788
FIG2DEV		?= fig2dev	# XFig
789
GNUPLOT		?= gnuplot	# GNUplot
790
INKSCAPE	?= inkscape	# Inkscape (svg support)
791
XMGRACE		?= xmgrace	# XMgrace
792
PNGTOPNM	?= pngtopnm	# From NetPBM - step 1 for png -> eps
793
PPMTOPGM	?= ppmtopgm	# From NetPBM - (gray) step 2 for png -> eps
794
PNMTOPS		?= pnmtops	# From NetPBM - step 3 for png -> eps
795
GUNZIP		?= gunzip	# GZipped EPS
796
ASYMPTOTE   ?= asy
797
# == Beamer Enlarged Output ==
798
PSNUP		?= psnup
799
# == Viewing Stuff ==
800
VIEW_POSTSCRIPT	?= gv
801
VIEW_PDF	?= xpdf
802
VIEW_GRAPHICS	?= display
803
804
# Xindy glossaries
805
XINDYLANG	?= english
806
XINDYENC	?= utf8
807
808
# If cygpath is present, then we create a path-norm function that uses it,
809
# otherwise the function is just a no-op.  Issue 112 has details.
810
USE_CYGPATH := $(if $(shell $(WHICH) $(CYGPATH) 2>/dev/null),yes,)
811
812
define path-norm
813
$(if $(USE_CYGPATH),$(shell $(CYGPATH) -u "$1"),$1)
814
endef
815
816
# Command options for embedding fonts and postscript->pdf conversion
817
PS_EMBED_OPTIONS	?= -dPDFSETTINGS=/prepress -dEmbedAllFonts=true -dSubsetFonts=true -dMaxSubsetPct=100
818
PS_COMPATIBILITY	?= 1.4
819
820
# If set to something, will cause temporary files to not be deleted immediately
821
KEEP_TEMP	?=
822
823
# Defaults for GPI
824
DEFAULT_GPI_EPS_FONTSIZE	?= 22
825
DEFAULT_GPI_PDF_FONTSIZE	?= 12
826
827
# Style file for ReST
828
RST_STYLE_FILE			?= $(wildcard _rststyle_._include_.tex)
829
830
# This ensures that even when echo is a shell builtin, we still use the binary
831
# (the builtin doesn't always understand -n)
832
FIXED_ECHO	:= $(if $(findstring -n,$(shell $(ECHO) -n)),$(shell which echo),$(ECHO))
833
ECHO		:= $(if $(FIXED_ECHO),$(FIXED_ECHO),$(ECHO))
834
835
define determine-gnuplot-output-extension
836
$(if $(shell $(WHICH) $(GNUPLOT) 2>/dev/null),
837
     $(if $(findstring unknown or ambiguous, $(shell $(GNUPLOT) -e "set terminal pdf" 2>&1)),
838
	  eps, pdf),
839
     none)
840
endef
841
842
GNUPLOT_OUTPUT_EXTENSION	?= $(strip $(call determine-gnuplot-output-extension))
843
844
# Internal code should use this because of :=.  This means that the potentially
845
# expensive script invocation used to determine whether pdf is available will
846
# only be run once.
847
GPI_OUTPUT_EXTENSION := $(strip $(GNUPLOT_OUTPUT_EXTENSION))
848
849
# Note, if the terminal *does* understand fsize, then we expect this call to
850
# create a specific error here: "fsize: expecting font size".  Otherwise, we
851
# assume that fsize is not understood.
852
GPI_FSIZE_SYNTAX := $(strip \
853
$(if \
854
  $(filter pdf,$(GPI_OUTPUT_EXTENSION)),\
855
  $(if \
856
    $(findstring fsize: expecting font size,$(shell $(GNUPLOT) -e "set terminal pdf fsize" 2>&1)),\
857
    fsize FONTSIZE,\
858
    font ",FONTSIZE"),\
859
  FONTSIZE))
860
861
# Directory into which we place "binaries" if it exists.
862
# Note that this can be changed on the commandline or in Makefile.ini:
863
#
864
# Command line:
865
#   make BINARY_TARGET_DIR=$HOME/pdfs myfile.pdf
866
#
867
# Also, you can specify a relative directory (relative to the Makefile):
868
#   make BINARY_TARGET_DIR=pdfs myfile.pdf
869
#
870
# Or, you can use Makefile.ini:
871
#
872
#   BINARY_TARGET_DIR := $(HOME)/bin_out
873
#
874
BINARY_TARGET_DIR	?= _out_
875
876
RESTARTS		:= $(if $(MAKE_RESTARTS),$(MAKE_RESTARTS),0)
877
# SH NOTES
878
#
879
# On some systems, /bin/sh, which is the default shell, is not linked to
880
# /bin/bash.  While bash is supposed to be sh-compatible when invoked as sh, it
881
# just isn't.  This section details some of the things you have to stay away
882
# from to remain sh-compatible.
883
#
884
#	* File pattern expansion does not work for {}
885
#	* [ "$x" = "$y" ] has to be [ x"$x" x"$y" ]
886
#	* &> for stderr redirection doesn't work, use 2>&1 instead
887
#
888
# BSD SED NOTES
889
#
890
# BSD SED is not very nice compared to GNU sed, but it is the most
891
# commonly-invoked sed on Macs (being based on BSD), so we have to cater to
892
# it or require people to install GNU sed.  It seems like the GNU
893
# requirement isn't too bad since this makefile is really a GNU makefile,
894
# but apparently GNU sed is much less common than GNU make in general, so
895
# I'm supporting it here.
896
#
897
# Sad experience has taught me the following about BSD sed:
898
#
899
# 	* \+ is not understood to mean \{1,\}
900
# 	* \| is meaningless (does not branch)
901
# 	* \n cannot be used as a substitution character
902
# 	* ? does not mean \{0,1\}, but is literal
903
# 	* a\ works, but only reliably for a single line if subsequent lines
904
# 		have forward slashes in them (as is the case in postscript)
905
#
906
# For more info (on the Mac) you can consult
907
#
908
# man -M /usr/share/man re_format
909
#
910
# And look for the word "Obsolete" near the bottom.
911
912
#
913
# EXTERNAL PROGRAM DOCUMENTATION SCRIPT
914
#
915
916
# $(call output-all-programs,[<output file>])
917
define output-all-programs
918
	[ -f '$(this_file)' ] && \
919
	$(SED) \
920
		-e '/^[[:space:]]*#[[:space:]]*EXTERNAL PROGRAMS:/,/^$$/!d' \
921
		-e '/EXTERNAL PROGRAMS/d' \
922
		-e '/^$$/d' \
923
		-e '/^[[:space:]]*#/i\ '\
924
		-e 's/^[[:space:]]*#[[:space:]][^=]*//' \
925
		$(this_file) $(if $1,> '$1',) || \
926
	$(ECHO) "Cannot determine the name of this makefile."
927
endef
928
929
# If they misspell gray, it should still work.
930
GRAY	?= $(call get-default,$(GREY),)
931
932
#
933
# Utility Functions and Definitions
934
#
935
#
936
# Transcript
937
# For debug/testing purposes: writes a message to
938
# filename.transcript.make for each command that was run, including
939
# some human-readable justification for why it had to be run.
940
# For example: "Running latex (log-file indicated that this is necessary)"
941
# Set WRITE_TRANSCRIPT to something to activate
942
WRITE_TRANSCRIPT ?=
943
# Set reason for the next run call
944
# $(call set-run-reason,message)
945
set-run-reason = export run_reason="$1"
946
# Log command to the transcript file
947
# $(call set-run-reason,command,job_name)
948
define transcript
949
$(if $(WRITE_TRANSCRIPT), \
950
	$(ECHO) "Running $1 ($$run_reason)" >> $2.transcript.make; \
951
	export run_reason="", \
952
	$(sh_true))
953
endef
954
955
# Don't call this directly - it is here to avoid calling wildcard more than
956
# once in remove-files.
957
remove-files-helper	= $(if $1,$(RM) $1,$(sh_true))
958
959
# $(call remove-files,file1 file2)
960
remove-files		= $(call remove-files-helper,$(wildcard $1))
961
962
# Removes all cleanable files in the given list
963
# $(call clean-files,file1 file2 file3 ...)
964
# Works exactly like remove-files, but filters out files in $(neverclean)
965
clean-files		= \
966
	$(call remove-files-helper,$(call cleanable-files,$(wildcard $1)))
967
968
# Outputs all generated files to STDOUT, along with some others that are
969
# created by these (e.g., .idx files end up producing .ilg and .ind files).
970
# Discovered by reading *.fls OUTPUT lines and producing corresponding .ind
971
# filenames as needed.
972
#
973
# $(call get-generated-names,<source recorder file (*.fls)>)
974
define get-generated-names
975
[ -f '$1' ] && \
976
$(SED) \
977
	-e '/^OUTPUT /{' \
978
	-e '  s///' \
979
	-e '  p' \
980
	-e '  s/\.idx/\.ind/p' \
981
	-e '  s/\.ind/\.ilg/p' \
982
	-e '}' \
983
	-e 'd' \
984
	'$1' \
985
| $(SORT) | $(UNIQ)
986
endef
987
988
# This removes files without checking whether they are there or not.  This
989
# sometimes has to be used when the file is created by a series of shell
990
# commands, but there ends up being a race condition: make doesn't know about
991
# the file generation as quickly as the system does, so $(wildcard ...) doesn't
992
# work right.  Blech.
993
# $(call remove-temporary-files,filenames)
994
remove-temporary-files	= $(if $(KEEP_TEMP),:,$(if $1,$(RM) $1,:))
995
996
# Create an identifier from a file name
997
# $(call cleanse-filename,filename)
998
cleanse-filename	= $(subst .,_,$(subst /,__,$1))
999
1000
# Escape dots
1001
# $(call escape-fname-regex,str)
1002
escape-fname-regex	= $(subst /,\\/,$(subst .,\\.,$1))
1003
1004
# Test that a file exists
1005
# $(call test-exists,file)
1006
test-exists		= [ -e '$1' ]
1007
# $(call test-not-exists,file)
1008
test-not-exists   = [ ! -e '$1' ]
1009
1010
# $(call move-files,source,destination)
1011
move-if-exists		= $(call test-exists,$1) && $(MV) '$1' '$2'
1012
1013
# Copy file1 to file2 only if file2 doesn't exist or they are different
1014
# $(call copy-if-different,sfile,dfile)
1015
copy-if-different	= $(call test-different,$1,$2) && $(CP) '$1' '$2'
1016
copy-if-exists		= $(call test-exists,$1) && $(CP) '$1' '$2'
1017
move-if-different	= $(call test-different,$1,$2) && $(MV) '$1' '$2'
1018
replace-if-different-and-remove	= \
1019
	$(call test-different,$1,$2) \
1020
	&& $(MV) '$1' '$2' \
1021
	|| $(call remove-files,'$1')
1022
1023
# Note that $(DIFF) returns success when the files are the SAME....
1024
# $(call test-different,sfile,dfile)
1025
test-different		= ! $(DIFF) -q '$1' '$2' >/dev/null 2>&1
1026
test-exists-and-different	= \
1027
	$(call test-exists,$2) && $(call test-different,$1,$2)
1028
1029
# Return value 1, or value 2 if value 1 is empty
1030
# $(call get-default,<possibly empty arg>,<default value if empty>)
1031
get-default	= $(if $1,$1,$2)
1032
1033
# Copy a file and log what's going on
1034
# $(call copy-with-logging,<source>,<target>)
1035
define copy-with-logging
1036
if [ -d '$2/' ]; then \
1037
	if $(CP) '$1' '$2/'; then \
1038
		$(ECHO) "$(C_INFO)Copied '$1' to '$2/'$(C_RESET)"; \
1039
	else \
1040
		$(ECHO) "$(C_ERROR)Failed to copy '$1' to '$2/'$(C_RESET)"; \
1041
	fi; \
1042
fi
1043
endef
1044
1045
# Gives a reassuring message about the failure to find include files
1046
# $(call include-message,<list of include files>)
1047
define include-message
1048
$(strip \
1049
$(if $(filter-out $(wildcard $1),$1),\
1050
	$(shell $(ECHO) \
1051
	"$(C_INFO)NOTE: You may ignore warnings about the"\
1052
	"following files:" >&2;\
1053
	$(ECHO) >&2; \
1054
	$(foreach s,$(filter-out $(wildcard $1),$1),$(ECHO) '     $s' >&2;)\
1055
	$(ECHO) "$(C_RESET)" >&2)
1056
))
1057
endef
1058
# Characters that are hard to specify in certain places
1059
space		:= $(empty) $(empty)
1060
colon		:= \:
1061
comma		:= ,
1062
1063
# Useful shell definitions
1064
sh_true		:= :
1065
sh_false	:= ! :
1066
1067
# Clear out the standard interfering make suffixes
1068
.SUFFIXES:
1069
1070
# Turn off forceful rm (RM is usually mapped to rm -f)
1071
ifdef SAFE_RM
1072
RM	:= rm
1073
endif
1074
1075
# Turn command echoing back on with VERBOSE=1
1076
ifndef VERBOSE
1077
QUIET	:= @
1078
endif
1079
1080
# Turn on shell debugging with SHELL_DEBUG=1
1081
# (EVERYTHING is echoed, even $(shell ...) invocations)
1082
ifdef SHELL_DEBUG
1083
SHELL	+= -x
1084
endif
1085
1086
# Get the name of this makefile (always right in 3.80, often right in 3.79)
1087
# This is only really used for documentation, so it isn't too serious.
1088
ifdef MAKEFILE_LIST
1089
this_file	:= $(firstword $(MAKEFILE_LIST))
1090
else
1091
this_file	:= $(wildcard GNUmakefile makefile Makefile)
1092
endif
1093
1094
# Terminal color definitions
1095
1096
REAL_TPUT 	:= $(if $(NO_COLOR),,$(shell $(WHICH) $(TPUT)))
1097
1098
# $(call get-term-code,codeinfo)
1099
# e.g.,
1100
# $(call get-term-code,setaf 0)
1101
get-term-code = $(if $(REAL_TPUT),$(shell $(REAL_TPUT) $1),)
1102
1103
black	:= $(call get-term-code,setaf 0)
1104
red	:= $(call get-term-code,setaf 1)
1105
green	:= $(call get-term-code,setaf 2)
1106
yellow	:= $(call get-term-code,setaf 3)
1107
blue	:= $(call get-term-code,setaf 4)
1108
magenta	:= $(call get-term-code,setaf 5)
1109
cyan	:= $(call get-term-code,setaf 6)
1110
white	:= $(call get-term-code,setaf 7)
1111
bold	:= $(call get-term-code,bold)
1112
uline	:= $(call get-term-code,smul)
1113
reset	:= $(call get-term-code,sgr0)
1114
1115
#
1116
# User-settable definitions
1117
#
1118
LATEX_COLOR_WARNING	?= magenta
1119
LATEX_COLOR_ERROR	?= red
1120
LATEX_COLOR_INFO	?= green
1121
LATEX_COLOR_UNDERFULL	?= magenta
1122
LATEX_COLOR_OVERFULL	?= red bold
1123
LATEX_COLOR_PAGES	?= bold
1124
LATEX_COLOR_BUILD	?= cyan
1125
LATEX_COLOR_GRAPHIC	?= yellow
1126
LATEX_COLOR_DEP		?= green
1127
LATEX_COLOR_SUCCESS	?= green bold
1128
LATEX_COLOR_FAILURE	?= red bold
1129
1130
# Gets the real color from a simple textual definition like those above
1131
# $(call get-color,ALL_CAPS_COLOR_NAME)
1132
# e.g., $(call get-color,WARNING)
1133
get-color	= $(subst $(space),,$(foreach c,$(LATEX_COLOR_$1),$($c)))
1134
1135
#
1136
# STANDARD COLORS
1137
#
1138
C_WARNING	:= $(call get-color,WARNING)
1139
C_ERROR		:= $(call get-color,ERROR)
1140
C_INFO		:= $(call get-color,INFO)
1141
C_UNDERFULL	:= $(call get-color,UNDERFULL)
1142
C_OVERFULL	:= $(call get-color,OVERFULL)
1143
C_PAGES		:= $(call get-color,PAGES)
1144
C_BUILD		:= $(call get-color,BUILD)
1145
C_GRAPHIC	:= $(call get-color,GRAPHIC)
1146
C_DEP		:= $(call get-color,DEP)
1147
C_SUCCESS	:= $(call get-color,SUCCESS)
1148
C_FAILURE	:= $(call get-color,FAILURE)
1149
C_RESET		:= $(reset)
1150
1151
#
1152
# PRE-BUILD TESTS
1153
#
1154
1155
# Check that clean targets are not combined with other targets (weird things
1156
# happen, and it's not easy to fix them)
1157
hascleangoals	:= $(if $(sort $(filter clean clean-%,$(MAKECMDGOALS))),1)
1158
hasbuildgoals	:= $(if $(sort $(filter-out clean clean-%,$(MAKECMDGOALS))),1)
1159
ifneq "$(hasbuildgoals)" ""
1160
ifneq "$(hascleangoals)" ""
1161
$(error $(C_ERROR)Clean and build targets specified together$(C_RESET)))
1162
endif
1163
endif
1164
1165
#
1166
# VARIABLE DECLARATIONS
1167
#
1168
1169
# Names of sed scripts that morph gnuplot files -- only the first found is used
1170
GNUPLOT_SED	:= global-gpi.sed gnuplot.sed
1171
GNUPLOT_GLOBAL	:= global._include_.gpi gnuplot.global
1172
1173
ifeq "$(strip $(BUILD_STRATEGY))" "latex"
1174
default_graphic_extension	?= eps
1175
latex_build_program		?= $(LATEX)
1176
build_target_extension		?= dvi
1177
hyperref_driver_pattern		?= hdvips
1178
hyperref_driver_error		?= Using dvips: specify ps2pdf in the hyperref options.
1179
endif
1180
1181
ifeq "$(strip $(BUILD_STRATEGY))" "pdflatex"
1182
default_graphic_extension	?= pdf
1183
latex_build_program		?= $(PDFLATEX)
1184
build_target_extension		?= pdf
1185
hyperref_driver_pattern		?= hpdf.*
1186
hyperref_driver_error		?= Using pdflatex: specify pdftex in the hyperref options (or leave it blank).
1187
endif
1188
1189
ifeq "$(strip $(BUILD_STRATEGY))" "xelatex"
1190
default_graphic_extension	?= pdf
1191
latex_build_program		?= $(XELATEX)
1192
build_target_extension		?= pdf
1193
hyperref_driver_pattern		?= hdvipdf.*
1194
hyperref_driver_error		?= Using xelatex: specify xelatex in the hyperref options (or leave it blank).
1195
endif
1196
1197
ifeq "$(strip $(BUILD_STRATEGY))" "lualatex"
1198
default_graphic_extension	?= pdf
1199
latex_build_program		?= $(LUALATEX)
1200
build_target_extension		?= pdf
1201
hyperref_driver_pattern		?= hdvipdf.*
1202
hyperref_driver_error		?= Using xelatex: specify lualatex in the hyperref options (or leave it blank).
1203
endif
1204
1205
1206
# Files of interest
1207
all_files.tex		?= $(wildcard *.tex)
1208
all_files.xmpdata	?= $(wildcard *.xmpdata)
1209
all_files.tex.sh	?= $(wildcard *.tex.sh)
1210
all_files.tex.pl	?= $(wildcard *.tex.pl)
1211
all_files.tex.py	?= $(wildcard *.tex.py)
1212
all_files.rst		?= $(wildcard *.rst)
1213
all_files.lhs		?= $(wildcard *.lhs)
1214
all_files.mp		?= $(wildcard *.mp)
1215
all_files.fig		?= $(wildcard *.fig)
1216
all_files.asy   	?= $(wildcard *.asy)
1217
all_files.gpi		?= $(wildcard *.gpi)
1218
all_files.dot		?= $(wildcard *.dot)
1219
all_files.xvg		?= $(wildcard *.xvg)
1220
all_files.svg		?= $(wildcard *.svg)
1221
all_files.png		?= $(wildcard *.png)
1222
all_files.jpg		?= $(wildcard *.jpg)
1223
all_files.jpeg		?= $(wildcard *.jpeg)
1224
all_files.eps.gz	?= $(wildcard *.eps.gz)
1225
all_files.eps		?= $(wildcard *.eps)
1226
1227
# Utility function for obtaining all files not specified in $(neverclean)
1228
# $(call cleanable-files,file1 file2 file3 ...)
1229
# Returns the list of files that is not in $(wildcard $(neverclean))
1230
cleanable-files = $(filter-out $(wildcard $(neverclean)), $1)
1231
1232
# Utility function for getting all .$1 files that are to be ignored
1233
#  * files listed in $(includes.$1)
1234
#  * files not listed in $(onlysources.$1) if it is defined
1235
ignore_files = \
1236
  $(includes.$1) \
1237
  $(if $(onlysources.$1),$(filter-out $(onlysources.$1), $(all_files.$1)))
1238
1239
# Patterns to never be allowed as source targets
1240
ignore_patterns	:= %._include_
1241
1242
# Patterns allowed as source targets but not included in 'all' builds
1243
nodefault_patterns := %._nobuild_ $(ignore_patterns)
1244
1245
# Utility function for getting targets suitable building
1246
# $(call filter-buildable,suffix)
1247
filter-buildable	= \
1248
	$(filter-out $(call ignore_files,$1) \
1249
		$(addsuffix .$1,$(ignore_patterns)),$(all_files.$1))
1250
1251
# Utility function for getting targets suitable for 'all' builds
1252
# $(call filter-default,suffix)
1253
filter-default		= \
1254
	$(filter-out $(call ignore_files,$1) \
1255
		$(addsuffix .$1,$(nodefault_patterns)),$(all_files.$1))
1256
1257
# Top level sources that can be built even when they are not by default
1258
files.tex	:= $(call filter-buildable,tex)
1259
files.tex.sh	:= $(call filter-buildable,tex.sh)
1260
files.tex.pl	:= $(call filter-buildable,tex.pl)
1261
files.tex.py	:= $(call filter-buildable,tex.py)
1262
files.rst	:= $(call filter-buildable,rst)
1263
files.lhs	:= $(call filter-buildable,lhs)
1264
files.gpi	:= $(call filter-buildable,gpi)
1265
files.dot	:= $(call filter-buildable,dot)
1266
files.mp	:= $(call filter-buildable,mp)
1267
files.fig	:= $(call filter-buildable,fig)
1268
files.asy	:= $(call filter-buildable,asy)
1269
files.xvg	:= $(call filter-buildable,xvg)
1270
files.svg	:= $(call filter-buildable,svg)
1271
files.png	:= $(call filter-buildable,png)
1272
files.jpg	:= $(call filter-buildable,jpg)
1273
files.jpeg	:= $(call filter-buildable,jpeg)
1274
files.eps.gz	:= $(call filter-buildable,eps.gz)
1275
files.eps	:= $(call filter-buildable,eps)
1276
1277
# Make all pstex targets secondary.  The pstex_t target requires the pstex
1278
# target, and nothing else really depends on it, so it often gets deleted.
1279
# This avoids that by allowing *all* fig files to be pstex targets, which is
1280
# perfectly valid and causes no problems even if they're going to become eps
1281
# files in the end.
1282
.SECONDARY:	$(patsubst %.fig,%.pstex,$(files.fig))
1283
1284
# Make all .tex targets secondary that result .rst and .lhs:
1285
.SECONDARY:	$(patsubst %.rst,%.tex,$(files.rst))
1286
.SECONDARY:	$(patsubst %.lhs,%.tex,$(files.lhs))
1287
1288
# Top level sources that are built by default targets
1289
default_files.tex	:= $(call filter-default,tex)
1290
default_files.tex.sh	:= $(call filter-default,tex.sh)
1291
default_files.tex.pl	:= $(call filter-default,tex.pl)
1292
default_files.tex.py	:= $(call filter-default,tex.py)
1293
default_files.rst	:= $(call filter-default,rst)
1294
default_files.lhs	:= $(call filter-default,lhs)
1295
default_files.gpi	:= $(call filter-default,gpi)
1296
default_files.dot	:= $(call filter-default,dot)
1297
default_files.mp	:= $(call filter-default,mp)
1298
default_files.fig	:= $(call filter-default,fig)
1299
default_files.asy	:= $(call filter-default,asy)
1300
default_files.xvg	:= $(call filter-default,xvg)
1301
default_files.svg	:= $(call filter-default,svg)
1302
default_files.png	:= $(call filter-default,png)
1303
default_files.jpg	:= $(call filter-default,jpg)
1304
default_files.jpeg	:= $(call filter-default,jpeg)
1305
default_files.eps.gz	:= $(call filter-default,eps.gz)
1306
default_files.eps	:= $(call filter-default,eps)
1307
1308
# Utility function for creating larger lists of files
1309
# $(call concat-files,suffixes,[prefix])
1310
concat-files	= $(foreach s,$1,$($(if $2,$2_,)files.$s))
1311
1312
# Useful file groupings
1313
all_files_source	:= $(call concat-files,tex,all)
1314
all_files_source_gen	:= $(call concat-files,rst rhs,all)
1315
all_files_scripts	:= $(call concat-files,tex.sh tex.pl tex.py,all)
1316
1317
.PHONY: $(all_files_scripts)
1318
1319
default_files_source		:= $(call concat-files,tex,default)
1320
default_files_source_gen	:= $(call concat-files,rhs lhs,default)
1321
default_files_scripts		:= $(call concat-files,tex.sh tex.pl tex.py,default)
1322
1323
files_source		:= $(call concat-files,tex)
1324
files_source_gen	:= $(call concat-files,rst lhs)
1325
files_scripts		:= $(call concat-files,tex.sh tex.pl tex.py)
1326
1327
# Utility function for obtaining stems
1328
# $(call get-stems,suffix,[prefix])
1329
get-stems	= $(sort $($(if $2,$2_,)files.$1:%.$1=%))
1330
1331
# List of all stems (including ._include_ and ._nobuild_ file stems)
1332
all_stems.tex		:= $(call get-stems,tex,all)
1333
all_stems.tex.sh	:= $(call get-stems,tex.sh,all)
1334
all_stems.tex.pl	:= $(call get-stems,tex.pl,all)
1335
all_stems.tex.py	:= $(call get-stems,tex.py,all)
1336
all_stems.rst		:= $(call get-stems,rst,all)
1337
all_stems.lhs		:= $(call get-stems,lhs,all)
1338
all_stems.mp		:= $(call get-stems,mp,all)
1339
all_stems.fig		:= $(call get-stems,fig,all)
1340
all_stems.gpi		:= $(call get-stems,gpi,all)
1341
all_stems.dot		:= $(call get-stems,dot,all)
1342
all_stems.xvg		:= $(call get-stems,xvg,all)
1343
all_stems.svg		:= $(call get-stems,svg,all)
1344
all_stems.png		:= $(call get-stems,png,all)
1345
all_stems.jpg		:= $(call get-stems,jpg,all)
1346
all_stems.jpeg		:= $(call get-stems,jpeg,all)
1347
all_stems.eps.gz	:= $(call get-stems,eps.gz,all)
1348
all_stems.eps		:= $(call get-stems,eps,all)
1349
1350
# List of all default stems (all default PDF targets):
1351
default_stems.tex		:= $(call get-stems,tex,default)
1352
default_stems.tex.sh		:= $(call get-stems,tex.sh,default)
1353
default_stems.tex.pl		:= $(call get-stems,tex.pl,default)
1354
default_stems.tex.py		:= $(call get-stems,tex.py,default)
1355
default_stems.rst		:= $(call get-stems,rst,default)
1356
default_stems.lhs		:= $(call get-stems,lhs,default)
1357
default_stems.mp		:= $(call get-stems,mp,default)
1358
default_stems.fig		:= $(call get-stems,fig,default)
1359
default_stems.gpi		:= $(call get-stems,gpi,default)
1360
default_stems.dot		:= $(call get-stems,dot,default)
1361
default_stems.xvg		:= $(call get-stems,xvg,default)
1362
default_stems.svg		:= $(call get-stems,svg,default)
1363
default_stems.png		:= $(call get-stems,png,default)
1364
default_stems.jpg		:= $(call get-stems,jpg,default)
1365
default_stems.jpeg		:= $(call get-stems,jpeg,default)
1366
default_stems.eps.gz		:= $(call get-stems,eps.gz,default)
1367
default_stems.eps		:= $(call get-stems,eps,default)
1368
1369
# List of all stems (all possible bare PDF targets created here):
1370
stems.tex		:= $(call get-stems,tex)
1371
stems.tex.sh		:= $(call get-stems,tex.sh)
1372
stems.tex.pl		:= $(call get-stems,tex.pl)
1373
stems.tex.py		:= $(call get-stems,tex.py)
1374
stems.rst		:= $(call get-stems,rst)
1375
stems.lhs		:= $(call get-stems,lhs)
1376
stems.mp		:= $(call get-stems,mp)
1377
stems.fig		:= $(call get-stems,fig)
1378
stems.gpi		:= $(call get-stems,gpi)
1379
stems.dot		:= $(call get-stems,dot)
1380
stems.xvg		:= $(call get-stems,xvg)
1381
stems.svg		:= $(call get-stems,svg)
1382
stems.png		:= $(call get-stems,png)
1383
stems.jpg		:= $(call get-stems,jpg)
1384
stems.jpeg		:= $(call get-stems,jpeg)
1385
stems.eps.gz		:= $(call get-stems,eps.gz)
1386
stems.eps		:= $(call get-stems,eps)
1387
1388
# Utility function for creating larger lists of stems
1389
# $(call concat-stems,suffixes,[prefix])
1390
concat-stems	= $(sort $(foreach s,$1,$($(if $2,$2_,)stems.$s)))
1391
1392
# The most likely to be source but not finished product go first
1393
graphic_source_extensions	:= mp \
1394
				   fig \
1395
				   gpi \
1396
				   xvg \
1397
				   svg \
1398
				   dot \
1399
				   asy \
1400
				   eps.gz
1401
1402
ifeq "$(strip $(BUILD_STRATEGY))" "latex"
1403
graphic_source_extensions	+= png jpg jpeg eps
1404
graphic_target_extensions	:= eps ps
1405
endif
1406
1407
ifeq "$(strip $(BUILD_STRATEGY))" "pdflatex"
1408
graphic_source_extensions	+= eps
1409
graphic_target_extensions	:= pdf png jpg jpeg mps tif
1410
endif
1411
1412
ifeq "$(strip $(BUILD_STRATEGY))" "xelatex"
1413
graphic_source_extensions	+= eps
1414
graphic_target_extensions	:= pdf png jpg jpeg mps tif
1415
endif
1416
1417
ifeq "$(strip $(BUILD_STRATEGY))" "lualatex"
1418
graphic_source_extensions	+= eps
1419
graphic_target_extensions	:= pdf png jpg jpeg mps tif
1420
endif
1421
1422
all_stems_source	:= $(call concat-stems,tex,all)
1423
all_stems_source_gen	:= $(call concat-stems,rst lhs,all)
1424
all_stems_script	:= $(call concat-stems,tex.sh tex.pl tex.py,all)
1425
all_stems_graphic	:= $(call concat-stems,$(graphic_source_extensions),all)
1426
all_stems_ss		:= $(sort $(all_stems_source) $(all_stems_source_gen) $(all_stems_script))
1427
all_stems_sg		:= $(sort $(all_stems_script) $(all_stems_source_gen))
1428
all_stems_ssg		:= $(sort $(all_stems_ss))
1429
1430
default_stems_source		:= $(call concat-stems,tex,default)
1431
default_stems_source_gen	:= $(call concat-stems,rst lhs,default)
1432
default_stems_script		:= $(call concat-stems,tex.sh tex.pl tex.py,default)
1433
default_stems_ss	:= $(sort $(default_stems_source) $(default_stems_source_gen) $(default_stems_script))
1434
default_stems_sg	:= $(sort $(default_stems_script) $(default_stems_source_gen))
1435
default_stems_ssg	:= $(sort $(default_stems_ss))
1436
1437
stems_source		:= $(call concat-stems,tex)
1438
stems_source_gen	:= $(call concat-stems,rst lhs)
1439
stems_script		:= $(call concat-stems,tex.sh tex.pl tex.py)
1440
stems_graphic		:= $(call concat-stems,$(graphic_source_extensions))
1441
stems_gg		:= $(sort $(stems_graphic))
1442
stems_ss		:= $(sort $(stems_source) $(stems_source_gen) $(stems_script))
1443
stems_sg		:= $(sort $(stems_script) $(stems_source_gen))
1444
stems_ssg		:= $(sort $(stems_ss))
1445
1446
# Calculate names that can generate the need for an include file.  We can't
1447
# really do this with patterns because it's too easy to screw up, so we create
1448
# an exhaustive list.
1449
allowed_source_suffixes	:= \
1450
	pdf \
1451
	ps \
1452
	dvi \
1453
	ind \
1454
	nls \
1455
	bbl \
1456
	bci \
1457
	aux \
1458
	aux.make \
1459
	d \
1460
	auxbbl.make \
1461
	_graphics \
1462
	_show
1463
allowed_source_patterns		:= $(addprefix %.,$(allowed_source_suffixes))
1464
1465
allowed_graphic_suffixes	:= \
1466
	pdf \
1467
	eps \
1468
	gpihead.make \
1469
	gpi.d
1470
allowed_graphic_patterns	:= $(addprefix %.,$(allowed_graphic_suffixes))
1471
1472
# All targets allowed to build documents
1473
allowed_source_targets	:= \
1474
	$(foreach suff,$(allowed_source_suffixes),\
1475
	$(addsuffix .$(suff),$(stems_ssg)))
1476
1477
# All targets allowed to build graphics
1478
allowed_graphic_targets	:= \
1479
	$(foreach suff,$(allowed_graphic_suffixes),\
1480
	$(addsuffix .$(suff),$(stems_gg)))
1481
1482
# All targets that build multiple documents (like 'all')
1483
allowed_batch_source_targets	:= \
1484
	all \
1485
	all-pdf \
1486
	all-ps \
1487
	all-dvi \
1488
	all-bbl \
1489
	all-ind \
1490
	all-gls \
1491
	all-nls \
1492
	show
1493
1494
# All targets that build multiple graphics (independent of document)
1495
allowed_batch_graphic_targets	:= \
1496
	all-graphics \
1497
	all-pstex \
1498
	all-dot2tex \
1499
	show-graphics
1500
1501
# Now we figure out which stuff is available as a make target for THIS RUN.
1502
real_goals	:= $(call get-default,$(filter-out _includes,$(MAKECMDGOALS)),\
1503
			all)
1504
1505
specified_source_targets	:= $(strip \
1506
	$(filter $(allowed_source_targets) $(stems_ssg),$(real_goals)) \
1507
	)
1508
1509
specified_batch_source_targets	:= $(strip \
1510
	$(filter $(allowed_batch_source_targets),$(real_goals)) \
1511
	)
1512
1513
specified_graphic_targets	:= $(strip \
1514
	$(filter $(allowed_graphic_targets),$(real_goals)) \
1515
	)
1516
1517
specified_batch_graphic_targets	:= $(strip \
1518
	$(filter $(allowed_batch_graphic_targets),$(real_goals)) \
1519
	)
1520
1521
specified_gpi_targets	:= $(patsubst %.gpi,%.$(default_graphic_extension),\
1522
	$(filter $(patsubst %.$(default_graphic_extension),%.gpi,$(specified_graphic_targets)),\
1523
		$(all_files.gpi)) \
1524
	)
1525
1526
# Determine which .d files need including from the information gained above.
1527
# This is done by first checking whether a batch target exists.  If it does,
1528
# then all *default* stems are used to create possible includes (nobuild need
1529
# not apply for batch status).  If no batch targets exist, then the individual
1530
# targets are considered and appropriate includes are taken from them.
1531
source_stems_to_include	:= \
1532
	$(sort\
1533
	$(if $(specified_batch_source_targets),\
1534
		$(default_stems_ss),\
1535
		$(foreach t,$(specified_source_targets),\
1536
		$(foreach p,$(allowed_source_patterns),\
1537
			$(patsubst $p,%,$(filter $p $(stems_ssg),$t)) \
1538
		)) \
1539
	))
1540
1541
# Determine which .gpi.d files are needed using the above information.  We
1542
# first check whether a batch target is specified, then check individual
1543
# graphics that may have been specified.
1544
graphic_stems_to_include	:= \
1545
	$(sort\
1546
	$(if $(specified_batch_graphic_targets),\
1547
		$(default_stems.gpi),\
1548
		$(foreach t,$(specified_gpi_targets),\
1549
		$(foreach p,$(allowed_graphic_patterns),\
1550
			$(patsubst $p,%,$(filter $p,$t)) \
1551
		)) \
1552
	))
1553
1554
# All dependencies for the 'all' targets
1555
all_pdf_targets		:= $(addsuffix .pdf,$(stems_ssg))
1556
all_ps_targets		:= $(addsuffix .ps,$(stems_ssg))
1557
all_dvi_targets		:= $(addsuffix .dvi,$(stems_ssg))
1558
all_tex_targets		:= $(addsuffix .tex,$(stems_sg))
1559
all_d_targets		:= $(addsuffix .d,$(stems_ssg))
1560
all_graphics_targets	:= $(addsuffix .$(default_graphic_extension),$(stems_gg))
1561
all_pstex_targets	:= $(addsuffix .pstex_t,$(stems.fig))
1562
all_dot2tex_targets	:= $(addsuffix .dot_t,$(stems.dot))
1563
1564
all_known_graphics	:= $(sort $(all_graphics_targets) $(wildcard *.$(default_graphic_extension)))
1565
1566
default_pdf_targets	:= $(addsuffix .pdf,$(default_stems_ss))
1567
1568
ifeq "$(strip $(BUILD_STRATEGY))" "latex"
1569
default_ps_targets	:= $(addsuffix .ps,$(default_stems_ss))
1570
default_dvi_targets	:= $(addsuffix .dvi,$(default_stems_ss))
1571
pre_pdf_extensions	:= dvi ps
1572
endif
1573
1574
# Extensions generated by LaTeX invocation that can be removed when complete
1575
rm_ext		:= \
1576
	log *.log aux $(pre_pdf_extensions) ps pdf blg bcf bbl out nav snm toc lof lot lol pfg \
1577
	fls vrb idx ind ilg glg glo gls lox nls nlo nlg brf mtc* mlf* mlt* maf brf ist fmt
1578
backup_patterns	:= *~ *.bak *.backup body.tmp head.tmp
1579
1580
graph_stem	:= _graph
1581
1582
# All LaTeX-generated files that can be safely removed
1583
1584
rm_tex := \
1585
	$(foreach e,$(rm_ext),$(addsuffix .$e,$(all_stems_source))) \
1586
	$(foreach e,$(rm_ext) tex,$(addsuffix .$e,$(all_stems_sg))) \
1587
	$(addsuffix .log,$(all_ps_targets) $(all_pdf_targets)) \
1588
	$(addsuffix .*.log,$(stems_graphic))
1589
1590
# These are the files that will affect .gpi transformation for all .gpi files.
1591
#
1592
# Use only the first one found.  Backward compatible values are at the end.
1593
# Note that we use foreach, even though wildcard also returns a list, to ensure
1594
# that the order in the uppercase variables is preserved.  Directory listings
1595
# provide no such guarantee, so we avoid relying on them.
1596
gpi_sed		:= $(strip \
1597
	$(firstword $(foreach f,$(GNUPLOT_SED),$(wildcard $f))))
1598
gpi_global	:= $(strip \
1599
	$(firstword $(foreach f,$(GNUPLOT_GLOBAL),$(wildcard $f))))
1600
1601
#
1602
# Functions used in generating output
1603
#
1604
1605
# Outputs all source dependencies to stdout.  The first argument is the file to
1606
# be parsed, the second is a list of files that will show up as dependencies in
1607
# the new .d file created here.
1608
#
1609
# $(call get-inputs,<parsed file>,<target files>)
1610
define get-inputs
1611
$(SED) \
1612
-e '/^INPUT/!d' \
1613
-e 's!^INPUT \(\./\)\{0,1\}!!' \
1614
-e 's/[[:space:]]/\\ /g' \
1615
-e 's/\(.*\)\.aux$$/\1.tex/' \
1616
-e '/\.tex$$/b addtargets' \
1617
-e '/\.cls$$/b addtargets' \
1618
-e '/\.sty$$/b addtargets' \
1619
-e '/\.pstex_t$$/b addtargets' \
1620
-e '/\.dot_t$$/b addtargets' \
1621
-e 'd' \
1622
-e ':addtargets' \
1623
-e 's!.*!$2: $$(call path-norm,&)!' \
1624
'$1' | $(SORT) | $(UNIQ)
1625
endef
1626
1627
# $(call get-format,<tex file>,<target files>)
1628
define get-format
1629
$(SED) \
1630
-e '1!d' \
1631
-e '/^%&\([[:alnum:]]\{1,\}\)\( .*\)*$$/{' \
1632
-e '  s!!\1!' \
1633
-e '  h' \
1634
-e '  s/.*/# MISSING format "&.fmt" (comment forces rebuild of target file)/' \
1635
-e '  p' \
1636
-e '  g' \
1637
-e '  s!.*!$2: $$(call path-norm,&.fmt)!' \
1638
-e '  p' \
1639
-e '}' \
1640
-e 'd' \
1641
'$1'
1642
endef
1643
1644
# $(call get-missing-inputs,<log file>,<target files>)
1645
define get-missing-inputs
1646
$(SED) \
1647
-e '$${' \
1648
-e '  /^$$/!{' \
1649
-e '    H' \
1650
-e '    s/.*//' \
1651
-e '  }' \
1652
-e '}' \
1653
-e '/^$$/!{' \
1654
-e '  H' \
1655
-e '  d' \
1656
-e '}' \
1657
-e '/^$$/{' \
1658
-e '  x' \
1659
-e '  s/^\(\n\)\(.*\)/\2\1/' \
1660
-e '}' \
1661
-e '/^::P\(P\{1,\}\)::/{' \
1662
-e '  s//::\1::/' \
1663
-e '  G' \
1664
-e '  h' \
1665
-e '  d' \
1666
-e '}' \
1667
-e '/^::P::/{' \
1668
-e '  s//::0::/' \
1669
-e '  G' \
1670
-e '}' \
1671
-e 'b start' \
1672
-e ':needonemore' \
1673
-e 's/^/::P::/' \
1674
-e 'G' \
1675
-e 'h' \
1676
-e 'd' \
1677
-e ':needtwomore' \
1678
-e 's/^/::PP::/' \
1679
-e 'G' \
1680
-e 'h' \
1681
-e 'd' \
1682
-e ':needthreemore' \
1683
-e 's/^/::PPP::/' \
1684
-e 'G' \
1685
-e 'h' \
1686
-e 'd' \
1687
-e ':start' \
1688
-e '/^! LaTeX Error: File `/{' \
1689
-e '  b needtwomore' \
1690
-e '}' \
1691
-e '/^::0::\(.*\)/{' \
1692
-e '  s//\1/' \
1693
-e '  /Default extension: /!d' \
1694
-e '  s/.*File `\([^'"'"']*\)'"'"' not found.*/\1/' \
1695
-e '  s/[[:cntrl:]]//' \
1696
-e '  /\.tex/!s/$$/.tex/' \
1697
-e '  s/[[:space:]]/\\ /g' \
1698
-e '  h' \
1699
-e '  s/.*/# MISSING input "&" - (presence of comment affects build)/' \
1700
-e '  p' \
1701
-e '  s/.*//' \
1702
-e '  x' \
1703
-e '  s!^.*!$2: $$(call path-norm,&)!' \
1704
-e '  p' \
1705
-e '}' \
1706
-e 'd' \
1707
'$1' | $(SORT) | $(UNIQ)
1708
endef
1709
1710
# Get source file for specified graphics stem.
1711
#
1712
# $(call graphics-source,<stem>)
1713
define graphics-source
1714
$(strip $(firstword \
1715
	$(wildcard \
1716
		$(addprefix $1.,\
1717
			$(graphic_source_extensions))) \
1718
	$1 \
1719
))
1720
endef
1721
1722
# Get the target file for the specified graphics file/stem
1723
#
1724
# $(call graphics-target,<stem>)
1725
define graphics-target
1726
$(strip $(if 	$(filter $(addprefix %.,$(graphic_target_extensions)),$1), $1,
1727
	$(firstword $(patsubst $(addprefix %.,$(graphic_source_extensions) $(graphic_target_extensions)), %, $1).$(default_graphic_extension) $1.$(default_graphic_extension))))
1728
endef
1729
1730
# Outputs all of the graphical dependencies to stdout.  The first argument is
1731
# the stem of the source file being built, the second is a list of suffixes
1732
# that will show up as dependencies in the generated .d file.
1733
#
1734
# Note that we try to escape spaces in filenames where possible.  We have to do
1735
# it with three backslashes so that as the name percolates through the makefile
1736
# it eventually ends up with the proper escaping when the build rule is found.
1737
# Ugly, but it appears to work.  Note that graphicx doesn't allow filenames
1738
# with spaces, so this could in many ways be moot unless you're using something
1739
# like grffile.
1740
#
1741
# For pdflatex, we really need the missing file to be specified without an
1742
# extension, otherwise compilation barfs on the first missing file.  Truly
1743
# annoying, but there you have it.
1744
#
1745
# It turns out that the graphics errors, although they have lines with empty
1746
# space, are only made of two paragraphs.  So, we just use some sed magic to
1747
# get everything into paragraphs, detect when it's a paragraph that interests
1748
# us, and double it up.  Then we get the filename only if we're missing
1749
# extensions (a sign that it's graphicx complaining).
1750
#
1751
# $(call get-graphics,<target file stem>)
1752
define get-graphics
1753
$(SED) \
1754
-e '/^File: \(.*\) Graphic file (type [^)]*)/{' \
1755
-e '  s//\1/' \
1756
-e '  s/\.e\{0,1\}ps$$//' \
1757
-e '  b addtargets' \
1758
-e '}' \
1759
-e '$${' \
1760
-e '  /^$$/!{' \
1761
-e '    H' \
1762
-e '    s/.*//' \
1763
-e '  }' \
1764
-e '}' \
1765
-e '/^$$/!{' \
1766
-e '  H' \
1767
-e '  d' \
1768
-e '}' \
1769
-e '/^$$/{' \
1770
-e '  x' \
1771
-e '  s/^\(\n\)\(.*\)/\2\1/' \
1772
-e '}' \
1773
-e '/^::P\(P\{1,\}\)::/{' \
1774
-e '  s//::\1::/' \
1775
-e '  G' \
1776
-e '  h' \
1777
-e '  d' \
1778
-e '}' \
1779
-e '/^::P::/{' \
1780
-e '  s//::0::/' \
1781
-e '  G' \
1782
-e '}' \
1783
-e 'b start' \
1784
-e ':needonemore' \
1785
-e 's/^/::P::/' \
1786
-e 'G' \
1787
-e 'h' \
1788
-e 'd' \
1789
-e ':needtwomore' \
1790
-e 's/^/::PP::/' \
1791
-e 'G' \
1792
-e 'h' \
1793
-e 'd' \
1794
-e ':needthreemore' \
1795
-e 's/^/::PPP::/' \
1796
-e 'G' \
1797
-e 'h' \
1798
-e 'd' \
1799
-e ':start' \
1800
-e '/^[^[:cntrl:]:]*:[[:digit:]]\{1,\}:[[:space:][:cntrl:]]*LaTeX[[:space:][:cntrl:]]*Error:[[:space:][:cntrl:]]*File `/{' \
1801
-e '  s/\n//g' \
1802
-e '  b needonemore' \
1803
-e '}' \
1804
-e '/^::0::.*: LaTeX Error: File `/{' \
1805
-e '  /\n\n$$/{' \
1806
-e '    s/^::0:://' \
1807
-e '    b needonemore' \
1808
-e '  }' \
1809
-e '  s/\n\{1,\}/ /g' \
1810
-e '  s/[[:space:]]\{1,\}/ /g' \
1811
-e '  s/^.*File `//' \
1812
-e '  /extensions: /{' \
1813
-e '    s/'"'"' not found\..*extensions: \([^[:space:]]*\).*/::::\1/' \
1814
-e '    b fileparsed' \
1815
-e '  }' \
1816
-e '  s/'"'"' not found\..*/::::/' \
1817
-e '  :fileparsed' \
1818
-e '  s/\.e\{0,1\}ps::::$$/::::/' \
1819
-e '  h' \
1820
-e '  s/\(.*\)::::\(.*\)/# MISSING stem "\1" - allowed extensions are "\2" - leave comment here - it affects the build/' \
1821
-e '  p' \
1822
-e '  g' \
1823
-e '  s/::::.*//' \
1824
-e '  b addtargets' \
1825
-e '}' \
1826
-e 'd' \
1827
-e ':addtargets' \
1828
-e 's/[[:space:]]/\\\\\\&/g' \
1829
-e 'h' \
1830
-e 's/.*/-include &.gpi.d/' \
1831
-e 'p' \
1832
-e 'g' \
1833
-e 's!.*!$1.d: $$$$(call graphics-source,&)!' \
1834
-e 'p' \
1835
-e 's/.*//' \
1836
-e 'x' \
1837
-e 's!.*!$1.$(build_target_extension) $1._graphics: $$$$(call graphics-target,&)!' \
1838
-e 'p' \
1839
-e 'd' \
1840
$1.log
1841
endef
1842
1843
# Get some special comments out of the source file (e.g., paper size, beamer
1844
# usage, etc.)
1845
#
1846
# $(call get-source-specials,<source file name>,<output file>)
1847
define get-source-specials
1848
$(SED) \
1849
-e '/^%%[[:space:]]*\([^%].*\)[[:space:]]*$$/{' \
1850
-e '  s//\1/' \
1851
-e '  s/[[:space:]]//g' \
1852
-e '  /BEAMER/{' \
1853
-e '    /BEAMERLARGE/!d' \
1854
-e '    s/.*/BEAMER/' \
1855
-e '  }' \
1856
-e '  p' \
1857
-e '  d' \
1858
-e '}' \
1859
-e '/\\documentclass[^{]*{.*}/b procclass' \
1860
-e '/\\documentclass/,/}/{' \
1861
-e '  s/%.*//' \
1862
-e '  H' \
1863
-e '  /}/{' \
1864
-e '    s/.*//' \
1865
-e '    x' \
1866
-e '    b procclass' \
1867
-e '  }' \
1868
-e '  d' \
1869
-e '}' \
1870
-e 'd' \
1871
-e ':procclass' \
1872
-e 's/\\documentclass//' \
1873
-e 's/[][]//g' \
1874
-e 's/{.*}//' \
1875
-e 's/[[:cntrl:][:space:]]*//g' \
1876
-e 's/,/ /g' \
1877
-e 's/^/ /' \
1878
-e 's/$$/ /' \
1879
-e '/.* \([[:alnum:]]\{1,\}\)paper .*/{' \
1880
-e '  h' \
1881
-e '  s//PAPERSIZE=\1/' \
1882
-e '  p' \
1883
-e '  g' \
1884
-e '}' \
1885
-e '/.* landscape .*/{' \
1886
-e '  h' \
1887
-e '  s//ORIENTATION=landscape/' \
1888
-e '  p' \
1889
-e '  g' \
1890
-e '}' \
1891
-e 'd' \
1892
$1 > '$2'
1893
endef
1894
1895
# Checks for build failure due to pstex inclusion, and gives instructions.
1896
#
1897
# $(call die-on-pstexs,<parsed file>)
1898
define die-on-pstexs
1899
if $(EGREP) -q '^! LaTeX Error: File .*\.pstex.* not found' $1; then \
1900
	$(ECHO) "$(C_ERROR)Missing pstex_t file(s)$(C_RESET)"; \
1901
	$(ECHO) "$(C_ERROR)Please run$(C_RESET)"; \
1902
	$(ECHO) "$(C_ERROR)  make all-pstex$(C_RESET)"; \
1903
	$(ECHO) "$(C_ERROR)before proceeding.$(C_RESET)"; \
1904
	exit 1; \
1905
fi
1906
endef
1907
1908
# Checks for the use of import.sty and bails - we don't support subdirectories
1909
#
1910
# $(call die-on-import-sty,<log file>)
1911
define die-on-import-sty
1912
if $(EGREP) -s '/import.sty\)' '$1'; then \
1913
	$(ECHO) "$(C_ERROR)import.sty is not supported - included files must"; \
1914
	$(ECHO) "$(C_ERROR)be in the same directory as the primary document$(C_RESET)"; \
1915
	exit 1; \
1916
fi
1917
endef
1918
1919
# Checks for build failure due to dot2tex, and gives instructions.
1920
#
1921
# $(call die-on-dot2tex,<parsed file>)
1922
define die-on-dot2tex
1923
if $(EGREP) -q ' LaTeX Error: File .*\.dot_t.* not found' $1; then \
1924
	$(ECHO) "$(C_ERROR)Missing dot_t file(s)$(C_RESET)"; \
1925
	$(ECHO) "$(C_ERROR)Please run$(C_RESET)"; \
1926
	$(ECHO) "$(C_ERROR)  make all-dot2tex$(C_RESET)"; \
1927
	$(ECHO) "$(C_ERROR)before proceeding.$(C_RESET)"; \
1928
	exit 1; \
1929
fi
1930
endef
1931
1932
# Checks for the existence of a .aux file, and dies with an error message if it
1933
# isn't there.  Note that we pass the file stem in, not the full filename,
1934
# e.g., to check for foo.aux, we call it thus: $(call die-on-no-aux,foo)
1935
#
1936
# $(call die-on-no-aux,<aux stem>)
1937
define die-on-no-aux
1938
if $(call test-not-exists,$1.aux); then \
1939
	$(call colorize-latex-errors,$1.log); \
1940
	$(ECHO) "$(C_ERROR)Error: failed to create $1.aux$(C_RESET)"; \
1941
	exit 1; \
1942
fi
1943
endef
1944
1945
# Outputs all index files to stdout.  Arg 1 is the source file stem, arg 2 is
1946
# the list of targets for the discovered dependency.
1947
#
1948
# $(call get-log-index,<log file stem>,<target files>)
1949
define get-log-index
1950
$(SED) \
1951
-e 's/^No file \(.*\.ind\)\.$$/TARGETS=\1/' \
1952
-e 's/^No file \(.*\.[gn]ls\)\.$$/TARGETS=\1/' \
1953
-e 's/[[:space:]]/\\&/g' \
1954
-e '/^TARGETS=/{' \
1955
-e '  h' \
1956
-e '  s!^TARGETS=!$2: !p' \
1957
-e '  g' \
1958
-e '  s!^TARGETS=\(.*\)!\1: $1.tex!p' \
1959
-e '}' \
1960
-e 'd' \
1961
'$1.log' | $(SORT) | $(UNIQ)
1962
endef
1963
1964
1965
# Outputs all bibliography files to stdout.  Arg 1 is the source stem, arg 2 is
1966
# a list of targets for each dependency found.
1967
#
1968
# The script kills all lines that do not contain bibdata.  Remaining lines have
1969
# the \bibdata macro and delimiters removed to create a dependency list.  A
1970
# trailing comma is added, then all adjacent commas are collapsed into a single
1971
# comma.  Then commas are replaced with the string .bib[space], and the
1972
# trailing space is killed off.  Finally, all filename spaces are escaped.
1973
# This produces a list of space-delimited .bib filenames, which is what the
1974
# make dep file expects to see.
1975
#
1976
# Note that we give kpsewhich a bogus argument so that a failure of sed to
1977
# produce output will not cause an error.
1978
#
1979
# $(call get-bibs,<aux file>,<targets>)
1980
define get-bibs
1981
$(SED) \
1982
-e '/^\\bibdata/!d' \
1983
-e 's/\\bibdata{\([^}]*\)}/\1,/' \
1984
-e 's/,\{2,\}/,/g' \
1985
-e 's/[[:space:]]/\\&/g' \
1986
-e 's/,/.bib /g' \
1987
-e 's/ \{1,\}$$//' \
1988
'$1' | $(XARGS) $(KPSEWHICH) '#######' | \
1989
$(SED) \
1990
-e 's!.*!$2: $$(call path-norm,&)!' | \
1991
$(SORT) | $(UNIQ)
1992
endef
1993
1994
# Makes a an aux file that only has stuff relevant to the target in it
1995
# $(call make-auxtarget-file,<flattened-aux>,<new-aux>)
1996
define make-auxtarget-file
1997
$(SED) \
1998
-e '/^\\newlabel/!d' \
1999
$1 > $2
2000
endef
2001
2002
# Makes an aux file that only has stuff relevant to the bbl in it
2003
# $(call make-auxbbl-file,<flattened-aux>,<new-aux>)
2004
define make-auxbbl-file
2005
$(SED) \
2006
-e '/^\\newlabel/d' \
2007
$1 > $2
2008
endef
2009
2010
# Makes a .gpi.d file from a .gpi file
2011
# $(call make-gpi-d,<.gpi>,<.gpi.d>)
2012
define make-gpi-d
2013
$(ECHO) '# vim: ft=make' > $2; \
2014
$(ECHO) 'ifndef INCLUDED_$(call cleanse-filename,$2)' >> $2; \
2015
$(ECHO) 'INCLUDED_$(call cleanse-filename,$2) := 1' >> $2; \
2016
$(call get-gpi-deps,$1,$(addprefix $(2:%.gpi.d=%).,$(GPI_OUTPUT_EXTENSION) gpi.d)) >> $2; \
2017
$(ECHO) 'endif' >> $2;
2018
endef
2019
2020
# Parse .gpi files for data and loaded dependencies, output to stdout
2021
#
2022
# The sed script here tries to be clever about obtaining valid
2023
# filenames from the gpi file.  It assumes that the plot command starts its own
2024
# line, which is not too difficult a constraint to satisfy.
2025
#
2026
# This command script also generates 'include' directives for every 'load'
2027
# command in the .gpi file.  The load command must appear on a line by itself
2028
# and the file it loads must have the suffix .gpi.  If you don't want it to be
2029
# compiled when running make graphics, then give it a suffix of ._include_.gpi.
2030
#
2031
# $(call get-gpi-deps,<gpi file>,<targets>)
2032
define get-gpi-deps
2033
$(SED) \
2034
-e '/^[[:space:]]*s\{0,1\}plot/,/[^\\]$$/{' \
2035
-e ' H' \
2036
-e ' /[^\\]$$/{' \
2037
-e '  s/.*//' \
2038
-e '  x' \
2039
-e '  s/\\\{0,1\}\n//g' \
2040
-e '  s/^[[:space:]]*s\{0,1\}plot[[:space:]]*\(\[[^]]*\][[:space:]]*\)*/,/' \
2041
-e '  s/[[:space:]]*\(['"'"'\'"'"''"'"'"][^'"'"'\'"'"''"'"'"]*['"'"'\'"'"''"'"'"]\)\{0,1\}[^,]*/\1/g' \
2042
-e '  s/,['"'"'\'"'"''"'"'"]-\{0,1\}['"'"'\'"'"''"'"'"]//g' \
2043
-e '  s/[,'"'"'\'"'"''"'"'"]\{1,\}/ /g' \
2044
-e '  s/.*:.*/$$(error Error: Filenames with colons are not allowed: &)/' \
2045
-e '  s!.*!$2: &!' \
2046
-e '  p' \
2047
-e ' }' \
2048
-e ' d' \
2049
-e '}' \
2050
-e 's/^[[:space:]]*load[[:space:]]*['"'"'\'"'"''"'"'"]\([^'"'"'\'"'"''"'"'"]*\.gpi\)['"'"'\'"'"''"'"'"].*$$/-include \1.d/p' \
2051
-e 'd' \
2052
'$1'
2053
endef
2054
2055
# Colorizes real, honest-to-goodness LaTeX errors that can't be overcome with
2056
# recompilation.
2057
#
2058
# Note that we only ignore file not found errors for things that we know how to
2059
# build, like graphics files.
2060
#
2061
# Also note that the output of this is piped through sed again to escape any
2062
# backslashes that might have made it through.  This is to avoid sending things
2063
# like "\right" to echo, which interprets \r as LF.  In bash, we could just do
2064
# ${var//\\/\\\\}, but in other popular sh variants (like dash), this doesn't
2065
# work.
2066
#
2067
# $(call colorize-latex-errors,<log file>)
2068
define colorize-latex-errors
2069
$(SED) \
2070
-e '$${' \
2071
-e '  /^$$/!{' \
2072
-e '    H' \
2073
-e '    s/.*//' \
2074
-e '  }' \
2075
-e '}' \
2076
-e '/^$$/!{' \
2077
-e '  H' \
2078
-e '  d' \
2079
-e '}' \
2080
-e '/^$$/{' \
2081
-e '  x' \
2082
-e '  s/^\(\n\)\(.*\)/\2\1/' \
2083
-e '}' \
2084
-e '/^::P\(P\{1,\}\)::/{' \
2085
-e '  s//::\1::/' \
2086
-e '  G' \
2087
-e '  h' \
2088
-e '  d' \
2089
-e '}' \
2090
-e '/^::P::/{' \
2091
-e '  s//::0::/' \
2092
-e '  G' \
2093
-e '}' \
2094
-e 'b start' \
2095
-e ':needonemore' \
2096
-e 's/^/::P::/' \
2097
-e 'G' \
2098
-e 'h' \
2099
-e 'd' \
2100
-e ':needtwomore' \
2101
-e 's/^/::PP::/' \
2102
-e 'G' \
2103
-e 'h' \
2104
-e 'd' \
2105
-e ':needthreemore' \
2106
-e 's/^/::PPP::/' \
2107
-e 'G' \
2108
-e 'h' \
2109
-e 'd' \
2110
-e ':start' \
2111
-e '/^! LaTeX Error: File /{' \
2112
-e '  s/\n//g' \
2113
-e '  b needtwomore' \
2114
-e '}' \
2115
-e 's/^[^[:cntrl:]:]*:[[:digit:]]\{1,\}:/!!! &/' \
2116
-e 's/^\(.*\n\)\([^[:cntrl:]:]*:[[:digit:]]\{1,\}: .*\)/\1!!! \2/' \
2117
-e '/^!!! .*[[:space:][:cntrl:]]LaTeX[[:space:][:cntrl:]]Error:[[:space:][:cntrl:]]*File /{' \
2118
-e '  s/\n//g' \
2119
-e '  b needonemore' \
2120
-e '}' \
2121
-e '/^::0::! LaTeX Error: File .*/{' \
2122
-e '  /\n\n$$/{' \
2123
-e '    s/^::0:://' \
2124
-e '    b needonemore' \
2125
-e '  }' \
2126
-e '  s/^::0::! //' \
2127
-e '  s/^\(.*not found.\).*Enter file name:.*\n\(.*[[:digit:]]\{1,\}\): Emergency stop.*/\2: \1/' \
2128
-e '  b error' \
2129
-e '}' \
2130
-e '/^::0::!!! .*LaTeX Error: File .*/{' \
2131
-e '  /\n\n$$/{' \
2132
-e '    s/^::0:://' \
2133
-e '    b needonemore' \
2134
-e '  }' \
2135
-e '  s/::0::!!! //' \
2136
-e '  /File .*\.e\{0,1\}ps'"'"' not found/b skip' \
2137
-e '  /could not locate.*any of these extensions:/{' \
2138
-e '    b skip' \
2139
-e '  }' \
2140
-e '  s/\(not found\.\).*/\1/' \
2141
-e '  s/^/!!! /' \
2142
-e '  b error' \
2143
-e '}' \
2144
-e '/^\(.* LaTeX Error: Missing .begin.document.\.\).*/{' \
2145
-e '  s//\1 --- Are you trying to build an include file?/' \
2146
-e '  b error' \
2147
-e '}' \
2148
-e '/.*\(!!! .*Undefined control sequence\)[^[:cntrl:]]*\(.*\)/{' \
2149
-e '  s//\1: \2/' \
2150
-e '  s/\nl\.[[:digit:]][^[:cntrl:]]*\(\\[^\\[:cntrl:]]*\).*/\1/' \
2151
-e '  b error' \
2152
-e '}' \
2153
-e '/^\(!pdfTeX error:.*\)s*/{' \
2154
-e '  b error' \
2155
-e '}' \
2156
-e '/.*\(!!! .*\)/{' \
2157
-e '  s//\1/' \
2158
-e '  s/[[:cntrl:]]//' \
2159
-e '  s/[[:cntrl:]]$$//' \
2160
-e '  /Cannot determine size of graphic .*(no BoundingBox)/b skip' \
2161
-e '  b error' \
2162
-e '}' \
2163
-e ':skip' \
2164
-e 'd' \
2165
-e ':error' \
2166
-e 's/^!\(!! \)\{0,1\}\(.*\)/$(C_ERROR)\2$(C_RESET)/' \
2167
-e 'p' \
2168
-e 'd' \
2169
'$1' | $(SED) -e 's/\\\\/\\\\\\\\/g'
2170
endef
2171
2172
# Colorize Makeindex errors
2173
define colorize-makeindex-errors
2174
$(SED) \
2175
-e '/^!! /{' \
2176
-e '  N' \
2177
-e '  s/^.*$$/$(C_ERROR)&$(C_RESET)/' \
2178
-e '  p' \
2179
-e '}' \
2180
-e 'd' \
2181
'$1'
2182
endef
2183
2184
# Colorize xindy errors
2185
# $(call colorize-xindy-errors,<log file>)
2186
define colorize-xindy-errors
2187
$(SED) \
2188
-e 's/^xindy:.*/$(C_ERROR)&$(C_RESET)/p' \
2189
-e 'd' \
2190
'$1'
2191
endef
2192
2193
# Colorize epstopdf errors
2194
#
2195
# $(call colorize-epstopdf-errors,<log file>)
2196
define colorize-epstopdf-errors
2197
$(SED) \
2198
-e '/^Error:/,/^Execution stack:/{' \
2199
-e '  /^Execution stack:/d' \
2200
-e '  s/.*/$(C_ERROR)&$(C_RESET)/' \
2201
-e '  p' \
2202
-e '}' \
2203
-e 'd' \
2204
'$1'
2205
endef
2206
2207
# Colorize GNUplot errors
2208
#
2209
# $(call colorize-gnuplot-errors,<log file>)
2210
define colorize-gnuplot-errors
2211
$(SED) \
2212
-e '/, line [0-9]*:/!{' \
2213
-e '  H' \
2214
-e '  x' \
2215
-e '  s/.*\n\(.*\n.*\)$$/\1/' \
2216
-e '  x' \
2217
-e '}' \
2218
-e '/, line [0-9]*:/{' \
2219
-e '  H' \
2220
-e '  /unknown.*terminal type/{' \
2221
-e '    s/.*/--- Try changing the GNUPLOT_OUTPUT_EXTENSION variable to '"'"'eps'"'"'./' \
2222
-e '    H' \
2223
-e '  }' \
2224
-e '  /gpihead/{' \
2225
-e '    s/.*/--- This could be a Makefile bug - contact the maintainer./' \
2226
-e '    H' \
2227
-e '  }' \
2228
-e '  g' \
2229
-e '  s/.*/$(C_ERROR)&$(C_RESET)/' \
2230
-e '  p' \
2231
-e '}' \
2232
-e '/^gnuplot>/,/^$$/{' \
2233
-e '  s/^gnuplot.*/$(C_ERROR)&/' \
2234
-e '  s/^$$/$(C_RESET)/' \
2235
-e '  p' \
2236
-e '}' \
2237
-e 'd' \
2238
$1
2239
endef
2240
2241
# Colorize GraphViz errors
2242
#
2243
# $(call colorize-dot-errors,<log file>)
2244
define colorize-dot-errors
2245
$(SED) \
2246
-e 's/.*not found.*/$(C_ERROR)&$(C_RESET)/p' \
2247
-e '/^Error:/,/context:/s/.*/$(C_ERROR)&$(C_RESET)/p' \
2248
-e 's/^Warning:.*/$(C_WARNING)&$(C_RESET)/p' \
2249
-e 'd' \
2250
'$1'
2251
endef
2252
2253
# Get all important .aux files from the top-level .aux file and merges them all
2254
# into a single file, which it outputs to stdout.
2255
# It does this by finding all \input commands and creating a new sed script
2256
# that reads those files inline when it encounters one.
2257
# It then runs that sed script, generating a flattened aux file, and
2258
# then it cleans up the flattened file by removing some crufty things.
2259
#
2260
# $(call flatten-aux,<toplevel aux>,<output file>)
2261
define flatten-aux
2262
$(SED) \
2263
-e '/\\@input{\(.*\)}/{' \
2264
-e '  s//\1/' \
2265
-e '  s![.:]!\\&!g' \
2266
-e '  h' \
2267
-e '  s!.*!\\:\\\\@input{&}:{!' \
2268
-e '  p' \
2269
-e '  x' \
2270
-e '  s/\\././g' \
2271
-e '  s/.*/r &/p' \
2272
-e '  s/.*/d/p' \
2273
-e '  s/.*/}/p' \
2274
-e '  d' \
2275
-e '}' \
2276
-e 'd' \
2277
'$1' > "$1.$$$$.sed.make"; \
2278
$(SED) -f "$1.$$$$.sed.make" '$1' > "$1.$$$$.make"; \
2279
$(SED) \
2280
-e '/^\\relax/d' \
2281
-e '/^\\bibcite/d' \
2282
-e 's/^\(\\newlabel{[^}]\{1,\}}\).*/\1/' \
2283
"$1.$$$$.make" | $(SORT) > '$2'; \
2284
$(call remove-temporary-files,$1.$$$$.make $1.$$$$.sed.make)
2285
endef
2286
2287
# Generate pdf from postscript
2288
#
2289
# Note that we don't just call ps2pdf, since there are so many versions of that
2290
# script on various systems.  Instead, we call the postscript interpreter
2291
# directly.
2292
#
2293
# $(call ps2pdf,infile,outfile,[embed fonts])
2294
define ps2pdf
2295
	$(GS) \
2296
		-dSAFER -dCompatibilityLevel=$(PS_COMPATIBILITY) \
2297
		$(if $3,$(PS_EMBED_OPTIONS)) \
2298
		-q -dNOPAUSE -dBATCH \
2299
		-sDEVICE=pdfwrite -sstdout=%stderr \
2300
		'-sOutputFile=$2' \
2301
		-dSAFER -dCompatibilityLevel=$(PS_COMPATIBILITY) \
2302
		$(if $3,$(PS_EMBED_OPTIONS)) \
2303
		-c .setpdfwrite \
2304
		-f '$1'
2305
endef
2306
2307
# Colorize LaTeX output.
2308
color_tex := \
2309
$(SED) \
2310
-e '$${' \
2311
-e '  /^$$/!{' \
2312
-e '    H' \
2313
-e '    s/.*//' \
2314
-e '  }' \
2315
-e '}' \
2316
-e '/^$$/!{' \
2317
-e '  H' \
2318
-e '  d' \
2319
-e '}' \
2320
-e '/^$$/{' \
2321
-e '  x' \
2322
-e '  s/^\n//' \
2323
-e '  /Output written on /{' \
2324
-e '    s/.*Output written on \([^(]*\) (\([^)]\{1,\}\)).*/Success!  Wrote \2 to \1/' \
2325
-e '    s/[[:digit:]]\{1,\}/$(C_PAGES)&$(C_RESET)/g' \
2326
-e '    s/Success!/$(C_SUCCESS)&$(C_RESET)/g' \
2327
-e '    s/to \(.*\)$$/to $(C_SUCCESS)\1$(C_RESET)/' \
2328
-e '    b end' \
2329
-e '  }' \
2330
-e '  / *LaTeX Error:.*/{' \
2331
-e '    s/.*\( *LaTeX Error:.*\)/\1/' \
2332
-e '    b error' \
2333
-e '  }' \
2334
-e '  /^[^[:cntrl:]:]*:[[:digit:]]\{1,\}:/b error' \
2335
-e '  /.*Warning:.*/{' \
2336
-e '    s//$(C_WARNING)&$(C_RESET)/' \
2337
-e '    b end' \
2338
-e '  }' \
2339
-e '  /Underfull.*/{' \
2340
-e '    s/.*\(Underfull.*\)/$(C_UNDERFULL)\1$(C_RESET)/' \
2341
-e '    b end' \
2342
-e '  }' \
2343
-e '  /Overfull.*/{' \
2344
-e '    s/.*\(Overfull.*\)/$(C_OVERFULL)\1$(C_RESET)/' \
2345
-e '    b end' \
2346
-e '  }' \
2347
-e '  d' \
2348
-e '  :error' \
2349
-e '  s/.*/$(C_ERROR)&$(C_RESET)/' \
2350
-e '  b end' \
2351
-e '  :end' \
2352
-e '  G' \
2353
-e '}'
2354
2355
# Colorize BibTeX output.
2356
color_bib := \
2357
$(SED) \
2358
-e 's/^Warning--.*/$(C_WARNING)&$(C_RESET)/' \
2359
-e 't' \
2360
-e '/---/,/^.[^:]/{' \
2361
-e '  H' \
2362
-e '  /^.[^:]/{' \
2363
-e '    x' \
2364
-e '    s/\n\(.*\)/$(C_ERROR)\1$(C_RESET)/' \
2365
-e '    p' \
2366
-e '    s/.*//' \
2367
-e '    h' \
2368
-e '    d' \
2369
-e '  }' \
2370
-e '  d' \
2371
-e '}' \
2372
-e '/(.*error.*)/s//$(C_ERROR)&$(C_RESET)/' \
2373
-e 'd'
2374
2375
# Make beamer output big enough to print on a full page.  Landscape doesn't
2376
# seem to work correctly.
2377
enlarge_beamer	= $(PSNUP) -l -1 -W128mm -H96mm -pletter
2378
2379
# $(call test-run-again,<source stem>)
2380
define test-run-again
2381
$(EGREP) '^(.*Rerun .*|No file $1\.[^.]+\.)$$' $1.log \
2382
| $(EGREP) -q -v '^(Package: rerunfilecheck.*Rerun checks for auxiliary files.*)$$'
2383
endef
2384
2385
# This tests whether the build target commands should be run at all, from
2386
# viewing the log file.
2387
# $(call test-log-for-need-to-run,<source stem>)
2388
define test-log-for-need-to-run
2389
$(SED) \
2390
-e '/^No file $(call escape-fname-regex,$1)\.aux\./d' \
2391
$1.log \
2392
| $(EGREP) '^(.*Rerun .*|No file $1\.[^.]+\.|No file .+\.tex\.|LaTeX Warning: File.*)$$' \
2393
| $(EGREP) -q -v '^(Package: rerunfilecheck.*Rerun checks for auxiliary files.*)$$'
2394
endef
2395
2396
# LaTeX invocations
2397
#
2398
# Note that we use
2399
#
2400
#  -recorder: generates .fls files for things that are input and output
2401
#  -jobname: to make sure that .fls files are named after the source that created them
2402
#  -file-line-error: to make sure that we have good line information for error output
2403
#  -interaction=batchmode: so that we don't stop on errors (we'll parse logs for that)
2404
#
2405
# $(call latex,<tex file stem, e.g., $*>,[extra LaTeX args])
2406
define run-latex
2407
$(latex_build_program) -jobname='$1' -interaction=batchmode -file-line-error $(LATEX_OPTS) $(if $2,$2,) $1 > /dev/null; \
2408
$(call transcript,latex,$1)
2409
endef
2410
2411
# $(call latex-color-log,<LaTeX stem>)
2412
latex-color-log	= $(color_tex) $1.log
2413
2414
# $(call run-makeindex,<input>,<output>,<log>,[.ist style file])
2415
define run-makeindex
2416
success=1; \
2417
if ! $(MAKEINDEX) -q $1 -t $3 -o $2 $(if $4,-s $4,) > /dev/null || $(EGREP) -q '^!!' $3; \
2418
then \
2419
	$(call colorize-makeindex-errors,$3); \
2420
	$(RM) -f '$2'; \
2421
	success=0; \
2422
	$(call transcript,makeindex,$1); \
2423
fi; \
2424
[ "$$success" = "1" ] && $(sh_true) || $(sh_false);
2425
endef
2426
2427
# $(call run-xindy,<input>,<output>,<module>,<log>)
2428
define run-xindy
2429
success=1; \
2430
if ! $(XINDY) -q -o $2 -L $(XINDYLANG) -C $(XINDYENC) -I xindy -M $3 -t $4 $1 > /dev/null || $(EGREP) -q '^xindy:' $4; then \
2431
	$(call colorize-xindy-errors,$4); \
2432
	$(RM) -f '$2'; \
2433
	success=0; \
2434
	$(call transcript,xindy,$1); \
2435
fi; \
2436
[ "$$success" = "1" ] && $(sh_true) || $(sh_false);
2437
endef
2438
2439
# This runs the given script to generate output, and it uses MAKE_RESTARTS to
2440
# ensure that it never runs it more than once for a particular root make
2441
# invocation.
2442
#
2443
# $(call run-script,<interpreter>,<input>,<output>)
2444
define run-script
2445
$(call test-not-exists,$2.cookie) && $(ECHO) "restarts=$(RESTARTS)" \
2446
	> $2.cookie && $(ECHO) "level=$(MAKELEVEL)" >> $2.cookie; \
2447
restarts=`$(SED) -n -e 's/^restarts=//p' $2.cookie`; \
2448
level=`$(SED) -n -e 's/^level=//p' $2.cookie`; \
2449
if $(EXPR) $(MAKELEVEL) '<=' $$level '&' $(RESTARTS) '<=' $$restarts >/dev/null; then \
2450
	$(call echo-build,$2,$3,$(RESTARTS)-$(MAKELEVEL)); \
2451
	$1 '$2' '$3'; \
2452
	$(ECHO) "restarts=$(RESTARTS)" > '$2.cookie'; \
2453
	$(ECHO) "level=$(MAKELEVEL)" >> '$2.cookie'; \
2454
fi
2455
endef
2456
2457
# BibTeX invocations
2458
#
2459
# $(call run-bibtex,<tex stem>)
2460
ifeq "$(strip $(BIB_STRATEGY))" "bibtex"
2461
run-bibtex	= $(BIBTEX) $1 | $(color_bib); $(call transcript,bibtex,$1)
2462
endif
2463
ifeq "$(strip $(BIB_STRATEGY))" "biblatex"
2464
run-bibtex	= $(BIBER) $1 | $(color_bib); $(call transcript,biber,$1)
2465
endif
2466
2467
# $(call convert-eps-to-pdf,<eps file>,<pdf file>,[gray])
2468
# Note that we don't use the --filter flag because it has trouble with bounding boxes that way.
2469
define convert-eps-to-pdf
2470
$(if $3,$(CAT) '$1' | $(call kill-ps-color) > '$1.cookie',$(CP) '$1' '$1.cookie'); \
2471
$(EPSTOPDF) '$1.cookie' --outfile='$2' > $1.log; \
2472
$(call colorize-epstopdf-errors,$1.log);
2473
endef
2474
2475
# $(call default-gpi-fontsize,<output file>)
2476
#
2477
# Find the default fontsize given the *output* file (it is based on the output extension)
2478
#
2479
default-gpi-fontsize = $(if $(filter %.pdf,$1),$(DEFAULT_GPI_PDF_FONTSIZE),$(DEFAULT_GPI_EPS_FONTSIZE))
2480
2481
# $(call gpi-fontsize,<gpi file>,<output file>)
2482
#
2483
# Find out what the gnuplot fontsize should be.  Tries, in this order:
2484
# - ##FONTSIZE comment in gpi file
2485
# - ##FONTSIZE comment in global gpi file
2486
# - default fontsize based on output type
2487
define gpi-fontsize
2488
$(strip $(firstword \
2489
	$(shell $(SED) -e 's/^\#\#FONTSIZE=\([[:digit:]]\{1,\}\)/\1/p' -e 'd' $1 $(strip $(gpi_global))) \
2490
	$(call default-gpi-fontsize,$2)))
2491
endef
2492
2493
# $(call gpi-monochrome,<gpi file>,[gray])
2494
define gpi-monochrome
2495
$(strip $(if $2,monochrome,$(if $(shell $(EGREP) '^\#\#[[:space:]]*GRAY[[:space:]]*$$' $1 $(gpi_global)),monochrome,color)))
2496
endef
2497
2498
# $(call gpi-font-entry,<output file>,<fontsize>)
2499
#
2500
# Get the font entry given the output file (type) and the font size.  For PDF
2501
# it uses fsize or font, for eps it just uses the bare number.
2502
gpi-font-entry = $(if $(filter %.pdf,$1),$(subst FONTSIZE,$2,$(GPI_FSIZE_SYNTAX)),$2)
2503
2504
# $(call gpi-terminal,<gpi file><output file>,[gray])
2505
#
2506
# Get the terminal settings for a given gpi and its intended output file
2507
define gpi-terminal
2508
$(if $(filter %.pdf,$2),pdf enhanced,postscript enhanced eps) \
2509
$(call gpi-font-entry,$2,$(call gpi-fontsize,$1,$2)) \
2510
$(call gpi-monochrome,$1,$3)
2511
endef
2512
2513
# $(call gpi-embed-pdf-fonts,<input file>,<output file>)
2514
#
2515
define gpi-embed-pdf-fonts
2516
$(GS) \
2517
	-q \
2518
	-dSAFER \
2519
	-dNOPAUSE \
2520
	-dBATCH \
2521
	-sDEVICE=$(if $(filter pdf,$(GPI_OUTPUT_EXTENSION)),pdfwrite,pswrite) \
2522
	-sOutputFile='$2' \
2523
	-sstdout=%stderr \
2524
	-dColorConversionStrategy=/LeaveColorUnchanged \
2525
	-dCompatibilityLevel=1.5 \
2526
	-dPDFSETTINGS=/prepress \
2527
	-c .setpdfwrite \
2528
	-f '$1'
2529
endef
2530
2531
# $(call convert-gpi,<gpi file>,<output file>,[gray])
2532
#
2533
define convert-gpi
2534
$(ECHO) 'set terminal $(call gpi-terminal,$1,$2,$3)' > $1head.make; \
2535
$(ECHO) 'set output "$2"' >> $1head.make; \
2536
$(if $(gpi_global),$(CAT) $(gpi_global) >> $1head.make;,) \
2537
fnames='$1head.make $1';\
2538
$(if $(gpi_sed),\
2539
	$(SED) -f '$(gpi_sed)' $$fnames > $1.temp.make; \
2540
	fnames=$1.temp.make;,\
2541
) \
2542
success=1; \
2543
if ! $(GNUPLOT) $$fnames 2>$1.log; then \
2544
	$(call colorize-gnuplot-errors,$1.log); \
2545
	success=0; \
2546
elif [ x"$(suffix $2)" = x".pdf" ]; then \
2547
	if ! $(call gpi-embed-pdf-fonts,$2,$2.embed.tmp.make); then \
2548
		success=0; \
2549
	else \
2550
		$(call move-if-exists,$2.embed.tmp.make,$2); \
2551
	fi; \
2552
fi; \
2553
$(if $(gpi_sed),$(call remove-temporary-files,$1.temp.make);,) \
2554
$(call remove-temporary-files,$1head.make); \
2555
[ "$$success" = "1" ] && $(sh_true) || $(sh_false);
2556
endef
2557
2558
# Creation of .eps files from .png files
2559
#
2560
# The intermediate step of PNM (using NetPBM) produces much nicer output than
2561
# ImageMagick's "convert" binary.  I couldn't get the right combination of
2562
# flags to make it look nice, anyway.
2563
#
2564
# To handle gray scale conversion, we pipe things through ppmtopgm in the
2565
# middle.
2566
#
2567
# $(call convert-png,<png file>,<eps file>)
2568
define convert-png
2569
$(PNGTOPNM) "$1" \
2570
	$(if $3,| $(PPMTOPGM),) \
2571
	| $(PNMTOPS) -noturn \
2572
	> "$2"
2573
endef
2574
2575
# Creation of .eps files from .jpg/.jpeg files
2576
#
2577
# Thanks to brubakee for this solution.
2578
#
2579
# Uses Postscript level 2 to avoid file size bloat
2580
# $(call convert-jpg,<jpg file>,<eps file>)
2581
define convert-jpg
2582
$(CONVERT) $(if $3,-type Grayscale,) '$1' eps2:'$2'
2583
endef
2584
2585
# Creation of .pdf files from .asy files
2586
# $(call convert-asy,<asy file>)
2587
convert-asy	= $(ASYMPTOTE) -V -f pdf $1
2588
2589
# Creation of .eps files from .fig files
2590
# $(call convert-fig,<fig file>,<output file>,[gray])
2591
convert-fig	= $(FIG2DEV) -L $(if $(filter %.pdf,$2),pdf,eps) $(if $3,-N,) $1 $2
2592
2593
# Creation of .pstex files from .fig files
2594
# $(call convert-fig-pstex,<fig file>,<pstex file>)
2595
convert-fig-pstex	= $(FIG2DEV) -L pstex $1 $2 > /dev/null 2>&1
2596
2597
# Creation of .pstex_t files from .fig files
2598
# $(call convert-fig-pstex-t,<fig file>,<pstex file>,<pstex_t file>)
2599
convert-fig-pstex-t	= $(FIG2DEV) -L pstex_t -p $3 $1 $2 > /dev/null 2>&1
2600
2601
# Creation of .dot_t files from .dot files
2602
# #(call convert-dot-tex,<dot file>,<dot_t file>)
2603
convert-dot-tex		= $(DOT2TEX) '$1' > '$2'
2604
2605
# Converts svg files into .eps files
2606
#
2607
# $(call convert-svg,<svg file>,<eps/pdf file>,[gray])
2608
convert-svg	= $(INKSCAPE) --without-gui $(if $(filter %.pdf,$2),--export-pdf,--export-eps)='$2' '$1'
2609
2610
# Converts xvg files into .eps files
2611
#
2612
# $(call convert-xvg,<xvg file>,<eps file>,[gray])
2613
convert-xvg	= $(XMGRACE) '$1' -printfile - -hardcopy -hdevice $(if $3,-mono,) EPS > '$2'
2614
2615
# Converts .eps.gz files into .eps files
2616
#
2617
# $(call convert-epsgz,<eps.gz file>,<eps file>,[gray])
2618
convert-epsgz	= $(GUNZIP) -c '$1' $(if $3,| $(call kill-ps-color)) > '$2'
2619
2620
# Generates a .bb file from a .eps file (sometimes latex really wants this)
2621
#
2622
# $(call eps-bb,<eps file>,<eps.bb file>)
2623
define eps-bb
2624
$(SED) \
2625
-e '/^%%Title:/p' \
2626
-e '/^%%Creator:/p' \
2627
-e '/^%%BoundingBox:/p' \
2628
-e '/^%%CreationDate:/p' \
2629
-e '/^%%EndComments/{' \
2630
-e '  d' \
2631
-e '  q' \
2632
-e '}' \
2633
-e 'd' \
2634
$1 > "$2"
2635
endef
2636
2637
# Converts .eps files into .eps files (usually a no-op, but can make grayscale)
2638
#
2639
# $(call convert-eps,<in file>,<out file>,[gray])
2640
convert-eps	= $(if $3,$(call kill-ps-color) $1 > $2)
2641
2642
# The name of the file containing special postscript commands for grayscale
2643
gray_eps_file	:= gray.eps.make
2644
2645
# Changes sethsbcolor and setrgbcolor calls in postscript to always produce
2646
# grayscale.  In general, this is accomplished by writing new versions of those
2647
# functions into the user dictionary space, which is looked up before the
2648
# global or system dictionaries (userdict is one of the permanent dictionaries
2649
# in postscript and is not read-only like systemdict).
2650
#
2651
# For setrgbcolor, the weighted average of the triple is computed and the
2652
# triple is replaced with three copies of that average before the original
2653
# procedure is called: .299R + .587G + .114B
2654
#
2655
# For sethsbcolor, the color is first converted to RGB, then to grayscale by
2656
# the new setrgbcolor operator as described above.  Why is this done?
2657
# Because simply using the value component will tend to make pure colors
2658
# white, a very undesirable thing.  Pure blue should not translate to white,
2659
# but to some level of gray.  Conversion to RGB does the right thing.  It's
2660
# messy, but it works.
2661
#
2662
# From
2663
# http://en.wikipedia.org/wiki/HSV_color_space#Transformation_from_HSV_to_RGB,
2664
# HSB = HSV (Value = Brightness), and the formula used to convert to RGB is
2665
# as follows:
2666
#
2667
# Hi = int(floor(6 * H)) mod 6
2668
# f = 6 * H - Hi
2669
# p = V(1-S)
2670
# q = V(1-fS)
2671
# t = V(1-(1-f)S)
2672
# if Hi = 0: R G B <-- V t p
2673
# if Hi = 1: R G B <-- q V p
2674
# if Hi = 2: R G B <-- p V t
2675
# if Hi = 3: R G B <-- p q V
2676
# if Hi = 4: R G B <-- t p V
2677
# if Hi = 5: R G B <-- V p q
2678
#
2679
# The messy stack-based implementation is below
2680
# $(call create-gray-eps-file,filename)
2681
define create-gray-eps-file
2682
$(ECHO) -n -e '\
2683
/OLDRGB /setrgbcolor load def\n\
2684
/setrgbcolor {\n\
2685
    .114 mul exch\n\
2686
    .587 mul add exch\n\
2687
    .299 mul add\n\
2688
    dup dup\n\
2689
    OLDRGB\n\
2690
} bind def\n\
2691
/OLDHSB /sethsbcolor load def\n\
2692
/sethsbcolor {\n\
2693
    2 index                     % H V S H\n\
2694
    6 mul floor cvi 6 mod       % Hi V S H\n\
2695
    3 index                     % H Hi V S H\n\
2696
    6 mul                       % 6H Hi V S H\n\
2697
    1 index                     % Hi 6H Hi V S H\n\
2698
    sub                         % f Hi V S H\n\
2699
    2 index 1                   % 1 V f Hi V S H\n\
2700
    4 index                     % S 1 V f Hi V S H\n\
2701
    sub mul                     % p f Hi V S H\n\
2702
    3 index 1                   % 1 V p f Hi V S H\n\
2703
    6 index                     % S 1 V p f Hi V S H\n\
2704
    4 index                     % f S 1 V p f Hi V S H\n\
2705
    mul sub mul                 % q p f Hi V S H\n\
2706
    4 index 1 1                 % 1 1 V q p f Hi V S H\n\
2707
    5 index                     % f 1 1 V q p f Hi V S H\n\
2708
    sub                         % (1-f) 1 V q p f Hi V S H\n\
2709
    8 index                     % S (1-f) 1 V q p f Hi V S H\n\
2710
    mul sub mul                 % t q p f Hi V S H\n\
2711
    4 -1 roll pop               % t q p Hi V S H\n\
2712
    7 -2 roll pop pop           % t q p Hi V\n\
2713
    5 -2 roll                   % Hi V t q p\n\
2714
    dup 0 eq\n\
2715
    {1 index 3 index 6 index}\n\
2716
    {\n\
2717
        dup 1 eq\n\
2718
        {3 index 2 index 6 index}\n\
2719
        {\n\
2720
            dup 2 eq\n\
2721
            {4 index 2 index 4 index}\n\
2722
            {\n\
2723
                dup 3 eq\n\
2724
                {4 index 4 index 3 index}\n\
2725
                {\n\
2726
                    dup 4 eq\n\
2727
                    {2 index 5 index 3 index}\n\
2728
                    {\n\
2729
                        dup 5 eq\n\
2730
                        {1 index 5 index 5 index}\n\
2731
                        {0 0 0}\n\
2732
                        ifelse\n\
2733
                    }\n\
2734
                    ifelse\n\
2735
                }\n\
2736
                ifelse\n\
2737
            }\n\
2738
            ifelse\n\
2739
        }\n\
2740
        ifelse\n\
2741
    }\n\
2742
    ifelse                      % B G R Hi V t q p\n\
2743
    setrgbcolor\n\
2744
    5 {pop} repeat\n\
2745
} bind def\n'\
2746
> $1
2747
endef
2748
2749
# This actually inserts the color-killing code into a postscript file
2750
# $(call kill-ps-color)
2751
define kill-ps-color
2752
$(SED) -e '/%%EndComments/r $(gray_eps_file)'
2753
endef
2754
2755
# Converts graphviz .dot files into .eps files
2756
# Grayscale is not directly supported by dot, so we pipe it through fig2dev in
2757
# that case.
2758
# $(call convert-dot,<dot file>,<eps file>,<log file>,[gray])
2759
define convert-dot
2760
$(DOT) -Tps '$1' 2>'$3' $(if $4,| $(call kill-ps-color)) > $2; \
2761
$(call colorize-dot-errors,$3)
2762
endef
2763
2764
# Convert DVI to Postscript
2765
# $(call make-ps,<dvi file>,<ps file>,<log file>,[<paper size>],[<beamer info>])
2766
make-ps		= \
2767
	$(DVIPS) -z -o '$2' $(if $(strip $4),-t$(strip $4),) '$1' \
2768
		$(if $5,| $(enlarge_beamer)) > $3 2>&1
2769
2770
# Convert Postscript to PDF
2771
# $(call make-pdf,<ps file>,<pdf file>,<log file>,<embed file>)
2772
make-pdf	= \
2773
	$(call ps2pdf,$1,$2,$(filter 1,$(shell $(CAT) '$4'))) > '$3' 2>&1
2774
2775
# Display information about what is being done
2776
# $(call echo-build,<input file>,<output file>,[<run number>])
2777
echo-build	= $(ECHO) "$(C_BUILD)= $1 --> $2$(if $3, ($3),) =$(C_RESET)"
2778
echo-graphic	= $(ECHO) "$(C_GRAPHIC)= $1 --> $2 =$(C_RESET)"
2779
echo-dep	= $(ECHO) "$(C_DEP)= $1 --> $2 =$(C_RESET)"
2780
2781
# Display a list of something
2782
# $(call echo-list,<values>)
2783
echo-list	= for x in $1; do $(ECHO) "$$x"; done
2784
2785
#
2786
# DEFAULT TARGET
2787
#
2788
2789
.PHONY: all
2790
all: $(default_pdf_targets) ;
2791
2792
.PHONY: all-pdf
2793
all-pdf: $(default_pdf_targets) ;
2794
2795
ifeq "$(strip $(BUILD_STRATEGY))" "latex"
2796
.PHONY: all-ps
2797
all-ps: $(default_ps_targets) ;
2798
2799
.PHONY: all-dvi
2800
all-dvi: $(default_dvi_targets) ;
2801
endif
2802
2803
#
2804
# VIEWING TARGET
2805
#
2806
.PHONY: show
2807
show: all
2808
	$(QUIET)for x in $(default_pdf_targets); do \
2809
		[ -e "$$x" ] && $(VIEW_PDF) $$x & \
2810
	done
2811
2812
#
2813
# INCLUDES
2814
#
2815
source_includes	:= $(addsuffix .d,$(source_stems_to_include))
2816
graphic_includes := $(addsuffix .gpi.d,$(graphic_stems_to_include))
2817
2818
# Check the version of the makefile
2819
ifneq "" "$(filter 3.79 3.80,$(MAKE_VERSION))"
2820
$(warning $(C_WARNING)Your version of make is too old.  Please upgrade.$(C_RESET))
2821
endif
2822
2823
# Include only the dependencies used
2824
ifneq "" "$(source_includes)"
2825
include $(source_includes)$(call include-message,$(source_includes))
2826
endif
2827
ifneq "" "$(graphic_includes)"
2828
include $(graphic_includes)$(call include-message,$(graphic_includes))
2829
endif
2830
2831
#
2832
# MAIN TARGETS
2833
#
2834
2835
# Note that we don't just say %: %.pdf here - this can tend to mess up our
2836
# includes, which detect what kind of file we are asking for.  For example,
2837
# asking to build foo.pdf is much different than asking to build foo when
2838
# foo.gpi exists, because we look through all of the goals for *.pdf that
2839
# matches *.gpi, then use that to determine which include files we need to
2840
# build.
2841
#
2842
# Thus, we invoke make recursively with better arugments instead, restarting
2843
# all of the appropriate machinery.
2844
.PHONY: $(default_stems_ss)
2845
$(default_stems_ss): %: %.pdf ;
2846
2847
# This builds and displays the wanted file.
2848
.PHONY: $(addsuffix ._show,$(stems_ssg))
2849
$(addsuffix ._show,$(stems_ssg)): %._show: %.pdf
2850
	$(QUIET)$(VIEW_PDF) $< &
2851
2852
ifeq "$(strip $(BUILD_STRATEGY))" "latex"
2853
.SECONDARY: $(all_pdf_targets)
2854
%.pdf: %.ps %.embed.make
2855
	$(QUIET)$(call echo-build,$<,$@)
2856
	$(QUIET)$(call make-pdf,$<,$@.temp,$@.log,$*.embed.make); \
2857
	if [ x"$$?" = x"0" ]; then \
2858
	    $(if $(VERBOSE),$(CAT) $@.log,:); \
2859
	    $(RM) -f '$@'; \
2860
	    $(MV) '$@.temp' '$@'; \
2861
	    $(TOUCH) '$@'; \
2862
	    $(call copy-with-logging,$@,$(BINARY_TARGET_DIR)); \
2863
	else \
2864
	    $(CAT) $@.log; \
2865
	    $(call remove-temporary-files,'$@.temp'); \
2866
	    $(sh_false); \
2867
	fi
2868
2869
.SECONDARY: $(all_ps_targets)
2870
%.ps: %.dvi %.paper.make %.beamer.make
2871
	$(QUIET)$(call echo-build,$<,$@)
2872
	$(QUIET)$(call make-ps,$<,$@.temp,$@.log,\
2873
			$(strip $(shell $(CAT) $*.paper.make)),\
2874
			$(strip $(shell $(CAT) $*.beamer.make))); \
2875
	if [ x"$$?" = x"0" ]; then \
2876
	    $(if $(VERBOSE),$(CAT) $@.log,:); \
2877
	    $(RM) -f '$@'; \
2878
	    $(MV) '$@.temp' '$@'; \
2879
	    $(TOUCH) '$@'; \
2880
	    $(call copy-with-logging,$@,$(BINARY_TARGET_DIR)); \
2881
	else \
2882
	    $(CAT) $@.log; \
2883
	    $(call remove-temporary-files,'$@.temp'); \
2884
	    $(sh_false); \
2885
	fi
2886
endif
2887
2888
# Build the final target (dvi or pdf) file.  This is a very tricky rule because
2889
# of the way that latex runs multiple times, needs graphics after the first run
2890
# (or maybe already has them), and relies on bibliographies or indices that may
2891
# not exist.
2892
#
2893
#	Check the log for fatal errors.  If they exist, colorize and bail.
2894
#
2895
#	Create the .auxtarget.cookie file.  (Needed for next time if not present)
2896
#
2897
#	If any of the following are true, we must rebuild at least one time:
2898
#
2899
#	* the .bbl was recently rebuilt
2900
#
2901
#		check a cookie, then delete it
2902
#
2903
#	* any of several output files was created or changed:
2904
#
2905
#		check $*.run.cookie, then delete it
2906
#
2907
#	* the .aux file changed in a way that necessitates attention
2908
#
2909
#		Note that if the .auxtarget.make file doesn't exist, this means
2910
#		that we are doing a clean build, so it doesn't figure into the
2911
#		test for running again.
2912
#
2913
#		compare against .auxtarget.make
2914
#
2915
#		move if different, remove if not
2916
#
2917
#	* the .log file has errors or warnings requiring at least one more run
2918
#
2919
#	We use a loop over a single item to simplify the process of breaking
2920
#	out when we find one of the conditions to be true.
2921
#
2922
#	If we do NOT need to run latex here, then we move the $@.1st.make file
2923
#	over to $@ because the target file has already been built by the first
2924
#	dependency run and is valid.
2925
#
2926
#	If we do, we delete that cookie file and do the normal multiple-runs
2927
#	routine.
2928
#
2929
ifeq "$(strip $(BUILD_STRATEGY))" "latex"
2930
.SECONDARY: $(all_dvi_targets)
2931
endif
2932
%.$(build_target_extension): %.bbl %.aux %.$(build_target_extension).1st.make
2933
	$(QUIET)\
2934
	fatal=`$(call colorize-latex-errors,$*.log)`; \
2935
	if [ x"$$fatal" != x"" ]; then \
2936
		$(ECHO) "$$fatal"; \
2937
		exit 1; \
2938
	fi; \
2939
	$(call make-auxtarget-file,$*.aux.make,$*.auxtarget.cookie); \
2940
	run=0; \
2941
	for i in 1; do \
2942
		if $(call test-exists,$*.bbl.cookie); then \
2943
			$(call set-run-reason,$*.bbl.cookie is present); \
2944
			run=1; \
2945
			break; \
2946
		fi; \
2947
		if $(call test-exists,$*.run.cookie); then \
2948
			$(call set-run-reason,$*.run.cookie is present); \
2949
			run=1; \
2950
		    	break; \
2951
		fi; \
2952
		if $(call \
2953
		test-exists-and-different,$*.auxtarget.cookie,$*.auxtarget.make);\
2954
		then \
2955
			$(call set-run-reason,$*.auxtarget.cookie differs from $*.auxtarget.make); \
2956
			run=1; \
2957
			break; \
2958
		fi; \
2959
		if $(call test-log-for-need-to-run,$*); then \
2960
			$(call set-run-reason,$*.log indicated that this is necessary); \
2961
			run=1; \
2962
			break; \
2963
		fi; \
2964
		if $(call test-not-exists,$@.1st.make); then \
2965
			$(call set-run-reason,$@.1st.make does not exist); \
2966
			run=1; \
2967
			break; \
2968
		fi; \
2969
	done; \
2970
	$(call remove-temporary-files,$*.bbl.cookie $*.run.cookie); \
2971
	$(MV) $*.auxtarget.cookie $*.auxtarget.make; \
2972
	if [ x"$$run" = x"1" ]; then \
2973
		$(call remove-files,$@.1st.make); \
2974
		for i in 2 3 4 5; do \
2975
			$(if $(findstring 3.79,$(MAKE_VERSION)),\
2976
				$(call echo-build,$*.tex,$@,$(RESTARTS)-$$$$i),\
2977
				$(call echo-build,$*.tex,$@,$(RESTARTS)-$$i)\
2978
			); \
2979
			$(call run-latex,$*); \
2980
			$(CP) '$*.log' '$*.'$(RESTARTS)-$$i'.log'; \
2981
			if $(call test-run-again,$*); then \
2982
				$(call set-run-reason,rerun requested by $*.log); \
2983
			else \
2984
				break; \
2985
			fi; \
2986
		done; \
2987
	else \
2988
		$(MV) '$@.1st.make' '$@'; \
2989
	fi; \
2990
	$(call copy-with-logging,$@,$(BINARY_TARGET_DIR)); \
2991
	$(call latex-color-log,$*)
2992
2993
# Build the .bbl file.  When dependencies are included, this will (or will
2994
# not!) depend on something.bib, which we detect, acting accordingly.  The
2995
# dependency creation also produces the %.auxbbl.make file.  BibTeX is a bit
2996
# finicky about what you call the actual files, but we can rest assured that if
2997
# a .auxbbl.make file exists, then the .aux file does, as well.  The
2998
# .auxbbl.make file is a cookie indicating whether the .bbl needs to be
2999
# rewritten.  It only changes if the .aux file changes in ways relevant to .bbl
3000
# creation.
3001
#
3002
# Note that we do NOT touch the .bbl file if there is no need to
3003
# create/recreate it.  We would like to leave existing files alone if they
3004
# don't need to be changed, thus possibly avoiding a rebuild trigger.
3005
ifeq "$(strip $(BIB_STRATEGY))" "bibtex"
3006
%.bbl: %.auxbbl.make
3007
	$(QUIET)\
3008
	$(if $(filter %.bib,$^),\
3009
		$(call echo-build,$(filter %.bib,$?) $*.aux,$@); \
3010
		$(call set-run-reason,dependencies of $@ changed); \
3011
		$(call run-bibtex,$*); \
3012
		$(TOUCH) $@.cookie; \
3013
	) \
3014
	if $(EGREP) -q 'bibstyle.(apacite|apacann|chcagoa|[^}]*annot)' '$*.aux'; then \
3015
		$(call echo-build,** annotated extra latex **,output ignored,$(RESTARTS)-1); \
3016
		$(call run-latex,$*); \
3017
		$(CP) '$*.log' '$*.$(RESTARTS)-annotated.log'; \
3018
		$(if $(filter %.bib,$^),\
3019
			$(call echo-build,** annotated extra bibtex ** $(filter %.bib,$?) $*.aux,$@); \
3020
			$(call run-bibtex,$*); \
3021
			$(TOUCH) $@.cookie; \
3022
		) \
3023
		$(call echo-build,** annotated extra latex **,output ignored,$(RESTARTS)-2); \
3024
		$(call run-latex,$*); \
3025
	fi
3026
endif
3027
ifeq "$(strip $(BIB_STRATEGY))" "biblatex"
3028
%.bbl: %.bcf
3029
	$(QUIET)$(call echo-build,$<,$@)
3030
	$(QUIET)$(call run-bibtex,$<,$@,$*.bcf)
3031
endif
3032
3033
# Create the index file - note that we do *not* depend on %.tex here, since
3034
# that unnecessarily restricts the kinds of indices that we can build to those
3035
# with exactly the same stem as the source file.  Things like splitidx create
3036
# idx files with other names.
3037
#
3038
# Therefore, we add the .tex dependency in the sourcestem.d file in the call to
3039
# get index file dependencies from the logs.
3040
%.ind:	%.idx
3041
	$(QUIET)$(call echo-build,$<,$@)
3042
	$(QUIET)$(call run-makeindex,$<,$@,$*.ilg)
3043
3044
# Create a glossary file from a .ist file
3045
%.gls:	%.glo %.tex %.ist
3046
	$(QUIET)$(call echo-build,$<,$@)
3047
	$(QUIET)$(call run-makeindex,$<,$@,$*.glg,$*.ist)
3048
3049
# Create a glossary file from a glossary input formatted for xindy
3050
%.gls:	%.glo %.tex %.xdy
3051
	$(QUIET)$(call echo-build,$<,$@)
3052
	$(QUIET)$(call run-xindy,$<,$@,$*,$*.glg)
3053
3054
# Create the glossary file from a nomenclature file
3055
%.gls:	%.glo %.tex $(call path-norm,$(shell $(KPSEWHICH) nomencl.ist || $(ECHO) nomencl.ist))
3056
	$(QUIET)$(call echo-build,$<,$@)
3057
	$(QUIET)$(call run-makeindex,$<,$@,$*.glg,nomencl.ist)
3058
3059
# Create the nomenclature file
3060
%.nls:	%.nlo %.tex $(call path-norm,$(shell $(KPSEWHICH) nomencl.ist || $(ECHO) nomencl.ist))
3061
	$(QUIET)$(call echo-build,$<,$@)
3062
	$(QUIET)$(call run-makeindex,$<,$@,$*.nlg,nomencl.ist)
3063
3064
# Precompile the format file
3065
%.fmt:	%.tex
3066
	$(QUIET)$(call echo-build,$<,$@)
3067
	$(QUIET)\
3068
	$(call run-latex,$*,-ini "&$(latex_build_program) $*.tex\dump"); \
3069
	fatal=`$(call colorize-latex-errors,$*.log)`; \
3070
	if [ x"$$fatal" != x"" ]; then \
3071
		$(ECHO) "$$fatal"; \
3072
		exit 1; \
3073
	fi;
3074
3075
# SCRIPTED LaTeX TARGETS
3076
#
3077
# Keep the generated .tex files around for debugging if needed.
3078
.SECONDARY: $(all_tex_targets)
3079
3080
%.tex::	%.tex.sh
3081
	$(QUIET)$(call run-script,$(SHELL),$<,$@)
3082
3083
%.tex::	%.tex.py
3084
	$(QUIET)$(call run-script,$(PYTHON),$<,$@)
3085
3086
%.tex::	%.tex.pl
3087
	$(QUIET)$(call run-script,$(PERL),$<,$@)
3088
3089
%.tex::	%.rst $(RST_STYLE_FILE)
3090
	$(QUIET)\
3091
	$(call run-script,$(RST2LATEX)\
3092
		--documentoptions=letterpaper\
3093
		$(if $(RST_STYLE_FILE),--stylesheet=$(RST_STYLE_FILE),),$<,$@)
3094
3095
%.tex::	%.lhs
3096
	$(QUIET)\
3097
	function run_lhs2tex() { $(LHS2TEX) -o "$$2" "$$1"; }; \
3098
	$(call run-script,run_lhs2tex,$<,$@)
3099
3100
#
3101
# GRAPHICS TARGETS
3102
#
3103
.PHONY: all-graphics
3104
all-graphics:	$(all_graphics_targets);
3105
3106
ifeq "$(strip $(BUILD_STRATEGY))" "latex"
3107
.PHONY: all-pstex
3108
all-pstex:	$(all_pstex_targets);
3109
endif
3110
3111
.PHONY: all-dot2tex
3112
all-dot2tex:	$(all_dot2tex_targets);
3113
3114
.PHONY: show-graphics
3115
show-graphics: all-graphics
3116
	$(VIEW_GRAPHICS) $(all_known_graphics)
3117
3118
$(gray_eps_file):
3119
	$(QUIET)$(call echo-build,$^,$@)
3120
	$(QUIET)$(call create-gray-eps-file,$@)
3121
3122
ifeq "$(strip $(BUILD_STRATEGY))" "pdflatex"
3123
%.pdf: %.eps $(if $(GRAY),$(gray_eps_file))
3124
	$(QUIET)$(call echo-graphic,$^,$@)
3125
	$(QUIET)$(call convert-eps-to-pdf,$<,$@,$(GRAY))
3126
3127
ifeq "$(strip $(GPI_OUTPUT_EXTENSION))" "pdf"
3128
%.pdf:	%.gpi %.gpi.d $(gpi_sed) $(gpi_global)
3129
	$(QUIET)$(call echo-graphic,$^,$@)
3130
	$(QUIET)$(call convert-gpi,$<,$@,$(GRAY))
3131
endif
3132
3133
%.pdf:	%.fig
3134
	$(QUIET)$(call echo-graphic,$^,$@)
3135
	$(QUIET)$(call convert-fig,$<,$@,$(GRAY))
3136
3137
%.pdf:	%.asy
3138
	$(QUIET)$(call echo-graphic,$^,$@)
3139
	$(QUIET)$(call convert-asy,$<)
3140
3141
%.pdf:	%.svg
3142
	$(QUIET)$(call echo-graphic,$^,$@)
3143
	$(QUIET)$(call convert-svg,$<,$@,$(GRAY))
3144
endif
3145
3146
ifeq "$(strip $(BUILD_STRATEGY))" "xelatex"
3147
%.pdf: %.eps $(if $(GRAY),$(gray_eps_file))
3148
	$(QUIET)$(call echo-graphic,$^,$@)
3149
	$(QUIET)$(call convert-eps-to-pdf,$<,$@,$(GRAY))
3150
3151
ifeq "$(strip $(GPI_OUTPUT_EXTENSION))" "pdf"
3152
%.pdf:	%.gpi %.gpi.d $(gpi_sed) $(gpi_global)
3153
	$(QUIET)$(call echo-graphic,$^,$@)
3154
	$(QUIET)$(call convert-gpi,$<,$@,$(GRAY))
3155
endif
3156
3157
%.pdf:	%.fig
3158
	$(QUIET)$(call echo-graphic,$^,$@)
3159
	$(QUIET)$(call convert-fig,$<,$@,$(GRAY))
3160
3161
%.pdf:	%.asy
3162
	$(QUIET)$(call echo-graphic,$^,$@)
3163
	$(QUIET)$(call convert-asy,$<)
3164
3165
%.pdf:	%.svg
3166
	$(QUIET)$(call echo-graphic,$^,$@)
3167
	$(QUIET)$(call convert-svg,$<,$@,$(GRAY))
3168
endif
3169
3170
ifeq "$(strip $(BUILD_STRATEGY))" "lualatex"
3171
%.pdf: %.eps $(if $(GRAY),$(gray_eps_file))
3172
	$(QUIET)$(call echo-graphic,$^,$@)
3173
	$(QUIET)$(call convert-eps-to-pdf,$<,$@,$(GRAY))
3174
3175
ifeq "$(strip $(GPI_OUTPUT_EXTENSION))" "pdf"
3176
%.pdf:	%.gpi %.gpi.d $(gpi_sed) $(gpi_global)
3177
	$(QUIET)$(call echo-graphic,$^,$@)
3178
	$(QUIET)$(call convert-gpi,$<,$@,$(GRAY))
3179
endif
3180
3181
%.pdf:	%.fig
3182
	$(QUIET)$(call echo-graphic,$^,$@)
3183
	$(QUIET)$(call convert-fig,$<,$@,$(GRAY))
3184
3185
%.pdf:	%.asy
3186
	$(QUIET)$(call echo-graphic,$^,$@)
3187
	$(QUIET)$(call convert-asy,$<)
3188
3189
%.pdf:	%.svg
3190
	$(QUIET)$(call echo-graphic,$^,$@)
3191
	$(QUIET)$(call convert-svg,$<,$@,$(GRAY))
3192
endif
3193
3194
3195
# TODO: capture mpost output and display errors
3196
# TODO: figure out why pdf generation is erroring out (but working anyway)
3197
%.eps %.mps %.mpx %.log: %.mp
3198
	$(QUIET)$(call echo-graphic,$^,$@)
3199
	$(QUIET)$(MPOST) $*
3200
	$(QUIET)$(call move-if-exists,$*.mps,$*.eps)
3201
	$(QUIET)$(call move-if-exists,$*.log,$*.log.make)
3202
	$(QUIET)$(call move-if-exists,$*.mpx,$*.mpx.make)
3203
3204
%.eps:	%.gpi %.gpi.d $(gpi_sed) $(gpi_global)
3205
	$(QUIET)$(call echo-graphic,$^,$@)
3206
	$(QUIET)$(call convert-gpi,$<,$@,$(GRAY))
3207
3208
%.eps: %.fig
3209
	$(QUIET)$(call echo-graphic,$^,$@)
3210
	$(QUIET)$(call convert-fig,$<,$@,$(GRAY))
3211
3212
%.eps: %.dot $(if $(GRAY),$(gray_eps_file))
3213
	$(QUIET)$(call echo-graphic,$^,$@)
3214
	$(QUIET)$(call convert-dot,$<,$@,$<.log,$(GRAY))
3215
3216
%.eps: %.xvg $(if $(GRAY),$(gray_eps_file))
3217
	$(QUIET)$(call echo-graphic,$^,$@)
3218
	$(QUIET)$(call convert-xvg,$<,$@,$(GRAY))
3219
3220
ifneq "$(default_graphic_extension)" "pdf"
3221
# We have a perfectly good build rule for svg to pdf, so we eliminate this to
3222
# avoid confusing make (it sometimes chooses to go svg -> eps -> pdf).
3223
%.eps: %.svg $(if $(GRAY),$(gray_eps_file))
3224
	$(QUIET)$(call echo-graphic,$^,$@)
3225
	$(QUIET)$(call convert-svg,$<,$@,$(GRAY))
3226
3227
# Similarly for these, we don't need eps if we have supported extensions
3228
# already.
3229
%.eps: %.jpg $(if $(GRAY),$(gray_eps_file))
3230
	$(QUIET)$(call echo-graphic,$^,$@)
3231
	$(QUIET)$(call convert-jpg,$<,$@,$(GRAY))
3232
3233
%.eps: %.jpeg $(if $(GRAY),$(gray_eps_file))
3234
	$(QUIET)$(call echo-graphic,$^,$@)
3235
	$(QUIET)$(call convert-jpg,$<,$@,$(GRAY))
3236
3237
%.eps: %.png $(if $(GRAY),$(gray_eps_file))
3238
	$(QUIET)$(call echo-graphic,$^,$@)
3239
	$(QUIET)$(call convert-png,$<,$@,$(GRAY))
3240
endif
3241
3242
%.eps.bb: %.eps
3243
	$(QUIET)$(call echo-graphic,$^,$@)
3244
	$(QUIET)$(call eps-bb,$<,$@)
3245
3246
%.eps: %.eps.gz $(if $(GRAY),$(gray_eps_file))
3247
	$(QUIET)$(call echo-graphic,$^,$@)
3248
	$(QUIET)$(call convert-epsgz,$<,$@,$(GRAY))
3249
3250
%.pstex: %.fig
3251
	$(QUIET)$(call echo-graphic,$^,$@)
3252
	$(QUIET)$(call convert-fig-pstex,$<,$@,$(GRAY))
3253
3254
%.pstex_t: %.fig %.pstex
3255
	$(QUIET)$(call echo-graphic,$^,$@)
3256
	$(QUIET)$(call convert-fig-pstex-t,$<,$@,$*.pstex,$(GRAY))
3257
3258
%.dot_t: %.dot
3259
	$(QUIET)$(call echo-graphic,$^,$@)
3260
	$(QUIET)$(call convert-dot-tex,$<,$@)
3261
3262
#
3263
# DEPENDENCY-RELATED TARGETS.
3264
#
3265
3266
# Generate all of the information needed to get dependencies
3267
# As a side effect, this creates a .dvi or .pdf file (depending on the build
3268
# strategy).  We need to be sure to remove it if there are errors.  Errors can
3269
# take several forms and all of them are found within the log file:
3270
#	* There was a LaTeX error
3271
#	* A needed file was not found
3272
#	* Cross references need adjustment
3273
#
3274
# Behavior:
3275
#	This rule is responsible for generating the following:
3276
#	%.aux
3277
#	%.d
3278
#	%.aux.make
3279
#	%.(pdf|dvi).1st.make (the .pdf or .dvi output file, moved)
3280
#
3281
#	Steps:
3282
#
3283
#	Run latex
3284
#	Move .pdf or .dvi somewhere else (make no judgements about success)
3285
#	Flatten the .aux file into another file
3286
#	Add source dependencies
3287
#	Add graphic dependencies
3288
#	Add bib dependencies
3289
#
3290
#	Create cookies for various suffixes that may represent files that
3291
#	need to be read by LaTeX in order for it to function properly.
3292
#
3293
#	Note that if some of the dependencies are discovered because they turn
3294
#	up missing in the log file, we really need the .d file to be reloaded.
3295
#	Adding a sleep command helps with this.  Otherwise make is extremely
3296
#	nondeterministic, sometimes working, sometimes not.
3297
#
3298
#	Usually we can force this by simply removing the generated pdf file and
3299
#	not creating a .1st.make file..
3300
#
3301
%.$(build_target_extension).1st.make %.d %.aux %.aux.make %.fls: %.tex
3302
	$(QUIET)$(call echo-build,$<,$*.d $*.$(build_target_extension).1st.make,$(RESTARTS)-1)
3303
	$(QUIET)\
3304
	$(call set-run-reason,need to build .d and .$(build_target_extension).1st.make); \
3305
	$(call run-latex,$*,-recorder) || $(sh_true); \
3306
	$(CP) '$*.log' '$*.$(RESTARTS)-1.log'; \
3307
	$(call die-on-import-sty,$*.log); \
3308
	$(call die-on-dot2tex,$*.log); \
3309
	$(call die-on-no-aux,$*); \
3310
	$(call flatten-aux,$*.aux,$*.aux.make); \
3311
	$(ECHO) "# vim: ft=make" > $*.d; \
3312
	$(ECHO) ".PHONY: $*._graphics" >> $*.d; \
3313
	$(call get-inputs,$*.fls,$(addprefix $*.,aux aux.make d $(build_target_extension))) >> $*.d; \
3314
	$(call get-format,$<,$(addprefix $*.,fls aux aux.make d $(build_target_extension) $(build_target_extension).1st.make)) >> $*.d; \
3315
	$(call get-missing-inputs,$*.log,$(addprefix $*.,aux aux.make d $(build_target_extension))) >> $*.d; \
3316
	$(ECHO) ".SECONDEXPANSION:" >> $*.d; \
3317
	$(call get-graphics,$*) >> $*.d; \
3318
	$(call get-log-index,$*,$(addprefix $*.,aux aux.make)) >> $*.d; \
3319
	$(call get-bibs,$*.aux.make,$(addprefix $*.,bbl aux aux.make)) >> $*.d; \
3320
	$(EGREP) -q "# MISSING stem" $*.d && $(SLEEP) 1 && $(RM) $*.pdf; \
3321
	$(EGREP) -q "# MISSING format" $*.d && $(RM) $*.pdf; \
3322
	$(call move-if-exists,$*.$(build_target_extension),$*.$(build_target_extension).1st.make); \
3323
	for s in toc out lot lof lol nav; do \
3324
		if [ -e "$*.$$s" ]; then \
3325
			if ! $(DIFF) -q $*.$$s $*.$$s.make >/dev/null 2>&1; then \
3326
				$(TOUCH) $*.run.cookie; \
3327
			fi; \
3328
			$(CP) $*.$$s $*.$$s.make; \
3329
		fi; \
3330
	done
3331
3332
# This is a cookie that is updated if the flattened aux file has changed in a
3333
# way that affects the bibliography generation.
3334
.SECONDARY: $(addsuffix .auxbbl.make,$(stems_ssg))
3335
%.auxbbl.make: %.aux.make
3336
	$(QUIET)\
3337
	$(call make-auxbbl-file,$<,$@.temp); \
3338
	$(call replace-if-different-and-remove,$@.temp,$@)
3339
3340
# Build a dependency file for .gpi files.  These often plot data files that
3341
# also reside in the directory, so if a data file changes, it's nice to know
3342
# about it.  This also handles loaded .gpi files, whose filename should have
3343
# _include_. in it.
3344
%.gpi.d: %.gpi
3345
	$(QUIET)$(call echo-build,$<,$@)
3346
	$(QUIET)$(call make-gpi-d,$<,$@)
3347
3348
# Get source specials, e.g., paper size and special %% comments.
3349
%.specials.make: %.tex
3350
	$(QUIET)$(call get-source-specials,$<,$@)
3351
3352
# Get info about whether to enlarge beamer postscript files (for use with
3353
# dvips, and requires a special comment in the source file).
3354
.SECONDARY: $(addsuffix .specials.make,$(all_stems_ss))
3355
%.beamer.make: %.specials.make
3356
	$(QUIET)$(SED) -e 's/^BEAMER.*/BEAMER/p' -e 'd' '$<' > '$@'
3357
3358
# Store the paper size for this document -- note that if beamer is used we set
3359
# it to the special BEAMER paper size.  We only do this, however, if the
3360
# special comment exists, in which case we enlarge the output with psnup.
3361
#
3362
#	The paper size is extracted from a documentclass attribute.
3363
%.paper.make: %.specials.make
3364
	$(QUIET)$(SED) -e 's/^PAPERSIZE=//p' -e 'd' '$<' > '$@'
3365
3366
# Store embedding instructions for this document using a special comment
3367
%.embed.make: %.specials.make
3368
	$(QUIET)$(EGREP) '^NOEMBED$$' $< \
3369
		&& $(ECHO) '' > $@ \
3370
		|| $(ECHO) '1' > $@;
3371
3372
#
3373
# HELPFUL PHONY TARGETS
3374
#
3375
3376
.PHONY: _all_programs
3377
_all_programs:
3378
	$(QUIET)$(ECHO) "== All External Programs Used =="
3379
	$(QUIET)$(call output-all-programs)
3380
3381
.PHONY: _check_programs
3382
_check_programs:
3383
	$(QUIET)$(ECHO) "== Checking Makefile Dependencies =="; $(ECHO)
3384
	$(QUIET) \
3385
	allprogs=`\
3386
	 ($(call output-all-programs)) | \
3387
	 $(SED) \
3388
	 -e 's/^[[:space:]]*//' \
3389
	 -e '/^#/d' \
3390
	 -e 's/[[:space:]]*#.*//' \
3391
	 -e '/^=/s/[[:space:]]/_/g' \
3392
	 -e '/^[[:space:]]*$$/d' \
3393
	 -e 's/^[^=].*=[[:space:]]*\([^[:space:]]\{1,\}\).*$$/\\1/' \
3394
	 `; \
3395
	spaces='                             '; \
3396
	for p in $${allprogs}; do \
3397
	case $$p in \
3398
		=*) $(ECHO); $(ECHO) "$$p";; \
3399
		*) \
3400
			$(ECHO) -n "$$p:$$spaces" | $(SED) -e 's/^\(.\{0,20\}\).*$$/\1/'; \
3401
			loc=`$(WHICH) $$p`; \
3402
			if [ x"$$?" = x"0" ]; then \
3403
				$(ECHO) "$(C_SUCCESS)Found:$(C_RESET) $$loc"; \
3404
			else \
3405
				$(ECHO) "$(C_FAILURE)Not Found$(C_RESET)"; \
3406
			fi; \
3407
			;; \
3408
	esac; \
3409
	done
3410
3411
.PHONY: _check_gpi_files
3412
_check_gpi_files:
3413
	$(QUIET)$(ECHO) "== Checking all .gpi files for common errors =="; \
3414
	$(ECHO); \
3415
	for f in $(files.gpi); do \
3416
	result=`$(EGREP) '^([^#]*set terminal |set output )' $$f`; \
3417
	$(ECHO) -n "$$f: "; \
3418
	if [ x"$$result" = x"" ]; then \
3419
		$(ECHO) "$(C_SUCCESS)Okay$(C_RESET)"; \
3420
	else \
3421
		$(ECHO) "$(C_FAILURE)Warning: Problematic commands:$(C_RESET)";\
3422
		$(ECHO) "$(C_ERROR)$$result$(C_RESET)"; \
3423
	fi; \
3424
	done; \
3425
	$(ECHO)
3426
3427
.PHONY: _all_stems
3428
_all_stems:
3429
	$(QUIET)$(ECHO) "== All Stems =="
3430
	$(QUIET)$(call echo-list,$(sort $(default_stems_ss)))
3431
3432
.PHONY: _includes
3433
_includes:
3434
	$(QUIET)$(ECHO) "== Include Stems =="
3435
	$(QUIET)$(ECHO) "=== Sources ==="
3436
	$(QUIET)$(call echo-list,$(sort $(source_includes)))
3437
	$(QUIET)$(ECHO) "=== Graphics ==="
3438
	$(QUIET)$(call echo-list,$(sort $(graphic_includes)))
3439
3440
.PHONY: _all_sources
3441
_all_sources:
3442
	$(QUIET)$(ECHO) "== All Sources =="
3443
	$(QUIET)$(call echo-list,$(sort $(all_files.tex)))
3444
3445
.PHONY: _dependency_graph
3446
_dependency_graph:
3447
	$(QUIET)$(ECHO) "/* LaTeX Dependency Graph */"
3448
	$(QUIET)$(call output-dependency-graph)
3449
3450
.PHONY: _show_dependency_graph
3451
_show_dependency_graph:
3452
	$(QUIET)$(call output-dependency-graph,$(graph_stem).dot)
3453
	$(QUIET)$(DOT) -Tps -o $(graph_stem).eps $(graph_stem).dot
3454
	$(QUIET)$(VIEW_POSTSCRIPT) $(graph_stem).eps
3455
	$(QUIET)$(call remove-temporary-files,$(graph_stem).*)
3456
3457
.PHONY: _sources
3458
_sources:
3459
	$(QUIET)$(ECHO) "== Sources =="
3460
	$(QUIET)$(call echo-list,$(sort $(files.tex)))
3461
3462
.PHONY: _source_gens
3463
_source_gens:
3464
	$(QUIET)$(ECHO) "== Generated Sources =="
3465
	$(QUIET)$(call echo-list,$(sort $(files_source_gen)))
3466
3467
.PHONY: _scripts
3468
_scripts:
3469
	$(QUIET)$(ECHO) "== Scripts =="
3470
	$(QUIET)$(call echo-list,$(sort $(files_scripts)))
3471
3472
.PHONY: _graphic_outputs
3473
_graphic_outputs:
3474
	$(QUIET)$(ECHO) "== Graphic Outputs =="
3475
	$(QUIET)$(call echo-list,$(sort $(all_graphics_targets)))
3476
3477
.PHONY: _env
3478
_env:
3479
ifdef .VARIABLES
3480
	$(QUIET)$(ECHO) "== MAKE VARIABLES =="
3481
	$(QUIET)$(call echo-list,$(foreach var,$(sort $(.VARIABLES)),'$(var)'))
3482
endif
3483
	$(QUIET)$(ECHO) "== ENVIRONMENT =="
3484
	$(QUIET)$(ENV)
3485
3486
#
3487
# CLEAN TARGETS
3488
#
3489
# clean-generated is somewhat unique - it relies on the .fls file being
3490
# properly built so that it can determine which of the files was generated, and
3491
# which was not.  Expect it to silently fail if the .fls file is missing.
3492
#
3493
# This is used to, e.g., clean up index files that are generated by the LaTeX.
3494
.PHONY: clean-generated
3495
clean-generated:
3496
	$(QUIET)$(call clean-files,$(foreach e,$(addsuffix .fls,$(all_stems_source)),\
3497
						$(shell $(call get-generated-names,$e))))
3498
3499
.PHONY: clean-deps
3500
clean-deps:
3501
	$(QUIET)$(call clean-files,$(all_d_targets) *.make *.make.temp *.cookie)
3502
3503
.PHONY: clean-tex
3504
clean-tex: clean-deps
3505
	$(QUIET)$(call clean-files,$(rm_tex))
3506
3507
.PHONY: clean-graphics
3508
# TODO: This *always* deletes pstex files, even if they were not generated by
3509
# anything....  In other words, if you create a pstex and pstex_t pair by hand
3510
# an drop them in here without the generating fig file, they will be deleted
3511
# and you won't get them back.  It's a hack put in here because I'm not sure we
3512
# even want to keep pstex functionality, so my motivation is not terribly high
3513
# for doing it right.
3514
clean-graphics:
3515
	$(QUIET)$(call clean-files,$(all_graphics_targets) *.gpi.d *.pstex *.pstex_t *.dot_t)
3516
3517
.PHONY: clean-backups
3518
clean-backups:
3519
	$(QUIET)$(call clean-files,$(backup_patterns) *.temp)
3520
3521
.PHONY: clean-auxiliary
3522
clean-auxiliary:
3523
	$(QUIET)$(call clean-files,$(graph_stem).*)
3524
3525
.PHONY: clean-nographics
3526
clean-nographics: clean-tex clean-deps clean-backups clean-auxiliary ;
3527
3528
.PHONY: clean
3529
clean: clean-generated clean-tex clean-graphics clean-deps clean-backups clean-auxiliary ;
3530
3531
#
3532
# HELP TARGETS
3533
#
3534
3535
.PHONY: help
3536
help:
3537
	$(help_text)
3538
3539
.PHONY: version
3540
version:
3541
	$(QUIET)\
3542
	$(ECHO) "$(fileinfo) Version $(version)"; \
3543
	$(ECHO) "by $(author)"; \
3544
3545
#
3546
# HELP TEXT
3547
#
3548
3549
define help_text
3550
# $(fileinfo) Version $(version)
3551
#
3552
# by $(author)
3553
#
3554
# Generates a number of possible output files from a LaTeX document and its
3555
# various dependencies.  Handles .bib files, \include and \input, and .eps
3556
# graphics.  All dependencies are handled automatically by running LaTeX over
3557
# the source.
3558
#
3559
# USAGE:
3560
#
3561
#    make [GRAY=1] [VERBOSE=1] [SHELL_DEBUG=1] <target(s)>
3562
#
3563
# STANDARD OPTIONS:
3564
#    GRAY:
3565
#        Setting this variable forces all recompiled graphics to be grayscale.
3566
#        It is useful when creating a document for printing.  The default is
3567
#        to allow colors.  Note that it only changes graphics that need to be
3568
#        rebuilt!  It is usually a good idea to do a 'make clean' first.
3569
#
3570
#    VERBOSE:
3571
#        This turns off all @ prefixes for commands invoked by make.  Thus,
3572
#        you get to see all of the gory details of what is going on.
3573
#
3574
#    SHELL_DEBUG:
3575
#        This enables the -x option for sh, meaning that everything it does is
3576
#        echoed to stderr.  This is particularly useful for debugging
3577
#        what is going on in $$(shell ...) invocations.  One of my favorite
3578
#        debugging tricks is to do this:
3579
#
3580
#        make -d SHELL_DEBUG=1 VERBOSE=1 2>&1 | less
3581
#
3582
#    KEEP_TEMP:
3583
#        When set, this allows .make and other temporary files to stick around
3584
#        long enough to do some debugging.  This can be useful when trying to
3585
#        figure out why gnuplot is not doing the right things, for example
3586
#        (e.g., look for *head.make).
3587
#
3588
# STANDARD AUXILIARY FILES:
3589
#
3590
#      Variables.ini (formerly Makefile.ini, which still works)
3591
#
3592
#          This file can contain variable declarations that override various
3593
#          aspects of the makefile.  For example, one might specify
3594
#
3595
#          neverclean := *.pdf *.ps
3596
#          onlysources.tex := main.tex
3597
#          LATEX_COLOR_WARNING := 'bold red uline'
3598
#
3599
#          And this would override the neverclean setting to ensure that pdf
3600
#          and ps files always remain behind, set the makefile to treat all
3601
#          .tex files that are not "main.tex" as includes (and therefore not
3602
#          default targets).  It also changes the LaTeX warning output to be
3603
#          red, bold, and underlined.
3604
#
3605
#          There are numerous variables in this file that can be overridden in
3606
#          this way.  Search for '?=' to find them all.
3607
#
3608
#          The Variables.ini is imported before *anything else* is done, so go
3609
#          wild with your ideas for changes to this makefile in there.  It
3610
#          makes it easy to test them before submitting patches.
3611
#
3612
#          If you're adding rules or targets, however, see Targets.ini below.
3613
#
3614
#      Targets.ini
3615
#
3616
#          This is included much later in the makefile, after all variables and
3617
#          targets are defined.  This is where you would put new make rules,
3618
#          e.g.,
3619
#
3620
#          generated.tex: generating_script.weird_lang depA depB
3621
#             ./generating_script.weird_lang > $$@
3622
#
3623
#          In this file, you have access to all of the variables that the
3624
#          makefile creates, like $$(onlysources.tex).  While accessing those can
3625
#          be somewhat brittle (they are implementation details and may change),
3626
#          it is a great way to test your ideas when submitting feature requests.
3627
#
3628
# STANDARD ENVIRONMENT VARIABLES:
3629
#
3630
#      LATEX_COLOR_WARNING        '$(LATEX_COLOR_WARNING)'
3631
#      LATEX_COLOR_ERROR          '$(LATEX_COLOR_ERROR)'
3632
#      LATEX_COLOR_UNDERFULL      '$(LATEX_COLOR_UNDERFULL)'
3633
#      LATEX_COLOR_OVERFULL       '$(LATEX_COLOR_OVERFULL)'
3634
#      LATEX_COLOR_PAGES          '$(LATEX_COLOR_PAGES)'
3635
#      LATEX_COLOR_BUILD          '$(LATEX_COLOR_BUILD)'
3636
#      LATEX_COLOR_GRAPHIC        '$(LATEX_COLOR_GRAPHIC)'
3637
#      LATEX_COLOR_DEP            '$(LATEX_COLOR_DEP)'
3638
#      LATEX_COLOR_SUCCESS        '$(LATEX_COLOR_SUCCESS)'
3639
#      LATEX_COLOR_FAILURE        '$(LATEX_COLOR_FAILURE)'
3640
#
3641
#   These may be redefined in your environment to be any of the following:
3642
#
3643
#      black
3644
#      red
3645
#      green
3646
#      yellow
3647
#      blue
3648
#      magenta
3649
#      cyan
3650
#      white
3651
#
3652
#   Bold or underline may be used, as well, either alone or in combination
3653
#   with colors:
3654
#
3655
#      bold
3656
#      uline
3657
#
3658
#   Order is not important.  You may want, for example, to specify:
3659
#
3660
#   export LATEX_COLOR_SUCCESS='bold blue uline'
3661
#
3662
#   in your .bashrc file.  I don't know why, but you may want to.
3663
#
3664
# STANDARD TARGETS:
3665
#
3666
#    all:
3667
#        Make all possible documents in this directory.  The documents are
3668
#        determined by scanning for .tex and .tex.sh (described in more detail
3669
#        later) and omitting any file that ends in ._include_.tex or
3670
#        ._nobuild_.tex.  The output is a set of .pdf files.
3671
#
3672
#        If you wish to omit files without naming them with the special
3673
#        underscore names, set the following near the top of the Makefile,
3674
#        or (this is recommended) within a Makefile.ini in the same directory:
3675
#
3676
#         includes.tex := file1.tex file2.tex
3677
#
3678
#        This will cause the files listed to be considered as include files.
3679
#
3680
#        If you have only few source files, you can set
3681
#
3682
#         onlysources.tex := main.tex
3683
#
3684
#        This will cause only the source files listed to be considered in
3685
#        dependency detection.  All other .tex files will be considered as
3686
#        include files.  Note that these options work for *any* source type,
3687
#        so you could do something similar with includes.gpi, for example.
3688
#        Note that this works for *any valid source* target.  All of the
3689
#        onlysources.* variables are commented out in the shipping version of
3690
#        this file, so it does the right thing when they simply don't exist.
3691
#        The comments are purely documentation.  If you know, for example, that
3692
#        file.mycoolformat is supported by this Makefile, but don't see the
3693
#        "onlysources.mycoolformat" declared in the comments, that doesn't mean
3694
#        you can't use it.  Go ahead and set "onlysources.mycoolformat" and it
3695
#        should do the right thing.
3696
#
3697
#    show:
3698
#        Builds and displays all documents in this directory.  It uses the
3699
#        environment-overridable value of VIEW_PDF (currently $(VIEW_PDF)) to
3700
#        do its work.
3701
#
3702
#    all-graphics:
3703
#        Make all of the graphics in this directory.
3704
#
3705
#    all-pstex (only for BUILD_STRATEGY=latex):
3706
#        Build all fig files into pstex and pstex_t files.  Gray DOES NOT WORK.
3707
#
3708
#    all-gray-pstex (only for BUILD_STRATEGY=latex):
3709
#          Build all fig files into grayscale pstex and pstex_t files.
3710
#
3711
#    all-dot2tex:
3712
#          Build all dot files into tex files.
3713
#
3714
#    show-graphics:
3715
#        Builds and displays all graphics in this directory.  Uses the
3716
#        environment-overridable value of VIEW_GRAPHICS (currently
3717
#        $(VIEW_GRAPHICS)) to do its work.
3718
#
3719
#    clean:
3720
#        Remove ALL generated files, leaving only source intact.
3721
#        This will *always* skip files mentioned in the "neverclean" variable,
3722
#        either in this file or specified in Makefile.ini:
3723
#
3724
#         neverclean := *.pdf *.ps
3725
#
3726
#       The neverclean variable works on all "clean" targets below, as well.
3727
#
3728
#    clean-graphics:
3729
#        Remove all generated graphics files.
3730
#
3731
#    clean-backups:
3732
#        Remove all backup files: $(backup_patterns)
3733
#        (XFig and other editors have a nasty habit of leaving them around)
3734
#        Also removes Makefile-generated .temp files
3735
#
3736
#    clean-tex:
3737
#        Remove all files generated from LaTeX invocations except dependency
3738
#        information.  Leaves graphics alone.
3739
#
3740
#    clean-deps:
3741
#        Removes all auto-generated dependency information.
3742
#
3743
#    clean-auxiliary:
3744
#        Removes extra files created by various targets (like the dependency
3745
#        graph output).
3746
#
3747
#    clean-nographics:
3748
#        Cleans everything *except* the graphics files.
3749
#
3750
#    help:
3751
#        This help text.
3752
#
3753
#    version:
3754
#        Version information about this LaTeX makefile.
3755
#
3756
# DEBUG TARGETS:
3757
#
3758
#    _all_programs:
3759
#        A list of the programs used by this makefile.
3760
#
3761
#    _check_programs:
3762
#        Checks your system for the needed software and reports what it finds.
3763
#
3764
#    _check_gpi_files:
3765
#        Checks the .gpi files in the current directory for common errors, such
3766
#        as specification of the terminal or output file inside of the gpi file
3767
#        itself.
3768
#
3769
#    _dependency_graph:
3770
#        Outputs a .dot file to stdout that represents a graph of LaTeX
3771
#        dependencies.  To see it, use the _show_dependency_graph target or
3772
#        direct the output to a file, run dot on it, and view the output, e.g.:
3773
#
3774
#        make _dependency_graph > graph.dot
3775
#        dot -T ps -o graph.eps graph.dot
3776
#        gv graph.eps
3777
#
3778
#    _show_dependency_graph:
3779
#        Makes viewing the graph simple: extracts, builds and displays the
3780
#        dependency graph given in the _dependency_graph target using the value
3781
#        of the environment-overridable VIEW_POSTSCRIPT variable (currently set
3782
#        to $(VIEW_POSTSCRIPT)).  The postscript viewer is used because it
3783
#        makes it easier to zoom in on the graph, a critical ability for
3784
#        something so dense and mysterious.
3785
#
3786
#    _all_sources:
3787
#        List all .tex files in this directory.
3788
#
3789
#    _sources:
3790
#        Print out a list of all compilable sources in this directory.  This is
3791
#        useful for determining what make thinks it will be using as the
3792
#        primary source for 'make all'.
3793
#
3794
#    _scripts:
3795
#        Print out a list of scripts that make knows can be used to generate
3796
#        .tex files (described later).
3797
#
3798
#    _all_stems:
3799
#        Print a list of stems.  These represent bare targets that can be
3800
#        executed.  Listing <stem> as a bare target will produce <stem>.pdf.
3801
#
3802
#    _includes:
3803
#        A list of .d files that would be included in this run if _includes
3804
#        weren't specified.  This target may be used alone or in conjunction
3805
#        with other targets.
3806
#
3807
#    _graphic_outputs:
3808
#        A list of all generated .eps files
3809
#
3810
#    _env:
3811
#        A list of environment variables and their values.  If supported by
3812
#        your version of make, also a list of variables known to make.
3813
#
3814
# FILE TARGETS:
3815
#
3816
#    %, %.pdf:
3817
#        Build a PDF file from the corresponding %.tex file.
3818
#
3819
#        If BUILD_STRATEGY=pdflatex, then this builds the pdf directly.
3820
#        Otherwise, it uses this old-school but effective approach:
3821
#
3822
#            latex -> dvips -> ps2pdf
3823
#
3824
#        The BUILD_STRATEGY can be overridden in Makefile.ini in the same
3825
#        directory.  The default is pdflatex.
3826
#
3827
#        Reasons for using latex -> dvips include the "psfrag" package, and the
3828
#        generation of postscript instead of PDF.  Arguments for using pdflatex
3829
#        include "new and shiny" and "better supported."  I can't argue with
3830
#        either of those, and supporting them both didn't turn out to be that
3831
#        difficult, so there you have it.  Choices.
3832
#
3833
#    %._show:
3834
#        A phony target that builds the pdf file and then displays it using the
3835
#        environment-overridable value of VIEW_PDF ($(VIEW_PDF)).
3836
#
3837
#    %._graphics:
3838
#        A phony target that generates all graphics on which %.pdf (or %.dvi)
3839
#        depends.
3840
#
3841
#    %.ps (only for BUILD_STRATEGY=latex):
3842
#        Build a Postscript file from the corresponding %.tex file.
3843
#        This is done using dvips.  Paper size is automatically
3844
#        extracted from the declaration
3845
#
3846
#        \documentclass[<something>paper]
3847
#
3848
#        or it is the system default.
3849
#
3850
#        If using beamer (an excellent presentation class), the paper
3851
#        size is ignored.  More on this later.
3852
#
3853
#    %.dvi (only for BUILD_STRATEGY=latex):
3854
#        Build the DVI file from the corresponding %.tex file.
3855
#
3856
#    %.ind:
3857
#        Build the index for this %.tex file.
3858
#
3859
#    %.gls:
3860
#        Build the nomenclature glossary for this %.tex file.
3861
#
3862
#    %.nls:
3863
#        Build the (newer) nomenclature file for this %.tex file.
3864
#
3865
#    %.eps:
3866
#        Build an eps file from one of the following file types:
3867
#
3868
#       .dot    : graphviz
3869
#       .gpi    : gnuplot
3870
#       .fig    : xfig
3871
#       .xvg    : xmgrace
3872
#       .svg    : scalable vector graphics (goes through inkscape)
3873
#       .png    : png (goes through NetPBM)
3874
#       .jpg      : jpeg (goes through ImageMagick)
3875
#       .eps.gz : gzipped eps
3876
#
3877
#       The behavior of this makefile with each type is described in
3878
#       its own section below.
3879
#
3880
#    %.pstex{,_t} (only for BUILD_STRATEGY=latex):
3881
#       Build a .pstex_t file from a .fig file.
3882
#
3883
# FEATURES:
3884
#
3885
#    Optional Binary Directory:
3886
#        If you create the _out_ directory in the same place as the makefile,
3887
#        it will automatically be used as a dumping ground for .pdf (or .dvi,
3888
#        .ps, and .pdf) output files.
3889
#
3890
#        Alternatively, you can set the BINARY_TARGET_DIR variable, either as a
3891
#        make argument or in Makefile.ini, to point to your directory of
3892
#        choice.  Note that no pathname wildcard expansion is done in the
3893
#        makefile, so make sure that the path is complete before going in
3894
#        there.  E.g., if you want to specify something in your home directory,
3895
#        use $$HOME/ instead of ~/ so that the shell expands it before it gets
3896
#        to the makefile.
3897
#
3898
#    External Program Dependencies:
3899
#        Every external program used by the makefile is represented by an
3900
#        ALLCAPS variable at the top of this file.  This should allow you to
3901
#        make judgments about whether your system supports the use of this
3902
#        makefile.  The list is available in the ALL_PROGRAMS variable and,
3903
#        provided that you are using GNU make 3.80 or later (or you haven't
3904
#        renamed this file to something weird like "mylatexmakefile" and like
3905
#        invoking it with make -f) can be viewed using
3906
#
3907
#        make _all_programs
3908
#
3909
#        Additionally, the availability of these programs can be checked
3910
#        automatically for you by running
3911
#
3912
#        make _check_programs
3913
#
3914
#        The programs are categorized according to how important they are and
3915
#        what function they perform to help you decide which ones you really
3916
#        need.
3917
#
3918
#    Colorized Output:
3919
#        The output of commands is colorized to highlight things that are often
3920
#        important to developers.  This includes {underfull,overfull}
3921
#        {h,v}boxes, general LaTeX Errors, each stage of document building, and
3922
#        the number of pages in the final document.  The colors are obtained
3923
#        using 'tput', so colorization should work pretty well on any terminal.
3924
#
3925
#        The colors can be customized very simply by setting any of the
3926
#        LATEX_COLOR_<CONTEXT> variables in your environment (see above).
3927
#
3928
#    Predecessors to TeX Files:
3929
#        Given a target <target>, if no <target>.tex file exists but a
3930
#        corresponding script or predecessor file exists, then appropriate
3931
#        action will be taken to generate the tex file.
3932
#
3933
#        Currently supported script or predecessor languages are:
3934
#
3935
#        sh:     %.tex.sh
3936
#        perl:   %.tex.pl
3937
#        python: %.tex.py
3938
#
3939
#           Calls the script using the appropriate interpreter, assuming that
3940
#           its output is a .tex file.
3941
#
3942
#           The script is called thus:
3943
#
3944
#              <interpreter> <script file name> <target tex file>
3945
#
3946
#           and therefore sees exactly one parameter: the name of the .tex
3947
#           file that it is to create.
3948
#
3949
#           Why does this feature exist?  I ran into this while working on
3950
#           my paper dissertation.  I wrote a huge bash script that used a
3951
#           lot of sed to bring together existing papers in LaTeX.  It
3952
#           would have been nice had I had something like this to make my
3953
#           life easier, since as it stands I have to run the script and
3954
#           then build the document with make.  This feature provides hooks
3955
#           for complicated stuff that you may want to do, but that I have
3956
#           not considered.  It should work fine with included dependencies,
3957
#           too.
3958
#
3959
#           Scripts are run every time make is invoked.  Some trickery is
3960
#           employed to make sure that multiple restarts of make don't cause
3961
#           them to be run again.
3962
#
3963
#        reST: %.rst
3964
#
3965
#           Runs the reST to LaTeX converter to generate a .tex file
3966
#           If it finds a file names _rststyle_._include_.tex, uses it as
3967
#           the "stylesheet" option to rst2latex.
3968
#
3969
#           Note that this does not track sub-dependencies in rst files.  It
3970
#           assumes that the top-level rst file will change if you want a
3971
#           rebuild.
3972
#
3973
#       literate Haskell: %.lhs
3974
#
3975
#           Runs the lhs2tex program to generate a .tex file.
3976
#
3977
#    Dependencies:
3978
#
3979
#        In general, dependencies are extracted directly from LaTeX output on
3980
#        your document.  This includes
3981
#
3982
#        *    Bibliography information
3983
#        *    \include or \input files (honoring \includeonly, too)
3984
#        *    Graphics files inserted by the graphicx package
3985
#
3986
#        Where possible, all of these are built correctly and automatically.
3987
#        In the case of graphics files, these are generated from the following
3988
#        file types:
3989
#
3990
#        GraphViz:      .dot
3991
#        GNUPlot:       .gpi
3992
#        XFig:          .fig
3993
#        XMgrace:       .xvg
3994
#        SVG:           .svg
3995
#        PNG:           .png
3996
#        JPEG:          .jpg
3997
#        GZipped EPS:   .eps.gz
3998
#
3999
#        If the file exists as a .eps already, it is merely used (and will not
4000
#        be deleted by 'clean'!).
4001
#
4002
#        LaTeX and BibTeX are invoked correctly and the "Rerun to get
4003
#        cross-references right" warning is heeded a reasonable number of
4004
#        times.  In my experience this is enough for even the most troublesome
4005
#        documents, but it can be easily changed (if LaTeX has to be run after
4006
#        BibTeX more than three times, it is likely that something is moving
4007
#        back and forth between pages, and no amount of LaTeXing will fix
4008
#        that).
4009
#
4010
#        \includeonly is honored by this system, so files that are not
4011
#        specified there will not trigger a rebuild when changed.
4012
#
4013
#    Beamer:
4014
#        A special TeX source comment is recognized by this makefile (only when
4015
#        BUILD_STRATEGY=latex, since this invokes psnup):
4016
#
4017
#        %%[[:space:]]*BEAMER[[:space:]]*LARGE
4018
#
4019
#        The presence of this comment forces the output of dvips through psnup
4020
#        to enlarge beamer slides to take up an entire letter-sized page.  This
4021
#        is particularly useful when printing transparencies or paper versions
4022
#        of the slides.  For some reason landscape orientation doesn't appear
4023
#        to work, though.
4024
#
4025
#        If you want to put multiple slides on a page, use this option and then
4026
#        print using mpage, a2ps, or psnup to consolidate slides.  My personal
4027
#        favorite is a2ps, but your mileage may vary.
4028
#
4029
#        When beamer is the document class, dvips does NOT receive a paper size
4030
#        command line attribute, since beamer does special things with sizes.
4031
#
4032
#    GNUPlot Graphics:
4033
#        When creating a .gpi file, DO NOT INCLUDE the "set terminal" or "set
4034
#        output" commands!  The makefile will include terminal information for
4035
#        you.  Besides being unnecessary and potentially harmful, including the
4036
#        terminal definition in the .gpi file makes it harder for you, the one
4037
#        writing the document, to preview your graphics, e.g., with
4038
#
4039
#           gnuplot -persist myfile.gpi
4040
#
4041
#        so don't do specify a terminal or an output file in your .gpi files.
4042
#
4043
#        When building a gpi file into an eps file, there are several features
4044
#        available to the document designer:
4045
#
4046
#        Global Header:
4047
#            The makefile searches for the files in the variable GNUPLOT_GLOBAL
4048
#            in order:
4049
#
4050
#            ($(GNUPLOT_GLOBAL))
4051
#
4052
#            Only the first found is used.  All .gpi files in the directory are
4053
#            treated as though the contents of GNUPLOT_GLOBAL were directly
4054
#            included at the top of the file.
4055
#
4056
#            NOTE: This includes special comments! (see below)
4057
#
4058
#        Font Size:
4059
#            A special comment in a .gpi file (or a globally included file) of
4060
#            the form
4061
#
4062
#            ## FONTSIZE=<number>
4063
#
4064
#            will change the font size of the GPI output.  If font size is
4065
#            specified in both the global file and the GPI file, the
4066
#            specification in the individual GPI file is used.
4067
#
4068
#        Grayscale Output:
4069
#            GNUplot files also support a special comment to force them to be
4070
#            output in grayscale *no matter what*:
4071
#
4072
#            ## GRAY
4073
#
4074
#            This is not generally advisable, since you can always create a
4075
#            grayscale document using the forms mentioned above.  But, if your
4076
#            plot simply must be grayscale even in a document that allows
4077
#            colors, this is how you do it.
4078
#
4079
#    XFig Graphics:
4080
#            No special handling is done with XFig, except when a global
4081
#            grayscale method is used, e.g.
4082
#
4083
#                make GRAY=1 document
4084
#
4085
#            In these cases the .eps files is created using the -N switch to
4086
#            fig2dev to turn off color output.  (Only works with eps, not pstex
4087
#            output)
4088
#
4089
#    GraphVis Graphics:
4090
#            Color settings are simply ignored here.  The 'dot' program is used
4091
#            to transform a .dot file into a .eps file.
4092
#
4093
#            If you want, you can use the dot2tex program to convert dot files
4094
#            to tex graphics.  The default is to just call dot2tex with no
4095
#            arguments, but you can change the DOT2TEX definition to include
4096
#            options as needed (in your Makefile.ini).
4097
#
4098
#            Note that, as with pstex, the makefile cannot use latex's own
4099
#            output to discover all missing dot_t (output) files, since anytime
4100
#            TeX includes TeX, it has to bail when it can't find the include
4101
#            file.  It can therefore only stop on the first missing file it
4102
#            discovers, and we can't get a large list of them out easily.
4103
#
4104
#            So, the makefile errors out if it's missing an included dot_t
4105
#            file, then prompts the user to run this command manually:
4106
#
4107
#                make all-dot2tex
4108
#
4109
#    GZipped EPS Graphics:
4110
#
4111
#        A .eps.gz file is sometimes a nice thing to have.  EPS files can get
4112
#        very large, especially when created from bitmaps (don't do this if you
4113
#        don't have to).  This makefile will unzip them (not in place) to
4114
#        create the appropriate EPS file.
4115
#
4116
#
4117
endef
4118
4119
#
4120
# DEPENDENCY CHART:
4121
#
4122
# digraph "g" {
4123
#     rankdir=TB
4124
#     size="9,9"
4125
#     edge [fontsize=12 weight=10]
4126
#     node [shape=box fontsize=14 style=rounded]
4127
#
4128
#     eps [
4129
#         shape=Mrecord
4130
#         label="{{<gpi> GNUplot|<epsgz> GZip|<dot> Dot|<fig> XFig}|<eps> eps}"
4131
#         ]
4132
#     pstex [label="%.pstex"]
4133
#     pstex_t [label="%.pstex_t"]
4134
#     tex_outputs [shape=point]
4135
#     extra_tex_files [shape=point]
4136
#     gpi_data [label="<data>"]
4137
#     gpi_includes [label="_include_.gpi"]
4138
#     aux [label="%.aux"]
4139
#     fls [label="%.fls"]
4140
#     idx [label="%.idx"]
4141
#     glo [label="%.glo"]
4142
#     ind [label="%.ind"]
4143
#     log [label="%.log"]
4144
#     tex_sh [label="%.tex.sh"]
4145
#     rst [label="%.rst"]
4146
#     tex [
4147
#         shape=record
4148
#         label="<tex> %.tex|<include> _include_.tex"
4149
#         ]
4150
#     include_aux [label="_include_.aux"]
4151
#     file_bib [label=".bib"]
4152
#     bbl [label="%.bbl"]
4153
#     dvi [label="%.dvi"]
4154
#     ps [label="%.ps"]
4155
#     pdf [label="%.pdf"]
4156
#     fig [label=".fig"]
4157
#     dot [label=".dot"]
4158
#     gpi [label=".gpi"]
4159
#     eps_gz [label=".eps.gz"]
4160
#
4161
#     gpi_files [shape=point]
4162
#
4163
#     rst -> tex:tex [label="reST"]
4164
#     tex_sh -> tex:tex [label="sh"]
4165
#     tex_pl -> tex:tex [label="perl"]
4166
#     tex_py -> tex:tex [label="python"]
4167
#     tex -> tex_outputs [label="latex"]
4168
#     tex_outputs -> dvi
4169
#     tex_outputs -> aux
4170
#     tex_outputs -> log
4171
#     tex_outputs -> fls
4172
#     tex_outputs -> idx
4173
#     tex_outputs -> include_aux
4174
#     aux -> bbl [label="bibtex"]
4175
#     file_bib -> bbl [label="bibtex"]
4176
#     idx -> ind [label="makeindex"]
4177
#     glo -> gls [label="makeindex"]
4178
#     nlo -> nls [label="makeindex"]
4179
#     gls -> extra_tex_files
4180
#     nls -> extra_tex_files
4181
#     ind -> extra_tex_files
4182
#     bbl -> extra_tex_files
4183
#     eps -> extra_tex_files
4184
#     extra_tex_files -> dvi [label="latex"]
4185
#     gpi_files -> eps:gpi [label="gnuplot"]
4186
#     gpi -> gpi_files
4187
#     gpi_data -> gpi_files
4188
#     gpi_includes -> gpi_files
4189
#     eps_gz -> eps:epsgz [label="gunzip"]
4190
#     fig -> eps:fig [label="fig2dev"]
4191
#     fig -> pstex [label="fig2dev"]
4192
#     fig -> pstex_t [label="fig2dev"]
4193
#     pstex -> pstex_t [label="fig2dev"]
4194
#     dot -> eps:dot [label="dot"]
4195
#     dvi -> ps [label="dvips"]
4196
#     include_aux -> bbl [label="bibtex"]
4197
#     ps -> pdf [label="ps2pdf"]
4198
#
4199
#     edge [ color=blue label="" style=dotted weight=1 fontcolor=blue]
4200
#     fls -> tex:include [label="INPUT: *.tex"]
4201
#     fls -> file_bib [label="INPUT: *.aux"]
4202
#     aux -> file_bib [label="\\bibdata{...}"]
4203
#     include_aux -> file_bib [label="\\bibdata{...}"]
4204
#     log -> gpi [label="Graphic file"]
4205
#     log -> fig [label="Graphic file"]
4206
#     log -> eps_gz [label="Graphic file"]
4207
#     log -> dot [label="Graphic file"]
4208
#     log -> idx [label="No file *.ind"]
4209
#     log -> glo [label="No file *.gls"]
4210
#     log -> nlo [label="No file *.nls"]
4211
#     gpi -> gpi_data [label="plot '...'"]
4212
#     gpi -> gpi_includes [label="load '...'"]
4213
#     tex:tex -> ps [label="paper"]
4214
#     tex:tex -> pdf [label="embedding"]
4215
# }
4216
#
4217
4218
#
4219
# DEPENDENCY CHART SCRIPT
4220
#
4221
# $(call output_dependency_graph,[<output file>])
4222
define output-dependency-graph
4223
	if [ -f '$(this_file)' ]; then \
4224
	$(SED) \
4225
		-e '/^[[:space:]]*#[[:space:]]*DEPENDENCY CHART:/,/^$$/!d' \
4226
		-e '/DEPENDENCY CHART/d' \
4227
		-e '/^$$/d' \
4228
		-e 's/^[[:space:]]*#//' \
4229
		$(this_file) $(if $1,> '$1',); \
4230
	else \
4231
		$(ECHO) "Cannot determine the name of this makefile."; \
4232
	fi
4233
endef
4234
#
4235
.PHONY: Targets.ini $(HOME)/.latex-makefile/Targets.ini
4236
-include Targets.ini
4237
-include $(HOME)/.latex-makefile/Targets.ini
4238
#
4239
# vim: noet sts=0 sw=8 ts=8