OpenCores
URL https://opencores.org/ocsvn/phr/phr/trunk

Subversion Repositories phr

[/] [phr/] [trunk/] [doc/] [informe-tesis/] [template/] [phd-thesis-template-master/] [Makefile] - Blame information for rev 140

Go to most recent revision | Details | Compare with Previous | View Log

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



powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.