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