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