diff options
author | Florian Bruhin <git@the-compiler.org> | 2013-08-14 17:22:14 +0200 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2013-08-14 17:22:14 +0200 |
commit | af94d5853697383b5fc2692c3e910edd05512338 (patch) | |
tree | 0329c2aa1fbab64d447c39fa96ec1bc61084b22d | |
parent | f1c7bab3a156e2a475f4da17445dd551f1979067 (diff) | |
download | latex-workshop-master.tar.gz latex-workshop-master.zip |
-rwxr-xr-x | makefile/Makefile | 459 |
1 files changed, 357 insertions, 102 deletions
diff --git a/makefile/Makefile b/makefile/Makefile index 62951f3..fe48e92 100755 --- a/makefile/Makefile +++ b/makefile/Makefile @@ -30,7 +30,7 @@ # fileinfo := LaTeX Makefile author := Chris Monson -version := 2.2.0 +version := 2.2.1-alpha9 # .DEFAULT_GOAL := all # Note that the user-global version is imported *after* the source directory, @@ -46,6 +46,8 @@ version := 2.2.0 # This can be pdflatex or latex - you can change this by adding the following line to your Makefile.ini: # BUILD_STRATEGY := latex BUILD_STRATEGY ?= pdflatex +# This can be used to pass extra options to latex. +LATEX_OPTS ?= # # Sets LC_ALL=C, by default, so that the locale-aware tools, like sort, be # # immune to changes to the locale in the user environment. @@ -55,10 +57,12 @@ export LC_ALL ?= C # If you specify sources here, all other files with the same suffix # will be treated as if they were _include_ files. #onlysources.tex ?= main.tex +#onlysources.lhs ?= #onlysources.tex.sh ?= #onlysources.tex.pl ?= #onlysources.tex.py ?= #onlysources.rst ?= +#onlysources.mp ?= #onlysources.fig ?= #onlysources.gpi ?= #onlysources.dot ?= @@ -69,10 +73,12 @@ export LC_ALL ?= C # # If you list files here, they will be treated as _include_ files #includes.tex ?= file1.tex file2.tex +#includes.lhs ?= #includes.tex.sh ?= #includes.tex.pl ?= #includes.tex.py ?= #includes.rst ?= +#includes.mp ?= #includes.fig ?= #includes.gpi ?= #includes.dot ?= @@ -111,9 +117,61 @@ export LC_ALL ?= C # # # CHANGES: -# Chris Monson (2011-05-20): +# Chris Monson (2012-06-25): +# * Bumped version to 2.2.1-alpha9 +# * Built with Holger Dell's changes to fix multiple unnecessary compilations. +# Chris Monson (2011-11-10): +# * Issue 144: Help patch from girard.nicolas applied +# Andrew McNabb (2011-09-30): +# * Bumped version to 2.2.1-alpha8 +# * Issue 141: No font embedding for gnuplot when not doing pdf +# * Syntax error fixed for gpi handling code +# Chris Monson (2011-09-06): +# * Issue 140: clean mlt*, mlf*, and mtc* files +# * Issue 136: initial support for metapost files +# Chris Monson (2011-08-09): +# * Bumped version to 2.2.1-alpha7 +# * Issue 138: existing .eps files now included correctly +# * Issue 139: added missing backslash to ps build rule +# Chris Monson (2011-07-20): +# * Added LATEX_OPTS +# Chris Monson (2011-06-23): +# * Bumped version to 2.2.1-alpha6 +# * Issue 133: Set jobname to fix .fls generation to always have the source name +# * Removed unnecessary (?) double-invocation of cygpath +# Chris Monson (2011-06-16): +# * Added support for keeping .rst and .lhs tex intermediates around. +# * Separated scripts from source generation files (rst and lhs) +# * Fixed run-script problem for lhs2tex (was invoked incorrectly) +# * Issue 133: Fixed typo from literate Haskell support +# Chris Monson (2011-06-13): +# * Bumped version to 2.2.1-alpha5 +# * Fixed problems with detecting graphics for very long source names. +# Chris Monson (2011-06-13): +# * Issue 134: name of self corrected for dependency graph +# * Issue 133: Added literate Haskell support (lhs2tex) +# Chris Monson (2011-05-31): +# * Rewrote specials (%%COMMENTS) to be easier to extend and parse. +# Chris Monson (2011-05-11): +# * Bumped version to 2.2.1-alpha4 +# * Issue 129: nomenclature dependency fix +# Chris Monson (2011-05-09): +# * Bumped version to 2.2.1-alpha3 +# * Issue 112: Cygpath fixes +# Chris Monson (2011-04-27): +# * Bumped version to 2.2.1-alpha2 +# * Issue 126: Broken log parsing for latex pipeline +# * Fixed month in recent changes (had May, should be April) +# * Noticed problems with some existing parsing (colorizing errors, notably) and +# fixed them. +# * New test case for specified graphic extensions. +# * Added .bb generation for .eps files (when extensionless in latex pipeline) +# Chris Monson (2011-04-22): +# * Bumped version to 2.2.1-alpha1 +# * Issue 105: add support for format file detection and compilation +# Chris Monson (2011-04-20): # * Bumped version to 2.2.0 (release!) -# Chris Monson (2011-05-19): +# Chris Monson (2011-04-19): # * Bumped version to 2.2.0-rc15 # * Issue 125: infinite recursion with nomenclature files # * Issue 125: removed .d as a target for .nls in get-log-index @@ -701,10 +759,12 @@ TPUT ?= tput PERL ?= perl PYTHON ?= python RST2LATEX ?= rst2latex.py +LHS2TEX ?= lhs2tex # == EPS Generation == CONVERT ?= convert # ImageMagick DOT ?= dot # GraphViz DOT2TEX ?= dot2tex # dot2tex - add options (not -o) as needed +MPOST ?= mpost # MetaPost FIG2DEV ?= fig2dev # XFig GNUPLOT ?= gnuplot # GNUplot INKSCAPE ?= inkscape # Inkscape (svg support) @@ -728,13 +788,8 @@ XINDYENC ?= utf8 # otherwise the function is just a no-op. Issue 112 has details. USE_CYGPATH := $(if $(shell $(WHICH) $(CYGPATH) 2>/dev/null),yes,) -# $(call get-cygpath,<path>) -define get-cygpath -$(shell $(CYGPATH) -u "$(shell $(CYGPATH) -s -w $1)") -endef - define path-norm -$(if $(USE_CYGPATH),$(call get-cygpath,$1),$1) +$(if $(USE_CYGPATH),$(shell $(CYGPATH) -u "$1"),$1) endef # Command options for embedding fonts and postscript->pdf conversion @@ -856,6 +911,25 @@ GRAY ?= $(call get-default,$(GREY),) # # Utility Functions and Definitions # +# +# Transcript +# For debug/testing purposes: writes a message to +# filename.transcript.make for each command that was run, including +# some human-readable justification for why it had to be run. +# For example: "Running latex (log-file indicated that this is necessary)" +# Set WRITE_TRANSCRIPT to something to activate +WRITE_TRANSCRIPT ?= +# Set reason for the next run call +# $(call set-run-reason,message) +set-run-reason = export run_reason="$1" +# Log command to the transcript file +# $(call set-run-reason,command,job_name) +define transcript +$(if $(WRITE_TRANSCRIPT), \ + $(ECHO) "Running $1 ($$run_reason)" >> $2.transcript.make; \ + export run_reason="", \ + $(sh_true)) +endef # Don't call this directly - it is here to avoid calling wildcard more than # once in remove-files. @@ -909,6 +983,8 @@ escape-fname-regex = $(subst /,\\/,$(subst .,\\.,$1)) # Test that a file exists # $(call test-exists,file) test-exists = [ -e '$1' ] +# $(call test-not-exists,file) +test-not-exists = [ ! -e '$1' ] # $(call move-files,source,destination) move-if-exists = $(call test-exists,$1) && $(MV) '$1' '$2' @@ -989,7 +1065,7 @@ endif # Get the name of this makefile (always right in 3.80, often right in 3.79) # This is only really used for documentation, so it isn't too serious. ifdef MAKEFILE_LIST -this_file := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) +this_file := $(firstword $(MAKEFILE_LIST)) else this_file := $(wildcard GNUmakefile makefile Makefile) endif @@ -1103,6 +1179,8 @@ all_files.tex.sh ?= $(wildcard *.tex.sh) all_files.tex.pl ?= $(wildcard *.tex.pl) all_files.tex.py ?= $(wildcard *.tex.py) all_files.rst ?= $(wildcard *.rst) +all_files.lhs ?= $(wildcard *.lhs) +all_files.mp ?= $(wildcard *.mp) all_files.fig ?= $(wildcard *.fig) all_files.gpi ?= $(wildcard *.gpi) all_files.dot ?= $(wildcard *.dot) @@ -1150,8 +1228,10 @@ files.tex.sh := $(call filter-buildable,tex.sh) files.tex.pl := $(call filter-buildable,tex.pl) files.tex.py := $(call filter-buildable,tex.py) files.rst := $(call filter-buildable,rst) +files.lhs := $(call filter-buildable,lhs) files.gpi := $(call filter-buildable,gpi) files.dot := $(call filter-buildable,dot) +files.mp := $(call filter-buildable,mp) files.fig := $(call filter-buildable,fig) files.xvg := $(call filter-buildable,xvg) files.svg := $(call filter-buildable,svg) @@ -1168,14 +1248,20 @@ files.eps := $(call filter-buildable,eps) # files in the end. .SECONDARY: $(patsubst %.fig,%.pstex,$(files.fig)) +# Make all .tex targets secondary that result .rst and .lhs: +.SECONDARY: $(patsubst %.rst,%.tex,$(files.rst)) +.SECONDARY: $(patsubst %.lhs,%.tex,$(files.lhs)) + # Top level sources that are built by default targets default_files.tex := $(call filter-default,tex) default_files.tex.sh := $(call filter-default,tex.sh) default_files.tex.pl := $(call filter-default,tex.pl) default_files.tex.py := $(call filter-default,tex.py) default_files.rst := $(call filter-default,rst) +default_files.lhs := $(call filter-default,lhs) default_files.gpi := $(call filter-default,gpi) default_files.dot := $(call filter-default,dot) +default_files.mp := $(call filter-default,mp) default_files.fig := $(call filter-default,fig) default_files.xvg := $(call filter-default,xvg) default_files.svg := $(call filter-default,svg) @@ -1191,15 +1277,18 @@ concat-files = $(foreach s,$1,$($(if $2,$2_,)files.$s)) # Useful file groupings all_files_source := $(call concat-files,tex,all) -all_files_scripts := $(call concat-files,tex.sh tex.pl tex.py rst,all) +all_files_source_gen := $(call concat-files,rst rhs,all) +all_files_scripts := $(call concat-files,tex.sh tex.pl tex.py,all) .PHONY: $(all_files_scripts) -default_files_source := $(call concat-files,tex,default) -default_files_scripts := $(call concat-files,tex.sh tex.pl tex.py rst,default) +default_files_source := $(call concat-files,tex,default) +default_files_source_gen := $(call concat-files,rhs lhs,default) +default_files_scripts := $(call concat-files,tex.sh tex.pl tex.py,default) -files_source := $(call concat-files,tex) -files_scripts := $(call concat-files,tex.sh tex.pl tex.py rst) +files_source := $(call concat-files,tex) +files_source_gen := $(call concat-files,rst lhs) +files_scripts := $(call concat-files,tex.sh tex.pl tex.py) # Utility function for obtaining stems # $(call get-stems,suffix,[prefix]) @@ -1211,6 +1300,8 @@ all_stems.tex.sh := $(call get-stems,tex.sh,all) all_stems.tex.pl := $(call get-stems,tex.pl,all) all_stems.tex.py := $(call get-stems,tex.py,all) all_stems.rst := $(call get-stems,rst,all) +all_stems.lhs := $(call get-stems,lhs,all) +all_stems.mp := $(call get-stems,mp,all) all_stems.fig := $(call get-stems,fig,all) all_stems.gpi := $(call get-stems,gpi,all) all_stems.dot := $(call get-stems,dot,all) @@ -1228,6 +1319,8 @@ default_stems.tex.sh := $(call get-stems,tex.sh,default) default_stems.tex.pl := $(call get-stems,tex.pl,default) default_stems.tex.py := $(call get-stems,tex.py,default) default_stems.rst := $(call get-stems,rst,default) +default_stems.lhs := $(call get-stems,lhs,default) +default_stems.mp := $(call get-stems,mp,default) default_stems.fig := $(call get-stems,fig,default) default_stems.gpi := $(call get-stems,gpi,default) default_stems.dot := $(call get-stems,dot,default) @@ -1245,6 +1338,8 @@ stems.tex.sh := $(call get-stems,tex.sh) stems.tex.pl := $(call get-stems,tex.pl) stems.tex.py := $(call get-stems,tex.py) stems.rst := $(call get-stems,rst) +stems.lhs := $(call get-stems,lhs) +stems.mp := $(call get-stems,mp) stems.fig := $(call get-stems,fig) stems.gpi := $(call get-stems,gpi) stems.dot := $(call get-stems,dot) @@ -1261,7 +1356,8 @@ stems.eps := $(call get-stems,eps) concat-stems = $(sort $(foreach s,$1,$($(if $2,$2_,)stems.$s))) # The most likely to be source but not finished product go first -graphic_source_extensions := fig \ +graphic_source_extensions := mp \ + fig \ gpi \ xvg \ svg \ @@ -1269,7 +1365,7 @@ graphic_source_extensions := fig \ eps.gz ifeq "$(strip $(BUILD_STRATEGY))" "latex" -graphic_source_extensions += png jpg jpeg +graphic_source_extensions += png jpg jpeg eps graphic_target_extensions := eps ps endif @@ -1284,24 +1380,27 @@ graphic_target_extensions := pdf png jpg jpeg mps tif endif all_stems_source := $(call concat-stems,tex,all) -all_stems_script := $(call concat-stems,tex.sh tex.pl tex.py rst,all) +all_stems_source_gen := $(call concat-stems,rst lhs,all) +all_stems_script := $(call concat-stems,tex.sh tex.pl tex.py,all) all_stems_graphic := $(call concat-stems,$(graphic_source_extensions),all) -all_stems_ss := $(sort $(all_stems_source) $(all_stems_script)) -all_stems_sg := $(sort $(all_stems_script)) +all_stems_ss := $(sort $(all_stems_source) $(all_stems_source_gen) $(all_stems_script)) +all_stems_sg := $(sort $(all_stems_script) $(all_stems_source_gen)) all_stems_ssg := $(sort $(all_stems_ss)) -default_stems_source := $(call concat-stems,tex,default) -default_stems_script := $(call concat-stems,tex.sh tex.pl tex.py rst,default) -default_stems_ss := $(sort $(default_stems_source) $(default_stems_script)) -default_stems_sg := $(sort $(default_stems_script)) +default_stems_source := $(call concat-stems,tex,default) +default_stems_source_gen := $(call concat-stems,rst lhs,default) +default_stems_script := $(call concat-stems,tex.sh tex.pl tex.py,default) +default_stems_ss := $(sort $(default_stems_source) $(default_stems_source_gen) $(default_stems_script)) +default_stems_sg := $(sort $(default_stems_script) $(default_stems_source_gen)) default_stems_ssg := $(sort $(default_stems_ss)) stems_source := $(call concat-stems,tex) -stems_script := $(call concat-stems,tex.sh tex.pl tex.py rst) +stems_source_gen := $(call concat-stems,rst lhs) +stems_script := $(call concat-stems,tex.sh tex.pl tex.py) stems_graphic := $(call concat-stems,$(graphic_source_extensions)) stems_gg := $(sort $(stems_graphic)) -stems_ss := $(sort $(stems_source) $(stems_script)) -stems_sg := $(sort $(stems_script)) +stems_ss := $(sort $(stems_source) $(stems_source_gen) $(stems_script)) +stems_sg := $(sort $(stems_script) $(stems_source_gen)) stems_ssg := $(sort $(stems_ss)) # Calculate names that can generate the need for an include file. We can't @@ -1434,7 +1533,7 @@ endif # Extensions generated by LaTeX invocation that can be removed when complete rm_ext := \ log *.log aux $(pre_pdf_extensions) pdf blg bbl out nav snm toc lof lot lol pfg \ - fls vrb idx ind ilg glg glo gls lox nls nlo nlg brf mtc maf brf ist + fls vrb idx ind ilg glg glo gls lox nls nlo nlg brf mtc* mlf* mlt* maf brf ist fmt backup_patterns := *~ *.bak *.backup body.tmp head.tmp graph_stem := _graph @@ -1484,6 +1583,23 @@ $(SED) \ '$1' | $(SORT) | $(UNIQ) endef +# $(call get-format,<tex file>,<target files>) +define get-format +$(SED) \ +-e '1!d' \ +-e '/^%&\([[:alnum:]]\{1,\}\)\( .*\)*$$/{' \ +-e ' s!!\1!' \ +-e ' h' \ +-e ' s/.*/# MISSING format "&.fmt" (comment forces rebuild of target file)/' \ +-e ' p' \ +-e ' g' \ +-e ' s!.*!$2: $$(call path-norm,&.fmt)!' \ +-e ' p' \ +-e '}' \ +-e 'd' \ +'$1' +endef + # $(call get-missing-inputs,<log file>,<target files>) define get-missing-inputs $(SED) \ @@ -1592,11 +1708,11 @@ endef # extensions (a sign that it's graphicx complaining). # # $(call get-graphics,<target file stem>) -#.log,$(addprefix $*.,d $(build_target_extension) _graphics) define get-graphics $(SED) \ -e '/^File: \(.*\) Graphic file (type [^)]*)/{' \ -e ' s//\1/' \ +-e ' s/\.e\{0,1\}ps$$//' \ -e ' b addtargets' \ -e '}' \ -e '$${' \ @@ -1640,7 +1756,7 @@ $(SED) \ -e 'h' \ -e 'd' \ -e ':start' \ --e '/^[^[:cntrl:]:]*:[[:digit:]]\{1,\}: LaTeX Error: File `/{' \ +-e '/^[^[:cntrl:]:]*:[[:digit:]]\{1,\}:[[:space:][:cntrl:]]*LaTeX[[:space:][:cntrl:]]*Error:[[:space:][:cntrl:]]*File `/{' \ -e ' s/\n//g' \ -e ' b needonemore' \ -e '}' \ @@ -1652,7 +1768,13 @@ $(SED) \ -e ' s/\n\{1,\}/ /g' \ -e ' s/[[:space:]]\{1,\}/ /g' \ -e ' s/^.*File `//' \ --e ' s/'"'"' not found\..*extensions: \([^[:space:]]*\).*/::::\1/' \ +-e ' /extensions: /{' \ +-e ' s/'"'"' not found\..*extensions: \([^[:space:]]*\).*/::::\1/' \ +-e ' b fileparsed' \ +-e ' }' \ +-e ' s/'"'"' not found\..*/::::/' \ +-e ' :fileparsed' \ +-e ' s/\.e\{0,1\}ps::::$$/::::/' \ -e ' h' \ -e ' s/\(.*\)::::\(.*\)/# MISSING stem "\1" - allowed extensions are "\2" - leave comment here - it affects the build/' \ -e ' p' \ @@ -1677,6 +1799,58 @@ $(SED) \ $1.log endef +# Get some special comments out of the source file (e.g., paper size, beamer +# usage, etc.) +# +# $(call get-source-specials,<source file name>,<output file>) +define get-source-specials +$(SED) \ +-e '/^%%[[:space:]]*\([^%].*\)[[:space:]]*$$/{' \ +-e ' s//\1/' \ +-e ' s/[[:space:]]//g' \ +-e ' /BEAMER/{' \ +-e ' /BEAMERLARGE/!d' \ +-e ' s/.*/BEAMER/' \ +-e ' }' \ +-e ' p' \ +-e ' d' \ +-e '}' \ +-e '/\\documentclass[^{]*{.*}/b procclass' \ +-e '/\\documentclass/,/}/{' \ +-e ' s/%.*//' \ +-e ' H' \ +-e ' /}/{' \ +-e ' s/.*//' \ +-e ' x' \ +-e ' b procclass' \ +-e ' }' \ +-e ' d' \ +-e '}' \ +-e 'd' \ +-e ':procclass' \ +-e 's/\\documentclass//' \ +-e 's/[][]//g' \ +-e 's/{.*}//' \ +-e 's/[[:cntrl:][:space:]]*//g' \ +-e 's/,/ /g' \ +-e 's/^/ /' \ +-e 's/$$/ /' \ +-e '/.* \([[:alnum:]]\{1,\}\)paper .*/{' \ +-e ' h' \ +-e ' s//PAPERSIZE=\1/' \ +-e ' p' \ +-e ' g' \ +-e '}' \ +-e '/.* landscape .*/{' \ +-e ' h' \ +-e ' s//ORIENTATION=landscape/' \ +-e ' p' \ +-e ' g' \ +-e '}' \ +-e 'd' \ +$1 > '$2' +endef + # Checks for build failure due to pstex inclusion, and gives instructions. # # $(call die-on-pstexs,<parsed file>) @@ -1720,7 +1894,7 @@ endef # # $(call die-on-no-aux,<aux stem>) define die-on-no-aux -if [ ! -e '$1.aux' ]; then \ +if $(call test-not-exists,$1.aux); then \ $(call colorize-latex-errors,$1.log); \ $(ECHO) "$(C_ERROR)Error: failed to create $1.aux$(C_RESET)"; \ exit 1; \ @@ -1770,9 +1944,9 @@ $(SED) \ -e 's/[[:space:]]/\\&/g' \ -e 's/,/.bib /g' \ -e 's/ \{1,\}$$//' \ -$1 | $(XARGS) $(KPSEWHICH) '#######' | \ +'$1' | $(XARGS) $(KPSEWHICH) '#######' | \ $(SED) \ --e 's!^!$2: !' | \ +-e 's!.*!$2: $$(call path-norm,&)!' | \ $(SORT) | $(UNIQ) endef @@ -1899,7 +2073,7 @@ $(SED) \ -e '}' \ -e 's/^[^[:cntrl:]:]*:[[:digit:]]\{1,\}:/!!! &/' \ -e 's/^\(.*\n\)\([^[:cntrl:]:]*:[[:digit:]]\{1,\}: .*\)/\1!!! \2/' \ --e '/^!!! .* LaTeX Error: File /{' \ +-e '/^!!! .*[[:space:][:cntrl:]]LaTeX[[:space:][:cntrl:]]Error:[[:space:][:cntrl:]]*File /{' \ -e ' s/\n//g' \ -e ' b needonemore' \ -e '}' \ @@ -1918,10 +2092,12 @@ $(SED) \ -e ' b needonemore' \ -e ' }' \ -e ' s/::0::!!! //' \ +-e ' /File .*\.e\{0,1\}ps'"'"' not found/b skip' \ -e ' /could not locate.*any of these extensions:/{' \ --e ' d' \ +-e ' b skip' \ -e ' }' \ -e ' s/\(not found\.\).*/\1/' \ +-e ' s/^/!!! /' \ -e ' b error' \ -e '}' \ -e '/^\(.* LaTeX Error: Missing .begin.document.\.\).*/{' \ @@ -1940,8 +2116,10 @@ $(SED) \ -e ' s//\1/' \ -e ' s/[[:cntrl:]]//' \ -e ' s/[[:cntrl:]]$$//' \ +-e ' /Cannot determine size of graphic .*(no BoundingBox)/b skip' \ -e ' b error' \ -e '}' \ +-e ':skip' \ -e 'd' \ -e ':error' \ -e 's/^!\(!! \)\{0,1\}\(.*\)/$(C_ERROR)\2$(C_RESET)/' \ @@ -2033,22 +2211,26 @@ endef # Get all important .aux files from the top-level .aux file and merges them all # into a single file, which it outputs to stdout. +# It does this by finding all \input commands and creating a new sed script +# that reads those files inline when it encounters one. +# It then runs that sed script, generating a flattened aux file, and +# then it cleans up the flattened file by removing some crufty things. # # $(call flatten-aux,<toplevel aux>,<output file>) define flatten-aux $(SED) \ -e '/\\@input{\(.*\)}/{' \ --e 's//\1/' \ --e 's![.:]!\\&!g' \ --e 'h' \ --e 's!.*!\\:\\\\@input{&}:{!' \ --e 'p' \ --e 'x' \ --e 's/\\././g' \ --e 's/.*/r &/p' \ --e 's/.*/d/p' \ --e 's/.*/}/p' \ --e 'd' \ +-e ' s//\1/' \ +-e ' s![.:]!\\&!g' \ +-e ' h' \ +-e ' s!.*!\\:\\\\@input{&}:{!' \ +-e ' p' \ +-e ' x' \ +-e ' s/\\././g' \ +-e ' s/.*/r &/p' \ +-e ' s/.*/d/p' \ +-e ' s/.*/}/p' \ +-e ' d' \ -e '}' \ -e 'd' \ '$1' > "$1.$$$$.sed.make"; \ @@ -2105,9 +2287,10 @@ $(SED) \ -e ' b end' \ -e ' }' \ -e ' / *LaTeX Error:.*/{' \ --e ' s/.*\( *LaTeX Error:.*\)/$(C_ERROR)\1$(C_RESET)/' \ --e ' b end' \ +-e ' s/.*\( *LaTeX Error:.*\)/\1/' \ +-e ' b error' \ -e ' }' \ +-e ' /^[^[:cntrl:]:]*:[[:digit:]]\{1,\}:/b error' \ -e ' /.*Warning:.*/{' \ -e ' s//$(C_WARNING)&$(C_RESET)/' \ -e ' b end' \ @@ -2121,6 +2304,9 @@ $(SED) \ -e ' b end' \ -e ' }' \ -e ' d' \ +-e ' :error' \ +-e ' s/.*/$(C_ERROR)&$(C_RESET)/' \ +-e ' b end' \ -e ' :end' \ -e ' G' \ -e '}' @@ -2150,7 +2336,10 @@ $(SED) \ enlarge_beamer = $(PSNUP) -l -1 -W128mm -H96mm -pletter # $(call test-run-again,<source stem>) -test-run-again = $(EGREP) -q '^(.*Rerun .*|No file $1\.[^.]+\.)$$' $1.log +define test-run-again +$(EGREP) '^(.*Rerun .*|No file $1\.[^.]+\.)$$' $1.log \ +| $(EGREP) -q -v '^(Package: rerunfilecheck.*Rerun checks for auxiliary files.*)$$' +endef # This tests whether the build target commands should be run at all, from # viewing the log file. @@ -2159,13 +2348,24 @@ define test-log-for-need-to-run $(SED) \ -e '/^No file $(call escape-fname-regex,$1)\.aux\./d' \ $1.log \ -| $(EGREP) -q '^(.*Rerun .*|No file $1\.[^.]+\.|No file .+\.tex\.|LaTeX Warning: File.*)$$' +| $(EGREP) '^(.*Rerun .*|No file $1\.[^.]+\.|No file .+\.tex\.|LaTeX Warning: File.*)$$' \ +| $(EGREP) -q -v '^(Package: rerunfilecheck.*Rerun checks for auxiliary files.*)$$' endef # LaTeX invocations # -# $(call latex,<tex file>,[<extra LaTeX args>]) -run-latex = $(latex_build_program) -interaction=batchmode -file-line-error $(if $2,$2,) $1 > /dev/null +# Note that we use +# +# -recorder: generates .fls files for things that are input and output +# -jobname: to make sure that .fls files are named after the source that created them +# -file-line-error: to make sure that we have good line information for error output +# -interaction=batchmode: so that we don't stop on errors (we'll parse logs for that) +# +# $(call latex,<tex file stem, e.g., $*>,[extra LaTeX args]) +define run-latex +$(latex_build_program) -jobname='$1' -interaction=batchmode -file-line-error $(LATEX_OPTS) $(if $2,$2,) $1 > /dev/null; \ +$(call transcript,latex,$1) +endef # $(call latex-color-log,<LaTeX stem>) latex-color-log = $(color_tex) $1.log @@ -2178,11 +2378,11 @@ then \ $(call colorize-makeindex-errors,$3); \ $(RM) -f '$2'; \ success=0; \ + $(call transcript,makeindex,$1); \ fi; \ [ "$$success" = "1" ] && $(sh_true) || $(sh_false); endef - # $(call run-xindy,<input>,<output>,<module>,<log>) define run-xindy success=1; \ @@ -2190,6 +2390,7 @@ if ! $(XINDY) -q -o $2 -L $(XINDYLANG) -C $(XINDYENC) -I xindy -M $3 -t $4 $1 > $(call colorize-xindy-errors,$4); \ $(RM) -f '$2'; \ success=0; \ + $(call transcript,xindy,$1); \ fi; \ [ "$$success" = "1" ] && $(sh_true) || $(sh_false); endef @@ -2200,7 +2401,8 @@ endef # # $(call run-script,<interpreter>,<input>,<output>) define run-script -[ ! -e '$2.cookie' ] && $(ECHO) "restarts=$(RESTARTS)" > $2.cookie && $(ECHO) "level=$(MAKELEVEL)" >> $2.cookie; \ +$(call test-not-exists,$2.cookie) && $(ECHO) "restarts=$(RESTARTS)" \ + > $2.cookie && $(ECHO) "level=$(MAKELEVEL)" >> $2.cookie; \ restarts=`$(SED) -n -e 's/^restarts=//p' $2.cookie`; \ level=`$(SED) -n -e 's/^level=//p' $2.cookie`; \ if $(EXPR) $(MAKELEVEL) '<=' $$level '&' $(RESTARTS) '<=' $$restarts >/dev/null; then \ @@ -2214,8 +2416,7 @@ endef # BibTeX invocations # # $(call run-bibtex,<tex stem>) -run-bibtex = $(BIBTEX) $1 | $(color_bib) - +run-bibtex = $(BIBTEX) $1 | $(color_bib); $(call transcript,bibtex,$1) # $(call convert-eps-to-pdf,<eps file>,<pdf file>,[gray]) # Note that we don't use the --filter flag because it has trouble with bounding boxes that way. @@ -2295,11 +2496,11 @@ success=1; \ if ! $(GNUPLOT) $$fnames 2>$1.log; then \ $(call colorize-gnuplot-errors,$1.log); \ success=0; \ -else \ - if ! $(call gpi-embed-pdf-fonts,$2,$2.embed.make); then \ - success = 0; \ +elif [ x"$(suffix $2)" = x".pdf" ]; then \ + if ! $(call gpi-embed-pdf-fonts,$2,$2.embed.tmp.make); then \ + success=0; \ else \ - $(call move-if-exists,$2.embed.make,$2); \ + $(call move-if-exists,$2.embed.tmp.make,$2); \ fi; \ fi; \ $(if $(gpi_sed),$(call remove-temporary-files,$1.temp.make);,) \ @@ -2365,6 +2566,23 @@ convert-xvg = $(XMGRACE) '$1' -printfile - -hardcopy -hdevice $(if $3,-mono,) EP # $(call convert-epsgz,<eps.gz file>,<eps file>,[gray]) convert-epsgz = $(GUNZIP) -c '$1' $(if $3,| $(call kill-ps-color)) > '$2' +# Generates a .bb file from a .eps file (sometimes latex really wants this) +# +# $(call eps-bb,<eps file>,<eps.bb file>) +define eps-bb +$(SED) \ +-e '/^%%Title:/p' \ +-e '/^%%Creator:/p' \ +-e '/^%%BoundingBox:/p' \ +-e '/^%%CreationDate:/p' \ +-e '/^%%EndComments/{' \ +-e ' d' \ +-e ' q' \ +-e '}' \ +-e 'd' \ +$1 > "$2" +endef + # Converts .eps files into .eps files (usually a no-op, but can make grayscale) # # $(call convert-eps,<in file>,<out file>,[gray]) @@ -2493,10 +2711,10 @@ $(call colorize-dot-errors,$3) endef # Convert DVI to Postscript -# $(call make-ps,<dvi file>,<ps file>,<log file>,[<paper size>]) +# $(call make-ps,<dvi file>,<ps file>,<log file>,[<paper size>],[<beamer info>]) make-ps = \ - $(DVIPS) -z -o '$2' $(if $(filter-out BEAMER,$4),-t$(firstword $4),) '$1' \ - $(if $(filter BEAMER,$4),| $(enlarge_beamer)) > $3 2>&1 + $(DVIPS) -z -o '$2' $(if $(strip $4),-t$(strip $4),) '$1' \ + $(if $5,| $(enlarge_beamer)) > $3 2>&1 # Convert Postscript to PDF # $(call make-pdf,<ps file>,<pdf file>,<log file>,<embed file>) @@ -2598,10 +2816,11 @@ ifeq "$(strip $(BUILD_STRATEGY))" "latex" fi .SECONDARY: $(all_ps_targets) -%.ps: %.dvi %.paper.make +%.ps: %.dvi %.paper.make %.beamer.make $(QUIET)$(call echo-build,$<,$@) $(QUIET)$(call make-ps,$<,$@.temp,$@.log,\ - $(firstword $(shell $(CAT) $*.paper.make))); \ + $(strip $(shell $(CAT) $*.paper.make)),\ + $(strip $(shell $(CAT) $*.beamer.make))); \ if [ x"$$?" = x"0" ]; then \ $(if $(VERBOSE),$(CAT) $@.log,:); \ $(RM) -f '$@'; \ @@ -2670,24 +2889,29 @@ endif run=0; \ for i in 1; do \ if $(call test-exists,$*.bbl.cookie); then \ + $(call set-run-reason,$*.bbl.cookie is present); \ run=1; \ break; \ fi; \ if $(call test-exists,$*.run.cookie); then \ + $(call set-run-reason,$*.run.cookie is present); \ run=1; \ break; \ fi; \ if $(call \ test-exists-and-different,$*.auxtarget.cookie,$*.auxtarget.make);\ then \ + $(call set-run-reason,$*.auxtarget.cookie differs from $*.auxtarget.make); \ run=1; \ break; \ fi; \ if $(call test-log-for-need-to-run,$*); then \ + $(call set-run-reason,$*.log indicated that this is necessary); \ run=1; \ break; \ fi; \ - if [ ! -e $*.1st.*.make ]; then \ + if $(call test-not-exists,$@.1st.make); then \ + $(call set-run-reason,$@.1st.make does not exist); \ run=1; \ break; \ fi; \ @@ -2703,7 +2927,11 @@ endif ); \ $(call run-latex,$*); \ $(CP) '$*.log' '$*.'$(RESTARTS)-$$i'.log'; \ - $(call test-run-again,$*) || break; \ + if $(call test-run-again,$*); then \ + $(call set-run-reason,rerun requested by $*.log); \ + else \ + break; \ + fi; \ done; \ else \ $(MV) '$@.1st.make' '$@'; \ @@ -2727,6 +2955,7 @@ endif $(QUIET)\ $(if $(filter %.bib,$^),\ $(call echo-build,$(filter %.bib,$?) $*.aux,$@); \ + $(call set-run-reason,dependencies of $@ changed); \ $(call run-bibtex,$*); \ $(TOUCH) $@.cookie; \ ) \ @@ -2765,15 +2994,26 @@ endif $(QUIET)$(call run-xindy,$<,$@,$*,$*.glg) # Create the glossary file from a nomenclature file -%.gls: %.glo %.tex nomencl.ist +%.gls: %.glo %.tex $(call path-norm,$(shell $(KPSEWHICH) nomencl.ist || $(ECHO) nomencl.ist)) $(QUIET)$(call echo-build,$<,$@) $(QUIET)$(call run-makeindex,$<,$@,$*.glg,nomencl.ist) # Create the nomenclature file -%.nls: %.nlo %.tex nomencl.ist +%.nls: %.nlo %.tex $(call path-norm,$(shell $(KPSEWHICH) nomencl.ist || $(ECHO) nomencl.ist)) $(QUIET)$(call echo-build,$<,$@) $(QUIET)$(call run-makeindex,$<,$@,$*.nlg,nomencl.ist) +# Precompile the format file +%.fmt: %.tex + $(QUIET)$(call echo-build,$<,$@) + $(QUIET)\ + $(call run-latex,$*,-ini "&$(latex_build_program) $*.tex\dump"); \ + fatal=`$(call colorize-latex-errors,$*.log)`; \ + if [ x"$$fatal" != x"" ]; then \ + $(ECHO) "$$fatal"; \ + exit 1; \ + fi; + # SCRIPTED LaTeX TARGETS # # Keep the generated .tex files around for debugging if needed. @@ -2794,6 +3034,11 @@ endif --documentoptions=letterpaper\ $(if $(RST_STYLE_FILE),--stylesheet=$(RST_STYLE_FILE),),$<,$@) +%.tex:: %.lhs + $(QUIET)\ + function run_lhs2tex() { $(LHS2TEX) -o "$$2" "$$1"; }; \ + $(call run-script,run_lhs2tex,$<,$@) + # # GRAPHICS TARGETS # @@ -2854,6 +3099,15 @@ endif endif +# TODO: capture mpost output and display errors +# TODO: figure out why pdf generation is erroring out (but working anyway) +%.eps %.mps %.mpx %.log: %.mp + $(QUIET)$(call echo-graphic,$^,$@) + $(QUIET)$(MPOST) $* + $(QUIET)$(call move-if-exists,$*.mps,$*.eps) + $(QUIET)$(call move-if-exists,$*.log,$*.log.make) + $(QUIET)$(call move-if-exists,$*.mpx,$*.mpx.make) + %.eps: %.gpi %.gpi.d $(gpi_sed) $(gpi_global) $(QUIET)$(call echo-graphic,$^,$@) $(QUIET)$(call convert-gpi,$<,$@,$(GRAY)) @@ -2892,6 +3146,10 @@ ifneq "$(default_graphic_extension)" "pdf" $(QUIET)$(call convert-png,$<,$@,$(GRAY)) endif +%.eps.bb: %.eps + $(QUIET)$(call echo-graphic,$^,$@) + $(QUIET)$(call eps-bb,$<,$@) + %.eps: %.eps.gz $(if $(GRAY),$(gray_eps_file)) $(QUIET)$(call echo-graphic,$^,$@) $(QUIET)$(call convert-epsgz,$<,$@,$(GRAY)) @@ -2950,7 +3208,8 @@ endif %.$(build_target_extension).1st.make %.d %.aux %.aux.make %.fls: %.tex $(QUIET)$(call echo-build,$<,$*.d $*.$(build_target_extension).1st.make,$(RESTARTS)-1) $(QUIET)\ - $(call run-latex,$<,-recorder) || $(sh_true); \ + $(call set-run-reason,need to build .d and .$(build_target_extension).1st.make); \ + $(call run-latex,$*,-recorder) || $(sh_true); \ $(CP) '$*.log' '$*.$(RESTARTS)-1.log'; \ $(call die-on-import-sty,$*.log); \ $(call die-on-dot2tex,$*.log); \ @@ -2959,12 +3218,14 @@ endif $(ECHO) "# vim: ft=make" > $*.d; \ $(ECHO) ".PHONY: $*._graphics" >> $*.d; \ $(call get-inputs,$*.fls,$(addprefix $*.,aux aux.make d $(build_target_extension))) >> $*.d; \ + $(call get-format,$<,$(addprefix $*.,fls aux aux.make d $(build_target_extension) $(build_target_extension).1st.make)) >> $*.d; \ $(call get-missing-inputs,$*.log,$(addprefix $*.,aux aux.make d $(build_target_extension))) >> $*.d; \ $(ECHO) ".SECONDEXPANSION:" >> $*.d; \ $(call get-graphics,$*) >> $*.d; \ $(call get-log-index,$*,$(addprefix $*.,aux aux.make)) >> $*.d; \ $(call get-bibs,$*.aux.make,$(addprefix $*.,bbl aux aux.make)) >> $*.d; \ - $(EGREP) -q "# MISSING" $*.d && $(SLEEP) 1 && $(RM) $*.pdf; \ + $(EGREP) -q "# MISSING stem" $*.d && $(SLEEP) 1 && $(RM) $*.pdf; \ + $(EGREP) -q "# MISSING format" $*.d && $(RM) $*.pdf; \ $(call move-if-exists,$*.$(build_target_extension),$*.$(build_target_extension).1st.make); \ for s in toc out lot lof lol nav; do \ if [ -e "$*.$$s" ]; then \ @@ -2991,42 +3252,27 @@ endif $(QUIET)$(call echo-build,$<,$@) $(QUIET)$(call make-gpi-d,$<,$@) +# Get source specials, e.g., paper size and special %% comments. +%.specials.make: %.tex + $(QUIET)$(call get-source-specials,$<,$@) + +# Get info about whether to enlarge beamer postscript files (for use with +# dvips, and requires a special comment in the source file). +.SECONDARY: $(addsuffix .specials.make,$(all_stems_ss)) +%.beamer.make: %.specials.make + $(QUIET)$(SED) -e 's/^BEAMER.*/BEAMER/p' -e 'd' '$<' > '$@' + # Store the paper size for this document -- note that if beamer is used we set # it to the special BEAMER paper size. We only do this, however, if the # special comment exists, in which case we enlarge the output with psnup. # # The paper size is extracted from a documentclass attribute. -%.paper.make: %.tex - $(QUIET)$(SED) \ - -e '/\\documentclass/,/}/{' \ - -e ' s/%.*//' \ - -e ' H' \ - -e ' /}/{' \ - -e ' s/.*//' \ - -e ' x' \ - -e ' /\\documentclass/!d' \ - -e ' s/[\n[:space:]]*//g' \ - -e ' s/\([,{[]\)\([[:alnum:]]\{1,\}\)paper\([],}]\)/\1%-\2-%\3/g' \ - -e ' s/\([,{[]\)\(landscape\)\([],}]\)/\1%-\2-%\3/g' \ - -e ' s/^[^%]*%-//' \ - -e ' s/-%[^%]*$$//' \ - -e ' s/-%[^%]%-/ /g' \ - -e ' p' \ - -e ' }' \ - -e ' d' \ - -e '}' \ - -e 'd' \ - $< > $@; \ - $(EGREP) -q '^[^%]*\\documentclass[^{]*{beamer}' $< && \ - (\ - $(EGREP) -q '^%%[[:space:]]*BEAMER[[:space:]]*LARGE$$' $< && \ - $(ECHO) "BEAMER" > $@ || \ - : > $@ \ - ) || $(sh_true) +%.paper.make: %.specials.make + $(QUIET)$(SED) -e 's/^PAPERSIZE=//p' -e 'd' '$<' > '$@' # Store embedding instructions for this document using a special comment -%.embed.make: %.tex - $(QUIET)$(EGREP) '^%%[[:space:]]*NO[[:space:]]*EMBED[[:space:]]*$$' $< \ +%.embed.make: %.specials.make + $(QUIET)$(EGREP) '^NOEMBED$$' $< \ && $(ECHO) '' > $@ \ || $(ECHO) '1' > $@; @@ -3120,6 +3366,11 @@ _sources: $(QUIET)$(ECHO) "== Sources ==" $(QUIET)$(call echo-list,$(sort $(files.tex))) +.PHONY: _source_gens +_source_gens: + $(QUIET)$(ECHO) "== Generated Sources ==" + $(QUIET)$(call echo-list,$(sort $(files_source_gen))) + .PHONY: _scripts _scripts: $(QUIET)$(ECHO) "== Scripts ==" @@ -3277,7 +3528,7 @@ define help_text # ./generating_script.weird_lang > $$@ # # In this file, you have access to all of the variables that the -# makefile creates, like $(onlysources.tex). While accessing those can +# makefile creates, like $$(onlysources.tex). While accessing those can # be somewhat brittle (they are implementation details and may change), # it is a great way to test your ideas when submitting feature requests. # @@ -3626,6 +3877,10 @@ define help_text # assumes that the top-level rst file will change if you want a # rebuild. # +# literate Haskell: %.lhs +# +# Runs the lhs2tex program to generate a .tex file. +# # Dependencies: # # In general, dependencies are extracted directly from LaTeX output on |