ingo@3661: # Copyright 2004 Chris Monson (shiblon@gmail.com) ingo@3661: # Latest version available at http://www.bouncingchairs.net/oss ingo@3661: # ingo@3661: # This file is part of ``Chris Monson's Free Software''. ingo@3661: # ingo@3661: # ``Chris Monson's Free Software'' is free software; you can redistribute it ingo@3661: # and/or modify it under the terms of the GNU General Public License as ingo@3661: # published by the Free Software Foundation, Version 2. ingo@3661: # ingo@3661: # ``Chris Monson's Free Software'' is distributed in the hope that it will ingo@3661: # be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of ingo@3661: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General ingo@3661: # Public License for more details. ingo@3661: # ingo@3661: # You should have received a copy of the GNU General Public License along ingo@3661: # with ``Chris Monson's Free Software''; if not, write to the Free Software ingo@3661: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ingo@3661: # ingo@3661: # It is also available on the web at http://www.gnu.org/copyleft/gpl.html ingo@3661: # ingo@3661: # Note that using this makefile to build your documents does NOT place them ingo@3661: # under the GPL unless you, the author, specifically do so. In other words, ingo@3661: # I, Chris Monson, the copyright holder and author of this makefile, ingo@3661: # consider it impossible to ``link'' to this makefile in any way covered by ingo@3661: # the GPL. ingo@3661: # ingo@3661: # TO OBTAIN INSTRUCTIONS FOR USING THIS FILE, RUN: ingo@3661: # make help ingo@3661: # ingo@3661: fileinfo := LaTeX Makefile ingo@3661: author := Chris Monson ingo@3661: version := 2.2.0-rc1 ingo@3661: # ingo@3661: # Note that the user-global version is imported *after* the source directory, ingo@3661: # so that you can use stuff like ?= to get proper override behavior. ingo@3661: .PHONY: Makefile GNUmakefile Makefile.ini $(HOME)/.latex-makefile/Makefile.ini ingo@3661: -include Makefile.ini ingo@3661: -include $(HOME)/.latex-makefile/Makefile.ini ingo@3661: # ingo@3661: # This can be pdflatex or latex - you can change this by adding the following line to your Makefile.ini: ingo@3661: # BUILD_STRATEGY := latex ingo@3661: BUILD_STRATEGY ?= pdflatex ingo@3661: # ingo@3661: # Sets LC_ALL=C, by default, so that the locale-aware tools, like sort, be ingo@3661: # # immune to changes to the locale in the user environment. ingo@3661: export LC_ALL ?= C ingo@3661: # ingo@3661: # ingo@3661: # If you specify sources here, all other files with the same suffix ingo@3661: # will be treated as if they were _include_ files. ingo@3661: #onlysources.tex ?= main.tex ingo@3661: #onlysources.tex.sh ?= ingo@3661: #onlysources.tex.pl ?= ingo@3661: #onlysources.tex.py ?= ingo@3661: #onlysources.rst ?= ingo@3661: #onlysources.fig ?= ingo@3661: #onlysources.gpi ?= ingo@3661: #onlysources.dot ?= ingo@3661: #onlysources.xvg ?= ingo@3661: #onlysources.svg ?= ingo@3661: #onlysources.eps.gz ?= ingo@3661: #onlysources.eps ?= ingo@3661: # ingo@3661: # If you list files here, they will be treated as _include_ files ingo@3661: #includes.tex ?= file1.tex file2.tex ingo@3661: #includes.tex.sh ?= ingo@3661: #includes.tex.pl ?= ingo@3661: #includes.tex.py ?= ingo@3661: #includes.rst ?= ingo@3661: #includes.fig ?= ingo@3661: #includes.gpi ?= ingo@3661: #includes.dot ?= ingo@3661: #includes.xvg ?= ingo@3661: #includes.svg ?= ingo@3661: #includes.eps.gz ?= ingo@3661: #includes.eps ?= ingo@3661: # ingo@3661: # If you list files or wildcards here, they will *not* be cleaned - default is ingo@3661: # to allow everything to be cleaned. ingo@3661: #neverclean ?= *.pdf ingo@3661: # ingo@3661: # Alternatively (recommended), you can add those lines to a Makefile.ini file ingo@3661: # and it will get picked up automatically without your having to edit this ingo@3661: # Makefile. ingo@3661: # ingo@3661: # KNOWN ISSUES: ingo@3661: # * The following occurs: ingo@3661: # file with: \usepackage{named}\bibliographystyle{named} ingo@3661: # Compile ingo@3661: # change to: \usepackage{apalike}\bibliographystyle{apalike} ingo@3661: # Compile again -- BARF! ingo@3661: # ingo@3661: # The workaround: make clean-nographics; make ingo@3661: # ingo@3661: # Note that we may not be able to fix this. LaTeX itself barfs ingo@3661: # on this, not the makefile. The very first invocation of LaTeX ingo@3661: # (when something like this has happened) reads the existing .aux ingo@3661: # file and discovers invalid commands like \citeauthoryear that ingo@3661: # are only valid in the package that was just removed. It then ingo@3661: # tries to parse them and explodes. It's not at all clear to me ingo@3661: # how to fix this. I tried removing the .aux files on the first ingo@3661: # run of LaTeX, but that necessarily requires more subsequent ingo@3661: # rebuilds on common edits. There does not appear to be a ingo@3661: # graceful solution to this issue. ingo@3661: # ingo@3661: # CHANGES: ingo@3661: # Chris Monson (2010-04-08): ingo@3661: # * Bumped version to 2.2.0-rc1 ingo@3661: # * Added back in the rst_style_file stuff that got broken when switching ingo@3661: # rst -> tex to use the script mechanism ingo@3661: # Chris Monson (2010-03-23): ingo@3661: # * Bumped version to 2.2.0-beta8 ingo@3661: # * Work on issue 76: bad backtick escape for some sed versions, failure ingo@3661: # to clear out the hold buffer when outputting MISSING comment. ingo@3661: # - Backed out 2>&1 to &> (doesn't work in sh) ingo@3661: # - Backed out using . to source variables ingo@3661: # Chris Monson (2010-03-22): ingo@3661: # * Bumped version to 2.2.0-beta7 ingo@3661: # * Issue 72: Fix latex/bibtex invocation order for annotated bib styles ingo@3661: # * Fixed informational output to reflect which LaTeX run we're on ingo@3661: # * Fixed graphic detection to include graphics that are already there in ingo@3661: # .d files ingo@3661: # * Tightened up the .d file output to only make .d depend on graphic ingo@3661: # *source* files. This means that building foo.d no longer ingo@3661: # builds all of the graphics files on which foo.tex depends. ingo@3661: # Had to use .SECONDEXPANSION trickery to make it work. ingo@3661: # * Changed get-graphics to only accept a stem. ingo@3661: # * Fixed build-once logic for scripted .tex to work better ingo@3661: # * Made get-inputs sed script more maintainable. ingo@3661: # * Moved Makefile.ini import up higher. ingo@3661: # * Changed bare stems to not recursively invoke make ingo@3661: # * Updated diff output to be more silent everywhere ingo@3661: # * Added a MISSING comment to the .d file if stuff isn't found - forces ingo@3661: # removal of .1st.make file, which often forces it to try again. ingo@3661: # * Fixed broken graphics-target function ingo@3661: # * Added sleep to .d file generation when stuff is missing - if it ingo@3661: # builds too fast, make doesn't realize it needs to be reloaded, ingo@3661: # and thus never discovers some deeper dependencies (especially ingo@3661: # evident when graphics are included from scripted include ingo@3661: # files). ingo@3661: # Chris Monson (2010-03-17): ingo@3661: # * Bumped version to 2.2.0-beta6 ingo@3661: # * Fixed bareword builds to actually work (requires static patterns) ingo@3661: # * Fixed colorization to work with new paragraph stuff ingo@3661: # Chris Monson (2010-03-17): ingo@3661: # * Bumped version to 2.2.0-beta5 ingo@3661: # * Fixed graphic detection to be much more focused - splits log file ingo@3661: # into paragraphs before doing pattern matching. ingo@3661: # * Fixed make foo to work properly (recursively calls make foo.pdf) ingo@3661: # * Fixed gpi -> pdf generation to not waste time building .eps *after* ingo@3661: # the pdf already exists. ingo@3661: # * Changed log copies to include MAKE_RESTARTS as part of the name. ingo@3661: # * Fixed missing include file detection (also makes use of the paragraph ingo@3661: # stuff) to detect missing scripted include files. ingo@3661: # Chris Monson (2010-03-16): ingo@3661: # * Bumped version to 2.2.0-beta4 ingo@3661: # * issue 70: .pdf not moved out of the way properly on first ingo@3661: # compilation, resulting in early error detection failure. ingo@3661: # * issue 74: fixed broken error on missing .aux files: the ingo@3661: # implementation was masking real errors. ingo@3661: # Chris Monson (2010-03-15): ingo@3661: # * Bumped version to 2.2.0-beta3 ingo@3661: # * issue 71: Made the tput dependency optional ingo@3661: # * issue 73: Made .tex targets not pull in .d files (building them from ingo@3661: # scripts should not require a .d) ingo@3661: # * issue 74: Output a much saner error when a .aux file is not produced ingo@3661: # (e.g., when you are typing "make" without arguments in a ingo@3661: # directory with included .tex files that are not named with ingo@3661: # ._include_.) ingo@3661: # Chris Monson (2010-03-11): ingo@3661: # * Bumped version to 2.2.0-beta2 ingo@3661: # * Fixed clean-graphics to get rid of intermediate .eps files that may ingo@3661: # be hanging around ingo@3661: # * Added an automatic setting to use eps terminals in pdflatex mode for ingo@3661: # gnuplot if it doesn't understand pdf. ingo@3661: # * issue 66: Removed grayscale generation via magic suffix. Grayscale ingo@3661: # generation is now only available via GRAY=1 ingo@3661: # * issue 68: Added explicit handling of LC_ALL for locale-aware tools ingo@3661: # like "sort" ingo@3661: # Chris Monson (2010-03-10): ingo@3661: # * Bumped version to 2.2.0-beta1 ingo@3661: # * Fixed success message to handle output message in different places ingo@3661: # * Added name of produced file to success message ingo@3661: # Chris Monson (2010-03-10): ingo@3661: # * Bumped version to 2.2.0-alpha3 ingo@3661: # * Added meaningful error message for wrong hyperref options ingo@3661: # * Added meaningful error message for incorrect graphics extensions ingo@3661: # Chris Monson (2010-03-09): ingo@3661: # * Bumped version to 2.2.0-alpha2 ingo@3661: # * Updated graphics handling (gnuplot and fig generate pdf natively) ingo@3661: # * Changed xmgrace to output monochrome natively ingo@3661: # Chris Monson (2010-03-09): ingo@3661: # * Bumped version to 2.2.0-alpha1 - major change! ingo@3661: # * Support pdflatex natively and by default (issue 6 - a long time coming) ingo@3661: # * Add ability to have a single $HOME/.latex-makefile/Makefile.ini for ingo@3661: # all invocations ingo@3661: # * Reworked graphic inclusion detection so that extensions need not be ingo@3661: # specified for either build strategy (e.g., ingo@3661: # \includegraphics{test1.eps} -> \includegrahpics{test1}) ingo@3661: # * Changed log format to include filenames and line numbers ingo@3661: # Chris Monson (2010-02-04): ingo@3661: # * Bumped version to 2.1.43 ingo@3661: # * All of the following are for issue 63 (thanks to mojoh81): ingo@3661: # * Added documentation about fixing Makefile.ini default target ingo@3661: # * Added perl and python script targets ingo@3661: # * Fixed run logic to allow included .tex files to be scripted (the ingo@3661: # run-again logic now detects missing .tex files, and the MV ingo@3661: # command has been switched out for a command that only invokes ingo@3661: # MV if the files exist) ingo@3661: # * Changed scripted generation to only run once per make invocation ingo@3661: # * Added dependency on expr ingo@3661: # Chris Monson (2010-01-19): ingo@3661: # * Bumped version to 2.1.42 ingo@3661: # * issue 62: Added .brf extension to cleanable files (backrefs) ingo@3661: # Chris Monson (2010-01-07): ingo@3661: # * Bumped version to 2.1.41 ingo@3661: # * issue 60: bad makeindex runs now error out on subsequent tries ingo@3661: # Chris Monson (2009-12-01): ingo@3661: # * Bumped version to 2.1.40 ingo@3661: # * issue 36: build all indices (for e.g., splitidx usage) ingo@3661: # * issue 59: clean up all generated files (including indices) ingo@3661: # Chris Monson (2009-11-23): ingo@3661: # * Bumped version to 2.1.39 ingo@3661: # * issue 57: change ps2pdf invocations to just use gs directly ingo@3661: # Chris Monson (2009-11-19): ingo@3661: # * Bumped version to 2.1.38 ingo@3661: # * issue 57: Added some limited support for Cygwin (spaces in filenames) ingo@3661: # Chris Monson (2009-11-15): ingo@3661: # * Bumped version to 2.1.37 ingo@3661: # * Removed svninfo, since this is now managed by mercurial ingo@3661: # * Fixed typo in changelist ingo@3661: # * Issue 52: added jpg->eps conversion (thanks to brubakee) ingo@3661: # * Issue 54: fix missing Overfull colorization due to lack of a blank ingo@3661: # line preceding the first error. ingo@3661: # * Issue 51: remove head.tmp and body.tmp in make clean invocation ingo@3661: # * Issue 56: maintain multiple versions of log files (for debugging) ingo@3661: # Chris Monson (2009-11-14): ingo@3661: # * Bumped version to 2.1.36 ingo@3661: # * Issues 53 and 49: added .brf, .mtc, and .maf to the cleanables ingo@3661: # Chris Monson (2009-11-05): ingo@3661: # * Bumped version to 2.1.35 ingo@3661: # * Added nomenclature support (see issue 48) ingo@3661: # Chris Monson (2009-10-29): ingo@3661: # * Bumped version to 2.1.34 ingo@3661: # * Fixed _out_ creation bug introduced in 2.1.33 (it was always created) ingo@3661: # * Fixed erroneous help output for $HOME in BINARY_TARGET_DIR ingo@3661: # * Changed contact email address - bring on the spam! ingo@3661: # Chris Monson (2009-10-21): ingo@3661: # * Bumped version to 2.1.33 ingo@3661: # * Fixed issue 46, adding support for dot2tex (thanks to fdemesmay) ingo@3661: # * Made all_files.* settable in Makefile.ini (using ?= instead of :=) ingo@3661: # * Fixed issue 47, thanks to fdemesmay: add binary copy directory, copy ingo@3661: # dvi, pdf, and ps if it exists ingo@3661: # Chris Monson (2009-09-25): ingo@3661: # * Bumped version to 2.1.32 ingo@3661: # * Fixed so that a changed lol file will cause a rebuild ingo@3661: # * Added .lol files to the cleanable list ingo@3661: # Chris Monson (2009-09-08): ingo@3661: # * Bumped version to 2.1.31 ingo@3661: # * Closed issue 43: evince doesn't notice pdf change w/out touch ingo@3661: # Chris Monson (2009-08-28): ingo@3661: # * Bumped version to 2.1.30 ingo@3661: # * Closed issue 39: Capture multi-line log warnings/errors to output ingo@3661: # Chris Monson (2009-08-26): ingo@3661: # * Bumped version to 2.1.29 ingo@3661: # * Closed issue 42: add svg support using inkscape ingo@3661: # Chris Monson (2009-08-17): ingo@3661: # * Bumped version to 2.1.28 ingo@3661: # * Patch from paul.biggar for issue 38: package warnings are overlooked ingo@3661: # Chris Monson (2009-08-07): ingo@3661: # * Bumped version to 2.1.27 ingo@3661: # * Included patch for issue 37 - removes pdf/ps files before copying, ingo@3661: # allowing some broken viewers to see changes properly. ingo@3661: # Chris Monson (2009-05-15): ingo@3661: # * Bumped version to 2.1.26 ingo@3661: # * Included patch for issue 9 from favonia - detects .fig changes for ingo@3661: # pstex files during regular compilation, so long as the pstex ingo@3661: # has been built at least once with make all-pstex. ingo@3661: # Chris Monson (2009-03-27): ingo@3661: # * Bumped version to 2.1.25 ingo@3661: # * Cleaned up a bunch of variable setting stuff - more stuff is now ingo@3661: # settable from Makefile.ini ingo@3661: # * Cleaned up documentation for various features, especially settable ingo@3661: # variables. ingo@3661: # * issue 28: support for png -> eps conversion (it even looks good!) ingo@3661: # * issue 29: support for "neverclean" files in Makefile.ini ingo@3661: # * issue 30: make ps2pdf14 the default - fall back when not there ingo@3661: # Chris Monson (2009-03-09): ingo@3661: # * Bumped version to 2.1.24 ingo@3661: # * issue 27: xmgrace support (thanks to rolandschulzhd) ingo@3661: # Chris Monson (2008-10-23): ingo@3661: # * Bumped version to 2.1.23 ingo@3661: # * issue 23: fixed _check_programs to not use bash string subs ingo@3661: # Chris Monson (2008-09-02): ingo@3661: # * Bumped version to 2.1.22 ingo@3661: # * Appled patch from Holger <yllohy@googlemail.com> to add include ingo@3661: # sources and some documentation updates. ingo@3661: # * Updated backup_patterns to be a bit more aggressive (also thanks to ingo@3661: # Holger) ingo@3661: # Chris Monson (2008-08-30): ingo@3661: # * Bumped version to 2.1.21 ingo@3661: # * Added ability to specify onlysources.* variables to indicate the only ingo@3661: # files that should *not* be considered includes. Thanks to Holger ingo@3661: # <yllohy@googlemail.com> for this patch. ingo@3661: # * Added an automatic include of Makefile.ini if it exists. Allows ingo@3661: # settings to be made outside of this makefile. ingo@3661: # Chris Monson (2008-05-21): ingo@3661: # * Bumped version to 2.1.20 ingo@3661: # * Added manual pstex compilation support (run make all-pstex first) ingo@3661: # * Removed all automatic pstex support. It was totally breaking ingo@3661: # everything and is very hard to incorporate into the makefile ingo@3661: # concept because it requires LaTeX to *fail* before it can ingo@3661: # determine that it needs the files. ingo@3661: # Chris Monson (2008-04-17): ingo@3661: # * Bumped version to 2.1.19 ingo@3661: # * Changed the pstex build hack to be on by default ingo@3661: # Chris Monson (2008-04-09): ingo@3661: # * Bumped version to 2.1.18 ingo@3661: # * issue 16: fixed pstex build problems, seems nondeterministic. Added ingo@3661: # gratuitious hack for testing: set PSTEX_BUILD_ALL_HACK=1. ingo@3661: # Chris Monson (2008-04-09): ingo@3661: # * Bumped version to 2.1.17 ingo@3661: # * issue 20: fixed accumulation of <pid>*.make files - wildcard was ingo@3661: # refusing to work on files that are very recently created. ingo@3661: # Chris Monson (2008-04-02): ingo@3661: # * Bumped version to 2.1.16 ingo@3661: # * issue 19: Removed the use of "type" to fix broken "echo" settings ingo@3661: # Chris Monson (2008-03-27): ingo@3661: # * Bumped version to 2.1.15 ingo@3661: # * issue 18: Favors binary echo over builtin, as binary understands -n ingo@3661: # * issue 16: Fixed handling of missing pstex_t files in the log ingo@3661: # * issue 9: Added .SECONDARY target for .pstex files ingo@3661: # Chris Monson (2008-03-21): ingo@3661: # * Bumped version to 2.1.14 ingo@3661: # * Fixed broken aux file flattening, which caused included bibs to be ingo@3661: # missed. ingo@3661: # Chris Monson (2008-03-20): ingo@3661: # * Bumped version to 2.1.13 ingo@3661: # * Changed error output colorization to show errors for missing files ingo@3661: # that are not graphics files. ingo@3661: # Chris Monson (2008-03-20): ingo@3661: # * Bumped version to 2.1.12 ingo@3661: # * Fixed a regression introduced in r28 that makes bibtex fail when ingo@3661: # there is no index file present ingo@3661: # Chris Monson (2008-03-03): ingo@3661: # * Bumped version to 2.1.11 ingo@3661: # * Fixed issue 11 (handle index files, reported by abachn) ingo@3661: # * Cleaned up some comments and help text ingo@3661: # Chris Monson (2008-01-24): ingo@3661: # * Bumped version to 2.1.10 ingo@3661: # * Fixed to work when 'sh' is a POSIX shell like 'dash' ingo@3661: # Chris Monson (2007-12-12): ingo@3661: # * Bumped version to 2.1.9 ingo@3661: # * Fixed documentation and dependency graph for pstex files ingo@3661: # Chris Monson (2007-12-12): ingo@3661: # * Bumped version to 2.1.8 ingo@3661: # * Added basic pstex_t support for fig files (Issue 9 by favonia) ingo@3661: # I still suggest that psfrag be used instead. ingo@3661: # Chris Monson (2007-10-16): ingo@3661: # * Bumped version to 2.1.7 ingo@3661: # * Removed todo item: allow other comment directives for rst conversion ingo@3661: # * Added ability to use global rst style file _rststyle_._include_.tex ingo@3661: # * Added help text to that effect ingo@3661: # Chris Monson (2007-05-20): ingo@3661: # * Bumped version to 2.1.6 ingo@3661: # * Changed default paper size for rst files ingo@3661: # * Added todo item: fix paper size for rst files ingo@3661: # * Added todo item: allow other comment directives for rst conversion ingo@3661: # Chris Monson (2007-04-02): ingo@3661: # * Bumped version to 2.1.5 ingo@3661: # * Addressed Issue 7, incorrect .gpi.d generation in subdirectories ingo@3661: # Chris Monson (2007-03-28): ingo@3661: # * Bumped version to 2.1.4 ingo@3661: # * Fixed syntax error in dot output ingo@3661: # Chris Monson (2007-03-01): ingo@3661: # * Bumped version to 2.1.3 ingo@3661: # * Added reST to the included documentation ingo@3661: # * Fixed graphics and script generation to be settable in the ingo@3661: # environment. ingo@3661: # Chris Monson (2007-02-23): ingo@3661: # * Bumped version to 2.1.2 ingo@3661: # * Added the ability to generate .tex files from .rst files ingo@3661: # Chris Monson (2006-10-17): ingo@3661: # * Bumped version to 2.1.1 ingo@3661: # * Fixed includes from subdirectories (sed-to-sed slash escape problem) ingo@3661: # Chris Monson (2006-10-05): ingo@3661: # * Bumped version to 2.1.0 (pretty serious new feature added) ingo@3661: # * New feature: bib files can now be anywhere on the BIBINPUTS path ingo@3661: # * New programs: kpsewhich (with tetex) and xargs (BSD) ingo@3661: # Chris Monson (2006-09-28): ingo@3661: # * Bumped version to 2.0.9 ingo@3661: # * Added ability to parse more than one bibliography ingo@3661: # Chris Monson (2006-06-01): ingo@3661: # * Bumped version to 2.0.8 ingo@3661: # * Added .vrb to the list of cleaned files ingo@3661: # Chris Monson (2006-04-26): ingo@3661: # * Bumped version to 2.0.7 ingo@3661: # * Fixed so that clean-nographics does not remove .gpi.d files ingo@3661: # * Removed jpg -> eps hack (not working properly -- just pre-convert) ingo@3661: # * Fixed so that postscript grayscale can be done with BSD sed ingo@3661: # Chris Monson (2006-04-25): ingo@3661: # * Bumped version to 2.0.6 ingo@3661: # * Fixed so that changed toc, lot, lof, or out causes a rebuild ingo@3661: # Chris Monson (2006-04-17): ingo@3661: # * Bumped version to 2.0.5 ingo@3661: # * Added jpg -> eps conversion target ingo@3661: # Chris Monson (2006-04-12): ingo@3661: # * Bumped version to 2.0.4 ingo@3661: # * Fixed BSD sed invocation to not use \| as a branch delimiter ingo@3661: # * Added a comment section on what is and is not allowed in BSD sed ingo@3661: # * Made paper size handling more robust while I was at it ingo@3661: # * Fixed postscript RGB grayscale to use a weighted average ingo@3661: # * Fixed postscript HSB grayscale to convert to RGB first ingo@3661: # * Fixed a problem with rebuilding .bbl files ingo@3661: # Chris Monson (2006-04-11): ingo@3661: # * Bumped version to 2.0.3 ingo@3661: # * Fixed some BSD sed problems: can't use \n in substitutions ingo@3661: # Chris Monson (2006-04-10): ingo@3661: # * Bumped version to 2.0.2 ingo@3661: # * Once again removed ability to create .tex files from scripts ingo@3661: # * \includeonly works again ingo@3661: # Chris Monson (2006-04-09): ingo@3661: # * Bumped version to 2.0.1 ingo@3661: # * Fixed grayscale postscript handling to be more robust ingo@3661: # * Added ability to generate ._gray_. files from eps and eps.gz ingo@3661: # * Added ability to clean ._gray_.eps files created from .eps files ingo@3661: # Chris Monson (2006-04-07): ingo@3661: # * Bumped version to 2.0.0 ingo@3661: # * Removed clunky ability to create included .tex files from scripts ingo@3661: # * Added note in the help about included tex scripting not working ingo@3661: # * Fixed the .eps generation to delete %.gpihead.make when finished ingo@3661: # * Abandoned designs to use shell variables to create sed scripts ingo@3661: # * Abandoned __default__.tex.sh idea: it causes recursion with %: . ingo@3661: # * Removed web page to-do. All items are now complete. ingo@3661: # * Added better grayscale conversion for dot figures (direct ps fixup). ingo@3661: # * Include files can now be scripted (at the expense of \includeonly). ingo@3661: # * Updated dependency graph to contain better node names. ingo@3661: # Chris Monson (2006-04-06): ingo@3661: # * Bumped version to 2.0b3 ingo@3661: # * Top level includes now fail if there is no rule to build them ingo@3661: # * A helpful message is printed when they do fail ingo@3661: # * Grayscale has been changed to be ._gray_, other phonies use _ now, too ingo@3661: # * Grayscale handling has been completed ingo@3661: # * Changed _include_stems target to _includes target. ingo@3661: # * Fixed _includes target to be useful by itself. ingo@3661: # * Removed the ability to specify clean and build targets at once ingo@3661: # * Verified that epsfig works fine with current code ingo@3661: # * Fixed included scripts so that they are added to the dep files ingo@3661: # * Fixed so that graphics includes don't happen if they aren't for gpi ingo@3661: # * Fixed dot output to allow grayscale. ingo@3661: # Chris Monson (2006-04-05): ingo@3661: # * Bumped version to 2.0b2 ingo@3661: # * Removed automatic -gray output. It needs fixing in a bad way. ingo@3661: # * Revamped dependency creation completely. ingo@3661: # * Fixed conditional inclusion to actually work (test.nobuild.d, test.d). ingo@3661: # * Fixed clean target to remove log targets ingo@3661: # * Added the 'monochrome' word for gray gpi output ingo@3661: # * Added a _check_gpi_files target that checks for common problems ingo@3661: # * Changed the _version target into the version target (no _) ingo@3661: # * Added better handling of grayscale files. Use the .gray.pdf target. ingo@3661: # * Fixed testing for rebuilds ingo@3661: # Chris Monson (2006-04-04): ingo@3661: # * Bumped version to 2.0b1 ingo@3661: # * Changed colorization of output ingo@3661: # * Made .auxbbl and .auxtex .make files secondary targets ingo@3661: # * Shortened and simplified the final latex invocation loop ingo@3661: # * Added version-specific output ($$i vs. $$$$i) in latex loop ingo@3661: # * Added a build message for the first .dvi run (Building .dvi (0)) ingo@3661: # * Removed some build messages that most people don't care about. ingo@3661: # * Simplified procedure for user-set colors -- simple text specification ingo@3661: # * Fixed diff output to...not output. ingo@3661: # * Fixed rerun bug -- detect not only when preceded with LaTeX Warning ingo@3661: # * Sped up gpi plotting ingo@3661: # * Added error handling and colorized output for gpi failure ingo@3661: # * Documented color changing stuff. ingo@3661: # * Now sort the flattened aux file to avoid false recompilation needs ingo@3661: # * Added clean-nographics target ingo@3661: # * Don't remove self.dvi file if self.aux is missing in the log ingo@3661: # * Clarified some code. Did some very minor adjusting. ingo@3661: # Chris Monson (2006-04-03): ingo@3661: # * Bumped version to 2.0a7 ingo@3661: # * Added .dvi and .ps files as secondary files. ingo@3661: # * Fixed handling of multiple run detection when includeonly is in use. ingo@3661: # * Added code to flatten .aux files. ingo@3661: # * Added more files as .SECONDARY prerequisites to avoid recompilation. ingo@3661: # * Fixed the inputs generation to be much simpler and to use pipes. ingo@3661: # * Added the dependency graph directly into the makefile. ingo@3661: # * Changed flatten-aux to remove \@writefile \relax \newlabel, etc. ingo@3661: # * Undid pipe changes with sed usage (BSD sed doesn't know -f-). ingo@3661: # * Added a _check_programs target that tells you what your system has. ingo@3661: # * Fixed an error in colorization that made unnecessary errors appear ingo@3661: # * Added view targets. ingo@3661: # * Updated help text. ingo@3661: # * Augmented cookies so that .aux can trigger .bbl and .dvi rebuilds ingo@3661: # * Added more informative error handling for dvips and ps2pdf ingo@3661: # Chris Monson (2006-04-02): ingo@3661: # * Bumped version to 2.0a6 ingo@3661: # * Added indirection to .bbl dependencies to avoid rebuilding .bbl files ingo@3661: # * Streamlined the diff invocation to eliminate an existence test ingo@3661: # * Removed special shell quote escape variables ingo@3661: # * Moved includes to a more prominent location ingo@3661: # * Fixed .inputs.make to not contain .aux files ingo@3661: # * Fixed embedding to use a file instead of always grepping. ingo@3661: # * Added *.make.temp to the list of cleanable files ingo@3661: # * Fixed Ruby. It should now be supported properly. ingo@3661: # * Now differentiate between all, default, and buildable files. ingo@3661: # * Fixed to bail out on serious errors. ingo@3661: # * Revised the handling of includable files. Still working on it. ingo@3661: # Chris Monson (2006-03-31): ingo@3661: # * Bumped version to 2.0a5 ingo@3661: # * Fixed a bug with LaTeX error detection (there can be spaces) ingo@3661: # * Added .bbl support, simplifying everything and making it more correct ingo@3661: # * Refactored some tests that muddy the code ingo@3661: # * Did a little cleanup of some shell loops that can safely be make loops ingo@3661: # * Added support for graphviz .dot files ingo@3661: # * Made _all_programs output easier to read ingo@3661: # * Added the ruby support that has long been advertised ingo@3661: # * Font embedding was screwed up for PostScript -- now implicit ingo@3661: # * Changed the generation of -gray.gpi files to a single command ingo@3661: # * Changed any make-generated file that is not included from .d to .make ingo@3661: # Chris Monson (2006-03-30): ingo@3661: # * Bumped version to 2.0a4 ingo@3661: # * Fixed a bug with very long graphics file names ingo@3661: # * Added a todo entry for epsfig support ingo@3661: # * Fixed a bug paper size bug: sometimes more than one entry appears ingo@3661: # * Fixed DVI build echoing to display the number instead of process ID ingo@3661: # * DVI files are now removed on first invocation if ANY file is missing ingo@3661: # * Added a simple grayscale approach: if a file ends with -gray.gpi, it ingo@3661: # is created from the corresponding .gpi file with a special ingo@3661: # comment ##GRAY in its header, which causes coloring to be ingo@3661: # turned off. ingo@3661: # * Fixed a bug in the handling of .tex.sh files. For some reason I had ingo@3661: # neglected to define file stems for scripted output. ingo@3661: # * Removed a trailing ; from the %.graphics dependencies ingo@3661: # * Added dvips embedding (I think it works, anyway) ingo@3661: # Chris Monson (2006-03-29): ingo@3661: # * Bumped version to 2.0a3 ingo@3661: # * Fixed error in make 3.79 with MAKEFILE_LIST usage ingo@3661: # * Added the presumed filename to the _version output ingo@3661: # * Added a vim macro for converting sed scripts to make commands ingo@3661: # * Added gpi dependency support (plotting external files and loading gpi) ingo@3661: # * Allow .gpi files to be ignored if called .include.gpi or .nobuild.gpi ingo@3661: # * Fixed sed invocations where \+ was used. BSD sed uses \{1,\}. ingo@3661: # Chris Monson (2006-03-28): ingo@3661: # * Bumped version to 2.0a2 ingo@3661: # * Added SHELL_DEBUG and VERBOSE options ingo@3661: # * Changed the default shell back to /bin/sh (unset, in other words) ingo@3661: # * Moved .PHONY declarations closer to their targets ingo@3661: # * Moved help text into its own define block to obtain better formatting ingo@3661: # * Removed need for double-entry when adding a new program invocation ingo@3661: # * Moved .SECONDARY declaration closer to its relevant occurrence ingo@3661: # * Commented things more heavily ingo@3661: # * Added help text about setting terminal and output in gnuplot ingo@3661: # * Created more fine-grained clean targets ingo@3661: # * Added a %.graphics target that generates all of %'s graphics ingo@3661: # * Killed backward-compatible graphics generation (e.g., eps.gpi=gpi.eps) ingo@3661: # * For now, we're just GPL 2, not 3. Maybe it will change later ingo@3661: # * Made the version and svninfo into variables ingo@3661: # Chris Monson (2006-03-27): ingo@3661: # * Bumped version to 2.0a1 ingo@3661: # * Huge, sweeping changes -- automatic dependencies ingo@3661: ingo@3661: # IMPORTANT! ingo@3661: # ingo@3661: # When adding to the following list, do not introduce any blank lines. The ingo@3661: # list is extracted for documentation using sed and is terminated by a blank ingo@3661: # line. ingo@3661: # ingo@3661: # EXTERNAL PROGRAMS: ingo@3661: # = ESSENTIAL PROGRAMS = ingo@3661: # == Basic Shell Utilities == ingo@3661: CAT ?= cat ingo@3661: CP ?= cp -f ingo@3661: DIFF ?= diff ingo@3661: ECHO ?= echo ingo@3661: EGREP ?= egrep ingo@3661: ENV ?= env ingo@3661: EXPR ?= expr ingo@3661: MV ?= mv -f ingo@3661: SED ?= sed ingo@3661: SORT ?= sort ingo@3661: TOUCH ?= touch ingo@3661: UNIQ ?= uniq ingo@3661: WHICH ?= which ingo@3661: XARGS ?= xargs ingo@3661: SLEEP ?= sleep ingo@3661: # == LaTeX (tetex-provided) == ingo@3661: BIBTEX ?= bibtex ingo@3661: DVIPS ?= dvips ingo@3661: LATEX ?= latex ingo@3661: PDFLATEX ?= pdflatex ingo@3661: EPSTOPDF ?= epstopdf ingo@3661: MAKEINDEX ?= makeindex ingo@3661: KPSEWHICH ?= kpsewhich ingo@3661: GS ?= gs ingo@3661: # = OPTIONAL PROGRAMS = ingo@3661: # == Makefile Color Output == ingo@3661: TPUT ?= tput ingo@3661: # == TeX Generation == ingo@3661: PERL ?= perl ingo@3661: PYTHON ?= python ingo@3661: RST2LATEX ?= rst2latex.py ingo@3661: # == EPS Generation == ingo@3661: CONVERT ?= convert # ImageMagick ingo@3661: DOT ?= dot # GraphViz ingo@3661: DOT2TEX ?= dot2tex # dot2tex - add options (not -o) as needed ingo@3661: FIG2DEV ?= fig2dev # XFig ingo@3661: GNUPLOT ?= gnuplot # GNUplot ingo@3661: INKSCAPE ?= inkscape # Inkscape (svg support) ingo@3661: XMGRACE ?= xmgrace # XMgrace ingo@3661: PNGTOPNM ?= pngtopnm # From NetPBM - step 1 for png -> eps ingo@3661: PPMTOPGM ?= ppmtopgm # From NetPBM - (gray) step 2 for png -> eps ingo@3661: PNMTOPS ?= pnmtops # From NetPBM - step 3 for png -> eps ingo@3661: GUNZIP ?= gunzip # GZipped EPS ingo@3661: # == Beamer Enlarged Output == ingo@3661: PSNUP ?= psnup ingo@3661: # == Viewing Stuff == ingo@3661: VIEW_POSTSCRIPT ?= gv ingo@3661: VIEW_PDF ?= xpdf ingo@3661: VIEW_GRAPHICS ?= display ingo@3661: ingo@3661: # Command options for embedding fonts and postscript->pdf conversion ingo@3661: PS_EMBED_OPTIONS ?= -dPDFSETTINGS=/printer -dEmbedAllFonts=true -dSubsetFonts=true -dMaxSubsetPct=100 ingo@3661: PS_COMPATIBILITY ?= 1.4 ingo@3661: ingo@3661: # Defaults for GPI ingo@3661: DEFAULT_GPI_EPS_FONTSIZE ?= 22 ingo@3661: DEFAULT_GPI_PDF_FONTSIZE ?= 12 ingo@3661: ingo@3661: # Style file for ReST ingo@3661: RST_STYLE_FILE ?= $(wildcard _rststyle_._include_.tex) ingo@3661: ingo@3661: # This ensures that even when echo is a shell builtin, we still use the binary ingo@3661: # (the builtin doesn't always understand -n) ingo@3661: FIXED_ECHO := $(if $(findstring -n,$(shell $(ECHO) -n)),$(shell which echo),$(ECHO)) ingo@3661: ECHO := $(if $(FIXED_ECHO),$(FIXED_ECHO),$(ECHO)) ingo@3661: ingo@3661: define determine-gnuplot-output-extension ingo@3661: $(if $(shell $(WHICH) $(GNUPLOT)), ingo@3661: $(if $(findstring unknown or ambiguous, $(shell $(GNUPLOT) -e "set terminal pdf" 2>&1)), ingo@3661: eps, pdf), ingo@3661: none) ingo@3661: endef ingo@3661: ingo@3661: GNUPLOT_OUTPUT_EXTENSION ?= $(strip $(call determine-gnuplot-output-extension)) ingo@3661: ingo@3661: # Directory into which we place "binaries" if it exists. ingo@3661: # Note that this can be changed on the commandline or in Makefile.ini: ingo@3661: # ingo@3661: # Command line: ingo@3661: # make BINARY_TARGET_DIR=$HOME/pdfs myfile.pdf ingo@3661: # ingo@3661: # Also, you can specify a relative directory (relative to the Makefile): ingo@3661: # make BINARY_TARGET_DIR=pdfs myfile.pdf ingo@3661: # ingo@3661: # Or, you can use Makefile.ini: ingo@3661: # ingo@3661: # BINARY_TARGET_DIR := $(HOME)/bin_out ingo@3661: # ingo@3661: BINARY_TARGET_DIR ?= _out_ ingo@3661: ingo@3661: RESTARTS := $(if $(MAKE_RESTARTS),$(MAKE_RESTARTS),0) ingo@3661: # SH NOTES ingo@3661: # ingo@3661: # On some systems, /bin/sh, which is the default shell, is not linked to ingo@3661: # /bin/bash. While bash is supposed to be sh-compatible when invoked as sh, it ingo@3661: # just isn't. This section details some of the things you have to stay away ingo@3661: # from to remain sh-compatible. ingo@3661: # ingo@3661: # * File pattern expansion does not work for {} ingo@3661: # * [ "$x" = "$y" ] has to be [ x"$x" x"$y" ] ingo@3661: # * &> for stderr redirection doesn't work, use 2>&1 instead ingo@3661: # ingo@3661: # BSD SED NOTES ingo@3661: # ingo@3661: # BSD SED is not very nice compared to GNU sed, but it is the most ingo@3661: # commonly-invoked sed on Macs (being based on BSD), so we have to cater to ingo@3661: # it or require people to install GNU sed. It seems like the GNU ingo@3661: # requirement isn't too bad since this makefile is really a GNU makefile, ingo@3661: # but apparently GNU sed is much less common than GNU make in general, so ingo@3661: # I'm supporting it here. ingo@3661: # ingo@3661: # Sad experience has taught me the following about BSD sed: ingo@3661: # ingo@3661: # * \+ is not understood to mean \{1,\} ingo@3661: # * \| is meaningless (does not branch) ingo@3661: # * \n cannot be used as a substitution character ingo@3661: # * ? does not mean \{0,1\}, but is literal ingo@3661: # * a\ works, but only reliably for a single line if subsequent lines ingo@3661: # have forward slashes in them (as is the case in postscript) ingo@3661: # ingo@3661: # For more info (on the Mac) you can consult ingo@3661: # ingo@3661: # man -M /usr/share/man re_format ingo@3661: # ingo@3661: # And look for the word "Obsolete" near the bottom. ingo@3661: ingo@3661: # ingo@3661: # EXTERNAL PROGRAM DOCUMENTATION SCRIPT ingo@3661: # ingo@3661: ingo@3661: # $(call output-all-programs,[<output file>]) ingo@3661: define output-all-programs ingo@3661: [ -f '$(this_file)' ] && \ ingo@3661: $(SED) \ ingo@3661: -e '/^[[:space:]]*#[[:space:]]*EXTERNAL PROGRAMS:/,/^$$/!d' \ ingo@3661: -e '/EXTERNAL PROGRAMS/d' \ ingo@3661: -e '/^$$/d' \ ingo@3661: -e '/^[[:space:]]*#/i\ '\ ingo@3661: -e 's/^[[:space:]]*#[[:space:]][^=]*//' \ ingo@3661: $(this_file) $(if $1,> '$1',) || \ ingo@3661: $(ECHO) "Cannot determine the name of this makefile." ingo@3661: endef ingo@3661: ingo@3661: # If they misspell gray, it should still work. ingo@3661: GRAY ?= $(call get-default,$(GREY),) ingo@3661: ingo@3661: # ingo@3661: # Utility Functions and Definitions ingo@3661: # ingo@3661: ingo@3661: # While not exactly a make function, this vim macro is useful. It takes a ingo@3661: # verbatim sed script and converts each line to something suitable in a command ingo@3661: # context. Just paste the script's contents into the editor, yank this into a ingo@3661: # register (starting at '0') and run the macro once for each line of the ingo@3661: # original script: ingo@3661: # ingo@3661: # 0i -e :s/\$/$$/eg ingo@3661: :s/'/'"'"'/eg ingo@3661: ^Ela'A' \:noh ingo@3661: j ingo@3661: ingo@3661: # don't call this directly - it is here to avoid calling wildcard more than ingo@3661: # once in remove-files. ingo@3661: remove-files-helper = $(if $1,$(RM) $1,$(sh_true)) ingo@3661: ingo@3661: # $(call remove-files,file1 file2) ingo@3661: remove-files = $(call remove-files-helper,$(wildcard $1)) ingo@3661: ingo@3661: # Removes all cleanable files in the given list ingo@3661: # $(call clean-files,file1 file2 file3 ...) ingo@3661: # Works exactly like remove-files, but filters out files in $(neverclean) ingo@3661: clean-files = \ ingo@3661: $(call remove-files-helper,$(call cleanable-files,$(wildcard $1))) ingo@3661: ingo@3661: # Outputs all generated files to STDOUT, along with some others that are ingo@3661: # created by these (e.g., .idx files end up producing .ilg and .ind files). ingo@3661: # Discovered by reading *.fls OUTPUT lines and producing corresponding .ind ingo@3661: # filenames as needed. ingo@3661: # ingo@3661: # $(call get-generated-names,<source recorder file (*.fls)>) ingo@3661: define get-generated-names ingo@3661: [ -f '$1' ] && \ ingo@3661: $(SED) \ ingo@3661: -e '/^OUTPUT /{' \ ingo@3661: -e ' s///' \ ingo@3661: -e ' p' \ ingo@3661: -e ' s/\.idx/\.ind/p' \ ingo@3661: -e ' s/\.ind/\.ilg/p' \ ingo@3661: -e '}' \ ingo@3661: -e 'd' \ ingo@3661: '$1' \ ingo@3661: | $(SORT) | $(UNIQ) ingo@3661: endef ingo@3661: ingo@3661: # This removes files without checking whether they are there or not. This ingo@3661: # sometimes has to be used when the file is created by a series of shell ingo@3661: # commands, but there ends up being a race condition: make doesn't know about ingo@3661: # the file generation as quickly as the system does, so $(wildcard ...) doesn't ingo@3661: # work right. Blech. ingo@3661: # $(call remove-temporary-files,filenames) ingo@3661: remove-temporary-files = $(if $1,$(RM) $1,:) ingo@3661: ingo@3661: # Create an identifier from a file name ingo@3661: # $(call cleanse-filename,filename) ingo@3661: cleanse-filename = $(subst .,_,$(subst /,__,$1)) ingo@3661: ingo@3661: # Escape dots ingo@3661: # $(call escape-dots,str) ingo@3661: escape-dots = $(subst .,\\.,$1) ingo@3661: ingo@3661: # Test that a file exists ingo@3661: # $(call test-exists,file) ingo@3661: test-exists = [ -e '$1' ] ingo@3661: ingo@3661: # $(call move-files,source,destination) ingo@3661: move-if-exists = $(call test-exists,$1) && $(MV) '$1' '$2' ingo@3661: ingo@3661: # Copy file1 to file2 only if file2 doesn't exist or they are different ingo@3661: # $(call copy-if-different,sfile,dfile) ingo@3661: copy-if-different = $(call test-different,$1,$2) && $(CP) '$1' '$2' ingo@3661: copy-if-exists = $(call test-exists,$1) && $(CP) '$1' '$2' ingo@3661: move-if-different = $(call test-different,$1,$2) && $(MV) '$1' '$2' ingo@3661: replace-if-different-and-remove = \ ingo@3661: $(call test-different,$1,$2) \ ingo@3661: && $(MV) '$1' '$2' \ ingo@3661: || $(call remove-files,'$1') ingo@3661: ingo@3661: # Note that $(DIFF) returns success when the files are the SAME.... ingo@3661: # $(call test-different,sfile,dfile) ingo@3661: test-different = ! $(DIFF) -q '$1' '$2' >/dev/null 2>&1 ingo@3661: test-exists-and-different = \ ingo@3661: $(call test-exists,$2) && $(call test-different,$1,$2) ingo@3661: ingo@3661: # Return value 1, or value 2 if value 1 is empty ingo@3661: # $(call get-default,<possibly empty arg>,<default value if empty>) ingo@3661: get-default = $(if $1,$1,$2) ingo@3661: ingo@3661: # Copy a file and log what's going on ingo@3661: # $(call copy-with-logging,<source>,<target>) ingo@3661: define copy-with-logging ingo@3661: if [ -d '$2/' ]; then \ ingo@3661: if $(CP) '$1' '$2/'; then \ ingo@3661: $(ECHO) "$(C_INFO)Copied '$1' to '$2/'$(C_RESET)"; \ ingo@3661: else \ ingo@3661: $(ECHO) "$(C_ERROR)Failed to copy '$1' to '$2/'$(C_RESET)"; \ ingo@3661: fi; \ ingo@3661: fi ingo@3661: endef ingo@3661: ingo@3661: # Gives a reassuring message about the failure to find include files ingo@3661: # $(call include-message,<list of include files>) ingo@3661: define include-message ingo@3661: $(strip \ ingo@3661: $(if $(filter-out $(wildcard $1),$1),\ ingo@3661: $(shell $(ECHO) \ ingo@3661: "$(C_INFO)NOTE: You may ignore warnings about the"\ ingo@3661: "following files:" >&2;\ ingo@3661: $(ECHO) >&2; \ ingo@3661: $(foreach s,$(filter-out $(wildcard $1),$1),$(ECHO) ' $s' >&2;)\ ingo@3661: $(ECHO) "$(C_RESET)" >&2) ingo@3661: )) ingo@3661: endef ingo@3661: # Characters that are hard to specify in certain places ingo@3661: space := $(empty) $(empty) ingo@3661: colon := \: ingo@3661: comma := , ingo@3661: ingo@3661: # Useful shell definitions ingo@3661: sh_true := : ingo@3661: sh_false := ! : ingo@3661: ingo@3661: # Clear out the standard interfering make suffixes ingo@3661: .SUFFIXES: ingo@3661: ingo@3661: # Turn off forceful rm (RM is usually mapped to rm -f) ingo@3661: ifdef SAFE_RM ingo@3661: RM := rm ingo@3661: endif ingo@3661: ingo@3661: # Turn command echoing back on with VERBOSE=1 ingo@3661: ifndef VERBOSE ingo@3661: QUIET := @ ingo@3661: endif ingo@3661: ingo@3661: # Turn on shell debugging with SHELL_DEBUG=1 ingo@3661: # (EVERYTHING is echoed, even $(shell ...) invocations) ingo@3661: ifdef SHELL_DEBUG ingo@3661: SHELL += -x ingo@3661: endif ingo@3661: ingo@3661: # Get the name of this makefile (always right in 3.80, often right in 3.79) ingo@3661: # This is only really used for documentation, so it isn't too serious. ingo@3661: ifdef MAKEFILE_LIST ingo@3661: this_file := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) ingo@3661: else ingo@3661: this_file := $(wildcard GNUmakefile makefile Makefile) ingo@3661: endif ingo@3661: ingo@3661: # Terminal color definitions ingo@3661: ingo@3661: REAL_TPUT := $(if $(NO_COLOR),,$(shell $(WHICH) $(TPUT))) ingo@3661: ingo@3661: # $(call get-term-code,codeinfo) ingo@3661: # e.g., ingo@3661: # $(call get-term-code,setaf 0) ingo@3661: get-term-code = $(if $(REAL_TPUT),$(shell $(REAL_TPUT) $1),) ingo@3661: ingo@3661: black := $(call get-term-code,setaf 0) ingo@3661: red := $(call get-term-code,setaf 1) ingo@3661: green := $(call get-term-code,setaf 2) ingo@3661: yellow := $(call get-term-code,setaf 3) ingo@3661: blue := $(call get-term-code,setaf 4) ingo@3661: magenta := $(call get-term-code,setaf 5) ingo@3661: cyan := $(call get-term-code,setaf 6) ingo@3661: white := $(call get-term-code,setaf 7) ingo@3661: bold := $(call get-term-code,bold) ingo@3661: uline := $(call get-term-code,smul) ingo@3661: reset := $(call get-term-code,sgr0) ingo@3661: ingo@3661: # ingo@3661: # User-settable definitions ingo@3661: # ingo@3661: LATEX_COLOR_WARNING ?= magenta ingo@3661: LATEX_COLOR_ERROR ?= red ingo@3661: LATEX_COLOR_INFO ?= green ingo@3661: LATEX_COLOR_UNDERFULL ?= magenta ingo@3661: LATEX_COLOR_OVERFULL ?= red bold ingo@3661: LATEX_COLOR_PAGES ?= bold ingo@3661: LATEX_COLOR_BUILD ?= cyan ingo@3661: LATEX_COLOR_GRAPHIC ?= yellow ingo@3661: LATEX_COLOR_DEP ?= green ingo@3661: LATEX_COLOR_SUCCESS ?= green bold ingo@3661: LATEX_COLOR_FAILURE ?= red bold ingo@3661: ingo@3661: # Gets the real color from a simple textual definition like those above ingo@3661: # $(call get-color,ALL_CAPS_COLOR_NAME) ingo@3661: # e.g., $(call get-color,WARNING) ingo@3661: get-color = $(subst $(space),,$(foreach c,$(LATEX_COLOR_$1),$($c))) ingo@3661: ingo@3661: # ingo@3661: # STANDARD COLORS ingo@3661: # ingo@3661: C_WARNING := $(call get-color,WARNING) ingo@3661: C_ERROR := $(call get-color,ERROR) ingo@3661: C_INFO := $(call get-color,INFO) ingo@3661: C_UNDERFULL := $(call get-color,UNDERFULL) ingo@3661: C_OVERFULL := $(call get-color,OVERFULL) ingo@3661: C_PAGES := $(call get-color,PAGES) ingo@3661: C_BUILD := $(call get-color,BUILD) ingo@3661: C_GRAPHIC := $(call get-color,GRAPHIC) ingo@3661: C_DEP := $(call get-color,DEP) ingo@3661: C_SUCCESS := $(call get-color,SUCCESS) ingo@3661: C_FAILURE := $(call get-color,FAILURE) ingo@3661: C_RESET := $(reset) ingo@3661: ingo@3661: # ingo@3661: # PRE-BUILD TESTS ingo@3661: # ingo@3661: ingo@3661: # Check that clean targets are not combined with other targets (weird things ingo@3661: # happen, and it's not easy to fix them) ingo@3661: hascleangoals := $(if $(sort $(filter clean clean-%,$(MAKECMDGOALS))),1) ingo@3661: hasbuildgoals := $(if $(sort $(filter-out clean clean-%,$(MAKECMDGOALS))),1) ingo@3661: ifneq "$(hasbuildgoals)" "" ingo@3661: ifneq "$(hascleangoals)" "" ingo@3661: $(error $(C_ERROR)Clean and build targets specified together$(C_RESET))) ingo@3661: endif ingo@3661: endif ingo@3661: ingo@3661: # ingo@3661: # VARIABLE DECLARATIONS ingo@3661: # ingo@3661: ingo@3661: # Names of sed scripts that morph gnuplot files -- only the first found is used ingo@3661: GNUPLOT_SED := global-gpi.sed gnuplot.sed ingo@3661: GNUPLOT_GLOBAL := global._include_.gpi gnuplot.global ingo@3661: ingo@3661: ifneq "$(strip $(BUILD_STRATEGY))" "pdflatex" ingo@3661: default_graphic_extension ?= eps ingo@3661: latex_build_program ?= $(LATEX) ingo@3661: build_target_extension ?= dvi ingo@3661: hyperref_driver_pattern ?= hdvips ingo@3661: hyperref_driver_error ?= Using dvips: specify ps2pdf in the hyperref options. ingo@3661: else ingo@3661: default_graphic_extension ?= pdf ingo@3661: latex_build_program ?= $(PDFLATEX) ingo@3661: build_target_extension ?= pdf ingo@3661: hyperref_driver_pattern ?= hpdf.* ingo@3661: hyperref_driver_error ?= Using pdflatex: specify pdftex in the hyperref options (or leave it blank). ingo@3661: endif ingo@3661: ingo@3661: # Files of interest ingo@3661: all_files.tex ?= $(wildcard *.tex) ingo@3661: all_files.tex.sh ?= $(wildcard *.tex.sh) ingo@3661: all_files.tex.pl ?= $(wildcard *.tex.pl) ingo@3661: all_files.tex.py ?= $(wildcard *.tex.py) ingo@3661: all_files.rst ?= $(wildcard *.rst) ingo@3661: all_files.fig ?= $(wildcard *.fig) ingo@3661: all_files.gpi ?= $(wildcard *.gpi) ingo@3661: all_files.dot ?= $(wildcard *.dot) ingo@3661: all_files.xvg ?= $(wildcard *.xvg) ingo@3661: all_files.svg ?= $(wildcard *.svg) ingo@3661: all_files.png ?= $(wildcard *.png) ingo@3661: all_files.jpg ?= $(wildcard *.jpg) ingo@3661: all_files.eps.gz ?= $(wildcard *.eps.gz) ingo@3661: all_files.eps ?= $(wildcard *.eps) ingo@3661: ingo@3661: # Utility function for obtaining all files not specified in $(neverclean) ingo@3661: # $(call cleanable-files,file1 file2 file3 ...) ingo@3661: # Returns the list of files that is not in $(wildcard $(neverclean)) ingo@3661: cleanable-files = $(filter-out $(wildcard $(neverclean)), $1) ingo@3661: ingo@3661: # Utility function for getting all .$1 files that are to be ignored ingo@3661: # * files listed in $(includes.$1) ingo@3661: # * files not listed in $(onlysources.$1) if it is defined ingo@3661: ignore_files = \ ingo@3661: $(includes.$1) \ ingo@3661: $(if $(onlysources.$1),$(filter-out $(onlysources.$1), $(all_files.$1))) ingo@3661: ingo@3661: # Patterns to never be allowed as source targets ingo@3661: ignore_patterns := %._include_ ingo@3661: ingo@3661: # Patterns allowed as source targets but not included in 'all' builds ingo@3661: nodefault_patterns := %._nobuild_ $(ignore_patterns) ingo@3661: ingo@3661: # Utility function for getting targets suitable building ingo@3661: # $(call filter-buildable,suffix) ingo@3661: filter-buildable = \ ingo@3661: $(filter-out $(call ignore_files,$1) \ ingo@3661: $(addsuffix .$1,$(ignore_patterns)),$(all_files.$1)) ingo@3661: ingo@3661: # Utility function for getting targets suitable for 'all' builds ingo@3661: # $(call filter-default,suffix) ingo@3661: filter-default = \ ingo@3661: $(filter-out $(call ignore_files,$1) \ ingo@3661: $(addsuffix .$1,$(nodefault_patterns)),$(all_files.$1)) ingo@3661: ingo@3661: # Top level sources that can be built even when they are not by default ingo@3661: files.tex := $(call filter-buildable,tex) ingo@3661: files.tex.sh := $(call filter-buildable,tex.sh) ingo@3661: files.tex.pl := $(call filter-buildable,tex.pl) ingo@3661: files.tex.py := $(call filter-buildable,tex.py) ingo@3661: files.rst := $(call filter-buildable,rst) ingo@3661: files.gpi := $(call filter-buildable,gpi) ingo@3661: files.dot := $(call filter-buildable,dot) ingo@3661: files.fig := $(call filter-buildable,fig) ingo@3661: files.xvg := $(call filter-buildable,xvg) ingo@3661: files.svg := $(call filter-buildable,svg) ingo@3661: files.png := $(call filter-buildable,png) ingo@3661: files.jpg := $(call filter-buildable,jpg) ingo@3661: files.eps.gz := $(call filter-buildable,eps.gz) ingo@3661: ingo@3661: # Make all pstex targets secondary. The pstex_t target requires the pstex ingo@3661: # target, and nothing else really depends on it, so it often gets deleted. ingo@3661: # This avoids that by allowing *all* fig files to be pstex targets, which is ingo@3661: # perfectly valid and causes no problems even if they're going to become eps ingo@3661: # files in the end. ingo@3661: .SECONDARY: $(patsubst %.fig,%.pstex,$(files.fig)) ingo@3661: ingo@3661: # Top level sources that are built by default targets ingo@3661: default_files.tex := $(call filter-default,tex) ingo@3661: default_files.tex.sh := $(call filter-default,tex.sh) ingo@3661: default_files.tex.pl := $(call filter-default,tex.pl) ingo@3661: default_files.tex.py := $(call filter-default,tex.py) ingo@3661: default_files.rst := $(call filter-default,rst) ingo@3661: default_files.gpi := $(call filter-default,gpi) ingo@3661: default_files.dot := $(call filter-default,dot) ingo@3661: default_files.fig := $(call filter-default,fig) ingo@3661: default_files.xvg := $(call filter-default,xvg) ingo@3661: default_files.svg := $(call filter-default,svg) ingo@3661: default_files.png := $(call filter-default,png) ingo@3661: default_files.jpg := $(call filter-default,jpg) ingo@3661: default_files.eps.gz := $(call filter-default,eps.gz) ingo@3661: ingo@3661: # Utility function for creating larger lists of files ingo@3661: # $(call concat-files,suffixes,[prefix]) ingo@3661: concat-files = $(foreach s,$1,$($(if $2,$2_,)files.$s)) ingo@3661: ingo@3661: # Useful file groupings ingo@3661: all_files_source := $(call concat-files,tex,all) ingo@3661: all_files_scripts := $(call concat-files,tex.sh tex.pl tex.py rst,all) ingo@3661: ingo@3661: .PHONY: $(all_files_scripts) ingo@3661: ingo@3661: default_files_source := $(call concat-files,tex,default) ingo@3661: default_files_scripts := $(call concat-files,tex.sh tex.pl tex.py rst,default) ingo@3661: ingo@3661: files_source := $(call concat-files,tex) ingo@3661: files_scripts := $(call concat-files,tex.sh tex.pl tex.py rst) ingo@3661: ingo@3661: # Utility function for obtaining stems ingo@3661: # $(call get-stems,suffix,[prefix]) ingo@3661: get-stems = $(sort $($(if $2,$2_,)files.$1:%.$1=%)) ingo@3661: ingo@3661: # List of all stems (including ._include_ and ._nobuild_ file stems) ingo@3661: all_stems.tex := $(call get-stems,tex,all) ingo@3661: all_stems.tex.sh := $(call get-stems,tex.sh,all) ingo@3661: all_stems.tex.pl := $(call get-stems,tex.pl,all) ingo@3661: all_stems.tex.py := $(call get-stems,tex.py,all) ingo@3661: all_stems.rst := $(call get-stems,rst,all) ingo@3661: all_stems.fig := $(call get-stems,fig,all) ingo@3661: all_stems.gpi := $(call get-stems,gpi,all) ingo@3661: all_stems.dot := $(call get-stems,dot,all) ingo@3661: all_stems.xvg := $(call get-stems,xvg,all) ingo@3661: all_stems.svg := $(call get-stems,svg,all) ingo@3661: all_stems.png := $(call get-stems,png,all) ingo@3661: all_stems.jpg := $(call get-stems,jpg,all) ingo@3661: all_stems.eps.gz := $(call get-stems,eps.gz,all) ingo@3661: all_stems.eps := $(call get-stems,eps,all) ingo@3661: ingo@3661: # List of all default stems (all default PDF targets): ingo@3661: default_stems.tex := $(call get-stems,tex,default) ingo@3661: default_stems.tex.sh := $(call get-stems,tex.sh,default) ingo@3661: default_stems.tex.pl := $(call get-stems,tex.pl,default) ingo@3661: default_stems.tex.py := $(call get-stems,tex.py,default) ingo@3661: default_stems.rst := $(call get-stems,rst,default) ingo@3661: default_stems.fig := $(call get-stems,fig,default) ingo@3661: default_stems.gpi := $(call get-stems,gpi,default) ingo@3661: default_stems.dot := $(call get-stems,dot,default) ingo@3661: default_stems.xvg := $(call get-stems,xvg,default) ingo@3661: default_stems.svg := $(call get-stems,svg,default) ingo@3661: default_stems.png := $(call get-stems,png,default) ingo@3661: default_stems.jpg := $(call get-stems,jpg,default) ingo@3661: default_stems.eps.gz := $(call get-stems,eps.gz,default) ingo@3661: ingo@3661: # List of all stems (all possible bare PDF targets created here): ingo@3661: stems.tex := $(call get-stems,tex) ingo@3661: stems.tex.sh := $(call get-stems,tex.sh) ingo@3661: stems.tex.pl := $(call get-stems,tex.pl) ingo@3661: stems.tex.py := $(call get-stems,tex.py) ingo@3661: stems.rst := $(call get-stems,rst) ingo@3661: stems.fig := $(call get-stems,fig) ingo@3661: stems.gpi := $(call get-stems,gpi) ingo@3661: stems.dot := $(call get-stems,dot) ingo@3661: stems.xvg := $(call get-stems,xvg) ingo@3661: stems.svg := $(call get-stems,svg) ingo@3661: stems.png := $(call get-stems,png) ingo@3661: stems.jpg := $(call get-stems,jpg) ingo@3661: stems.eps.gz := $(call get-stems,eps.gz) ingo@3661: ingo@3661: # Utility function for creating larger lists of stems ingo@3661: # $(call concat-stems,suffixes,[prefix]) ingo@3661: concat-stems = $(sort $(foreach s,$1,$($(if $2,$2_,)stems.$s))) ingo@3661: ingo@3661: # The most likely to be source but not finished product go first ingo@3661: graphic_source_extensions := fig \ ingo@3661: gpi \ ingo@3661: xvg \ ingo@3661: svg \ ingo@3661: dot \ ingo@3661: eps.gz ingo@3661: ingo@3661: ifneq "$(strip $(BUILD_STRATEGY))" "pdflatex" ingo@3661: graphic_source_extensions += png jpg ingo@3661: graphic_target_extensions := eps ps ingo@3661: else ingo@3661: graphic_source_extensions += eps ingo@3661: graphic_target_extensions := pdf png jpg mps tif ingo@3661: endif ingo@3661: ingo@3661: all_stems_source := $(call concat-stems,tex,all) ingo@3661: all_stems_script := $(call concat-stems,tex.sh tex.pl tex.py rst,all) ingo@3661: all_stems_graphic := $(call concat-stems,$(graphic_source_extensions),all) ingo@3661: all_stems_ss := $(sort $(all_stems_source) $(all_stems_script)) ingo@3661: all_stems_sg := $(sort $(all_stems_script)) ingo@3661: all_stems_ssg := $(sort $(all_stems_ss)) ingo@3661: ingo@3661: default_stems_source := $(call concat-stems,tex,default) ingo@3661: default_stems_script := $(call concat-stems,tex.sh tex.pl tex.py rst,default) ingo@3661: default_stems_ss := $(sort $(default_stems_source) $(default_stems_script)) ingo@3661: default_stems_sg := $(sort $(default_stems_script)) ingo@3661: default_stems_ssg := $(sort $(default_stems_ss)) ingo@3661: ingo@3661: stems_source := $(call concat-stems,tex) ingo@3661: stems_script := $(call concat-stems,tex.sh tex.pl tex.py rst) ingo@3661: stems_graphic := $(call concat-stems,$(graphic_source_extensions)) ingo@3661: stems_gg := $(sort $(stems_graphic)) ingo@3661: stems_ss := $(sort $(stems_source) $(stems_script)) ingo@3661: stems_sg := $(sort $(stems_script)) ingo@3661: stems_ssg := $(sort $(stems_ss)) ingo@3661: ingo@3661: # Calculate names that can generate the need for an include file. We can't ingo@3661: # really do this with patterns because it's too easy to screw up, so we create ingo@3661: # an exhaustive list. ingo@3661: allowed_source_suffixes := \ ingo@3661: pdf \ ingo@3661: ps \ ingo@3661: dvi \ ingo@3661: ind \ ingo@3661: nls \ ingo@3661: bbl \ ingo@3661: aux \ ingo@3661: aux.make \ ingo@3661: d \ ingo@3661: auxbbl.make \ ingo@3661: _graphics \ ingo@3661: _show ingo@3661: allowed_source_patterns := $(addprefix %.,$(allowed_source_suffixes)) ingo@3661: ingo@3661: allowed_graphic_suffixes := \ ingo@3661: pdf \ ingo@3661: eps \ ingo@3661: gpihead.make \ ingo@3661: gpi.d ingo@3661: allowed_graphic_patterns := $(addprefix %.,$(allowed_graphic_suffixes)) ingo@3661: ingo@3661: # All targets allowed to build documents ingo@3661: allowed_source_targets := \ ingo@3661: $(foreach suff,$(allowed_source_suffixes),\ ingo@3661: $(addsuffix .$(suff),$(stems_ssg))) ingo@3661: ingo@3661: # All targets allowed to build graphics ingo@3661: allowed_graphic_targets := \ ingo@3661: $(foreach suff,$(allowed_graphic_suffixes),\ ingo@3661: $(addsuffix .$(suff),$(stems_gg))) ingo@3661: ingo@3661: # All targets that build multiple documents (like 'all') ingo@3661: allowed_batch_source_targets := \ ingo@3661: all \ ingo@3661: all-pdf \ ingo@3661: all-ps \ ingo@3661: all-dvi \ ingo@3661: all-bbl \ ingo@3661: all-ind \ ingo@3661: all-gls \ ingo@3661: all-nls \ ingo@3661: show ingo@3661: ingo@3661: # All targets that build multiple graphics (independent of document) ingo@3661: allowed_batch_graphic_targets := \ ingo@3661: all-graphics \ ingo@3661: all-pstex \ ingo@3661: all-dot2tex \ ingo@3661: show-graphics ingo@3661: ingo@3661: # Now we figure out which stuff is available as a make target for THIS RUN. ingo@3661: real_goals := $(call get-default,$(filter-out _includes,$(MAKECMDGOALS)),\ ingo@3661: all) ingo@3661: ingo@3661: specified_source_targets := $(strip \ ingo@3661: $(filter $(allowed_source_targets) $(stems_ssg),$(real_goals)) \ ingo@3661: ) ingo@3661: ingo@3661: specified_batch_source_targets := $(strip \ ingo@3661: $(filter $(allowed_batch_source_targets),$(real_goals)) \ ingo@3661: ) ingo@3661: ingo@3661: specified_graphic_targets := $(strip \ ingo@3661: $(filter $(allowed_graphic_targets),$(real_goals)) \ ingo@3661: ) ingo@3661: ingo@3661: specified_batch_graphic_targets := $(strip \ ingo@3661: $(filter $(allowed_batch_graphic_targets),$(real_goals)) \ ingo@3661: ) ingo@3661: ingo@3661: specified_gpi_targets := $(patsubst %.gpi,%.$(default_graphic_extension),\ ingo@3661: $(filter $(patsubst %.$(default_graphic_extension),%.gpi,$(specified_graphic_targets)),\ ingo@3661: $(all_files.gpi)) \ ingo@3661: ) ingo@3661: ingo@3661: # Determine which .d files need including from the information gained above. ingo@3661: # This is done by first checking whether a batch target exists. If it does, ingo@3661: # then all *default* stems are used to create possible includes (nobuild need ingo@3661: # not apply for batch status). If no batch targets exist, then the individual ingo@3661: # targets are considered and appropriate includes are taken from them. ingo@3661: source_stems_to_include := \ ingo@3661: $(sort\ ingo@3661: $(if $(specified_batch_source_targets),\ ingo@3661: $(default_stems_ss),\ ingo@3661: $(foreach t,$(specified_source_targets),\ ingo@3661: $(foreach p,$(allowed_source_patterns),\ ingo@3661: $(patsubst $p,%,$(filter $p $(stems_ssg),$t)) \ ingo@3661: )) \ ingo@3661: )) ingo@3661: ingo@3661: # Determine which .gpi.d files are needed using the above information. We ingo@3661: # first check whether a batch target is specified, then check individual ingo@3661: # graphics that may have been specified. ingo@3661: graphic_stems_to_include := \ ingo@3661: $(sort\ ingo@3661: $(if $(specified_batch_graphic_targets),\ ingo@3661: $(default_stems.gpi),\ ingo@3661: $(foreach t,$(specified_gpi_targets),\ ingo@3661: $(foreach p,$(allowed_graphic_patterns),\ ingo@3661: $(patsubst $p,%,$(filter $p,$t)) \ ingo@3661: )) \ ingo@3661: )) ingo@3661: ingo@3661: # All dependencies for the 'all' targets ingo@3661: all_pdf_targets := $(addsuffix .pdf,$(stems_ssg)) ingo@3661: all_ps_targets := $(addsuffix .ps,$(stems_ssg)) ingo@3661: all_dvi_targets := $(addsuffix .dvi,$(stems_ssg)) ingo@3661: all_tex_targets := $(addsuffix .tex,$(stems_sg)) ingo@3661: all_d_targets := $(addsuffix .d,$(stems_ssg)) ingo@3661: all_graphics_targets := $(addsuffix .$(default_graphic_extension),$(stems_gg)) ingo@3661: intermediate_graphics_targets := $(if $(filter pdf,$(default_graphic_extension)),$(addsuffix .eps,$(stems_gg)),) ingo@3661: all_pstex_targets := $(addsuffix .pstex_t,$(stems.fig)) ingo@3661: all_dot2tex_targets := $(addsuffix .dot_t,$(stems.dot)) ingo@3661: ingo@3661: all_known_graphics := $(sort $(all_graphics_targets) $(wildcard *.$(default_graphic_extension))) ingo@3661: ingo@3661: default_pdf_targets := $(addsuffix .pdf,$(default_stems_ss)) ingo@3661: ifneq "$(strip $(BUILD_STRATEGY))" "pdflatex" ingo@3661: default_ps_targets := $(addsuffix .ps,$(default_stems_ss)) ingo@3661: default_dvi_targets := $(addsuffix .dvi,$(default_stems_ss)) ingo@3661: pre_pdf_extensions := dvi ps ingo@3661: endif ingo@3661: ingo@3661: # Extensions generated by LaTeX invocation that can be removed when complete ingo@3661: rm_ext := \ ingo@3661: log *.log aux $(pre_pdf_extensions) pdf blg bbl out nav snm toc lof lot lol pfg \ ingo@3661: fls vrb idx ind ilg glg glo gls lox nls nlo nlg brf mtc maf brf ingo@3661: backup_patterns := *~ *.bak *.backup body.tmp head.tmp ingo@3661: ingo@3661: graph_stem := _graph ingo@3661: ingo@3661: # All LaTeX-generated files that can be safely removed ingo@3661: ingo@3661: rm_tex := \ ingo@3661: $(foreach e,$(rm_ext),$(addsuffix .$e,$(all_stems_source))) \ ingo@3661: $(foreach e,$(rm_ext) tex,$(addsuffix .$e,$(all_stems_sg))) \ ingo@3661: $(addsuffix .log,$(all_ps_targets) $(all_pdf_targets)) \ ingo@3661: $(addsuffix .*.log,$(stems_graphic)) ingo@3661: ingo@3661: # These are the files that will affect .gpi transformation for all .gpi files. ingo@3661: # ingo@3661: # Use only the first one found. Backward compatible values are at the end. ingo@3661: # Note that we use foreach, even though wildcard also returns a list, to ensure ingo@3661: # that the order in the uppercase variables is preserved. Directory listings ingo@3661: # provide no such guarantee, so we avoid relying on them. ingo@3661: gpi_sed := $(strip \ ingo@3661: $(firstword $(foreach f,$(GNUPLOT_SED),$(wildcard $f)))) ingo@3661: gpi_global := $(strip \ ingo@3661: $(firstword $(foreach f,$(GNUPLOT_GLOBAL),$(wildcard $f)))) ingo@3661: ingo@3661: # ingo@3661: # Functions used in generating output ingo@3661: # ingo@3661: ingo@3661: # Outputs all source dependencies to stdout. The first argument is the file to ingo@3661: # be parsed, the second is a list of files that will show up as dependencies in ingo@3661: # the new .d file created here. ingo@3661: # ingo@3661: # NOTE: BSD sed does not understand \|, so we have to do something more ingo@3661: # clunky to extract suitable extensions. ingo@3661: # ingo@3661: # Also, we do a little bit of funny rewriting up front (TARGETS=) to make sure ingo@3661: # that we can properly backslash-escape spaces in file names (e.g, on Cygwin ingo@3661: # for tex distributions that have "Program Files" in their name). ingo@3661: # ingo@3661: # $(call get-inputs,<parsed file>,<target files>) ingo@3661: define get-inputs ingo@3661: $(SED) \ ingo@3661: -e '/^INPUT/!d' \ ingo@3661: -e 's!^INPUT \(\./\)\{0,1\}!!' \ ingo@3661: -e 's/[[:space:]]/\\ /g' \ ingo@3661: -e 's/\(.*\)\.aux$$/\1.tex/' \ ingo@3661: -e '/\.tex$$/b addtargets' \ ingo@3661: -e '/\.cls$$/b addtargets' \ ingo@3661: -e '/\.sty$$/b addtargets' \ ingo@3661: -e '/\.pstex_t$$/b addtargets' \ ingo@3661: -e '/\.dot_t$$/b addtargets' \ ingo@3661: -e 'd' \ ingo@3661: -e ':addtargets' \ ingo@3661: -e 's/^/$2: /' \ ingo@3661: $1 | $(SORT) | $(UNIQ) ingo@3661: endef ingo@3661: ingo@3661: # $(call get-missing-inputs,<log file>,<target files>) ingo@3661: define get-missing-inputs ingo@3661: $(SED) \ ingo@3661: -e '$$ b para' \ ingo@3661: -e '/^$$/b para' \ ingo@3661: -e 'H' \ ingo@3661: -e 'd' \ ingo@3661: -e ':para' \ ingo@3661: -e 'x' \ ingo@3661: -e '/^$$/d' \ ingo@3661: -e 's/^\n*//' \ ingo@3661: -e '/^! LaTeX Error: File /{' \ ingo@3661: -e ' s/^/::DOUBLE_PARAGRAPH::/' \ ingo@3661: -e ' h' \ ingo@3661: -e ' d' \ ingo@3661: -e '}' \ ingo@3661: -e 's/^::DOUBLE_PARAGRAPH:://' \ ingo@3661: -e '/Default extension: /!d' \ ingo@3661: -e 's/[[:space:]]\{1,\}/ /g' \ ingo@3661: -e 's/\n\{1,\}/ /g' \ ingo@3661: -e 's/^.*File `//' \ ingo@3661: -e 's/'"'"' not found\..*//' \ ingo@3661: -e '/\.tex/!s/$$/.tex/' \ ingo@3661: -e 's/[[:space:]]/\\ /g' \ ingo@3661: -e 'h' \ ingo@3661: -e 's/.*/# MISSING input "&" - (presence of comment affects build)/' \ ingo@3661: -e 'p' \ ingo@3661: -e 's/.*//' \ ingo@3661: -e 'x' \ ingo@3661: -e 's/^/$2: /' \ ingo@3661: $1 | $(SORT) | $(UNIQ) ingo@3661: endef ingo@3661: ingo@3661: # Get source file for specified graphics stem. ingo@3661: # ingo@3661: # $(call graphics-source,<stem>) ingo@3661: define graphics-source ingo@3661: $(strip $(firstword \ ingo@3661: $(wildcard \ ingo@3661: $(addprefix $1.,\ ingo@3661: $(graphic_source_extensions))) \ ingo@3661: $1 \ ingo@3661: )) ingo@3661: endef ingo@3661: ingo@3661: # Get the target file for the specified graphics file/stem ingo@3661: # ingo@3661: # $(call graphics-target,<stem>) ingo@3661: define graphics-target ingo@3661: $(strip $(if $(filter $(addprefix %.,$(graphic_target_extensions)),$1), $1, ingo@3661: $(firstword $(patsubst $(addprefix %.,$(graphic_source_extensions) $(graphic_target_extensions)), %, $1).$(default_graphic_extension) $1.$(default_graphic_extension)))) ingo@3661: endef ingo@3661: ingo@3661: # Outputs all of the graphical dependencies to stdout. The first argument is ingo@3661: # the stem of the source file being built, the second is a list of suffixes ingo@3661: # that will show up as dependencies in the generated .d file. ingo@3661: # ingo@3661: # Note that we try to escape spaces in filenames where possible. We have to do ingo@3661: # it with three backslashes so that as the name percolates through the makefile ingo@3661: # it eventually ends up with the proper escaping when the build rule is found. ingo@3661: # Ugly, but it appears to work. Note that graphicx doesn't allow filenames ingo@3661: # with spaces, so this could in many ways be moot unless you're using something ingo@3661: # like grffile. ingo@3661: # ingo@3661: # For pdflatex, we really need the missing file to be specified without an ingo@3661: # extension, otherwise compilation barfs on the first missing file. Truly ingo@3661: # annoying, but there you have it. ingo@3661: # ingo@3661: # It turns out that the graphics errors, although they have lines with empty ingo@3661: # space, are only made of two paragraphs. So, we just use some sed magic to ingo@3661: # get everything into paragraphs, detect when it's a paragraph that interests ingo@3661: # us, and double it up. Then we get the filename only if we're missing ingo@3661: # extensions (a sign that it's graphicx complaining). ingo@3661: # ingo@3661: # $(call get-graphics,<target file stem>) ingo@3661: #.log,$(addprefix $*.,d $(build_target_extension) _graphics) ingo@3661: define get-graphics ingo@3661: $(SED) \ ingo@3661: -e '$$ b para' \ ingo@3661: -e '/^$$/b para' \ ingo@3661: -e 'H' \ ingo@3661: -e 'd' \ ingo@3661: -e ':para' \ ingo@3661: -e 'x' \ ingo@3661: -e '/^$$/d' \ ingo@3661: -e 's/^\n*//' \ ingo@3661: -e '/^! LaTeX Error: File `/{' \ ingo@3661: -e ' s/^/::DOUBLE_PARAGRAPH::/' \ ingo@3661: -e ' h' \ ingo@3661: -e ' d' \ ingo@3661: -e '}' \ ingo@3661: -e 's/^::DOUBLE_PARAGRAPH:://' \ ingo@3661: -e '/could not locate the file with any of these extensions:/{' \ ingo@3661: -e ' s/\n\{1,\}/ /g' \ ingo@3661: -e ' s/[[:space:]]\{1,\}/ /g' \ ingo@3661: -e ' s/^.*File `//' \ ingo@3661: -e ' s/'"'"' not found\..*//' \ ingo@3661: -e ' h' \ ingo@3661: -e ' s/.*/# MISSING stem "&" - (presence of comment affects build)/' \ ingo@3661: -e ' p' \ ingo@3661: -e ' g' \ ingo@3661: -e ' b addtargets' \ ingo@3661: -e '}' \ ingo@3661: -e '/.*File: \(.*\) Graphic file (type [^)]*).*/{' \ ingo@3661: -e ' s//\1/' \ ingo@3661: -e ' b addtargets' \ ingo@3661: -e '}' \ ingo@3661: -e 'd' \ ingo@3661: -e ':addtargets' \ ingo@3661: -e 's/[[:space:]]/\\\\\\&/g' \ ingo@3661: -e 'h' \ ingo@3661: -e 's/.*/-include &.gpi.d/' \ ingo@3661: -e 'p' \ ingo@3661: -e 'g' \ ingo@3661: -e 's/.*/$(addprefix $1,.d): $$$$(call graphics-source,&)/' \ ingo@3661: -e 'p' \ ingo@3661: -e 's/.*//' \ ingo@3661: -e 'x' \ ingo@3661: -e 's/.*/$(addprefix $1.,$(build_target_extension) _graphics): $$$$(call graphics-target,&)/' \ ingo@3661: -e 'p' \ ingo@3661: -e 'd' \ ingo@3661: $*.log ingo@3661: endef ingo@3661: ingo@3661: # Checks for build failure due to pstex inclusion, and gives instructions. ingo@3661: # ingo@3661: # $(call die-on-pstexs,<parsed file>) ingo@3661: define die-on-pstexs ingo@3661: if $(EGREP) -q '^! LaTeX Error: File .*\.pstex.* not found' $1; then \ ingo@3661: $(ECHO) "$(C_ERROR)Missing pstex_t file(s)$(C_RESET)"; \ ingo@3661: $(ECHO) "$(C_ERROR)Please run$(C_RESET)"; \ ingo@3661: $(ECHO) "$(C_ERROR) make all-pstex$(C_RESET)"; \ ingo@3661: $(ECHO) "$(C_ERROR)before proceeding.$(C_RESET)"; \ ingo@3661: exit 1; \ ingo@3661: fi ingo@3661: endef ingo@3661: ingo@3661: # Checks for build failure due to dot2tex, and gives instructions. ingo@3661: # ingo@3661: # $(call die-on-dot2tex,<parsed file>) ingo@3661: define die-on-dot2tex ingo@3661: if $(EGREP) -q ' LaTeX Error: File .*\.dot_t.* not found' $1; then \ ingo@3661: $(ECHO) "$(C_ERROR)Missing dot_t file(s)$(C_RESET)"; \ ingo@3661: $(ECHO) "$(C_ERROR)Please run$(C_RESET)"; \ ingo@3661: $(ECHO) "$(C_ERROR) make all-dot2tex$(C_RESET)"; \ ingo@3661: $(ECHO) "$(C_ERROR)before proceeding.$(C_RESET)"; \ ingo@3661: exit 1; \ ingo@3661: fi ingo@3661: endef ingo@3661: ingo@3661: # Checks for the existence of a .aux file, and dies with an error message if it ingo@3661: # isn't there. Note that we pass the file stem in, not the full filename, ingo@3661: # e.g., to check for foo.aux, we call it thus: $(call die-on-no-aux,foo) ingo@3661: # ingo@3661: # $(call die-on-no-aux,<aux stem>) ingo@3661: define die-on-no-aux ingo@3661: if [ ! -e '$1.aux' ]; then \ ingo@3661: $(call colorize-latex-errors,$1.log); \ ingo@3661: exit 1; \ ingo@3661: fi ingo@3661: endef ingo@3661: ingo@3661: # Outputs all index files to stdout. Arg 1 is the source file stem, arg 2 is ingo@3661: # the list of targets for the discovered dependency. ingo@3661: # ingo@3661: # $(call get-log-index,<log file stem>,<target files>) ingo@3661: define get-log-index ingo@3661: $(SED) \ ingo@3661: -e 's/^No file \(.*\.ind\)\.$$/TARGETS=\1/' \ ingo@3661: -e 's/^No file \(.*\.[gn]ls\)\.$$/TARGETS=\1/' \ ingo@3661: -e 's/[[:space:]]/\\&/g' \ ingo@3661: -e '/^TARGETS=/{' \ ingo@3661: -e ' h' \ ingo@3661: -e ' s/^TARGETS=/$2: /p' \ ingo@3661: -e ' g' \ ingo@3661: -e ' s/^TARGETS=\(.*\)/\1: $1.tex/p' \ ingo@3661: -e '}' \ ingo@3661: -e 'd' \ ingo@3661: '$1.log' | $(SORT) | $(UNIQ) ingo@3661: endef ingo@3661: ingo@3661: ingo@3661: # Outputs all bibliography files to stdout. Arg 1 is the source stem, arg 2 is ingo@3661: # a list of targets for each dependency found. ingo@3661: # ingo@3661: # The script kills all lines that do not contain bibdata. Remaining lines have ingo@3661: # the \bibdata macro and delimiters removed to create a dependency list. A ingo@3661: # trailing comma is added, then all adjacent commas are collapsed into a single ingo@3661: # comma. Then commas are replaced with the string .bib[space], and the ingo@3661: # trailing space is killed off. Finally, all filename spaces are escaped. ingo@3661: # This produces a list of space-delimited .bib filenames, which is what the ingo@3661: # make dep file expects to see. ingo@3661: # ingo@3661: # Note that we give kpsewhich a bogus argument so that a failure of sed to ingo@3661: # produce output will not cause an error. ingo@3661: # ingo@3661: # $(call get-bibs,<aux file>,<targets>) ingo@3661: define get-bibs ingo@3661: $(SED) \ ingo@3661: -e '/^\\bibdata/!d' \ ingo@3661: -e 's/\\bibdata{\([^}]*\)}/\1,/' \ ingo@3661: -e 's/,\{2,\}/,/g' \ ingo@3661: -e 's/[[:space:]]/\\&/g' \ ingo@3661: -e 's/,/.bib /g' \ ingo@3661: -e 's/ \{1,\}$$//' \ ingo@3661: $1 | $(XARGS) $(KPSEWHICH) '#######' | \ ingo@3661: $(SED) \ ingo@3661: -e 's/^/$2: /' | \ ingo@3661: \$(SORT) | $(UNIQ) ingo@3661: endef ingo@3661: ingo@3661: # Makes a an aux file that only has stuff relevant to the target in it ingo@3661: # $(call make-auxtarget-file,<flattened-aux>,<new-aux>) ingo@3661: define make-auxtarget-file ingo@3661: $(SED) \ ingo@3661: -e '/^\\newlabel/!d' \ ingo@3661: $1 > $2 ingo@3661: endef ingo@3661: ingo@3661: # Makes an aux file that only has stuff relevant to the bbl in it ingo@3661: # $(call make-auxbbl-file,<flattened-aux>,<new-aux>) ingo@3661: define make-auxbbl-file ingo@3661: $(SED) \ ingo@3661: -e '/^\\newlabel/d' \ ingo@3661: $1 > $2 ingo@3661: endef ingo@3661: ingo@3661: # Makes a .gpi.d file from a .gpi file ingo@3661: # $(call make-gpi-d,<.gpi>,<.gpi.d>) ingo@3661: define make-gpi-d ingo@3661: $(ECHO) '# vim: ft=make' > $2; \ ingo@3661: $(ECHO) 'ifndef INCLUDED_$(call cleanse-filename,$2)' >> $2; \ ingo@3661: $(ECHO) 'INCLUDED_$(call cleanse-filename,$2) := 1' >> $2; \ ingo@3661: $(call get-gpi-deps,$1,$(addprefix $(2:%.gpi.d=%).,$(GNUPLOT_OUTPUT_EXTENSION) gpi.d)) >> $2; \ ingo@3661: $(ECHO) 'endif' >> $2; ingo@3661: endef ingo@3661: ingo@3661: # Parse .gpi files for data and loaded dependencies, output to stdout ingo@3661: # ingo@3661: # The sed script here tries to be clever about obtaining valid ingo@3661: # filenames from the gpi file. It assumes that the plot command starts its own ingo@3661: # line, which is not too difficult a constraint to satisfy. ingo@3661: # ingo@3661: # This command script also generates 'include' directives for every 'load' ingo@3661: # command in the .gpi file. The load command must appear on a line by itself ingo@3661: # and the file it loads must have the suffix .gpi. If you don't want it to be ingo@3661: # compiled when running make graphics, then give it a suffix of ._include_.gpi. ingo@3661: # ingo@3661: # $(call get-gpi-deps,<gpi file>,<targets>) ingo@3661: define get-gpi-deps ingo@3661: $(SED) \ ingo@3661: -e '/^[[:space:]]*s\{0,1\}plot/,/[^\\]$$/{' \ ingo@3661: -e ' H' \ ingo@3661: -e ' /[^\\]$$/{' \ ingo@3661: -e ' s/.*//' \ ingo@3661: -e ' x' \ ingo@3661: -e ' s/\\\{0,1\}\n//g' \ ingo@3661: -e ' s/^[[:space:]]*s\{0,1\}plot[[:space:]]*\(\[[^]]*\][[:space:]]*\)*/,/' \ ingo@3661: -e ' s/[[:space:]]*\(['\''"][^'\''"]*['\''"]\)\{0,1\}[^,]*/\1/g' \ ingo@3661: -e ' s/,['\''"]-\{0,1\}['\''"]//g' \ ingo@3661: -e ' s/[,'\''"]\{1,\}/ /g' \ ingo@3661: -e ' s!.*!$2: &!' \ ingo@3661: -e ' p' \ ingo@3661: -e ' }' \ ingo@3661: -e ' d' \ ingo@3661: -e '}' \ ingo@3661: -e 's/^[[:space:]]*load[[:space:]]*['\''"]\([^'\''"]*\.gpi\)['\''"].*$$/-include \1.d/p' \ ingo@3661: -e 'd' \ ingo@3661: $1 ingo@3661: endef ingo@3661: ingo@3661: # Colorizes real, honest-to-goodness LaTeX errors that can't be overcome with ingo@3661: # recompilation. ingo@3661: # ingo@3661: # Note that we only ignore file not found errors for things that we know how to ingo@3661: # build, like graphics files. ingo@3661: # ingo@3661: # $(call colorize-latex-errors,<log file>) ingo@3661: define colorize-latex-errors ingo@3661: $(SED) \ ingo@3661: -e '$$ b para' \ ingo@3661: -e '/^$$/b para' \ ingo@3661: -e 'H' \ ingo@3661: -e 'd' \ ingo@3661: -e ':para' \ ingo@3661: -e 'x' \ ingo@3661: -e '/^$$/d' \ ingo@3661: -e 's/^\n*//' \ ingo@3661: -e '/^! LaTeX Error: File /{' \ ingo@3661: -e ' s/^/::DOUBLE_PARAGRAPH::/' \ ingo@3661: -e ' h' \ ingo@3661: -e ' d' \ ingo@3661: -e '}' \ ingo@3661: -e 's/^::DOUBLE_PARAGRAPH:://' \ ingo@3661: -e '/could not locate the file with any of these extensions:/d' \ ingo@3661: -e '/Missing .begin.document/{' \ ingo@3661: -e ' h' \ ingo@3661: -e ' s/.*/Are you trying to build an include file?/' \ ingo@3661: -e ' x' \ ingo@3661: -e ' G' \ ingo@3661: -e '}' \ ingo@3661: -e '/ LaTeX Error: Cannot determine size/d' \ ingo@3661: -e 's/.* LaTeX Error .*/$(C_ERROR)&$(C_RESET)/p' \ ingo@3661: -e 's/Error: pdflatex (file .*/$(C_ERROR)& - try specifying it without an extension$(C_RESET)/p' \ ingo@3661: -e '/.*\*hyperref using.*driver \(.*\)\*.*/{' \ ingo@3661: -e ' s//\1/' \ ingo@3661: -e ' /^$(hyperref_driver_pattern)$$/!{' \ ingo@3661: -e ' s/.*//' \ ingo@3661: -e ' p' \ ingo@3661: -e ' s/.*/$(C_ERROR)--- Using incorrect driver for hyperref! ---$(C_RESET)/' \ ingo@3661: -e ' p' \ ingo@3661: -e ' s/.*/$(C_ERROR)$(hyperref_driver_error)$(C_RESET)/' \ ingo@3661: -e ' p' \ ingo@3661: -e ' }' \ ingo@3661: -e ' d' \ ingo@3661: -e '}' \ ingo@3661: -e '/ LaTeX Error: Unknown graphics extension/{' \ ingo@3661: -e ' s/^/ /' \ ingo@3661: -e ' h' \ ingo@3661: -e ' s/.*/--- Graphics extension error:/' \ ingo@3661: -e ' G' \ ingo@3661: -e ' h' \ ingo@3661: -e ' s/.*/--- If you specified the extension explicitly in your .tex file, try removing it./' \ ingo@3661: -e ' H' \ ingo@3661: -e ' g' \ ingo@3661: -e ' s/.*/$(C_ERROR)&$(C_RESET)/' \ ingo@3661: -e ' p' \ ingo@3661: -e ' s/.*//' \ ingo@3661: -e ' h' \ ingo@3661: -e ' b' \ ingo@3661: -e '}' \ ingo@3661: -e 's/.*\(\n\{0,\}! .*\)/$(C_ERROR)\1$(C_RESET)/p' \ ingo@3661: -e 'd' \ ingo@3661: $1 ingo@3661: endef ingo@3661: ingo@3661: # Colorize Makeindex errors ingo@3661: define colorize-makeindex-errors ingo@3661: $(SED) \ ingo@3661: -e '/^!! /{' \ ingo@3661: -e ' N' \ ingo@3661: -e ' s/^.*$$/$(C_ERROR)&$(C_RESET)/' \ ingo@3661: -e ' p' \ ingo@3661: -e '}' \ ingo@3661: -e 'd' \ ingo@3661: $1 ingo@3661: endef ingo@3661: ingo@3661: # Colorize epstopdf errors ingo@3661: # ingo@3661: # $(call colorize-epstopdf-errors,<log file>) ingo@3661: define colorize-epstopdf-errors ingo@3661: $(SED) \ ingo@3661: -e '/^Error:/,/^Execution stack:/{' \ ingo@3661: -e ' /^Execution stack:/d' \ ingo@3661: -e ' s/.*/$(C_ERROR)&$(C_RESET)/' \ ingo@3661: -e ' p' \ ingo@3661: -e '}' \ ingo@3661: -e 'd' \ ingo@3661: $1 ingo@3661: endef ingo@3661: ingo@3661: # Colorize GNUplot errors ingo@3661: # ingo@3661: # $(call colorize-gnuplot-errors,<log file>) ingo@3661: define colorize-gnuplot-errors ingo@3661: $(SED) \ ingo@3661: -e '/, line [0-9]*:/!{' \ ingo@3661: -e ' H' \ ingo@3661: -e ' x' \ ingo@3661: -e ' s/.*\n\(.*\n.*\)$$/\1/' \ ingo@3661: -e ' x' \ ingo@3661: -e '}' \ ingo@3661: -e '/, line [0-9]*:/{' \ ingo@3661: -e ' H' \ ingo@3661: -e ' /unknown.*terminal type/{' \ ingo@3661: -e ' s/.*/--- Try changing the GNUPLOT_OUTPUT_EXTENSION variable to 'eps'./' \ ingo@3661: -e ' H' \ ingo@3661: -e ' }' \ ingo@3661: -e ' /gpihead/{' \ ingo@3661: -e ' s/.*/--- This could be a Makefile bug - contact the maintainer./' \ ingo@3661: -e ' H' \ ingo@3661: -e ' }' \ ingo@3661: -e ' g' \ ingo@3661: -e ' s/.*/$(C_ERROR)&$(C_RESET)/' \ ingo@3661: -e ' p' \ ingo@3661: -e '}' \ ingo@3661: -e '/^gnuplot>/,/^$$/{' \ ingo@3661: -e ' s/^gnuplot.*/$(C_ERROR)&/' \ ingo@3661: -e ' s/^$$/$(C_RESET)/' \ ingo@3661: -e ' p' \ ingo@3661: -e '}' \ ingo@3661: -e 'd' \ ingo@3661: $1 ingo@3661: endef ingo@3661: ingo@3661: # Colorize GraphViz errors ingo@3661: # ingo@3661: # $(call colorize-dot-errors,<log file>) ingo@3661: define colorize-dot-errors ingo@3661: $(SED) \ ingo@3661: -e '/^Error:/,/context:/s/.*/$(C_ERROR)&$(C_RESET)/p' \ ingo@3661: -e 's/^Warning:.*/$(C_WARNING)&$(C_RESET)/p' \ ingo@3661: -e 'd' \ ingo@3661: '$1' ingo@3661: endef ingo@3661: ingo@3661: # Get all important .aux files from the top-level .aux file and merges them all ingo@3661: # into a single file, which it outputs to stdout. ingo@3661: # ingo@3661: # $(call flatten-aux,<toplevel aux>,<output file>) ingo@3661: define flatten-aux ingo@3661: $(SED) \ ingo@3661: -e '/\\@input{\(.*\)}/{' \ ingo@3661: -e 's//\1/' \ ingo@3661: -e 's![.:]!\\&!g' \ ingo@3661: -e 'h' \ ingo@3661: -e 's!.*!\\:\\\\@input{&}:{!' \ ingo@3661: -e 'p' \ ingo@3661: -e 'x' \ ingo@3661: -e 's/\\././g' \ ingo@3661: -e 's/.*/r &/p' \ ingo@3661: -e 's/.*/d/p' \ ingo@3661: -e 's/.*/}/p' \ ingo@3661: -e 'd' \ ingo@3661: -e '}' \ ingo@3661: -e 'd' \ ingo@3661: '$1' > "$1.$$$$.sed.make"; \ ingo@3661: $(SED) -f "$1.$$$$.sed.make" '$1' > "$1.$$$$.make"; \ ingo@3661: $(SED) \ ingo@3661: -e '/^\\relax/d' \ ingo@3661: -e '/^\\bibcite/d' \ ingo@3661: -e 's/^\(\\newlabel{[^}]\{1,\}}\).*/\1/' \ ingo@3661: "$1.$$$$.make" | $(SORT) > '$2'; \ ingo@3661: $(call remove-temporary-files,$1.$$$$.make $1.$$$$.sed.make) ingo@3661: endef ingo@3661: ingo@3661: # Generate pdf from postscript ingo@3661: # ingo@3661: # Note that we don't just call ps2pdf, since there are so many versions of that ingo@3661: # script on various systems. Instead, we call the postscript interpreter ingo@3661: # directly. ingo@3661: # ingo@3661: # $(call ps2pdf,infile,outfile,[embed fonts]) ingo@3661: define ps2pdf ingo@3661: $(GS) \ ingo@3661: -dSAFER -dCompatibilityLevel=$(PS_COMPATIBILITY) \ ingo@3661: $(if $3,$(PS_EMBED_OPTIONS)) \ ingo@3661: -q -dNOPAUSE -dBATCH \ ingo@3661: -sDEVICE=pdfwrite -sstdout=%stderr \ ingo@3661: '-sOutputFile=$2' \ ingo@3661: -dSAFER -dCompatibilityLevel=$(PS_COMPATIBILITY) \ ingo@3661: $(if $3,$(PS_EMBED_OPTIONS)) \ ingo@3661: -c .setpdfwrite \ ingo@3661: -f '$1' ingo@3661: endef ingo@3661: ingo@3661: # Colorize LaTeX output. ingo@3661: # This uses a neat trick from the Sed & Awk Book from O'Reilly: ingo@3661: # 1) If a line has a single ending paren, delete it to make a blank line (so ingo@3661: # that we catch the first error, which is not always preceded by a blank ingo@3661: # line). ingo@3661: # 2) Ensure that the last line of the file gets appended to the hold buffer, ingo@3661: # and blank it out to trigger end-of-paragraph logic below. ingo@3661: # 3) When encountering a blank line (LaTeX output helpfully breaks output on ingo@3661: # newlines) ingo@3661: # a) swap the hold buffer (containing the paragraph) into the pattern buffer (putting a blank line into the hold buffer), ingo@3661: # b) remove the newline at the beginning (don't ask), ingo@3661: # c) apply any colorizing substitutions necessary to ensure happiness. ingo@3661: # d) get the newline out of the hold buffer and append it ingo@3661: # e) profit! (print) ingo@3661: # 4) Anything not colorized is deleted, unless in verbose mode. ingo@3661: color_tex := \ ingo@3661: $(SED) \ ingo@3661: -e '$${' \ ingo@3661: -e ' /^$$/!{' \ ingo@3661: -e ' H' \ ingo@3661: -e ' s/.*//' \ ingo@3661: -e ' }' \ ingo@3661: -e '}' \ ingo@3661: -e '/^$$/!{' \ ingo@3661: -e ' H' \ ingo@3661: -e ' d' \ ingo@3661: -e '}' \ ingo@3661: -e '/^$$/{' \ ingo@3661: -e ' x' \ ingo@3661: -e ' s/^\n//' \ ingo@3661: -e ' /Output written on /{' \ ingo@3661: -e ' s/.*Output written on \([^(]*\) (\([^)]\{1,\}\)).*/Success! Wrote \2 to \1/' \ ingo@3661: -e ' s/[[:digit:]]\{1,\}/$(C_PAGES)&$(C_RESET)/g' \ ingo@3661: -e ' s/Success!/$(C_SUCCESS)&$(C_RESET)/g' \ ingo@3661: -e ' s/to \(.*\)$$/to $(C_SUCCESS)\1$(C_RESET)/' \ ingo@3661: -e ' b end' \ ingo@3661: -e ' }' \ ingo@3661: -e ' / *LaTeX Error:.*/{' \ ingo@3661: -e ' s/.*\( *LaTeX Error:.*\)/$(C_ERROR)\1$(C_RESET)/' \ ingo@3661: -e ' b end' \ ingo@3661: -e ' }' \ ingo@3661: -e ' /.*Warning:.*/{' \ ingo@3661: -e ' s//$(C_WARNING)&$(C_RESET)/' \ ingo@3661: -e ' b end' \ ingo@3661: -e ' }' \ ingo@3661: -e ' /Underfull.*/{' \ ingo@3661: -e ' s/.*\(Underfull.*\)/$(C_UNDERFULL)\1$(C_RESET)/' \ ingo@3661: -e ' b end' \ ingo@3661: -e ' }' \ ingo@3661: -e ' /Overfull.*/{' \ ingo@3661: -e ' s/.*\(Overfull.*\)/$(C_OVERFULL)\1$(C_RESET)/' \ ingo@3661: -e ' b end' \ ingo@3661: -e ' }' \ ingo@3661: $(if $(VERBOSE),,-e ' d') \ ingo@3661: -e ' :end' \ ingo@3661: -e ' G' \ ingo@3661: -e '}' \ ingo@3661: ingo@3661: # Colorize BibTeX output. ingo@3661: color_bib := \ ingo@3661: $(SED) \ ingo@3661: -e 's/^Warning--.*/$(C_WARNING)&$(C_RESET)/' -e 't' \ ingo@3661: -e '/---/,/^.[^:]/{' \ ingo@3661: -e ' H' \ ingo@3661: -e ' /^.[^:]/{' \ ingo@3661: -e ' x' \ ingo@3661: -e ' s/\n\(.*\)/$(C_ERROR)\1$(C_RESET)/' \ ingo@3661: -e ' p' \ ingo@3661: -e ' s/.*//' \ ingo@3661: -e ' h' \ ingo@3661: -e ' d' \ ingo@3661: -e ' }' \ ingo@3661: -e ' d' \ ingo@3661: -e '}' \ ingo@3661: -e '/(.*error.*)/s//$(C_ERROR)&$(C_RESET)/' \ ingo@3661: $(if $(VERBOSE),,-e 'd') ingo@3661: ingo@3661: ingo@3661: # Make beamer output big enough to print on a full page. Landscape doesn't ingo@3661: # seem to work correctly. ingo@3661: enlarge_beamer = $(PSNUP) -l -1 -W128mm -H96mm -pletter ingo@3661: ingo@3661: # $(call test-run-again,<source stem>) ingo@3661: test-run-again = $(EGREP) -q '^(.*Rerun .*|No file $1\.[^.]+\.)$$' $1.log ingo@3661: ingo@3661: # This tests whether the build target commands should be run at all, from ingo@3661: # viewing the log file. ingo@3661: # $(call test-log-for-need-to-run,<source stem>) ingo@3661: define test-log-for-need-to-run ingo@3661: $(SED) \ ingo@3661: -e '/^No file $(call escape-dots,$1)\.aux\./d' \ ingo@3661: $1.log \ ingo@3661: | $(EGREP) -q '^(.*Rerun .*|No file $1\.[^.]+\.|No file .+\.tex\.|LaTeX Warning: File.*)$$' ingo@3661: endef ingo@3661: ingo@3661: # LaTeX invocations ingo@3661: # ingo@3661: # $(call latex,<tex file>,[<extra LaTeX args>]) ingo@3661: run-latex = $(latex_build_program) --interaction=batchmode $(if $2,$2,) $1 > /dev/null ingo@3661: ingo@3661: # $(call latex-color-log,<LaTeX stem>) ingo@3661: latex-color-log = $(color_tex) $1.log ingo@3661: ingo@3661: # $(call run-makeindex,<input>,<output>,<log>,<extra flags>) ingo@3661: define run-makeindex ingo@3661: success=1; \ ingo@3661: if ! $(MAKEINDEX) -q $1 -t $3 -o $2 $4 > /dev/null || $(EGREP) -q '^!!' $3; then \ ingo@3661: $(call colorize-makeindex-errors,$3); \ ingo@3661: $(RM) -f '$2'; \ ingo@3661: success=0; \ ingo@3661: fi; \ ingo@3661: [ "$$success" = "1" ] && $(sh_true) || $(sh_false); ingo@3661: endef ingo@3661: ingo@3661: # This runs the given script to generate output, and it uses MAKE_RESTARTS to ingo@3661: # ensure that it never runs it more than once for a particular root make ingo@3661: # invocation. ingo@3661: # ingo@3661: # $(call run-script,<interpreter>,<input>,<output>) ingo@3661: define run-script ingo@3661: [ ! -e '$2.cookie' ] && $(ECHO) "restarts=$(RESTARTS)" > $2.cookie && $(ECHO) "level=$(MAKELEVEL)" >> $2.cookie; \ ingo@3661: restarts=`$(SED) -n -e 's/^restarts=//p' $2.cookie`; \ ingo@3661: level=`$(SED) -n -e 's/^level=//p' $2.cookie`; \ ingo@3661: if $(EXPR) $(MAKELEVEL) '<=' $$level '&' $(RESTARTS) '<=' $$restarts >/dev/null; then \ ingo@3661: $(call echo-build,$2,$3,$(RESTARTS)-$(MAKELEVEL)); \ ingo@3661: $1 '$2' '$3'; \ ingo@3661: $(ECHO) "restarts=$(RESTARTS)" > '$2.cookie'; \ ingo@3661: $(ECHO) "level=$(MAKELEVEL)" >> '$2.cookie'; \ ingo@3661: fi ingo@3661: endef ingo@3661: ingo@3661: # BibTeX invocations ingo@3661: # ingo@3661: # $(call run-bibtex,<tex stem>) ingo@3661: run-bibtex = $(BIBTEX) $1 | $(color_bib) ingo@3661: ingo@3661: ingo@3661: # $(call convert-eps-to-pdf,<eps file>,<pdf file>,[gray]) ingo@3661: # Note that we don't use the --filter flag because it has trouble with bounding boxes that way. ingo@3661: define convert-eps-to-pdf ingo@3661: $(if $3,$(CAT) '$1' | $(call kill-ps-color) > '$1.cookie',$(CP) '$1' '$1.cookie'); \ ingo@3661: $(EPSTOPDF) '$1.cookie' --outfile='$2' > $1.log; \ ingo@3661: $(call colorize-epstopdf-errors,$1.log); ingo@3661: endef ingo@3661: ingo@3661: # $(call convert-gpi,<gpi file>,<output file>,[gray]) ingo@3661: # ingo@3661: define convert-gpi ingo@3661: $(ECHO) 'set terminal $(if $(filter %.pdf,$2),pdf enhanced,postscript enhanced eps)' \ ingo@3661: $(if $(filter %.pdf,$2),fsize ,)$(call get-default,$(strip \ ingo@3661: $(firstword \ ingo@3661: $(shell \ ingo@3661: $(SED) \ ingo@3661: -e 's/^\#\#FONTSIZE=\([[:digit:]]\{1,\}\)/\1/p' \ ingo@3661: -e 'd' \ ingo@3661: $1 $(strip $(gpi_global)) \ ingo@3661: ) \ ingo@3661: ) \ ingo@3661: ),$(if $(filter %.pdf,$2),$(DEFAULT_GPI_PDF_FONTSIZE),$(DEFAULT_GPI_EPS_FONTSIZE))) \ ingo@3661: $(strip $(if $3,monochrome,$(if \ ingo@3661: $(shell $(EGREP) '^\#\#[[:space:]]*GRAY[[:space:]]*$$' $< $(gpi_global)),\ ingo@3661: ,color))) > $1head.make; \ ingo@3661: $(ECHO) 'set output "$2"' >> $1head.make; \ ingo@3661: $(if $(gpi_global),$(CAT) $(gpi_global) >> $1head.make;,) \ ingo@3661: fnames='$1head.make $1';\ ingo@3661: $(if $(gpi_sed),\ ingo@3661: $(SED) -f '$(gpi_sed)' $$fnames > $1.temp.make; \ ingo@3661: fnames=$1.temp.make;,\ ingo@3661: ) \ ingo@3661: success=1; \ ingo@3661: if ! $(GNUPLOT) $$fnames 2>$1.log; then \ ingo@3661: $(call colorize-gnuplot-errors,$1.log); \ ingo@3661: success=0; \ ingo@3661: fi; \ ingo@3661: $(if $(gpi_sed),$(call remove-temporary-files,$1.temp.make);,) \ ingo@3661: $(call remove-temporary-files,$1head.make); \ ingo@3661: [ "$$success" = "1" ] && $(sh_true) || $(sh_false); ingo@3661: endef ingo@3661: ingo@3661: # Creation of .eps files from .png files ingo@3661: # ingo@3661: # The intermediate step of PNM (using NetPBM) produces much nicer output than ingo@3661: # ImageMagick's "convert" binary. I couldn't get the right combination of ingo@3661: # flags to make it look nice, anyway. ingo@3661: # ingo@3661: # To handle gray scale conversion, we pipe things through ppmtopgm in the ingo@3661: # middle. ingo@3661: # ingo@3661: # $(call convert-png,<png file>,<eps file>) ingo@3661: define convert-png ingo@3661: $(PNGTOPNM) "$1" \ ingo@3661: $(if $3,| $(PPMTOPGM),) \ ingo@3661: | $(PNMTOPS) -noturn \ ingo@3661: > "$2" ingo@3661: endef ingo@3661: ingo@3661: # Creation of .eps files from .jpg files ingo@3661: # ingo@3661: # Thanks to brubakee for this solution. ingo@3661: # ingo@3661: # Uses Postscript level 2 to avoid file size bloat ingo@3661: # $(call convert-jpg,<jpg file>,<eps file>) ingo@3661: define convert-jpg ingo@3661: $(CONVERT) $(if $3,-type Grayscale,) '$1' eps2:'$2' ingo@3661: endef ingo@3661: ingo@3661: # Creation of .eps files from .fig files ingo@3661: # $(call convert-fig,<fig file>,<output file>,[gray]) ingo@3661: convert-fig = $(FIG2DEV) -L $(if $(filter %.pdf,$2),pdf,eps) $(if $3,-N,) $1 $2 ingo@3661: ingo@3661: # Creation of .pstex files from .fig files ingo@3661: # $(call convert-fig-pstex,<fig file>,<pstex file>) ingo@3661: convert-fig-pstex = $(FIG2DEV) -L pstex $1 $2 > /dev/null 2>&1 ingo@3661: ingo@3661: # Creation of .pstex_t files from .fig files ingo@3661: # $(call convert-fig-pstex-t,<fig file>,<pstex file>,<pstex_t file>) ingo@3661: convert-fig-pstex-t = $(FIG2DEV) -L pstex_t -p $3 $1 $2 > /dev/null 2>&1 ingo@3661: ingo@3661: # Creation of .dot_t files from .dot files ingo@3661: # #(call convert-dot-tex,<dot file>,<dot_t file>) ingo@3661: convert-dot-tex = $(DOT2TEX) '$1' > '$2' ingo@3661: ingo@3661: # Converts svg files into .eps files ingo@3661: # ingo@3661: # $(call convert-svg,<svg file>,<eps file>,[gray]) ingo@3661: convert-svg = $(INKSCAPE) --export-eps='$2' '$1' ingo@3661: ingo@3661: # Converts xvg files into .eps files ingo@3661: # ingo@3661: # $(call convert-xvg,<xvg file>,<eps file>,[gray]) ingo@3661: convert-xvg = $(XMGRACE) '$1' -printfile - -hardcopy -hdevice $(if $3,-mono,) EPS > '$2' ingo@3661: ingo@3661: # Converts .eps.gz files into .eps files ingo@3661: # ingo@3661: # $(call convert-epsgz,<eps.gz file>,<eps file>,[gray]) ingo@3661: convert-epsgz = $(GUNZIP) -c '$1' $(if $3,| $(call kill-ps-color)) > '$2' ingo@3661: ingo@3661: # Converts .eps files into .eps files (usually a no-op, but can make grayscale) ingo@3661: # ingo@3661: # $(call convert-eps,<in file>,<out file>,[gray]) ingo@3661: convert-eps = $(if $3,$(call kill-ps-color) $1 > $2) ingo@3661: ingo@3661: # The name of the file containing special postscript commands for grayscale ingo@3661: gray_eps_file := gray.eps.make ingo@3661: ingo@3661: # Changes sethsbcolor and setrgbcolor calls in postscript to always produce ingo@3661: # grayscale. In general, this is accomplished by writing new versions of those ingo@3661: # functions into the user dictionary space, which is looked up before the ingo@3661: # global or system dictionaries (userdict is one of the permanent dictionaries ingo@3661: # in postscript and is not read-only like systemdict). ingo@3661: # ingo@3661: # For setrgbcolor, the weighted average of the triple is computed and the ingo@3661: # triple is replaced with three copies of that average before the original ingo@3661: # procedure is called: .299R + .587G + .114B ingo@3661: # ingo@3661: # For sethsbcolor, the color is first converted to RGB, then to grayscale by ingo@3661: # the new setrgbcolor operator as described above. Why is this done? ingo@3661: # Because simply using the value component will tend to make pure colors ingo@3661: # white, a very undesirable thing. Pure blue should not translate to white, ingo@3661: # but to some level of gray. Conversion to RGB does the right thing. It's ingo@3661: # messy, but it works. ingo@3661: # ingo@3661: # From ingo@3661: # http://en.wikipedia.org/wiki/HSV_color_space#Transformation_from_HSV_to_RGB, ingo@3661: # HSB = HSV (Value = Brightness), and the formula used to convert to RGB is ingo@3661: # as follows: ingo@3661: # ingo@3661: # Hi = int(floor(6 * H)) mod 6 ingo@3661: # f = 6 * H - Hi ingo@3661: # p = V(1-S) ingo@3661: # q = V(1-fS) ingo@3661: # t = V(1-(1-f)S) ingo@3661: # if Hi = 0: R G B <-- V t p ingo@3661: # if Hi = 1: R G B <-- q V p ingo@3661: # if Hi = 2: R G B <-- p V t ingo@3661: # if Hi = 3: R G B <-- p q V ingo@3661: # if Hi = 4: R G B <-- t p V ingo@3661: # if Hi = 5: R G B <-- V p q ingo@3661: # ingo@3661: # The messy stack-based implementation is below ingo@3661: # $(call create-gray-eps-file,filename) ingo@3661: define create-gray-eps-file ingo@3661: $(ECHO) -n -e '\ ingo@3661: /OLDRGB /setrgbcolor load def\n\ ingo@3661: /setrgbcolor {\n\ ingo@3661: .114 mul exch\n\ ingo@3661: .587 mul add exch\n\ ingo@3661: .299 mul add\n\ ingo@3661: dup dup\n\ ingo@3661: OLDRGB\n\ ingo@3661: } bind def\n\ ingo@3661: /OLDHSB /sethsbcolor load def\n\ ingo@3661: /sethsbcolor {\n\ ingo@3661: 2 index % H V S H\n\ ingo@3661: 6 mul floor cvi 6 mod % Hi V S H\n\ ingo@3661: 3 index % H Hi V S H\n\ ingo@3661: 6 mul % 6H Hi V S H\n\ ingo@3661: 1 index % Hi 6H Hi V S H\n\ ingo@3661: sub % f Hi V S H\n\ ingo@3661: 2 index 1 % 1 V f Hi V S H\n\ ingo@3661: 4 index % S 1 V f Hi V S H\n\ ingo@3661: sub mul % p f Hi V S H\n\ ingo@3661: 3 index 1 % 1 V p f Hi V S H\n\ ingo@3661: 6 index % S 1 V p f Hi V S H\n\ ingo@3661: 4 index % f S 1 V p f Hi V S H\n\ ingo@3661: mul sub mul % q p f Hi V S H\n\ ingo@3661: 4 index 1 1 % 1 1 V q p f Hi V S H\n\ ingo@3661: 5 index % f 1 1 V q p f Hi V S H\n\ ingo@3661: sub % (1-f) 1 V q p f Hi V S H\n\ ingo@3661: 8 index % S (1-f) 1 V q p f Hi V S H\n\ ingo@3661: mul sub mul % t q p f Hi V S H\n\ ingo@3661: 4 -1 roll pop % t q p Hi V S H\n\ ingo@3661: 7 -2 roll pop pop % t q p Hi V\n\ ingo@3661: 5 -2 roll % Hi V t q p\n\ ingo@3661: dup 0 eq\n\ ingo@3661: {1 index 3 index 6 index}\n\ ingo@3661: {\n\ ingo@3661: dup 1 eq\n\ ingo@3661: {3 index 2 index 6 index}\n\ ingo@3661: {\n\ ingo@3661: dup 2 eq\n\ ingo@3661: {4 index 2 index 4 index}\n\ ingo@3661: {\n\ ingo@3661: dup 3 eq\n\ ingo@3661: {4 index 4 index 3 index}\n\ ingo@3661: {\n\ ingo@3661: dup 4 eq\n\ ingo@3661: {2 index 5 index 3 index}\n\ ingo@3661: {\n\ ingo@3661: dup 5 eq\n\ ingo@3661: {1 index 5 index 5 index}\n\ ingo@3661: {0 0 0}\n\ ingo@3661: ifelse\n\ ingo@3661: }\n\ ingo@3661: ifelse\n\ ingo@3661: }\n\ ingo@3661: ifelse\n\ ingo@3661: }\n\ ingo@3661: ifelse\n\ ingo@3661: }\n\ ingo@3661: ifelse\n\ ingo@3661: }\n\ ingo@3661: ifelse % B G R Hi V t q p\n\ ingo@3661: setrgbcolor\n\ ingo@3661: 5 {pop} repeat\n\ ingo@3661: } bind def\n'\ ingo@3661: > $1 ingo@3661: endef ingo@3661: ingo@3661: # This actually inserts the color-killing code into a postscript file ingo@3661: # $(call kill-ps-color) ingo@3661: define kill-ps-color ingo@3661: $(SED) -e '/%%EndComments/r $(gray_eps_file)' ingo@3661: endef ingo@3661: ingo@3661: # Converts graphviz .dot files into .eps files ingo@3661: # Grayscale is not directly supported by dot, so we pipe it through fig2dev in ingo@3661: # that case. ingo@3661: # $(call convert-dot,<dot file>,<eps file>,<log file>,[gray]) ingo@3661: define convert-dot ingo@3661: $(DOT) -Tps '$1' 2>'$3' $(if $4,| $(call kill-ps-color)) > $2; \ ingo@3661: $(call colorize-dot-errors,$3) ingo@3661: endef ingo@3661: ingo@3661: # Convert DVI to Postscript ingo@3661: # $(call make-ps,<dvi file>,<ps file>,<log file>,[<paper size>]) ingo@3661: make-ps = \ ingo@3661: $(DVIPS) -o '$2' $(if $(filter-out BEAMER,$4),-t$(firstword $4),) '$1' \ ingo@3661: $(if $(filter BEAMER,$4),| $(enlarge_beamer)) > $3 2>&1 ingo@3661: ingo@3661: # Convert Postscript to PDF ingo@3661: # $(call make-pdf,<ps file>,<pdf file>,<log file>,<embed file>) ingo@3661: make-pdf = \ ingo@3661: $(call ps2pdf,$1,$2,$(filter 1,$(shell $(CAT) '$4'))) > '$3' 2>&1 ingo@3661: ingo@3661: # Display information about what is being done ingo@3661: # $(call echo-build,<input file>,<output file>,[<run number>]) ingo@3661: echo-build = $(ECHO) "$(C_BUILD)= $1 --> $2$(if $3, ($3),) =$(C_RESET)" ingo@3661: echo-graphic = $(ECHO) "$(C_GRAPHIC)= $1 --> $2 =$(C_RESET)" ingo@3661: echo-dep = $(ECHO) "$(C_DEP)= $1 --> $2 =$(C_RESET)" ingo@3661: ingo@3661: # Display a list of something ingo@3661: # $(call echo-list,<values>) ingo@3661: echo-list = for x in $1; do $(ECHO) "$$x"; done ingo@3661: ingo@3661: # ingo@3661: # DEFAULT TARGET ingo@3661: # ingo@3661: ingo@3661: .PHONY: all ingo@3661: all: $(default_pdf_targets) ; ingo@3661: ingo@3661: .PHONY: all-pdf ingo@3661: all-pdf: $(default_pdf_targets) ; ingo@3661: ingo@3661: ifneq "$(strip $(BUILD_STRATEGY))" "pdflatex" ingo@3661: .PHONY: all-ps ingo@3661: all-ps: $(default_ps_targets) ; ingo@3661: ingo@3661: .PHONY: all-dvi ingo@3661: all-dvi: $(default_dvi_targets) ; ingo@3661: endif ingo@3661: ingo@3661: # ingo@3661: # VIEWING TARGET ingo@3661: # ingo@3661: .PHONY: show ingo@3661: show: all ingo@3661: $(QUIET)for x in $(default_pdf_targets); do \ ingo@3661: [ -e "$$x" ] && $(VIEW_PDF) $$x & \ ingo@3661: done ingo@3661: ingo@3661: # ingo@3661: # INCLUDES ingo@3661: # ingo@3661: source_includes := $(addsuffix .d,$(source_stems_to_include)) ingo@3661: graphic_includes := $(addsuffix .gpi.d,$(graphic_stems_to_include)) ingo@3661: ingo@3661: # Include only the dependencies used ingo@3661: ifneq "" "$(source_includes)" ingo@3661: include $(source_includes)$(call include-message,$(source_includes)) ingo@3661: endif ingo@3661: ifneq "" "$(graphic_includes)" ingo@3661: include $(graphic_includes)$(call include-message,$(graphic_includes)) ingo@3661: endif ingo@3661: ingo@3661: # ingo@3661: # MAIN TARGETS ingo@3661: # ingo@3661: ingo@3661: # Note that we don't just say %: %.pdf here - this can tend to mess up our ingo@3661: # includes, which detect what kind of file we are asking for. For example, ingo@3661: # asking to build foo.pdf is much different than asking to build foo when ingo@3661: # foo.gpi exists, because we look through all of the goals for *.pdf that ingo@3661: # matches *.gpi, then use that to determine which include files we need to ingo@3661: # build. ingo@3661: # ingo@3661: # Thus, we invoke make recursively with better arugments instead, restarting ingo@3661: # all of the appropriate machinery. ingo@3661: .PHONY: $(default_stems_ss) ingo@3661: $(default_stems_ss): %: %.pdf ; ingo@3661: ingo@3661: # This builds and displays the wanted file. ingo@3661: .PHONY: $(addsuffix ._show,$(stems_ssg)) ingo@3661: %._show: %.pdf ingo@3661: $(QUIET)$(VIEW_PDF) $< & ingo@3661: ingo@3661: ifneq "$(strip $(BUILD_STRATEGY))" "pdflatex" ingo@3661: .SECONDARY: $(all_pdf_targets) ingo@3661: %.pdf: %.ps %.embed.make ingo@3661: $(QUIET)$(call echo-build,$<,$@) ingo@3661: $(QUIET)$(call make-pdf,$<,$@.temp,$@.log,$*.embed.make); \ ingo@3661: if [ x"$$?" = x"0" ]; then \ ingo@3661: $(if $(VERBOSE),$(CAT) $@.log,:); \ ingo@3661: $(RM) -f '$@'; \ ingo@3661: $(MV) '$@.temp' '$@'; \ ingo@3661: $(TOUCH) '$@'; \ ingo@3661: $(call copy-with-logging,$@,$(BINARY_TARGET_DIR)); \ ingo@3661: else \ ingo@3661: $(CAT) $@.log; \ ingo@3661: $(call remove-temporary-files,'$@.temp'); \ ingo@3661: $(sh_false); \ ingo@3661: fi ingo@3661: ingo@3661: .SECONDARY: $(all_ps_targets) ingo@3661: %.ps: %.dvi %.paper.make ingo@3661: $(QUIET)$(call echo-build,$<,$@) ingo@3661: $(QUIET)$(call make-ps,$<,$@.temp,$@.log,\ ingo@3661: $(firstword $(shell $(CAT) $*.paper.make))); \ ingo@3661: if [ x"$$?" = x"0" ]; then \ ingo@3661: $(if $(VERBOSE),$(CAT) $@.log,:); \ ingo@3661: $(RM) -f '$@'; \ ingo@3661: $(MV) '$@.temp' '$@'; \ ingo@3661: $(TOUCH) '$@'; \ ingo@3661: $(call copy-with-logging,$@,$(BINARY_TARGET_DIR)); \ ingo@3661: else \ ingo@3661: $(CAT) $@.log; \ ingo@3661: $(call remove-temporary-files,'$@.temp'); \ ingo@3661: $(sh_false); \ ingo@3661: fi ingo@3661: endif ingo@3661: ingo@3661: # Build the final target (dvi or pdf) file. This is a very tricky rule because ingo@3661: # of the way that latex runs multiple times, needs graphics after the first run ingo@3661: # (or maybe already has them), and relies on bibliographies or indices that may ingo@3661: # not exist. ingo@3661: # ingo@3661: # Check the log for fatal errors. If they exist, colorize and bail. ingo@3661: # ingo@3661: # Create the .auxtarget.cookie file. (Needed for next time if not present) ingo@3661: # ingo@3661: # If any of the following are true, we must rebuild at least one time: ingo@3661: # ingo@3661: # * the .bbl was recently rebuilt ingo@3661: # ingo@3661: # check a cookie, then delete it ingo@3661: # ingo@3661: # * any of several output files was created or changed: ingo@3661: # ingo@3661: # check $*.run.cookie, then delete it ingo@3661: # ingo@3661: # * the .aux file changed in a way that necessitates attention ingo@3661: # ingo@3661: # Note that if the .auxtarget.make file doesn't exist, this means ingo@3661: # that we are doing a clean build, so it doesn't figure into the ingo@3661: # test for running again. ingo@3661: # ingo@3661: # compare against .auxtarget.make ingo@3661: # ingo@3661: # move if different, remove if not ingo@3661: # ingo@3661: # * the .log file has errors or warnings requiring at least one more run ingo@3661: # ingo@3661: # We use a loop over a single item to simplify the process of breaking ingo@3661: # out when we find one of the conditions to be true. ingo@3661: # ingo@3661: # If we do NOT need to run latex here, then we move the $@.1st.make file ingo@3661: # over to $@ because the target file has already been built by the first ingo@3661: # dependency run and is valid. ingo@3661: # ingo@3661: # If we do, we delete that cookie file and do the normal multiple-runs ingo@3661: # routine. ingo@3661: # ingo@3661: ifneq "$(strip $(BUILD_STRATEGY))" "pdflatex" ingo@3661: .SECONDARY: $(all_dvi_targets) ingo@3661: endif ingo@3661: %.$(build_target_extension): %.bbl %.aux %.$(build_target_extension).1st.make ingo@3661: $(QUIET)\ ingo@3661: fatal=`$(call colorize-latex-errors,$*.log)`; \ ingo@3661: if [ x"$$fatal" != x"" ]; then \ ingo@3661: $(ECHO) "$$fatal"; \ ingo@3661: exit 1; \ ingo@3661: fi; \ ingo@3661: $(call make-auxtarget-file,$*.aux.make,$*.auxtarget.cookie); \ ingo@3661: run=0; \ ingo@3661: for i in 1; do \ ingo@3661: if $(call test-exists,$*.bbl.cookie); then \ ingo@3661: run=1; \ ingo@3661: break; \ ingo@3661: fi; \ ingo@3661: if $(call test-exists,$*.run.cookie); then \ ingo@3661: run=1; \ ingo@3661: break; \ ingo@3661: fi; \ ingo@3661: if $(call \ ingo@3661: test-exists-and-different,$*.auxtarget.cookie,$*.auxtarget.make);\ ingo@3661: then \ ingo@3661: run=1; \ ingo@3661: break; \ ingo@3661: fi; \ ingo@3661: if $(call test-log-for-need-to-run,$*); then \ ingo@3661: run=1; \ ingo@3661: break; \ ingo@3661: fi; \ ingo@3661: done; \ ingo@3661: $(call remove-temporary-files,$*.bbl.cookie $*.run.cookie); \ ingo@3661: $(MV) $*.auxtarget.cookie $*.auxtarget.make; \ ingo@3661: if [ x"$$run" = x"1" ]; then \ ingo@3661: $(call remove-files,$@.1st.make); \ ingo@3661: for i in 2 3 4 5; do \ ingo@3661: $(if $(findstring 3.79,$(MAKE_VERSION)),\ ingo@3661: $(call echo-build,$*.tex,$@,$(RESTARTS)-$$$$i),\ ingo@3661: $(call echo-build,$*.tex,$@,$(RESTARTS)-$$i)\ ingo@3661: ); \ ingo@3661: $(call run-latex,$*); \ ingo@3661: $(CP) '$*.log' '$*.'$(RESTARTS)-$$i'.log'; \ ingo@3661: $(call test-run-again,$*) || break; \ ingo@3661: done; \ ingo@3661: else \ ingo@3661: $(MV) '$@.1st.make' '$@'; \ ingo@3661: fi; \ ingo@3661: $(call copy-with-logging,$@,$(BINARY_TARGET_DIR)); \ ingo@3661: $(call latex-color-log,$*) ingo@3661: ingo@3661: # Build the .bbl file. When dependencies are included, this will (or will ingo@3661: # not!) depend on something.bib, which we detect, acting accordingly. The ingo@3661: # dependency creation also produces the %.auxbbl.make file. BibTeX is a bit ingo@3661: # finicky about what you call the actual files, but we can rest assured that if ingo@3661: # a .auxbbl.make file exists, then the .aux file does, as well. The ingo@3661: # .auxbbl.make file is a cookie indicating whether the .bbl needs to be ingo@3661: # rewritten. It only changes if the .aux file changes in ways relevant to .bbl ingo@3661: # creation. ingo@3661: # ingo@3661: # Note that we do NOT touch the .bbl file if there is no need to ingo@3661: # create/recreate it. We would like to leave existing files alone if they ingo@3661: # don't need to be changed, thus possibly avoiding a rebuild trigger. ingo@3661: %.bbl: %.auxbbl.make ingo@3661: $(QUIET)\ ingo@3661: $(if $(filter %.bib,$^),\ ingo@3661: $(call echo-build,$(filter %.bib,$?) $*.aux,$@); \ ingo@3661: $(call run-bibtex,$*); \ ingo@3661: $(TOUCH) $@.cookie; \ ingo@3661: ) \ ingo@3661: if $(EGREP) -q 'bibstyle.(apacann|chcagoa|[^}]*annot)' '$*.aux'; then \ ingo@3661: $(call echo-build,** annotated extra latex **,output ignored,$(RESTARTS)-1); \ ingo@3661: $(call run-latex,$*); \ ingo@3661: $(CP) '$*.log' '$*.$(RESTARTS)-annotated.log'; \ ingo@3661: $(if $(filter %.bib,$^),\ ingo@3661: $(call echo-build,** annotated extra bibtex ** $(filter %.bib,$?) $*.aux,$@); \ ingo@3661: $(call run-bibtex,$*); \ ingo@3661: $(TOUCH) $@.cookie; \ ingo@3661: ) \ ingo@3661: $(call echo-build,** annotated extra latex **,output ignored,$(RESTARTS)-2); \ ingo@3661: $(call run-latex,$*); \ ingo@3661: fi ingo@3661: ingo@3661: # Create the index file - note that we do *not* depend on %.tex here, since ingo@3661: # that unnecessarily restricts the kinds of indices that we can build to those ingo@3661: # with exactly the same stem as the source file. Things like splitidx create ingo@3661: # idx files with other names. ingo@3661: # ingo@3661: # Therefore, we add the .tex dependency in the sourcestem.d file in the call to ingo@3661: # get index file dependencies from the logs. ingo@3661: %.ind: %.idx ingo@3661: $(QUIET)$(call echo-build,$<,$@) ingo@3661: $(QUIET)$(call run-makeindex,$<,$@,$*.ilg) ingo@3661: ingo@3661: # Create the glossary file ingo@3661: %.gls: %.glo %.tex ingo@3661: $(QUIET)$(call echo-build,$<,$@) ingo@3661: $(QUIET)$(call run-makeindex,$<,$@,$*.glg,-s nomencl.ist) ingo@3661: ingo@3661: # Create the nomenclature file ingo@3661: %.nls: %.nlo %.tex ingo@3661: $(QUIET)$(call echo-build,$<,$@) ingo@3661: $(QUIET)$(call run-makeindex,$<,$@,$*.nlg,-s nomencl.ist) ingo@3661: ingo@3661: # SCRIPTED LaTeX TARGETS ingo@3661: # ingo@3661: # Keep the generated .tex files around for debugging if needed. ingo@3661: .SECONDARY: $(all_tex_targets) ingo@3661: ingo@3661: %.tex:: %.tex.sh ingo@3661: $(QUIET)$(call run-script,$(SHELL),$<,$@) ingo@3661: ingo@3661: %.tex:: %.tex.py ingo@3661: $(QUIET)$(call run-script,$(PYTHON),$<,$@) ingo@3661: ingo@3661: %.tex:: %.tex.pl ingo@3661: $(QUIET)$(call run-script,$(PERL),$<,$@) ingo@3661: ingo@3661: %.tex:: %.rst $(RST_STYLE_FILE) ingo@3661: $(QUIET)\ ingo@3661: $(call run-script,$(RST2LATEX)\ ingo@3661: --documentoptions=letterpaper\ ingo@3661: $(if $(RST_STYLE_FILE),--stylesheet=$(RST_STYLE_FILE),),$<,$@) ingo@3661: ingo@3661: # ingo@3661: # GRAPHICS TARGETS ingo@3661: # ingo@3661: .PHONY: all-graphics ingo@3661: all-graphics: $(all_graphics_targets); ingo@3661: ingo@3661: ifneq "$(strip $(BUILD_STRATEGY))" "pdflatex" ingo@3661: .PHONY: all-pstex ingo@3661: all-pstex: $(all_pstex_targets); ingo@3661: endif ingo@3661: ingo@3661: .PHONY: all-dot2tex ingo@3661: all-dot2tex: $(all_dot2tex_targets); ingo@3661: ingo@3661: .PHONY: show-graphics ingo@3661: show-graphics: all-graphics ingo@3661: $(VIEW_GRAPHICS) $(all_known_graphics) ingo@3661: ingo@3661: $(gray_eps_file): ingo@3661: $(QUIET)$(call echo-build,$^,$@) ingo@3661: $(QUIET)$(call create-gray-eps-file,$@) ingo@3661: ingo@3661: ifeq "$(strip $(BUILD_STRATEGY))" "pdflatex" ingo@3661: %.pdf: %.eps $(if $(GRAY),$(gray_eps_file)) ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-eps-to-pdf,$<,$@,$(GRAY)) ingo@3661: ingo@3661: ifeq "$(strip $(GNUPLOT_OUTPUT_EXTENSION))" "pdf" ingo@3661: %.pdf: %.gpi %.gpi.d $(gpi_sed) ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-gpi,$<,$@,$(GRAY)) ingo@3661: endif ingo@3661: ingo@3661: %.pdf: %.fig ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-fig,$<,$@,$(GRAY)) ingo@3661: ingo@3661: endif ingo@3661: ingo@3661: %.eps: %.gpi %.gpi.d $(gpi_sed) ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-gpi,$<,$@,$(GRAY)) ingo@3661: ingo@3661: %.eps: %.fig ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-fig,$<,$@,$(GRAY)) ingo@3661: ingo@3661: %.eps: %.dot $(if $(GRAY),$(gray_eps_file)) ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-dot,$<,$@,$<.log,$(GRAY)) ingo@3661: ingo@3661: %.eps: %.xvg $(if $(GRAY),$(gray_eps_file)) ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-xvg,$<,$@,$(GRAY)) ingo@3661: ingo@3661: %.eps: %.svg $(if $(GRAY),$(gray_eps_file)) ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-svg,$<,$@,$(GRAY)) ingo@3661: ingo@3661: %.eps: %.jpg $(if $(GRAY),$(gray_eps_file)) ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-jpg,$<,$@,$(GRAY)) ingo@3661: ingo@3661: %.eps: %.png $(if $(GRAY),$(gray_eps_file)) ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-png,$<,$@,$(GRAY)) ingo@3661: ingo@3661: %.eps: %.eps.gz $(if $(GRAY),$(gray_eps_file)) ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-epsgz,$<,$@,$(GRAY)) ingo@3661: ingo@3661: %.pstex: %.fig ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-fig-pstex,$<,$@,$(GRAY)) ingo@3661: ingo@3661: %.pstex_t: %.fig %.pstex ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-fig-pstex-t,$<,$@,$*.pstex,$(GRAY)) ingo@3661: ingo@3661: %.dot_t: %.dot ingo@3661: $(QUIET)$(call echo-graphic,$^,$@) ingo@3661: $(QUIET)$(call convert-dot-tex,$<,$@) ingo@3661: ingo@3661: # ingo@3661: # DEPENDENCY-RELATED TARGETS. ingo@3661: # ingo@3661: ingo@3661: # Generate all of the information needed to get dependencies ingo@3661: # As a side effect, this creates a .dvi or .pdf file (depending on the build ingo@3661: # strategy). We need to be sure to remove it if there are errors. Errors can ingo@3661: # take several forms and all of them are found within the log file: ingo@3661: # * There was a LaTeX error ingo@3661: # * A needed file was not found ingo@3661: # * Cross references need adjustment ingo@3661: # ingo@3661: # Behavior: ingo@3661: # This rule is responsible for generating the following: ingo@3661: # %.aux ingo@3661: # %.d ingo@3661: # %.aux.make ingo@3661: # %.(pdf|dvi).1st.make (the .pdf or .dvi output file, moved) ingo@3661: # ingo@3661: # Steps: ingo@3661: # ingo@3661: # Run latex ingo@3661: # Move .pdf or .dvi somewhere else (make no judgements about success) ingo@3661: # Flatten the .aux file into another file ingo@3661: # Add source dependencies ingo@3661: # Add graphic dependencies ingo@3661: # Add bib dependencies ingo@3661: # ingo@3661: # Create cookies for various suffixes that may represent files that ingo@3661: # need to be read by LaTeX in order for it to function properly. ingo@3661: # ingo@3661: # Note that if some of the dependencies are discovered because they turn ingo@3661: # up missing in the log file, we really need the .d file to be reloaded. ingo@3661: # Adding a sleep command helps with this. Otherwise make is extremely ingo@3661: # nondeterministic, sometimes working, sometimes not. ingo@3661: # ingo@3661: # Usually we can force this by simply removing the generated pdf file and ingo@3661: # not creating a .1st.make file.. ingo@3661: # ingo@3661: %.$(build_target_extension).1st.make %.d %.aux %.aux.make %.fls: %.tex ingo@3661: $(QUIET)$(call echo-build,$<,$*.d $*.$(build_target_extension).1st.make,$(RESTARTS)-1) ingo@3661: $(QUIET)\ ingo@3661: $(call run-latex,$<,--recorder) || $(sh_true); \ ingo@3661: $(CP) '$*.log' '$*.$(RESTARTS)-1.log'; \ ingo@3661: $(call die-on-dot2tex,$*.log); \ ingo@3661: $(call die-on-no-aux,$*); \ ingo@3661: $(call flatten-aux,$*.aux,$*.aux.make); \ ingo@3661: $(ECHO) "# vim: ft=make" > $*.d; \ ingo@3661: $(ECHO) ".PHONY: $*._graphics" >> $*.d; \ ingo@3661: $(call get-inputs,$*.fls,$(addprefix $*.,aux aux.make d $(build_target_extension))) >> $*.d; \ ingo@3661: $(call get-missing-inputs,$*.log,$(addprefix $*.,aux aux.make d $(build_target_extension))) >> $*.d; \ ingo@3661: $(ECHO) ".SECONDEXPANSION:" >> $*.d; \ ingo@3661: $(call get-graphics,$*) >> $*.d; \ ingo@3661: $(call get-log-index,$*,$(addprefix $*.,d aux aux.make)) >> $*.d; \ ingo@3661: $(call get-bibs,$*.aux.make,$(addprefix $*.,bbl aux aux.make)) >> $*.d; \ ingo@3661: $(EGREP) -q "# MISSING" $*.d && $(SLEEP) 1 && $(RM) $*.pdf; \ ingo@3661: $(call move-if-exists,$*.$(build_target_extension),$*.$(build_target_extension).1st.make); \ ingo@3661: for s in toc out lot lof lol nav; do \ ingo@3661: if [ -e "$*.$$s" ]; then \ ingo@3661: if ! $(DIFF) -q $*.$$s $*.$$s.make >/dev/null 2>&1; then \ ingo@3661: $(TOUCH) $*.run.cookie; \ ingo@3661: fi; \ ingo@3661: $(CP) $*.$$s $*.$$s.make; \ ingo@3661: fi; \ ingo@3661: done ingo@3661: ingo@3661: # This is a cookie that is updated if the flattened aux file has changed in a ingo@3661: # way that affects the bibliography generation. ingo@3661: .SECONDARY: $(addsuffix .auxbbl.make,$(stems_ssg)) ingo@3661: %.auxbbl.make: %.aux.make ingo@3661: $(QUIET)\ ingo@3661: $(call make-auxbbl-file,$<,$@.temp); \ ingo@3661: $(call replace-if-different-and-remove,$@.temp,$@) ingo@3661: ingo@3661: # Build a dependency file for .gpi files. These often plot data files that ingo@3661: # also reside in the directory, so if a data file changes, it's nice to know ingo@3661: # about it. This also handles loaded .gpi files, whose filename should have ingo@3661: # _include_. in it. ingo@3661: %.gpi.d: %.gpi ingo@3661: $(QUIET)$(call echo-build,$<,$@) ingo@3661: $(QUIET)$(call make-gpi-d,$<,$@) ingo@3661: ingo@3661: # Store the paper size for this document -- note that if beamer is used we set ingo@3661: # it to the special BEAMER paper size. We only do this, however, if the ingo@3661: # special comment exists, in which case we enlarge the output with psnup. ingo@3661: # ingo@3661: # The paper size is extracted from a documentclass attribute. ingo@3661: %.paper.make: %.tex ingo@3661: $(QUIET)$(SED) \ ingo@3661: -e '/\\documentclass/,/}/{' \ ingo@3661: -e ' s/%.*//' \ ingo@3661: -e ' H' \ ingo@3661: -e ' /}/{' \ ingo@3661: -e ' s/.*//' \ ingo@3661: -e ' x' \ ingo@3661: -e ' /\\documentclass/!d' \ ingo@3661: -e ' s/[\n[:space:]]*//g' \ ingo@3661: -e ' s/\([,{[]\)\([[:alnum:]]\{1,\}\)paper\([],}]\)/\1%-\2-%\3/g' \ ingo@3661: -e ' s/\([,{[]\)\(landscape\)\([],}]\)/\1%-\2-%\3/g' \ ingo@3661: -e ' s/^[^%]*%-//' \ ingo@3661: -e ' s/-%[^%]*$$//' \ ingo@3661: -e ' s/-%[^%]%-/ /g' \ ingo@3661: -e ' p' \ ingo@3661: -e ' }' \ ingo@3661: -e ' d' \ ingo@3661: -e '}' \ ingo@3661: -e 'd' \ ingo@3661: $< > $@; \ ingo@3661: $(EGREP) -q '^[^%]*\\documentclass[^{]*{beamer}' $< && \ ingo@3661: (\ ingo@3661: $(EGREP) -q '^%%[[:space:]]*BEAMER[[:space:]]*LARGE$$' $< && \ ingo@3661: $(ECHO) "BEAMER" > $@ || \ ingo@3661: : > $@ \ ingo@3661: ) || $(sh_true) ingo@3661: ingo@3661: # Store embedding instructions for this document using a special comment ingo@3661: %.embed.make: %.tex ingo@3661: $(QUIET)$(EGREP) '^%%[[:space:]]*NO[[:space:]]*EMBED[[:space:]]*$$' $< \ ingo@3661: && $(ECHO) '' > $@ \ ingo@3661: || $(ECHO) '1' > $@; ingo@3661: ingo@3661: # ingo@3661: # HELPFUL PHONY TARGETS ingo@3661: # ingo@3661: ingo@3661: .PHONY: _all_programs ingo@3661: _all_programs: ingo@3661: $(QUIET)$(ECHO) "== All External Programs Used ==" ingo@3661: $(QUIET)$(call output-all-programs) ingo@3661: ingo@3661: .PHONY: _check_programs ingo@3661: _check_programs: ingo@3661: $(QUIET)$(ECHO) "== Checking Makefile Dependencies =="; $(ECHO) ingo@3661: $(QUIET) \ ingo@3661: $(ECHO) hi; \ ingo@3661: allprogs=`\ ingo@3661: ($(call output-all-programs)) | \ ingo@3661: $(SED) \ ingo@3661: -e 's/^[[:space:]]*//' \ ingo@3661: -e '/^#/d' \ ingo@3661: -e 's/[[:space:]]*#.*//' \ ingo@3661: -e '/^=/s/[[:space:]]/_/g' \ ingo@3661: -e '/^[[:space:]]*$$/d' \ ingo@3661: -e 's/^[^=].*=[[:space:]]*\([^[:space:]]\{1,\}\).*$$/\\1/' \ ingo@3661: `; \ ingo@3661: spaces=' '; \ ingo@3661: for p in $${allprogs}; do \ ingo@3661: case $$p in \ ingo@3661: =*) $(ECHO); $(ECHO) "$$p";; \ ingo@3661: *) \ ingo@3661: $(ECHO) -n "$$p:$$spaces" | $(SED) -e 's/^\(.\{0,20\}\).*$$/\1/'; \ ingo@3661: loc=`$(WHICH) $$p`; \ ingo@3661: if [ x"$$?" = x"0" ]; then \ ingo@3661: $(ECHO) "$(C_SUCCESS)Found:$(C_RESET) $$loc"; \ ingo@3661: else \ ingo@3661: $(ECHO) "$(C_FAILURE)Not Found$(C_RESET)"; \ ingo@3661: fi; \ ingo@3661: ;; \ ingo@3661: esac; \ ingo@3661: done ingo@3661: ingo@3661: .PHONY: _check_gpi_files ingo@3661: _check_gpi_files: ingo@3661: $(QUIET)$(ECHO) "== Checking all .gpi files for common errors =="; \ ingo@3661: $(ECHO); \ ingo@3661: for f in $(files.gpi); do \ ingo@3661: result=`$(EGREP) '^([^#]*set terminal |set output )' $$f`; \ ingo@3661: $(ECHO) -n "$$f: "; \ ingo@3661: if [ x"$$result" = x"" ]; then \ ingo@3661: $(ECHO) "$(C_SUCCESS)Okay$(C_RESET)"; \ ingo@3661: else \ ingo@3661: $(ECHO) "$(C_FAILURE)Warning: Problematic commands:$(C_RESET)";\ ingo@3661: $(ECHO) "$(C_ERROR)$$result$(C_RESET)"; \ ingo@3661: fi; \ ingo@3661: done; \ ingo@3661: $(ECHO) ingo@3661: ingo@3661: .PHONY: _all_stems ingo@3661: _all_stems: ingo@3661: $(QUIET)$(ECHO) "== All Stems ==" ingo@3661: $(QUIET)$(call echo-list,$(sort $(default_stems_ss))) ingo@3661: ingo@3661: .PHONY: _includes ingo@3661: _includes: ingo@3661: $(QUIET)$(ECHO) "== Include Stems ==" ingo@3661: $(QUIET)$(ECHO) "=== Sources ===" ingo@3661: $(QUIET)$(call echo-list,$(sort $(source_includes))) ingo@3661: $(QUIET)$(ECHO) "=== Graphics ===" ingo@3661: $(QUIET)$(call echo-list,$(sort $(graphic_includes))) ingo@3661: ingo@3661: .PHONY: _all_sources ingo@3661: _all_sources: ingo@3661: $(QUIET)$(ECHO) "== All Sources ==" ingo@3661: $(QUIET)$(call echo-list,$(sort $(all_files.tex))) ingo@3661: ingo@3661: .PHONY: _dependency_graph ingo@3661: _dependency_graph: ingo@3661: $(QUIET)$(ECHO) "/* LaTeX Dependency Graph */" ingo@3661: $(QUIET)$(call output-dependency-graph) ingo@3661: ingo@3661: .PHONY: _show_dependency_graph ingo@3661: _show_dependency_graph: ingo@3661: $(QUIET)$(call output-dependency-graph,$(graph_stem).dot) ingo@3661: $(QUIET)$(DOT) -Tps -o $(graph_stem).eps $(graph_stem).dot ingo@3661: $(QUIET)$(VIEW_POSTSCRIPT) $(graph_stem).eps ingo@3661: $(QUIET)$(call remove-temporary-files,$(graph_stem).*) ingo@3661: ingo@3661: .PHONY: _sources ingo@3661: _sources: ingo@3661: $(QUIET)$(ECHO) "== Sources ==" ingo@3661: $(QUIET)$(call echo-list,$(sort $(files.tex))) ingo@3661: ingo@3661: .PHONY: _scripts ingo@3661: _scripts: ingo@3661: $(QUIET)$(ECHO) "== Scripts ==" ingo@3661: $(QUIET)$(call echo-list,$(sort $(files_scripts))) ingo@3661: ingo@3661: .PHONY: _graphic_outputs ingo@3661: _graphic_outputs: ingo@3661: $(QUIET)$(ECHO) "== Graphic Outputs ==" ingo@3661: $(QUIET)$(call echo-list,$(sort $(all_graphics_targets))) ingo@3661: ingo@3661: .PHONY: _env ingo@3661: _env: ingo@3661: ifdef .VARIABLES ingo@3661: $(QUIET)$(ECHO) "== MAKE VARIABLES ==" ingo@3661: $(QUIET)$(call echo-list,$(foreach var,$(sort $(.VARIABLES)),'$(var)')) ingo@3661: endif ingo@3661: $(QUIET)$(ECHO) "== ENVIRONMENT ==" ingo@3661: $(QUIET)$(ENV) ingo@3661: ingo@3661: # ingo@3661: # CLEAN TARGETS ingo@3661: # ingo@3661: # clean-generated is somewhat unique - it relies on the .fls file being ingo@3661: # properly built so that it can determine which of the files was generated, and ingo@3661: # which was not. Expect it to silently fail if the .fls file is missing. ingo@3661: # ingo@3661: # This is used to, e.g., clean up index files that are generated by the LaTeX. ingo@3661: .PHONY: clean-generated ingo@3661: clean-generated: ingo@3661: $(QUIET)$(call clean-files,$(foreach e,$(addsuffix .fls,$(all_stems_source)),\ ingo@3661: $(shell $(call get-generated-names,$e)))) ingo@3661: ingo@3661: .PHONY: clean-deps ingo@3661: clean-deps: ingo@3661: $(QUIET)$(call clean-files,$(all_d_targets) *.make *.make.temp *.cookie) ingo@3661: ingo@3661: .PHONY: clean-tex ingo@3661: clean-tex: clean-deps ingo@3661: $(QUIET)$(call clean-files,$(rm_tex)) ingo@3661: ingo@3661: .PHONY: clean-graphics ingo@3661: # TODO: This *always* deletes pstex files, even if they were not generated by ingo@3661: # anything.... In other words, if you create a pstex and pstex_t pair by hand ingo@3661: # an drop them in here without the generating fig file, they will be deleted ingo@3661: # and you won't get them back. It's a hack put in here because I'm not sure we ingo@3661: # even want to keep pstex functionality, so my motivation is not terribly high ingo@3661: # for doing it right. ingo@3661: clean-graphics: ingo@3661: $(QUIET)$(call clean-files,$(all_graphics_targets) $(intermediate_graphics_targets) *.gpi.d *.pstex *.pstex_t *.dot_t) ingo@3661: ingo@3661: .PHONY: clean-backups ingo@3661: clean-backups: ingo@3661: $(QUIET)$(call clean-files,$(backup_patterns) *.temp) ingo@3661: ingo@3661: .PHONY: clean-auxiliary ingo@3661: clean-auxiliary: ingo@3661: $(QUIET)$(call clean-files,$(graph_stem).*) ingo@3661: ingo@3661: .PHONY: clean-nographics ingo@3661: clean-nographics: clean-tex clean-deps clean-backups clean-auxiliary ; ingo@3661: ingo@3661: .PHONY: clean ingo@3661: clean: clean-generated clean-tex clean-graphics clean-deps clean-backups clean-auxiliary ingo@3661: ingo@3661: # ingo@3661: # HELP TARGETS ingo@3661: # ingo@3661: ingo@3661: .PHONY: help ingo@3661: help: ingo@3661: $(help_text) ingo@3661: ingo@3661: .PHONY: version ingo@3661: version: ingo@3661: $(QUIET)\ ingo@3661: $(ECHO) "$(fileinfo) Version $(version)"; \ ingo@3661: $(ECHO) "by $(author)"; \ ingo@3661: ingo@3661: # ingo@3661: # HELP TEXT ingo@3661: # ingo@3661: ingo@3661: define help_text ingo@3661: # $(fileinfo) Version $(version) ingo@3661: # ingo@3661: # by $(author) ingo@3661: # ingo@3661: # Generates a number of possible output files from a LaTeX document and its ingo@3661: # various dependencies. Handles .bib files, \include and \input, and .eps ingo@3661: # graphics. All dependencies are handled automatically by running LaTeX over ingo@3661: # the source. ingo@3661: # ingo@3661: # USAGE: ingo@3661: # ingo@3661: # make [GRAY=1] [VERBOSE=1] [SHELL_DEBUG=1] <target(s)> ingo@3661: # ingo@3661: # STANDARD OPTIONS: ingo@3661: # GRAY: ingo@3661: # Setting this variable forces all recompiled graphics to be grayscale. ingo@3661: # It is useful when creating a document for printing. The default is ingo@3661: # to allow colors. Note that it only changes graphics that need to be ingo@3661: # rebuilt! It is usually a good idea to do a 'make clean' first. ingo@3661: # ingo@3661: # VERBOSE: ingo@3661: # This turns off all @ prefixes for commands invoked by make. Thus, ingo@3661: # you get to see all of the gory details of what is going on. ingo@3661: # ingo@3661: # SHELL_DEBUG: ingo@3661: # This enables the -x option for sh, meaning that everything it does is ingo@3661: # echoed to stderr. This is particularly useful for debugging ingo@3661: # what is going on in $$(shell ...) invocations. One of my favorite ingo@3661: # debugging tricks is to do this: ingo@3661: # ingo@3661: # make -d SHELL_DEBUG=1 VERBOSE=1 2>&1 | less ingo@3661: # ingo@3661: # STANDARD AUXILIARY FILES: ingo@3661: # ingo@3661: # Makefile.ini ingo@3661: # ingo@3661: # This file can contain variable declarations that override various ingo@3661: # aspects of the makefile. For example, one might specify ingo@3661: # ingo@3661: # neverclean := *.pdf *.ps ingo@3661: # onlysources.tex := main.tex ingo@3661: # LATEX_COLOR_WARNING := 'bold red uline' ingo@3661: # ingo@3661: # And this would override the neverclean setting to ensure that pdf ingo@3661: # and ps files always remain behind, set the makefile to treat all ingo@3661: # .tex files that are not "main.tex" as includes (and therefore not ingo@3661: # default targets). It also changes the LaTeX warning output to be ingo@3661: # red, bold, and underlined. ingo@3661: # ingo@3661: # There are numerous variables in this file that can be overridden in ingo@3661: # this way. Search for '?=' to find them all. ingo@3661: # ingo@3661: # Also, you can put arbitrary targets into it if, for example, you ingo@3661: # want your source built from something else, e.g.: ingo@3661: # ingo@3661: # generated.tex: generating_script.weird_lang depA depB ingo@3661: # ./generating_script.weird_lang > $$@ ingo@3661: # ingo@3661: # Note that if you are not careful, you can override the default ingo@3661: # target (what happens when you type "make" without arguments), so if ingo@3661: # you do use Makefile.ini, you probably want to start it with ingo@3661: # something like the following line: ingo@3661: # ingo@3661: # default: all ingo@3661: # ingo@3661: # Since the first target in any makefile is automatically the default, ingo@3661: # and the makefile already has a sensible "all" target, this will do ingo@3661: # what you want. ingo@3661: # ingo@3661: # The Makefile.ini is imported before *anything else* is done, so go ingo@3661: # wild with your ideas for changes to this makefile in there. It ingo@3661: # makes it easy to test them before submitting patches. ingo@3661: # ingo@3661: # STANDARD ENVIRONMENT VARIABLES: ingo@3661: # ingo@3661: # LATEX_COLOR_WARNING '$(LATEX_COLOR_WARNING)' ingo@3661: # LATEX_COLOR_ERROR '$(LATEX_COLOR_ERROR)' ingo@3661: # LATEX_COLOR_UNDERFULL '$(LATEX_COLOR_UNDERFULL)' ingo@3661: # LATEX_COLOR_OVERFULL '$(LATEX_COLOR_OVERFULL)' ingo@3661: # LATEX_COLOR_PAGES '$(LATEX_COLOR_PAGES)' ingo@3661: # LATEX_COLOR_BUILD '$(LATEX_COLOR_BUILD)' ingo@3661: # LATEX_COLOR_GRAPHIC '$(LATEX_COLOR_GRAPHIC)' ingo@3661: # LATEX_COLOR_DEP '$(LATEX_COLOR_DEP)' ingo@3661: # LATEX_COLOR_SUCCESS '$(LATEX_COLOR_SUCCESS)' ingo@3661: # LATEX_COLOR_FAILURE '$(LATEX_COLOR_FAILURE)' ingo@3661: # ingo@3661: # These may be redefined in your environment to be any of the following: ingo@3661: # ingo@3661: # black ingo@3661: # red ingo@3661: # green ingo@3661: # yellow ingo@3661: # blue ingo@3661: # magenta ingo@3661: # cyan ingo@3661: # white ingo@3661: # ingo@3661: # Bold or underline may be used, as well, either alone or in combination ingo@3661: # with colors: ingo@3661: # ingo@3661: # bold ingo@3661: # uline ingo@3661: # ingo@3661: # Order is not important. You may want, for example, to specify: ingo@3661: # ingo@3661: # export LATEX_COLOR_SUCCESS='bold blue uline' ingo@3661: # ingo@3661: # in your .bashrc file. I don't know why, but you may want to. ingo@3661: # ingo@3661: # STANDARD TARGETS: ingo@3661: # ingo@3661: # all: ingo@3661: # Make all possible documents in this directory. The documents are ingo@3661: # determined by scanning for .tex and .tex.sh (described in more detail ingo@3661: # later) and omitting any file that ends in ._include_.tex or ingo@3661: # ._nobuild_.tex. The output is a set of .pdf files. ingo@3661: # ingo@3661: # If you wish to omit files without naming them with the special ingo@3661: # underscore names, set the following near the top of the Makefile, ingo@3661: # or (this is recommended) within a Makefile.ini in the same directory: ingo@3661: # ingo@3661: # includes.tex := file1.tex file2.tex ingo@3661: # ingo@3661: # This will cause the files listed to be considered as include files. ingo@3661: # ingo@3661: # If you have only few source files, you can set ingo@3661: # ingo@3661: # onlysources.tex := main.tex ingo@3661: # ingo@3661: # This will cause only the source files listed to be considered in ingo@3661: # dependency detection. All other .tex files will be considered as ingo@3661: # include files. Note that these options work for *any* source type, ingo@3661: # so you could do something similar with includes.gpi, for example. ingo@3661: # Note that this works for *any valid source* target. All of the ingo@3661: # onlysources.* variables are commented out in the shipping version of ingo@3661: # this file, so it does the right thing when they simply don't exist. ingo@3661: # The comments are purely documentation. If you know, for example, that ingo@3661: # file.mycoolformat is supported by this Makefile, but don't see the ingo@3661: # "onlysources.mycoolformat" declared in the comments, that doesn't mean ingo@3661: # you can't use it. Go ahead and set "onlysources.mycoolformat" and it ingo@3661: # should do the right thing. ingo@3661: # ingo@3661: # show: ingo@3661: # Builds and displays all documents in this directory. It uses the ingo@3661: # environment-overridable value of VIEW_PDF (currently $(VIEW_PDF)) to ingo@3661: # do its work. ingo@3661: # ingo@3661: # all-graphics: ingo@3661: # Make all of the graphics in this directory. ingo@3661: # ingo@3661: # all-pstex (only for BUILD_STRATEGY=latex): ingo@3661: # Build all fig files into pstex and pstex_t files. Gray DOES NOT WORK. ingo@3661: # ingo@3661: # all-gray-pstex (only for BUILD_STRATEGY=latex): ingo@3661: # Build all fig files into grayscale pstex and pstex_t files. ingo@3661: # ingo@3661: # all-dot2tex: ingo@3661: # Build all dot files into tex files. ingo@3661: # ingo@3661: # show-graphics: ingo@3661: # Builds and displays all graphics in this directory. Uses the ingo@3661: # environment-overridable value of VIEW_GRAPHICS (currently ingo@3661: # $(VIEW_GRAPHICS)) to do its work. ingo@3661: # ingo@3661: # clean: ingo@3661: # Remove ALL generated files, leaving only source intact. ingo@3661: # This will *always* skip files mentioned in the "neverclean" variable, ingo@3661: # either in this file or specified in Makefile.ini: ingo@3661: # ingo@3661: # neverclean := *.pdf *.ps ingo@3661: # ingo@3661: # The neverclean variable works on all "clean" targets below, as well. ingo@3661: # ingo@3661: # clean-graphics: ingo@3661: # Remove all generated graphics files. ingo@3661: # ingo@3661: # clean-backups: ingo@3661: # Remove all backup files: $(backup_patterns) ingo@3661: # (XFig and other editors have a nasty habit of leaving them around) ingo@3661: # Also removes Makefile-generated .temp files ingo@3661: # ingo@3661: # clean-tex: ingo@3661: # Remove all files generated from LaTeX invocations except dependency ingo@3661: # information. Leaves graphics alone. ingo@3661: # ingo@3661: # clean-deps: ingo@3661: # Removes all auto-generated dependency information. ingo@3661: # ingo@3661: # clean-auxiliary: ingo@3661: # Removes extra files created by various targets (like the dependency ingo@3661: # graph output). ingo@3661: # ingo@3661: # clean-nographics: ingo@3661: # Cleans everything *except* the graphics files. ingo@3661: # ingo@3661: # help: ingo@3661: # This help text. ingo@3661: # ingo@3661: # version: ingo@3661: # Version information about this LaTeX makefile. ingo@3661: # ingo@3661: # DEBUG TARGETS: ingo@3661: # ingo@3661: # _all_programs: ingo@3661: # A list of the programs used by this makefile. ingo@3661: # ingo@3661: # _check_programs: ingo@3661: # Checks your system for the needed software and reports what it finds. ingo@3661: # ingo@3661: # _check_gpi_files: ingo@3661: # Checks the .gpi files in the current directory for common errors, such ingo@3661: # as specification of the terminal or output file inside of the gpi file ingo@3661: # itself. ingo@3661: # ingo@3661: # _dependency_graph: ingo@3661: # Outputs a .dot file to stdout that represents a graph of LaTeX ingo@3661: # dependencies. To see it, use the _show_dependency_graph target or ingo@3661: # direct the output to a file, run dot on it, and view the output, e.g.: ingo@3661: # ingo@3661: # make _dependency_graph > graph.dot ingo@3661: # dot -T ps -o graph.eps graph.dot ingo@3661: # gv graph.eps ingo@3661: # ingo@3661: # _show_dependency_graph: ingo@3661: # Makes viewing the graph simple: extracts, builds and displays the ingo@3661: # dependency graph given in the _dependency_graph target using the value ingo@3661: # of the environment-overridable VIEW_POSTSCRIPT variable (currently set ingo@3661: # to $(VIEW_POSTSCRIPT)). The postscript viewer is used because it ingo@3661: # makes it easier to zoom in on the graph, a critical ability for ingo@3661: # something so dense and mysterious. ingo@3661: # ingo@3661: # _all_sources: ingo@3661: # List all .tex files in this directory. ingo@3661: # ingo@3661: # _sources: ingo@3661: # Print out a list of all compilable sources in this directory. This is ingo@3661: # useful for determining what make thinks it will be using as the ingo@3661: # primary source for 'make all'. ingo@3661: # ingo@3661: # _scripts: ingo@3661: # Print out a list of scripts that make knows can be used to generate ingo@3661: # .tex files (described later). ingo@3661: # ingo@3661: # _all_stems: ingo@3661: # Print a list of stems. These represent bare targets that can be ingo@3661: # executed. Listing <stem> as a bare target will produce <stem>.pdf. ingo@3661: # ingo@3661: # _includes: ingo@3661: # A list of .d files that would be included in this run if _includes ingo@3661: # weren't specified. This target may be used alone or in conjunction ingo@3661: # with other targets. ingo@3661: # ingo@3661: # _graphic_outputs: ingo@3661: # A list of all generated .eps files ingo@3661: # ingo@3661: # _env: ingo@3661: # A list of environment variables and their values. If supported by ingo@3661: # your version of make, also a list of variables known to make. ingo@3661: # ingo@3661: # FILE TARGETS: ingo@3661: # ingo@3661: # %, %.pdf: ingo@3661: # Build a PDF file from the corresponding %.tex file. ingo@3661: # ingo@3661: # If BUILD_STRATEGY=pdflatex, then this builds the pdf directly. ingo@3661: # Otherwise, it uses this old-school but effective approach: ingo@3661: # ingo@3661: # latex -> dvips -> ps2pdf ingo@3661: # ingo@3661: # The BUILD_STRATEGY can be overridden in Makefile.ini in the same ingo@3661: # directory. The default is pdflatex. ingo@3661: # ingo@3661: # Reasons for using latex -> dvips include the "psfrag" package, and the ingo@3661: # generation of postscript instead of PDF. Arguments for using pdflatex ingo@3661: # include "new and shiny" and "better supported." I can't argue with ingo@3661: # either of those, and supporting them both didn't turn out to be that ingo@3661: # difficult, so there you have it. Choices. ingo@3661: # ingo@3661: # %._show: ingo@3661: # A phony target that builds the pdf file and then displays it using the ingo@3661: # environment-overridable value of VIEW_PDF ($(VIEW_PDF)). ingo@3661: # ingo@3661: # %._graphics: ingo@3661: # A phony target that generates all graphics on which %.pdf (or %.dvi) ingo@3661: # depends. ingo@3661: # ingo@3661: # %.ps (only for BUILD_STRATEGY=latex): ingo@3661: # Build a Postscript file from the corresponding %.tex file. ingo@3661: # This is done using dvips. Paper size is automatically ingo@3661: # extracted from the declaration ingo@3661: # ingo@3661: # \documentclass[<something>paper] ingo@3661: # ingo@3661: # or it is the system default. ingo@3661: # ingo@3661: # If using beamer (an excellent presentation class), the paper ingo@3661: # size is ignored. More on this later. ingo@3661: # ingo@3661: # %.dvi (only for BUILD_STRATEGY=latex): ingo@3661: # Build the DVI file from the corresponding %.tex file. ingo@3661: # ingo@3661: # %.ind: ingo@3661: # Build the index for this %.tex file. ingo@3661: # ingo@3661: # %.gls: ingo@3661: # Build the nomenclature glossary for this %.tex file. ingo@3661: # ingo@3661: # %.nls: ingo@3661: # Build the (newer) nomenclature file for this %.tex file. ingo@3661: # ingo@3661: # %.eps: ingo@3661: # Build an eps file from one of the following file types: ingo@3661: # ingo@3661: # .dot : graphviz ingo@3661: # .gpi : gnuplot ingo@3661: # .fig : xfig ingo@3661: # .xvg : xmgrace ingo@3661: # .svg : scalable vector graphics (goes through inkscape) ingo@3661: # .png : png (goes through NetPBM) ingo@3661: # .jpg : jpeg (goes through ImageMagick) ingo@3661: # .eps.gz : gzipped eps ingo@3661: # ingo@3661: # The behavior of this makefile with each type is described in ingo@3661: # its own section below. ingo@3661: # ingo@3661: # %.pstex{,_t} (only for BUILD_STRATEGY=latex): ingo@3661: # Build a .pstex_t file from a .fig file. ingo@3661: # ingo@3661: # FEATURES: ingo@3661: # ingo@3661: # Optional Binary Directory: ingo@3661: # If you create the _out_ directory in the same place as the makefile, ingo@3661: # it will automatically be used as a dumping ground for .pdf (or .dvi, ingo@3661: # .ps, and .pdf) output files. ingo@3661: # ingo@3661: # Alternatively, you can set the BINARY_TARGET_DIR variable, either as a ingo@3661: # make argument or in Makefile.ini, to point to your directory of ingo@3661: # choice. Note that no pathname wildcard expansion is done in the ingo@3661: # makefile, so make sure that the path is complete before going in ingo@3661: # there. E.g., if you want to specify something in your home directory, ingo@3661: # use $$HOME/ instead of ~/ so that the shell expands it before it gets ingo@3661: # to the makefile. ingo@3661: # ingo@3661: # External Program Dependencies: ingo@3661: # Every external program used by the makefile is represented by an ingo@3661: # ALLCAPS variable at the top of this file. This should allow you to ingo@3661: # make judgments about whether your system supports the use of this ingo@3661: # makefile. The list is available in the ALL_PROGRAMS variable and, ingo@3661: # provided that you are using GNU make 3.80 or later (or you haven't ingo@3661: # renamed this file to something weird like "mylatexmakefile" and like ingo@3661: # invoking it with make -f) can be viewed using ingo@3661: # ingo@3661: # make _all_programs ingo@3661: # ingo@3661: # Additionally, the availability of these programs can be checked ingo@3661: # automatically for you by running ingo@3661: # ingo@3661: # make _check_programs ingo@3661: # ingo@3661: # The programs are categorized according to how important they are and ingo@3661: # what function they perform to help you decide which ones you really ingo@3661: # need. ingo@3661: # ingo@3661: # Colorized Output: ingo@3661: # The output of commands is colorized to highlight things that are often ingo@3661: # important to developers. This includes {underfull,overfull} ingo@3661: # {h,v}boxes, general LaTeX Errors, each stage of document building, and ingo@3661: # the number of pages in the final document. The colors are obtained ingo@3661: # using 'tput', so colorization should work pretty well on any terminal. ingo@3661: # ingo@3661: # The colors can be customized very simply by setting any of the ingo@3661: # LATEX_COLOR_<CONTEXT> variables in your environment (see above). ingo@3661: # ingo@3661: # Predecessors to TeX Files: ingo@3661: # Given a target <target>, if no <target>.tex file exists but a ingo@3661: # corresponding script or predecessor file exists, then appropriate ingo@3661: # action will be taken to generate the tex file. ingo@3661: # ingo@3661: # Currently supported script or predecessor languages are: ingo@3661: # ingo@3661: # sh: %.tex.sh ingo@3661: # perl: %.tex.pl ingo@3661: # python: %.tex.py ingo@3661: # ingo@3661: # Calls the script using the appropriate interpreter, assuming that ingo@3661: # its output is a .tex file. ingo@3661: # ingo@3661: # The script is called thus: ingo@3661: # ingo@3661: # <interpreter> <script file name> <target tex file> ingo@3661: # ingo@3661: # and therefore sees exactly one parameter: the name of the .tex ingo@3661: # file that it is to create. ingo@3661: # ingo@3661: # Why does this feature exist? I ran into this while working on ingo@3661: # my paper dissertation. I wrote a huge bash script that used a ingo@3661: # lot of sed to bring together existing papers in LaTeX. It ingo@3661: # would have been nice had I had something like this to make my ingo@3661: # life easier, since as it stands I have to run the script and ingo@3661: # then build the document with make. This feature provides hooks ingo@3661: # for complicated stuff that you may want to do, but that I have ingo@3661: # not considered. It should work fine with included dependencies, ingo@3661: # too. ingo@3661: # ingo@3661: # Scripts are run every time make is invoked. Some trickery is ingo@3661: # employed to make sure that multiple restarts of make don't cause ingo@3661: # them to be run again. ingo@3661: # ingo@3661: # reST: %.rst ingo@3661: # ingo@3661: # Runs the reST to LaTeX converter to generate a .tex file ingo@3661: # If it finds a file names _rststyle_._include_.tex, uses it as ingo@3661: # the "stylesheet" option to rst2latex. ingo@3661: # ingo@3661: # Note that this does not track sub-dependencies in rst files. It ingo@3661: # assumes that the top-level rst file will change if you want a ingo@3661: # rebuild. ingo@3661: # ingo@3661: # Dependencies: ingo@3661: # ingo@3661: # In general, dependencies are extracted directly from LaTeX output on ingo@3661: # your document. This includes ingo@3661: # ingo@3661: # * Bibliography information ingo@3661: # * \include or \input files (honoring \includeonly, too) ingo@3661: # * Graphics files inserted by the graphicx package ingo@3661: # ingo@3661: # Where possible, all of these are built correctly and automatically. ingo@3661: # In the case of graphics files, these are generated from the following ingo@3661: # file types: ingo@3661: # ingo@3661: # GraphViz: .dot ingo@3661: # GNUPlot: .gpi ingo@3661: # XFig: .fig ingo@3661: # XMgrace: .xvg ingo@3661: # SVG: .svg ingo@3661: # PNG: .png ingo@3661: # JPEG: .jpg ingo@3661: # GZipped EPS: .eps.gz ingo@3661: # ingo@3661: # If the file exists as a .eps already, it is merely used (and will not ingo@3661: # be deleted by 'clean'!). ingo@3661: # ingo@3661: # LaTeX and BibTeX are invoked correctly and the "Rerun to get ingo@3661: # cross-references right" warning is heeded a reasonable number of ingo@3661: # times. In my experience this is enough for even the most troublesome ingo@3661: # documents, but it can be easily changed (if LaTeX has to be run after ingo@3661: # BibTeX more than three times, it is likely that something is moving ingo@3661: # back and forth between pages, and no amount of LaTeXing will fix ingo@3661: # that). ingo@3661: # ingo@3661: # \includeonly is honored by this system, so files that are not ingo@3661: # specified there will not trigger a rebuild when changed. ingo@3661: # ingo@3661: # Beamer: ingo@3661: # A special TeX source comment is recognized by this makefile (only when ingo@3661: # BUILD_STRATEGY=latex, since this invokes psnup): ingo@3661: # ingo@3661: # %%[[:space:]]*BEAMER[[:space:]]*LARGE ingo@3661: # ingo@3661: # The presence of this comment forces the output of dvips through psnup ingo@3661: # to enlarge beamer slides to take up an entire letter-sized page. This ingo@3661: # is particularly useful when printing transparencies or paper versions ingo@3661: # of the slides. For some reason landscape orientation doesn't appear ingo@3661: # to work, though. ingo@3661: # ingo@3661: # If you want to put multiple slides on a page, use this option and then ingo@3661: # print using mpage, a2ps, or psnup to consolidate slides. My personal ingo@3661: # favorite is a2ps, but your mileage may vary. ingo@3661: # ingo@3661: # When beamer is the document class, dvips does NOT receive a paper size ingo@3661: # command line attribute, since beamer does special things with sizes. ingo@3661: # ingo@3661: # GNUPlot Graphics: ingo@3661: # When creating a .gpi file, DO NOT INCLUDE the "set terminal" or "set ingo@3661: # output" commands! The makefile will include terminal information for ingo@3661: # you. Besides being unnecessary and potentially harmful, including the ingo@3661: # terminal definition in the .gpi file makes it harder for you, the one ingo@3661: # writing the document, to preview your graphics, e.g., with ingo@3661: # ingo@3661: # gnuplot -persist myfile.gpi ingo@3661: # ingo@3661: # so don't do specify a terminal or an output file in your .gpi files. ingo@3661: # ingo@3661: # When building a gpi file into an eps file, there are several features ingo@3661: # available to the document designer: ingo@3661: # ingo@3661: # Global Header: ingo@3661: # The makefile searches for the files in the variable GNUPLOT_GLOBAL ingo@3661: # in order: ingo@3661: # ingo@3661: # ($(GNUPLOT_GLOBAL)) ingo@3661: # ingo@3661: # Only the first found is used. All .gpi files in the directory are ingo@3661: # treated as though the contents of GNUPLOT_GLOBAL were directly ingo@3661: # included at the top of the file. ingo@3661: # ingo@3661: # NOTE: This includes special comments! (see below) ingo@3661: # ingo@3661: # Font Size: ingo@3661: # A special comment in a .gpi file (or a globally included file) of ingo@3661: # the form ingo@3661: # ingo@3661: # ## FONTSIZE=<number> ingo@3661: # ingo@3661: # will change the font size of the GPI output. If font size is ingo@3661: # specified in both the global file and the GPI file, the ingo@3661: # specification in the individual GPI file is used. ingo@3661: # ingo@3661: # Grayscale Output: ingo@3661: # GNUplot files also support a special comment to force them to be ingo@3661: # output in grayscale *no matter what*: ingo@3661: # ingo@3661: # ## GRAY ingo@3661: # ingo@3661: # This is not generally advisable, since you can always create a ingo@3661: # grayscale document using the forms mentioned above. But, if your ingo@3661: # plot simply must be grayscale even in a document that allows ingo@3661: # colors, this is how you do it. ingo@3661: # ingo@3661: # XFig Graphics: ingo@3661: # No special handling is done with XFig, except when a global ingo@3661: # grayscale method is used, e.g. ingo@3661: # ingo@3661: # make GRAY=1 document ingo@3661: # ingo@3661: # In these cases the .eps files is created using the -N switch to ingo@3661: # fig2dev to turn off color output. (Only works with eps, not pstex ingo@3661: # output) ingo@3661: # ingo@3661: # GraphVis Graphics: ingo@3661: # Color settings are simply ignored here. The 'dot' program is used ingo@3661: # to transform a .dot file into a .eps file. ingo@3661: # ingo@3661: # If you want, you can use the dot2tex program to convert dot files ingo@3661: # to tex graphics. The default is to just call dot2tex with no ingo@3661: # arguments, but you can change the DOT2TEX definition to include ingo@3661: # options as needed (in your Makefile.ini). ingo@3661: # ingo@3661: # Note that, as with pstex, the makefile cannot use latex's own ingo@3661: # output to discover all missing dot_t (output) files, since anytime ingo@3661: # TeX includes TeX, it has to bail when it can't find the include ingo@3661: # file. It can therefore only stop on the first missing file it ingo@3661: # discovers, and we can't get a large list of them out easily. ingo@3661: # ingo@3661: # So, the makefile errors out if it's missing an included dot_t ingo@3661: # file, then prompts the user to run this command manually: ingo@3661: # ingo@3661: # make all-dot2tex ingo@3661: # ingo@3661: # GZipped EPS Graphics: ingo@3661: # ingo@3661: # A .eps.gz file is sometimes a nice thing to have. EPS files can get ingo@3661: # very large, especially when created from bitmaps (don't do this if you ingo@3661: # don't have to). This makefile will unzip them (not in place) to ingo@3661: # create the appropriate EPS file. ingo@3661: # ingo@3661: endef ingo@3661: ingo@3661: # ingo@3661: # DEPENDENCY CHART: ingo@3661: # ingo@3661: #digraph "g" { ingo@3661: # rankdir=TB ingo@3661: # size="9,9" ingo@3661: # edge [fontsize=12 weight=10] ingo@3661: # node [shape=box fontsize=14 style=rounded] ingo@3661: # ingo@3661: # eps [ ingo@3661: # shape=Mrecord ingo@3661: # label="{{<gpi> GNUplot|<epsgz> GZip|<dot> Dot|<fig> XFig}|<eps> eps}" ingo@3661: # ] ingo@3661: # pstex [label="%.pstex"] ingo@3661: # pstex_t [label="%.pstex_t"] ingo@3661: # tex_outputs [shape=point] ingo@3661: # extra_tex_files [shape=point] ingo@3661: # gpi_data [label="<data>"] ingo@3661: # gpi_includes [label="_include_.gpi"] ingo@3661: # aux [label="%.aux"] ingo@3661: # fls [label="%.fls"] ingo@3661: # idx [label="%.idx"] ingo@3661: # glo [label="%.glo"] ingo@3661: # ind [label="%.ind"] ingo@3661: # log [label="%.log"] ingo@3661: # tex_sh [label="%.tex.sh"] ingo@3661: # rst [label="%.rst"] ingo@3661: # tex [ ingo@3661: # shape=record ingo@3661: # label="<tex> %.tex|<include> _include_.tex" ingo@3661: # ] ingo@3661: # include_aux [label="_include_.aux"] ingo@3661: # file_bib [label=".bib"] ingo@3661: # bbl [label="%.bbl"] ingo@3661: # dvi [label="%.dvi"] ingo@3661: # ps [label="%.ps"] ingo@3661: # pdf [label="%.pdf"] ingo@3661: # fig [label=".fig"] ingo@3661: # dot [label=".dot"] ingo@3661: # gpi [label=".gpi"] ingo@3661: # eps_gz [label=".eps.gz"] ingo@3661: # ingo@3661: # gpi_files [shape=point] ingo@3661: # ingo@3661: # rst -> tex:tex [label="reST"] ingo@3661: # tex_sh -> tex:tex [label="sh"] ingo@3661: # tex_pl -> tex:tex [label="perl"] ingo@3661: # tex_py -> tex:tex [label="python"] ingo@3661: # tex -> tex_outputs [label="latex"] ingo@3661: # tex_outputs -> dvi ingo@3661: # tex_outputs -> aux ingo@3661: # tex_outputs -> log ingo@3661: # tex_outputs -> fls ingo@3661: # tex_outputs -> idx ingo@3661: # tex_outputs -> include_aux ingo@3661: # aux -> bbl [label="bibtex"] ingo@3661: # file_bib -> bbl [label="bibtex"] ingo@3661: # idx -> ind [label="makeindex"] ingo@3661: # glo -> gls [label="makeindex"] ingo@3661: # nlo -> nls [label="makeindex"] ingo@3661: # gls -> extra_tex_files ingo@3661: # nls -> extra_tex_files ingo@3661: # ind -> extra_tex_files ingo@3661: # bbl -> extra_tex_files ingo@3661: # eps -> extra_tex_files ingo@3661: # extra_tex_files -> dvi [label="latex"] ingo@3661: # gpi_files -> eps:gpi [label="gnuplot"] ingo@3661: # gpi -> gpi_files ingo@3661: # gpi_data -> gpi_files ingo@3661: # gpi_includes -> gpi_files ingo@3661: # eps_gz -> eps:epsgz [label="gunzip"] ingo@3661: # fig -> eps:fig [label="fig2dev"] ingo@3661: # fig -> pstex [label="fig2dev"] ingo@3661: # fig -> pstex_t [label="fig2dev"] ingo@3661: # pstex -> pstex_t [label="fig2dev"] ingo@3661: # dot -> eps:dot [label="dot"] ingo@3661: # dvi -> ps [label="dvips"] ingo@3661: # include_aux -> bbl [label="bibtex"] ingo@3661: # ps -> pdf [label="ps2pdf"] ingo@3661: # ingo@3661: # edge [ color=blue label="" style=dotted weight=1 fontcolor=blue] ingo@3661: # fls -> tex:include [label="INPUT: *.tex"] ingo@3661: # fls -> file_bib [label="INPUT: *.aux"] ingo@3661: # aux -> file_bib [label="\\bibdata{...}"] ingo@3661: # include_aux -> file_bib [label="\\bibdata{...}"] ingo@3661: # log -> gpi [label="Graphic file"] ingo@3661: # log -> fig [label="Graphic file"] ingo@3661: # log -> eps_gz [label="Graphic file"] ingo@3661: # log -> dot [label="Graphic file"] ingo@3661: # log -> idx [label="No file *.ind"] ingo@3661: # log -> glo [label="No file *.gls"] ingo@3661: # log -> nlo [label="No file *.nls"] ingo@3661: # gpi -> gpi_data [label="plot '...'"] ingo@3661: # gpi -> gpi_includes [label="load '...'"] ingo@3661: # tex:tex -> ps [label="paper"] ingo@3661: # tex:tex -> pdf [label="embedding"] ingo@3661: #} ingo@3661: ingo@3661: # ingo@3661: # DEPENDENCY CHART SCRIPT ingo@3661: # ingo@3661: # $(call output_dependency_graph,[<output file>]) ingo@3661: define output-dependency-graph ingo@3661: if [ -f '$(this_file)' ]; then \ ingo@3661: $(SED) \ ingo@3661: -e '/^[[:space:]]*#[[:space:]]*DEPENDENCY CHART:/,/^$$/!d' \ ingo@3661: -e '/DEPENDENCY CHART/d' \ ingo@3661: -e '/^$$/d' \ ingo@3661: -e 's/^[[:space:]]*#//' \ ingo@3661: $(this_file) $(if $1,> '$1',); \ ingo@3661: else \ ingo@3661: $(ECHO) "Cannot determine the name of this makefile."; \