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