summaryrefslogtreecommitdiff
path: root/support/latexmk
diff options
context:
space:
mode:
Diffstat (limited to 'support/latexmk')
-rw-r--r--support/latexmk/CHANGES692
-rw-r--r--support/latexmk/COPYING341
-rw-r--r--support/latexmk/INSTALL414
-rw-r--r--support/latexmk/README234
-rw-r--r--support/latexmk/example_rcfiles/README-latexmk-rcfiles66
-rw-r--r--support/latexmk/example_rcfiles/asymptote_latexmkrc76
-rw-r--r--support/latexmk/example_rcfiles/bib2gls_latexmkrc35
-rw-r--r--support/latexmk/example_rcfiles/clean_pattern_latexmkrc30
-rw-r--r--support/latexmk/example_rcfiles/exceltex1.sty74
-rw-r--r--support/latexmk/example_rcfiles/exceltex_latexmkrc64
-rw-r--r--support/latexmk/example_rcfiles/fix-aux.latexmkrc96
-rw-r--r--support/latexmk/example_rcfiles/glossary_latexmkrc39
-rw-r--r--support/latexmk/example_rcfiles/lualatex_latexmkrc11
-rw-r--r--support/latexmk/example_rcfiles/mpost_latexmkrc28
-rw-r--r--support/latexmk/example_rcfiles/nomenclature_latexmkrc9
-rw-r--r--support/latexmk/example_rcfiles/pdflatexmkrc77
-rw-r--r--support/latexmk/example_rcfiles/pythontex-latexmkrc39
-rw-r--r--support/latexmk/example_rcfiles/sagetex_latexmkrc21
-rw-r--r--support/latexmk/example_rcfiles/splitindex.latexmkrc29
-rw-r--r--support/latexmk/example_rcfiles/sweave_latexmkrc57
-rw-r--r--support/latexmk/example_rcfiles/tex4ht-latexmkrc33
-rw-r--r--support/latexmk/example_rcfiles/texinfo-latexmkrc76
-rw-r--r--support/latexmk/example_rcfiles/tikz-externalized-latexmkrc75
-rw-r--r--support/latexmk/example_rcfiles/xelatex_latexmkrc13
-rw-r--r--support/latexmk/extra-scripts/README-latexmk-scripts147
-rw-r--r--support/latexmk/extra-scripts/dvipdfm_call14
-rw-r--r--support/latexmk/extra-scripts/dvipdfm_call.bat19
-rw-r--r--support/latexmk/extra-scripts/dvipdfmx_call14
-rw-r--r--support/latexmk/extra-scripts/dvipdfmx_call.bat19
-rw-r--r--support/latexmk/extra-scripts/htlatexonly10
-rw-r--r--support/latexmk/extra-scripts/kickxdvi22
-rw-r--r--support/latexmk/extra-scripts/l1122
-rw-r--r--support/latexmk/extra-scripts/l2143
-rw-r--r--support/latexmk/extra-scripts/myhtlatex219
-rw-r--r--support/latexmk/extra-scripts/pst2pdf_for_latexmk49
-rw-r--r--support/latexmk/extra-scripts/pst2pdf_for_latexmk_README.txt13
-rw-r--r--support/latexmk/extra-scripts/startacroread231
-rw-r--r--support/latexmk/latexmk.13821
-rw-r--r--support/latexmk/latexmk.bat5
-rw-r--r--support/latexmk/latexmk.pdfbin0 -> 189317 bytes
-rwxr-xr-xsupport/latexmk/latexmk.pl9968
-rw-r--r--support/latexmk/latexmk.txt4620
42 files changed, 21865 insertions, 0 deletions
diff --git a/support/latexmk/CHANGES b/support/latexmk/CHANGES
new file mode 100644
index 0000000000..b3ef76ac63
--- /dev/null
+++ b/support/latexmk/CHANGES
@@ -0,0 +1,692 @@
+List of main changes in latexmk
+
+
+From v. 3.04 to v. 3.07
+ Pdf files can be made by any of three methods: pdflatex, from dvi
+ or from postscript.
+ Extra command-line options -- see documentation
+ Improved configuration options -- see documentation
+ Bug fixes, etc
+ Improved detection of dependencies
+ If latexmk exits because of an error with latex, bibtex
+ or makeindex, then it gives a non-zero exit code.
+ Under MS-Windows allow wildcards in filenames.
+
+From v. 3.07 to v. 4.01
+ Allow dvips, etc to put files in temporary location then move to
+ final location. This enables the problem to be avoided that
+ some viewers look for changes in a file and read a new file
+ before the writing of it is complete.
+ Ensure that an error in exectuing an rcfile results in an error
+ message visible to the user.
+ OS-specific initialization code now includes section for Mac OS-X.
+ Make code safe, as far as possible, for filenames containing
+ spaces.
+ Change method of detecting out-of-date-ness, etc, to examine all
+ files for changes. Keep a database (in a file with extension
+ fdb_latexmk) of the previous state of the files. The aux.bak
+ and idx.bak files are no longer used. The primary method of
+ detecting change is from the md5 checksum of a file. This deals
+ automatically with the vast majority of cases where there is
+ circular dependence of files, without needing special coding in
+ latexmk to know which input files to a LaTeX run are generated
+ from a previous run.
+ Hence make a much more systematic and general method for treating
+ dependencies.
+ Substituteable place holders allowed in command specifications, to
+ allow very general specification of commands (including multiple
+ commands, pipelines etc).
+ Extra option --dependents to list dependent files.
+ Support for multibib.sty, multind.sty, etc.
+ Support for index.sty as well as makeidx.sty.
+ Allow .latexmkrc as file name in project directory (as opposed to
+ latexmkrc).
+ Command-line option -e to allow execution of initialization code
+ from command-line invocation of latexmk.
+ Routines add_cus_dep, remove_cus_dep and show_cus_dep for
+ manipulating custom-dependency list.
+ Ability to specify lines to be ignored in computing md5 checksum of
+ a file of a particular extension. (An example would be a
+ comment line in an encapsulated postscript file that contains
+ the date and time it was created. Such lines may change without
+ having any consequence on the use of the file.)
+ Miscellaneous bug fixes, etc.
+ Improvements in parsing of log file
+
+From v. 4.01 to v. 4.05
+ Miscellaneous bug fixes
+ Fix bug that -ps -pdfps runs ps2pdf before dvips
+ Deal with quoted filenames in log file
+ Correct problem with invocation of MSWin start command
+ -c and -C now also delete fdb_latex file
+ For home directory (where user's .latexmkrc is located,
+ when $ENV{'HOME'} does not exist, use $ENV{USERPROFILE}
+ (suitable for MS-Win).
+ Correct treatment of -e option
+ Fix possibility that unwrapping of lines in log_file is done
+ incorrectly
+ Correct parsing of log file
+ Improve diagnostics of reasons for rerun of external program.
+ Fix problems when using both latex and pdflatex
+ Configurable extensions for finding cusdep
+ Change to a nicer #! line
+ Safer use of % in placeholders in commands
+
+From v. 4.05 to v. 4.07
+ In preview-continuous mode, arrange that ctrl/C used to stop the
+ processing loop does not automatically kill a script used to
+ call latexmk
+ Better handling of situation when a run of (pdf)latex does not
+ produce a dvi or pdf file, or when the opposite type of output
+ is produced than expected (e.g., pdf instead of dvi by latex)
+ Deal better with case that file is written and read by (pdf)latex
+ during a run
+
+From v. 4.07 to v. 4.10
+ Binmode for log file under MSWin to avoid problem with ctrl/Z
+ written by Miktex 2.7 giving spurious end-of-file.
+ Deal with issues in depedency structure caused by epstopdf, which
+ automatically creates pdf files from eps files during run of
+ pdflatex.
+ Correct problem with determining use of custom dependencies, when
+ file-not found-report has extensionless filename, but
+ corresponding .tex file exists.
+ Preview-continuous mode now doesn't bomb out if there are errors
+ during first run of (pdf)latex. (Previously that caused the
+ previewer not to run even if viewed file exists.)
+
+From v. 4.10 to v. 4.11
+ Corrects a long-standing bug that when the main file uses
+ bibtex, and uses \include for subdocuments, changes in
+ bibliography citations did not always trigger a rerun of bibtex.
+ Fixed a problem that latexmk did not detect changed aux files etc
+ on a small document when the run of (pdf)latex was within the
+ 1-second granularity of filetimes.
+ Improved start-up times on some large documents by avoiding
+ unnecessary recalculations of md5 checksums.
+ Deals better with eps-to-pdf conversions reported by epstopdf
+ package.
+ -silent option now causes suppression of certain messages about
+ non-existent files
+ When view files are make via a temporary file (not-yet-documented
+ feature), delete old view file before moving the temporary file.
+ (To avoid reported bug in kpdf and okular.)
+ Corrects a problem that with an error introduced at v. 4.08 that
+ on finding an error in processing one file latexmk exits rather
+ than continuing processing other requested files. The exit code
+ returned by latexmk was also incorrect in this situation
+
+From v. 4.11 to v. 4.12
+ Added an option not to run bibtex (to deal with situations
+ where a bbl file is available but not the bib file from which
+ it was made).
+ Corrected misprints in documentation.
+
+From v. 4.12 to v. 4.13
+ Corrected clean_up so aux file is deleted.
+ Default for running bibtex: Only when .bib file exists.
+ Correction insertion of bbl into list of generated extensions.
+
+From v. 4.13 to v. 4.13a
+ Corrected a problem that clean-up option (-C) failed to delete
+ certain generated files.
+
+From v. 4.13a to v. 4.15
+ Change defaults on $latex_silent_switch and $pdflatex_silent_switch
+ to make them always TeXLive compatible.
+ To avoid problems with apparent source files that are incorrectly
+ determined from the log file: (a) Make sure md5 calc doesn't
+ bomb out on directory. (b) In parsing log file: if apparent
+ dependent file is directory, remove it from list of dependent
+ files.
+ Better diagnostics at end of run with multiple files: list
+ applications of latex and pdflatex that failed.
+ Fixed problem that with -pvc when (pdf)latex failed, latexmk kept
+ doing dvips, dvipdf, etc.
+
+From v. 4.15 to v. 4.15b
+ Changed default location of system rc files for cygwin to include
+ both Unix-like and MSWindows paths.
+ Changed use of Digest module to use of Digest::MD5 module, to give
+ compatibility with the limited installation of perl shipped
+ with TeX Live.
+
+From v. 4.15b to v. 4.15c
+ Solved problem that occasionally latexmk failed to detect a
+ dependent file when it analyzed a .log file. (It incorrectly
+ treated some lines of length 79 as being wrapped.)
+
+From v. 4.15b to v. 4.16
+ Solved another problem with misparsed log files. Some versions of
+ pdflatex fail to preceed some warning messages by a new line.
+ Thus these warning messages sometimes appear to be part of a
+ filename.
+ Updated documentation to mention previously undocumented feature
+ about the use of temporary files in making ps and pdf files.
+
+From v. 4.16 to v. 4.16a
+ Sanity check on $sleep_time. (Negative times and times between 0
+ and 1 are replaced by 1.)
+ Corrected problem under preview-continuous mode that some
+ previewers would not see the changed file on an NFS file
+ system.
+
+From v. 4.16a to v. 4.17
+ Deal with bug about misparsing log file with non-space-containing
+ filename that is followed by a space and a message on same line.
+ Previously, the filename would not be detected as a dependent.
+ With $force_mode on, do a better job of completing processing.
+ Remove long-unused options -F and -F-
+
+From v. 4.17 to v. 4.18
+ Only produce "Removing no-longer-needed dependent" messages
+ when diagnostics are on.
+ In analysis of log file, add test for natbib's citation-undefined
+ warning.
+ Correct misprint in documentation.
+
+From v. 4.18 to v. 4.20
+ Fix problem that when bibtex finds no citations, this is treated
+ by bibtex as an error. Previously latexmk respected this and
+ did not continue processing. Now if the only bibtex error is
+ the finding of no citations, then latexmk now treats it as
+ only a warning and continues processing (by latex/pdflatex) as
+ appropriate.
+ Get .bst file in source file list for bibtex. (So an update to
+ the bst file provokes a rerun of the relevant programs.)
+ Allow clean-up to delete destination files of custom-dependencies
+ Configuration variable $cleanup_includes_cusdep_generated to
+ configure whether this is done. (Default is off, for backward
+ compatibility.)
+ Remove use of --width option on $pscmd on linux. It's no longer
+ needed.
+ Remove double quotes (if any) surrounding output filename read
+ from .log file, to avoid wrong diagnostic message.
+ Allow a more general pattern for files to clean up (when the -c,
+ or -C option is used). For details, see the explanation of
+ the $clean_ext variable in the latexmk documentation.
+ Options to set commands used for latex and pdflatex, as in
+ -latex=special_latex_replacement_command
+ -pdflatex=special_pdflatex_replacement_command
+ (This is not yet documented.)
+
+From v. 4.20 to v. 4.21
+ Fix some problems with parsing quoted filenames in log file.
+ These prevented latexmk working correctly with latest version
+ of asymptote.sty.
+ Corrected potential bug in locating graphics files.
+
+From v. 4.21 to v. 4.22
+ Support use of biber (with the biblatex package) for generating
+ bibliographies, with automatic selection of bibtex or biber.
+
+From v. 4.22 to v. 4.22b
+ Compatibility with biber 0.7.2. (Latexmk failed to detect .bib
+ files used by biber 0.7.2.)
+
+From v. 4.22b to v. 4.22c
+ Biber support is now compatible with MikTeX.
+
+From v. 4.22c to v. 4.22d
+ Fix compatibility problem MiKTeX v. 2.8, that latexmk didn't
+ always detect use of makeindex.
+
+From v. 4.22d to v. 4.22e
+ Fix incorrect error handling in reading initialization files.
+ (Sometimes an error was incorrectly detected, after which latexmk
+ stopped.)
+
+From v. 4.22e to v. 4.23
+ Deal with problem that if maximum number of runs of (pdf)latex is
+ exceeded, -pvc mode infinitely repeats (pdf)latex
+ Fix problem that changes in generated files during run of
+ (pdf)latex may not be detected if the run is shorter than the
+ granularity of file times.
+ Corrections of comments and messages. Documentation improvement.
+ Correctly parse blg files of biber 0.8
+ Correct handling of errors given by rc files
+ Enhancements for convenient use of latexmk with Makefiles (options
+ -deps, -deps-out, -use-make)
+ -recorder option for improved detection of input and output files.
+
+From v. 4.23 to v. 4.23a
+ Correct bug in detection of source files listed in .fls file
+
+From v. 4.23a to v. 4.24
+ When running biber, find locations of source files when they
+ aren't in the current directory (by use of kpsewhich). This was
+ previously done for bibtex but not biber.
+
+From v. 4.24 to v. 4.25
+ Fix to evade apparent cygwin bug that prevented system
+ rc-file from being read.
+ Diagnostic for unreadable rc-file.
+ Add deps output file to target part of dependency information
+
+From v. 4.25 to v. 4.26
+ Make compatible with biber 0.9.4.
+ Fix some bugs in error reporting.
+
+From v. 4.26 to v. 4.27a
+ Deal with problem that making of ps or pdf file via a temporary
+ file fails if the command making it has no %D placeholder
+ Add png to list of graphics extensions for pdflatex
+ Add -norc option that prevents auto reading of rc files.
+ Options -aux-directory -output-directory like those of (pdf)latex,
+ to set the output directories of (pdf)latex. (-aux-directory
+ is MiKTeX only). Corresponding configuration variables, and
+ placeholders for command specification.
+
+From v. 4.27a to 4.28
+ Correct handling of situations where some file(s) needed by bibtex
+ (or biber) don't exist. Previously latexmk incorrectly stopped
+ with an error message instead of continuing.
+
+From v. 4.28 to 4.28a
+ Correct duplicate making of view file
+
+From v. 4.28a to 4.28c
+ When biber doesn't find the bib file, latexmk treats this as a
+ warning rather than a fatal error, so further processing
+ can continue normally.
+ Latexmk now parses correctly error messages from biber v. 0.9.7.
+
+From v. 4.28c to 4.29a
+ Latexmk now works with the feynmp package and mpost,
+ provided a suitable custom dependency is defined. (See the
+ example latexmkrc fragment mpost_latexmkrc in the
+ example_rcfiles directory in the latexmk distribution.)
+ If output directory is set, arrange that dvips can find files
+ there.
+ In searching for cus-deps that can make a missing file, look in
+ $out_dir.
+ Solves problem that sometimes dvips and dvipdf weren't run when
+ they should have been. (The problem only arose with certain
+ changes in eps files being made within a minute of the previous
+ run.)
+
+From v. 4.29a to 4.30a
+ Fix use of bibtex so that it works correctly when $aux_dir and/or
+ $out_dir are set.
+ Use OS-dependent search path separator when when manipulating
+ TEXINPUTS, etc. Then use of -output-directory and
+ -aux-directory options should work on MSWin systems.
+ Documentation of $search_path_separator variable.
+
+From v. 4.30a to 4.31
+ Add -M -MP and -MF options, like gcc.
+ Recorder option is now on by default.
+ Add options reproducing most options of (pdf)latex (list from both
+ TeXLive and MikTeX versions).
+ Options NOT implemented by latexmk at all:
+ -ini and -initialize since they refer to operations
+ not supported by latexmk
+ -includedirectory=dir its support needs extra code in
+ latexmk, not currently written
+ Options differently processed by latexmk:
+ -help
+ -version
+ -quiet
+ Options that are passed to (pdf)latex but that also have special
+ processing by latexmk
+ -aux-directory=dir
+ -output-directory=dir
+ -recorder
+ Add -latexoption=... option to latexmk
+ Add -xelatex option for use of xelatex
+ Change OS-X default for pdf previewer command to open
+ Command specification string can start with "include routine" to
+ invoke a Perl subroutine instead of an external cmd.
+ Viewers are detached by default. (The start keyword is now normally
+ superfluous in command specifications.)
+ Keyword nostart added in command specification.
+ Add configuration variables $compiling_cmd, $success_cmd,
+ $failure_cmd. These specify external commands (if any) to be
+ executed during latexmk's continuous preview mode at the
+ following points: $compiling_cmd at the start of compilation,
+ $success_cmd at the end of a successful compilation, and
+ $failure_cmd at the end of an unsuccessful compilation. They
+ can be used, for example, to show the progress of compilation by
+ setting the titles of editor and/or previewer windows.
+ If aux and/or output directories are specified but don't exist,
+ make them.
+ Remove excessive repetition of tests for changes of source files
+ (improves performance of latexmk in some situations).
+ Documentation improvements.
+ Minor bug corrections.
+
+From v. 4.31 to 4.33a
+ Improve operation under MSWindows: substitute "\" for "/" for
+ directory separator in command lines, deal consistently with
+ directory separator, which can be both "\" and "/".
+ Correct some bugs that interfered with use of auxiliary directory
+ and output directory for files generated by (pdf)latex,
+ especially with MiKTeX.
+ Fix problems caused because in the log and fls files MiKTeX writes
+ absolute path for many filenames at and below current directory,
+ and is inconsistent in its use of "/" vs. "\" as directory
+ separator.
+ Add $dvipdf_silent_switch configuration variable.
+ Improve handling of errors in (pdf)latex; previously latexmk would
+ give up processing in some situations continuing is correct.
+ Documentation corrections/improvements.
+ Reduce number of warnings in silent operation.
+ Cure slowness of v. 4.33 under Cygwin.
+
+From v. 4.33a to 4.33b
+ Documentation improvements.
+ Improve text displayed by using -showextraoptions option.
+
+From v. 4.33b to 4.33c
+ Correct infinite loop when maximum passes through latex/pdflatex
+ are exceeded
+
+From v. 4.33c to 4.34
+ Correct non-optimality that if (pdf)latex reads a file only after
+ it has been written in the same run, the file is not a true
+ source file, but nevertheless latexmk treats it as a source
+ file. Thus changes in the file sometimes caused latexmk to make
+ unnecessary (but otherwise innocuous) extra runs of (pdflatex).
+
+From v. 4.34 to 4.35
+ Correct bug in parsing fls file from native MS-Windows LaTeX (e.g.,
+ MiKTeX) when latexmk is run under cygwin. (The names of some
+ files used by latexmk incorrectly contained a CR character.)
+ Correct bug that when the --gg option is used, the rule database
+ from the old fdb file was used instead of being cleared.
+
+From v. 4.35 to 4.37
+ Correct failure that happens when name of current directory
+ contains characters with special meaning in regular expression.
+ -rules option now works with -pvc
+ Add -lualatex option, like -xelatex.
+ File specifications in $clean_ext and $clean_full_ext are allowed
+ to contain wildcards.
+ Warnings are given when rc file is a directory instead of a file.
+ Correct bug that if revtex4-1.cls is used, footnotes are set to
+ be in the bibliography, and latexmk's aux_dir or out_dir is set,
+ then latexmk fails to run bibtex when needed, because the
+ relevant bib file is not found.
+ Other minor corrections and code improvements.
+ Documentation updates and corrections.
+
+From v. 4.37 to 4.39
+ Automatic creation of necessary subdirectories of auxdir when needed
+ for writing aux files.
+ Add error diagnostics to if_source
+ Allow $print_type = 'auto', and make this the default, so that
+ when the -p option to latexmk is used to print the file, the
+ default is to determine the type of file to be printed, rather
+ than always requiring postscript.
+ Fix the failures when dealing with directories whose names contained
+ certain special characters in them (notably '[', ']' and space).
+ [Technical issue: these characters had special meaning when
+ previously interpreted as metacharacters in a glob operation.]
+ This gives dependency on Perl's File::Glob module, which is a
+ standard module in normal installations of Perl.
+ When an output directory is a subdirectory of a directory, ensure
+ that it is correctly created, if it has to be created.
+ Previously, the creation of the output directory when it does not
+ exist only worked for one level.
+ This gives dependency on Perl's File::Path module with v. >= 2.08,
+ which is a standard module in normal installations of Perl.
+ In output of dependencies, include pathname of target file(s) in the
+ rule.
+ In -pvc mode, writing of deps file (caused by the -M and related
+ options) is per make not per overall run.
+
+From v. 4.39 to 4.39 documentation update of 2 Dec 2013
+ Correct two errors in documentation and in the file COPYING.
+
+From v. 4.39 to 4.40
+ Fix failure to clean up correctly when root filename contains [,
+ which is a glob metacharacter.
+
+From v. 4.40 to 4.41
+ -c also deletes $deps_file if it is used
+ Quote jobname when needed.
+ Change maintainer's preferred e-mail
+ Attempt to improve handling of errors from (pdf)latex.
+ Fix up for the making of -eps-converted-to.pdf
+ Improve listing of warning lines from log file.
+ Fix failure when using both -cd and -output-directory
+ If user's home directory can't be determined, then don't read ~/.latexmkrc
+ Introduce configuration variable $silence_logfile_warnings
+ In setting $pscmd, allow for non-existent environment variable USER
+ Correct subroutine Run for internal cmd w/o arguments
+ Experimental: Add analysis hook for aux file.
+ System initialization files: allow them to be named latexmkrc as
+ well as LatexMk, for more consistency with user directory names.
+ Keep both cases, to preserve backward compatibility.
+ Change sign-on message. Bug report info with help.
+
+From v. 4.41 to 4.42
+ Fix bugs associated with the -cd option
+ Add missfont.log and the generated synctex.gz to standard cleaned-up files
+
+From v. 4.42 to 4.43a
+ Fix problem that source files are not correctly detected under
+ MiKTeX when name of current working directory contains non-ASCII
+ characters.
+ On cleanup, synctex.gz files are deleted only by -C, not by -c.
+
+From v. 4.43a to 4.43c
+ Correct normalization of filenames, so that initial "./" is always
+ removed. This prevents custom dependencies being run twice on the
+ same file.
+ Documentation correction on use of @BIBINPUTS.
+ Diagnostic correction.
+ Example rc file for using texinfo (thanks to Vincent Bela\"iche).
+ Additions to documentation concerning advanced configuration.
+
+From v. 4.43c to 4.44
+ Correct bug in use of %hash_calc_ignore_pattern
+ (Previously it only had its documented effect when a targetted
+ file hadn't changed in size.)
+ Correct error handling when biber finds a malformed .bcf file.
+
+From v. 4.44 to 4.45
+ Fix problem of -C not always working correctly when compilation was
+ with -pdf and clear was default.
+ Fix bug in limiting number of passes when $max_repeat >= 10
+ Fix bug in finding id of viewer process id under OS-X
+
+From v. 4.45 to 4.46
+ Correct creation of output and aux directories to correctly handle
+ relative paths when -cd is used.
+ Minor documentation corrections.
+
+From v. 4.46 to 4.48
+ Correct documention: default value of $recorder is 1
+ Add routines rdb_list_source, rdb_set_source for manipulating
+ dependency lists of a rule. Add these to the documentated
+ interface, in addition to the already documented rdb_ensure_file,
+ rdb_remove_files.
+ Update webpages in documentation.
+
+From v. 4.48 to 4.52
+ Optimize number of calls to kpsewhich. This often gives a
+ considerable savings of run time when a document includes many
+ graphics files that are in a texmf tree.
+ Fix bug that if an .aux file is deleted and latexmk is run, the
+ wrong number of runs of (pdf)latex was made.
+ Fix related problem that latexmk sometimes does too few runs of
+ (pdf)latex because of the incorrect detection that a file is only
+ read after being written.
+ Implement direct support for xelatex and lualatex. Previously these
+ programs were used by configuring the $pdflatex so that the desired
+ program is run instead of pdflatex. There are now configuration
+ variables $xelatex and $lualatex to specify the commands used, and
+ extra command line options -pdfxe and -pdflua.
+ In the case of xelatex, considerable improvement in run time is
+ given for documents containing large graphics files. This is
+ because compilation is made first to an xdv file instead of direct
+ to a pdf file. Only when this file is finalized is a single
+ conversion to a pdf file made. (This last step can be especially
+ time-consuming for documents that bring in large graphics files.)
+ Correct detection for missing graphics files with xelatex.
+ Work around LuaTeX line-wrapping bug.
+ Update documentation.
+ Minor improvements in code and diagnostics.
+
+From v. 4.52 to 4.52b
+ Fix bug introduced in 4.52 that use of bibtex wasn't always detected
+ when recorder mode is on.
+
+From v. 4.52b to 4.52c
+ Make -jobname work with -pdfxe and -pdflua.
+
+From v. 4.52c to 4.54
+ In deps_list, correct bug in identifying generated files.
+ Otherwise, generated files could have been identified as true
+ source files.
+ Remove insertion of name of deps file in list of targets in deps file.
+ Don't send to screen deps info in deps mode (unless diagnostics on).
+ Correct ordering of list of options given by -help.
+ Fix incorrect deletion of non-generated aux files.
+ Optimize away current directory string in $out_dir and $aux_dir.
+ Make compatible with future versions of Perl where File::Glob's glob
+ function won't exist.
+ Add extra value 1.5 for $bibtex_use, with corresponding option
+ -bibtex-cond1; this treats bbl files as conditionally precious in
+ cleanup operations, depending on the existence or non-exisitence
+ of bib files.
+ When running bibtex, ensure that the change in search paths is made to work
+ around deficiencies in bibtex is local and does not affect other
+ programs.
+ Collection of timing information now works in silent mode.
+ Set better default previewers for MSys.
+ Restore default of $analyze_input_log_always to 1.
+ This restores the default detection of certain constructs for dependencies
+ for input files in the .log file. See the comments on this variable in
+ latexmk.pl for details. This works around a problem caused by a change in
+ the behavior of lualatex in TeXLive 2017; it no longer lists all input
+ files in the .fls file. Note that latexmk.pl always examines the .log
+ file for relevant information. The variable $analyze_input_log_always
+ only concerns whether it looks for <...> and (...) constructs.
+ Add item to @file_not_found for the particular format of generic package
+ warning about "No file", that is produced by glossaries-extra, and
+ probably other packages.
+ Documentation improvements, especially on methods of implementing
+ custom dependencies for multiple kinds of index.
+ Document $kpsewhich_show variable.
+ Add a sample latexmkrc file for use with bib2gls and glossaries-extra.
+
+From v. 4.54 to 4.54c
+ Work-around for when bsd_glob is not available on old installations of
+ Perl. (Note that with these old installations, clean-up operations
+ may not work when file or directory names contain spaces.)
+
+From v. 4.54c to 4.55
+ Correct bug that $search_path_separator wasn't defined under msys.
+ Ensure that all configuration variables do have sensible default
+ definitions (which wasn't always the case previously).
+ Allow optional timeout in pvc mode after a period of inactivity.
+ (See documentation for -pvctimeout option.)
+ Compensate for problems caused by time offset between system time on
+ system running latexmk and file times on remote file system.
+ (It caused wrong behavior when a document uses biber, MiKTeX
+ is used, the aux_dir is on a remote file system, and the system
+ time on the host of the file system differs from the system time on
+ the system running latexmk.)
+
+From v. 4.55 to 4.55a
+ Add option that latexmk returns a non-zero status code when
+ the final run of (pdf)latex gives warnings about undefined
+ references or citations or about multiply defined references.
+ Implement $warning_cmd to allow a visual cue for these situations in
+ pvc mode (in addition to the current possibilities for
+ $compiling_cmd, $success_cmd and $failure_cmd).
+
+From v. 4.55a to 4.56
+ Correct parsing of biber's log file.
+ Implement $warning_cmd.
+ Deal correctly with situation that files reported in the .fls file
+ as INPUT or OUTPUT files no longer exist at end of run. These
+ files aren't true source files or generated files from latexmk's
+ point of view. Such cases can arise from a bug in the TeX
+ engine (as with lualatex in TeXLive 2016/2017). They can also
+ arise when temporary files are created, read and deleted during
+ a run (as with the minted package).
+ Update example latexmrc file for pythontex.
+ Better error message when .bib file(s) not found.
+ Better handling and diagnostics when names of expected and actual
+ names of .log disagree.
+ In particular, there is some automatic reconfiguration when .log
+ file is not in expected place (e.g., because $aux_dir is different
+ to $out_dir, but TeXLive is used, so -aux-directory option for TeX
+ engines isn't supported).
+ Fix problem of .bib files sometimes not being found by bibtex when
+ latexmk runs under msys and -outputdirectory is specified.
+ Add use of environment variable LATEXMKRCSYS to specify system rc
+ file.
+
+From v. 4.56 to 4.57
+ Correct problem that in calculation of md5 checksum, an error
+ sometimes occurs about malformed utf8 characters. This can happen
+ if the environment variable PERL_UNICODE is set.
+ Add configuration variable $bibtex_fudge to allow to choose
+ whether to use the fudge that made bibtex run correctly when
+ an output directory (or aux directory) is specified. (A
+ planned future version of bibtex in TeXLive will not need
+ the fudge.)
+
+From v. 4.57 to 4.59
+ Deal with double quote ('"') characters in files on command line to
+ correspond to behavior of tex programs. Remove balanced pairs,
+ and give fatal error for unbalanced double quotes. (Note MiKTeX's
+ tex programs simply remove unbalanced quotes.) In all cases, the
+ '"' character is not allowed in a filename read by tex and
+ friends.
+ Give fatal error when name of tex file on command line is either not
+ allowed by tex and friends , or gives problematic behavior.
+ Use TEXINPUTS as search path for source files for custom
+ dependency.
+ Only give warning about differing expected and output filenames when
+ the extensions differ. All other cases gave only false positives.
+ Do better to ensure xelatex gets its -no-pdf option.
+
+From v. 4.59 to 4.61
+ Add -pdfxelatex and -pdflualatex options to set commands for
+ xelatex and lualatex (in analogy with -pdflatex and -latex).
+ Correct bug that use of -gg option with -deps-file option
+ did not create deps file.
+ After run of latex/pdflatex (etc), report count of warnings about missing
+ characters (typically unavailable Unicode characters). Messages about
+ this may appear only in the .log file and are therefore easily missed
+ by the user.
+ Fix problem that if biber gets a remote file, latexmk would report it
+ incorrectly as a missing file.
+ Provide routines for setting all of $latex, etc, with a common pattern.
+ Variables, options, placeholders for executing code in *latex before
+ inputting source file. The new variable is $pre_tex_code, the
+ options are -pretex, -usepretex, and the new placeholders are %P
+ and %U.
+ Improved definitions provided for the configuration of latexmk to
+ use pythontex; see the file pythontex-latexmkrc in the directory
+ example_rcfiles.
+ Correction to use of specifications in $clean_ext and
+ $clean_full_ext so that %R can appear in the interior of a string
+ as in 'pythontex-files-%R/*'.
+ Updates of documentation.
+
+From v. 4.61 to 4.63b
+ Update example_rcfiles/glossary_latexmkrc
+ Fix problem that in -cd mode, an error is raised when the path
+ part of the tex filename contains a character prohibited by *tex.
+ Implement changing of rule network when output of *latex is not what
+ is expected, e.g., because \pdfoutput is used in document.
+ Implement placeholder for true basename of main tex file, and use it
+ in jobname.
+ Various bug fixes.
+
+From v. 4.63b to 4.64
+ Fix problem that rules processing dvi and xdv did not always run after
+ rapid-fire changes in graphics files.
+
+From v. 4.64 to 4.64a
+ Fix incorrect listings by -rules and by -deps
+
+From v. 4.64a to 4.65
+ Fix incorrect parsing of long quoted filenames in log file that sometimes
+ prevented latexmk from running.
diff --git a/support/latexmk/COPYING b/support/latexmk/COPYING
new file mode 100644
index 0000000000..b411c8b4fe
--- /dev/null
+++ b/support/latexmk/COPYING
@@ -0,0 +1,341 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/support/latexmk/INSTALL b/support/latexmk/INSTALL
new file mode 100644
index 0000000000..9cb537bfcc
--- /dev/null
+++ b/support/latexmk/INSTALL
@@ -0,0 +1,414 @@
+ INSTALLING latexmk
+ ==================
+ (Version 4.65, 18 June 2019)
+
+ John Collins
+ Physics Department
+ Penn State University
+ 104 Davey Lab, Box 208
+ University Park PA 16802
+ U.S.A.
+
+ http://www.personal.psu.edu/jcc8/
+ http://www.personal.psu.edu/jcc8/latexmk/
+ username jcc8 at node psu.edu
+
+Latexmk is a "make" tool for building latex documents. It runs latex
+and/or pdflatex the appropriate number of times to resolve cross
+references etc, and, if necessary, it also runs makeindex and/or
+bibtex (or biber) and other programs when appropriate. Then it can
+make postscript or pdf files, print the result or preview it, as
+requested. It can also be set to run continuously with a previewer;
+the latex program, etc, are then rerun whenever one of the source
+files is modified. Latexmk automatically determines file dependencies
+from the LaTeX .log and .fls files.
+
+Latexmk can be installed and used on UNIX (including LINUX and OS-X),
+and MS Windows (tested under WinXP and some later versions). It can
+presumably be used on other systems with suitable customization.
+
+On all systems, the prequisites are
+
+a. A working installation of Perl. (See http://www.cpan.org/ if you
+ don't have one. Modern UNIX-like systems, particularly linux and
+ OS-X, normally have perl installed by default. As for MSWindows,
+ the TeXLive distribution (2009 or later) includes Perl, and also
+ includes latexmk.)
+
+b. A working installation of TeX and LaTeX. (See http://www.ctan.org/ if
+ you don't have one.)
+
+c. In addition, the installation of TeX and LaTex should, of course,
+ contain the packages etc that are needed for your specific
+ documents to be compiled and processed.
+
+
+!!!! IMPORTANT NOTE: !!!!
+===========================
+
+If you have installed a modern distribution of TeX and friends, you
+may find that latexmk is already installed on your computer. This is
+true for full installations of TeXLive 2009 or later on the operating
+systems it supports. (Note that MacTeX on OS-X incorporates TeXLive,
+so anything said about TeXLive also applies to MacTeX.) If you have
+only installed a subset of packages, e.g., because you installed
+BasicTeX, then the subset may not include latexmk; in that case you
+should be able to use your distribution's package manager to install
+latexmk. This is generally the recommended method; only use the
+manual installation method below if you have a special need for it.
+However, you should still examine the information on configuration
+here and in the main documentation to get latexmk working exactly as
+you want it.
+
+You can test whether latexmk is already properly installed by trying
+the command "latexmk -v" from the command line. If this succeeds,
+then latexmk is already installed. Otherwise, if you are using
+TeXLive or MacTeX, then you can simply use its package manager to get
+latexmk installed, the same as for any other missing package.
+
+If you are on MS-Windows and you are using TeXLive (2009, or later),
+this distribution also includes a distribution of Perl sufficient to
+run latexmk.pl, so you don't need to install Perl separately. It also
+includes an executable file latexmk.exe that runs latexmk, so you
+don't have to use the latexmk.bat that is part of the latexmk
+distribution.
+
+In the case of MiKTeX, the other standard distribution for MS-Windows,
+the main difference from TeXLive as regards latexmk is that you may
+need to install a distribution of Perl. A standard default
+installation of Perl should enable latexmk to work.
+
+
+Installing on UNIX/LINUX/OS-X
+=============================
+
+(Power users can modify these as appropriate.)
+
+NOTE: If you are using TeXLive 2009 or later, you can install latexmk
+simply by using the TeXLive package manager (that includes users of
+MacTeX on OS-X). In fact, depending on how much of TeXLive you have
+already installed, latexmk may already have been installed. In that
+case you don't normally need to bother with the manual installation
+explained below. Still you may need to examine the configuration
+instructions.
+
+1. Make sure you have working installations of Perl and TeX/LaTeX.
+
+2. Put the file latexmk.pl in a directory for executable files. For
+ example, for a system-wide installation, you could put it in
+ /usr/local/bin. But if you are an ordinary user, you can put the
+ file somewhere where you have access, and ensure that the PATH
+ environment variable includes the directory where latexmk is
+ installed.
+
+3. Rename this file to latexmk.
+
+4. Make sure latexmk is executable, e.g., by using chmod suitably.
+ [Special case, which you probably don't have to be concerned
+ with: You may also find it necessary to change the first line
+ of the script so that perl can be found to execute latexmk.
+ Currently the first line is #!/usr/bin/env perl, which uses
+ the program /usr/bin/env to find perl, provided only that the
+ perl executable can be found in the PATH for executables.
+ This insulates latexmk from the fact that the Perl executable
+ has a system-dependent location. The program /usr/bin/env is
+ present on almost all modern UNIX/Linux systems.]
+
+5. (Optional) Copy the file latexmk.1 to an appropriate directory for man
+ pages, e.g., /usr/local/man/man1/.
+
+ Alternatively, or in addition, put the file latexmk.pdf in a
+ suitable place for pdf files for documentation.
+
+6. Check whether the commands used by latexmk for executing latex etc
+ are correct. The ones you particularly have to worry about are
+ those for previewing files ($pdf_previewer, $ps_previewer, and
+ $dvi_previwer), and most importantly $pscmd, and its associated
+ variable $pid_position --- see below. The command $pscmd is the
+ least obvious: it runs the command ps and is used in
+ preview_continuous_mode to determine whether a previewer is
+ already running. The format of the output of ps is highly system
+ dependent. Latexmk should get it right under LINUX and OS-X.
+ If latexmk does not get this or another command correct, put an
+ override in a startup file:
+
+ a. For a system-wide installation, the correction should be in the
+ system startup file, which is any one of the files
+ /opt/local/share/latexmk/LatexMk,
+ /usr/local/share/latexmk/LatexMk,
+ /usr/local/lib/latexmk/LatexMk,
+ /opt/local/share/latexmk/latexmkrc,
+ /usr/local/share/latexmk/latexmkrc,
+ /usr/local/lib/latexmk/latexmkrc.
+ (You get to choose which, but only one. If none of these
+ directories is appropriate you'll need to modify latexmk.pl.)
+
+ Those directories apply to Unix-like operating systems
+ (including linux and OS-X). On MS-Windows, the system
+ start-up file is one of C:\latexmk\LatexMk
+ C:\latexmk\latexmkrc (If you happen to use Cygwin, latexmk
+ combines both the MS-Windows and the Unix possibilities.)
+
+ b. If you are installing latexmk as an ordinary user, the startup
+ file is the user startup file, which is the file .latexmkrc in
+ your home directory.
+
+ (Under normal circumstances, latexmk's definition of home
+ directory under Unix-like operating systems is the usual one,
+ i.e., the value in the environment variable HOME. Under
+ MS-Windows, a user's home directory is normally the directory
+ of the user profile, as given in the environment variable
+ USERPROFILE. In general, latexmk takes a user's home
+ directory to be the directory specified in the first of the
+ environment variables HOME and USERPROFILE that is non-empty.)
+
+ The startup files are written in Perl, so possible overrides are like
+
+ $latex = 'unusual_program_to_run_instead_of_normal_latex %O %S';
+
+ for changing the program to run latex, and
+
+ $pscmd = 'ps -aeg';
+ $pid_position = 1;
+
+ for the ps command. Here, $pid_position = 1 indicates that the
+ process ID number is in the first column of the output of the
+ command ps. See the latexmk.pl file for some more examples.
+
+ To determine what commands latexmk currently uses run the
+ following:
+
+ latexmk --commands
+
+
+7. If you need any modifications on the commands for running previewers,
+ like gv, note that prefixing a command by start, as in
+
+ $ps_previewer = 'start gv -watch %O %S';
+
+ ensures that the command is run detached, as is normally appropriate
+ for a previewer.
+
+ (In the examples above, there appear the strings %O and %S. See
+ the documenation for details. They are placeholders used when
+ latexmk constructs the command line. %O denotes any options
+ latexmk wants to add to the command invocation, and %S denotes the
+ source file.)
+
+8. You may also want to change the defaults on what kinds of output
+ file latexmk makes. By default latexmk makes dvi files, but not
+ postscript or pdf files. If you (or people on your system)
+ generally make pdf files using pdflatex, it would be a good idea
+ to put the following in an appropriate initialization file:
+
+ $pdf_mode = 1;
+ $postscript_mode = 0;
+ $dvi_mode = 0;
+
+ This change is particularly useful for Mac OS-X. See step 6 for
+ the locations of the initialization/configuration files (under
+ UNIX-like systems), where you should put this lines.
+
+
+Installing on MS-Windows
+========================
+
+(Power users can modify these as appropriate.)
+
+NOTE: If you are using TeXLive 2009 or later, you can install latexmk
+simply by using the TeXLive package manager. In fact, depending on
+how much of TeXLive you have already installed, latexmk may already
+have been installed. In that case you don't normally need to bother
+with the manual installation explained below.
+
+Similarly if you have MiKTeX, you can install latexmk by using
+MiKTeX's package manager. But to allow latexmk to work, you will also
+need to install a distribution of Perl if you haven't done so already.
+
+1. Make sure you have working installations of Perl and TeX/LaTeX,
+ complete with viewers for dvi and/or postscript files. You will
+ also need whatever packages your document needs.
+
+2. If necessary, unpack the latexmk distribution. [Note: It is a
+ good idea to unpack the files so that they have the correct
+ line-end characters for MS-Windows. For example, if you use unzip
+ on latexmk.zip, the command unzip -a latexmk.zip should do the
+ job. If you don't do this conversion, it probably won't matter,
+ since much software, including Perl, MikTeX and emacs, handles
+ MS-Windows and UNIX line ends equally well.]
+
+3. Copy the files latexmk.pl and latexmk.bat to a suitable directory
+ (your choice). One possibility is a directory C:\local\bin. You will
+ need to make sure this directory in the search path for executable
+ files --- see the next step.
+
+4. If the directory in the previous step is NOT already in the search
+ path for executable files, arrange for this, by adjusting the
+ environment variable PATH suitably. Suppose the latexmk directory
+ is C:\local\bin. (Warning: the exact details of the instructions
+ below are subject to change as new versions of MS-Windows come out,
+ so you may need to do some exploration to find the equivalents of
+ the instructions under other versions; the principles remain
+ unchanged.)
+
+ a. In Windows XP, there is an item in the Control Panel to adjust
+ the environment: normally Control Panel -> Performance and
+ Maintenance -> System. The pick the tab Advanced and click on
+ Environment Variables.
+
+ (i) If you are a REGULAR user, examine the User variables. If
+ there is already an entry for PATH, append a semicolon and
+ then the name of latexmk's directory (e.g., C:\local\bin).
+ If not, then make a new variable named PATH with the value
+ %PATH%;C:\local\bin
+
+ (ii) If you are an administrator, examine the System variables,
+ and adjust the entry to PATH, as above.
+
+ b. OBSOLETE: ONLY in Windows 95, 98 and ME: you will need to add a
+ line to the end of the C:\AUTOEXEC.BAT file. Suppose the
+ directory for latexmk is named C:\local\bin, then the line you
+ add is
+
+ PATH %PATH%;C:\local\bin
+
+ This change will take effect the next time you reboot.
+
+5. (Optional) Copy documentation file(s) to a suitable directory. The
+ only requirement on the directory is your convenience: some convenient
+ place to look up documentation. The relevant files are latexmk.txt
+ which is a pure ASCII text file, and latexmk.pdf which is a postscript
+ file.
+
+6. Check whether perl is in the search path for executables. (E.g.,
+ from the MS-Windows command-line prompt, try the command perl
+ --version.) If perl is not in the search path, then modify the
+ first line of latexmk.bat (which you installed at step 2) by
+ replacing the command perl by the full path name for perl, e.g.,
+ C:\perl\bin\perl.exe.
+
+7. You may need to reboot, or at least logoff and log back in, if you
+ made any changes to the path at step 3. Test out the installation
+ at the command-line prompt:
+
+ a. First do
+
+ latexmk --version
+
+ This should show you the version number of latexmk. If this works
+ latexmk is accessible. If not, you will have to figure out what
+ did not work in the previous steps.
+
+ b. Then change to a directory where you have a good LaTeX file.
+ Suppose the file is paper.tex. Delete any pre-existing dvi file,
+ so that latexmk is forced to remake the output files. The
+ following commands will check out the main features of latexmk:
+
+ latexmk paper
+ latexmk -pv paper
+ latexmk -pv -ps paper
+
+ The first command will create the dvi file, running latex a
+ suitable number of times, and additionally running bibtex and
+ makeindex, but only if needed. The second command will open a
+ viewer of the dvi file. The third command will create a postscript
+ file, and then open a viewer for it.
+
+ c. If the above works, you are done. If not, you will have to figure
+ out what is wrong, and correct it. FIRST, READ THE DOCUMENTATION!
+ The normal problems are that the names for the commands used by
+ latexmk are incorrect for your system, or they are not present on
+ your system. See the next item for how to customize latexmk.
+ Also LOOK AT THE SECTION NAMED "TRICKY POINTS" below to see some
+ hints.
+
+
+8. If the commands used by latexmk are incorrect, see the UNIX
+ installation instructions for what to do. The only changes needed
+ from the UNIX instructions are:
+
+ a. The system initialization file is C:\latexmk\LatexMk. (If
+ this is not suitable for some reason, you'll need to change
+ the latexmk.pl file where this filename appears.)
+
+ b. The user initialization file is .latexmkrc in the directory
+ specified by the environment variable HOME. If there is no HOME
+ variable, then the file is in the directory specified by the
+ environment variable USERPROFILE, which should have been set
+ by the MS-Windows operating system at login.
+
+
+
+Other systems
+=============
+
+For other systems you are on your own. The instructions for
+UNIX/LINUX and MS-Windows should help you to see what to do. Let me
+know (username jcc8 at node psu.edu) what happens, so that I
+can update these instructions and possibly latexmk as well.
+
+
+Tricky points
+=============
+
+1. BEWARE of filenames with double extensions, for example,
+ two.part.tex. The behavior of TeX-related software is not
+ consistent in this situation. You may, for example, find a log
+ file named two.log or two.part.log, depending on which version of
+ which implementation of TeX/LaTeX you use. Naturally, there is a
+ possibility in this situation that latexmk will get confused, and
+ not recognize, for example, that a dvi file has been generated.
+ Latexmk has configuration variables to deal with some of the
+ possibilities, so you could try playing with them --- see the
+ code. But it general, it is best to avoid such double extensions:
+ they make your files non-portable. Do something like two-part.tex
+ or two_part.tex instead.
+
+2. The same goes for filenames and directory names with spaces in
+ them. Much software tends to interpret spaces as separators
+ between different filenames or between filenames and other text.
+ This can cause problems in some of the programs called by latexmk.
+ It can also cause problems when latexmk parses a .log file to
+ determine dependency information. Latexmk does try to correctly
+ treat filenames with spaces, as do current implementations of the
+ TeX program.
+
+3. Beware also of files and directories whose names contain non-ASCII
+ characters. There are some tricky problems because of mismatches
+ between character codings as used by different software and
+ operating systems. Latexmk tries to do its best, but problems can
+ arise.
+
+4. If you need to remake documentation files, e.g., latexmk.pdf or
+ latexmk.txt, from the man page file latexmk.1, the following
+ commands work (on my linux and OS-X systems at least):
+
+ Postscript file from latexmk.1:
+
+ groff -Tps -man-old -rcR=0 latexmk.1 > latexmk.ps
+
+ Pdf file from postscript:
+
+ ps2pdf latexmk.ps latexmk.pdf
+
+ Text file:
+
+ groff -Tascii -man-old -rcR=0 latexmk.1 > latexmk.txt
+
+
+
+Credits
+=======
+
+The original version of this program was called 'go', and written by David
+Musliner. That version is Copyright 1992 by David J. Musliner and The
+University of Michigan.
+
+Version 2 was modified by Evan McLean.
+
+The current version is by John Collins (username jcc8 at node
+psu.edu) -- other contact details at the top. It is copyright
+1998-2019 by John Collins, and the previous authors; see the copyright
+notice in the latexmk.pl file, which gives permission to use, copy,
+modify, and distribute this software and its documentation under the
+terms of the GNU Public License v. 2.
diff --git a/support/latexmk/README b/support/latexmk/README
new file mode 100644
index 0000000000..3353af467f
--- /dev/null
+++ b/support/latexmk/README
@@ -0,0 +1,234 @@
+Latexmk, version 4.65, 18 June 2019
+-----------------------------------
+
+Latexmk completely automates the process of generating a LaTeX
+document. Essentially, it is a highly specialized cousin of the
+general make utility. Given the source files for a document, latexmk
+issues the appropriate sequence of commands to generate a .dvi, .ps,
+.pdf or hardcopy version of the document, including repeated running
+of the programs until cross references etc are resolved. Latexmk can also
+be set to run continuously with a previewer; the latex program, etc,
+are rerun whenever one of the source files is modified.
+
+Latexmk automatically determines file dependencies from the LaTeX .log
+file. It features: a fully reliable algorithm for deciding how many
+times to run latex and related programs, automatic detection of
+dependent files, the ability to generate pdf files using pdflatex or
+via dvi or postscript files, and the continuous-preview mode. For
+bibliographies, the current version now supports biber as well as the
+traditional bibtex. Which of bibtex or biber to use is determined
+automatically.
+
+Please read the man page (or the corresponding text or postscript
+file) for details of what latexmk does and what all the features are.
+A copy of the fast help that can be seen by doing "latexmk -h" is at
+the end of this file.
+
+Latexmk is a perl script. It is licensed under the GNU General Public
+License v. 2.
+
+It was modified by Evan McLean from the original script called "go"
+written by David J. Musliner. Now it is supported by
+
+ John Collins
+ Physics Department
+ Penn State University
+ 104 Davey Lab, Box 208
+ University Park PA 16802
+ U.S.A.
+
+ http://www.personal.psu.edu/jcc8/
+ username jcc8 at node psu.edu
+
+The start of the script file has copyright notices and disclaimers. It
+also has a modification history for those who are interested.
+
+NOTES:-
+
+1) See the INSTALL file for installation instructions
+
+2) Portability under various UNIX-type systems (including Linux):
+ A special hack is used at the beginning of the latexmk script to ensure
+ that it correctly runs without the need to adjust a #! line. All that
+ is necessary is that the script has execute permission.
+
+3) Portability under non-UNIX systems:
+ Under other operating systems some other arrangement needs to be made
+ to run the file. For example under MS-Windows, the supplied batch file
+ latexmk.bat will do this. Under current TeXLive (2009 or later)
+ distribution, latexmk can be installed by TeXLive's package
+ manager, in which case an executable program is also installed to
+ run latexmk.pl, and an appropriate version of Perl is part of the
+ TeXLive system.
+
+ You may also find it necessary to convert files to the correct
+ local format for text files. As downloaded, the files are in UNIX
+ format (line-ending is '\n'). On MS-Windows systems, the
+ conversion to MSDOS format (with line-ending '\r\n') is normally
+ UNnecessary, since much current software handles the UNIX format
+ correctly. (The known current software for which this statement
+ applies includes MikTeX, TeXLive, emacs.)
+
+4) Portability: The various commands to process LaTeX files made need to
+ be changed for particular installations. See the INSTALL file and the
+ documentation for information on customization.
+
+5) Portability: Users of different UNIX-like systems may have to change
+ the "$pscmd" variable in their RC file if the -pvc option is to work
+ perfectly. Refer to $pscmd in the man page.
+
+6) Latexmk can be downloaded from the author's site at
+ http://www.personal.psu.edu/jcc8/latexmk/
+ This site also includes previous versions, and sometimes newer
+ versions under development.
+
+7) Latexmk is archived on the CTAN tex archive --- see
+ http://www.ctan.org/pkg/latexmk
+
+John Collins
+---------------------------- "latexmk -h" ----------------------------
+Latexmk 4.65: Automatic LaTeX document generation routine
+
+Usage: latexmk [latexmk_options] [filename ...]
+
+ Latexmk_options:
+ -aux-directory=dir or -auxdir=dir
+ - set name of directory for auxiliary files (aux, log)
+ - Currently this only works with MiKTeX
+ -bibtex - use bibtex when needed (default)
+ -bibtex- - never use bibtex
+ -bibtex-cond - use bibtex when needed, but only if the bib file exists
+ -bibtex-cond1 - use bibtex when needed, but only if the bib file exists;
+ on cleanup delete bbl file only if bib file exists
+ -bm <message> - Print message across the page when converting to postscript
+ -bi <intensity> - Set contrast or intensity of banner
+ -bs <scale> - Set scale for banner
+ -commands - list commands used by latexmk for processing files
+ -c - clean up (remove) all nonessential files, except
+ dvi, ps and pdf files.
+ This and the other clean-ups are instead of a regular make.
+ -C - clean up (remove) all nonessential files
+ including aux, dep, dvi, postscript and pdf files
+ and file of database of file information
+ -CA - clean up (remove) all nonessential files.
+ Equivalent to -C option.
+ -CF - Remove file of database of file information before doing
+ other actions
+ -cd - Change to directory of source file when processing it
+ -cd- - Do NOT change to directory of source file when processing it
+ -dependents or -deps - Show list of dependent files after processing
+ -dependents- or -deps- - Do not show list of dependent files
+ -deps-out=file - Set name of output file for dependency list,
+ and turn on showing of dependency list
+ -dF <filter> - Filter to apply to dvi file
+ -dvi - generate dvi
+ -dvi- - turn off required dvi
+ -e <code> - Execute specified Perl code (as part of latexmk start-up
+ code)
+ -f - force continued processing past errors
+ -f- - turn off forced continuing processing past errors
+ -gg - Super go mode: clean out generated files (-CA), and then
+ process files regardless of file timestamps
+ -g - process regardless of file timestamps
+ -g- - Turn off -g
+ -h - print help
+ -help - print help
+ -jobname=STRING - set basename of output file(s) to STRING.
+ (Like --jobname=STRING on command line for many current
+ implementations of latex/pdflatex.)
+ -l - force landscape mode
+ -l- - turn off -l
+ -latex=<program> - set program used for latex.
+ (replace '<program>' by the program name)
+ -latexoption=<option> - add the given option to the (pdf)latex command
+ -logfilewarninglist or -logfilewarnings
+ give list of warnings after run of (pdf)latex
+ -logfilewarninglist- or -logfilewarnings-
+ do not give list of warnings after run of (pdf)latex
+ -lualatex - use lualatex for processing files to pdf
+ and turn dvi/ps modes off
+ -M - Show list of dependent files after processing
+ -MF file - Specifies name of file to receives list dependent files
+ -MP - List of dependent files includes phony target for each source file.
+ -new-viewer - in -pvc mode, always start a new viewer
+ -new-viewer- - in -pvc mode, start a new viewer only if needed
+ -nobibtex - never use bibtex
+ -nodependents - Do not show list of dependent files after processing
+ -norc - omit automatic reading of system, user and project rc files
+ -output-directory=dir or -outdir=dir
+ - set name of directory for output files
+ -pdf - generate pdf by pdflatex
+ -pdfdvi - generate pdf by dvipdf
+ -pdflatex=<program> - set program used for pdflatex.
+ (replace '<program>' by the program name)
+ -pdflualatex=<program> - set program used for lualatex.
+ (replace '<program>' by the program name)
+ -pdfps - generate pdf by ps2pdf
+ -pdflua - generate pdf by lualatex
+ -pdfxe - generate pdf by xelatex
+ -pdfxelatex=<program> - set program used for xelatex.
+ (replace '<program>' by the program name)
+ -pdf- - turn off pdf
+ -ps - generate postscript
+ -ps- - turn off postscript
+ -pF <filter> - Filter to apply to postscript file
+ -p - print document after generating postscript.
+ (Can also .dvi or .pdf files -- see documentation)
+ -pretex=<TeX code> - Sets TeX code to be executed before inputting source
+ file, if commands suitable configured
+ -print=dvi - when file is to be printed, print the dvi file
+ -print=ps - when file is to be printed, print the ps file (default)
+ -print=pdf - when file is to be printed, print the pdf file
+ -pv - preview document. (Side effect turn off continuous preview)
+ -pv- - turn off preview mode
+ -pvc - preview document and continuously update. (This also turns
+ on force mode, so errors do not cause latexmk to stop.)
+ (Side effect: turn off ordinary preview mode.)
+ -pvc- - turn off -pvc
+ -pvctimeout - timeout in pvc mode after period of inactivity
+ -pvctimeout- - don't timeout in pvc mode after inactivity
+ -pvctimeoutmins=<time> - set period of inactivity (minutes) for pvc timeout
+ -quiet - silence progress messages from called programs
+ -r <file> - Read custom RC file
+ (N.B. This file could override options specified earlier
+ on the command line.)
+ -recorder - Use -recorder option for (pdf)latex
+ (to give list of input and output files)
+ -recorder- - Do not use -recorder option for (pdf)latex
+ -rules - Show list of rules after processing
+ -rules- - Do not show list of rules after processing
+ -showextraoptions - Show other allowed options that are simply passed
+ as is to latex and pdflatex
+ -silent - silence progress messages from called programs
+ -stdtexcmds - Sets standard commands for *latex
+ -time - show CPU time used
+ -time- - don't show CPU time used
+ -use-make - use the make program to try to make missing files
+ -use-make- - don't use the make program to try to make missing files
+ -usepretex - Sets commands for *latex to use extra code before inputting
+ source file
+ -usepretex=<TeX code> - Equivalent to -pretex=<TeX code> -usepretex
+ -v - display program version
+ -verbose - display usual progress messages from called programs
+ -version - display program version
+ -view=default - viewer is default (dvi, ps, pdf)
+ -view=dvi - viewer is for dvi
+ -view=none - no viewer is used
+ -view=ps - viewer is for ps
+ -view=pdf - viewer is for pdf
+ -Werror - treat warnings from called programs as errors
+ -xelatex - use xelatex for processing files to pdf
+ and turn dvi/ps modes off
+
+ filename = the root filename of LaTeX document
+
+-p, -pv and -pvc are mutually exclusive
+-h, -c and -C override all other options.
+-pv and -pvc require one and only one filename specified
+All options can be introduced by '-' or '--'. (E.g., --help or -help.)
+
+In addition, latexmk recognizes many other options that are passed to
+latex and/or pdflatex without interpretation by latexmk. Run latexmk
+with the option -showextraoptions to see a list of these
+
+Report bugs etc to John Collins <jcc8 at psu.edu>.
diff --git a/support/latexmk/example_rcfiles/README-latexmk-rcfiles b/support/latexmk/example_rcfiles/README-latexmk-rcfiles
new file mode 100644
index 0000000000..19690cf168
--- /dev/null
+++ b/support/latexmk/example_rcfiles/README-latexmk-rcfiles
@@ -0,0 +1,66 @@
+The files in this directory provide suggestions for customizing an
+initialization file ("rc file") for latexmk. See the latexmk
+documentation for general information on its initialization files.
+
+Not only do these files provide solutions to particular problems, but
+they can be also used as inspiration for solutions to other cases.
+
+NOTES:
+
+1. The examples are not complete rc files, but contain fragments that
+ you can copy to one of your .latexmkrc/latexmkrc files.
+
+2. These examples are developed by particular users to solve
+ particular problems. You may have to customize them for your own
+ needs. So read the comments carefully, and understand how the
+ examples are working.
+
+3. I have generally arranged for filenames to be quoted on command
+ lines, e.g.,
+
+ system( "makeindex -o \"$_[0].lnd\" \"$_[0].ldx\"" );
+
+ In many cases the quotes may be omitted, as in
+
+ system( "makeindex -o $_[0].lnd $_[0].ldx" );
+
+ But it is preferable to leave the quotes in, since they provide
+ safety against special characters in filenames. The double quotes
+ appear not to cause problems in all situations that I have tried.
+
+5. Note that the files for exceltex and pythontex illustrate an answer
+ to an issue that arises in the following generic situation:
+ a. A LaTeX package wants to use an external program to do some
+ processing. It does this by writing a control file that is used
+ by the external program.
+ b. The user is to run the external program after a first run of
+ latex/pdflatex (etc). It generates some files that are to be
+ read by a subsequent compilation of the TeX document.
+ c. It is desired to do the run of the external program and
+ to do the extra run of latex/pdflatex only when necessary.
+ d. Possibly there are further dependencies on files used by the
+ external program.
+ The third problem is handled nicely by latexmk's normal mechanisms,
+ but it is necessary to persuade it to create a suitable rule to run
+ the external program. A nice trick with custom dependencies,
+ illustrated by exceltex and pythontex examples, gets the rule set
+ up. The exceltex shows how dependencies on other files can be
+ determined.
+
+6. Further assistance for latexmk can be provided when style files
+ provide suitable messages about missing files. See the
+ exceltex1.sty file for an example of what is needed. This file is
+ a modification of exceltex.sty and pythontex.sty that provide the
+ necessary assistance. (The version on which the modification is
+ based is the one current on 30 April 2013.) The necessary support
+ is in pythontex, in v. 0.16.
+
+7. Another technique, exemplified in pythontex-latexmkrc, is to append
+ lines to the .log file to simulate messages about missing files.
+ This provokes latexmk into deducing that the files are intended
+ source files. If one of the other rules then can make that file,
+ correct dependency information is obtained.
+
+
+
+
diff --git a/support/latexmk/example_rcfiles/asymptote_latexmkrc b/support/latexmk/example_rcfiles/asymptote_latexmkrc
new file mode 100644
index 0000000000..45f32979d0
--- /dev/null
+++ b/support/latexmk/example_rcfiles/asymptote_latexmkrc
@@ -0,0 +1,76 @@
+# This shows how to use Asymptote (http://asymptote.sourceforge.net/,
+# or http://www.ctan.org/pkg/asymptote/)
+# with latexmk. Asymptote is a vector graphics language with a
+# processing program that generates graphics files that can be used in
+# a LaTex file.
+#
+# A standard method of using it is with the asymptote LaTeX style file
+# (http://mirror.ctan.org/graphics/asymptote/doc/asymptote.sty)
+# The graphics drawing code is in the tex file, and applying pdflatex to
+# the tex file produces one or more files with a base name the same as
+# or related to the main tex file, but with the extension 'asy'. The
+# .asy is processed by the program asy (part of the asymptote
+# software) to produce graphics files (which may be eps, tex, or pdf
+# files) that are used the next time pdflatex is run on the main tex
+# file.
+#
+# Latexmk can be arranged to run asymptote (i.e., the program asy)
+# when needed, by defining the following custom dependency. (The code
+# is to be put in one of latexmk's rc files, e.g., ~/.latexmkrc.)
+#
+
+## OLD simple method (taken from the documentation for V. 2.03 of
+## asymptote). These definitions are simple, but they may not always
+## give the desired type of output file, and they do not ensure that
+## latexmk has dependency information about files imported from the
+## asy file.
+#OLD sub asy {return system("asy \"$_[0]\"");}
+#OLD add_cus_dep("asy","eps",0,"asy");
+#OLD add_cus_dep("asy","pdf",0,"asy");
+#OLD add_cus_dep("asy","tex",0,"asy");
+
+
+# The following definitions arrange to run asy with the correct output
+# file type. They run asy in a verbose mode so that dependency
+# information on imported files can be extracted. To avoid adding a
+# lot of extra printout on the screen of unimportant messages, the
+# output is sent to a log file. Since this includes error messages,
+# which the user should see, latexmk types out error messages and the
+# like. These definitions need latexmk 4.48 or later.
+
+add_cus_dep("asy","eps",0,"asy2eps");
+add_cus_dep("asy","pdf",0,"asy2pdf");
+add_cus_dep("asy","tex",0,"asy2tex");
+
+sub asy2eps { return asy2x( $_[0], 'eps' ); }
+sub asy2pdf { return asy2x( $_[0], 'pdf' ); }
+sub asy2tex { return asy2x( $_[0], 'tex' ); }
+
+sub asy2x {
+ my $ret = system("asy -vv -f '$_[1]' '$_[0]' >& '$_[0].log'");
+ my $FH = new FileHandle;
+ open $FH, "$_[0].log";
+ %imp = ();
+
+ while (<$FH>) {
+ if (/^(Including|Loading) .* from (.*)\s*$/) {
+ my $import = $2;
+ $imp{$import} = 1;
+ }
+ elsif ( /^error/ || /^.*\.asy: \d/ ) {
+ warn "==Message from asy: $_";
+ $ret = 1;
+ }
+ elsif ( /^kpsewhich / || /^Processing / || /^Using /
+ || /^Welcome / || /^Wrote /|| /^cd /|| /^gs /
+ ) {
+ }
+ else {
+ warn "==Message from asy: $_";
+ }
+ }
+ close $FH;
+# For latexmk 4.48
+ rdb_set_source( $rule, keys %imp );
+ return $ret;
+}
diff --git a/support/latexmk/example_rcfiles/bib2gls_latexmkrc b/support/latexmk/example_rcfiles/bib2gls_latexmkrc
new file mode 100644
index 0000000000..53f13ff30a
--- /dev/null
+++ b/support/latexmk/example_rcfiles/bib2gls_latexmkrc
@@ -0,0 +1,35 @@
+# Implementing glossary with bib2gls and glossaries-extra, with the
+# log file (.glg) analyzed to get dependence on a .bib file.
+
+# !!! ONLY WORKS WITH VERSION 4.54 or higher of latexmk
+
+push @generated_exts, 'glstex', 'glg';
+
+add_cus_dep('aux', 'glstex', 0, 'run_bib2gls');
+
+sub run_bib2gls {
+ if ( $silent ) {
+ my $ret = system "bib2gls --silent --group '$_[0]'";
+ } else {
+ my $ret = system "bib2gls --group '$_[0]'";
+ };
+
+ my ($base, $path) = fileparse( $_[0] );
+ if ($path && -e "$base.glstex") {
+ rename "$base.glstex", "$path$base.glstex";
+ }
+
+ # Analyze log file.
+ local *LOG;
+ $LOG = "$_[0].glg";
+ if (!$ret && -e $LOG) {
+ open LOG, "<$LOG";
+ while (<LOG>) {
+ if (/^Reading (.*\.bib)\s$/) {
+ rdb_ensure_file( $rule, $1 );
+ }
+ }
+ close LOG;
+ }
+ return $ret;
+}
diff --git a/support/latexmk/example_rcfiles/clean_pattern_latexmkrc b/support/latexmk/example_rcfiles/clean_pattern_latexmkrc
new file mode 100644
index 0000000000..b15507c623
--- /dev/null
+++ b/support/latexmk/example_rcfiles/clean_pattern_latexmkrc
@@ -0,0 +1,30 @@
+# To allow more general pattern in $clean_ext instead of just an
+# extension or something containing %R.
+# This is done by overriding latexmk's cleanup1 subroutine.
+
+# Here is an example of a usefule application:
+$clean_ext = "*-eps-converted-to.pdf";
+
+sub cleanup1 {
+ # Usage: cleanup1( directory, pattern_or_ext_without_period, ... )
+ #
+ # The directory is a fixed name, so I must escape any glob metacharacters
+ # in it:
+ print "========= MODIFIED cleanup1 cw latexmk v. 4.39 and earlier\n";
+ my $dir = fix_pattern( shift );
+
+ # Change extensions to glob patterns
+ foreach (@_) {
+ # If specified pattern is pure extension, without period,
+ # wildcard character (?, *) or %R,
+ # then prepend it with directory/root_filename and period to
+ # make a full file specification
+ # Else leave the pattern as is, to be used by glob.
+ # New feature: pattern is unchanged if it contains ., *, ?
+ (my $name = (/%R/ || /[\*\.\?]/) ? $_ : "%R.$_") =~ s/%R/$dir$root_filename/;
+ unlink_or_move( glob( "$name" ) );
+ }
+} #END cleanup1
+
+
+
diff --git a/support/latexmk/example_rcfiles/exceltex1.sty b/support/latexmk/example_rcfiles/exceltex1.sty
new file mode 100644
index 0000000000..270f94d818
--- /dev/null
+++ b/support/latexmk/example_rcfiles/exceltex1.sty
@@ -0,0 +1,74 @@
+%% THIS IS A MODIFICATION BY JOHN COLLINS 30 Apr 2013 OF V. 0.5.1 OF
+%% exceltex.sty TO HELP latexmk.
+%% The modification consists of changing the calls to the
+%% \InputIfFileExists macro to a call to a new macro that provides a
+%% warning message when the file to be read does not exist.
+
+% get data from excel files into LaTeX
+%
+% (c) 2004-2006 by Hans-Peter Doerr <doerr@cip.physik.uni-freiburg.de>
+% 2013 John Collins <collins@phys.psu.edu>
+%
+% exceltex is free software. you can redistribute or modify it under
+% the terms of the GNU GENERAL PUBLIC LICENSE Version 2. See COPYING for
+% details.
+%
+\def\exceltexVersion{0.5.1JCC}
+%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{exceltex1}[2013/04/30 v.\exceltexVersion]
+\DeclareOption{cellrefs}{\def\cellrefs{1}}
+\ProcessOptions
+%
+\typeout{This is exceltex v\exceltexVersion}
+% ulem needs option normalem for not breaking \em and \emph
+\RequirePackage[normalem]{ulem}
+\RequirePackage{color}
+%\RequirePackage{eurosym}
+%
+
+%% JCC's addition:
+\providecommand\InputFileOrMessage[3]{%
+ \InputIfFileExists{#1}%
+ {#2}%
+ {#3\PackageWarning{exceltex1}{File `#1' not found.}}%
+}
+%%
+
+\newcounter{exceltexCounterC}\setcounter{exceltexCounterC}{0}
+\newcounter{exceltexCounterT}\setcounter{exceltexCounterT}{0}
+%
+\immediate\openout 10=\jobname.excltx
+%
+%
+% write index header
+\ifx\cellrefs\undefined
+%
+\else
+\immediate\write 10{;cellrefs}
+\fi
+\immediate\write 10{;created by exceltex v. \exceltexVersion}
+%
+\newcommand{\inccell}[1]{%
+ \stepcounter{exceltexCounterC}%
+ \ifx\cellrefs\undefined%
+ \immediate\write 10{c:\theexceltexCounterC:#1}%
+ \InputFileOrMessage{\jobname-excltx/c-\theexceltexCounterC}{}{}%
+ \else
+ \immediate\write 10{c:#1}%
+ \InputFileOrMessage{\jobname-excltx/c-#1}{}{}%
+ \fi
+}%
+%
+%
+\newcommand{\inctab}[1]{%
+ \stepcounter{exceltexCounterT}%
+ \ifx\cellrefs\undefined%
+ \immediate\write 10{t:\theexceltexCounterT:#1}%
+ \InputFileOrMessage{\jobname-excltx/t-\theexceltexCounterT}{}{\\}%
+ \else
+ \immediate\write 10{t:#1}%
+ \InputFileOrMessage{\jobname-excltx/t-#1}{}{\\}%
+ \fi
+}%
+\endinput
diff --git a/support/latexmk/example_rcfiles/exceltex_latexmkrc b/support/latexmk/example_rcfiles/exceltex_latexmkrc
new file mode 100644
index 0000000000..e1cf68424f
--- /dev/null
+++ b/support/latexmk/example_rcfiles/exceltex_latexmkrc
@@ -0,0 +1,64 @@
+# This shows how to use the exceltex package with latexmk
+#
+# Exceltex is a package that enables LaTeX documents to use data from
+# Excel spreadsheets. It has two parts: a LaTeX package in a file
+# named exceltex.sty and a (Perl) script named exceltex. The custom
+# dependency given below enables latexmk to call the exceltex script
+# whenever appropriate.
+#
+# The functioning is as follows: The main tex file uses the package
+# exceltex to specify the use of the contents of cells in an xls
+# spreadsheet. It does this by writing a specification of the cells to
+# a file with extension excltx. The script exceltex reads this,
+# extracts the data from the spreadsheet(s), and writes them in files
+# that are read during the next compilation of the main document. (The
+# exceltex package, with its script, is part of the current version of
+# TeXLive, as of 2012.)
+#
+# In addition to running the exceltex script, the subroutine defined
+# below also reads the excltx file to find the names of the
+# spreadsheet files used. It then uses an internal subroutine of
+# latexmk to add these files to the source-file list of the custom
+# dependency. Thus if the spreadsheet file (or files) changes, even
+# without any other changes, latexmk will know to rerun exceltex and
+# then recompile the main tex file if necessary.
+#
+# Notes:
+# 1. See
+# http://tex.stackexchange.com/questions/107764/exceltex-dependencies-in-latexmk
+# for the motivation, and see the exceltex documentation for an
+# example of the use of the exceltex package.
+# 2. You may find you need to install certain Perl modules in
+# order for the exceltex script to work; these modules are needed
+# for parsing excel spreadsheets. You'll need to examine
+# documentation for Perl to find out how to do this.
+
+
+add_cus_dep('excltx', 'tex', 0, 'excel2tex');
+sub excel2tex {
+ # This subroutine is a fudge, because it from latexmk's point of
+ # view, it makes the main .tex file depend on the .excltx file.
+ # But it doesn't actually make the .tex file, but is used for its
+ # side effects in creating other files. The dependence is a way
+ # of triggering the rule to be run whenever the .excltx file
+ # changes, and to do this before running latex/pdflatex again.
+
+ # First find dependency/ies on .xls files, by parsing the .excltx file,
+ my $Hsource = new FileHandle;
+ my %xls = ();
+ my $source = "$_[0].excltx";
+ if (! open $Hsource, "<$source") {
+ warn "excel2tex subroutine: Could not read '$source'\n";
+ return 1;
+ }
+ while ( <$Hsource> ) {
+ if ( /^\s*;/ ) { next; }
+ if ( /^\s*[ct]:[^:]*\:([^!]*)!/ ) { $xls{$1} = 1; }
+ }
+ close $Hsource;
+ foreach (keys %xls) {
+ rdb_ensure_file( $rule, $_ );
+ }
+ return system("exceltex \"$_[0]\"") ;
+}
+
diff --git a/support/latexmk/example_rcfiles/fix-aux.latexmkrc b/support/latexmk/example_rcfiles/fix-aux.latexmkrc
new file mode 100644
index 0000000000..9b01210a14
--- /dev/null
+++ b/support/latexmk/example_rcfiles/fix-aux.latexmkrc
@@ -0,0 +1,96 @@
+# This shows how to implement the use of different values for $aux_dir and
+# $out_dir when the latex (etc) engines don't support the -aux-directory
+# option. (Of the standard distributions, MiKTeX supports -aux-directory,
+# but TeXLive does not.)
+
+
+foreach my $cmd ('latex', 'lualatex', 'pdflatex', 'xelatex' ) {
+ ${$cmd} = "internal latex_fix_aux $cmd %O %S";
+}
+$xelatex =~ s/%O/-no-pdf %O/;
+
+
+#---------------------------
+
+sub latex_fix_aux {
+ # Fudge to allow use of -aux_directory option with non-MiKTeX system.
+ # This subroutine is called to do a compilation by one of latex, pdflatex,
+ # etc. It's arguments are the command name, and the command-line arguments,
+ # including possible uses of the options -aux-directory, -output-directory.
+ # Functioning:
+ # 1. Obtain the values of the aux and output directories from the options
+ # on the command line, with appropriate defaults if one or both options
+ # is not used.
+ # 2. Change the command line (a) to avoid the use of the -aux-directory
+ # option, and (b) to use the -output-directory to get all output
+ # sent to the intended aux-directory. If neither an -aux-directory
+ # nor an -output-directory option is used, no change is made to the
+ # command line.
+ # 3. Run the command.
+ # 4. If the aux and output directories are different, move any of the dvi,
+ # fls, ps and pdf files that are present in the intended aux directory
+ # to the intended output directory.
+ # N.B. It might seem more appropriate to keep the fls file in the aux
+ # directory. But MiKTeX puts it in the output directory, so we must do
+ # the same to copy its behavior.
+ # It might also seem appropriate for an xdv file to go in the output
+ # directory, like a dvi file. But xelatex under MiKTeX puts it in the
+ # aux directory, so we must copy that behavior.
+
+ # Determine aux and output directories from command line:
+ my $auxD = '';
+ my $outD = '';
+ foreach (@_) {
+ if ( /^-{1,2}aux-directory=(.*)$/ ) {
+ $auxD = $1;
+ }
+ elsif ( /^-{1,2}output-directory=(.*)$/ ) {
+ $outD = $1;
+ }
+ }
+ if ( $outD eq '' ) { $outD = '.'; }
+ if ( $auxD eq '' ) { $auxD = $outD; }
+
+# Construct modified command line, with at most one occurrence of -output-directory
+ my @args_act = ();
+ my $set_outD = 0;
+ foreach (@_) {
+ if ( /^-{1,2}(aux|output)-directory=.*$/ ) {
+ if ( ! $set_outD ) {
+ push @args_act, "-output-directory=$auxD";
+ $set_outD = 1;
+ }
+ }
+ else {
+ push @args_act, $_;
+ }
+ }
+
+# Construct strings for aux and output directories that are suitable
+# for prepending to a file name, so that they have any necessary
+# directory separators:
+ my $outD1 = $outD;
+ my $auxD1 = $auxD;
+ foreach ( $auxD1, $outD1 ) {
+ # Append directory separator '/', but only for a non-empty name
+ # that isn't simple an MSWin drive name.
+ if ( ($_ ne '') && ! m([\\/\:]$) ) {
+ $_ .= '/';
+ }
+ # Clean up by removing any sequence of './'. These refer to
+ # current directory.
+ while ( s[^\.\/][] ) {}
+ }
+
+ print "Running: '@args_act'\n";
+ my $ret = system @args_act;
+ if ($auxD ne $outD) {
+ print "Moving dvi, fls, ps, pdf files from '$auxD' to '$outD'\n";
+ foreach my $ext ('dvi', 'fls', 'ps', 'pdf' ) {
+ rename "$auxD1$root_filename.$ext", "$outD1$root_filename.$ext",;
+ }
+ }
+ return $ret;
+}
+
+#---------------------------
diff --git a/support/latexmk/example_rcfiles/glossary_latexmkrc b/support/latexmk/example_rcfiles/glossary_latexmkrc
new file mode 100644
index 0000000000..2c15e9aac6
--- /dev/null
+++ b/support/latexmk/example_rcfiles/glossary_latexmkrc
@@ -0,0 +1,39 @@
+# This shows how to use
+# the glossaries package (http://www.ctan.org/pkg/glossaries)
+# the glossaries-extra package (http://www.ctan.org/pkg/glossaries-extra)
+# with latexmk.
+
+# N.B. There is also the OBSOLETE glossary package
+# (http://www.ctan.org/pkg/glossary), which has some differences. See items
+# 2 and 3
+
+# 1. If you use the glossaries or the glossaries-extra package, then you use:
+
+ add_cus_dep( 'acn', 'acr', 0, 'makeglossaries' );
+ add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' );
+ $clean_ext .= " acr acn alg glo gls glg";
+ sub makeglossaries {
+ my ($name, $path) = fileparse( $$Psource );
+ return system "makeglossaries -d '$path' '$name'";
+ }
+
+
+# 2. If you use the OBSOLETE glossary package, then you can do
+
+ add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' );
+ sub makeglo2gls {
+ system("makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" );
+ }
+
+# 2. If you use the OBSOLETE glossary package, then you can do
+# the following for acronyms:
+
+ # ONLY FOR PACKAGE glossary, NOT FOR glossaries and glossaries-extra
+ add_cus_dep( 'acr', 'acn', 0, 'makeacr2acn' );
+ sub makeacr2acn {
+ system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acn\" \"$_[0].acr\"" );
+ }
+
+# ===> WARNING: In the current glossaries and glossaries-extra packages
+# the roles of the .acr and .acn files are exchanged, so the above
+# code will fail with the more modern packages.
diff --git a/support/latexmk/example_rcfiles/lualatex_latexmkrc b/support/latexmk/example_rcfiles/lualatex_latexmkrc
new file mode 100644
index 0000000000..dd36ddf002
--- /dev/null
+++ b/support/latexmk/example_rcfiles/lualatex_latexmkrc
@@ -0,0 +1,11 @@
+# This shows how to use lualatex (http://en.wikipedia.org/wiki/LuaTeX)
+# with latexmk.
+#
+# WARNING: The method shown here is suitable only for ver. 4.51 and
+# later of latexmk, not for earlier versions.
+#
+
+$pdf_mode = 4;
+$postscript_mode = $dvi_mode = 0;
+
+
diff --git a/support/latexmk/example_rcfiles/mpost_latexmkrc b/support/latexmk/example_rcfiles/mpost_latexmkrc
new file mode 100644
index 0000000000..c1b3e13d4f
--- /dev/null
+++ b/support/latexmk/example_rcfiles/mpost_latexmkrc
@@ -0,0 +1,28 @@
+# N.B. ===> (3, 4 Mar 2014) This file contains a correction relative to
+# the previous version
+
+# This shows how to use mpost, as used by the feynmp package.
+# The feynmp package writes files with extension .mp, e.g., foo.mp,
+# and these are to be converted by mpost to make postscript files,
+# e.g., foo.1, which are later read in by dvips.
+#
+# A more complicated custom dependency is needed than normal, because:
+# if the output directory ($out_dir) or the auxiliary directory
+# ($aux_dir) is set, mpost doesn't put its output in the correct
+# place.
+
+add_cus_dep( 'mp', '1', 0, 'mpost' );
+
+
+sub mpost {
+ my $file = $_[0];
+ my ($name, $path) = fileparse( $file );
+ my $return = system "mpost \"$file\"";
+ # Fix the problem that mpost puts its output and log files
+ # in the current directory, not in the auxiliary directory
+ # (which is often the same as the output directory):
+ move "$name.1", $path;
+ move "$name.log", $aux_dir;
+ return $return;
+}
+
diff --git a/support/latexmk/example_rcfiles/nomenclature_latexmkrc b/support/latexmk/example_rcfiles/nomenclature_latexmkrc
new file mode 100644
index 0000000000..4c6817c9a8
--- /dev/null
+++ b/support/latexmk/example_rcfiles/nomenclature_latexmkrc
@@ -0,0 +1,9 @@
+# This shows how to use the nomencl package for making a nomenclature
+# with latexmk.
+# (See http://www.ctan.org/pkg/nomencl for information on the nomencl package.)
+
+
+add_cus_dep("nlo", "nls", 0, "nlo2nls");
+sub nlo2nls {
+ system("makeindex $_[0].nlo -s nomencl.ist -o $_[0].nls -t $_[0].nlg");
+}
diff --git a/support/latexmk/example_rcfiles/pdflatexmkrc b/support/latexmk/example_rcfiles/pdflatexmkrc
new file mode 100644
index 0000000000..6f43e982ec
--- /dev/null
+++ b/support/latexmk/example_rcfiles/pdflatexmkrc
@@ -0,0 +1,77 @@
+# Use of glossaries, extra indexes, epstopdf, and other images conversions
+# Thanks to Herb Schulz
+
+
+$pdflatex = 'pdflatex --shell-escape %O %S';
+
+# Custom dependency for glossary/glossaries package
+# if you make custom glossaries you may have to add items to the @cus_dep_list and corresponding sub-routines
+add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' );
+sub makeglo2gls {
+ system( "makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" );
+}
+# The glossaries package, with the [acronym] option, produces a .acn file when processed with (xe/pdf)latex and
+# then makeindex to process the .acn into .acr and finally runs of (xe/pdf)latex to read in the .acr file. Unfortunately
+# the glossary package does just the reverse; i.e. (xe/pdf)latex processing produces a .acr files and makeindex then
+# is used to convert the .acr file to a .acn file which is then ... . This dependency assumes the glossaries package.
+add_cus_dep( 'acn', 'acr', 0, 'makeacn2acr' );
+sub makeacn2acr {
+ system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acr\" \"$_[0].acn\"" );
+}
+# for glossary package (Sigh...) --- they can co-exist!
+add_cus_dep( 'acr', 'acn', 0, 'makeacr2acn' );
+sub makeacr2acn {
+ system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acn\" \"$_[0].acr\"" );
+}
+# example of an added custom glossary type that is used in some of the glossary/glossaries example files:
+# this is for the new glossary type command \newglossary[nlg]{notation}{not}{ntn}{Notation} from the glossaries package
+# NOTE: the glossary package uses a very different command: the <in-ext> and <out-ext>
+# are reversed in the calling sequence :-(
+add_cus_dep( 'ntn', 'not', 0, 'makentn2not' );
+sub makentn2not {
+ system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].not\" \"$_[0].ntn\"" );
+}
+# for the glossary package (Sigh...) --- they can co-exist!
+add_cus_dep( 'not', 'ntn', 0, 'makenot2ntn' );
+sub makenot2ntn {
+ system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].ntn\" \"$_[0].not\"" );
+}
+
+# dependencies for custom indexes using the index package
+# examples for sample.tex for index package:
+ add_cus_dep( 'adx', 'and', 0, 'makeadx2and' );
+sub makeadx2and {
+ system( "makeindex -o \"$_[0].and\" \"$_[0].adx\"" );
+}
+add_cus_dep( 'ndx', 'nnd', 0, 'makendx2nnd' );
+sub makendx2nnd {
+ system( "makeindex -o \"$_[0].nnd\" \"$_[0].ndx\"" );
+}
+add_cus_dep( 'ldx', 'lnd', 0, 'makeldx2lnd' );
+sub makeldx2lnd {
+ system( "makeindex -o \"$_[0].lnd\" \"$_[0].ldx\"" );
+}
+
+# Custom dependency and function for nomencl package
+add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' );
+sub makenlo2nls {
+ system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" );
+}
+
+# Custom dependency and function(s) for epstopdf package
+
+# FOR USERS OF epstopf v1.4 and before: should also work with v1.5 and later
+# note: you may get extras runs if you use the .eps extension in the \includgraphics command
+# deletes an outdated pdf-image, and triggers a pdflatex-run
+add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_delete_dest' );
+
+# FOR USERS OF epstopdf v1.5 and later only:
+# load it as \usepackage[update,prepend]{epstopdf}
+# detects an outdated pdf-image, and triggers a pdflatex-run
+#add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_require_primary_run' );
+
+# Custom dependecy to convert tif to png
+add_cus_dep( 'tif', 'png', 0, 'maketif2png' );
+sub maketif2png {
+ system( "convert \"$_[0].tif\" \"$_[0].png\"" );
+}
diff --git a/support/latexmk/example_rcfiles/pythontex-latexmkrc b/support/latexmk/example_rcfiles/pythontex-latexmkrc
new file mode 100644
index 0000000000..ba02de3ee7
--- /dev/null
+++ b/support/latexmk/example_rcfiles/pythontex-latexmkrc
@@ -0,0 +1,39 @@
+# Support for pythontex in v. 0.16 or higher, with latexmk 4.62 or higher
+#
+# What these definitions provide/do:
+# 1. Variable specifying command string for invoking pythontex
+# 2. Addition to %extra_rule_spec of template for pythontex rule. This
+# tells latexmkrc to create the rule when it is initializing for
+# processing a TeX file.
+# 3. A subroutine mypythontex that the pythontex rule is defined to
+# call. This runs pythontex and then sets dependency information.
+# 4. Settings for the files generated by the pythontex package and the
+# pythontex program so that the files are deleted in a clean-up
+# operation.
+
+$clean_ext .= " pythontex-files-%R/* pythontex-files-%R";
+push @generated_exts, 'pytxcode';
+
+$pythontex = 'pythontex %O %S';
+$extra_rule_spec{'pythontex'} = [ 'internal', '', 'mypythontex', "%Y%R.pytxcode", "%Ypythontex-files-%R/%R.pytxmcr", "%R", 1 ];
+
+sub mypythontex {
+ my $result_dir = $aux_dir1."pythontex-files-$$Pbase";
+ my $ret = Run_subst( $pythontex, 2 );
+ rdb_add_generated( glob "$result_dir/*" );
+ my $fh = new FileHandle $$Pdest, "r";
+ if ($fh) {
+ while (<$fh>) {
+ if ( /^%PythonTeX dependency:\s+'([^']+)';/ ) {
+ print "Found pythontex dependency '$1'\n";
+ rdb_ensure_file( $rule, $aux_dir1.$1 );
+ }
+ }
+ undef $fh;
+ }
+ else {
+ warn "mypythontex: I could not read '$$Pdest'\n",
+ " to check dependencies\n";
+ }
+ return $ret;
+}
diff --git a/support/latexmk/example_rcfiles/sagetex_latexmkrc b/support/latexmk/example_rcfiles/sagetex_latexmkrc
new file mode 100644
index 0000000000..a97702a9c7
--- /dev/null
+++ b/support/latexmk/example_rcfiles/sagetex_latexmkrc
@@ -0,0 +1,21 @@
+# This is to allow the use of sagetex package
+# (http://www.ctan.org/pkg/sagetex)
+# with latexmk. Sagetex outputs a file with the extension .sage.
+# This file is to be processed by sage software (http://sagemath.org)
+# to make a file with extension .sout. This file is then read in by
+# sagetex during a later run of (pdf)latex.
+#
+# This can be done by normal custom dependency. However the .sage
+# contains unimportant information about line numbers for error
+# reporting. It is useful not to rerun sage if this is the only
+# information that has changed in the .sage file. So the
+# hash_calc_ignore_pattern variable is used to configure latexmk to
+# ignore this lines when computing whether the .sage file has
+# changed.
+
+
+add_cus_dep( 'sage', 'sout', 0, 'makesout' );
+$hash_calc_ignore_pattern{'sage'} = '^( _st_.goboom|print .SageT)';
+sub makesout {
+ system( "sage \"$_[0].sage\"" );
+}
diff --git a/support/latexmk/example_rcfiles/splitindex.latexmkrc b/support/latexmk/example_rcfiles/splitindex.latexmkrc
new file mode 100644
index 0000000000..4509538dd7
--- /dev/null
+++ b/support/latexmk/example_rcfiles/splitindex.latexmkrc
@@ -0,0 +1,29 @@
+$clean_ext .= " %R-*.ind %R-*.idx %R-*.ilg %R-*.ind";
+
+$makeindex = 'internal splitindex';
+
+sub splitindex {
+ # Use splitindex instead of makeindex.
+ # The splitindex programe starts from an .idx file, makes a set of
+ # other .idx files for separate indexes, and then runs makeindex to
+ # make corresponding .ind files.
+ # However, it is possible that the document uses the splitindex
+ # package, but in a way compatible with the standard methods
+ # compatible with makeindex, i.e., with a single index and with the
+ # use of the \printindex command.
+ # Then we need to invoke makeindex.
+ # In addition, latexmk assumes that makeindex or its replacement makes
+ # an .ind file from an .idx file, and latexmk gives an error if it
+ # doesn't exist, we need to make an .ind file.
+ # Both problems are solved by running makeindex and then splitindex.
+ # Note: errors are returned by makeindex and splitindex for things
+ # like a missing input file. No error is returned for lines in an
+ # input file that are in an incorrect format; they are simply
+ # ignored. So no problem is caused by lines in the .idx file
+ # that are generated by splitindex in a format incompatible with
+ # makeindex.
+ my $ret1 = system( "makeindex", $$Psource );
+ my $ret2 = system( "splitindex", $$Psource );
+ return $ret1 || $ret2;
+}
+
diff --git a/support/latexmk/example_rcfiles/sweave_latexmkrc b/support/latexmk/example_rcfiles/sweave_latexmkrc
new file mode 100644
index 0000000000..19f046be6b
--- /dev/null
+++ b/support/latexmk/example_rcfiles/sweave_latexmkrc
@@ -0,0 +1,57 @@
+# This is to allow the use of Sweave with latexmk, and in addition to
+# make synctex work properly with it.
+# SEE THE IMPORTANT NOTES below.
+#
+# Sweave (http://www.stat.uni-muenchen.de/~leisch/Sweave/) is a tool
+# that allows to embed the R code for complete data analyses in latex
+# documents. The user edits a file with an extension like .Rnw, and
+# the .tex file is generated from this.
+#
+# Four problems are solved by the code below:
+# 1. Generate the .tex file automatically.
+# 2. Arrange not to re-run unmodified chunks of R code. (A pure
+# optimization.)
+# 3. Fix the execution environment for (pdf)latex.
+# 4. Deal with synctex: If the user wants to use synctex
+# (www.tug.org/TUGboat/tb29-3/tb93laurens.pdf) to synchronize the
+# pdf file with the source file, by default synctex does the
+# synchronization with the generated .tex file, not the original
+# source file. Postprocessing of the .synctex.gz file is necessary
+# to fix this.
+#
+# The following version was worked out and tested by a user (thanks
+# to Brian Beitzel) on MSWindows. It will need at least one change to
+# work on UNIX-like operating systems (which include Linux and OS-X).
+
+# N.B. ===> IMPORTANT NOTES <===
+#
+# 1. The patchDVI package for R needs to be installed from R-Forge, as
+# follows:
+#
+# install.packages("patchDVI", repos="http://R-Forge.R-project.org")
+#
+# 2. In all Sweave (.Rnw) documents, the following lines must be included:
+#
+# \usepackage{Sweave}
+# \SweaveOpts{concordance=TRUE}
+
+
+# Fix the pdflatex command to run Sweave first, and to postprocess the
+# .synctex.gz file:
+# !!!!! THIS IS THE VERSION FOR MS-WINDOWS, with && as a command
+# separator
+$pdflatex = "cmd /c "
+ . "Rscript -e \"library(cacheSweave); setCacheDir(getwd()); "
+ . "Sweave('%S', driver=cacheSweaveDriver)\""
+ . " && R CMD pdflatex -interaction=nonstopmode -synctex=1 %O %B.tex"
+ . " && Rscript -e "
+ . "\"library('patchDVI');patchSynctex('%B.synctex.gz')\"";
+#
+# !!!TO FIX THIS FOR Linux/OS-X/UNIX, try uncommenting the following:
+# (this version hasn't been tested).
+#$pdflatex = "Rscript -e \"library(cacheSweave); setCacheDir(getwd()); "
+# . "Sweave('%S', driver=cacheSweaveDriver)\""
+# . " ; R CMD pdflatex -interaction=nonstopmode -synctex=1 %O %B.tex"
+# . " ; Rscript -e "
+# . "\"library('patchDVI');patchSynctex('%B.synctex.gz')\"";
+
diff --git a/support/latexmk/example_rcfiles/tex4ht-latexmkrc b/support/latexmk/example_rcfiles/tex4ht-latexmkrc
new file mode 100644
index 0000000000..de486d8d8b
--- /dev/null
+++ b/support/latexmk/example_rcfiles/tex4ht-latexmkrc
@@ -0,0 +1,33 @@
+# Sometime in the future, latexmk will directly support the use of
+# TeX4ht to obtain html from tex. Meanwhile, here is how to use
+# latexmk with TeX4ht. There is a script htlatex supplied by the
+# TeX4ht package: It simply runs latex a fixed number of times and
+# then the programs tex4ht and t4ht. To use latexmk to get optimal
+# processing use the following instructions (under UNIX-like operating
+# systems, e.g., OS-X and linux):
+#
+# 1. Put the scripts htlatexonly and myhtlatex2 somewhere in the PATH
+# for executables (and make sure they have excutable permissions
+# set).
+# 2. Set up an initialization file for latexmk like this one.
+#
+# 3. To process file.tex to make file.html, run
+#
+# myhtlatex2 file
+#
+
+# Since these instructions use scripts that are UNIX shell scripts,
+# the instructions work as written for UNIX-like operating
+# systems. Users of other operating systems will have to adjust them
+# and modify the scripts suitably.
+
+
+warn "latexmkrc for htlatex\n";
+
+$dvi_mode = 1;
+$pdf_mode = 0;
+$quote_filenames = 0;
+$latex = 'htlatexonly %S';
+
+$clean_ext .= ' 4ct 4tc idv lg tmp xref';
+$clean_full_ext .= ' css html';
diff --git a/support/latexmk/example_rcfiles/texinfo-latexmkrc b/support/latexmk/example_rcfiles/texinfo-latexmkrc
new file mode 100644
index 0000000000..3a21a3c15d
--- /dev/null
+++ b/support/latexmk/example_rcfiles/texinfo-latexmkrc
@@ -0,0 +1,76 @@
+# Modifications 2015 Sep 9-10, John Collins
+# Copyright 2014 Vincent Belaïche <vincent.b.1@hotmail.fr>
+
+# With the settings here, latexmk can be used to process texinfo files
+# (typical extension .texi) to pdf files, including the making of
+# indices. This version uses a newly documented internal routine
+# of latexmk.
+
+###!!!!!!!!! NOTE THAT THE NAMES OF THE INDEX FILES ARE POSSIBLY
+### SUBJECT TO CHANGE IN FUTURE VERSIONS OF texinfo.
+### The configuration provided by this file was valid in
+### September 2015. (The file texinfo.tex had version
+### 2015-07-01.07.)
+
+$quote_filenames = 1;
+$pdflatex = 'internal mylatex %R %Z pdftex %O %S';
+$latex = 'internal mylatex %R %Z etex %O %S';
+
+sub mylatex {
+ my $root = shift;
+ my $dir_string = shift;
+ my $ret = system @_;
+ for my $ext (split " ",$texinfo_indices){
+ my $idx = $dir_string.$root.'.'.$ext;
+ my $ind = $idx.'s';
+ if ( (-e $idx) && (-s $idx) ) {
+ # Only make dependency on the ind-like file
+ # if the idx-like file both exists and is of
+ # non-zero length. The test on the length is
+ # needed because current versions of texindex
+ # produce no output file if the input file is
+ # of zero length.
+ rdb_ensure_file( $rule, $ind );
+ }
+ }
+ return $ret;
+}
+
+# Please add needed other extensions if there are other user defined indices
+$texinfo_indices = 'ky fn cp vr tp pg';
+
+$clean_ext .= ' ' . $texinfo_indices;
+$clean_full_ext .= ' pdf toc aux';
+
+for my $ext (split " ",$texinfo_indices){
+ my $index_ext = $ext . 's';
+ add_cus_dep( $ext, $index_ext, 1, $ext . '_texindex');
+ add_input_ext('pdflatex', $index_ext);
+ add_input_ext('latex', $index_ext);
+ $clean_ext .= " $index_ext";
+}
+
+sub ky_texindex
+{
+ system( "texindex \"$_[0].ky\"" );
+}
+sub fn_texindex
+{
+ system( "texindex \"$_[0].fn\"" );
+}
+sub cp_texindex
+{
+ system( "texindex \"$_[0].cp\"" );
+}
+sub vr_texindex
+{
+ system( "texindex \"$_[0].vr\"" );
+}
+sub tp_texindex
+{
+ system( "texindex \"$_[0].tp\"" );
+}
+sub pg_texindex
+{
+ system( "texindex \"$_[0].pg\"" );
+}
diff --git a/support/latexmk/example_rcfiles/tikz-externalized-latexmkrc b/support/latexmk/example_rcfiles/tikz-externalized-latexmkrc
new file mode 100644
index 0000000000..22ed6f7d38
--- /dev/null
+++ b/support/latexmk/example_rcfiles/tikz-externalized-latexmkrc
@@ -0,0 +1,75 @@
+# This shows how to deal with tikz when it is used in its externalized mode.
+#
+# Here is an example of a document that uses externalization.
+# Externalization results in a .pdf file for each tikzpicture
+# environment.
+#
+# \documentclass{article}
+# \usepackage{tikz,pgfplots}
+# \usetikzlibrary{external}
+# \tikzexternalize[mode=list and make]
+#
+# \begin{document}
+# \begin{tikzpicture}
+# \begin{axis}
+# \addplot coordinates {(1,1) (2,2) (3,5)};
+# \end{axis}
+# \end{tikzpicture}%
+# \end{document}
+
+
+$clean_ext .= ' %R.figlist %R-figure* %R.makefile fls.tmp';
+
+$latex = 'internal tikzlatex latex %B %O %S';
+$pdflatex = 'internal tikzlatex pdflatex %B %O %S';
+$lualatex = 'internal tikzlatex lualatex %B %O %S';
+$xelatex = 'internal tikzlatex xelatex %B %O %S';
+
+$hash_calc_ignore_pattern{'pdf'} = '^(/CreationDate|/ModDate|/ID)';
+$hash_calc_ignore_pattern{'ps'} = '^%%CreationDate';
+
+sub tikzlatex {
+ my ($engine, $base, @args) = @_;
+ my $ret = 0;
+ print "Tikzlatex: ===Running '$engine @args'...\n";
+ $ret = system( $engine, @args );
+ print "Tikzlatex: Fixing .fls file ...\n";
+ system "echo INPUT \"$aux_dir1$base.figlist\" > \"$aux_dir1$base.fls.tmp\"";
+ system "echo INPUT \"$aux_dir1$base.makefile\" >> \"$aux_dir1$base.fls.tmp\"";
+ system "cat \"$aux_dir1$base.fls\" >> \"$aux_dir1$base.fls.tmp\"";
+ rename "$aux_dir1$base.fls.tmp", "$aux_dir1$base.fls";
+ if ($ret) { return $ret; }
+ if ( -e "$aux_dir1$base.makefile" ) {
+ if ($engine eq 'xelatex') {
+ print "Tikzlatex: ---Correcting '$aux_dir1$base.makefile' made under xelatex\n";
+ system( 'perl', '-i', '-p', '-e', 's/^\^\^I/\t/', "$aux_dir1$base.makefile" );
+ }
+ elsif ($engine eq 'latex') {
+ print "Tikzlatex: ---Correcting '$aux_dir1$base.makefile' made under latex\n";
+ system( 'perl', '-i', '-p', '-e', 's/\.epsi/\.ps/', "$aux_dir1$base.makefile" );
+ }
+ print "Tikzlatex: ---Running 'make -f $aux_dir1$base.makefile' ...\n";
+ if ($aux_dir) {
+ # latexmk has set $ENV{TEXINPUTS} in this case.
+ my $SAVETEXINPUTS = $ENV{TEXINPUTS};
+ $ENV{TEXINPUTS} = good_cwd().$search_path_separator.$ENV{TEXINPUTS};
+ pushd( $aux_dir );
+ $ret = system "make", "-j", "5", "-f", "$base.makefile";
+ &popd;
+ $ENV{TEXINPUTS} = $SAVETEXINPUTS;
+ }
+ else {
+ $ret = system "make", "-j", "5", "-f", "$base.makefile";
+ }
+ if ($ret) {
+ print "Tikzlatex: !!!!!!!!!!!!!! Error from make !!!!!!!!! \n",
+ " The log files for making the figures '$aux_dir1$base-figure*.log'\n",
+ " may have information\n";
+ }
+ }
+ else {
+ print "Tikzlatex: No '$aux_dir1$base.makefile', so I won't run make.\n";
+ }
+ return $ret;
+}
+
diff --git a/support/latexmk/example_rcfiles/xelatex_latexmkrc b/support/latexmk/example_rcfiles/xelatex_latexmkrc
new file mode 100644
index 0000000000..4c1c8d9644
--- /dev/null
+++ b/support/latexmk/example_rcfiles/xelatex_latexmkrc
@@ -0,0 +1,13 @@
+# This shows how to use xelatex (http://en.wikipedia.org/wiki/XeTeX)
+# with latexmk. Xelatex uses Unicode and "supporting modern font
+# technologies such as OpenType or Apple Advanced Typography.
+#
+# WARNING: The method shown here is suitable only for ver. 4.51 and
+# later of latexmk, not for earlier versions.
+#
+#
+
+$pdf_mode = 5;
+$postscript_mode = $dvi_mode = 0;
+
+
diff --git a/support/latexmk/extra-scripts/README-latexmk-scripts b/support/latexmk/extra-scripts/README-latexmk-scripts
new file mode 100644
index 0000000000..a1c35e471d
--- /dev/null
+++ b/support/latexmk/extra-scripts/README-latexmk-scripts
@@ -0,0 +1,147 @@
+Auxiliary scripts for latexmk
+=============================
+
+John Collins (jcc8 at psu.edu)
+13 Oct 2016
+
+Latexmk can be configured to use different programs than the standard
+ones to perform its tasks. If a user finds that the default behavior
+is not what is desired, it is frequently possible to use a script
+replacing a standard program to acheive the desired effect. It is
+also possible to have a script to run some other programs as well as
+latexmk to do certain tasks. A certain amount of creativity works
+wonders.
+
+In this directory are some scripts that you may find useful. They
+have been provided by other users (who I thank) or by myself. They
+were written to perform certain jobs desired by these users, so they
+may have some very special features that are not useful to everytone.
+You may well need to modify them for your own needs, and you will
+probably need to read through them in detail to understand what they
+do. They can also be quite operating system specific.
+
+For all these scripts, the instructions assumes that the script is in
+the path for executables, and that you have done whatever your OS
+needs you to do to make the script executable.
+
+1. startacroread
+
+ This is specific for UNIX/LINUX systems (script running under
+ bash). It solves a problem that when acroread is used as a pdf
+ viewer and latexmk is used in preview-continuous mode, acroread
+ does not automatically update its display when the pdf file
+ changes.
+
+ Prerequisites:
+ UNIX-style OS
+ bash (command shell)
+ acroread
+ pdfopen and pdfclose from the xpdfopen package
+ (see http://www.ctan.org/pkg/xpdfopen/)
+
+ To use:
+
+ Put the following lines in a startup file for latexmk
+
+ $pdf_previewer = "start startacrobat";
+ $pdf_update_method = "2";
+
+ This will, of course, only have an effect when latexmk will
+ have you view pdf files.
+
+ Advantage:
+
+ Use of acroread (under UNIX/LINUX) for viewing pdf files, with
+ automatic update when latexmk -pvc is used.
+
+ Disadvantage:
+
+ Acroread does not retain its page position; it returns to the
+ first page. (Both gv and xpdf are better for this.)
+
+ Notes:
+
+ The viewer window disappears and then reappears as the
+ foreground window.
+
+ This solution cannot be easily adapted under MSWindows, since
+ the MSWindows version of acroread locks the pdf file, so that a
+ new version cannot be written.
+
+ Thanks: Thorsten Bonow
+
+
+
+2. l1
+
+ For UNIX/LINUX, possibly cygwin, although I haven't tried.
+
+ It is a replacement for latex that brings up a window there are
+ errors. It first runs latex to completion (without a stop if
+ there are errors). Then if there are errors, it makes their
+ description (from the log file) into a dvi file, which it brings
+ up in a separate window.
+
+ Advantage:
+
+ Automatic display of log file, in middle of workflow when using
+ latexmk in preview-continuous mode.
+
+ Disadvantage:
+
+ Log files are verbose. A single line error message in a latex
+ run is often easier to read.
+
+ Thanks: Tom Schneider
+
+
+3. l2
+
+ A version of l1 with command-line options for changing its
+ behavior.
+
+
+4. kickxdvi
+
+ A script for making xdvi update its display. Used by l1.
+
+5. dvipdfm_call
+ dvipdfmx_call
+ dvipdfm_call.bat
+ dvipdfmx_call.bat
+
+ Scripts for using dvipdfm or dvipdfmx with the same command-line
+ syntax as dvipdf.
+
+ To get latexmk to use dvipdfm or dvipdfmx to convert dvi files to
+ pdf files, it USED to be necessary to configure latexmk to use one
+ of these scripts. But since v. 4.01, latexmk has more flexible
+ configuration methods. Currently, to use dvipdfm, just put the
+ following in one of latexmk's initialization files (e.g.,
+ ~/.latexmkrc):
+
+ $dvipdf = "dvipdfm %O -o %D %S";
+
+ (To use dvipdfmx, just change the string dvipdfm to dvipdfmx.)
+ The command specified here is used when latexmk is requested to
+ make pdf files by conversion from dvi files, e.g., by the
+ latexmk's command-line option -pdfdvi.
+
+ But I leave the scripts here. For OLD versions of latexmk, you
+ would have used the configuration line
+
+ $dvipdf = 'dvipdfm_call'; #OBSOLETE
+ or
+ $dvipdf = 'dvipdfmx_call'; #OBSOLETE
+
+ These still work, but they are obsolete.
+
+ For Unix-like systems, including linux and Mac OS-X, use the
+ scripts dvipdfm_call and dvipdfmx_call.
+ For MS-Windows systems use the batch files dvipdfm_call.bat and
+ dvipdfmx_call.bat.
+
+6. completion.bash
+
+ Bash script by Christoph Junghans that implements a bash
+ completion function for latexmk.
diff --git a/support/latexmk/extra-scripts/dvipdfm_call b/support/latexmk/extra-scripts/dvipdfm_call
new file mode 100644
index 0000000000..896dce71fc
--- /dev/null
+++ b/support/latexmk/extra-scripts/dvipdfm_call
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Run dvipdfm from dvipdf-style command-line
+# Assume no options specified
+# If this script is called from latexmk,
+# we have $1=source.dvi, $2=dest.pdf
+# But for safety, let's handle correctly a one argument call,
+# i.e., $1=source, with no $2
+
+if [ "$2" = "" ]; then
+ dvipdfm $1
+else
+ dvipdfm -o $2 $1
+fi
diff --git a/support/latexmk/extra-scripts/dvipdfm_call.bat b/support/latexmk/extra-scripts/dvipdfm_call.bat
new file mode 100644
index 0000000000..104bbabe85
--- /dev/null
+++ b/support/latexmk/extra-scripts/dvipdfm_call.bat
@@ -0,0 +1,19 @@
+@echo off
+REM Run dvipdfm from dvipdf-style command-line
+REM Assume no options specified
+REM If this script is called from latexmk,
+REM we have %1=source.dvi, %2=dest.pdf
+REM But for safety, let's handle correctly a one argument call,
+REM i.e., %1=source, with no %2
+
+if "%2" == "" goto onearg
+
+:twoarg
+dvipdfm -o %2 %1
+goto done
+
+:onearg
+dvipdfm %1
+
+
+:done \ No newline at end of file
diff --git a/support/latexmk/extra-scripts/dvipdfmx_call b/support/latexmk/extra-scripts/dvipdfmx_call
new file mode 100644
index 0000000000..9ff04c4bdc
--- /dev/null
+++ b/support/latexmk/extra-scripts/dvipdfmx_call
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Run dvipdfmx from dvipdf-style command-line
+# Assume no options specified
+# If this script is called from latexmk,
+# we have $1=source.dvi, $2=dest.pdf
+# But for safety, let's handle correctly a one argument call,
+# i.e., $1=source, with no $2
+
+if [ "$2" = "" ]; then
+ dvipdfmx $1
+else
+ dvipdfmx -o $2 $1
+fi
diff --git a/support/latexmk/extra-scripts/dvipdfmx_call.bat b/support/latexmk/extra-scripts/dvipdfmx_call.bat
new file mode 100644
index 0000000000..01a140a65f
--- /dev/null
+++ b/support/latexmk/extra-scripts/dvipdfmx_call.bat
@@ -0,0 +1,19 @@
+@echo off
+REM Run dvipdfmx from dvipdf-style command-line
+REM Assume no options specified
+REM If this script is called from latexmk,
+REM we have %1=source.dvi, %2=dest.pdf
+REM But for safety, let's handle correctly a one argument call,
+REM i.e., %1=source, with no %2
+
+if "%2" == "" goto onearg
+
+:twoarg
+dvipdfmx -o %2 %1
+goto done
+
+:onearg
+dvipdfmx %1
+
+
+:done \ No newline at end of file
diff --git a/support/latexmk/extra-scripts/htlatexonly b/support/latexmk/extra-scripts/htlatexonly
new file mode 100644
index 0000000000..ea50bf9bf2
--- /dev/null
+++ b/support/latexmk/extra-scripts/htlatexonly
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Replacement for latex executable when latexmk is used for htlatex
+# See TeX4ht-latexmkrc in the example-rcfiles directory of the latexmk
+# distribution for how to use this.
+#
+# This is a shell script suitable for UNIX-like operating systems (including
+# OS-X and linux, and presumably Cygwin under MS-Windows).
+
+latex --recorder $5 '\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\g@addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname tex4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode '$2'.a.b.c.\input ' $1
diff --git a/support/latexmk/extra-scripts/kickxdvi b/support/latexmk/extra-scripts/kickxdvi
new file mode 100644
index 0000000000..f0809637aa
--- /dev/null
+++ b/support/latexmk/extra-scripts/kickxdvi
@@ -0,0 +1,22 @@
+#!/bin/csh -f
+#(ie run the cshell on this but don't read the .cshrc)
+
+echo version = 1.05 of kickxdvi 2002 Nov 12
+# 2002 Nov 12, 1.05: (John Collins) Simplify
+# 2002 Nov 5, 1.04: (John Collins) Simplify
+# 2002 Oct 21, 1.04: functional!
+# origin 1999Feb15.17:23:04
+
+echo refresh xdvi processes:
+
+# It picks up multiple processes just fine.
+
+set whoami = `whoami`
+
+set pid=`ps -f -u $whoami | grep xdvi.bin | grep -v grep | cut -c10-14`
+if ( "$pid" != "" ) then
+ echo pid: $pid
+ /usr/bin/kill -s USR1 $pid
+else
+ echo No xdvi.bin processes
+endif
diff --git a/support/latexmk/extra-scripts/l1 b/support/latexmk/extra-scripts/l1
new file mode 100644
index 0000000000..cf8d1c4b64
--- /dev/null
+++ b/support/latexmk/extra-scripts/l1
@@ -0,0 +1,122 @@
+#!/bin/csh -f
+#(ie run the cshell on this but don't read the .cshrc)
+
+clear
+echo version = 2.17 of l 2002 Nov 5
+# 2002 Nov 5, 2.17: (John Collins) Make work with latexmk
+# 2002 Oct 21, 2.16: replace popcross with kickxdvi
+# 2000 Mar 6, 2.14: done is created as a directory (more useful than a file)
+# 1999 Nov 18: removal of a paper triggers bibtex call now
+# 1999 Aug 19: when done, `touch done` so that other
+# programs can be triggered (ie latex2html!)
+
+set myname=l1
+
+if ( "$1" == "") then
+ set paper=paper
+else
+ set paper=$1
+endif
+
+if ( "$paper:e" == "" ) then
+ set base=$paper
+ set paper=${base}.tex
+else
+ set base=$paper:r
+endif
+
+if !(-f $paper) then
+ echo $paper does not exist\!
+ exit 1;
+endif
+
+# popcross refreshes the xdvi display by briefly putting
+# a window in front of the xdvi window. This is crude but effective.
+# A better way is to use the kickxdvi routine.
+set kickxdvi = popcross # old method.
+set kickxdvi = kickxdvi
+
+# set overfull = Overfull
+set overfull = NoOverfull
+echo ALL $overfull MESSAGES WILL BE SUPPRESSED
+# see Lamport page 177 for dealing with overfull boxes.
+# basically, do this:
+# \documentclass[12pt,draft]{article}
+# draft will mark the overfull boxes and the solution
+# will become obvious...
+
+# run latex. The cat /dev/null prevents
+# latex from stopping. Errors are reported to paper.log
+cat /dev/null | latex $paper | grep -v $overfull
+
+# determine if there was an error, by looking at paper.log:
+grep "! Emergency stop." $base.log
+@ EmergencyStop = ($status == 0)
+# Also find if no output produced:
+# Examine only the last line of the file to pick out only the
+# message produced by TeX, and not something else with the same
+# string.
+tail -1 $base.log | grep "No pages of output."
+@ NoOutput = ($status == 0)
+
+if ($EmergencyStop || $NoOutput)then
+
+ # begin latexerrors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ echo create and display latex errors
+
+ set err = `whoami`-$base
+ set tmperr = /tmp/$err.tex
+
+ echo "\documentclass[12pt]{article}" > $tmperr
+ echo "\textwidth 7.5in" >> $tmperr
+ echo "\begin{document}" >> $tmperr
+ if ( $EmergencyStop ) then
+ echo "Error(s) in tex file ($paper): " >> $tmperr
+ else if ( $NoOutput ) then
+ echo "No output from tex file ($paper): " >> $tmperr
+ endif
+ echo "\begin{verbatim}" >> $tmperr
+
+ cat $base.log >> $tmperr
+
+ echo "\end{verbatim}" >> $tmperr
+ echo "\end{document}" >> $tmperr
+
+ pushd /tmp
+ latex $err.tex
+ if ( $EmergencyStop ) then
+ echo xdvi display shows the last page of the errors
+ set page = '+'
+ else
+ set page = ''
+ endif
+ xdvi $err.dvi $page &
+ popd
+ # end latexerrors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ cp /tmp/$err.dvi $base.dvi
+ $kickxdvi
+ echo "****************************************"
+ echo "* ERROR IN PAPER - fix paper.tex file\! *"
+ echo "****************************************"
+ # beep
+ echo -n ""
+ sleep 2
+ # beep
+ echo -n ""
+ cd /tmp
+ rm -f $err.aux $err.dvi $err.log $err.tex
+
+ exit 1
+else
+ echo Successful run
+ $kickxdvi
+ if !(-f done || -d done) then
+ mkdir done
+ endif
+ touch done
+
+ exit
+
+endif
diff --git a/support/latexmk/extra-scripts/l2 b/support/latexmk/extra-scripts/l2
new file mode 100644
index 0000000000..f179bf36a5
--- /dev/null
+++ b/support/latexmk/extra-scripts/l2
@@ -0,0 +1,143 @@
+#!/bin/csh -f
+#(ie run the cshell on this but don't read the .cshrc)
+
+# l2: 2002 Nov 12. John Collins.
+# l2: 2002 Nov 11. John Collins.
+# l2: 2002 Nov 6. John Collins.
+# l2: 2002 Nov 5. John Collins. Simplified from l v. 2.17
+
+set myname=l2
+set displayErrors = 0
+set mainCwd = $cwd
+
+
+#alias beep '(echo -n ""; sleep 1; echo -n "")'
+alias beep '(echo -n "")'
+
+
+nextarg:
+if ( "$1" == "-d" ) then
+ set displayErrors=1
+ shift
+ goto nextarg
+endif
+if ( "$1" == "-d-" ) then
+ set displayErrors=0
+ shift
+ goto nextarg
+endif
+
+if ( ("$1" == "") || ("$1" == "-h") || ("$1" == "--help") ) then
+ echo "Usage $myname [-d|-d-] paper.tex"
+ echo ""
+ echo " -d ==> display errors"
+ echo " -d- ==> do not display errors (default)"
+ echo " -h, --help ==> show this message"
+ exit 0
+endif
+
+set paper=$1
+if ( "$paper:e" == "" ) then
+ set base=$paper
+ set paper=${base}.tex
+else
+ set base=$paper:r
+endif
+
+if !(-f $paper) then
+ echo $paper does not exist\!
+ exit 1
+endif
+
+# set overfull = Overfull
+set overfull = NoOverfull
+echo ALL $overfull MESSAGES WILL BE SUPPRESSED
+# see Lamport page 177 for dealing with overfull boxes.
+# basically, do this:
+# \documentclass[12pt,draft]{article}
+# draft will mark the overfull boxes and the solution
+# will become obvious...
+
+# run latex. The cat /dev/null prevents
+# latex from stopping. Errors are reported to paper.log
+cat /dev/null | latex $paper | grep -v $overfull
+
+# determine if there was an error, by looking at paper.log:
+grep "Emergency stop" $base.log
+@ emergencyStop = ($status == 0)
+
+# Also find if no output produced:
+# Examine only the last line of the file to pick out only the
+# message produced by TeX, and not something else with the same
+# string.
+tail -1 $base.log | grep "No pages of output."
+@ noOutput = ($status == 0)
+
+if ($emergencyStop || $noOutput)then
+ # begin latexerrors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ echo create and display latex errors
+ beep&
+ set err = /tmp/`whoami`-$base:t
+ set tmperr = $err.tex
+
+ echo "\documentclass[12pt]{article}" > $tmperr
+ echo "\textwidth 7.5in" >> $tmperr
+ echo "\begin{document}" >> $tmperr
+ if ( $emergencyStop ) then
+ echo "Error(s) in tex file ($paper): " >> $tmperr
+ else if ( $noOutput ) then
+ echo "No output from tex file ($paper): " >> $tmperr
+ endif
+ echo "\begin{verbatim}" >> $tmperr
+
+ cat $base.log >> $tmperr
+
+ echo "\end{verbatim}" >> $tmperr
+ echo "\end{document}" >> $tmperr
+
+ # latex puts its generated files in the current directory, rather
+ # than the directory of the source file. So change to the
+ # temporary directory, and run latex with the path removed from the
+ # filename argument:
+ pushd /tmp
+ latex $err:t
+ popd
+
+ # Give the original latex file a valid dvi file containing the error log.
+ cp $err.dvi $base.dvi
+
+ # Make a dummy aux file. And also make a .aux.bak file. This
+ # solves the following:
+ # 1. Sometimes a run with errors results from or has produced
+ # a bad .aux file. This gets read in on the next run and
+ # an infinite error loop results unless the .aux file is
+ # deleted or replaced by something innocuous.
+ # 2. Latexmk is liable to make extra runs of latex after an
+ # error is produced. In simple cases, this can be avoided
+ # if the aux file is later than the tex file and the
+ # aux.bak file has the same contents.
+ echo "\relax" > $base.aux
+ echo "\relax" > $base.aux.bak
+
+ rm -f $err.aux $err.log $err.tex
+
+ if ( $displayErrors) then
+ # Popup a new window containing the error log
+ if ( $emergencyStop ) then
+ echo xdvi display shows the last page of the errors
+ set page = '+'
+ else
+ set page = ''
+ endif
+ xdvi $err.dvi $page &
+ sleep 2
+ endif
+ rm -f $err.dvi
+
+ exit 1
+ # end latexerrors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+else
+ echo Successful run
+ exit 0
+endif
diff --git a/support/latexmk/extra-scripts/myhtlatex2 b/support/latexmk/extra-scripts/myhtlatex2
new file mode 100644
index 0000000000..f2db06fd66
--- /dev/null
+++ b/support/latexmk/extra-scripts/myhtlatex2
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# This is a replacement for htlatex from the TeX4ht package. It allows
+# latexmk to be used to do the latex part of the processing.
+# See TeX4ht-latexmkrc in the example-rcfiles directory of the latexmk
+# distribution for how to use this.
+#
+# This is a shell script suitable for UNIX-like operating systems (including
+# OS-X and linux, and presumably Cygwin under MS-Windows).
+
+if [[ $# -lt 1 || $1 == "--help" || $1 == "-help" || $1 == "-h" ]]; then
+ echo "Convert tex file to html. Simplest usage"
+ echo " myhtlatex2 file"
+ exit 1
+fi
+
+latexmk $1
+tex4ht -f/$1 -i~/tex4ht.dir/texmf/tex4ht/ht-fonts/$3
+t4ht -f/$1 $4 ## -d~/WWW/temp/ -m644
diff --git a/support/latexmk/extra-scripts/pst2pdf_for_latexmk b/support/latexmk/extra-scripts/pst2pdf_for_latexmk
new file mode 100644
index 0000000000..8dae4d26c9
--- /dev/null
+++ b/support/latexmk/extra-scripts/pst2pdf_for_latexmk
@@ -0,0 +1,49 @@
+#! /bin/bash
+# pst2pdf_for_latexmk
+# PSTricks 2 PDF converter :
+# Usage:
+# pst2pdf_for_latexmk
+# produces PDF files for all files of the form *-fig*.tex
+# pst2pdf_for_latexmk <FILE>
+# only considers FILE-fig*.tex
+
+# Modified from pst2pdf distributed with pdftricks.sty to use latexmk
+
+# IT REQUIRES VERSION 3.21 OR HIGHER OF latexmk
+
+# For each pdf file will only be made if the tex source is out-of-date
+# This version of pst2pdf does not clean up generated files: they are
+# needed by latexmk to determine whether or not the pdf file is
+# out-of-date.
+#
+# To use this automatically with latexmk (linux/UNIX system assumed)
+# 1. Install this script (pst2pdf_for_latexmk) somewhere in your PATH
+# 2. Put a line like the following in an initialization file for latexmk:
+# $pdflatex = 'pdflatex %O %S; pst2pdf_for_latexmk %B';
+
+# 13 Oct 2016 John Collins: Remove outdated URL and version information
+# 1 Oct 2007 John Collins: Remove path from latexmk
+# 28 Sep 2007 Herb Schulz processing steprs of figure files changed for no rotation and better BoundingBox
+# 27 Sep 2007 John Collins
+# 26 Sep 2007 John Collins
+
+Myname='Pst2pdf_for_latexmk'
+myname='pst2pdf_for_latexmk'
+
+echo "This is $myname modified to use latexmk, by John Collins"
+
+FILE=$1
+if test -z $FILE; then
+ FIGURES=`ls *-fig*.tex`;
+else
+ FIGURES=`ls -- $FILE-fig*.tex`;
+fi
+
+
+if test -z "$FIGURES"; then
+ echo $Myname: No files to process
+else
+ echo $Myname: Using latexmk to process: $FIGURES
+# latexmk -pdfdvi -ps- -dvi- -e '$dvipdf = q{dvips -E -o %B.eps %S && epstopdf %B.eps --outfile=%D}' $FIGURES
+ latexmk -pdfdvi -ps- -dvi- -e '$dvipdf = q{dvips -o %B.ps %S ; ps2pdf13 -dAutoRotatePages=/None %B.ps ; pdfcrop %B.pdf ; /bin/mv %B-crop.pdf %D}' $FIGURES
+fi
diff --git a/support/latexmk/extra-scripts/pst2pdf_for_latexmk_README.txt b/support/latexmk/extra-scripts/pst2pdf_for_latexmk_README.txt
new file mode 100644
index 0000000000..5ca5586266
--- /dev/null
+++ b/support/latexmk/extra-scripts/pst2pdf_for_latexmk_README.txt
@@ -0,0 +1,13 @@
+Pdftricks implementation for TeXShop.
+
+The files ``pdftricksmkrc'' and ``pst2pdf_for_latexmk'' (as well as latexmk, etc.) are stored in ~/Library/TeXShop/bin/
+
+The file pdftrciskmk.engine is stored in ~/Library/TeXShop/Engines/.
+
+When instructed to Typeset a the file TeXShop cd's to the tex files directory and calls pdftricksmk.engine passing the file name (with extension). This executes latexmk using the pdftricksmkrc file for initialization.
+
+The call to pdflatex in the rc file DOES use shell escape (just in case eps files are also being input using epstopdf) so you MUST use the [noshell] option for pdftricks (\usepackage[noshell]{pdftricks}) to avoid a run condition.
+
+The processing steps I use for the -fig* files differs from that used in the standard pdftricks (and what you used). We've discovered that the original processing sometimes rotates figures and also sometimes produces a BoundingBox that cuts off descenders on letters at the edge of the figure. (I've changed my pdftricks package to use these steps too and have let the authors of that package know.)
+
+So far it seems to work. I'll get to work on a pst-pdf package example but, now that I'm beginning to understand what is happening with your new extensions to latexmk, I also suspect it should be fairly easy to accomodate that package. I don't see a case where anyone would use both pdftricks and pst-pdf while I do see cases where eps images, included using epstopdf, will be mixed with pstricks type images.
diff --git a/support/latexmk/extra-scripts/startacroread b/support/latexmk/extra-scripts/startacroread
new file mode 100644
index 0000000000..a1e98fce6b
--- /dev/null
+++ b/support/latexmk/extra-scripts/startacroread
@@ -0,0 +1,231 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------
+#
+# Shell program to start an instance of "acroread" on localhost via
+# "pdfopen" and call "pdfopen" again every time when catching the SIGUSR1
+# signal. This provides the same behaviour as "xdvi" for reloading changed
+# files. Acrobat Reader doesn't come with a "watch file" option, hence
+# this workaround, sigh...
+#
+# Copyright 2005, Thorsten Bonow
+# ( thorsten.bonow at post.rwth-aachen.de ).
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# Description:
+#
+#
+#
+# Usage:
+#
+# startacrobat [ -h | --help ] [PDF document]
+#
+# Options:
+#
+# -h, --help Display this help message and exit.
+#
+# Known Bugs:
+#
+# No other instance of Acrobat Reader should be running: this script kills
+# all of them on exit!
+#
+# Revision History:
+#
+# 01/05/2005 Initial version, adapted from "startxpdf"
+# 28/08/2005 Adapted to "pdfopen" and "acrobat"
+# 01/14/2006 Use HUP or USR1 signal for update to be fully
+# compatible with latexmk 3.07 and 3.08
+# (modification by John Collins (collins at phys.psu.edu))
+#
+#
+# -------------------------------------------------------------------
+
+
+# -------------------------------------------------------------------
+# Constants
+# -------------------------------------------------------------------
+
+ PROGNAME=$(basename $0)
+ VERSION="0.95A"
+ ACRO_RELOAD_EXEC="pdfopen --file"
+ ACROBAT_EXEC="acroread"
+
+# -------------------------------------------------------------------
+# Functions
+# -------------------------------------------------------------------
+
+
+function clean_up
+{
+
+# -----------------------------------------------------------------------
+# Function to kill remote instance of acrobat
+# No arguments
+# -----------------------------------------------------------------------
+
+ return
+}
+
+
+function error_exit
+{
+
+# -----------------------------------------------------------------------
+# Function for exit due to fatal program error
+# Accepts 1 argument:
+# string containing descriptive error message
+# -----------------------------------------------------------------------
+
+
+ echo "${PROGNAME}: ${1:-"Unknown Error"}" >&2
+ clean_up
+ exit 1
+}
+
+
+function graceful_exit
+{
+
+# -----------------------------------------------------------------------
+# Function called for a graceful exit
+# No arguments
+# -----------------------------------------------------------------------
+
+ clean_up
+ exit
+}
+
+
+function usage
+{
+
+# -----------------------------------------------------------------------
+# Function to display usage message (does not exit)
+# No arguments
+# -----------------------------------------------------------------------
+
+ echo "Usage: ${PROGNAME} [-h | --help] [PDF document]"
+}
+
+
+function helptext
+{
+
+# -----------------------------------------------------------------------
+# Function to display help message for program
+# No arguments
+# -----------------------------------------------------------------------
+
+ local tab=$(echo -en "\t\t")
+
+ cat <<- -EOF-
+
+ ${PROGNAME} ver. ${VERSION}
+ Shell program to start an instance of "acroread" on localhost via
+ "acro-reload" and call "acro-reload" again every time when catching the
+ SIGUSR1 signal. This provides the same behaviour as "xdvi" for reloading
+ changed files. Acrobat Reader doesn't come with a "watch file" option,
+ hence this workaround, sigh...
+
+ $(usage)
+
+ Options:
+
+ -h, --help Display this help message and exit.
+
+
+
+
+-EOF-
+}
+
+
+function signal_handle
+{
+
+# -----------------------------------------------------------------------
+# Function to handle signals
+# Accepts 1 argument:
+# signal_spec
+# -----------------------------------------------------------------------
+
+ case $1 in
+ INT) echo "$PROGNAME: Program aborted by user" >&2
+ clean_up
+ exit
+ ;;
+ TERM) echo "$PROGNAME: Program terminated" >&2
+ clean_up
+ exit
+ ;;
+ USR1) echo "$PROGNAME: Reloading..." >&2
+ $ACRO_RELOAD_EXEC $PDF_FILE
+ ;;
+ *) error_exit "$PROGNAME: Terminating on unknown signal"
+ ;;
+ esac
+}
+
+
+# -------------------------------------------------------------------
+# Program starts here
+# -------------------------------------------------------------------
+
+
+##### Command Line Processing #####
+
+if [ "$1" = "--help" ]; then
+ helptext
+ graceful_exit
+fi
+
+while getopts ":h" opt; do
+ case $opt in
+
+ h ) helptext
+ graceful_exit ;;
+ * ) usage
+ clean_up
+ exit 1
+ esac
+done
+
+PDF_FILE="$1"
+
+##### Initialization And Setup #####
+
+# Trap TERM and INT signals and properly exit
+
+trap "signal_handle TERM" TERM
+trap "signal_handle INT" INT
+
+# Trap HUP and USR1 signals for reloading the PDF document
+# Convert to USR1
+# (Note HUP is used by gv, and USR1 by xdvi, so both signals have precedent)
+
+trap "signal_handle USR1" HUP USR1
+
+
+##### Main Logic #####
+
+$ACRO_RELOAD_EXEC $PDF_FILE
+
+while [ 1 ];
+ do
+ # sleeps again after being interrupted by SIGUSR1, breaks if Acrobat Reader is
+ # killed
+ sleep 1
+ eval pgrep "-f" "$ACROBAT_EXEC" ">/dev/null" || break
+done
+
+graceful_exit
+
diff --git a/support/latexmk/latexmk.1 b/support/latexmk/latexmk.1
new file mode 100644
index 0000000000..5c00bafa43
--- /dev/null
+++ b/support/latexmk/latexmk.1
@@ -0,0 +1,3821 @@
+.TH LATEXMK 1 "18 June 2019" ""
+.SH NAME
+latexmk \- generate LaTeX document
+.SH SYNOPSIS
+.B latexmk [options] [file ...]
+.SH DESCRIPTION
+.I Latexmk
+completely automates the process of compiling a LaTeX document.
+Essentially, it is like a specialized relative of the general
+\fImake\fR utility, but one which determines dependencies
+automatically and has some other very useful features. In its basic
+mode of operation \fIlatexmk\fR is given the name of the primary
+source file for a document, and it issues the appropriate sequence of
+commands to generate a .dvi, .ps, .pdf and/or hardcopy version of the
+document.
+.PP
+By default \fIlatexmk\fR will run the commands necessary to generate
+a .dvi file.
+.PP
+\fILatexmk\fR can also be set to run continuously with a suitable
+previewer. In that case the \fIlatex\fR program (or one of its
+relatives), etc, are rerun whenever
+one of the source files is modified, and the previewer automatically
+updates the on-screen view of the compiled document.
+.PP
+\fILatexmk\fR determines which are the source files by examining the
+log file. (Optionally, it also examines the list of input and output
+files generated by the \fB-recorder\fR option of modern versions of
+\fIlatex\fR (and \fIpdflatex\fR, \fIxelatex\fR, \fIlualatex\fR, etc).
+See the documentation for the \fB-recorder\fR option of \fIlatexmk\fR
+below.) When \fIlatexmk\fR is run, it examines properties of the
+source files, and if any have been changed since the last document
+generation, \fIlatexmk\fR will run the various LaTeX processing
+programs as necessary. In particular, it will repeat the run of
+\fIlatex\fR (or a related program)) often enough to resolve all cross
+references; depending on the macro packages used. With some macro
+packages and document classes, four, or even more, runs may be
+needed. If necessary, \fIlatexmk\fR will also run \fIbibtex\fR,
+\fIbiber\fR, and/or \fImakeindex\fR. In addition, \fIlatexmk\fR can
+be configured to generate other necessary files. For example, from an
+updated figure file it can automatically generate a file in
+encapsulated postscript or another suitable format for reading by
+LaTeX.
+.PP
+\fILatexmk\fR has two different previewing options. With the simple
+\fB-pv\fR option, a dvi, postscript or pdf previewer is automatically
+run after generating the dvi, postscript or pdf version of the
+document. The type of file to view is selected according to
+configuration settings and command line options.
+.PP
+The second previewing option is the powerful \fB-pvc\fR option
+(mnemonic: "preview continuously"). In this case, \fIlatexmk\fR runs
+continuously, regularly monitoring all the source files to see if any
+have changed. Every time a change is detected, \fIlatexmk\fR runs all
+the programs necessary to generate a new version of the document. A
+good previewer will then automatically update its
+display. Thus the user can simply edit a file and, when the changes
+are written to disk, \fIlatexmk\fR completely automates the cycle of
+updating the .dvi (and/or the .ps and .pdf) file, and refreshing
+the previewer's display. It's not quite WYSIWYG, but usefully close.
+.PP
+For other previewers, the user may have to manually make the previewer
+update its display, which can be (e.g., with some versions of \fIxdvi\fR and
+\fIgsview\fR) as simple as forcing a redraw of its display.
+.PP
+\fILatexmk\fR has the ability to print a banner in gray diagonally
+across each page when making the postscript file. It can also, if
+needed, call an external program to do other postprocessing on
+generated dvi and postscript files. (See the options \fB-dF\fR and
+\fB-pF\fR, and the documentation for the \fI$dvi_filter\fR and
+\fI$ps_filter\fR configuration variables.) These capabilities are
+leftover from older versions of \fIlatexmk\fR, but \fBare currently
+non-functional\fR.
+More flexibility can
+be obtained in current versions, since the command strings for running
+\fIlatex\fR, \fIpdflatex\fR, etc can now be configured to run multiple
+commands.
+This also extends the possibility of postprocessing generated files.
+.PP
+\fILatexmk\fR is highly configurable, both from the command line and
+in configuration files, so that it can accommodate a wide variety of
+user needs and system configurations. Default values are set
+according to the operating system, so \fIlatexmk\fR often works
+without special configuration on MS-Windows, cygwin, Linux, OS-X, and
+other UNIX systems. See the section "Configuration/Initialization
+(rc) Files", and then the later sections "How to Set Variables in
+Initialization Files", "Format of Command Specifications", "List of
+Configuration Variables Usable in Initialization Files", "Custom
+Dependencies", and "Advanced Configuration"
+.PP
+A very annoying complication handled very reliably by \fIlatexmk\fR,
+is that LaTeX is a multiple pass system. On each run, LaTeX reads in
+information generated on a previous run, for things like cross
+referencing and indexing. In the simplest cases, a second run of
+LaTeX suffices, and often the log file contains a message about the
+need for another pass. However, there is a wide variety of add-on
+macro packages to LaTeX, with a variety of behaviors. The result is
+to break simple-minded determinations of how many runs are needed and
+of which programs. \fILatexmk\fR has a highly
+general and efficient solution to these issues. The solution involves
+retaining between runs information on the source files, and a symptom
+is that \fIlatexmk\fR generates an extra file (with extension
+\fI.fdb_latexmk\fR, by default) that contains the source file
+information.
+
+.SH LATEXMK OPTIONS AND ARGUMENTS ON COMMAND LINE
+In general the command line to invoke \fIlatexmk\fR has the form
+
+ latexmk [options] [file]
+
+All options can be introduced by single or double "-" characters,
+e.g., "latexmk -help" or "latexmk --help".
+
+\fBNote 1\fR: \fBIn addition to the options in the list below,
+\fIlatexmk\fR recognizes almost all the options recognized by the
+\fIlatex\fR, \fIpdflatex\fR programs (and their relatives) in their
+current TeXLive and MiKTeX implementations. Some of the options for
+these programs also trigger special action or behavior by
+\fIlatexmk\fR, in which case they have specific explanations in this
+document. Otherwise, they
+are just passed through to a called \fIlatex\fR or \fIpdflatex\fR
+program. Run \fIlatexmk\fR with the \fB-showextraoptions\fR to get a
+list of the options that \fIlatexmk\fR accepts and that are simply
+passed through to \fIlatex\fR or \fIpdflatex\fR (etc). See also the
+explanation of the \fB-showextraoptions\fR option for more
+information.
+
+\fBNote 2\fR: In this documentation, the program \fIpdflatex\fR is often
+referred to. Users of programs like \fIlualatex\fR and \fIxelatex\fR
+should know that from \fIlatexmk\fR's point of view, these other
+programs behave very like \fIpdflatex\fR, i.e., they make a pdf file from a
+tex file, etc. So whenever \fIpdflatex\fR is mentioned without
+mention of the other programs, the statements apply equally to
+\fIlualatex\fR, \fIxelatex\fR, and any other similar programs.
+\fILatexmk\fR can be easily configured to use whichever of these
+programs is needed. See the documentation for the following options:
+\fB-pdflua\fR, \fB-pdfxe\fR, \fB-lualatex\fR, and \fB-xelatex\fR,
+and also see the documentation for the
+\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR configuration variables.
+At present \fIlatexmk\fR does not do automatic detection of which
+program is to be used.
+
+
+\fBDefinitions of options and arguments\fR
+
+.TP
+.B file
+One or more files can be specified. If no files are specified,
+\fIlatexmk\fR will, by default, run on all files in the current working directory
+with a ".tex" extension. This behavior can be changed: see the
+description concerning the \fI@default_files\fR variable in the
+section "List of configuration variables usable in initialization
+files".
+
+If a file is specified without an extension, then the ".tex" extension
+is automatically added, just as LaTeX does. Thus, if you specify:
+
+ latexmk foo
+
+then \fIlatexmk\fR will operate on the file "foo.tex".
+
+There are certain restrictions on what characters can be in a
+filename; certain characters are either prohibited or problematic for
+the \fIlatex\fR etc programs. These characters are: "$", "%", "\\",
+"~", the double quote character, and the control characters null, tab,
+form feed, carriage return, line feed, and delete. In addition "&" is
+prohibited when it is the first character of a filename.
+
+\fILatexmk\fR gives a fatal error when it detects any of the above
+characters in the TeX filename(s) specified on the command line.
+\fIHowever\fR before testing for illegal characters, \fIlatexmk\fR
+removes matching pairs of double quotes from a filename. This matches
+the behavior of \fIlatex\fR etc, and deals with problems that occasionally
+result from filenames that have been incorrectly quoted on the command
+line. \fIIn addition\fR, under Microsoft Windows, the forward slash
+character "\\" is a directory separator, so \fIlatexmk\fR replaces it
+by a backward slash "/", which is also a legal directory separator in
+Windows, and is accepted by \fIlatex\fR etc.
+
+.TP
+.B -auxdir=FOO or -aux-directory=FOO
+Sets the directory for auxiliary output files of (pdf)latex
+(.aux, .log etc). This
+achieves its effect by the \fB-aux-directory\fR option of (pdf)latex,
+which currently is only implemented on the MiKTeX version of
+(pdf)latex.
+
+See also the \fB-outdir\fR/\fB-output-directory\fR options, and the
+\fI$aux_dir\fR, \fI$out_dir\fR, and \fI$search_path_separator\fR
+configuration variables of \fIlatexmk\fR. In particular, see the
+documentation of \fI$out_dir\fR for some complications on what
+directory names are suitable.
+
+If you also use the \fB-cd\fR option, and the specified auxiliary output
+directory is a relative path, then the path is interpreted relative to
+the document directory.
+
+.TP
+.B -bibtex
+When the source file uses bbl files for bibliography, run bibtex or
+biber as needed to regenerate the bbl files.
+
+This property can also be configured by setting the \fI$bibtex_use\fR
+variable to 2 in a configuration file.
+
+.TP
+.B -bibtex-
+Never run bibtex or biber. Also, always treat .bbl files as precious,
+i.e., do not delete them in a cleanup operation.
+
+A common use for this option is when a document comes from an external
+source, complete with its bbl file(s), and the user does not have the
+corresponding bib files available. In this situation use of the
+\fB-bibtex-\fR option will prevent \fIlatexmk\fR from trying to run
+\fIbibtex\fR or \fIbiber\fR, which would result in overwriting of the
+bbl files.
+
+This property can also be configured by setting the \fI$bibtex_use\fR
+variable to 0 in a configuration file.
+
+.TP
+.B -bibtex-cond
+When the source file uses bbl file(s) for the bibliography, run
+\fIbibtex\fR or \fIbiber\fR as needed to regenerate the bbl files, but
+only if the
+relevant bib file(s) exist. Thus when the bib files are not
+available, \fIbibtex\fR or \fIbiber\fR is not run, thereby avoiding
+overwriting of
+the bbl file(s).
+Also, always treat .bbl files as precious,
+i.e., do not delete them in a cleanup operation.
+
+This is the default setting.
+It can also be configured by setting the \fI$bibtex_use\fR
+variable to 1 in a configuration file.
+
+The reason for using this setting is that sometimes a .bbl file is
+available containing the bibliography for a document, but the .bib
+file is not available. An example would be for a scientific journal
+where authors submit .tex and .bbl files, but not the original .bib
+file. In that case, running \fIbibtex\fR or \fIbiber\fR would not
+work, and the .bbl file should be treated as a user source file, and
+not as a file that can be regenerated on demand.
+
+(Note that it is possible for \fIlatexmk\fR to decide that the bib
+file does not exist, even though the bib file does exist and
+\fIbibtex\fR or \fIbiber\fR finds it. The problem is that the bib
+file may not be in
+the current directory but in some search path; the places
+\fIlatexmk\fR and \fIbibtex\fR or \fIbiber\fR cause to be searched need not be
+identical. On modern installations of TeX and related programs this
+problem should not arise, since \fIlatexmk\fR uses the \fIkpsewhich\fR
+program to do the search, and \fIkpsewhich\fR should use the same
+search path as \fIbibtex\fR and \fIbiber\fR. If this problem arises, use the
+\fB-bibtex\fR option when invoking \fIlatexmk\fR.)
+
+Note that this value does \fInot\fR work properly if the document uses
+\fIbiber\fR instead of \fIbibtex\fR. (There's a long story why not.)
+
+.TP
+.B -bibtex-cond1
+The same as \fB-bibtex-cond1\fR except that .bbl files are only
+treated as precious if one or more bibfiles fails to exist.
+
+Thus if all the bib files exist, \fIbibtex\fR or \fIbiber\fR is run to
+generate .bbl files as needed, and then it is appropriate to delete
+the bbl files in a cleanup operation since they can be re-generated.
+
+This property can also be configured by setting the \fI$bibtex_use\fR
+variable to 1.5 in a configuration file.
+
+.TP
+.B -bm <message>
+A banner message to print diagonally across each page when converting
+the dvi file to postscript. The message must be a single argument on
+the command line so be careful with quoting spaces and such.
+
+Note that if the \fB-bm\fR option is specified, the \fB-ps\fR option is
+assumed.
+
+.TP
+.B -bi <intensity>
+How dark to print the banner message. A decimal number between 0 and 1.
+0 is black and 1 is white. The default is 0.95, which is OK unless your
+toner cartridge is getting low.
+
+.TP
+.B -bs <scale>
+A decimal number that specifies how large the banner message will be
+printed. Experimentation is necessary to get the right scale for your
+message, as a rule of thumb the scale should be about equal to 1100
+divided by the number of characters in the message. The default is 220.0
+which is just right for 5 character messages.
+
+.TP
+.B -commands
+List the commands used by \fIlatexmk\fR for processing files, and then
+exit.
+
+.TP
+.B -c
+Clean up (remove) all regeneratable files generated by \fIlatex\fR and
+\fIbibtex\fR or \fIbiber\fR except dvi, postscript and pdf. These files are a
+combination of log files, aux files, \fIlatexmk\fR's database file of
+source file information,
+and those with extensions
+specified in the \fI@generated_exts\fR configuration variable. In addition,
+files specified by the \fI$clean_ext\fR and \fI@generated_exts\fR
+configuration variables are removed.
+
+This cleanup is instead of a regular make. See the \fB-gg\fR option
+if you want to do a cleanup then a make.
+
+\fITreatment of .bbl files: \fR If \fI$bibtex_use\fR is set to 0 or 1,
+bbl files are always treated as non-regeneratable. If
+\fI$bibtex_use\fR is set to 1.5, bbl files are counted as
+non-regeneratable conditionally: If the bib file exists, then bbl
+files are regeneratable, and are deleted in a clean up. But if
+\fI$bibtex_use\fR is 1.5 and a bib file doesn't exist, then the bbl
+files are treated as non-regeneratable and hence are not deleted.
+
+In contrast, if \fI$bibtex_use\fR is set to 2, bbl files are always
+treated as regeneratable, and are deleted in a cleanup.
+
+\fITreatment of files generated by custom dependencies:\fR If
+\fI$cleanup_includes_cusdep_generated\fR is nonzero, regeneratable
+files are considered as including those generated by custom
+dependencies and are also deleted. Otherwise these files are not
+deleted.
+
+.TP
+.B -C
+Clean up (remove) all regeneratable files generated by \fIlatex\fR and
+\fIbibtex\fR or \fIbiber\fR. This is the same as the \fB-c\fR option with the
+addition of dvi, postscript and pdf files, and those specified
+in the \fI$clean_full_ext\fR configuration variable.
+
+This cleanup is instead of a regular make. See the \fB-gg\fR option
+if you want to do a cleanup than a make.
+
+See the \fB-c\fR option for the specification of whether or not .bbl
+files are treated as non-regeneratable or regeneratable.
+
+If \fI$cleanup_includes_cusdep_generated\fR is nonzero, regeneratable
+files are considered as including those generated by custom
+dependencies and are also deleted. Otherwise these files are not deleted.
+
+.TP
+.B -CA
+(Obsolete). Now equivalent to the \fB-C\fR option. See that option
+for details.
+
+.TP
+.B -cd
+Change to the directory containing the main source file before processing
+it. Then all the generated files (.aux, .log, .dvi, .pdf, etc) will be
+relative to the source file.
+
+This option is particularly useful when \fIlatexmk\fR is invoked from
+a GUI configured to invoke \fIlatexmk\fR with a full pathname for the
+source file.
+
+This option works by setting the \fB$do_cd\fR configuration variable
+to one; you can set that variable if you want to configure
+\fIlatexmk\fR to have the effect of the \fB-cd\fR option without
+specifying it on the command line. See the documentation for that
+variable.
+
+.TP
+.B -cd-
+Do NOT change to the directory containing the main source file before processing
+it. Then all the generated files (.aux, .log, .dvi, .pdf, etc) will be
+relative to the current directory rather than the source file.
+
+This is the default behavior and corresponds to the behavior of the
+\fIlatex\fR and \fIpdflatex\fR programs. However, it is not desirable
+behavior when \fIlatexmk\fR is invoked by a GUI configured to invoke
+\fIlatexmk\fR with a full pathname for the source file. See the
+\fB-cd\fR option.
+
+This option works by setting the \fB$do_cd\fR configuration variable
+to zero. See the documentation for that variable for more
+information.
+
+.TP
+.B -CF
+Remove the file containing the database of source file information,
+before doing the other actions requested.
+
+.TP
+.B -d
+Set draft mode. This prints the banner message "DRAFT" across your
+page when converting the dvi file to postscript. Size and intensity
+can be modified with the \fB-bs\fR and \fB-bi\fR options. The \fB-bm\fR
+option will override this option as this is really just a short way of
+specifying:
+
+ latexmk -bm DRAFT
+
+Note that if the \fB-d\fR option is specified, the \fB-ps\fR option is
+assumed.
+
+.TP
+.B -deps
+Show a list of dependent files after processing. This is in the form
+of a dependency list of the form used by the \fImake\fR program, and
+it is therefore suitable for use in a Makefile. It gives an overall
+view of the files without listing intermediate files, as well as
+\fIlatexmk\fR can determine them.
+
+By default the list of dependent files is sent to stdout (i.e.,
+normally to the screen unless you've redirected \fIlatexmk\fR's
+output). But you can set the filename where the list is sent by the
+\fB-deps-out=\fR option.
+
+See the section "USING \fIlatexmk\fR WITH \fImake\fR" for
+an example of how to use a dependency list with \fImake\fR.
+
+Users familiar with GNU \fIautomake\fR and \fIgcc\fR will find that
+the \fB-deps\fR option is very similar in its purpose and results to
+the \fB-M\fR option to \fIgcc\fR. (In fact, \fIlatexmk\fR also has
+options \fB-M\fR, \fB-MF\fR, and \fB-MP\fR options that behave like
+those of \fIgcc\fR.)
+
+.TP
+.B -dependents
+Equivalent to \fB-deps\fR.
+
+.TP
+.B -deps-
+Do not show a list of dependent files after processing. (This is the
+default.)
+
+.TP
+.B -dependents-
+Equivalent to \fB-deps-\fR.
+
+.TP
+.B -deps-out=FILENAME
+Set the filename to which the list of dependent files is written. If
+the FILENAME argument is omitted or set to "-", then the output is
+sent to stdout.
+
+Use of this option also turns on the output of the list of dependent
+files after processing.
+
+.TP
+.B -dF
+Dvi file filtering. The argument to this option is a filter which will
+generate a filtered dvi file with the extension ".dviF". All extra
+processing (e.g. conversion to postscript, preview, printing) will then
+be performed on this filtered dvi file.
+
+Example usage: To use dviselect to select only the even pages of the dvi file:
+
+ latexmk -dF "dviselect even" foo.tex
+
+.TP
+.B -diagnostics
+Print detailed diagnostics during a run. This may help for debugging
+problems or to understand \fIlatexmk\fR's behavior in difficult
+situations.
+
+.TP
+.B -dvi
+Generate dvi version of document.
+
+.TP
+.B -dvi-
+Turn off generation of dvi version of document. (This may get
+overridden, if some other file is made (e.g., a .ps file) that is
+generated from the dvi file, or if no generated file at all is
+requested.)
+
+.TP
+.B -e <code>
+Execute the specified initialization code before processing. The code
+is \fIPerl\fR code of the same form as is used in \fIlatexmk\fR's
+initialization files. For more details,
+see the information on the
+\fB-r\fR option, and the section about "Configuration/initialization
+(RC) files". The code is typically a sequence of assignment
+statements separated by semicolons.
+
+The code is executed when the \fB-e\fR option is encountered during
+\fIlatexmk\fR's parsing of its command line. See the \fB-r\fR option
+for a way of executing initialization code from a file. An error
+results in \fIlatexmk\fR stopping. Multiple instances of the \fB-r\fR
+and \fB-e\fR options can be used, and they are executed in the order
+they appear on the command line.
+
+Some care is needed to deal with proper quoting of special characters
+in the code on the command line. For example, suppose you want
+to set the latex command to use its -shell-escape option, then under
+UNIX/Linux you could use the line
+
+ latexmk -e '$latex=q/latex %O -shell-escape %S/' file.tex
+
+Note that the single quotes block normal UNIX/Linux command shells
+from treating the characters inside the quotes as special.
+(In this example, the q/.../ construct is a
+\fIPerl\fR idiom equivalent to using
+single quotes. This avoids the complications of getting a quote
+character inside an already quoted string in a way that is independent
+of both the shell and the operating-system.)
+
+The above command line will NOT work under MS-Windows with cmd.exe or
+command.com or 4nt.exe. For MS-Windows with these command shells you
+could use
+
+ latexmk -e "$latex=q/latex %O -shell-escape %S/" file.tex
+
+or
+
+ latexmk -e "$latex='latex %O -shell-escape %S'" file.tex
+
+The last two examples will NOT work with UNIX/Linux command shells.
+
+(\fINote\fR: the above examples show are to show how to use the
+\fB-e\fR to specify initialization code to be executed. But the
+particular effect can be achieved also by the use of the \fB-latex\fR
+option with less problems in dealing with quoting.)
+
+.TP
+.B -f
+Force \fIlatexmk\fR to continue document processing despite errors.
+Normally, when \fIlatexmk\fR detects that LaTeX or another program has
+found an error which will not be resolved by further processing, no
+further processing is carried out.
+
+Note: "Further processing" means the running of other programs or the
+rerunning of \fIlatex\fR (etc) that would be done if no errors had
+occurred. If instead, or additionally, you want the \fIlatex\fR (etc)
+program not to pause for user input after an error, you should arrange
+this by an option that is passed to the program, e.g., by
+\fIlatexmk\fR's option \fB-interaction=nonstopmode\fR.
+
+.TP
+.B -f-
+Turn off the forced processing-past-errors such as is set by the
+\fB-f\fR option. This could be used to override a setting in a
+configuration file.
+
+.TP
+.B -g
+Force \fIlatexmk\fR to process document fully, even under situations
+where \fIlatexmk\fR would normally decide that no changes in the
+source files have occurred since the previous run.
+This option is useful, for example, if you change some options and
+wish to reprocess the files.
+
+.TP
+.B -g-
+Turn off \fB-g\fR.
+
+.TP
+.B -gg
+"Super go mode" or "clean make": clean out generated files as if
+\fB-C\fR had been given, and then do a regular make.
+
+.TP
+.B -h, -help
+Print help information.
+
+.TP
+.B -jobname=STRING
+Set the basename of output files(s) to STRING, instead of the default,
+which is the basename of the specified TeX file. (At present, STRING
+should not contain spaces.)
+
+This is like the same option for current implementations of the
+\fIlatex\fR, \fIpdflatex\fR, etc, and the passing of this option to
+these programs is part of \fIlatexmk\fR's implementation of
+\fB-jobname\fR.
+
+There is one enhancement, that the STRING may contain the
+placeholder '%A'. This will be substituted by the basename of the TeX
+file. The primary purpose is when multiple files are specified on the
+command line to \fIlatexmk\fR, and you wish to use a jobname with a
+different file-dependent value for each file. For example, suppose
+you had .tex files test1.tex and test2.tex, and you wished to compare
+the results of compilation by \fIpdflatex\fR and those with
+\fIxelatex\fR. Then under a unix-type operating system you could use
+the command line
+
+ latexmk -pdf -jobname=%A-pdflatex *.tex
+ latexmk -pdfxe -jobname=%A-xelatex *.tex
+
+Then the .aux, .log, and .pdf files from the use of \fIpdflatex\fR
+would have basenames test1-pdflatex and test2-pdflatex, while from
+\fIxelatex\fR, the basenames would be test1-xelatex and test2-xelatex.
+
+Under MS-Windows with cmd.exe, you would need to double the percent
+sign, so that the percent character is passed to latexmk rather than
+being used to substitute an environment variable:
+
+ latexmk -pdf -jobname=%%A-pdflatex *.tex
+ latexmk -pdfxe -jobname=%%A-xelatex *.tex
+
+.TP
+.B -l
+Run in landscape mode, using the landscape mode for the previewers and
+the dvi to postscript converters. This option is not normally needed
+nowadays, since current previewers normally determine this information
+automatically.
+
+.TP
+.B -l-
+Turn off \fB-l\fR.
+
+.TP
+.B -latex="COMMAND"
+This sets the string specifying the command to run latex, and is
+typically used to add desired options. Since the string normally
+contains spaces, it should be quoted, e.g.,
+
+ latexmk -latex="latex --shell-escape %O %S" foo.tex
+
+The specification of the contents of the string are the same as for
+the \fI$latex\fR configuration variable. Depending on your
+operating system and the command-line shell you are using, you may
+need to change the single quotes to double quotes (or something
+else).
+
+To set the command for running \fIpdflatex\fR (rather than the command for
+\fIlatex\fR) see the \fB-pdflatex\fR option.
+
+.TP
+.B -logfilewarninglist
+.B -logfilewarnings
+After a run of \fI(pdf)latex\fR, give a list of warnings about
+undefined citations and references (unless silent mode is on).
+
+See also the \fI$silence_logfile_warnings\fR configuration variable.
+
+.TP
+.B -logfilewarninglist-
+.B -logfilewarnings-
+After a run of \fI(pdf)latex\fR, do not give a list of warnings about
+undefined citations and references. (Default)
+
+See also the \fI$silence_logfile_warnings\fR configuration variable.
+
+.TP
+.B -lualatex
+Use \fIlualatex\fR. That is, use \fIlualatex\fR to process the source file(s) to
+pdf. The generation of dvi and postscript files is turned off.
+
+This option is equivalent to using the following set of options
+
+ -pdflua -dvi- -ps-
+
+(\fINote\fR: Note that the method of implementation of this option,
+but not its intended effect, differ from some earlier versions of
+\fIlatexmk\fR.)
+
+.TP
+.B -M
+Show list of dependent files after processing. This is equivalent to
+the \fB-deps\fR option.
+
+.TP
+.B -MF file
+If a list of dependents is made, the \fB-MF\fR specifies the file to
+write it to.
+
+.TP
+.B -MP
+If a list of dependents is made, include a phony target for each source
+file. If you use the dependents list in a Makefile, the dummy rules
+work around errors the program \fImake\fR gives if you remove header
+files without updating the Makefile to match.
+
+.TP
+.B -new-viewer
+When in continuous-preview mode, always start a new viewer to view the
+generated file. By default, \fIlatexmk\fR will, in continuous-preview
+mode, test for a previously running previewer for the same file and
+not start a new one if a previous previewer is running. However, its
+test sometimes fails (notably if there is an already-running previewer
+that is viewing a file of the same name as the current file, but in a
+different directory). This option turns off the default behavior.
+
+.TP
+.B -new-viewer-
+The inverse of the \fB-new-viewer\fR option. It puts \fIlatexmk\fR
+in its normal behavior that in preview-continuous mode it checks for
+an already-running previewer.
+
+.TP
+.B -nobibtex
+Never run bibtex or biber. Equivalent to the \fB-bibtex-\fR option.
+
+.TP
+.B -norc
+Turn off the automatic reading of initialization (rc) files.
+
+N.B. Normally the initialization files are read and obeyed, and then
+command line options are obeyed in the order they are encountered.
+But \fB-norc\fR is an exception to this rule: it is acted on first,
+no matter where it occurs on the command line.
+
+.TP
+.B -outdir=FOO or -output-directory=FOO
+
+Sets the directory for the output files of (pdf)latex. This achieves
+its effect by the \fB-output-directory\fR option of (pdf)latex, which
+currently (Dec. 2011 and later) is implemented on the common versions of
+(pdf)latex, i.e., MiKTeX and TeXLive. It may not be present in other
+versions.
+
+See also the \fB-auxdir\fR/\fB-aux-directory\fR options, and the
+\fI$aux_dir\fR, \fI$out_dir\fR, and \fI$search_path_separator\fR
+configuration variables of \fIlatexmk\fR. In particular, see the
+documentation of \fI$out_dir\fR for some complications on what
+directory names are suitable.
+
+If you also use the \fB-cd\fR option, and the specified output
+directory is a relative path, then the path is interpreted relative to
+the document directory.
+
+.TP
+.B -p
+Print out the document. By default the file to be printed is
+the first in the list postscript, pdf, dvi that is being made.
+But you can use the
+\fB-print=...\fR option to change the type of file to be printed, and you
+can configure this in a start up file (by setting the
+\fI$print_type\fR variable).
+
+However, printing is enabled by default only under UNIX/Linux systems,
+where the default is to use the lpr command and only on postscript
+files. In general, the correct
+behavior for printing very much depends on your system's software. In
+particular, under MS-Windows you must have suitable program(s)
+available, and you must have configured the print commands used by
+\fIlatexmk\fR. This can be non-trivial. See the documentation on the
+\fI$lpr\fR, \fI$lpr_dvi\fR, and \fI$lpr_pdf\fR configuration variables
+to see how to set the commands for printing.
+
+This option is incompatible with the \fB-pv\fR and \fB-pvc\fR options,
+so it turns them off.
+
+.TP
+.B -pdf
+Generate pdf version of document using \fIpdflatex\fR. (If you wish
+to use \fIlualatex\fR or \fIxelatex\fR, you can use whichever of the
+options \fB-pdflua\fR, \fB-pdfxe\fR, \fB-lualatex\fR or \fB-xelatex\fR
+applies.) To configure
+\fIlatexmk\fR to have such behavior by default, see the section on
+"Configuration/initialization (rc) files".
+
+.TP
+.B -pdfdvi
+Generate pdf version of document from the dvi file, by default using dvipdf.
+
+.TP
+.B -pdflua
+Generate pdf version of document using \fIlualatex\fR.
+
+.TP
+.B -pdfps
+Generate pdf version of document from the .ps file, by default using
+\fIps2pdf\fR.
+
+.TP
+.B -pdfxe
+Generate pdf version of document using \fIxelatex\fR. Note that to
+optimize processing time, \fIlatexmk\fR uses \fIxelatex\fR to generate
+an .xdv file rather than a pdf file directly. Only after possibly
+multiple runs to generate a fully up-to-date .xdv file does \fIlatexmk\fR
+then call \fIxdvipdfmx\fR to generate the final .pdf file.
+
+(\fINote:\fR When the document includes large graphics files,
+especially .png files, the last step can be quite time consuming, even
+when the creation of the .xdv file by \fIxelatex\fR is fast. So the
+use of the intermediate .xdv file can result in substantial gains in
+procesing time, since the .pdf file is produced once rather than on
+every run of \fIxelatex\fR. See the documentation on the \fB-pdfxe\fR
+option for why an .xdv file is used.
+
+.TP
+.B -pdf-
+Turn off generation of pdf version of document.
+(This can be used to override a setting in a configuration file.
+It may get overridden if some other option requires the generation of
+a pdf file.)
+
+If after all options have been processed, pdf generation is still
+turned off, then generation of a dvi file will be turned on, and then
+the program used to compiled a document will be \fIlatex\fR (or, more
+precisely, whatever program is configured to be used in the
+\fI$latex\fR configuration variable).
+
+.TP
+.B -pdflatex="COMMAND"
+This sets the string specifying the command to run \fIpdflatex\fR, and is
+typically used to add desired options. Since the string normally
+contains spaces, it should be quoted, e.g.,
+
+ latexmk -pdf -pdflatex="pdflatex --shell-escape %O %S" foo.tex
+
+The specification of the contents of the string are the same as for
+the \fI$pdflatex\fR configuration variable. (The option
+\fB-pdflatex\fR in fact sets the variable \fI$pdflatex\fR.)
+Depending on your
+operating system and the command-line shell you are using, you may
+need to change the single quotes to double quotes (or something
+else).
+
+To set the command for running \fIlatex\fR (rather than the command
+for \fIpdflatex\fR) see the \fB-latex\fR option.
+
+.TP
+.B -pdflualatex="COMMAND"
+This sets the string specifying the command to run \fIlualatex\fR. It
+behaves like the \fB-pdflatex\fR option, but sets the variable
+\fI$lualatex\fR.
+
+.TP
+.B -pdfxelatex="COMMAND"
+This sets the string specifying the command to run \fIxelatex\fR. It
+behaves like the \fB-pdflatex\fR option, but sets the variable
+\fI$xelatex\fR.
+
+\fIWarning\fR: It is important to ensure that the -no-pdf is used when
+\fIxelatex\fR is invoked; see the explanation for the variable
+\fI$xelatex\fR for why this is necessary. If you provide %O in the
+command specification, this will be done automatically.
+
+An example of the use of the \fB-pdfxelatex\fR option:
+
+ latexmk -pdfxe -pdfxelatex="xelatex --shell-escape %O %S" foo.tex
+
+
+.TP
+.B -pretex=CODE
+
+Given that CODE is some TeX code, this options sets that code to be
+executed before inputting source file. This only works if the command
+for invoking the relevant \fI*latex\fR is suitably configured. See
+the documentation of the variable \fI$pre_tex_code\fR, and the
+substitution strings %P and %U for more details. This option works by
+setting the variable \fI$pre_tex_code\fR.
+
+See also the \fB-usepretex\fR option.
+
+An example:
+
+ latexmk -pretex='\\AtBeginDocument{Message\\par}' -usepretex foo.tex
+
+But this is better written
+
+ latexmk -usepretex='\\AtBeginDocument{Message\\par}' foo.tex
+
+If you already have a suitable command configured, you only need
+
+ latexmk -pretex='\\AtBeginDocument{Message\\par}' foo.tex
+
+.TP
+.B -print=dvi, -print=ps, -print=pdf, -print=auto,
+Define which kind of file is printed. This option also ensures that
+the requisite file is made, and turns on printing.
+
+The (default) case
+\fB-print=auto\fR determines the kind of print file automatically from
+the set of files that is being made. The first in the list
+postscript, pdf, dvi that is among the files to be made is the one
+used for print out.
+
+.TP
+.B -ps
+Generate postscript version of document.
+
+.TP
+.B -ps-
+Turn off generation of postscript version of document.
+This can be used to override a setting in a configuration file.
+(It may get overridden by some other option that requires a postscript
+file, for example a request for printing.)
+
+.TP
+.B -pF
+Postscript file filtering. The argument to this option is a filter
+which will generate a filtered postscript file with the extension
+".psF". All extra processing (e.g. preview, printing) will then be
+performed on this filtered postscript file.
+
+Example of usage: Use psnup to print two pages on the one page:
+
+ latexmk -ps -pF 'psnup -2' foo.tex
+
+or
+
+ latexmk -ps -pF "psnup -2" foo.tex
+
+Whether to use single or double quotes round the "psnup -2" will
+depend on your command interpreter, as used by the particular version
+of perl and the operating system on your computer.
+
+.TP
+.B -pv
+Run file previewer. If the \fB-view\fR option is used, this will select
+the kind of file to be previewed (.dvi, .ps or .pdf).
+Otherwise the viewer views the "highest" kind of file selected, by the
+\fB-dvi\fR, \fB-ps\fR, \fB-pdf\fR, \fB-pdfps\fR options, in the
+order .dvi, .ps, .pdf (low to high).
+If no file type has been selected, the dvi previewer will be used.
+This option is incompatible with the \fB-p\fR and \fB-pvc\fR options,
+so it turns them off.
+
+.TP
+.B -pv-
+Turn off \fB-pv\fR.
+
+.TP
+.B -pvc
+Run a file previewer and continually update the .dvi, .ps, and/or .pdf
+files whenever changes are made to source files (see the Description
+above). Which of these files is generated and which is viewed is
+governed by the other options, and is the same as for the \fB-pv\fR
+option.
+The preview-continuous option \fB-pvc\fR can only work with one file.
+So in this case you will normally only specify one filename on
+the command line. It is also incompatible with the
+\fB-p\fR and \fB-pv\fR options, so it turns these options off.
+
+The \fB-pvc\fR option also turns off force mode (\fB-f\fR), as is
+normally best for continuous preview mode. If you really want force
+mode, use the options in the order \fB-pvc -f\fR.
+
+With a good previewer the display will be automatically updated.
+(Under \fIsome but not all\fR versions of UNIX/Linux "gv -watch" does
+this for postscript files; this can be set by a configuration
+variable. This would also work for pdf files except for an apparent
+bug in gv that causes an error when the newly updated pdf file is
+read.) Many other previewers will need a manual update.
+
+\fBImportant note\fR: the acroread program on MS-Windows locks the pdf file,
+and prevents new versions being written, so it is a bad idea to use
+acroread to view pdf files in preview-continuous mode.
+It is better to use a different viewer: \fISumatraPDF\fR and
+\fIgsview\fR are good possibilities.
+
+There are some other methods for arranging an update, notably useful
+for many versions of \fIxdvi\fR and \fIxpdf\fR. These are best set in
+\fIlatexmk\fR's configuration; see below.
+
+Note that if \fIlatexmk\fR dies or is stopped by the user, the
+"forked" previewer will continue to run. Successive invocations with
+the \fB-pvc\fR option will not fork new previewers, but \fIlatexmk\fR
+will normally use the existing previewer. (At least this will happen
+when \fIlatexmk\fR is running under an operating system where it knows
+how to determine whether an existing previewer is running.)
+
+.TP
+.B -pvc-
+Turn off \fB-pvc\fR.
+
+.TP
+.B -pvctimeout
+Do timeout in pvc mode after period of inactivity, which is 30 min. by
+default. Inactivity means a period when \fIlatexmk\fR has detected no
+file changes and hence has not taken any actions like compiling the
+document.
+
+.TP
+.B -pvctimeout-
+Don't do timeout in pvc mode after inactivity.
+
+.TP
+.B -pvctimeoutmins=<time>
+Set period of inactivity in \fIminutes\fR for pvc timeout.
+
+.TP
+.B -quiet
+Same as -silent
+
+.TP
+.B -r <rcfile>
+Read the specified initialization file ("RC file") before processing.
+
+Be careful about the ordering: (1) Standard initialization files --
+see the section below on "Configuration/initialization (RC) files" --
+are read first. (2) Then the options on the command line are acted on
+in the order they are given. Therefore if an initialization file is
+specified by the \fB-r\fR option, it is read during this second step.
+Thus an initialization file specified with the \fB-r\fR option can
+override both the standard initialization files and \fIpreviously\fR
+specified options. But all of these can be overridden by \fIlater\fR
+options.
+
+The contents of the RC file just comprise a piece of code in the
+\fIPerl\fR programming language
+(typically a sequence of assignment statements); they are executed
+when the \fB-r\fR option is encountered during \fIlatexmk\fR's parsing
+of its command line. See the \fB-e\fR option for a way of giving
+initialization code directly on \fIlatexmk\fR's command line. An
+error results in \fIlatexmk\fR stopping. Multiple instances of the
+\fB-r\fR and \fB-e\fR options can be used, and they are executed in
+the order they appear on the command line.
+
+.TP
+.B -recorder
+Give the -recorder option with \fIlatex\fR and \fIpdflatex\fR. In
+(most) modern versions of these programs, this results in a file of
+extension \fI.fls\fR containing a list of the files that these
+programs have read and written. \fILatexmk\fR will then use this file
+to improve its detection of source files and generated files after a
+run of \fIlatex\fR or \fIpdflatex\fR. This is the default setting of
+\fIlatexmk\fR, unless overridden in an initialization file.
+
+For further information, see the documentation for the \fI$recorder\fR
+configuration variable.
+
+.TP
+.B -recorder-
+Do not supply the -recorder option with \fIlatex\fR and \fIpdflatex\fR.
+
+.TP
+.B -rules
+Show a list of \fIlatemk\fR's rules and dependencies after processing.
+
+.TP
+.B -rules-
+Do not show a list of \fIlatexmk\fR's rules and dependencies after
+processing. (This is the default.)
+
+.TP
+.B -showextraoptions
+Show the list of extra \fIlatex\fR and \fIpdflatex\fR options that
+\fIlatexmk\fR recognizes, but that it simply passes
+through to the programs \fIlatex\fR, \fIpdflatex\fR, etc when they
+are run. These options are
+(currently) a combination of those allowed by the TeXLive and MiKTeX
+implementations. (If a particular option is given to \fIlatexmk\fR
+but is not handled by the particular implementation of \fIlatex\fR or
+\fIpdflatex\fR that is being used, that program will probably give an
+error message.) These options are very numerous, but are not listed
+in this documentation because they have no effect on \fIlatexmk\fR's
+actions.
+
+There are a few options (\fB-includedirectory=dir\fR,
+\fB-initialize\fR, \fB-ini\fR) that are not recognized, either because
+they don't fit with \fIlatexmk\fR's intended operations, or because
+they need special processing by \fIlatexmk\fR that isn't implemented
+(at least, not yet).
+
+There are also options that are accepted by \fIlatex\fR etc, but
+instead trigger actions by \fIlatexmk\fR: \fB-help\fR,
+\fB-version\fR.
+
+Finally, there are certain options for \fIlatex\fR and \fIpdflatex\fR
+(e.g., \fB-recorder\fR) that trigger special actions or behavior by
+\fIlatexmk\fR itself as well as being passed in some form to the
+called \fIlatex\fR and \fIpdflatex\fR program, or that affect other
+programs as well. These options do have entries in this
+documentation. These options are:
+\fB-jobname=STRING\fR, \fB-aux-directory=dir\fR,
+\fB-output-directory=DIR\fR, \fB-quiet\fR, and \fB-recorder\fR.
+
+.TP
+.B -silent
+Run commands silently, i.e., with options that reduce the amount of
+diagnostics generated. For example, with the default settings, the
+command "latex -interaction=batchmode" is used for \fIlatex\fR,
+and similarly for its friends.
+
+See also the \fB-logfilewarninglist\fR and \fB-logfilewarninglist-\fR
+options.
+
+Also reduce the number of informational messages that \fIlatexmk\fR
+itself generates.
+
+To change the options used to make the commands run silently, you need
+to configure \fIlatexmk\fR with changed values of its configuration
+variables, the relevant ones being \fI$bibtex_silent_switch\fR,
+\fI$biber_silent_switch\fR, \fI$dvipdf_silent_switch\fR,
+\fI$dvips_silent_switch\fR, \fI$latex_silent_switch\fR,
+\fI$lualatex_silent_switch\fR
+\fI$makeindex_silent_switch\fR, \fI$pdflatex_silent_switch\fR,
+and \fI$xelatex_silent_switch\fR
+
+.TP
+.B -stdtexcmds
+Sets the commands for \fIlatex\fR, etc, so that they are the standard
+ones. This is useful to override special configurations.
+
+The result is that \fI$latex = 'latex %O %S'\fR, and similarly for
+\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR. (The option
+\fB-no-pdf\fR needed for \fI$xelatex\fR is provided automatically,
+given that %O appears in the definition.)
+
+.TP
+.B -time
+Show CPU time used.
+See also the configuration variable \fI$show_time\fR.
+
+.TP
+.B -time-
+Do not show CPU time used.
+See also the configuration variable \fI$show_time\fR.
+
+.TP
+.B -use-make
+When after a run of \fIlatex\fR or \fIpdflatex\fR, there are warnings
+about missing files (e.g., as requested by the LaTeX \\input, \\include,
+and \\includgraphics commands), \fIlatexmk\fR tries to make them by a custom
+dependency. If no relevant custom dependency with an appropriate
+source file is found, and if the \fB-use-make\fR option is set, then
+as a last resort \fIlatexmk\fR will try to use the \fImake\fR program
+to try to make the missing files.
+
+Note that the filename may be specified without an extension, e.g.,
+by \\includegraphics{drawing} in a LaTeX file. In that case,
+\fIlatexmk\fR will try making drawing.ext with ext set in turn to the
+possible extensions that are relevant for \fIlatex\fR (or as
+appropriate \fIpdflatex\fR).
+
+See also the documentation for the \fI$use_make_for_missing_files\fR
+configuration variable.
+
+.TP
+.B -use-make-
+Do not use the make program to try to make missing files. (Default.)
+
+.TP
+.B -usepretex
+Sets the command lines for \fIlatex\fR, etc, so that they use the code
+that is defined by the variable \fI$pre_tex_code\fR or that is set by
+the option \fB-pretex=CODE\fR to execute the specified TeX code before
+the source file is read. This option overrides any previous
+definition of the command lines.
+
+The result is that \fI$latex = 'latex %O %P'\fR, and similarly for
+\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR. (The option
+\fB-no-pdf\fR needed for \fI$xelatex\fR is provided automatically,
+given that %O appears in the definition.)
+
+.TP
+.B -usepretex=CODE
+Equivalent to \fB-pretex=CODE -usepretex\fR. Example
+
+ latexmk -usepretex='\\AtBeginDocument{Message\\par}' foo.tex
+
+.TP
+.B -v, -version
+Print version number of \fIlatexmk\fR.
+
+.TP
+.B -verbose
+Opposite of \fB-silent\fR. This is the default setting.
+
+.TP
+.B -view=default, -view=dvi, -view=ps, -view=pdf, -view=none
+Set the kind of file used when previewing is requested (e.g., by the
+\fB-pv\fR or \fB-pvc\fR switches). The default is to view the "highest"
+kind of requested file (in the low-to-high order .dvi, .ps, .pdf).
+
+Note the possibility \fB-view=none\fR where no viewer is opened at
+all. One example of is use is in conjunction with the \fB-pvc\fR
+option, when you want \fIlatexmk\fR to do a compilation automatically
+whenever source file(s) change, but do not want a previewer to be opened.
+
+.TP
+.B -Werror
+This causes \fIlatexmk\fR to return a non-zero status code if any of
+the files processed gives a warning about problems with citations or
+references (i.e., undefined citations or references or about multiply
+defined references). This is \fBafter\fR \fIlatexmk\fR has completed
+all the runs it needs to try and resolve references and citations.
+Thus \fB-Werror\fR causes \fIlatexmk\fR to treat such warnings as
+errors, but only when they occur on the last run of (pdf)latex and
+only after processing is complete. Also can be set by the
+configuration variable \fI$warnings_as_errors\fR.
+
+.TP
+.B -xelatex
+Use \fIxelatex\fR. That is, use \fIxelatex\fR to process the source file(s) to
+pdf. The generation of dvi and postscript files is turned off.
+
+This option is equivalent to using the following set of options
+
+ -pdfxe -dvi- -ps-
+
+[\fINote\fR: Note that the method of implementation of this option,
+but not its intended primary effect, differ from some earlier versions
+of \fIlatexmk\fR. \fILatexmk\fR first uses \fIxelatex\fR to make
+an .xdv file, and does all the extra runs needed (including those of
+\fIbibtex\fR, etc). Only after that does it make the pdf file from
+the .xdv file, using \fIxdvipdfmx\fR. This procedure can result in
+considerable savings in run time, since the xdv-to-pdf conversion is
+quite time-consuming when large graphics files are used in the
+document.]
+
+
+.PP
+\fBCompatibility between options\fR
+
+The preview-continuous option \fB-pvc\fR can only work with one file.
+So in this case you will normally only specify one filename on
+the command line.
+.PP
+Options \fB-p\fR, \fB-pv\fR and \fB-pvc\fR are mutually exclusive. So
+each of these options turns the others off.
+
+.SH EXAMPLES
+.nf
+.ta 2i
+% \fBlatexmk thesis\fR \fI# run latex enough times to resolve
+ cross-references\fR
+
+% \fBlatexmk -pvc -ps thesis\fR \fI# run latex enough times to resolve
+ cross-references, make a postscript
+ file, start a previewer. Then
+ watch for changes in the source
+ file thesis.tex and any files it
+ uses. After any changes rerun latex
+ the appropriate number of times and
+ remake the postscript file. If latex
+ encounters an error, \fIlatexmk\fR will
+ keep running, watching for
+ source file changes.
+
+% \fBlatexmk -c\fR \fI# remove .aux, .log, .bbl, .blg, .dvi,
+ .pdf, .ps & .bbl files\fR
+
+
+.SH DEALING WITH ERRORS, PROBLEMS, ETC
+
+.PP
+Some possibilities:
+
+a. If you get a strange error, do look carefully at the output that is
+on the screen and in log files. While there is much that is
+notoriously verbose in the output of \fIlatex\fR (and that is added to
+by \fIlatexmk\fR), the verbosity is there for a reason: to enable the
+user to diagnose problems. \fILatexmk\fR does repeat some messages at
+the end of a run that it thinks would otherwise be easy to miss in the
+middle of other output.
+
+b. Generally, remember that \fIlatexmk\fR does its work by running
+other programs. Your first priority in dealing with errors should be
+to examine what went wrong with the individual programs. Then you
+need to correct the causes of errors in the runs of these programs.
+(Often these come from errors in the source document, but they could
+also be about missing LaTeX packages, etc.)
+
+c. If \fIlatexmk\fR doesn't run the programs the way you would like,
+then you need to look in this documentation at the list of command
+line options and then at the sections on configuration/initialization
+files. A lot of \fIlatexmk\fR's behavior is configurable to deal with
+particular situations. (But there is a lot of reading!)
+
+\fIThe remainder of these notes consists of ideas for dealing with more
+difficult situations.\fR
+
+d. Further tricks can involve replacing the standard commands that
+\fIlatexmk\fR runs by other commands or scripts.
+
+e. For possible examples of code for use in an RC file, see the
+directory example_rcfiles in the distribution of \fIlatexmk\fR (e.g.,
+at http://mirror.ctan.org/support/latexmk/example_rcfiles).
+Even if these examples don't do what you want, they may provide
+suitable inspiration.
+
+f. There's a useful trick that can be used when you use \fIlualatex\fR
+instead of \fIpdflatex\fR (and in some related situations). The
+problem is that \fIlatexmk\fR won't notice a dependency on a file,
+bar.baz say, that is input by the lua code in your document instead of
+by the LaTeX part. (Thus if you change bar.baz and rerun
+\fIlatexmk\fR, then \fIlatexmk\fR will think no files have changed and
+not rerun \fIlualatex\fR, whereas if you had '\\input{bar.baz}' in the
+LaTeX part of the document, \fIlatexmk\fR would notice the change.)
+One solution is just to put the following somewhere in the LaTeX part
+of the document:
+
+ \\typeout{(bar.baz)}
+
+This puts a line in the log file that \fIlatexmk\fR will treat as
+implying that the file bar.baz was read. (At present I don't know a
+way of doing this automatically.) Of course, if the file has a
+different name, change bar.baz to the name of your file.
+
+g. See also the section "Advanced Configuration: Some extra resources".
+
+h. Look on tex.stackexchange, i.e., at
+http://tex.stackexchange.com/questions/tagged/latexmk Someone may
+have already solved your problem.
+
+i. Ask a question at tex.stackexchange.com.
+
+j. Or ask me (the author of \fIlatexmk\fR). My e-mail is at the end
+of this documentation.
+
+
+.SH ALLOWING FOR CHANGE OF OUTPUT FILE TYPE
+
+When one of the latex engines is run, the usual situation is that
+\fIlatex\fR produces a .dvi file, while \fIpdflatex\fR and
+\fIlualatex\fR produce a .pdf file. For \fIxelatex\fR the default is
+to produce a .pdf file, but to optimize processing time \fIlatexmk\fR
+runs \fIxelatex\fR its \fB-no-pdf\fR option so that it produces
+an .xdv file. Further processing by \fIlatexmk\fR takes this as a
+starting point.
+
+However, the actual output file may differ from the normal
+expectation; and then \fIlatexmk\fR can adjust its processing to
+accommodate this situation. The difference in output file type can
+happen for two reasons: One is that for \fIlatex\fR, \fIpdflatex\fR
+and \fIlualatex\fR the document itself can override the defaults. The
+other is that there may be a configuration, or misconfiguration, such
+that the program that \fIlatexmk\fR invokes to compile the document is
+not the expected one, or is given options incompatible with what
+\fIlatexmk\fR initially expects. (E.g., the \fB-output-format=...\fR
+option could be used with \fIlualatex\fR, or \fIxelatex\fR gets
+invoked without the \fB-no-pdf\fR option.)
+
+Under \fIlatex\fR and \fIpdflatex\fR, control of the output format by
+the document is done by setting the \\pdfoutput macro. Under
+\fIlualatex\fR, the \\outputmode macro is used instead.
+
+One example of an important use-case for document control of the
+output format is a document that uses the psfrag package to insert
+graphical elements in the output file. The psfrag package achieves its
+effects by inserting postscript code in the output of the compilation
+of the document. This entails the use of compilation to a .dvi file,
+followed by the use of conversion to a postscript file (either
+directly, as by \fIdvips\fR or implicitly, as an intermediate step by
+\fIdvipdf\fR). Then it is useful to force output to be of the .dvi
+format by inserting \\pdfoutput=0 in the preamble of the document.
+
+Another example is where the document uses graphics file of
+the .pdf, .jpg, and png types. With the default setting for the
+graphicx package, these can be processed in compilation to .pdf but
+not with compilation to .dvi. In this case, it is useful to insert
+\\pdfoutput=1 in the preamble of the document to force compilation
+to .pdf output format.
+
+In all of these cases, it is needed that \fIlatexmk\fR has to adjust
+its processing to deal with a mismatch between the actual output
+format (out of .pdf, .dvi, .xdv) and the initially expected output, if
+possible. \fILatexmk\fR does this provided the following conditions
+are met.
+
+The first is that \fIlatexmk\fR's \fI$allow_switch\fR configuration
+variable is set to a non-zero value as it is by default. If this
+variable is zero, a mismatch of filetypes in the compilation results
+in an erro.
+
+The second condition for \fIlatexmk\fR to be able to handle a change
+of output type is that no explicit requests for .dvi or .ps output
+files are made. Explicit requests are by the \fB-dvi\fR and
+\fB-ps\fR, \fB-print=dvi\fR, \fB-print=ps\fR, \fB-view=dvi\fR, and
+\fB-view=ps\fR options, and by corresponding settings of the
+\fI$dvi_mode\fR, \fI$postscript_mode\fR, \fI$print_type\fR, and
+\fI$view\fR configuration variables. The print-type and view-type
+restrictions only apply when printing and viewing are explicitly
+requested, respectively. For this purpose, the use of the
+\fB-pdfdvi\fR and \fB-pdfps\fR options (and the corresponding setting
+of the \fI$pdf_mode\fR variable) does not count as an explicit request
+for the .dvi and .ps files; they are merely regarded as a request for
+making a .pdf file together with an initial proposal for the
+processing route to make it.
+
+Note that when accommodating a change in output file type, there is
+involved a substantial change in the network of rules that
+\fIlatexmk\fR uses in its actions. The second condition applied to
+accommodate a change is to avoid situations where the change in the
+rule network is too radical to be readily handled automatically.
+
+
+.SH CONFIGURATION/INITIALIZATION (RC) FILES
+.PP
+In this section is explained which configuration files are read by
+\fIlatexmk\fR. Subsequent sections "How to Set Variables in
+Initialization Files", "Format of Command Specifications", "List of
+Configuration Variables Usable in Initialization Files", "Custom
+Dependencies", and "Advanced Configuration" give details on what can
+be configured and how.
+
+\fILatexmk\fR can be customized using initialization files, which are
+read at startup in the following order:
+.PP
+1) The system RC file, if it exists.
+ On a UNIX system, \fIlatexmk\fR searches for following places for its
+system RC file, in the following order, and reads the first it finds:
+ "/opt/local/share/latexmk/LatexMk",
+ "/usr/local/share/latexmk/LatexMk",
+ "/usr/local/lib/latexmk/LatexMk".
+ On a MS-Windows system it looks for "C:\\latexmk\\LatexMk".
+ On a cygwin system (i.e., a MS-Windows system in which Perl is
+that of cygwin), \fIlatexmk\fR reads the first it finds of
+ "/cygdrive/c/latexmk/LatexMk",
+ "/opt/local/share/latexmk/LatexMk",
+ "/usr/local/share/latexmk/LatexMk",
+ "/usr/local/lib/latexmk/LatexMk".
+
+In addition, it then tries the same set of locations, but with the
+file name replaced "LatexMk" replaced by "latexmkrc".
+
+If the environment variable LATEXMKRCSYS is set, its value is used as
+the name of the system RC file, instead of any of the above.
+.PP
+2) The user's RC file, if it exists. This can be in one of two
+places. The traditional one is ".latexmkrc" in the user's home
+directory. The other possibility is "latexmk/latexmkrc" in the user's
+XDG configuration home directory. The actual file read is the first
+of "$XDG_CONFIG_HOME/latexmk/latexmkrc" or "$HOME/.latexmkrc" which
+exists. (See
+https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
+for details on the XDG Base Directory Specification.)
+
+Here $HOME
+is the user's home directory. [\fILatexmk\fR determines the user's
+home directory as follows: It is the value of the environment variable
+HOME, if this variable exists, which normally is the case on UNIX-like
+systems (including Linux and OS-X). Otherwise the environment
+variable USERPROFILE is used, if it exists, which normally is the case
+on MS-Windows systems. Otherwise a blank string is used instead of
+$HOME, in which case \fIlatexmk\fR does not look for an RC file in
+it.]
+
+$XDG_CONFIG_HOME is the value of the environment variable
+XDG_CONFIG_HOME if it exists. If this environment variable does not
+exist, but $HOME is non-blank, then $XDG_CONFIG_HOME is set to the
+default value of $HOME/.config. Otherwise $XDG_CONFIG_HOME is blank,
+and \fIlatexmk\fR does not look for an RC file under it.
+
+.PP
+3) The RC file in the current working directory. This file can be
+named either "latexmkrc" or ".latexmkrc", and the first of these to be
+found is used, if any.
+.PP
+4) Any RC file(s) specified on the command line with the \fB-r\fR
+option.
+.PP
+Each RC file is a sequence of \fIPerl\fR commands. Naturally, a user can use
+this in creative ways. But for most purposes, one simply uses a
+sequence of assignment statements that override some of the built-in
+settings of \fILatexmk\fR. Straightforward cases can be handled
+without knowledge of the \fIPerl\fR language by using the examples in this
+document as templates. Comment lines are introduced by the "#"
+character.
+
+Note that command line options are obeyed in the order in which
+they are written; thus any RC file specified on the command line with
+the \fB-r\fR option can override previous options but can be itself
+overridden by later options on the command line. There is also the
+\fB-e\fR option, which allows initialization code to be specified in
+\fIlatexmk\fR's command line.
+
+\fI
+For possible examples of code for in an RC file, see the directory
+example_rcfiles in the distribution of \fIlatexmk\fR (e.g., at
+http://mirror.ctan.org/support/latexmk/example_rcfiles).
+\fR
+
+.SH HOW TO SET VARIABLES IN INITIALIZATION FILES
+.PP
+The important variables that can be configured are described in the
+section "List of configuration variables usable in initialization
+files". (See the earlier section "Configuration/Initialization (rc)
+Files" for the files where the configurations are done.) Syntax for
+setting these variables is of the following forms:
+.PP
+ $bibtex = 'bibtex %O %B';
+.PP
+for the setting of a string variable,
+.PP
+ $preview_mode = 1;
+.PP
+for the setting of a numeric variable, and
+.PP
+ @default_files = ('paper', 'paper1');
+.PP
+for the setting of an array of strings. It is possible to append an
+item to an array variable as follows:
+
+ push @default_files, 'paper2';
+
+Note that simple "scalar" variables have names that begin with a $
+character and array variables have names that begin with a @
+character. Each statement ends with a semicolon.
+
+Strings should be enclosed in single quotes. (You could use double
+quotes, as in many programming languages. But then the \fIPerl\fR
+programming language brings into play some special rules for
+interpolating variables into strings. People not fluent in \fIPerl\fR
+will want to avoid these complications.)
+
+You can do much more complicated things, but for this you will need to
+consult a manual for the \fIPerl\fR programming language.
+
+
+
+.SH FORMAT OF COMMAND SPECIFICATIONS
+
+Some of the variables set the commands that \fIlatexmk\fR uses for
+carrying out its work, for example to generate a .dvi file from a .tex
+file or to view a postscript file. This section describes some
+important features of how the commands are specified.
+(Note\ that some of the possibilities listed here do not apply to
+the \fI$kpsewhich\fR variable; see its documentation.)
+
+\fBPlaceholders\fR: Supposed you wanted \fIlatexmk\fR to use the
+command elatex in place of the regular latex command, and suppose
+moreover that you wanted to give it the option "--shell-escape". You
+could do this by the following setting:
+.PP
+ $latex = 'elatex --shell-escape %O %S';
+.PP
+The two items starting with the % character are placeholders. These
+are substituted by appropriate values before the command is run. Thus
+%S will be replaced by the source file that elatex will be applied to,
+and %O will be replaced by any options that \fIlatexmk\fR has decided
+to use for this command. (E.g., if you used the \fB-silent\fR option in the
+invocation of \fIlatexmk\fR, it results in the replacement of %O by
+"-interaction=batchmode".)
+
+The available placeholders are:
+.TP
+.B %A
+basename of the main tex file. Unlike %R, this is unaffected by the
+setting of a jobname by the \fI-jobname\fR option or the
+\fI$jobname\fR configuration value.
+.TP
+.B %B
+base of filename for current command. E.g., if a postscript file
+document.ps is being made from the dvi file document.dvi, then the
+basename is document.
+.TP
+.B %D
+destination file (e.g., the name of the postscript file when
+converting a dvi file to postscript).
+.TP
+.B %O
+options
+.TP
+.B %P
+If the variable \fI$pre_tex_code\fR is non-empty, then %P is
+substituted by the contents of \fI$pre_tex_code\fR followed by
+\fI\\input{SOURCE}\fR, where SOURCE stands for the name of the source
+file. Appropriate quoting is done. This enables TeX code to be
+passed to one of the \fI*latex\fR engines to be executed before the
+source file is read.
+
+If the variable \fI$pre_tex_code\fR is the empty string, then %P is
+equivalent to %S.
+.TP
+.B %R
+root filename. This is the base name for the main tex file.
+
+By default this is the basename of the main tex file. However the
+value can be changed by the use of the \fI-jobname\fR option or the
+\fI$jobname\fR configuration variable.
+.TP
+.B %S
+source file (e.g., the name of the dvi file when converting a .dvi file
+to ps).
+.TP
+.B %T
+The name of the primary tex file.
+.TP
+.B %U
+If the variable \fI$pre_tex_code\fR is non-empty, then its value is
+substituted for %U (appropriately quoted). Otherwise it is replaced
+by a null string.
+.TP
+.B %Y
+Name of directory for auxiliary output files (see the configuration
+variable \fI$aux_dir\fR). A directory separation character ('/') is
+appended if \fI$aux_dir\fR is non-empty and does not end in a suitable
+character, with suitable characters being those appropriate to UNIX
+and MS-Windows, i.e., ':', '/' and '\\'. Note that if after
+initialization, \fI$out_dir\fR is set, but \fI$aux_dir\fR is not set
+(i.e., it is blank), then \fIlatexmk\fR sets \fI$aux_dir\fR to the
+same value \fI$out_dir\fR.
+.TP
+.B %Z
+Name of directory for output files (see the configuration
+variable \fI$out_dir\fR). A directory separation character ('/') is
+appended if \fI$out_dir\fR is non-empty and does not end in a suitable
+character, with suitable characters being those appropriate to UNIX
+and MS-Windows, i.e., ':', '/' and '\\'.
+.PP
+If for some reason you need a literal % character in your string not
+subject to the above rules, use "%%".
+.PP
+Appropriate quoting will be applied to the filename substitutions, so
+you mustn't supply them yourself even if the names of your files have
+spaces in them. (But if your TeX filenames have spaces in them,
+beware that some older versions of the TeX program cannot correctly handle
+filenames containing spaces.) In case \fIlatexmk\fR's quoting does not work
+correctly on your system, you can turn it off -- see the documentation
+for the variable \fI$quote_filenames\fR.
+.PP
+The distinction between %B and %R needs a bit of care, since they are
+often the same, but not always. For example on a simple document, the
+basename of a bibtex run is the same as for the texfile. But in a
+document with several bibliographies, the bibliography files will have
+a variety of names. Since bibtex is invoked with the basename of the
+bibliography file, the setting for the bibtex command should therefore
+be
+.PP
+ $bibtex = 'bibtex %O %B';
+.PP
+Generally, you should use %B rather than %R. Similarly for most
+purposes, the name %T of the primary texfile is not a useful
+placeholder.
+
+See the default values in the section "List of configuration variables
+usable in initialization files" for what is normally the most
+appropriate usage.
+
+If you omit to supply any placeholders whatever in the specification
+of a command, \fIlatexmk\fR will supply what its author thinks are
+appropriate defaults. This gives compatibility with configuration
+files for previous versions of \fIlatexmk\fR, which didn't use
+placeholders.
+
+\fB"Detaching" a command\fR: Normally when \fIlatexmk\fR runs a
+command, it waits for the command to run to completion. This is
+appropriate for commands like latex, of course. But for previewers,
+the command should normally run detached, so that \fIlatexmk\fR gets
+the previewer running and then returns to its next task (or exits if
+there is nothing else to do). To achieve this effect of detaching a
+command, you need to precede the command name with "start ", as in
+.PP
+ $dvi_previewer = 'start xdvi %O %S';
+.PP
+This will be translated to whatever is appropriate for your operating
+system.
+
+Notes: (1) In some circumstances, \fIlatexmk\fR will always run a
+command detached. This is the case for a previewer in preview
+continuous mode, since otherwise previewing continuously makes no
+sense. (2) This precludes the possibility of running a command named
+start. (3) If the word start occurs more than once at the beginning
+of the command string, that is equivalent to having just one. (4)
+Under cygwin, some complications happen, since cygwin amounts to a
+complicated merging of UNIX and MS-Windows. See the source code for
+how I've handled the problem.
+
+\fBCommand names containing spaces\fR: Under MS-Windows it is common
+that the name of a command includes spaces, since software is often
+installed in a subdirectory of "C:\\Program Files". Such command names
+should be enclosed in double quotes, as in
+.PP
+ $lpr_pdf = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p %S';
+ $pdf_previewer = 'start "c:/Program Files/SumatraPDF/SumatraPDF.exe" %O %S';
+ $pdf_previewer = 'start "c:/Program Files/SumatraPDF (x86)/SumatraPDF.exe" %O %S';
+
+.PP
+(Note about the above example: Under MS-Windows forward slashes are
+equivalent to backslashes in a filename under almost all circumstances,
+provided that the filename
+is inside double quotes. It is easier to use forward slashes in
+examples like the one above, since then one does not have to worry
+about the rules for dealing with forward slashes in strings in the
+Perl language.)
+
+\fBCommand names under Cygwin\fR: If \fIlatexmk\fR is executed by Cygwin's
+Perl, \fI be particularly certain that pathnames in commands have
+\fBforward\fI slashes\fR not the usual backslashes for the separator
+of pathname components. See the above examples. Backslashes often
+get misinterpreted by the Unix shell used by Cygwin's Perl to execute
+external commands. Forward slashes don't suffer from this problem,
+and (when quoted, as above) are equally acceptable to MS-Windows.
+
+\fBUsing MS-Windows file associations\fR: A useful trick under modern
+versions of MS-Windows (e.g., WinXP) is to use just the
+command 'start' by itself:
+.PP
+ $dvi_previewer = 'start %S';
+.PP
+Under MS-Windows, this will cause to be run
+whatever program the system has associated with dvi files. (The same
+applies for a postscript viewer and a pdf viewer.) But note that this
+trick is not always suitable for the pdf previwer, if your system has
+acroread for the default pdf viewer. As explained elsewhere, acroread
+under MS-Windows does not work well with \fIlatex\fR and
+\fIlatexmk\fR, because acroread locks the pdf file.
+
+\fBNot using a certain command\fR: If a command is not to be run, the
+command name NONE is used, as in
+.PP
+ $lpr = 'NONE lpr';
+.PP
+This typically is used when an appropriate command does not exist on
+your system. The string after the "NONE" is effectively a comment.
+
+\fBOptions to commands\fR:
+Setting the name of a command can be used not only for changing the
+name of the command called, but also to add options to command.
+Suppose you want \fIlatexmk\fR to use latex with source specials
+enabled. Then you might use the following line in an initialization
+file:
+.PP
+ $latex = 'latex --src-specials %O %S';
+.PP
+
+\fBRunning a subroutine instead of an external command\fR: Use a
+specification starting with "internal", as in
+.PP
+ $latex = 'internal mylatex %O %S';
+ sub mylatex {
+ my @args = @_;
+ # Possible preprocessing here
+ return system 'latex', @args;
+ }
+.PP
+For some of the more exotic possibilities that then become available,
+see the section "ADVANCED CONFIGURATION: Some extra resources and
+advanced tricks". Also see some of the examples in the directory
+\fIexample_rcfiles\fR in the \fIlatexmk\fR distribution.
+
+\fBAdvanced tricks\fR: Normally one specifies a single command for the
+commands invoked by \fIlatexmk\fR. Naturally, if there is some
+complicated additional processing you need to do in your special
+situation, you can write a script (or batch file) to do the
+processing, and then configure \fIlatexmk\fR to use your script in
+place of the standard program.
+
+You can also use a Perl subroutine instead of a script -- see above.
+This is generally the most flexible and portable solution.
+
+It is also possible to configure \fIlatexmk\fR to run multiple
+commands. For example, if when running \fIpdflatex\fR to generate a pdf
+file from a tex file you need to run another program after \fIpdflatex\fR to
+perform some extra processing, you could do something like:
+
+ $pdflatex = 'pdflatex --shell-escape %O %S; pst2pdf_for_latexmk %B';
+
+This definition assumes you are using a UNIX-like system (which
+includes Linux and OS-X), so that the
+two commands to be run are separated by the semicolon in the middle of
+the string.
+
+If you are using MS-Windows, you would replace the above line by
+
+ $pdflatex = 'cmd /c pdflatex --shell-escape %O %S'
+ . '&& pst2pdf_for_latexmk %B';
+
+Here, the UNIX command separator ; is replaced by &&. In addition,
+there is a problem that some versions of \fIPerl\fR on MS-Windows do
+not obey the command separator; this problem is overcome by explicitly
+invoking the MS-Windows command-line processor \fIcmd.exe\fR.
+
+.SH LIST OF CONFIGURATION VARIABLES USABLE IN INITIALIZATION FILES
+.PP
+In this section are specified the variables whose values can be
+adjusted to configure \fIlatexmk\fR. (See the earlier section
+"Configuration/Initialization (rc) Files" for the files where the
+configurations are done.)
+
+Default values are indicated in brackets. Note that for variables
+that are boolean in character, concerning whether \fIlatexmk\fR does
+or does not behave in a certain way, a non-zero value, normally 1,
+indicates true, i.e., the behavior occurs, while a zero value
+indicates a false value, i.e., the behavior does not occur.
+
+.TP
+.B $allow_switch [1]
+
+This controls what happens when the output extension of latex,
+pdflatex, lualatex or xelatex differs from what is expected. (The
+possible extensions are .dvi, .pdf, .xdv.) This can happen with the
+use of the \\pdfoutput macro in a document compiled under \fIlatex\fR
+or \fIpdflatex\fR, or with the use of the \\outputmode macro under
+\fIlualatex\fR. It can also happen with certain kinds of incorrect
+configuration.
+
+In such a case, \fIlatexmk\fR can appropriately adjust its network of
+rules. The adjustment is made if \fI$allow_switch\fR is on, and if no
+request for a dvi or ps file has been made.
+
+See the section ALLOWING FOR CHANGE OF OUTPUT EXTENSION.
+
+.TP
+.B $always_view_file_via_temporary [0]
+Whether .ps and .pdf files are initially to be made in a temporary
+directory and then moved to the final location. (This applies to
+\fIdvips\fR, \fIdvipdf\fR, and \fIps2pdf\fR operations, and the
+filtering operators on .dvi and .ps files. It does not apply to
+\fIpdflatex\fR, unfortunately, since \fIpdflatex\fR provides no way of
+specifying a chosen name for the output file.)
+
+This use of a temporary file solves a problem that the making of these
+files can occupy a substantial time. If a viewer (notably \fIgv\fR)
+sees that the file has changed, it may read the new file before
+the program writing the file has not yet finished its work, which can
+cause havoc.
+
+See the \fI$pvc_view_file_via_temporary\fR variable for a setting that
+applies only if preview-continuous mode (-pvc option) is used. See
+\fI$tmpdir\fR for the setting of the directory where the temporary
+file is created.
+
+.TP
+.B $analyze_input_log_always [1]
+
+After a run of latex (etc), always analyze .log for input files in the
+<...> and (...) constructions. Otherwise, only do the analysis when
+fls file doesn't exist or is out of date.
+
+Under normal circumstances, the data in the fls file is reliable, and
+the test of the log file gets lots of false positives; usually
+$analyze_input_log_always is best set to zero. But the test of the
+log file is needed at least in the following situation: When a user
+needs to persuade latexmk that a certain file is a source file, and
+latexmk doesn't otherwise find it. Then the user can write code that
+causes a line with (...) to be written to log file. One important
+case is for lualatex, which doesn't always generate lines in the .fls
+file for input lua files. (The situation with lualatex is HIGHLY
+version dependent, e.g., there was a big change between TeXLive 2016
+and TeXLive 2017.)
+
+To keep backward compatibility with older versions
+of latexmk, the default is to set
+$analyze_input_log_always to 1.
+
+.TP
+.B $auto_rc_use [1]
+Whether to automatically read the standard initialization (rc) files,
+which are the system RC file, the user's RC file, and the RC file in
+the current directory. The command line option \fB-norc\fR can be
+used to turn this setting off. Each RC file could also turn this
+setting off, i.e., it could set \fI$auto_rc_use\fR to zero to prevent
+automatic reading of the later RC files.
+
+This variable does not affect the reading of RC files specified on the
+command line by the \fB-r\fR option.
+.TP
+.B $aux_dir [""]
+The directory in which auxiliary files (aux, log, etc) are to be
+written by a run of (pdf)latex. If this variable is not set, but
+\fI$out_dir\fR is set, then \fI$aux_dir\fR is set to \fI$out_dir\fR,
+which is the directory to which general output files are to be
+written.
+
+\fBImportant note\fR: The effect of \fI$aux_dir\fR, if different from
+\fI$out_dir\fR, is achieved by giving \fI(pdf)latex\fR the
+\fB-aux-directory\fR. Currently (Dec. 2011 and later) this only works on the
+MiKTeX version of \fI(pdf)latex\fR.
+
+See also the documentation of \fI$out_dir\fR for some complications on
+what directory names are suitable.
+
+If you also use the \fB-cd\fR option, and \fI$out_dir\fR (or \fI$aux_dir\fR) contains a
+relative path, then the path is interpreted relative to the document
+directory.
+.TP
+.B $banner [0]
+If nonzero, the banner message is printed across each page when
+converting the dvi file to postscript. Without modifying the variable
+\fI$banner_message\fR, this is equivalent to specifying the \fB-d\fR
+option.
+
+Note that if \fI$banner\fR is nonzero, the \fI$postscript_mode\fR is
+assumed and the postscript file is always generated, even if it is newer
+than the dvi file.
+.TP
+.B $banner_intensity [0.95]
+Equivalent to the \fB-bi\fR option, this is a decimal number between 0
+and 1 that specifies how dark to print the banner message. 0 is black,
+1 is white. The default is just right if your toner cartridge isn't
+running too low.
+.TP
+.B $banner_message ["DRAFT"]
+The banner message to print across each page when converting the dvi
+file to postscript. This is equivalent to the \fB-bm\fR option.
+.TP
+.B $banner_scale [220.0]
+A decimal number that specifies how large the banner message will be
+printed. Experimentation is necessary to get the right scale for your
+message, as a rule of thumb the scale should be about equal to 1100
+divided by the number of characters in the message. The Default is
+just right for 5 character messages. This is equivalent to the
+\fB-bs\fR option.
+.TP
+.B @BIBINPUTS
+This is an array variable, now mostly obsolete, that specifies
+directories where
+\fIlatexmk\fR should look for .bib files. By default it is set from
+the BIBINPUTS environment variable of the operating system. If that
+environment variable is not set, a single element list consisting of
+the current directory is set. The format of the directory names
+depends on your operating system, of course. Examples for setting
+this variable are:
+
+ @BIBINPUTS = ( ".", "C:\\\\bibfiles" );
+ @BIBINPUTS = ( ".", "\\\\server\\bibfiles" );
+ @BIBINPUTS = ( ".", "C:/bibfiles" );
+ @BIBINPUTS = ( ".", "//server/bibfiles" );
+ @BIBINPUTS = ( ".", "/usr/local/texmf/bibtex/bib" );
+
+Note that under MS Windows, either a forward slash "/" or a backward
+slash "\(rs" can be used to separate pathname components, so the first
+two and the second two examples are equivalent. Each backward slash
+should be doubled to avoid running afoul of \fIPerl\fR's rules for writing
+strings.
+
+\fIImportant note:\fR This variable is now mostly obsolete in the
+current version of \fIlatexmk\fR,
+since it has a better method of searching for files using the
+kpsewhich command. However, if your system is an unusual one without
+the kpsewhich command, you may need to set the variable \fI@BIBINPUTS\fR.
+.TP
+.B $biber ["biber %O %S"]
+The biber processing program.
+.TP
+.B $biber_silent_switch ["--onlylog"]
+Switch(es) for the biber processing program when silent mode is on.
+.TP
+.B $bibtex ["bibtex %O %S"]
+The BibTeX processing program.
+.TP
+.B $bibtex_fudge [1]
+When using bibtex, whether to take special action to allow bibtex to
+work when $out_dir or $aux_dir is specified. In May 2018, there was
+planned an update to bibtex to correct a bug, after that update, the
+special action will no longer be required.
+.TP
+.B $bibtex_silent_switch ["-terse"]
+Switch(es) for the BibTeX processing program when silent mode is on.
+.TP
+.B $bibtex_use [1]
+Under what conditions to run \fIbibtex\fR or \fIbiber\fR. When
+\fIlatexmk\fR discovers
+from the log file that one (or more)
+\fIbibtex\fR/\fIbiber\fR-generated bibliographies
+are used, it can run \fIbibtex\fR or \fIbiber\fR whenever it appears
+necessary to regenerate the bbl file(s) from their source bib database
+file(s).
+But sometimes, the bib file(s) are not available (e.g., for a document
+obtained from an external archive), but the bbl files are provided.
+In that case use of \fIbibtex\fR or \fIbiber\fR will result in
+incorrect overwriting of the precious bbl files. The variable
+\fI$bibtex_use\fR controls whether this happens, and also controls
+whether or not .bbl files are deleted in a cleanup operation.
+
+The possible values of \fI$bibtex_use\fR are:
+ 0: never use BibTeX or biber;
+never delete .bbl files in a cleanup.
+ 1: only use \fIbibtex\fR or \fIbiber\fR if the bib files exist;
+never delete .bbl files in a cleanup.
+ 1.5: only use \fIbibtex\fR or \fIbiber\fR if the bib files exist;
+conditionally delete .bbl files in a cleanup (i.e., delete them only
+when the bib files all exist).
+ 2: run \fIbibtex\fR or \fIbiber\fR whenever it appears necessary to
+update the bbl
+files, without testing for the existence of the bib files;
+always delete .bbl files in a cleanup.
+
+Note that the value 1.5 does \fInot\fR work properly if the document
+uses \fIbiber\fR instead of \fIbibtex\fR. (There's a long story why
+not.)
+
+.TP
+.B $cleanup_includes_cusdep_generated [0]
+If nonzero, specifies that cleanup also deletes files that are
+generated by custom dependencies.
+(When doing a clean up, e.g., by use of the \fB-C\fR option, custom
+dependencies are those listed in the \fI.fdb_latexmk\fR file from a
+previous run.)
+.TP
+.B $cleanup_includes_generated [0]
+If nonzero, specifies that cleanup also deletes files that are
+detected in the fls file (or failing that, in log file) as being
+generated. It will also include files made from these first
+generation generated files.
+
+This operation is somewhat dangerous, and can have unintended
+consequences, since the files to be deleted are determined from a file
+created by (pdf)latex, which can contain erroneous
+information. Therefore this variable is turned off by default, and
+then files to be deleted are restricted to those explictly specified
+by patterns configured in the variables \fIclean_ext\fR,
+\fIclean_full_ext\fR, and \fI@generated_exts\fR, together with those
+very standard cases that are hardwired into \fIlatexmk\fR (e.g., .log
+files).
+.TP
+.B $cleanup_mode [0]
+If nonzero, specifies cleanup mode: 1 for full cleanup, 2 for cleanup
+except for .dvi, .ps and .pdf files, 3 for cleanup except for dep and aux
+files. (There is also extra cleaning as specified by the
+\fI$clean_ext\fR, \fI$clean_full_ext\fR and \fI@generated_exts\fR
+variables.)
+
+This variable is equivalent to specifying one of
+the \fB-c\fR or \fB-C\fR options. But there should be no need
+to set this variable from an RC file.
+.TP
+.B $clean_ext [""]
+Extra extensions of files for \fIlatexmk\fR to remove when any of the
+clean-up options (\fB-c\fR or \fB-C\fR) is selected.
+The value of this variable is a string containing the extensions
+separated by spaces.
+
+It is also possible to specify a more general pattern of file to be
+deleted, by using the place holder %R, as in commands, and it is also
+possible to use wildcards. Thus setting
+
+ $clean_ext = "out %R-blx.bib %R-figures*.log pythontex-files-%R/*";
+
+in an initialization file will imply that when a clean-up operation is
+specified, not only is the standard set of files deleted, but also
+files of the form FOO.out, FOO-blx.bib, %R-figures*.log, and
+pythontex-files-FOO/*, where FOO stands for the basename of the file
+being processed (as in FOO.tex).
+
+The files to be deleted are relative to the directory specified by
+\fI$aux_dir\fR. (Note that if \fI$out_dir\fR but not \fI$aux_dir\fR
+is set, then in its initialization, \fIlatexmk\fR sets \fI$aux_dir\fR
+equal to \fI$out_dir\fR. A normal situation is therefore that \fI$aux_dir\fR
+equals \fI$out_dir\fR, which is the only case supported by
+TeXLive, unlike MiKTeX.)
+
+The filenames specfied for a clean-up operation can refer not only to
+regular files but also to directories. Directories are only deleted
+if they are empty. An example of an application is to pythontex, which
+creates files in a particular directory. You can arrange to remove
+both the files and the directory by setting
+
+ $clean_ext = "pythontex-files-%R pythontex-files-%R";
+
+See also the variable \fI@generated_exts\fR.
+.TP
+.B $clean_full_ext [""]
+Extra extensions of files for \fIlatexmk\fR to remove when the \fB-C\fR
+option is selected, i.e., extensions of files to remove when the .dvi,
+etc files are to be cleaned-up.
+
+More general patterns are allowed, as for \fI$clean_ext\fR.
+
+The files specified by \fI$clean_full_ext\fR to be deleted are
+relative to the directory specified by \fI$out_dir\fR.
+
+.TP
+.B $compiling_cmd [""], $failure_cmd [""], $warning_cmd [""], $success_cmd [""]
+
+These variables specify commands that are executed at certain points
+of compilations during preview-continuous mode. One motivation for
+their existance is to allow very useful convenient visual indications of
+compilation status even when the window receiving the screen output of
+the compilation is hidden.
+
+The commands are executed at the following points:
+\fI$compiling_cmd\fR at the start of compilation, \fI$success_cmd\fR
+at the end of a completely successful compilation, \fI$failure_cmd\fR
+at the end of an unsuccessful compilation, \fI$warning_cmd\fR at the
+of an otherwise successful compilation that gives warnings about
+undefined citations or references or about multiply defined
+references. If any of above variables is undefined or blank (the
+default situation), then the corresponding command is not executed.
+
+However, when \fI$warning_cmd\fR is not set, then in the case of a
+compilation with warnings about references or citations, but with no
+other error, one or other of \fI$success_cmd\fR or \fI$failure_cmd\fR
+is used (if it is set) according to the setting of
+\fI$warnings_as_errors\fR.
+
+An example of a simple setting of these variables is as follows
+
+ $compiling_cmd = "xdotool search --name \\"%D\\" set_window --name \\"%D compiling\\"";
+ $success_cmd = "xdotool search --name \\"%D\\" set_window --name \\"%D OK\\"";
+ $warning_cmd = "xdotool search --name \\"%D\\" ".
+ "set_window --name \\"%D CITE/REF ISSUE\\"";
+ $failure_cmd = "xdotool search --name \\"%D\\" set_window --name \\"%D FAILURE\\"";
+
+These assume that the program \fIxdotool\fR is installed, that the
+previewer is using an X-Window system for display, and that the title
+of the window contains the name of the displayed file, as it normally
+does. When the commands are executed, the placeholder string %D is replaced by
+the name of the destination file, which is the previewed file. The
+above commands result in an appropriate string being appended to the
+filename in the window title: " compiling", " OK", or " FAILURE".
+
+Other placeholders that can be used are %S, %T, and %R, with %S and %T
+normally being identical. These can be useful for a command changing
+the title of the edit window. The visual indication in a window title
+can useful, since the user does not have to keep shifting attention to
+the (possibly hidden) compilation window to know the status of the
+compilation.
+
+More complicated situations can best be handled by defining a Perl
+subroutine to invoke the necessary commands, and using the "internal"
+keyword in the definitions to get the subroutine to be invoked. (See
+the section "Format of Command Specifications" for how to do this.)
+
+Naturally, the above settings that invoke the \fIxdotool\fR program
+are only applicable when the X-Window system is used for the relevant
+window(s). For other cases, you will have to find what software
+solutions are available.
+
+.TP
+.B @cus_dep_list [()]
+Custom dependency list -- see section on "Custom Dependencies".
+.TP
+.B @default_excluded_files [()]
+When \fIlatexmk\fR is invoked with no files specified on the command
+line, then, by default, it will process all files in the current
+directory with the extension .tex. (In general, it will process the
+files specified in the \fI@default_files\fR variable.)
+
+But sometimes you want to exclude particular files from this default
+list. In that case you can specify the excluded files in the array
+\fI@default_excluded_files\fR. For example if you wanted to process
+all .tex files with the exception of common.tex, which is a not a
+standard alone LaTeX file but a file input by some or all of the
+others, you could do
+
+ @default_files = ("*.tex");
+
+ @default_excluded_files = ("common.tex");
+
+If you have a variable or large number of files to be processed, this
+method saves you from having to list them in detail in
+\fI@default_files\fR and having to update the list every time you
+change the set of files to be processed.
+
+Notes: 1. This variable has no effect except when no files are
+specified on the \fIlatexmk\fR command line. 2. Wildcards are allowed
+in \fI@default_excluded_files\fR.
+.TP
+.B @default_files [("*.tex")]
+Default list of files to be processed.
+
+If no filenames are specified on the command line,
+\fIlatexmk\fR processes all tex files specified in the \fI@default_files\fR
+variable, which by default is set to all tex files ("*.tex") in the
+current directory. This is a convenience: just run \fIlatexmk\fR and
+it will process an appropriate set of files. But sometimes you want
+only some of these files to be processed. In this case you can list
+the files to be processed by setting
+\fI@default_files\fR in an initialization file
+(e.g., the file "latexmkrc" in the current directory). Then if no
+files are specified on the command line then the files you specify by
+setting \fI@default_files\fR are processed.
+
+Three examples:
+
+ @default_files = ("paper_current");
+
+ @default_files = ("paper1", "paper2.tex");
+
+ @default_files = ("*.tex", "*.dtx");
+
+Note that more than file may be given, and that the default extension
+is ".tex". Wild cards are allowed. The parentheses are because
+\fI@default_files\fR is an array variable, i.e., a sequence of
+filename specifications is possible.
+
+If you want \fIlatexmk\fR to process all .tex files with a few
+exceptions, see the \fI@default_excluded_files\fR array variable.
+.TP
+.B $dependents_phony [0]
+If a list of dependencies is output, this variable determines whether
+to include a phony target for each source file. If you use the
+dependents list in a Makefile, the dummy rules work around errors make
+gives if you remove header files without updating the Makefile to
+match.
+.TP
+.B $dependents_list [0]
+Whether to display a list(s) of dependencies at the end of a run.
+.TP
+.B $deps_file ["-"]
+Name of file to receive list(s) of dependencies at the end of a run,
+to be used if \fI$dependesnt_list\fR is set. If the filename is "-",
+then the dependency list is set to stdout (i.e., normally the screen).
+.TP
+.B $do_cd [0]
+Whether to change working directory to the directory specified for the
+main source file before processing it. The default behavior is not to
+do this, which is the same as the behavior of \fIlatex\fR and
+\fIpdflatex\fR programs. This variable is set by the \fB-cd\fR and
+\fB-cd-\fR options on \fIlatexmk\fR's command line.
+.TP
+.B $dvi_filter [empty]
+The dvi file filter to be run on the newly produced dvi file before
+other processing. Equivalent to specifying the \fB-dF\fR option.
+.TP
+.B $dvi_mode [See below for default]
+If nonzero, generate a dvi version of the document.
+Equivalent to the \fB-dvi\fR option.
+
+The variable $dvi_mode defaults to 0, but if no explicit requests are
+made for other types of file (postscript, pdf), then $dvi_mode will be
+set to 1. In addition, if a request for a file for which a .dvi file
+is a prerequisite, then $dvi_mode will be set to 1.
+.TP
+.B $dvi_previewer ["start xdvi %O %S" under UNIX]
+The command to invoke a dvi-previewer.
+[Under MS-Windows the default is "start"; then \fIlatexmk\fR arranges to
+use the MS-Windows \fIstart\fR program, which will cause to be run
+whatever command the system has associated with .dvi files.]
+
+\fBImportant note\fR: Normally you will want to have a previewer run
+detached, so that \fIlatexmk\fR doesn't wait for the previewer to
+terminate before continuing its work. So normally you should prefix
+the command by "start ", which flags to \fIlatexmk\fR that it should
+do the detaching of the previewer itself (by whatever method is
+appropriate to the operating system). But sometimes letting
+\fIlatexmk\fR do the detaching is not appropriate (for a variety of
+non-trivial reasons), so you should put the "start " bit in
+yourself, whenever it is needed.
+.TP
+.B $dvi_previewer_landscape ["start xdvi %O %S"]
+The command to invoke a dvi-previewer in landscape mode.
+[Under MS-Windows the default is "start"; then \fIlatexmk\fR arranges to
+use the MS-Windows \fIstart\fR program, which will cause to be run
+whatever command the system has associated with .dvi files.]
+.TP
+.B $dvipdf ["dvipdf %O %S %D"]
+Command to convert .dvi to .pdf file. A common reconfiguration is to
+use the dvipdfm command, which needs its arguments in a different order:
+
+ $dvipdf = "dvipdfm %O -o %D %S";
+
+WARNING: The default dvipdf script generates pdf files with bitmapped
+fonts, which do not look good when viewed by acroread. That script
+should be modified to give dvips the options "-P pdf" to ensure that
+type 1 fonts are used in the pdf file.
+.TP
+.B $dvipdf_silent_switch ["-q"]
+Switch(es) for dvipdf program when silent mode is on.
+
+N.B. The standard dvipdf program runs silently, so adding the silent
+switch has no effect, but is actually innocuous. But if an
+alternative program is used, e.g., dvipdfmx, then the silent switch
+has an effect. The default setting is correct for \fIdvipdfm\fR and
+\fIdvipdfmx\fR.
+.TP
+.B $dvips ["dvips %O -o %D %S"]
+The program to used as a filter to convert a .dvi file to a .ps file.
+If pdf is going to be generated from pdf, then the value of the
+\fI$dvips_pdf_switch\fR variable -- see below -- will be included in
+the options substituted for "%O".
+.TP
+.B $dvips_landscape ["dvips -tlandscape %O -o %D %S"]
+The program to used as a filter to convert a .dvi file to a .ps file
+in landscape mode.
+.TP
+.B $dvips_pdf_switch ["-P pdf"]
+Switch(es) for \fIdvips\fR program when pdf file is to be generated
+from .ps file.
+.TP
+.B $dvips_silent_switch ["-q"]
+Switch(es) for \fIdvips\fR program when silent mode is on.
+.TP
+.B $dvi_update_command [""]
+When the dvi previewer is set to be updated by running a command, this
+is the command that is run. See the information for the variable
+\fI$dvi_update_method\fR for further information, and see information
+on the variable \fI$pdf_update_method\fR for an example for the
+analogous case of a pdf previewer.
+.TP
+.B $dvi_update_method [2 under UNIX, 1 under MS-Windows]
+How the dvi viewer updates its display when the dvi file has changed.
+The values here apply equally to the \fI$pdf_update_method\fR and to
+the \fI$ps_update_method\fR variables.
+ 0 => update is automatic,
+ 1=> manual update by user, which may only mean a mouse click on the
+viewer's window or may mean a more serious action.
+ 2 => Send the signal, whose number is in the variable
+\fI$dvi_update_signal\fR. The default value under UNIX is
+suitable for \fIxdvi\fR.
+ 3 => Viewer cannot do an update, because it locks the file. (As with
+\fIacroread\fR under MS-Windows.)
+ 4 => run a command to do the update. The command is specified by
+the variable \fI$dvi_update_command\fR.
+
+See information on the variable \fI$pdf_update_method\fR for an
+example of updating by command.
+.TP
+.B $dvi_update_signal [Under UNIX: SIGUSR1, which is a system-dependent value]
+The number of the signal that is sent to the dvi viewer when it is
+updated by sending a signal -- see the information on the variable
+\fI$dvi_update_method\fR. The default value is the one appropriate
+for \fIxdvi\fR on a UNIX system.
+.TP
+.B $failure_cmd [undefined]
+See the documentation for \fI$compiling_cmd\fR.
+.TP
+.B $fdb_ext ["fdb_latexmk"]
+The extension of the file which \fIlatexmk\fR generates to contain a
+database of information on source files. You will not normally need
+to change this.
+.TP
+.B $filetime_causality_threshold [5]; $filetime_offset_report_threshold [30]. \fR(Units of seconds.)
+
+These variables control how \fIlatexmk\fR deals with the following
+issue, which can affect the use of files that are on a remote
+filesystem (network share) instead of being on a file system local to
+the computer running \fIlatexmk\fR. Almost users will not have to
+worry about these settings, and can ignore the following explanation.
+
+In almost all situations, \fIlatexmk\fR does not need to use the time
+stamps of the files it works with. However, there are a couple of
+situations when it needs to know whether a certain file was created in
+the current run of a program (e.g., \fI(pdf)latex\fR) or is a leftover
+file from a previous run. It does this by comparing the modification
+time of the file with the system time just before the program was
+started. If the modification time is earlier than when the program was
+started, the file is a leftover file, which \fIlatexmk\fR treats as if
+it were not created. If the filetime is at least the program start
+time, then it can be assumed that the file was created in the current
+run.
+
+Unfortunately, this test can fail if the file is on a remote system,
+since its system time is not necessarily synchronized with that of the
+local system; the timestamps on the remote files are set by the remote
+system, not the local system. Generally, modern operating systems
+regularly synchronize their time with a server, so the
+non-synchronization is mostly small (a second or so, or a few
+seconds). But even a small difference can mess up \fIlatexmk\fR's
+test.
+
+\fILatexmk\fR measures the time difference between the time on the two
+systems and compensates for this. But the measurement (in a
+system-independent way) is only accurate to a second or two. So
+\fIlatexmk\fR allows for a threshold on the difference between file
+and system time before it concludes that a file is a leftover file
+from a previous run. The configuration variable
+\fI$filetime_causality_theshhold\fR, which in units of seconds,
+specifies this threshold. Luckily high precision is not needed. The
+previous run is normally the previous run in a human run-edit-run
+cycle, and is at least many seconds back. A few seconds is therefore
+appropriate for the threshold, \fI$filetime_causality_theshhold\fR; it
+should be non-negative always, and should be bigger than 2 if a remote
+filesystem or network share is used.
+
+If the difference in system times on the two systems is large, it
+normally indicates that at least one of the systems is misconfigured.
+The variable \fI$filetime_offset_report_threshold\fR specifies the
+smallest size of the difference (or offset) in seconds between the
+times of the local and remote system beyond which the offset is
+reported. This is reported at the point in the \fIlatexmk\fR's
+progress that it measures the offset. The report is made if silent
+mode is used and diagnostic mode is not on.
+
+.TP
+.B $force_mode [0]
+If nonzero, continue processing past minor \fIlatex\fR errors
+including unrecognized cross references. Equivalent to specifying the
+\fB-f\fR option.
+.TP
+.B @generated_exts [( "aux", "bbl", "idx", "ind", "lof", "lot", "out", "toc", $fdb_ext )]
+This contains a list of extensions for files that are generated during
+a LaTeX run and that are read in by LaTeX in later runs, either
+directly or indirectly.
+
+This list specifies files known to be generated by latex (and
+pdflatex, etc). It is used in two ways:
+(a) The specified files are deleted in a cleanup operation (with the
+\fB-c\fR, \fB-C\fR, \fB-CA\fR, \fB-g\fR and \fB-gg\fR options), and
+(b) It affects the determination of whether a rerun of (pdf)LaTeX is
+needed after a run that gives an error.
+
+(Concerning item (b): Normally, a change of a source file during a run
+should provoke a rerun. This includes a file generated by LaTeX,
+e.g., an aux file, that is read in on subsequent runs. But after a
+run that results in an error, a new run should not occur until the
+user has made a change in the files. But the user may have corrected
+an error in a source .tex file during the run. So \fIlatexmk\fR needs
+to distinguish user-generated and automatically generated files; it
+determines the automatically generated files as those with extensions
+in the list in @generated_exts.)
+
+A convenient way to add an extra extension to the list, without losing
+the already defined ones is to use a push command in the line in an
+RC file. E.g.,
+
+ push @generated_exts, "end";
+
+adds the extension "end" to the list of predefined generated
+extensions. (This extension is used by the RevTeX package, for
+example.)
+.TP
+.B $go_mode [0]
+If nonzero, process files regardless of timestamps, and is then
+equivalent to the \fB-g\fR option.
+.TP
+.B %hash_calc_ignore_pattern
+\fB!!!This variable is for experts only!!!\fR
+
+The general rule \fIlatexmk\fR uses for determining when an extra run
+of some program is needed is that one of the source files has changed.
+But consider for example a latex package that causes an encapsulated
+postscript file (an "eps" file) to be made that is to be read in on
+the next run. The file contains a comment line giving its creation
+date and time. On the next run the time changes, \fIlatex\fR sees
+that the eps file has changed, and therefore reruns latex. This
+causes an infinite loop, that is only terminated because \fIlatexmk\fR
+has a limit
+on the number of runs to guard against pathological situations.
+
+But the changing line has no real effect, since it is a comment. You
+can instruct \fIlatex\fR to ignore the offending line as follows:
+
+ $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: ';
+
+This creates a rule for files with extension \fI.eps\fR about lines to
+ignore. The left-hand side is a \fIPerl\fR idiom for setting an item
+in a hash. Note that the file extension is specified without a
+period. The value, on the right-hand side, is a string containing a
+regular expresssion. (See documentation on \fIPerl\fR for how they
+are to be specified in general.) This particular regular expression
+specifies that lines beginning with "%%CreationDate: " are to be
+ignored in deciding whether a file of the given extension \fI.eps\fR
+has changed.
+
+There is only one regular expression available for each extension. If
+you need more one pattern to specify lines to ignore, then you need to
+combine the patterns into a single regular expression. The simplest
+method is separate the different simple patterns by a vertical bar
+character (indicating "alternation" in the jargon of regular
+expressions). For example,
+
+ $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: |^%%Title: ';
+
+causes lines starting with either "^%%CreationDate: " or "^%%Title: "
+to be ignored.
+
+It may happen that a pattern to be ignored is specified in, for
+example, in a system or user initialization file, and you wish to
+remove this in a file that is read later. To do this, you use Perl's
+delete function, e.g.,
+
+ delete $hash_calc_ignore_pattern{'eps'};
+
+.TP
+.B $jobname [""]
+
+This specifies the jobname, i.e., the basename that is used for
+generated files (.aux, .log, .dvi, .ps, .pdf, etc). If this variable
+is a null string, then the basename is the basename of the main tex
+file.
+(At present, the string in \fI$jobname\fR should not contain spaces.)
+
+The placeholder '%A' is permitted. This will be substituted by the
+basename of the TeX file. The primary purpose is when a variety of
+tex files are to be processed, and you want to use a different jobname
+for each but one that is distinct for each. Thus if you wanted to
+compare compilations of a set of files on different operating systems,
+with distinct filenames for all the cases, you could set
+
+ $jobname = "%A-$^O";
+
+in an initialization file. (Here \fI$^O\fR is a variable provided by
+perl that contains perl's name for the operating system.)
+
+Suppose you had .tex files test1.tex and test2.tex. Then when you run
+
+ latexmk -pdf *.tex
+
+both files will be compiled. The .aux, .log, and .pdf files will have
+basenames test1-MSWin32 ante test2-MSWin32 on a MS-Windows system,
+test1-darwin and test2-darwin on an OS-X system, and a variety of
+similar cases on linux systems.
+
+.TP
+.B $kpsewhich ["kpsewhich %S"]
+The program called to locate a source file when the name alone is not
+sufficient. Most filenames used by \fIlatexmk\fR have sufficient path
+information to be found directly. But sometimes, notably when a .bib
+or a .bst file is found from the log file of a \fIbibtex\fR or
+\fIbiber\fR run, only the base name of the file is known, but not its
+path. The program specified by \fI$kpsewhich\fR is used to find it.
+
+(\fIFor advanced users:\fR Because of the different way in which
+\fIlatexmk\fR uses the command specified in \fI$kpsewhich\fR, some of
+the possibilities listed in the FORMAT OF COMMAND SPECIFICATIONS do
+not apply. The \fIinternal\fR and \fIstart\fR keywords are not
+available. A simple command specification with possible options and
+then "%S" is all that is guaranteed to work. Note that for other
+commands, "%S" is substituted by a single source file. In contrast,
+for \fI$kpsewhich\fR, "%S" may be substituted by a long list of
+space-separated filenames, each of which is quoted. The result on
+STDOUT of running the command is then piped to \fIlatexmk\fR.)
+
+See also the \fI@BIBINPUTS\fR variable for another way that \fIlatexmk\fR
+also uses to try to locate files; it applies only in the case of .bib
+files.
+.TP
+.B $kpsewhich_show [0]
+Whether to show diagnostics about invocations of \fIkpsewhich\fR: the
+command line use to invoke it and the results. These diagnostics are
+shown if \fI$kpsewhich_show\fR is non-zero or if diagnostics mode is
+on. (But in the second case, lots of other diagnostics are also
+shown.) Without these diagnostics there is nothing visible in
+\fIlatexmk\fR's screen output about invocations of \fIkpsewhich\fR.
+.TP
+.B $landscape_mode [0]
+If nonzero, run in landscape mode, using the landscape mode previewers and
+dvi to postscript converters. Equivalent to the \fB-l\fR option.
+Normally not needed with current previewers.
+.TP
+.B $latex ["latex %O %S"]
+Specifies the command line for
+the LaTeX processing program. Note that as with other programs, you
+can use this variable not just to change the name of the program used,
+but also specify options to the program. E.g.,
+
+ $latex = "latex --src-specials %O %S";
+
+To do a coordinated setting of all of \fI$latex\fR, \fI$pdflatex\fR,
+\fI$lualatex\fR, and \fI$xelatex\fR, see the section "Advanced
+Configuration".
+
+.TP
+.B %latex_input_extensions
+This variable specifies the extensions tried by \fIlatexmk\fR when it finds
+that a LaTeX run resulted in an error that a file has not been found,
+and the file is given without an extension. This typically happens when
+LaTeX commands of the form \\input{file} or \\includegraphics{figure},
+when the relevant source file does not exist.
+
+In this situation, \fIlatexmk\fR searches for custom dependencies to make
+the missing file(s), but restricts it to the extensions specified by
+the variable %latex_input_extensions. The default extensions
+are 'tex' and 'eps'.
+
+(For Perl experts: %latex_input_extensions is a hash whose keys are
+the extensions. The values are irrelevant.) Two subroutines are
+provided for manipulating this and the related variable
+%pdflatex_input_extensions, add_input_ext and remove_input_ext. They
+are used as in the following examples are possible lines in an
+initialization file:
+
+ remove_input_ext( 'latex', 'tex' );
+
+removes the extension 'tex' from latex_input_extensions
+
+ add_input_ext( 'latex', 'asdf' );
+
+add the extension 'asdf to latex_input_extensions. (Naturally with
+such an extension, you should have made an appropriate custom
+dependency for \fIlatexmk\fR, and should also have done the appropriate
+programming in the LaTeX source file to enable the file to be read.
+The standard extensions are handled by LaTeX and its graphics/graphicx
+packages.)
+.TP
+.B $latex_silent_switch ["-interaction=batchmode"]
+Switch(es) for the LaTeX processing program when silent mode is on.
+
+If you use MikTeX, you may prefer the results if you configure the
+options to include -c-style-errors, e.g., by the following line in an
+initialization file
+
+ $latex_silent_switch = "-interaction=batchmode -c-style-errors";
+
+.TP
+.B $lpr ["lpr %O %S" under UNIX/Linux, \(dqNONE lpr\(dq under MS-Windows]
+The command to print postscript files.
+
+Under MS-Windows (unlike UNIX/Linux), there is no standard program for
+printing files. But there are ways you can do it. For example, if
+you have \fIgsview\fR installed, you could use it with the option "/p":
+
+ $lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p';
+
+If \fIgsview\fR is installed in a different directory, you will need to make
+the appropriate change. Note the combination of single and double
+quotes around the name. The single quotes specify that this is a
+string to be assigned to the configuration variable \fI$lpr\fR. The double
+quotes are part of the string passed to the operating system to get
+the command obeyed; this is necessary because one part of the command
+name ("Program Files") contains a space which would otherwise be
+misinterpreted.
+.TP
+.B $lpr_dvi ["NONE lpr_dvi"]
+The printing program to print dvi files.
+.TP
+.B $lpr_pdf ["NONE lpr_pdf"]
+The printing program to print pdf files.
+
+Under MS-Windows you could set this to use \fIgsview\fR, if it is installed,
+e.g.,
+
+ $lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p';
+
+If \fIgsview\fR is installed in a different directory, you will need to make
+the appropriate change. Note the double quotes around the name: this
+is necessary because one part of the command name ("Program Files")
+contains a space which would otherwise be misinterpreted.
+.TP
+.B $lualatex ["lualatex %O %S"]
+Specifies the command line for
+the LaTeX processing program that is to be used when the \fIlualatex\fR
+program is called for (e.g., by the option \fB-lualatex\fR.
+
+To do a coordinated setting of all of \fI$latex\fR, \fI$pdflatex\fR,
+\fI$lualatex\fR, and \fI$xelatex\fR, see the section "Advanced
+Configuration".
+
+.TP
+.B %lualatex_input_extensions
+This variable specifies the extensions tried by \fIlatexmk\fR when it finds
+that a \fIlualatex\fR run resulted in an error that a file has not been found,
+and the file is given without an extension. This typically happens when
+LaTeX commands of the form \\input{file} or \\includegraphics{figure},
+when the relevant source file does not exist.
+
+In this situation, \fIlatexmk\fR searches for custom dependencies to make
+the missing file(s), but restricts it to the extensions specified by
+the variable %pdflatex_input_extensions. The default extensions
+are 'tex', 'pdf', 'jpg, and 'png'.
+
+See details of the \fI%latex_input_extensions\fR for other information
+that equally applies to \fI%lualatex_input_extensions\fR.
+.TP
+.B $lualatex_silent_switch ["-interaction=batchmode"]
+Switch(es) for the \fIlualatex\fR program (specified in the variable
+\fI$lualatex\fR) when silent mode is on.
+
+See details of the \fI$latex_silent_switch\fR for other information
+that equally applies to \fI$lualatex_silent_switch\fR.
+.TP
+.B $make ["make"]
+The make processing program.
+.TP
+.B $makeindex ["makeindex %O -o %D %S"]
+The index processing program.
+.TP
+.B $makeindex_silent_switch ["-q"]
+\fBSwitch(es)\fR for the index processing program when silent mode is on.
+.TP
+.B $max_repeat [5]
+The maximum number of times \fIlatexmk\fR will run latex/pdflatex
+before deciding that there may be an infinite loop and that it needs
+to bail out, rather than rerunning latex/pdflatex again to resolve
+cross-references, etc. The default value covers all normal cases.
+
+(Note that the "etc" covers a lot of cases where one run of
+latex/pdflatex generates files to be read in on a later run.)
+.TP
+.B $MSWin_back_slash [1]
+This configuration variable only has an effect when \fIlatexmk\fR is
+running under MS-Windows. It determines whether, when a command is
+executed under MS-Windows, there should be substituted "\\" for the
+separator character between components of a directory name.
+Internally, \fIlatexmk\fR uses "/" for the directory separator
+character, which is the character used by Unix-like systems.
+
+For many programs under MS-Windows, both "\\" and "/" are acceptable
+as the directory separator character. But some programs only accept
+"\\" on the command line. So for safety \fIlatexmk\fR makes a
+translation, by default.
+It is conceivable that under certain situations this is undesirable,
+so the configuration can be changed. (A possible example might be
+when some of the software is implemented using Cygwin, which provides
+a Unix-like environment inside MS-Windows.)
+.TP
+.B $new_viewer_always [0]
+This variable applies to \fIlatexmk\fR \fBonly\fR in
+continuous-preview mode. If \fI$new_viewer_always\fR is 0,
+\fIlatexmk\fR will check for a previously running previewer on the
+same file, and if one is running will not start a new one. If
+\fI$new_viewer_always\fR is non-zero, this check will be skipped, and
+\fIlatexmk\fR will behave as if no viewer is running.
+.TP
+.B $out_dir [""]
+If non-blank, this variable specifies the directory in which output
+files are to be written by a run of
+(pdf)latex. See also the variable \fI$aux_dir\fR.
+
+The effect of this variable (when non-blank) is achieved by using the
+\fB-output-directory\fR option of (pdf)latex. This exists in the
+usual current (Dec. 2011 and later) implementations of TeX, i.e., MiKTeX and
+TeXLive. But it may not be present in other versions.
+
+If you also use the \fB-cd\fR option, and \fI$out_dir\fR (or \fI$aux_dir\fR) contains a
+relative path, then the path is interpreted relative to the document
+directory.
+
+Commonly, the directory specified for output files is a subdirectory
+of the current working directory. However, if you specify some other
+directory, e.g., "/tmp/foo" or "../output", be aware that this could
+cause problems, e.g., with \fImakeindex\fR or \fIbibtex\fR. This is
+because modern versions of these programs, by default, will refuse to
+work when they find that they are asked to write to a file in a
+directory that appears not to be the current working directory or one
+of its subdirectories. This is part of security measures by the whole
+TeX system that try to prevent malicious or errant TeX documents from
+incorrectly messing with a user's files. If for \fI$out_dir\fR or
+\fI$aux_dir\fR you really do need to specify an absolute pathname
+(e.g., "/tmp/foo") or a path (e.g., "../output") that includes a
+higher-level directory, and you need to use \fImakeindex\fR or
+\fIbibtex\fR, then you need to disable the security measures
+(and assume any risks). One way of doing this is to temporarily set an
+operating system environment variable openout_any to "a" (as in
+"all"), to override the default "paranoid" setting.
+.TP
+.B $pdf_mode [0]
+If zero, do NOT generate a pdf version of the document.
+If equal to 1, generate a pdf version of the document using \fIpdflatex\fR,
+using the command specified by the \fI$pdflatex\fR variable.
+If equal to 2, generate a pdf version of the document from the ps
+file, by using the command specified by the \fI$ps2pdf\fR variable.
+If equal to 3, generate a pdf version of the document from the dvi
+file, by using the command specified by the \fI$dvipdf\fR variable.
+If equal to 4, generate a pdf version of the document using \fIlualatex\fR,
+using the command specified by the \fI$lualatex\fR variable.
+If equal to 5, generate a pdf version (and an xdv version) of the
+document using \fIxelatex\fR, using the commands specified by the
+\fI$xelatex\fR and \fIxdvipdfmx\fR variables.
+
+In \fI$pdf_mode\fR=2, it is ensured that .dvi and .ps files are also made.
+In \fI$pdf_mode\fR=3, it is ensured that a .dvi file is also made.
+But this may be overridden by the document.
+.TP
+.B $pdflatex ["pdflatex %O %S"]
+Specifies the command line for
+the LaTeX processing program in a version that makes a pdf file instead
+of a dvi file.
+
+An example use of this variable is to add certain options to the
+command line for the program, e.g.,
+
+ $pdflatex = "pdflatex --shell-escape %O %S";
+
+(In some earlier versions of \fIlatexmk\fR, you needed to use an assignment
+to \fI$pdflatex\fR to allow the use of \fIlualatex\fR or \fIxelatex\fR
+instead of \fIpdflatex\fR. There are now separate configuration
+variables for the use of \fIlualatex\fR or \fIxelatex\fR. See
+\fI$lualatex\fR and \fI$xelatex\fR.)
+
+To do a coordinated setting of all of \fI$latex\fR, \fI$pdflatex\fR,
+\fI$lualatex\fR, and \fI$xelatex\fR, see the section "Advanced
+Configuration".
+.TP
+.B %pdflatex_input_extensions
+This variable specifies the extensions tried by \fIlatexmk\fR when it finds
+that a \fIpdflatex\fR run resulted in an error that a file has not been found,
+and the file is given without an extension. This typically happens when
+LaTeX commands of the form \\input{file} or \\includegraphics{figure},
+when the relevant source file does not exist.
+
+In this situation, \fIlatexmk\fR searches for custom dependencies to make
+the missing file(s), but restricts it to the extensions specified by
+the variable %pdflatex_input_extensions. The default extensions
+are 'tex', 'pdf', 'jpg, and 'png'.
+
+See details of the \fI%latex_input_extensions\fR for other information
+that equally applies to \fI%pdflatex_input_extensions\fR.
+.TP
+.B $pdflatex_silent_switch ["-interaction=batchmode"]
+Switch(es) for the \fIpdflatex\fR program (specified in the variable
+\fI$pdflatex\fR) when silent mode is on.
+
+See details of the \fI$latex_silent_switch\fR for other information
+that equally applies to \fI$pdflatex_silent_switch\fR.
+.TP
+.B $pdf_previewer ["start acroread %O %S"]
+The command to invoke a pdf-previewer.
+
+On MS-Windows, the default is changed to "cmd /c start """; under more recent versions of
+Windows, this will cause to be run whatever command the system has
+associated with .pdf files. But this may be undesirable if this
+association is to \fIacroread\fR -- see the notes in the explanation
+of the \fB-pvc\fR option.]
+
+On OS-X the default is changed to "open %S", which results in OS-X
+starting up (and detaching) the viewer associated with the file. By
+default, for pdf files this association is to OS-X's preview, which is
+quite satisfactory.
+
+\fBWARNING\fR: Problem under MS-Windows:
+if acroread is used as the pdf previewer, and it is
+actually viewing a pdf file, the pdf file cannot be updated. Thus
+makes acroread a bad choice of previewer if you use \fIlatexmk\fR's
+previous-continuous mode (option \fB-pvc\fR) under MS-windows.
+This problem does not occur if, for example, \fISumatraPDF\fR or \fIgsview\fR is
+used to view pdf files.
+
+\fBImportant note\fR: Normally you will want to have a previewer run
+detached, so that \fIlatexmk\fR doesn't wait for the previewer to
+terminate before continuing its work. So normally you should prefix
+the command by "start ", which flags to \fIlatexmk\fR that it should
+do the detaching of the previewer itself (by whatever method is
+appropriate to the operating system). But sometimes letting
+\fIlatexmk\fR do the detaching is not appropriate (for a variety of
+non-trivial reasons), so you should put the "start " bit in
+yourself, whenever it is needed.
+.TP
+.B $pdf_update_command [""]
+When the pdf previewer is set to be updated by running a command, this
+is the command that is run. See the information for the variable
+\fI$pdf_update_method\fR.
+.TP
+.B $pdf_update_method [1 under UNIX, 3 under MS-Windows]
+How the pdf viewer updates its display when the pdf file has
+changed. See the information on the variable \fI$dvi_update_method\fR
+for the codes. (Note that information needs be changed slightly so
+that for the value 4, to run a command to do the update, the command
+is specified by the variable \fI$pdf_update_command\fR, and for the
+value 2, to specify update by signal, the signal is specified by
+\fI$pdf_update_signal\fR.)
+
+Note that acroread under MS-Windows (but not UNIX) locks the pdf file, so
+the default value is then 3.
+
+Arranging to use a command to get a previewer explicitly updated
+requires three variables to be set. For example:
+
+ $pdf_previewer = "start xpdf -remote %R %O %S";
+ $pdf_update_method = 4;
+ $pdf_update_command = "xpdf -remote %R -reload";
+
+The first setting arranges for the xpdf program to be used in its
+"remote server mode", with the server name specified as the rootname
+of the TeX file. The second setting arranges for updating to be done
+in response to a command, and the third setting sets the update command.
+.TP
+.B $pdf_update_signal [Under UNIX: SIGHUP, which is a system-dependent value]
+The number of the signal that is sent to the pdf viewer when it is
+updated by sending a signal -- see the information on the variable
+\fI$pdf_update_method\fR. The default value is the one appropriate
+for \fIgv\fR on a UNIX system.
+.TP
+.B $pid_position[1 under UNIX, -1 under MS-Windows]
+The variable \fI$pid_position\fR is used to
+specify which word in lines of the output from \fI$pscmd\fR
+corresponds to the process ID. The first word in the line is numbered
+0. The default value of 1 (2nd word in line) is correct for Solaris
+2.6, Linux, and OS-X with their default settings of \fI$pscmd\fR.
+
+Setting the variable to -1 is used to indicate that
+\fI$pscmd\fR is not to be used.
+.TP
+.B $postscript_mode [0]
+If nonzero, generate a postscript version of the document.
+Equivalent to the \fB-ps\fR option.
+
+If some other request is made for which a postscript file is needed,
+then $postscript_mode will be set to 1.
+.TP
+.B $pre_tex_code ['']
+
+Sets TeX code to be executed before inputting the source file. This
+works if the relevant one of \fI$latex\fR, etc contains a suitable
+command line with a %P or %U substitution. For example you could do
+
+ $latex = 'latex %O %P';
+ $pre_tex_code = '\\AtBeginDocument{An initial message\\par}';
+
+To set all of \fI$latex\fR, \fI$pdflatex\fR, \fI$lualatex\fR, and
+\fI$xelatex\fR you could use the subroutine \fIalt_tex_cmds\fR:
+
+ &alt_tex_cmds;
+ $pre_tex_code = '\\AtBeginDocument{An initial message\\par}';
+
+
+.TP
+.B $preview_continuous_mode [0]
+If nonzero, run a previewer to view the document, and
+continue running \fIlatexmk\fR to keep .dvi up-to-date. Equivalent to
+the \fB-pvc\fR option.
+Which previewer is run depends on the other settings, see the command
+line options \fB-view=\fR, and the variable \fI$view\fR.
+.TP
+.B $preview_mode [0]
+If nonzero, run a previewer to preview the document.
+Equivalent to the \fB-pv\fR option.
+Which previewer is run depends on the other settings, see the command
+line options \fB-view=\fR, and the variable \fI$view\fR.
+.TP
+.B $printout_mode [0]
+If nonzero, print the document using the command specified in the
+\fI$lpr\fR variable. Equivalent to the
+\fB-p\fR option. This is recommended \fBnot\fR to be set from an RC
+file, otherwise you could waste lots of paper.
+.TP
+.B $print_type = ["auto"]
+Type of file to printout: possibilities are "auto", "dvi", "none",
+"pdf", or "ps". See the option \fB-print=\fR for the meaning of the
+"auto" value.
+.TP
+.B $pscmd
+Command used to get all the processes currently run by the user. The
+-pvc option uses the command specified by the variable \fI$pscmd\fR to
+determine if there is an already running previewer, and to find the
+process ID (needed if \fIlatexmk\fR needs to signal the previewer
+about file changes).
+
+Each line of the output of this command is assumed to correspond to
+one process. See the \fI$pid_position\fR variable for how the process
+number is determined.
+
+The default for \fIpscmd\fR is "NONE" under MS-Windows and cygwin
+(i.e., the command is not used), "ps -ww -u $ENV{USER}" under
+OS-X, and
+"ps -f -u $ENV{USER}" under other operating systems (including Linux).
+In these specifications "$ENV{USER}" is substituted by the username.
+.TP
+.B $ps2pdf ["ps2pdf %O %S %D"]
+Command to convert .ps to .pdf file.
+.TP
+.B $ps_filter [empty]
+The postscript file filter to be run on the newly produced postscript
+file before other processing. Equivalent to specifying the \fB-pF\fR
+option.
+.TP
+.B $ps_previewer ["start gv %O %S", but "start %O %S" under MS-Windows]
+The command to invoke a ps-previewer. (The default under MS-Windows
+will cause to be run whatever command the system has associated
+with .ps files.)
+
+Note that \fIgv\fR could be used with the -watch option updates its display
+whenever the postscript file changes, whereas ghostview does not.
+However, different versions of \fIgv\fR have slightly different ways of
+writing this option. You can configure this variable appropriately.
+
+\fBWARNING\fR: Linux systems may have installed one (or more) versions
+of \fIgv\fR under different names, e.g., \fIggv\fR, \fIkghostview\fR,
+etc, but perhaps not one actually called \fIgv\fR.
+
+\fBImportant note\fR: Normally you will want to have a previewer run
+detached, so that \fIlatexmk\fR doesn't wait for the previewer to
+terminate before continuing its work. So normally you should prefix
+the command by "start ", which flags to \fIlatexmk\fR that it should
+do the detaching of the previewer itself (by whatever method is
+appropriate to the operating system). But sometimes letting
+\fIlatexmk\fR do the detaching is not appropriate (for a variety of
+non-trivial reasons), so you should put the "start " bit in
+yourself, whenever it is needed.
+
+.TP
+.B $ps_previewer_landscape ["start gv -swap %O %S", but "start %O %S" under MS-Windows]
+The command to invoke a ps-previewer in landscape mode.
+.TP
+.B $ps_update_command [""]
+When the postscript previewer is set to be updated by running a command, this
+is the command that is run. See the information for the variable
+\fI$ps_update_method\fR.
+.TP
+.B $ps_update_method [0 under UNIX, 1 under MS-Windows]
+How the postscript viewer updates its display when the .ps file has
+changed. See the information on the variable \fI$dvi_update_method\fR
+for the codes. (Note that information needs be changed slightly so
+that for the value 4, to run a command to do the update, the command
+is specified by the variable \fI$ps_update_command\fR, and for the
+value 2, to specify update by signal, the signal is specified by
+\fI$ps_update_signal\fR.)
+.TP
+.B $ps_update_signal [Under UNIX: SIGHUP, which is a system-dependent value]
+The number of the signal that is sent to the pdf viewer when it is
+updated by sending a signal -- see \fI$ps_update_method\fR. The
+default value is the one appropriate for gv on a UNIX system.
+.TP
+.B $pvc_timeout [0]
+If this variable is nonzero, there will be a timeout in pvc mode
+after a period of inactivity. Inactivity means a period when
+\fIlatexmk\fR has detected no file changes and hence has not taken any
+actions like compiling the document. The period of inactivity is in
+the variable $pvc_timeout_mins.
+
+.TP
+.B $pvc_timeout_mins [30]
+The period of inactivity, in minutes, after which pvc mode times out.
+This is used if \fI$pvc_timeout\fR is nonzero.
+.TP
+.B $pvc_view_file_via_temporary [1]
+The same as \fI$always_view_file_via_temporary\fR, except that it only
+applies in preview-continuous mode (-pvc option).
+.TP
+.B $quote_filenames [1]
+This specifies whether substitutions for placeholders in command
+specifications (as in \fI$pdflatex\fR) are surrounded by double
+quotes. If this variable is 1 (or any other value Perl regards as
+true), then quoting is done. Otherwise quoting is omitted.
+
+The quoting method used by \fIlatexmk\fR is tested to work correctly under
+UNIX systems (including Linux and Mac OS-X) and under MS-Windows. It
+allows the use of filenames containing special characters, notably
+spaces. (But note that many versions of \fIlatex\fR and \fIpdflatex\fR cannot
+correctly deal with TeX files whose names contain spaces. \fILatexmk\fR's
+quoting only ensures that such filenames are correctly treated by the
+operating system in passing arguments to programs.)
+.TP
+.B $recorder [1]
+Whether to use the \fB-recorder\fR option to \fIlatex\fR and
+\fIpdflatex\fR. Use of this option results in a file of extension
+\fI.fls\fR containing a list of the files that these programs have
+read and written. \fILatexmk\fR will then use this file to improve
+its detection of source files and generated files after a run of
+\fIlatex\fR or \fIpdflatex\fR.
+
+It is generally recommended to use this option (or to configure the
+\fI$recorder\fR variable to be on.) But it only works if
+\fI(pdf)latex\fR supports the -recorder option, which is true for most
+current implementations
+
+\fINote about the name of the .fls file:\fR Most implementations of
+\fI(pdf)latex\fR produce an .fls file with the same basename as the
+main document's LaTeX, e.g., for Document.tex, the .fls file is
+Document.fls. However, some implementations instead produce files
+named for the program, i.e., latex.fls or pdflatex.fls. In this
+second case, \fIlatexmk\fR copies the latex.fls or pdflatex.fls to a
+file with the basename of the main LaTeX document, e.g., Document.fls.
+.TP
+.B $search_path_separator [See below for default]
+The character separating paths in the environment variables TEXINPUTS,
+BIBINPUTS, and BSTINPUTS. This variable is mainly used by
+\fIlatexmk\fR when the \fB-outdir\fR, \fB-output-directory\fR,
+\fB-auxdir\fR, and/or \fB-aux-directory\fR options are used. In that
+case \fIlatexmk\fR needs to communicate appropriately modified search
+paths to \fIbibtex\fR, \fIdvipdf\fR, \fIdvips\fR, and
+\fI(pdf)latex\fR.
+
+[Comment to technically savvy readers: \fI(pdf)latex\fR doesn't
+actually need the modified search path. But, surprisingly,
+\fIdvipdf\fR and \fIdvips\fR do,
+because sometimes graphics files get generated in the output or aux
+directories.]
+
+The default under MSWin and Cygwin is ';' and under UNIX-like
+operating systems (including Linux and OS-X) is ':'. Normally the
+defaults give correct behavior. But there can be difficulties if your
+operating system is of one kind, but some of your software is running
+under an emulator for the other kind of operating system; in that case
+you'll need to find out what is needed, and set
+\fI$search_path_separator\fR explicitly. (The same goes, of course,
+for unusual operating systems that are not in the MSWin, Linux, OS-X,
+Unix collection.)
+.TP
+.B $show_time [0]
+Whether to show CPU time used.
+.TP
+.B $silence_logfile_warnings [0]
+Whether after a run of (pdf)latex to summarize warnings in the log
+file about undefined citations and references. Setting
+$silence_logfile_warnings=0 gives the summary of warnings (provided
+silent mode isn't also set), and this is useful to locate undefined
+citations and references without searching through the much more
+verbose log file or the screen output of (pdf)latex. But the summary
+can also be excessively annoying. The default is not to give these
+warnings. The command line options
+\fB-silence_logfile_warning_list\fR and
+\fB-silence_logfile_warning_list-\fR also set this variable.
+
+Note that multiple occurrences for the same undefined object on the
+same page and same line will be compressed to a single warning.
+.TP
+.B $silent [0]
+Whether to run silently. Setting $silent to 1 has the same effect as
+the \fB-quiet\fR of \fB-silent\fR options on the command line.
+.TP
+.B $sleep_time [2]
+The time to sleep (in seconds) between checking for source file
+changes when running with the \fB-pvc\fR option. This is subject to a
+minimum of one second delay, except that zero delay is also allowed.
+
+A value of exactly 0 gives no delay, and typically results in 100% CPU
+usage, which may not be desirable.
+.TP
+.B $texfile_search [""]
+This is an obsolete variable, replaced by the \fI@default_files\fR
+variable.
+
+For backward compatibility, if you choose to set
+\fI$texfile_search\fR, it is a string of space-separated filenames, and
+then \fIlatexmk\fR replaces \fI@default_files\fR with the filenames in
+\fI$texfile_search\fR to which is added "*.tex".
+.TP
+.B $success_cmd [undefined]
+See the documentation for $compiling_cmd.
+.TP
+.B $tmpdir [See below for default]
+Directory to store temporary files that \fIlatexmk\fR may generate while
+running.
+
+The default under MSWindows (including cygwin), is to set
+\fI$tmpdir\fR to the value of the first of whichever of the system
+environment variables TMPDIR or TEMP exists, otherwise to the current
+directory. Under other operating systems (expected to be UNIX/Linux,
+including OS-X), the default is the value of the system environment
+variable TMPDIR if it exists, otherwise "/tmp".
+.TP
+.B $use_make_for_missing_files [0]
+Whether to use \fImake\fR to try and make files that are missing after
+a run of \fIlatex\fR or \fIpdflatex\fR, and for which a custom
+dependency has not been found. This is generally useful only when
+\fIlatexmk\fR is used as part of a bigger project which is built by
+using the \fImake\fR program.
+
+Note that once a missing file has been made, no further calls to
+\fImake\fR will be made on a subsequent run of \fIlatexmk\fR to update
+the file. Handling this problem is the job of a suitably defined
+Makefile. See the section "USING \fIlatexmk\fR WITH \fImake\fR" for
+how to do this. The intent of calling \fImake\fR from \fIlatexmk\fR
+is merely to detect dependencies.
+.TP
+.B $view ["default"]
+Which kind of file is to be previewed if a previewer is used. The
+possible values are "default", "dvi", "ps", "pdf". The value
+of "default" means that the "highest" of the kinds of file generated is
+to be used (among .dvi, .ps and .pdf).
+
+.TP
+.B $warnings_as_errors [0]
+Normally \fIlatexmk\fR copies the behavior of \fIlatex\fR in treating
+undefined references and citations and multiply defined references as
+conditions that give a warning but not an error. The variable
+\fI$warnings_as_errors\fR controls whether this behavior is modified.
+
+When the variable is non-zero, \fIlatexmk\fR at the end of its run
+will return a non-zero status code to the operating system if any of
+the files processed gives a warning about problems with citations or
+references (i.e., undefined citations or references or multiply
+defined references). This is \fBafter\fR \fIlatexmk\fR has completed
+all the runs it needs to try and resolve references and citations.
+Thus \fI$warnings_as_errors\fR being nonzero causes \fIlatexmk\fR to
+treat such warnings as errors, but only when they occur on the last
+run of (pdf)latex and only after processing is complete. A non-zero
+value \fI$warnings_as_errors\fR can be set by the command-line option
+\fB-Werror\fR.
+
+The default behavior is normally satisfactory in the usual
+edit-compile-edit cycle. But, for example, \fIlatexmk\fR can also be
+used as part of a build process for some bigger project, e.g., for
+creating documentation in the build of a software application. Then
+it is often sensible to treat citation and reference warnings as
+errors that require the overall build process to be aborted. Of
+course, since multiple runs of (pdf)latex are generally needed to
+resolve references and citations, what matters is \fInot\fR the
+warnings on the first run, but the warnings on the \fIlast\fR run;
+\fIlatexmk\fR takes this into account appropriately.
+
+In addition, when preview-continuous mode is used, a non-zero value
+for \fI$warnings_as_errors\fR changes the use of the commands
+\fI$failure_cmd\fR, \fI$warning_cmd\fR, and \fI$success_cmd\fR after a
+compliation. If there are citation or reference warnings, but no
+other errors, the behavior is as follows. If \fI$warning_cmd\fR is
+set, it is used. If it is not set, then then if
+\fI$warnings_as_errors\fR is non-zero and \fI$failure_cmd\fR is set,
+then \fI$failure_cmd\fR. Otherwise \fI$success_cmd\fR is used, if it
+is set. (The foregoing explanation is rather complicated, because
+\fIlatexmk\fR has to deal with the case that one or more of the
+commands isn't set.)
+
+.TP
+.B $xdvipdfmx ["xdvipdfmx -o %D %O %S"]
+
+The program to make a pdf file from an xdv file (used in conjunction
+with \fIxelatex\fR when \fI$pdf_mode\fR=5).
+.TP
+.B $xdvipdfmx_silent_switch ["-q"]
+Switch(es) for the \fIxdvipdfmx\fR program when silent mode is on.
+.TP
+.B $xelatex ["xelatex %O %S"]
+Specifies the command line for
+the LaTeX processing program of
+when the \fIxelatex\fR program is called for. See the
+documentation of the \fB-xelatex\fR option for some special properties
+of \fIlatexmk\fR's use of \fIxelatex\fR.
+
+\fINote about xelatex\fR: Now \fIlatexmk\fR uses \fIxelatex\fR to make
+an .xdv rather than .pdf file, with the .pdf file being created in a
+separate step. This is enforced by the use of the \fB-no-pdf\fR
+option. If %O is part of the command for invoking \fIxelatex\fR, then
+\fIlatexmk\fR will insert the \fB-no-pdf\fR option automatically,
+otherwise you must provide the option yourself
+
+To do a coordinated setting of all of \fI$latex\fR, \fI$pdflatex\fR,
+\fI$lualatex\fR, and \fI$xelatex\fR, see the section "Advanced
+Configuration".
+
+.TP
+.B %xelatex_input_extensions
+This variable specifies the extensions tried by \fIlatexmk\fR when it finds
+that an \fIxelatex\fR run resulted in an error that a file has not been found,
+and the file is given without an extension. This typically happens when
+LaTeX commands of the form \\input{file} or \\includegraphics{figure},
+when the relevant source file does not exist.
+
+In this situation, \fIlatexmk\fR searches for custom dependencies to make
+the missing file(s), but restricts it to the extensions specified by
+the variable %xelatex_input_extensions. The default extensions
+are 'tex', 'pdf', 'jpg, and 'png'.
+
+See details of the \fI%latex_input_extensions\fR for other information
+that equally applies to \fI%xelatex_input_extensions\fR.
+.TP
+.B $xelatex_silent_switch ["-interaction=batchmode"]
+Switch(es) for the \fIxelatex\fR program (specified in the variable
+\fI$xelatex\fR) when silent mode is on.
+
+See details of the \fI$latex_silent_switch\fR for other information
+that equally applies to \fI$xelatex_silent_switch\fR.
+
+
+
+.SH CUSTOM DEPENDENCIES
+.PP
+In any RC file a set of custom dependencies can be set up to convert a
+file with one extension to a file with another. An example use of this
+would be to allow \fIlatexmk\fR to convert a \fI.fig\fR file to
+\fI.eps\fR to be included in the \fI.tex\fR file.
+
+.SS Defining a custom dependency:
+The old method of configuring \fIlatexmk\fR to use a custom dependency
+was to directly manipulate the \fI@cus_dep_list\fR array that contains
+information defining the custom dependencies. (See the section "Old Method of
+Defining Custom Dependencies" for details.) This method still
+works, but is no longer preferred.
+
+A better method is to use the subroutines that allow convenient
+manipulations of the custom dependency list. These are
+
+ add_cus_dep( fromextension, toextension, must, subroutine )
+ remove_cus_dep( fromextension, toextension )
+ show_cus_dep()
+
+The arguments are as follows:
+.TP
+.B from extension:
+The extension of the file we are converting from (e.g. "fig").
+It is specified without a period.
+.TP
+.B to extension:
+The extension of the file we are converting to (e.g. "eps").
+It is specified without a period.
+.TP
+.B must:
+If non-zero, the file from which we are converting \fBmust\fR exist, if it
+doesn't exist \fIlatexmk\fR will give an error message and exit unless
+the \fB-f\fR option is specified. If \fImust\fR is zero and the file
+we are converting from doesn't exist, then no action is taken.
+Generally, the appropriate value of \fImust\fR is zero.
+.TP
+.B function:
+The name of the subroutine that \fIlatexmk\fR should call to perform the
+file conversion. The first argument to the subroutine is the base name
+of the file to be converted without any extension. The subroutines are
+declared in the syntax of \fIPerl\fR. The function should return 0 if
+it was successful and a nonzero number if it failed.
+
+.PP
+
+Naturally \fIadd_cus_dep\fR adds a custom dependency with the
+specified from and to extensions. If a custom dependency has been
+previously defined (e.g., in an rcfile that was read earlier), then it
+is replaced by the new one.
+
+The subroutine \fIremove_cus_dep\fR removes the specified custom
+dependency. The subroutine \fIshow_cus_dep\fR causes a list of the
+currently defined custom dependencies to be sent to the screen
+output.
+
+.SS How custom dependencies are used:
+An instance of a custom dependency rule is created whenever
+\fIlatexmk\fR detects that a run of latex/pdflatex needs to read a
+file, like a graphics file, whose extension is the to-extension of a
+custom dependency. Then \fIlatexmk\fR examines whether a file exists
+with the same name, but with the corresponding from-extension, as
+specified in the custom-dependency. If it does, then a corresponding
+instance of the custom dependency is created, after which the rule is
+invoked whenever the destination file (the one with the to-extension)
+is out-of-date with respect to the corresponding source file.
+
+To make the new destination file, the \fIPerl\fR subroutine specified in the
+rule is invoked, with an argument that is the base name of the files
+in question. Simple cases just involve a subroutine invoking an
+external program; this can be done by following the templates below,
+even by those without knowledge of the \fIPerl\fR programming language. Of
+course, experts could do something much more elaborate.
+
+One item in the specification of each custom-dependency rule, labeled
+"must" above, specifies how the rule should be applied when the source
+file fails to exist.
+
+When \fIlatex\fR reports that an input file (e.g., a graphics file)
+does not exist, \fIlatexmk\fR tries to find a source file and a custom
+dependency that can be used to make it. If it succeeds, then it
+creates an instance of the custom dependency and invokes it to make
+the missing file, after which the next pass of \fIlatex\fR etc will be
+able to read the newly created file.
+
+\fINote for advanced usage\fR: The operating system's environment
+variable TEXINPUTS can be used to specify a search path for finding
+files by \fIlatex\fR etc. Correspondingly, when a missing file is
+reported, \fIlatexmk\fR looks in the directories specified in
+TEXINPUTS as well as in the current directory, to find a source file
+from which an instance of a custom dependency can be used to make the
+missing file.
+
+.SS Function to implement custom dependency, traditional method:
+The function that implements a custom dependency gets the information
+on the files to be processed in two ways. The first is through its
+one argument; the argument contains the base name of the source and
+destination files. The second way is described later.
+
+A simple and typical example of code in an initialization rcfile using
+the first method is:
+
+ add_cus_dep( 'fig', 'eps', 0, 'fig2eps' );
+ sub fig2eps {
+ system( "fig2dev -Leps \\"$_[0].fig\\" \\"$_[0].eps\\"" );
+ }
+
+The first line adds a custom dependency that converts a file with
+extension "fig", as created by the \fIxfig\fR program, to an encapsulated
+postscript file, with extension "eps". The remaining lines define a
+subroutine that carries out the conversion. If a rule for converting
+"fig" to "eps" files already exists (e.g., from a previously read-in
+initialization file), the \fIlatexmk\fR will delete this rule before
+making the new one.
+
+Suppose \fIlatexmk\fR is using this rule to convert a file
+"figure.fig" to "figure.eps". Then it will invoke the fig2eps
+subroutine defined in the above code with a single argument "figure",
+which is the basename of each of the files (possibly with a path
+component). This argument is referred to by \fIPerl\fR as $_[0]. In
+the example above, the subroutine uses the \fIPerl\fR command system
+to invoke the program fig2dev. The double quotes around the string
+are a \fIPerl\fR idiom that signify that each string of the form of a
+variable name, $_[0] in this case, is to be substituted by its value.
+
+If the return value of the subroutine is non-zero, then \fIlatexmk\fR
+will assume an error occurred during the execution of the subroutine.
+In the above example, no explicit return value is given, and instead
+the return value is the value returned by the last (and only)
+statement, i.e., the invocation of system, which returns the value 0
+on success.
+
+If you use \fIpdflatex\fR instead of latex, then you will probably prefer to
+convert your graphics files to pdf format, in which case you would
+replace the above code in an initialization file by
+
+ add_cus_dep( 'fig', 'pdf, 0, 'fig2pdf' );
+ sub fig2pdf {
+ system( "fig2dev -Lpdf \\"$_[0].fig\\" \\"$_[0].pdf\\"" );
+ }
+
+\fBNote 1:\fR In the command lines given in the system commands in the
+above examples, double quotes have been inserted around the file names
+(implemented by '\\"' \" " COMMENT TO FOOL EDITOR INTO MATCHING DOUBLE QUOTES
+in the Perl language). They immunize the running
+of the program against special characters in filenames. Very often
+these quotes are not necessary, i.e., they can be omitted. But it is
+normally safer to keep them in. Even though the rules for quoting
+vary between operating systems, command shells and individual pieces
+of software, the quotes in the above examples do not cause problems in
+the cases I have tested.
+
+\fBNote 2:\fR One case in which the quotes are important is when the
+files are in a subdirectory and your operating system is Microsoft
+Windows. Then the separator character for directory components can be
+either a forward slash '/' or Microsoft's more usual backward slash
+\'\\'. Forward slashes are generated by \fIlatexmk\fR, to maintain its
+sanity from software like MiKTeX that mixes both directory
+separators; but their correct use normally requires quoted filenames.
+(See a log file from a run of MiKTeX (at least in v. 2.9) for an
+example of the use of both directory separators.)
+
+\fBNote 3:\fR The subroutines implementing custom dependencies in the
+examples given just have a single line invoking an external program.
+That's the usual situation. But since the subroutines are in the Perl
+language, you can implement much more complicated processing if you
+need it.
+
+.SS Removing custom dependencies, and when you might need to do this:
+If you have some general custom dependencies defined in the system or
+user initialization file, you may find that for a particular project
+they are undesirable. So you might want to delete the unneeded ones.
+A situation where this would be desirable is where there are multiple
+custom dependencies with the same from-extension or the same
+to-extension. In that case, \fIlatexmk\fR might choose a different one
+from the one you want for a specific project. As an example, to
+remove any "fig" to "eps" rule you would use:
+
+ remove_cus_dep( 'fig', 'eps' );
+
+If you have complicated sets of custom dependencies, you may want to
+get a listing of the custom dependencies. This is done by using the
+line
+
+ show_cus_dep();
+
+in an initialization file.
+
+.SS Function implementing custom dependency, alternative methods:
+So far the examples for functions to implement custom dependencies
+have used the argument of the function to specify the base name of
+converted file. This method has been available since very old
+versions of \fIlatexmk\fR, and many examples can be found, e.g., on
+the web.
+
+However in later versions of \fIlatexmk\fR the internal structure of
+the implementation of its "rules" for the steps of processing,
+including custom dependencies, became much more powerful. The
+function implementing a custom dependency is executed within a special
+context where a number of extra variables and subroutines are
+defined. Publicly documented ones, intended to be long-term stable,
+are listed below, under the heading "Variables and subroutines for
+processing a rule".
+
+Examples of their use is given in the following examples, concerning
+multiple index files and glossaries.
+
+The only index-file conversion built-in to \fIlatexmk\fR is from an
+".idx" file written on one run of latex/pdflatex to an ".ind" file to
+be read in on a subsequent run. But with the index.sty package, for
+example, you can create extra indexes with extensions that you
+configure. \fILatexmk\fR does not know how to deduce the extensions
+from the information it has. But you can easily write a custom
+dependency. For example if your latex file uses the command
+"\\newindex{special}{ndx}{nnd}{Special index}" you will need to get
+\fIlatexmk\fR to convert files with the extension \fI.ndx\fR to
+\fI.nnd\fR. The most elementary method is to define a custom
+dependency as follows:
+
+ add_cus_dep( 'ndx', 'nnd', 0, 'ndx2nnd' );
+ sub ndx2nnd {
+ return system( "makeindex -o \\"$_[0].nnd\\" \\"$_[0].ndx\\"" );
+ }
+ push @generated_exts, 'ndx', 'nnd';
+
+Notice the added line compared with earlier examples. The extra line
+gets the extensions "ndx" and "nnd" added to the list of extensions
+for generated files; then the extra index files will be deleted by
+clean-up operations
+
+But if you have yet more indexes with yet different extensions, e.g.,
+"adx" and "and", then you will need a separate function for each pair
+of extensions. This is quite annoying. You can use the
+\fIRun_subst\fR function to simplify the definitions to use a single
+function:
+
+ add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
+ add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
+ sub dx2nd {
+ return Run_subst( "makeindex -o %D %S" );
+ }
+ push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
+
+You could also instead use
+
+ add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
+ add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
+ sub dx2nd {
+ return Run_subst( $makeindex );
+ }
+ push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
+
+This last example uses the command specification in \fI$makeindex\fR,
+and so any customization you have made for the standard index also
+applies to your extra indexes.
+
+Similar techniques can be applied for glossaries.
+
+Those of you with experience with Makefiles, may get
+concerned that the \fI.ndx\fR file is written during a run of
+latex/pdflatex and is always later than the \fI.nnd\fR last read in.
+Thus the \fI.nnd\fR appears to be perpetually out-of-date. This
+situation, of circular dependencies, is endemic to latex, and is one
+of the issues that \fIlatexmk\fR is programmed to overcome. It
+examines the contents of the files (by use of a checksum), and only
+does a remake when the file contents have actually changed.
+
+Of course if you choose to write random data to the \fI.nnd\fR (or the
+\fI.aux\fR file, etc) that changes on each new run, then you will have
+a problem. For real experts: See the \fI%hash_cal_ignore_pattern\fR
+if you have to deal with such problems.
+
+.SS Old Method of Defining Custom Dependencies:
+In much older versions of \fIlatexmk\fR, the only method of defining
+custom dependencies was to directly manipulate the table of custom
+dependencies. This is contained in the \fI@cus_dep_list\fR array. It
+is an array of strings, and each string in the array has four items in
+it, each separated by a space, the from-extension, the to-extension,
+the "must" item, and the name of the subroutine for the custom
+dependency. These were all defined above.
+.PP
+An example of the old method of defining custom dependencies is as
+follows. It is the code in an RC file to ensure automatic conversion
+of \fI.fig\fR files to \fI.eps\fR files:
+
+ push @cus_dep_list, "fig eps 0 fig2eps";
+ sub fig2eps {
+ return system( "fig2dev -Lps \\"$_[0].fig\\" \\"$_[0].eps\\"" );
+ }
+
+This method still works, and is almost equivalent to the code given
+earlier that used the \fIadd_cus_dep\fR subroutine. However, the old
+method doesn't delete any previous custom-dependency for the same
+conversion. So the new method is preferable.
+
+
+.SH ADVANCED CONFIGURATION: Some extra resources and advanced tricks
+
+For most purposes, simple configuration for \fIlatexmk\fR along the
+lines of the examples given is sufficient. But sometimes you need
+something harder. In this section, I indicate some extra
+possibilities. Generally to use these, you need to be fluent in the
+Perl language, since this is what is used in the rc files.
+
+See also the section DEALING WITH ERRORS, PROBLEMS, ETC. See
+also the examples in the directory \fIexample_rcfiles\fR in the
+\fIlatexmk\fR distributions. Even if none of the examples apply to
+your case, they may give you useful ideas
+
+.SS Utility subroutines
+
+.TP
+.B ensure_path( var, values ...)
+
+The first parameter is the name of one of the system's environment
+variables for search paths. The remaining parameters are values that
+should be in the variable. For each of the value parameters, if it
+isn't already in the variable, then it is prepended to the variable;
+in that case the environment variable is created if it doesn't already
+exist. For separating values, the character appropriate the the
+operating system is used -- see the configuration variable
+\fI$search_path_separator\fR.
+
+Example:
+
+ ensure_path( 'TEXINPUTS', './custom_cls_sty_files//' );
+
+(In this example, the trailing '//' is documented by TeX systems to
+mean that latex, pdflatex, etc search for files in the specified
+directory and in all subdirectories.)
+
+Technically \fIensure_path\fR works by setting Perl's variable
+\fI$ENV{var}\fR, where \fIvar\fR is the name of the target variable.
+The changed value is then passed as an environment variable to any
+invoked programs.
+
+.SS Variables and subroutines for processing a rule
+
+A step in the processing is called a rule. One possibility to
+implement the processing of a rule is by a Perl subroutine. This is
+always the case for custom dependencies. Also, for any other rule, you
+can use a subroutine by prefixing the command specification by the
+word "internal" -- see the section FORMAT OF COMMAND SPECIFICATIONS.
+
+When you use a subroutine for processing a rule, all the possibilities
+of Perl programming are available, of course. In addition, some of
+\fIlatexmk\fR's internal variables and subroutines are available.
+The ones listed below are intended to be available to (advanced)
+users, and their specifications will generally have stability under
+upgrades. Generally, the variables should be treated as read-only:
+Changing their values can have bad consequences, since it is liable to
+mess up the consistency of what \fIlatexmk\fR is doing.
+.TP
+.B $rule
+This variable has the name of the rule, as known to
+\fIlatexmk\fR. Note that the exact contents of this variable for a
+given rule may be dependent on the version of \fIlatexmk\fR
+.TP
+.B $$Psource
+This gives the name of the primary source file. Note the double
+dollar signs.
+.TP
+.B $$Pdest
+This gives the name of the main output file if any. Note the double
+dollar signs.
+.TP
+.B rdb_ensure_file( $rule, file )
+This a subroutine that ensures that the given file is among the source
+files for the specified rule. It is typically used when, during the
+processing of a rule, it is known that a particular extra file is
+among the dependencies that \fIlatexmk\fR should know, but its default
+methods don't find the dependency. Almost always the first argument is
+the name of the rule currently being processed, so it is then
+appropriate to specify it by \fI$rule\fR.
+
+For examples of its use, see some of the files in the directory
+\fIexample_rcfiles\fR of \fIlatexmk\fR's distribution. Currently the
+cases that use this subroutine are \fIbib2gls-latexmkrc\fR,
+\fIexceltex_latexmkrc\fR and \fItexinfo-latexmkrc\fR. These
+illustrate typical cases where \fIlatexmk\fR's normal processing fails
+to detect certain extra source files.
+.TP
+.B rdb_remove_files( $rule, file, ... )
+This subroutine removes one or more files from the dependency list for
+the given rule.
+.TP
+.B rdb_list_source( $rule )
+This subroutine returns the list of source files (i.e., the dependency
+list) for the given rule.
+.TP
+.B rdb_set_source( $rule, file, ... )
+.TP
+.B rdb_set_source( $rule, @files )
+This subroutine sets the dependency list for the given rule to be the
+specified files. Files that are already in the list have unchanged
+information. Files that were not in the list are added to it. Files
+in the previous dependency list that are not in the newly specified
+list of files are removed from the dependency list.
+.TP
+.B Run_subst( command_spec )
+This subroutine runs the command specified by \fIcommand_spec\fR. The
+specification is a string in the format listed in the section "Format
+of Command Specifications". An important action of the
+\fIRun_subst\fR is to make substitutions of placeholders, e.g., %S and
+%D for source and destination files; these get substituted before the
+command is run. In addition, the command after substitution is
+printed to the screen unless \fIlatexmk\fR is running in silent mode.
+
+.PP
+
+
+.SS Coordinated Setting of Commands for *latex
+
+To set all of \fI$latex\fR, \fI$pdflatex\fR, \fI$lualatex\fR, and
+\fI$xelatex\fR to a common pattern, you can use one of the following
+subroutines, std_tex_cmds, alt_tex_cmds, and set_tex_cmds.
+
+They work as follows
+
+ &std_tex_cmds;
+
+This results in \fI$latex = 'latex %O %S'\fR, and similarly for
+\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR. Note the
+ampersand in the invocation; this indicates to Perl that a subroutine
+is being called.
+
+ &alt_tex_cmds;
+
+This results in \fI$latex = 'latex %O %P'\fR, and similarly for
+\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR. Note the
+ampersand in the invocation; this indicates to Perl that a subroutine
+is being called.
+
+ set_tex_cmds( CMD_SPEC );
+
+Here CMD_SPEC is the command line without the program name. This
+results in \fI$latex = 'CMD_SPEC'\fR, and similarly for
+\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR. An example would
+be
+
+ set_tex_cmds( '--interaction=batchmode %O %S' );
+
+.PP
+
+.SS Advanced configuration: Using \fIlatexmk\fB with \fImake\fR
+
+This section is targeted only at advanced users who use the \fImake\fR
+program for complex projects, as for software development, with the
+dependencies specified by a Makefile.
+
+Now the basic task of \fIlatexmk\fR is to run the appropriate programs
+to make a viewable version of a LaTeX document. However, the usual
+\fImake\fR program is not suited to this purpose for at least two
+reasons. First is that the use of LaTeX involves circular
+dependencies (e.g., via .aux files), and these cannot be handled by
+the standard \fImake\fR program. Second is that in a large document
+the set of source files can change quite frequently, particularly with
+included graphics files; in this situation keeping a Makefile manually
+updated is inappropriate and error-prone, especially when the
+dependencies can be determined automatically. \fILatexmk\fR solves
+both of these problems robustly.
+
+Thus for many standard LaTeX documents \fIlatexmk\fR can be used by
+itself without the \fImake\fR program. In a complex project it simply
+needs to be suitably configured. A standard configuration would be to
+define custom dependencies to make graphics files from their source
+files (e.g., as created by the \fIxfig\fR program). Custom
+dependencies are \fIlatexmk\fR's equivalent of pattern rules in
+Makefiles.
+
+Nevertheless there are projects for which a Makefile is appropriate,
+and it is useful to know how to use \fIlatexmk\fR from a Makefile. A
+typical example would be to generate documentation for a software
+project. Potentially the interaction with the rest of the rules in
+the Makefile could be quite complicated, for example if some of the
+source files for a LaTeX document are generated by the project's
+software.
+
+In this section, I give a couple of examples of how \fIlatexmk\fR can
+be usefully invoked from a Makefile. The examples use specific
+features of current versions of GNU \fImake\fR, which is the default
+on both linux and OS-X systems. They may need modifications for other
+versions of \fImake\fR.
+
+The simplest method is simply to delegate all the relevant tasks to
+\fIlatexmk\fR, as is suitable for a straightforward LaTeX document.
+For this a suitable Makefile is like
+
+ .PHONY : FORCE_MAKE
+ all : try.pdf
+ %.pdf : %.tex FORCE_MAKE
+ latexmk -pdf -dvi- -ps- $<
+
+(Note: the last line must be introduced by a tab for the Makefile to
+function correctly!) Naturally, if making try.pdf from its associated
+LaTeX file try.tex were the only task to be performed, a direct use of
+\fIlatexmk\fR without a Makefile would normally be better. The
+benefit of using a Makefile for a LaTeX document would be in a larger
+project, where lines such as the above would be only be a small part
+of a larger Makefile.
+
+The above example has a pattern rule for making a .pdf file from
+a .tex file, and it is defined to use \fIlatexmk\fR in the obvious way.
+There is a conventional default target named "all", with a
+prerequisite of try.pdf. So when \fImake\fR is invoked, by default it
+makes try.pdf. The only complication is that there may be many source
+files beyond try.tex, but these aren't specified in the Makefile, so
+changes in them will not by themselves cause \fIlatexmk\fR to be
+invoked. Instead, the pattern rule is equipped with a "phony"
+prerequisite FORCE_MAKE; this has the effect of causing the rule to be
+always out-of-date, so that \fIlatexmk\fR is always run. It is
+\fIlatexmk\fR that decides whether any action is needed, e.g., a rerun
+of \fIpdflatex\fR. Effectively the Makefile delegates all decisions
+to \fIlatexmk\fR, while \fImake\fR has no knowledge of the list of
+source files except for primary LaTeX file for the document. If
+there are, for example, graphics files to be made, these must be
+made by custom dependencies configured in \fIlatexmk\fR.
+
+But something better is needed in more complicated situations, for
+example, when the making of graphics files needs to be specified by
+rules in the Makefile. To do this, one can use a Makefile like the
+following:
+
+ TARGETS = document1.pdf document2.pdf
+ DEPS_DIR = .deps
+ LATEXMK = latexmk -recorder -use-make -deps \\
+ -e 'warn qq(In Makefile, turn off custom dependencies\\n);' \\
+ -e '@cus_dep_list = ();' \\
+ -e 'show_cus_dep();'
+ all : $(TARGETS)
+ $(foreach file,$(TARGETS),$(eval -include $(DEPS_DIR)/$(file)P))
+ $(DEPS_DIR) :
+ mkdir $@
+ %.pdf : %.tex
+ if [ ! -e $(DEPS_DIR) ]; then mkdir $(DEPS_DIR); fi
+ $(LATEXMK) -pdf -dvi- -ps- -deps-out=$(DEPS_DIR)/$@P $<
+ %.pdf : %.fig
+ fig2dev -Lpdf $< $@
+
+(Again, the lines containing the commands for the rules should be
+started with tabs.) This example was inspired by how GNU
+\fIautomake\fR handles automatic dependency tracking of C source
+files.
+
+After each run of \fIlatexmk\fR, dependency information is put in a file
+in the .deps subdirectory. The Makefile causes these dependency files
+to be read by \fImake\fR, which now has the full dependency
+information for each target .pdf file. To make things less trivial it
+is specificed that two files document1.pdf and document2.pdf are the
+targets. The dependency files are .deps/document1.pdfP
+and .deps/document2.pdfP.
+
+There is now no need for the phony prerequisite for the rule to
+make .pdf files from .tex files. But I have added a rule to
+make .pdf files from .fig files produced by the \fIxfig\fR program;
+these are commonly used for graphics insertions in LaTeX documents.
+\fILatexmk\fR is arranged to output a dependency file after each run.
+It is given the \fB-recorder\fR option, which improves its detection
+of files generated during a run of \fIpdflatex\fR; such files should
+not be in the dependency list. The \fB-e\fR options are used to turn
+off all custom dependencies, and to document this. Instead the
+\fB-use-make\fR is used to delegate the making of missing files to
+\fImake\fR itself.
+
+Suppose in the LaTeX file there is a command \\includegraphics{graph},
+and an \fIxfig\fR file "graph.fig" exists. On a first run,
+\fIpdflatex\fR reports a missing file, named "graph". \fILatexmk\fR
+succeeds in making "graph.pdf" by calling "make graph.pdf", and after
+completion of its work, it lists "fig.pdf" among the dependents of the
+file \fIlatexmk\fR is making. Then let "fig.fig" be updated, and then
+let \fImake\fR be run. \fIMake\fR first remakes "fig.pdf", and only
+then reruns \fIlatexmk\fR.
+
+Thus we now have a method by which all the subsidiary processing is
+delegated to \fImake\fR.
+
+.SH SEE ALSO
+latex(1), bibtex(1), lualatex(1), pdflatex(1), xelatex(1).
+.SH BUGS
+Sometimes a viewer (gv) tries to read an updated .ps or .pdf file
+after its creation is started but before the file is complete. Work
+around: manually refresh (or reopen) display. Or use one of the other
+previewers and update methods.
+
+(The following isn't really a bug, but concerns features of previewers.)
+Preview continuous mode only works perfectly with certain previewers:
+Xdvi on UNIX/Linux works for dvi files.
+Gv on UNIX/Linux works for both postscript and pdf.
+Ghostview on UNIX/Linux needs a manual update (reopen); it views
+postscript and pdf.
+Gsview under MS-Windows works for both postscript and pdf,
+but only reads the updated file when its screen is refreshed.
+Acroread under UNIX/Linux views pdf, but the file needs to be closed
+and reopened to view an updated version.
+Under MS-Windows, acroread locks its input file and so the
+pdf file cannot be updated. (Remedy: configure \fIlatexmk\fR to use
+\fIsumatrapdf\fR instead.)
+.SH THANKS TO
+Authors of previous versions. Many users with their feedback, and
+especially
+David Coppit (username david at node coppit.org) who made many useful
+suggestions that contributed to version 3, and Herbert Schulz.
+(Please note that the
+e-mail addresses are not written in their standard form to avoid being
+harvested too easily.)
+.SH AUTHOR
+Current version, by John Collins (username jcc8 at node psu.edu).
+(Version 4.65).
+
+Released version can be obtained from CTAN:
+<http://www.ctan.org/pkg/latexmk/>, and from the
+author's website <http://www.personal.psu.edu/jcc8/latexmk/>.
+.br
+Modifications and enhancements by Evan McLean (Version 2.0)
+.br
+Original script called "go" by David J. Musliner (RCS Version 3.2)
+
+\" LocalWords: fR fIlatexmk dvi ps fILatexmk pdflatex bibtex makeindex fB pv
+\" LocalWords: pvc fIgv xdvi gsview cygwin fdb TP tex bm bs fIlatex fIbibtex
+\" LocalWords: gg regeneratable dep exts dF dviF dviselect fI fR's lpr pdfps
+\" LocalWords: pdfdvi dvipdf pF psF psnup fIsome gv acroread xpdf rcfile cus
+\" LocalWords: batchmode latexmkrc elatex basename texfile WinXP BIBINPUTS
+\" LocalWords: kpsewhich BibTeX dtx dvipdfm dvips fpTeX MikTeX fBWARNING pid
+\" LocalWords: pscmd fIlpr fBnot ENV OSX SIGHUP tmpdir MSWindows tmp eps dev
+\" LocalWords: fImust fIperl Lps fIfig
diff --git a/support/latexmk/latexmk.bat b/support/latexmk/latexmk.bat
new file mode 100644
index 0000000000..f119082ada
--- /dev/null
+++ b/support/latexmk/latexmk.bat
@@ -0,0 +1,5 @@
+Rem Execute latexmk.pl, searching for it in the PATH
+Rem Assume perl is in the PATH. If not, you should replace 'perl' by
+Rem the full pathname of the perl executable, e.g., 'C:\perl\bin\perl.exe'
+
+perl -S latexmk.pl %1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/support/latexmk/latexmk.pdf b/support/latexmk/latexmk.pdf
new file mode 100644
index 0000000000..92acf17b3b
--- /dev/null
+++ b/support/latexmk/latexmk.pdf
Binary files differ
diff --git a/support/latexmk/latexmk.pl b/support/latexmk/latexmk.pl
new file mode 100755
index 0000000000..7dd5dc35e3
--- /dev/null
+++ b/support/latexmk/latexmk.pl
@@ -0,0 +1,9968 @@
+#!/usr/bin/env perl
+
+#!!!!!!!!!!!!!!!!!!!????????? CLEAN UP INITIALIZATION
+#!!! See all FIX items.
+
+# Perhaps add subroutine rdb_change_active( (rules to deactivate), (rules to activate))
+
+# ?? Still need to fix bcf error issue.
+# Don't keep looping after error
+# pvc: Only re-run on USER FILE CHANGE.
+# See # ??????? BCF
+
+
+#!!!!!!!!??? Check @pwd_log
+
+
+# !!!!!!!!!! Don't forget to document $silence_logfile_warnings.!!!
+
+# N.B. !!!!!!!!!!! See 17 July 2012 comments !!!!!!!!!!!!!!!!!!
+
+# On a UNIX-like system, the above enables latexmk to run independently
+# of the location of the perl executable. This line relies on the
+# existence of the program /usr/bin/env
+# If there is a problem for any reason, you can replace the first line of
+# this file by:
+
+#!/usr/bin/perl -w
+
+# with the path of the perl executable adjusted for your system.
+
+use warnings;
+
+# Delete #??!! when working
+
+# See ?? <===============================
+
+## ?? Issues with clean-up
+## List of aux files deleted is those read, not those generated.
+## Other files are generated by (pdf)latex; should they be deleted?
+## (I have hooks for this).
+
+
+
+#=======================================
+
+#?? Force mode doesn't appear to do force (if error in latex file)
+#??? Get banner back in.
+#?? CORRECT DIAGNOSTICS ON CHANGED FILES IF THEY DIDN'T EXIST BEFORE
+#?? Further corrections to deal with disappeared source files for custom dependencies.
+# Message repeatedly appears about remake when source file of cusdep doesn't exist.
+#?? logfile w/o fdb file: don't set changed file, perhaps for generated exts.
+# Reconsider
+#?? Do proper run-stuff for bibtex, makeindex, cus-deps. OK I think
+# Parse and correctly find ist files
+
+
+# ATTEMPT TO ALLOW FILENAMES WITH SPACES:
+# (as of 1 Apr 2006, and then 14 Sep. 2007)
+
+# Problems:
+# A. Quoting filenames will not always work.
+# a. Under UNIX, quotes are legal in filenames, so when PERL
+# directly runs a binary, a quoted filename will be treated as
+# as a filename containing a quote character. But when it calls
+# a shell, the quotes are handled by the shell as quotes.
+# b. Under MSWin32, quotes are illegal filename characters, and tend
+# to be handled correctly.
+# c. But under cygwin, results are not so clear (there are many
+# combinations: native v. cygwin perl, native v cygwin programs
+# NT v. unix scripts, which shell is called.
+# B. TeX doesn't always handle filenames with spaces gracefully.
+# a. UNIX/LINUX: The version on gluon2 Mar 31, 2006 to Sep. 2007)
+# doesn't handle them at all. (TeX treats space as separator.)
+# b. At least some later versions actually do (Brad Miller e-mail,
+# Sep. 2007).
+# c. fptex [[e-TeXk, Version 3.141592-2.1 (Web2c 7.5.2)] does, on
+# my MSWin at home. In \input the filename must be in quotes.
+# d. Bibtex [BibTeX (Web2c 7.5.2) 0.99c on my MSWin system at home,
+# Sep. 2007] does not allow names of bibfiles to have spaces.
+# C. =====> Using the shell for command lines is not safe, since special
+# characters can cause lots of mayhem.
+# It will therefore be a good idea to sanitize filenames.
+#
+# I've sanitized all calls out:
+# a. system and exec use a single argument, which forces
+# use of shell, under all circumstances
+# Thus I can safely use quotes on filenames: They will be handled by
+# the shell under UNIX, and simply passed on to the program under MSWin32.
+# b. I reorganized Run, Run_Detached to use single command line
+# c. All calls to Run and Run_Detached have quoted filenames.
+# d. So if a space-free filename with wildcards is given on latexmk's
+# command line, and it globs to space-containing filename(s), that
+# works (fptex on home computer, native NT tex)
+# e. ====> But globbing fails: the glob function takes space as filename
+# separator. ====================
+
+#================= TO DO ================
+#
+# 1. See ?? ESPECIALLY $MSWin_fudge_break
+# 2. Check fudged conditions in looping and make_files
+# 3. Should not completely abort after a run that ends in failure from latex
+# Missing input files (including via custom dependency) should be checked for
+# a change in status
+# If sources for missing files from custom dependency
+# are available, then do a rerun
+# If sources of any kind become available rerun (esp. for pvc)
+# rerun
+# Must parse log_file after unsuccessful run of latex: it may give
+# information about missing files.
+# 4. Check file of bug reports and requests
+# 5. Rationalize bibtex warnings and errors. Two almost identical routines.
+# Should 1. Use single routine
+# 2. Convert errors to failure only in calling routine
+# 3. Save first warning/error.
+
+# ?? Use of generated_exts arrays and hashes needs rationalization
+
+# To do:
+# Rationalize again handling of include files.
+# Now I use kpsewhich to do searches, if file not found
+# (How do I avoid getting slowed down too much?)
+# Document the assumptions at each stage of processing algorithm.
+# Option to restart previewer automatically, if it dies under -pvc
+# Test for already running previewer gets wrong answer if another
+# process has the viewed file in its command line
+
+## Copyright John Collins 1998-2019
+## (username jcc8 at node psu.edu)
+## (and thanks to David Coppit (username david at node coppit.org)
+## for suggestions)
+## Copyright Evan McLean
+## (modifications up to version 2)
+## Copyright 1992 by David J. Musliner and The University of Michigan.
+## (original version)
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+##
+##
+##
+## NEW FEATURES, since v. 2.0:
+## 1. Correct algorithm for deciding how many times to run latex:
+## based on whether source file(s) change between runs
+## 2. Continuous preview works, and can be of ps file or dvi file
+## 3. pdf creation by pdflatex possible
+## 4. Defaults for commands are OS dependent.
+## 5. Parsing of log file instead of source file is used to
+## obtain dependencies, by default.
+##
+## Modification log from 9 Dec 2011 onwards in detail
+##
+## 12 Jan 2012 STILL NEED TO DOCUMENT some items below
+##
+## 28 Jun 2019 John Collins Try to deal with log file parsing problems
+## V. 4.65
+## 21 May 2019 John Collins Fix incorrect listings by -rules and by -deps
+## 21 May 2019 John Collins V. 4.64a.
+## 20,21 May 2019 John Collins Fix problem with not always running dvipdf,
+## dvips, xdvpdf because of missing information
+## on source files. Do this by adding a
+## source_rule hash to each rule and adding a
+## pass-based criterion for out-of-dateness
+## 20 May 2019 John Collins V. 4.64.
+## 17 Mar 2019 John Collins V. 4.63c.
+## 18 Mar 2019 John Collins Update copyright date
+## 17 Mar 2019 John Collins Further test for problems when linking rules
+## 17 Mar 2019 John Collins V. 4.63b.
+## 17 Mar 2019 John Collins Fix problem revealed by bibtopic package
+## 15 Mar 2019 John Collins Corrections
+## 14 Mar 2019 John Collins Version to 4.63a
+## 12-14 Mar 2019 John Collins Jobname has placeholder
+## 8-11 Mar 2019 John Collins Correct aux-dir bugs
+## 8 Mar 2019 John Collins Version to 4.63
+## 1 Jan 2019 John Collins Correct bug in output switching code
+## 31 Dec 2018 John Collins Correct bug that with $cleanup_includes_generated
+## -c mode deletes final output files (e.g., .dvi, .pdf).
+## 13 Dec 2018 John Collins Fixes, cleanup
+## 12 Dec 2018 John Collins Fix rdb_read
+## 11 Dec 2018 John Collins For output-switch: Reorganize initialization
+## Remove possibility of more than one primary.
+## 1 Dec 2018 John Collins Clean up some code.
+## 30 Nov 2018 John Collins Allow any characters in directory part of tex
+## filename when cd mode on. (Still standard
+## set of disallowed characters applies basename.)
+## 21 Nov 2018 John Collins Infrastructure finished, I think, for active flag
+## Start on output switch
+## 16 Nov 2018 John Collins Remove in non-diagnostics mode a warning about
+## rule not in use in this session that is given
+## when reading an fdb_latexmk file.
+## 2 Nov 2018 John Collins Start implementing active flag for rules.
+## 1 Nov 2018 John Collins Fix finding of missing files that are relative to aux_dir
+## 29-31 Oct 2018 John Collins Some cleanup.
+## 27,28 Oct 2018 John Collins Fix bug that in -pvc mode, after an error in
+## certain rules, new rounds of compilation
+## are triggered because of changes in generated
+## files, instead of only by later user-generated
+## changes.
+## Improve linking of rules.
+## 25 Oct 2018 John Collins V. 4.62
+## Clean up can remove (empty) directories
+## 25 Oct 2018 John Collins Fix definition of clean up substitution for %R
+## so that something with intermediate %R works,
+## as in 'pythontex-files-%R/*'.
+##
+## 1998-2018, John Collins. Many improvements and fixes.
+## See CHANGE-log.txt for full list, and CHANGES for summary
+##
+## Modified by Evan McLean (no longer available for support)
+## Original script (RCS version 2.3) called "go" written by David J. Musliner
+##
+##-----------------------------------------------------------------------
+
+
+## Explicit exit codes:
+## 10 = bad command line arguments
+## 11 = file specified on command line not found
+## or other file not found
+## 12 = failure in some part of making files
+## 13 = error in initialization file
+## 20 = probable bug
+## or retcode from called program.
+
+$my_name = 'latexmk';
+$My_name = 'Latexmk';
+$version_num = '4.65';
+$version_details = "$My_name, John Collins, 18 June 2019";
+
+use Config;
+use File::Basename;
+use File::Copy;
+use File::Spec;
+
+# If possible, use better glob, which does not use space as item separator.
+# It's either File::Glob::bsd_glob or File::Glob::glob
+# The first does not exist in old versions of Perl, while the second
+# is deprecated in more recent versions and will be removed
+$have_bsd_glob = 0;
+sub my_glob {
+ if ($have_bsd_glob) { return bsd_glob( $_[0] ); }
+ else { return glob( $_[0] ); }
+}
+use File::Glob;
+if ( eval{ File::Glob->import('bsd_glob'); 1; } ) {
+ # Success in importing bsd_glob
+ $have_bsd_glob = 1;
+}
+elsif ( eval{ File::Glob->import('glob'); 1; } ) {
+ warn "$My_name: I could not import File::Glob:bsd_glob, probably because your\n",
+ " Perl is too old. I have arranged to use the deprecated File::Glob:glob\n",
+ " instead.\n",
+ " WARNING: It may malfunction on clean up operation on filenames containing\n",
+ " spaces.\n";
+ $have_bsd_glob = 0;
+}
+else {
+ die "Could not import 'File::Glob:bsd_glob' or 'File::Glob:glob'\n";
+}
+
+use File::Path 2.08 qw( make_path );
+use FileHandle;
+use File::Find;
+use List::Util qw( max );
+use Cwd; # To be able to change cwd
+use Cwd "chdir"; # Ensure $ENV{PWD} tracks cwd
+use Digest::MD5;
+
+#use strict;
+
+# The following variables are assigned once and then used in symbolic
+# references, so we need to avoid warnings 'name used only once':
+use vars qw( $dvi_update_command $ps_update_command $pdf_update_command );
+
+# Translation of signal names to numbers and vv:
+%signo = ();
+@signame = ();
+if ( defined $Config{sig_name} ) {
+ $i = 0;
+ foreach $name (split('\s+', $Config{sig_name})) {
+ $signo{$name} = $i;
+ $signame[$i] = $name;
+ $i++;
+ }
+}
+else {
+ warn "Something wrong with the perl configuration: No signals?\n";
+}
+
+
+# Line length in log file that indicates wrapping.
+# This number EXCLUDES line-end characters, and is one-based.
+# It is the parameter max_print_line in the TeX program. (tex.web)
+$log_wrap = 79;
+
+#########################################################################
+## Default parsing and file-handling settings
+
+## Array of reg-exps for patterns in log-file for file-not-found
+## Each item is the string in a regexp, without the enclosing slashes.
+## First parenthesized part is the filename.
+## Note the need to quote slashes and single right quotes to make them
+## appear in the regexp.
+## Add items by push, e.g.,
+## push @file_not_found, '^No data file found `([^\\\']*)\\\'';
+## will give match to line starting "No data file found `filename'"
+@file_not_found = (
+ '^No file\\s*(.*)\\.$',
+ '^\\! LaTeX Error: File `([^\\\']*)\\\' not found\\.',
+ '.*?:\\d*: LaTeX Error: File `([^\\\']*)\\\' not found\\.',
+ '^LaTeX Warning: File `([^\\\']*)\\\' not found',
+ '^Package .* [fF]ile `([^\\\']*)\\\' not found',
+ '^Package .* No file `([^\\\']*)\\\'',
+ 'Error: pdflatex \(file ([^\)]*)\): cannot find image file',
+ ': File (.*) not found:\s*$',
+ '! Unable to load picture or PDF file \\\'([^\\\']+)\\\'.',
+);
+
+# Characters that we won't allow in the name of a TeX file.
+# Notes: Some are disallowed by TeX itself.
+# '\' results in TeX macro expansion
+# '$' results in possible variable substitution by kpsewhich called from tex.
+# '"' gets special treatment.
+# See subroutine test_fix_texnames and its call for their use.
+$illegal_in_texname = "\x00\t\f\n\r\$%\\~\x7F";
+
+
+## Hash mapping file extension (w/o period, e.g., 'eps') to a single regexp,
+# whose matching by a line in a file with that extension indicates that the
+# line is to be ignored in the calculation of the hash number (md5 checksum)
+# for the file. Typically used for ignoring datestamps in testing whether
+# a file has changed.
+# Add items e.g., by
+# $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: ';
+# This makes the hash calculation for an eps file ignore lines starting with
+# '%%CreationDate: '
+# ?? Note that a file will be considered changed if
+# (a) its size changes
+# or (b) its hash changes
+# So it is useful to ignore lines in the hash calculation only if they
+# are of a fixed size (as with a date/time stamp).
+%hash_calc_ignore_pattern =();
+
+
+# Specification of templates for extra rules.
+# See subroutine rdb_initialize_rules for examples of rule templates, and
+# how they get used to construct rules.
+# (Documentation obviously needs to be improved!)
+%extra_rule_spec = ();
+
+
+# Hooks for customized extra processing on aux files. The following
+# variable is an array of references to function. Each function is
+# invoked in turn when a line of an aux file is processed (if none
+# of the built-in actions have been done). On entry to the function,
+# the following variables are set:
+# $_ = current line of aux file
+# $rule = name of rule during the invocation of which, the aux file
+# was supposed to have been generated.
+@aux_hooks = ();
+
+#########################################################################
+## Default document processing programs, and related settings,
+## These are mostly the same on all systems.
+## Most of these variables represents the external command needed to
+## perform a certain action. Some represent switches.
+
+
+## Which TeX distribution is being used
+## E.g., "MiKTeX 2.9", "TeX Live 2018"
+## "" means not determined. Obtain from first line of .log file.
+$tex_distribution = '';
+
+&std_tex_cmds;
+
+# Possible code to execute by *latex before inputting source file.
+# Not used by default.
+$pre_tex_code = '';
+
+## Default switches:
+$latex_default_switches = '';
+$pdflatex_default_switches = '';
+$lualatex_default_switches = '';
+ # Note that xelatex is used to give xdv file, not pdf file, hence
+ # we need the -no-pdf option.
+$xelatex_default_switches = '-no-pdf';
+
+## Switch(es) to make them silent:
+$latex_silent_switch = '-interaction=batchmode';
+$pdflatex_silent_switch = '-interaction=batchmode';
+$lualatex_silent_switch = '-interaction=batchmode';
+$xelatex_silent_switch = '-interaction=batchmode';
+
+%input_extensions = ();
+# %input_extensions maps primary_rule_name to pointer to hash of file extensions
+# used for extensionless files specified in the source file by constructs
+# like \input{file} \includegraphics{file}
+set_input_ext( 'latex', 'tex', 'eps' );
+set_input_ext( 'pdflatex', 'tex', 'jpg', 'pdf', 'png' );
+$input_extensions{lualatex} = $input_extensions{pdflatex};
+$input_extensions{xelatex} = $input_extensions{pdflatex};
+# Save these values as standards to be used when switching output,
+# i.e., when actual primary rule differs from standard.
+%standard_input_extensions = %input_extensions;
+
+%allowed_output_ext = ( ".dvi" => 1, ".xdv" => 1, ".pdf" => 1 );
+# Extensions of files preserved when clean up is by -c rather than -C:
+%small_cleanup_preserved_exts = ();
+foreach ( 'dvi', 'dviF', 'ps', 'psF', 'pdf', 'synctex.gz', 'xdv' ) {
+ $small_cleanup_preserved_exts{$_} = 1;
+}
+
+
+# Information about options to latex and pdflatex that latexmk will simply
+# pass through to (pdf)latex
+# Option without arg. maps to itself.
+# Option with arg. maps the option part to the full specification
+# e.g., -kpathsea-debug => -kpathsea-debug=NUMBER
+%allowed_latex_options = ();
+%allowed_latex_options_with_arg = ();
+foreach (
+ #####
+ # TeXLive options
+ "-draftmode switch on draft mode (generates no output PDF)",
+ "-enc enable encTeX extensions such as \\mubyte",
+ "-etex enable e-TeX extensions",
+ "-file-line-error enable file:line:error style messages",
+ "-no-file-line-error disable file:line:error style messages",
+ "-fmt=FMTNAME use FMTNAME instead of program name or a %& line",
+ "-halt-on-error stop processing at the first error",
+ "-interaction=STRING set interaction mode (STRING=batchmode/nonstopmode/\n".
+ " scrollmode/errorstopmode)",
+ "-ipc send DVI output to a socket as well as the usual\n".
+ " output file",
+ "-ipc-start as -ipc, and also start the server at the other end",
+ "-kpathsea-debug=NUMBER set path searching debugging flags according to\n".
+ " the bits of NUMBER",
+ "-mktex=FMT enable mktexFMT generation (FMT=tex/tfm/pk)",
+ "-no-mktex=FMT disable mktexFMT generation (FMT=tex/tfm/pk)",
+ "-mltex enable MLTeX extensions such as \charsubdef",
+ "-output-comment=STRING use STRING for DVI file comment instead of date\n".
+ " (no effect for PDF)",
+ "-output-format=FORMAT use FORMAT for job output; FORMAT is `dvi\" or `pdf\"",
+ "-parse-first-line enable parsing of first line of input file",
+ "-no-parse-first-line disable parsing of first line of input file",
+ "-progname=STRING set program (and fmt) name to STRING",
+ "-shell-escape enable \\write18{SHELL COMMAND}",
+ "-no-shell-escape disable \\write18{SHELL COMMAND}",
+ "-shell-restricted enable restricted \\write18",
+ "-src-specials insert source specials into the DVI file",
+ "-src-specials=WHERE insert source specials in certain places of\n".
+ " the DVI file. WHERE is a comma-separated value\n".
+ " list: cr display hbox math par parend vbox",
+ "-synctex=NUMBER generate SyncTeX data for previewers if nonzero",
+ "-translate-file=TCXNAME use the TCX file TCXNAME",
+ "-8bit make all characters printable by default",
+
+ #####
+ # MikTeX options not in TeXLive
+ "-alias=app pretend to be app",
+ "-buf-size=n maximum number of characters simultaneously present\n".
+ " in current lines",
+ "-c-style-errors C-style error messages",
+ "-disable-installer disable automatic installation of missing packages",
+ "-disable-pipes disable input (output) from (to) child processes",
+ "-disable-write18 disable the \\write18{command} construct",
+ "-dont-parse-first-line disable checking whether the first line of the main\n".
+ " input file starts with %&",
+ "-enable-enctex enable encTeX extensions such as \\mubyte",
+ "-enable-installer enable automatic installation of missing packages",
+ "-enable-mltex enable MLTeX extensions such as \charsubdef",
+ "-enable-pipes enable input (output) from (to) child processes",
+ "-enable-write18 fully enable the \\write18{command} construct",
+ "-error-line=n set the width of context lines on terminal error\n".
+ " messages",
+ "-extra-mem-bot=n set the extra size (in memory words) for large data\n".
+ " structures",
+ "-extra-mem-top=n set the extra size (in memory words) for chars,\n".
+ " tokens, et al",
+ "-font-max=n set the maximum internal font number",
+ "-font-mem-size=n set the size, in TeX memory words, of the font memory",
+ "-half-error-line=n set the width of first lines of contexts in terminal\n".
+ " error messages",
+ "-hash-extra=n set the extra space for the hash table of control\n".
+ " sequences",
+ "-job-time=file set the time-stamp of all output files equal to\n".
+ " file's time-stamp",
+ "-main-memory=n change the total size (in memory words) of the main\n".
+ " memory array",
+ "-max-in-open=n set the maximum number of input files and error\n".
+ " insertions that can be going on simultaneously",
+ "-max-print-line=n set the width of longest text lines output",
+ "-max-strings=n set the maximum number of strings",
+ "-nest-size=n set the maximum number of semantic levels\n".
+ " simultaneously active",
+ "-no-c-style-errors standard error messages",
+ "-param-size=n set the the maximum number of simultaneous macro\n".
+ " parameters",
+ "-pool-size=n set the maximum number of characters in strings",
+ "-record-package-usages=file record all package usages and write them into\n".
+ " file",
+ "-restrict-write18 partially enable the \\write18{command} construct",
+ "-save-size=n set the the amount of space for saving values\n".
+ " outside of current group",
+ "-stack-size=n set the maximum number of simultaneous input sources",
+ "-string-vacancies=n set the minimum number of characters that should be\n".
+ " available for the user's control sequences and font\n".
+ " names",
+ "-tcx=name process the TCX table name",
+ "-time-statistics show processing time statistics",
+ "-trace enable trace messages",
+ "-trace=tracestreams enable trace messages. The tracestreams argument is\n".
+ " a comma-separated list of trace stream names",
+ "-trie-size=n set the amount of space for hyphenation patterns",
+ "-undump=name use name as the name of the format to be used,\n".
+ " instead of the name by which the program was\n".
+ " called or a %& line.",
+
+ #####
+ # Options passed to (pdf)latex that have special processing by latexmk,
+ # so they are commented out here.
+ #-jobname=STRING set the job name to STRING
+ #-aux-directory=dir Set the directory dir to which auxiliary files are written
+ #-output-directory=DIR use existing DIR as the directory to write files in
+ #-quiet
+ #-recorder enable filename recorder
+ #
+ # Options with different processing by latexmk than (pdf)latex
+ #-help
+ #-version
+ #
+ # Options NOT used by latexmk
+ #-includedirectory=dir prefix dir to the search path
+ #-initialize become the INI variant of the compiler
+ #-ini be pdfinitex, for dumping formats; this is implicitly
+ # true if the program name is `pdfinitex'
+) {
+ if ( /^([^\s=]+)=/ ) {
+ $allowed_latex_options_with_arg{$1} = $_;
+ }
+ elsif ( /^([^\s=]+)\s/ ) {
+ $allowed_latex_options{$1} = $_;
+ }
+ else {
+ $allowed_latex_options{$_} = $_;
+ }
+}
+
+# Arrays of options that will be added to latex and pdflatex.
+# These need to be stored until after the command line parsing is finished,
+# in case the values of $latex and/or $pdflatex change after an option
+# is added.
+@extra_latex_options = ();
+@extra_pdflatex_options = ();
+@extra_lualatex_options = ();
+@extra_xelatex_options = ();
+
+
+## Command to invoke biber & bibtex
+$biber = 'biber %O %B';
+$bibtex = 'bibtex %O %B';
+# Switch(es) to make biber & bibtex silent:
+$bibtex_fudge = 1; # Use hack to get bibtex working in old versions that
+ # don't handle output-directory.
+$biber_silent_switch = '--onlylog';
+$bibtex_silent_switch = '-terse';
+$bibtex_use = 1; # Whether to actually run bibtex to update bbl files.
+ # This variable is also used in deciding whether to
+ # delete bbl files in clean up operations.
+ # 0: Never run bibtex.
+ # Do NOT delete bbl files on clean up.
+ # 1: Run bibtex only if the bibfiles exists
+ # according to kpsewhich, and the bbl files
+ # appear to be out-of-date.
+ # Do NOT delete bbl files on clean up.
+ # 1.5: Run bibtex only if the bibfiles exists
+ # according to kpsewhich, and the bbl files
+ # appear to be out-of-date.
+ # Only delete bbl files on clean up if bibfiles exist.
+ # 2: Run bibtex when the bbl files are out-of-date
+ # Delete bbl files on clean up.
+ #
+ # In any event bibtex is only run if the log file
+ # indicates that the document uses bbl files.
+
+## Command to invoke makeindex
+$makeindex = 'makeindex %O -o %D %S';
+# Switch(es) to make makeinex silent:
+$makeindex_silent_switch = '-q';
+
+## Command to convert dvi file to pdf file directly:
+$dvipdf = 'dvipdf %O %S %D';
+# N.B. Standard dvipdf runs dvips and gs with their silent switch, so for
+# standard dvipdf $dvipdf_silent_switch is unneeded, but innocuous.
+# But dvipdfmx can be used instead, and it has a silent switch (-q).
+# So implementing $dvipdf_silent_switch is useful.
+
+$dvipdf_silent_switch = '-q';
+
+## Command to convert dvi file to ps file:
+$dvips = 'dvips %O -o %D %S';
+## Command to convert dvi file to ps file in landscape format:
+$dvips_landscape = 'dvips -tlandscape %O -o %D %S';
+# Switch(es) to get dvips to make ps file suitable for conversion to good pdf:
+# (If this is not used, ps file and hence pdf file contains bitmap fonts
+# (type 3), which look horrible under acroread. An appropriate switch
+# ensures type 1 fonts are generated. You can put this switch in the
+# dvips command if you prefer.)
+$dvips_pdf_switch = '-P pdf';
+# Switch(es) to make dvips silent:
+$dvips_silent_switch = '-q';
+
+## Command to convert ps file to pdf file:
+$ps2pdf = 'ps2pdf %O %S %D';
+
+## Command to convert xdv file to pdf file
+$xdvipdfmx = 'xdvipdfmx -o %D %O %S';
+$xdvipdfmx_silent_switch = '-q';
+
+
+## Command to search for tex-related files
+$kpsewhich = 'kpsewhich %S';
+
+## Command to run make:
+$make = 'make';
+
+##Printing:
+$print_type = 'auto'; # When printing, print the postscript file.
+ # Possible values: 'dvi', 'ps', 'pdf', 'auto', 'none'
+ # 'auto' ==> set print type according to the printable
+ # file(s) being made: priority 'ps', 'pdf', 'dvi'
+
+## Which treatment of default extensions and filenames with
+## multiple extensions is used, for given filename on
+## tex/latex's command line? See sub find_basename for the
+## possibilities.
+## Current tex's treat extensions like UNIX teTeX:
+$extension_treatment = 'unix';
+
+# Viewers. These are system dependent, so default to none:
+$pdf_previewer = $ps_previewer = $ps_previewer_landscape = $dvi_previewer = $dvi_previewer_landscape = "NONE";
+
+$dvi_update_signal = undef;
+$ps_update_signal = undef;
+$pdf_update_signal = undef;
+
+$dvi_update_command = undef;
+$ps_update_command = undef;
+$pdf_update_command = undef;
+
+$allow_subdir_creation = 1;
+
+$new_viewer_always = 0; # If 1, always open a new viewer in pvc mode.
+ # If 0, only open a new viewer if no previous
+ # viewer for the same file is detected.
+
+# Commands for use in pvc mode for compiling, success, warnings, and failure;
+# they default to empty, i.e., not to use:
+$compiling_cmd = $success_cmd = $warning_cmd = $failure_cmd = "";
+
+# Commands for printing are highly system dependent, so default to NONE:
+$lpr = 'NONE $lpr variable is not configured to allow printing of ps files';
+$lpr_dvi = 'NONE $lpr_dvi variable is not configured to allow printing of dvi files';
+$lpr_pdf = 'NONE $lpr_pdf variable is not configured to allow printing of pdf files';
+
+
+# The $pscmd below holds a **system-dependent** command to list running
+# processes. It is used to find the process ID of the viewer looking at
+# the current output file. The output of the command must include the
+# process number and the command line of the processes, since the
+# relevant process is identified by the name of file to be viewed.
+# Its use is not essential.
+$pscmd = 'NONE $pscmd variable is not configured to detect running processes';
+$pid_position = -1; # offset of PID in output of pscmd.
+ # Negative means I cannot use ps
+
+
+$quote_filenames = 1; # Quote filenames in external commands
+
+$del_dir = ''; # Directory into which cleaned up files are to be put.
+ # If $del_dir is '', just delete the files
+
+@rc_system_files = ();
+
+#########################################################################
+
+################################################################
+## Special variables for system-dependent fudges, etc.
+$log_file_binary = 0; # Whether to treat log file as binary
+ # Normally not, since the log file SHOULD be pure text.
+ # But Miktex 2.7 sometimes puts binary characters
+ # in it. (Typically in construct \OML ... after
+ # overfull box with mathmode.)
+ # Sometimes there is ctrl/Z, which is not only non-text,
+ # but is end-of-file marker for MS-Win in text mode.
+
+$MSWin_fudge_break = 1; # Give special treatment to ctrl/C and ctrl/break
+ # in -pvc mode under MSWin
+ # Under MSWin32 (at least with perl 5.8 and WinXP)
+ # when latexmk is running another program, and the
+ # user gives ctrl/C or ctrl/break, to stop the
+ # daughter program, not only does it reach
+ # the daughter, but also latexmk/perl, so
+ # latexmk is stopped also. In -pvc mode,
+ # this is not normally desired. So when the
+ # $MSWin_fudge_break variable is set,
+ # latexmk arranges to ignore ctrl/C and
+ # ctrl/break during processing of files;
+ # only the daughter programs receive them.
+ # This fudge is not applied in other
+ # situations, since then having latexmk also
+ # stopping because of the ctrl/C or
+ # ctrl/break signal is desirable.
+ # The fudge is not needed under UNIX (at least
+ # with Perl 5.005 on Solaris 8). Only the
+ # daughter programs receive the signal. In
+ # fact the inverse would be useful: In
+ # normal processing, as opposed to -pvc, if
+ # force mode (-f) is set, a ctrl/C is
+ # received by a daughter program does not
+ # also stop latexmk. Under tcsh, we get
+ # back to a command prompt, while latexmk
+ # keeps running in the background!
+
+## Substitute backslashes in file and directory names for
+## MSWin command line
+$MSWin_back_slash = 1;
+
+## Separator of elements in search_path. Default is unix value
+$search_path_separator = ':';
+
+
+# Directory for temporary files. Default to current directory.
+$tmpdir = ".";
+
+
+# When the aux_dir is on a network share (or the like), its system
+# time may differ from the system time on which latexmk is running.
+# This complicates the tests of whether particular files have been
+# made in a current run of a program or are left over from a previous
+# run. One test, which is needed under some situations, is that a
+# file was made on a previous run when the files modification time is
+# less than the system time when the program is started. (See
+# subroutine test_gen_file; this is only needed in a couple of
+# situations.) The comparison between file and system times must be
+# corrected if there is an offset between system times on the computer
+# running latexmk and the computer hosting the file system containing
+# aux_dir. The offset is measured in subroutine get_filetime_offset
+# by writing a temporary file; the test only needs to be done once.
+#
+# The following variables are used. Since the system-independent
+# values of system and file time are only accurate to a second (or 2
+# seconds for FAT file systems), the offset is also accurate only to a
+# second or two. So thresholds are needed below which differences
+# are insignificant.
+#
+# Note that the making or not making of a file is controlled by the
+# state of the document being compiled and by latexmk's configuration.
+# So a file that is left over from a previous run and not overwritten
+# on the current run will have a file time at least many seconds less
+# than the current time, corresponding to the time scale for a human
+# run-edit-run cycle.
+#
+$filetime_offset_measured = 0; # Measurement not yet done.
+$filetime_offset = 0; # Filetime relative to system time.
+$filetime_causality_threshold = 5; # Threshold for detection of left-over file.
+ # Should be non-negative always, and should
+ # be bigger than 2 secs if a remote
+ # filesystem or network share is used.
+$filetime_offset_report_threshold = 30; # Threshold beyond which filetime offsets
+ # are reported; large offsets indicate
+ # incorrect system time on at least one system.
+
+
+################################################################
+
+
+# System-dependent overrides:
+# Currently, the cases I have tests for are: MSWin32, cygwin, linux and
+# darwin, msys, with the main complications being for MSWin32 and cygwin.
+# Further special treatment may also be useful for MSYS (for which $^O reports
+# "msys"). This is another *nix-emulation/system for MSWindows. At
+# present it is treated as unix-like, but the environment variables
+# are those of Windows. (The test for USERNAME as well as USER was
+# to make latexmk work under MSYS's perl.)
+#
+if ( $^O eq "MSWin32" ) {
+# Pure MSWindows configuration
+ ## Configuration parameters:
+
+ ## Use first existing case for $tmpdir:
+ $tmpdir = $ENV{TMPDIR} || $ENV{TEMP} || '.';
+ $log_file_binary = 1; # Protect against ctrl/Z in log file from
+ # Miktex 2.7.
+
+ ## List of possibilities for the system-wide initialization file.
+ ## The first one found (if any) is used.
+ @rc_system_files = ( "C:/latexmk/LatexMk", "C:/latexmk/latexmkrc" );
+
+ $search_path_separator = ';'; # Separator of elements in search_path
+
+ # For a pdf-file, "start x.pdf" starts the pdf viewer associated with
+ # pdf files, so no program name is needed:
+ $pdf_previewer = 'start %O %S';
+ $ps_previewer = 'start %O %S';
+ $ps_previewer_landscape = $ps_previewer;
+ $dvi_previewer = 'start %O %S';
+ $dvi_previewer_landscape = "$dvi_previewer";
+ # Viewer update methods:
+ # 0 => auto update: viewer watches file (e.g., gv)
+ # 1 => manual update: user must do something: e.g., click on window.
+ # (e.g., ghostview, MSWIN previewers, acroread under UNIX)
+ # 2 => send signal. Number of signal in $dvi_update_signal,
+ # $ps_update_signal, $pdf_update_signal
+ # 3 => viewer can't update, because it locks the file and the file
+ # cannot be updated. (acroread under MSWIN)
+ # 4 => run a command to force the update. The commands are
+ # specified by the variables $dvi_update_command,
+ # $ps_update_command, $pdf_update_command
+ $dvi_update_method = 1;
+ $ps_update_method = 1;
+ $pdf_update_method = 3; # acroread locks the pdf file
+}
+elsif ( $^O eq "cygwin" ) {
+ # The problem is a mixed MSWin32 and UNIX environment.
+ # Perl decides the OS is cygwin in two situations:
+ # 1. When latexmk is run from a cygwin shell under a cygwin
+ # environment. Perl behaves in a UNIX way. This is OK, since
+ # the user is presumably expecting UNIXy behavior.
+ # 2. When CYGWIN exectuables are in the path, but latexmk is run
+ # from a native NT shell. Presumably the user is expecting NT
+ # behavior. But perl behaves more UNIXy. This causes some
+ # clashes.
+ # The issues to handle are:
+ # 1. Perl sees both MSWin32 and cygwin filenames. This is
+ # normally only an advantage.
+ # 2. Perl uses a UNIX shell in the system command
+ # This is a nasty problem: under native NT, there is a
+ # start command that knows about NT file associations, so that
+ # we can do, e.g., (under native NT) system("start file.pdf");
+ # But this won't work when perl has decided the OS is cygwin,
+ # even if it is invoked from a native NT command line. An
+ # NT command processor must be used to deal with this.
+ # 3. External executables can be native NT (which only know
+ # NT-style file names) or cygwin executables (which normally
+ # know both cygwin UNIX-style file names and NT file names,
+ # but not always; some do not know about drive names, for
+ # example).
+ # Cygwin executables for tex and latex may only know cygwin
+ # filenames.
+ # 4. The BIBINPUTS environment variables may be
+ # UNIX-style or MSWin-style depending on whether native NT or
+ # cygwin executables are used. They are therefore parsed
+ # differently. Here is the clash:
+ # a. If a user is running under an NT shell, is using a
+ # native NT installation of tex (e.g., fptex or miktex),
+ # but has the cygwin executables in the path, then perl
+ # detects the OS as cygwin, but the user needs NT
+ # behavior from latexmk.
+ # b. If a user is running under an UNIX shell in a cygwin
+ # environment, and is using the cygwin installation of
+ # tex, then perl detects the OS as cygwin, and the user
+ # needs UNIX behavior from latexmk.
+ # Latexmk has no way of detecting the difference. The two
+ # situations may even arise for the same user on the same
+ # computer simply by changing the order of directories in the
+ # path environment variable
+
+
+ ## Configuration parameters: We'll assume native NT executables.
+ ## The user should override if they are not.
+
+ # This may fail: perl converts MSWin temp directory name to cygwin
+ # format. Names containing this string cannot be handled by native
+ # NT executables.
+ $tmpdir = $ENV{TMPDIR} || $ENV{TEMP} || '.';
+
+ ## List of possibilities for the system-wide initialization file.
+ ## The first one found (if any) is used.
+ ## We could stay with MSWin files here, since cygwin perl understands them
+ ## @rc_system_files = ( 'C:/latexmk/LatexMk', 'C:/latexmk/latexmkrc' );
+ ## But they are deprecated in v. 1.7. So use the UNIX version, prefixed
+ ## with a cygwin equivalent of the MSWin location
+ ## In addition, we need to add the same set of possible locations as with
+ ## unix, so that the user use a unix-style setup.
+ @rc_system_files = ();
+ foreach ( 'LatexMk', 'latexmkrc' ) {
+ push @rc_system_files,
+ ( "/cygdrive/c/latexmk/$_",
+ "/opt/local/share/latexmk/$_",
+ "/usr/local/share/latexmk/$_",
+ "/usr/local/lib/latexmk/$_" );
+ }
+ $search_path_separator = ';'; # Separator of elements in search_path
+ # This is tricky. The search_path_separator depends on the kind
+ # of executable: native NT v. cygwin.
+ # So the user will have to override this.
+
+ # We will assume that files can be viewed by native NT programs.
+ # Then we must fix the start command/directive, so that the
+ # NT-native start command of a cmd.exe is used.
+ # For a pdf-file, "start x.pdf" starts the pdf viewer associated with
+ # pdf files, so no program name is needed:
+ $start_NT = "cmd /c start \"\"";
+ $pdf_previewer = "$start_NT %O %S";
+ $ps_previewer = "$start_NT %O %S";
+ $ps_previewer_landscape = $ps_previewer;
+ $dvi_previewer = "$start_NT %O %S";
+ $dvi_previewer_landscape = $dvi_previewer;
+ # Viewer update methods:
+ # 0 => auto update: viewer watches file (e.g., gv)
+ # 1 => manual update: user must do something: e.g., click on window.
+ # (e.g., ghostview, MSWIN previewers, acroread under UNIX)
+ # 2 => send signal. Number of signal in $dvi_update_signal,
+ # $ps_update_signal, $pdf_update_signal
+ # 3 => viewer can't update, because it locks the file and the file
+ # cannot be updated. (acroread under MSWIN)
+ $dvi_update_method = 1;
+ $ps_update_method = 1;
+ $pdf_update_method = 3; # acroread locks the pdf file
+}
+elsif ( $^O eq "msys" ) {
+ $search_path_separator = ';'; # Separator of elements in search_path
+ # I think MS-Win value is OK, since
+ # msys is running under MS-Win
+ $pdf_previewer = q[sh -c 'start %S'];
+ $ps_previewer = q[sh -c 'start %S'];
+ $dvi_previewer = q[sh -c 'start %S'];
+ $ps_previewer_landscape = $ps_previewer;
+ $dvi_previewer_landscape = "$dvi_previewer";
+}
+else {
+ # Assume anything else is UNIX or clone
+ # Do special cases (e.g., linux, darwin (i.e., OS-X)) inside this block.
+
+ ## Use first existing case for $tmpdir:
+ $tmpdir = $ENV{TMPDIR} || '/tmp';
+
+ ## List of possibilities for the system-wide initialization file.
+ ## The first one found (if any) is used.
+ ## Normally on a UNIX it will be in a subdirectory of /opt/local/share or
+ ## /usr/local/share, depending on the local conventions.
+ ## But /usr/local/lib/latexmk is put in the list for
+ ## compatibility with older versions of latexmk.
+ @rc_system_files = ();
+ foreach ( 'LatexMk', 'latexmkrc' ) {
+ push @rc_system_files,
+ ( "/opt/local/share/latexmk/$_",
+ "/usr/local/share/latexmk/$_",
+ "/usr/local/lib/latexmk/$_" );
+ }
+ $search_path_separator = ':'; # Separator of elements in search_path
+
+ $dvi_update_signal = $signo{USR1}
+ if ( defined $signo{USR1} ); # Suitable for xdvi
+ $ps_update_signal = $signo{HUP}
+ if ( defined $signo{HUP} ); # Suitable for gv
+ $pdf_update_signal = $signo{HUP}
+ if ( defined $signo{HUP} ); # Suitable for gv
+ ## default document processing programs.
+ # Viewer update methods:
+ # 0 => auto update: viewer watches file (e.g., gv)
+ # 1 => manual update: user must do something: e.g., click on window.
+ # (e.g., ghostview, MSWIN previewers, acroread under UNIX)
+ # 2 => send signal. Number of signal in $dvi_update_signal,
+ # $ps_update_signal, $pdf_update_signal
+ # 3 => viewer can't update, because it locks the file and the file
+ # cannot be updated. (acroread under MSWIN)
+ # 4 => Run command to update. Command in $dvi_update_command,
+ # $ps_update_command, $pdf_update_command.
+ $dvi_previewer = 'start xdvi %O %S';
+ $dvi_previewer_landscape = 'start xdvi -paper usr %O %S';
+ if ( defined $dvi_update_signal ) {
+ $dvi_update_method = 2; # xdvi responds to signal to update
+ } else {
+ $dvi_update_method = 1;
+ }
+# if ( defined $ps_update_signal ) {
+# $ps_update_method = 2; # gv responds to signal to update
+# $ps_previewer = 'start gv -nowatch';
+# $ps_previewer_landscape = 'start gv -swap -nowatch';
+# } else {
+# $ps_update_method = 0; # gv -watch watches the ps file
+# $ps_previewer = 'start gv -watch';
+# $ps_previewer_landscape = 'start gv -swap -watch';
+# }
+ # Turn off the fancy options for gv. Regular gv likes -watch etc
+ # GNU gv likes --watch etc. User must configure
+ $ps_update_method = 0; # gv -watch watches the ps file
+ $ps_previewer = 'start gv %O %S';
+ $ps_previewer_landscape = 'start gv -swap %O %S';
+ $pdf_previewer = 'start acroread %O %S';
+ $pdf_update_method = 1; # acroread under unix needs manual update
+ $lpr = 'lpr %O %S'; # Assume lpr command prints postscript files correctly
+ $lpr_dvi =
+ 'NONE $lpr_dvi variable is not configured to allow printing of dvi files';
+ $lpr_pdf =
+ 'NONE $lpr_pdf variable is not configured to allow printing of pdf files';
+ # The $pscmd below holds a command to list running processes. It
+ # is used to find the process ID of the viewer looking at the
+ # current output file. The output of the command must include the
+ # process number and the command line of the processes, since the
+ # relevant process is identified by the name of file to be viewed.
+ # Uses:
+ # 1. In preview_continuous mode, to save running a previewer
+ # when one is already running on the relevant file.
+ # 2. With xdvi in preview_continuous mode, xdvi must be
+ # signalled to make it read a new dvi file.
+ #
+ # The following works on Solaris, LINUX, HP-UX, IRIX
+ # Use -f to get full listing, including command line arguments.
+ # Use -u $ENV{USER} to get all processes started by current user (not just
+ # those associated with current terminal), but none of other users'
+ # processes.
+ # However, the USER environment variable may not exist. Windows uses
+ # USERNAME instead. (And this propagates to a situation of
+ # unix-emulation software running under Windows.)
+ if ( exists $ENV{USER} ) {
+ $pscmd = "ps -f -u $ENV{USER}";
+ }
+ elsif ( exists $ENV{USERNAME} ) {
+ $pscmd = "ps -f -u $ENV{USERNAME}";
+ }
+ else {
+ $pscmd = "ps -f";
+ }
+ $pid_position = 1; # offset of PID in output of pscmd; first item is 0.
+ if ( $^O eq "linux" ) {
+ # Ps on Redhat (at least v. 7.2) appears to truncate its output
+ # at 80 cols, so that a long command string is truncated.
+ # Fix this with the --width option. This option works under
+ # other versions of linux even if not necessary (at least
+ # for SUSE 7.2).
+ # However the option is not available under other UNIX-type
+ # systems, e.g., Solaris 8.
+ # But (19 Aug 2010), the truncation doesn't happen on RHEL4 and 5,
+ # unless the output is written to a terminal. So the --width
+ # option is now unnecessary
+ # $pscmd = "ps --width 200 -f -u $ENV{USER}";
+ }
+ elsif ( $^O eq "darwin" ) {
+ # OS-X on Macintosh
+ # open starts command associated with a file.
+ # For pdf, this is set by default to OS-X's preview, which is suitable.
+ # Manual update is simply by clicking on window etc, which is OK.
+ # For ps, this is set also to preview. This works, but since it
+ # converts the file to pdf and views the pdf file, it doesn't
+ # see updates, and a refresh cannot be done. This is far from
+ # optimal.
+ # For a full installation of MacTeX, which is probably the most common
+ # on OS-X, an association is created between dvi files and TeXShop.
+ # This also converts the file to pdf, so again while it works, it
+ # does not deal with changed dvi files, as far as I can see.
+ $pdf_previewer = 'open %S';
+ $pdf_update_method = 1; # manual
+ $dvi_previewer = $dvi_previewer_landscape = 'NONE';
+ $ps_previewer = $ps_previewer_landscape = 'NONE';
+ # Others
+ $lpr_pdf = 'lpr %O %S';
+ $pscmd = "ps -ww -u $ENV{USER}";
+ }
+}
+
+## default parameters
+$auto_rc_use = 1; # Whether to read rc files automatically
+$max_repeat = 5; # Maximum times I repeat latex. Normally
+ # 3 would be sufficient: 1st run generates aux file,
+ # 2nd run picks up aux file, and maybe toc, lof which
+ # contain out-of-date information, e.g., wrong page
+ # references in toc, lof and index, and unresolved
+ # references in the middle of lines. But the
+ # formatting is more-or-less correct. On the 3rd
+ # run, the page refs etc in toc, lof, etc are about
+ # correct, but some slight formatting changes may
+ # occur, which mess up page numbers in the toc and lof,
+ # Hence a 4th run is conceivably necessary.
+ # At least one document class (JHEP.cls) works
+ # in such a way that a 4th run is needed.
+ # We allow an extra run for safety for a
+ # maximum of 5. Needing further runs is
+ # usually an indication of a problem; further
+ # runs may not resolve the problem, and
+ # instead could cause an infinite loop.
+$clean_ext = ""; # space separated extensions of files that are
+ # to be deleted when doing cleanup, beyond
+ # standard set
+$clean_full_ext = ""; # space separated extensions of files that are
+ # to be deleted when doing cleanup_full, beyond
+ # standard set and those in $clean_ext
+@cus_dep_list = (); # Custom dependency list
+@default_files = ( '*.tex' ); # Array of LaTeX files to process when
+ # no files are specified on the command line.
+ # Wildcards allowed
+ # Best used for project specific files.
+@default_excluded_files = ( );
+ # Array of LaTeX files to exclude when using
+ # @default_files, i.e., when no files are specified
+ # on the command line.
+ # Wildcards allowed
+ # Best used for project specific files.
+$texfile_search = ""; # Specification for extra files to search for
+ # when no files are specified on the command line
+ # and the @default_files variable is empty.
+ # Space separated, and wildcards allowed.
+ # These files are IN ADDITION to *.tex in current
+ # directory.
+ # This variable is obsolete, and only in here for
+ # backward compatibility.
+
+$fdb_ext = 'fdb_latexmk'; # Extension for the file for latexmk's
+ # file-database
+ # Make it long to avoid possible collisions.
+$fdb_ver = 3; # Version number for kind of fdb_file.
+
+$jobname = ''; # Jobname: as with current tex, etc indicates
+ # basename of generated files. Defined so
+ # that --jobname=STRING on latexmk's command
+ # line has same effect as with current tex,
+ # etc, with the exception listed below. (If
+ # $jobname is non-empty, then the
+ # --jobname=... option is used on tex.)
+ # Extension: $jobname is allowed to contain
+ # placeholder(s) (currently only %A),
+ # which allows construction of jobnames
+ # dependent on name of main TeX file; this is
+ # useful when a jobname is used and latexmk is
+ # invoked on multiple files.
+$out_dir = ''; # Directory for output files.
+ # Cf. --output-directory of current (pdf)latex
+$aux_dir = ''; # Directory for aux files (log, aux, etc).
+ # Cf. --aux-directory of current (pdf)latex in MiKTeX.
+
+
+## default flag settings.
+$recorder = 1; # Whether to use recorder option on latex/pdflatex
+$silent = 0; # Silence latex's messages?
+$warnings_as_errors = 0;# Treat warnings as errors and exit with non-zero exit code
+$silence_logfile_warnings = 0; # Do list warnings in log file
+$kpsewhich_show = 0; # Show calls to and results from kpsewhich
+$landscape_mode = 0; # default to portrait mode
+$analyze_input_log_always = 1; # Always analyze .log for input files in the
+ # <...> and (...) constructions. Otherwise, only
+ # do the analysis when fls file doesn't exist or is
+ # out of date.
+ # Under normal circumstances, the data in the fls file
+ # is reliable, and the test of the log file gets lots
+ # of false positives; usually $analyze_input_log_always
+ # is best set to zero. But the test of the log file
+ # is needed at least in the following situation:
+ # When a user needs to persuade latexmk that a certain
+ # file is a source file, and latexmk doesn't otherwise
+ # find it. User code causes line with (...) to be
+ # written to log file. One important case is for
+ # lualatex, which doesn't always generate lines in the
+ # .fls file for input lua files. (The situation with
+ # lualatex is HIGHLY version dependent, e.g., between
+ # 2016 and 2017.)
+ # To keep backward compatibility with older versions
+ # of latexmk, the default is to set
+ # $analyze_input_log_always to 1.
+
+# The following two arrays contain lists of extensions (without
+# period) for files that are read in during a (pdf)LaTeX run but that
+# are generated automatically from the previous run, as opposed to
+# being user generated files (directly or indirectly from a custom
+# dependency). These files get two kinds of special treatment:
+# 1. In clean up, where depending on the kind of clean up, some
+# or all of these generated files are deleted.
+# (Note that special treatment is given to aux files.)
+# 2. In analyzing the results of a run of (pdf)LaTeX, to
+# determine if another run is needed. With an error free run,
+# a rerun should be provoked by a change in any source file,
+# whether a user file or a generated file. But with a run
+# that ends in an error, only a change in a user file during
+# the run (which might correct the error) should provoke a
+# rerun, but a change in a generated file should not.
+# These arrays can be user-configured.
+
+@generated_exts = ( 'aux', 'bcf', 'fls', 'idx', 'ind', 'lof', 'lot',
+ 'out', 'toc' );
+ # N.B. 'out' is generated by hyperref package
+
+# Which kinds of file do I have requests to make?
+# If no requests at all are made, then I will make dvi file
+# If particular requests are made then other files may also have to be
+# made. E.g., ps file requires a dvi file
+$dvi_mode = 0; # No dvi file requested
+$postscript_mode = 0; # No postscript file requested
+$pdf_mode = 0; # No pdf file requested to be made by pdflatex
+ # Possible values:
+ # 0 don't create pdf file
+ # 1 to create pdf file by pdflatex
+ # 2 to create pdf file by ps2pdf
+ # 3 to create pdf file by dvipdf
+ # 4 to create pdf file by lualatex
+ # 5 to create pdf file by xelatex + xdvipdfmx
+$view = 'default'; # Default preview is of highest of dvi, ps, pdf
+$sleep_time = 2; # time to sleep b/w checks for file changes in -pvc mode
+$banner = 0; # Non-zero if we have a banner to insert
+$banner_scale = 220; # Original default scale
+$banner_intensity = 0.95; # Darkness of the banner message
+$banner_message = 'DRAFT'; # Original default message
+$do_cd = 0; # Do not do cd to directory of source file.
+ # Thus behave like latex.
+$dependents_list = 0; # Whether to display list(s) of dependencies
+$dependents_phony = 0; # Whether list(s) of dependencies includes phony targets
+ # (as with 'gcc -MP').
+$deps_file = '-'; # File for dependency list output. Default stdout.
+$rules_list = 0; # Whether to display list(s) of dependencies
+@dir_stack = (); # Stack of pushed directories, each of form of
+ # pointer to array [ cwd, good_cwd ], where
+ # good_cwd differs from cwd by being converted
+ # to native MSWin path when cygwin is used.
+$cleanup_mode = 0; # No cleanup of nonessential LaTex-related files.
+ # $cleanup_mode = 0: no cleanup
+ # $cleanup_mode = 1: full cleanup
+ # $cleanup_mode = 2: cleanup except for dvi,
+ # dviF, pdf, ps, psF & xdv
+$cleanup_fdb = 0; # No removal of file for latexmk's file-database
+$cleanup_only = 0; # When doing cleanup, do not go on to making files
+$cleanup_includes_generated = 0;
+ # Determines whether cleanup deletes files generated by
+ # (pdf)latex (found from \openout lines in log file).
+ # It's more than that. BUG
+$cleanup_includes_cusdep_generated = 0;
+ # Determines whether cleanup deletes files generated by
+ # custom dependencies
+$diagnostics = 0;
+$dvi_filter = ''; # DVI filter command
+$ps_filter = ''; # Postscript filter command
+
+$force_mode = 0; # =1 to force processing past errors
+$go_mode = 0; # =1 to force processing regardless of time-stamps
+ # =2 full clean-up first
+$preview_mode = 0;
+$preview_continuous_mode = 0;
+$printout_mode = 0; # Don't print the file
+
+## Control pvc inactivity timeout:
+$pvc_timeout = 0;
+$pvc_timeout_mins = 30;
+
+$show_time = 0;
+@timings = ();
+$processing_time1 = processing_time();
+
+$use_make_for_missing_files = 0; # Whether to use make to try to make missing files.
+
+# Do we make view file in temporary then move to final destination?
+# (To avoid premature updating by viewer).
+$always_view_file_via_temporary = 0; # Set to 1 if viewed file is always
+ # made through a temporary.
+$pvc_view_file_via_temporary = 1; # Set to 1 if only in -pvc mode is viewed
+ # file made through a temporary.
+
+# State variables initialized here:
+
+$updated = 0; # Flags when something has been remade
+ # Used to allow convenient user message in -pvc mode
+$waiting = 0; # Flags whether we are in loop waiting for an event
+ # Used to avoid unnecessary repeated o/p in wait loop
+
+# The following are used for some results of parsing log file
+# Global variables, so results can be reported in main program.
+$reference_changed = 0;
+$mult_defined = 0;
+$bad_reference = 0;
+$bad_character = 0;
+$bad_citation = 0;
+@primary_warning_summary = ();
+
+# Cache of expensive-to-compute state variables, e.g., cwd in form
+# fixed to deal with cygwin issues.
+%cache = ();
+&cache_good_cwd;
+
+# Set search paths for includes.
+# Set them early so that they can be overridden
+$BIBINPUTS = $ENV{'BIBINPUTS'};
+if (!$BIBINPUTS) { $BIBINPUTS = '.'; }
+
+# Convert search paths to arrays:
+# If any of the paths end in '//' then recursively search the
+# directory. After these operations, @BIBINPUTS should
+# have all the directories that need to be searched
+
+@BIBINPUTS = find_dirs1( $BIBINPUTS );
+
+
+######################################################################
+######################################################################
+#
+# ??? UPDATE THE FOLLOWING!!
+#
+# We will need to determine whether source files for runs of various
+# programs are out of date. In a normal situation, this is done by
+# asking whether the times of the source files are later than the
+# destination files. But this won't work for us, since a common
+# situation is that a file is written on one run of latex, for
+# example, and read back in on the next run (e.g., an .aux file).
+# Some situations of this kind are standard in latex generally; others
+# occur with particular macro packages or with particular
+# postprocessors.
+#
+# The correct criterion for whether a source is out-of-date is
+# therefore NOT that its modification time is later than the
+# destination file, but whether the contents of the source file have
+# changed since the last successful run. This also handles the case
+# that the user undoes some changes to a source file by replacing the
+# source file by reverting to an earlier version, which may well have
+# an older time stamp. Since a direct comparison of old and new files
+# would involve storage and access of a large number of backup files,
+# we instead use the md5 signature of the files. (Previous versions
+# of latexmk used the backup file method, but restricted to the case
+# of .aux and .idx files, sufficient for most, but not all,
+# situations.)
+#
+# We will have a database of (time, size, md5) for the relevant
+# files. If the time and size of a file haven't changed, then the file
+# is assumed not to have changed; this saves us from having to
+# determine its md5 signature, which would involve reading the whole
+# file, which is naturally time-consuming, especially if network file
+# access to a server is needed, and many files are involved, when most
+# of them don't change. It is of course possible to change a file
+# without changing its size, but then to adjust its timestamp
+# to what it was previously; this requires a certain amount of
+# perversity. We can safely assume that if the user edits a file or
+# changes its contents, then the file's timestamp changes. The
+# interesting case is that the timestamp does change, because the file
+# has actually been written to, but that the contents do not change;
+# it is for this that we use the md5 signature. However, since
+# computing the md5 signature involves reading the whole file, which
+# may be large, we should avoid computing it more than necessary.
+#
+# So we get the following structure:
+#
+# 1. For each relevant run (latex, pdflatex, each instance of a
+# custom dependency) we have a database of the state of the
+# source files that were last used by the run.
+# 2. On an initial startup, the database for a primary tex file
+# is read that was created by a previous run of latex or
+# pdflatex, if this exists.
+# 3. If the file doesn't exist, then the criterion for
+# out-of-dateness for an initial run is that it goes by file
+# timestamps, as in previous versions of latexmk, with due
+# (dis)regard to those files that are known to be generated by
+# latex and re-read on the next run.
+# 4. Immediately before a run, the database is updated to
+# represent the current conditions of the run's source files.
+# 5. After the run, it is determined whether any of the source
+# files have changed. This covers both files written by the
+# run, which are therefore in a dependency loop, and files that
+# the user may have updated during the run. (The last often
+# happens when latex takes a long time, for a big document,
+# and the user makes edits before latex has finished. This is
+# particularly prevalent when latexmk is used with
+# preview-continuous mode.)
+# 6. In the case of latex or pdflatex, the custom dependencies
+# must also be checked and redone if out-of-date.
+# 7. If any source files have changed, the run is redone,
+# starting at step 1.
+# 8. There is naturally a limit on the number of reruns, to avoid
+# infinite loops from bugs and from pathological or unforeseen
+# conditions.
+# 9. After the run is done, the run's file database is updated.
+# (By hypothesis, the sizes and md5s are correct, if the run
+# is successful.)
+# 10. To allow reuse of data from previous runs, the file database
+# is written to a file after every complete set of passes
+# through latex or pdflatex. (Note that there is separate
+# information for latex and pdflatex; the necessary
+# information won't coincide: Out-of-dateness for the files
+# for each program concerns the properties of the files when
+# the other program was run, and the set of source files could
+# be different, e.g., for graphics files.)
+#
+# We therefore maintain the following data structures.:
+#
+# a. For each run (latex, pdflatex, each custom dependency) a
+# database is maintained. This is a hash from filenames to a
+# reference to an array: [time, size, md5]. The semantics of
+# the database is that it represents the state of the source
+# files used in the run. During a run it represents the state
+# immediately before the run; after a run, with all reruns, it
+# represents the state of the files used, modified by having
+# the latest timestamps for generated files.
+# b. There is a global database for all files, which represents
+# the current state. This saves having to recompute the md5
+# signatures of a changed file used in more than one run
+# (e.g., latex and pdflatex).
+# c. Each of latex and pdflatex has a list of the relevant custom
+# dependencies.
+#
+# In all the following a fdb-hash is a hash of the form:
+# filename -> [time, size, md5]
+# If a file is found to disappear, its entry is removed from the hash.
+# In returns from fdb access routines, a size entry of -1 indicates a
+# non-existent file.
+
+
+# List of known rules. Rule types: primary,
+# external (calls program), internal (calls routine), cusdep.
+
+%possible_primaries = ( 'latex' => 'primary', 'pdflatex' => 'primary',
+ 'lualatex' => 'primary', 'xelatex' => 'primary' );
+
+# Hashes, whose keys give names of particular kinds of rule, and targets.
+# We use hashes for ease of lookup.
+%possible_one_time = ( 'view' => 1, 'print' => 1, 'update_view' => 1, );
+%target_files = (); # Hash for target files.
+ # The keys are the filenames and the value is
+ # currently irrelevant.
+%target_rules = (); # Hash for target rules beyond those corresponding to files.
+ # The keys are the rule names and the value is
+ # currently irrelevant.
+# The target **files** can only be set inside the FILE loop.
+$current_primary = 'latex'; # Rule to compile .tex file.
+ # Subject to document-dependent override if .tex document
+ # uses metcommands andobeying them is enabled.
+$pdf_method = ''; # How to make pdf file. '' if not requested,
+ # else 'ps2pdf', 'dvipdf', 'pdflatex', 'lualatex' or 'xelatex'
+ # Subject to document-dependent override if .tex document
+ #uses \pdfoutput or c.
+%requested_filetypes = (); # Hash of requested file types (dvi, dviF, etc)
+%one_time = (); # Hash for requested one-time-only rules, currently
+ # possible values 'print' and 'view'.
+
+%actives = (); # Hash of active rules
+
+$allow_switch = 1; # Allow switch of rule structure to accommodate
+ # changed output file name of primary. Even if
+ # this flag is set on, the switch may be
+ # prohibited by other issues.
+
+%rule_db = (); # Database of all rules:
+ # Hash: rulename -> [array of rule data]
+ # Rule data:
+ # 0: [ cmd_type, ext_cmd, int_cmd, test_kind,
+ # source, dest, base,
+ # out_of_date, out_of_date_user,
+ # time_of_last_run, time_of_last_file_check,
+ # changed
+ # last_result, last_message,
+ # default_extra_generated,
+ # ]
+ # where
+ # cmd_type is 'primary', 'external', or 'cusdep'
+ # ext_cmd is string for associated external command
+ # with substitutions (%D for destination, %S
+ # for source, %B for base of current rule,
+ # %R for base of primary tex file, %T for
+ # texfile name, %O for options,
+ # %Y for $aux_dir1, and %Z for $out_dir1
+ # int_cmd specifies any internal command to be
+ # used to implement the application of the
+ # rule. If this is present, it overrides
+ # the external command, and it is the
+ # responsibility of the perl subroutine
+ # specified in intcmd to execute the
+ # external command if this is appropriate.
+ # This variable intcmd is a reference to an array,
+ # $$intcmd[0] = internal routine
+ # $$intcmd[1...] = its arguments (if any)
+ # test_kind specifies method of determining
+ # whether a file is out-of-date:
+ # 0 for never
+ # 1 for usual: whether there is a source
+ # file change
+ # 2 for dest earlier than source
+ # 3 for method 2 at first run, 1 thereafter
+ # (used when don't have file data from
+ # previous run).
+ # source = name of primary source file, if any
+ # dest = name of primary destination file,
+ # if any
+ # base = base name, if any, of files for
+ # this rule
+ # out_of_date = 1 if it has been detected that
+ # this rule needs to be run
+ # (typically because a source
+ # file has changed).
+ # Other values may be used for special cases.
+ # 0 otherwise
+ # out_of_date_user is like out_of_date, except
+ # that the detection of out-of-dateness
+ # has been made from a change of a
+ # putative user file, i.e., one that is
+ # not a generated file (e.g., aux). This
+ # kind of out-of-dateness should provoke a
+ # rerun whether or not there was an error
+ # during a run of (pdf)LaTeX. Normally,
+ # if there is an error, one should wait
+ # for the user to correct the error. But
+ # it is possible the error condition is
+ # already corrected during the run, e.g.,
+ # by the user changing a source file in
+ # response to an error message.
+ # time_of_last_run = time that this rule was
+ # last applied. (In standard units
+ # from perl, to be directly compared
+ # with file modification times.)
+ # time_of_last_file_check = last time that a check
+ # was made for changes in source files.
+ # changed flags whether special changes have been made
+ # that require file-existence status to be ignored
+ # last_result is
+ # -1 if no run has been made,
+ # 0 if the last run was successful
+ # 1 if last run was successful, but
+ # failed to create an output file
+ # 2 if last run failed
+ # 200 if last run gave a warning that is
+ # important enough to be reported with
+ # the error summary. The warning
+ # message is stored in last_message.
+ # last_message is error message for last run
+ # default_extra_generated is a reference to an array
+ # of specifications of extra generated files (beyond
+ # the main dest file. Standard place holders are used.
+ # 1: {Hash sourcefile -> [source-file data] }
+ # Source-file data array:
+ # 0: time
+ # 1: size
+ # 2: md5
+ # 3: name of rule to make this file
+ # 4: whether the file is of the kind made by epstopdf.sty
+ # during a primary run. It will have been read during
+ # the run, so that even though the file changes during
+ # a primary run, there is no need to trigger another
+ # run because of this.
+ # Size and md5 correspond to the values at the last run.
+ # But time may be updated to correspond to the time
+ # for the file, if the file is otherwise unchanged.
+ # This saves excessive md5 calculations, which would
+ # otherwise be done everytime the file is checked,
+ # in the following situation:
+ # When the file has been rewritten after a run
+ # has started (commonly aux, bbl files etc),
+ # but the actual file contents haven't
+ # changed. Then because the filetime has
+ # changed, on every file-change check latexmk
+ # would normally redo the md5 calculation to
+ # test for actual changes. Once one such
+ # check is done, and the contents are
+ # unchanged, later checks are superfluous, and
+ # can be avoided by changing the file's time
+ # in the source-file list.
+ # 2: {Hash generated_file -> 1 }
+ # This lists all generated files; the values
+ # are currently unused, only the keys
+ # 3: {Hash source_rule -> last_pass }
+ # This lists rules that are to be considered source
+ # rules for the current rule, separately from the
+ # from_rules of the source files. It maps the name
+ # of each of these rules to the pass number of the
+ # current rule when it was last run. The current rule
+ # is out-of-date if the last_pass for a source rule
+ # is less than the pass number for the rule.
+ # The purpose of this is when the source file list
+ # is expected to be inaccurate, because the source
+ # files are hard to determine. Typical needs are
+ # for rules applied to dvi and xdv files, when
+ # graphics files are involved. Their names are coded
+ # inside the dvi/xdv file, but not the contents.
+ # It would need parsing of the contents of the file
+ # to determine the actual source files.
+ # An implication of using a source_rule is that this
+ # rule passes files to the current rule and that the
+ # current rule can be considered out-of-date whenever
+ # the source_rule has been run. Effectively these
+ # files are unconditionallyconsidered changed when
+ # the source_rule runs.
+
+%fdb_current = (); # Hash of information for all files used.
+ # It maps filename to a reference to an array
+ # (time, size, md5_checksum).
+@nofile = (0,-1,0); # What we use for initializing a new entry in fdb
+ # or flagging non-existent file.
+
+# The following provide information about the structure of the network of rules
+# and files. They are set by the routine rdb_set_rule_net
+%from_rules = (); # Used to optimize test for whether a file is generated.
+ # This maps files to rules that generate them. (Files
+ # anywhere in %$PHdest.)
+%from_rules_main = (); # Used to optimize test for whether a file is generated.
+ # This maps files to rules that generate them as the
+ # MAIN output. (I.e., file $$Pdest only.)
+# Classification of rules, for determining order of application
+%current_primaries = (); # Keys are primary rules (latex, etc) that are currently in use.
+@pre_primary = (); # Array of rules that are thought of as pre-primary
+@post_primary = (); # Array of rules that are thought of as post-primary
+@unusual_one_time = (); # Array of rules that are special cases of one-time rules.
+ # Currently not used.
+
+
+# User's home directory
+$HOME = '';
+if (exists $ENV{'HOME'} ) {
+ $HOME = $ENV{'HOME'};
+}
+elsif (exists $ENV{'USERPROFILE'} ) {
+ $HOME = $ENV{'USERPROFILE'};
+}
+# XDG configuration home
+$XDG_CONFIG_HOME = '';
+if (exists $ENV{'XDG_CONFIG_HOME'} ) {
+ $XDG_CONFIG_HOME = $ENV{'XDG_CONFIG_HOME'};
+}
+elsif ($HOME ne '') {
+ if ( -d "$HOME/.config") {
+ $XDG_CONFIG_HOME = "$HOME/.config";
+ }
+}
+
+
+#==================================================
+
+# Options that are to be obeyed before rc files are read:
+
+foreach $_ ( @ARGV )
+{
+ if (/^-{1,2}norc$/ ) {
+ $auto_rc_use = 0;
+ }
+}
+
+#==================================================
+## Read rc files with this subroutine
+
+sub read_first_rc_file_in_list {
+ foreach my $rc_file ( @_ ) {
+ #print "===Testing for rc file \"$rc_file\" ...\n";
+ if ( -d $rc_file ) {
+ warn "$My_name: I have found a DIRECTORY named \"$rc_file\".\n",
+ " Have you perhaps misunderstood latexmk's documentation?\n",
+ " This name is normally used for a latexmk configuration (rc) file,\n",
+ " and in that case it should be a regular text file, not a directory.\n";
+ }
+ elsif ( -e $rc_file ) {
+ #print "===Reading rc file \"$rc_file\" ...\n";
+ process_rc_file( $rc_file );
+ return;
+ }
+ }
+}
+
+# Note that each rc file may unset $auto_rc_use to
+# prevent lower-level rc files from being read.
+# So test on $auto_rc_use in each case.
+if ( $auto_rc_use ) {
+ # System rc file:
+ if (exists $ENV{LATEXMKRCSYS} ) {
+ push @rc_system_files, $ENV{LATEXMKRCSYS};
+ if ( !-e $ENV{LATEXMKRCSYS} ) {
+ warn "$My_name: you've specified a system rc file `$ENV{LATEXMKRCSYS}`\n",
+ " in environment variable LATEXMKRCSYS, but the file doesn't exist.\n",
+ " I won't read any system rc file.\n";
+ }
+ else {
+ process_rc_file( $ENV{LATEXMKRCSYS} );
+ }
+ }
+ else {
+ read_first_rc_file_in_list( @rc_system_files );
+ }
+}
+if ( $auto_rc_use && ($HOME ne "" ) ) {
+ # User rc file:
+ @user_rc = ();
+ if ( $XDG_CONFIG_HOME ) {
+ push @user_rc, "$XDG_CONFIG_HOME/latexmk/latexmkrc";
+ }
+ # N.B. $HOME equals "" if latexmk couldn't determine a home directory.
+ # In that case, we shouldn't look for an rc file there.
+ if ( $HOME ) {
+ push @user_rc, "$HOME/.latexmkrc";
+ }
+ read_first_rc_file_in_list( @user_rc );
+}
+if ( $auto_rc_use ) {
+ # Rc file in current directory:
+ read_first_rc_file_in_list( "latexmkrc", ".latexmkrc" );
+}
+
+## Process command line args.
+@command_line_file_list = ();
+$bad_options = 0;
+
+while ($_ = $ARGV[0])
+{
+ # Make -- and - equivalent at beginning of option,
+ # but save original for possible use in (pdf)latex command line
+ $original = $_;
+ s/^--/-/;
+ shift;
+ if ( /^-aux-directory=(.*)$/ || /^-auxdir=(.*)$/ ) {
+ $aux_dir = $1;
+ }
+ elsif (/^-bibtex$/) { $bibtex_use = 2; }
+ elsif (/^-bibtex-$/) { $bibtex_use = 0; }
+ elsif (/^-nobibtex$/) { $bibtex_use = 0; }
+ elsif (/^-bibtex-cond$/) { $bibtex_use = 1; }
+ elsif (/^-bibtex-cond1$/) { $bibtex_use = 1.5; }
+ elsif (/^-c$/) { $cleanup_mode = 2; $cleanup_fdb = 1; $cleanup_only = 1; }
+ elsif (/^-C$/ || /^-CA$/ ) { $cleanup_mode = 1; $cleanup_fdb = 1; $cleanup_only = 1; }
+ elsif (/^-CF$/) { $cleanup_fdb = 1; }
+ elsif (/^-cd$/) { $do_cd = 1; }
+ elsif (/^-cd-$/) { $do_cd = 0; }
+ elsif (/^-commands$/) { &print_commands; exit; }
+ elsif (/^-d$/) { $banner = 1; }
+ elsif (/^-dependents$/ || /^-deps$/ || /^-M$/ ) { $dependents_list = 1; }
+ elsif (/^-nodependents$/ || /^-dependents-$/ || /^-deps-$/) { $dependents_list = 0; }
+ elsif (/^-deps-out=(.*)$/) {
+ $deps_file = $1;
+ $dependents_list = 1;
+ }
+ elsif (/^-diagnostics/) { $diagnostics = 1; }
+ elsif (/^-dvi$/) { $dvi_mode = 1; }
+ elsif (/^-dvi-$/) { $dvi_mode = 0; }
+ elsif (/^-f$/) { $force_mode = 1; }
+ elsif (/^-f-$/) { $force_mode = 0; }
+ elsif (/^-g$/) { $go_mode = 1; }
+ elsif (/^-g-$/) { $go_mode = 0; }
+ elsif (/^-gg$/) {
+ $go_mode = 2; $cleanup_mode = 1; $cleanup_fdb = 1; $cleanup_only = 0;
+ }
+ elsif ( /^-h$/ || /^-help$/ ) { &print_help; exit;}
+ elsif (/^-jobname=(.*)$/) {
+ $jobname = $1;
+ }
+ elsif (/^-l$/) { $landscape_mode = 1; }
+ elsif (/^-l-$/) { $landscape_mode = 0; }
+ elsif (/^-latex=(.*)$/) {
+ $latex = $1;
+ }
+ elsif (/^-latexoption=(.*)$/) {
+ push @extra_latex_options, $1;
+ push @extra_pdflatex_options, $1;
+ push @extra_lualatex_options, $1;
+ push @extra_xelatex_options, $1;
+ }
+ elsif ( /^-logfilewarninglist$/ || /^-logfilewarnings$/ )
+ { $silence_logfile_warnings = 0; }
+ elsif ( /^-logfilewarninglist-$/ || /^-logfilewarnings-$/ )
+ { $silence_logfile_warnings = 1; }
+# See above for -M
+ elsif (/^-MF$/) {
+ if ( $ARGV[0] eq '' ) {
+ &exit_help( "No file name specified after -MF switch");
+ }
+ $deps_file = $ARGV[0];
+ shift;
+ }
+ elsif ( /^-MP$/ ) { $dependents_phony = 1; }
+ elsif (/^-new-viewer$/) {
+ $new_viewer_always = 1;
+ }
+ elsif (/^-new-viewer-$/) {
+ $new_viewer_always = 0;
+ }
+ elsif (/^-norc$/ ) {
+ $auto_rc_use = 0;
+ # N.B. This has already been obeyed.
+ }
+ elsif ( /^-output-directory=(.*)$/ ||/^-outdir=(.*)$/ ) {
+ $out_dir = $1;
+ }
+ elsif (/^-p$/) { $printout_mode = 1;
+ $preview_continuous_mode = 0; # to avoid conflicts
+ $preview_mode = 0;
+ }
+ elsif (/^-p-$/) { $printout_mode = 0; }
+ elsif (/^-pdf$/) { $pdf_mode = 1; }
+ elsif (/^-pdf-$/) { $pdf_mode = 0; }
+ elsif (/^-pdfdvi$/){ $pdf_mode = 3; }
+ elsif (/^-pdflua$/){ $pdf_mode = 4; }
+ elsif (/^-pdfps$/) { $pdf_mode = 2; }
+ elsif (/^-pdfxe$/) { $pdf_mode = 5; }
+# elsif (/^-pdflatex$/) {
+# $pdflatex = "pdflatex %O %S";
+# $pdf_mode = 1;
+# $dvi_mode = $postscript_mode = 0;
+# }
+ elsif (/^-pdflatex=(.*)$/) {
+ $pdflatex = $1;
+ }
+ elsif (/^-pdflualatex=(.*)$/) {
+ $lualatex = $1;
+ }
+ elsif (/^-pdfxelatex=(.*)$/) {
+ $xelatex = $1;
+ }
+ elsif (/^-pretex=(.*)$/) {
+ $pre_tex_code = $1;
+ }
+ elsif (/^-print=(.*)$/) {
+ $value = $1;
+ if ( $value =~ /^dvi$|^ps$|^pdf$|^auto$/ ) {
+ $print_type = $value;
+ $printout_mode = 1;
+ }
+ else {
+ &exit_help("$My_name: unknown print type '$value' in option '$_'");
+ }
+ }
+ elsif (/^-ps$/) { $postscript_mode = 1; }
+ elsif (/^-ps-$/) { $postscript_mode = 0; }
+ elsif (/^-pv$/) { $preview_mode = 1;
+ $preview_continuous_mode = 0; # to avoid conflicts
+ $printout_mode = 0;
+ }
+ elsif (/^-pv-$/) { $preview_mode = 0; }
+ elsif (/^-pvc$/) { $preview_continuous_mode = 1;
+ $force_mode = 0; # So that errors do not cause loops
+ $preview_mode = 0; # to avoid conflicts
+ $printout_mode = 0;
+ }
+ elsif (/^-pvc-$/) { $preview_continuous_mode = 0; }
+ elsif (/^-pvctimeout$/) { $pvc_timeout = 1; }
+ elsif (/^-pvctimeout-$/) { $pvc_timeout = 0; }
+ elsif (/^-pvctimeoutmins=(.*)$/) { $pvc_timeout_mins = $1; }
+ elsif (/^-recorder$/ ){ $recorder = 1; }
+ elsif (/^-recorder-$/ ){ $recorder = 0; }
+ elsif (/^-rules$/ ) { $rules_list = 1; }
+ elsif (/^-norules$/ || /^-rules-$/ ) { $rules_list = 0; }
+ elsif (/^-showextraoptions$/) {
+ print "List of extra latex and pdflatex options recognized by $my_name.\n",
+ "These are passed as is to (pdf)latex. They may not be recognized by\n",
+ "particular versions of (pdf)latex. This list is a combination of those\n",
+ "for TeXLive and MikTeX.\n",
+ "\n",
+ "Note that in addition to the options in this list, there are several\n",
+ "options known to the (pdf)latex programs that are also recognized by\n",
+ "latexmk and trigger special behavior by latexmk. Since these options\n",
+ "appear in the main list given by running 'latexmk --help', they do not\n",
+ "appear in the following list\n",
+ "NOTE ALSO: Not all of these options are supported by all versions of (pdf)latex.\n",
+ "\n";
+ foreach $option ( sort( keys %allowed_latex_options, keys %allowed_latex_options_with_arg ) ) {
+ if (exists $allowed_latex_options{$option} ) { print " $allowed_latex_options{$option}\n"; }
+ if (exists $allowed_latex_options_with_arg{$option} ) { print " $allowed_latex_options_with_arg{$option}\n"; }
+ }
+ exit;
+ }
+ elsif (/^-silent$/ || /^-quiet$/ ){ $silent = 1; }
+ elsif (/^-stdtexcmds$/) { &std_tex_cmds; }
+ elsif (/^-time$/) { $show_time = 1;}
+ elsif (/^-time-$/) { $show_time = 0;}
+ elsif (/^-use-make$/) { $use_make_for_missing_files = 1; }
+ elsif (/^-use-make-$/) { $use_make_for_missing_files = 0; }
+ elsif (/^-usepretex$/) { &alt_tex_cmds; }
+ elsif (/^-usepretex=(.*)$/) {
+ &alt_tex_cmds;
+ $pre_tex_code = $1;
+ }
+ elsif (/^-v$/ || /^-version$/) {
+ print "\n$version_details. Version $version_num\n";
+ exit;
+ }
+ elsif (/^-verbose$/) { $silent = 0; }
+ elsif (/^-view=default$/) { $view = "default";}
+ elsif (/^-view=dvi$/) { $view = "dvi";}
+ elsif (/^-view=none$/) { $view = "none";}
+ elsif (/^-view=ps$/) { $view = "ps";}
+ elsif (/^-view=pdf$/) { $view = "pdf"; }
+ elsif (/^-Werror$/){ $warnings_as_errors = 1; }
+ elsif (/^-lualatex$/) {
+ $pdf_mode = 4;
+ $dvi_mode = $postscript_mode = 0;
+ }
+ elsif (/^-xelatex$/) {
+ $pdf_mode = 5;
+ $dvi_mode = $postscript_mode = 0;
+ }
+ elsif (/^-e$/) {
+ if ( $#ARGV < 0 ) {
+ &exit_help( "No code to execute specified after -e switch");
+ }
+ execute_code_string( $ARGV[0] );
+ shift;
+ }
+ elsif (/^-r$/) {
+ if ( $ARGV[0] eq '' ) {
+ &exit_help( "No RC file specified after -r switch");
+ }
+ if ( -e $ARGV[0] ) {
+ process_rc_file( $ARGV[0] );
+ }
+ else {
+ die "$My_name: RC file [$ARGV[0]] does not exist\n";
+ }
+ shift;
+ }
+ elsif (/^-bm$/) {
+ if ( $ARGV[0] eq '' ) {
+ &exit_help( "No message specified after -bm switch");
+ }
+ $banner = 1; $banner_message = $ARGV[0];
+ shift;
+ }
+ elsif (/^-bi$/) {
+ if ( $ARGV[0] eq '' ) {
+ &exit_help( "No intensity specified after -bi switch");
+ }
+ $banner_intensity = $ARGV[0];
+ shift;
+ }
+ elsif (/^-bs$/) {
+ if ( $ARGV[0] eq '' ) {
+ &exit_help( "No scale specified after -bs switch");
+ }
+ $banner_scale = $ARGV[0];
+ shift;
+ }
+ elsif (/^-dF$/) {
+ if ( $ARGV[0] eq '' ) {
+ &exit_help( "No dvi filter specified after -dF switch");
+ }
+ $dvi_filter = $ARGV[0];
+ shift;
+ }
+ elsif (/^-pF$/) {
+ if ( $ARGV[0] eq '' ) {
+ &exit_help( "No ps filter specified after -pF switch");
+ }
+ $ps_filter = $ARGV[0];
+ shift;
+ }
+ elsif ( ( exists( $allowed_latex_options{$_} ) )
+ || ( /^(-.+)=/ && exists( $allowed_latex_options_with_arg{$1} ) )
+ )
+ {
+ push @extra_latex_options, $original;
+ push @extra_pdflatex_options, $original;
+ push @extra_lualatex_options, $original;
+ push @extra_xelatex_options, $original;
+ }
+ elsif (/^-/) {
+ warn "$My_name: $_ bad option\n";
+ $bad_options++;
+ }
+ else {
+ push @command_line_file_list, $_ ;
+ }
+}
+
+if ( $bad_options > 0 ) {
+ &exit_help( "Bad options specified" );
+}
+
+warn "$My_name: This is $version_details, version: $version_num.\n",
+ unless $silent;
+
+
+if ( ($out_dir ne '') && ($aux_dir eq '') ){
+ $aux_dir = $out_dir;
+}
+
+# Save original values for use in diagnositics.
+# We may change $aux_dir and $out_dir after a detection
+# of results of misconfiguration.
+$aux_dir_requested = $aux_dir;
+$out_dir_requested = $out_dir;
+# The following reports results of diagnostics on location of .log file
+# after the first run of a latex engine, when actually used aux_dir
+# may not be the expected one, due to a configuration error.
+# Values: -1 uninitialized (before first run)
+# 0 log file not found;
+# 1 log file in aux_dir;
+# 2 log file **not** in aux_dir but in out_dir;
+# 3 log file **not** in aux_dir or out_dir, but in cwd.
+$where_log = -1;
+
+&set_dirs_etc;
+
+if ($bibtex_use > 1) {
+ push @generated_exts, 'bbl';
+}
+
+# For backward compatibility, convert $texfile_search to @default_files
+# Since $texfile_search is initialized to "", a nonzero value indicates
+# that an initialization file has set it.
+if ( $texfile_search ne "" ) {
+ @default_files = split /\s+/, "*.tex $texfile_search";
+}
+
+#Glob the filenames command line if the script was not invoked under a
+# UNIX-like environment.
+# Cases: (1) MS/MSwin native Glob
+# (OS detected as MSWin32)
+# (2) MS/MSwin cygwin Glob [because we do not know whether
+# the cmd interpreter is UNIXy (and does glob) or is
+# native MS-Win (and does not glob).]
+# (OS detected as cygwin)
+# (3) UNIX Don't glob (cmd interpreter does it)
+# (Currently, I assume this is everything else)
+if ( ($^O eq "MSWin32") || ($^O eq "cygwin") ) {
+ # Preserve ordering of files
+ @file_list = glob_list1(@command_line_file_list);
+#print "A1:File list:\n";
+#for ($i = 0; $i <= $#file_list; $i++ ) { print "$i: '$file_list[$i]'\n"; }
+}
+else {
+ @file_list = @command_line_file_list;
+}
+@file_list = uniq1( @file_list );
+
+
+# Check we haven't selected mutually exclusive modes.
+# Note that -c overrides all other options, but doesn't cause
+# an error if they are selected.
+if (($printout_mode && ( $preview_mode || $preview_continuous_mode ))
+ || ( $preview_mode && $preview_continuous_mode ))
+{
+ # Each of the options -p, -pv, -pvc turns the other off.
+ # So the only reason to arrive here is an incorrect inititalization
+ # file, or a bug.
+ &exit_help( "Conflicting options (print, preview, preview_continuous) selected");
+}
+
+if ( @command_line_file_list ) {
+ # At least one file specified on command line (before possible globbing).
+ if ( !@file_list ) {
+ &exit_help( "Wildcards in file names didn't match any files");
+ }
+}
+else {
+ # No files specified on command line, try and find some
+ # Evaluate in order specified. The user may have some special
+ # for wanting processing in a particular order, especially
+ # if there are no wild cards.
+ # Preserve ordering of files
+ my @file_list1 = uniq1( glob_list1(@default_files) );
+ my @excluded_file_list = uniq1( glob_list1(@default_excluded_files) );
+ # Make hash of excluded files, for easy checking:
+ my %excl = ();
+ foreach my $file (@excluded_file_list) {
+ $excl{$file} = '';
+ }
+ foreach my $file (@file_list1) {
+ push( @file_list, $file) unless ( exists $excl{$file} );
+ }
+ if ( !@file_list ) {
+ &exit_help( "No file name specified, and I couldn't find any");
+ }
+}
+
+$num_files = $#file_list + 1;
+$num_specified = $#command_line_file_list + 1;
+
+#print "Command line file list:\n";
+#for ($i = 0; $i <= $#command_line_file_list; $i++ ) { print "$i: '$command_line_file_list[$i]'\n"; }
+#print "File list:\n";
+#for ($i = 0; $i <= $#file_list; $i++ ) { print "$i: '$file_list[$i]'\n"; }
+
+
+# If selected a preview-continuous mode, make sure exactly one filename was specified
+if ($preview_continuous_mode && ($num_files != 1) ) {
+ if ($num_specified > 1) {
+ &exit_help(
+ "Need to specify exactly one filename for ".
+ "preview-continuous mode\n".
+ " but $num_specified were specified"
+ );
+ }
+ elsif ($num_specified == 1) {
+ &exit_help(
+ "Need to specify exactly one filename for ".
+ "preview-continuous mode\n".
+ " but wildcarding produced $num_files files"
+ );
+ }
+ else {
+ &exit_help(
+ "Need to specify exactly one filename for ".
+ "preview-continuous mode.\n".
+ " Since none were specified on the command line, I looked for \n".
+ " files in '@default_files'.\n".
+ " But I found $num_files files, not 1."
+ );
+ }
+}
+
+# If selected jobname, can only apply that to one file:
+if ( ($jobname ne '') && ($jobname !~ /%A/) && ($num_files > 1) ) {
+ &exit_help(
+ "Need to specify at most one filename if ".
+ "jobname specified without a %A, \n".
+ " but $num_files were found (after defaults and wildcarding)."
+ );
+}
+if ( $jobname =~ /%[^A]/ ) {
+ &exit_help(
+ "Jobname '$jobname' contains placeholder other than %A."
+ );
+}
+
+# Normalize the commands, to have place-holders for source, dest etc:
+&fix_cmds;
+
+# Add common options
+add_option( $latex_default_switches, \$latex );
+add_option( $pdflatex_default_switches, \$pdflatex );
+add_option( $lualatex_default_switches, \$lualatex );
+add_option( $xelatex_default_switches, \$xelatex );
+
+foreach (@extra_latex_options) { add_option( $_, \$latex ); }
+foreach (@extra_pdflatex_options) { add_option( $_, \$pdflatex ); }
+foreach (@extra_lualatex_options) { add_option( $_, \$lualatex ); }
+foreach (@extra_xelatex_options) { add_option( $_, \$xelatex ); }
+
+
+# If landscape mode, change dvips processor, and the previewers:
+if ( $landscape_mode )
+{
+ $dvips = $dvips_landscape;
+ $dvi_previewer = $dvi_previewer_landscape;
+ $ps_previewer = $ps_previewer_landscape;
+}
+
+if ( $silent ) {
+ add_option( "$latex_silent_switch", \$latex );
+ add_option( "$pdflatex_silent_switch", \$pdflatex );
+ add_option( "$lualatex_silent_switch", \$lualatex );
+ add_option( "$xelatex_silent_switch", \$xelatex );
+ add_option( "$biber_silent_switch", \$biber );
+ add_option( "$bibtex_silent_switch", \$bibtex );
+ add_option( "$makeindex_silent_switch", \$makeindex );
+ add_option( "$dvipdf_silent_switch", \$dvipdf );
+ add_option( "$dvips_silent_switch", \$dvips );
+ add_option( "$xdvipdfmx_silent_switch", \$xdvipdfmx );
+}
+
+if ( $recorder ) {
+ add_option( "-recorder", \$latex, \$pdflatex, \$lualatex, \$xelatex );
+}
+
+# If the output and/or aux directories are specified, fix the (pdf)latex
+# commands to use them.
+# N.B. We'll ensure that the directories actually exist only after a
+# possible cd to the document directory, since the directories can be
+# relative to the document.
+
+if ( $out_dir ) {
+ add_option( "-output-directory=\"$out_dir\"",
+ \$latex, \$pdflatex, \$lualatex, \$xelatex );
+}
+if ( $aux_dir && ($aux_dir ne $out_dir) ) {
+ # N.B. If $aux_dir and $out_dir are the same, then the -output-directory
+ # option is sufficient, especially because the -aux-directory exists
+ # only in MiKTeX, not in TeXLive.
+ add_option( "-aux-directory=\"$aux_dir\"",
+ \$latex, \$pdflatex, \$lualatex, \$xelatex );
+}
+
+if ( $jobname ne '' ) {
+ # Since $jobname may include placeholder(s), put %R placeholder
+ # in option, and let %R be substituted by actual jobname at runtime.
+ add_option( "--jobname=%R", \$latex, \$lualatex, \$pdflatex, \$xelatex );
+}
+
+# Which kind of file do we preview?
+if ( $view eq "default" ) {
+ # If default viewer requested, use "highest" of dvi, ps and pdf
+ # that was requested by user.
+ # No explicit request means view dvi.
+ $view = "dvi";
+ if ( $postscript_mode ) { $view = "ps"; }
+ if ( $pdf_mode ) { $view = "pdf"; }
+}
+
+# Make sure we make the kind of file we want to view:
+if ($view eq 'dvi') { $dvi_mode = 1; }
+if ($view eq 'ps') { $postscript_mode = 1; }
+if ( ($view eq 'pdf') && ($pdf_mode == 0) ) {
+ $pdf_mode = 1;
+}
+
+# Make sure that we make something if all requests are turned off
+if ( ! ( $dvi_mode || $pdf_mode || $postscript_mode || $printout_mode) ) {
+ print "No specific requests made, so default to dvi by latex\n";
+ $dvi_mode = 1;
+}
+
+# Determine requests.
+if ( $banner ) { $postscript_mode = 1; }
+if ( $dvi_mode ) {
+ $current_primary = 'latex';
+ $requested_filetypes{'dvi'} = 1;
+ if ( length($dvi_filter) != 0 ) { $requested_filetypes{'dviF'} = 1; }
+}
+if ( $postscript_mode ) {
+ $current_primary = 'latex';
+ $requested_filetypes{'ps'} = 1;
+ if ( length($ps_filter) != 0 ) { $requested_filetypes{'psF'} = 1; }
+}
+
+if ($pdf_mode > 5) {
+ warn "$My_name: Non-allowed value of \$pdf_mode = $pdf_mode,",
+ " replaced by 1.\n";
+ $pdf_mode = 1;
+}
+if ( ($dvi_mode || $postscript_mode) && $pdf_mode ) {
+ my %disallowed = ();
+ foreach (1,4,5) { $disallowed{$_} = 1; }
+ if ($disallowed{$pdf_mode}) {
+ warn "$My_name: \$pdf_mode = $pdf_mode is incompatible with dvi and postscript modes\n",
+ " which are required by other requests.\n";
+ if ($postscript_mode) {$pdf_mode = 2;}
+ else { $pdf_mode = 3; }
+ warn " I replaced it by $pdf_mode.\n";
+ }
+}
+if ( $pdf_mode == 0 ) {
+ $pdf_method = '';
+}
+elsif ( $pdf_mode == 1 ) {
+ $requested_filetypes{'pdf'} = 1;
+ $pdf_method = 'pdflatex';
+}
+elsif ( $pdf_mode == 2 ) {
+ $requested_filetypes{'pdf'} = 1;
+ $pdf_method = 'ps2pdf';
+}
+elsif ( $pdf_mode == 3 ) {
+ $requested_filetypes{'pdf'} = 1;
+ $pdf_method = 'dvipdf';
+}
+elsif ( $pdf_mode == 4 ) {
+ $requested_filetypes{'pdf'} = 1;
+ $pdf_method = 'lualatex';
+}
+elsif ( $pdf_mode == 5 ) {
+ $requested_filetypes{'pdf'} = 1;
+ $pdf_method = 'xelatex';
+}
+
+if ($print_type eq 'auto') {
+ if ( $postscript_mode ) { $print_type = 'ps'; }
+ elsif ( $pdf_mode ) { $print_type = 'pdf'; }
+ elsif ( $dvi_mode ) { $print_type = 'dvi'; }
+ else { $print_type = 'none'; }
+}
+if ( $printout_mode ) {
+ $one_time{'print'} = 1;
+ if ($print_type eq 'none'){
+ warn "$My_name: You have requested printout, but \$print_type is set to 'none'\n";
+ }
+}
+if ( $preview_continuous_mode || $preview_mode ) { $one_time{'view'} = 1; }
+
+$can_switch = $allow_switch;
+if ( $dvi_mode || $postscript_mode
+ || ( $printout_mode && ($print_type eq 'ps') || ($print_type eq 'dvi') )
+ || ( ($preview_mode || $preview_continuous_mode) && ( ($view eq 'ps') || ($view eq 'dvi') ) )
+ ) {
+ # Automatic switching (e.g., pdf<->dvi o/p) requires pdf files to be
+ # the only destinations. So if ps or dvi files needed, we cannot
+ # allow switching. (There will then be an error condition if a TeX
+ # engine fails to produce the correct type of output file.)
+ warn "$My_name: Disallowing switch of output file as incompatible\n",
+ " with file requests.\n";
+ $can_switch = 0;
+}
+
+
+if ( $pdf_mode == 2 ) {
+ # We generate pdf from ps. Make sure we have the correct kind of ps.
+ add_option( "$dvips_pdf_switch", \$dvips );
+}
+
+# Restrict variables to allowed values:
+
+if ($filetime_causality_threshold < 0) {
+ warn "$My_name: Correcting negative value of \$filetime_causality_threshold to zero.\n";
+ $filetime_causality_threshold = 0;
+}
+
+# Note sleep has granularity of 1 second.
+# Sleep periods 0 < $sleep_time < 1 give zero delay,
+# which is probably not what the user intended.
+# Sleep periods less than zero give infinite delay
+if ( $sleep_time < 0 ) {
+ warn "$My_name: Correcting negative sleep_time to 1 sec.\n";
+ $sleep_time = 1;
+}
+elsif ( ($sleep_time < 1) && ( $sleep_time != 0 ) ) {
+ warn "$My_name: Correcting nonzero sleep_time of less than 1 sec to 1 sec.\n";
+ $sleep_time = 1;
+}
+elsif ( $sleep_time == 0 ) {
+ warn "$My_name: sleep_time was configured to zero.\n",
+ " Do you really want to do this? It will give 100% CPU usage.\n";
+}
+
+# Make convenient forms for lookup.
+# Extensions always have period.
+
+# Convert @generated_exts to a hash for ease of look up and deletion
+# Keep extension without period!
+%generated_exts_all = ();
+foreach (@generated_exts ) {
+ $generated_exts_all{$_} = 1;
+}
+
+$quell_uptodate_msgs = $silent;
+ # Whether to quell informational messages when files are uptodate
+ # Will turn off in -pvc mode
+
+$failure_count = 0;
+@failed_primaries = ();
+
+if ($deps_file eq '' ) {
+ # Standardize name used for stdout
+ $deps_file = '-';
+}
+
+# Since deps_file is global (common to all processed files), we must
+# delete it here when doing a clean up, and not in the FILE loop, where
+# per-file processing (including clean-up) is done
+if ( ($cleanup_mode > 0) && $dependents_list && ( $deps_file ne '-' ) ) {
+ unlink_or_move( $deps_file );
+}
+
+# In non-pvc mode, the dependency list is global to all processed TeX files,
+# so we open a single file here, and add items to it after processing
+# each file. But in -pvc mode, the dependency list should be written
+# after round of processing the single TeX file (as if each round were
+# a separate run of latexmk).
+# If we are cleaning up ($cleanup_mode != 0) AND NOT continuing to
+# make files (--gg option and $go_mode == 2), deps_file should not be
+# created.
+# I will use definedness of $deps_handle as flag for global deps file having
+# been opened and therefore being available to be written to after
+# compiling a file.
+$deps_handle = undef;
+if ( $dependents_list
+ && ! $preview_continuous_mode
+ && ( ($cleanup_mode == 0) || ($go_mode == 2) )
+ ) {
+ $deps_handle = new FileHandle "> $deps_file";
+ if (! $deps_handle ) {
+ die "Cannot open '$deps_file' for output of dependency information\n";
+ }
+}
+
+# Remove leading and trailing space in the following space-separated lists,
+# and collapse multiple spaces to one,
+# to avoid getting incorrect blank items when they are split.
+foreach ($clean_ext, $clean_full_ext) { s/^\s+//; s/\s+$//; s/\s+/ /g; }
+
+# Deal with illegal and problematic characters in filename:
+test_fix_texnames( @file_list );
+
+FILE:
+foreach $filename ( @file_list )
+{
+ # Global variables for making of current file:
+ $updated = 0;
+ $failure = 0; # Set nonzero to indicate failure at some point of
+ # a make. Use value as exit code if I exit.
+ $failure_msg = ''; # Indicate reason for failure
+
+ if ( $do_cd ) {
+ ($filename, $path) = fileparse( $filename );
+ warn "$My_name: Changing directory to '$path'\n"
+ if !$silent;
+ pushd( $path );
+ }
+ else {
+ $path = '';
+ }
+
+ # Ensure the output/auxiliary directories exist, if need be
+ if ( $out_dir ) {
+ if ( ! -e $out_dir ) {
+ warn "$My_name: making output directory '$out_dir'\n"
+ if ! $silent;
+ make_path $out_dir;
+ }
+ elsif ( ! -d $out_dir ) {
+ warn "$My_name: you requested output directory '$out_dir',\n",
+ " but an ordinary file of the same name exists, which will\n",
+ " probably give an error later\n";
+ }
+ }
+
+ if ( $aux_dir && ($aux_dir ne $out_dir) ) {
+ # N.B. If $aux_dir and $out_dir are the same, then the -output-directory
+ # option is sufficient, especially because the -aux-directory exists
+ # only in MiKTeX, not in TeXLive.
+ if ( ! -e $aux_dir ) {
+ warn "$My_name: making auxiliary directory '$aux_dir'\n"
+ if ! $silent;
+ make_path $aux_dir;
+ }
+ elsif ( ! -d $aux_dir ) {
+ warn "$My_name: you requested aux directory '$aux_dir',\n",
+ " but an ordinary file of the same name exists, which will\n",
+ " probably give an error later\n";
+ }
+ }
+
+ &set_names;
+ # For use under error conditions:
+ @default_includes = ($texfile_name, $aux_main);
+ # N.B. Do **not** apply local %rule_db here. It might appear appropriate,
+ # but %rule_db is needed in the continue block, which is not in the
+ # scope of a local declaration here.
+ &rdb_initialize_rules;
+
+ if ( $cleanup_mode > 0 ) {
+# ?? MAY NEED TO FIX THE FOLLOWING IF $aux_dir or $out_dir IS SET.
+ my %other_generated = ();
+ my @index_bibtex_generated = ();
+ my @aux_files = ();
+ my @missing_bib_files = ();
+ my $bibs_all_exist = 0;
+ my %final_output_files = ();
+ foreach (keys %small_cleanup_preserved_exts) {
+ $final_output_files{"$out_dir1$root_filename.$_"} = 1;
+ }
+ $have_fdb = 0;
+ if ( -e $fdb_name ) {
+ print "$My_name: Examining fdb file '$fdb_name' for rules ...\n"
+ if $diagnostics;
+ $have_fdb = ( 0 == rdb_read( $fdb_name ) );
+ }
+ if ( $have_fdb ) {
+ rdb_for_actives(
+ sub { # Find generated files at rule level
+ my ($base, $path, $ext) = fileparseA( $$Psource );
+ $base = $path.$base;
+ if ( $rule =~ /^makeindex/ ) {
+ push @index_bibtex_generated, $$Psource, $$Pdest, "$base.ilg";
+ }
+ elsif ( $rule =~ /^(bibtex|biber)/ ) {
+ push @index_bibtex_generated, $$Pdest, "$base.blg";
+ push @aux_files, $$Psource;
+ if ( $bibtex_use == 1.5) {
+ foreach ( keys %$PHsource ) {
+ if ( ( /\.bib$/ ) && (! -e $_) ) {
+ push @missing_bib_files, $_;
+ }
+ }
+ }
+ }
+ elsif ( exists $other_generated{$$Psource} ) {
+# print "=========== CHECKING: source file of rule '$rule', '$$Psource'\n",
+# " is a generated file.\n";
+ ## OLD with apparent bug:
+ #$other_generated{$$Pdest};
+ }
+ foreach my $key (keys %$PHdest) {
+ $other_generated{$key} = 1;
+ }
+ },
+ sub { # Find generated files at source file level
+ if ( $file =~ /\.aux$/ ) { push @aux_files, $file; }
+ }
+ );
+ if ($#missing_bib_files == -1) { $bibs_all_exist = 1; }
+ }
+ elsif ( -e $log_name ) {
+ # No fdb file, but log file exists, so do inferior job by parse_log
+ print "$My_name: Examining log file '$log_name' for generated files...\n"
+ if $diagnostics;
+ # Variables set by parse_log. Can I remove them?
+ local %generated_log = ();
+ local %dependents = (); # Maps files to status. Not used here.
+ local @bbl_files = (); # Not used here.
+ local %idx_files = (); # Maps idx_file to (ind_file, base). Not used here.
+ local %conversions = (); # (pdf)latex-performed conversions. Not used here.
+ # Maps output file created and read by (pdf)latex
+ # to source file of conversion.
+ local $primary_out = ''; # Actual output file (dvi or pdf). Not used here.
+ local $fls_file_analyzed = 0;
+ &parse_log;
+ %other_generated = %generated_log;
+ }
+ else {
+ print "$My_name: No fdb or log file, so clean up default set of files ...\n"
+ if $diagnostics;
+ }
+
+ if ( ($go_mode == 2) && !$silent ) {
+ warn "$My_name: Removing all generated files\n" unless $silent;
+ }
+ my $keep_bbl = 1;
+ if ( ($bibtex_use > 1.6)
+ ||
+ ( ($bibtex_use == 1.5) && ($bibs_all_exist) )
+ ) {
+ $keep_bbl = 0;
+ }
+ if ($keep_bbl) {
+ delete $generated_exts_all{'bbl'};
+ }
+ # Convert two arrays to hashes:
+ my %index_bibtex_generated = ();
+ my %aux_files = ();
+ my %aux_files_to_save = ();
+ foreach (@index_bibtex_generated) {
+ $index_bibtex_generated{$_} = 1
+ unless ( /\.bbl$/ && ($keep_bbl) );
+ delete( $other_generated{$_} );
+ }
+ foreach (@aux_files) {
+ if (exists $other_generated{$_} ) {
+ $aux_files{$_} = 1;
+ }
+ else {
+ $aux_files_to_save{$_} = 1;
+ }
+ }
+
+ foreach (keys %final_output_files) { delete $other_generated{$_}; }
+
+ if ($diagnostics) {
+ show_array( "For deletion, the following were determined from fdb file or log file:\n"
+ ." Generated (from makeindex and bibtex):",
+ keys %index_bibtex_generated );
+ show_array( " Aux files:", keys %aux_files );
+ show_array( " Other generated files:\n"
+ ." (only deleted if \$cleanup_includes_generated is set): ",
+ keys %other_generated );
+ show_array( " Yet other generated files are specified by patterns:\n".
+ " Explicit pattern with %R or root-filename.extension:",
+ keys %generated_exts_all );
+ show_array( " Aux files to SAVE and not delete:", keys %aux_files_to_save );
+ }
+
+ my @clean_args = ( 'blg', 'ilg', 'log', 'aux.bak', 'idx.bak',
+ split('\s+',$clean_ext), keys %generated_exts_all );
+ cleanup1( $aux_dir1, @clean_args );
+ if ( $out_dir1 ne $aux_dir1 ) { cleanup1( $out_dir1, @clean_args ); }
+ if ( $cleanup_mode == 1 ) {
+ my @clean_args = ( keys %small_cleanup_preserved_exts, split('\s+', $clean_full_ext) );
+ cleanup1( $aux_dir1, @clean_args );
+ if ( $out_dir1 ne $aux_dir1 ) { cleanup1( $out_dir1, @clean_args ); }
+ }
+ unlink_or_move( 'texput.log', "texput.aux", "missfont.log",
+ keys %index_bibtex_generated,
+ keys %aux_files );
+ if ($cleanup_includes_generated) {
+ unlink_or_move( keys %other_generated );
+ }
+ if ( $cleanup_includes_cusdep_generated) {
+ &cleanup_cusdep_generated;
+ }
+ }
+ if ($cleanup_fdb) {
+ unlink_or_move( $fdb_name );
+ # If the fdb file exists, it will have been read, and therefore changed
+ # rule database. But deleting the fdb file implies we also want
+ # a virgin rule database, so we must reset it:
+ &rdb_initialize_rules;
+ }
+ if ($cleanup_only) { next FILE; }
+
+ if ( $diagnostics ) {
+ print "$My_name: Rules after start up for '$texfile_name'\n";
+ rdb_show();
+ }
+
+ $have_fdb = 0;
+ if (! -e $aux_main ) {
+ # No aux file => set up trivial aux file
+ # and corresponding fdb_file. Arrange them to provoke one run
+ # as minimum, but no more if actual aux file is trivial.
+ # (Useful on big files without cross references.)
+ # If aux file doesn't exist, then any fdb file is surely
+ # wrong.
+ # Previously, I had condition for this as being both aux and
+ # fdb files failing to exist. But it's not obvious what to
+ # do if aux exists and fdb doesn't. So I won't do anything.
+ &set_trivial_aux_fdb;
+ }
+
+ if ( -e $fdb_name ) {
+ $rdb_errors = rdb_read( $fdb_name );
+ $have_fdb = ($rdb_errors == 0);
+ }
+ if (!$have_fdb) {
+ # We didn't get a valid set of data on files used in
+ # previous run. So use filetime criterion for make
+ # instead of change from previous run, until we have
+ # done our own make.
+ rdb_recurse( [keys %possible_primaries],
+ sub{ if ( $$Ptest_kind == 1 ) { $$Ptest_kind = 3;} }
+ );
+ if ( -e $log_name ) {
+ rdb_for_some( [keys %possible_primaries], \&rdb_set_latex_deps );
+ }
+ }
+ foreach $rule ( &rdb_accessible ) {
+ # For all source files of all accessible rules,
+ # if the file data are not already set (e.g., from fdb_latexmk
+ # file, set them from disk.
+ rdb_one_rule ($rule, undef,
+ sub{ if ( $$Ptime == 0) { &rdb_update1; } }
+ );
+ }
+
+ if ($go_mode) {
+ # Force everything to be remade.
+ rdb_recurse( [ &rdb_target_array], sub{$$Pout_of_date=1;} );
+ }
+
+
+ if ( $diagnostics ) {
+ print "$My_name: Rules after initialization\n";
+ rdb_show();
+ }
+
+ #************************************************************
+
+ if ( $preview_continuous_mode ) {
+ &make_preview_continuous;
+ next FILE;
+ }
+
+
+## Handling of failures:
+## Variable $failure is set to indicate a failure, with information
+## put in $failure_msg.
+## These variables should be set to 0 and '' at any point at which it
+## should be assumed that no failures have occurred.
+## When after a routine is called it is found that $failure is set, then
+## processing should normally be aborted, e.g., by return.
+## Then there is a cascade of returns back to the outermost level whose
+## responsibility is to handle the error.
+## Exception: An outer level routine may reset $failure and $failure_msg
+## after initial processing, when the error condition may get
+## ameliorated later.
+ #Initialize failure flags now.
+ $failure = 0;
+ $failure_msg = '';
+ $failure = &rdb_make;
+ if ( ( $failure <= 0 ) || $force_mode ) {
+ rdb_for_some( [keys %one_time], \&rdb_run1 );
+ }
+ if ($#primary_warning_summary > -1) {
+ # N.B. $mult_defined, $bad_reference, $bad_character, $bad_citation also available here.
+ if ($warnings_as_errors) {
+ $failure = 1;
+ $failure_msg = "Warning(s) from latex (or c.) for '$filename'; treated as error";
+ }
+ }
+ if ($failure > 0) { next FILE; }
+} # end FILE
+continue {
+ if ($deps_handle) { deps_list($deps_handle); }
+ # If requested, print the list of rules. But don't do this in -pvc
+ # mode, since the rules list has already been printed.
+ if ($rules_list && ! $preview_continuous_mode) { rdb_list(); }
+ # Handle any errors
+ $error_message_count = rdb_show_rule_errors();
+ if ( ($error_message_count == 0) || ($failure > 0) ) {
+ if ( $failure_msg ) {
+ #Remove trailing space
+ $failure_msg =~ s/\s*$//;
+ warn "----------------------\n";
+ warn "This message may duplicate earlier message.\n";
+ warn "$My_name: Failure in processing file '$filename':\n",
+ " $failure_msg\n";
+ warn "----------------------\n";
+ $failure = 1;
+ }
+ }
+ if ( ($failure > 0) || ($error_message_count > 0) ) {
+ $failure_count ++;
+ push @failed_primaries, $filename;
+ }
+ &ifcd_popd;
+}
+close($deps_handle) if ( $deps_handle );
+
+if ($show_time) { show_timing();}
+
+sub show_timing {
+ my $processing_time = processing_time() - $processing_time1;
+ print @timings, "Accumulated processing time = $processing_time\n";
+ @timings = ();
+ $processing_time1 = processing_time();
+}
+
+# If we get here without going through the continue section:
+if ( $do_cd && ($#dir_stack > -1) ) {
+ # Just in case we did an abnormal exit from the loop
+ warn "$My_name: Potential bug: dir_stack not yet unwound, undoing all directory changes now\n";
+ &finish_dir_stack;
+}
+
+if ($failure_count > 0) {
+ if ( $#file_list > 0 ) {
+ # Error occured, but multiple files were processed, so
+ # user may not have seen all the error messages
+ warn "\n------------\n";
+ show_array(
+ "$My_name: Some operations failed, for the following tex file(s)",
+ @failed_primaries);
+ }
+ if ( !$force_mode ) {
+ warn "$My_name: Use the -f option to force complete processing,\n",
+ " unless error was exceeding maximum runs, or warnings treated as errors.\n";
+ }
+ exit 12;
+}
+
+if ( $where_log == 2 ) {
+ warn "$My_name: You requested aux_dir '$aux_dir_requested',\n".
+ " but '$aux_dir' was used by the (pdf)latex engine.\n".
+ " That indicates a configuration error.\n";
+ if ( ($tex_distribution !~ /^MiKTeX/i) && ($aux_dir_requested ne $out_dir_requested) ) {
+ warn " Probably you set different aux and out directories,\n".
+ " but that is not supported by your TeX distribution.\n".
+ " The only current distribution supporting this is MiKTeX.\n";
+ }
+}
+
+
+
+# end MAIN PROGRAM
+#############################################################
+#############################################################
+
+sub set_tex_cmds {
+ # Usage, e.g., set_tex_cmds( '%O %S' )
+ my $args = $_[0];
+ foreach my $cmd ('latex', 'lualatex', 'pdflatex', 'xelatex' ) {
+ ${$cmd} = "$cmd $args";
+ }
+ # N.B. See setting of $latex_default_switches, ...,
+ # $xelatex_default_switches, etc, for any special options needed.
+}
+
+sub std_tex_cmds { set_tex_cmds( '%O %S' ); }
+
+sub alt_tex_cmds { set_tex_cmds( '%O %P' ); }
+
+#========================
+
+sub test_fix_texnames {
+ my $illegal_char = 0;
+ my $unbalanced_quote = 0;
+ my $balanced_quote = 0;
+ foreach (@_) {
+ if ( $^O eq "MSWin32" ) {
+ # On MS-Win, change directory separator '\' to '/', as needed
+ # by the TeX engines, for which '\' introduces a macro name.
+ # Remember that '/' is a valid directory separator in MS-Win.
+ s[\\][/]g;
+ }
+ if ($do_cd) {
+ my ($filename, $path) = fileparse( $_ );
+ if ($filename =~ /[\Q$illegal_in_texname\E]/ ) {
+ $illegal_char++;
+ warn "$My_name: Filename '$filename' contains character not allowed for TeX file.\n";
+ }
+ if ($filename =~ /^&/) {
+ $illegal_char++;
+ warn "$My_name: Filename '$filename' contains initial '&', which is\n",
+ " not allowed for TeX file.\n";
+ }
+ }
+ else {
+ if ( /[\Q$illegal_in_texname\E]/ ) {
+ $illegal_char++;
+ warn "$My_name: Filename '$_' contains character not allowed for TeX file.\n";
+ }
+ if (/^&/ ) {
+ $illegal_char++;
+ warn "$My_name: Filename '$_' contains initial '&', which is not allowed\n",
+ " for TeX file.\n";
+ }
+ }
+ my $count_q = ($_ =~ tr/\"//);
+ if ( ($count_q % 2) != 0 ) {
+ warn "$My_name: Filename '$_' contains unbalanced quotes, not allowed.\n";
+ $unbalanced_quote++;
+ }
+ elsif ( $count_q > 0 ) {
+ warn "$My_name: Removed (balanced quotes) from filename '$_',\n";
+ s/\"//g;
+ warn " and obtained '$_'.\n";
+ $balanced_quote++;
+ }
+ }
+ if ($illegal_char || $unbalanced_quote) {
+ die "$My_name: Stopping because of bad filename(s).\n";
+ }
+}
+
+#############################################################
+
+sub ensure_path {
+ # Usage: ensure_path( $var, values ...)
+ # $ENV{$var} is an environment variable (e.g. $ENV{TEXINPUTS}.
+ # Ensure the values are in it, prepending them if not, and
+ # creating the environment variable if it doesn't already exist.
+ my $var = shift;
+ my %cmpts = ();
+ if ( exists $ENV{$var} ) {
+ foreach ( split $search_path_separator, $ENV{$var} ) {
+ if ($_ ne '') { $cmpts{$_} = 1; }
+ }
+ }
+ foreach (@_) {
+ next if ( ($_ eq '') || (exists $cmpts{$_}) );
+ if (exists $ENV{$var}) {
+ $ENV{$var} = $_ . $search_path_separator . $ENV{$var};
+ }
+ else {
+ $ENV{$var} = $_ . $search_path_separator;
+ }
+ }
+}
+
+#############################################################
+
+sub set_dirs_etc {
+ # Normalize versions terminating in directory/path separator
+ # and versions referring to current directory
+ # These actions in a subroutine so they can be used elsewhere.
+ $out_dir1 = $out_dir;
+ $aux_dir1 = $aux_dir;
+ foreach ( $aux_dir1, $out_dir1 ) {
+ if ( ($_ ne '') && ! m([\\/\:]$) ) {
+ $_ .= '/';
+ }
+ while ( s[^\.\/][] ) {}
+ }
+ if ($aux_dir) {
+ # Ensure $aux_dir is in BIBINPUTS and TEXINPUTS search paths.
+ # TEXINPUTS is used by dvips for files generated by mpost.
+ # For BIBINPUTS,
+ # at least one widely package (revtex4-1) generates a bib file
+ # (which is used in revtex4-1 for putting footnotes in the reference
+ # list), and bibtex must be run to use it. But latexmk needs to
+ # determine the existence of the bib file by use of kpsewhich, otherwise
+ # there is an error. So cope with this situation (and any analogous
+ # cases by adding the aux_dir to the relevant path search environment
+ # variables. BIBINPUTS seems to be the only one currently affected.
+ foreach ( 'BIBINPUTS', 'TEXINPUTS' ) {
+ ensure_path( $_, $aux_dir );
+ }
+ }
+}
+
+#############################################################
+
+sub fix_cmds {
+ # If commands do not have placeholders for %S etc, put them in
+ foreach ($latex, $lualatex, $pdflatex, $xelatex, $lpr, $lpr_dvi, $lpr_pdf,
+ $pdf_previewer, $ps_previewer, $ps_previewer_landscape,
+ $dvi_previewer, $dvi_previewer_landscape,
+ $kpsewhich
+ ) {
+ # Source only
+ if ( $_ && ! /%/ ) { $_ .= " %O %S"; }
+ }
+ foreach ($pdf_previewer, $ps_previewer, $ps_previewer_landscape,
+ $dvi_previewer, $dvi_previewer_landscape,
+ ) {
+ # Run previewers detached
+ if ( $_ && ! /^(nostart|NONE|internal) / ) {
+ $_ = "start $_";
+ }
+ }
+ foreach ($biber, $bibtex) {
+ # Base only
+ if ( $_ && ! /%/ ) { $_ .= " %O %B"; }
+ }
+ foreach ($dvipdf, $ps2pdf) {
+ # Source and dest without flag for destination
+ if ( $_ && ! /%/ ) { $_ .= " %O %S %D"; }
+ }
+ foreach ($dvips, $makeindex) {
+ # Source and dest with -o dest before source
+ if ( $_ && ! /%/ ) { $_ .= " %O -o %D %S"; }
+ }
+ foreach ($dvi_filter, $ps_filter) {
+ # Source and dest, but as filters
+ if ( $_ && ! /%/ ) { $_ .= " %O <%S >%D"; }
+ }
+} #END fix_cmds
+
+#############################################################
+
+sub add_option {
+ # Call add_option( $opt, \$cmd ... )
+ # Add option to one or more commands
+ my $option = shift;
+ while (@_) {
+ if ( ${$_[0]} !~ /%/ ) { &fix_cmds; }
+ ${$_[0]} =~ s/%O/$option %O/;
+ shift;
+ }
+} #END add_option
+
+#############################################################
+
+sub rdb_initialize_rules {
+ # Initialize rule database.
+ # (The rule database may get overridden/extended after the fdb_latexmk
+ # file is read, and after running commands to adjust to dependencies
+ # determined from document.
+ %rule_db = ();
+ %target_rules = ();
+ %target_files = ();
+
+ local %rule_list = ();
+ &rdb_set_rule_templates;
+
+ my %rule_template = %rule_list;
+ while ( my ($key, $value) = each %extra_rule_spec ) {
+ $rule_template{$key} = $value;
+ }
+ foreach my $rule ( keys %rule_template ) {
+ my ( $cmd_type, $ext_cmd, $int_cmd, $source, $dest, $base, $test_kind, $PA_extra_gen ) = @{$rule_template{$rule}};
+ if ( ! $PA_extra_gen ) { $PA_extra_gen = []; }
+ my $needs_making = 0;
+ # Substitute in the filename variables, since we will use
+ # those for determining filenames. But delay expanding $cmd
+ # until run time, in case of changes.
+ foreach ($base, $source, $dest, @$PA_extra_gen ) {
+ s/%R/$root_filename/g;
+ s/%Y/$aux_dir1/;
+ s/%Z/$out_dir1/;
+ }
+ foreach ($source, $dest ) {
+ s/%B/$base/;
+ s/%T/$texfile_name/;
+ }
+ rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $test_kind,
+ $source, $dest, $base,
+ $needs_making, undef, undef, 1, $PA_extra_gen );
+ } # End rule iteration
+
+ # Ensure we only have one way to make pdf file, and that it is appropriate. Remove other incompatibilities
+ if ($pdf_mode == 1) { rdb_deactivate( 'dvipdf', 'ps2pdf', 'latex', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
+ elsif ($pdf_mode == 2) { rdb_deactivate( 'dvipdf', 'pdflatex', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
+ elsif ($pdf_mode == 3) { rdb_deactivate( 'pdflatex', 'ps2pdf', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
+ elsif ($pdf_mode == 4) { rdb_deactivate( 'pdflatex', 'ps2pdf', 'dvipdf', 'xdvipdfmx', 'xelatex' ); }
+ elsif ($pdf_mode == 5) { rdb_deactivate( 'pdflatex', 'ps2pdf', 'dvipdf', 'lualatex' ); }
+ else { rdb_deactivate( 'dvipdf', 'pdflatex', 'ps2pdf', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
+
+ if ($dvi_mode == 1) {
+ rdb_activate( 'latex' );
+ $target_files{$dvi_final} = 1;
+ }
+ if ($postscript_mode == 1) {
+ rdb_activate( 'latex' );
+ $target_files{$ps_final} = 1;
+ }
+ if ($pdf_mode) { $target_files{$pdf_final} = 1; }
+ &rdb_set_rule_net;
+} # END rdb_initialize_rules
+
+#************************************************************
+
+sub rdb_set_rule_templates {
+# Set up specifications for standard rules, adjusted to current conditions
+# Substitutions: %S = source, %D = dest, %B = this rule's base
+# %T = texfile, %R = root = base for latex.
+# %Y for $aux_dir1, %Z for $out_dir1
+
+
+ my $print_file = '';
+ my $print_cmd = 'NONE';
+ if ( $print_type eq 'dvi' ) {
+ $print_file = $dvi_final;
+ $print_cmd = $lpr_dvi;
+ }
+ elsif ( $print_type eq 'pdf' ) {
+ $print_file = $pdf_final;
+ $print_cmd = $lpr_pdf;
+ }
+ elsif ( $print_type eq 'ps' ) {
+ $print_file = $ps_final;
+ $print_cmd = $lpr;
+ }
+ elsif ( $print_type eq 'none' ) {
+ $print_cmd = 'NONE echo NO PRINTING CONFIGURED';
+ }
+
+ my $view_file = '';
+ my $viewer = '';
+ my $viewer_update_method = 0;
+ my $viewer_update_signal = undef;
+ my $viewer_update_command = undef;
+
+ if ( ($view eq 'dvi') || ($view eq 'pdf') || ($view eq 'ps') ) {
+ $view_file = ${$view.'_final'};
+ $viewer = ${$view.'_previewer'};
+ $viewer_update_method = ${$view.'_update_method'};
+ $viewer_update_signal = ${$view.'_update_signal'};
+ if (defined ${$view.'_update_command'}) {
+ $viewer_update_command = ${$view.'_update_command'};
+ }
+ }
+ # Specification of internal command for viewer update:
+ my $PA_update = ['do_update_view', $viewer_update_method, $viewer_update_signal, 0, 1];
+
+# For test_kind: Use file contents for latex and friends, but file time for the others.
+# This is because, especially for dvi file, the contents of the file may contain
+# a pointer to a file to be included, not the contents of the file!
+ %rule_list = (
+ 'latex' => [ 'primary', "$latex", '', "%T", $dvi_name, "%R", 1, [$log_name] ],
+ 'pdflatex' => [ 'primary', "$pdflatex", '', "%T", $pdf_name, "%R", 1, [$log_name] ],
+ 'lualatex' => [ 'primary', "$lualatex", '', "%T", $pdf_name, "%R", 1, [$log_name] ],
+ 'xelatex' => [ 'primary', "$xelatex", '', "%T", $xdv_name, "%R", 1, [$log_name] ],
+ 'dvipdf' => [ 'external', "$dvipdf", 'do_viewfile', $dvi_final, $pdf_name, "%Z%R", 2 ],
+ 'xdvipdfmx' => [ 'external', "$xdvipdfmx", 'do_viewfile', $xdv_final, $pdf_name, "%Z%R", 2 ],
+ 'dvips' => [ 'external', "$dvips", 'do_viewfile', $dvi_final, $ps_name, "%Z%R", 2 ],
+ 'dvifilter' => [ 'external', $dvi_filter, 'do_viewfile', $dvi_name, $dviF_name, "%Z%R", 2 ],
+ 'ps2pdf' => [ 'external', "$ps2pdf", 'do_viewfile', $ps_final, $pdf_name, "%Z%R", 2 ],
+ 'psfilter' => [ 'external', $ps_filter, 'do_viewfile', $ps_name, $psF_name, "%Z%R", 2 ],
+ 'print' => [ 'external', "$print_cmd", 'if_source', $print_file, "", "", 2 ],
+ 'update_view' => [ 'external', $viewer_update_command, $PA_update,
+ $view_file, "", "", 2 ],
+ 'view' => [ 'external', "$viewer", 'if_source', $view_file, "", "", 2 ],
+ );
+} # END rdb_set_rule_templates
+
+#************************************************************
+
+sub rdb_set_rule_net {
+ # Set network of rules, including links
+ &rdb_make_links;
+ &rdb_classify_rules;
+}
+
+#************************************************************
+
+sub rdb_make_links {
+# ?? Problem if there are multiple rules for getting a file. Notably pdf.
+# Which one to choose?
+# ?? Problem: what if a rule is inactive,
+# e.g., bibtex because biber is in use,
+# or xelatex when pdflatex is in use
+# or bibtex when $bibtex_use is 0.
+# What if both latex and pdflatex are being used?
+# That has been allowed. But .aux file (also
+# .log file) are made by both.
+
+# Other case: package (like bibtopic) creates bbl or other file when
+# it doesn't exist. Later a rule is created by latexmk to make that
+# file. Then the rule's main destination file should have priority
+# over non-main generated files from other rules.
+ local %from_rules_old = %from_rules;
+ &rdb_cache_generated;
+ rdb_for_actives(
+ 0,
+ sub{
+ if ( exists $from_rules_main{$file} ) {
+ $$Pfrom_rule = $from_rules_main{$file};
+ }
+ elsif ( exists $from_rules{$file} ) {
+ $$Pfrom_rule = $from_rules{$file};
+ }
+ if ( $$Pfrom_rule && (! rdb_rule_exists( $$Pfrom_rule ) ) ) {
+ $$Pfrom_rule = '';
+ }
+ }
+ );
+ rdb_for_actives( \&rdb_set_source_rules );
+# &rdb_show;
+} # END rdb_make_links
+
+#************************************************************
+
+sub rdb_set_source_rules {
+ # This applies to rules whose source file is a dvi or xdv file
+ # Uses rule context
+ my ($base, $path, $ext) = fileparseA( $$Psource );
+ if ( ($ext eq '.dvi') || ($ext eq '.dviF') || ($ext eq '.xdv') ) {
+ my $old_rule = $from_rules_old{$$Psource};
+ my $new_rule = $from_rules{$$Psource};
+ if ( defined $old_rule
+ && defined $new_rule
+ && ($old_rule eq $new_rule)
+ && defined $$PHsource_rules{$new_rule}
+ )
+ { # Nothing to do: source rule is correct.
+ }
+ else {
+ if ( defined $old_rule ) { delete $$PHsource_rules{$old_rule}; }
+ if ( defined $new_rule ) { $$PHsource_rules{$new_rule} = 0; }
+ }
+ }
+}
+
+#************************************************************
+
+sub rdb_cache_generated {
+ # Update %from_rules
+ %from_rules = ();
+ %from_rules_main = ();
+ rdb_for_actives( \&one_from_main_rule_cache );
+ rdb_for_actives( \&one_from_rule_cache );
+} # END rdb_cache_generated
+
+#------------
+
+sub one_from_main_rule_cache {
+ # Rule context assumed.
+ # Set from_rules_main items for one rule
+ if (! $$Pdest) { return; }
+# Error message trigger: if ( $$Pdest =~ /pdf$/) { $from_rules_main{$$Pdest} = 'pdflatexA'; }
+ if ( exists $from_rules_main{$$Pdest} ) {
+ my $old_rule = $from_rules_main{$$Pdest};
+ if ( $old_rule eq $rule ) {
+ # OK
+ }
+ else {
+ warn "$My_name: Possible bug:\n",
+ " In linking rules I already set from_rules_main{$$Pdest} to '$old_rule'\n",
+ " But now I want to set it to '$rule'\n";
+#???? traceback();
+ }
+ }
+ $from_rules_main{$$Pdest} = $rule;
+} # END one_from_main_rule_cache
+
+#------------
+
+sub one_from_rule_cache {
+ # Rule context assumed.
+ # Set from_rules items for one rule
+ foreach ( @$PA_extra_gen, keys %$PHdest ) {
+ # Error message trigger: if ( $_ =~ /aux$/) { $from_rules{$_} = 'pdflatexA'; }
+ if ( exists $from_rules{$_} ) {
+ my $old_rule = $from_rules{$_};
+ if ( $old_rule eq $rule ) {
+ # OK
+ }
+ elsif ( exists $from_rules_main{$_} && ( $from_rules_main{$_} ne $rule ) ) {
+ warn "$My_name: Possible problem:\n",
+ " In linking rules, I already set from_rules_main{$_}\n".
+ " to '$from_rules_main{$_}'\n",
+ " But now I also have a different rule '$rule' that also made the file.\n";
+ }
+ elsif ( exists($possible_primaries{$old_rule}) && exists($possible_primaries{$rule}) ) {
+ # This could be problematic. But we'll let it go,
+ # because it is a common case for .aux and .log files
+ # (etc), and these cases do not appear to mess up
+ # anything (by experience).
+ # Once we allow an active flag for rules and only
+ # examine active rules, the only case of this that
+ # will appear (in the absence of other problems) will
+ # be where two primary rules are active, notably a
+ # latex rule to make dvi and a pdflatex (or other
+ # rule) to make pdf.
+ }
+ else {
+ warn "$My_name: Possible bug:\n",
+ " In linking rules I already set from_rules{$_} to '$old_rule'\n",
+ " But now I want to set it to '$rule'\n";
+#???? traceback();
+ }
+ }
+ $from_rules{$_} = $rule;
+ }
+} #END from_rule_cache
+
+#************************************************************
+
+sub set_trivial_aux_fdb {
+ # 1. Write aux file EXACTLY as would be written if the tex file
+ # had no cross references, etc. I.e., a minimal .aux file.
+ # 2. Write a corresponding fdb file
+ # 3. Provoke a run of (pdf)latex (actually of all primaries).
+
+ local *aux_file;
+ open( aux_file, '>', $aux_main )
+ or die "Cannot write file '$aux_main'\n";
+ print aux_file "\\relax \n";
+ close(aux_file);
+
+ foreach my $rule (keys %possible_primaries ) {
+ rdb_ensure_file( $rule, $texfile_name );
+ rdb_ensure_file( $rule, $aux_main );
+ rdb_one_rule( $rule,
+ sub{ $$Pout_of_date = 1; }
+ );
+ }
+ &rdb_write( $fdb_name );
+} #END set_trivial_aux_fdb
+
+#************************************************************
+#### Particular actions
+#************************************************************
+#************************************************************
+
+sub do_cusdep {
+ # Unconditional application of custom-dependency
+ # except that rule is not applied if the source file source
+ # does not exist, and an error is returned if the dest is not made.
+ #
+ # Assumes rule context for the custom-dependency, and that my first
+ # argument is the name of the subroutine to apply
+ my $func_name = $_[0];
+ my $return = 0;
+ if ( !-e $$Psource ) {
+ # Source does not exist. Users of this rule will need to turn
+ # it off when custom dependencies are reset
+ if ( !$silent ) {
+## ??? Was commented out. 1 Sep. 2008 restored, for cusdep no-file-exists issue
+ warn "$My_name: In trying to apply custom-dependency rule\n",
+ " to make '$$Pdest' from '$$Psource'\n",
+ " the source file has disappeared since the last run\n";
+ }
+ # Treat as successful
+ }
+ elsif ( !$func_name ) {
+ warn "$My_name: Possible misconfiguration or bug:\n",
+ " In trying to apply custom-dependency rule\n",
+ " to make '$$Pdest' from '$$Psource'\n",
+ " the function name is blank.\n";
+ }
+ elsif ( ! defined &$func_name ) {
+ warn "$My_name: Misconfiguration or bug,",
+ " in trying to apply custom-dependency rule\n",
+ " to make '$$Pdest' from '$$Psource'\n",
+ " function name '$func_name' does not exists.\n";
+ }
+ else {
+ my $cusdep_ret = &$func_name( $$Pbase );
+ if ( defined $cusdep_ret && ($cusdep_ret != 0) ) {
+ $return = $cusdep_ret;
+ if ($return) {
+ warn "Rule '$rule', function '$func_name'\n",
+ " failed with return code = $return\n";
+ }
+ }
+ elsif ( !-e $$Pdest ) {
+ # Destination non-existent, but routine failed to give an error
+ warn "$My_name: In running custom-dependency rule\n",
+ " to make '$$Pdest' from '$$Psource'\n",
+ " function '$func_name' did not make the destination.\n";
+ $return = -1;
+ }
+ }
+ return $return;
+} # END do_cusdep
+
+#************************************************************
+
+sub do_viewfile {
+ # Unconditionally make file for viewing, going through temporary file if
+ # Assumes rule context
+
+ my $return = 0;
+ my ($base, $path, $ext) = fileparseA( $$Pdest );
+ if ( &view_file_via_temporary ) {
+ if ( $$Pext_cmd =~ /%D/ ) {
+ my $tmpfile = tempfile1( "${root_filename}_tmp", $ext );
+ warn "$My_name: Making '$$Pdest' via temporary '$tmpfile'...\n";
+ $return = &Run_subst( undef, undef, undef, undef, $tmpfile );
+ move( $tmpfile, $$Pdest );
+ }
+ else {
+ warn "$My_name is configured to make '$$Pdest' via a temporary file\n",
+ " but the command template '$$Pext_cmd' does not have a slot\n",
+ " to set the destination file, so I won't use a temporary file\n";
+ $return = &Run_subst();
+ }
+ }
+ else {
+ $return = &Run_subst();
+ }
+ return $return;
+} #END do_viewfile
+
+#************************************************************
+
+sub do_update_view {
+ # Update viewer
+ # Assumes rule context
+ # Arguments: (method, signal, viewer_process)
+
+ my $return = 0;
+
+ # Although the process is passed as an argument, we'll need to update it.
+ # So (FUDGE??) bypass the standard interface for the process.
+ # We might as well do this for all the arguments.
+ my $viewer_update_method = ${$PAint_cmd}[1];
+ my $viewer_update_signal = ${$PAint_cmd}[2];
+ my $Pviewer_process = \${$PAint_cmd}[3];
+ my $Pneed_to_get_viewer_process = \${$PAint_cmd}[4];
+
+ if ($viewer_update_method == 2) {
+ if ($$Pneed_to_get_viewer_process) {
+ $$Pviewer_process = &find_process_id( $$Psource );
+ if ($$Pviewer_process != 0) {
+ $$Pneed_to_get_viewer_process = 0;
+ }
+ }
+ if ($$Pviewer_process == 0) {
+ print "$My_name: need to signal viewer for file '$$Psource', but didn't get \n",
+ " process ID for some reason, e.g., no viewer, bad configuration, bug\n"
+ if $diagnostics ;
+ }
+ elsif ( defined $viewer_update_signal) {
+ print "$My_name: signalling viewer, process ID $$Pviewer_process ",
+ "with signal $viewer_update_signal\n"
+ if $diagnostics ;
+ kill $viewer_update_signal, $$Pviewer_process;
+ }
+ else {
+ warn "$My_name: viewer is supposed to be sent a signal\n",
+ " but no signal is defined. Misconfiguration or bug?\n";
+ $return = 1;
+ }
+ }
+ elsif ($viewer_update_method == 4) {
+ if (defined $$Pext_cmd) {
+ $return = &Run_subst();
+ }
+ else {
+ warn "$My_name: viewer is supposed to be updated by running a command,\n",
+ " but no command is defined. Misconfiguration or bug?\n";
+ }
+ }
+ return $return;
+} #END do_update_view
+
+#************************************************************
+
+sub if_source {
+ # Unconditionally apply rule if source file exists.
+ # Assumes rule context
+ if ( -e $$Psource ) {
+ return &Run_subst();
+ }
+ else {
+ warn "Needed source file '$$Psource' does not exist.\n";
+ return -1;
+ }
+} #END if_source
+
+#************************************************************
+#### Subroutines
+#************************************************************
+#************************************************************
+
+sub find_basename {
+ # Finds the basename of the root file
+ # Arguments:
+ # 1 - Filename to breakdown
+ # 2 - Where to place base file
+ # 3 - Where to place tex file
+ # Returns non-zero if tex file does not exist
+ #
+ # The rules for determining this depend on the implementation of TeX.
+ # The variable $extension_treatment determines which rules are used.
+
+ # !!!!!!!! I still need to implement use of kpsewhich to match behavior
+ # of (pdf)latex correctly.
+
+ local($given_name, $base_name, $ext, $path, $tex_name);
+ $given_name = $_[0];
+ if ( "$extension_treatment" eq "miktex_old" ) {
+ # Miktex v. 1.20d:
+ # 1. If the filename has an extension, then use it.
+ # 2. Else append ".tex".
+ # 3. The basename is obtained from the filename by
+ # removing the path component, and the extension, if it
+ # exists. If a filename has a multiple extension, then
+ # all parts of the extension are removed.
+ # 4. The names of generated files (log, aux) are obtained by
+ # appending .log, .aux, etc to the basename. Note that
+ # these are all in the CURRENT directory, and the drive/path
+ # part of the originally given filename is ignored.
+ #
+ # Thus when the given filename is "\tmp\a.b.c", the tex
+ # filename is the same, and the basename is "a".
+
+ ($base_name, $path, $ext) = fileparse( $given_name, '\..*' );
+ if ( "$ext" eq "") { $tex_name = "$given_name.tex"; }
+ else { $tex_name = $given_name; }
+ $_[1] = $base_name;
+ $_[2] = $tex_name;
+ }
+ elsif ( "$extension_treatment" eq "unix" ) {
+ # unix (at least TeXLive 2016) =>
+ # A. Finding of tex file:
+ # 1. If filename.tex exists, use it,
+ # 2. else if kpsewhich finds filename.tex, use it
+ # 3. else if filename exists, use it,
+ # 4. else if kpsewhich finds filename, use it.
+ # (Probably can unify the above by
+ # 1'. If kpsewhich finds filename.tex, use result.
+ # 2'. else if kpsewhich finds filename, use result.
+ # 3'. else report file not found.
+ # B. The base filename is obtained by deleting the path
+ # component and, if an extension exists, the last
+ # component of the extension, even if the extension is
+ # null. (A name ending in "." has a null extension.)
+ # C. The names of generated files (log, aux) are obtained by
+ # appending .log, .aux, etc to the basename. Note that
+ # these are all in the CURRENT directory, and the drive/path
+ # part of the originally given filename is ignored.
+ #
+ # Thus when the given filename is "/tmp/a.b.c", there are two
+ # cases:
+ # a. /tmp/a.b.c.tex exists. Then this is the tex file,
+ # and the basename is "a.b.c".
+ # b. /tmp/a.b.c.tex does not exist. Then the tex file is
+ # "/tmp/a.b.c", and the basename is "a.b".
+ # But there are also modifications of this when a file can be
+ # found by kpsewhich.
+
+ if ( -f "$given_name.tex" ) {
+ $tex_name = "$given_name.tex";
+ }
+ else {
+ $tex_name = "$given_name";
+ }
+ ($base_name, $path, $ext) = fileparse( $tex_name, '\.[^\.]*' );
+ $_[1] = $base_name;
+ $_[2] = $tex_name;
+ }
+ else {
+ die "$My_name: Incorrect configuration gives \$extension_treatment=",
+ "'$extension_treatment'\n";
+ }
+ if ($diagnostics) {
+ print "Given='$given_name', tex='$tex_name', base='$base_name'\n";
+ }
+ return ! -e $tex_name;
+} #END find_basename
+
+#************************************************************
+
+sub make_preview_continuous {
+ local @changed = ();
+ local %changed_rules = ();
+ local @changed_user = ();
+ local @disappeared = ();
+ local @no_dest = (); # Non-existent destination files
+ local @rules_never_run = ();
+ local @rules_to_apply = ();
+
+ local $failure = 0;
+ local %rules_applied = ();
+ local $updated = 0;
+
+ print "======= Need to update make_preview_continuous for target files\n";
+
+ $quell_uptodate_msgs = 1;
+
+ local $view_file = '';
+ rdb_one_rule( 'view', sub{ $view_file = $$Psource; } );
+
+ if ( ($view eq 'dvi') || ($view eq 'pdf') || ($view eq 'ps') ) {
+ warn "Viewing $view\n";
+ }
+ elsif ( $view eq 'none' ) {
+ warn "Not using a previewer\n";
+ $view_file = '';
+ }
+ else {
+ warn "$My_name: BUG: Invalid preview method '$view'\n";
+ exit 20;
+ }
+
+ my $viewer_running = 0; # No viewer known to be running yet
+ # Get information from update_view rule
+ local $viewer_update_method = 0;
+ # Pointers so we can update the following:
+ local $Pviewer_process = undef;
+ local $Pneed_to_get_viewer_process = undef;
+ rdb_one_rule( 'update_view',
+ sub{ $viewer_update_method = $$PAint_cmd[1];
+ $Pviewer_process = \$$PAint_cmd[3];
+ $Pneed_to_get_viewer_process = \$$PAint_cmd[4];
+ }
+ );
+ # Note that we don't get the previewer process number from the program
+ # that starts it; that might only be a script to get things set up and the
+ # actual previewer could be (and sometimes IS) another process.
+
+ if ( ($view_file ne '') && (-e $view_file) && !$new_viewer_always ) {
+ # Is a viewer already running?
+ # (We'll save starting up another viewer.)
+ $$Pviewer_process = &find_process_id( $view_file );
+ if ( $$Pviewer_process ) {
+ warn "$My_name: Previewer is already running\n"
+ if !$silent;
+ $viewer_running = 1;
+ $$Pneed_to_get_viewer_process = 0;
+ }
+ }
+
+ # Loop forever, rebuilding .dvi and .ps as necessary.
+ # Set $first_time to flag first run (to save unnecessary diagnostics)
+ my $last_action_time = time();
+ my $timed_out = 0;
+CHANGE:
+ for (my $first_time = 1; 1; $first_time = 0 ) {
+
+ my %rules_to_watch = array_to_hash( &rdb_accessible );
+
+ $updated = 0;
+ $failure = 0;
+ $failure_msg = '';
+ if ( $MSWin_fudge_break && ($^O eq "MSWin32") ) {
+ # Fudge under MSWin32 ONLY, to stop perl/latexmk from
+ # catching ctrl/C and ctrl/break, and let it only reach
+ # downstream programs. See comments at first definition of
+ # $MSWin_fudge_break.
+ $SIG{BREAK} = $SIG{INT} = 'IGNORE';
+ }
+ if ($compiling_cmd) {
+ Run_subst( $compiling_cmd );
+ }
+ $failure = &rdb_make;
+
+## warn "=========Viewer PID = $$Pviewer_process; updated=$updated\n";
+
+ if ( $MSWin_fudge_break && ($^O eq "MSWin32") ) {
+ $SIG{BREAK} = $SIG{INT} = 'DEFAULT';
+ }
+ # Start viewer if needed.
+ if ( ($failure > 0) && (! $force_mode) ) {
+ # No viewer yet
+ }
+ elsif ( ($view_file ne '') && (-e $view_file) && $updated && $viewer_running ) {
+ # A viewer is running. Explicitly get it to update screen if we have to do it:
+ rdb_one_rule( 'update_view', \&rdb_run1 );
+ }
+ elsif ( ($view_file ne '') && (-e $view_file) && !$viewer_running ) {
+ # Start the viewer
+ if ( !$silent ) {
+ if ($new_viewer_always) {
+ warn "$My_name: starting previewer for '$view_file'\n",
+ "------------\n";
+ }
+ else {
+ warn "$My_name: I have not found a previewer that ",
+ "is already running. \n",
+ " So I will start it for '$view_file'\n",
+ "------------\n";
+ }
+ }
+ local $retcode = 0;
+ rdb_one_rule( 'view', sub { $retcode = &rdb_run1;} );
+ if ( $retcode != 0 ) {
+ if ($force_mode) {
+ warn "$My_name: I could not run previewer\n";
+ }
+ else {
+ &exit_msg1( "I could not run previewer", $retcode);
+ }
+ }
+ else {
+ $viewer_running = 1;
+ $$Pneed_to_get_viewer_process = 1;
+ } # end analyze result of trying to run viewer
+ } # end start viewer
+ if ( $failure > 0 ) {
+ if ( !$failure_msg ) {
+ $failure_msg = 'Failure to make the files correctly';
+ }
+ &rdb_set_rule_net;
+ %rules_to_watch = array_to_hash( &rdb_accessible );
+
+ # There will be files changed during the run that are irrelevant.
+ # We need to wait for the user to change the files.
+
+ # So set the GENERATED files from (pdf)latex as up-to-date:
+ rdb_for_some( [keys %current_primaries], \&rdb_update_gen_files );
+
+ # And don't watch for changes for post_primary rules (ps and pdf
+ # from dvi, etc haven't been run after an error in (pdf)latex, so
+ # are out-of-date by filetime criterion, but they should not be run
+ # until after another (pdf)latex run:
+ foreach (@post_primary) { delete $rules_to_watch{$_}; }
+
+ $failure_msg =~ s/\s*$//; #Remove trailing space
+ warn "$My_name: $failure_msg\n",
+ " ==> You will need to change a source file before I do another run <==\n";
+ if ($failure_cmd) {
+ Run_subst( $failure_cmd );
+ }
+ }
+ else {
+ if ( ($#primary_warning_summary > -1) && $warning_cmd ) {
+ Run_subst( $warning_cmd );
+ }
+ elsif ( ($#primary_warning_summary > -1) && $warnings_as_errors && $failure_cmd ) {
+ Run_subst( $failure_cmd );
+ }
+ elsif ($success_cmd) {
+ Run_subst( $success_cmd );
+ }
+ }
+ rdb_show_rule_errors();
+ if ($rules_list) { rdb_list(); }
+ if ($show_time && ! $first_time) { show_timing(); }
+ if ( $dependents_list && ($updated || $failure) ) {
+ my $deps_handle = new FileHandle "> $deps_file";
+ if ( defined $deps_handle ) {
+ deps_list($deps_handle);
+ close($deps_handle);
+ }
+ else {
+ warn "Cannot open '$deps_file' for output of dependency information\n";
+ }
+ }
+
+ # Now wait for a file to change...
+ &rdb_cache_generated;
+ # During waiting for file changes, handle ctrl/C and ctrl/break here,
+ # rather than letting system handle them by terminating script (and
+ # code in the following command line to work: any script that calls
+ # it). This allows, for example, the command cleanup in the following
+ # command line to work:
+ # latexmk -pvc foo; cleanup;
+ &catch_break;
+ $have_break = 0;
+ $last_action_time = time();
+ $waiting = 1;
+ print "\n=== Watching for updated files. Use ctrl/C to stop ...\n";
+ WAIT: while (1) {
+ sleep( $sleep_time );
+ if ($have_break) { last WAIT; }
+ if ( rdb_user_changes(keys %rules_to_watch) ) {
+ if (!$silent) {
+ warn "$My_name: Need to remake files.\n";
+ &rdb_diagnose_changes( ' ' );
+ }
+ last WAIT;
+ }
+ # Don't count waiting time in processing:
+ $processing_time1 = processing_time();
+ # Does this do this job????
+ local $new_files = 0;
+ rdb_for_some( [keys %current_primaries], sub{ $new_files += &rdb_find_new_files } );
+ if ($new_files > 0) {
+ warn "$My_name: New file(s) found.\n";
+ last WAIT;
+ }
+ if ($have_break) { last WAIT; }
+ if ($pvc_timeout && ( time() > $last_action_time+60*$pvc_timeout_mins ) ) {
+ $timed_out = 1;
+ last WAIT;
+ }
+ } # end WAIT:
+ &default_break;
+ if ($have_break) {
+ print "$My_name: User typed ctrl/C or ctrl/break. I'll finish.\n";
+ return;
+ }
+ if ($timed_out) {
+ print "$My_name: More than $pvc_timeout_mins mins of inactivity. I'll finish.\n";
+ return;
+ }
+ $waiting = 0; if ($diagnostics) { warn "NOT WAITING\n"; }
+ } #end infinite_loop CHANGE:
+} #END sub make_preview_continuous
+
+#************************************************************
+
+sub process_rc_file {
+ # Usage process_rc_file( filename )
+ # NEW VERSION
+ # Run rc_file whose name is given in first argument
+ # Exit with code 0 on success
+ # Exit with code 1 if file cannot be read or does not exist.
+ # Stop if there is a syntax error or other problem.
+ # PREVIOUSLY:
+ # Exit with code 2 if is a syntax error or other problem.
+ my $rc_file = $_[0];
+ my $ret_code = 0;
+ warn "$My_name: Executing Perl code in file '$rc_file'...\n"
+ if $diagnostics;
+ # I could use the do command of perl, but the preceeding -r test
+ # to get good diagnostics gets the wrong result under cygwin
+ # (e.g., on /cygdrive/c/latexmk/LatexMk)
+ my $RCH = new FileHandle;
+ if ( !-e $rc_file ) {
+ warn "$My_name: The rc-file '$rc_file' does not exist\n";
+ return 1;
+ }
+ elsif ( -d $rc_file ) {
+ warn "$My_name: The supposed rc-file '$rc_file' is a directory; but it\n",
+ " should be a normal text file\n";
+ return 1;
+ }
+ elsif ( open $RCH, "<$rc_file" ) {
+ { local $/; eval <$RCH>; }
+ close $RCH;
+ }
+ else {
+ warn "$My_name: I cannot read the rc-file '$rc_file'\n";
+ return 1;
+ }
+ # PREVIOUS VERSION
+# if ( ! -r $rc_file ) {
+# warn "$My_name: I cannot read the rc-file '$rc_file'\n",
+# " or at least that's what Perl (for $^O) reports\n";
+# return 1;
+# }
+# do( $rc_file );
+ if ( $@ ) {
+ # Indent each line of possibly multiline message:
+ my $message = prefix( $@, " " );
+ warn "$My_name: Initialization file '$rc_file' gave an error:\n",
+ "$message\n";
+ die "$My_name: Stopping because of problem with rc file\n";
+ # Use the following if want non-fatal error.
+ return 2;
+ }
+ return 0;
+} #END process_rc_file
+
+#************************************************************
+
+sub execute_code_string {
+ # Usage execute_code_string( string_of_code )
+ # Run the perl code contained in first argument
+ # Halt if there is a syntax error or other problem.
+ # ???Should I leave the exiting to the caller (perhaps as an option)?
+ # But I can always catch it with an eval if necessary.
+ # That confuses ctrl/C and ctrl/break handling.
+ my $code = $_[0];
+ warn "$My_name: Executing initialization code specified by -e:\n",
+ " '$code'...\n"
+ if $diagnostics;
+ eval $code;
+ # The return value from the eval is not useful, since it is the value of
+ # the last expression evaluated, which could be anything.
+ # The correct test of errors is on the value of $@.
+
+ if ( $@ ) {
+ # Indent each line of possibly multiline message:
+ my $message = prefix( $@, " " );
+ die "$My_name: ",
+ "Stopping because executing following code from command line\n",
+ " $code\n",
+ "gave an error:\n",
+ "$message\n";
+ }
+} #END execute_code_string
+
+#************************************************************
+
+sub cleanup1 {
+ # Usage: cleanup1( directory, exts_without_period, ... )
+ #
+ # The directory and the root file name are fixed names, so I must escape
+ # any glob metacharacters in them:
+ my $dir = fix_pattern( shift );
+ my $root_fixed = fix_pattern( $root_filename );
+ foreach (@_) {
+ my $name = /%R/ ? $_ : "%R.$_";
+ $name =~ s/%R/${root_fixed}/;
+ $name = $dir.$name;
+ unlink_or_move( my_glob( "$name" ) );
+ }
+} #END cleanup1
+
+#************************************************************
+
+sub cleanup_cusdep_generated {
+ # Remove files generated by custom dependencies
+ rdb_for_actives( \&cleanup_one_cusdep_generated );
+} #END cleanup_cusdep_generated
+
+#************************************************************
+
+sub cleanup_one_cusdep_generated {
+ # Remove destination file generated by one custom dependency
+ # Assume rule context, but not that the rule is a custom dependency.
+ # Only delete destination file if source file exists (so destination
+ # file can be recreated)
+ if ( $$Pcmd_type ne 'cusdep' ) {
+ # NOT cusdep
+ return;
+ }
+ if ( ! -e $$Psource ) {
+ warn "$My_name: For custom dependency '$rule',\n",
+ " I won't delete destination file '$$Pdest'\n",
+ " and any other generated files,\n",
+ " because the source file '$$Psource' doesn't exist,\n",
+ " so the destination file may not be able to be recreated\n";
+ return;
+ }
+ unlink_or_move( $$Pdest, keys %$PHdest );
+} #END cleanup_one_cusdep_generated
+
+#************************************************************
+#************************************************************
+#************************************************************
+
+# Error handling routines, warning routines, help
+
+#************************************************************
+
+sub die_trace {
+ # Call: die_trace( message );
+ &traceback; # argument(s) passed unchanged
+ die "\n";
+} #END die_trace
+
+#************************************************************
+
+sub traceback {
+ # Call: &traceback
+ # or traceback( message, )
+ my $msg = shift;
+ if ($msg) { warn "$msg\n"; }
+ warn "Traceback:\n";
+ my $i=0; # Start with immediate caller
+ while ( my ($pack, $file, $line, $func) = caller($i++) ) {
+ if ($func eq 'die_trace') { next; }
+ warn " $func called from line $line\n";
+ }
+} #END traceback
+
+#************************************************************
+
+sub exit_msg1
+{
+ # exit_msg1( error_message, retcode [, action])
+ # 1. display error message
+ # 2. if action set, then restore aux file
+ # 3. exit with retcode
+ warn "\n------------\n";
+ warn "$My_name: $_[0].\n";
+ warn "-- Use the -f option to force complete processing.\n";
+
+ my $retcode = $_[1];
+ if ($retcode >= 256) {
+ # Retcode is the kind returned by system from an external command
+ # which is 256 * command's_retcode
+ $retcode /= 256;
+ }
+ exit $retcode;
+} #END exit_msg1
+
+#************************************************************
+
+sub warn_running {
+ # Message about running program:
+ if ( $silent ) {
+ warn "$My_name: @_\n";
+ }
+ else {
+ warn "------------\n@_\n------------\n";
+ }
+} #END warn_running
+
+#************************************************************
+
+sub exit_help
+# Exit giving diagnostic from arguments and how to get help.
+{
+ warn "\n$My_name: @_\n",
+ "Use\n",
+ " $my_name -help\nto get usage information\n";
+ exit 10;
+} #END exit_help
+
+
+#************************************************************
+
+sub print_help
+{
+ print
+ "$My_name $version_num: Automatic LaTeX document generation routine\n\n",
+ "Usage: $my_name [latexmk_options] [filename ...]\n\n",
+ " Latexmk_options:\n",
+ " -aux-directory=dir or -auxdir=dir \n",
+ " - set name of directory for auxiliary files (aux, log)\n",
+ " - Currently this only works with MiKTeX\n",
+ " -bibtex - use bibtex when needed (default)\n",
+ " -bibtex- - never use bibtex\n",
+ " -bibtex-cond - use bibtex when needed, but only if the bib file exists\n",
+ " -bibtex-cond1 - use bibtex when needed, but only if the bib file exists;\n",
+ " on cleanup delete bbl file only if bib file exists\n",
+ " -bm <message> - Print message across the page when converting to postscript\n",
+ " -bi <intensity> - Set contrast or intensity of banner\n",
+ " -bs <scale> - Set scale for banner\n",
+ " -commands - list commands used by $my_name for processing files\n",
+ " -c - clean up (remove) all nonessential files, except\n",
+ " dvi, ps and pdf files.\n",
+ " This and the other clean-ups are instead of a regular make.\n",
+ " -C - clean up (remove) all nonessential files\n",
+ " including aux, dep, dvi, postscript and pdf files\n",
+ " and file of database of file information\n",
+ " -CA - clean up (remove) all nonessential files.\n",
+ " Equivalent to -C option.\n",
+ " -CF - Remove file of database of file information before doing \n",
+ " other actions\n",
+ " -cd - Change to directory of source file when processing it\n",
+ " -cd- - Do NOT change to directory of source file when processing it\n",
+ " -dependents or -deps - Show list of dependent files after processing\n",
+ " -dependents- or -deps- - Do not show list of dependent files\n",
+ " -deps-out=file - Set name of output file for dependency list,\n",
+ " and turn on showing of dependency list\n",
+ " -dF <filter> - Filter to apply to dvi file\n",
+ " -dvi - generate dvi\n",
+ " -dvi- - turn off required dvi\n",
+ " -e <code> - Execute specified Perl code (as part of latexmk start-up\n",
+ " code)\n",
+ " -f - force continued processing past errors\n",
+ " -f- - turn off forced continuing processing past errors\n",
+ " -gg - Super go mode: clean out generated files (-CA), and then\n",
+ " process files regardless of file timestamps\n",
+ " -g - process regardless of file timestamps\n",
+ " -g- - Turn off -g\n",
+ " -h - print help\n",
+ " -help - print help\n",
+ " -jobname=STRING - set basename of output file(s) to STRING.\n",
+ " (Like --jobname=STRING on command line for many current\n",
+ " implementations of latex/pdflatex.)\n",
+ " -l - force landscape mode\n",
+ " -l- - turn off -l\n",
+ " -latex=<program> - set program used for latex.\n",
+ " (replace '<program>' by the program name)\n",
+ " -latexoption=<option> - add the given option to the (pdf)latex command\n",
+ " -logfilewarninglist or -logfilewarnings \n",
+ " give list of warnings after run of (pdf)latex\n",
+ " -logfilewarninglist- or -logfilewarnings- \n",
+ " do not give list of warnings after run of (pdf)latex\n",
+ " -lualatex - use lualatex for processing files to pdf\n",
+ " and turn dvi/ps modes off\n",
+ " -M - Show list of dependent files after processing\n",
+ " -MF file - Specifies name of file to receives list dependent files\n",
+ " -MP - List of dependent files includes phony target for each source file.\n",
+ " -new-viewer - in -pvc mode, always start a new viewer\n",
+ " -new-viewer- - in -pvc mode, start a new viewer only if needed\n",
+ " -nobibtex - never use bibtex\n",
+ " -nodependents - Do not show list of dependent files after processing\n",
+ " -norc - omit automatic reading of system, user and project rc files\n",
+ " -output-directory=dir or -outdir=dir\n",
+ " - set name of directory for output files\n",
+ " -pdf - generate pdf by pdflatex\n",
+ " -pdfdvi - generate pdf by dvipdf\n",
+ " -pdflatex=<program> - set program used for pdflatex.\n",
+ " (replace '<program>' by the program name)\n",
+ " -pdflualatex=<program> - set program used for lualatex.\n",
+ " (replace '<program>' by the program name)\n",
+ " -pdfps - generate pdf by ps2pdf\n",
+ " -pdflua - generate pdf by lualatex\n",
+ " -pdfxe - generate pdf by xelatex\n",
+ " -pdfxelatex=<program> - set program used for xelatex.\n",
+ " (replace '<program>' by the program name)\n",
+ " -pdf- - turn off pdf\n",
+ " -ps - generate postscript\n",
+ " -ps- - turn off postscript\n",
+ " -pF <filter> - Filter to apply to postscript file\n",
+ " -p - print document after generating postscript.\n",
+ " (Can also .dvi or .pdf files -- see documentation)\n",
+ " -pretex=<TeX code> - Sets TeX code to be executed before inputting source\n",
+ " file, if commands suitable configured\n",
+ " -print=dvi - when file is to be printed, print the dvi file\n",
+ " -print=ps - when file is to be printed, print the ps file (default)\n",
+ " -print=pdf - when file is to be printed, print the pdf file\n",
+ " -pv - preview document. (Side effect turn off continuous preview)\n",
+ " -pv- - turn off preview mode\n",
+ " -pvc - preview document and continuously update. (This also turns\n",
+ " on force mode, so errors do not cause $my_name to stop.)\n",
+ " (Side effect: turn off ordinary preview mode.)\n",
+ " -pvc- - turn off -pvc\n",
+ " -pvctimeout - timeout in pvc mode after period of inactivity\n",
+ " -pvctimeout- - don't timeout in pvc mode after inactivity\n",
+ " -pvctimeoutmins=<time> - set period of inactivity (minutes) for pvc timeout\n",
+ " -quiet - silence progress messages from called programs\n",
+ " -r <file> - Read custom RC file\n",
+ " (N.B. This file could override options specified earlier\n",
+ " on the command line.)\n",
+ " -recorder - Use -recorder option for (pdf)latex\n",
+ " (to give list of input and output files)\n",
+ " -recorder- - Do not use -recorder option for (pdf)latex\n",
+ " -rules - Show list of rules after processing\n",
+ " -rules- - Do not show list of rules after processing\n",
+ " -showextraoptions - Show other allowed options that are simply passed\n",
+ " as is to latex and pdflatex\n",
+ " -silent - silence progress messages from called programs\n",
+ " -stdtexcmds - Sets standard commands for *latex\n",
+ " -time - show CPU time used\n",
+ " -time- - don't show CPU time used\n",
+ " -use-make - use the make program to try to make missing files\n",
+ " -use-make- - don't use the make program to try to make missing files\n",
+ " -usepretex - Sets commands for *latex to use extra code before inputting\n",
+ " source file\n",
+ " -usepretex=<TeX code> - Equivalent to -pretex=<TeX code> -usepretex\n",
+ " -v - display program version\n",
+ " -verbose - display usual progress messages from called programs\n",
+ " -version - display program version\n",
+ " -view=default - viewer is default (dvi, ps, pdf)\n",
+ " -view=dvi - viewer is for dvi\n",
+ " -view=none - no viewer is used\n",
+ " -view=ps - viewer is for ps\n",
+ " -view=pdf - viewer is for pdf\n",
+ " -Werror - treat warnings from called programs as errors\n",
+ " -xelatex - use xelatex for processing files to pdf\n",
+ " and turn dvi/ps modes off\n",
+ "\n",
+ " filename = the root filename of LaTeX document\n",
+ "\n",
+ "-p, -pv and -pvc are mutually exclusive\n",
+ "-h, -c and -C override all other options.\n",
+ "-pv and -pvc require one and only one filename specified\n",
+ "All options can be introduced by '-' or '--'. (E.g., --help or -help.)\n",
+ " \n",
+ "In addition, latexmk recognizes many other options that are passed to\n",
+ "latex and/or pdflatex without interpretation by latexmk. Run latexmk\n",
+ "with the option -showextraoptions to see a list of these\n",
+ "\n",
+ "Report bugs etc to John Collins <jcc8 at psu.edu>.\n";
+
+} #END print_help
+
+#************************************************************
+
+sub print_commands {
+ warn "Commands used by $my_name:\n",
+ " To run latex, I use \"$latex\"\n",
+ " To run pdflatex, I use \"$pdflatex\"\n",
+ " To run lualatex, I use \"$lualatex\"\n",
+ " To run xelatex, I use \"$xelatex\"\n",
+ " To run biber, I use \"$biber\"\n",
+ " To run bibtex, I use \"$bibtex\"\n",
+ " To run makeindex, I use \"$makeindex\"\n",
+ " To make a ps file from a dvi file, I use \"$dvips\"\n",
+ " To make a ps file from a dvi file with landscape format, ",
+ "I use \"$dvips_landscape\"\n",
+ " To make a pdf file from a dvi file, I use \"$dvipdf\"\n",
+ " To make a pdf file from a ps file, I use \"$ps2pdf\"\n",
+ " To make a pdf file from an xdv file, I use \"$xdvipdfmx\"\n",
+ " To view a pdf file, I use \"$pdf_previewer\"\n",
+ " To view a ps file, I use \"$ps_previewer\"\n",
+ " To view a ps file in landscape format, ",
+ "I use \"$ps_previewer_landscape\"\n",
+ " To view a dvi file, I use \"$dvi_previewer\"\n",
+ " To view a dvi file in landscape format, ",
+ "I use \"$dvi_previewer_landscape\"\n",
+ " To print a ps file, I use \"$lpr\"\n",
+ " To print a dvi file, I use \"$lpr_dvi\"\n",
+ " To print a pdf file, I use \"$lpr_pdf\"\n",
+ " To find running processes, I use \"$pscmd\", \n",
+ " and the process number is at position $pid_position\n";
+ warn "Notes:\n",
+ " Command starting with \"start\" is run detached\n",
+ " Command that is just \"start\" without any other command, is\n",
+ " used under MS-Windows to run the command the operating system\n",
+ " has associated with the relevant file.\n",
+ " Command starting with \"NONE\" is not used at all\n";
+} #END print_commands
+
+#************************************************************
+
+sub view_file_via_temporary {
+ return $always_view_file_via_temporary
+ || ($pvc_view_file_via_temporary && $preview_continuous_mode);
+} #END view_file_via_temporary
+
+#************************************************************
+#### Tex-related utilities
+
+#**************************************************
+
+sub check_biber_log {
+ # Check for biber warnings:
+ # Usage: check_biber_log( base_of_biber_run, \@biber_source )
+ # return 0: OK;
+ # 1: biber warnings;
+ # 2: biber errors;
+ # 3: could not open .blg file;
+ # 4: failed to find one or more source files, except for bibfile;
+ # 5: failed to find bib file;
+ # 6: missing file, one of which is control file
+ # 10: only error is missing \citation commands.
+ # 11: Malformed bcf file (normally due to error in pdflatex run)
+ # Side effect: add source files @biber_source
+ my $base = $_[0];
+ my $Pbiber_source = $_[1];
+ my $blg_name = "$base.blg";
+ my $blg_file = new FileHandle;
+ open( $blg_file, "<$blg_name" )
+ or return 3;
+ my $have_warning = 0;
+ my $have_error = 0;
+ my $missing_citations = 0;
+ my $no_citations = 0;
+ my $error_count = 0; # From my counting of error messages
+ my $warning_count = 0; # From my counting of warning messages
+ # The next two occur only from biber
+ my $bibers_error_count = 0; # From biber's counting of errors
+ my $bibers_warning_count = 0; # From biber's counting of warnings
+ my $not_found_count = 0;
+ my $control_file_missing = 0;
+ my $control_file_malformed = 0;
+ my %remote = (); # List of extensions of remote files
+ while (<$blg_file>) {
+ if (/> WARN /) {
+ print "Biber warning: $_";
+ $have_warning = 1;
+ $warning_count ++;
+ }
+ elsif (/> (FATAL|ERROR) /) {
+ print "Biber error: $_";
+ if ( /> (FATAL|ERROR) - Cannot find file '([^']+)'/ #'
+ || /> (FATAL|ERROR) - Cannot find '([^']+)'/ ) { #'
+ $not_found_count++;
+ push @$Pbiber_source, $2;
+ }
+ elsif ( /> (FATAL|ERROR) - Cannot find control file '([^']+)'/ ) { #'
+ $not_found_count++;
+ $control_file_missing = 1;
+ push @$Pbiber_source, $2;
+ }
+ elsif ( /> ERROR - .*\.bcf is malformed/ ) {
+ # Special treatment: Malformed .bcf file commonly results from error
+ # in (pdf)latex run. This error must be ignored.
+ $control_file_malformed = 1;
+ }
+ else {
+ $have_error = 1;
+ $error_count ++;
+ if ( /> (FATAL|ERROR) - The file '[^']+' does not contain any citations!/ ) { #'
+ $no_citations++;
+ }
+ }
+ }
+ elsif ( /> INFO - Data source '([^']*)' is a remote BibTeX data source - fetching/
+ ){
+ my $spec = $1;
+ my ( $base, $path, $ext ) = fileparseA( $spec );
+ $remote{$ext} = 1;
+ }
+ elsif ( /> INFO - Found .* '([^']+)'\s*$/
+ || /> INFO - Found '([^']+)'\s*$/
+ || /> INFO - Reading '([^']+)'\s*$/
+ || /> INFO - Processing .* file '([^']+)' .*$/
+ ) {
+ my $file = $1;
+ my ( $base, $path, $ext ) = fileparseA( $file );
+ if ($remote{$ext} && ( $base =~ /^biber_remote_data_source/ ) && 1) {
+ # Ignore the file, which appears to be a temporary local copy
+ # of a remote file. Treating the file as a source file will
+ # be misleading, since it will normally have been deleted by
+ # biber itself.
+ }
+ elsif ( (defined $Pbiber_source) && (-e $file) ) {
+ # Note that biber log file gives full path to file. (No search is
+ # needed to find it.) The file must have existed when biber was
+ # run. If it doesn't exist now, a few moments later, it must
+ # have gotten deleted, probably by biber (e.g., because it is a
+ # copy of a remote file).
+ # So I have included a condition above that the file must
+ # exist to be included in the source-file list.
+ push @$Pbiber_source, $file;
+ }
+ }
+ elsif ( /> INFO - WARNINGS: ([\d]+)\s*$/ ) {
+ $bibers_warning_count = $1;
+ }
+ elsif ( /> INFO - ERRORS: ([\d]+)\s*$/ ) {
+ $bibers_error_count = $1;
+ }
+ }
+ close $blg_file;
+ if ($control_file_malformed){return 11;}
+
+ my @not_found = &find_file_list1( $Pbiber_source, $Pbiber_source,
+ '', \@BIBINPUTS );
+ @$Pbiber_source = uniqs( @$Pbiber_source );
+
+ if ( ($#not_found < 0) && ($#$Pbiber_source >= 0) ) {
+ warn "$My_name: Found biber source file(s) [@$Pbiber_source]\n"
+ unless $silent;
+ }
+ elsif ( ($#not_found == 0) && ($not_found[0] =~ /\.bib$/) ) {
+ # Special treatment if sole missing file is bib file
+ # I don't want to treat that as an error
+ warn "$My_name: Biber did't find bib file [$not_found[0]]\n";
+ return 5;
+ }
+ else {
+ warn "$My_name: Failed to find one or more biber source files:\n";
+ foreach (@not_found) { warn " '$_'\n"; }
+ if ($force_mode) {
+ warn "==== Force_mode is on, so I will continue. ",
+ "But there may be problems ===\n";
+ }
+ if ($control_file_missing) {
+ return 6;
+ }
+ return 4;
+ }
+# print "$My_name: #Biber errors = $error_count, warning messages = $warning_count,\n ",
+# "missing citation messages = $missing_citations, no_citations = $no_citations\n";
+ if ( ! $have_error && $no_citations ) {
+ # If the only errors are missing citations, or lack of citations, that should
+ # count as a warning.
+ # HOWEVER: biber doesn't generate a new bbl. So it is an error condition.
+ return 10;
+ }
+ if ($have_error) {return 2;}
+ if ($have_warning) {return 1;}
+ return 0;
+} #END check_biber_log
+
+#**************************************************
+
+sub run_bibtex {
+ my $return = 999;
+ # Prevent changes we make to environment becoming global:
+ local %ENV = %ENV;
+ my ( $base, $path, $ext ) = fileparseA( $$Psource );
+ if ( $path && $bibtex_fudge ) {
+ # Since (e.g.,) 'bibtex output/main.aux' doesn't find subsidiary .aux
+ # files, as from \@include{chap.aux}, we change directory to the
+ # directory of the top-level .aux file to run bibtex. But we have to
+ # fix search paths for .bib and .bst, since they may be specified
+ # relative to the document directory.
+ my $cwd = good_cwd();
+ foreach ( 'BIBINPUTS', 'BSTINPUTS' ) {
+ if ( exists $ENV{$_} ) {
+ $ENV{$_} = $cwd.$search_path_separator.$ENV{$_};
+ }
+ else {
+ $ENV{$_} = $cwd.$search_path_separator;
+ }
+ }
+ pushd( $path );
+ if (!$silent) {
+ print "$My_name: changed directory to '$path'\n",
+ "Set BIBINPUTS='$ENV{BIBINPUTS}'\n",
+ "Set BSTINPUTS='$ENV{BSTINPUTS}'\n";
+ }
+ $return = &Run_subst( undef, undef, '', $base.$ext, '', $base );
+ popd();
+ if (!$silent) {
+ print "$My_name: changed directory back to '", cwd(), "'\n";
+ }
+ }
+ else {
+ $return = Run_subst();
+ }
+ return $return;
+}
+
+
+#**************************************************
+
+sub check_bibtex_log {
+ # Check for bibtex warnings:
+ # Usage: check_bibtex_log( base_of_bibtex_run )
+ # return 0: OK, 1: bibtex warnings, 2: bibtex errors,
+ # 3: could not open .blg file.
+ # 10: only error is missing \citation commands or a missing aux file
+ # (which would normally be corrected after a later run of
+ # (pdf)latex).
+
+ my $base = $_[0];
+ my $blg_name = "$base.blg";
+ my $blg_file = new FileHandle;
+ open( $blg_file, "<$blg_name" )
+ or return 3;
+ my $have_warning = 0;
+ my $have_error = 0;
+ my $missing_citations = 0;
+ my @missing_aux = ();
+ my $error_count = 0;
+ while (<$blg_file>) {
+ if (/^Warning--/) {
+ #print "Bibtex warning: $_";
+ $have_warning = 1;
+ }
+ elsif ( /^I couldn\'t open auxiliary file (.*\.aux)/ ) {
+ push @missing_aux, $1;
+ }
+ elsif ( /^I found no \\citation commands---while reading file/ ) {
+ $missing_citations++;
+ }
+ elsif (/There (were|was) (\d+) error message/) {
+ $error_count = $2;
+ #print "Bibtex error: count=$error_count $_";
+ $have_error = 1;
+ }
+ }
+ close $blg_file;
+ my $missing = $missing_citations + $#missing_aux + 1;
+
+ if ( $#missing_aux > -1 ) {
+ # Need to make the missing files.
+ warn "$My_name: One or more aux files is missing for bibtex. I'll try\n",
+ " to get (pdf)latex to remake them.\n";
+ rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } );
+ }
+ #print "Bibtex errors = $error_count, missing aux files and citations = $missing\n";
+ if ($have_error && ($error_count <= $missing )
+ && ($missing > 0) ) {
+ # If the only error is a missing citation line, that should only
+ # count as a warning.
+ # Also a missing aux file should be innocuous; it will be created on
+ # next run of (pdf)latex. ?? HAVE I HANDLED THAT CORRECTLY?
+ # But have to deal with the problem that bibtex gives a non-zero
+ # exit code. So leave things as they are so that the user gets
+ # a better diagnostic ??????????????????????????
+# $have_error = 0;
+# $have_warning = 1;
+ return 10;
+ }
+ if ($have_error) {return 2;}
+ if ($have_warning) {return 1;}
+ return 0;
+} #END check_bibtex_log
+
+#**************************************************
+
+sub normalize_force_directory {
+ # Usage, normalize_force_directory( dir, filename )
+ # Perform the following operations:
+ # Clean filename
+ # If filename contains no path component, insert dir in front
+ # Normalize filename
+ # Return result
+ my $default_dir = $_[0];
+ my $filename = clean_filename( $_[1] );
+ my ($base_name, $path ) = fileparse( $filename );
+ if ( $base_name eq $filename ) {
+ $filename = "$default_dir$filename";
+ }
+ return normalize_filename( $filename );
+} #END normalize force_directory
+
+#**************************************************
+
+sub set_names {
+ # Set names of standard files. These are global variables.
+
+ ## Remove extension from filename if was given.
+ if ( find_basename($filename, $root_filename, $texfile_name) ) {
+ if ( $force_mode ) {
+ warn "$My_name: Could not find file '$texfile_name'\n";
+ }
+ else {
+ &ifcd_popd;
+ &exit_msg1( "Could not find file '$texfile_name'",
+ 11);
+ }
+ }
+ $tex_basename = $root_filename; # Base name of TeX file itself
+ if ($jobname ne '' ) {
+ $root_filename = $jobname;
+ $root_filename =~ s/%A/$tex_basename/g;
+ }
+
+ $aux_main = "%Y%R.aux";
+ $log_name = "%Y%R.log";
+ $fdb_name = "%Y%R.$fdb_ext";
+ # Note: Only MiKTeX allows out_dir ne aux_dir. It puts
+ # .fls file in out_dir, not aux_dir, which seems
+ # not natural.
+ $fls_name = "%Z%R.fls";
+
+ $dvi_name = "%Z%R.dvi";
+ $dviF_name = "%Z%R.dviF";
+ $ps_name = "%Z%R.ps";
+ $psF_name = "%Z%R.psF";
+ $pdf_name = "%Z%R.pdf";
+ ## It would be logical for a .xdv file to be put in the out_dir,
+ ## just like a .dvi file. But the only program, MiKTeX, that
+ ## currently implements aux_dir, and hence allows aux_dir ne out_dir,
+ ## puts .xdv file in aux_dir. So we must use %Y not %Z:
+ $xdv_name = "%Y%R.xdv";
+
+ foreach ( $aux_main, $log_name, $fdb_name, $fls_name,
+ $dvi_name, $ps_name, $pdf_name, $xdv_name, $dviF_name, $psF_name ) {
+ s/%R/$root_filename/g;
+ s/%Y/$aux_dir1/;
+ s/%Z/$out_dir1/;
+ }
+
+ $dvi_final = $dvi_name;
+ $ps_final = $ps_name;
+ $pdf_final = $pdf_name;
+ $xdv_final = $xdv_name;
+
+ if ( length($dvi_filter) > 0) {
+ $dvi_final = $dviF_name;
+ }
+ if ( length($ps_filter) > 0) {
+ $ps_final = $psF_name;
+ }
+}
+
+#**************************************************
+
+sub parse_log {
+# Scan log file for: dependent files
+# reference_changed, bad_reference, bad_citation
+# Return value: 1 if success, 0 if no log file.
+# Put results in UPDATES of global variables (which are normally declared
+# local in calling routine, to be suitably scoped):
+# %dependents: maps definite dependents to code:
+# 0 = from missing-file line
+# May have no extension
+# May be missing path
+# 1 = from 'File: ... Graphic file (type ...)' line
+# no path. Should exist, but may need a search, by kpsewhich.
+# 2 = from regular '(...' coding for input file,
+# Has NO path, which it would do if LaTeX file
+# Highly likely to be mis-parsed line
+# 3 = ditto, but has a path character ('/').
+# Should be LaTeX file that exists.
+# If it doesn't exist, we have probably a mis-parsed line.
+# There's no need to do a search.
+# 4 = definitive, which in this subroutine is only done:
+# for default dependents,
+# and for files that exist and are source of conversion
+# reported by epstopdf et al.
+# 5 = Had a missing file line. Now the file exists.
+# 6 = File was written during run. (Overrides 5)
+# 7 = File was created during run to be read in. (Overrides 5 and 6)
+# (e.g., by epstopdf)
+# Treat the following specially, since they have special rules
+# @bbl_files to list of .bbl files.
+# %idx_files to map from .idx files to .ind files.
+# %generated_log: keys give set of files written by (pdf)latex (e.g., aux, idx)
+# as determined by \openout = ... lines in log file.
+# @missing_subdirs = list of needed subdirectories of aux_dir
+# These are needed for writing aux_files when an included file is in
+# a subdirectory relative to the directory of the main TeX file.
+# This variable is only set when the needed subdirectories don't exist,
+# and the aux_dir is non-trivial, which results in an error message in
+# the log file
+# %conversions Internally made conversions from one file to another
+#
+# These may have earlier found information in them, so they should NOT
+# be initialized.
+#
+# Also SET
+# $reference_changed, $bad_reference, $bad_citation
+# $pwd_latex
+#
+# Put in trivial or default values if log file does not exist/cannot be opened
+#
+# Input globals: $primary_out, $fls_file_analyzed
+#
+
+
+# Give a quick way of looking up custom-dependency extensions
+ my %cusdep_from = ();
+ my %cusdep_to = ();
+ foreach ( @cus_dep_list ) {
+ my ($fromext, $toext) = split;
+ $cusdep_from{$fromext} = $cusdep_from{".$fromext"} = $_;
+ $cusdep_to{$toext} = $cusdep_to{".$toext"} = $_;
+ }
+# print "==== Cusdep from-exts:"; foreach (keys %cusdep_from) {print " '$_'";} print "\n";
+# print "==== Cusdep to-exts:"; foreach (keys %cusdep_to) {print " '$_'";} print "\n";
+
+
+ # Filenames given in log file may be preceded by a pathname
+ # denoting current directory. In MiKTeX, this is an absolute
+ # pathname; in TeXLive, it is './'. Either way, we'll want to
+ # remove this pathname string --- see the comments in sub
+ # rdb_set_latex_deps. In order of reliability for use in
+ # normalizing filenames from the log file, the following forms
+ # of the cwd are used:
+ # (a) internally deduced pwd from log file from sequence of lines
+ # **file
+ # (dir/file
+ # if possible. NO THAT'S WRONG if kpsearch is done.
+ # (b) from PWD line in fls file (if available), passed as $pwd_latex
+ # (c) system-given cwd as interpreted by sub good_cwd.
+ # We'll put the first two in @pwd_log
+ my @pwd_log = ();
+ if ($pwd_latex) { push @pwd_log, $pwd_latex; }
+
+ # $primary_out is actual output file (dvi or pdf)
+ # It is initialized before the call to this routine, to ensure
+ # a sensible default in case of misparsing
+
+ $reference_changed = 0;
+ $mult_defined = 0;
+ $bad_reference = 0;
+ $bad_character = 0;
+ $bad_citation = 0;
+
+ my $log_file = new FileHandle;
+ if ( ! open( $log_file, "<$log_name" ) ) {
+ return 0;
+ }
+ if ($log_file_binary) { binmode $log_file; }
+# Collect lines of log file
+ my @lines = ();
+ my $line = 0;
+ my $engine = 'pdfTeX'; # Simple default in case of problems
+ while(<$log_file>) {
+ $line++;
+ # Could use chomp here, but that fails if there is a mismatch
+ # between the end-of-line sequence used by latex and that
+ # used by perl. (Notably a problem with MSWin latex and
+ # cygwin perl!)
+ s/[\n\r]*$//;
+ # Handle wrapped lines:
+ # They are lines brutally broken at exactly $log_wrap chars
+ # excluding line-end. Sometimes a line $log_wrap chars
+ # long is an ordinary line, sometimes it is part of a line
+ # that was wrapped. To handle all cases, I keep both
+ # options open by putting the line into @lines before
+ # and after appending the next line:
+ my $len = length($_);
+ if ($line == 1) {
+ if ( /^This is ([^,]+), / ) {
+ $engine = $1;
+ print "=== TeX engine is '$engine'\n"
+ if (!$silent);
+ if ( /^This is ([^,]+), [^\(]*\(([^\)]+)\)/ ) {
+ $tex_distribution = $2;
+ print "=== TeX distribution is '$tex_distribution'\n"
+ if ($diagnostics);
+ }
+ }
+ else {
+ warn "$My_name: First line of .log file '$log_name' is not in standard format.\n";
+ }
+ }
+ else {
+ # LuaTeX sometimes wraps at 80 instead of 79, so work around this
+ while ( ( ($len == $log_wrap) || ( ($engine eq 'LuaTeX') && ($len == $log_wrap+1) ) )
+ && !eof($log_file) ) {
+ push @lines, $_;
+ my $extra = <$log_file>;
+ $extra =~ s/[\n\r]*$//;
+ $len = length($extra);
+ $_ .= $extra;
+ }
+ }
+ push @lines, $_;
+ }
+ close $log_file;
+
+ push @lines, ""; # Blank line to terminate. So multiline blocks
+ # are always terminated by non-block line, rather than eof.
+
+ $line = 0;
+ my $state = 0; # 0 => before ** line,
+ # 1 => after **filename line, before next line (first file-reading line)
+ # 2 => pwd_log determined.
+ # For parsing multiple line blocks of info
+ my $current_pkg = ""; # non-empty string for package name, if in
+ # middle of parsing multi-line block of form:
+ # Package name ....
+ # (name) ...
+ # ...
+ my $block_type = ""; # Specify information in such a block
+ my $delegated_source = ""; # If it is a file conversion, specify source
+ my $delegated_output = ""; # and output file. (Don't put in
+ # data structure until block is ended.)
+ my %new_conversions = ();
+ my @retries = ();
+ my $log_silent = ($silent || $silence_logfile_warnings);
+ my @warning_list = ();
+LINE:
+ while( ($line <= $#lines) || ($#retries > -1) ) {
+ if ($#retries > -1) {
+ $_ = pop @retries;
+ }
+ else {
+ $_ = $lines[$line];
+ $line ++;
+ }
+ if ( /^! pdfTeX warning/ || /^pdfTeX warning/ ) {
+ # This kind of warning is produced by some versions of pdftex
+ # or produced by my reparse of warnings from other
+ # versions.
+ next;
+ }
+ elsif ( /^(.+)(pdfTeX warning.*)$/ ) {
+ # Line contains a pdfTeX warnings that may have been
+ # inserted directly after other material without an
+ # intervening new line. I think pdfTeX always inserts a
+ # newline after the warning. (From examination of source
+ # code.)
+ push @retries, $1;
+ # But continue parsing the original line, in case it was a
+ # misparse, e.g., of a filename ending in 'pdfTeX';
+ }
+ if ( $line == 1 ){
+ if ( /^This is / ) {
+ # First line OK
+ next LINE;
+ } else {
+ warn "$My_name: Error on first line of '$log_name'.\n".
+ "This is apparently not a TeX log file. ",
+ "The first line is:\n$_\n";
+ $failure = 1;
+ $failure_msg = "Log file '$log_name' appears to have wrong format.";
+ return 0;
+ }
+ }
+
+ if ( ($state == 0) && /^\*\*(.*)$/ ) {
+ # Line containing first line specified to tex
+ # It's either a filename or a command starting with \
+ my $first = $1;
+ $state = 1;
+ if ( ! /^\\/ ) {
+ $source_log = $first;
+ if ( -e "$source_log.tex" ) { $source_log .= '.tex'; }
+ }
+ else {
+ $state = 2;
+ }
+ next LINE;
+ }
+ elsif ( $state == 1 ) {
+ $state = 2;
+ if (-e $source_log) {
+ # then the string preceeding $source_log on the line after the
+ # ** line is probably the PWD as it appears in filenames in the
+ # log file, except if the file appears in two locations.
+ if ( m{^\("([^"]*)[/\\]\Q$source_log\E"} ) {
+ unshift @pwd_log, $1;
+ }
+ elsif ( m{^\((.*)[/\\]\Q$source_log\E} ) {
+ unshift @pwd_log, $1;
+ }
+ }
+ }
+
+ if ( $block_type ) {
+ # In middle of parsing block
+ if ( /^\($current_pkg\)/ ) {
+ # Block continues
+ if ( ($block_type eq 'conversion')
+ && /^\($current_pkg\)\s+Output file: <([^>]+)>/ )
+ {
+ $delegated_output = normalize_clean_filename($1, @pwd_log);
+ }
+ next LINE;
+ }
+ # Block has ended.
+ if ($block_type eq 'conversion') {
+#print "=== $delegated_source -> $delegated_output\n";
+ $new_conversions{$delegated_source} = $delegated_output;
+ }
+ $current_pkg = $block_type
+ = $delegated_source = $delegated_output = "";
+ # Then process current line
+ }
+
+ # Check for changed references, bad references and bad citations:
+ if (/Rerun to get/) {
+ warn "$My_name: References changed.\n" if ! $log_silent;
+ $reference_changed = 1;
+ }
+ if (/^LaTeX Warning: (Reference[^\001]*undefined on input line .*)\./) {
+ push @warning_list, $1;
+ $bad_reference++;
+ }
+ elsif (/^LaTeX Warning: (Label [^\001]* multiply defined.*)\./) {
+ push @warning_list, $1;
+ $mult_defined++;
+ }
+ elsif (/^LaTeX Warning: (Citation[^\001]*undefined on input line .*)\./) {
+ push @warning_list, $1;
+ $bad_citation++;
+ }
+ elsif (/^Package natbib Warning: (Citation[^\001]*undefined on input line .*)\./) {
+ push @warning_list, $1;
+ $bad_citation++;
+ }
+ elsif ( /^Missing character: There is no /
+ || /^! Package inputenc Error: Unicode character /
+ || /^! Bad character code /
+ ) {
+ $bad_character++;
+ }
+ elsif ( /^Document Class: / ) {
+ # Class sign-on line
+ next LINE;
+ }
+ elsif ( /^\(Font\)/ ) {
+ # Font info line
+ next LINE;
+ }
+ elsif (/^No pages of output\./) {
+ $primary_out = '';
+ warn "$My_name: Log file says no output from latex\n";
+ next LINE;
+ }
+ elsif ( /^Output written on\s+(.*)\s+\(\d+\s+page/ ) {
+ $primary_out = normalize_clean_filename($1, @pwd_log);
+ warn "$My_name: Log file says output to '$primary_out'\n"
+ unless $silent;
+ next LINE;
+ }
+ elsif ( /^Overfull /
+ || /^Underfull /
+ || /^or enter new name\. \(Default extension: .*\)/
+ || /^\*\*\* \(cannot \\read from terminal in nonstop modes\)/
+ ) {
+ # Latex error/warning, etc.
+ next LINE;
+ }
+ elsif ( /^\\openout\d+\s*=\s*(.*)\s*$/ ) {
+ # \openout followed by filename followed by line end.
+ # pdflatex and xelatex quote it and wrap,
+ # lualatex leaves filename as is, and doesn't wrap.
+ my $cand = $1;
+ if ( $cand =~ /\`\"([^\'\"]+)\"\'\.$/ ) {
+ # One form of quoting by pdflatex, xelatex: `"..."'.
+ $cand = $1;
+ }
+ elsif ( $cand =~ /\`([^\']+)\'\.$/ ) {
+ # Another form of quoting by pdflatex, xelatex: `...'.
+ $cand = $1;
+ }
+ if ( $cand =~ /[\`\'\"]/){
+ # Bad quotes: e.g., incomplete wrapped line
+ next LINE;
+ }
+ $generated_log{normalize_force_directory( $aux_dir1, $cand )} = 1;
+ next LINE;
+ }
+ # Test for conversion produced by package:
+ elsif ( /^Package (\S+) Info: Source file: <([^>]+)>/ ) {
+ # Info. produced by epstopdf (and possibly others)
+ # about file conversion
+ $current_pkg = normalize_clean_filename($1, @pwd_log);
+ $delegated_source = normalize_clean_filename($2, @pwd_log);
+ $block_type = 'conversion';
+ next LINE;
+ }
+# Test for writing of index file. The precise format of the message
+# depends on which package (makeidx.sty , multind.sty or index.sty) and
+# which version writes the message.
+ elsif ( /Writing index file (.*)$/ ) {
+ my $idx_file = '';
+ if ( /^Writing index file (.*)$/ ) {
+ # From makeidx.sty or multind.sty
+ $idx_file = $1;
+ }
+ elsif ( /^index\.sty> Writing index file (.*)$/ ) {
+ # From old versions of index.sty
+ $idx_file = $1;
+ }
+ elsif ( /^Package \S* Info: Writing index file (.*) on input line/ ) {
+ # From new versions of index.sty
+ $idx_file = $1;
+ }
+ else {
+ warn "$My_name: Message indicates index file was written\n",
+ " ==> but I do not know how to understand it: <==\n",
+ " '$_'\n";
+ next LINE;
+ }
+ # Typically, there is trailing space, not part of filename:
+ $idx_file =~ s/\s*$//;
+ # When (pdf)latex is run with an -output-directory
+ # or an -aux_directory, the file name does not contain
+ # the output path; fix this, after removing quotes:
+ $idx_file = normalize_force_directory( $aux_dir1, $idx_file );
+ my ($idx_base, $idx_path, $idx_ext) = fileparseA( $idx_file );
+ $idx_base = $idx_path.$idx_base;
+ $idx_file = $idx_base.$idx_ext;
+ if ( $idx_ext eq '.idx' ) {
+ warn "$My_name: Index file '$idx_file' was written\n"
+ unless $silent;
+ $idx_files{$idx_file} = [ "$idx_base.ind", $idx_base ];
+ }
+ elsif ( exists $cusdep_from{$idx_ext} ) {
+ if ( !$silent ) {
+ warn "$My_name: Index file '$idx_file' was written\n";
+ warn " Cusdep '$cusdep_from{$idx_ext}' should be used\n";
+ }
+ # No action needed here
+ }
+ else {
+ warn "$My_name: Index file '$idx_file' written\n",
+ " ==> but it has an extension I do not know how to handle <==\n";
+ }
+
+ next LINE;
+ }
+ elsif ( /^No file (.*?\.bbl)./ ) {
+ # When (pdf)latex is run with an -output-directory
+ # or an -aux_directory, the file name does not contain
+ # the output path; fix this, after removing quotes:
+ my $bbl_file = normalize_force_directory( $aux_dir1, $1 );
+ warn "$My_name: Non-existent bbl file '$bbl_file'\n $_\n";
+ $dependents{$bbl_file} = 0;
+ push @bbl_files, $bbl_file;
+ next LINE;
+ }
+ foreach my $pattern (@file_not_found) {
+ if ( /$pattern/ ) {
+ my $file = clean_filename($1);
+ warn "$My_name: Missing input file: '$file' from line\n '$_'\n"
+ unless $silent;
+ $dependents{normalize_filename($file, @pwd_log)} = 0;
+ my $file1 = $file;
+ if ( $aux_dir ) {
+ # Allow for the possibility that latex generated
+ # a file in $aux_dir, from which the missing file can
+ # be created by a cusdep (or other) rule that puts
+ # the result in $out_dir. If the announced missing file
+ # has no path, then it would be effectively a missing
+ # file in $aux_dir, with a path. So give this alternate
+ # location.
+ # It is also possible to have a file that is in a directory
+ # relative to the aux_dir, so allow for that as well
+ my $file1 = normalize_force_directory( $aux_dir1, $file );
+ $dependents{$file1} = 0;
+ $dependents{$aux_dir1.$file} = 0;
+
+ }
+ next LINE;
+ }
+ }
+ if ( (! $fls_file_analyzed)
+ && /^File: (.+) Graphic file \(type / ) {
+ # First line of message from includegraphics/x
+ # But this does NOT include full path information
+ # (if exact match is not found and a non-trivial
+ # kpsearch was done by (pdf)latex).
+ # But the source-file information is in the fls file,
+ # if we are using it.
+ $dependents{normalize_clean_filename($1, @pwd_log)} = 1;
+ next LINE;
+ }
+ # Now test for generic lines to ignore, only after special cases!
+ if ( /^File: / ) {
+ # Package sign-on line. Includegraphics/x also produces a line
+ # with this signature, but I've already handled it.
+ next LINE;
+ }
+ if ( /^Package: / ) {
+ # Package sign-on line
+ next LINE;
+ }
+ if (/^\! LaTeX Error: / ) {
+ next LINE;
+ }
+ if ( m[^! I can't write on file `(.*)/([^/']*)'.\s*$] ) {
+ my $dir = $1;
+ my $file = $2;
+ my $full_dir = $aux_dir1.$dir;
+ if ( ($aux_dir ne '') && (! -e $full_dir) && ( $file =~ /\.aux$/) ) {
+ warn "$My_name: === There were problems writing to '$file' in '$full_dir'\n",
+ " I'll try to make the subdirectory later.\n"
+ if $diagnostics;
+ push @missing_subdirs, $full_dir;
+ }
+ else {
+ warn "$My_name: ====== There were problems writing to",
+ "----- '$file' in '$full_dir'.\n",
+ "----- But this is not the standard situation of\n",
+ "----- aux file to subdir of output directory, with\n",
+ "----- non-existent subdir\n",
+ }
+ }
+
+ if ( ($fls_file_analyzed) && (! $analyze_input_log_always) ) {
+ # Skip the last part, which is all about finding input
+ # file names which should all appear more reliably in the
+ # fls file.
+ next LINE;
+ }
+
+ my @new_includes = ();
+
+ GRAPHICS_INCLUDE_CANDIDATE:
+ while ( /<([^>]+)(>|$)/g ) {
+ if ( -f $1 ) { push @new_includes, $1; }
+ } # GRAPHICS_INCLUDE_CANDIDATE:
+
+ INCLUDE_CANDIDATE:
+ while ( /\((.*$)/ ) {
+ # Filename found by
+ # '(', then filename, then terminator.
+ # Terminators: obvious candidates: ')': end of reading file
+ # '(': beginning of next file
+ # ' ': space is an obvious separator
+ # ' [': start of page: latex
+ # and pdflatex put a
+ # space before the '['
+ # '[': start of config file
+ # in pdflatex, after
+ # basefilename.
+ # '{': some kind of grouping
+ # Problem:
+ # All or almost all special characters are allowed in
+ # filenames under some OS, notably UNIX. Luckily most cases
+ # are rare, if only because the special characters need
+ # escaping. BUT 2 important cases are characters that are
+ # natural punctuation
+ # Under MSWin, spaces are common (e.g., "C:\Program Files")
+ # Under VAX/VMS, '[' delimits directory names. This is
+ # tricky to handle. But I think few users use this OS
+ # anymore.
+ #
+ # Solution: use ' [', but not '[' as first try at delimiter.
+ # Then if candidate filename is of form 'name1[name2]', then
+ # try splitting it. If 'name1' and/or 'name2' exists, put
+ # it/them in list, else just put 'name1[name2]' in list.
+ # So form of filename is now:
+ # '(',
+ # then any number of characters that are NOT ')', '(', or '{'
+ # (these form the filename);
+ # then ' [', or ' (', or ')', or end-of-string.
+ # That fails for pdflatex
+ # In log file:
+ # '(' => start of reading of file, followed by filename
+ # ')' => end of reading of file
+ # '[' => start of page (normally preceeded by space)
+ # Remember:
+ # filename (on VAX/VMS) may include '[' and ']' (directory
+ # separators)
+ # filenames (on MS-Win) commonly include space.
+ # filenames on UNIX can included space.
+ # Miktex quotes filenames
+ # But web2c doesn't. Then
+ # (string message
+ # is ambiguous: is the filename "string" or "string message".
+ # Allow both as candidates, since user filenames with spaces
+ # are rare. System filenames with spaces are common, but
+ # they are normally followed by a newline rather than messages.
+
+ # First step: replace $_ by whole of line after the '('
+ # Thus $_ is putative filename followed by other stuff.
+ $_ = $1;
+ # Array of new candidate include files; sometimes more than one.
+ my $quoted = 0;
+ if ( /^\"([^\"]+)\"/ ) {
+ # Quoted file name, as from MikTeX
+ $quoted = 1;
+ }
+ elsif ( /^\"/ ) {
+ # Incomplete quoted file, as in wrapped line before appending
+ # next line
+ next LINE;
+ }
+ elsif ( /^([^\(^\)]*?)\s+[\[\{\<]/ ) {
+ # Terminator: space then '[' or '{' or '<'
+ # Use *? in condition: to pick up first ' [' (etc)
+ # as terminator
+ }
+ elsif ( /^([^\(^\)]*)\s+(?=\()/ ) {
+ # Terminator is ' (', but '(' isn't in matched string,
+ # so we keep the '(' ready for the next match
+ }
+ elsif ( /^([^\(^\)]*)(\))/ ) {
+ # Terminator is ')'
+ }
+ else {
+ #Terminator is end-of-string
+ }
+ $_ = $'; # Put $_ equal to the unmatched tail of string '
+ my $include_candidate = $1;
+ $include_candidate =~ s/\s*$//; # Remove trailing space.
+ if ($quoted) {
+ # Remove quotes around filename.
+ $include_candidate =~ s/^\"(.*)\"$/$1/;
+ }
+ elsif ( !$quoted && ($include_candidate =~ /(\S+)\s/ ) ){
+ # Non-space-containing filename-candidate
+ # followed by space followed by message
+ # (Common)
+ push @new_includes, $1;
+ }
+ if ($include_candidate =~ /[\"\'\`]/) {
+ # Quote inside filename. Probably misparse.
+ next INCLUDE_CANDIDATE;
+ }
+ if ( $include_candidate eq "[]" ) {
+ # Part of overfull hbox message
+ next INCLUDE_CANDIDATE;
+ }
+ if ( $include_candidate =~ /^\\/ ) {
+ # Part of font message
+ next INCLUDE_CANDIDATE;
+ }
+
+ push @new_includes, $include_candidate;
+ if ( $include_candidate =~ /^(.+)\[([^\]]+)\]$/ ) {
+ # Construct of form 'file1[file2]', as produced by pdflatex
+ if ( -e $1 ) {
+ # If the first component exists, we probably have the
+ # pdflatex form
+ push @new_includes, $1, $2;
+ }
+ else {
+ # We have something else.
+ # So leave the original candidate in the list
+ }
+ }
+ } # INCLUDE_CANDIDATE
+
+ INCLUDE_NAME:
+ foreach my $include_name (@new_includes) {
+ if ($include_name =~ /[\"\'\`]/) {
+ # Quote inside filename. Probably misparse.
+ next INCLUDE_NAME;
+ }
+ $include_name = normalize_filename( $include_name, @pwd_log );
+ my ($base, $path, $ext) = fileparseB( $include_name );
+ if ( ($path eq './') || ($path eq '.\\') ) {
+ $include_name = $base.$ext;
+ }
+ if ( $include_name !~ m'[/|\\]' ) {
+ # Filename does not include a path character
+ # High potential for misparsed line
+ $dependents{$include_name} = 2;
+ } else {
+ $dependents{$include_name} = 3;
+ }
+ if ( $ext eq '.bbl' ) {
+ warn "$My_name: Found input bbl file '$include_name'\n"
+ unless $silent;
+ push @bbl_files, $include_name;
+ }
+ } # INCLUDE_NAME
+ } # LINE
+
+ # Default includes are always definitive:
+ foreach (@default_includes) { $dependents{$_} = 4; }
+
+ ###print "New parse: \n";
+ ###foreach (sort keys %dependents) { print " '$_': $dependents{$_}\n"; }
+
+ my @misparsed = ();
+ my @missing = ();
+ my @not_found = ();
+
+ my %kpsearch_candidates = ();
+CANDIDATE:
+ foreach my $candidate (keys %dependents) {
+ my $code = $dependents{$candidate};
+ if ( -d $candidate ) {
+ # If $candidate is directory, it was presumably found from a
+ # mis-parse, so remove it from the list. (Misparse can
+ # arise, for example from a mismatch of latexmk's $log_wrap
+ # value and texmf.cnf value of max_print_line.)
+ delete $dependents{$candidate};
+ }
+ elsif ( -e $candidate ) {
+ if ( exists $generated_log{$candidate} ){
+ $dependents{$candidate} = 6;
+ }
+ elsif ($code == 0) {
+ $dependents{$candidate} = 5;
+ }
+ else {
+ $dependents{$candidate} = 4;
+ }
+ }
+ elsif ($code == 1) {
+ # Graphics file that is supposed to have been read.
+ # Candidate name is as given in source file, not as path
+ # to actual file.
+ # We have already tested that file doesn't exist, as given.
+ # so use kpsewhich.
+ # If the file still is not found, assume non-existent;
+ $kpsearch_candidates{$candidate} = 1;
+ delete $dependents{$candidate};
+ }
+ elsif ($code == 2) {
+ # Candidate is from '(...' construct in log file, for input file
+ # which should include pathname if valid input file.
+ # Name does not have pathname-characteristic character (hence
+ # $code==2.
+ # We get here if candidate file does not exist with given name
+ # Almost surely result of a misparsed line in log file.
+ delete $dependents{$candidate};
+ push @misparse, $candidate;
+ }
+ elsif ($code == 3) {
+ # Candidate is from '(...' construct in log file, for input file
+ # which should include pathname if valid input file.
+ # Name does have pathname-characteristic character (hence
+ # $code==3.
+ # But we get here only if candidate file does not exist with
+ # given name.
+ # Almost surely result of a misparsed line in log file.
+ # But with lower probability than $code == 2
+ delete $dependents{$candidate};
+ push @misparse, $candidate;
+ }
+ elsif ($code == 0) {
+ my ($base, $path, $ext) = fileparseA($candidate);
+ $ext =~ s/^\.//;
+ if ( ($ext eq '') && (-e "$path$base.tex") ) {
+ # I don't think the old version was correct.
+ # If the missing-file report was of a bare
+ # extensionless file, and a corresponding .tex file
+ # exists, then the missing file does not correspond
+ # to the missing file, unless the .tex file was
+ # created during the run.
+ # OLD $dependents{"$path$base.tex"} = 4;
+ # OLD delete $dependents{$candidate};
+ # NEW:
+ $dependents{"$path$base.tex"} = 4;
+ }
+ push @missing, $candidate;
+ }
+ }
+
+ my @kpsearch_candidates = keys %kpsearch_candidates;
+ if (@kpsearch_candidates) {
+ foreach my $result ( kpsewhich( @kpsearch_candidates ) ) {
+ $dependents{$result} = 4;
+ }
+ }
+
+CANDIDATE_PAIR:
+ foreach my $delegated_source (keys %new_conversions) {
+ my $delegated_output = $new_conversions{$delegated_source};
+ my $rule = "Delegated $delegated_source, $delegated_output";
+ # N.B. $delegated_source eq '' means the output file
+ # was created without a named input file.
+ foreach my $candidate ($delegated_source, $delegated_output) {
+ if (! -e $candidate ) {
+ # The file might be somewhere that can be found
+ # in the search path of kpathsea:
+ my @kpse_result = kpsewhich( $candidate,);
+ if ($#kpse_result > -1) {
+ $candidate = $kpse_result[0];
+ }
+ }
+ }
+ if ( ( (-e $delegated_source) || ($delegated_source eq '') )
+ && (-e $delegated_output) )
+ {
+ $conversions{$delegated_output} = $delegated_source;
+ $dependents{$delegated_output} = 7;
+ if ($delegated_source) {
+ $dependents{$delegated_source} = 4;
+ }
+ }
+ elsif (!$silent) {
+ print "Logfile claimed conversion from '$delegated_source' ",
+ "to '$delegated_output'. But:\n";
+ if (! -e $delegated_output) {
+ print " Output file does not exist\n";
+ }
+ if ( ($delegated_source ne '') && (! -e $delegated_source) ) {
+ print " Input file does not exist\n";
+ }
+ }
+ }
+
+ if ( ($#warning_list >= 0) && !$log_silent ) {
+ @warning_list = uniqs( @warning_list );
+ show_array( "$My_name: List of undefined refs and citations:",
+ @warning_list );
+ }
+
+ if ( $diagnostics ) {
+ @misparse = uniqs( @misparse );
+ @missing = uniqs( @missing );
+ @not_found = uniqs( @not_found );
+ my @dependents = sort( keys %dependents );
+
+ my $dependents = $#dependents + 1;
+ my $misparse = $#misparse + 1;
+ my $missing = $#missing + 1;
+ my $not_found = $#not_found + 1;
+ my $exist = $dependents - $not_found - $missing;
+ my $bbl = $#bbl_files + 1;
+
+ print "$dependents dependent files detected, of which ",
+ "$exist exist, $not_found were not found,\n",
+ " and $missing appear not to exist.\n";
+ print "Dependents:\n";
+ foreach (@dependents) {
+ print " '$_' ";
+ if ( $dependents{$_} == 6 ) { print " written by (pdf)latex";}
+ if ( $dependents{$_} == 7 ) { print " converted by (pdf)latex";}
+ print "\n";
+ }
+ if ($not_found > 0) {
+ print "Not found:\n";
+ foreach (@not_found) { print " $_\n"; }
+ }
+ if ($missing > 0) {
+ print "Not existent:\n";
+ foreach (@missing) { print " $_\n"; }
+ }
+ if ( $bbl > 0 ) {
+ print "Input bbl files:\n";
+ foreach (@bbl_files) { print " $_\n"; }
+ }
+
+ if ( $misparse > 0 ) {
+ print "Possible input files, perhaps from misunderstood lines in .log file:\n";
+ foreach ( @misparse ) { print " $_\n"; }
+ }
+ }
+ return 1;
+} #END parse_log
+
+#************************************************************
+
+sub find_set_log {
+ # Locate the log file, if possible. This allows for possible configuration
+ # errors, e.g., because the command for (*)latex was such that it did not
+ # do the setting of -output-directory or -aux-directory that the user intended,
+ # or because the version used did not support one or other of these options.
+ # Put result in $where_log (see its initial declaration/definition for details).
+ # Change $aux_dir and/or $out_dir as appropriate, and make consequent changes.
+ #
+ # Probably further attention to location of output file (.dvi, .pdf, or .xdv)
+ # could be done, to get $out_dir and $$Pdest more accurately set.
+ #
+ # Typical configuration errors that lead to the need for this subroutine:
+ # %O not used in command definition, so directory options don't getpassed
+ # to (*)latex.
+ # Use of $aux_dir different to $out_dir, when (*)latex doesn't support
+ # the -aux-directory option (notably with TeXLive distribution).
+ if ($where_log >= 0) {
+ # .log file was found on previous run. No need to repeat search, since
+ # if the location were to change from run to run, we'd have other
+ # serious difficulties that are to hard to deal with.
+ return;
+ }
+ if ( test_gen_file( "$aux_dir1$root_filename.log" ) ) {
+ # .log file is in expected place.
+ $where_log = 1;
+ }
+ elsif ( test_gen_file( "$out_dir1$root_filename.log" ) ) {
+ # .log file is in out_dir not in aux_dir.
+ # Presumably there is a configuration error
+ # that prevents aux_dir from being used by latex.
+ # So change $aux_dir to the actually used value.
+ $where_log = 2;
+ $aux_dir = $out_dir;
+ }
+ elsif ( test_gen_file( "$root_filename.log" ) ) {
+ # .log file is not in out_dir nor in aux_dir, but is in cwd.
+ # Presumably there is a configuration error
+ # that prevents the directories from being used by latex.
+ # So change $aux_dir to the actually used value.
+ $where_log = 3;
+ $aux_dir = "";
+ }
+ else {
+ # No .log file found
+ $failure = 1;
+ $$Plast_result = 2;
+ $where_log = 0;
+ $failure_msg
+ = "(Pdf)LaTeX didn't generate the expected log file '$log_name'\n";
+ }
+ if ($where_log > 1) {
+ warn "$My_name: Changed aux_dir from '$aux_dir_requested' to '$aux_dir'\n".
+ " to allow for probable configuration error\n";
+ # Allow for the changes associated with change of $aux_dir:
+ &set_dirs_etc;
+ &set_names;
+ warn "$My_name: Actual .log file is\n",
+ " '$log_name'\n",
+ " instead of the value\n",
+ " '$aux_dir_requested/$root_filename.log'\n",
+ " that seemed to be intended.\n";
+ }
+}
+
+#************************************************************
+
+sub parse_fls {
+ my ($fls_name, $Pinputs, $Poutputs, $Pfirst_read_after_write, $Ppwd_latex ) = @_;
+ %$Pinputs = %$Poutputs = %$Pfirst_read_after_write = ();
+ my $fls_file = new FileHandle;
+ # Make a note of current working directory
+ # I'll update it from the fls file later
+ # Currently I don't use this, but it would be useful to use
+ # this when testing prefix for cwd in a filename, by
+ # giving (pdf)latex's best view of the cwd. Note that the
+ # value given by the cwd() function may be mangled, e.g., by cygwin
+ # compared with native MSWin32.
+ #
+ # Two relevant forms of cwd exist: The system one, which we can find, and
+ # the one reported by (pdf)latex in the fls file. It will be
+ # useful to remove leading part of cwd in filenames --- see the
+ # comments in sub rdb_set_latex_deps. Given the possible multiplicity
+ # of representations of cwd, the one reported in the fls file should
+ # be definitive in the fls file.
+
+ my $cwd = good_cwd();
+ if ( ! open ($fls_file, "<$fls_name") ) {
+ return 1;
+ }
+ foreach $_ ( <$fls_file> ) {
+ # Remove trailing CR and LF. Thus we get correct behavior when an fls file
+ # is produced by MS-Windows program (e.g., in MiKTeX) with CRLF line ends,
+ # but is read by Unix Perl (which treats LF as line end, and preserves CRLF
+ # in read-in lines):
+ $_ =~ s/[\n\r]*$//;
+ if (/^\s*PWD\s+(.*)$/) {
+ $cwd = $1;
+ $$Ppwd_latex = $cwd;
+ if ( $cwd =~ /\"/ ) {
+ warn "$My_name: The working directory has a '\"' character in its name:\n",
+ " '$cwd'\n This can cause me trouble. Beware!\n";
+ }
+ }
+ elsif (/^\s*INPUT\s+(.*)$/) {
+ # Take precautions against aliasing of foo, ./foo and other possibilities for cwd.
+ my $file = $1;
+ # Remove exactly pwd reported in this file, and following separator.
+ # MiKTeX reports absolute pathnames, and this way of removing PWD insulates
+ # us from coding issues if the PWD contains non-ASCII characters. What
+ # coding scheme (UTF-8, code page, etc) is used depends on OS, TeX
+ # implementation, ...
+ if ( defined $$Ppwd_latex ) {
+ $file =~ s(^\Q$$Ppwd_latex\E[\\/])();
+ }
+ $file = normalize_filename( $file );
+ if ( (exists $$Poutputs{$file}) && (! exists $$Pinputs{$file}) ) {
+ $$Pfirst_read_after_write{$file} = 1;
+ }
+ $$Pinputs{$file} = 1;
+ }
+ elsif (/^\s*OUTPUT\s+(.*)$/) {
+ # Take precautions against aliasing of foo, ./foo and other possibilities for cwd.
+ my $file = $1;
+ $file =~ s(^\Q$$Ppwd_latex\E[\\/])();
+ $file = normalize_filename( $file );
+ $$Poutputs{$file} = 1;
+ }
+ }
+ close( $fls_file );
+ return 0;
+} #END parse_fls
+
+#************************************************************
+
+sub clean_filename {
+ # Convert quoted filename as found in log file to filename without quotes
+ # Allows arbitrarily embedded double-quoted substrings, includes the
+ # cases
+ # 1. `"string".ext', which arises e.g., from \jobname.bbl:
+ # when the base filename contains spaces, \jobname has quotes.
+ # and from \includegraphics with basename specified.
+ # Also deals with filenames written by asymptote.sty
+ # 2. Or "string.ext" from \includegraphcs with basename and ext specified.
+ # and from MiKTeX logfile for input files with spaces.
+ # Doubled quotes (e.g., A""B) don't get converted.
+ # Neither do unmatched quotes.
+ my $filename = $_[0];
+ while ( $filename =~ s/^([^\"]*)\"([^\"]+)\"(.*)$/$1$2$3/ ) {}
+ return $filename;
+}
+
+# ------------------------------
+
+sub normalize_filename {
+ # Usage: normalize_filename( filename [, extra forms of name of cwd] )
+ # Returns filename with removal of various forms for cwd, and
+ # with conversion of directory separator to '/' only
+ #
+ my ( $file, @dirs ) = @_;
+ my $file1 = $file; # Saved original value
+ my $cwd = good_cwd();
+ # Normalize files to use / to separate directory components:
+ # (Note both / and \ are allowed under MSWin.)
+ foreach ($cwd, $file, @dirs) {
+ s(\\)(/)g;
+ }
+ # Remove initial component equal to current working directory.
+ # Use \Q and \E round directory name in regex to avoid interpretation
+ # of metacharacters in directory name:
+ foreach my $dir ( @dirs, '.', $cwd ) {
+ if ( $file =~ s(^\Q$dir\E/)() ) {
+ last;
+ }
+ }
+ return $file;
+}
+
+# ------------------------------
+
+sub normalize_clean_filename {
+ # Usage: normalize_clean_filename( filename [, extra forms of name of cwd] )
+ # Same as normalize_filename, but first remove any double quotes, as
+ # done by clean_filename, which is appropriate for filenames from log file.
+ my ($file, @dirs) = @_;
+ return normalize_filename( clean_filename( $file ) , @dirs );
+}
+
+#************************************************************
+
+sub fix_pattern {
+ # Escape the characters [ and {, to give a pattern for use in glob
+ # with these characters taken literally.
+ my $pattern = shift;
+ $pattern =~ s/\[/\\\[/g;
+ $pattern =~ s/\{/\\\{/g;
+ return $pattern;
+}
+
+#************************************************************
+
+sub parse_aux {
+ #Usage: parse_aux( $aux_file, \@new_bib_files, \@new_aux_files, \@new_bst_files )
+ # Parse aux_file (recursively) for bib files, and bst files.
+ # If can't open aux file, then
+ # Return 0 and leave @new_bib_files empty
+ # Else set @new_bib_files from information in the aux files
+ # And:
+ # Return 1 if no problems
+ # Return 2 with @new_bib_files empty if there are no \bibdata
+ # lines.
+ # Return 3 if I couldn't locate all the bib_files
+ # Set @new_aux_files to aux files parsed
+
+ my $aux_file = $_[0];
+ local $Pbib_files = $_[1];
+ local $Paux_files = $_[2];
+ local $Pbst_files = $_[3];
+
+ @$Pbib_files = ();
+ @$Pbst_files = ();
+ @$Paux_files = ();
+
+ parse_aux1( $aux_file );
+ if ($#{$Paux_files} < 0) {
+ return 0;
+ }
+ @$Pbib_files = uniqs( @$Pbib_files );
+ @$Pbst_files = uniqs( @$Pbst_files );
+
+ if ( $#{$Pbib_files} == -1 ) {
+ warn "$My_name: No .bib files listed in .aux file '$aux_file' \n",
+ return 2;
+ }
+ my @not_found = &find_file_list1( $Pbib_files, $Pbib_files,
+ '.bib', \@BIBINPUTS );
+ @$Pbib_files = uniqs( @$Pbib_files );
+ &find_file_list1( $Pbst_files, $Pbst_files, '.bst' );
+ @$Pbst_files = uniqs( @$Pbst_files );
+ my @bad_bib = ();
+ foreach ( @$Pbib_files ) {
+ if ( /\s/ ) { push @bad_bib, $_; }
+ }
+ if ($#bad_bib >= 0) {
+ warn "$My_name: White space in an argument list for \\bibliography.\n",
+ " which is not allowed by bibtex. Bad arguments:\n";
+ foreach (@bad_bib ) { warn " '$_'\n"; }
+ return 3;
+ }
+ if ( $#not_found < 0) {
+ warn "$My_name: Found bibliography file(s) [@$Pbib_files]\n"
+ unless $silent;
+ }
+ else {
+ warn "$My_name: Failed to find one or more bibliography files:\n";
+ foreach (@not_found) { warn " '$_'\n"; }
+ if ($force_mode) {
+ warn "==== Force_mode is on, so I will continue. ",
+ "But there may be problems ===\n";
+ }
+ return 3;
+ }
+ return 1;
+} #END parse_aux
+
+#************************************************************
+
+sub parse_aux1
+# Parse single aux file for bib files.
+# Usage: &parse_aux1( aux_file_name )
+# Append newly found bib_filenames in @$Pbib_files, already
+# initialized/in use.
+# Append aux_file_name to @$Paux_files if aux file opened
+# Recursively check \@input aux files
+# Return 1 if success in opening $aux_file_name and parsing it
+# Return 0 if fail to open it
+{
+ my $aux_file = $_[0];
+ my $aux_fh = new FileHandle;
+ if (! open($aux_fh, $aux_file) ) {
+ warn "$My_name: Couldn't find aux file '$aux_file'\n";
+ return 0;
+ }
+ push @$Paux_files, $aux_file;
+AUX_LINE:
+ while (<$aux_fh>) {
+ if ( /^\\bibdata\{(.*)\}/ ) {
+ # \\bibdata{comma_separated_list_of_bib_file_names}
+ # These are normally without the '.bib' extension.
+ push @$Pbib_files, split /,/, $1;
+ }
+ elsif ( /^\\bibstyle\{(.*)\}/ ) {
+ # \\bibstyle{bst_file_name}
+ # Normally without the '.bst' extension.
+ push @$Pbst_files, split /,/, $1;
+ }
+ elsif ( /^\\\@input\{(.*)\}/ ) {
+ # \\@input{next_aux_file_name}
+ &parse_aux1( $aux_dir1.$1 );
+ }
+ else {
+ foreach my $Psub (@aux_hooks) {
+ &$Psub;
+ }
+ }
+ }
+ close($aux_fh);
+ return 1;
+} #END parse_aux1
+
+#************************************************************
+
+#************************************************************
+#************************************************************
+#************************************************************
+
+# Manipulations of main file database:
+
+#************************************************************
+
+sub fdb_get {
+ # Call: fdb_get(filename [, check_time])
+ # Returns an array (time, size, md5) for the current state of the
+ # named file.
+ # The optional argument check_time is either the run_time of some command
+ # that may have changed the file or the last time the file was checked
+ # for changes --- see below.
+ # For non-existent file, deletes its entry in fdb_current,
+ # and returns (0,-1,0) (whatever is in @nofile).
+ # As an optimization, the md5 value is taken from the cache in
+ # fdb_current, if the time and size stamp indicate that the
+ # file has not changed.
+ # The md5 value is recalculated if
+ # the current filetime differs from the cached value:
+ # file has been written
+ # the current filesize differs from the cached value:
+ # file has definitely changed
+ # But the file can also be rewritten without change in filetime when
+ # file processing happens within the 1-second granularity of the
+ # timestamp (notably for aux files from latex on a short source file).
+ # The only case that concerns us is when the file is an input to a program
+ # at some runtime t, the file is rewritten later by the same or another
+ # program, with timestamp t, and when the initial file also has
+ # timestamp t.
+ # A test is applied for this situation if the check_time argument is
+ # supplied and is nonzero.
+
+ my ($file, $check_time) = @_;
+ if ( ! defined $check_time ) { $check_time = 0;}
+ my ($new_time, $new_size) = get_time_size($file);
+ if ( $new_size < 0 ) {
+ delete $fdb_current{$file};
+ return @nofile;
+ }
+ my $recalculate_md5 = 0;
+ if ( ! exists $fdb_current{$file} ) {
+ # Ensure we have a record.
+ $fdb_current{$file} = [@nofile];
+ $recalculate_md5 = 1;
+ }
+ my $file_data = $fdb_current{$file};
+ my ( $time, $size, $md5 ) = @$file_data;
+
+ if ( ($new_time != $time) || ($new_size != $size)
+ || ( $check_time && ($check_time == $time ) )
+ ) {
+ # Only force recalculation of md5 if time or size changed.
+ # However, the physical file time may have changed without
+ # affecting the value of the time coded in $time, because
+ # times are computed with a 1-second granularity.
+ # The only case to treat specially is where the file was created,
+ # then used by the current rule, and then rewritten, all within
+ # the granularity size, otherwise the value of the reported file
+ # time changed, and we've handled it. But we may have already
+ # checked this at an earlier time than the current check. So the
+ # only dangerous case is where the file time equals a check_time,
+ # which is either the run_time of the command or the time of a
+ # previous check.
+ # Else we assume file is really unchanged.
+ $recalculate_md5 = 1;
+ }
+ if ($recalculate_md5) {
+ @$file_data = ( $new_time, $new_size, get_checksum_md5( $file ) );
+ }
+ return @$file_data;;
+} #END fdb_get
+
+#************************************************************
+
+sub fdb_set {
+ # Call: fdb_set(filename, $time, $size, $md5 )
+ # Set data in file data cache, i.e., %fdb_current
+ my ($file, $time, $size, $md5 ) = @_;
+ if ( ! exists $fdb_current{$file} ) {
+ $fdb_current{$file} = [@nofile];
+ }
+ @{$fdb_current{$file}} = ( $time, $size, $md5 );
+} #END fdb_set
+
+#************************************************************
+
+sub fdb_show {
+ # Displays contents of fdb
+ foreach my $file ( sort keys %fdb_current ) {
+ print "'$file': @{$fdb_current{$file}}\n";
+ }
+} #END fdb_show
+
+#************************************************************
+#************************************************************
+#************************************************************
+
+# Routines for manipulating rule database
+
+#************************************************************
+
+sub rdb_read {
+ # Call: rdb_read( $in_name )
+ # Sets rule database from saved file, in format written by rdb_write.
+ # Returns -1 if file could not be read else number of errors.
+ # Thus return value on success is 0
+ # Requires: Rule database initialized with standard rules, with
+ # conditions corresponding to requests determined by
+ # initialization and command line options.
+ # Asssumption: Normally the fdb_latexmk file contains state of
+ # rules and files corresponding to end of last
+ # compilation, and the rules in the file were
+ # active on that run.
+ # Complications arise when that state does not correspond to current
+ # rule set:
+ # (a) Configuration etc may have changed: e.g., different out_dir,
+ # different target rules and files, including different tex engine.
+ # (b) Output extension of primary rule may be different from current
+ # initialized one, because of document properties (use of
+ # \pdfoutput etc).
+ # (c) The same may arise because of misconfigured rules, a situation
+ # that may or may not have changed in current run.
+ # (d) The primary engine requested may not be the one used in
+ # the previous run, possibly because (i) request has
+ # changed, or (ii) document metacommand was obeyed to change
+ # engine. (The last is not currently implemented, but
+ # may/should be in the future.)
+ # (e) Something else, e.g., copying/editing of fdb_latexmk file.
+ #
+ local $in_name = $_[0];
+ my $in_handle = new FileHandle;
+ $in_handle->open( $in_name, '<' )
+ or return ();
+ my $errors = 0;
+ my $state = -1; # Values: -1: before start; 0: outside rule;
+ # 1: in source section;
+ # 2: in generated file section;
+ # 10: ignored rule.
+ my $rule = '';
+ local $run_time = 0;
+ local $source = '';
+ local $dest = '';
+ my $base = '';
+ my %old_actives = (); # Hash: keys are rules in fdb_latexmk file
+ local %new_sources = (); # Hash: rule => { file=>[ time, size, md5, fromrule ] }
+ my $new_source = undef; # Reference to hash of sources for current rule
+LINE:
+ while ( <$in_handle> ) {
+ # Remove leading and trailing white space.
+ s/^\s*//;
+ s/\s*$//;
+ if ($state == -1) {
+ if ( ! /^# Fdb version ([\d]+)$/ ) {
+ warn "$My_name: File-database '$in_name' is not of correct format\n";
+ return 1;
+ }
+ if ( $1 > $fdb_ver) {
+ warn "$My_name: File-database '$in_name' is of too new version, $1 > $fdb_ver\n";
+ return 1;
+ }
+ $state = 0;
+ }
+ # Ignore blank lines and comments
+ if ( /^$/ || /^#/ || /^%/ ) { next LINE;}
+ if ( /^\[\"([^\"]+)\"\]/ ) {
+ # Start of section
+ $rule = $1;
+ my $tail = $'; #' Single quote in comment tricks the parser in
+ # emacs from misparsing an isolated single quote
+ $run_time = $check_time = 0;
+ $source = $dest = $base = '';
+ $old_actives{$rule} = 1;
+ if ( $tail =~ /^\s*(\S+)\s*$/ ) {
+ $run_time = $1;
+ }
+ elsif ( $tail =~ /^\s*(\S+)\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s*$/ ) {
+ $run_time = $1;
+ $source = $2;
+ $dest = $3;
+ $base = $4;
+ }
+ elsif ( $tail =~ /^\s*(\S+)\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+(\S+)\s*$/ ) {
+ $run_time = $1;
+ $source = $2;
+ $dest = $3;
+ $base = $4;
+ $check_time = $5;
+ }
+ if ( rdb_rule_exists( $rule ) ) {
+ rdb_one_rule( $rule, \&rdb_read_set_rule );
+ }
+ elsif ($rule =~ /^cusdep\s+(\S+)\s+(\S+)\s+(.+)$/ ) {
+ # Create custom dependency
+ my $fromext = $1;
+ my $toext = $2;
+ my $base = $3;
+ $source = "$base.$fromext";
+# $dest = "$base.$toext";
+ my $func_name = '';
+ foreach my $dep ( @cus_dep_list ) {
+ my ($tryfromext,$trytoext,$must,$try_func_name) = split('\s+',$dep);
+ if ( ($tryfromext eq $fromext) && ($trytoext eq $toext) ) {
+ $func_name = $try_func_name;
+ }
+ }
+ if ($func_name) {
+ my $PAnew_cmd = ['do_cusdep', $func_name];
+ # Set source file as non-existent.
+ # If it existed on last run, it will be in later
+ # lines of the fdb file
+ rdb_create_rule( $rule, 'cusdep', '', $PAnew_cmd, 1,
+ $source, $dest, $base, 0, $run_time, $check_time, 1 );
+ }
+ else {
+ warn "$My_name: In file-database '$in_name', the custom-dependency rule\n",
+ " '$rule' is not available in this session.\n",
+ " Presumably it's no longer in your configuration for latexmk.\n";
+ $state = 10;
+ next LINE;
+ }
+ }
+ elsif ( $rule =~ /^(makeindex|bibtex|biber)\s*(.*)$/ ) {
+ my $PA_extra_gen = [];
+ my $rule_generic = $1;
+ my $int_cmd = '';
+ if ( ! $source ) {
+ # If fdb_file was old-style (v. 1)
+ $source = $2;
+ my $path = '';
+ my $ext = '';
+ ($base, $path, $ext) = fileparseA( $source );
+ $base = $path.$base;
+ if ($rule_generic eq 'makeindex') {
+ $dest = "$base.ind";
+ }
+ elsif ($rule_generic eq 'bibtex') {
+ $dest = "$base.bbl";
+ $source = "$base.aux";
+ }
+ elsif ($rule_generic eq 'biber') {
+ $dest = "$base.bbl";
+ $source = "$base.bcf";
+ }
+ }
+ if ($rule =~ /^makeindex/) { $PA_extra_gen = [ "$base.ilg" ]; }
+ if ($rule =~ /^(bibtex|biber)/) { $PA_extra_gen = [ "$base.blg" ]; }
+ if ($rule =~ /^bibtex/) { $int_cmd = "run_bibtex"; }
+ warn "$My_name: File-database '$in_name': setting rule '$rule'\n"
+ if $diagnostics;
+ my $cmd_type = 'external';
+ my $ext_cmd = ${$rule_generic};
+ warn " Rule kind = '$rule_generic'; ext_cmd = '$ext_cmd';\n",
+ " int_cmd = '$int_cmd';\n",
+ " source = '$source'; dest = '$dest'; base = '$base';\n"
+ if $diagnostics;
+ # Set source file as non-existent.
+ # If it existed on last run, it will be in later
+ # lines of the fdb file
+ rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, 1,
+ $source, $dest, $base, 0, $run_time, $check_time, 1, $PA_extra_gen );
+ }
+ else {
+ if ($diagnostics) {
+ warn "$My_name: In file-database '$in_name' rule '$rule'\n",
+ " is not in use in this session\n";
+ }
+ $new_source = undef;
+ $state = 10;
+ next LINE;
+ }
+ $new_source = $new_sources{$rule} = {};
+ $state = 1; #Reading a section, source part
+ }
+ elsif ( ($state <=0) || ($state >= 3) ) {
+ next LINE;
+ }
+ elsif ( /^\(source\)/ ) { $state = 1; next LINE; }
+ elsif ( /^\(generated\)/ ) { $state = 2; next LINE; }
+ elsif ( ($state == 1) && /^\"([^\"]*)\"\s+(\S+)\s+(\S+)\s+(\S+)\s+\"([^\"]*)\"/ ) {
+ # Source file line
+ my $file = $1;
+ my $time = $2;
+ my $size = $3;
+ my $md5 = $4;
+ my $from_rule = $5;
+#?? print " --- File '$file'\n";
+ if ($state != 1) {
+ warn "$My_name: In file-database '$in_name' ",
+ "line $. is outside a section:\n '$_'\n";
+ $errors++;
+ next LINE;
+ }
+ # Set file in database. But ensure we don't do an unnecessary
+ # fdb_get, which can trigger a new MD5 calculation, which is
+ # lengthy for a big file. Ininitially flagging the file
+ # as non-existent solves the problem:
+ rdb_ensure_file( $rule, $file, undef, 1 );
+ rdb_set_file1( $rule, $file, $time, $size, $md5 );
+ fdb_set( $file, $time, $size, $md5 );
+ # Save the rest of the data, especially the from_rule until we know all
+ # the rules, otherwise the from_rule may not exist.
+ # Also we'll have a better chance of looping through files.
+ ${$new_source}{$file} = [ $time, $size, $md5, $from_rule ];
+ }
+ elsif ( ($state == 2) && /^\"([^\"]*)\"/ ) {
+ my $file = $1;
+ rdb_one_rule( $rule, sub{ rdb_add_generated($file); } );
+ }
+ else {
+ warn "$My_name: In file-database '$in_name' ",
+ "line $. is of wrong format:\n '$_'\n";
+ $errors++;
+ next LINE;
+ }
+ }
+ undef $in_handle;
+ # Set cus dependencies.
+ &rdb_set_dependents( keys %rule_db );
+ &rdb_set_rule_net;
+
+ return $errors;
+} # END rdb_read
+
+#************************************************************
+
+sub rdb_read_set_rule {
+ # Rule context assumed. Implicit passing of $dest, $run_time, $check_time,
+ # $in_name used as local variables in calling routine rdb_read;
+ if ($$Ptest_kind == 3) { $$Ptest_kind = 1; }
+ $$Prun_time = $run_time;
+ $$Pcheck_time = $check_time;
+ # Deal with possibility that destination in fdb_latexmk has different name
+ # than the default one. The only case that concerns us is where
+ # the extension is changed (by \pdfoutput, e.g., in tex file). But
+ # it is possible out and aux directories have been chosen differently,
+ # and the user choice there MUST OVERRIDE the value in the fdb_latexmk file.
+ if ($dest ne $$Pdest) {
+ if (! $possible_primaries{$rule} ) {
+ warn "$My_name: In reading rule '$rule' in '$in_name',\n",
+ " name of destination file is not current one; I'll flag rule as out of date.\n";
+ $$Pout_of_date = 10;
+ }
+ elsif ( ! rdb_is_active($rule) ) {
+ warn "$My_name: In reading rule '$rule' in '$in_name',\n",
+ " rule is not currently active.\n";
+ # No fixup now. Causes to be analyzed:
+ # Change of requested files: no action needed.
+ # Obeying of metacommand: not implemented yet.
+ }
+ else {
+ # Get here if rule is active and primary and destination is different
+ warn "$My_name: In reading rule '$rule' in '$in_name',\n",
+ " destination has different name than configured...\n";
+ my ($oldbase, $oldpath, $oldext) = fileparseA( $dest );
+ my ($newbase, $newpath, $newext) = fileparseA( $$Pdest );
+ if ($oldext ne $newext) {
+ if ( ! exists $allowed_output_ext{$oldext} ) {
+ warn " Old extension '$oldext' not allowed.\n";
+ $$Pout_of_date = 10;
+ }
+ else {
+ warn " ===== CHANGING output type from '$newext' to '$oldext' in '$rule'\n";
+ my $switch_error = switch_output( $oldext, $newext );
+ if ($switch_error) {
+ warn " I could not accommodate the changed output extension\n",
+ " (either because the configuration does not allow it\n",
+ " or because there is a conflict with requested filetypes).\n",
+ "===> There may be subsequent warnings, which may or may not be ignorable.\n",
+ "===> If necessary, clean out generated files and try again\n";
+ }
+ }
+ }
+ if ( ($oldbase ne $newbase) || ($oldpath ne $newpath) ) {
+ # There are further issues (e.g., change of out_dir).
+ # Need rerun to correct:
+ $$Pout_of_date = 10;
+ }
+ }
+ }
+} #END rdb_read_set_rule
+
+#************************************************************
+
+sub rdb_write {
+ # Call: rdb_write( $out_name )
+ # Writes to the given file name the database of file and rule data
+ # for all rules needed to make final output
+ # Returns 1 on success, 0 if file couldn't be opened.
+ local $out_name = $_[0];
+ local $out_handle = new FileHandle;
+ if ( ($out_name eq "") || ($out_name eq "-") ) {
+ # Open STDOUT
+ $out_handle->open( '>-' );
+ }
+ else {
+ $out_handle->open( $out_name, '>' );
+ }
+ if (!$out_handle) { return 0; }
+
+ &rdb_set_rule_net;
+
+ print $out_handle "# Fdb version $fdb_ver\n";
+ my @rules = sort &rdb_accessible;
+ rdb_for_some(
+ \@rules,
+ sub {
+ # Omit data on a unused and never-run primary rule:
+ if ( ($$Prun_time == 0)
+ && exists( $possible_primaries{$rule} )
+ && ! exists( $current_primaries{$rule} )
+ )
+ {
+ return;
+ }
+ print $out_handle "[\"$rule\"] $$Prun_time \"$$Psource\" \"$$Pdest\" \"$$Pbase\" $$Pcheck_time\n";
+ rdb_do_files(
+ sub { print $out_handle " \"$file\" $$Ptime $$Psize $$Pmd5 \"$$Pfrom_rule\"\n"; }
+ );
+ print $out_handle " (generated)\n";
+ foreach (keys %$PHdest) {
+ print $out_handle " \"$_\"\n";
+ }
+ }
+ );
+ undef $out_handle;
+ return 1;
+} #END rdb_write
+
+#************************************************************
+
+sub rdb_set_latex_deps {
+ # Assume rule context.
+ # This is intended to be applied only for a primary (LaTeX-like) rule.
+ # Set its dependents etc, using information from log, aux, and fls files.
+ # Use fls file only if $recorder is set, and the fls file was generated
+ # on this run.
+
+ # N.B. A complication which we try and handle in determining
+ # dependent files is that there may be aliasing of file names,
+ # especially when characters are used in file and directory
+ # names that are not pure 7-bit-ASCII. Here is a list of some
+ # of the difficulties that do arise, between, on the one hand,
+ # the filenames specified on latexmk's and the cwd found by
+ # latexmk from the system, and, on the other hand, the filenames
+ # and their components reported by (pdf)latex in the fls and log
+ # files:
+ # 1. Whether the separator of path components is / or \ in
+ # MSWin.
+ # 2. Whether the LFN or the SFN is provided.
+ # 3. Whether the filenames include the cwd or whether they
+ # are relative to the current directory.
+ # 4. Under cygwin, whether the absolute filenames are
+ # specified by UNIX or native MSWin conventions.
+ # (With cygin, the programs used, including the Perl that
+ # executes latexmk, can be any combination of native MSWin
+ # programs and cygwin programs with their UNIX-like
+ # behavior.)
+ # 5. Whether UTF-8 or some other coding is used, and under
+ # which circumstances: e.g., in calls to the OS to access
+ # files, in files output by programs, on latexmk's command
+ # line, on other programs' command lines, by the command
+ # interpreterS.
+ # 6. If UTF-8 is used, what kind of canonicalization is used,
+ # if any. (This is a particular bugbear when files are
+ # transferred between different OSes.)
+ # 7. Whether the name of a file in the current directory is
+ # reported as the simple filename or whether it is
+ # preceeded by ".\" or "./".
+ # 8. How is it determined whether a pathname is absolute or
+ # relative? An absolute pathname in MSWin may start with
+ # a drive letter and a colon, but under UNIX-type systems,
+ # the colon is an ordinary character.
+ # 9. Whether a filename reported in an fls or log file can be
+ # used as is by perl to access a file, or on the command
+ # line to invoke another program, and whether the use on a
+ # command line depends on whether the command line is
+ # executed by a CLI, and by which CLI. (E.g., cmd.exe,
+ # v. sh v. tcsh, etc.)
+ # 10. Whether such a filename for the filename on (pdf)latex's
+ # file agrees with the one on the command line.
+ # The above questions have arisen from actual experiences and
+ # tests.
+ #
+ # In any case, when determining dependent files, we will try to
+ # remove an initial directory string from filenames found in the
+ # fls and log files, whenever it denotes the current
+ # directory. The directory string may be an absolute pathname,
+ # such as MiKTeX writes in both fls and log files, or it may be
+ # simply "./" as given by TeXLive in its log file. There are
+ # several reasons for removing a directory string when possible:
+ #
+ # 1. To avoid having multiple names referring to the same
+ # file in the list of dependents.
+ # 2. Because the name may be in a different coding. Thus
+ # under MSWin 7, cmd.exe and perl (by default) work in an
+ # "ANSI" coding with some code page, but the filenames
+ # written by MiKTeX are UTF-8 coded (and if they are non-ASCII
+ # can't be used for file-processing by Perl without some
+ # trouble). This is a particular problem if the pathname
+ # contains non-ASCII characters; the directory names may not
+ # even be under the user's control, unlike typical filenames.
+ # 3. When it comes to filenames that are then used in calls to
+ # bibtex and makeindex, it is bad to use absolute pathnames
+ # instead of clearly relative pathnames, because the default
+ # security settings are to prohibit writing files to the
+ # corresponding directories, which makes the calls to these
+ # programs unnecessarily fail.
+ #
+ # In removing unnecessary directory-specifying strings, to
+ # convert a filename to a simple specification relative to the
+ # current directory, it will be important to preferentially use
+ # a determination of the current directory from the file being
+ # processed. In the fls file, there is normally a PWD line. In
+ # the log file, if (pdf)latex is started with a filename instead
+ # of a command-executing first line, then this can be determined
+ # from the first few lines of the log file -- see parse_log.
+ # This gives a more reliable determination of the relevant path
+ # string; this is especially important in cases where there is a
+ # mismatch of coding of the current directory, particularly
+ # notable in the above-mentioned case of non-ASCII characters
+ # under MSWin. Other inconsistencies happen when there is a
+ # mixure of cygwin and native MSWin software. There can also be
+ # inconsistencies between whether the separator of pathname
+ # components is "/" or "\". So we will allow for this. The
+ # necessary normalizations of filenames are handled by the
+ # subroutines normalize_filename and normalize_clean_filename.
+ #
+ # I have not tried to handle the (currently rare) cases that the
+ # OS is neither UNIX-like nor MSWin-like.
+ #
+ # Assumption: the list of generated files in %PHdest was already initialized earlier.
+ # In principle, I should do it here, but useful possibilities (e.g.,
+ # see pythontex-latexmk) for subroutine called to process a .tex to add items to
+ # %PHdest. So initializing here is too late.
+
+ # Rules should only be primary
+ if ( $$Pcmd_type ne 'primary' ) {
+ warn "\n$My_name: ==========$My_name: Probable BUG======= \n ",
+ " rdb_set_latex_deps called to set files ",
+ "for non-primary rule '$rule'\n\n";
+ return;
+ }
+
+#?? # We'll prune this by all files determined to be needed for source files.
+#?? my %unneeded_source = %$PHsource;
+
+ # Parse fls and log files to find relevant filenames
+ # Result in the following variables:
+ local %dependents = (); # Maps files to status
+ local @bbl_files = ();
+ local %idx_files = (); # Maps idx_file to (ind_file, base)
+ local %generated_log = (); # Lists generated files found in log file
+ local %generated_fls = (); # Lists generated files found in fls file
+ local %source_fls = (); # Lists source files found in fls file
+ local %first_read_after_write = (); # Lists source files that are only read
+ # after being written (so are not true
+ # source files.
+ local $primary_out = $$Pdest; # output file (dvi or pdf)
+ local %conversions = (); # (pdf)latex-performed conversions.
+ # Maps output file created and read by (pdf)latex
+ # to source file of conversion.
+ local @missing_subdirs = (); # Missing subdirectories in aux_dir
+
+ local $pwd_latex = undef; # Cwd as reported in fls file by (pdf)latex
+
+ local %created_rules = (); # Maps files to rules existing or created to
+ # make them. Use to avoid misunderstood
+ # dependencies when a package creates a
+ # missing file during *latex compliation
+ # instead of just allowing to be made later
+ # by another rule.
+
+ # The following are also returned by parsing routines, but are global,
+ # to be used by caller:
+ # $reference_changed, $bad_reference, $bad_character, $bad_citation, $mult_defined
+
+ # Do I have my own eps-to-pdf conversion?
+ my $epspdf_cusdep = 0;
+ foreach (@cus_dep_list) {
+ if ( /^eps pdf / ) { $epspdf_cusdep = 1; last; }
+ }
+
+ # Analyze fls file first. It tells us the working directory as seen by (pdf)latex
+ # But we'll use the results later, so that they take priority over the findings
+ # from the log file.
+ local $fls_file_analyzed = 0;
+ if ($recorder && test_gen_file($fls_name) ) {
+ $fls_file_analyzed =
+ (0== parse_fls( $fls_name, \%source_fls, \%generated_fls, \%first_read_after_write, \$pwd_latex ));
+ if (! $fls_file_analyzed ) {
+ warn "$My_name: fls file '$fls_name' appears to have been made but it couldn't be opened.\n";
+ }
+ }
+
+ &parse_log;
+ $missing_dirs = 'none'; # Status of missing directories
+ if (@missing_subdirs) {
+ $missing_dirs = 'success';
+ if ($allow_subdir_creation) {
+ foreach my $dir ( uniqs( @missing_subdirs ) ) {
+ if ( -d $dir ) {
+ $missing_dirs = 'failure';
+ warn "$My_name: ==== Directory '$dir' is said to be missing\n",
+ " But it exists!\n";
+ }
+ elsif ( (-e $dir) && (!-d $dir) ) {
+ $missing_dirs = 'failure';
+ warn "$My_name: ==== Directory '$dir' is said to be missing\n",
+ " But a non-directory file of this name exists!\n";
+ }
+ else {
+ if (mkdir $dir) {
+ warn "$My_name: Directory '$dir' created\n";
+ }
+ else {
+ $missing_dirs = 'failure';
+ warn "$My_name: Couldn't create directory '$dir'.\n",
+ " System error: '$!'\n";
+ }
+ }
+ }
+ }
+ else {
+ $missing_dirs = 'not allowed';
+ warn "$My_name: There are missing subdirectories, but their creation\n",
+ " is not allowed. The subdirectories are:\n";
+ foreach my $dir ( uniqs( @missing_subdirs ) ) {
+ warn " '$dir'\n";
+ }
+ }
+ }
+ # Use results from fls file. (N.B. The hashes will be empty if the fls file
+ # wasn't used/analyzed, so we don't need a test as to whether the fls file was
+ # used.
+ foreach (keys %source_fls) {
+ if (! -e ) {
+ # File is listed in .fls file as read, but doesn't exist now.
+ # Therefore it is not a true source file, surely.
+ # Sometimes this is caused by a bug (e.g., lualatex in TeXLive 2016,
+ # 2017) when there is an incorrect line in .fls file. (This
+ # would deserve a warning.)
+ # But sometimes (e.g., with minted package), the file could be
+ # created during a run, read, and then deleted.
+ next;
+ }
+ $dependents{$_} = 4;
+ if ( /\.bbl$/ ) { push @bbl_files, $_; }
+ }
+ foreach (keys %generated_fls) {
+ if (! -e ) {
+ # File is listed in .fls file as written, but doesn't exist now.
+ # Therefore it is not a true externally visible generated file.
+ # (Typically, e.g., with the minted package, it is a temporary
+ # file created during a run and then deleted during the run.)
+ next;
+ }
+ rdb_add_generated( $_ );
+ if ( exists($dependents{$_}) ) {
+ $dependents{$_} = 6;
+ }
+ }
+
+ for my $conv (sort keys %conversions) {
+ my $conv_source = $conversions{$conv};
+ if ( $conv =~ /^(.*)-eps-converted-to\.pdf$/ ) {
+ # Check all the conditions for pdflatex's conversion eps to pdf
+ # are valid; if they are, treat the converted file as not a
+ # source file.
+ my $base = $1;
+ if ( (-e $conv_source) && (-e $conv) && ( $conv_source eq "$base.eps" ) ) {
+ # $conv isn't a real source of (pdf)latex
+ rdb_remove_files( $rule, $conv );
+ delete $dependents{$conv};
+ if ($epspdf_cusdep) {
+ $dependents{"$base.pdf"} = ((-e "$base.pdf") ? 4 : 0 );
+ }
+ }
+ }
+ }
+
+
+
+# ?? !! Should also deal with .run.xml file
+
+ # Handle result on output file:
+ # 1. Non-existent output file, which is because of no content.
+ # This could either be because the source file has genuinely
+ # no content, or because of a missing input file. Since a
+ # missing input file might be correctable by a run of some
+ # other program whose running is provoked AFTER a run of
+ # (pdf)latex, we'll set a diagnostic and leave it to the
+ # rdb_make to handle after all circular dependencies are
+ # resolved.
+ # 2. The output file might be of a different kind than expected
+ # (i.e., dvi instead of pdf, or vv). This could
+ # legitimately occur when the source file (or an invoked
+ # package or class) sets \pdfoutput.
+ $missing_dvi_pdf = '';
+ if ($primary_out eq '') {
+ warn "$My_name: For rule '$rule', no output was made\n";
+ $missing_dvi_pdf = $$Pdest;
+ }
+ elsif ($primary_out ne normalize_filename($$Pdest) ) {
+ my ($actual_base, $actual_path, $actual_ext) = fileparseA( $primary_out );
+ my ($intended_base, $intended_path, $intended_ext) = fileparseA( $$Pdest );
+ if ( $actual_ext ne $intended_ext ) {
+ warn "$My_name: ===For rule '$rule', the extensions differ between the\n",
+ " actual output file '$primary_out',\n",
+ " and the expected output '$$Pdest'.\n";
+ if ( ! exists $allowed_output_ext{$actual_ext} ) {
+ warn " Actual output file has an extension '$actual_ext' that\n",
+ " is not one I know about. I cannot handle this\n";
+ }
+ else {
+ my $switch_error = switch_output( $actual_ext, $intended_ext );
+ if ( $switch_error ) {
+ warn " I could not accommodate the changed output extension\n",
+ " (either because the configuration does not allow it\n",
+ " or because there is a conflict with requested filetypes).\n";
+ $failure = 1;
+ $failure_msg = 'Could not handle change of output extension';
+ }
+ else {
+ warn " Rule structure will be changed suitably.\n";
+ }
+ }
+ }
+ }
+
+ IDX_FILE:
+ foreach my $idx_file ( keys %idx_files ) {
+ my ($ind_file, $ind_base) = @{$idx_files{$idx_file}};
+ my $from_rule = "makeindex $idx_file";
+ if ( ! rdb_rule_exists( $from_rule ) ){
+ print "!!!===Creating rule '$from_rule': '$ind_file' from '$idx_file'\n"
+ if ($diagnostics);
+ rdb_create_rule( $from_rule, 'external', $makeindex, '', 1,
+ $idx_file, $ind_file, $ind_base, 1, 0, 0, 1, [ "$ind_base.ilg" ] );
+ print " ===Source file '$ind_file' for '$rule'\n"
+ if ($diagnostics);
+ rdb_ensure_file( $rule, $ind_file, $from_rule );
+ }
+ # Make sure the .ind file is treated as a detected source file;
+ # otherwise if the log file has it under a different name (as
+ # with MiKTeX which gives full directory information), there
+ # will be problems with the clean-up of the rule concerning
+ # no-longer-in-use source files:
+ $dependents{$ind_file} = 4;
+ if ( ! -e $ind_file ) {
+ # Failure was non-existence of makable file
+ # Leave failure issue to other rules.
+ $failure = 0;
+ }
+ $created_rules{$ind_file} = $from_rule;
+ }
+
+ local %processed_aux_files = ();
+ BBL_FILE:
+ foreach my $bbl_file ( uniqs( @bbl_files ) ) {
+ my ($bbl_base, $bbl_path, $bbl_ext) = fileparseA( $bbl_file );
+ $bbl_base = $bbl_path.$bbl_base;
+ my @new_bib_files = ();
+ my @new_aux_files = ();
+ my @new_bst_files = ();
+ my @biber_source = ( "$bbl_base.bcf" );
+ my $bib_program = 'bibtex';
+ if ( test_gen_file( "$bbl_base.bcf" ) ) {
+ $bib_program = 'biber';
+ }
+ my $from_rule = "$bib_program $bbl_base";
+ print "======= Dealing with '$from_rule'\n" if ($diagnostics);
+ # Don't change to use activation and deactivation here, rather than
+ # creation and removal of rules. This is because rules are to be
+ # created on the fly here with details corresponding to current. So
+ # activating a previously inactive rule, which is out-of-date, may
+ # cause trouble.
+ if ($bib_program eq 'biber') {
+ check_biber_log( $bbl_base, \@biber_source );
+ # Remove OPPOSITE kind of bbl generation:
+ rdb_remove_rule( "bibtex $bbl_base" );
+ }
+ else {
+ parse_aux( "$bbl_base.aux", \@new_bib_files, \@new_aux_files, \@new_bst_files );
+ # Remove OPPOSITE kind of bbl generation:
+ rdb_remove_rule( "biber $bbl_base" );
+ }
+ if ( ! rdb_rule_exists( $from_rule ) ){
+ print " ===Creating rule '$from_rule'\n" if ($diagnostics);
+ if ( $bib_program eq 'biber' ) {
+ rdb_create_rule( $from_rule, 'external', $biber, '', 1,
+ "$bbl_base.bcf", $bbl_file, $bbl_base, 1, 0, 0, 1, [ "$bbl_base.blg" ] );
+ }
+ else {
+ rdb_create_rule( $from_rule, 'external', $bibtex, 'run_bibtex', 1,
+ "$bbl_base.aux", $bbl_file, $bbl_base, 1, 0, 0, 1, [ "$bbl_base.blg" ] );
+ }
+ }
+ $created_rules{$bbl_file} = $from_rule;
+ local %old_sources = ();
+ rdb_one_rule( $from_rule, sub { %old_sources = %$PHsource; } );
+ my @new_sources = ( @new_bib_files, @new_aux_files, @new_bst_files );
+ if ( $bib_program eq 'biber' ) {
+ push @new_sources, @biber_source;
+ }
+ foreach my $source ( @new_sources ) {
+ print " ===Source file '$source' for '$from_rule'\n"
+ if ($diagnostics);
+ rdb_ensure_file( $from_rule, $source );
+ delete $old_sources{$source};
+ }
+ foreach my $source ( @new_aux_files ) {
+ $processed_aux_files{$source} = 1;
+ }
+ if ($diagnostics) {
+ foreach ( keys %old_sources ) {
+ print "Removing no-longer-needed dependent '$_' from rule '$from_rule'\n";
+ }
+ }
+ rdb_remove_files( $from_rule, keys %old_sources );
+ print " ===Source file '$bbl_file' for '$rule'\n"
+ if ($diagnostics);
+ rdb_ensure_file( $rule, $bbl_file, $from_rule );
+ if ( ! -e $bbl_file ) {
+ # Failure was non-existence of makable file
+ # Leave failure issue to other rules.
+ $failure = 0;
+ }
+ }
+
+ if ( ($#aux_hooks > -1) && ! exists $processed_aux_files{$aux_main} ) {
+ my @new_bib_files = ();
+ my @new_aux_files = ();
+ my @new_bst_files = ();
+ parse_aux( $aux_main, \@new_bib_files, \@new_aux_files, \@new_bst_files );
+ foreach my $source ( @new_aux_files ) {
+ $processed_aux_files{$source} = 1;
+ }
+ }
+
+NEW_SOURCE:
+ foreach my $new_source (keys %dependents) {
+ print " ===Source file for rule '$rule': '$new_source'\n"
+ if ($diagnostics);
+ if ( exists $first_read_after_write{$new_source} ) {
+ if ( dep_at_start($new_source) ) {
+ #warn "--- READ ONLY AFTER WRITE OF '$new_source'\n";
+ $dependents{$new_source} = 7;
+ }
+ else {
+ #warn "--- READ ONLY AFTER CREATE OF '$new_source'\n";
+ $dependents{$new_source} = 6;
+ }
+ }
+ if ( ($dependents{$new_source} == 5)
+ || ($dependents{$new_source} == 6)
+ ) {
+ # (a) File was detected in "No file..." line in log file.
+ # Typically file was searched for early in run of
+ # latex/pdflatex, was not found, and then was written
+ # later in run.
+ # or (b) File was written during run.
+ # In both cases, if file doesn't already exist in database, we
+ # don't know its previous status. Therefore we tell
+ # rdb_ensure_file that if it needs to add the file to its
+ # database, then the previous version of the file should be
+ # treated as non-existent, to ensure another run is forced.
+ rdb_ensure_file( $rule, $new_source, undef, 1 );
+ }
+ elsif ( $dependents{$new_source} == 7 ) {
+ # File was result of conversion by (pdf)latex.
+ my $cnv_source = $conversions{$new_source};
+ rdb_ensure_file( $rule, $new_source );
+# if ($cnv_source && ($cnv_source !~ /\"/ ) ) {
+ if ($cnv_source ) {
+ # Conversion from $cnv_source to $new_source
+ # implies that effectively $cnv_source is a source
+ # of the (pdf)latex run.
+ rdb_ensure_file( $rule, $cnv_source );
+ }
+ # Flag that changes of the generated file during a run
+ # do not require a rerun:
+ rdb_one_file( $new_source, sub{ $$Pcorrect_after_primary = 1; } );
+ }
+ else {
+ # But we don't need special precautions for ordinary user files
+ # (or for files that are generated outside of latex/pdflatex).
+ rdb_ensure_file( $rule, $new_source );
+ }
+ if ( ($dependents{$new_source} == 6)
+ || ($dependents{$new_source} == 7)
+ ) {
+ rdb_add_generated($new_source);
+ }
+ }
+
+ # Some packages (e.g., bibtopic) generate a dummy error-message-providing
+ # bbl file when a bbl file does not exist. Then the fls and log files
+ # show the bbl file as created by the primary run and hence as a
+ # generated file. Since we now have a rule to create a real bbl file,
+ # the information in the fls and log files no longer represents a
+ # correct dependency, so the bbl file is to be removed from the
+ # generated files.
+ foreach (keys %created_rules) { rdb_remove_generated( $_ ); }
+
+ my @more_sources = &rdb_set_dependents( $rule );
+ my $num_new = $#more_sources + 1;
+ foreach (@more_sources) {
+ $dependents{$_} = 4;
+ if ( ! -e $_ ) {
+ # Failure was non-existence of makable file
+ # Leave failure issue to other rules.
+ $failure = 0;
+ $$Pchanged = 1; # New files can be made. Ignore error.
+ }
+ }
+ if ($diagnostics) {
+ if ($num_new > 0 ) {
+ print "$num_new new source files for rule '$rule':\n";
+ foreach (@more_sources) { print " '$_'\n"; }
+ }
+ else {
+ print "No new source files for rule '$rule':\n";
+ }
+ my @first_read_after_write = sort keys %first_read_after_write;
+ if ($#first_read_after_write >= 0) {
+ print "The following files were only read after being written:\n";
+ foreach (@first_read_after_write) {
+ print " '$_'\n";
+ }
+ }
+ }
+ my @files_not_needed = ();
+ foreach (keys %$PHsource) {
+ if ( ! exists $dependents{$_} ) {
+ print "Removing no-longer-needed dependent '$_' from rule '$rule'\n"
+ if $diagnostics;
+ push @files_not_needed, $_;
+ }
+ }
+ rdb_remove_files( $rule, @files_not_needed );
+
+} # END rdb_set_latex_deps
+
+#************************************************************
+
+sub switch_output {
+ # Assume rule context for primary rule
+ # Return 0 on success, non-zero error code on failure
+
+ my ( $actual_ext, $intended_ext ) = @_;
+ if ( $actual_ext eq $intended_ext) { return 0; }
+ if ( ! $can_switch ) { return 1; }
+
+ if ( $intended_ext eq '.dvi' ) {
+ rdb_deactivate_derequest( 'dvipdf', 'pspdf' );
+ }
+ elsif ( $intended_ext eq '.xdv' ) {
+ rdb_deactivate_derequest( 'xdvipdfmx' );
+ }
+ else { }
+
+ if ( $actual_ext eq '.dvi' ) {
+ rdb_activate_request( 'dvipdf' );
+ $input_extensions{$rule} = $standard_input_extensions{latex};
+ }
+ elsif ( $actual_ext eq '.xdv' ) {
+ rdb_activate_request( 'xdvipdfmx' );
+ $input_extensions{$rule} = $standard_input_extensions{xelatex};
+ }
+ else {
+ $input_extensions{$rule} = $standard_input_extensions{pdflatex};
+ }
+
+ my $old_dest = $$Pdest;
+ my $new_dest = $$Pdest;
+ $new_dest =~ s/$intended_ext$/$actual_ext/;
+ # Compensate for MiKTeX's behavior: dvi and pdf are put in out_dir, but xdv is put in aux_dir:
+ if ( ($actual_ext eq '.xdv') && ($out_dir ne $aux_dir) ){ $new_dest =~ s/^$out_dir1/$aux_dir1/; }
+ if ( ($intended_ext eq '.xdv') && ($out_dir ne $aux_dir) ){ $new_dest =~ s/^$aux_dir1/$out_dir1/; }
+
+ rdb_change_dest( $new_dest );
+
+ # Some fixes to avoid spurious error conditions:
+ $switched_primary_output = 1;
+ if (-e $$Pdest) {
+ $missing_dvi_pdf = '';
+ if ($$Plast_result == 1 ) { $$Plast_result = 0; }
+ }
+ else { $missing_dvi_pdf = $$Pdest; }
+
+ return 0;
+} #END switch_output
+
+#************************************************************
+
+sub test_gen_file {
+ # Usage: test_gen_file( filename )
+ # Tests whether the file was generated during a run of (pdf)latex.
+ # Assumes context for primary rule.
+ # Two kinds of test are used:
+ # a. From %generated_log, which works after the log file has been parsed,
+ # but only for certain files and for those TeX engines (not MiKTeX)
+ # that put \openout lines in log file.
+ # b. By the file existing and being at least as new as the system
+ # time at the start of the run. But we allow for a measured
+ # offset between filetime and system time, which could be
+ # nonzero if the file is on a different, remote system than the
+ # one running latexmk. We must also allow a threshold in the
+ # comparisons of filetimes to allow for the inaccuracy of the
+ # offset measurement.
+ my $file = shift;
+ return exists $generated_log{$file}
+ || ( -e $file && ( get_mtime( $file ) >= $$Prun_time + $filetime_offset - $filetime_causality_threshold));
+}
+
+#************************************************************
+
+sub dep_at_start {
+ # Usage: dep_at_start( filename )
+ # Tests whether the file was source file and existed at start of run.
+ # Assumes context for primary rule.
+ my $time = undef;
+ rdb_one_file( shift, sub{ $time = $$Ptime; } );
+ return (defined $time) && ($time != 0);
+}
+
+#************************************************************
+
+sub rdb_find_new_files {
+ # Call: rdb_find_new_files
+ # Assumes rule context for primary rule.
+ # Deal with files which were missing and for which a method
+ # of finding them has become available:
+ # (a) A newly available source file for a custom dependency.
+ # (b) When there was no extension, a file with appropriate
+ # extension
+ # (c) When there was no extension, and a newly available source
+ # file for a custom dependency can make it.
+
+ my %new_includes = ();
+
+MISSING_FILE:
+ foreach my $missing ( keys %$PHsource ) {
+ next if ( $$PHsource{$missing} != 0 );
+ my ($base, $path, $ext) = fileparseA( $missing );
+ $ext =~ s/^\.//;
+ if ( -e "$missing.tex" ) {
+ $new_includes{"$missing.tex"} = 1;
+ }
+ elsif ( -e $missing ) {
+ $new_includes{$missing} = 1;
+ }
+ elsif ( $ext ne "" ) {
+ foreach my $dep (@cus_dep_list){
+ my ($fromext,$toext) = split('\s+',$dep);
+ if ( ( "$ext" eq "$toext" )
+ && ( -e "$path$base.$fromext" )
+ ) {
+ # Source file for the missing file exists
+ # So we have a real include file, and it will be made
+ # next time by rdb_set_dependents
+ $new_includes{$missing} = 1;
+ }
+ else {
+ # no point testing the $toext if the file doesn't exist.
+ }
+ next MISSING_FILE;
+ }
+ }
+ else {
+ # $_ doesn't exist, $_.tex doesn't exist,
+ # and $_ doesn't have an extension
+ foreach my $dep (@cus_dep_list){
+ my ($fromext,$toext) = split('\s+',$dep);
+ if ( -e "$path$base.$fromext" ) {
+ # Source file for the missing file exists
+ # So we have a real include file, and it will be made
+ # next time by &rdb__dependents
+ $new_includes{"$path$base.$toext"} = 1;
+# next MISSING_FILE;
+ }
+ if ( -e "$path$base.$toext" ) {
+ # We've found the extension for the missing file,
+ # and the file exists
+ $new_includes{"$path$base.$toext"} = 1;
+# next MISSING_FILE;
+ }
+ }
+ }
+ } # end MISSING_FILES
+
+ # Sometimes bad line-breaks in log file (etc) create the
+ # impression of a missing file e.g., ./file, but with an incorrect
+ # extension. The above tests find the file with an extension,
+ # e.g., ./file.tex, but it is already in the list. So now I will
+ # remove files in the new_include list that are already in the
+ # include list. Also handle aliasing of file.tex and ./file.tex.
+ # For example, I once found:
+# (./qcdbook.aux (./to-do.aux) (./ideas.aux) (./intro.aux) (./why.aux) (./basics
+#.aux) (./classics.aux)
+
+ my $found = 0;
+ foreach my $file (keys %new_includes) {
+# if ( $file =~ /\"/ ) {next; }
+ my $stripped = $file;
+ $stripped =~ s{^\./}{};
+ if ( exists $PHsource{$file} ) {
+ delete $new_includes{$file};
+ }
+ else {
+ $found ++;
+ rdb_ensure_file( $rule, $file );
+ }
+ }
+
+ if ( $diagnostics && ( $found > 0 ) ) {
+ warn "$My_name: Detected previously missing files:\n";
+ foreach ( sort keys %new_includes ) {
+ warn " '$_'\n";
+ }
+ }
+ return $found;
+} # END rdb_find_new_files
+
+#************************************************************
+
+sub rdb_set_dependents {
+ # Call rdb_set_dependents( rules ...)
+ # Returns array (sorted), of new source files.
+ local @new_sources = ();
+ local @deletions = ();
+
+# Shouldn't recurse. The definite rules to be examined are given.
+ rdb_for_some( [@_], 0, \&rdb_one_dep );
+# OLD rdb_recurse( [@_], 0, \&rdb_one_dep );
+ foreach (@deletions) {
+ my ($rule, $file) = @$_;
+ rdb_remove_files( $rule, $file );
+ }
+ &rdb_make_links;
+ return uniqs( @new_sources );
+} #END rdb_set_dependents
+
+#************************************************************
+
+sub rdb_find_source_file {
+ # Helper for searching dependencies in all paths inside the TEXINPUTS
+ # environment variable.
+ my $test = "$_[0].$_[1]";
+ if ( -e $test ) {
+ return $_[0];
+ }
+ if ( exists $ENV{TEXINPUTS} ) {
+ foreach my $searchpath (split $search_path_separator, $ENV{TEXINPUTS}) {
+ my $file = File::Spec->catfile($searchpath,$_[0]);
+ my $test = "$file.$_[1]";
+ if ( -e $test ) {
+ return $file;
+ }
+ }
+ }
+ return "$_[0]";
+}
+
+#************************************************************
+
+sub rdb_one_dep {
+ # Helper for finding dependencies. One case, $rule and $file given
+ # Assume file (and rule) context for DESTINATION file.
+
+ # Only look for dependency if $rule is primary rule (i.e., latex
+ # or pdflatex) or is a custom dependency:
+ if ( (! exists $possible_primaries{$rule}) && ($rule !~ /^cusdep/) ) {
+ return;
+ }
+#print "=============ONE_DEP: '$rule' '$file'\n";
+ local $new_dest = $file;
+ my ($base_name, $path, $toext) = fileparseA( $new_dest );
+ $base_name = $path.$base_name;
+ $toext =~ s/^\.//;
+ my $Pinput_extensions = $input_extensions{$rule};
+DEP:
+ foreach my $dep ( @cus_dep_list ) {
+ my ($fromext,$proptoext,$must,$func_name) = split('\s+',$dep);
+ if ( $toext eq $proptoext ) {
+ $base_name = rdb_find_source_file($base_name, $fromext);
+ my $source = "$base_name.$fromext";
+ # Found match of rule
+ if ($diagnostics) {
+ print "Found cusdep: $source to make $rule:$new_dest ====\n";
+ }
+ if ( -e $source ) {
+ $$Pfrom_rule = "cusdep $fromext $toext $base_name";
+ my $new_new_dest = "$base_name.$toext";
+ if ($new_new_dest ne $new_dest) {
+ rdb_ensure_file( $rule, $new_new_dest );
+ $new_dest = $new_new_dest;
+ }
+ local @PAnew_cmd = ( 'do_cusdep', $func_name );
+ if ( !-e $new_dest ) {
+ push @new_sources, $new_dest;
+ }
+ if (! rdb_rule_exists( $$Pfrom_rule ) ) {
+ print "$My_name: === Creating rule '$$Pfrom_rule'\n" if $diagnostics;
+ rdb_create_rule( $$Pfrom_rule, 'cusdep', '', \@PAnew_cmd, 3,
+ $source, $new_dest, $base_name, 0 );
+ }
+ return;
+ }
+ else {
+ # Source file does not exist
+ if ( !$force_mode && ( $must != 0 ) ) {
+ # But it is required that the source exist ($must !=0)
+ $failure = 1;
+ $failure_msg = "File '$base_name.$fromext' does not exist ".
+ "to build '$base_name.$toext'";
+ return;
+ }
+ elsif ( $$Pfrom_rule =~ /^cusdep $fromext $toext / ) {
+ # Source file does not exist, destination has the rule set.
+ # So turn the from_rule off
+ $$Pfrom_rule = '';
+ }
+ else {
+ }
+ }
+ }
+ elsif ( ($toext eq '')
+ && (! -e $file )
+ && (! -e "$base_name.$proptoext" )
+ && exists $$Pinput_extensions{$proptoext}
+ ) {
+ # Empty extension and non-existent destination
+ # This normally results from \includegraphics{A}
+ # without graphics extension for file, when file does
+ # not exist. So we will try to find something to make it.
+ $base_name = rdb_find_source_file($base_name, $fromext);
+ my $source = "$base_name.$fromext";
+ if ( -e $source ) {
+ $new_dest = "$base_name.$proptoext";
+ my $from_rule = "cusdep $fromext $proptoext $base_name";
+ push @new_sources, $new_dest;
+ print "Ensuring rule for '$from_rule', to make '$new_dest'\n"
+ if $diagnostics > -1;
+ local @PAnew_cmd = ( 'do_cusdep', $func_name );
+ if (! rdb_rule_exists( $from_rule ) ) {
+ print "$My_name: === Creating rule '$$Pfrom_rule'\n" if $diagnostics;
+ rdb_create_rule( $from_rule, 'cusdep', '', \@PAnew_cmd, 3,
+ $source, $new_dest, $base_name, 0 );
+ }
+ rdb_ensure_file( $rule, $new_dest, $from_rule );
+ # We've now got a spurious file in our rule. But don't mess
+ # with deleting an item we are in the middle of!
+ push @deletions, [$rule, $file];
+ return;
+ }
+ } # End of Rule found
+ } # End DEP
+ if ( (! -e $file) && $use_make_for_missing_files ) {
+ # Try to make the missing file
+ #Set character to surround filenames in commands:
+ my $q = $quote_filenames ? '"' : '';
+ if ( $toext ne '' ) {
+ print "$My_name: '$rule': source file '$file' doesn't exist. I'll try making it...\n";
+ &Run_subst( "$make $q$file$q" );
+ if ( -e $file ) {
+ return;
+ }
+ }
+ else {
+ print "$My_name: '$rule': source '$file' doesn't exist.\n",
+ " I'll try making it with allowed extensions \n";
+ foreach my $try_ext ( keys %$Pinput_extensions ) {
+ my $new_dest = "$file.$try_ext";
+ &Run_subst( "$make $q$new_dest$q" );
+ if ( -e $new_dest ) {
+ print "SUCCESS in making '$new_dest'\n";
+ # Put file in rule, without a from_rule, but
+ # set its state as non-existent, to correspond
+ # to file's state before the file was made
+ # This ensures a rerun of (pdf)latex is provoked.
+ rdb_ensure_file( $rule, $new_dest, undef, 1 );
+ push @new_sources, $new_dest;
+ push @deletions, [$rule, $file];
+ # Flag need for a new run of (pdf)latex despite
+ # the error due to a missing file.
+ $$Pout_of_date_user = 1;
+ return;
+ }
+ }
+ }
+ }
+} #END rdb_one_dep
+
+#************************************************************
+
+sub rdb_list {
+ # Call: rdb_list()
+ # List rules and their source files
+ print "===Rules:\n";
+ local $count_rules = 0;
+ my @accessible_all = &rdb_accessible;
+ rdb_for_some(
+ \@accessible_all,
+ sub{ $count_rules++;
+ print "Rule '$rule' depends on:\n";
+ },
+ sub{ print " '$file'\n"; },
+ sub{ print " and generates:\n";
+ foreach (keys %$PHdest) { print " '$_'\n"; }
+# print " default_extra_generated:\n";
+# foreach (@$PA_extra_gen) { print " '$_'\n"; }
+ },
+ );
+ if ($count_rules <= 0) {
+ print " ---No rules defined\n";
+ }
+} #END rdb_list
+
+#************************************************************
+
+sub deps_list {
+ # Call: deps_list(fh)
+ # List dependent files to file open on fh
+ my $fh = $_[0];
+ print $fh "#===Dependents, and related info, for $filename:\n";
+ my @dest_exts = ();
+ if ($pdf_mode) {push @dest_exts, '.pdf';}
+ if ($dvi_mode) {push @dest_exts, '.dvi';}
+ if ($postscript_mode) {push @dest_exts, '.ps';}
+ my %source = ( $texfile_name => 1 );
+ my @generated = ();
+ my @accessible_all = &rdb_accessible;
+ rdb_for_some(
+ \@accessible_all,
+ sub{ push @generated, keys %$PHdest; },
+ sub{ $source{$file} = 1; }
+ );
+ foreach (keys %generated_exts_all) {
+ (my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/${aux_dir1}${root_filename}/;
+ push @generated, $name;
+ }
+ show_array( "Generated:", @generated ) if $diagnostics;
+ foreach (@generated) {
+ delete $source{$_};
+ }
+ show_array( "Sources:", keys %source ) if $diagnostics;
+ foreach my $ext (@dest_exts) {
+ # Don't insert name of deps file in targets.
+ # The previous behavior of inserting the name of the deps file
+ # matched the method recommended by GNU make for automatically
+ # generated prerequisites -- see Sec. "Generating Prerequisites
+ # Automatically" of GNU make manual (v. 4.2). But this can
+ # cause problems in complicated cases, and as far as I can see,
+ # it doesn't actually help, despite the reasoning given.
+ # The only purpose of the deps file is to to determine source
+ # files for a particular rule. The files whose changes make the
+ # deps file out-of-date are the same as those that make the real
+ # target file (e.g., .pdf) out-of-date. So the GNU method seems
+ # completely unnecessary.
+ print $fh "${out_dir1}${root_filename}${ext} :";
+ foreach (sort keys %source) {
+ print $fh "\\\n $_";
+ }
+ print $fh "\n";
+ }
+ print $fh "#===End dependents for $filename:\n";
+ if ($dependents_phony) {
+ print $fh "\n#===Phony rules for $filename:\n\n";
+ foreach (sort keys %source) {
+ print $fh "$_ :\n\n";
+ }
+ print $fh "#===End phony rules for $filename:\n";
+ }
+} #END deps_list
+
+#************************************************************
+
+sub rdb_show {
+ # Call: rdb_show()
+ # Displays contents of rule data base.
+ # Side effect: Exercises access routines!
+ print "===Rules:\n";
+ local $count_rules = 0;
+ rdb_for_actives(
+ sub{ $count_rules++;
+ my @int_cmd = @$PAint_cmd;
+ foreach (@int_cmd) {
+ if ( !defined($_) ) { $_='undef';}
+ }
+ print " [$rule]: '$$Pcmd_type' '$$Pext_cmd' '@int_cmd' $$Ptest_kind ",
+ "'$$Psource' '$$Pdest' '$$Pbase' $$Pout_of_date $$Pout_of_date_user\n"; },
+ sub{ print " '$file': $$Ptime $$Psize $$Pmd5 '$$Pfrom_rule'\n"; }
+ );
+ if ($count_rules <= 0) {
+ print " ---No rules defined\n";
+ }
+} #END rdb_show
+
+#************************************************************
+
+sub rdb_target_array {
+ # Returns array of all rules implicated by %target_rules and %target_files
+ my %rules = &rdb_target_hash;
+ return keys %rules;
+} # End rdb_target_array
+
+#************************************************************
+
+sub rdb_target_hash {
+ # Returns hash mapping to 1 all rules implicated by %target_rules and %target_files
+ my %rules = %target_rules;
+ foreach (keys %target_files) {
+ if (exists $from_rules{$_}) { $rules{$from_rules{$_}} = 1; }
+ }
+ return %rules;
+} # End rdb_target_hash
+
+#************************************************************
+
+sub rdb_accessible {
+ # Call: &rdb_accessible
+ # Returns array of rules accessible from target rules and rules to make target files
+
+ local %accessible_rules = &rdb_target_hash;
+ rdb_recurse( [keys %accessible_rules], sub{ $accessible_rules{$rule} = 1; } );
+ return keys %accessible_rules;
+} #END rdb_accessible
+
+#************************************************************
+#************************************************************
+#************************************************************
+
+sub rdb_make {
+ # Call: &rdb_make
+ # Makes the targets and prerequisites.
+ # Leaves one-time rules to last.
+ # Does appropriate repeated makes to resolve dependency loops
+
+ # Returns 0 on success, nonzero on failure.
+
+ # General method: Find all accessible rules, then repeatedly make
+ # them until all accessible rules are up-to-date and the source
+ # files are unchanged between runs. On termination, all
+ # accessible rules have stable source files.
+ #
+ # One-time rules are view and print rules that should not be
+ # repeated in an algorithm that repeats rules until the source
+ # files are stable. It is the calling routine's responsibility to
+ # arrange to call them, or to use them here with caution.
+ #
+ # Note that an update-viewer rule need not be considered
+ # one-time. It can be legitimately applied everytime the viewed
+ # file changes.
+ #
+ # Note also that the criterion of stability is to be applied to
+ # source files, not to output files. Repeated application of a
+ # rule to IDENTICALLY CONSTANT source files may produce different
+ # output files. This may be for a trivial reason (e.g., the
+ # output file contains a time stamp, as in the header comments for
+ # a typical postscript file), or for a non-trivial reason (e.g., a
+ # stochastic algorithm, as in abcm2ps).
+ #
+ # This caused me some actual trouble. In general, circular
+ # dependencies produce non-termination, and the the following
+ # situation is an example of a generic situation where certain
+ # rules must be obeyed in order to obtain proper results:
+ # 1. A/the latex source file contains specifications for
+ # certain postprocessing operations. Standard (pdf)latex
+ # already has this, for indexing and bibliography.
+ # 2. In the case in point that caused me trouble, the
+ # specification was for musical tunes that were contained
+ # in external source files not directly input to
+ # (pdf)latex. But in the original version, there was a
+ # style file (abc.sty) that caused latex itself to call
+ # abcm2ps to make .eps files for each tune that were to be
+ # read in on the next run of latex.
+ # 3. Thus the specification can cause a non-terminating loop
+ # for latexmk, because the output files of abcm2ps changed
+ # even with identical input.
+ # 4. The solution was to
+ # a. Use a style file abc_get.sty that simply wrote the
+ # specification on the tunes to the .aux file in a
+ # completely deterministic fashion.
+ # b. Instead of latex, use a script abclatex.pl that runs
+ # latex and then extracts the abc contents for each tune
+ # from the source abc file. This is also
+ # deterministic.
+ # c. Use a cusdep rule in latexmk to convert the tune abc
+ # files to eps. This is non-deterministic, but only
+ # gets called when the (deterministic) source file
+ # changes.
+ # This solves the problem. Latexmk works. Also, it is no
+ # longer necessary to enable write18 in latex, and multiple
+ # unnecessary runs of abcm2ps are no longer used.
+ #
+ # The order of testing and applying rules is chosen by the
+ # following heuristics:
+ # 1. Both latex and pdflatex may be used, but the resulting
+ # aux files etc may not be completely identical. Define
+ # latex and pdflatex as primary rules. Apply the general
+ # method of repeated circulating through all rules until
+ # the source files are stable for each primary rule
+ # separately. Naturally the rules are all accessible
+ # rules, but excluding primary rules except for the current
+ # primary.
+ # 2. Assume that the primary rules are relatively
+ # time-consuming, so that unnecessary passes through them
+ # to check stability of the source files should be avoided.
+ # 3. Assume that although circular dependencies exist, the
+ # rules can nevertheless be thought of as basically
+ # non-circular, and that many rules are strictly or
+ # normally non-circular. In particular cusdep rules are
+ # typically non-circular (e.g., fig2eps), as are normal
+ # output processing rules like dvi2ps.
+ # 4. The order for the non-circular approximation is
+ # determined by applying the assumption that an output file
+ # from one rule that is read in for an earlier stage is
+ # unchanged.
+ # HOWEVER, at a first attempt, the ordering is not needed. It
+ # only gives an optimization
+ # 5. (Note that these assumptions could be violated, e.g., if
+ # $dvips is arranged not only to do the basic dvips
+ # command, but also to extract information from the ps file
+ # and feed it back to an input file for (pdf)latex.)
+ # 6. Nevertheless, the overall algorithm should allow
+ # circularities. Then the general criterion of stability
+ # of source files covers the general case, and also
+ # robustly handles the case that the USER changes source
+ # files during a run. This is particularly important in
+ # -pvc mode, given that a full make on a large document can
+ # be quite lengthy in time, and moreover that a user
+ # naturally wishes to make corrections in response to
+ # errors, particularly latex errors, and have them apply
+ # right away.
+ # This leads to the following approach:
+ # 1. Classify accessible rules as: primary, pre-primary
+ # (typically cusdep, bibtex, makeindex, etc), post-primary
+ # (typically dvips, etc), and one-time
+ # 2. Then stratify the rules into an order of application that
+ # corresponds to the basic feedforward structure, with the
+ # exclusion of one-time rules.
+ # 3. Always require that one-time rules are among the
+ # explicitly requested rules, i.e., the last to be applied,
+ # were we to apply them. Anything else would not match the
+ # idea of a one-time rule.
+ # 4. Then work as follows:
+ # a. Loop over primaries
+ # b. For each primary, examine each pre-primary rule and
+ # apply if needed, then the primary rule and then each
+ # post-primary rule. The ordering of the pre-primary
+ # and post-primary rules was found in step 2.
+ # BUT applying the ordering is not essential
+ # c. Any time that a pre-primary or primary rule is
+ # applied, loop back to the beginning of step b. This
+ # ensures that bibtex etc are applied before rerunning
+ # (pdf)latex, and also covers changing source files, and
+ # gives priority to quick pre-primary rules for changing
+ # source files against slow reruns of latex.
+ # d. Then apply post-primary rules in order, but not
+ # looping back after each rule. This non-looping back
+ # is because the rules are normally feed-forward only.
+ # BUT applying the ordering is not essential
+ # e. But after completing post-primary rules do loop back
+ # to b if any rules were applied. This covers exotic
+ # circular dependence (and as a byproduct, changing
+ # source files).
+ # f. On each case of looping back to b, re-evaluate the
+ # dependence setup to allow for the effect of changing
+ # source files.
+ #
+
+
+ &rdb_set_rule_net;
+
+ local %pass = ();
+ local $failure = 0; # General accumulated error flag
+ local $missing_dvi_pdf = ''; # Did primary run fail to make its output file?
+ local $runs = 0;
+ local $too_many_passes = 0;
+ local %rules_applied = ();
+ local $switched_primary_output = 0;
+ my $retry_msg = 0; # Did I earlier say I was going to attempt
+ # another pass after a failure?
+ rdb_for_some ( [keys %rule_db],
+ sub{ $pass{$rule} = 0;
+ foreach (keys %$PHsource_rules) {
+ $$PHsource_rules{$_} = 0;
+ }
+ }
+ );
+ PASS:
+ while (1==1) {
+ # Exit condition at end of body of loop.
+ $runs = 0;
+ $switched_primary_output = 0;
+ my $previous_failure = $failure;
+ $failure = 0;
+ local $newrule_nofile = 0; # Flags whether rule created for
+ # making currently non-existent file, which
+ # could become a needed source file for a run
+ # and therefore undo an error condition
+ foreach my $rule (keys %rule_db) {
+ # Update %pass in case new rules have been created
+ if (! exists $pass{$rule} ) { $pass{$rule} = 0; }
+ }
+ if ($diagnostics) {
+ print "Make: doing pre_primary and primary...\n";
+ }
+ # Do the primary run if it is needed. On return $runs == 0
+ # signals that nothing was run (and hence no output
+ # files changed), either because no input files
+ # changed and no run was needed, or because the
+ # number of passes through the rule exceeded the
+ # limit. In the second case $too_many_runs is set.
+ rdb_for_some( [@pre_primary, $current_primary], \&rdb_make1 );
+ if ($switched_primary_output) {
+ print "=========SWITCH OF OUTPUT WAS DONE.\n";
+ next PASS;
+ }
+ if ( ($runs > 0) && ! $too_many_passes ) {
+ $retry_msg = 0;
+ if ( $force_mode || (! $failure) || $switched_primary_output ) {
+ next PASS;
+ }
+ # Get here on failure, without being in force_mode
+ if ( $newrule_nofile ) {
+ $retry_msg = 1;
+ print "$My_name: Error on run, but found possibility to ",
+ "make new source files\n";
+ next PASS;
+ }
+ else { last PASS; }
+ }
+ if ($runs == 0) {
+ # $failure not set on this pass, so use value from previous pass:
+ $failure = $previous_failure;
+ if ($retry_msg) {
+ print "But in fact no new files made\n";
+ }
+ if ($failure && !$force_mode ) { last PASS; }
+ }
+ if ( $missing_dvi_pdf ) {
+ # No output from primary, after completing circular dependence
+ warn "Failure to make '$missing_dvi_pdf'\n";
+ $failure = 1;
+ last PASS;
+ }
+ if ($diagnostics) {
+ print "Make: doing post_primary...\n";
+ }
+ rdb_for_some( [@post_primary], \&rdb_make1 );
+ if ( ($runs == 0) || $too_many_passes ) {
+ # If $too_many_passes is set, it should also be that
+ # $runs == 0; but for safety, I also checked
+ # $too_many_passes.
+ last PASS;
+ }
+ }
+ continue {
+ # Re-evaluate rule classification and accessibility,
+ # but do not change primaries.
+ # Problem is that %current_primaries gets altered
+ &rdb_set_rule_net;
+ } #End PASS
+
+ rdb_for_some( [@unusual_one_time], \&rdb_make1 );
+ rdb_write( $fdb_name );
+
+ if ($#primary_warning_summary > -1) {
+ # N.B. $mult_defined, $bad_reference, $bad_character, $bad_citation also available here.
+ show_array( "$My_name: Summary of warnings from last run of (pdf)latex:",
+ @primary_warning_summary );
+ }
+ if (! $silent) {
+ if ($failure && $force_mode) {
+ print "$My_name: Errors, in force_mode: so I tried finishing targets\n";
+ }
+ elsif ($failure) {
+ print "$My_name: Errors, so I did not complete making targets\n";
+ }
+ else {
+ local @dests = ();
+ rdb_for_some( [@_], sub{ push @dests, $$Pdest if ($$Pdest); } );
+ print "$My_name: All targets (@dests) are up-to-date\n";
+ }
+ }
+ rdb_for_some ( [keys %rule_db],
+ sub{
+ foreach my $s_rule (keys %$PHsource_rules) {
+ $$PHsource_rules{$s_rule} = $pass{$s_rule};
+ }
+ }
+ );
+ return $failure;
+} #END rdb_make
+
+#-------------------
+
+sub rdb_show_rule_errors {
+ local @errors = ();
+ local @warnings = ();
+ rdb_for_actives(
+ sub{
+ if ($$Plast_message ne '') {
+ if ($$Plast_result == 200) {
+ push @warnings, "$rule: $$Plast_message";
+ }
+ else {
+ push @errors, "$rule: $$Plast_message";
+ }
+ }
+ elsif ($$Plast_result == 1) {
+ push @errors, "$rule: failed to create output file";
+ }
+ elsif ($$Plast_result == 2) {
+ push @errors, "$rule: gave an error";
+ }
+ elsif ($$Prun_time == 0) {
+ # This can have innocuous causes. So don't report
+ }
+ }
+ );
+ if ($#warnings > -1) {
+ warn "Collected warning summary (may duplicate other messages):\n";
+ foreach (@warnings){
+ warn " $_\n";
+ }
+ }
+ if ($#errors > -1) {
+ warn "Collected error summary (may duplicate other messages):\n";
+ foreach (@errors){
+ warn " $_\n";
+ }
+ }
+ return $#errors+1;
+}
+
+#-------------------
+
+sub rdb_make1 {
+ # Call: rdb_make1
+ # Helper routine for rdb_make.
+ # Carries out make at level of given rule (all data available).
+ # Assumes contexts for recursion, make, and rule, and
+ # assumes that source files for the rule are to be considered
+ # up-to-date.
+ if ($diagnostics) { print " Make1 $rule\n"; }
+ if ($failure & ! $force_mode) {return;}
+ if ( ! defined $pass{$rule} ) {$pass{$rule} = 0; }
+
+ # Special fix up for bibtex:
+ my $bibtex_not_run = -1; # Flags status as to whether this is a
+ # bibtex rule and if it is, whether out-of-date condition is to
+ # be ignored.
+ # -1 => not a bibtex rule
+ # 0 => no special treatment
+ # 1 => don't run bibtex because of non-existent bibfiles
+ # (and setting to do this test)
+ # 2 => don't run bibtex because of setting
+ my @missing_bib_files = ();
+ if ( $rule =~ /^(bibtex|biber)/ ) {
+ $bibtex_not_run = 0;
+ if ($bibtex_use == 0) {
+ $bibtex_not_run = 2;
+ }
+ elsif ( ($bibtex_use == 1) || ($bibtex_use == 1.5) ) {
+ foreach ( keys %$PHsource ) {
+ if ( ( /\.bib$/ ) && (! -e $_) ) {
+ push @missing_bib_files, $_;
+ $bibtex_not_run = 1;
+ }
+ }
+ }
+ }
+
+ if ( ($$Prun_time == 0) && exists($possible_primaries{$rule}) ) {
+ push @rules_never_run, $rule;
+ $$Pout_of_date = 1;
+ $$Plast_result = -1;
+ }
+ else {
+ if ( $$Pdest && (! -e $$Pdest) ) {
+ # With a non-existent destination, if we haven't made any passes
+ # through a rule, rerunning the rule is good, because the file
+ # may fail to exist because of being deleted by the user (for ex.)
+ # rather than because of a failure on a previous run.
+ # (We could do better with a flag in fdb file.)
+ # But after the first pass, the situation is different.
+ # For a primary rule (pdf)latex, the lack of a destination file
+ # could result from there being zero content due to a missing
+ # essential input file. The input file could be generated
+ # by a program to be run later (e.g., a cusdep or bibtex),
+ # so we should wait until all passes are completed before
+ # deciding a non-existent destination file is an error.
+ # For a custom dependency, the rule may be obsolete, and
+ # if the source file does not exist also, we should simply
+ # not run the rule, but not set an error condition.
+ # Any error will arise at the (pdf)latex level due to a
+ # missing source file at that level.
+ if ( $$Psource && (! -e $$Psource)
+ && ( ( $$Pcmd_type ne 'primary') )
+ ) {
+ # Main source file doesn't exist, and rule is NOT primary.
+ # No action, since a run is pointless. Primary is different:
+ # file might be found elsewhere (by kpsearch from (pdf)latex),
+ # while non-existence of main source file is a clear error.
+ }
+ elsif ( $$Pcmd_type eq 'delegated' ) {
+ # Delegate to destination rule
+ }
+ elsif ( $pass{$rule}==0) {
+ push @no_dest, $$Pdest;
+ $$Pout_of_date = 1;
+ }
+ if ( $$Pcmd_type eq 'primary' ) {
+ $missing_dvi_pdf = $$Pdest;
+ }
+ }
+ }
+
+ &rdb_clear_change_record;
+ &rdb_flag_changes_here(0);
+
+ if (!$$Pout_of_date) {
+ return;
+ }
+ if ($diagnostics) { print " remake\n"; }
+ if (!$silent) {
+ print "$My_name: applying rule '$rule'...\n";
+ &rdb_diagnose_changes( "Rule '$rule': " );
+ }
+
+ # We are applying the rule, so its source file state for when it
+ # was last made is as of now:
+ # ??IS IT CORRECT TO DO NOTHING IN CURRENT VERSION?
+
+ # The actual run
+ my $return = 0; # Return code from called routine
+ # Rule may have been created since last run:
+ if ( ! defined $pass{$rule} ) {$pass{$rule} = 0; }
+ if ( $pass{$rule} >= $max_repeat ) {
+ # Avoid infinite loop by having a maximum repeat count
+ # Getting here represents some kind of weird error.
+ warn "$My_name: Maximum runs of $rule reached ",
+ "without getting stable files\n";
+ $too_many_passes = 1;
+ # Treat rule as completed, else in -pvc mode get infinite reruns:
+ $$Pout_of_date = 0;
+ $failure = 1;
+ $failure_msg = "'$rule' needed too many passes";
+ return;
+ }
+
+ $rules_applied{$rule} = 1;
+ $runs++;
+
+ $pass{$rule}++;
+ if ($bibtex_not_run > 0) {
+ if ($bibtex_not_run == 1 ) {
+ show_array ("$My_name: I WON'T RUN '$rule' because I don't find the following files:",
+ @missing_bib_files);
+ }
+ elsif ($bibtex_not_run == 2 ) {
+ warn "$My_name: I AM CONFIGURED/INVOKED NOT TO RUN '$rule'\n";
+ }
+ $return = &rdb_dummy_run1;
+ }
+ else {
+ warn_running( "Run number $pass{$rule} of rule '$rule'" );
+ if ($$Pcmd_type eq 'primary' ) {
+ $return = &rdb_primary_run;
+ }
+ else { $return = &rdb_run1; }
+ }
+ if ($$Pchanged) {
+ $newrule_nofile = 1;
+ $return = 0;
+ }
+ elsif ( $$Pdest && ( !-e $$Pdest ) && (! $failure) ){
+ # If there is a destination to make, but for some reason
+ # it did not get made, and no other error was reported,
+ # then a priori there appears to be an error condition:
+ # the run failed. But there are some important cases in
+ # which this is a wrong diagnosis.
+ if ( ( $$Pcmd_type eq 'cusdep') && $$Psource && (! -e $$Psource) ) {
+ # However, if the rule is a custom dependency, this is not by
+ # itself an error, if also the source file does not exist. In
+ # that case, we may have the situation that (1) the dest file is no
+ # longer needed by the tex file, and (2) therefore the user
+ # has deleted the source and dest files. After the next
+ # latex run and the consequent analysis of the log file, the
+ # cusdep rule will no longer be needed, and will be removed.
+
+ # So in this case, do NOT report an error
+ $$Pout_of_date = 0;
+ }
+ elsif ($$Pcmd_type eq 'primary' ) {
+ # For a primary rule, i.e., (pdf)latex, not to produce the
+ # expected output file may not be an error condition.
+ # Diagnostics were handled in parsing the log file.
+ # Special action in main loop in rdb_make
+ $missing_dvi_pdf = $$Pdest;
+ }
+ elsif ($return == -2) {
+ # Missing output file was reported to be NOT an error
+ $$Pout_of_date = 0;
+ }
+ elsif ( ($bibtex_use <= 1.5) && ($bibtex_not_run > 0) ) {
+ # Lack of destination file is not to be treated as an error
+ # for a bibtex rule when latexmk is configured not to treat
+ # this as an error, and the lack of a destination file is the
+ # only error.
+ $$Pout_of_date = 0;
+ }
+ else {
+ $failure = 1;
+ }
+ }
+ if ( ($return != 0) && ($return != -2) ) {
+ $failure = 1;
+ $$Plast_result = 2;
+ if ( !$$Plast_message ) {
+ $$Plast_message = "Run of rule '$rule' gave a non-zero error code";
+ }
+# !!?? $failure_msg = $$Plast_message;
+
+ }
+ foreach ( keys %$PHsource_rules ) {
+ $$PHsource_rules{$_} = $pass{$_};
+ }
+} #END rdb_make1
+
+#************************************************************
+
+sub rdb_classify_rules {
+ # Usage: &rdb_classify_rules
+ # Assume the following variables are available (global or local):
+ # Input:
+ # %target_rules # Set to target rules
+ # %target_files # Set to target files
+ # %possible_primaries
+
+ # Output:
+ # %current_primaries # Keys are actual primaries
+ # @pre_primary # Array of rules
+ # @post_primary # Array of rules
+ # @unusual_one_time # Array of rules
+ # @pre_primary and @post_primary are in natural order of application.
+
+ local @requested_targets = &rdb_target_array;
+ local $state = 0; # Post-primary
+ local @classify_stack = ();
+
+ %current_primaries = ();
+ @pre_primary = ();
+ @post_primary = ();
+ @unusual_one_time = ();
+
+ rdb_recurse( \@requested_targets, \&rdb_classify1, 0,0, \&rdb_classify2 );
+
+ # Reverse, as tendency is to find last rules first.
+ @pre_primary = reverse @pre_primary;
+ @post_primary = reverse @post_primary;
+
+ my @current_primaries = keys %current_primaries;
+ if ($#current_primaries < 0) {
+ die "$My_name: No active primary rules found. I have to stop.\n";
+ }
+ elsif ($#current_primaries > 0) {
+ die "$My_name: More than one active primary rule found. I have to stop.\n",
+ " Primary rules: @current_primaries\n";
+ }
+ $current_primary = $current_primaries[0];
+
+ if ($diagnostics) {
+ print "Rule classification: \n";
+ if ($#requested_targets < 0) {
+ print " No requested rules\n";
+ }
+ else {
+ print " Requested rules:\n";
+ foreach ( @requested_targets ) { print " $_\n"; }
+ }
+ if ($#pre_primary < 0) {
+ print " No pre-primaries\n";
+ }
+ else {
+ print " Pre-primaries:\n";
+ foreach (@pre_primary) { print " $_\n"; }
+ }
+ print " Primaries:\n";
+ foreach (keys %current_primaries) { print " $_\n"; }
+ if ($#post_primary < 0) {
+ print " No post-primaries\n";
+ }
+ else {
+ print " Post-primaries:\n";
+ foreach (@post_primary) { print " $_\n"; }
+ }
+ if ($#unusual_one_time < 0) {
+ print " No inner-level one_time rules, as expected\n";
+ }
+ else {
+ print " Inner-level one_time rules:\n";
+ foreach ( @unusual_one_time ) { print " $_\n"; }
+ }
+ my @normal_one_time = keys %one_time;
+ if ($#normal_one_time < 0) {
+ print " No outer-level one_time rules\n";
+ }
+ else {
+ print " Outer-level one_time rules:\n";
+ foreach ( @normal_one_time ) { print " $_\n"; }
+ }
+ } #end diagnostics
+
+} #END rdb_classify_rules
+
+#-------------------
+
+sub rdb_classify1 {
+ # Helper routine for rdb_classify_rules
+ # Applied as rule_act1 in recursion over rules
+ # Assumes rule context, and local variables from rdb_classify_rules
+ push @classify_stack, [$state];
+ if ( exists $possible_one_time{$rule} ) {
+ # Normally, we will have already extracted the one_time rules,
+ # and they will never be accessed here. But just in case of
+ # problems or generalizations, we will cover all possibilities:
+ if ($depth > 1) {
+ warn "ONE TIME rule not at outer level '$rule'\n";
+ }
+ push @unusual_one_time, $rule;
+ }
+ elsif ($state == 0) {
+ if ( exists $possible_primaries{$rule} ) {
+ $state = 1; # In primary rule
+ $current_primaries{ $rule } = 1;
+ }
+ else {
+ push @post_primary, $rule;
+ }
+ }
+ else {
+ $state = 2; # in post-primary rule
+ push @pre_primary, $rule;
+ }
+} #END rdb_classify1
+
+#-------------------
+
+sub rdb_classify2 {
+ # Helper routine for rdb_classify_rules
+ # Applied as rule_act2 in recursion over rules
+ # Assumes rule context
+ ($state) = @{ pop @classify_stack };
+} #END rdb_classify2
+
+#************************************************************
+
+
+sub rdb_run1 {
+ # Assumes contexts for: rule.
+ # Unconditionally apply the rule
+ # Returns return code from applying the rule.
+ # Otherwise: 0 on other kind of success,
+ # -1 on error,
+ # -2 when missing dest_file is to be ignored
+
+ # Source file data, by definition, correspond to the file state just
+ # before the latest run, and the run_time to the time just before the run:
+ &rdb_update_files;
+ $$Prun_time = time();
+ $$Pchanged = 0; # No special changes in files
+ $$Plast_result = 0;
+ $$Plast_message = '';
+
+ # Return values for external command:
+ my $return = 0;
+
+ # Find any internal command
+ my @int_args = @$PAint_cmd;
+ my $int_cmd = shift @int_args;
+ my @int_args_for_printing = @int_args;
+ foreach (@int_args_for_printing) {
+ if ( ! defined $_ ) { $_ = 'undef'; }
+ }
+ if ($int_cmd) {
+ print "For rule '$rule', running '\&$int_cmd( @int_args_for_printing )' ...\n";
+ $return = &$int_cmd( @int_args );
+ }
+ elsif ($$Pext_cmd) {
+ $return = &Run_subst() / 256;
+ }
+ else {
+ warn "$My_name: Either a bug OR a configuration error:\n",
+ " No command provided for '$rule'\n";
+ &traceback();
+ $return = -1;
+ $$Plast_result = 2;
+ $$Plast_message = "Bug or configuration error; incorrect command type";
+ }
+ if ( $rule =~ /^biber/ ) {
+ my @biber_source = ( );
+ my $retcode = check_biber_log( $$Pbase, \@biber_source );
+ foreach my $source ( @biber_source ) {
+# if ( $source =~ /\"/ ) {next; }
+ print " ===Source file '$source' for '$rule'\n"
+ if ($diagnostics);
+ rdb_ensure_file( $rule, $source );
+ }
+ if ($retcode == 5) {
+ # Special treatment if sole missing file is bib file
+ # I don't want to treat that as an error
+ $return = 0;
+ $$Plast_result = 200;
+ $$Plast_message = "Could not find bib file for '$$Pbase'";
+ push @warnings, "Bib file not found for '$$Pbase'";
+ }
+ elsif ($retcode == 6) {
+ # Missing control file. Need to remake it (if possible)
+ # Don't treat missing bbl file as error.
+ warn "$My_name: bibtex control file missing. Since that can\n",
+ " be recreated, I'll try to do so.\n";
+ $return = -2;
+ rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } );
+ }
+ elsif ($retcode == 4) {
+ $$Plast_result = 2;
+ $$Plast_message = "Could not find all biber source files for '$$Pbase'";
+ push @warnings, "Not all biber source files found for '$$Pbase'";
+ }
+ elsif ($retcode == 3) {
+ $$Plast_result = 2;
+ $$Plast_message = "Could not open biber log file for '$$Pbase'";
+ push @warnings, $$Plast_message;
+ }
+ elsif ($retcode == 2) {
+ $$Plast_message = "Biber errors: See file '$$Pbase.blg'";
+ push @warnings, $$Plast_message;
+ }
+ elsif ($retcode == 1) {
+ push @warnings, "Biber warnings for '$$Pbase'";
+ }
+ elsif ($retcode == 10) {
+ push @warnings, "Biber found no citations for '$$Pbase'";
+ # Biber doesn't generate a bbl file in this situation.
+ $return = -2;
+ }
+ elsif ($retcode == 11) {
+ push @warnings, "Biber: malformed bcf file for '$$Pbase'. IGNORE";
+ if (!$silent) {
+ warn "$My_name: biber found malformed bcf file for '$$Pbase'.\n",
+ " I'll ignore error, and delete any bbl file.\n";
+ }
+ # Malformed bcf file is a downstream consequence, normally,
+ # of an error in (pdf)latex run. So this is not an error
+ # condition in biber itself.
+ # Current version of biber deletes bbl file.
+ # Older versions (pre-2016) made an incorrect bbl file, which
+ # tended to cause latex errors, and give a self-perpetuating error.
+ # To be safe, ensure the bbl file doesn't exist.
+ unlink $$Pdest;
+ # The missing bbl file is now not an error:
+ $return = -2;
+# ??????? BCF
+# Following is intended to work, but creates infinite loop
+# in malformed bcf file situation under -pvc.
+# since on each check for change in ANY file, pvc finds changed file
+# Need to restrict pvc reruns to case of changed USER files
+# # To give good properties for (pdf)latex rule, it is best
+# # to have a valid bbl file that exists:
+# create_empty_file( $$Pdest );
+# $return = 0;
+
+ }
+ }
+ if ( $rule =~ /^bibtex/ ) {
+ my $retcode = check_bibtex_log($$Pbase);
+ if ( ! -e $$Psource ) {
+ $retcode = 10;
+ rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } );
+ }
+ if ($retcode == 3) {
+ $$Plast_result = 2;
+ $$Plast_message = "Could not open bibtex log file for '$$Pbase'";
+ push @warnings, $$Plast_message;
+ }
+ elsif ($retcode == 2) {
+ $$Plast_message = "Bibtex errors: See file '$$Pbase.blg'";
+ $failure = 1;
+ push @warnings, $$Plast_message;
+ }
+ elsif ($retcode == 1) {
+ push @warnings, "Bibtex warnings for '$$Pbase'";
+ }
+ elsif ($retcode == 10) {
+ push @warnings, "Bibtex found no citations for '$$Pbase',\n",
+ " or bibtex found a missing aux file\n";
+ if (! -e $$Pdest ) {
+ warn "$My_name: Bibtex did not produce '$$Pdest'. But that\n",
+ " was because of missing files, so I will continue.\n";
+ $return = -2;
+ }
+ else {
+ $return = 0;
+ }
+ }
+ }
+
+ $updated = 1;
+ if ($$Ptest_kind == 3) {
+ # We are time-criterion first time only. Now switch to
+ # file-change criterion
+ $$Ptest_kind = 1;
+ }
+ $$Pout_of_date = $$Pout_of_date_user = 0;
+
+ if ( ($$Plast_result == 0) && ($return != 0) && ($return != -2) ) {
+ $$Plast_result = 2;
+ if ($$Plast_message eq '') {
+ $$Plast_message = "Command for '$rule' gave return code $return";
+ if ($rule =~ /^(pdf|lua|xe|)latex/) {
+ $$Plast_message .= "\n Refer to '$log_name' for details";
+ }
+ elsif ($rule =~ /^makeindex/) {
+ $$Plast_message .= "\n Refer to '${aux_dir1}${root_filename}.ilg' for details";
+ }
+ }
+ }
+ elsif ( $$Pdest && (! -e $$Pdest) && ($return != -2) ) {
+ $$Plast_result = 1;
+ }
+ return $return;
+} # END rdb_run1
+
+#-----------------
+
+sub rdb_dummy_run1 {
+ # Assumes contexts for: rule.
+ # Update rule state as if the rule ran successfully,
+ # but don't run the rule.
+ # Returns 0 (success code)
+
+ # Source file data, by definition, correspond to the file state just before
+ # the latest run, and the run_time to the time just before the run:
+ &rdb_update_files;
+ $$Prun_time = time();
+ $$Pchanged = 0; # No special changes in files
+ $$Plast_result = 0;
+ $$Plast_message = '';
+
+ if ($$Ptest_kind == 3) {
+ # We are time-criterion first time only. Now switch to
+ # file-change criterion
+ $$Ptest_kind = 1;
+ }
+ $$Pout_of_date = $$Pout_of_date_user = 0;
+
+ return 0;
+} # END rdb_dummy_run1
+
+#-----------------
+
+sub Run_subst {
+ # Call: Run_subst( cmd, msg, options, source, dest, base )
+ # Runs command with substitutions.
+ # If an argument is omitted or undefined, it is replaced by a default:
+ # cmd is the command to execute
+ # msg is whether to print a message:
+ # 0 for not, 1 according to $silent setting, 2 always
+ # options, source, dest, base: correspond to placeholders.
+ # Substitutions:
+ # %S=source, %D=dest, %B=base, %R=root=base for latex, %O=options,
+ # %T=texfile, %Y=$aux_dir1, %Z=$out_dir1
+ # This is a globally usable subroutine, and works in a rule context,
+ # and outside.
+ # Defaults:
+ # cmd: $PPext_cmd if defined, else '';
+ # msg: 1
+ # options: ''
+ # source: $$Psource if defined, else $texfile_name;
+ # dest: $$Pdest if defined, else $view_file, else '';
+ # base: $$Pbase if defined, else $root_filename;
+
+ my ($ext_cmd, $msg, $options, $source, $dest, $base ) = @_;
+
+ $ext_cmd ||= ( $Pext_cmd ? $$Pext_cmd : '' );
+ $msg = ( defined $msg ? $msg : 1 );
+ $options ||= '';
+ $source ||= ( $Psource ? $$Psource : $texfile_name );
+ $dest ||= ( $Pdest ? $$Pdest : ( $view_file || '' ) );
+ $base ||= ( $Pbase ? $$Pbase : $root_filename );
+
+ if ( $ext_cmd eq '' ) {
+ return 0;
+ }
+
+ #Set character to surround filenames:
+ my $q = $quote_filenames ? '"' : '';
+
+ my %subst = (
+ '%A' => $q.$tex_basename.$q,
+ '%B' => $q.$base.$q,
+ '%D' => $q.$dest.$q,
+ '%O' => $options,
+ '%S' => $q.$source.$q,
+ '%R' => $q.$root_filename.$q,
+ '%S' => $q.$source.$q,
+ '%T' => $q.$texfile_name.$q,
+ '%Y' => $q.$aux_dir1.$q,
+ '%Z' => $q.$out_dir1.$q,
+ '%%' => '%' # To allow literal %B, %R, etc, by %%B.
+ );
+ if ($pre_tex_code) {
+ $subst{'%U'} = $q.$pre_tex_code.$q;
+ $subst{'%P'} = "$q$pre_tex_code\\input{$source}$q";
+ }
+ else {
+ $subst{'%U'} = '';
+ $subst{'%P'} = $subst{'%S'};
+ }
+ if ( ($^O eq "MSWin32" ) && $MSWin_back_slash ) {
+ foreach ( '%R', '%B', '%T', '%S', '%D', '%Y', '%Z' ) {
+ $subst{$_} =~ s(/)(\\)g;
+ }
+ }
+
+ my @tokens = split /(%.)/, $ext_cmd;
+ foreach (@tokens) {
+ if (exists($subst{$_})) { $_ = $subst{$_}; }
+ }
+ $ext_cmd = join '', @tokens;
+
+ my ($pid, $return) =
+ ( ($msg == 0) || ( ($msg == 1) && $silent ) )
+ ? &Run($ext_cmd)
+ : &Run_msg($ext_cmd);
+ return $return;
+} #END Run_subst
+
+#-----------------
+
+sub rdb_primary_run {
+#?? See multipass_run in previous version Aug 2007 for issues
+ # Call: rdb_primary_run
+ # Assumes contexts for: recursion, make, & rule.
+ # Assumes (a) the rule is a primary,
+ # (b) a run has to be made,
+ # (c) source files have been made.
+ # This routine carries out the run of the rule unconditionally,
+ # and then parses log file etc.
+ my $return = 0;
+
+ if ( ! $filetime_offset_measured ) {
+ $filetime_offset = get_filetime_offset( $aux_dir1."tmp" );
+ if ( (abs($filetime_offset) > $filetime_offset_report_threshold)
+ && ($diagnostics || ! $silent) )
+ {
+ warn "$My_name: I am working around an offset relative to my system time by\n",
+ " $filetime_offset secs for file times in directory '$aux_dir1'.\n";
+ }
+ $filetime_offset_measured = 1;
+ }
+
+ # Need to reset the list of generated files. If we don't it can contain
+ # out-of-date items from previous run. (Think bibtopic, which writes
+ # bbl files!)
+ &rdb_initialize_generated;
+ my $return_latex = &rdb_run1;
+
+ # Need to worry about changed directory, changed output extension
+ # Where else is $missing_dvi_pdf set? Was it initialized?
+ if (-e $$Pdest) { $missing_dvi_pdf = '';}
+
+ # Handle case that log file is caused to be in an unexpected place,
+ # from a configuration error:
+ &find_set_log;
+
+ if ($recorder) {
+ # Handle problem that some version of (pdf)latex give fls files
+ # of name latex.fls or pdflatex.fls instead of $root_filename.fls.
+ # Also that setting of -output-directory -aux-directory is not
+ # respected by (pdf)latex, at least in some versions.
+ my $std_fls_file = $fls_name;
+ my @other_fls_names = ( );
+ if ( $rule =~ /^pdflatex/ ) {
+ push @other_fls_names, "pdflatex.fls";
+ }
+ else {
+ push @other_fls_names, "latex.fls";
+ }
+ if ( $aux_dir1 ne '' ) {
+ push @other_fls_names, "$root_filename.fls";
+ # MiKTeX uses out_dir for .fls. However, it seems logical to
+ # me for .fls to be in aux_dir. So I'll allow for this
+ # Possibility, although I don't know if it has been used.
+ push @other_fls_names, "$aux_dir1$root_filename.fls";
+ }
+ # Find the first non-standard fls file and copy it to the standard
+ # place. But only do this if the file time is compatible with being
+ # generated in the current run, and if the standard fls file hasn't
+ # been made in the current run, as tested by the use of
+ # test_gen_file; that avoids problems with fls files leftover from
+ # earlier runs with other versions of latex.
+ if ( ! test_gen_file( $std_fls_file ) ) {
+ foreach my $cand (@other_fls_names) {
+ if ( test_gen_file( $cand ) ) {
+ copy $cand, $std_fls_file;
+ last;
+ }
+ }
+ }
+ if ( ! test_gen_file( $std_fls_file ) ) {
+ warn "$My_name: fls file doesn't appear to have been made.\n";
+ }
+ }
+
+ # Find current set of source files:
+ &rdb_set_latex_deps;
+
+ # For each file of the kind made by epstopdf.sty during a run,
+ # if the file has changed during a run, then the new version of
+ # the file will have been read during the run. Unlike the usual
+ # case, we will NOT need to redo the primary run because of the
+ # change of this file during the run. Therefore set the file as
+ # up-to-date:
+ rdb_do_files( sub { if ($$Pcorrect_after_primary) {&rdb_update1;} } );
+
+ $updated = 1; # Flag that some dependent file has been remade
+
+#?? # Fix the state of the files as of now: this will solve the
+#?? # problem of latex and pdflatex interfering with each other,
+#?? # at the expense of some non-optimality
+#?? #?? Check this is correct:
+#?? &rdb_update_files;
+
+ if ( $diagnostics ) {
+ print "$My_name: Rules after run: \n";
+ rdb_show();
+ }
+
+ $return = $return_latex;
+
+# ???? Is the following needed?
+ if ($return_latex && $$Pout_of_date_user) {
+ print "Error in (pdf)LaTeX, but change of user file(s), ",
+ "so ignore error & provoke rerun\n"
+ if (! $silent);
+ $return = 0;
+ }
+ # Summarize issues that may have escaped notice:
+ @primary_warning_summary = ();
+ if ($bad_reference) {
+ push @primary_warning_summary,
+ "Latex failed to resolve $bad_reference reference(s)";
+ }
+ if ($mult_defined) {
+ push @primary_warning_summary,
+ "Latex found $mult_defined multiply defined reference(s)";
+ }
+ if ($bad_character) {
+ push @primary_warning_summary,
+ "=====Latex reported missing or unavailable character(s).\n".
+ "=====See log file for details.";
+ }
+ if ($bad_citation) {
+ push @primary_warning_summary,
+ "Latex failed to resolve $bad_citation citation(s)";
+ }
+ if ( $diagnostics && ($#primary_warning_summary > -1) ) {
+ show_array( "$My_name: Summary of warnings:", @primary_warning_summary );
+ }
+ return $return;
+} #END rdb_primary_run
+
+#************************************************************
+
+sub rdb_clear_change_record {
+ # Initialize diagnostics for reasons for running rule.
+ @changed = ();
+ %changed_rules = ();
+ @changed_user = ();
+ @disappeared = ();
+ @no_dest = (); # We are not now using this
+ @rules_never_run = ();
+ @rules_to_apply = (); # This is used in recursive application
+ # of rdb_flag_changes_here, to list
+ # rules that were out-of-date for some reason.
+} #END rdb_clear_change_record
+
+#************************************************************
+
+sub rdb_flag_changes_here {
+ # Flag changes in current rule.
+ # Assumes rule context.
+ # Usage: rdb_flag_changes_here( ignore_run_time )
+ # Argument: if true then fdb_get shouldn't do runtime test
+ # for recalculation of md5
+ local $ignore_run_time = $_[0];
+ if ( ! defined $ignore_run_time ) { $ignore_run_time = 0; }
+
+ $$Pcheck_time = time();
+
+ local $dest_mtime = 0;
+ $dest_mtime = get_mtime($$Pdest) if ($$Pdest);
+ rdb_do_files( \&rdb_file_change1);
+ while ( my ($s_rule, $l_pass) = each %$PHsource_rules ) {
+ if ( defined $pass{$s_rule}
+ && ($pass{$s_rule} > $l_pass)
+ )
+ {
+ $changed_rules{$s_rule} = $rule;
+ $$Pout_of_date = 1;
+ }
+ }
+ if ($$Pout_of_date) {
+ push @rules_to_apply, $rule;
+ }
+#?? print "======== flag: $rule $$Pout_of_date ==========\n";
+} #END rdb_flag_changes_here
+
+#************************************************************
+
+sub rdb_file_change1 {
+ # Call: &rdb_file_change1
+ # Assumes rule and file context. Assumes $dest_mtime set.
+ # Flag whether $file in $rule has changed or disappeared.
+ # Set rule's make flag if there's a change.
+
+ my $check_time_argument = 0;
+ if (! $ignore_run_time ) {
+ $check_time_argument = max( $$Pcheck_time, $$Prun_time );
+ }
+ my ($new_time, $new_size, $new_md5) = fdb_get($file, $check_time_argument );
+ my $ext_no_period = ext_no_period( $file );
+ my $generated = exists $from_rules{$file};
+ if ( ($new_size < 0) && ($$Psize >= 0) ) {
+ # print "Disappeared '$file' in '$rule'\n";
+ push @disappeared, $file;
+ # No reaction is good.
+ #$$Pout_of_date = 1;
+ # ??? 1 Sep. 2008: I do NOT think so, for cusdep no-file-exists issue
+ # ??? 30 Sep 2008: I think I have this fixed. There were other changes
+ # needed. No-change-flagged is correct. The array @disappeared flags
+ # files that have disappeared, if I need to know. But having a source
+ # file disappear is not a reason for a remake unless I know how to
+ # make the file. If the file is a destination of a rule, that rule
+ # will be rerun. It may be that the user is changing another source
+ # in such a way that the disappeared file won't be needed. Before the
+ # change is applied we get a superfluous infinite loop.
+ return;
+ }
+ if ( ($new_size < 0) && ($$Psize < 0) ) {
+ return;
+ }
+ # Primarily use md5 signature to determine whether file contents have
+ # changed.
+ # Backup by file size change, but only in the case where there is
+ # no pattern of lines to ignore in testing for a change
+ if ( ($new_md5 ne $$Pmd5)
+ || (
+ (! exists $hash_calc_ignore_pattern{$ext_no_period})
+ && ($new_size != $$Psize)
+ )
+ ) {
+ push @changed, $file;
+ $$Pout_of_date = 1;
+ if ( ! $generated ) {
+ push @changed_user, $file;
+ $$Pout_of_date_user = 1;
+ }
+ }
+ elsif ( $new_time != $$Ptime ) {
+ $$Ptime = $new_time;
+ }
+ if ( ( ($$Ptest_kind == 2) || ($$Ptest_kind == 3) )
+ && (! $generated)
+ && ( $new_time > $dest_mtime )
+ ) {
+ push @changed, $file;
+ $$Pout_of_date = $$Pout_of_date_user = 1;
+ }
+} #END rdb_file_change1
+
+#************************************************************
+
+sub rdb_user_changes {
+ # Argument(s): a set of top level rules.
+ # Aim: Find any changed user files for those rules and all ancestors.
+ # Assumption: List of from_rules for files is up-to-date.
+ &rdb_clear_change_record;
+ rdb_recurse( [@_], sub{ &rdb_flag_changes_here(1); } );
+ if ($#changed_user >=0) { show_array( 'User changed files', @changed_user ); }
+ return ($#changed_user >= 0);
+} #END rdb_user_changes
+
+#************************************************************
+
+sub rdb_diagnose_changes {
+ # Call: rdb_diagnose_changes or rdb_diagnose_changes( heading )
+ # List changes on STDERR
+ # Precede the message by the optional heading, else by "$My_name: "
+ my $heading = defined($_[0]) ? $_[0] : "$My_name: ";
+
+ if ($#rules_never_run >= 0) {
+ warn "${heading}Rules & subrules not known to be previously run:\n";
+ foreach (@rules_never_run) { warn " $_\n"; }
+ }
+ if ( ($#changed >= 0) || (keys %changed_rules > 0) || ($#disappeared >= 0) || ($#no_dest >= 0) ) {
+ warn "${heading}File changes, etc:\n";
+ if ( $#changed >= 0 ) {
+ warn " Changed files, or newly in use since previous run(s):\n";
+ foreach (uniqs(@changed)) { warn " '$_'\n"; }
+ }
+ if ( $#disappeared >= 0 ) {
+ warn " No-longer-existing files:\n";
+ foreach (uniqs(@disappeared)) { warn " '$_'\n"; }
+ }
+ if ( $#no_dest >= 0 ) {
+ warn " Non-existent destination files:\n";
+ foreach (uniqs(@no_dest)) { warn " '$_'\n"; }
+ }
+ if ( keys %changed_rules > 0 ) {
+ warn " Rule(s) that have been run and require run of dependent rule:\n";
+ while (my ($s_rule, $d_rule) = each %changed_rules) {
+ warn " '$s_rule' which requires run of '$d_rule'\n";
+ }
+ }
+ }
+ elsif ($#rules_to_apply >=0) {
+ warn "${heading}The following rules & subrules became out-of-date:\n";
+ foreach (@rules_to_apply) { warn " '$_'\n"; }
+ }
+ else {
+ warn "${heading}No file changes\n";
+ }
+} #END rdb_diagnose_changes
+
+
+#************************************************************
+#************************************************************
+#************************************************************
+#************************************************************
+
+#************************************************************
+#************************************************************
+#************************************************************
+#************************************************************
+
+# Routines for convenient looping and recursion through rule database
+# ================= NEW VERSION ================
+
+# There are several places where we need to loop through or recurse
+# through rules and files. This tends to involve repeated, tedious
+# and error-prone coding of much book-keeping detail. In particular,
+# working on files and rules needs access to the variables involved,
+# which either involves direct access to the elements of the database,
+# and consequent fragility against changes and upgrades in the
+# database structure, or involves lots of routines for reading and
+# writing data in the database, then with lots of repetitious
+# house-keeping code.
+#
+# The routines below provide a solution. Looping and recursion
+# through the database are provided by a set of basic routines where
+# each necessary kind of looping and iteration is coded once. The
+# actual actions are provided as references to action subroutines.
+# (These can be either actual references, as in \&routine, or
+# anonymous subroutines, as in sub{...}, or aas a zero value 0 or an
+# omitted argument, to indicate that no action is to be performed.)
+#
+# When the action subroutine(s) are actually called, a context for the
+# rule and/or file (as appropriate) is given by setting named
+## NEW ??
+# variables to REFERENCES to the relevant data values. These can be
+# used to retrieve and set the data values. As a convention,
+# references to scalars are given by variables named start with "$P",
+# as in "$Pdest", while references to arrays start with "$PA", as in
+# "$PAint_cmd", and references to hashes with "$PH", as in "$PHsource".
+# After the action subroutine has finished, checks for data
+# consistency may be made.
+## ??? OLD
+# variables to the relevant data values. After the action subroutine
+# has finished, the database is updated with the values of these named
+# variables, with any necessary consistency checks. Thus the action
+# subroutines can act on sensibly named variables without needed to
+# know the database structure.
+#
+# The only routines that actually use the database structure and need
+# to be changed if that is changed are: (a) the routines rdb_one_rule
+# and rdb_one_file that implement the calling of the action subroutines,
+# (b) routines for creation of single rules and file items, and (c) to
+# a lesser extent, the routine for destroying a file item.
+#
+# Note that no routine is provided for destroying a rule. During a
+# run, a rule, with its source files, may become inaccessible or
+# unused. This happens dynamically, depending on the dependencies
+# caused by changes in the source file or by error conditions that
+# cause the computation of dependencies, particular of latex files, to
+# become wrong. In that situation the files certainly come and go in
+# the database, but subsidiary rules, with their content information
+# on their source files, need to be retained so that their use can be
+# reinstated later depending on dynamic changes in other files.
+#
+# However, there is a potential memory leak unless some pruning is
+# done in what is written to the fdb file. (Probably only accessible
+# rules and those for which source files exist. Other cases have no
+# relevant information that needs to be preserved between runs.)
+
+#
+#
+
+
+#************************************************************
+
+# First the top level routines for recursion and iteration
+
+#************************************************************
+
+sub rdb_recurse {
+ # Call: rdb_recurse( rule | [ rules],
+ # \&rule_act1, \&file_act1, \&file_act2,
+ # \&rule_act2 )
+ # The actions are pointers to subroutines, and may be null (0, or
+ # undefined) to indicate no action to be applied.
+ # Recursively acts on the given rules and all ancestors:
+ # foreach rule found:
+ # apply rule_act1
+ # loop through its files:
+ # apply file_act1
+ # act on its ancestor rule, if any
+ # apply file_act2
+ # apply rule_act2
+ # Guards against loops.
+ # Access to the rule and file data by local variables, only
+ # for getting and setting.
+
+ # This routine sets a context for anything recursive, with @heads,
+ # %visited and $depth being set as local variables.
+
+ local @heads = ();
+ my $rules = shift;
+
+ # Distinguish between single rule (a string) and a reference to an
+ # array of rules:
+ if ( ref $rules eq 'ARRAY' ) { @heads = @$rules; }
+ else { @heads = ( $rules ); }
+
+ # Keep a list of visited rules, used to block loops in recursion:
+ local %visited = ();
+ local $depth = 0;
+
+ foreach $rule ( @heads ) {
+ if ( rdb_is_active($rule) ) { rdb_recurse_rule( $rule, @_ ); }
+ }
+
+} #END rdb_recurse
+
+#************************************************************
+
+sub rdb_for_actives {
+ # Call: rdb_for_actives( \&rule_act1, \&file_act, \&rule_act2 )
+ # Loops through all rules and their source files, using the
+ # specified set of actions, which are pointers to subroutines.
+ # Sorts rules alphabetically.
+ # See rdb_for_some for details.
+# rdb_for_some( [ sort keys %rule_db ], @_);
+ rdb_for_some( [ sort &rdb_actives ], @_);
+} #END rdb_for_actives
+
+#************************************************************
+
+sub rdb_for_some {
+ # Call: rdb_for_some( rule | [ rules],
+ # \&rule_act1, \&file_act, \&rule_act2)
+ # Actions can be zero, and rules at tail of argument list can be
+ # omitted. E.g. rdb_for_some( rule, 0, \&file_act ).
+ # Anonymous subroutines can be used, e.g., rdb_for_some( rule, sub{...} ).
+ #
+ # Loops through rules and their source files, using the
+ # specified set of rules:
+ # foreach rule:
+ # apply rule_act1
+ # loop through its files:
+ # apply file_act
+ # apply rule_act2
+ #
+ # Rule data and file data are made available in local variables
+ # for access by the subroutines.
+
+ local @heads = ();
+ my $rules = shift;
+ # Distinguish between single rule (a string) and a reference to an
+ # array of rules:
+ if ( ref $rules eq 'ARRAY' ) { @heads = @$rules; }
+ else { @heads = ( $rules ); }
+
+ foreach $rule ( @heads ) {
+ # $rule is implicitly local
+ &rdb_one_rule( $rule, @_ );
+ }
+} #END rdb_for_some
+
+#************************************************************
+
+sub rdb_for_one_file {
+ my $rule = shift;
+ # Avoid name collisions with general recursion and iteraction routines:
+ local $file1 = shift;
+ local $action1 = shift;
+ rdb_for_some( $rule, sub{rdb_one_file($file1,$action1)} );
+} #END rdb_for_one_file
+
+
+#************************************************************
+
+# Routines for inner part of recursion and iterations
+
+#************************************************************
+
+sub rdb_recurse_rule {
+ # Call: rdb_recurse_rule($rule, \&rule_act1, \&file_act1, \&file_act2,
+ # \&rule_act2 )
+ # to do the work for one rule, recurisvely called from_rules for
+ # the sources of the rules.
+ # Assumes recursion context, i.e. that %visited, @heads, $depth.
+ # We are overriding actions:
+ my ($rule, $rule_act1, $new_file_act1, $new_file_act2, $rule_act2)
+ = @_;
+ if (! rdb_is_active($rule)) { return; }
+ # and must propagate the file actions:
+ local $file_act1 = $new_file_act1;
+ local $file_act2 = $new_file_act2;
+ # Prevent loops:
+ if ( (! $rule) || exists $visited{$rule} ) { return; }
+ $visited{$rule} = 1;
+ # Recursion depth
+ $depth++;
+ # We may need to repeat actions on dependent rules, without being
+ # blocked by the test on visited files. So save %visited:
+ # NOT CURRENTLY USED!! local %visited_at_rule_start = %visited;
+ # At end, the last value set for %visited wins.
+ rdb_one_rule( $rule, $rule_act1, \&rdb_recurse_file, $rule_act2 );
+ $depth--;
+ } #END rdb_recurse_rule
+
+#************************************************************
+
+sub rdb_recurse_file {
+ # Call: rdb_recurse_file to do the work for one file.
+ # This has no arguments, since it is used as an action subroutine,
+ # passed as a reference in calls in higher-level subroutine.
+ # Assumes contexts set for: Recursion, rule, and file
+ &$file_act1 if $file_act1;
+ rdb_recurse_rule( $$Pfrom_rule, $rule_act1, $file_act1, $file_act2,
+ $rule_act2 )
+ if $$Pfrom_rule;
+ &$file_act2 if $file_act2;
+} #END rdb_recurse_file
+
+#************************************************************
+
+sub rdb_do_files {
+ # Assumes rule context, including $PHsource.
+ # Applies an action to all the source files of the rule.
+ local $file_act = shift;
+ my @file_list = sort keys %$PHsource;
+ foreach my $file ( @file_list ){
+ rdb_one_file( $file, $file_act );
+ }
+} #END rdb_do_files
+
+#************************************************************
+
+# Routines for action on one rule and one file. These are the main
+# places (in addition to creation and destruction routines for rules
+# and files) where the database structure is accessed.
+
+#************************************************************
+
+sub rdb_one_rule {
+ # Call: rdb_one_rule( $rule, $rule_act1, $file_act, $rule_act2 )
+ # Sets context for rule and carries out the actions.
+#===== Accesses rule part of database structure =======
+
+ local ( $rule, $rule_act1, $file_act, $rule_act2 ) = @_;
+#?? &R1;
+ if ( (! $rule) || ! rdb_rule_exists($rule) ) { return; }
+
+ local ( $PArule_data, $PHsource, $PHdest, $PHsource_rules ) = @{$rule_db{$rule}};
+ local ($Pcmd_type, $Pext_cmd, $PAint_cmd, $Ptest_kind,
+ $Psource, $Pdest, $Pbase,
+ $Pout_of_date, $Pout_of_date_user, $Prun_time, $Pcheck_time,
+ $Pchanged,
+ $Plast_result, $Plast_message, $PA_extra_gen )
+ = Parray( $PArule_data );
+
+ &$rule_act1 if $rule_act1;
+ &rdb_do_files( $file_act ) if $file_act;
+ &$rule_act2 if $rule_act2;
+#?? &R2;
+} #END rdb_one_rule
+
+#************************************************************
+
+sub rdb_activate {
+ # Usage rdb_activate( rule_names )
+ # Turns on active flag for the rules
+ foreach ( @_ ) {
+ if ( rdb_rule_exists($_) ) { $actives{$_} = 1; }
+ }
+}
+
+#--------------------------------------------------
+
+sub rdb_deactivate {
+ # Usage rdb_deactivate( rule_names )
+ # Turns off active flag for the rules
+ foreach ( @_ ) { delete $actives{$_}; }
+}
+
+#--------------------------------------------------
+
+sub rdb_activate_request {
+ # Usage rdb_activate_request( rule_names )
+ # Turns on active flag for the rules.
+ # Adds rules to target_rules list
+ foreach ( @_ ) {
+ if ( rdb_rule_exists($_) ) { $actives{$_} = 1; $target_rules{$_} = 1; }
+ }
+}
+
+#--------------------------------------------------
+
+sub rdb_deactivate_derequest {
+ # Usage rdb_deactivate_derequest( rule_names )
+ # Turns off active flag for the rules
+ # Removes rules from target_rules list
+ foreach ( @_ ) { delete $actives{$_}; delete $target_rules{$_}; }
+}
+
+#--------------------------------------------------
+sub rdb_is_active {
+ # Usage rdb_is_active( rule_name )
+ if ( (exists $actives{$_[0]}) && rdb_rule_exists($_[0]) ) { return 1; }
+ else { return 0; }
+}
+
+#--------------------------------------------------
+
+sub rdb_actives {
+ # Returns array of active rules
+ return keys %actives;
+}
+
+#************************************************************
+
+sub rdb_one_file {
+ # Call: rdb_one_file($file, $file_act)
+ # Sets context for file and carries out the action.
+ # Assumes $rule context set.
+#===== Accesses file part of database structure =======
+ local ($file, $file_act) = @_;
+#?? &F1;
+ if ( (!$file) ||(!exists ${$PHsource}{$file}) ) { return; }
+ local $PAfile_data = ${$PHsource}{$file};
+ local ($Ptime, $Psize, $Pmd5, $Pfrom_rule, $Pcorrect_after_primary )
+ = Parray( $PAfile_data );
+ &$file_act() if $file_act;
+ if ( ! rdb_rule_exists( $$Pfrom_rule ) ) {
+ $$Pfrom_rule = '';
+ }
+#?? &F2;
+} #END rdb_one_file
+
+#************************************************************
+
+# Routines for creation of rules and file items, and for removing file
+# items.
+
+#************************************************************
+
+sub rdb_remove_rule {
+ # rdb_remove_rule( rule, ... )
+ foreach my $key (@_) {
+ delete $rule_db{$key};
+ delete $actives{$key};
+ }
+}
+
+#************************************************************
+
+sub rdb_create_rule {
+ # rdb_create_rule( rule, command_type, ext_cmd, int_cmd, test_kind,
+ # source, dest, base,
+ # needs_making, run_time, check_time, set_file_not_exists,
+ # ref_to_array_of_specs_of_extra_generated_files )
+ # int_cmd is either a string naming a perl subroutine or it is a
+ # reference to an array containing the subroutine name and its
+ # arguments.
+ # Makes rule. Update rule if it already exists.
+ # Omitted arguments: replaced by 0 or '' as needed.
+ # Rule is made active
+# ==== Sets rule data ====
+ my ( $rule, $cmd_type, $ext_cmd, $PAint_cmd, $test_kind,
+ $source, $dest, $base,
+ $needs_making, $run_time, $check_time, $set_file_not_exists, $extra_gen ) = @_;
+ my $active = 1;
+ my $changed = 0;
+
+ # Set defaults, and normalize parameters:
+ foreach ( $cmd_type, $ext_cmd, $PAint_cmd, $source, $dest, $base,
+ $set_file_not_exists ) {
+ if (! defined $_) { $_ = ''; }
+ }
+ if ( ($source =~ /\"/) || ($dest =~ /\"/) || ($base =~ /\"/) ) {
+ die "$My_name: Error. In rdb_create_rule to create rule\n",
+ " '$rule',\n",
+ " there is a double quote in one of source, destination or base parameters:\n",
+ " '$source'\n",
+ " '$dest'\n",
+ " '$base'\n",
+ " I cannot handle this. Cause is probably a latexmk bug. Please report it.\n";
+ }
+ foreach ( $needs_making, $run_time, $check_time, $test_kind ) {
+ if (! defined $_) { $_ = 0; }
+ }
+ if (!defined $test_kind) {
+ # Default to test on file change
+ $test_kind = 1;
+ }
+ if ( ref( $PAint_cmd ) eq '' ) {
+ # It is a single command. Convert to array reference:
+ $PAint_cmd = [ $PAint_cmd ];
+ }
+ else {
+ # COPY the referenced array:
+ $PAint_cmd = [ @$PAint_cmd ];
+ }
+ my $PA_extra_gen = [];
+ if ($extra_gen) {
+ @$PA_extra_gen = @$extra_gen;
+ }
+ $rule_db{$rule} =
+ [ [$cmd_type, $ext_cmd, $PAint_cmd, $test_kind,
+ $source, $dest, $base,
+ $needs_making, 0, $run_time, $check_time, $changed,
+ -1, '', $PA_extra_gen ],
+ {},
+ {},
+ {}
+ ];
+ if ($source) {
+ rdb_ensure_file( $rule, $source, undef, $set_file_not_exists );
+ }
+ rdb_one_rule( $rule, \&rdb_initialize_generated );
+ if ($active) { rdb_activate($rule); }
+ else { rdb_deactivate($rule); }
+} #END rdb_create_rule
+
+#************************************************************
+
+sub rdb_initialize_generated {
+# Assume rule context.
+# Initialize hash of generated files
+ %$PHdest = ();
+ if ($$Pdest) { rdb_add_generated($$Pdest); }
+ rdb_add_generated(@$PA_extra_gen);
+} #END rdb_initialize_generated
+
+#************************************************************
+
+sub rdb_add_generated {
+# Assume rule context.
+# Add arguments to hash of generated files, and to global cache
+ foreach (@_) {
+ $$PHdest{$_} = 1;
+ $from_rules{$_} = $rule;
+ }
+} #END rdb_add_generated
+
+#************************************************************
+
+sub rdb_remove_generated {
+# Assume rule context.
+# Remove arguments from hash of generated files
+ foreach (@_) { delete $$PHdest{$_}; }
+} #END rdb_remove_generated
+
+#************************************************************
+
+sub rdb_ensure_file {
+ # rdb_ensure_file( rule, file[, fromrule[, set_not_exists]] )
+ # Ensures the source file item exists in the given rule.
+ # Then if the fromrule is specified, set it for the file item.
+ # If the item is created, then:
+ # (a) by default initialize it to current file state.
+ # (b) but if the fourth argument, set_not_exists, is true,
+ # initialize the item as if the file does not exist.
+ # This case is typically used when the log file for a run
+ # of latex/pdflatex claims that the file was non-existent
+ # at the beginning of a run.
+#============ rule and file data set here ======================================
+ my $rule = shift;
+ local ( $new_file, $new_from_rule, $set_not_exists ) = @_;
+ if ( ! rdb_rule_exists( $rule ) ) {
+ die_trace( "$My_name: BUG in call to rdb_ensure_file: non-existent rule '$rule'" );
+ }
+ if ( ! defined $new_file ) {
+ die_trace( "$My_name: BUG in call to rdb_ensure_file: undefined file for '$rule'" );
+ }
+ if ( $new_file =~ /\"/ ) {
+ warn "$My_name: in rdb_ensure_file for rule '$rule', there is a double quote in\n",
+ " the filename: '$new_file'.\n",
+ " I cannot handle this, will ignore this file.\n";
+ return;
+ }
+ if ( ! defined $set_not_exists ) { $set_not_exists = 0; }
+ rdb_one_rule( $rule,
+ sub{
+ if (! exists ${$PHsource}{$new_file} ) {
+ if ( $set_not_exists ) {
+ ${$PHsource}{$new_file} = [@nofile, '', 0];
+ }
+ else {
+ ${$PHsource}{$new_file}
+ = [fdb_get($new_file, $$Prun_time), '', 0];
+ }
+ }
+ }
+ );
+ if (defined $new_from_rule ) {
+ rdb_for_one_file( $rule, $new_file, sub{ $$Pfrom_rule = $new_from_rule; });
+ }
+} #END rdb_ensure_file
+
+#************************************************************
+
+sub rdb_remove_files {
+ # rdb_remove_file( rule, file, ... )
+ # Removes file(s) for the rule.
+ my $rule = shift;
+ if (!$rule) { return; }
+ local @files = @_;
+ rdb_one_rule( $rule,
+ sub{ foreach (@files) { delete ${$PHsource}{$_}; } }
+ );
+} #END rdb_remove_files
+
+#************************************************************
+
+sub rdb_list_source {
+ # rdb_list_source( rule )
+ # Return array of source files for rule.
+ my $rule = shift;
+ my @files = ();
+ rdb_one_rule( $rule,
+ sub{ @files = keys %$PHsource; }
+ );
+ return @files;
+} #END rdb_list_source
+
+#************************************************************
+
+sub rdb_set_source {
+ # rdb_set_source( rule, file, ... )
+ my $rule = shift;
+ if (!$rule) { return; }
+ my %files = ();
+ foreach (@_) {
+# if ( /\"/ ) {next; }
+ rdb_ensure_file( $rule, $_ );
+ $files{$_} = 1;
+ }
+ foreach ( rdb_list_source($rule) ) {
+ if ( ! exists $files{$_} ) { rdb_remove_files( $rule, $_ ); }
+ }
+ return;
+} #END rdb_list_source
+
+#************************************************************
+
+sub rdb_change_dest {
+ # Assumes rule context.
+ # Usage change_dest( new_dest [, flag] )
+ # Changes destination for this rule. Fixes from_rule links.
+ # If flag set, make the new_dest a source file in any rule
+ # for which the old destination is already set.
+ # No action if there's no change of destination.
+ local ($new_dest, $flag) = @_;
+ local $old_dest = $$Pdest;
+ if ($old_dest eq $new_dest) { return; }
+# if ( $new_dest =~ /\"/ ) { return; }
+ rdb_remove_generated( $old_dest );
+ rdb_add_generated( $new_dest );
+ if ($flag) {
+ print "rdb_change_dest: fixing dependencies\n";
+ rdb_for_actives( sub{ if ( rdb_file_exists( $rule, $old_dest ) ) {
+ rdb_ensure_file( $rule, $new_dest );
+ rdb_remove_files( $rule, $old_dest );
+ }
+ }
+ );
+ }
+ $$Pdest = $new_dest;
+ # ??? Do I need to fix from_rule setting?
+ #&rdb_make_links;
+ return;
+} #END rdb_change_dest
+
+#************************************************************
+
+sub rdb_rule_exists {
+ # Call rdb_rule_exists($rule): Returns whether rule exists.
+ my $rule = shift;
+ if (! $rule ) { return 0; }
+ return exists $rule_db{$rule};
+} #END rdb_rule_exists
+
+#************************************************************
+
+sub rdb_file_exists {
+ # Call rdb_file_exists($rule, $file):
+ # Returns whether source file item in rule exists.
+ local ( $rule, $file ) = @_;
+ local $exists = 0;
+ rdb_one_rule( $rule,
+ sub{ $exists = exists( ${$PHsource}{$file} ) ? 1:0; }
+ );
+ return $exists;
+} #END rdb_file_exists
+
+#************************************************************
+
+sub rdb_update_gen_files {
+ # Assumes rule context. Update source files of rule to current state.
+ rdb_do_files(
+ sub{
+ if ( exists $generated_exts_all{ ext_no_period($file) }
+ || exists $$PHdest{$file}
+ ) {
+ &rdb_update1;
+ }
+ }
+ );
+} #END rdb_update_gen_files
+
+#************************************************************
+
+sub rdb_update_files {
+ # Call: rdb_update_files
+ # Assumes rule context. Update source files of rule to current state.
+ rdb_do_files( \&rdb_update1 );
+}
+
+#************************************************************
+
+sub rdb_update1 {
+ # Call: rdb_update1.
+ # Assumes file context. Updates file data to correspond to
+ # current file state on disk
+ ($$Ptime, $$Psize, $$Pmd5) = fdb_get($file);
+}
+
+#************************************************************
+
+sub rdb_set_file1 {
+ # Call: fdb_file1(rule, file, new_time, new_size, new_md5)
+ # Sets file time, size and md5.
+ my $rule = shift;
+ my $file = shift;
+ local @new_file_data = @_;
+ rdb_for_one_file( $rule, $file, sub{ ($$Ptime,$$Psize,$$Pmd5)=@new_file_data; } );
+}
+
+#************************************************************
+
+sub rdb_dummy_file {
+ # Returns file data for non-existent file
+# ==== Uses rule_db structure ====
+ return (0, -1, 0, '');
+}
+
+#************************************************************
+#************************************************************
+
+# Predefined subroutines for custom dependency
+
+sub cus_dep_delete_dest {
+ # This subroutine is used for situations like epstopdf.sty, when
+ # the destination (target) of the custom dependency invoking
+ # this subroutine will be made by the primary run provided the
+ # file (destination of the custom dependency, source of the
+ # primary run) doesn't exist.
+ # It is assumed that the resulting file will be read by the
+ # primary run.
+
+ # Remove the destination file, to indicate it needs to be remade:
+ unlink_or_move( $$Pdest );
+ # Arrange that the non-existent destination file is not treated as
+ # an error. The variable changed here is a bit misnamed.
+ $$Pchanged = 1;
+ # Ensure a primary run is done
+ &cus_dep_require_primary_run;
+ # Return success:
+ return 0;
+}
+
+#************************************************************
+
+sub cus_dep_require_primary_run {
+ # This subroutine is used for situations like epstopdf.sty, when
+ # the destination (target) of the custom dependency invoking
+ # this subroutine will be made by the primary run provided the
+ # file (destination of the custom dependency, source of the
+ # primary run) doesn't exist.
+ # It is assumed that the resulting file will be read by the
+ # primary run.
+
+ local $cus_dep_target = $$Pdest;
+ # Loop over all rules and source files:
+ rdb_for_actives( 0,
+ sub { if ($file eq $cus_dep_target) {
+ $$Pout_of_date = 1;
+ $$Pcorrect_after_primary = 1;
+ }
+ }
+ );
+ # Return success:
+ return 0;
+}
+
+
+#************************************************************
+#************************************************************
+#************************************************************
+#
+# UTILITIES:
+#
+
+#************************************************************
+# Miscellaneous
+
+sub show_array {
+# For use in diagnostics and debugging.
+# On stderr, print line with $_[0] = label.
+# Then print rest of @_, one item per line preceeded by some space
+ warn "$_[0]\n";
+ shift;
+ if ($#_ >= 0) { foreach (@_){ warn " $_\n";} }
+ else { warn " NONE\n"; }
+}
+
+
+#************************************************************
+
+sub array_to_hash {
+ # Call: array_to_hash( items )
+ # Returns: hash mapping items to 1
+ my %hash = ();
+ foreach (@_) {$hash{$_} = 1; }
+ return %hash;
+}
+
+#************************************************************
+
+sub Parray {
+ # Call: Parray( \@A )
+ # Returns array of references to the elements of @A
+ # But if an element of @A is already a reference, the
+ # reference will be returned in the output array, not a
+ # reference to the reference.
+ my $PA = shift;
+ my @P = (undef) x (1+$#$PA);
+ foreach my $i (0..$#$PA) {
+ $P[$i] = (ref $$PA[$i]) ? ($$PA[$i]) : (\$$PA[$i]);
+ }
+ return @P;
+}
+
+#************************************************************
+
+sub glob_list1 {
+ # Glob a collection of filenames.
+ # But no sorting or elimination of duplicates
+ # Usage: e.g., @globbed = glob_list1(string, ...);
+ # Since perl's glob appears to use space as separator, I'll do a special check
+ # for existence of non-globbed file (assumed to be tex like)
+
+ my @globbed = ();
+ foreach my $file_spec (@_) {
+ # Problem, when the PATTERN contains spaces, the space(s) are
+ # treated as pattern separaters.
+ # Solution: I now the glob from use File::Glob.
+ # The following hack avoids issues with glob in the case that a file exists
+ # with the specified name (possibly with extension .tex):
+ if ( -e $file_spec || -e "$file_spec.tex" ) {
+ # Non-globbed file exists, return the file_spec.
+ # Return $file_spec only because this is not a file-finding subroutine, but
+ # only a globber
+ push @globbed, $file_spec;
+ }
+ else {
+ push @globbed, my_glob( "$file_spec" );
+ }
+ }
+ return @globbed;
+} #END glob_list1
+
+#************************************************************
+# Miscellaneous
+
+sub prefix {
+ #Usage: prefix( string, prefix );
+ #Return string with prefix inserted at the front of each line
+ my @line = split( /\n/, $_[0] );
+ my $prefix = $_[1];
+ for (my $i = 0; $i <= $#line; $i++ ) {
+ $line[$i] = $prefix.$line[$i]."\n";
+ }
+ return join( "", @line );
+} #END prefix
+
+
+#===============================
+
+sub parse_quotes {
+ # Split string into words.
+ # Words are delimited by space, except that strings
+ # quoted all stay inside a word. E.g.,
+ # 'asdf B" df "d "jkl"'
+ # is split to ( 'asdf', 'B df d', 'jkl').
+ # An array is returned.
+ my @results = ();
+ my $item = '';
+ local $_ = shift;
+ pos($_) = 0;
+ ITEM:
+ while() {
+ /\G\s*/gc;
+ if ( /\G$/ ) {
+ last ITEM;
+ }
+ # Now pos (and \G) is at start of item:
+ PART:
+ while () {
+ if (/\G([^\s\"]*)/gc) {
+ $item .= $1;
+ }
+ if ( /\G\"([^\"]*)\"/gc ) {
+ # Match balanced quotes
+ $item .= $1;
+ next PART;
+ }
+ elsif ( /\G\"(.*)$/gc ) {
+ # Match unbalanced quote
+ $item .= $1;
+ warn "====Non-matching quotes in\n '$_'\n";
+ }
+ push @results, $item;
+ $item = '';
+ last PART;
+ }
+ }
+ return @results;
+} #END parse_quotes
+
+#************************************************************
+#************************************************************
+# File handling utilities:
+
+
+#************************************************************
+
+sub get_latest_mtime
+# - arguments: each is a filename.
+# - returns most recent modify time.
+{
+ my $return_mtime = 0;
+ foreach my $include (@_)
+ {
+ my $include_mtime = &get_mtime($include);
+ # The file $include may not exist. If so ignore it, otherwise
+ # we'll get an undefined variable warning.
+ if ( ($include_mtime) && ($include_mtime > $return_mtime) )
+ {
+ $return_mtime = $include_mtime;
+ }
+ }
+ return $return_mtime;
+}
+
+#************************************************************
+
+sub get_mtime_raw
+{
+ my $mtime = (stat($_[0]))[9];
+ return $mtime;
+}
+
+#************************************************************
+
+sub get_mtime {
+ return get_mtime0($_[0]);
+}
+
+#************************************************************
+
+sub get_mtime0 {
+ # Return time of file named in argument
+ # If file does not exist, return 0;
+ if ( -e $_[0] ) {
+ return get_mtime_raw($_[0]);
+ }
+ else {
+ return 0;
+ }
+}
+
+#************************************************************
+
+sub get_size {
+ # Return time of file named in argument
+ # If file does not exist, return 0;
+ if ( -e $_[0] ) {
+ return get_size_raw($_[0]);
+ }
+ else {
+ return 0;
+ }
+}
+
+#************************************************************
+
+sub get_size_raw
+{
+ my $size = (stat($_[0]))[7];
+ return $size;
+}
+
+#************************************************************
+
+sub get_time_size {
+ # Return time and size of file named in argument
+ # If file does not exist, return (0,-1);
+ if ( -e $_[0] ) {
+ return get_time_size_raw($_[0]);
+ }
+ else {
+ return (0,-1);
+ }
+}
+
+#************************************************************
+
+sub get_time_size_raw
+{
+ my $mtime = (stat($_[0]))[9];
+ my $size = (stat($_[0]))[7];
+ return ($mtime, $size);
+}
+
+#************************************************************
+
+sub processing_time
+{ my ($user, $system, $cuser, $csystem) = times();
+ return $user + $system + $cuser + $csystem;
+}
+
+#************************************************************
+
+sub get_checksum_md5 {
+ my $source = shift;
+ my $input = new FileHandle;
+ my $md5 = Digest::MD5->new;
+ my $ignore_pattern = undef;
+
+#&traceback;
+#warn "======= GETTING MD5: $source\n";
+ if ( -d $source ) {
+ # We won't use checksum for directory
+ return 0;
+ }
+ else {
+ open( $input, '<:bytes', $source )
+ or return 0;
+ my ($base, $path, $ext) = fileparseA( $source );
+ $ext =~ s/^\.//;
+ if ( exists $hash_calc_ignore_pattern{$ext} ) {
+ $ignore_pattern = $hash_calc_ignore_pattern{$ext};
+ }
+ }
+ if ( defined $ignore_pattern ) {
+ while (<$input>) {
+ if ( ! /$ignore_pattern/ ){
+ $md5->add($_);
+ }
+ }
+ }
+ else {
+ $md5->addfile($input);
+ }
+ close $input;
+ return $md5->hexdigest();
+}
+
+#************************************************************
+#************************************************************
+
+sub create_empty_file {
+ my $name = shift;
+ my $h = new FileHandle ">$name"
+ or return 1;
+ close ($h);
+ return 0;
+}
+
+#************************************************************
+#************************************************************
+
+sub find_file1 {
+#?? Need to use kpsewhich, if possible
+
+ # Usage: find_file1(name, ref_to_array_search_path)
+ # Modified find_file, which doesn't die.
+ # Given filename and path, return array of:
+ # full name
+ # retcode
+ # On success: full_name = full name with path, retcode = 0
+ # On failure: full_name = given name, retcode = 1
+
+ my $name = $_[0];
+ # Make local copy of path, since we may rewrite it!
+ my @path = ();
+ if ($_[1]) {
+ @path = @{$_[1]};
+ }
+ if ( $name =~ /^\// ) {
+ # Absolute path (if under UNIX)
+ # This needs fixing, in general
+ if (-e $name) { return( $name, 0 );}
+ else { return( $name, 1 );}
+ }
+ foreach my $dir ( @path ) {
+ #??print "-------------dir='$dir', ";
+ # Make $dir concatenatable, and empty for current dir:
+ if ( $dir eq '.' ) {
+ $dir = '';
+ }
+ elsif ( $dir =~ /[\/\\:]$/ ) {
+ #OK if dir ends in / or \ or :
+ }
+ elsif ( $dir ne '' ) {
+ #Append directory separator only to non-empty dir
+ $dir = "$dir/";
+ }
+ #?? print " newdir='$dir'\n";
+ if (-e "$dir$name") {
+ return("$dir$name", 0);
+ }
+ }
+ my @kpse_result = kpsewhich( $name );
+ if ($#kpse_result > -1) {
+ return( $kpse_result[0], 0);
+ }
+ return("$name" , 1);
+} #END find_file1
+
+#************************************************************
+
+sub find_file_list1 {
+ # Modified version of find_file_list that doesn't die.
+ # Given output and input arrays of filenames, a file suffix, and a path,
+ # fill the output array with full filenames
+ # Return array of not-found files.
+ # Usage: find_file_list1( ref_to_output_file_array,
+ # ref_to_input_file_array,
+ # suffix,
+ # ref_to_array_search_path
+ # )
+ # SPECIAL TREATMENT TO .bib extension, because of behavior of bibtex
+ # OTHER SPECIAL TREATMENT IF EXTENSION IS GIVEN.
+
+ my $ref_output = $_[0];
+ my $ref_input = $_[1];
+ my $suffix = $_[2];
+ my $ref_search = $_[3];
+ my @not_found = ();
+
+#?? show_array( "=====find_file_list1. Suffix: '$suffix'\n Source:", @$ref_input );
+#?? show_array( " Bibinputs:", @$ref_search );
+
+ my @return_list = (); # Generate list in local array, since input
+ # and output arrays may be same
+ my $retcode = 0;
+ foreach my $file1 (@$ref_input) {
+ my $file = $file1;
+ if ($suffix eq '.bib') { $file =~ s/\.bib$//; }
+ my ($tmp_file, $find_retcode) = &find_file1( "$file$suffix", $ref_search );
+ if ($tmp_file) {
+ push @return_list, $tmp_file;
+ }
+ if ( $find_retcode != 0 ) {
+ push @not_found, $file.$suffix;
+ }
+ }
+ @$ref_output = @return_list;
+#?? show_array( " Output", @$ref_output );
+#?? foreach (@$ref_output) { if ( /\/\// ) { print " ====== double slash in '$_'\n"; } }
+ return @not_found;
+} #END find_file_list1
+
+#************************************************************
+
+sub unlink_or_move {
+ if ( $del_dir eq '' ) {
+ foreach (@_) {
+ if (!-e) {next;}
+ if (-d) {
+ if (!rmdir) {
+ warn "$My_name: Cannot remove directory '$_'\n";
+ }
+ }
+ else {
+ if (!unlink) {
+ warn "$My_name: Cannot remove file '$_'\n";
+ }
+ }
+ }
+ }
+ else {
+ foreach (@_) {
+ if (-e $_ && ! move $_, "$del_dir/$_" ) {
+ warn "$My_name: Cannot move '$_' to '$del_dir/$_'\n";
+ }
+ }
+ }
+}
+
+#************************************************************
+
+sub kpsewhich {
+# Usage: kpsewhich( filespec, ...)
+# Returns array of files with paths as found by kpsewhich
+# kpsewhich( 'try.sty', 'jcc.bib' );
+# With standard use of kpsewhich (i.e., without -all option), the array
+# has either 0 or 1 element.
+# Can also do, e.g.,
+# kpsewhich( '-format=bib', 'trial.bib', 'file with spaces');
+ my $cmd = $kpsewhich;
+ my @args = @_;
+ if ( ($cmd eq '') || ( $cmd =~ /^NONE($| )/ ) ) {
+ # Kpsewhich not set up.
+ warn "$My_name: Kpsewhich command needed but not set up\n";
+ return ();
+ }
+ foreach (@args) {
+ if ( ! /^-/ ) {
+ $_ = "\"$_\"";
+ }
+ }
+ $cmd =~ s/%[RBTDO]//g;
+ $cmd =~ s/%S/@args/g;
+ my @found = ();
+ local $fh;
+ if ( $kpsewhich_show || $diagnostics ) {
+ print "$My_name.kpsewhich: Running '$cmd'...\n";
+ }
+ open $fh, "$cmd|"
+ or die "Cannot open pipe for \"$cmd\"\n";
+ while ( <$fh> ) {
+ s/[\r\n]*$//;
+ push @found, $_;
+ }
+ close $fh;
+ if ( $kpsewhich_show || $diagnostics ) {
+ show_array( "$My_name.kpsewhich: '$cmd' ==>", @found );
+ }
+ return @found;
+}
+
+####################################################
+
+sub add_cus_dep {
+ # Usage: add_cus_dep( from_ext, to_ext, flag, sub_name )
+ # Add cus_dep after removing old versions
+ my ($from_ext, $to_ext, $must, $sub_name) = @_;
+ remove_cus_dep( $from_ext, $to_ext );
+ push @cus_dep_list, "$from_ext $to_ext $must $sub_name";
+}
+
+####################################################
+
+sub remove_cus_dep {
+ # Usage: remove_cus_dep( from_ext, to_ext )
+ my ($from_ext, $to_ext) = @_;
+ my $i = 0;
+ while ($i <= $#cus_dep_list) {
+ # Use \Q and \E round directory name in regex to avoid interpretation
+ # of metacharacters in directory name:
+ if ( $cus_dep_list[$i] =~ /^\Q$from_ext $to_ext \E/ ) {
+ splice @cus_dep_list, $i, 1;
+ }
+ else {
+ $i++;
+ }
+ }
+}
+
+####################################################
+
+sub show_cus_dep {
+ show_array( "Custom dependency list:", @cus_dep_list );
+}
+
+####################################################
+
+sub add_aux_hook {
+ # Usage: add_aux_hook( sub_name )
+ # Add the name subroutine to the array of hooks for
+ # processing lines of aux files.
+ # The argument is either a string naming the subroutine, e.g.
+ # add_aux_hook( 'subname' );
+ # or a Perl reference to the subroutine, e.g.,
+ # add_aux_hook( \&subname );
+ # It is also possible to use an anonymous subroutine, e.g.,
+ # add_aux_hook( sub{ code of subroutine... } );
+ my ($sub_name) = @_;
+ push @aux_hooks, $sub_name;
+}
+
+####################################################
+
+sub set_input_ext {
+ # Usage: set_input_ext( rule, ext, ... )
+ # Set list of extension(s) (specified without a leading period)
+ # for the given rule ('latex', 'pdflatex', etc).
+ # These extensions are used when an input
+ # file without an extension is found by (pdf)latex, as in
+ # \input{file} or \includegraphics{figure}. When latexmk searches
+ # custom dependencies to make the missing file, it will assume that
+ # the file has one of the specified extensions.
+ my $rule = shift;
+ $input_extensions{$rule} = {};
+ my $Prule = $input_extensions{$rule};
+ foreach (@_) { $$Prule{$_} = 1; }
+}
+
+####################################################
+
+sub show_input_ext {
+ # Usage: show_input_ext( rule )
+ my $rule = shift;
+ show_array ("Input extensions for rule '$rule': ",
+ keys %{$input_extensions{$rule}} );
+}
+
+####################################################
+
+sub find_dirs1 {
+ # Same as find_dirs, but argument is single string with directories
+ # separated by $search_path_separator
+ find_dirs( &split_search_path( $search_path_separator, ".", $_[0] ) );
+}
+
+
+#************************************************************
+
+sub find_dirs {
+# @_ is list of directories
+# return: same list of directories, except that for each directory
+# name ending in //, a list of all subdirectories (recursive)
+# is added to the list.
+# Non-existent directories and non-directories are removed from the list
+# Trailing "/"s and "\"s are removed
+ local @result = ();
+ my $find_action
+ = sub
+ { ## Subroutine for use in File::find
+ ## Check to see if we have a directory
+ if (-d) { push @result, $File::Find::name; }
+ };
+ foreach my $directory (@_) {
+ my $recurse = ( $directory =~ m[//$] );
+ # Remove all trailing /s, since directory name with trailing /
+ # is not always allowed:
+ $directory =~ s[/+$][];
+ # Similarly for MSWin reverse slash
+ $directory =~ s[\\+$][];
+ if ( ! -e $directory ){
+ next;
+ }
+ elsif ( $recurse ){
+ # Recursively search directory
+ find( $find_action, $directory );
+ }
+ else {
+ push @result, $directory;
+ }
+ }
+ return @result;
+}
+
+#************************************************************
+
+sub uniq
+# Read arguments, delete neighboring items that are identical,
+# return array of results
+{
+ my @sort = ();
+ my ($current, $prev);
+ my $first = 1;
+ while (@_)
+ {
+ $current = shift;
+ if ($first || ($current ne $prev) )
+ {
+ push @sort, $current;
+ $prev = $current;
+ $first = 0;
+ }
+ }
+ return @sort;
+}
+
+#==================================================
+
+sub uniq1 {
+ # Usage: uniq1( strings )
+ # Returns array of strings with duplicates later in list than
+ # first occurence deleted. Otherwise preserves order.
+
+ my @strings = ();
+ my %string_hash = ();
+
+ foreach my $string (@_) {
+ if (!exists( $string_hash{$string} )) {
+ $string_hash{$string} = 1;
+ push @strings, $string;
+ }
+ }
+ return @strings;
+}
+
+#************************************************************
+
+sub uniqs {
+ # Usage: uniq2( strings )
+ # Returns array of strings sorted and with duplicates deleted
+ return uniq( sort @_ );
+}
+
+#************************************************************
+
+sub ext {
+ # Return extension of filename. Extension includes the period
+ my $file_name = $_[0];
+ my ($base_name, $path, $ext) = fileparseA( $file_name );
+ return $ext;
+ }
+
+#************************************************************
+
+sub ext_no_period {
+ # Return extension of filename. Extension excludes the period
+ my $file_name = $_[0];
+ my ($base_name, $path, $ext) = fileparseA( $file_name );
+ $ext =~ s/^\.//;
+ return $ext;
+ }
+
+#************************************************************
+
+sub fileparseA {
+ # Like fileparse but replace $path for current dir ('./' or '.\') by ''
+ # Also default second argument to get normal extension.
+ my $given = $_[0];
+ my $pattern = '\.[^\.]*';
+ if ($#_ > 0 ) { $pattern = $_[1]; }
+ my ($base_name, $path, $ext) = fileparse( $given, $pattern );
+ if ( ($path eq './') || ($path eq '.\\') ) {
+ $path = '';
+ }
+ return ($base_name, $path, $ext);
+}
+
+#************************************************************
+
+sub fileparseB {
+ # Like fileparse but with default second argument for normal extension
+ my $given = $_[0];
+ my $pattern = '\.[^\.]*';
+ if ($#_ > 0 ) { $pattern = $_[1]; }
+ my ($base_name, $path, $ext) = fileparse( $given, $pattern );
+ return ($base_name, $path, $ext);
+}
+
+#************************************************************
+
+sub split_search_path
+{
+# Usage: &split_search_path( separator, default, string )
+# Splits string by separator and returns array of the elements
+# Allow empty last component.
+# Replace empty terms by the default.
+ my $separator = $_[0];
+ my $default = $_[1];
+ my $search_path = $_[2];
+ my @list = split( /$separator/, $search_path);
+ if ( $search_path =~ /$separator$/ ) {
+ # If search path ends in a blank item, the split subroutine
+ # won't have picked it up.
+ # So add it to the list by hand:
+ push @list, "";
+ }
+ # Replace each blank argument (default) by current directory:
+ for ($i = 0; $i <= $#list ; $i++ ) {
+ if ($list[$i] eq "") {$list[$i] = $default;}
+ }
+ return @list;
+}
+
+#################################
+
+sub get_filetime_offset {
+ # Usage: get_filetime_offset( prefix, [suffix] )
+ # Measures offset between filetime in a directory and system time
+ # Makes a temporary file of a unique name, and deletes in.
+ # Filename is of form concatenation of prefix, an integer, suffix.
+ # Prefix is normally of form dir/ or dir/tmp.
+ # Default default suffix ".tmp".
+ my $prefix = $_[0];
+ my $suffix = $_[1] || '.tmp';
+ my $tmp_file_count = 0;
+ while (1==1) {
+ # Find a new temporary file, and make it.
+ $tmp_file_count++;
+ my $tmp_file = "${prefix}${tmp_file_count}${suffix}";
+ if ( ! -e $tmp_file ) {
+ open( TMP, ">$tmp_file" )
+ or die "$My_name.get_filetime_offset: In measuring filetime offset, couldn't write to\n",
+ " temporary file '$tmp_file'\n";
+ my $time = time();
+ close(TMP);
+ my $offset = get_mtime($tmp_file) - $time;
+ unlink $tmp_file;
+ return $offset;
+ }
+ }
+ die "$My_name.get_filetime_offset: BUG TO ARRIVE HERE\n";
+}
+
+#################################
+
+sub tempfile1 {
+ # Makes a temporary file of a unique name. I could use file::temp,
+ # but it is not present in all versions of perl.
+ # Filename is of form $tmpdir/$_[0]nnn$suffix, where nnn is an integer
+ my $tmp_file_count = 0;
+ my $prefix = $_[0];
+ my $suffix = $_[1];
+ while (1==1) {
+ # Find a new temporary file, and make it.
+ $tmp_file_count++;
+ my $tmp_file = "${tmpdir}/${prefix}${tmp_file_count}${suffix}";
+ if ( ! -e $tmp_file ) {
+ open( TMP, ">$tmp_file" )
+ or next;
+ close(TMP);
+ return $tmp_file;
+ }
+ }
+ die "$My_name.tempfile1: BUG TO ARRIVE HERE\n";
+}
+
+#################################
+
+#************************************************************
+#************************************************************
+# Process/subprocess routines
+
+sub Run_msg {
+ # Same as Run, but give message about my running
+ warn_running( "Running '$_[0]'" );
+ return Run($_[0]);
+} #END Run_msg
+
+#==================
+
+sub Run {
+ # This is wrapper around Run_no_time to capture timing information
+ my $time1 = processing_time();
+ my ($pid, $return) = Run_no_time($_[0]);
+ my $time = processing_time() - $time1;
+ push @timings, "'$_[0]': time = $time\n";
+ return ($pid, $return);
+} #END Run_msg
+
+#==================
+
+sub Run_no_time {
+# Usage: Run_no_time ("command string");
+# or Run_no_time ("one-or-more keywords command string");
+# Possible keywords: internal, NONE, start, nostart.
+#
+# A command string not started by keywords just gives a call to system with
+# the specified string, I return after that has finished executing.
+# Exceptions to this behavior are triggered by keywords.
+# The general form of the string is
+# Zero or more occurences of the start keyword,
+# followed by at most one of the other key words (internal, nostart, NONE),
+# followed by (a) a command string to be executed by the systerm
+# or (b) if the command string is specified to be internal, then
+# it is of the form
+#
+# routine arguments
+#
+# which implies invocation of the named Perl subroutine
+# with the given arguments, which are obtained by splitting
+# the string into words, delimited by spaces, but with
+# allowance for double quotes.
+#
+# The meaning of the keywords is:
+#
+# start: The command line is to be running detached, as appropriate for
+# a previewer. The method is appropriate for the operating system
+# (and the keyword is inspired by the action of the start command
+# that implements in under MSWin).
+# HOWEVER: the start keyword is countermanded by the nostart,
+# internal, and NONE keywords. This allows rules that do
+# previewing to insert a start keyword to create a presumption
+# of detached running unless otherwise.
+# nostart: Countermands a previous start keyword; the following command
+# string is then to be obeyed by the system, and any necessary
+# detaching (as of a previewer) is done by the executed command(s).
+# internal: The following command string, of the form 'routine arguments'
+# specifies a call to the named Perl subroutine.
+# NONE: This does not run anything, but causes an error message to be
+# printed. This is provided to allow program names defined in the
+# configuration to flag themselves as unimplemented.
+# Note that if the word "start" is duplicated at the beginning, that is
+# equivalent to a single "start".
+#
+# Return value is a list (pid, exitcode):
+# If a process is spawned sucessfully, and I know the PID,
+# return (pid, 0),
+# else if process is spawned sucessfully, but I do not know the PID,
+# return (0, 0),
+# else if process is run,
+# return (0, exitcode of process)
+# else if I fail to run the requested process
+# return (0, suitable return code)
+# where return code is 1 if cmdline is null or begins with "NONE" (for
+# an unimplemented command)
+# or the return value of the Perl subroutine.
+ my $cmd_line = $_[0];
+ if ( $cmd_line eq '' ) {
+ traceback( "$My_name: Bug OR configuration error\n".
+ " In run of '$rule', attempt to run a null program" );
+ return (0, 1);
+ }
+ # Deal with latexmk-defined pseudocommands 'start' and 'NONE'
+ # at front of command line:
+ my $detach = 0;
+ while ( $cmd_line =~ s/^start +// ) {
+ # But first remove extra starts (which may have been inserted
+ # to force a command to be run detached, when the command
+ # already contained a "start").
+ $detach = 1;
+ }
+ if ( $cmd_line =~ s/^nostart +// ) {
+ $detach = 0;
+ }
+ if ( $cmd_line =~ /^internal\s+([a-zA-Z_]\w*)\s+(.*)$/ ) {
+ my $routine = $1;
+ my @args = parse_quotes( $2 );
+ warn "$My_name: calling $routine( $2 )\n"
+ if (! $silent);
+ return ( 0, &$routine( @args ) );
+ }
+ elsif ( $cmd_line =~ /^internal\s+([a-zA-Z_]\w*)\s*$/ ) {
+ my $routine = $1;
+ warn "$My_name: calling $routine()\n"
+ if (! $silent);
+ return ( 0, &$routine() );
+ }
+ elsif ( $cmd_line =~ /^NONE/ ) {
+ warn "$My_name: ",
+ "Program not implemented for this version. Command line:\n";
+ warn " '$cmd_line'\n";
+ return (0, 1);
+ }
+ elsif ($detach) {
+ # Run detached. How to do this depends on the OS
+ return &Run_Detached( $cmd_line );
+ }
+ else {
+ # The command is given to system as a single argument, to force shell
+ # metacharacters to be interpreted:
+ return( 0, system( $cmd_line ) );
+ }
+} #END Run
+
+#************************************************************
+
+sub Run_Detached {
+# Usage: Run_Detached ("program arguments ");
+# Runs program detached. Returns 0 on success, 1 on failure.
+# Under UNIX use a trick to avoid the program being killed when the
+# parent process, i.e., me, gets a ctrl/C, which is undesirable for pvc
+# mode. (The simplest method, system("program arguments &"), makes the
+# child process respond to the ctrl/C.)
+# Return value is a list (pid, exitcode):
+# If process is spawned sucessfully, and I know the PID,
+# return (pid, 0),
+# else if process is spawned sucessfully, but I do not know the PID,
+# return (0, 0),
+# else if I fail to spawn a process
+# return (0, 1)
+
+ my $cmd_line = $_[0];
+
+## warn "Running '$cmd_line' detached...\n";
+ if ( $cmd_line =~ /^NONE / ) {
+ warn "$My_name: ",
+ "Program not implemented for this version. Command line:\n";
+ warn " '$cmd_line'\n";
+ return (0, 1);
+ }
+
+ if ( "$^O" eq "MSWin32" ){
+ # Win95, WinNT, etc: Use MS's start command:
+ # Need extra double quotes to deal with quoted filenames:
+ # MSWin start takes first quoted argument to be a Window title.
+ return( 0, system( "start \"\" $cmd_line" ) );
+ } else {
+ # Assume anything else is UNIX or clone
+ # For this purpose cygwin behaves like UNIX.
+ ## warn "Run_Detached.UNIX: A\n";
+ my $pid = fork();
+ ## warn "Run_Detached.UNIX: B pid=$pid\n";
+ if ( ! defined $pid ) {
+ ## warn "Run_Detached.UNIX: C\n";
+ warn "$My_name: Could not fork to run the following command:\n";
+ warn " '$cmd_line'\n";
+ return (0, 1);
+ }
+ elsif( $pid == 0 ){
+ ## warn "Run_Detached.UNIX: D\n";
+ # Forked child process arrives here
+ # Insulate child process from interruption by ctrl/C to kill parent:
+ # setpgrp(0,0);
+ # Perhaps this works if setpgrp doesn't exist
+ # (and therefore gives fatal error):
+ eval{ setpgrp(0,0);};
+ exec( $cmd_line );
+ # Exec never returns; it replaces current process by new process
+ die "$My_name forked process: could not run the command\n",
+ " '$cmd_line'\n";
+ }
+ ##warn "Run_Detached.UNIX: E\n";
+ # Original process arrives here
+ return ($pid, 0);
+ }
+ # NEVER GET HERE.
+ ##warn "Run_Detached.UNIX: F\n";
+} #END Run_Detached
+
+#************************************************************
+
+sub find_process_id {
+# find_process_id(string) finds id of process containing string and
+# being run by the present user. Typically the string will be the
+# name of the process or part of its command line.
+# On success, this subroutine returns the process ID.
+# On failure, it returns 0.
+# This subroutine only works on UNIX systems at the moment.
+
+ if ( $pid_position < 0 ) {
+ # I cannot do a ps on this system
+ return (0);
+ }
+
+ my $looking_for = $_[0];
+ my @ps_output = `$pscmd`;
+ my @ps_lines = ();
+
+# There may be multiple processes. Find only latest,
+# almost surely the one with the highest process number
+# This will deal with cases like xdvi where a script is used to
+# run the viewer and both the script and the actual viewer binary
+# have running processes.
+ my @found = ();
+
+ shift(@ps_output); # Discard the header line from ps
+ foreach (@ps_output) {
+ next unless ( /$looking_for/ ) ;
+ s/^\s*//;
+ my @ps_line = split ('\s+');
+ push @found, $ps_line[$pid_position];
+ push @ps_lines, $_;
+ }
+
+ if ($#found < 0) {
+ # No luck in finding the specified process.
+ return(0);
+ }
+ @found = reverse sort @found;
+ if ($diagnostics) {
+ print "Found the following processes concerning '$looking_for'\n",
+ " @found\n",
+ " I will use $found[0]\n";
+ print " The relevant lines from '$pscmd' were:\n";
+ foreach (@ps_lines) { print " $_"; }
+ }
+ return $found[0];
+}
+
+#************************************************************
+#************************************************************
+#************************************************************
+
+#============================================
+
+sub cache_good_cwd {
+ # Set cached value of cwd to current cwd.
+ # Under cygwin, the cached value is converted to a native MSWin path so
+ # that the result can be used for input to MSWin programs as well
+ # as cygwin programs.
+ # Similarly for msys.
+ my $cwd = cwd();
+ if ( $^O eq "cygwin" ) {
+ my $cmd = "cygpath -w \"$cwd\"";
+ my $Win_cwd = `$cmd`;
+ chomp $Win_cwd;
+ if ( $Win_cwd ) {
+ $cwd = $Win_cwd;
+ }
+ else {
+ warn "$My_name: Could not correctly run command\n",
+ " '$cmd'\n",
+ " to get MSWin version of cygwin path\n",
+ " '$cwd'\n",
+ " The result was\n",
+ " '$Win_cwd'\n";
+ }
+ }
+ elsif ( $^O eq "msys" ) {
+ $cwd =~ s[^/([a-z])/][\u$1:/];
+ }
+ $cache{cwd} = $cwd;
+} # END cache_good_cwd
+
+#============================================
+
+sub good_cwd {
+ # Return cwd, but under cygwin (or ...), convert to MSWin path.
+ # Use cached result, to save a possible expensive computation (running
+ # of extenal program under cygwin).
+ return $cache{cwd};
+} # END good_cwd
+
+#============================================
+
+# Directory stack routines
+
+sub pushd {
+ push @dir_stack, [cwd(), $cache{cwd}];
+ if ( $#_ > -1) {
+ chdir $_[0];
+ &cache_good_cwd;
+ }
+}
+
+#************************************************************
+
+sub popd {
+ if ($#dir_stack > -1 ) {
+ my $Parr = pop @dir_stack;
+ chdir $$Parr[0];
+ $cache{cwd} = $$Parr[1];
+ }
+}
+
+#************************************************************
+
+sub ifcd_popd {
+ if ( $do_cd ) {
+ warn "$My_name: Undoing directory change\n"
+ if !$silent;
+ &popd;
+ }
+}
+
+#************************************************************
+
+sub finish_dir_stack {
+ while ($#dir_stack > -1 ) { &popd; }
+}
+
+#************************************************************
+#************************************************************
+# Break handling routines (for wait-loop in preview continuous)
+
+sub end_wait {
+ # Handler for break: Set global variable $have_break to 1.
+ # Some systems (e.g., MSWin reset) appear to reset the handler.
+ # So I'll re-enable it
+ &catch_break;
+ $have_break = 1;
+}
+
+#========================
+
+sub catch_break {
+# Capture ctrl/C and ctrl/break.
+# $SIG{INT} corresponds to ctrl/C on LINUX/?UNIX and MSWin
+# $SIG{BREAK} corresponds to ctrl/break on MSWin, doesn't exist on LINUX
+ $SIG{INT} = \&end_wait;
+ if ( exists $SIG{BREAK} ) {
+ $SIG{BREAK} = \&end_wait;
+ }
+}
+
+#========================
+
+sub default_break {
+# Arrange for ctrl/C and ctrl/break to give default behavior
+ $SIG{INT} = 'DEFAULT';
+ if ( exists $SIG{BREAK} ) {
+ $SIG{BREAK} = 'DEFAULT';
+ }
+}
+
+#************************************************************
+#************************************************************
diff --git a/support/latexmk/latexmk.txt b/support/latexmk/latexmk.txt
new file mode 100644
index 0000000000..6f62542380
--- /dev/null
+++ b/support/latexmk/latexmk.txt
@@ -0,0 +1,4620 @@
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+NAME
+ latexmk - generate LaTeX document
+
+SYNOPSIS
+ latexmk [options] [file ...]
+
+DESCRIPTION
+ Latexmk completely automates the process of compiling a LaTeX document.
+ Essentially, it is like a specialized relative of the general make
+ utility, but one which determines dependencies automatically and has
+ some other very useful features. In its basic mode of operation la-
+ texmk is given the name of the primary source file for a document, and
+ it issues the appropriate sequence of commands to generate a .dvi, .ps,
+ .pdf and/or hardcopy version of the document.
+
+ By default latexmk will run the commands necessary to generate a .dvi
+ file.
+
+ Latexmk can also be set to run continuously with a suitable previewer.
+ In that case the latex program (or one of its relatives), etc, are re-
+ run whenever one of the source files is modified, and the previewer au-
+ tomatically updates the on-screen view of the compiled document.
+
+ Latexmk determines which are the source files by examining the log
+ file. (Optionally, it also examines the list of input and output files
+ generated by the -recorder option of modern versions of latex (and
+ pdflatex, xelatex, lualatex, etc). See the documentation for the
+ -recorder option of latexmk below.) When latexmk is run, it examines
+ properties of the source files, and if any have been changed since the
+ last document generation, latexmk will run the various LaTeX processing
+ programs as necessary. In particular, it will repeat the run of latex
+ (or a related program)) often enough to resolve all cross references;
+ depending on the macro packages used. With some macro packages and
+ document classes, four, or even more, runs may be needed. If necessary,
+ latexmk will also run bibtex, biber, and/or makeindex. In addition,
+ latexmk can be configured to generate other necessary files. For exam-
+ ple, from an updated figure file it can automatically generate a file
+ in encapsulated postscript or another suitable format for reading by
+ LaTeX.
+
+ Latexmk has two different previewing options. With the simple -pv op-
+ tion, a dvi, postscript or pdf previewer is automatically run after
+ generating the dvi, postscript or pdf version of the document. The
+ type of file to view is selected according to configuration settings
+ and command line options.
+
+ The second previewing option is the powerful -pvc option (mnemonic:
+ "preview continuously"). In this case, latexmk runs continuously, reg-
+ ularly monitoring all the source files to see if any have changed. Ev-
+ ery time a change is detected, latexmk runs all the programs necessary
+ to generate a new version of the document. A good previewer will then
+ automatically update its display. Thus the user can simply edit a file
+ and, when the changes are written to disk, latexmk completely automates
+ the cycle of updating the .dvi (and/or the .ps and .pdf) file, and
+
+
+
+ 18 June 2019 1
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ refreshing the previewer's display. It's not quite WYSIWYG, but use-
+ fully close.
+
+ For other previewers, the user may have to manually make the previewer
+ update its display, which can be (e.g., with some versions of xdvi and
+ gsview) as simple as forcing a redraw of its display.
+
+ Latexmk has the ability to print a banner in gray diagonally across
+ each page when making the postscript file. It can also, if needed,
+ call an external program to do other postprocessing on generated dvi
+ and postscript files. (See the options -dF and -pF, and the documenta-
+ tion for the $dvi_filter and $ps_filter configuration variables.)
+ These capabilities are leftover from older versions of latexmk, but are
+ currently non-functional. More flexibility can be obtained in current
+ versions, since the command strings for running latex, pdflatex, etc
+ can now be configured to run multiple commands. This also extends the
+ possibility of postprocessing generated files.
+
+ Latexmk is highly configurable, both from the command line and in con-
+ figuration files, so that it can accommodate a wide variety of user
+ needs and system configurations. Default values are set according to
+ the operating system, so latexmk often works without special configura-
+ tion on MS-Windows, cygwin, Linux, OS-X, and other UNIX systems. See
+ the section "Configuration/Initialization (rc) Files", and then the
+ later sections "How to Set Variables in Initialization Files", "Format
+ of Command Specifications", "List of Configuration Variables Usable in
+ Initialization Files", "Custom Dependencies", and "Advanced Configura-
+ tion"
+
+ A very annoying complication handled very reliably by latexmk, is that
+ LaTeX is a multiple pass system. On each run, LaTeX reads in informa-
+ tion generated on a previous run, for things like cross referencing and
+ indexing. In the simplest cases, a second run of LaTeX suffices, and
+ often the log file contains a message about the need for another pass.
+ However, there is a wide variety of add-on macro packages to LaTeX,
+ with a variety of behaviors. The result is to break simple-minded de-
+ terminations of how many runs are needed and of which programs. La-
+ texmk has a highly general and efficient solution to these issues. The
+ solution involves retaining between runs information on the source
+ files, and a symptom is that latexmk generates an extra file (with ex-
+ tension .fdb_latexmk, by default) that contains the source file infor-
+ mation.
+
+
+LATEXMK OPTIONS AND ARGUMENTS ON COMMAND LINE
+ In general the command line to invoke latexmk has the form
+
+ latexmk [options] [file]
+
+ All options can be introduced by single or double "-" characters, e.g.,
+ "latexmk -help" or "latexmk --help".
+
+ Note 1: In addition to the options in the list below, latexmk recog-
+ nizes almost all the options recognized by the latex, pdflatex programs
+
+
+
+ 18 June 2019 2
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ (and their relatives) in their current TeXLive and MiKTeX implementa-
+ tions. Some of the options for these programs also trigger special ac-
+ tion or behavior by latexmk, in which case they have specific explana-
+ tions in this document. Otherwise, they are just passed through to a
+ called latex or pdflatex program. Run latexmk with the -showextraop-
+ tions to get a list of the options that latexmk accepts and that are
+ simply passed through to latex or pdflatex (etc). See also the expla-
+ nation of the -showextraoptions option for more information.
+
+ Note 2: In this documentation, the program pdflatex is often referred
+ to. Users of programs like lualatex and xelatex should know that from
+ latexmk's point of view, these other programs behave very like pdfla-
+ tex, i.e., they make a pdf file from a tex file, etc. So whenever
+ pdflatex is mentioned without mention of the other programs, the state-
+ ments apply equally to lualatex, xelatex, and any other similar pro-
+ grams. Latexmk can be easily configured to use whichever of these pro-
+ grams is needed. See the documentation for the following options:
+ -pdflua, -pdfxe, -lualatex, and -xelatex, and also see the documenta-
+ tion for the $pdflatex, $lualatex, and $xelatex configuration vari-
+ ables. At present latexmk does not do automatic detection of which
+ program is to be used.
+
+
+ Definitions of options and arguments
+
+
+ file One or more files can be specified. If no files are specified,
+ latexmk will, by default, run on all files in the current work-
+ ing directory with a ".tex" extension. This behavior can be
+ changed: see the description concerning the @default_files vari-
+ able in the section "List of configuration variables usable in
+ initialization files".
+
+ If a file is specified without an extension, then the ".tex" ex-
+ tension is automatically added, just as LaTeX does. Thus, if
+ you specify:
+
+ latexmk foo
+
+ then latexmk will operate on the file "foo.tex".
+
+ There are certain restrictions on what characters can be in a
+ filename; certain characters are either prohibited or problem-
+ atic for the latex etc programs. These characters are: "$",
+ "%", "\", "~", the double quote character, and the control char-
+ acters null, tab, form feed, carriage return, line feed, and
+ delete. In addition "&" is prohibited when it is the first
+ character of a filename.
+
+ Latexmk gives a fatal error when it detects any of the above
+ characters in the TeX filename(s) specified on the command line.
+ However before testing for illegal characters, latexmk removes
+ matching pairs of double quotes from a filename. This matches
+ the behavior of latex etc, and deals with problems that
+
+
+
+ 18 June 2019 3
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ occasionally result from filenames that have been incorrectly
+ quoted on the command line. In addition, under Microsoft Win-
+ dows, the forward slash character "\" is a directory separator,
+ so latexmk replaces it by a backward slash "/", which is also a
+ legal directory separator in Windows, and is accepted by latex
+ etc.
+
+
+ -auxdir=FOO or -aux-directory=FOO
+ Sets the directory for auxiliary output files of (pdf)latex
+ (.aux, .log etc). This achieves its effect by the -aux-direc-
+ tory option of (pdf)latex, which currently is only implemented
+ on the MiKTeX version of (pdf)latex.
+
+ See also the -outdir/-output-directory options, and the
+ $aux_dir, $out_dir, and $search_path_separator configuration
+ variables of latexmk. In particular, see the documentation of
+ $out_dir for some complications on what directory names are
+ suitable.
+
+ If you also use the -cd option, and the specified auxiliary out-
+ put directory is a relative path, then the path is interpreted
+ relative to the document directory.
+
+
+ -bibtex
+ When the source file uses bbl files for bibliography, run bibtex
+ or biber as needed to regenerate the bbl files.
+
+ This property can also be configured by setting the $bibtex_use
+ variable to 2 in a configuration file.
+
+
+ -bibtex-
+ Never run bibtex or biber. Also, always treat .bbl files as
+ precious, i.e., do not delete them in a cleanup operation.
+
+ A common use for this option is when a document comes from an
+ external source, complete with its bbl file(s), and the user
+ does not have the corresponding bib files available. In this
+ situation use of the -bibtex- option will prevent latexmk from
+ trying to run bibtex or biber, which would result in overwriting
+ of the bbl files.
+
+ This property can also be configured by setting the $bibtex_use
+ variable to 0 in a configuration file.
+
+
+ -bibtex-cond
+ When the source file uses bbl file(s) for the bibliography, run
+ bibtex or biber as needed to regenerate the bbl files, but only
+ if the relevant bib file(s) exist. Thus when the bib files are
+ not available, bibtex or biber is not run, thereby avoiding
+ overwriting of the bbl file(s). Also, always treat .bbl files
+
+
+
+ 18 June 2019 4
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ as precious, i.e., do not delete them in a cleanup operation.
+
+ This is the default setting. It can also be configured by set-
+ ting the $bibtex_use variable to 1 in a configuration file.
+
+ The reason for using this setting is that sometimes a .bbl file
+ is available containing the bibliography for a document, but the
+ .bib file is not available. An example would be for a scien-
+ tific journal where authors submit .tex and .bbl files, but not
+ the original .bib file. In that case, running bibtex or biber
+ would not work, and the .bbl file should be treated as a user
+ source file, and not as a file that can be regenerated on de-
+ mand.
+
+ (Note that it is possible for latexmk to decide that the bib
+ file does not exist, even though the bib file does exist and
+ bibtex or biber finds it. The problem is that the bib file may
+ not be in the current directory but in some search path; the
+ places latexmk and bibtex or biber cause to be searched need not
+ be identical. On modern installations of TeX and related pro-
+ grams this problem should not arise, since latexmk uses the
+ kpsewhich program to do the search, and kpsewhich should use the
+ same search path as bibtex and biber. If this problem arises,
+ use the -bibtex option when invoking latexmk.)
+
+ Note that this value does not work properly if the document uses
+ biber instead of bibtex. (There's a long story why not.)
+
+
+ -bibtex-cond1
+ The same as -bibtex-cond1 except that .bbl files are only
+ treated as precious if one or more bibfiles fails to exist.
+
+ Thus if all the bib files exist, bibtex or biber is run to gen-
+ erate .bbl files as needed, and then it is appropriate to delete
+ the bbl files in a cleanup operation since they can be re-gener-
+ ated.
+
+ This property can also be configured by setting the $bibtex_use
+ variable to 1.5 in a configuration file.
+
+
+ -bm <message>
+ A banner message to print diagonally across each page when con-
+ verting the dvi file to postscript. The message must be a sin-
+ gle argument on the command line so be careful with quoting spa-
+ ces and such.
+
+ Note that if the -bm option is specified, the -ps option is as-
+ sumed.
+
+
+ -bi <intensity>
+ How dark to print the banner message. A decimal number between
+
+
+
+ 18 June 2019 5
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ 0 and 1. 0 is black and 1 is white. The default is 0.95, which
+ is OK unless your toner cartridge is getting low.
+
+
+ -bs <scale>
+ A decimal number that specifies how large the banner message
+ will be printed. Experimentation is necessary to get the right
+ scale for your message, as a rule of thumb the scale should be
+ about equal to 1100 divided by the number of characters in the
+ message. The default is 220.0 which is just right for 5 charac-
+ ter messages.
+
+
+ -commands
+ List the commands used by latexmk for processing files, and then
+ exit.
+
+
+ -c Clean up (remove) all regeneratable files generated by latex and
+ bibtex or biber except dvi, postscript and pdf. These files are
+ a combination of log files, aux files, latexmk's database file
+ of source file information, and those with extensions specified
+ in the @generated_exts configuration variable. In addition,
+ files specified by the $clean_ext and @generated_exts configura-
+ tion variables are removed.
+
+ This cleanup is instead of a regular make. See the -gg option
+ if you want to do a cleanup then a make.
+
+ Treatment of .bbl files: If $bibtex_use is set to 0 or 1, bbl
+ files are always treated as non-regeneratable. If $bibtex_use
+ is set to 1.5, bbl files are counted as non-regeneratable condi-
+ tionally: If the bib file exists, then bbl files are regenerat-
+ able, and are deleted in a clean up. But if $bibtex_use is 1.5
+ and a bib file doesn't exist, then the bbl files are treated as
+ non-regeneratable and hence are not deleted.
+
+ In contrast, if $bibtex_use is set to 2, bbl files are always
+ treated as regeneratable, and are deleted in a cleanup.
+
+ Treatment of files generated by custom dependencies: If
+ $cleanup_includes_cusdep_generated is nonzero, regeneratable
+ files are considered as including those generated by custom de-
+ pendencies and are also deleted. Otherwise these files are not
+ deleted.
+
+
+ -C Clean up (remove) all regeneratable files generated by latex and
+ bibtex or biber. This is the same as the -c option with the ad-
+ dition of dvi, postscript and pdf files, and those specified in
+ the $clean_full_ext configuration variable.
+
+ This cleanup is instead of a regular make. See the -gg option
+ if you want to do a cleanup than a make.
+
+
+
+ 18 June 2019 6
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ See the -c option for the specification of whether or not .bbl
+ files are treated as non-regeneratable or regeneratable.
+
+ If $cleanup_includes_cusdep_generated is nonzero, regeneratable
+ files are considered as including those generated by custom de-
+ pendencies and are also deleted. Otherwise these files are not
+ deleted.
+
+
+ -CA (Obsolete). Now equivalent to the -C option. See that option
+ for details.
+
+
+ -cd Change to the directory containing the main source file before
+ processing it. Then all the generated files (.aux, .log, .dvi,
+ .pdf, etc) will be relative to the source file.
+
+ This option is particularly useful when latexmk is invoked from
+ a GUI configured to invoke latexmk with a full pathname for the
+ source file.
+
+ This option works by setting the $do_cd configuration variable
+ to one; you can set that variable if you want to configure la-
+ texmk to have the effect of the -cd option without specifying it
+ on the command line. See the documentation for that variable.
+
+
+ -cd- Do NOT change to the directory containing the main source file
+ before processing it. Then all the generated files (.aux, .log,
+ .dvi, .pdf, etc) will be relative to the current directory
+ rather than the source file.
+
+ This is the default behavior and corresponds to the behavior of
+ the latex and pdflatex programs. However, it is not desirable
+ behavior when latexmk is invoked by a GUI configured to invoke
+ latexmk with a full pathname for the source file. See the -cd
+ option.
+
+ This option works by setting the $do_cd configuration variable
+ to zero. See the documentation for that variable for more in-
+ formation.
+
+
+ -CF Remove the file containing the database of source file informa-
+ tion, before doing the other actions requested.
+
+
+ -d Set draft mode. This prints the banner message "DRAFT" across
+ your page when converting the dvi file to postscript. Size and
+ intensity can be modified with the -bs and -bi options. The -bm
+ option will override this option as this is really just a short
+ way of specifying:
+
+ latexmk -bm DRAFT
+
+
+
+ 18 June 2019 7
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ Note that if the -d option is specified, the -ps option is as-
+ sumed.
+
+
+ -deps Show a list of dependent files after processing. This is in the
+ form of a dependency list of the form used by the make program,
+ and it is therefore suitable for use in a Makefile. It gives an
+ overall view of the files without listing intermediate files, as
+ well as latexmk can determine them.
+
+ By default the list of dependent files is sent to stdout (i.e.,
+ normally to the screen unless you've redirected latexmk's out-
+ put). But you can set the filename where the list is sent by the
+ -deps-out= option.
+
+ See the section "USING latexmk WITH make" for an example of how
+ to use a dependency list with make.
+
+ Users familiar with GNU automake and gcc will find that the
+ -deps option is very similar in its purpose and results to the
+ -M option to gcc. (In fact, latexmk also has options -M, -MF,
+ and -MP options that behave like those of gcc.)
+
+
+ -dependents
+ Equivalent to -deps.
+
+
+ -deps- Do not show a list of dependent files after processing. (This
+ is the default.)
+
+
+ -dependents-
+ Equivalent to -deps-.
+
+
+ -deps-out=FILENAME
+ Set the filename to which the list of dependent files is writ-
+ ten. If the FILENAME argument is omitted or set to "-", then
+ the output is sent to stdout.
+
+ Use of this option also turns on the output of the list of de-
+ pendent files after processing.
+
+
+ -dF Dvi file filtering. The argument to this option is a filter
+ which will generate a filtered dvi file with the extension
+ ".dviF". All extra processing (e.g. conversion to postscript,
+ preview, printing) will then be performed on this filtered dvi
+ file.
+
+ Example usage: To use dviselect to select only the even pages of
+ the dvi file:
+
+
+
+
+ 18 June 2019 8
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ latexmk -dF "dviselect even" foo.tex
+
+
+ -diagnostics
+ Print detailed diagnostics during a run. This may help for de-
+ bugging problems or to understand latexmk's behavior in diffi-
+ cult situations.
+
+
+ -dvi Generate dvi version of document.
+
+
+ -dvi- Turn off generation of dvi version of document. (This may get
+ overridden, if some other file is made (e.g., a .ps file) that
+ is generated from the dvi file, or if no generated file at all
+ is requested.)
+
+
+ -e <code>
+ Execute the specified initialization code before processing.
+ The code is Perl code of the same form as is used in latexmk's
+ initialization files. For more details, see the information on
+ the -r option, and the section about "Configuration/initializa-
+ tion (RC) files". The code is typically a sequence of assign-
+ ment statements separated by semicolons.
+
+ The code is executed when the -e option is encountered during
+ latexmk's parsing of its command line. See the -r option for a
+ way of executing initialization code from a file. An error re-
+ sults in latexmk stopping. Multiple instances of the -r and -e
+ options can be used, and they are executed in the order they ap-
+ pear on the command line.
+
+ Some care is needed to deal with proper quoting of special char-
+ acters in the code on the command line. For example, suppose
+ you want to set the latex command to use its -shell-escape op-
+ tion, then under UNIX/Linux you could use the line
+
+ latexmk -e '$latex=q/latex %O -shell-escape %S/' file.tex
+
+ Note that the single quotes block normal UNIX/Linux command
+ shells from treating the characters inside the quotes as spe-
+ cial. (In this example, the q/.../ construct is a Perl idiom
+ equivalent to using single quotes. This avoids the complica-
+ tions of getting a quote character inside an already quoted
+ string in a way that is independent of both the shell and the
+ operating-system.)
+
+ The above command line will NOT work under MS-Windows with
+ cmd.exe or command.com or 4nt.exe. For MS-Windows with these
+ command shells you could use
+
+ latexmk -e "$latex=q/latex %O -shell-escape %S/" file.tex
+
+
+
+
+ 18 June 2019 9
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ or
+
+ latexmk -e "$latex='latex %O -shell-escape %S'" file.tex
+
+ The last two examples will NOT work with UNIX/Linux command
+ shells.
+
+ (Note: the above examples show are to show how to use the -e to
+ specify initialization code to be executed. But the particular
+ effect can be achieved also by the use of the -latex option with
+ less problems in dealing with quoting.)
+
+
+ -f Force latexmk to continue document processing despite errors.
+ Normally, when latexmk detects that LaTeX or another program has
+ found an error which will not be resolved by further processing,
+ no further processing is carried out.
+
+ Note: "Further processing" means the running of other programs
+ or the rerunning of latex (etc) that would be done if no errors
+ had occurred. If instead, or additionally, you want the latex
+ (etc) program not to pause for user input after an error, you
+ should arrange this by an option that is passed to the program,
+ e.g., by latexmk's option -interaction=nonstopmode.
+
+
+ -f- Turn off the forced processing-past-errors such as is set by the
+ -f option. This could be used to override a setting in a con-
+ figuration file.
+
+
+ -g Force latexmk to process document fully, even under situations
+ where latexmk would normally decide that no changes in the
+ source files have occurred since the previous run. This option
+ is useful, for example, if you change some options and wish to
+ reprocess the files.
+
+
+ -g- Turn off -g.
+
+
+ -gg "Super go mode" or "clean make": clean out generated files as if
+ -C had been given, and then do a regular make.
+
+
+ -h, -help
+ Print help information.
+
+
+ -jobname=STRING
+ Set the basename of output files(s) to STRING, instead of the
+ default, which is the basename of the specified TeX file. (At
+ present, STRING should not contain spaces.)
+
+
+
+
+ 18 June 2019 10
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ This is like the same option for current implementations of the
+ latex, pdflatex, etc, and the passing of this option to these
+ programs is part of latexmk's implementation of -jobname.
+
+ There is one enhancement, that the STRING may contain the place-
+ holder '%A'. This will be substituted by the basename of the TeX
+ file. The primary purpose is when multiple files are specified
+ on the command line to latexmk, and you wish to use a jobname
+ with a different file-dependent value for each file. For exam-
+ ple, suppose you had .tex files test1.tex and test2.tex, and you
+ wished to compare the results of compilation by pdflatex and
+ those with xelatex. Then under a unix-type operating system you
+ could use the command line
+
+ latexmk -pdf -jobname=%A-pdflatex *.tex
+ latexmk -pdfxe -jobname=%A-xelatex *.tex
+
+ Then the .aux, .log, and .pdf files from the use of pdflatex
+ would have basenames test1-pdflatex and test2-pdflatex, while
+ from xelatex, the basenames would be test1-xelatex and test2-xe-
+ latex.
+
+ Under MS-Windows with cmd.exe, you would need to double the per-
+ cent sign, so that the percent character is passed to latexmk
+ rather than being used to substitute an environment variable:
+
+ latexmk -pdf -jobname=%%A-pdflatex *.tex
+ latexmk -pdfxe -jobname=%%A-xelatex *.tex
+
+
+ -l Run in landscape mode, using the landscape mode for the preview-
+ ers and the dvi to postscript converters. This option is not
+ normally needed nowadays, since current previewers normally de-
+ termine this information automatically.
+
+
+ -l- Turn off -l.
+
+
+ -latex="COMMAND"
+ This sets the string specifying the command to run latex, and is
+ typically used to add desired options. Since the string nor-
+ mally contains spaces, it should be quoted, e.g.,
+
+ latexmk -latex="latex --shell-escape %O %S" foo.tex
+
+ The specification of the contents of the string are the same as
+ for the $latex configuration variable. Depending on your oper-
+ ating system and the command-line shell you are using, you may
+ need to change the single quotes to double quotes (or something
+ else).
+
+ To set the command for running pdflatex (rather than the command
+ for latex) see the -pdflatex option.
+
+
+
+ 18 June 2019 11
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ -logfilewarninglist
+ -logfilewarnings After a run of (pdf)latex, give a list of warn-
+ ings about undefined citations and references (unless silent
+ mode is on).
+
+ See also the $silence_logfile_warnings configuration variable.
+
+
+ -logfilewarninglist-
+ -logfilewarnings- After a run of (pdf)latex, do not give a list
+ of warnings about undefined citations and references. (Default)
+
+ See also the $silence_logfile_warnings configuration variable.
+
+
+ -lualatex
+ Use lualatex. That is, use lualatex to process the source
+ file(s) to pdf. The generation of dvi and postscript files is
+ turned off.
+
+ This option is equivalent to using the following set of options
+
+ -pdflua -dvi- -ps-
+
+ (Note: Note that the method of implementation of this option,
+ but not its intended effect, differ from some earlier versions
+ of latexmk.)
+
+
+ -M Show list of dependent files after processing. This is equiva-
+ lent to the -deps option.
+
+
+ -MF file
+ If a list of dependents is made, the -MF specifies the file to
+ write it to.
+
+
+ -MP If a list of dependents is made, include a phony target for each
+ source file. If you use the dependents list in a Makefile, the
+ dummy rules work around errors the program make gives if you re-
+ move header files without updating the Makefile to match.
+
+
+ -new-viewer
+ When in continuous-preview mode, always start a new viewer to
+ view the generated file. By default, latexmk will, in continu-
+ ous-preview mode, test for a previously running previewer for
+ the same file and not start a new one if a previous previewer is
+ running. However, its test sometimes fails (notably if there is
+ an already-running previewer that is viewing a file of the same
+ name as the current file, but in a different directory). This
+ option turns off the default behavior.
+
+
+
+
+ 18 June 2019 12
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ -new-viewer-
+ The inverse of the -new-viewer option. It puts latexmk in its
+ normal behavior that in preview-continuous mode it checks for an
+ already-running previewer.
+
+
+ -nobibtex
+ Never run bibtex or biber. Equivalent to the -bibtex- option.
+
+
+ -norc Turn off the automatic reading of initialization (rc) files.
+
+ N.B. Normally the initialization files are read and obeyed, and
+ then command line options are obeyed in the order they are en-
+ countered. But -norc is an exception to this rule: it is acted
+ on first, no matter where it occurs on the command line.
+
+
+ -outdir=FOO or -output-directory=FOO
+
+ Sets the directory for the output files of (pdf)latex. This
+ achieves its effect by the -output-directory option of (pdf)la-
+ tex, which currently (Dec. 2011 and later) is implemented on the
+ common versions of (pdf)latex, i.e., MiKTeX and TeXLive. It may
+ not be present in other versions.
+
+ See also the -auxdir/-aux-directory options, and the $aux_dir,
+ $out_dir, and $search_path_separator configuration variables of
+ latexmk. In particular, see the documentation of $out_dir for
+ some complications on what directory names are suitable.
+
+ If you also use the -cd option, and the specified output direc-
+ tory is a relative path, then the path is interpreted relative
+ to the document directory.
+
+
+ -p Print out the document. By default the file to be printed is
+ the first in the list postscript, pdf, dvi that is being made.
+ But you can use the -print=... option to change the type of file
+ to be printed, and you can configure this in a start up file (by
+ setting the $print_type variable).
+
+ However, printing is enabled by default only under UNIX/Linux
+ systems, where the default is to use the lpr command and only on
+ postscript files. In general, the correct behavior for printing
+ very much depends on your system's software. In particular, un-
+ der MS-Windows you must have suitable program(s) available, and
+ you must have configured the print commands used by latexmk.
+ This can be non-trivial. See the documentation on the $lpr,
+ $lpr_dvi, and $lpr_pdf configuration variables to see how to set
+ the commands for printing.
+
+ This option is incompatible with the -pv and -pvc options, so it
+ turns them off.
+
+
+
+ 18 June 2019 13
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ -pdf Generate pdf version of document using pdflatex. (If you wish
+ to use lualatex or xelatex, you can use whichever of the options
+ -pdflua, -pdfxe, -lualatex or -xelatex applies.) To configure
+ latexmk to have such behavior by default, see the section on
+ "Configuration/initialization (rc) files".
+
+
+ -pdfdvi
+ Generate pdf version of document from the dvi file, by default
+ using dvipdf.
+
+
+ -pdflua
+ Generate pdf version of document using lualatex.
+
+
+ -pdfps Generate pdf version of document from the .ps file, by default
+ using ps2pdf.
+
+
+ -pdfxe Generate pdf version of document using xelatex. Note that to
+ optimize processing time, latexmk uses xelatex to generate an
+ .xdv file rather than a pdf file directly. Only after possibly
+ multiple runs to generate a fully up-to-date .xdv file does la-
+ texmk then call xdvipdfmx to generate the final .pdf file.
+
+ (Note: When the document includes large graphics files, espe-
+ cially .png files, the last step can be quite time consuming,
+ even when the creation of the .xdv file by xelatex is fast. So
+ the use of the intermediate .xdv file can result in substantial
+ gains in procesing time, since the .pdf file is produced once
+ rather than on every run of xelatex. See the documentation on
+ the -pdfxe option for why an .xdv file is used.
+
+
+ -pdf- Turn off generation of pdf version of document. (This can be
+ used to override a setting in a configuration file. It may get
+ overridden if some other option requires the generation of a pdf
+ file.)
+
+ If after all options have been processed, pdf generation is
+ still turned off, then generation of a dvi file will be turned
+ on, and then the program used to compiled a document will be la-
+ tex (or, more precisely, whatever program is configured to be
+ used in the $latex configuration variable).
+
+
+ -pdflatex="COMMAND"
+ This sets the string specifying the command to run pdflatex, and
+ is typically used to add desired options. Since the string nor-
+ mally contains spaces, it should be quoted, e.g.,
+
+ latexmk -pdf -pdflatex="pdflatex --shell-escape %O %S"
+ foo.tex
+
+
+
+ 18 June 2019 14
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ The specification of the contents of the string are the same as
+ for the $pdflatex configuration variable. (The option -pdflatex
+ in fact sets the variable $pdflatex.) Depending on your operat-
+ ing system and the command-line shell you are using, you may
+ need to change the single quotes to double quotes (or something
+ else).
+
+ To set the command for running latex (rather than the command
+ for pdflatex) see the -latex option.
+
+
+ -pdflualatex="COMMAND"
+ This sets the string specifying the command to run lualatex. It
+ behaves like the -pdflatex option, but sets the variable $luala-
+ tex.
+
+
+ -pdfxelatex="COMMAND"
+ This sets the string specifying the command to run xelatex. It
+ behaves like the -pdflatex option, but sets the variable $xela-
+ tex.
+
+ Warning: It is important to ensure that the -no-pdf is used when
+ xelatex is invoked; see the explanation for the variable $xela-
+ tex for why this is necessary. If you provide %O in the command
+ specification, this will be done automatically.
+
+ An example of the use of the -pdfxelatex option:
+
+ latexmk -pdfxe -pdfxelatex="xelatex --shell-escape %O %S"
+ foo.tex
+
+
+
+ -pretex=CODE
+
+ Given that CODE is some TeX code, this options sets that code to
+ be executed before inputting source file. This only works if
+ the command for invoking the relevant *latex is suitably config-
+ ured. See the documentation of the variable $pre_tex_code, and
+ the substitution strings %P and %U for more details. This op-
+ tion works by setting the variable $pre_tex_code.
+
+ See also the -usepretex option.
+
+ An example:
+
+ latexmk -pretex='\AtBeginDocument{Message\par}' -usepretex
+ foo.tex
+
+ But this is better written
+
+ latexmk -usepretex='\AtBeginDocument{Message\par}' foo.tex
+
+
+
+
+ 18 June 2019 15
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ If you already have a suitable command configured, you only need
+
+ latexmk -pretex='\AtBeginDocument{Message\par}' foo.tex
+
+
+ -print=dvi, -print=ps, -print=pdf, -print=auto,
+ Define which kind of file is printed. This option also ensures
+ that the requisite file is made, and turns on printing.
+
+ The (default) case -print=auto determines the kind of print file
+ automatically from the set of files that is being made. The
+ first in the list postscript, pdf, dvi that is among the files
+ to be made is the one used for print out.
+
+
+ -ps Generate postscript version of document.
+
+
+ -ps- Turn off generation of postscript version of document. This can
+ be used to override a setting in a configuration file. (It may
+ get overridden by some other option that requires a postscript
+ file, for example a request for printing.)
+
+
+ -pF Postscript file filtering. The argument to this option is a
+ filter which will generate a filtered postscript file with the
+ extension ".psF". All extra processing (e.g. preview, printing)
+ will then be performed on this filtered postscript file.
+
+ Example of usage: Use psnup to print two pages on the one page:
+
+ latexmk -ps -pF 'psnup -2' foo.tex
+
+ or
+
+ latexmk -ps -pF "psnup -2" foo.tex
+
+ Whether to use single or double quotes round the "psnup -2" will
+ depend on your command interpreter, as used by the particular
+ version of perl and the operating system on your computer.
+
+
+ -pv Run file previewer. If the -view option is used, this will se-
+ lect the kind of file to be previewed (.dvi, .ps or .pdf). Oth-
+ erwise the viewer views the "highest" kind of file selected, by
+ the -dvi, -ps, -pdf, -pdfps options, in the order .dvi, .ps,
+ .pdf (low to high). If no file type has been selected, the dvi
+ previewer will be used. This option is incompatible with the -p
+ and -pvc options, so it turns them off.
+
+
+ -pv- Turn off -pv.
+
+
+
+
+
+ 18 June 2019 16
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ -pvc Run a file previewer and continually update the .dvi, .ps,
+ and/or .pdf files whenever changes are made to source files (see
+ the Description above). Which of these files is generated and
+ which is viewed is governed by the other options, and is the
+ same as for the -pv option. The preview-continuous option -pvc
+ can only work with one file. So in this case you will normally
+ only specify one filename on the command line. It is also in-
+ compatible with the -p and -pv options, so it turns these op-
+ tions off.
+
+ The -pvc option also turns off force mode (-f), as is normally
+ best for continuous preview mode. If you really want force
+ mode, use the options in the order -pvc -f.
+
+ With a good previewer the display will be automatically updated.
+ (Under some but not all versions of UNIX/Linux "gv -watch" does
+ this for postscript files; this can be set by a configuration
+ variable. This would also work for pdf files except for an ap-
+ parent bug in gv that causes an error when the newly updated pdf
+ file is read.) Many other previewers will need a manual update.
+
+ Important note: the acroread program on MS-Windows locks the pdf
+ file, and prevents new versions being written, so it is a bad
+ idea to use acroread to view pdf files in preview-continuous
+ mode. It is better to use a different viewer: SumatraPDF and
+ gsview are good possibilities.
+
+ There are some other methods for arranging an update, notably
+ useful for many versions of xdvi and xpdf. These are best set
+ in latexmk's configuration; see below.
+
+ Note that if latexmk dies or is stopped by the user, the
+ "forked" previewer will continue to run. Successive invocations
+ with the -pvc option will not fork new previewers, but latexmk
+ will normally use the existing previewer. (At least this will
+ happen when latexmk is running under an operating system where
+ it knows how to determine whether an existing previewer is run-
+ ning.)
+
+
+ -pvc- Turn off -pvc.
+
+
+ -pvctimeout
+ Do timeout in pvc mode after period of inactivity, which is 30
+ min. by default. Inactivity means a period when latexmk has de-
+ tected no file changes and hence has not taken any actions like
+ compiling the document.
+
+
+ -pvctimeout-
+ Don't do timeout in pvc mode after inactivity.
+
+
+
+
+
+ 18 June 2019 17
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ -pvctimeoutmins=<time>
+ Set period of inactivity in minutes for pvc timeout.
+
+
+ -quiet Same as -silent
+
+
+ -r <rcfile>
+ Read the specified initialization file ("RC file") before pro-
+ cessing.
+
+ Be careful about the ordering: (1) Standard initialization files
+ -- see the section below on "Configuration/initialization (RC)
+ files" -- are read first. (2) Then the options on the command
+ line are acted on in the order they are given. Therefore if an
+ initialization file is specified by the -r option, it is read
+ during this second step. Thus an initialization file specified
+ with the -r option can override both the standard initialization
+ files and previously specified options. But all of these can be
+ overridden by later options.
+
+ The contents of the RC file just comprise a piece of code in the
+ Perl programming language (typically a sequence of assignment
+ statements); they are executed when the -r option is encountered
+ during latexmk's parsing of its command line. See the -e option
+ for a way of giving initialization code directly on latexmk's
+ command line. An error results in latexmk stopping. Multiple
+ instances of the -r and -e options can be used, and they are ex-
+ ecuted in the order they appear on the command line.
+
+
+ -recorder
+ Give the -recorder option with latex and pdflatex. In (most)
+ modern versions of these programs, this results in a file of ex-
+ tension .fls containing a list of the files that these programs
+ have read and written. Latexmk will then use this file to im-
+ prove its detection of source files and generated files after a
+ run of latex or pdflatex. This is the default setting of la-
+ texmk, unless overridden in an initialization file.
+
+ For further information, see the documentation for the $recorder
+ configuration variable.
+
+
+ -recorder-
+ Do not supply the -recorder option with latex and pdflatex.
+
+
+ -rules Show a list of latemk's rules and dependencies after processing.
+
+
+ -rules-
+ Do not show a list of latexmk's rules and dependencies after
+ processing. (This is the default.)
+
+
+
+ 18 June 2019 18
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ -showextraoptions
+ Show the list of extra latex and pdflatex options that latexmk
+ recognizes, but that it simply passes through to the programs
+ latex, pdflatex, etc when they are run. These options are
+ (currently) a combination of those allowed by the TeXLive and
+ MiKTeX implementations. (If a particular option is given to la-
+ texmk but is not handled by the particular implementation of la-
+ tex or pdflatex that is being used, that program will probably
+ give an error message.) These options are very numerous, but
+ are not listed in this documentation because they have no effect
+ on latexmk's actions.
+
+ There are a few options (-includedirectory=dir, -initialize,
+ -ini) that are not recognized, either because they don't fit
+ with latexmk's intended operations, or because they need special
+ processing by latexmk that isn't implemented (at least, not
+ yet).
+
+ There are also options that are accepted by latex etc, but in-
+ stead trigger actions by latexmk: -help, -version.
+
+ Finally, there are certain options for latex and pdflatex (e.g.,
+ -recorder) that trigger special actions or behavior by latexmk
+ itself as well as being passed in some form to the called latex
+ and pdflatex program, or that affect other programs as well.
+ These options do have entries in this documentation. These op-
+ tions are: -jobname=STRING, -aux-directory=dir, -output-direc-
+ tory=DIR, -quiet, and -recorder.
+
+
+ -silent
+ Run commands silently, i.e., with options that reduce the amount
+ of diagnostics generated. For example, with the default set-
+ tings, the command "latex -interaction=batchmode" is used for
+ latex, and similarly for its friends.
+
+ See also the -logfilewarninglist and -logfilewarninglist- op-
+ tions.
+
+ Also reduce the number of informational messages that latexmk
+ itself generates.
+
+ To change the options used to make the commands run silently,
+ you need to configure latexmk with changed values of its config-
+ uration variables, the relevant ones being $bib-
+ tex_silent_switch, $biber_silent_switch, $dvipdf_silent_switch,
+ $dvips_silent_switch, $latex_silent_switch, $luala-
+ tex_silent_switch $makeindex_silent_switch, $pdfla-
+ tex_silent_switch, and $xelatex_silent_switch
+
+
+ -stdtexcmds
+ Sets the commands for latex, etc, so that they are the standard
+ ones. This is useful to override special configurations.
+
+
+
+ 18 June 2019 19
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ The result is that $latex = 'latex %O %S', and similarly for
+ $pdflatex, $lualatex, and $xelatex. (The option -no-pdf needed
+ for $xelatex is provided automatically, given that %O appears in
+ the definition.)
+
+
+ -time Show CPU time used. See also the configuration variable
+ $show_time.
+
+
+ -time- Do not show CPU time used. See also the configuration variable
+ $show_time.
+
+
+ -use-make
+ When after a run of latex or pdflatex, there are warnings about
+ missing files (e.g., as requested by the LaTeX \input, \include,
+ and \includgraphics commands), latexmk tries to make them by a
+ custom dependency. If no relevant custom dependency with an ap-
+ propriate source file is found, and if the -use-make option is
+ set, then as a last resort latexmk will try to use the make pro-
+ gram to try to make the missing files.
+
+ Note that the filename may be specified without an extension,
+ e.g., by \includegraphics{drawing} in a LaTeX file. In that
+ case, latexmk will try making drawing.ext with ext set in turn
+ to the possible extensions that are relevant for latex (or as
+ appropriate pdflatex).
+
+ See also the documentation for the $use_make_for_missing_files
+ configuration variable.
+
+
+ -use-make-
+ Do not use the make program to try to make missing files. (De-
+ fault.)
+
+
+ -usepretex
+ Sets the command lines for latex, etc, so that they use the code
+ that is defined by the variable $pre_tex_code or that is set by
+ the option -pretex=CODE to execute the specified TeX code before
+ the source file is read. This option overrides any previous
+ definition of the command lines.
+
+ The result is that $latex = 'latex %O %P', and similarly for
+ $pdflatex, $lualatex, and $xelatex. (The option -no-pdf needed
+ for $xelatex is provided automatically, given that %O appears in
+ the definition.)
+
+
+ -usepretex=CODE
+ Equivalent to -pretex=CODE -usepretex. Example
+
+
+
+
+ 18 June 2019 20
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ latexmk -usepretex='\AtBeginDocument{Message\par}' foo.tex
+
+
+ -v, -version
+ Print version number of latexmk.
+
+
+ -verbose
+ Opposite of -silent. This is the default setting.
+
+
+ -view=default, -view=dvi, -view=ps, -view=pdf, -view=none
+ Set the kind of file used when previewing is requested (e.g., by
+ the -pv or -pvc switches). The default is to view the "highest"
+ kind of requested file (in the low-to-high order .dvi, .ps,
+ .pdf).
+
+ Note the possibility -view=none where no viewer is opened at
+ all. One example of is use is in conjunction with the -pvc op-
+ tion, when you want latexmk to do a compilation automatically
+ whenever source file(s) change, but do not want a previewer to
+ be opened.
+
+
+ -Werror
+ This causes latexmk to return a non-zero status code if any of
+ the files processed gives a warning about problems with cita-
+ tions or references (i.e., undefined citations or references or
+ about multiply defined references). This is after latexmk has
+ completed all the runs it needs to try and resolve references
+ and citations. Thus -Werror causes latexmk to treat such warn-
+ ings as errors, but only when they occur on the last run of
+ (pdf)latex and only after processing is complete. Also can be
+ set by the configuration variable $warnings_as_errors.
+
+
+ -xelatex
+ Use xelatex. That is, use xelatex to process the source file(s)
+ to pdf. The generation of dvi and postscript files is turned
+ off.
+
+ This option is equivalent to using the following set of options
+
+ -pdfxe -dvi- -ps-
+
+ [Note: Note that the method of implementation of this option,
+ but not its intended primary effect, differ from some earlier
+ versions of latexmk. Latexmk first uses xelatex to make an .xdv
+ file, and does all the extra runs needed (including those of
+ bibtex, etc). Only after that does it make the pdf file from
+ the .xdv file, using xdvipdfmx. This procedure can result in
+ considerable savings in run time, since the xdv-to-pdf conver-
+ sion is quite time-consuming when large graphics files are used
+ in the document.]
+
+
+
+ 18 June 2019 21
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ Compatibility between options
+
+ The preview-continuous option -pvc can only work with one file. So in
+ this case you will normally only specify one filename on the command
+ line.
+
+ Options -p, -pv and -pvc are mutually exclusive. So each of these op-
+ tions turns the others off.
+
+
+EXAMPLES
+ % latexmk thesis # run latex enough times to resolve
+ cross-references
+
+ % latexmk -pvc -ps thesis# run latex enough times to resolve
+ cross-references, make a postscript
+ file, start a previewer. Then
+ watch for changes in the source
+ file thesis.tex and any files it
+ uses. After any changes rerun latex
+ the appropriate number of times and
+ remake the postscript file. If latex
+ encounters an error, latexmk will
+ keep running, watching for
+ source file changes.
+
+ % latexmk -c # remove .aux, .log, .bbl, .blg, .dvi,
+ .pdf, .ps & .bbl files
+
+
+
+DEALING WITH ERRORS, PROBLEMS, ETC
+ Some possibilities:
+
+ a. If you get a strange error, do look carefully at the output that is
+ on the screen and in log files. While there is much that is notori-
+ ously verbose in the output of latex (and that is added to by latexmk),
+ the verbosity is there for a reason: to enable the user to diagnose
+ problems. Latexmk does repeat some messages at the end of a run that
+ it thinks would otherwise be easy to miss in the middle of other out-
+ put.
+
+ b. Generally, remember that latexmk does its work by running other pro-
+ grams. Your first priority in dealing with errors should be to examine
+ what went wrong with the individual programs. Then you need to correct
+ the causes of errors in the runs of these programs. (Often these come
+ from errors in the source document, but they could also be about miss-
+ ing LaTeX packages, etc.)
+
+ c. If latexmk doesn't run the programs the way you would like, then you
+ need to look in this documentation at the list of command line options
+ and then at the sections on configuration/initialization files. A lot
+ of latexmk's behavior is configurable to deal with particular situa-
+ tions. (But there is a lot of reading!)
+
+
+
+ 18 June 2019 22
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ The remainder of these notes consists of ideas for dealing with more
+ difficult situations.
+
+ d. Further tricks can involve replacing the standard commands that la-
+ texmk runs by other commands or scripts.
+
+ e. For possible examples of code for use in an RC file, see the direc-
+ tory example_rcfiles in the distribution of latexmk (e.g., at
+ http://mirror.ctan.org/support/latexmk/example_rcfiles). Even if these
+ examples don't do what you want, they may provide suitable inspiration.
+
+ f. There's a useful trick that can be used when you use lualatex in-
+ stead of pdflatex (and in some related situations). The problem is
+ that latexmk won't notice a dependency on a file, bar.baz say, that is
+ input by the lua code in your document instead of by the LaTeX part.
+ (Thus if you change bar.baz and rerun latexmk, then latexmk will think
+ no files have changed and not rerun lualatex, whereas if you had '\in-
+ put{bar.baz}' in the LaTeX part of the document, latexmk would notice
+ the change.) One solution is just to put the following somewhere in
+ the LaTeX part of the document:
+
+ \typeout{(bar.baz)}
+
+ This puts a line in the log file that latexmk will treat as implying
+ that the file bar.baz was read. (At present I don't know a way of do-
+ ing this automatically.) Of course, if the file has a different name,
+ change bar.baz to the name of your file.
+
+ g. See also the section "Advanced Configuration: Some extra resources".
+
+ h. Look on tex.stackexchange, i.e., at http://tex.stackex-
+ change.com/questions/tagged/latexmk Someone may have already solved
+ your problem.
+
+ i. Ask a question at tex.stackexchange.com.
+
+ j. Or ask me (the author of latexmk). My e-mail is at the end of this
+ documentation.
+
+
+
+ALLOWING FOR CHANGE OF OUTPUT FILE TYPE
+ When one of the latex engines is run, the usual situation is that latex
+ produces a .dvi file, while pdflatex and lualatex produce a .pdf file.
+ For xelatex the default is to produce a .pdf file, but to optimize pro-
+ cessing time latexmk runs xelatex its -no-pdf option so that it pro-
+ duces an .xdv file. Further processing by latexmk takes this as a
+ starting point.
+
+ However, the actual output file may differ from the normal expectation;
+ and then latexmk can adjust its processing to accommodate this situa-
+ tion. The difference in output file type can happen for two reasons:
+ One is that for latex, pdflatex and lualatex the document itself can
+ override the defaults. The other is that there may be a configuration,
+
+
+
+ 18 June 2019 23
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ or misconfiguration, such that the program that latexmk invokes to com-
+ pile the document is not the expected one, or is given options incom-
+ patible with what latexmk initially expects. (E.g., the -output-for-
+ mat=... option could be used with lualatex, or xelatex gets invoked
+ without the -no-pdf option.)
+
+ Under latex and pdflatex, control of the output format by the document
+ is done by setting the \pdfoutput macro. Under lualatex, the \output-
+ mode macro is used instead.
+
+ One example of an important use-case for document control of the output
+ format is a document that uses the psfrag package to insert graphical
+ elements in the output file. The psfrag package achieves its effects by
+ inserting postscript code in the output of the compilation of the docu-
+ ment. This entails the use of compilation to a .dvi file, followed by
+ the use of conversion to a postscript file (either directly, as by
+ dvips or implicitly, as an intermediate step by dvipdf). Then it is
+ useful to force output to be of the .dvi format by inserting \pdfout-
+ put=0 in the preamble of the document.
+
+ Another example is where the document uses graphics file of the .pdf,
+ .jpg, and png types. With the default setting for the graphicx pack-
+ age, these can be processed in compilation to .pdf but not with compi-
+ lation to .dvi. In this case, it is useful to insert \pdfoutput=1 in
+ the preamble of the document to force compilation to .pdf output for-
+ mat.
+
+ In all of these cases, it is needed that latexmk has to adjust its pro-
+ cessing to deal with a mismatch between the actual output format (out
+ of .pdf, .dvi, .xdv) and the initially expected output, if possible.
+ Latexmk does this provided the following conditions are met.
+
+ The first is that latexmk's $allow_switch configuration variable is set
+ to a non-zero value as it is by default. If this variable is zero, a
+ mismatch of filetypes in the compilation results in an erro.
+
+ The second condition for latexmk to be able to handle a change of out-
+ put type is that no explicit requests for .dvi or .ps output files are
+ made. Explicit requests are by the -dvi and -ps, -print=dvi,
+ -print=ps, -view=dvi, and -view=ps options, and by corresponding set-
+ tings of the $dvi_mode, $postscript_mode, $print_type, and $view con-
+ figuration variables. The print-type and view-type restrictions only
+ apply when printing and viewing are explicitly requested, respectively.
+ For this purpose, the use of the -pdfdvi and -pdfps options (and the
+ corresponding setting of the $pdf_mode variable) does not count as an
+ explicit request for the .dvi and .ps files; they are merely regarded
+ as a request for making a .pdf file together with an initial proposal
+ for the processing route to make it.
+
+ Note that when accommodating a change in output file type, there is in-
+ volved a substantial change in the network of rules that latexmk uses
+ in its actions. The second condition applied to accommodate a change
+ is to avoid situations where the change in the rule network is too rad-
+ ical to be readily handled automatically.
+
+
+
+ 18 June 2019 24
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+CONFIGURATION/INITIALIZATION (RC) FILES
+ In this section is explained which configuration files are read by la-
+ texmk. Subsequent sections "How to Set Variables in Initialization
+ Files", "Format of Command Specifications", "List of Configuration
+ Variables Usable in Initialization Files", "Custom Dependencies", and
+ "Advanced Configuration" give details on what can be configured and
+ how.
+
+ Latexmk can be customized using initialization files, which are read at
+ startup in the following order:
+
+ 1) The system RC file, if it exists.
+ On a UNIX system, latexmk searches for following places for its sys-
+ tem RC file, in the following order, and reads the first it finds:
+ "/opt/local/share/latexmk/LatexMk",
+ "/usr/local/share/latexmk/LatexMk",
+ "/usr/local/lib/latexmk/LatexMk".
+ On a MS-Windows system it looks for "C:\latexmk\LatexMk".
+ On a cygwin system (i.e., a MS-Windows system in which Perl is that
+ of cygwin), latexmk reads the first it finds of
+ "/cygdrive/c/latexmk/LatexMk",
+ "/opt/local/share/latexmk/LatexMk",
+ "/usr/local/share/latexmk/LatexMk",
+ "/usr/local/lib/latexmk/LatexMk".
+
+ In addition, it then tries the same set of locations, but with the file
+ name replaced "LatexMk" replaced by "latexmkrc".
+
+ If the environment variable LATEXMKRCSYS is set, its value is used as
+ the name of the system RC file, instead of any of the above.
+
+ 2) The user's RC file, if it exists. This can be in one of two places.
+ The traditional one is ".latexmkrc" in the user's home directory. The
+ other possibility is "latexmk/latexmkrc" in the user's XDG configura-
+ tion home directory. The actual file read is the first of "$XDG_CON-
+ FIG_HOME/latexmk/latexmkrc" or "$HOME/.latexmkrc" which exists. (See
+ https://specifications.freedesktop.org/basedir-spec/basedir-spec-lat-
+ est.html for details on the XDG Base Directory Specification.)
+
+ Here $HOME is the user's home directory. [Latexmk determines the
+ user's home directory as follows: It is the value of the environment
+ variable HOME, if this variable exists, which normally is the case on
+ UNIX-like systems (including Linux and OS-X). Otherwise the environ-
+ ment variable USERPROFILE is used, if it exists, which normally is the
+ case on MS-Windows systems. Otherwise a blank string is used instead of
+ $HOME, in which case latexmk does not look for an RC file in it.]
+
+ $XDG_CONFIG_HOME is the value of the environment variable XDG_CON-
+ FIG_HOME if it exists. If this environment variable does not exist,
+ but $HOME is non-blank, then $XDG_CONFIG_HOME is set to the default
+ value of $HOME/.config. Otherwise $XDG_CONFIG_HOME is blank, and la-
+ texmk does not look for an RC file under it.
+
+
+
+
+
+ 18 June 2019 25
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ 3) The RC file in the current working directory. This file can be
+ named either "latexmkrc" or ".latexmkrc", and the first of these to be
+ found is used, if any.
+
+ 4) Any RC file(s) specified on the command line with the -r option.
+
+ Each RC file is a sequence of Perl commands. Naturally, a user can use
+ this in creative ways. But for most purposes, one simply uses a se-
+ quence of assignment statements that override some of the built-in set-
+ tings of Latexmk. Straightforward cases can be handled without knowl-
+ edge of the Perl language by using the examples in this document as
+ templates. Comment lines are introduced by the "#" character.
+
+ Note that command line options are obeyed in the order in which they
+ are written; thus any RC file specified on the command line with the -r
+ option can override previous options but can be itself overridden by
+ later options on the command line. There is also the -e option, which
+ allows initialization code to be specified in latexmk's command line.
+
+ For possible examples of code for in an RC file, see the directory ex-
+ ample_rcfiles in the distribution of latexmk (e.g., at http://mir-
+ ror.ctan.org/support/latexmk/example_rcfiles).
+
+
+HOW TO SET VARIABLES IN INITIALIZATION FILES
+ The important variables that can be configured are described in the
+ section "List of configuration variables usable in initialization
+ files". (See the earlier section "Configuration/Initialization (rc)
+ Files" for the files where the configurations are done.) Syntax for
+ setting these variables is of the following forms:
+
+ $bibtex = 'bibtex %O %B';
+
+ for the setting of a string variable,
+
+ $preview_mode = 1;
+
+ for the setting of a numeric variable, and
+
+ @default_files = ('paper', 'paper1');
+
+ for the setting of an array of strings. It is possible to append an
+ item to an array variable as follows:
+
+ push @default_files, 'paper2';
+
+ Note that simple "scalar" variables have names that begin with a $
+ character and array variables have names that begin with a @ character.
+ Each statement ends with a semicolon.
+
+ Strings should be enclosed in single quotes. (You could use double
+ quotes, as in many programming languages. But then the Perl program-
+ ming language brings into play some special rules for interpolating
+ variables into strings. People not fluent in Perl will want to avoid
+
+
+
+ 18 June 2019 26
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ these complications.)
+
+ You can do much more complicated things, but for this you will need to
+ consult a manual for the Perl programming language.
+
+
+
+
+FORMAT OF COMMAND SPECIFICATIONS
+ Some of the variables set the commands that latexmk uses for carrying
+ out its work, for example to generate a .dvi file from a .tex file or
+ to view a postscript file. This section describes some important fea-
+ tures of how the commands are specified. (Note that some of the possi-
+ bilities listed here do not apply to the $kpsewhich variable; see its
+ documentation.)
+
+ Placeholders: Supposed you wanted latexmk to use the command elatex in
+ place of the regular latex command, and suppose moreover that you
+ wanted to give it the option "--shell-escape". You could do this by
+ the following setting:
+
+ $latex = 'elatex --shell-escape %O %S';
+
+ The two items starting with the % character are placeholders. These
+ are substituted by appropriate values before the command is run. Thus
+ %S will be replaced by the source file that elatex will be applied to,
+ and %O will be replaced by any options that latexmk has decided to use
+ for this command. (E.g., if you used the -silent option in the invoca-
+ tion of latexmk, it results in the replacement of %O by "-interac-
+ tion=batchmode".)
+
+ The available placeholders are:
+
+ %A basename of the main tex file. Unlike %R, this is unaffected by
+ the setting of a jobname by the -jobname option or the $jobname
+ configuration value.
+
+ %B base of filename for current command. E.g., if a postscript
+ file document.ps is being made from the dvi file document.dvi,
+ then the basename is document.
+
+ %D destination file (e.g., the name of the postscript file when
+ converting a dvi file to postscript).
+
+ %O options
+
+ %P If the variable $pre_tex_code is non-empty, then %P is substi-
+ tuted by the contents of $pre_tex_code followed by \in-
+ put{SOURCE}, where SOURCE stands for the name of the source
+ file. Appropriate quoting is done. This enables TeX code to be
+ passed to one of the *latex engines to be executed before the
+ source file is read.
+
+ If the variable $pre_tex_code is the empty string, then %P is
+
+
+
+ 18 June 2019 27
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ equivalent to %S.
+
+ %R root filename. This is the base name for the main tex file.
+
+ By default this is the basename of the main tex file. However
+ the value can be changed by the use of the -jobname option or
+ the $jobname configuration variable.
+
+ %S source file (e.g., the name of the dvi file when converting a
+ .dvi file to ps).
+
+ %T The name of the primary tex file.
+
+ %U If the variable $pre_tex_code is non-empty, then its value is
+ substituted for %U (appropriately quoted). Otherwise it is re-
+ placed by a null string.
+
+ %Y Name of directory for auxiliary output files (see the configura-
+ tion variable $aux_dir). A directory separation character ('/')
+ is appended if $aux_dir is non-empty and does not end in a suit-
+ able character, with suitable characters being those appropriate
+ to UNIX and MS-Windows, i.e., ':', '/' and '\'. Note that if
+ after initialization, $out_dir is set, but $aux_dir is not set
+ (i.e., it is blank), then latexmk sets $aux_dir to the same
+ value $out_dir.
+
+ %Z Name of directory for output files (see the configuration vari-
+ able $out_dir). A directory separation character ('/') is ap-
+ pended if $out_dir is non-empty and does not end in a suitable
+ character, with suitable characters being those appropriate to
+ UNIX and MS-Windows, i.e., ':', '/' and '\'.
+
+ If for some reason you need a literal % character in your string not
+ subject to the above rules, use "%%".
+
+ Appropriate quoting will be applied to the filename substitutions, so
+ you mustn't supply them yourself even if the names of your files have
+ spaces in them. (But if your TeX filenames have spaces in them, beware
+ that some older versions of the TeX program cannot correctly handle
+ filenames containing spaces.) In case latexmk's quoting does not work
+ correctly on your system, you can turn it off -- see the documentation
+ for the variable $quote_filenames.
+
+ The distinction between %B and %R needs a bit of care, since they are
+ often the same, but not always. For example on a simple document, the
+ basename of a bibtex run is the same as for the texfile. But in a doc-
+ ument with several bibliographies, the bibliography files will have a
+ variety of names. Since bibtex is invoked with the basename of the
+ bibliography file, the setting for the bibtex command should therefore
+ be
+
+ $bibtex = 'bibtex %O %B';
+
+ Generally, you should use %B rather than %R. Similarly for most
+
+
+
+ 18 June 2019 28
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ purposes, the name %T of the primary texfile is not a useful place-
+ holder.
+
+ See the default values in the section "List of configuration variables
+ usable in initialization files" for what is normally the most appropri-
+ ate usage.
+
+ If you omit to supply any placeholders whatever in the specification of
+ a command, latexmk will supply what its author thinks are appropriate
+ defaults. This gives compatibility with configuration files for previ-
+ ous versions of latexmk, which didn't use placeholders.
+
+ "Detaching" a command: Normally when latexmk runs a command, it waits
+ for the command to run to completion. This is appropriate for commands
+ like latex, of course. But for previewers, the command should normally
+ run detached, so that latexmk gets the previewer running and then re-
+ turns to its next task (or exits if there is nothing else to do). To
+ achieve this effect of detaching a command, you need to precede the
+ command name with "start ", as in
+
+ $dvi_previewer = 'start xdvi %O %S';
+
+ This will be translated to whatever is appropriate for your operating
+ system.
+
+ Notes: (1) In some circumstances, latexmk will always run a command de-
+ tached. This is the case for a previewer in preview continuous mode,
+ since otherwise previewing continuously makes no sense. (2) This pre-
+ cludes the possibility of running a command named start. (3) If the
+ word start occurs more than once at the beginning of the command
+ string, that is equivalent to having just one. (4) Under cygwin, some
+ complications happen, since cygwin amounts to a complicated merging of
+ UNIX and MS-Windows. See the source code for how I've handled the
+ problem.
+
+ Command names containing spaces: Under MS-Windows it is common that the
+ name of a command includes spaces, since software is often installed in
+ a subdirectory of "C:\Program Files". Such command names should be en-
+ closed in double quotes, as in
+
+ $lpr_pdf = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p
+ %S';
+ $pdf_previewer = 'start "c:/Program Files/SumatraPDF/Suma-
+ traPDF.exe" %O %S';
+ $pdf_previewer = 'start "c:/Program Files/SumatraPDF (x86)/Suma-
+ traPDF.exe" %O %S';
+
+
+ (Note about the above example: Under MS-Windows forward slashes are
+ equivalent to backslashes in a filename under almost all circumstances,
+ provided that the filename is inside double quotes. It is easier to
+ use forward slashes in examples like the one above, since then one does
+ not have to worry about the rules for dealing with forward slashes in
+ strings in the Perl language.)
+
+
+
+ 18 June 2019 29
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ Command names under Cygwin: If latexmk is executed by Cygwin's Perl,
+ be particularly certain that pathnames in commands have forward slashes
+ not the usual backslashes for the separator of pathname components.
+ See the above examples. Backslashes often get misinterpreted by the
+ Unix shell used by Cygwin's Perl to execute external commands. Forward
+ slashes don't suffer from this problem, and (when quoted, as above) are
+ equally acceptable to MS-Windows.
+
+ Using MS-Windows file associations: A useful trick under modern ver-
+ sions of MS-Windows (e.g., WinXP) is to use just the command 'start' by
+ itself:
+
+ $dvi_previewer = 'start %S';
+
+ Under MS-Windows, this will cause to be run whatever program the system
+ has associated with dvi files. (The same applies for a postscript
+ viewer and a pdf viewer.) But note that this trick is not always suit-
+ able for the pdf previwer, if your system has acroread for the default
+ pdf viewer. As explained elsewhere, acroread under MS-Windows does not
+ work well with latex and latexmk, because acroread locks the pdf file.
+
+ Not using a certain command: If a command is not to be run, the command
+ name NONE is used, as in
+
+ $lpr = 'NONE lpr';
+
+ This typically is used when an appropriate command does not exist on
+ your system. The string after the "NONE" is effectively a comment.
+
+ Options to commands: Setting the name of a command can be used not only
+ for changing the name of the command called, but also to add options to
+ command. Suppose you want latexmk to use latex with source specials
+ enabled. Then you might use the following line in an initialization
+ file:
+
+ $latex = 'latex --src-specials %O %S';
+
+ Running a subroutine instead of an external command: Use a specifica-
+ tion starting with "internal", as in
+
+ $latex = 'internal mylatex %O %S';
+ sub mylatex {
+ my @args = @_;
+ # Possible preprocessing here
+ return system 'latex', @args;
+ }
+
+ For some of the more exotic possibilities that then become available,
+ see the section "ADVANCED CONFIGURATION: Some extra resources and ad-
+ vanced tricks". Also see some of the examples in the directory exam-
+ ple_rcfiles in the latexmk distribution.
+
+ Advanced tricks: Normally one specifies a single command for the com-
+ mands invoked by latexmk. Naturally, if there is some complicated
+
+
+
+ 18 June 2019 30
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ additional processing you need to do in your special situation, you can
+ write a script (or batch file) to do the processing, and then configure
+ latexmk to use your script in place of the standard program.
+
+ You can also use a Perl subroutine instead of a script -- see above.
+ This is generally the most flexible and portable solution.
+
+ It is also possible to configure latexmk to run multiple commands. For
+ example, if when running pdflatex to generate a pdf file from a tex
+ file you need to run another program after pdflatex to perform some ex-
+ tra processing, you could do something like:
+
+ $pdflatex = 'pdflatex --shell-escape %O %S; pst2pdf_for_latexmk
+ %B';
+
+ This definition assumes you are using a UNIX-like system (which in-
+ cludes Linux and OS-X), so that the two commands to be run are sepa-
+ rated by the semicolon in the middle of the string.
+
+ If you are using MS-Windows, you would replace the above line by
+
+ $pdflatex = 'cmd /c pdflatex --shell-escape %O %S'
+ . '&& pst2pdf_for_latexmk %B';
+
+ Here, the UNIX command separator ; is replaced by &&. In addition,
+ there is a problem that some versions of Perl on MS-Windows do not obey
+ the command separator; this problem is overcome by explicitly invoking
+ the MS-Windows command-line processor cmd.exe.
+
+
+LIST OF CONFIGURATION VARIABLES USABLE IN INITIALIZATION FILES
+ In this section are specified the variables whose values can be ad-
+ justed to configure latexmk. (See the earlier section "Configura-
+ tion/Initialization (rc) Files" for the files where the configurations
+ are done.)
+
+ Default values are indicated in brackets. Note that for variables that
+ are boolean in character, concerning whether latexmk does or does not
+ behave in a certain way, a non-zero value, normally 1, indicates true,
+ i.e., the behavior occurs, while a zero value indicates a false value,
+ i.e., the behavior does not occur.
+
+
+ $allow_switch [1]
+
+ This controls what happens when the output extension of latex,
+ pdflatex, lualatex or xelatex differs from what is expected.
+ (The possible extensions are .dvi, .pdf, .xdv.) This can happen
+ with the use of the \pdfoutput macro in a document compiled un-
+ der latex or pdflatex, or with the use of the \outputmode macro
+ under lualatex. It can also happen with certain kinds of incor-
+ rect configuration.
+
+ In such a case, latexmk can appropriately adjust its network of
+
+
+
+ 18 June 2019 31
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ rules. The adjustment is made if $allow_switch is on, and if no
+ request for a dvi or ps file has been made.
+
+ See the section ALLOWING FOR CHANGE OF OUTPUT EXTENSION.
+
+
+ $always_view_file_via_temporary [0]
+ Whether .ps and .pdf files are initially to be made in a tempo-
+ rary directory and then moved to the final location. (This ap-
+ plies to dvips, dvipdf, and ps2pdf operations, and the filtering
+ operators on .dvi and .ps files. It does not apply to pdflatex,
+ unfortunately, since pdflatex provides no way of specifying a
+ chosen name for the output file.)
+
+ This use of a temporary file solves a problem that the making of
+ these files can occupy a substantial time. If a viewer (notably
+ gv) sees that the file has changed, it may read the new file be-
+ fore the program writing the file has not yet finished its work,
+ which can cause havoc.
+
+ See the $pvc_view_file_via_temporary variable for a setting that
+ applies only if preview-continuous mode (-pvc option) is used.
+ See $tmpdir for the setting of the directory where the temporary
+ file is created.
+
+
+ $analyze_input_log_always [1]
+
+ After a run of latex (etc), always analyze .log for input files
+ in the <...> and (...) constructions. Otherwise, only do the
+ analysis when fls file doesn't exist or is out of date.
+
+ Under normal circumstances, the data in the fls file is reli-
+ able, and the test of the log file gets lots of false positives;
+ usually $analyze_input_log_always is best set to zero. But the
+ test of the log file is needed at least in the following situa-
+ tion: When a user needs to persuade latexmk that a certain file
+ is a source file, and latexmk doesn't otherwise find it. Then
+ the user can write code that causes a line with (...) to be
+ written to log file. One important case is for lualatex, which
+ doesn't always generate lines in the .fls file for input lua
+ files. (The situation with lualatex is HIGHLY version depen-
+ dent, e.g., there was a big change between TeXLive 2016 and
+ TeXLive 2017.)
+
+ To keep backward compatibility with older versions of latexmk,
+ the default is to set $analyze_input_log_always to 1.
+
+
+ $auto_rc_use [1]
+ Whether to automatically read the standard initialization (rc)
+ files, which are the system RC file, the user's RC file, and the
+ RC file in the current directory. The command line option -norc
+ can be used to turn this setting off. Each RC file could also
+
+
+
+ 18 June 2019 32
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ turn this setting off, i.e., it could set $auto_rc_use to zero
+ to prevent automatic reading of the later RC files.
+
+ This variable does not affect the reading of RC files specified
+ on the command line by the -r option.
+
+ $aux_dir [""]
+ The directory in which auxiliary files (aux, log, etc) are to be
+ written by a run of (pdf)latex. If this variable is not set,
+ but $out_dir is set, then $aux_dir is set to $out_dir, which is
+ the directory to which general output files are to be written.
+
+ Important note: The effect of $aux_dir, if different from
+ $out_dir, is achieved by giving (pdf)latex the -aux-directory.
+ Currently (Dec. 2011 and later) this only works on the MiKTeX
+ version of (pdf)latex.
+
+ See also the documentation of $out_dir for some complications on
+ what directory names are suitable.
+
+ If you also use the -cd option, and $out_dir (or $aux_dir) con-
+ tains a relative path, then the path is interpreted relative to
+ the document directory.
+
+ $banner [0]
+ If nonzero, the banner message is printed across each page when
+ converting the dvi file to postscript. Without modifying the
+ variable $banner_message, this is equivalent to specifying the
+ -d option.
+
+ Note that if $banner is nonzero, the $postscript_mode is assumed
+ and the postscript file is always generated, even if it is newer
+ than the dvi file.
+
+ $banner_intensity [0.95]
+ Equivalent to the -bi option, this is a decimal number between 0
+ and 1 that specifies how dark to print the banner message. 0 is
+ black, 1 is white. The default is just right if your toner car-
+ tridge isn't running too low.
+
+ $banner_message ["DRAFT"]
+ The banner message to print across each page when converting the
+ dvi file to postscript. This is equivalent to the -bm option.
+
+ $banner_scale [220.0]
+ A decimal number that specifies how large the banner message
+ will be printed. Experimentation is necessary to get the right
+ scale for your message, as a rule of thumb the scale should be
+ about equal to 1100 divided by the number of characters in the
+ message. The Default is just right for 5 character messages.
+ This is equivalent to the -bs option.
+
+ @BIBINPUTS
+ This is an array variable, now mostly obsolete, that specifies
+
+
+
+ 18 June 2019 33
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ directories where latexmk should look for .bib files. By de-
+ fault it is set from the BIBINPUTS environment variable of the
+ operating system. If that environment variable is not set, a
+ single element list consisting of the current directory is set.
+ The format of the directory names depends on your operating sys-
+ tem, of course. Examples for setting this variable are:
+
+ @BIBINPUTS = ( ".", "C:\\bibfiles" );
+ @BIBINPUTS = ( ".", "\\server\bibfiles" );
+ @BIBINPUTS = ( ".", "C:/bibfiles" );
+ @BIBINPUTS = ( ".", "//server/bibfiles" );
+ @BIBINPUTS = ( ".", "/usr/local/texmf/bibtex/bib" );
+
+ Note that under MS Windows, either a forward slash "/" or a
+ backward slash "\" can be used to separate pathname components,
+ so the first two and the second two examples are equivalent.
+ Each backward slash should be doubled to avoid running afoul of
+ Perl's rules for writing strings.
+
+ Important note: This variable is now mostly obsolete in the cur-
+ rent version of latexmk, since it has a better method of search-
+ ing for files using the kpsewhich command. However, if your
+ system is an unusual one without the kpsewhich command, you may
+ need to set the variable @BIBINPUTS.
+
+ $biber ["biber %O %S"]
+ The biber processing program.
+
+ $biber_silent_switch ["--onlylog"]
+ Switch(es) for the biber processing program when silent mode is
+ on.
+
+ $bibtex ["bibtex %O %S"]
+ The BibTeX processing program.
+
+ $bibtex_fudge [1]
+ When using bibtex, whether to take special action to allow bib-
+ tex to work when $out_dir or $aux_dir is specified. In May
+ 2018, there was planned an update to bibtex to correct a bug,
+ after that update, the special action will no longer be re-
+ quired.
+
+ $bibtex_silent_switch ["-terse"]
+ Switch(es) for the BibTeX processing program when silent mode is
+ on.
+
+ $bibtex_use [1]
+ Under what conditions to run bibtex or biber. When latexmk dis-
+ covers from the log file that one (or more) bibtex/biber-gener-
+ ated bibliographies are used, it can run bibtex or biber when-
+ ever it appears necessary to regenerate the bbl file(s) from
+ their source bib database file(s). But sometimes, the bib
+ file(s) are not available (e.g., for a document obtained from an
+ external archive), but the bbl files are provided. In that case
+
+
+
+ 18 June 2019 34
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ use of bibtex or biber will result in incorrect overwriting of
+ the precious bbl files. The variable $bibtex_use controls
+ whether this happens, and also controls whether or not .bbl
+ files are deleted in a cleanup operation.
+
+ The possible values of $bibtex_use are:
+ 0: never use BibTeX or biber; never delete .bbl files in a
+ cleanup.
+ 1: only use bibtex or biber if the bib files exist; never
+ delete .bbl files in a cleanup.
+ 1.5: only use bibtex or biber if the bib files exist; condi-
+ tionally delete .bbl files in a cleanup (i.e., delete them only
+ when the bib files all exist).
+ 2: run bibtex or biber whenever it appears necessary to update
+ the bbl files, without testing for the existence of the bib
+ files; always delete .bbl files in a cleanup.
+
+ Note that the value 1.5 does not work properly if the document
+ uses biber instead of bibtex. (There's a long story why not.)
+
+
+ $cleanup_includes_cusdep_generated [0]
+ If nonzero, specifies that cleanup also deletes files that are
+ generated by custom dependencies. (When doing a clean up, e.g.,
+ by use of the -C option, custom dependencies are those listed in
+ the .fdb_latexmk file from a previous run.)
+
+ $cleanup_includes_generated [0]
+ If nonzero, specifies that cleanup also deletes files that are
+ detected in the fls file (or failing that, in log file) as being
+ generated. It will also include files made from these first
+ generation generated files.
+
+ This operation is somewhat dangerous, and can have unintended
+ consequences, since the files to be deleted are determined from
+ a file created by (pdf)latex, which can contain erroneous infor-
+ mation. Therefore this variable is turned off by default, and
+ then files to be deleted are restricted to those explictly spec-
+ ified by patterns configured in the variables clean_ext,
+ clean_full_ext, and @generated_exts, together with those very
+ standard cases that are hardwired into latexmk (e.g., .log
+ files).
+
+ $cleanup_mode [0]
+ If nonzero, specifies cleanup mode: 1 for full cleanup, 2 for
+ cleanup except for .dvi, .ps and .pdf files, 3 for cleanup ex-
+ cept for dep and aux files. (There is also extra cleaning as
+ specified by the $clean_ext, $clean_full_ext and @generated_exts
+ variables.)
+
+ This variable is equivalent to specifying one of the -c or -C
+ options. But there should be no need to set this variable from
+ an RC file.
+
+
+
+
+ 18 June 2019 35
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ $clean_ext [""]
+ Extra extensions of files for latexmk to remove when any of the
+ clean-up options (-c or -C) is selected. The value of this
+ variable is a string containing the extensions separated by spa-
+ ces.
+
+ It is also possible to specify a more general pattern of file to
+ be deleted, by using the place holder %R, as in commands, and it
+ is also possible to use wildcards. Thus setting
+
+ $clean_ext = "out %R-blx.bib %R-figures*.log pythontex-
+ files-%R/*";
+
+ in an initialization file will imply that when a clean-up opera-
+ tion is specified, not only is the standard set of files
+ deleted, but also files of the form FOO.out, FOO-blx.bib, %R-
+ figures*.log, and pythontex-files-FOO/*, where FOO stands for
+ the basename of the file being processed (as in FOO.tex).
+
+ The files to be deleted are relative to the directory specified
+ by $aux_dir. (Note that if $out_dir but not $aux_dir is set,
+ then in its initialization, latexmk sets $aux_dir equal to
+ $out_dir. A normal situation is therefore that $aux_dir equals
+ $out_dir, which is the only case supported by TeXLive, unlike
+ MiKTeX.)
+
+ The filenames specfied for a clean-up operation can refer not
+ only to regular files but also to directories. Directories are
+ only deleted if they are empty. An example of an application is
+ to pythontex, which creates files in a particular directory.
+ You can arrange to remove both the files and the directory by
+ setting
+
+ $clean_ext = "pythontex-files-%R pythontex-files-%R";
+
+ See also the variable @generated_exts.
+
+ $clean_full_ext [""]
+ Extra extensions of files for latexmk to remove when the -C op-
+ tion is selected, i.e., extensions of files to remove when the
+ .dvi, etc files are to be cleaned-up.
+
+ More general patterns are allowed, as for $clean_ext.
+
+ The files specified by $clean_full_ext to be deleted are rela-
+ tive to the directory specified by $out_dir.
+
+
+ $compiling_cmd [""], $failure_cmd [""], $warning_cmd [""], $success_cmd
+ [""]
+
+ These variables specify commands that are executed at certain
+ points of compilations during preview-continuous mode. One mo-
+ tivation for their existance is to allow very useful convenient
+
+
+
+ 18 June 2019 36
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ visual indications of compilation status even when the window
+ receiving the screen output of the compilation is hidden.
+
+ The commands are executed at the following points: $compil-
+ ing_cmd at the start of compilation, $success_cmd at the end of
+ a completely successful compilation, $failure_cmd at the end of
+ an unsuccessful compilation, $warning_cmd at the of an otherwise
+ successful compilation that gives warnings about undefined cita-
+ tions or references or about multiply defined references. If any
+ of above variables is undefined or blank (the default situa-
+ tion), then the corresponding command is not executed.
+
+ However, when $warning_cmd is not set, then in the case of a
+ compilation with warnings about references or citations, but
+ with no other error, one or other of $success_cmd or $fail-
+ ure_cmd is used (if it is set) according to the setting of
+ $warnings_as_errors.
+
+ An example of a simple setting of these variables is as follows
+
+ $compiling_cmd = "xdotool search --name \"%D\" set_window
+ --name \"%D compiling\"";
+ $success_cmd = "xdotool search --name \"%D\" set_window
+ --name \"%D OK\"";
+ $warning_cmd = "xdotool search --name \"%D\" ".
+ "set_window --name \"%D CITE/REF ISSUE\"";
+ $failure_cmd = "xdotool search --name \"%D\" set_window
+ --name \"%D FAILURE\"";
+
+ These assume that the program xdotool is installed, that the
+ previewer is using an X-Window system for display, and that the
+ title of the window contains the name of the displayed file, as
+ it normally does. When the commands are executed, the place-
+ holder string %D is replaced by the name of the destination
+ file, which is the previewed file. The above commands result in
+ an appropriate string being appended to the filename in the win-
+ dow title: " compiling", " OK", or " FAILURE".
+
+ Other placeholders that can be used are %S, %T, and %R, with %S
+ and %T normally being identical. These can be useful for a com-
+ mand changing the title of the edit window. The visual indica-
+ tion in a window title can useful, since the user does not have
+ to keep shifting attention to the (possibly hidden) compilation
+ window to know the status of the compilation.
+
+ More complicated situations can best be handled by defining a
+ Perl subroutine to invoke the necessary commands, and using the
+ "internal" keyword in the definitions to get the subroutine to
+ be invoked. (See the section "Format of Command Specifications"
+ for how to do this.)
+
+ Naturally, the above settings that invoke the xdotool program
+ are only applicable when the X-Window system is used for the
+ relevant window(s). For other cases, you will have to find what
+
+
+
+ 18 June 2019 37
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ software solutions are available.
+
+
+ @cus_dep_list [()]
+ Custom dependency list -- see section on "Custom Dependencies".
+
+ @default_excluded_files [()]
+ When latexmk is invoked with no files specified on the command
+ line, then, by default, it will process all files in the current
+ directory with the extension .tex. (In general, it will process
+ the files specified in the @default_files variable.)
+
+ But sometimes you want to exclude particular files from this de-
+ fault list. In that case you can specify the excluded files in
+ the array @default_excluded_files. For example if you wanted to
+ process all .tex files with the exception of common.tex, which
+ is a not a standard alone LaTeX file but a file input by some or
+ all of the others, you could do
+
+ @default_files = ("*.tex");
+
+ @default_excluded_files = ("common.tex");
+
+ If you have a variable or large number of files to be processed,
+ this method saves you from having to list them in detail in @de-
+ fault_files and having to update the list every time you change
+ the set of files to be processed.
+
+ Notes: 1. This variable has no effect except when no files are
+ specified on the latexmk command line. 2. Wildcards are allowed
+ in @default_excluded_files.
+
+ @default_files [("*.tex")]
+ Default list of files to be processed.
+
+ If no filenames are specified on the command line, latexmk pro-
+ cesses all tex files specified in the @default_files variable,
+ which by default is set to all tex files ("*.tex") in the cur-
+ rent directory. This is a convenience: just run latexmk and it
+ will process an appropriate set of files. But sometimes you
+ want only some of these files to be processed. In this case you
+ can list the files to be processed by setting @default_files in
+ an initialization file (e.g., the file "latexmkrc" in the cur-
+ rent directory). Then if no files are specified on the command
+ line then the files you specify by setting @default_files are
+ processed.
+
+ Three examples:
+
+ @default_files = ("paper_current");
+
+ @default_files = ("paper1", "paper2.tex");
+
+ @default_files = ("*.tex", "*.dtx");
+
+
+
+ 18 June 2019 38
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ Note that more than file may be given, and that the default ex-
+ tension is ".tex". Wild cards are allowed. The parentheses are
+ because @default_files is an array variable, i.e., a sequence of
+ filename specifications is possible.
+
+ If you want latexmk to process all .tex files with a few excep-
+ tions, see the @default_excluded_files array variable.
+
+ $dependents_phony [0]
+ If a list of dependencies is output, this variable determines
+ whether to include a phony target for each source file. If you
+ use the dependents list in a Makefile, the dummy rules work
+ around errors make gives if you remove header files without up-
+ dating the Makefile to match.
+
+ $dependents_list [0]
+ Whether to display a list(s) of dependencies at the end of a
+ run.
+
+ $deps_file ["-"]
+ Name of file to receive list(s) of dependencies at the end of a
+ run, to be used if $dependesnt_list is set. If the filename is
+ "-", then the dependency list is set to stdout (i.e., normally
+ the screen).
+
+ $do_cd [0]
+ Whether to change working directory to the directory specified
+ for the main source file before processing it. The default be-
+ havior is not to do this, which is the same as the behavior of
+ latex and pdflatex programs. This variable is set by the -cd
+ and -cd- options on latexmk's command line.
+
+ $dvi_filter [empty]
+ The dvi file filter to be run on the newly produced dvi file be-
+ fore other processing. Equivalent to specifying the -dF option.
+
+ $dvi_mode [See below for default]
+ If nonzero, generate a dvi version of the document. Equivalent
+ to the -dvi option.
+
+ The variable $dvi_mode defaults to 0, but if no explicit re-
+ quests are made for other types of file (postscript, pdf), then
+ $dvi_mode will be set to 1. In addition, if a request for a
+ file for which a .dvi file is a prerequisite, then $dvi_mode
+ will be set to 1.
+
+ $dvi_previewer ["start xdvi %O %S" under UNIX]
+ The command to invoke a dvi-previewer. [Under MS-Windows the
+ default is "start"; then latexmk arranges to use the MS-Windows
+ start program, which will cause to be run whatever command the
+ system has associated with .dvi files.]
+
+ Important note: Normally you will want to have a previewer run
+ detached, so that latexmk doesn't wait for the previewer to
+
+
+
+ 18 June 2019 39
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ terminate before continuing its work. So normally you should
+ prefix the command by "start ", which flags to latexmk that it
+ should do the detaching of the previewer itself (by whatever
+ method is appropriate to the operating system). But sometimes
+ letting latexmk do the detaching is not appropriate (for a vari-
+ ety of non-trivial reasons), so you should put the "start " bit
+ in yourself, whenever it is needed.
+
+ $dvi_previewer_landscape ["start xdvi %O %S"]
+ The command to invoke a dvi-previewer in landscape mode. [Under
+ MS-Windows the default is "start"; then latexmk arranges to use
+ the MS-Windows start program, which will cause to be run what-
+ ever command the system has associated with .dvi files.]
+
+ $dvipdf ["dvipdf %O %S %D"]
+ Command to convert .dvi to .pdf file. A common reconfiguration
+ is to use the dvipdfm command, which needs its arguments in a
+ different order:
+
+ $dvipdf = "dvipdfm %O -o %D %S";
+
+ WARNING: The default dvipdf script generates pdf files with
+ bitmapped fonts, which do not look good when viewed by acroread.
+ That script should be modified to give dvips the options "-P
+ pdf" to ensure that type 1 fonts are used in the pdf file.
+
+ $dvipdf_silent_switch ["-q"]
+ Switch(es) for dvipdf program when silent mode is on.
+
+ N.B. The standard dvipdf program runs silently, so adding the
+ silent switch has no effect, but is actually innocuous. But if
+ an alternative program is used, e.g., dvipdfmx, then the silent
+ switch has an effect. The default setting is correct for
+ dvipdfm and dvipdfmx.
+
+ $dvips ["dvips %O -o %D %S"]
+ The program to used as a filter to convert a .dvi file to a .ps
+ file. If pdf is going to be generated from pdf, then the value
+ of the $dvips_pdf_switch variable -- see below -- will be in-
+ cluded in the options substituted for "%O".
+
+ $dvips_landscape ["dvips -tlandscape %O -o %D %S"]
+ The program to used as a filter to convert a .dvi file to a .ps
+ file in landscape mode.
+
+ $dvips_pdf_switch ["-P pdf"]
+ Switch(es) for dvips program when pdf file is to be generated
+ from .ps file.
+
+ $dvips_silent_switch ["-q"]
+ Switch(es) for dvips program when silent mode is on.
+
+ $dvi_update_command [""]
+ When the dvi previewer is set to be updated by running a
+
+
+
+ 18 June 2019 40
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ command, this is the command that is run. See the information
+ for the variable $dvi_update_method for further information, and
+ see information on the variable $pdf_update_method for an exam-
+ ple for the analogous case of a pdf previewer.
+
+ $dvi_update_method [2 under UNIX, 1 under MS-Windows]
+ How the dvi viewer updates its display when the dvi file has
+ changed. The values here apply equally to the $pdf_up-
+ date_method and to the $ps_update_method variables.
+ 0 => update is automatic,
+ 1=> manual update by user, which may only mean a mouse click
+ on the viewer's window or may mean a more serious action.
+ 2 => Send the signal, whose number is in the variable
+ $dvi_update_signal. The default value under UNIX is suitable
+ for xdvi.
+ 3 => Viewer cannot do an update, because it locks the file.
+ (As with acroread under MS-Windows.)
+ 4 => run a command to do the update. The command is speci-
+ fied by the variable $dvi_update_command.
+
+ See information on the variable $pdf_update_method for an exam-
+ ple of updating by command.
+
+ $dvi_update_signal [Under UNIX: SIGUSR1, which is a system-dependent
+ value]
+ The number of the signal that is sent to the dvi viewer when it
+ is updated by sending a signal -- see the information on the
+ variable $dvi_update_method. The default value is the one ap-
+ propriate for xdvi on a UNIX system.
+
+ $failure_cmd [undefined]
+ See the documentation for $compiling_cmd.
+
+ $fdb_ext ["fdb_latexmk"]
+ The extension of the file which latexmk generates to contain a
+ database of information on source files. You will not normally
+ need to change this.
+
+ $filetime_causality_threshold [5]; $filetime_offset_report_threshold
+ [30]. (Units of seconds.)
+
+ These variables control how latexmk deals with the following is-
+ sue, which can affect the use of files that are on a remote
+ filesystem (network share) instead of being on a file system lo-
+ cal to the computer running latexmk. Almost users will not have
+ to worry about these settings, and can ignore the following ex-
+ planation.
+
+ In almost all situations, latexmk does not need to use the time
+ stamps of the files it works with. However, there are a couple
+ of situations when it needs to know whether a certain file was
+ created in the current run of a program (e.g., (pdf)latex) or is
+ a leftover file from a previous run. It does this by comparing
+ the modification time of the file with the system time just
+
+
+
+ 18 June 2019 41
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ before the program was started. If the modification time is ear-
+ lier than when the program was started, the file is a leftover
+ file, which latexmk treats as if it were not created. If the
+ filetime is at least the program start time, then it can be as-
+ sumed that the file was created in the current run.
+
+ Unfortunately, this test can fail if the file is on a remote
+ system, since its system time is not necessarily synchronized
+ with that of the local system; the timestamps on the remote
+ files are set by the remote system, not the local system. Gen-
+ erally, modern operating systems regularly synchronize their
+ time with a server, so the non-synchronization is mostly small
+ (a second or so, or a few seconds). But even a small difference
+ can mess up latexmk's test.
+
+ Latexmk measures the time difference between the time on the two
+ systems and compensates for this. But the measurement (in a
+ system-independent way) is only accurate to a second or two. So
+ latexmk allows for a threshold on the difference between file
+ and system time before it concludes that a file is a leftover
+ file from a previous run. The configuration variable $file-
+ time_causality_theshhold, which in units of seconds, specifies
+ this threshold. Luckily high precision is not needed. The pre-
+ vious run is normally the previous run in a human run-edit-run
+ cycle, and is at least many seconds back. A few seconds is
+ therefore appropriate for the threshold, $filetime_causal-
+ ity_theshhold; it should be non-negative always, and should be
+ bigger than 2 if a remote filesystem or network share is used.
+
+ If the difference in system times on the two systems is large,
+ it normally indicates that at least one of the systems is mis-
+ configured. The variable $filetime_offset_report_threshold
+ specifies the smallest size of the difference (or offset) in
+ seconds between the times of the local and remote system beyond
+ which the offset is reported. This is reported at the point in
+ the latexmk's progress that it measures the offset. The report
+ is made if silent mode is used and diagnostic mode is not on.
+
+
+ $force_mode [0]
+ If nonzero, continue processing past minor latex errors includ-
+ ing unrecognized cross references. Equivalent to specifying the
+ -f option.
+
+ @generated_exts [( aux , bbl , idx , ind , lof , lot , out , toc ,
+ $fdb_ext )]
+ This contains a list of extensions for files that are generated
+ during a LaTeX run and that are read in by LaTeX in later runs,
+ either directly or indirectly.
+
+ This list specifies files known to be generated by latex (and
+ pdflatex, etc). It is used in two ways: (a) The specified files
+ are deleted in a cleanup operation (with the -c, -C, -CA, -g and
+ -gg options), and (b) It affects the determination of whether a
+
+
+
+ 18 June 2019 42
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ rerun of (pdf)LaTeX is needed after a run that gives an error.
+
+ (Concerning item (b): Normally, a change of a source file during
+ a run should provoke a rerun. This includes a file generated by
+ LaTeX, e.g., an aux file, that is read in on subsequent runs.
+ But after a run that results in an error, a new run should not
+ occur until the user has made a change in the files. But the
+ user may have corrected an error in a source .tex file during
+ the run. So latexmk needs to distinguish user-generated and au-
+ tomatically generated files; it determines the automatically
+ generated files as those with extensions in the list in @gener-
+ ated_exts.)
+
+ A convenient way to add an extra extension to the list, without
+ losing the already defined ones is to use a push command in the
+ line in an RC file. E.g.,
+
+ push @generated_exts, "end";
+
+ adds the extension "end" to the list of predefined generated ex-
+ tensions. (This extension is used by the RevTeX package, for
+ example.)
+
+ $go_mode [0]
+ If nonzero, process files regardless of timestamps, and is then
+ equivalent to the -g option.
+
+ %hash_calc_ignore_pattern
+ !!!This variable is for experts only!!!
+
+ The general rule latexmk uses for determining when an extra run
+ of some program is needed is that one of the source files has
+ changed. But consider for example a latex package that causes
+ an encapsulated postscript file (an "eps" file) to be made that
+ is to be read in on the next run. The file contains a comment
+ line giving its creation date and time. On the next run the
+ time changes, latex sees that the eps file has changed, and
+ therefore reruns latex. This causes an infinite loop, that is
+ only terminated because latexmk has a limit on the number of
+ runs to guard against pathological situations.
+
+ But the changing line has no real effect, since it is a comment.
+ You can instruct latex to ignore the offending line as follows:
+
+ $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: ';
+
+ This creates a rule for files with extension .eps about lines to
+ ignore. The left-hand side is a Perl idiom for setting an item
+ in a hash. Note that the file extension is specified without a
+ period. The value, on the right-hand side, is a string contain-
+ ing a regular expresssion. (See documentation on Perl for how
+ they are to be specified in general.) This particular regular
+ expression specifies that lines beginning with "%%CreationDate:
+ " are to be ignored in deciding whether a file of the given
+
+
+
+ 18 June 2019 43
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ extension .eps has changed.
+
+ There is only one regular expression available for each exten-
+ sion. If you need more one pattern to specify lines to ignore,
+ then you need to combine the patterns into a single regular ex-
+ pression. The simplest method is separate the different simple
+ patterns by a vertical bar character (indicating "alternation"
+ in the jargon of regular expressions). For example,
+
+ $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: |^%%Ti-
+ tle: ';
+
+ causes lines starting with either "^%%CreationDate: " or "^%%Ti-
+ tle: " to be ignored.
+
+ It may happen that a pattern to be ignored is specified in, for
+ example, in a system or user initialization file, and you wish
+ to remove this in a file that is read later. To do this, you
+ use Perl's delete function, e.g.,
+
+ delete $hash_calc_ignore_pattern{'eps'};
+
+
+ $jobname [""]
+
+ This specifies the jobname, i.e., the basename that is used for
+ generated files (.aux, .log, .dvi, .ps, .pdf, etc). If this
+ variable is a null string, then the basename is the basename of
+ the main tex file. (At present, the string in $jobname should
+ not contain spaces.)
+
+ The placeholder '%A' is permitted. This will be substituted by
+ the basename of the TeX file. The primary purpose is when a va-
+ riety of tex files are to be processed, and you want to use a
+ different jobname for each but one that is distinct for each.
+ Thus if you wanted to compare compilations of a set of files on
+ different operating systems, with distinct filenames for all the
+ cases, you could set
+
+ $jobname = "%A-$^O";
+
+ in an initialization file. (Here $^O is a variable provided by
+ perl that contains perl's name for the operating system.)
+
+ Suppose you had .tex files test1.tex and test2.tex. Then when
+ you run
+
+ latexmk -pdf *.tex
+
+ both files will be compiled. The .aux, .log, and .pdf files
+ will have basenames test1-MSWin32 ante test2-MSWin32 on a MS-
+ Windows system, test1-darwin and test2-darwin on an OS-X system,
+ and a variety of similar cases on linux systems.
+
+
+
+
+ 18 June 2019 44
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ $kpsewhich ["kpsewhich %S"]
+ The program called to locate a source file when the name alone
+ is not sufficient. Most filenames used by latexmk have suffi-
+ cient path information to be found directly. But sometimes, no-
+ tably when a .bib or a .bst file is found from the log file of a
+ bibtex or biber run, only the base name of the file is known,
+ but not its path. The program specified by $kpsewhich is used to
+ find it.
+
+ (For advanced users: Because of the different way in which la-
+ texmk uses the command specified in $kpsewhich, some of the pos-
+ sibilities listed in the FORMAT OF COMMAND SPECIFICATIONS do not
+ apply. The internal and start keywords are not available. A
+ simple command specification with possible options and then "%S"
+ is all that is guaranteed to work. Note that for other com-
+ mands, "%S" is substituted by a single source file. In contrast,
+ for $kpsewhich, "%S" may be substituted by a long list of space-
+ separated filenames, each of which is quoted. The result on
+ STDOUT of running the command is then piped to latexmk.)
+
+ See also the @BIBINPUTS variable for another way that latexmk
+ also uses to try to locate files; it applies only in the case of
+ .bib files.
+
+ $kpsewhich_show [0]
+ Whether to show diagnostics about invocations of kpsewhich: the
+ command line use to invoke it and the results. These diagnos-
+ tics are shown if $kpsewhich_show is non-zero or if diagnostics
+ mode is on. (But in the second case, lots of other diagnostics
+ are also shown.) Without these diagnostics there is nothing
+ visible in latexmk's screen output about invocations of kpse-
+ which.
+
+ $landscape_mode [0]
+ If nonzero, run in landscape mode, using the landscape mode pre-
+ viewers and dvi to postscript converters. Equivalent to the -l
+ option. Normally not needed with current previewers.
+
+ $latex ["latex %O %S"]
+ Specifies the command line for the LaTeX processing program.
+ Note that as with other programs, you can use this variable not
+ just to change the name of the program used, but also specify
+ options to the program. E.g.,
+
+ $latex = "latex --src-specials %O %S";
+
+ To do a coordinated setting of all of $latex, $pdflatex, $luala-
+ tex, and $xelatex, see the section "Advanced Configuration".
+
+
+ %latex_input_extensions
+ This variable specifies the extensions tried by latexmk when it
+ finds that a LaTeX run resulted in an error that a file has not
+ been found, and the file is given without an extension. This
+
+
+
+ 18 June 2019 45
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ typically happens when LaTeX commands of the form \input{file}
+ or \includegraphics{figure}, when the relevant source file does
+ not exist.
+
+ In this situation, latexmk searches for custom dependencies to
+ make the missing file(s), but restricts it to the extensions
+ specified by the variable %latex_input_extensions. The default
+ extensions are 'tex' and 'eps'.
+
+ (For Perl experts: %latex_input_extensions is a hash whose keys
+ are the extensions. The values are irrelevant.) Two subrou-
+ tines are provided for manipulating this and the related vari-
+ able %pdflatex_input_extensions, add_input_ext and remove_in-
+ put_ext. They are used as in the following examples are possi-
+ ble lines in an initialization file:
+
+ remove_input_ext( 'latex', 'tex' );
+
+ removes the extension 'tex' from latex_input_extensions
+
+ add_input_ext( 'latex', 'asdf' );
+
+ add the extension 'asdf to latex_input_extensions. (Naturally
+ with such an extension, you should have made an appropriate cus-
+ tom dependency for latexmk, and should also have done the appro-
+ priate programming in the LaTeX source file to enable the file
+ to be read. The standard extensions are handled by LaTeX and
+ its graphics/graphicx packages.)
+
+ $latex_silent_switch ["-interaction=batchmode"]
+ Switch(es) for the LaTeX processing program when silent mode is
+ on.
+
+ If you use MikTeX, you may prefer the results if you configure
+ the options to include -c-style-errors, e.g., by the following
+ line in an initialization file
+
+ $latex_silent_switch = "-interaction=batchmode -c-style-er-
+ rors";
+
+
+ $lpr ["lpr %O %S" under UNIX/Linux, "NONE lpr" under MS-Windows]
+ The command to print postscript files.
+
+ Under MS-Windows (unlike UNIX/Linux), there is no standard pro-
+ gram for printing files. But there are ways you can do it. For
+ example, if you have gsview installed, you could use it with the
+ option "/p":
+
+ $lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p';
+
+ If gsview is installed in a different directory, you will need
+ to make the appropriate change. Note the combination of single
+ and double quotes around the name. The single quotes specify
+
+
+
+ 18 June 2019 46
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ that this is a string to be assigned to the configuration vari-
+ able $lpr. The double quotes are part of the string passed to
+ the operating system to get the command obeyed; this is neces-
+ sary because one part of the command name ("Program Files") con-
+ tains a space which would otherwise be misinterpreted.
+
+ $lpr_dvi ["NONE lpr_dvi"]
+ The printing program to print dvi files.
+
+ $lpr_pdf ["NONE lpr_pdf"]
+ The printing program to print pdf files.
+
+ Under MS-Windows you could set this to use gsview, if it is in-
+ stalled, e.g.,
+
+ $lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p';
+
+ If gsview is installed in a different directory, you will need
+ to make the appropriate change. Note the double quotes around
+ the name: this is necessary because one part of the command name
+ ("Program Files") contains a space which would otherwise be mis-
+ interpreted.
+
+ $lualatex ["lualatex %O %S"]
+ Specifies the command line for the LaTeX processing program that
+ is to be used when the lualatex program is called for (e.g., by
+ the option -lualatex.
+
+ To do a coordinated setting of all of $latex, $pdflatex, $luala-
+ tex, and $xelatex, see the section "Advanced Configuration".
+
+
+ %lualatex_input_extensions
+ This variable specifies the extensions tried by latexmk when it
+ finds that a lualatex run resulted in an error that a file has
+ not been found, and the file is given without an extension.
+ This typically happens when LaTeX commands of the form \in-
+ put{file} or \includegraphics{figure}, when the relevant source
+ file does not exist.
+
+ In this situation, latexmk searches for custom dependencies to
+ make the missing file(s), but restricts it to the extensions
+ specified by the variable %pdflatex_input_extensions. The de-
+ fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
+
+ See details of the %latex_input_extensions for other information
+ that equally applies to %lualatex_input_extensions.
+
+ $lualatex_silent_switch ["-interaction=batchmode"]
+ Switch(es) for the lualatex program (specified in the variable
+ $lualatex) when silent mode is on.
+
+ See details of the $latex_silent_switch for other information
+ that equally applies to $lualatex_silent_switch.
+
+
+
+ 18 June 2019 47
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ $make ["make"]
+ The make processing program.
+
+ $makeindex ["makeindex %O -o %D %S"]
+ The index processing program.
+
+ $makeindex_silent_switch ["-q"]
+ Switch(es) for the index processing program when silent mode is
+ on.
+
+ $max_repeat [5]
+ The maximum number of times latexmk will run latex/pdflatex be-
+ fore deciding that there may be an infinite loop and that it
+ needs to bail out, rather than rerunning latex/pdflatex again to
+ resolve cross-references, etc. The default value covers all
+ normal cases.
+
+ (Note that the "etc" covers a lot of cases where one run of la-
+ tex/pdflatex generates files to be read in on a later run.)
+
+ $MSWin_back_slash [1]
+ This configuration variable only has an effect when latexmk is
+ running under MS-Windows. It determines whether, when a command
+ is executed under MS-Windows, there should be substituted "\"
+ for the separator character between components of a directory
+ name. Internally, latexmk uses "/" for the directory separator
+ character, which is the character used by Unix-like systems.
+
+ For many programs under MS-Windows, both "\" and "/" are accept-
+ able as the directory separator character. But some programs
+ only accept "\" on the command line. So for safety latexmk
+ makes a translation, by default. It is conceivable that under
+ certain situations this is undesirable, so the configuration can
+ be changed. (A possible example might be when some of the soft-
+ ware is implemented using Cygwin, which provides a Unix-like en-
+ vironment inside MS-Windows.)
+
+ $new_viewer_always [0]
+ This variable applies to latexmk only in continuous-preview
+ mode. If $new_viewer_always is 0, latexmk will check for a pre-
+ viously running previewer on the same file, and if one is run-
+ ning will not start a new one. If $new_viewer_always is non-
+ zero, this check will be skipped, and latexmk will behave as if
+ no viewer is running.
+
+ $out_dir [""]
+ If non-blank, this variable specifies the directory in which
+ output files are to be written by a run of (pdf)latex. See also
+ the variable $aux_dir.
+
+ The effect of this variable (when non-blank) is achieved by us-
+ ing the -output-directory option of (pdf)latex. This exists in
+ the usual current (Dec. 2011 and later) implementations of TeX,
+ i.e., MiKTeX and TeXLive. But it may not be present in other
+
+
+
+ 18 June 2019 48
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ versions.
+
+ If you also use the -cd option, and $out_dir (or $aux_dir) con-
+ tains a relative path, then the path is interpreted relative to
+ the document directory.
+
+ Commonly, the directory specified for output files is a subdi-
+ rectory of the current working directory. However, if you spec-
+ ify some other directory, e.g., "/tmp/foo" or "../output", be
+ aware that this could cause problems, e.g., with makeindex or
+ bibtex. This is because modern versions of these programs, by
+ default, will refuse to work when they find that they are asked
+ to write to a file in a directory that appears not to be the
+ current working directory or one of its subdirectories. This is
+ part of security measures by the whole TeX system that try to
+ prevent malicious or errant TeX documents from incorrectly mess-
+ ing with a user's files. If for $out_dir or $aux_dir you really
+ do need to specify an absolute pathname (e.g., "/tmp/foo") or a
+ path (e.g., "../output") that includes a higher-level directory,
+ and you need to use makeindex or bibtex, then you need to dis-
+ able the security measures (and assume any risks). One way of
+ doing this is to temporarily set an operating system environment
+ variable openout_any to "a" (as in "all"), to override the de-
+ fault "paranoid" setting.
+
+ $pdf_mode [0]
+ If zero, do NOT generate a pdf version of the document. If
+ equal to 1, generate a pdf version of the document using pdfla-
+ tex, using the command specified by the $pdflatex variable. If
+ equal to 2, generate a pdf version of the document from the ps
+ file, by using the command specified by the $ps2pdf variable.
+ If equal to 3, generate a pdf version of the document from the
+ dvi file, by using the command specified by the $dvipdf vari-
+ able. If equal to 4, generate a pdf version of the document us-
+ ing lualatex, using the command specified by the $lualatex vari-
+ able. If equal to 5, generate a pdf version (and an xdv ver-
+ sion) of the document using xelatex, using the commands speci-
+ fied by the $xelatex and xdvipdfmx variables.
+
+ In $pdf_mode=2, it is ensured that .dvi and .ps files are also
+ made. In $pdf_mode=3, it is ensured that a .dvi file is also
+ made. But this may be overridden by the document.
+
+ $pdflatex ["pdflatex %O %S"]
+ Specifies the command line for the LaTeX processing program in a
+ version that makes a pdf file instead of a dvi file.
+
+ An example use of this variable is to add certain options to the
+ command line for the program, e.g.,
+
+ $pdflatex = "pdflatex --shell-escape %O %S";
+
+ (In some earlier versions of latexmk, you needed to use an as-
+ signment to $pdflatex to allow the use of lualatex or xelatex
+
+
+
+ 18 June 2019 49
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ instead of pdflatex. There are now separate configuration vari-
+ ables for the use of lualatex or xelatex. See $lualatex and
+ $xelatex.)
+
+ To do a coordinated setting of all of $latex, $pdflatex, $luala-
+ tex, and $xelatex, see the section "Advanced Configuration".
+
+ %pdflatex_input_extensions
+ This variable specifies the extensions tried by latexmk when it
+ finds that a pdflatex run resulted in an error that a file has
+ not been found, and the file is given without an extension.
+ This typically happens when LaTeX commands of the form \in-
+ put{file} or \includegraphics{figure}, when the relevant source
+ file does not exist.
+
+ In this situation, latexmk searches for custom dependencies to
+ make the missing file(s), but restricts it to the extensions
+ specified by the variable %pdflatex_input_extensions. The de-
+ fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
+
+ See details of the %latex_input_extensions for other information
+ that equally applies to %pdflatex_input_extensions.
+
+ $pdflatex_silent_switch ["-interaction=batchmode"]
+ Switch(es) for the pdflatex program (specified in the variable
+ $pdflatex) when silent mode is on.
+
+ See details of the $latex_silent_switch for other information
+ that equally applies to $pdflatex_silent_switch.
+
+ $pdf_previewer ["start acroread %O %S"]
+ The command to invoke a pdf-previewer.
+
+ On MS-Windows, the default is changed to "cmd /c start """; un-
+ der more recent versions of Windows, this will cause to be run
+ whatever command the system has associated with .pdf files. But
+ this may be undesirable if this association is to acroread --
+ see the notes in the explanation of the -pvc option.]
+
+ On OS-X the default is changed to "open %S", which results in
+ OS-X starting up (and detaching) the viewer associated with the
+ file. By default, for pdf files this association is to OS-X's
+ preview, which is quite satisfactory.
+
+ WARNING: Problem under MS-Windows: if acroread is used as the
+ pdf previewer, and it is actually viewing a pdf file, the pdf
+ file cannot be updated. Thus makes acroread a bad choice of
+ previewer if you use latexmk's previous-continuous mode (option
+ -pvc) under MS-windows. This problem does not occur if, for ex-
+ ample, SumatraPDF or gsview is used to view pdf files.
+
+ Important note: Normally you will want to have a previewer run
+ detached, so that latexmk doesn't wait for the previewer to ter-
+ minate before continuing its work. So normally you should
+
+
+
+ 18 June 2019 50
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ prefix the command by "start ", which flags to latexmk that it
+ should do the detaching of the previewer itself (by whatever
+ method is appropriate to the operating system). But sometimes
+ letting latexmk do the detaching is not appropriate (for a vari-
+ ety of non-trivial reasons), so you should put the "start " bit
+ in yourself, whenever it is needed.
+
+ $pdf_update_command [""]
+ When the pdf previewer is set to be updated by running a com-
+ mand, this is the command that is run. See the information for
+ the variable $pdf_update_method.
+
+ $pdf_update_method [1 under UNIX, 3 under MS-Windows]
+ How the pdf viewer updates its display when the pdf file has
+ changed. See the information on the variable $dvi_update_method
+ for the codes. (Note that information needs be changed slightly
+ so that for the value 4, to run a command to do the update, the
+ command is specified by the variable $pdf_update_command, and
+ for the value 2, to specify update by signal, the signal is
+ specified by $pdf_update_signal.)
+
+ Note that acroread under MS-Windows (but not UNIX) locks the pdf
+ file, so the default value is then 3.
+
+ Arranging to use a command to get a previewer explicitly updated
+ requires three variables to be set. For example:
+
+ $pdf_previewer = "start xpdf -remote %R %O %S";
+ $pdf_update_method = 4;
+ $pdf_update_command = "xpdf -remote %R -reload";
+
+ The first setting arranges for the xpdf program to be used in
+ its "remote server mode", with the server name specified as the
+ rootname of the TeX file. The second setting arranges for up-
+ dating to be done in response to a command, and the third set-
+ ting sets the update command.
+
+ $pdf_update_signal [Under UNIX: SIGHUP, which is a system-dependent
+ value]
+ The number of the signal that is sent to the pdf viewer when it
+ is updated by sending a signal -- see the information on the
+ variable $pdf_update_method. The default value is the one ap-
+ propriate for gv on a UNIX system.
+
+ $pid_position[1 under UNIX, -1 under MS-Windows]
+ The variable $pid_position is used to specify which word in
+ lines of the output from $pscmd corresponds to the process ID.
+ The first word in the line is numbered 0. The default value of
+ 1 (2nd word in line) is correct for Solaris 2.6, Linux, and OS-X
+ with their default settings of $pscmd.
+
+ Setting the variable to -1 is used to indicate that $pscmd is
+ not to be used.
+
+
+
+
+ 18 June 2019 51
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ $postscript_mode [0]
+ If nonzero, generate a postscript version of the document.
+ Equivalent to the -ps option.
+
+ If some other request is made for which a postscript file is
+ needed, then $postscript_mode will be set to 1.
+
+ $pre_tex_code ['']
+
+ Sets TeX code to be executed before inputting the source file.
+ This works if the relevant one of $latex, etc contains a suit-
+ able command line with a %P or %U substitution. For example you
+ could do
+
+ $latex = 'latex %O %P';
+ $pre_tex_code = '\AtBeginDocument{An initial message\par}';
+
+ To set all of $latex, $pdflatex, $lualatex, and $xelatex you
+ could use the subroutine alt_tex_cmds:
+
+ &alt_tex_cmds;
+ $pre_tex_code = '\AtBeginDocument{An initial message\par}';
+
+
+
+ $preview_continuous_mode [0]
+ If nonzero, run a previewer to view the document, and continue
+ running latexmk to keep .dvi up-to-date. Equivalent to the -pvc
+ option. Which previewer is run depends on the other settings,
+ see the command line options -view=, and the variable $view.
+
+ $preview_mode [0]
+ If nonzero, run a previewer to preview the document. Equivalent
+ to the -pv option. Which previewer is run depends on the other
+ settings, see the command line options -view=, and the variable
+ $view.
+
+ $printout_mode [0]
+ If nonzero, print the document using the command specified in
+ the $lpr variable. Equivalent to the -p option. This is recom-
+ mended not to be set from an RC file, otherwise you could waste
+ lots of paper.
+
+ $print_type = ["auto"]
+ Type of file to printout: possibilities are "auto", "dvi",
+ "none", "pdf", or "ps". See the option -print= for the meaning
+ of the "auto" value.
+
+ $pscmd Command used to get all the processes currently run by the user.
+ The -pvc option uses the command specified by the variable
+ $pscmd to determine if there is an already running previewer,
+ and to find the process ID (needed if latexmk needs to signal
+ the previewer about file changes).
+
+
+
+
+ 18 June 2019 52
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ Each line of the output of this command is assumed to correspond
+ to one process. See the $pid_position variable for how the
+ process number is determined.
+
+ The default for pscmd is "NONE" under MS-Windows and cygwin
+ (i.e., the command is not used), "ps -ww -u $ENV{USER}" under
+ OS-X, and "ps -f -u $ENV{USER}" under other operating systems
+ (including Linux). In these specifications "$ENV{USER}" is sub-
+ stituted by the username.
+
+ $ps2pdf ["ps2pdf %O %S %D"]
+ Command to convert .ps to .pdf file.
+
+ $ps_filter [empty]
+ The postscript file filter to be run on the newly produced post-
+ script file before other processing. Equivalent to specifying
+ the -pF option.
+
+ $ps_previewer ["start gv %O %S", but start %O %S under MS-Windows]
+ The command to invoke a ps-previewer. (The default under MS-
+ Windows will cause to be run whatever command the system has as-
+ sociated with .ps files.)
+
+ Note that gv could be used with the -watch option updates its
+ display whenever the postscript file changes, whereas ghostview
+ does not. However, different versions of gv have slightly dif-
+ ferent ways of writing this option. You can configure this
+ variable appropriately.
+
+ WARNING: Linux systems may have installed one (or more) versions
+ of gv under different names, e.g., ggv, kghostview, etc, but
+ perhaps not one actually called gv.
+
+ Important note: Normally you will want to have a previewer run
+ detached, so that latexmk doesn't wait for the previewer to ter-
+ minate before continuing its work. So normally you should pre-
+ fix the command by "start ", which flags to latexmk that it
+ should do the detaching of the previewer itself (by whatever
+ method is appropriate to the operating system). But sometimes
+ letting latexmk do the detaching is not appropriate (for a vari-
+ ety of non-trivial reasons), so you should put the "start " bit
+ in yourself, whenever it is needed.
+
+
+ $ps_previewer_landscape ["start gv -swap %O %S", but start %O %S under
+ MS-Windows]
+ The command to invoke a ps-previewer in landscape mode.
+
+ $ps_update_command [""]
+ When the postscript previewer is set to be updated by running a
+ command, this is the command that is run. See the information
+ for the variable $ps_update_method.
+
+
+
+
+
+ 18 June 2019 53
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ $ps_update_method [0 under UNIX, 1 under MS-Windows]
+ How the postscript viewer updates its display when the .ps file
+ has changed. See the information on the variable $dvi_up-
+ date_method for the codes. (Note that information needs be
+ changed slightly so that for the value 4, to run a command to do
+ the update, the command is specified by the variable $ps_up-
+ date_command, and for the value 2, to specify update by signal,
+ the signal is specified by $ps_update_signal.)
+
+ $ps_update_signal [Under UNIX: SIGHUP, which is a system-dependent
+ value]
+ The number of the signal that is sent to the pdf viewer when it
+ is updated by sending a signal -- see $ps_update_method. The
+ default value is the one appropriate for gv on a UNIX system.
+
+ $pvc_timeout [0]
+ If this variable is nonzero, there will be a timeout in pvc
+ mode after a period of inactivity. Inactivity means a period
+ when latexmk has detected no file changes and hence has not
+ taken any actions like compiling the document. The period of in-
+ activity is in the variable $pvc_timeout_mins.
+
+
+ $pvc_timeout_mins [30]
+ The period of inactivity, in minutes, after which pvc mode times
+ out. This is used if $pvc_timeout is nonzero.
+
+ $pvc_view_file_via_temporary [1]
+ The same as $always_view_file_via_temporary, except that it only
+ applies in preview-continuous mode (-pvc option).
+
+ $quote_filenames [1]
+ This specifies whether substitutions for placeholders in command
+ specifications (as in $pdflatex) are surrounded by double
+ quotes. If this variable is 1 (or any other value Perl regards
+ as true), then quoting is done. Otherwise quoting is omitted.
+
+ The quoting method used by latexmk is tested to work correctly
+ under UNIX systems (including Linux and Mac OS-X) and under MS-
+ Windows. It allows the use of filenames containing special
+ characters, notably spaces. (But note that many versions of la-
+ tex and pdflatex cannot correctly deal with TeX files whose
+ names contain spaces. Latexmk's quoting only ensures that such
+ filenames are correctly treated by the operating system in pass-
+ ing arguments to programs.)
+
+ $recorder [1]
+ Whether to use the -recorder option to latex and pdflatex. Use
+ of this option results in a file of extension .fls containing a
+ list of the files that these programs have read and written.
+ Latexmk will then use this file to improve its detection of
+ source files and generated files after a run of latex or pdfla-
+ tex.
+
+
+
+
+ 18 June 2019 54
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ It is generally recommended to use this option (or to configure
+ the $recorder variable to be on.) But it only works if (pdf)la-
+ tex supports the -recorder option, which is true for most cur-
+ rent implementations
+
+ Note about the name of the .fls file: Most implementations of
+ (pdf)latex produce an .fls file with the same basename as the
+ main document's LaTeX, e.g., for Document.tex, the .fls file is
+ Document.fls. However, some implementations instead produce
+ files named for the program, i.e., latex.fls or pdflatex.fls.
+ In this second case, latexmk copies the latex.fls or pdfla-
+ tex.fls to a file with the basename of the main LaTeX document,
+ e.g., Document.fls.
+
+ $search_path_separator [See below for default]
+ The character separating paths in the environment variables TEX-
+ INPUTS, BIBINPUTS, and BSTINPUTS. This variable is mainly used
+ by latexmk when the -outdir, -output-directory, -auxdir, and/or
+ -aux-directory options are used. In that case latexmk needs to
+ communicate appropriately modified search paths to bibtex,
+ dvipdf, dvips, and (pdf)latex.
+
+ [Comment to technically savvy readers: (pdf)latex doesn't actu-
+ ally need the modified search path. But, surprisingly, dvipdf
+ and dvips do, because sometimes graphics files get generated in
+ the output or aux directories.]
+
+ The default under MSWin and Cygwin is ';' and under UNIX-like
+ operating systems (including Linux and OS-X) is ':'. Normally
+ the defaults give correct behavior. But there can be difficul-
+ ties if your operating system is of one kind, but some of your
+ software is running under an emulator for the other kind of op-
+ erating system; in that case you'll need to find out what is
+ needed, and set $search_path_separator explicitly. (The same
+ goes, of course, for unusual operating systems that are not in
+ the MSWin, Linux, OS-X, Unix collection.)
+
+ $show_time [0]
+ Whether to show CPU time used.
+
+ $silence_logfile_warnings [0]
+ Whether after a run of (pdf)latex to summarize warnings in the
+ log file about undefined citations and references. Setting $si-
+ lence_logfile_warnings=0 gives the summary of warnings (provided
+ silent mode isn't also set), and this is useful to locate unde-
+ fined citations and references without searching through the
+ much more verbose log file or the screen output of (pdf)latex.
+ But the summary can also be excessively annoying. The default
+ is not to give these warnings. The command line options -si-
+ lence_logfile_warning_list and -silence_logfile_warning_list-
+ also set this variable.
+
+ Note that multiple occurrences for the same undefined object on
+ the same page and same line will be compressed to a single
+
+
+
+ 18 June 2019 55
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ warning.
+
+ $silent [0]
+ Whether to run silently. Setting $silent to 1 has the same ef-
+ fect as the -quiet of -silent options on the command line.
+
+ $sleep_time [2]
+ The time to sleep (in seconds) between checking for source file
+ changes when running with the -pvc option. This is subject to a
+ minimum of one second delay, except that zero delay is also al-
+ lowed.
+
+ A value of exactly 0 gives no delay, and typically results in
+ 100% CPU usage, which may not be desirable.
+
+ $texfile_search [""]
+ This is an obsolete variable, replaced by the @default_files
+ variable.
+
+ For backward compatibility, if you choose to set $tex-
+ file_search, it is a string of space-separated filenames, and
+ then latexmk replaces @default_files with the filenames in $tex-
+ file_search to which is added "*.tex".
+
+ $success_cmd [undefined]
+ See the documentation for $compiling_cmd.
+
+ $tmpdir [See below for default]
+ Directory to store temporary files that latexmk may generate
+ while running.
+
+ The default under MSWindows (including cygwin), is to set $tm-
+ pdir to the value of the first of whichever of the system envi-
+ ronment variables TMPDIR or TEMP exists, otherwise to the cur-
+ rent directory. Under other operating systems (expected to be
+ UNIX/Linux, including OS-X), the default is the value of the
+ system environment variable TMPDIR if it exists, otherwise
+ "/tmp".
+
+ $use_make_for_missing_files [0]
+ Whether to use make to try and make files that are missing after
+ a run of latex or pdflatex, and for which a custom dependency
+ has not been found. This is generally useful only when latexmk
+ is used as part of a bigger project which is built by using the
+ make program.
+
+ Note that once a missing file has been made, no further calls to
+ make will be made on a subsequent run of latexmk to update the
+ file. Handling this problem is the job of a suitably defined
+ Makefile. See the section "USING latexmk WITH make" for how to
+ do this. The intent of calling make from latexmk is merely to
+ detect dependencies.
+
+
+
+
+
+ 18 June 2019 56
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ $view ["default"]
+ Which kind of file is to be previewed if a previewer is used.
+ The possible values are "default", "dvi", "ps", "pdf". The
+ value of "default" means that the "highest" of the kinds of file
+ generated is to be used (among .dvi, .ps and .pdf).
+
+
+ $warnings_as_errors [0]
+ Normally latexmk copies the behavior of latex in treating unde-
+ fined references and citations and multiply defined references
+ as conditions that give a warning but not an error. The vari-
+ able $warnings_as_errors controls whether this behavior is modi-
+ fied.
+
+ When the variable is non-zero, latexmk at the end of its run
+ will return a non-zero status code to the operating system if
+ any of the files processed gives a warning about problems with
+ citations or references (i.e., undefined citations or references
+ or multiply defined references). This is after latexmk has com-
+ pleted all the runs it needs to try and resolve references and
+ citations. Thus $warnings_as_errors being nonzero causes la-
+ texmk to treat such warnings as errors, but only when they occur
+ on the last run of (pdf)latex and only after processing is com-
+ plete. A non-zero value $warnings_as_errors can be set by the
+ command-line option -Werror.
+
+ The default behavior is normally satisfactory in the usual edit-
+ compile-edit cycle. But, for example, latexmk can also be used
+ as part of a build process for some bigger project, e.g., for
+ creating documentation in the build of a software application.
+ Then it is often sensible to treat citation and reference warn-
+ ings as errors that require the overall build process to be
+ aborted. Of course, since multiple runs of (pdf)latex are gen-
+ erally needed to resolve references and citations, what matters
+ is not the warnings on the first run, but the warnings on the
+ last run; latexmk takes this into account appropriately.
+
+ In addition, when preview-continuous mode is used, a non-zero
+ value for $warnings_as_errors changes the use of the commands
+ $failure_cmd, $warning_cmd, and $success_cmd after a complia-
+ tion. If there are citation or reference warnings, but no other
+ errors, the behavior is as follows. If $warning_cmd is set, it
+ is used. If it is not set, then then if $warnings_as_errors is
+ non-zero and $failure_cmd is set, then $failure_cmd. Otherwise
+ $success_cmd is used, if it is set. (The foregoing explanation
+ is rather complicated, because latexmk has to deal with the case
+ that one or more of the commands isn't set.)
+
+
+ $xdvipdfmx ["xdvipdfmx -o %D %O %S"]
+
+ The program to make a pdf file from an xdv file (used in con-
+ junction with xelatex when $pdf_mode=5).
+
+
+
+
+ 18 June 2019 57
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ $xdvipdfmx_silent_switch ["-q"]
+ Switch(es) for the xdvipdfmx program when silent mode is on.
+
+ $xelatex ["xelatex %O %S"]
+ Specifies the command line for the LaTeX processing program of
+ when the xelatex program is called for. See the documentation
+ of the -xelatex option for some special properties of latexmk's
+ use of xelatex.
+
+ Note about xelatex: Now latexmk uses xelatex to make an .xdv
+ rather than .pdf file, with the .pdf file being created in a
+ separate step. This is enforced by the use of the -no-pdf op-
+ tion. If %O is part of the command for invoking xelatex, then
+ latexmk will insert the -no-pdf option automatically, otherwise
+ you must provide the option yourself
+
+ To do a coordinated setting of all of $latex, $pdflatex, $luala-
+ tex, and $xelatex, see the section "Advanced Configuration".
+
+
+ %xelatex_input_extensions
+ This variable specifies the extensions tried by latexmk when it
+ finds that an xelatex run resulted in an error that a file has
+ not been found, and the file is given without an extension.
+ This typically happens when LaTeX commands of the form \in-
+ put{file} or \includegraphics{figure}, when the relevant source
+ file does not exist.
+
+ In this situation, latexmk searches for custom dependencies to
+ make the missing file(s), but restricts it to the extensions
+ specified by the variable %xelatex_input_extensions. The de-
+ fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
+
+ See details of the %latex_input_extensions for other information
+ that equally applies to %xelatex_input_extensions.
+
+ $xelatex_silent_switch ["-interaction=batchmode"]
+ Switch(es) for the xelatex program (specified in the variable
+ $xelatex) when silent mode is on.
+
+ See details of the $latex_silent_switch for other information
+ that equally applies to $xelatex_silent_switch.
+
+
+
+
+CUSTOM DEPENDENCIES
+ In any RC file a set of custom dependencies can be set up to convert a
+ file with one extension to a file with another. An example use of this
+ would be to allow latexmk to convert a .fig file to .eps to be included
+ in the .tex file.
+
+
+
+
+
+
+ 18 June 2019 58
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ Defining a custom dependency:
+ The old method of configuring latexmk to use a custom dependency was to
+ directly manipulate the @cus_dep_list array that contains information
+ defining the custom dependencies. (See the section "Old Method of
+ Defining Custom Dependencies" for details.) This method still works,
+ but is no longer preferred.
+
+ A better method is to use the subroutines that allow convenient manipu-
+ lations of the custom dependency list. These are
+
+ add_cus_dep( fromextension, toextension, must, subroutine )
+ remove_cus_dep( fromextension, toextension )
+ show_cus_dep()
+
+ The arguments are as follows:
+
+ from extension:
+ The extension of the file we are converting from (e.g. "fig").
+ It is specified without a period.
+
+ to extension:
+ The extension of the file we are converting to (e.g. "eps"). It
+ is specified without a period.
+
+ must: If non-zero, the file from which we are converting must exist,
+ if it doesn't exist latexmk will give an error message and exit
+ unless the -f option is specified. If must is zero and the file
+ we are converting from doesn't exist, then no action is taken.
+ Generally, the appropriate value of must is zero.
+
+ function:
+ The name of the subroutine that latexmk should call to perform
+ the file conversion. The first argument to the subroutine is
+ the base name of the file to be converted without any extension.
+ The subroutines are declared in the syntax of Perl. The func-
+ tion should return 0 if it was successful and a nonzero number
+ if it failed.
+
+
+ Naturally add_cus_dep adds a custom dependency with the specified from
+ and to extensions. If a custom dependency has been previously defined
+ (e.g., in an rcfile that was read earlier), then it is replaced by the
+ new one.
+
+ The subroutine remove_cus_dep removes the specified custom dependency.
+ The subroutine show_cus_dep causes a list of the currently defined cus-
+ tom dependencies to be sent to the screen output.
+
+
+ How custom dependencies are used:
+ An instance of a custom dependency rule is created whenever latexmk de-
+ tects that a run of latex/pdflatex needs to read a file, like a graph-
+ ics file, whose extension is the to-extension of a custom dependency.
+ Then latexmk examines whether a file exists with the same name, but
+
+
+
+ 18 June 2019 59
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ with the corresponding from-extension, as specified in the custom-de-
+ pendency. If it does, then a corresponding instance of the custom de-
+ pendency is created, after which the rule is invoked whenever the des-
+ tination file (the one with the to-extension) is out-of-date with re-
+ spect to the corresponding source file.
+
+ To make the new destination file, the Perl subroutine specified in the
+ rule is invoked, with an argument that is the base name of the files in
+ question. Simple cases just involve a subroutine invoking an external
+ program; this can be done by following the templates below, even by
+ those without knowledge of the Perl programming language. Of course,
+ experts could do something much more elaborate.
+
+ One item in the specification of each custom-dependency rule, labeled
+ "must" above, specifies how the rule should be applied when the source
+ file fails to exist.
+
+ When latex reports that an input file (e.g., a graphics file) does not
+ exist, latexmk tries to find a source file and a custom dependency that
+ can be used to make it. If it succeeds, then it creates an instance of
+ the custom dependency and invokes it to make the missing file, after
+ which the next pass of latex etc will be able to read the newly created
+ file.
+
+ Note for advanced usage: The operating system's environment variable
+ TEXINPUTS can be used to specify a search path for finding files by la-
+ tex etc. Correspondingly, when a missing file is reported, latexmk
+ looks in the directories specified in TEXINPUTS as well as in the cur-
+ rent directory, to find a source file from which an instance of a cus-
+ tom dependency can be used to make the missing file.
+
+
+ Function to implement custom dependency, traditional method:
+ The function that implements a custom dependency gets the information
+ on the files to be processed in two ways. The first is through its one
+ argument; the argument contains the base name of the source and desti-
+ nation files. The second way is described later.
+
+ A simple and typical example of code in an initialization rcfile using
+ the first method is:
+
+ add_cus_dep( 'fig', 'eps', 0, 'fig2eps' );
+ sub fig2eps {
+ system( "fig2dev -Leps \"$_[0].fig\" \"$_[0].eps\"" );
+ }
+
+ The first line adds a custom dependency that converts a file with ex-
+ tension "fig", as created by the xfig program, to an encapsulated post-
+ script file, with extension "eps". The remaining lines define a sub-
+ routine that carries out the conversion. If a rule for converting
+ "fig" to "eps" files already exists (e.g., from a previously read-in
+ initialization file), the latexmk will delete this rule before making
+ the new one.
+
+
+
+
+ 18 June 2019 60
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ Suppose latexmk is using this rule to convert a file "figure.fig" to
+ "figure.eps". Then it will invoke the fig2eps subroutine defined in
+ the above code with a single argument "figure", which is the basename
+ of each of the files (possibly with a path component). This argument
+ is referred to by Perl as $_[0]. In the example above, the subroutine
+ uses the Perl command system to invoke the program fig2dev. The double
+ quotes around the string are a Perl idiom that signify that each string
+ of the form of a variable name, $_[0] in this case, is to be substi-
+ tuted by its value.
+
+ If the return value of the subroutine is non-zero, then latexmk will
+ assume an error occurred during the execution of the subroutine. In
+ the above example, no explicit return value is given, and instead the
+ return value is the value returned by the last (and only) statement,
+ i.e., the invocation of system, which returns the value 0 on success.
+
+ If you use pdflatex instead of latex, then you will probably prefer to
+ convert your graphics files to pdf format, in which case you would re-
+ place the above code in an initialization file by
+
+ add_cus_dep( 'fig', 'pdf, 0, 'fig2pdf' );
+ sub fig2pdf {
+ system( "fig2dev -Lpdf \"$_[0].fig\" \"$_[0].pdf\"" );
+ }
+
+ Note 1: In the command lines given in the system commands in the above
+ examples, double quotes have been inserted around the file names (im-
+ plemented by '\"' in the Perl language). They immunize the running of
+ the program against special characters in filenames. Very often these
+ quotes are not necessary, i.e., they can be omitted. But it is nor-
+ mally safer to keep them in. Even though the rules for quoting vary
+ between operating systems, command shells and individual pieces of
+ software, the quotes in the above examples do not cause problems in the
+ cases I have tested.
+
+ Note 2: One case in which the quotes are important is when the files
+ are in a subdirectory and your operating system is Microsoft Windows.
+ Then the separator character for directory components can be either a
+ forward slash '/' or Microsoft's more usual backward slash '\'. For-
+ ward slashes are generated by latexmk, to maintain its sanity from
+ software like MiKTeX that mixes both directory separators; but their
+ correct use normally requires quoted filenames. (See a log file from a
+ run of MiKTeX (at least in v. 2.9) for an example of the use of both
+ directory separators.)
+
+ Note 3: The subroutines implementing custom dependencies in the exam-
+ ples given just have a single line invoking an external program.
+ That's the usual situation. But since the subroutines are in the Perl
+ language, you can implement much more complicated processing if you
+ need it.
+
+
+ Removing custom dependencies, and when you might need to do this:
+ If you have some general custom dependencies defined in the system or
+
+
+
+ 18 June 2019 61
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ user initialization file, you may find that for a particular project
+ they are undesirable. So you might want to delete the unneeded ones.
+ A situation where this would be desirable is where there are multiple
+ custom dependencies with the same from-extension or the same to-exten-
+ sion. In that case, latexmk might choose a different one from the one
+ you want for a specific project. As an example, to remove any "fig" to
+ "eps" rule you would use:
+
+ remove_cus_dep( 'fig', 'eps' );
+
+ If you have complicated sets of custom dependencies, you may want to
+ get a listing of the custom dependencies. This is done by using the
+ line
+
+ show_cus_dep();
+
+ in an initialization file.
+
+
+ Function implementing custom dependency, alternative methods:
+ So far the examples for functions to implement custom dependencies have
+ used the argument of the function to specify the base name of converted
+ file. This method has been available since very old versions of la-
+ texmk, and many examples can be found, e.g., on the web.
+
+ However in later versions of latexmk the internal structure of the im-
+ plementation of its "rules" for the steps of processing, including cus-
+ tom dependencies, became much more powerful. The function implementing
+ a custom dependency is executed within a special context where a number
+ of extra variables and subroutines are defined. Publicly documented
+ ones, intended to be long-term stable, are listed below, under the
+ heading "Variables and subroutines for processing a rule".
+
+ Examples of their use is given in the following examples, concerning
+ multiple index files and glossaries.
+
+ The only index-file conversion built-in to latexmk is from an ".idx"
+ file written on one run of latex/pdflatex to an ".ind" file to be read
+ in on a subsequent run. But with the index.sty package, for example,
+ you can create extra indexes with extensions that you configure. La-
+ texmk does not know how to deduce the extensions from the information
+ it has. But you can easily write a custom dependency. For example if
+ your latex file uses the command "\newindex{special}{ndx}{nnd}{Special
+ index}" you will need to get latexmk to convert files with the exten-
+ sion .ndx to .nnd. The most elementary method is to define a custom
+ dependency as follows:
+
+ add_cus_dep( 'ndx', 'nnd', 0, 'ndx2nnd' );
+ sub ndx2nnd {
+ return system( "makeindex -o \"$_[0].nnd\" \"$_[0].ndx\"" );
+ }
+ push @generated_exts, 'ndx', 'nnd';
+
+ Notice the added line compared with earlier examples. The extra line
+
+
+
+ 18 June 2019 62
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ gets the extensions "ndx" and "nnd" added to the list of extensions for
+ generated files; then the extra index files will be deleted by clean-up
+ operations
+
+ But if you have yet more indexes with yet different extensions, e.g.,
+ "adx" and "and", then you will need a separate function for each pair
+ of extensions. This is quite annoying. You can use the Run_subst
+ function to simplify the definitions to use a single function:
+
+ add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
+ add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
+ sub dx2nd {
+ return Run_subst( "makeindex -o %D %S" );
+ }
+ push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
+
+ You could also instead use
+
+ add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
+ add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
+ sub dx2nd {
+ return Run_subst( $makeindex );
+ }
+ push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
+
+ This last example uses the command specification in $makeindex, and so
+ any customization you have made for the standard index also applies to
+ your extra indexes.
+
+ Similar techniques can be applied for glossaries.
+
+ Those of you with experience with Makefiles, may get concerned that the
+ .ndx file is written during a run of latex/pdflatex and is always later
+ than the .nnd last read in. Thus the .nnd appears to be perpetually
+ out-of-date. This situation, of circular dependencies, is endemic to
+ latex, and is one of the issues that latexmk is programmed to overcome.
+ It examines the contents of the files (by use of a checksum), and only
+ does a remake when the file contents have actually changed.
+
+ Of course if you choose to write random data to the .nnd (or the .aux
+ file, etc) that changes on each new run, then you will have a problem.
+ For real experts: See the %hash_cal_ignore_pattern if you have to deal
+ with such problems.
+
+
+ Old Method of Defining Custom Dependencies:
+ In much older versions of latexmk, the only method of defining custom
+ dependencies was to directly manipulate the table of custom dependen-
+ cies. This is contained in the @cus_dep_list array. It is an array of
+ strings, and each string in the array has four items in it, each sepa-
+ rated by a space, the from-extension, the to-extension, the "must"
+ item, and the name of the subroutine for the custom dependency. These
+ were all defined above.
+
+
+
+
+ 18 June 2019 63
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ An example of the old method of defining custom dependencies is as fol-
+ lows. It is the code in an RC file to ensure automatic conversion of
+ .fig files to .eps files:
+
+ push @cus_dep_list, "fig eps 0 fig2eps";
+ sub fig2eps {
+ return system( "fig2dev -Lps \"$_[0].fig\" \"$_[0].eps\"" );
+ }
+
+ This method still works, and is almost equivalent to the code given
+ earlier that used the add_cus_dep subroutine. However, the old method
+ doesn't delete any previous custom-dependency for the same conversion.
+ So the new method is preferable.
+
+
+
+ADVANCED CONFIGURATION: Some extra resources and advanced tricks
+ For most purposes, simple configuration for latexmk along the lines of
+ the examples given is sufficient. But sometimes you need something
+ harder. In this section, I indicate some extra possibilities. Gener-
+ ally to use these, you need to be fluent in the Perl language, since
+ this is what is used in the rc files.
+
+ See also the section DEALING WITH ERRORS, PROBLEMS, ETC. See also the
+ examples in the directory example_rcfiles in the latexmk distributions.
+ Even if none of the examples apply to your case, they may give you use-
+ ful ideas
+
+
+ Utility subroutines
+ ensure_path( var, values ...)
+
+ The first parameter is the name of one of the system's environ-
+ ment variables for search paths. The remaining parameters are
+ values that should be in the variable. For each of the value
+ parameters, if it isn't already in the variable, then it is
+ prepended to the variable; in that case the environment variable
+ is created if it doesn't already exist. For separating values,
+ the character appropriate the the operating system is used --
+ see the configuration variable $search_path_separator.
+
+ Example:
+
+ ensure_path( 'TEXINPUTS', './custom_cls_sty_files//' );
+
+ (In this example, the trailing '//' is documented by TeX systems
+ to mean that latex, pdflatex, etc search for files in the speci-
+ fied directory and in all subdirectories.)
+
+ Technically ensure_path works by setting Perl's variable
+ $ENV{var}, where var is the name of the target variable. The
+ changed value is then passed as an environment variable to any
+ invoked programs.
+
+
+
+
+ 18 June 2019 64
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ Variables and subroutines for processing a rule
+ A step in the processing is called a rule. One possibility to implement
+ the processing of a rule is by a Perl subroutine. This is always the
+ case for custom dependencies. Also, for any other rule, you can use a
+ subroutine by prefixing the command specification by the word "inter-
+ nal" -- see the section FORMAT OF COMMAND SPECIFICATIONS.
+
+ When you use a subroutine for processing a rule, all the possibilities
+ of Perl programming are available, of course. In addition, some of la-
+ texmk's internal variables and subroutines are available. The ones
+ listed below are intended to be available to (advanced) users, and
+ their specifications will generally have stability under upgrades. Gen-
+ erally, the variables should be treated as read-only: Changing their
+ values can have bad consequences, since it is liable to mess up the
+ consistency of what latexmk is doing.
+
+ $rule This variable has the name of the rule, as known to latexmk.
+ Note that the exact contents of this variable for a given rule
+ may be dependent on the version of latexmk
+
+ $$Psource
+ This gives the name of the primary source file. Note the double
+ dollar signs.
+
+ $$Pdest
+ This gives the name of the main output file if any. Note the
+ double dollar signs.
+
+ rdb_ensure_file( $rule, file )
+ This a subroutine that ensures that the given file is among the
+ source files for the specified rule. It is typically used when,
+ during the processing of a rule, it is known that a particular
+ extra file is among the dependencies that latexmk should know,
+ but its default methods don't find the dependency. Almost always
+ the first argument is the name of the rule currently being pro-
+ cessed, so it is then appropriate to specify it by $rule.
+
+ For examples of its use, see some of the files in the directory
+ example_rcfiles of latexmk's distribution. Currently the cases
+ that use this subroutine are bib2gls-latexmkrc, exceltex_la-
+ texmkrc and texinfo-latexmkrc. These illustrate typical cases
+ where latexmk's normal processing fails to detect certain extra
+ source files.
+
+ rdb_remove_files( $rule, file, ... )
+ This subroutine removes one or more files from the dependency
+ list for the given rule.
+
+ rdb_list_source( $rule )
+ This subroutine returns the list of source files (i.e., the de-
+ pendency list) for the given rule.
+
+ rdb_set_source( $rule, file, ... )
+
+
+
+
+ 18 June 2019 65
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ rdb_set_source( $rule, @files )
+ This subroutine sets the dependency list for the given rule to
+ be the specified files. Files that are already in the list have
+ unchanged information. Files that were not in the list are
+ added to it. Files in the previous dependency list that are not
+ in the newly specified list of files are removed from the depen-
+ dency list.
+
+ Run_subst( command_spec )
+ This subroutine runs the command specified by command_spec. The
+ specification is a string in the format listed in the section
+ "Format of Command Specifications". An important action of the
+ Run_subst is to make substitutions of placeholders, e.g., %S and
+ %D for source and destination files; these get substituted be-
+ fore the command is run. In addition, the command after substi-
+ tution is printed to the screen unless latexmk is running in
+ silent mode.
+
+
+ Coordinated Setting of Commands for *latex
+ To set all of $latex, $pdflatex, $lualatex, and $xelatex to a common
+ pattern, you can use one of the following subroutines, std_tex_cmds,
+ alt_tex_cmds, and set_tex_cmds.
+
+ They work as follows
+
+ &std_tex_cmds;
+
+ This results in $latex = 'latex %O %S', and similarly for $pdflatex,
+ $lualatex, and $xelatex. Note the ampersand in the invocation; this
+ indicates to Perl that a subroutine is being called.
+
+ &alt_tex_cmds;
+
+ This results in $latex = 'latex %O %P', and similarly for $pdflatex,
+ $lualatex, and $xelatex. Note the ampersand in the invocation; this
+ indicates to Perl that a subroutine is being called.
+
+ set_tex_cmds( CMD_SPEC );
+
+ Here CMD_SPEC is the command line without the program name. This re-
+ sults in $latex = 'CMD_SPEC', and similarly for $pdflatex, $lualatex,
+ and $xelatex. An example would be
+
+ set_tex_cmds( '--interaction=batchmode %O %S' );
+
+
+ Advanced configuration: Using latexmk with make
+ This section is targeted only at advanced users who use the make pro-
+ gram for complex projects, as for software development, with the depen-
+ dencies specified by a Makefile.
+
+ Now the basic task of latexmk is to run the appropriate programs to
+ make a viewable version of a LaTeX document. However, the usual make
+
+
+
+ 18 June 2019 66
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ program is not suited to this purpose for at least two reasons. First
+ is that the use of LaTeX involves circular dependencies (e.g., via .aux
+ files), and these cannot be handled by the standard make program. Sec-
+ ond is that in a large document the set of source files can change
+ quite frequently, particularly with included graphics files; in this
+ situation keeping a Makefile manually updated is inappropriate and er-
+ ror-prone, especially when the dependencies can be determined automati-
+ cally. Latexmk solves both of these problems robustly.
+
+ Thus for many standard LaTeX documents latexmk can be used by itself
+ without the make program. In a complex project it simply needs to be
+ suitably configured. A standard configuration would be to define cus-
+ tom dependencies to make graphics files from their source files (e.g.,
+ as created by the xfig program). Custom dependencies are latexmk's
+ equivalent of pattern rules in Makefiles.
+
+ Nevertheless there are projects for which a Makefile is appropriate,
+ and it is useful to know how to use latexmk from a Makefile. A typical
+ example would be to generate documentation for a software project. Po-
+ tentially the interaction with the rest of the rules in the Makefile
+ could be quite complicated, for example if some of the source files for
+ a LaTeX document are generated by the project's software.
+
+ In this section, I give a couple of examples of how latexmk can be use-
+ fully invoked from a Makefile. The examples use specific features of
+ current versions of GNU make, which is the default on both linux and
+ OS-X systems. They may need modifications for other versions of make.
+
+ The simplest method is simply to delegate all the relevant tasks to la-
+ texmk, as is suitable for a straightforward LaTeX document. For this a
+ suitable Makefile is like
+
+ .PHONY : FORCE_MAKE
+ all : try.pdf
+ %.pdf : %.tex FORCE_MAKE
+ latexmk -pdf -dvi- -ps- $<
+
+ (Note: the last line must be introduced by a tab for the Makefile to
+ function correctly!) Naturally, if making try.pdf from its associated
+ LaTeX file try.tex were the only task to be performed, a direct use of
+ latexmk without a Makefile would normally be better. The benefit of
+ using a Makefile for a LaTeX document would be in a larger project,
+ where lines such as the above would be only be a small part of a larger
+ Makefile.
+
+ The above example has a pattern rule for making a .pdf file from a .tex
+ file, and it is defined to use latexmk in the obvious way. There is a
+ conventional default target named "all", with a prerequisite of
+ try.pdf. So when make is invoked, by default it makes try.pdf. The
+ only complication is that there may be many source files beyond
+ try.tex, but these aren't specified in the Makefile, so changes in them
+ will not by themselves cause latexmk to be invoked. Instead, the pat-
+ tern rule is equipped with a "phony" prerequisite FORCE_MAKE; this has
+ the effect of causing the rule to be always out-of-date, so that
+
+
+
+ 18 June 2019 67
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ latexmk is always run. It is latexmk that decides whether any action
+ is needed, e.g., a rerun of pdflatex. Effectively the Makefile dele-
+ gates all decisions to latexmk, while make has no knowledge of the list
+ of source files except for primary LaTeX file for the document. If
+ there are, for example, graphics files to be made, these must be made
+ by custom dependencies configured in latexmk.
+
+ But something better is needed in more complicated situations, for ex-
+ ample, when the making of graphics files needs to be specified by rules
+ in the Makefile. To do this, one can use a Makefile like the follow-
+ ing:
+
+ TARGETS = document1.pdf document2.pdf
+ DEPS_DIR = .deps
+ LATEXMK = latexmk -recorder -use-make -deps \
+ -e 'warn qq(In Makefile, turn off custom dependencies\n);' \
+ -e '@cus_dep_list = ();' \
+ -e 'show_cus_dep();'
+ all : $(TARGETS)
+ $(foreach file,$(TARGETS),$(eval -include $(DEPS_DIR)/$(file)P))
+ $(DEPS_DIR) :
+ mkdir $@
+ %.pdf : %.tex
+ if [ ! -e $(DEPS_DIR) ]; then mkdir $(DEPS_DIR); fi
+ $(LATEXMK) -pdf -dvi- -ps- -deps-out=$(DEPS_DIR)/$@P $<
+ %.pdf : %.fig
+ fig2dev -Lpdf $< $@
+
+ (Again, the lines containing the commands for the rules should be
+ started with tabs.) This example was inspired by how GNU automake han-
+ dles automatic dependency tracking of C source files.
+
+ After each run of latexmk, dependency information is put in a file in
+ the .deps subdirectory. The Makefile causes these dependency files to
+ be read by make, which now has the full dependency information for each
+ target .pdf file. To make things less trivial it is specificed that
+ two files document1.pdf and document2.pdf are the targets. The depen-
+ dency files are .deps/document1.pdfP and .deps/document2.pdfP.
+
+ There is now no need for the phony prerequisite for the rule to make
+ .pdf files from .tex files. But I have added a rule to make .pdf files
+ from .fig files produced by the xfig program; these are commonly used
+ for graphics insertions in LaTeX documents. Latexmk is arranged to
+ output a dependency file after each run. It is given the -recorder op-
+ tion, which improves its detection of files generated during a run of
+ pdflatex; such files should not be in the dependency list. The -e op-
+ tions are used to turn off all custom dependencies, and to document
+ this. Instead the -use-make is used to delegate the making of missing
+ files to make itself.
+
+ Suppose in the LaTeX file there is a command \includegraphics{graph},
+ and an xfig file "graph.fig" exists. On a first run, pdflatex reports
+ a missing file, named "graph". Latexmk succeeds in making "graph.pdf"
+ by calling "make graph.pdf", and after completion of its work, it lists
+
+
+
+ 18 June 2019 68
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ "fig.pdf" among the dependents of the file latexmk is making. Then let
+ "fig.fig" be updated, and then let make be run. Make first remakes
+ "fig.pdf", and only then reruns latexmk.
+
+ Thus we now have a method by which all the subsidiary processing is
+ delegated to make.
+
+
+SEE ALSO
+ latex(1), bibtex(1), lualatex(1), pdflatex(1), xelatex(1).
+
+BUGS
+ Sometimes a viewer (gv) tries to read an updated .ps or .pdf file after
+ its creation is started but before the file is complete. Work around:
+ manually refresh (or reopen) display. Or use one of the other preview-
+ ers and update methods.
+
+ (The following isn't really a bug, but concerns features of preview-
+ ers.) Preview continuous mode only works perfectly with certain pre-
+ viewers: Xdvi on UNIX/Linux works for dvi files. Gv on UNIX/Linux
+ works for both postscript and pdf. Ghostview on UNIX/Linux needs a
+ manual update (reopen); it views postscript and pdf. Gsview under MS-
+ Windows works for both postscript and pdf, but only reads the updated
+ file when its screen is refreshed. Acroread under UNIX/Linux views
+ pdf, but the file needs to be closed and reopened to view an updated
+ version. Under MS-Windows, acroread locks its input file and so the
+ pdf file cannot be updated. (Remedy: configure latexmk to use suma-
+ trapdf instead.)
+
+THANKS TO
+ Authors of previous versions. Many users with their feedback, and es-
+ pecially David Coppit (username david at node coppit.org) who made many
+ useful suggestions that contributed to version 3, and Herbert Schulz.
+ (Please note that the e-mail addresses are not written in their stan-
+ dard form to avoid being harvested too easily.)
+
+AUTHOR
+ Current version, by John Collins (username jcc8 at node psu.edu).
+ (Version 4.65).
+
+ Released version can be obtained from CTAN:
+ <http://www.ctan.org/pkg/latexmk/>, and from the author's website
+ <http://www.personal.psu.edu/jcc8/latexmk/>.
+ Modifications and enhancements by Evan McLean (Version 2.0)
+ Original script called "go" by David J. Musliner (RCS Version 3.2)
+
+
+
+
+
+
+
+
+
+
+
+
+ 18 June 2019 69
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 18 June 2019 70
+
+