comparison flys-backend/doc/documentation/de/Makefile @ 3661:3ea5e835ecce

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

http://dive4elements.wald.intevation.org