Merge lp:~matttbe/ubuntu/raring/latexmk/v4.35 into lp:ubuntu/raring/latexmk

Proposed by Matthieu Baerts
Status: Needs review
Proposed branch: lp:~matttbe/ubuntu/raring/latexmk/v4.35
Merge into: lp:ubuntu/raring/latexmk
Diff against target: 14022 lines (+6561/-3478)
30 files modified
CHANGES (+138/-0)
INSTALL (+1/-1)
README (+27/-8)
debian/changelog (+142/-0)
debian/compat (+1/-1)
debian/control (+7/-5)
debian/copyright (+1/-6)
debian/patches/00list (+0/-1)
debian/patches/rc-system-files.patch (+9/-11)
debian/patches/series (+1/-0)
debian/rules (+7/-14)
debian/source/format (+1/-0)
debian/watch (+8/-0)
example_rcfiles/README (+13/-0)
example_rcfiles/Sweave_latexmkrc (+57/-0)
example_rcfiles/TeX4ht-latexmkrc (+33/-0)
example_rcfiles/asymptote_latexmkrc (+1/-1)
example_rcfiles/glossary_latexmkrc (+6/-6)
example_rcfiles/mpost_latexmkrc (+26/-0)
example_rcfiles/pdflatexmkrc (+42/-42)
example_rcfiles/sagetex_latexmkrc (+2/-2)
example_rcfiles/sweave_latexmkrc (+57/-0)
example_rcfiles/xelatex_latexmkrc (+20/-0)
extra-scripts/htlatexonly (+10/-0)
extra-scripts/myhtlatex2 (+19/-0)
latexmk.1 (+542/-78)
latexmk.bat (+5/-5)
latexmk.pl (+1454/-524)
latexmk.ps (+2451/-1821)
latexmk.txt (+1480/-952)
To merge this branch: bzr merge lp:~matttbe/ubuntu/raring/latexmk/v4.35
Reviewer Review Type Date Requested Status
Andrew Starr-Bochicchio (community) Approve
Review via email: mp+141388@code.launchpad.net

Description of the change

Hello,

As you can see, Latexmk is available in Debian and Ubuntu repositories but it's an old version (4.24 - released more than one year ago).

A new version has been released less than two months ago and it's still not available in Debian repositories. It seems that the official maintainer doesn't answer to these bugs reports:
 * http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=668926 => [PATCH] latexmk: Helping to update to packaging format 3.0
 * http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=693126 => latexmk: New upstream release available + watch file

Is it possible to upload this new version to Ubuntu repositories because it will be needed by the new version of LaTeXila (and also because it fixes other bugs, please have a look at this debian/changelog file). Or should I first report this bug to another Debian dev? Or is it easier to upload this new version to Ubuntu repos first because Debian Testing migration has been frozen?
This new version has been uploaded to mentors.debian.net but I'm not sure that I'll receive an answer from the official Debian maintainer soon.

Thank you for your help,

Matt

PS: this new version can be easily tested by using this package: https://launchpad.net/~matttbe/+archive/experimental-debian-build/+sourcepub/2900053/+listing-archive-extra

To post a comment you must log in.
Revision history for this message
Andrew Starr-Bochicchio (andrewsomething) wrote :

Looks good, but I did make a few tweaks to the changelog. I condensed it to one entry as the proposed Debian versions haven't actually entered the Debian archive. I also dropped the upstream changelog as it's really more verbose than we need for debian/changelog.

Thanks for your work!

review: Approve
Revision history for this message
Matthieu Baerts (matttbe) wrote :

Thank you for these changes and for your support! :)

Matt

Unmerged revisions

9. By Matthieu Baerts

* New upstream release. (LP: #1094164)
* Upstream ChangeLog:
  - 4.35 dated 11 November 2012.
    * Corrects bug that fls file is incorrectly parsed when using a
      combination of cygwin and a native MS-Windows TeX program.
    * Corrects bug that old dependency information was retained when using
      the --gg option.
  - 4.34 dated 1 October 2012.
    * Corrects non-optimality that latexmk may do extra runs of (pdf)latex
      when a file is read and written during a run of (pdf)latex, but the
      file is only read after being written.
  - 4.33c dated 19 August 2012.
    * Corrects infinite loop in error messages when the maximum number of
      passes through latex/pdflatex is exceeded.
  - 4.33b dated 12 August 2012.
    * Documentation improvements, including documentation of the many
      options for the (pdf)latex programs that are supported by latexmk.
  - 4.33a dated 8 August 2012.
    * Fix slowness of v. 4.33 under Cygwin.
  - 4.33 dated 6 August 2012.
    * 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.
  - 4.31 dated 30 March 2012.
    * Implement most options allowed by latex and pdflatex.
    * Add -M -MP and -MF options, like gcc.
    * Recorder option is now on by default.
    * 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.
  - 4.30a dated 9 December 2011.
    * 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 correctly on MSWin systems.
    * Documentation of $search_path_separator variable.
    * Correct some bugs in v. 4.30 that manifested themselves under MSWin
      especially with Cygwin.
  - 4.29a dated 7 December 2011.
    * 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.
  - 4.28c dated 1 December 2011.
    * 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.
  - 4.28a dated 28 November 2011.
    * 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.
    * Correct duplicate invocations of dvipdf, ps2pdf
  - 4.27a dated 10 October 2011.
    * 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.
  - 4.26 dated 9 August 2011.
    * Make compatible with biber 0.9.4.
    * Fix some bugs in error reporting.
  - 4.25 dated 7 July 2011.
    * 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.
* debian/patches:
  - Refreshed
* debian/control:
  - Replaced gs-common by ghostscript as Suggested package Closes: #649700
* Previous changes by Antonio Ospite (4.24-1.2) Closes: #693126 and by
  Jari Aalto (4.24-1.1) Closes: #668926

8. By Matthieu Baerts

* debian/patches/rc-system-files.patch:
  - This file has a wrong name according to debian/patches/series

7. By Matthieu Baerts

Added debian/watch file

6. By Matthieu Baerts

* Non-maintainer upload.
* Remove deprecated dpatch and upgrade to packaging format "3.0 quilt".
* Update to Standards-Version to 3.9.3 and debhelper to 9.
* Add required build-arch and build-indep targets to rules file.
* Fix old-fsf-address-in-copyright-file (Lintian).
* Fix copyright-refers-to-symlink-license (Lintian).
* Fix capitalization-error-in-description LaTeX (Lintian).
* Fix no-homepage-field (Lintian).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGES'
2--- CHANGES 2011-06-11 22:09:09 +0000
3+++ CHANGES 2012-12-28 00:31:23 +0000
4@@ -257,3 +257,141 @@
5 aren't in the current directory (by use of kpsewhich). This was
6 previously done for bibtex but not biber.
7
8+From v. 4.24 to v. 4.25
9+ Fix to evade apparent cygwin bug that prevented system
10+ rc-file from being read.
11+ Diagnostic for unreadable rc-file.
12+ Add deps output file to target part of dependency information
13+
14+From v. 4.25 to v. 4.26
15+ Make compatible with biber 0.9.4.
16+ Fix some bugs in error reporting.
17+
18+From v. 4.26 to v. 4.27a
19+ Deal with problem that making of ps or pdf file via a temporary
20+ file fails if the command making it has no %D placeholder
21+ Add png to list of graphics extensions for pdflatex
22+ Add -norc option that prevents auto reading of rc files.
23+ Options -aux-directory -output-directory like those of (pdf)latex,
24+ to set the output directories of (pdf)latex. (-aux-directory
25+ is MiKTeX only). Corresponding configuration variables, and
26+ placeholders for command specification.
27+
28+From v. 4.27a to 4.28
29+ Correct handling of situations where some file(s) needed by bibtex
30+ (or biber) don't exist. Previously latexmk incorrectly stopped
31+ with an error message instead of continuing.
32+
33+From v. 4.28 to 4.28a
34+ Correct duplicate making of view file
35+
36+From v. 4.28a to 4.28c
37+ When biber doesn't find the bib file, latexmk treats this as a
38+ warning rather than a fatal error, so further processing
39+ can continue normally.
40+ Latexmk now parses correctly error messages from biber v. 0.9.7.
41+
42+From v. 4.28c to 4.29a
43+ Latexmk now works with the feynmp package and mpost,
44+ provided a suitable custom dependency is defined. (See the
45+ example latexmkrc fragment mpost_latexmkrc in the
46+ example_rcfiles directory in the latexmk distribution.)
47+ If output directory is set, arrange that dvips can find files
48+ there.
49+ In searching for cus-deps that can make a missing file, look in
50+ $out_dir.
51+ Solves problem that sometimes dvips and dvipdf weren't run when
52+ they should have been. (The problem only arose with certain
53+ changes in eps files being made within a minute of the previous
54+ run.)
55+
56+From v. 4.29a to 4.30a
57+ Fix use of bibtex so that it works correctly when $aux_dir and/or
58+ $out_dir are set.
59+ Use OS-dependent search path separator when when manipulating
60+ TEXINPUTS, etc. Then use of -output-directory and
61+ -aux-directory options should work on MSWin systems.
62+ Documentation of $search_path_separator variable.
63+
64+From v. 4.30a to 4.31
65+ Add -M -MP and -MF options, like gcc.
66+ Recorder option is now on by default.
67+ Add options reproducing most options of (pdf)latex (list from both
68+ TeXLive and MikTeX versions).
69+ Options NOT implemented by latexmk at all:
70+ -ini and -initialize since they refer to operations
71+ not supported by latexmk
72+ -includedirectory=dir its support needs extra code in
73+ latexmk, not currently written
74+ Options differently processed by latexmk:
75+ -help
76+ -version
77+ -quiet
78+ Options that are passed to (pdf)latex but that also have special
79+ processing by latexmk
80+ -aux-directory=dir
81+ -output-directory=dir
82+ -recorder
83+ Add -latexoption=... option to latexmk
84+ Add -xelatex option for use of xelatex
85+ Change OS-X default for pdf previewer command to open
86+ Command specification string can start with "include routine" to
87+ invoke a Perl subroutine instead of an external cmd.
88+ Viewers are detached by default. (The start keyword is now normally
89+ superfluous in command specifications.)
90+ Keyword nostart added in command specification.
91+ Add configuration variables $compiling_cmd, $success_cmd,
92+ $failure_cmd. These specify external commands (if any) to be
93+ executed during latexmk's continuous preview mode at the
94+ following points: $compiling_cmd at the start of compilation,
95+ $success_cmd at the end of a successful compilation, and
96+ $failure_cmd at the end of an unsuccessful compilation. They
97+ can be used, for example, to show the progress of compilation by
98+ setting the titles of editor and/or previewer windows.
99+ If aux and/or output directories are specified but don't exist,
100+ make them.
101+ Remove excessive repetition of tests for changes of source files
102+ (improves performance of latexmk in some situations).
103+ Documentation improvements.
104+ Minor bug corrections.
105+
106+From v. 4.31 to 4.33a
107+ Improve operation under MSWindows: substitute "\" for "/" for
108+ directory separator in command lines, deal consistently with
109+ directory separator, which can be both "\" and "/".
110+ Correct some bugs that interfered with use of auxiliary directory
111+ and output directory for files generated by (pdf)latex,
112+ especially with MiKTeX.
113+ Fix problems caused because in the log and fls files MiKTeX writes
114+ absolute path for many filenames at and below current directory,
115+ and is inconsistent in its use of "/" vs. "\" as directory
116+ separator.
117+ Add $dvipdf_silent_switch configuration variable.
118+ Improve handling of errors in (pdf)latex; previously latexmk would
119+ give up processing in some situations continuing is correct.
120+ Documentation corrections/improvements.
121+ Reduce number of warnings in silent operation.
122+ Cure slowness of v. 4.33 under Cygwin.
123+
124+From v. 4.33a to 4.33b
125+ Documentation improvements.
126+ Improve text displayed by using -showextraoptions option.
127+
128+From v. 4.33b to 4.33c
129+ Correct infinite loop when maximum passes through latex/pdflatex
130+ are exceeded
131+
132+From v. 4.33c to 4.34
133+ Correct non-optimality that if (pdf)latex reads a file only after
134+ it has been written in the same run, the file is not a true
135+ source file, but nevertheless latexmk treats it as a source
136+ file. Thus changes in the file sometimes caused latexmk to make
137+ unnecessary (but otherwise innocuous) extra runs of (pdflatex).
138+
139+From v. 4.34 to 4.35
140+ Correct bug in parsing fls file from native MS-Windows LaTeX (e.g.,
141+ MiKTeX) when latexmk is run under cygwin. (The names of some
142+ files used by latexmk incorrectly contained a CR character.)
143+ Correct bug that when the --gg option is used, the rule database
144+ from the old fdb file was used instead of being cleared.
145+
146
147=== modified file 'INSTALL'
148--- INSTALL 2011-06-11 22:09:09 +0000
149+++ INSTALL 2012-12-28 00:31:23 +0000
150@@ -1,6 +1,6 @@
151 INSTALLING latexmk
152 ==================
153- (Version 4.24, 7 May 2011)
154+ (Version 4.35, 11 November 2012)
155
156 John Collins
157 Physics Department
158
159=== modified file 'README'
160--- README 2011-06-11 22:09:09 +0000
161+++ README 2012-12-28 00:31:23 +0000
162@@ -1,5 +1,5 @@
163-Latexmk, version 4.24, 7 May 2011
164----------------------------------
165+Latexmk, version 4.35, 11 November 2012
166+---------------------------------------
167
168 Latexmk completely automates the process of generating a LaTeX
169 document. Essentially, it is a highly specialized cousin of the
170@@ -92,14 +92,17 @@
171
172 John Collins
173 ---------------------------- "latexmk -h" ----------------------------
174-Latexmk 4.24: Automatic LaTeX document generation routine
175+Latexmk 4.35: Automatic LaTeX document generation routine
176
177 Usage: latexmk [latexmk_options] [filename ...]
178
179 Latexmk_options:
180- -bibtex - use bibtex when needed (default)
181- -bibtex- - never use bibtex
182- -bibtex-cond - use bibtex when needed, but only if the bib files exist
183+ -aux-directory=dir or -auxdir=dir
184+ - set name of directory for auxiliary files (aux, log)
185+ - Currently this only works with MiKTeX
186+ -bibtex - use bibtex when needed (default)
187+ -bibtex- - never use bibtex
188+ -bibtex-cond - use bibtex when needed, but only if the bib files exist
189 -bm <message> - Print message across the page when converting to postscript
190 -bi <intensity> - Set contrast or intensity of banner
191 -bs <scale> - Set scale for banner
192@@ -140,10 +143,17 @@
193 -l- - turn off -l
194 -latex=<program> - set program used for latex.
195 (replace '<program>' by the program name)
196+ -latexoption=<option> - add the given option to the (pdf)latex command
197+ -M - Show list of dependent files after processing
198+ -MF file - Specifies name of file to receives list dependent files
199+ -MP - List of dependent files includes phony target for each source file.
200 -new-viewer - in -pvc mode, always start a new viewer
201 -new-viewer- - in -pvc mode, start a new viewer only if needed
202 -nobibtex - never use bibtex
203 -nodependents - Do not show list of dependent files after processing
204+ -norc - omit automatic reading of system, user and project rc files
205+ -output-directory=dir or -outdir=dir
206+ - set name of directory for output files
207 -pdf - generate pdf by pdflatex
208 -pdfdvi - generate pdf by dvipdf
209 -pdflatex=<program> - set program used for pdflatex.
210@@ -164,12 +174,17 @@
211 on force mode, so errors do not cause latexmk to stop.)
212 (Side effect: turn off ordinary preview mode.)
213 -pvc- - turn off -pvc
214+ -quiet - silence progress messages from called programs
215 -r <file> - Read custom RC file
216+ (N.B. This file could override options specified earlier
217+ on the command line.)
218 -recorder - Use -recorder option for (pdf)latex
219 (to give list of input and output files)
220 -recorder- - Do not use -recorder option for (pdf)latex
221 -rules - Show list of rules after processing
222 -rules- - Do not show list of rules after processing
223+ -showextraoptions - Show other allowed options that are simply passed
224+ as is to latex and pdflatex
225 -silent - silence progress messages from called programs
226 -time - show CPU time used
227 -time- - don't show CPU time used
228@@ -183,11 +198,15 @@
229 -view=none - no viewer is used
230 -view=ps - viewer is for ps
231 -view=pdf - viewer is for pdf
232+ -xelatex - use xelatex for processing files to pdf
233+
234 filename = the root filename of LaTeX document
235
236 -p, -pv and -pvc are mutually exclusive
237 -h, -c and -C override all other options.
238 -pv and -pvc require one and only one filename specified
239 All options can be introduced by '-' or '--'. (E.g., --help or -help.)
240-Contents of RC file specified by -r overrides options specified
241- before the -r option on the command line
242+
243+In addition, latexmk recognizes many other options that are passed to
244+latex and/or pdflatex without interpretation by latexmk. Run latexmk
245+with the option -showextraoptions to see a list of these
246
247=== modified file 'debian/changelog'
248--- debian/changelog 2011-06-11 22:09:09 +0000
249+++ debian/changelog 2012-12-28 00:31:23 +0000
250@@ -1,3 +1,145 @@
251+latexmk (1:4.35-0ubuntu1) raring; urgency=low
252+
253+ * New upstream release. (LP: #1094164)
254+ * Upstream ChangeLog:
255+ - 4.35 dated 11 November 2012.
256+ * Corrects bug that fls file is incorrectly parsed when using a
257+ combination of cygwin and a native MS-Windows TeX program.
258+ * Corrects bug that old dependency information was retained when using
259+ the --gg option.
260+ - 4.34 dated 1 October 2012.
261+ * Corrects non-optimality that latexmk may do extra runs of (pdf)latex
262+ when a file is read and written during a run of (pdf)latex, but the
263+ file is only read after being written.
264+ - 4.33c dated 19 August 2012.
265+ * Corrects infinite loop in error messages when the maximum number of
266+ passes through latex/pdflatex is exceeded.
267+ - 4.33b dated 12 August 2012.
268+ * Documentation improvements, including documentation of the many
269+ options for the (pdf)latex programs that are supported by latexmk.
270+ - 4.33a dated 8 August 2012.
271+ * Fix slowness of v. 4.33 under Cygwin.
272+ - 4.33 dated 6 August 2012.
273+ * Improve operation under MSWindows: substitute "\" for "/" for
274+ directory separator in command lines, deal consistently with
275+ directory separator, which can be both "\" and "/".
276+ * Correct some bugs that interfered with use of auxiliary directory
277+ and output directory for files generated by (pdf)latex, especially
278+ with MiKTeX.
279+ * Fix problems caused because in the log and fls files MiKTeX writes
280+ absolute path for many filenames at and below current directory, and
281+ is inconsistent in its use of "/" vs. "\" as directory separator.
282+ * Add $dvipdf_silent_switch configuration variable.
283+ * Improve handling of errors in (pdf)latex; previously latexmk would
284+ give up processing in some situations continuing is correct.
285+ * Documentation corrections/improvements.
286+ * Reduce number of warnings in silent operation.
287+ - 4.31 dated 30 March 2012.
288+ * Implement most options allowed by latex and pdflatex.
289+ * Add -M -MP and -MF options, like gcc.
290+ * Recorder option is now on by default.
291+ * Add -latexoption=... option to latexmk.
292+ * Add -xelatex option for use of xelatex.
293+ * Change OS-X default for pdf previewer command to open.
294+ * Command specification string can start with "include routine" to
295+ invoke a Perl subroutine instead of an external cmd.
296+ * Viewers are detached by default. (The start keyword is now normally
297+ superfluous in command specifications.)
298+ * Keyword nostart added in command specification.
299+ * Add configuration variables $compiling_cmd, $success_cmd,
300+ $failure_cmd. These specify external commands (if any) to be
301+ executed during latexmk's continuous preview mode at the following
302+ points: $compiling_cmd at the start of compilation, $success_cmd at
303+ the end of a successful compilation, and $failure_cmd at the end of
304+ an unsuccessful compilation. They can be used, for example, to show
305+ the progress of compilation by setting the titles of editor and/or
306+ previewer windows.
307+ * If aux and/or output directories are specified but don't exist, make
308+ them.
309+ * Remove excessive repetition of tests for changes of source files
310+ (improves performance of latexmk in some situations).
311+ * Documentation improvements.
312+ * Minor bug corrections.
313+ - 4.30a dated 9 December 2011.
314+ * Fix use of bibtex so that it works correctly when $aux_dir and/or
315+ $out_dir are set.
316+ * Use OS-dependent search path separator when when manipulating
317+ TEXINPUTS, etc. Then use of -output-directory and -aux-directory
318+ options should work correctly on MSWin systems.
319+ * Documentation of $search_path_separator variable.
320+ * Correct some bugs in v. 4.30 that manifested themselves under MSWin
321+ especially with Cygwin.
322+ - 4.29a dated 7 December 2011.
323+ * Latexmk now works with the feynmp package and mpost, provided a
324+ suitable custom dependency is defined. (See the example latexmkrc
325+ fragment mpost_latexmkrc in the example_rcfiles directory in the
326+ latexmk distribution.)
327+ * If output directory is set, arrange that dvips can find files there.
328+ * In searching for cus-deps that can make a missing file, look in
329+ $out_dir.
330+ - 4.28c dated 1 December 2011.
331+ * When biber doesn't find the bib file, latexmk treats this as a
332+ warning rather than a fatal error, so further processing can
333+ continue normally.
334+ * Latexmk now parses correctly error messages from biber v. 0.9.7.
335+ - 4.28a dated 28 November 2011.
336+ * Correct handling of situations where some file(s) needed by bibtex
337+ (or biber) don't exist. Previously latexmk incorrectly stopped with
338+ an error message instead of continuing.
339+ * Correct duplicate invocations of dvipdf, ps2pdf
340+ - 4.27a dated 10 October 2011.
341+ * Deal with problem that making of ps or pdf file via a temporary file
342+ fails if the command making it has no %D placeholder
343+ * Add png to list of graphics extensions for pdflatex
344+ * Add -norc option that prevents auto reading of rc files.
345+ * Options -aux-directory -output-directory like those of (pdf)latex,
346+ to set the output directories of (pdf)latex. (-aux-directory is
347+ MiKTeX only). Corresponding configuration variables, and
348+ placeholders for command specification.
349+ - 4.26 dated 9 August 2011.
350+ * Make compatible with biber 0.9.4.
351+ * Fix some bugs in error reporting.
352+ - 4.25 dated 7 July 2011.
353+ * Fix to evade apparent cygwin bug that prevented system rc-file from
354+ being read.
355+ * Diagnostic for unreadable rc-file.
356+ * Add deps output file to target part of dependency information.
357+ * debian/patches:
358+ - Refreshed
359+ * debian/control:
360+ - Replaced gs-common by ghostscript as Suggested package Closes: #649700
361+ * Previous changes by Antonio Ospite (4.24-1.2) Closes: #693126 and by
362+ Jari Aalto (4.24-1.1) Closes: #668926
363+
364+ -- Matthieu Baerts (matttbe) <matttbe@ubuntu.com> Fri, 28 Dec 2012 00:24:43 +0100
365+
366+latexmk (1:4.24-1.2ubuntu1) raring; urgency=low
367+
368+ * debian/patches/rc-system-files.patch:
369+ - This file has a wrong name according to debian/patches/series
370+
371+ -- Matthieu Baerts (matttbe) <matttbe@ubuntu.com> Thu, 27 Dec 2012 17:45:42 +0100
372+
373+latexmk (1:4.24-1.2) unstable; urgency=low
374+
375+ [ Antonio Ospite ]
376+ * Added debian/watch file
377+
378+ -- Matthieu Baerts (matttbe) <matttbe@ubuntu.com> Thu, 27 Dec 2012 17:15:34 +0100
379+
380+latexmk (1:4.24-1.1) unstable; urgency=low
381+
382+ * Non-maintainer upload.
383+ * Remove deprecated dpatch and upgrade to packaging format "3.0 quilt".
384+ * Update to Standards-Version to 3.9.3 and debhelper to 9.
385+ * Add required build-arch and build-indep targets to rules file.
386+ * Fix old-fsf-address-in-copyright-file (Lintian).
387+ * Fix copyright-refers-to-symlink-license (Lintian).
388+ * Fix capitalization-error-in-description LaTeX (Lintian).
389+ * Fix no-homepage-field (Lintian).
390+
391+ -- Jari Aalto <jari.aalto@cante.net> Sun, 15 Apr 2012 20:25:54 +0300
392+
393 latexmk (1:4.24-1) unstable; urgency=low
394
395 * New upstream release (Closes: #564199).
396
397=== modified file 'debian/compat'
398--- debian/compat 2006-06-12 00:43:25 +0000
399+++ debian/compat 2012-12-28 00:31:23 +0000
400@@ -1,1 +1,1 @@
401-5
402+9
403
404=== modified file 'debian/control'
405--- debian/control 2011-06-11 22:09:09 +0000
406+++ debian/control 2012-12-28 00:31:23 +0000
407@@ -1,19 +1,21 @@
408 Source: latexmk
409 Section: tex
410 Priority: optional
411-Build-Depends: debhelper (>= 5.0.0), dpatch
412-Maintainer: OHURA Makoto <ohura@debian.org>
413-Standards-Version: 3.9.2
414+Build-Depends: debhelper (>= 9)
415+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
416+XSBC-Original-Maintainer: OHURA Makoto <ohura@debian.org>
417+Standards-Version: 3.9.3
418+Homepage: http://www.phys.psu.edu/~collins/software/latexmk-jcc
419
420 Package: latexmk
421 Architecture: all
422 Depends: perl, texlive-latex-base, ${misc:Depends}
423-Suggests: gs-common
424+Suggests: ghostscript
425 Recommends: xpdf-reader | pdf-viewer, gv | postscript-viewer
426 Description: Perl script for running LaTeX the correct number of times
427 Latexmk runs LaTeX the correct number of times to resolve cross references,
428 etc; it also runs auxiliary programs (bibtex, makeindex if necessary, and
429 dvips and/or a previewer as requested). It has a number of other useful
430- capabilities, for example to start a previewer and then run latex whenever the
431+ capabilities, for example to start a previewer and then run LaTeX whenever the
432 source files are updated, so that the previewer gives an up-to-date view of
433 the document.
434
435=== modified file 'debian/copyright'
436--- debian/copyright 2006-06-12 00:43:25 +0000
437+++ debian/copyright 2012-12-28 00:31:23 +0000
438@@ -28,10 +28,5 @@
439 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
440 GNU General Public License for more details.
441
442-You should have received a copy of the GNU General Public License
443-along with this program; if not, write to the Free Software
444-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
445-
446-
447 On Debian GNU/Linux systems, the complete text of the GNU General
448-Public License can be found in `/usr/share/common-licenses/GPL'.
449+Public License can be found in `/usr/share/common-licenses/GPL-2'.
450
451=== removed file 'debian/patches/00list'
452--- debian/patches/00list 2006-06-12 00:43:25 +0000
453+++ debian/patches/00list 1970-01-01 00:00:00 +0000
454@@ -1,1 +0,0 @@
455-rc_system_files
456
457=== renamed file 'debian/patches/rc_system_files.dpatch' => 'debian/patches/rc-system-files.patch'
458--- debian/patches/rc_system_files.dpatch 2006-06-12 00:43:25 +0000
459+++ debian/patches/rc-system-files.patch 2012-12-28 00:31:23 +0000
460@@ -1,14 +1,12 @@
461-#! /bin/sh /usr/share/dpatch/dpatch-run
462-## rc_system_files.dpatch by Florian Ragwitz <rafl@debian.org>
463-##
464-## All lines beginning with `## DP:' are a description of the patch.
465-## DP: add /etc/LatexMk to @rc_system_files
466-
467-@DPATCH@
468-
469---- latexmk-307a.orig/latexmk.pl 2006-06-12 01:39:17.959196512 +0200
470-+++ latexmk-307a/latexmk.pl 2006-06-12 01:39:56.378355912 +0200
471-@@ -537,7 +537,8 @@
472+From: Florian Ragwitz <rafl@debian.org>
473+Subject: add /etc/LatexMk to @rc_system_files
474+
475+
476+Index: latexmk/latexmk.pl
477+===================================================================
478+--- latexmk.orig/latexmk.pl 2012-12-27 17:50:00.211349000 +0100
479++++ latexmk/latexmk.pl 2012-12-27 17:55:02.858109192 +0100
480+@@ -895,7 +895,8 @@
481 ## /usr/local/lib/latexmk/LatexMk is put in the list for
482 ## compatibility with older versions of latexmk.
483 @rc_system_files =
484
485=== added file 'debian/patches/series'
486--- debian/patches/series 1970-01-01 00:00:00 +0000
487+++ debian/patches/series 2012-12-28 00:31:23 +0000
488@@ -0,0 +1,1 @@
489+rc-system-files.patch
490
491=== modified file 'debian/rules'
492--- debian/rules 2006-06-12 00:43:25 +0000
493+++ debian/rules 2012-12-28 00:31:23 +0000
494@@ -1,28 +1,21 @@
495 #!/usr/bin/make -f
496
497-clean: clean1 unpatch
498-clean1:
499+clean:
500 dh_testdir
501 dh_testroot
502 rm -f install-stamp
503 dh_clean
504
505-build: patch
506-
507-patch: patch-stamp
508-patch-stamp:
509- dpatch apply-all
510- touch patch-stamp
511-
512-unpatch:
513- dpatch deapply-all
514- rm -rf patch-stamp debian/patched
515+build-arch: build
516+build-indep: build
517+
518+build:
519
520 install: install-stamp
521 install-stamp:
522 dh_testdir
523 dh_testroot
524- dh_clean -k
525+ dh_prep
526 dh_installdirs
527 install -m755 $(CURDIR)/latexmk.pl $(CURDIR)/debian/latexmk/usr/bin/latexmk
528 install -m644 $(CURDIR)/debian/config $(CURDIR)/debian/latexmk/etc/LatexMk
529@@ -45,4 +38,4 @@
530
531 binary: binary-arch binary-indep
532
533-.PHONY: clean build install binary-indep binary-arch binary patch unpatch
534+.PHONY: clean build install binary-indep binary-arch binary
535
536=== added directory 'debian/source'
537=== added file 'debian/source/format'
538--- debian/source/format 1970-01-01 00:00:00 +0000
539+++ debian/source/format 2012-12-28 00:31:23 +0000
540@@ -0,0 +1,1 @@
541+3.0 (quilt)
542
543=== added file 'debian/watch'
544--- debian/watch 1970-01-01 00:00:00 +0000
545+++ debian/watch 2012-12-28 00:31:23 +0000
546@@ -0,0 +1,8 @@
547+version=3
548+
549+# In the pattern below the first digit is isolated so to have a dotted
550+# version number in the debian packages, the upstream uses this dotted
551+# form in the changelog but removes the dot in the file names.
552+http://www.phys.psu.edu/~collins/software/latexmk-jcc/versions.html \
553+ latexmk-([\d])([\d]+[a-z]*).zip \
554+ debian uupdate
555
556=== modified file 'example_rcfiles/README'
557--- example_rcfiles/README 2011-06-11 22:09:09 +0000
558+++ example_rcfiles/README 2012-12-28 00:31:23 +0000
559@@ -20,3 +20,16 @@
560 examples. (The file Latexmk321jTeXShop.zip is the one you want.)
561 It shows how to use glossaries, epstopdf, pdftricks and pst-pdf.
562
563+4. I have generally arranged for filenames to be quoted on command
564+ lines, e.g.,
565+
566+ system( "makeindex -o \"$_[0].lnd\" \"$_[0].ldx\"" );
567+
568+ In many cases the quotes may be omitted, as in
569+
570+ system( "makeindex -o $_[0].lnd $_[0].ldx" );
571+
572+ But it is preferable to leave the quotes in, since they provide
573+ safety against special characters in filenames. The double quotes
574+ appear not to cause problems in all situations that I have tried.
575+
576
577=== added file 'example_rcfiles/Sweave_latexmkrc'
578--- example_rcfiles/Sweave_latexmkrc 1970-01-01 00:00:00 +0000
579+++ example_rcfiles/Sweave_latexmkrc 2012-12-28 00:31:23 +0000
580@@ -0,0 +1,57 @@
581+# This is to allow the use of Sweave with latexmk, and in addition to
582+# make synctex work properly with it.
583+# SEE THE IMPORTANT NOTES below.
584+#
585+# Sweave (http://www.stat.uni-muenchen.de/~leisch/Sweave/) is a tool
586+# that allows to embed the R code for complete data analyses in latex
587+# documents. The user edits a file with an extension like .Rnw, and
588+# the .tex file is generated from this.
589+#
590+# Four problems are solved by the code below:
591+# 1. Generate the .tex file automatically.
592+# 2. Arrange not to re-run unmodified chunks of R code. (A pure
593+# optimization.)
594+# 3. Fix the execution environment for (pdf)latex.
595+# 4. Deal with synctex: If the user wants to use synctex
596+# (www.tug.org/TUGboat/tb29-3/tb93laurens.pdf) to synchronize the
597+# pdf file with the source file, by default synctex does the
598+# synchronization with the generated .tex file, not the original
599+# source file. Postprocessing of the .synctex.gz file is necessary
600+# to fix this.
601+#
602+# The following version was worked out and tested by a user (thanks
603+# to Brian Beitzel) on MSWindows. It will need at least one change to
604+# work on UNIX-like operating systems (which include Linux and OS-X).
605+
606+# N.B. ===> IMPORTANT NOTES <===
607+#
608+# 1. The patchDVI package for R needs to be installed from R-Forge, as
609+# follows:
610+#
611+# install.packages("patchDVI", repos="http://R-Forge.R-project.org")
612+#
613+# 2. In all Sweave (.Rnw) documents, the following lines must be included:
614+#
615+# \usepackage{Sweave}
616+# \SweaveOpts{concordance=TRUE}
617+
618+
619+# Fix the pdflatex command to run Sweave first, and to postprocess the
620+# .synctex.gz file:
621+# !!!!! THIS IS THE VERSION FOR MS-WINDOWS, with && as a command
622+# separator
623+$pdflatex = "cmd /c "
624+ . "Rscript -e \"library(cacheSweave); setCacheDir(getwd()); "
625+ . "Sweave('%S', driver=cacheSweaveDriver)\""
626+ . " && R CMD pdflatex -interaction=nonstopmode -synctex=1 %O %B.tex"
627+ . " && Rscript -e "
628+ . "\"library('patchDVI');patchSynctex('%B.synctex.gz')\"";
629+#
630+# !!!TO FIX THIS FOR Linux/OS-X/UNIX, try uncommenting the following:
631+# (this version hasn't been tested).
632+#$pdflatex = "Rscript -e \"library(cacheSweave); setCacheDir(getwd()); "
633+# . "Sweave('%S', driver=cacheSweaveDriver)\""
634+# . " ; R CMD pdflatex -interaction=nonstopmode -synctex=1 %O %B.tex"
635+# . " ; Rscript -e "
636+# . "\"library('patchDVI');patchSynctex('%B.synctex.gz')\"";
637+
638
639=== added file 'example_rcfiles/TeX4ht-latexmkrc'
640--- example_rcfiles/TeX4ht-latexmkrc 1970-01-01 00:00:00 +0000
641+++ example_rcfiles/TeX4ht-latexmkrc 2012-12-28 00:31:23 +0000
642@@ -0,0 +1,33 @@
643+# Sometime in the future, latexmk will directly support the use of
644+# TeX4ht to obtain html from tex. Meanwhile, here is how to use
645+# latexmk with TeX4ht. There is a script htlatex supplied by the
646+# TeX4ht package: It simply runs latex a fixed number of times and
647+# then the programs tex4ht and t4ht. To use latexmk to get optimal
648+# processing use the following instructions (under UNIX-like operating
649+# systems, e.g., OS-X and linux):
650+#
651+# 1. Put the scripts htlatexonly and myhtlatex2 somewhere in the PATH
652+# for executables (and make sure they have excutable permissions
653+# set).
654+# 2. Set up an initialization file for latexmk like this one.
655+#
656+# 3. To process file.tex to make file.html, run
657+#
658+# myhtlatex2 file
659+#
660+
661+# Since these instructions use scripts that are UNIX shell scripts,
662+# the instructions work as written for UNIX-like operating
663+# systems. Users of other operating systems will have to adjust them
664+# and modify the scripts suitably.
665+
666+
667+warn "latexmkrc for htlatex\n";
668+
669+$dvi_mode = 1;
670+$pdf_mode = 0;
671+$quote_filenames = 0;
672+$latex = 'htlatexonly %S';
673+
674+$clean_ext .= ' 4ct 4tc idv lg tmp xref';
675+$clean_full_ext .= ' css html';
676
677=== modified file 'example_rcfiles/asymptote_latexmkrc'
678--- example_rcfiles/asymptote_latexmkrc 2011-06-11 22:09:09 +0000
679+++ example_rcfiles/asymptote_latexmkrc 2012-12-28 00:31:23 +0000
680@@ -21,7 +21,7 @@
681
682 # The following lines are taken from the documentation for V. 2.03 of
683 # asymptote:
684-sub asy {return system("asy '$_[0]'");}
685+sub asy {return system("asy \"$_[0]\"");}
686 add_cus_dep("asy","eps",0,"asy");
687 add_cus_dep("asy","pdf",0,"asy");
688 add_cus_dep("asy","tex",0,"asy");
689
690=== modified file 'example_rcfiles/glossary_latexmkrc'
691--- example_rcfiles/glossary_latexmkrc 2011-06-11 22:09:09 +0000
692+++ example_rcfiles/glossary_latexmkrc 2012-12-28 00:31:23 +0000
693@@ -10,18 +10,18 @@
694
695 # 1. For glossaries using glossary package
696
697-add_cus_dep('glo', 'gls', 0, 'makeglo2gls');
698+add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' );
699 sub makeglo2gls {
700- system("makeindex -s '$_[0]'.ist -t '$_[0]'.glg -o '$_[0]'.gls '$_[0]'.glo");
701+ system("makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" );
702 }
703
704
705
706 # 2. For acronyms using glossary package:
707
708-add_cus_dep('acr', 'acn', 0, 'makeacr2acn');
709+add_cus_dep( 'acr', 'acn', 0, 'makeacr2acn' );
710 sub makeacr2acn {
711- system("makeindex -s '$_[0]'.ist -t '$_[0]'.alg -o '$_[0]'.acn '$_[0]'.acr");
712+ system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acn\" \"$_[0].acr\"" );
713 }
714
715
716@@ -31,8 +31,8 @@
717 # 4. If you use the glossaries package and have the makeglossaries
718 # script installed, then you can do something simpler:
719
720- add_cus_dep('glo', 'gls', 0, 'makeglossaries');
721+ add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' );
722 sub makeglossaries {
723- system("makeglossaries $_[0]");
724+ system( "makeglossaries \"$_[0]\"" );
725 }
726
727
728=== added file 'example_rcfiles/mpost_latexmkrc'
729--- example_rcfiles/mpost_latexmkrc 1970-01-01 00:00:00 +0000
730+++ example_rcfiles/mpost_latexmkrc 2012-12-28 00:31:23 +0000
731@@ -0,0 +1,26 @@
732+# This shows how to use mpost, as used by the feynmp package.
733+# The feynmp package writes files with extension .mp, e.g., foo.mp,
734+# and these are to be converted by mpost to make postscript files,
735+# e.g., foo.1, which are later read in by dvips.
736+#
737+# A more complicated custom dependency is needed than normal, because:
738+# if the output directory ($out_dir) or the auxiliary directory
739+# ($out_dir) is set, mpost doesn't put its output in the correct
740+# place.
741+
742+add_cus_dep( 'mp', '1', 0, 'mpost' );
743+
744+
745+sub mpost {
746+ my $file = $_[0];
747+ my ($name, $path) = fileparse( $file );
748+ my $return = system "mpost \"$file\"";
749+ # Fix the problem that mpost puts its output and log files
750+ # in the current directory, not in the auxiliary directory
751+ # (which is often the same as the output directory):
752+ if ( ($path ne '') && ($path ne '.\\') && ($path ne './') ) {
753+ foreach ( "$name.1", "$name.log" ) { move $_, $aux_dir; }
754+ }
755+ return $return;
756+}
757+
758
759=== modified file 'example_rcfiles/pdflatexmkrc'
760--- example_rcfiles/pdflatexmkrc 2010-03-14 17:10:22 +0000
761+++ example_rcfiles/pdflatexmkrc 2012-12-28 00:31:23 +0000
762@@ -6,72 +6,72 @@
763
764 # Custom dependency for glossary/glossaries package
765 # if you make custom glossaries you may have to add items to the @cus_dep_list and corresponding sub-routines
766-add_cus_dep('glo', 'gls', 0, 'makeglo2gls');
767- sub makeglo2gls {
768- system("makeindex -s $_[0].ist -t $_[0].glg -o $_[0].gls $_[0].glo");
769- }
770+add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' );
771+sub makeglo2gls {
772+ system( "makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" );
773+}
774 # The glossaries package, with the [acronym] option, produces a .acn file when processed with (xe/pdf)latex and
775 # then makeindex to process the .acn into .acr and finally runs of (xe/pdf)latex to read in the .acr file. Unfortunately
776 # the glossary package does just the reverse; i.e. (xe/pdf)latex processing produces a .acr files and makeindex then
777 # is used to convert the .acr file to a .acn file which is then ... . This dependency assumes the glossaries package.
778-add_cus_dep('acn', 'acr', 0, 'makeacn2acr');
779- sub makeacn2acr {
780- system("makeindex -s $_[0].ist -t $_[0].alg -o $_[0].acr $_[0].acn");
781- }
782+add_cus_dep( 'acn', 'acr', 0, 'makeacn2acr' );
783+sub makeacn2acr {
784+ system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acr\" \"$_[0].acn\"" );
785+}
786 # for glossary package (Sigh...) --- they can co-exist!
787-add_cus_dep('acr', 'acn', 0, 'makeacr2acn');
788- sub makeacr2acn {
789- system("makeindex -s $_[0].ist -t $_[0].alg -o $_[0].acn $_[0].acr");
790- }
791+add_cus_dep( 'acr', 'acn', 0, 'makeacr2acn' );
792+sub makeacr2acn {
793+ system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acn\" \"$_[0].acr\"" );
794+}
795 # example of an added custom glossary type that is used in some of the glossary/glossaries example files:
796 # this is for the new glossary type command \newglossary[nlg]{notation}{not}{ntn}{Notation} from the glossaries package
797 # NOTE: the glossary package uses a very different command: the <in-ext> and <out-ext>
798 # are reversed in the calling sequence :-(
799-add_cus_dep('ntn', 'not', 0, 'makentn2not');
800- sub makentn2not {
801- system("makeindex -s $_[0].ist -t $_[0].nlg -o $_[0].not $_[0].ntn");
802- }
803+add_cus_dep( 'ntn', 'not', 0, 'makentn2not' );
804+sub makentn2not {
805+ system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].not\" \"$_[0].ntn\"" );
806+}
807 # for the glossary package (Sigh...) --- they can co-exist!
808-add_cus_dep('not', 'ntn', 0, 'makenot2ntn');
809- sub makenot2ntn {
810- system("makeindex -s $_[0].ist -t $_[0].nlg -o $_[0].ntn $_[0].not");
811- }
812+add_cus_dep( 'not', 'ntn', 0, 'makenot2ntn' );
813+sub makenot2ntn {
814+ system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].ntn\" \"$_[0].not\"" );
815+}
816
817 # dependencies for custom indexes using the index package
818 # examples for sample.tex for index package:
819- add_cus_dep('adx', 'and', 0, 'makeadx2and');
820- sub makeadx2and {
821- system("makeindex -o $_[0].and $_[0].adx");
822- }
823- add_cus_dep('ndx', 'nnd', 0, 'makendx2nnd');
824- sub makendx2nnd {
825- system("makeindex -o $_[0].nnd $_[0].ndx");
826- }
827- add_cus_dep('ldx', 'lnd', 0, 'makeldx2lnd');
828- sub makeldx2lnd {
829- system("makeindex -o $_[0].lnd $_[0].ldx");
830- }
831+ add_cus_dep( 'adx', 'and', 0, 'makeadx2and' );
832+sub makeadx2and {
833+ system( "makeindex -o \"$_[0].and\" \"$_[0].adx\"" );
834+}
835+add_cus_dep( 'ndx', 'nnd', 0, 'makendx2nnd' );
836+sub makendx2nnd {
837+ system( "makeindex -o \"$_[0].nnd\" \"$_[0].ndx\"" );
838+}
839+add_cus_dep( 'ldx', 'lnd', 0, 'makeldx2lnd' );
840+sub makeldx2lnd {
841+ system( "makeindex -o \"$_[0].lnd\" \"$_[0].ldx\"" );
842+}
843
844 # Custom dependency and function for nomencl package
845-add_cus_dep('nlo', 'nls', 0, 'makenlo2nls');
846- sub makenlo2nls {
847- system("makeindex -s nomencl.ist -o $_[0].nls $_[0].nlo");
848- }
849+add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' );
850+sub makenlo2nls {
851+ system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" );
852+}
853
854 # Custom dependency and function(s) for epstopdf package
855
856 # FOR USERS OF epstopf v1.4 and before: should also work with v1.5 and later
857 # note: you may get extras runs if you use the .eps extension in the \includgraphics command
858 # deletes an outdated pdf-image, and triggers a pdflatex-run
859-add_cus_dep('eps', 'pdf', 0, 'cus_dep_delete_dest');
860+add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_delete_dest' );
861
862 # FOR USERS OF epstopdf v1.5 and later only:
863 # load it as \usepackage[update,prepend]{epstopdf}
864 # detects an outdated pdf-image, and triggers a pdflatex-run
865-#add_cus_dep('eps', 'pdf', 0, 'cus_dep_require_primary_run');
866+#add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_require_primary_run' );
867
868 # Custom dependecy to convert tif to png
869-add_cus_dep('tif', 'png', 0, 'maketif2png');
870- sub maketif2png {
871- system("convert $_[0].tif $_[0].png");
872- }
873+add_cus_dep( 'tif', 'png', 0, 'maketif2png' );
874+sub maketif2png {
875+ system( "convert \"$_[0].tif\" \"$_[0].png\"" );
876+}
877
878=== modified file 'example_rcfiles/sagetex_latexmkrc'
879--- example_rcfiles/sagetex_latexmkrc 2011-06-11 22:09:09 +0000
880+++ example_rcfiles/sagetex_latexmkrc 2012-12-28 00:31:23 +0000
881@@ -14,8 +14,8 @@
882 # changed.
883
884
885-add_cus_dep('sage', 'sout', 0, 'makesout');
886+add_cus_dep( 'sage', 'sout', 0, 'makesout' );
887 $hash_calc_ignore_pattern{'sage'} = '^( _st_.goboom|print .SageT)';
888 sub makesout {
889- system("sage '$_[0].sage'");
890+ system( "sage \"$_[0].sage\"" );
891 }
892\ No newline at end of file
893
894=== added file 'example_rcfiles/sweave_latexmkrc'
895--- example_rcfiles/sweave_latexmkrc 1970-01-01 00:00:00 +0000
896+++ example_rcfiles/sweave_latexmkrc 2012-12-28 00:31:23 +0000
897@@ -0,0 +1,57 @@
898+# This is to allow the use of Sweave with latexmk, and in addition to
899+# make synctex work properly with it.
900+# SEE THE IMPORTANT NOTES below.
901+#
902+# Sweave (http://www.stat.uni-muenchen.de/~leisch/Sweave/) is a tool
903+# that allows to embed the R code for complete data analyses in latex
904+# documents. The user edits a file with an extension like .Rnw, and
905+# the .tex file is generated from this.
906+#
907+# Four problems are solved by the code below:
908+# 1. Generate the .tex file automatically.
909+# 2. Arrange not to re-run unmodified chunks of R code. (A pure
910+# optimization.)
911+# 3. Fix the execution environment for (pdf)latex.
912+# 4. Deal with synctex: If the user wants to use synctex
913+# (www.tug.org/TUGboat/tb29-3/tb93laurens.pdf) to synchronize the
914+# pdf file with the source file, by default synctex does the
915+# synchronization with the generated .tex file, not the original
916+# source file. Postprocessing of the .synctex.gz file is necessary
917+# to fix this.
918+#
919+# The following version was worked out and tested by a user (thanks
920+# to Brian Beitzel) on MSWindows. It will need at least one change to
921+# work on UNIX-like operating systems (which include Linux and OS-X).
922+
923+# N.B. ===> IMPORTANT NOTES <===
924+#
925+# 1. The patchDVI package for R needs to be installed from R-Forge, as
926+# follows:
927+#
928+# install.packages("patchDVI", repos="http://R-Forge.R-project.org")
929+#
930+# 2. In all Sweave (.Rnw) documents, the following lines must be included:
931+#
932+# \usepackage{Sweave}
933+# \SweaveOpts{concordance=TRUE}
934+
935+
936+# Fix the pdflatex command to run Sweave first, and to postprocess the
937+# .synctex.gz file:
938+# !!!!! THIS IS THE VERSION FOR MS-WINDOWS, with && as a command
939+# separator
940+$pdflatex = "cmd /c "
941+ . "Rscript -e \"library(cacheSweave); setCacheDir(getwd()); "
942+ . "Sweave('%S', driver=cacheSweaveDriver)\""
943+ . " && R CMD pdflatex -interaction=nonstopmode -synctex=1 %O %B.tex"
944+ . " && Rscript -e "
945+ . "\"library('patchDVI');patchSynctex('%B.synctex.gz')\"";
946+#
947+# !!!TO FIX THIS FOR Linux/OS-X/UNIX, try uncommenting the following:
948+# (this version hasn't been tested).
949+#$pdflatex = "Rscript -e \"library(cacheSweave); setCacheDir(getwd()); "
950+# . "Sweave('%S', driver=cacheSweaveDriver)\""
951+# . " ; R CMD pdflatex -interaction=nonstopmode -synctex=1 %O %B.tex"
952+# . " ; Rscript -e "
953+# . "\"library('patchDVI');patchSynctex('%B.synctex.gz')\"";
954+
955
956=== added file 'example_rcfiles/xelatex_latexmkrc'
957--- example_rcfiles/xelatex_latexmkrc 1970-01-01 00:00:00 +0000
958+++ example_rcfiles/xelatex_latexmkrc 2012-12-28 00:31:23 +0000
959@@ -0,0 +1,20 @@
960+# This shows how to use xelatex (http://en.wikipedia.org/wiki/XeTeX)
961+# with latexmk. Xelatex uses Unicode and "supporting modern font
962+# technologies such as OpenType or Apple Advanced Typography.
963+#
964+# WARNING: latexmk.pl is changing, and plans to have internal
965+# support for xelatex.
966+#
967+# Since xelatex only produces pdf files, it is a replacement for
968+# pdflatex. To make it your default typesetting engine within latexmk
969+# you will not only need to set the $pdflatex variable to require the
970+# use of xelatex, but also to turn on production of pdf files and to
971+# turn off the production of dvi and ps files, as in the following
972+# code:
973+
974+
975+$pdflatex = 'xelatex %O %S';
976+$pdf_mode = 1;
977+$postscript_mode = $dvi_mode = 0;
978+
979+
980
981=== added file 'extra-scripts/htlatexonly'
982--- extra-scripts/htlatexonly 1970-01-01 00:00:00 +0000
983+++ extra-scripts/htlatexonly 2012-12-28 00:31:23 +0000
984@@ -0,0 +1,10 @@
985+#!/bin/sh
986+
987+# Replacement for latex executable when latexmk is used for htlatex
988+# See TeX4ht-latexmkrc in the example-rcfiles directory of the latexmk
989+# distribution for how to use this.
990+#
991+# This is a shell script suitable for UNIX-like operating systems (including
992+# OS-X and linux, and presumably Cygwin under MS-Windows).
993+
994+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
995
996=== added file 'extra-scripts/myhtlatex2'
997--- extra-scripts/myhtlatex2 1970-01-01 00:00:00 +0000
998+++ extra-scripts/myhtlatex2 2012-12-28 00:31:23 +0000
999@@ -0,0 +1,19 @@
1000+#!/bin/sh
1001+
1002+# This is a replacement for htlatex from the TeX4ht package. It allows
1003+# latexmk to be used to do the latex part of the processing.
1004+# See TeX4ht-latexmkrc in the example-rcfiles directory of the latexmk
1005+# distribution for how to use this.
1006+#
1007+# This is a shell script suitable for UNIX-like operating systems (including
1008+# OS-X and linux, and presumably Cygwin under MS-Windows).
1009+
1010+if [[ $# -lt 1 || $1 == "--help" || $1 == "-help" || $1 == "-h" ]]; then
1011+ echo "Convert tex file to html. Simplest usage"
1012+ echo " myhtlatex2 file"
1013+ exit 1
1014+fi
1015+
1016+latexmk $1
1017+tex4ht -f/$1 -i~/tex4ht.dir/texmf/tex4ht/ht-fonts/$3
1018+t4ht -f/$1 $4 ## -d~/WWW/temp/ -m644
1019
1020=== modified file 'latexmk.1'
1021--- latexmk.1 2011-06-11 22:09:09 +0000
1022+++ latexmk.1 2012-12-28 00:31:23 +0000
1023@@ -1,4 +1,4 @@
1024-.TH LATEXMK 1L "7 May 2011" ""
1025+.TH LATEXMK 1L "11 November 2012" ""
1026 .SH NAME
1027 latexmk \- generate LaTeX document
1028 .SH SYNOPSIS
1029@@ -24,9 +24,9 @@
1030 .PP
1031 \fILatexmk\fR determines which are the source files by examining the
1032 log file. (Optionally, it also examines the list of input and output
1033-files generated by the \fI-recorder\fR option of modern versions of
1034+files generated by the \fB-recorder\fR option of modern versions of
1035 \fIlatex\fR and \fIpdflatex\fR. See the documentation for the
1036-\fI-recorder\fR option of \fIlatexmk\fR below.)
1037+\fB-recorder\fR option of \fIlatexmk\fR below.)
1038 When \fIlatexmk\fR is run, it examines properties of the
1039 source files, and if any have been changed since the last document
1040 generation, \fIlatexmk\fR will run the various LaTeX processing
1041@@ -63,8 +63,16 @@
1042 .PP
1043 \fILatexmk\fR has the ability to print a banner in gray diagonally
1044 across each page when making the postscript file. It can also, if
1045-needed, call an external program to do other postprocessing on the
1046-generated files.
1047+needed, call an external program to do other postprocessing on
1048+generated dvi and postscript files. (See the options \fB-dF\fR and
1049+\fB-pF\fR, and the documentation for the \fI$dvi_filter\fR and
1050+\fI$ps_filter\fR configuration variables.) These capabilities are
1051+leftover from older versions of \fIlatexmk\fR. More flexibility can
1052+be obtained in current versions, since the command strings for running
1053+latex, pdflatex, etc can now be configured to run multiple commands.
1054+This also extends the possibility of postprocessing generated files to
1055+pdf files.
1056+files.
1057 .PP
1058 \fILatexmk\fR is highly configurable, both from the command line and
1059 in configuration files, so that it can accommodate a wide variety of
1060@@ -89,8 +97,28 @@
1061 information.
1062
1063 .SH LATEXMK OPTIONS AND ARGUMENTS ON COMMAND LINE
1064-(All options can be introduced by single or double "-" characters,
1065-e.g., "latexmk -help" or "latexmk --help".)
1066+In general the command line to invoke \fIlatexmk\fR has the form
1067+
1068+ latexmk [options] [file]
1069+
1070+All options can be introduced by single or double "-" characters,
1071+e.g., "latexmk -help" or "latexmk --help".
1072+
1073+\fBNote\fR: In addition to the options in the list below,
1074+\fIlatexmk\fR recognizes almost all the options recognized by the
1075+\fIlatex\fR and \fIpdflatex\fR programs in one of both of their
1076+current TeXLive and MiKTeX implementations. Some of the options for
1077+these programs also trigger special action or behavior by
1078+\fIlatexmk\fR, in which case they are in this list. Otherwise, they
1079+are just passed through to a called \fIlatex\fR or \fIpdflatex\fR
1080+program. Run \fIlatexmk\fR with the \fB-showextraoptions\fR to get a
1081+list of the options that \fIlatexmk\fR accepts and that are simply
1082+passed through to \fIlatex\fR or \fIpdflatex\fR. See also the
1083+explanation of the \fB-showextraoptions\fR option for more
1084+information.
1085+
1086+\fBDefinitions of options and arguments\fR
1087+
1088 .TP
1089 .B file
1090 One or more files can be specified. If no files are specified,
1091@@ -107,6 +135,23 @@
1092
1093 then \fIlatexmk\fR will operate on the file "foo.tex".
1094 .TP
1095+
1096+.B -auxdir=FOO or -aux-directory=FOO
1097+
1098+Sets the directory for auxiliary output files of (pdf)latex
1099+(.aux, .log etc). This
1100+achieves its effect by the \fB-aux-directory\fR option of (pdf)latex,
1101+which currently is only implemented on the MiKTeX version of
1102+(pdf)latex.
1103+
1104+See also the \fB-outdir\fR/\fB-output-directory\fR options, and the
1105+\fI$aux_dir\fR, \fI$out_dir\fR, and \fI$search_path_separator\fR
1106+configuration variables of \fIlatexmk\fR. In particular, see the
1107+documentation of \fI$out_dir\fR for some complications on what
1108+directory names are suitable.
1109+
1110+.TP
1111+
1112 .B -bibtex
1113 When the source file uses bbl files for bibliography, run bibtex or
1114 biber as needed to regenerate the bbl files.
1115@@ -172,8 +217,8 @@
1116 .B -c
1117 Clean up (remove) all regeneratable files generated by \fIlatex\fR and
1118 \fIbibtex\fR or \fIbiber\fR except dvi, postscript and pdf. These files are a
1119-combination of log files, aux files, latexmk's database file of source
1120-file information,
1121+combination of log files, aux files, \fIlatexmk\fR's database file of
1122+source file information,
1123 and those with extensions
1124 specified in the \fI@generated_exts\fR configuration variable. In addition,
1125 files with extensions by the \fI$clean_ext\fR configuration variable are
1126@@ -233,30 +278,32 @@
1127 \fIlatexmk\fR can determine them.
1128
1129 By default the list of dependent files is sent to stdout (i.e.,
1130-normally to the screen unless you've redirected latexmk's output).
1131-But you can set the filename where the list is sent by the
1132-\fI-deps-out=\fR option.
1133+normally to the screen unless you've redirected \fIlatexmk\fR's
1134+output). But you can set the filename where the list is sent by the
1135+\fB-deps-out=\fR option.
1136
1137 See the section "USING \fIlatexmk\fR WITH \fImake\fR" for
1138 an example of how to use a dependency list with \fImake\fR.
1139
1140 Users familiar with GNU \fIautomake\fR and \fIgcc\fR will find that
1141-the \fI-deps\fR option is very similar in its purpose and results to
1142-the \fI-M\fR option to \fIgcc\fR.
1143+the \fB-deps\fR option is very similar in its purpose and results to
1144+the \fB-M\fR option to \fIgcc\fR. (In fact, \fIlatexmk\fR also has
1145+options \fB-M\fR, \fB-MF\fR, and \fB-MP\fR options that behave like
1146+those of \fIgcc\fR.)
1147 .TP
1148 .B -dependents
1149-Equivalent to \fI-deps\fR.
1150+Equivalent to \fB-deps\fR.
1151 .TP
1152 .B -deps-
1153 Do not show a list of dependent files after processing. (This is the
1154 default.)
1155 .TP
1156 .B -dependents-
1157-Equivalent to \fI-deps-\fR.
1158+Equivalent to \fB-deps-\fR.
1159 .TP
1160 .B -deps-out=FILENAME
1161 Set the filename to which the list of dependent files is written. If
1162-the FILENAME argument is omitted or set to '-', then the output is
1163+the FILENAME argument is omitted or set to "-", then the output is
1164 sent to stdout.
1165
1166 Use of this option also turns on the output of the list of dependent
1167@@ -270,7 +317,7 @@
1168
1169 Example usage: To use dviselect to select only the even pages of the dvi file:
1170
1171- latexmk -dF 'dviselect even' foo.tex
1172+ latexmk -dF "dviselect even" foo.tex
1173 .TP
1174 .B -diagnostics
1175 Print detailed diagnostics during a run. This may help for debugging
1176@@ -356,6 +403,16 @@
1177 .B -h, -help
1178 Print help information.
1179 .TP
1180+.B -jobname=STRING
1181+Set the basename of output files(s) to STRING, instead of the default,
1182+which is the basename of the specified TeX file.
1183+
1184+This is like the same option for current implementations of the
1185+\fIlatex\fR and \fIpdflatex\fR, and the passing of this option to
1186+these programs is part of \fIlatexmk\fR's implementation of
1187+\fB-jobname\fR.
1188+
1189+.TP
1190 .B -l
1191 Run in landscape mode, using the landscape mode for the previewers and
1192 the dvi to postscript converters. This option is not normally needed
1193@@ -365,6 +422,40 @@
1194 .B -l-
1195 Turn off \fB-l\fR.
1196 .TP
1197+.B -latex="COMMAND"
1198+This sets the string specifying the command to run latex, and is
1199+typically used to add desired options. Since the string normally
1200+contains spaces, it should be quoted, e.g.,
1201+
1202+ latex -latex="latex --shell-escape %O %S" foo.tex
1203+
1204+The specification of the contents of the string are the same as for
1205+the \fI$latex\fR configuration variable. Depending on your
1206+operating system and the command-line shell you are using, you may
1207+need to change the single quotes to double quotes (or something
1208+else).
1209+
1210+To set the command for running pdflatex (rather than the command for
1211+latex) see the \fB-pdflatex\fR option.
1212+
1213+Note that the effect of this option can also be achieved by using
1214+the \fB-e\fR option with a suitable line of Perl code to set the
1215+\fI$latex\fR variable. See the explanation of the \fB-e\fR option.
1216+.TP
1217+.B -M
1218+Show list of dependent files after processing. This is equivalent to
1219+the \fB-deps\fR option.
1220+.TP
1221+.B -MF file
1222+If a list of dependents is made, the \fB-MF\fR specifies the file to
1223+write it to.
1224+.TP
1225+.B -MP
1226+If a list of dependents is made, includes phony target for each source
1227+file. If you use the dependents list in a Makefile, the dummy rules
1228+work around errors make gives if you remove header files without
1229+updating the Makefile to match.
1230+.TP
1231 .B -new-viewer
1232 When in continuous-preview mode, always start a new viewer to view the
1233 generated file. By default, \fIlatexmk\fR will, in continuous-preview
1234@@ -389,6 +480,31 @@
1235 \fIbibtex\fR or \fIbiber\fR, which would result in overwriting of the
1236 bbl files.
1237 .TP
1238+.B -norc
1239+Turn off the automatic reading of initialization (rc) files.
1240+
1241+N.B. Normally the initialization files are read and obeyed, and then
1242+command line options are obeyed in the order they are encountered.
1243+Then \fB-norc\fR is an exception to this rule: it is acted on first,
1244+no matter where is occurs on the command line.
1245+.TP
1246+
1247+.B -outdir=FOO or -output-directory=FOO
1248+
1249+Sets the directory for the output files of (pdf)latex. This achieves
1250+its effect by the \fB-output-directory\fR option of (pdf)latex, which
1251+currently (Dec. 2011) is implemented on the common versions of
1252+(pdf)latex, i.e., MiKTeX and TeXLive. It may not be present in other
1253+versions.
1254+
1255+See also the \fB-auxdir\fR/\fB-aux-directory\fR options, and the
1256+\fI$aux_dir\fR, \fI$out_dir\fR, and \fI$search_path_separator\fR
1257+configuration variables of \fIlatexmk\fR. In particular, see the
1258+documentation of \fI$out_dir\fR for some complications on what
1259+directory names are suitable.
1260+
1261+.TP
1262+
1263 .B -p
1264 Print out the document. By default it is
1265 the generated postscript file that is printed. But you can use the
1266@@ -409,7 +525,9 @@
1267 so it turns them off.
1268 .TP
1269 .B -pdf
1270-Generate pdf version of document using pdflatex.
1271+Generate pdf version of document using pdflatex. (See the
1272+\fB-xelatex\fR if you wish to use \fIxelatex\fR to make your pdf
1273+file(s).)
1274 .TP
1275 .B -pdfdvi
1276 Generate pdf version of document from the dvi file, by default using dvipdf.
1277@@ -424,6 +542,26 @@
1278 It may get overridden if some other option requires the generation of
1279 a pdf file.)
1280 .TP
1281+.B -pdflatex="COMMAND"
1282+This sets the string specifying the command to run pdflatex, and is
1283+typically used to add desired options. Since the string normally
1284+contains spaces, it should be quoted, e.g.,
1285+
1286+ latex -pdf -pdflatex="pdflatex --shell-escape %O %S" foo.tex
1287+
1288+The specification of the contents of the string are the same as for
1289+the \fI$pdflatex\fR configuration variable. Depending on your
1290+operating system and the command-line shell you are using, you may
1291+need to change the single quotes to double quotes (or something
1292+else).
1293+
1294+To set the command for running latex (rather than the command for
1295+pdflatex) see the \fB-latex\fR option.
1296+
1297+Note that the effect of this option can also be achieved by using
1298+the \fB-e\fR option with a suitable line of Perl code to set the
1299+\fI$pdflatex\fR variable. See the explanation of the \fB-e\fR option.
1300+.TP
1301 .B -print=dvi, -print=ps, -print=pdf
1302 Define which kind of file is printed. This option also ensures that
1303 the requisite file is made, and turns on printing. The default is to
1304@@ -491,11 +629,11 @@
1305 bug in gv that causes an error when the newly updated pdf file is
1306 read.) Many other previewers will need a manual update.
1307
1308-Important note: the acroread program on MS-Windows locks the pdf file,
1309+\fBImportant note\fR: the acroread program on MS-Windows locks the pdf file,
1310 and prevents new versions being written, so it is a bad idea to use
1311-acroread to view pdf files in preview-continuous mode. It is better
1312-to use a dvi or ps viewer, as set by one of the \fB-view=dvi\fR and
1313-\fB-view=ps\fR options.
1314+acroread to view pdf files in preview-continuous mode.
1315+It is better to use a different viewer: SumatraPDF and gsview are
1316+good possibilities.
1317
1318 There are some other methods for arranging an update, notably useful
1319 for many versions of xdvi and xpdf. These are best set in
1320@@ -558,6 +696,39 @@
1321 Do not show a list of \fIlatexmk\fR's rules and dependencies after
1322 processing. (This is the default.)
1323 .TP
1324+.B -showextraoptions
1325+Show the list of extra \fIlatex\fR and \fIpdflatex\fR options that
1326+\fIlatexmk\fR recognizes. These are options for the \fIlatex\fR and
1327+\fIpdflatex\fR that \fIlatexmk\fR recognizes, but simply passes
1328+through to these programs when they are run. These options are
1329+(currently) a combination of those allowed by the TeXLive and MiKTeX
1330+implementations. (If a particular option is given to \fIlatexmk\fR
1331+but is not handled by the particular implementation of \fIlatex\fR or
1332+\fIpdflatex\fR that is being used, that program will probably give an
1333+error message.) These options are very numerous, but are not listed
1334+in this documentation because they have no effect on \fIlatexmk\fR's
1335+actions.
1336+
1337+There are a few options (\fB-includedirectory=dir\fR,
1338+\fB-initialize\fR, \fB-ini\fR) that are not recognized, either because
1339+they don't fit with \fIlatexmk\fR's intended operations, or because
1340+they need special processing by \fIlatexmk\fR that isn't implemented
1341+(at least, not yet).
1342+
1343+There are also options that are accepted by \fIlatex\fR etc, but
1344+instead trigger actions by \fIlatexmk\fR: \fB-help\fR,
1345+\fB-version\fR.
1346+
1347+Finally, there are certain options for \fIlatex\fR and \fIpdflatex\fR
1348+(e.g., \fB-recorder\fR) that trigger special actions or behavior by
1349+\fIlatexmk\fR itself as well as being passed in some form to the
1350+called \fIlatex\fR and \fIpdflatex\fR program, or that affect other
1351+programs as well. These options do have entries in this
1352+documentation. These options are:
1353+\fB-jobname=STRING\fR, \fB-aux-directory=dir\fR,
1354+\fB-output-directory=DIR\fR, \fB-quiet\fR, and \fB-recorder\fR.
1355+
1356+.TP
1357 .B -silent
1358 Run commands silently, i.e., with options that reduce the amount of
1359 diagnostics generated. For example, with the default settings, the
1360@@ -569,9 +740,9 @@
1361 To change the options used to make the commands run silently, you need
1362 to configure \fIlatexmk\fR with changed values of its configuration
1363 variables, the relevant ones being \fI$bibtex_silent_switch\fR,
1364-\fI$biber_silent_switch\fR,
1365-\fI$dvips_silent_switch\fR, \fI$latex_silent_switch\fR, and
1366-\fI$pdflatex_silent_switch\fR.
1367+\fI$biber_silent_switch\fR, \fI$dvipdf_silent_switch\fR,
1368+\fI$dvips_silent_switch\fR, \fI$latex_silent_switch\fR,
1369+\fI$makeindex_silent_switch\fR, and \fI$pdflatex_silent_switch\fR.
1370 .TP
1371 .B -use-make
1372 When after a run of \fIlatex\fR or \fIpdflatex\fR, there are warnings
1373@@ -604,6 +775,14 @@
1374 Set the kind of file used when previewing is requested (e.g., by the
1375 \fB-pv\fR or \fB-pvc\fR switches). The default is to view the "highest"
1376 kind of requested file (in the order dvi, ps, pdf).
1377+.TP
1378+.B -xelatex
1379+Use xelatex. That is, use xelatex to process the source file(s) to
1380+pdf (in place of pdflatex). This option is exactly equivalent to
1381+specifying the following sequence of options:
1382+
1383+ -pdflatex="xelatex %O %S" -pdf -dvi- -ps
1384+
1385 .PP
1386 The preview-continuous option \fB-pvc\fR can only work with one file.
1387 So in this case you will normally only specify one filename on
1388@@ -647,16 +826,19 @@
1389 "/usr/local/lib/latexmk/LatexMk".
1390 On a MS-WINDOWS system it looks for "C:\\latexmk\\LatexMk".
1391 On a cygwin system (i.e., a MS-Windows system in which perl is
1392- that of cygwin), \fIlatexmk\fR reads for the first it finds of
1393+that of cygwin), \fIlatexmk\fR reads for the first it finds of
1394 "/cygdrive/c/latexmk/LatexMk",
1395 "/opt/local/share/latexmk/LatexMk",
1396 "/usr/local/share/latexmk/LatexMk",
1397 "/usr/local/lib/latexmk/LatexMk".
1398 .PP
1399 2) The user's RC file, "$HOME/.latexmkrc", if it exists. Here $HOME
1400-is the value of the environment variable HOME. On UNIX and clones
1401-(including LINUX), this variable is set by the system; on MS-Windows,
1402-the user may choose to set it.
1403+is the user's home directory. [\fILatexmk\fR determines the user's
1404+home directory as follows: It is the value of the environment variable
1405+HOME, if this variable exists, which normally is the case on UNIX-like
1406+systems (including LINUX and OS-X). Otherwise the environment
1407+variable USERPROFILE is used, if it exists, which normally is the case
1408+on MS-Windows systems. Otherwise a blank string is used instead of $HOME.]
1409 .PP
1410 3) The RC file in the current working directory. This file can be
1411 named either "latexmkrc" or ".latexmkrc", and the first of these to be
1412@@ -679,6 +861,12 @@
1413 \fB-e\fR option, which allows initialization code to be specified in
1414 \fIlatexmk\fR's command line.
1415
1416+\fI
1417+For possible examples of code for in an RC file, see the directory
1418+example_rcfiles in the distribution of latexmk (e.g., at
1419+http://ctan.tug.org/tex-archive/support/latexmk/example_rcfiles).
1420+\fR
1421+
1422 .SH HOW TO SET VARIABLES IN INITIALIZATION FILES
1423 .PP
1424 The important variables that can be configured are described in the
1425@@ -759,6 +947,20 @@
1426 .TP
1427 .B %T
1428 The name of the primary tex file.
1429+.TP
1430+.B %Y
1431+Name of directory for auxiliary output files (see the configuration
1432+variable \fI$aux_dir\fR). A directory separation character ('/') is
1433+appended if \fI$aux_dir\fR is non-empty and does not end in a suitable
1434+character, with suitable characters being those appropriate to UNIX
1435+and MS-Windows, i.e., ':', '/' and '\\'.
1436+.TP
1437+.B %Z
1438+Name of directory for output files (see the configuration
1439+variable \fI$out_dir\fR). A directory separation character ('/') is
1440+appended if \fI$out_dir\fR is non-empty and does not end in a suitable
1441+character, with suitable characters being those appropriate to UNIX
1442+and MS-Windows, i.e., ':', '/' and '\\'.
1443 .PP
1444 If for some reason you need a literal % character in your string not
1445 subject to the above rules, use a pair of these characters. Thus with
1446@@ -768,7 +970,7 @@
1447 name of a postscript file to be viewed.
1448 .PP
1449 Appropriate quoting will be applied to the filename substitutions, so
1450-you mustn't supply them yourself even if you the names of your have
1451+you mustn't supply them yourself even if the names of your files have
1452 spaces in them. (But if your TeX filenames have spaces in them,
1453 beware that many versions of the TeX program cannot correctly handle
1454 filenames containing spaces.) In case latexmk's quoting does not work
1455@@ -828,6 +1030,9 @@
1456 should be enclosed in double quotes, as in
1457 .PP
1458 $lpr_pdf = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p %S';
1459+ $pdf_previewer = 'start "c:/Program Files/SumatraPDF/SumatraPDF.exe" %O %S';
1460+ $pdf_previewer = 'start "c:/Program Files/SumatraPDF (x86)/SumatraPDF.exe" %O %S';
1461+
1462 .PP
1463 (Note about the above example: Forward slashes are equivalent to
1464 backslashes in filenames under MS-Windows, provided that the filename
1465@@ -836,6 +1041,14 @@
1466 about the rules for dealing with forward slashes in strings in the
1467 Perl language.)
1468
1469+\fBCommand names under Cygwin\fR: If latexmk is executed by Cygwin's
1470+perl, \fI be particularly certain that pathnames in commands have
1471+\fBforward\fI slashes\fR not the usual backslashes for the separator
1472+of pathname components. See the above examples. Backslashes often
1473+get misinterpreted by the Unix shell used by Cygwin's Perl to execute
1474+external commands. Forward slashes don't suffer from this problem,
1475+and (when quoted, as above) are equally acceptable to MS-Windows.
1476+
1477 \fBUsing MS-Windows file associations\fR: A useful trick under modern
1478 versions of MS-Windows (e.g., WinXP) is to use just the
1479 command 'start' by itself:
1480@@ -844,7 +1057,11 @@
1481 .PP
1482 Under recent versions of MS-Windows, this will cause to be run
1483 whatever program the system has associated with dvi files. (The same
1484-applies for a postscript viewer and a pdf viewer.)
1485+applies for a postscript viewer and a pdf viewer.) But note that this
1486+trick is not always suitable for the pdf previwer, if your system has
1487+acroread for the default pdf viewer. As explained elsewhere, acroread
1488+under MS-Windows does not work well with \fIlatex\fR and
1489+\fIlatexmk\fR, because acroread locks the pdf file.
1490
1491 \fBNot using a certain command\fR: If a command is not to be run, the
1492 command name NONE is used, as in
1493@@ -864,6 +1081,17 @@
1494 $latex = 'latex --src-specials %O %S';
1495 .PP
1496
1497+\fBRunning a subroutine instead of an external command\fR: Use a
1498+specification starting with "internal", as in
1499+.PP
1500+ $latex = 'internal mylatex %O %S';
1501+ sub mylatex {
1502+ my @args = @_;
1503+ # Possible preprocessing here
1504+ return system 'latex', @args;
1505+ }
1506+.PP
1507+
1508 \fBAdvanced tricks\fR: Normally one specifies a single command for the
1509 commands invoked by \fIlatexmk\fR. Naturally, if there is some
1510 complicated additional processing you need to do in your special
1511@@ -878,10 +1106,20 @@
1512
1513 $pdflatex = 'pdflatex --shell-escape %O %S; pst2pdf_for_latexmk %B';
1514
1515-This definition assumes you are using a UNIX-like system, so that the
1516+This definition assumes you are using a UNIX-like system (which
1517+includes Linux and OS-X), so that the
1518 two commands to be run are separated by the semicolon in the middle of
1519-the string.
1520-
1521+the string.
1522+
1523+If you are using MS-Windows, you would replace the above line by
1524+
1525+ $pdflatex = 'cmd /c pdflatex --shell-escape %O %S'
1526+ . '&& pst2pdf_for_latexmk %B';
1527+
1528+Here, the UNIX command separator ; is replaced by &&. In addition,
1529+there is a problem that some versions of \fIPerl\fR on MS-Windows do
1530+not obey the command separator; this problem is overcome by explicitly
1531+invoking the MS-Windows command-line processor \fIcmd.exe\fR.
1532
1533 .SH LIST OF CONFIGURATION VARIABLES USABLE IN INITIALIZATION FILES
1534 .PP
1535@@ -904,6 +1142,34 @@
1536 file is created.
1537
1538 .TP
1539+.B $auto_rc_use [1]
1540+Whether to automatically read the standard initialization (rc) files,
1541+which are the system RC file, the user's RC file, and the RC file in
1542+the current directory. The command line option \fB-norc\fR can be
1543+used to turn this setting off. Each RC file could also turn this
1544+setting off, i.e., it could set \fI$auto_rc_use\fR to zero to prevent
1545+automatic reading of the later RC files.
1546+
1547+This variable does not affect the reading of RC files specified on the
1548+command line by the \fB-r\fR option.
1549+
1550+.TP
1551+.B $aux_dir [""]
1552+The directory in which auxiliary files (aux, log, etc) are to be
1553+written by a run of (pdf)latex. If this variable is not set, but
1554+\fI$out_dir\fR is set, then \fI$aux_dir\fR is set to \fI$out_dir\fR,
1555+which is the directory to which general output files are to be
1556+written.
1557+
1558+\fBImportant note\fR: The effect of \fI$aux_dir\fR, if different from
1559+\fI$out_dir\fR, is achieved by giving (pdf)latex the
1560+\fB-aux-directory\fR. Currently (Dec. 2011) this only works on the
1561+MiKTeX version of (pdf)latex.
1562+
1563+See also the documentation of \fI$out_dir\fR for some complications on
1564+what directory names are suitable.
1565+
1566+.TP
1567 .B $banner [0]
1568 If nonzero, the banner message is printed across each page when
1569 converting the dvi file to postscript. Without modifying the variable
1570@@ -953,7 +1219,7 @@
1571 two and the second two examples are equivalent. Each backward slash
1572 should be doubled to avoid running afoul of \fIPerl\fR's rules for writing
1573 strings.
1574-.PP
1575+
1576 \fIImportant note:\fR This variable is now mostly obsolete in the
1577 current version of \fIlatexmk\fR,
1578 since it has a better method of searching for files using the
1579@@ -990,7 +1256,7 @@
1580 .B $cleanup_includes_cusdep_generated [0]
1581 If nonzero, specifies that cleanup also deletes files that are
1582 generated by custom dependencies.
1583-(When doing a clean up, e.g., by use of the \fI-C\fR option, custom
1584+(When doing a clean up, e.g., by use of the \fB-C\fR option, custom
1585 dependencies are those listed in the \fI.fdb_latexmk\fR file from a
1586 previous run.)
1587 .TP
1588@@ -1006,7 +1272,7 @@
1589 files. (There is also extra cleaning as specified by the
1590 \fI$clean_ext\fR, \fI$clean_full_ext\fR and \fI@generated_exts\fR
1591 variables.)
1592-.PP
1593+
1594 This variable is equivalent to specifying one of
1595 the \fB-c\fR or \fB-C\fR options. But there should be no need
1596 to set this variable from an RC file.
1597@@ -1032,9 +1298,50 @@
1598 Extra extensions of files for \fIlatexmk\fR to remove when the \fB-C\fR
1599 option is selected, i.e., extensions of files to remove when the .dvi,
1600 etc files are to be cleaned-up.
1601+
1602+More general patterns are allowed, as for \fI$clean_ext\fR.
1603+
1604+.TP
1605+.B $compiling_cmd [undefined], $failure_cmd [undefined], $success_cmd [undefined]
1606+
1607+These variables specify commands that are executed at certain points
1608+of compilations during preview-continuous mode. One motivation for
1609+their existance is to allow convenient visual indications of
1610+compilation status even when the window receiving the screen output of
1611+the compilation is hidden.
1612+
1613+The commands are executed at the following points:
1614+$compiling_cmd at the start of compilation, $success_cmd at the end of
1615+a successful compilation, and $failure_cmd at the end of an
1616+unsuccessful compilation. If any of above variables is undefined (the
1617+default situation) or blank, then the corresponding command is not
1618+executed.
1619+
1620+An example of a typical setting of these variables is as follows
1621+
1622+ $compiling_cmd = "xdotool search --name \\"%D\\" set_window --name \\"%D compiling\\"";
1623+ $success_cmd = "xdotool search --name \\"%D\\" set_window --name \\"%D OK\\"";
1624+ $failure_cmd = "xdotool search --name \\"%D\\" set_window --name \\"%D FAILURE\\"";
1625+
1626+These assume that the program \fIxdotool\fR is installed, that the
1627+previewer is using an X-Window system for display, and that the title
1628+of the window contains the name of the displayed file, as it normally
1629+does. When the commands are executed, the placeholder string %D is replaced by
1630+the name of the destination file, which is the previewed file. The
1631+above commands result in an appropriate string being appended to the
1632+filename in the window title: " compiling", " OK", or " FAILURE".
1633+
1634+Other placeholders that can be used are %S, %T, and %R, with %S and %T
1635+normally being identical. These can be useful for a command changing
1636+the title of the edit window. The visual indication in a window title
1637+can useful, since the user does not have to keep shifting attention to
1638+the (possibly hidden) compilation window to know the status of the
1639+compilation.
1640+
1641 .TP
1642 .B @cus_dep_list [()]
1643 Custom dependency list -- see section on "Custom Dependencies".
1644+
1645 .TP
1646 .B @default_files [("*.tex")]
1647 Default list of files to be processed.
1648@@ -1063,6 +1370,13 @@
1649 \fI@default_files\fR is an array variable, i.e., a sequence of
1650 filename specifications is possible.
1651 .TP
1652+.B $dependents_phony [0]
1653+If a list of dependencies is output, this variable determines whether
1654+to include a phony target for each source file. If you use the
1655+dependents list in a Makefile, the dummy rules work around errors make
1656+gives if you remove header files without updating the Makefile to
1657+match.
1658+.TP
1659 .B $dependents_list [0]
1660 Whether to display a list(s) of dependencies at the end of a run.
1661 .TP
1662@@ -1073,7 +1387,7 @@
1663 .B $dvi_mode [See below for default]
1664 If nonzero, generate a dvi version of the document.
1665 Equivalent to the \fB-dvi\fR option.
1666-.PP
1667+
1668 The variable $dvi_mode defaults to 0, but if no explicit requests are
1669 made for other types of file (postscript, pdf), then $dvi_mode will be
1670 set to 1. In addition, if a request for a file for which a .dvi file
1671@@ -1083,7 +1397,18 @@
1672 The command to invoke a dvi-previewer.
1673 [Default is "start" under MS-WINDOWS; under more recent versions of
1674 Windows, this will cause to be run whatever command the system has
1675-associated with .dvi files.]
1676+associated with .dvi files.]
1677+
1678+\fBImportant note\fR: Normally you will want to have a previewer run
1679+detached, so that \fIlatexmk\fR doesn't wait for the previewer to
1680+terminate before continuing its work. So normally you should prefix
1681+the command by "start ", which flags to \fIlatexmk\fR that it should
1682+do the detaching of the previewer itself (by whatever method is
1683+appropriate to the operating system). But sometimes letting
1684+\fIlatexmk\fR do the detaching is not appropriate (for a variety of
1685+non-trivial reasons), so you should put the "start " bit in
1686+yourself, whenever it is needed.
1687+
1688 .TP
1689 .B $dvi_previewer_landscape ["start xdvi %O %S"]
1690 The command to invoke a dvi-previewer in landscape mode.
1691@@ -1102,6 +1427,14 @@
1692 should be modified to give dvips the options "-P pdf" to ensure that
1693 type 1 fonts are used in the pdf file.
1694 .TP
1695+.B $dvipdf_silent_switch ["-q"]
1696+Switch(es) for dvipdf program when silent mode is on.
1697+
1698+N.B. The standard dvipdf program runs silently, so adding the silent
1699+switch has no effect, but is actually innocuous. But if an
1700+alternative program is used, e.g., dvipdfmx, then the silent switch
1701+has an effect. The default setting is correct for dvipdfm and dvipdfmx.
1702+.TP
1703 .B $dvips ["dvips %O -o %D %S"]
1704 The program to used as a filter to convert a .dvi file to a .ps file.
1705 If pdf is going to be generated from pdf, then the value of the
1706@@ -1150,6 +1483,9 @@
1707 \fI$dvi_update_method\fR. The default value is the one appropriate
1708 for xdvi on a UNIX system.
1709 .TP
1710+.B $failure_cmd [undefined]
1711+See the documentation for $compiling_cmd.
1712+.TP
1713 .B $fdb_ext ["fdb_latexmk"]
1714 The extension of the file which \fIlatexmk\fR generates to contain a
1715 database of information on source files. You will not normally need
1716@@ -1353,6 +1689,9 @@
1717 .B $makeindex ["makeindex %O -o %D %S"]
1718 The index processing program.
1719 .TP
1720+.B $makeindex_silent_switch ["-q"]
1721+\fBSwitch(es)\fR for the index processing program when silent mode is on.
1722+.TP
1723 .B $max_repeat [5]
1724 The maximum number of times \fIlatexmk\fR will run latex/pdflatex
1725 before deciding that there may be an infinite loop and that it needs
1726@@ -1362,6 +1701,23 @@
1727 (Note that the "etc" covers a lot of cases where one run of
1728 latex/pdflatex generates files to be read in on a later run.)
1729 .TP
1730+.B $MSWin_back_slash [1]
1731+This configuration variable only has an effect when \fIlatexmk\fR is
1732+running under MS-Windows. It determines whether, when a command is
1733+executed under MS-Windows, there should be substituted "\\" for the
1734+separator character between components of a directory name.
1735+Internally, \fIlatexmk\fR uses "/" for the directory separator
1736+character, which is the character used by Unix-like systems.
1737+
1738+For many programs under MS-Windows, both "\\" and "/" are acceptable
1739+as the directory separator character. But some programs only accept
1740+"\\". So for safety \fIlatexmk\fR makes a translation, by default.
1741+It is conceivable that under certain situations this is undesirable,
1742+so the configuration can be changed. (A possible example might be
1743+when some of the software is implemented using Cygwin, which provides
1744+an Unix-like environment inside MS-Windows.)
1745+
1746+.TP
1747 .B $new_viewer_always [0]
1748 This variable applies to \fIlatexmk\fR \fBonly\fR in
1749 continuous-preview mode. If \fI$new_viewer_always\fR is 0,
1750@@ -1370,6 +1726,34 @@
1751 \fI$new_viewer_always\fR is non-zero, this check will be skipped, and
1752 \fIlatexmk\fR will behave as if no viewer is running.
1753 .TP
1754+
1755+.B $out_dir [""]
1756+The directory in which output files are to be written by a run of
1757+(pdf)latex. See also the variable \fI$aux_dir\fR.
1758+
1759+The effect of this variable (when non-blank) is achieved by using the
1760+\fB-output-directory\fR option of (pdf)latex. This exists in the
1761+usual current (Dec. 2011) implementations of TeX, i.e., MiKTeX and
1762+TeXLive. But it may not be present in other versions.
1763+
1764+Commonly, the directory specified for output files is a subdirectory
1765+of the current working directory. However, if you specify some other
1766+directory, e.g., "/tmp/foo" or "../output", be aware that this could
1767+cause problems, e.g., with \fImakeindex\fR or \fIbibtex\fR. This is
1768+because modern versions of these programs, by default, will refuse to
1769+work when they find that they are asked to write to a file in a
1770+directory that appears not to be the current working directory or one
1771+of its subdirectories. This is part of security measures by the whole
1772+TeX system that try to prevent malicious or errant TeX documents from
1773+incorrectly messing with a user's files. If for \fI$out_dir\fR or
1774+\fI$aux_dir\fR you really do need to specify an absolute pathname
1775+(e.g., "/tmp/foo") or a path (e.g., "../output") that includes a
1776+higher-level directory, then you need to disable the security measures
1777+(and assume any risks). This can be done by temporarily setting the
1778+operating system's environment variable openout_any to "a" (as in
1779+"all"), to override the default "paranoid" setting.
1780+.TP
1781+
1782 .B $pdf_mode [0]
1783 If zero, do NOT generate a pdf version of the document.
1784 If equal to 1, generate a pdf version of the document using pdflatex.
1785@@ -1381,9 +1765,24 @@
1786 Equivalent to the \fB-pdf-\fR, \fB-pdf\fR, \fB-pdfdvi\fR,
1787 \fB-pdfps\fR options.
1788 .TP
1789+
1790 .B $pdflatex ["pdflatex %O %S"]
1791 The LaTeX processing program in the version that makes a pdf file instead
1792 of a dvi file.
1793+
1794+An example of the use of this variable is to arrange for \fIxelatex\fR
1795+to be used instead of \fIpdflatex\fR, when you could set
1796+
1797+ $pdflatex = "xelatex %O %S";
1798+
1799+Note that \fIxelatex\fR only produces .pdf files (and not .dvi), so to
1800+use it you will also need to turn on production of .pdf files, and to
1801+turn off the production of .dvi (and .ps) files, either by command
1802+line options or by the following settings in an initialization file
1803+
1804+ $pdf_mode = 1; $postscript_mode = $dvi_mode = 0;
1805+
1806+
1807 .TP
1808 .B %pdflatex_input_extensions
1809 This variable specifies the extensions tried by latexmk when it finds
1810@@ -1431,17 +1830,36 @@
1811 .TP
1812 .B $pdf_previewer ["start acroread %O %S"]
1813 The command to invoke a pdf-previewer.
1814-[Default is changed to "start" on MS-WINDOWS; under more recent versions of
1815+
1816+On MS-WINDOWS, the default is changed to "cmd /c start """; under more recent versions of
1817 Windows, this will cause to be run whatever command the system has
1818-associated with .pdf files.]
1819-
1820-\fBWARNING\fR: Potential problem under MS-Windows:
1821+associated with .pdf files. But this may be undesirable if this
1822+association is to \fIacroread\fR -- see the notes in the explanation
1823+of the \fB-pvc\fR option.]
1824+
1825+On OS-X the default is changed to "open %S", which results in OS-X
1826+starting up (and detaching) the viewer associated with the file. By
1827+default, for pdf files this association is to OS-X's preview, which is
1828+quite satisfactory.
1829+
1830+\fBWARNING\fR: Problem under MS-Windows:
1831 if acroread is used as the pdf previewer, and it is
1832 actually viewing a pdf file, the pdf file cannot be updated. Thus
1833 makes acroread a bad choice of previewer if you use \fIlatexmk\fR's
1834 previous-continuous mode (option \fB-pvc\fR) under MS-windows.
1835-This problem does not occur if ghostview, gv or gsview is used to
1836-view pdf files.
1837+This problem does not occur if, for example, SumatraPDF or gsview is
1838+used to view pdf files.
1839+
1840+\fBImportant note\fR: Normally you will want to have a previewer run
1841+detached, so that \fIlatexmk\fR doesn't wait for the previewer to
1842+terminate before continuing its work. So normally you should prefix
1843+the command by "start ", which flags to \fIlatexmk\fR that it should
1844+do the detaching of the previewer itself (by whatever method is
1845+appropriate to the operating system). But sometimes letting
1846+\fIlatexmk\fR do the detaching is not appropriate (for a variety of
1847+non-trivial reasons), so you should put the "start " bit in
1848+yourself, whenever it is needed.
1849+
1850 .TP
1851 .B $pdf_update_command [""]
1852 When the pdf previewer is set to be updated by running a command, this
1853@@ -1490,7 +1908,7 @@
1854 .B $postscript_mode [0]
1855 If nonzero, generate a postscript version of the document.
1856 Equivalent to the \fB-ps\fR option.
1857-.PP
1858+
1859 If some other request is made for which a postscript file is needed,
1860 then $postscript_mode will be set to 1.
1861 .TP
1862@@ -1541,7 +1959,7 @@
1863 file before other processing. Equivalent to specifying the \fB-pF\fR
1864 option.
1865 .TP
1866-.B $ps_previewer ["start gv %O %S", but \(dqstart %O %S" under MS-WINDOWS]
1867+.B $ps_previewer ["start gv %O %S", but "start %O %S" under MS-WINDOWS]
1868 The command to invoke a ps-previewer. (The default under MS-WINDOWS
1869 will cause to be run whatever command the system has associated
1870 with .ps files.)
1871@@ -1554,8 +1972,19 @@
1872 \fBWARNING\fR: Linux systems may have installed one (or more) versions
1873 of gv under different names, e.g., ggv, kghostview, etc, but perhaps
1874 not one called gv.
1875+
1876+\fBImportant note\fR: Normally you will want to have a previewer run
1877+detached, so that \fIlatexmk\fR doesn't wait for the previewer to
1878+terminate before continuing its work. So normally you should prefix
1879+the command by "start ", which flags to \fIlatexmk\fR that it should
1880+do the detaching of the previewer itself (by whatever method is
1881+appropriate to the operating system). But sometimes letting
1882+\fIlatexmk\fR do the detaching is not appropriate (for a variety of
1883+non-trivial reasons), so you should put the "start " bit in
1884+yourself, whenever it is needed.
1885+
1886 .TP
1887-.B $ps_previewer_landscape ["start gv -swap %O %S", but \(dqstart %O %S" under MS-WINDOWS]
1888+.B $ps_previewer_landscape ["start gv -swap %O %S", but "start %O %S" under MS-WINDOWS]
1889 The command to invoke a ps-previewer in landscape mode.
1890 .TP
1891 .B $ps_update_command [""]
1892@@ -1589,7 +2018,7 @@
1893 specifications (as in \fI$pdflatex\fR) are surrounded by double
1894 quotes. If this variable is 1 (or any other value Perl regards as
1895 true), then quoting is done. Otherwise quoting is omitted.
1896-.PP
1897+
1898 The quoting method used by latexmk is tested to work correctly under
1899 UNIX systems (including Linux and Mac OS-X) and under MS-Windows. It
1900 allows the use of filenames containing special characters, notably
1901@@ -1599,7 +2028,7 @@
1902 operating system in passing arguments to programs.)
1903 .TP
1904 .B $recorder [0]
1905-Whether to use the \fI-recorder\fR option to \fIlatex\fR and
1906+Whether to use the \fB-recorder\fR option to \fIlatex\fR and
1907 \fIpdflatex\fR. Use of this option results in a file of extension
1908 \fI.fls\fR containing a list of the files that these programs have
1909 read and written. \fILatexmk\fR will then use this file to improve
1910@@ -1618,6 +2047,33 @@
1911 named for the program, i.e., latex.fls or pdflatex.fls. In this
1912 second case, \fIlatexmk\fR copies the latex.fls or pdflatex.fls to a
1913 file with the basename of the main LaTeX document, e.g., Document.fls.
1914+
1915+.TP
1916+.B $search_path_separator [See below for default]
1917+The character separating paths in the environment variables TEXINPUTS,
1918+BIBINPUTS, and BSTINPUTS. This variable is mainly used by
1919+\fIlatexmk\fR when the \fB-outdir\fR, \fB-output-directory\fR,
1920+\fB-auxdir\fR, and/or \fB-aux-directory\fR options are used. In that
1921+case \fIlatexmk\fR needs to communicate appropriately modified search
1922+paths to $\fIbibtex\fR, \fIdvipdf\fR, \fIdvips\fR, and
1923+\fI(pdf)latex\fR.
1924+
1925+[Comment to technically savvy readers: \fI(pdf)latex\fR doesn't
1926+actually need the modified search path, because it corrects it
1927+internally. But, surprisingly, \fIdvipdf\fR and \fIdvips\fR do,
1928+because sometimes graphics files get generated in the output or aux
1929+directories.]
1930+
1931+The default under MSWin and Cygwin is ';' and under UNIX-like
1932+operating systems (including Linux and OS-X) is ':'. Normally the
1933+defaults give correct behavior. But there can be difficulties if your
1934+operating system is of one kind, but some of your software is running
1935+under an emulator for the other kind of operating system; in that case
1936+you'll need to find out what is needed, and set
1937+\fI$search_path_separator\fR explicitly. (The same goes, of course,
1938+for unusual operating systems that are not in the MSWin, Linux, OS-X,
1939+Unix collection.)
1940+
1941 .TP
1942 .B $sleep_time [2]
1943 The time to sleep (in seconds) between checking for source file
1944@@ -1635,6 +2091,11 @@
1945 \fI$texfile_search\fR, it is a string of space-separated filenames, and
1946 then \fIlatexmk\fR replaces \fI@default_files\fR with the filenames in
1947 \fI$texfile_search\fR to which is added "*.tex".
1948+
1949+.TP
1950+.B $success_cmd [undefined]
1951+See the documentation for $compiling_cmd.
1952+
1953 .TP
1954 .B $tmpdir [See below for default]
1955 Directory to store temporary files that \fIlatexmk\fR may generate while
1956@@ -1732,7 +2193,7 @@
1957
1958 add_cus_dep( 'fig', 'eps', 0, 'fig2eps' );
1959 sub fig2eps {
1960- system("fig2dev -Leps $_[0].fig $_[0].eps");
1961+ system( "fig2dev -Leps \"$_[0].fig\" \"$_[0].eps\"" );
1962 }
1963
1964 The first line adds a custom dependency that converts a file with
1965@@ -1760,32 +2221,35 @@
1966 statement, i.e., the invocation of system, which returns the value 0
1967 on success.
1968
1969-If you use filenames with spaces in them, and if your LaTeX system and
1970-all other relevant software correctly handle such filenames, then you
1971-could put single quotes around filenames in the command line that is
1972-executed:
1973-
1974- add_cus_dep( 'fig', 'eps', 0, 'fig2eps' );
1975- sub fig2eps {
1976- system("fig2dev -Lps '$_[0].fig' '$_[0].eps'");
1977- }
1978-
1979-This causes the invocation of the \fIfig2dev\fR program to have quoted
1980-filenames; it should therefore work with filenames containing spaces.
1981-\fBHowever, not all software deals correctly with filenames that
1982-contain spaces. Moreover, the rules, if any, for quoting filenames
1983-vary between operating systems, command shells and individual pieces
1984-of software, so this code may not always work.\fR
1985-
1986 If you use pdflatex instead of latex, then you will probably prefer to
1987 convert your graphics files to pdf format, in which case you would
1988 replace the above code in an initialization file by
1989
1990 add_cus_dep( 'fig', 'pdf, 0, 'fig2pdf' );
1991 sub fig2pdf {
1992- system("fig2dev -Lpdf $_[0].fig $_[0].pdf");
1993+ system( "fig2dev -Lpdf \"$_[0].fig\" \"$_[0].pdf\"" );
1994 }
1995
1996+\fBNote 1:\fR In the command lines given in the system commands in the
1997+above examples, double quotes have been inserted around the file names
1998+(implemented by '\"' in the Perl language). They immunize the running
1999+of the program against special characters in filenames. Very often
2000+these quotes are not necessary, i.e., they can be omitted. But it is
2001+normally safer to keep them in. Even though the rules for quoting
2002+vary between operating systems, command shells and individual pieces
2003+of software, the quotes in the above examples do not cause problems in
2004+the cases I have tested.
2005+
2006+\fBNote 2:\fR One case in which the quotes are important is when the
2007+files are in a subdirectory and your operating system is Microsoft
2008+Windows. Then the separator character for directory components can be
2009+either a forward slash '/' or Microsoft's more usual backward slash
2010+'\\'. Forward slashes are generated by latexmk, to maintain its
2011+sanity from software like MiKTeX that mixes both directory
2012+separators; but their correct use normally requires quoted filenames.
2013+(See a log file from a run of MiKTeX (at least in v. 2.9) for an
2014+example of the use of both directory separators.)
2015+
2016 If you have some general custom dependencies defined in the system or
2017 user initialization file, you may find that for a particular project
2018 they are undesirable. So you might want to delete the unneeded ones.
2019@@ -1816,7 +2280,7 @@
2020
2021 add_cus_dep('ndx', 'nnd', 0, 'makendx2nnd');
2022 sub makendx2nnd {
2023- system("makeindex -o $_[0].nnd $_[0].ndx");
2024+ system( "makeindex -o \"$_[0].nnd\" \"$_[0].ndx"\" );
2025 }
2026
2027 (You will need to modify this code if you use filenames
2028@@ -1854,7 +2318,7 @@
2029
2030 push @cus_dep_list, "fig eps 0 fig2eps";
2031 sub fig2eps {
2032- system("fig2dev -Lps $_[0].fig $_[0].eps");
2033+ system( "fig2dev -Lps \"$_[0].fig\" \"$_[0].eps\"" );
2034 }
2035
2036 This method still works, and is equivalent to the earlier code using
2037@@ -1977,11 +2441,11 @@
2038 make .pdf files from .fig files produced by the \fIxfig\fR program;
2039 these are commonly used for graphics insertions in LaTeX documents.
2040 \fILatexmk\fR is arranged to output a dependency file after each run.
2041-It is given the \fI-recorder\fR option, which improves its detection
2042+It is given the \fB-recorder\fR option, which improves its detection
2043 of files generated during a run of \fIpdflatex\fR; such files should
2044-not be in the dependency list. The \fI-e\fR options are used to turn
2045+not be in the dependency list. The \fB-e\fR options are used to turn
2046 off all custom dependencies, and to document this. Instead the
2047-\fI-use-make\fR is used to delegate the making of missing files to
2048+\fB-use-make\fR is used to delegate the making of missing files to
2049 \fImake\fR itself.
2050
2051 Suppose in the LaTeX file there is a command \\includegraphics{graph},
2052@@ -2015,8 +2479,8 @@
2053 Acroread under UNIX/LINUX views pdf, but the file needs to be closed
2054 and reopened to view an updated version.
2055 Under MS-Windows, acroread locks its input file and so the
2056-pdf file cannot be updated. (Remedy: configure \fIlatexmk\fR to use gsview
2057-instead.)
2058+pdf file cannot be updated. (Remedy: configure \fIlatexmk\fR to use
2059+\fIsumatrapdf\fR instead.)
2060 .SH THANKS TO
2061 Authors of previous versions. Many users with their feedback, and
2062 especially
2063@@ -2027,7 +2491,7 @@
2064 harvested by worms and viruses.)
2065 .SH AUTHOR
2066 Current version, by John Collins (username collins at node phys.psu.edu).
2067-(Version 4.24).
2068+(Version 4.35).
2069
2070 Released version can be obtained from CTAN:
2071 <http://www.tug.org/tex-archive/support/latexmk/>, and from the
2072
2073=== modified file 'latexmk.bat'
2074--- latexmk.bat 2006-06-12 00:43:25 +0000
2075+++ latexmk.bat 2012-12-28 00:31:23 +0000
2076@@ -1,5 +1,5 @@
2077-Rem Execute latexmk.pl, searching for it in the PATH
2078-Rem Assume perl is in the PATH. If not, you should replace 'perl' by
2079-Rem the full pathname of the perl executable, e.g., 'C:\perl\bin\perl.exe'
2080-
2081-perl -S latexmk.pl %1 %2 %3 %4 %5 %6 %7 %8 %9
2082+Rem Execute latexmk.pl, searching for it in the PATH
2083+Rem Assume perl is in the PATH. If not, you should replace 'perl' by
2084+Rem the full pathname of the perl executable, e.g., 'C:\perl\bin\perl.exe'
2085+
2086+perl -S latexmk.pl %1 %2 %3 %4 %5 %6 %7 %8 %9
2087
2088=== modified file 'latexmk.pdf'
2089Binary files latexmk.pdf 2011-06-11 22:09:09 +0000 and latexmk.pdf 2012-12-28 00:31:23 +0000 differ
2090=== modified file 'latexmk.pl'
2091--- latexmk.pl 2011-06-11 22:09:09 +0000
2092+++ latexmk.pl 2012-12-28 00:31:23 +0000
2093@@ -1,4 +1,8 @@
2094 #!/usr/bin/env perl
2095+
2096+# N.B. !!!!!!!!!!! See 17 July 2012 comments !!!!!!!!!!!!!!!!!!
2097+
2098+
2099 # On a UNIX-like system, the above enables latexmk to run independently
2100 # of the location of the perl executable. This line relies on the
2101 # existence of the program /usr/bin/env
2102@@ -9,7 +13,6 @@
2103
2104 # with the path of the perl executable adjusted for your system.
2105
2106-
2107 use warnings;
2108
2109 # Delete #??!! when working
2110@@ -22,6 +25,7 @@
2111 ## (I have hooks for this).
2112
2113
2114+
2115 #=======================================
2116
2117 #?? Force mode doesn't appear to do force (if error in latex file)
2118@@ -107,15 +111,15 @@
2119
2120 $my_name = 'latexmk';
2121 $My_name = 'Latexmk';
2122-$version_num = '4.24';
2123-$version_details = "$My_name, John Collins, 7 May 2011";
2124-
2125+$version_num = '4.35';
2126+$version_details = "$My_name, John Collins, 11 Nov. 2012";
2127
2128 use Config;
2129 use File::Copy;
2130 use File::Basename;
2131 use FileHandle;
2132 use File::Find;
2133+use List::Util qw( max );
2134 use Cwd; # To be able to change cwd
2135 use Cwd "chdir"; # Ensure $ENV{PWD} tracks cwd
2136 use Digest::MD5;
2137@@ -141,7 +145,7 @@
2138 warn "Something wrong with the perl configuration: No signals?\n";
2139 }
2140
2141-## Copyright John Collins 1998-2011
2142+## Copyright John Collins 1998-2012
2143 ## (username collins at node phys.psu.edu)
2144 ## (and thanks to David Coppit (username david at node coppit.org)
2145 ## for suggestions)
2146@@ -175,37 +179,94 @@
2147 ## 5. Parsing of log file instead of source file is used to
2148 ## obtain dependencies, by default.
2149 ##
2150-## Modification log from 1 Jan 2011 onwards in detail
2151+## Modification log from 9 Dec 2011 onwards in detail
2152 ##
2153-## 7 May 2011, John Collins With biber, use kpsewhich to find source
2154-## files (e.g., .bib)
2155-## 24 Mar 2011, John Collins Correct bug in detection of source files
2156-## listed in .fls
2157-## 21 Mar 2011, John Collins Add 'bcf' to list of generated extensions
2158-## Deal with case that fls files are latex.fls
2159-## and pdflatex.fls
2160-## 19--21 Mar 2011, John Collins -deps and -rules options
2161-## $use_make_for_missing_files
2162-## -recorder option
2163-## 12 Mar 2011, John Collins Deal with problem that if maximum number of
2164-## runs of (pdf)latex is exceeded, -pvc mode
2165-## infinitely repeats (pdf)latex
2166-## 11 Mar 2011, John Collins Fix problem that changes in generated files
2167-## during run of (pdf)latex may not be detected
2168-## if the run is shorter than the granularity
2169-## of file times.
2170-## 28 Feb 2011, John Collins Corrections of comments and messages
2171-## 22 Feb 2011, John Collins Documentation improvement.
2172-## 16 Feb 2011, John Collins Correctly parse blg files of biber 0.8
2173-## Version 4.23.
2174-## 3 Feb 2011, John Collins Correct handling of errors in rc files
2175-## 23 Jan 2011, John Collins Fix detection of makeindex files with
2176-## MiKTeX v >= 2.8
2177-## 23 Jan 2011, John Collins Fix detection of biber use with MiKTeX
2178-## (which doesn't put openout lines in log file).
2179-## 9 Jan 2011, John Collins Correct parsing of blg file for biber 0.7.2
2180-## 3 Jan 2011, John Collins Small correction on reading .fdb_file
2181-## 1 Jan 2011, John Collins Biber implementation
2182+## 12 Jan 2012 STILL NEED TO DOCUMENT some items below
2183+## 11 Nov 2012 John Collins V. 4.35
2184+## Correct bug that under some combinations of
2185+## MS-Windows, cygwin and distributions of
2186+## TeX, line endings in fls file (CRLF v. LF)
2187+## were misparsed, resulting in source
2188+## filenames that incorrectly contained CR
2189+## characters.
2190+## Correct bug that when --gg mode is on, the
2191+## rule database contained items from the OLD
2192+## fdb file. Using --gg mode implies that
2193+## the rules in the OLD fdb file must be
2194+## ignored (since they may be wrong).
2195+## 1 Oct 2012 John Collins V. 4.34
2196+## Correct problem that if a file is read by
2197+## latex only after being written, it is
2198+## not a true source file.
2199+## 19 Aug 2012 John Collins V. 4.33c
2200+## Correct infinite loop when maximum passes
2201+## exceeded.
2202+## Improve error messages
2203+## 12 Aug 2012 John Collins V. 4.33b
2204+## Improve text displayed by -showextraoptions
2205+## 8 Aug 2012 John Collins V. 4.33a
2206+## Fix problem that with Cygwin,
2207+## latexmk runs very slowly, because
2208+## subroutine good_cwd() runs the
2209+## program cygpath on every
2210+## invocation. Solution: cach cwd.
2211+## 6 Aug 2012 John Collins Version number to 4.33
2212+## 4 Aug 2012 John Collins Further fixes of filename treatment:
2213+## normalize_filename routine to remove
2214+## string for current directory, and
2215+## convert '\' directory separator to '/'
2216+## (Note MiKTeX uses BOTH, see e.g., its
2217+## log file, so MSWin systems are NOT
2218+## guaranteed to be consistent. But latexmk
2219+## needs to treat filenames differing by
2220+## change of directory separator as equivalent.
2221+## Warning: SOME MWWin programs, e.g., current
2222+## cmd.exe (as tested yesterday on PSU computer
2223+## in library) do not accept '/' as directory
2224+## separator, so it may be worth allowing conversion
2225+## to '\' in executed files.)
2226+## Also improve running when $silent is on:
2227+## don't print warnings about undefined references
2228+## and citations, but simply display a summary, whose
2229+## criterion for being shown had to be fixed.
2230+## 3 Aug 2012 John Collins Fix finding of files in aux-dir
2231+## 1 Aug 2012 John Collins Handle aliasing of cwd in output file
2232+## to avoid unnecessary warnings about
2233+## actual o/p file .ne. expected with MiKTeX
2234+## Clean up subroutine names:
2235+## parse_logB to parse_log
2236+## make_preview_continuousB to make_preview_continuous
2237+## rdb_find_new_filesB to rdb_find_new_files
2238+## rdb_set_dependentsA to rdb_set_dependents
2239+## rdb_makeB to rdb_make
2240+## rdb_makeB1 to rdb_make1
2241+## rdb_one_depA to rdb_one_dep
2242+## rdb_recurseA to rdb_recurse
2243+## rdb_update_filesA to rdb_update_files
2244+## 28, 29, 30 Jul 2012 John Collins Try better file-name normalization in reading fls file.
2245+## 18 Jul 2012 John Collins Change ver. to 4.32d.
2246+## Merge changes from 29 June 2012:
2247+## Add $dvipdf_silent_switch
2248+## 17 Jul 2012 John Collins Try better fix for error/rerun and retest issue.
2249+## Now rdb_primary_run doesn't have so many complications
2250+## rdb_makeB's PASS loop is simpler
2251+## rdb_submakeB is unneeded.
2252+## See the lines starting #??
2253+## See comments nearby
2254+## Compare w/ v. 4.32a
2255+## V. 4.32b
2256+## 17 Jul 2012 John Collins Fix problem that after finding error in a run
2257+## of (pdf)latex, latexmk didn't check for
2258+## changed files before giving up.
2259+## To do that, I reverted some changes in
2260+## rdb_primary_run to pre v. 4.31
2261+## Remove unused code
2262+## v. 4.32a
2263+## 8 May 2012 John Collins Possibility to substitute backslashes for
2264+## forward slashes in file and directory
2265+## names in executed command line,
2266+## for MSWin
2267+## 5 May 2012 John Collins Comment on ctrl/C handling in WAIT loop
2268 ##
2269 ## 1998-2010, John Collins. Many improvements and fixes.
2270 ## See CHANGE-log.txt for full list, and CHANGES for summary
2271@@ -325,6 +386,7 @@
2272 '^LaTeX Warning: File `([^\\\']*)\\\' not found',
2273 '^Package .* [fF]ile `([^\\\']*)\\\' not found',
2274 'Error: pdflatex \(file ([^\)]*)\): cannot find image file',
2275+ ': File (.*) not found:\s*$',
2276 );
2277
2278 ## Hash mapping file extension (w/o period, e.g., 'eps') to a single regexp,
2279@@ -369,9 +431,152 @@
2280 # 'pdflatex' => { 'tex' => 1, 'pdf' => 1, 'jpg' => 1, 'png' => 1 }; );
2281 # Instead we'll exercise the user-friendly access routines:
2282 add_input_ext( 'latex', 'tex', 'eps' );
2283-add_input_ext( 'pdflatex', 'tex', 'jpg', 'pdf' );
2284+add_input_ext( 'pdflatex', 'tex', 'jpg', 'pdf', 'png' );
2285 #show_input_ext( 'latex' ); show_input_ext( 'pdflatex' );
2286
2287+# Information about options to latex and pdflatex that latexmk will simply
2288+# pass through to (pdf)latex
2289+# Option without arg. maps to itself.
2290+# Option with arg. maps the option part to the full specification
2291+# e.g., -kpathsea-debug => -kpathsea-debug=NUMBER
2292+%allowed_latex_options = ();
2293+%allowed_latex_options_with_arg = ();
2294+foreach (
2295+ #####
2296+ # TeXLive options
2297+ "-draftmode switch on draft mode (generates no output PDF)",
2298+ "-enc enable encTeX extensions such as \\mubyte",
2299+ "-etex enable e-TeX extensions",
2300+ "-file-line-error enable file:line:error style messages",
2301+ "-no-file-line-error disable file:line:error style messages",
2302+ "-fmt=FMTNAME use FMTNAME instead of program name or a %& line",
2303+ "-halt-on-error stop processing at the first error",
2304+ "-interaction=STRING set interaction mode (STRING=batchmode/nonstopmode/\n".
2305+ " scrollmode/errorstopmode)",
2306+ "-ipc send DVI output to a socket as well as the usual\n".
2307+ " output file",
2308+ "-ipc-start as -ipc, and also start the server at the other end",
2309+ "-kpathsea-debug=NUMBER set path searching debugging flags according to\n".
2310+ " the bits of NUMBER",
2311+ "-mktex=FMT enable mktexFMT generation (FMT=tex/tfm/pk)",
2312+ "-no-mktex=FMT disable mktexFMT generation (FMT=tex/tfm/pk)",
2313+ "-mltex enable MLTeX extensions such as \charsubdef",
2314+ "-output-comment=STRING use STRING for DVI file comment instead of date\n".
2315+ " (no effect for PDF)",
2316+ "-output-format=FORMAT use FORMAT for job output; FORMAT is `dvi\" or `pdf\"",
2317+ "-parse-first-line enable parsing of first line of input file",
2318+ "-no-parse-first-line disable parsing of first line of input file",
2319+ "-progname=STRING set program (and fmt) name to STRING",
2320+ "-shell-escape enable \\write18{SHELL COMMAND}",
2321+ "-no-shell-escape disable \\write18{SHELL COMMAND}",
2322+ "-shell-restricted enable restricted \\write18",
2323+ "-src-specials insert source specials into the DVI file",
2324+ "-src-specials=WHERE insert source specials in certain places of\n".
2325+ " the DVI file. WHERE is a comma-separated value\n".
2326+ " list: cr display hbox math par parend vbox",
2327+ "-synctex=NUMBER generate SyncTeX data for previewers if nonzero",
2328+ "-translate-file=TCXNAME use the TCX file TCXNAME",
2329+ "-8bit make all characters printable by default",
2330+
2331+ #####
2332+ # MikTeX options not in TeXLive
2333+ "-alias=app pretend to be app",
2334+ "-buf-size=n maximum number of characters simultaneously present\n".
2335+ " in current lines",
2336+ "-c-style-errors C-style error messages",
2337+ "-disable-installer disable automatic installation of missing packages",
2338+ "-disable-pipes disable input (output) from (to) child processes",
2339+ "-disable-write18 disable the \\write18{command} construct",
2340+ "-dont-parse-first-line disable checking whether the first line of the main\n".
2341+ " input file starts with %&",
2342+ "-enable-enctex enable encTeX extensions such as \\mubyte",
2343+ "-enable-installer enable automatic installation of missing packages",
2344+ "-enable-mltex enable MLTeX extensions such as \charsubdef",
2345+ "-enable-pipes enable input (output) from (to) child processes",
2346+ "-enable-write18 fully enable the \\write18{command} construct",
2347+ "-error-line=n set the width of context lines on terminal error\n".
2348+ " messages",
2349+ "-extra-mem-bot=n set the extra size (in memory words) for large data\n".
2350+ " structures",
2351+ "-extra-mem-top=n set the extra size (in memory words) for chars,\n".
2352+ " tokens, et al",
2353+ "-font-max=n set the maximum internal font number",
2354+ "-font-mem-size=n set the size, in TeX memory words, of the font memory",
2355+ "-half-error-line=n set the width of first lines of contexts in terminal\n".
2356+ " error messages",
2357+ "-hash-extra=n set the extra space for the hash table of control\n".
2358+ " sequences",
2359+ "-job-time=file set the time-stamp of all output files equal to\n".
2360+ " file'stime-stamp",
2361+ "-main-memory=n change the total size (in memory words) of the main\n".
2362+ " memory array",
2363+ "-max-in-open=n set the maximum number of input files and error\n".
2364+ " insertions that can be going on simultaneously",
2365+ "-max-print-line=n set the width of longest text lines output",
2366+ "-max-strings=n set the maximum number of strings",
2367+ "-nest-size=n set the maximum number of semantic levels\n".
2368+ " simultaneously active",
2369+ "-no-c-style-errors standard error messages",
2370+ "-param-size=n set the the maximum number of simultaneous macro\n".
2371+ " parameters",
2372+ "-pool-size=n set the maximum number of characters in strings",
2373+ "-record-package-usages=file record all package usages and write them into\n".
2374+ " file",
2375+ "-restrict-write18 partially enable the \\write18{command} construct",
2376+ "-save-size=n set the the amount of space for saving values\n".
2377+ " outside of current group",
2378+ "-stack-size=n set the maximum number of simultaneous input sources",
2379+ "-string-vacancies=n set the minimum number of characters that should be\n".
2380+ " available for the user's control sequences and font\n".
2381+ " names",
2382+ "-tcx=name process the TCX table name",
2383+ "-time-statistics show processing time statistics",
2384+ "-trace enable trace messages",
2385+ "-trace=tracestreams enable trace messages. The tracestreams argument is\n".
2386+ " a comma-separated list of trace stream names",
2387+ "-trie-size=n set the amount of space for hyphenation patterns",
2388+ "-undump=name use name as the name of the format to be used,\n".
2389+ " instead of the name by which the program was\n".
2390+ " called or a %& line.",
2391+
2392+ #####
2393+ # Options passed to (pdf)latex that have special processing by latexmk,
2394+ # so they are commented out here.
2395+ #-jobname=STRING set the job name to STRING
2396+ #-aux-directory=dir Set the directory dir to which auxiliary files are written
2397+ #-output-directory=DIR use existing DIR as the directory to write files in
2398+ #-quiet
2399+ #-recorder enable filename recorder
2400+ #
2401+ # Options with different processing by latexmk than (pdf)latex
2402+ #-help
2403+ #-version
2404+ #
2405+ # Options NOT used by latexmk
2406+ #-includedirectory=dir prefix dir to the search path
2407+ #-initialize become the INI variant of the compiler
2408+ #-ini be pdfinitex, for dumping formats; this is implicitly
2409+ # true if the program name is `pdfinitex'
2410+) {
2411+ if ( /^([^\s=]+)=/ ) {
2412+ $allowed_latex_options_with_arg{$1} = $_;
2413+ }
2414+ elsif ( /^([^\s=]+)\s/ ) {
2415+ $allowed_latex_options{$1} = $_;
2416+ }
2417+ else {
2418+ $allowed_latex_options{$_} = $_;
2419+ }
2420+}
2421+
2422+# Arrays of options that will be added to latex and pdflatex.
2423+# These need to be stored until after the command line parsing is finished,
2424+# in case the values of $latex and/or $pdflatex change after an option
2425+# is added.
2426+@extra_latex_options = ();
2427+@extra_pdflatex_options = ();
2428+
2429+
2430 ## Command to invoke biber & bibtex
2431 $biber = 'biber %O %B';
2432 $bibtex = 'bibtex %O %B';
2433@@ -394,6 +599,12 @@
2434
2435 ## Command to convert dvi file to pdf file directly:
2436 $dvipdf = 'dvipdf %O %S %D';
2437+# N.B. Standard dvipdf runs dvips and gs with their silent switch, so for
2438+# standard dvipdf $dvipdf_silent_switch is unneeded, but innocuous.
2439+# But dvipdfmx can be used instead, and it has a silent switch (-q).
2440+# So implementing $dvipdf_silent_switch is useful.
2441+
2442+$dvipdf_silent_switch = '-q';
2443
2444 ## Command to convert dvi file to ps file:
2445 $dvips = 'dvips %O -o %D %S';
2446@@ -428,6 +639,10 @@
2447 ## Current tex's treat extensions like UNIX teTeX:
2448 $extension_treatment = 'unix';
2449
2450+## Substitute backslashes in file and directory names for
2451+## MSWin command line
2452+$MSWin_back_slash = 1;
2453+
2454 $dvi_update_signal = undef;
2455 $ps_update_signal = undef;
2456 $pdf_update_signal = undef;
2457@@ -442,7 +657,8 @@
2458
2459 $quote_filenames = 1; # Quote filenames in external commands
2460
2461-
2462+$del_dir = ''; # Directory into which cleaned up files are to be put.
2463+ # If $del_dir is '', just delete the files
2464
2465 #########################################################################
2466
2467@@ -459,7 +675,7 @@
2468 $MSWin_fudge_break = 1; # Give special treatment to ctrl/C and ctrl/break
2469 # in -pvc mode under MSWin
2470 # Under MSWin32 (at least with perl 5.8 and WinXP)
2471- # when latemk is running another program, and the
2472+ # when latexmk is running another program, and the
2473 # user gives ctrl/C or ctrl/break, to stop the
2474 # daughter program, not only does it reach
2475 # the daughter, but also latexmk/perl, so
2476@@ -570,7 +786,7 @@
2477 # example).
2478 # Cygwin executables for tex and latex may only know cygwin
2479 # filenames.
2480- # 4. The BIBINPUTS and TEXINPUTS environment variables may be
2481+ # 4. The BIBINPUTS environment variables may be
2482 # UNIX-style or MSWin-style depending on whether native NT or
2483 # cygwin executables are used. They are therefore parsed
2484 # differently. Here is the clash:
2485@@ -763,12 +979,29 @@
2486 }
2487 elsif ( $^O eq "darwin" ) {
2488 # OS-X on Macintosh
2489- $lpr_pdf = 'lpr %O %S';
2490+ # open starts command associated with a file.
2491+ # For pdf, this is set by default to OS-X's preview, which is suitable.
2492+ # Manual update is simply by clicking on window etc, which is OK.
2493+ # For ps, this is set also to preview. This works, but since it
2494+ # converts the file to pdf and views the pdf file, it doesn't
2495+ # see updates, and a refresh cannot be done. This is far from
2496+ # optimal.
2497+ # For a full installation of MacTeX, which is probably the most common
2498+ # on OS-X, an association is created between dvi files and TeXShop.
2499+ # This also converts the file to pdf, so again while it works, it
2500+ # does not deal with changed dvi files, as far as I can see.
2501+ $pdf_previewer = 'open %S';
2502+ $pdf_update_method = 1; # manual
2503+ $dvi_previewer = $dvi_previewer_landscape = 'NONE';
2504+ $ps_previewer = $ps_previewer_landscape = 'NONE';
2505+ # Others
2506+ $lpr_pdf = 'lpr %O %S';
2507 $pscmd = "ps -ww -u $ENV{USER}";
2508 }
2509 }
2510
2511 ## default parameters
2512+$auto_rc_use = 1; # Whether to read rc files automatically
2513 $max_repeat = 5; # Maximum times I repeat latex. Normally
2514 # 3 would be sufficient: 1st run generates aux file,
2515 # 2nd run picks up aux file, and maybe toc, lof which
2516@@ -824,10 +1057,14 @@
2517 # command line has same effect as with current
2518 # tex, etc. (If $jobname is non-empty, then
2519 # the --jobname=... option is used on tex.)
2520+$out_dir = ''; # Directory for output files.
2521+ # Cf. --output-directory of current (pdf)latex
2522+$aux_dir = ''; # Directory for aux files (log, aux, etc).
2523+ # Cf. --aux-directory of current (pdf)latex in MiKTeX.
2524
2525
2526 ## default flag settings.
2527-$recorder = 0; # Whether to use recorder option on latex/pdflatex
2528+$recorder = 1; # Whether to use recorder option on latex/pdflatex
2529 $silent = 0; # silence latex's messages?
2530 $landscape_mode = 0; # default to portrait mode
2531
2532@@ -873,9 +1110,14 @@
2533 $do_cd = 0; # Do not do cd to directory of source file.
2534 # Thus behave like latex.
2535 $dependents_list = 0; # Whether to display list(s) of dependencies
2536+$dependents_phony = 0; # Whether list(s) of dependencies includes phony targets
2537+ # (as with 'gcc -MP').
2538 $deps_file = '-'; # File for dependency list output. Default stdout.
2539-$rules_list = 0; # Whether to display list(s) of dependencies
2540-@dir_stack = (); # Stack of pushed directories.
2541+$rules_list = 0; # Whether to display list(s) of dependencies
2542+@dir_stack = (); # Stack of pushed directories, each of form of
2543+ # pointer to array [ cwd, good_cwd ], where
2544+ # good_cwd differs from cwd by being converted
2545+ # to native MSWin path when cygwin is used.
2546 $cleanup_mode = 0; # No cleanup of nonessential LaTex-related files.
2547 # $cleanup_mode = 0: no cleanup
2548 # $cleanup_mode = 1: full cleanup
2549@@ -925,21 +1167,22 @@
2550 $bad_reference = 0;
2551 $bad_citation = 0;
2552
2553+# Cache of expensive-to-compute state variables, e.g., cwd in form
2554+# fixed to deal with cygwin issues.
2555+%cache = ();
2556+&cache_good_cwd;
2557
2558 # Set search paths for includes.
2559 # Set them early so that they can be overridden
2560 $BIBINPUTS = $ENV{'BIBINPUTS'};
2561 if (!$BIBINPUTS) { $BIBINPUTS = '.'; }
2562-#?? OBSOLETE
2563-$TEXINPUTS = $ENV{'TEXINPUTS'};
2564-if (!$TEXINPUTS) { $TEXINPUTS = '.'; }
2565
2566 # Convert search paths to arrays:
2567 # If any of the paths end in '//' then recursively search the
2568 # directory. After these operations, @BIBINPUTS should
2569 # have all the directories that need to be searched
2570
2571-@BIBINPUTS = find_dirs1 ($BIBINPUTS);
2572+@BIBINPUTS = find_dirs1( $BIBINPUTS );
2573
2574
2575 ######################################################################
2576@@ -1060,7 +1303,7 @@
2577 %primaries = (); # Hash of rules for primary part of make. Keys are
2578 # currently 'latex', 'pdflatex' or both. Value is
2579 # currently irrelevant. Use hash for ease of lookup
2580- # Make remove this later, if use makeB
2581+ # Make remove this later, if use rdb_makeB
2582
2583 # Hashes, whose keys give names of particular kinds of rule. We use
2584 # hashes for ease of lookup.
2585@@ -1077,7 +1320,9 @@
2586 # Rule data:
2587 # 0: [ cmd_type, ext_cmd, int_cmd, test_kind,
2588 # source, dest, base,
2589- # out_of_date, out_of_date_user, time_of_last_run, changed
2590+ # out_of_date, out_of_date_user,
2591+ # time_of_last_run, time_of_last_file_check,
2592+ # changed
2593 # last_result, last_message,
2594 # default_extra_generated
2595 # ]
2596@@ -1087,7 +1332,8 @@
2597 # with substitutions (%D for destination, %S
2598 # for source, %B for base of current rule,
2599 # %R for base of primary tex file, %T for
2600- # texfile name, and %O for options.
2601+ # texfile name, %O for options,
2602+ # %Y for $aux_dir1, and %Z for $out_dir1
2603 # int_cmd specifies any internal command to be
2604 # used to implement the application of the
2605 # rule. If this is present, it overrides
2606@@ -1135,6 +1381,8 @@
2607 # last applied. (In standard units
2608 # from perl, to be directly compared
2609 # with file modification times.)
2610+ # time_of_last_file_check = last time that a check
2611+ # was made for changes in source files.
2612 # changed flags whether special changes have been made
2613 # that require file-existence status to be ignored
2614 # last_result is
2615@@ -1143,11 +1391,15 @@
2616 # 1 if last run was successful, but
2617 # failed to create an output file
2618 # 2 if last run failed
2619+ # 200 if last run gave a warning that is
2620+ # important enough to be reported with
2621+ # the error summary. The warning
2622+ # message is stored in last_message.
2623 # last_message is error message for last run
2624 # default_extra_generated is a reference to an array
2625 # of specifications of extra generated files (beyond
2626 # the main dest file. Standard place holders are used.
2627- # Example ['%R.log'] for (pdf)latex, and ['%R.blg']
2628+ # Example ['%Y%R.log'] for (pdf)latex, and ['%R.blg']
2629 # for bibtex. (There's no need for '%R.aux', here,
2630 # since such generated files are detected dynamically.)
2631 # 1: {Hash sourcefile -> [source-file data] }
2632@@ -1185,9 +1437,6 @@
2633 %fdb_current = (); # Fdb-hash for all files used.
2634
2635
2636-#==================================================
2637-## Read rc files:
2638-
2639 # User's home directory
2640 $HOME = '';
2641 if (exists $ENV{'HOME'} ) {
2642@@ -1198,6 +1447,19 @@
2643 }
2644
2645
2646+#==================================================
2647+
2648+# Options that are to be obeyed before rc files are read:
2649+
2650+foreach $_ ( @ARGV )
2651+{
2652+ if (/^-{1,2}norc$/ ) {
2653+ $auto_rc_use = 0;
2654+ }
2655+}
2656+
2657+#==================================================
2658+## Read rc files with this subroutine
2659
2660 sub read_first_rc_file_in_list {
2661 foreach my $rc_file ( @_ ) {
2662@@ -1210,33 +1472,37 @@
2663 }
2664 }
2665
2666-# Read system rc file:
2667-read_first_rc_file_in_list( @rc_system_files );
2668-# Read user rc file.
2669-read_first_rc_file_in_list( "$HOME/.latexmkrc" );
2670-# Read rc file in current directory.
2671-read_first_rc_file_in_list( "latexmkrc", ".latexmkrc" );
2672-
2673-#==================================================
2674-
2675-if ($bibtex_use > 1) {
2676- push @generated_exts, 'bbl';
2677-}
2678-
2679-#show_array ("BIBINPUTS", @BIBINPUTS); die;
2680+# Note that each rc file may unset $auto_rc_use to
2681+# prevent lower-level rc files from being read.
2682+# So test on $auto_rc_use in each case.
2683+if ( $auto_rc_use ) {
2684+ # System rc file:
2685+ read_first_rc_file_in_list( @rc_system_files );
2686+}
2687+if ( $auto_rc_use ) {
2688+ # User rc file:
2689+ read_first_rc_file_in_list( "$HOME/.latexmkrc" );
2690+}
2691+if ( $auto_rc_use ) {
2692+ # Rc file in current directory:
2693+ read_first_rc_file_in_list( "latexmkrc", ".latexmkrc" );
2694+}
2695
2696 ## Process command line args.
2697 @command_line_file_list = ();
2698 $bad_options = 0;
2699
2700-#print "Command line arguments:\n"; for ($i = 0; $i <= $#ARGV; $i++ ) { print "$i: '$ARGV[$i]'\n"; }
2701-
2702 while ($_ = $ARGV[0])
2703 {
2704- # Make -- and - equivalent at beginning of option:
2705+ # Make -- and - equivalent at beginning of option,
2706+ # but save original for possible use in (pdf)latex command line
2707+ $original = $_;
2708 s/^--/-/;
2709 shift;
2710- if (/^-bibtex$/) { $bibtex_use = 2; }
2711+ if ( /^-aux-directory=(.*)$/ || /^-auxdir=(.*)$/ ) {
2712+ $aux_dir = $1;
2713+ }
2714+ elsif (/^-bibtex$/) { $bibtex_use = 2; }
2715 elsif (/^-bibtex-$/) { $bibtex_use = 0; }
2716 elsif (/^-nobibtex$/) { $bibtex_use = 0; }
2717 elsif (/^-bibtex-cond$/) { $bibtex_use = 1; }
2718@@ -1247,12 +1513,13 @@
2719 elsif (/^-cd-$/) { $do_cd = 0; }
2720 elsif (/^-commands$/) { &print_commands; exit; }
2721 elsif (/^-d$/) { $banner = 1; }
2722- elsif (/^-dependents$/ || /^-deps$/ ) { $dependents_list = 1; }
2723+ elsif (/^-dependents$/ || /^-deps$/ || /^-M$/ ) { $dependents_list = 1; }
2724 elsif (/^-nodependents$/ || /^-dependents-$/ || /^-deps-$/) { $dependents_list = 0; }
2725 elsif (/^-deps-out=(.*)$/) {
2726 $deps_file = $1;
2727 $dependents_list = 1;
2728 }
2729+ elsif (/^-diagnostics/) { $diagnostics = 1; }
2730 elsif (/^-dvi$/) { $dvi_mode = 1; }
2731 elsif (/^-dvi-$/) { $dvi_mode = 0; }
2732 elsif (/^-f$/) { $force_mode = 1; }
2733@@ -1263,7 +1530,6 @@
2734 $go_mode = 2; $cleanup_mode = 1; $cleanup_fdb = 1; $cleanup_only = 0;
2735 }
2736 elsif ( /^-h$/ || /^-help$/ ) { &print_help; exit;}
2737- elsif (/^-diagnostics/) { $diagnostics = 1; }
2738 elsif (/^-jobname=(.*)$/) {
2739 $jobname = $1;
2740 }
2741@@ -1272,24 +1538,44 @@
2742 elsif (/^-latex=(.*)$/) {
2743 $latex = $1;
2744 }
2745- elsif (/^-pdflatex=(.*)$/) {
2746- $pdflatex = $1;
2747- }
2748+ elsif (/^-latexoption=(.*)$/) {
2749+ push @extra_latex_options, $1;
2750+ push @extra_pdflatex_options, $1;
2751+ }
2752+# See above for -M
2753+ elsif (/^-MF$/) {
2754+ if ( $ARGV[0] eq '' ) {
2755+ &exit_help( "No file name specified after -MF switch");
2756+ }
2757+ $deps_file = $ARGV[0];
2758+ shift;
2759+ }
2760+ elsif ( /^-MP$/ ) { $dependents_phony = 1; }
2761 elsif (/^-new-viewer$/) {
2762- $new_viewer_always = 1;
2763+ $new_viewer_always = 1;
2764 }
2765 elsif (/^-new-viewer-$/) {
2766- $new_viewer_always = 0;
2767+ $new_viewer_always = 0;
2768+ }
2769+ elsif (/^-norc$/ ) {
2770+ $auto_rc_use = 0;
2771+ # N.B. This has already been obeyed.
2772+ }
2773+ elsif ( /^-output-directory=(.*)$/ ||/^-outdir=(.*)$/ ) {
2774+ $out_dir = $1;
2775 }
2776 elsif (/^-p$/) { $printout_mode = 1;
2777 $preview_continuous_mode = 0; # to avoid conflicts
2778 $preview_mode = 0;
2779 }
2780 elsif (/^-p-$/) { $printout_mode = 0; }
2781+ elsif (/^-pdf$/) { $pdf_mode = 1; }
2782+ elsif (/^-pdf-$/) { $pdf_mode = 0; }
2783 elsif (/^-pdfdvi$/){ $pdf_mode = 3; }
2784+ elsif (/^-pdflatex=(.*)$/) {
2785+ $pdflatex = $1;
2786+ }
2787 elsif (/^-pdfps$/) { $pdf_mode = 2; }
2788- elsif (/^-pdf$/) { $pdf_mode = 1; }
2789- elsif (/^-pdf-$/) { $pdf_mode = 0; }
2790 elsif (/^-print=(.*)$/) {
2791 $value = $1;
2792 if ( $value =~ /^dvi$|^ps$|^pdf$/ ) {
2793@@ -1317,21 +1603,44 @@
2794 elsif (/^-recorder-$/ ){ $recorder = 0; }
2795 elsif (/^-rules$/ ) { $rules_list = 1; }
2796 elsif (/^-norules$/ || /^-rules-$/ ) { $rules_list = 0; }
2797+ elsif (/^-showextraoptions$/) {
2798+ print "List of extra latex and pdflatex options recognized by $my_name.\n",
2799+ "These are passed as is to (pdf)latex. They may not be recognized by\n",
2800+ "particular versions of (pdf)latex. This list is a combination of those\n",
2801+ "for TeXLive and MikTeX.\n",
2802+ "\n",
2803+ "Note that in addition to the options in this list, there are several\n",
2804+ "options known to the (pdf)latex programs that are also recognized by\n",
2805+ "latexmk and trigger special behavior by latexmk. Since these options\n",
2806+ "appear in the main list given by running 'latexmk --help', they do not\n",
2807+ "appear in the following list\n",
2808+ "\n";
2809+ foreach $option ( sort( keys %allowed_latex_options, keys %allowed_latex_options_with_arg ) ) {
2810+ if (exists $allowed_latex_options{$option} ) { print " $allowed_latex_options{$option}\n"; }
2811+ if (exists $allowed_latex_options_with_arg{$option} ) { print " $allowed_latex_options_with_arg{$option}\n"; }
2812+ }
2813+ exit;
2814+ }
2815 elsif (/^-silent$/ || /^-quiet$/ ){ $silent = 1; }
2816 elsif (/^-time$/) { $show_time = 1;}
2817 elsif (/^-time-$/) { $show_time = 0;}
2818- elsif (/^-v$/ || /^-version$/) {
2819- print "\n$version_details. Version $version_num\n";
2820- exit;
2821- }
2822 elsif (/^-use-make$/) { $use_make_for_missing_files = 1; }
2823 elsif (/^-use-make-$/) { $use_make_for_missing_files = 0; }
2824+ elsif (/^-v$/ || /^-version$/) {
2825+ print "\n$version_details. Version $version_num\n";
2826+ exit;
2827+ }
2828 elsif (/^-verbose$/) { $silent = 0; }
2829 elsif (/^-view=default$/) { $view = "default";}
2830 elsif (/^-view=dvi$/) { $view = "dvi";}
2831 elsif (/^-view=none$/) { $view = "none";}
2832 elsif (/^-view=ps$/) { $view = "ps";}
2833 elsif (/^-view=pdf$/) { $view = "pdf"; }
2834+ elsif (/^-xelatex$/) {
2835+ $pdflatex = "xelatex %O %S";
2836+ $pdf_mode = 1;
2837+ $dvi_mode = $postscript_mode = 0;
2838+ }
2839 elsif (/^-e$/) {
2840 if ( $#ARGV < 0 ) {
2841 &exit_help( "No code to execute specified after -e switch");
2842@@ -1386,6 +1695,13 @@
2843 $ps_filter = $ARGV[0];
2844 shift;
2845 }
2846+ elsif ( ( exists( $allowed_latex_options{$_} ) )
2847+ || ( /^(-.+)=/ && exists( $allowed_latex_options_with_arg{$1} ) )
2848+ )
2849+ {
2850+ push @extra_latex_options, $original;
2851+ push @extra_pdflatex_options, $original;
2852+ }
2853 elsif (/^-/) {
2854 warn "$My_name: $_ bad option\n";
2855 $bad_options++;
2856@@ -1403,6 +1719,28 @@
2857 "**** Report bugs etc to John Collins <collins at phys.psu.edu>. ****\n"
2858 unless $silent;
2859
2860+if ( ($out_dir ne '') && ($aux_dir eq '') ){
2861+ $aux_dir = $out_dir;
2862+}
2863+
2864+foreach ($out_dir, $aux_dir) {
2865+ # Remove aliases to cwd:
2866+ $_ = normalize_filename( $_ );
2867+ if ($_ eq '.' ) { $_ = ''; }
2868+}
2869+# Versions terminating in directory/path separator
2870+$out_dir1 = $out_dir;
2871+$aux_dir1 = $aux_dir;
2872+foreach ( $aux_dir1, $out_dir1 ) {
2873+ if ( ($_ ne '') && ! m([\\/\:]$) ) {
2874+ $_ .= '/';
2875+ }
2876+}
2877+
2878+if ($bibtex_use > 1) {
2879+ push @generated_exts, 'bbl';
2880+}
2881+
2882 # For backward compatibility, convert $texfile_search to @default_files
2883 # Since $texfile_search is initialized to "", a nonzero value indicates
2884 # that an initialization file has set it.
2885@@ -1410,9 +1748,6 @@
2886 @default_files = split / /, "*.tex $texfile_search";
2887 }
2888
2889-#printA "A: Command line file list:\n";
2890-#for ($i = 0; $i <= $#command_line_file_list; $i++ ) { print "$i: '$command_line_file_list[$i]'\n"; }
2891-
2892 #Glob the filenames command line if the script was not invoked under a
2893 # UNIX-like environment.
2894 # Cases: (1) MS/MSwin native Glob
2895@@ -1431,8 +1766,6 @@
2896 }
2897 else {
2898 @file_list = @command_line_file_list;
2899-#print "A2:File list:\n";
2900-#for ($i = 0; $i <= $#file_list; $i++ ) { print "$i: '$file_list[$i]'\n"; }
2901 }
2902 @file_list = uniq1( @file_list );
2903
2904@@ -1526,8 +1859,11 @@
2905 &fix_cmds;
2906
2907 # Add common options
2908-add_option( \$latex, $latex_default_switches );
2909-add_option( \$pdflatex, $pdflatex_default_switches );
2910+add_option( $latex_default_switches, \$latex );
2911+add_option( $pdflatex_default_switches, \$pdflatex );
2912+
2913+foreach (@extra_latex_options) { add_option( $_, \$latex ); }
2914+foreach (@extra_pdflatex_options) { add_option( $_, \$pdflatex ); }
2915
2916
2917 # If landscape mode, change dvips processor, and the previewers:
2918@@ -1539,23 +1875,53 @@
2919 }
2920
2921 if ( $silent ) {
2922- add_option( \$latex, " $latex_silent_switch" );
2923- add_option( \$pdflatex, " $pdflatex_silent_switch" );
2924- add_option( \$biber, " $biber_silent_switch" );
2925- add_option( \$bibtex, " $bibtex_silent_switch" );
2926- add_option( \$makeindex, " $makeindex_silent_switch" );
2927- add_option( \$dvips, " $dvips_silent_switch" );
2928+ add_option( "$latex_silent_switch", \$latex );
2929+ add_option( "$pdflatex_silent_switch", \$pdflatex );
2930+ add_option( "$biber_silent_switch", \$biber );
2931+ add_option( "$bibtex_silent_switch", \$bibtex );
2932+ add_option( "$makeindex_silent_switch", \$makeindex );
2933+ add_option( "$dvipdf_silent_switch", \$dvipdf );
2934+ add_option( "$dvips_silent_switch", \$dvips );
2935 }
2936
2937 if ( $recorder ) {
2938- add_option( \$latex, "-recorder" );
2939- add_option( \$pdflatex, "-recorder" );
2940+ add_option( "-recorder", \$latex, \$pdflatex );
2941+}
2942+
2943+if ( $out_dir ) {
2944+ add_option( "-output-directory=\"$out_dir\"", \$latex, \$pdflatex );
2945+ if ( ! -e $out_dir ) {
2946+ warn "$My_name: making output directory '$out_dir'\n"
2947+ if ! $silent;
2948+ mkdir $out_dir;
2949+ }
2950+ elsif ( ! -d $out_dir ) {
2951+ warn "$My_name: you requested output directory '$out_dir',\n",
2952+ " but an ordinary file of the same name exists, which will\n",
2953+ " probably give an error later\n";
2954+ }
2955+}
2956+
2957+if ( $aux_dir && ($aux_dir ne $out_dir) ) {
2958+ # N.B. If $aux_dir and $out_dir are the same, then the -output-directory
2959+ # option is sufficient, especially because the -aux-directory exists
2960+ # only in MiKTeX, not in TeXLive.
2961+ add_option( "-aux-directory=\"$aux_dir\"", \$latex, \$pdflatex );
2962+ if ( ! -e $aux_dir ) {
2963+ warn "$My_name: making auxiliary directory '$aux_dir'\n"
2964+ if ! $silent;
2965+ mkdir $aux_dir;
2966+ }
2967+ elsif ( ! -d $aux_dir ) {
2968+ warn "$My_name: you requested aux directory '$aux_dir',\n",
2969+ " but an ordinary file of the same name exists, which will\n",
2970+ " probably give an error later\n";
2971+ }
2972 }
2973
2974 if ( $jobname ne '' ) {
2975 $jobstring = "--jobname=$jobname";
2976- add_option( \$latex, " $jobstring" );
2977- add_option( \$pdflatex, " $jobstring" );
2978+ add_option( "$jobstring", \$latex, \$pdflatex );
2979 }
2980
2981 # Which kind of file do we preview?
2982@@ -1606,7 +1972,7 @@
2983
2984 if ( $pdf_mode == 2 ) {
2985 # We generate pdf from ps. Make sure we have the correct kind of ps.
2986- add_option( \$dvips, " $dvips_pdf_switch" );
2987+ add_option( "$dvips_pdf_switch", \$dvips );
2988 }
2989
2990 # Note sleep has granularity of 1 second.
2991@@ -1636,6 +2002,22 @@
2992 $generated_exts_all{$_} = 1;
2993 }
2994
2995+if ($aux_dir) {
2996+ # Ensure $aux_dir is in TEXINPUTS search path.
2997+ # This is used by dvips for files generated by mpost.
2998+ if ( ! exists $ENV{TEXINPUTS} ) {
2999+ # Note the trailing ":" which ensures that the last item
3000+ # in the list of paths is the empty path, which actually
3001+ # means the default path, i.e., the following means that
3002+ # the TEXINPUTS search path is $aux_dir and the standard
3003+ # value.
3004+ $ENV{TEXINPUTS} = $aux_dir.$search_path_separator;
3005+ }
3006+ elsif ( $ENV{TEXINPUTS} !~ /$aux_dir$search_path_separator/ ) {
3007+ $ENV{TEXINPUTS} = $aux_dir.$search_path_separator.$ENV{TEXINPUTS};
3008+ }
3009+}
3010+
3011 $quell_uptodate_msgs = $silent;
3012 # Whether to quell informational messages when files are uptodate
3013 # Will turn off in -pvc mode
3014@@ -1690,26 +2072,30 @@
3015 $root_filename = $jobname;
3016 }
3017
3018+ $aux_main = "$aux_dir1$root_filename.aux";
3019+ $log_name = "$aux_dir1$root_filename.log";
3020+ $fdb_name = "$aux_dir1$root_filename.$fdb_ext";
3021+
3022 # Initialize basic dependency information:
3023
3024 # For use under error conditions:
3025- @default_includes = ($texfile_name, "$root_filename.aux");
3026+ @default_includes = ($texfile_name, $aux_main);
3027
3028- $fdb_file = "$root_filename.$fdb_ext";
3029-
3030- # Initialize file and rule databases.
3031+ # Initialize rule database.
3032+ # ?? Should I also initialize file database?
3033 %rule_list = ();
3034 &rdb_make_rule_list;
3035 &rdb_set_rules(\%rule_list);
3036
3037 if ( $cleanup_mode > 0 ) {
3038+# ?? MAY NEED TO FIX THE FOLLOWING IF $aux_dir or $out_dir IS SET.
3039 my %other_generated = ();
3040 my @index_bibtex_generated = ();
3041 my @aux_files = ();
3042 $have_fdb = 0;
3043- if ( -e $fdb_file ) {
3044- print "$My_name: Examining fdb file '$fdb_file' for rules ...\n";
3045- $have_fdb = ( 0 == rdb_read( $fdb_file ) );
3046+ if ( -e $fdb_name ) {
3047+ print "$My_name: Examining fdb file '$fdb_name' for rules ...\n";
3048+ $have_fdb = ( 0 == rdb_read( $fdb_name ) );
3049 }
3050 if ( $have_fdb ) {
3051 rdb_for_all(
3052@@ -1733,10 +2119,10 @@
3053 );
3054 }
3055 else {
3056- # No fdb file, so do inferior job by parse_logB
3057- print "$My_name: Examining log file '$root_filename.log' for generated files...\n";
3058+ # No fdb file, so do inferior job by parse_log
3059+ print "$My_name: Examining log file '$log_name' for generated files...\n";
3060
3061- # Variables set by parse_logB. Can I remove them
3062+ # Variables set by parse_log. Can I remove them
3063 local %generated_log = ();
3064 local %dependents = (); # Maps files to status. Not used here.
3065 local @bbl_files = (); # Not used here.
3066@@ -1745,7 +2131,7 @@
3067 # Maps output file created and read by (pdf)latex
3068 # to source file of conversion.
3069 local $primary_out = ''; # Actual output file (dvi or pdf). Not used here.
3070- &parse_logB;
3071+ &parse_log;
3072 %other_generated = %generated_log;
3073 }
3074
3075@@ -1776,31 +2162,36 @@
3076 ." (only deleted if \$cleanup_includes_generated is set): ",
3077 keys %other_generated );
3078 }
3079- # files used in previous versions of latexmk
3080- &cleanup1( $fdb_ext, 'blg', 'ilg', 'log', 'aux.bak', 'idx.bak',
3081+ &cleanup1( $aux_dir1, $fdb_ext, 'blg', 'ilg', 'log', 'aux.bak', 'idx.bak',
3082 split(' ',$clean_ext),
3083 keys %generated_exts_all
3084 );
3085- unlink( 'texput.log', "texput.aux",
3086+ unlink_or_move( 'texput.log', "texput.aux",
3087 keys %index_bibtex_generated,
3088 keys %aux_files );
3089 if ($cleanup_includes_generated) {
3090- unlink( keys %other_generated );
3091+ unlink_or_move( keys %other_generated );
3092 }
3093 if ( $cleanup_includes_cusdep_generated) {
3094 &cleanup_cusdep_generated;
3095 }
3096 if ( $cleanup_mode == 1 ) {
3097- &cleanup1( 'dvi', 'dviF', 'ps', 'psF', 'pdf',
3098+ &cleanup1( $out_dir1, 'dvi', 'dviF', 'ps', 'psF', 'pdf',
3099 split(' ', $clean_full_ext)
3100 );
3101 }
3102 }
3103- if ($cleanup_fdb) { unlink $fdb_file; }
3104+ if ($cleanup_fdb) {
3105+ unlink_or_move( $fdb_name );
3106+ # If the fdb file exists, it will have been read, and therefore changed
3107+ # rule database. But deleting the fdb file implies we also want
3108+ # a virgin rule database, so we must reset it:
3109+ rdb_set_rules( \%rule_list );
3110+ }
3111 if ($cleanup_only) { next FILE; }
3112
3113
3114-#??? The following are not needed if use makeB.
3115+#??? The following are not needed if use rdb_make.
3116 # ?? They may be set too early?
3117 # Arrays and hashes for picking out accessible rules.
3118 # Distinguish rules for making files and others
3119@@ -1826,7 +2217,7 @@
3120 }
3121
3122 $have_fdb = 0;
3123- if ( (! -e $fdb_file) && (! -e "$root_filename.aux") ) {
3124+ if ( (! -e $fdb_name) && (! -e $aux_main ) ) {
3125 # No aux and no fdb file => set up trivial aux file
3126 # and corresponding fdb_file. Arrange them to provoke one run
3127 # as minimum, but no more if actual aux file is trivial.
3128@@ -1834,8 +2225,8 @@
3129 &set_trivial_aux_fdb;
3130 }
3131
3132- if ( -e $fdb_file ) {
3133- $rdb_errors = rdb_read( $fdb_file );
3134+ if ( -e $fdb_name ) {
3135+ $rdb_errors = rdb_read( $fdb_name );
3136 $have_fdb = ($rdb_errors == 0);
3137 }
3138 if (!$have_fdb) {
3139@@ -1843,10 +2234,10 @@
3140 # previous run. So use filetime criterion for make
3141 # instead of change from previous run, until we have
3142 # done our own make.
3143- rdb_recurseA( [keys %possible_primaries],
3144+ rdb_recurse( [keys %possible_primaries],
3145 sub{ if ( $$Ptest_kind == 1 ) { $$Ptest_kind = 3;} }
3146 );
3147- if ( -e "$root_filename.log" ) {
3148+ if ( -e $log_name ) {
3149 rdb_for_some( [keys %possible_primaries], \&rdb_set_latex_deps );
3150 }
3151 }
3152@@ -1861,7 +2252,7 @@
3153
3154 if ($go_mode) {
3155 # Force everything to be remade.
3156- rdb_recurseA( [keys %requested_filerules], sub{$$Pout_of_date=1;} );
3157+ rdb_recurse( [keys %requested_filerules], sub{$$Pout_of_date=1;} );
3158 }
3159
3160
3161@@ -1873,7 +2264,7 @@
3162 #************************************************************
3163
3164 if ( $preview_continuous_mode ) {
3165- &make_preview_continuousB;
3166+ &make_preview_continuous;
3167 # Will probably exit by ctrl/C and never arrive here.
3168 next FILE;
3169 }
3170@@ -1894,7 +2285,7 @@
3171 #Initialize failure flags now.
3172 $failure = 0;
3173 $failure_msg = '';
3174- $failure = rdb_makeB( keys %requested_filerules );
3175+ $failure = rdb_make( keys %requested_filerules );
3176 if ($failure > 0) { next FILE; }
3177 rdb_for_some( [keys %one_time], \&rdb_run1 );
3178 } # end FILE
3179@@ -1907,7 +2298,8 @@
3180 if ( $failure_msg ) {
3181 #Remove trailing space
3182 $failure_msg =~ s/\s*$//;
3183- warn "$My_name: Did not finish processing file:\n $failure_msg\n";
3184+ warn "$My_name: Did not finish processing file '$filename':\n",
3185+ " $failure_msg\n";
3186 $failure = 1;
3187 }
3188 }
3189@@ -1945,7 +2337,8 @@
3190 @failed_primaries);
3191 }
3192 if ( !$force_mode ) {
3193- warn "$My_name: Use the -f option to force complete processing.\n";
3194+ warn "$My_name: Use the -f option to force complete processing,\n",
3195+ " unless error was exceeding maximum runs of latex/pdflatex.\n";
3196 }
3197 exit 12;
3198 }
3199@@ -1965,6 +2358,14 @@
3200 # Source only
3201 if ( $_ && ! /%/ ) { $_ .= " %O %S"; }
3202 }
3203+ foreach ($pdf_previewer, $ps_previewer, $ps_previewer_landscape,
3204+ $dvi_previewer, $dvi_previewer_landscape,
3205+ ) {
3206+ # Run previewers detached
3207+ if ( $_ && ! /^(nostart|NONE|internal) / ) {
3208+ $_ = "start $_";
3209+ }
3210+ }
3211 foreach ($biber, $bibtex) {
3212 # Base only
3213 if ( $_ && ! /%/ ) { $_ .= " %O %B"; }
3214@@ -1986,10 +2387,14 @@
3215 #############################################################
3216
3217 sub add_option {
3218- # Call add_option( \$cmd, $opt )
3219- # Add option to command
3220- if ( ${$_[0]} !~ /%/ ) { &fix_cmds; }
3221- ${$_[0]} =~ s/%O/$_[1] %O/;
3222+ # Call add_option( $opt, \$cmd ... )
3223+ # Add option to one or more commands
3224+ my $option = shift;
3225+ while (@_) {
3226+ if ( ${$_[0]} !~ /%/ ) { &fix_cmds; }
3227+ ${$_[0]} =~ s/%O/$option %O/;
3228+ shift;
3229+ }
3230 } #END add_option
3231
3232 #############################################################
3233@@ -1997,17 +2402,18 @@
3234 sub rdb_make_rule_list {
3235 # Substitutions: %S = source, %D = dest, %B = this rule's base
3236 # %T = texfile, %R = root = base for latex.
3237+# %Y for $aux_dir1, %Z for $out_dir1
3238
3239 # Defaults for dvi, ps, and pdf files
3240 # Use local, not my, so these variables can be referenced
3241- local $dvi_final = "%R.dvi";
3242- local $ps_final = "%R.ps";
3243- local $pdf_final = "%R.pdf";
3244+ local $dvi_final = "%Z%R.dvi";
3245+ local $ps_final = "%Z%R.ps";
3246+ local $pdf_final = "%Z%R.pdf";
3247 if ( length($dvi_filter) > 0) {
3248- $dvi_final = "%R.dviF";
3249+ $dvi_final = "%Z%R.dviF";
3250 }
3251 if ( length($ps_filter) > 0) {
3252- $ps_final = "%R.psF";
3253+ $ps_final = "%Z%R.psF";
3254 }
3255
3256 my $print_file = '';
3257@@ -2047,14 +2453,14 @@
3258 # This is because, especially for dvi file, the contents of the file may contain
3259 # a pointer to a file to be included, not the contents of the file!
3260 %rule_list = (
3261- 'latex' => [ 'primary', "$latex", '', "%T", "%B.dvi", "%R", 1, ["%R.log"] ],
3262- 'pdflatex' => [ 'primary', "$pdflatex", '', "%T", "%B.pdf", "%R", 1, ["%R.log"] ],
3263- 'dvipdf' => [ 'external', "$dvipdf", 'do_viewfile', $dvi_final, "%B.pdf", "%R", 2 ],
3264- 'dvips' => [ 'external', "$dvips", 'do_viewfile', $dvi_final, "%B.ps", "%R", 2 ],
3265- 'dvifilter'=> [ 'external', $dvi_filter, 'do_viewfile', "%B.dvi", "%B.dviF", "%R", 2 ],
3266- 'ps2pdf' => [ 'external', "$ps2pdf", 'do_viewfile', $ps_final, "%B.pdf", "%R", 2 ],
3267- 'psfilter' => [ 'external', $ps_filter, 'do_viewfile', "%B.ps", "%B.psF", "%R", 2 ],
3268- 'print' => [ 'external', "$print_cmd", 'if_source', $print_file, "", "", 2 ],
3269+ 'latex' => [ 'primary', "$latex", '', "%T", "%Z%B.dvi", "%R", 1, ["%Y%R.log"] ],
3270+ 'pdflatex' => [ 'primary', "$pdflatex", '', "%T", "%Z%B.pdf", "%R", 1, ["%Y%R.log"] ],
3271+ 'dvipdf' => [ 'external', "$dvipdf", 'do_viewfile', $dvi_final, "%B.pdf", "%Z%R", 2 ],
3272+ 'dvips' => [ 'external', "$dvips", 'do_viewfile', $dvi_final, "%B.ps", "%Z%R", 2 ],
3273+ 'dvifilter'=> [ 'external', $dvi_filter, 'do_viewfile', "%B.dvi", "%B.dviF", "%Z%R", 2 ],
3274+ 'ps2pdf' => [ 'external', "$ps2pdf", 'do_viewfile', $ps_final, "%B.pdf", "%Z%R", 2 ],
3275+ 'psfilter' => [ 'external', $ps_filter, 'do_viewfile', "%B.ps", "%B.psF", "%Z%R", 2 ],
3276+ 'print' => [ 'external', "$print_cmd", 'if_source', $print_file, "", "", 2 ],
3277 'update_view' => [ 'external', $viewer_update_command, $PA_update,
3278 $view_file, "", "", 2 ],
3279 'view' => [ 'external', "$viewer", 'if_source', $view_file, "", "", 2 ],
3280@@ -2095,6 +2501,8 @@
3281 # until run time, in case of changes.
3282 foreach ($base, $source, $dest, @$PA_extra_gen ) {
3283 s/%R/$root_filename/;
3284+ s/%Y/$aux_dir1/;
3285+ s/%Z/$out_dir1/;
3286 }
3287 foreach ($source, $dest ) {
3288 s/%B/$base/;
3289@@ -2104,7 +2512,7 @@
3290 # " S='$source', D='$dest', B='$base' $needs_making\n";
3291 rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $test_kind,
3292 $source, $dest, $base,
3293- $needs_making, undef, 1, $PA_extra_gen );
3294+ $needs_making, undef, undef, 1, $PA_extra_gen );
3295 # !! ?? Last line was
3296 # $needs_making, undef, ($test_kind==1) );
3297 }
3298@@ -2156,20 +2564,20 @@
3299 # 2. Write a corresponding fdb file
3300 # 3. Provoke a run of (pdf)latex (actually of all primaries).
3301
3302- local $aux_file = "$root_filename.aux";
3303- open( aux_file, '>', $aux_file )
3304- or die "Cannot write file '$aux_file'\n";
3305+ local *aux_file;
3306+ open( aux_file, '>', $aux_main )
3307+ or die "Cannot write file '$aux_main'\n";
3308 print aux_file "\\relax \n";
3309 close(aux_file);
3310
3311 foreach my $rule (keys %primaries ) {
3312 rdb_ensure_file( $rule, $texfile_name );
3313- rdb_ensure_file( $rule, $aux_file );
3314+ rdb_ensure_file( $rule, $aux_main );
3315 rdb_one_rule( $rule,
3316 sub{ $$Pout_of_date = 1; }
3317 );
3318 }
3319- &rdb_write( $fdb_file );
3320+ &rdb_write( $fdb_name );
3321 } #END set_trivial_aux_fdb
3322
3323 #************************************************************
3324@@ -2238,12 +2646,21 @@
3325 my $return = 0;
3326 my ($base, $path, $ext) = fileparseA( $$Pdest );
3327 if ( &view_file_via_temporary ) {
3328- my $tmpfile = tempfile1( "${root_filename}_tmp", $ext );
3329- $return = &rdb_ext_cmd1( '', '', $tmpfile );
3330- move( $tmpfile, $$Pdest );
3331+ if ( $$Pext_cmd =~ /%D/ ) {
3332+ my $tmpfile = tempfile1( "${root_filename}_tmp", $ext );
3333+ warn "$My_name: Making '$$Pdest' via temporary '$tmpfile'...\n";
3334+ $return = &Run_subst( undef, undef, undef, undef, $tmpfile );
3335+ move( $tmpfile, $$Pdest );
3336+ }
3337+ else {
3338+ warn "$My_name is configured to make '$$Pdest' via a temporary file\n",
3339+ " but the command template '$$Pext_cmd' does not have a slot\n",
3340+ " to set the destination file, so I won't use a temporary file\n";
3341+ $return = &Run_subst();
3342+ }
3343 }
3344 else {
3345- $return = &rdb_ext_cmd;
3346+ $return = &Run_subst();
3347 }
3348 return $return;
3349 } #END do_viewfile
3350@@ -2290,7 +2707,7 @@
3351 }
3352 elsif ($viewer_update_method == 4) {
3353 if (defined $$Pext_cmd) {
3354- $return = &rdb_ext_cmd;
3355+ $return = &Run_subst();
3356 }
3357 else {
3358 warn "$My_name: viewer is supposed to be updated by running a command,\n",
3359@@ -2306,7 +2723,7 @@
3360 # Unconditionally apply rule if source file exists.
3361 # Assumes rule context
3362 if ( -e $$Psource ) {
3363- return &rdb_ext_cmd;
3364+ return &Run_subst();
3365 }
3366 else {
3367 return -1;
3368@@ -2397,7 +2814,7 @@
3369
3370 #************************************************************
3371
3372-sub make_preview_continuousB {
3373+sub make_preview_continuous {
3374 local @changed = ();
3375 local @disappeared = ();
3376 local @no_dest = (); # Non-existent destination files
3377@@ -2405,7 +2822,6 @@
3378 local @rules_to_apply = ();
3379
3380 local $failure = 0;
3381- local $runs = 0;
3382 local %rules_applied = ();
3383 local $updated = 0;
3384
3385@@ -2472,7 +2888,10 @@
3386 # $MSWin_fudge_break.
3387 $SIG{BREAK} = $SIG{INT} = 'IGNORE';
3388 }
3389- $failure = rdb_makeB( @targets );
3390+ if ($compiling_cmd) {
3391+ Run_subst( $compiling_cmd );
3392+ }
3393+ $failure = rdb_make( @targets );
3394
3395 ## warn "=========Viewer PID = $$Pviewer_process; updated=$updated\n";
3396
3397@@ -2539,13 +2958,25 @@
3398 $failure_msg =~ s/\s*$//; #Remove trailing space
3399 warn "$My_name: $failure_msg\n",
3400 " ==> You will need to change a source file before I do another run <==\n";
3401+ if ($failure_cmd) {
3402+ Run_subst( $failure_cmd );
3403+ }
3404 }
3405+ else {
3406+ if ($success_cmd) {
3407+ Run_subst( $success_cmd );
3408+ }
3409+ }
3410 rdb_show_rule_errors();
3411 if ($show_time && ! $first_time) { show_timing(); }
3412 if ( $first_time || $updated || $failure ) {
3413 print "\n=== Watching for updated files. Use ctrl/C to stop ...\n";
3414 }
3415 $waiting = 1; if ($diagnostics) { warn "WAITING\n"; }
3416+# During waiting for file changes, handle ctrl/C and ctrl/break here, rather than letting
3417+# system handle them by terminating script (and any script that calls it). This allows,
3418+# for example, the clean up code in the following command line to work:
3419+# latexmk -pvc foo; cleanup;
3420 &catch_break;
3421 $have_break = 0;
3422 WAIT: while (1) {
3423@@ -2562,7 +2993,7 @@
3424 $processing_time1 = processing_time();
3425 # Does this do this job????
3426 local $new_files = 0;
3427- rdb_for_some( [keys %current_primaries], sub{ $new_files += &rdb_find_new_filesB } );
3428+ rdb_for_some( [keys %current_primaries], sub{ $new_files += &rdb_find_new_files } );
3429 if ($new_files > 0) {
3430 warn "$My_name: New file(s) found.\n";
3431 last WAIT;
3432@@ -2576,7 +3007,7 @@
3433 }
3434 $waiting = 0; if ($diagnostics) { warn "NOT WAITING\n"; }
3435 } #end infinite_loop CHANGE:
3436-} #END sub make_preview_continuousB
3437+} #END sub make_preview_continuous
3438
3439 #************************************************************
3440
3441@@ -2585,16 +3016,37 @@
3442 # NEW VERSION
3443 # Run rc_file whose name is given in first argument
3444 # Exit with code 0 on success
3445- # Exit with code 1 if file could not be read.
3446+ # Exit with code 1 if file cannot be read or does not exist.
3447 # Stop if there is a syntax error or other problem.
3448+ # PREVIOUSLY:
3449+ # Exit with code 2 if is a syntax error or other problem.
3450 my $rc_file = $_[0];
3451 my $ret_code = 0;
3452 warn "$My_name: Executing Perl code in file '$rc_file'...\n"
3453 if $diagnostics;
3454- if ( ! -r $rc_file ) {
3455- return 1;
3456- }
3457- do( $rc_file );
3458+ # I could use the do command of perl, but the preceeding -r test
3459+ # to get good diagnostics gets the wrong result under cygwin
3460+ # (e.g., on /cygdrive/c/latexmk/LatexMk)
3461+ my $RCH = new FileHandle;
3462+ if ( !-e $rc_file ) {
3463+ warn "$My_name: The rc-file '$rc_file' does not exist\n";
3464+ return 1;
3465+ }
3466+ elsif ( open $RCH, "<$rc_file" ) {
3467+ { local $/; eval <$RCH>; }
3468+ close $RCH;
3469+ }
3470+ else {
3471+ warn "$My_name: I cannot read the rc-file '$rc_file'\n";
3472+ return 1;
3473+ }
3474+ # PREVIOUS VERSION
3475+# if ( ! -r $rc_file ) {
3476+# warn "$My_name: I cannot read the rc-file '$rc_file'\n",
3477+# " or at least that's what Perl (for $^O) reports\n";
3478+# return 1;
3479+# }
3480+# do( $rc_file );
3481 if ( $@ ) {
3482 # Indent each line of possibly multiline message:
3483 my $message = prefix( $@, " " );
3484@@ -2639,10 +3091,11 @@
3485 #************************************************************
3486
3487 sub cleanup1 {
3488- # Usage: cleanup1( exts_without_period, ... )
3489+ # Usage: cleanup1( directory, exts_without_period, ... )
3490+ my $dir = shift;
3491 foreach (@_) {
3492- (my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/$root_filename/;
3493- unlink("$name");
3494+ (my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/$dir$root_filename/;
3495+ unlink_or_move("$name");
3496 }
3497 } #END cleanup1
3498
3499@@ -2665,7 +3118,7 @@
3500 return;
3501 }
3502 if ( (-e $$Pdest) && (-e $$Psource) ) {
3503- unlink $$Pdest;
3504+ unlink_or_move( $$Pdest );
3505 }
3506 elsif ( (-e $$Pdest) && (!-e $$Psource) ) {
3507 warn "$My_name: For custom dependency '$rule',\n",
3508@@ -2757,9 +3210,12 @@
3509 "$My_name $version_num: Automatic LaTeX document generation routine\n\n",
3510 "Usage: $my_name [latexmk_options] [filename ...]\n\n",
3511 " Latexmk_options:\n",
3512- " -bibtex - use bibtex when needed (default)\n",
3513- " -bibtex- - never use bibtex\n",
3514- " -bibtex-cond - use bibtex when needed, but only if the bib files exist\n",
3515+ " -aux-directory=dir or -auxdir=dir \n",
3516+ " - set name of directory for auxiliary files (aux, log)\n",
3517+ " - Currently this only works with MiKTeX\n",
3518+ " -bibtex - use bibtex when needed (default)\n",
3519+ " -bibtex- - never use bibtex\n",
3520+ " -bibtex-cond - use bibtex when needed, but only if the bib files exist\n",
3521 " -bm <message> - Print message across the page when converting to postscript\n",
3522 " -bi <intensity> - Set contrast or intensity of banner\n",
3523 " -bs <scale> - Set scale for banner\n",
3524@@ -2800,10 +3256,17 @@
3525 " -l- - turn off -l\n",
3526 " -latex=<program> - set program used for latex.\n",
3527 " (replace '<program>' by the program name)\n",
3528+ " -latexoption=<option> - add the given option to the (pdf)latex command\n",
3529+ " -M - Show list of dependent files after processing\n",
3530+ " -MF file - Specifies name of file to receives list dependent files\n",
3531+ " -MP - List of dependent files includes phony target for each source file.\n",
3532 " -new-viewer - in -pvc mode, always start a new viewer\n",
3533 " -new-viewer- - in -pvc mode, start a new viewer only if needed\n",
3534 " -nobibtex - never use bibtex\n",
3535 " -nodependents - Do not show list of dependent files after processing\n",
3536+ " -norc - omit automatic reading of system, user and project rc files\n",
3537+ " -output-directory=dir or -outdir=dir\n",
3538+ " - set name of directory for output files\n",
3539 " -pdf - generate pdf by pdflatex\n",
3540 " -pdfdvi - generate pdf by dvipdf\n",
3541 " -pdflatex=<program> - set program used for pdflatex.\n",
3542@@ -2824,12 +3287,17 @@
3543 " on force mode, so errors do not cause $my_name to stop.)\n",
3544 " (Side effect: turn off ordinary preview mode.)\n",
3545 " -pvc- - turn off -pvc\n",
3546+ " -quiet - silence progress messages from called programs\n",
3547 " -r <file> - Read custom RC file\n",
3548+ " (N.B. This file could override options specified earlier\n",
3549+ " on the command line.)\n",
3550 " -recorder - Use -recorder option for (pdf)latex\n",
3551 " (to give list of input and output files)\n",
3552 " -recorder- - Do not use -recorder option for (pdf)latex\n",
3553 " -rules - Show list of rules after processing\n",
3554 " -rules- - Do not show list of rules after processing\n",
3555+ " -showextraoptions - Show other allowed options that are simply passed\n",
3556+ " as is to latex and pdflatex\n",
3557 " -silent - silence progress messages from called programs\n",
3558 " -time - show CPU time used\n",
3559 " -time- - don't show CPU time used\n",
3560@@ -2843,14 +3311,18 @@
3561 " -view=none - no viewer is used\n",
3562 " -view=ps - viewer is for ps\n",
3563 " -view=pdf - viewer is for pdf\n",
3564+ " -xelatex - use xelatex for processing files to pdf\n",
3565+ "\n",
3566 " filename = the root filename of LaTeX document\n",
3567 "\n",
3568 "-p, -pv and -pvc are mutually exclusive\n",
3569 "-h, -c and -C override all other options.\n",
3570 "-pv and -pvc require one and only one filename specified\n",
3571 "All options can be introduced by '-' or '--'. (E.g., --help or -help.)\n",
3572- "Contents of RC file specified by -r overrides options specified\n",
3573- " before the -r option on the command line\n";
3574+ " \n",
3575+ "In addition, latexmk recognizes many other options that are passed to\n",
3576+ "latex and/or pdflatex without interpretation by latexmk. Run latexmk\n",
3577+ "with the option -showextraoptions to see a list of these\n";
3578
3579 } #END print_help
3580
3581@@ -2902,9 +3374,14 @@
3582
3583 sub check_biber_log {
3584 # Check for biber warnings:
3585- # Usage: check_biber_log( base_of_biber_run[, \@biber_source )
3586- # return 0: OK, 1: biber warnings, 2: biber errors,
3587- # 3: could not open .blg file.
3588+ # Usage: check_biber_log( base_of_biber_run, \@biber_source )
3589+ # return 0: OK;
3590+ # 1: biber warnings;
3591+ # 2: biber errors;
3592+ # 3: could not open .blg file;
3593+ # 4: failed to find one or more source files, except for bibfile;
3594+ # 5: failed to find bib file;
3595+ # 6: missing file, one of which is control file
3596 # 10: only error is missing \citation commands.
3597 # Side effect: add source files @biber_source
3598 my $base = $_[0];
3599@@ -2917,52 +3394,82 @@
3600 my $have_error = 0;
3601 my $missing_citations = 0;
3602 my $no_citations = 0;
3603- my $error_count = 0;
3604- my $warning_count = 0;
3605+ my $error_count = 0; # From my counting of error messages
3606+ my $warning_count = 0; # From my counting of warning messages
3607+ # The next two occur only from biber
3608+ my $bibers_error_count = 0; # From biber's counting of errors
3609+ my $bibers_warning_count = 0; # From biber's counting of warnings
3610+ my $not_found_count = 0;
3611+ my $control_file_missing = 0;
3612 while (<$log_file>) {
3613 if (/> WARN /) {
3614 print "Biber warning: $_";
3615 $have_warning = 1;
3616 $warning_count ++;
3617 }
3618- elsif (/> FATAL /) {
3619+ elsif (/> (FATAL|ERROR) /) {
3620 print "Biber error: $_";
3621- $have_error = 1;
3622- $error_count ++;
3623- if ( /> FATAL - The file '[^']+' does not contain any citations!/ ) {
3624- $no_citations++;
3625+ if ( /> (FATAL|ERROR) - Cannot find file '([^']+)'/ #'
3626+ || /> (FATAL|ERROR) - Cannot find '([^']+)'/ ) { #'
3627+ $not_found_count++;
3628+ push @$Pbiber_source, $2;
3629+ }
3630+ elsif ( /> (FATAL|ERROR) - Cannot find control file '([^']+)'/ ) { #'
3631+ $not_found_count++;
3632+ $control_file_missing = 1;
3633+ push @$Pbiber_source, $2;
3634+ }
3635+ else {
3636+ $have_error = 1;
3637+ $error_count ++;
3638+ if ( /> (FATAL|ERROR) - The file '[^']+' does not contain any citations!/ ) { #'
3639+ $no_citations++;
3640+ }
3641 }
3642 }
3643 elsif ( /> INFO - Found .* '([^']+)'\s*$/
3644 || /> INFO - Found '([^']+)'\s*$/
3645+ || /> INFO - Reading '([^']+)'\s*$/
3646+ || /> INFO - Reading (.*)$/
3647 || /> INFO - Processing .* file '([^']+)' .*$/
3648 ) {
3649 if ( defined $Pbiber_source ) {
3650 push @$Pbiber_source, $1;
3651 }
3652 }
3653+ elsif ( /> INFO - WARNINGS: ([\d]+)\s*$/ ) {
3654+ $bibers_warning_count = $1;
3655+ }
3656+ elsif ( /> INFO - ERRORS: ([\d]+)\s*$/ ) {
3657+ $bibers_error_count = $1;
3658+ }
3659 }
3660 close $log_file;
3661- my $bibret = &find_file_list1( $Pbiber_source, $Pbiber_source,
3662- '', \@BIBINPUTS );
3663+
3664+ my @not_found = &find_file_list1( $Pbiber_source, $Pbiber_source,
3665+ '', \@BIBINPUTS );
3666 @$Pbiber_source = uniqs( @$Pbiber_source );
3667- if ($bibret == 0) {
3668- warn "$My_name: Found biber source file(s) [@$Pbiber_source]\n"
3669+ if ( ($#not_found < 0) && ($#$Pbiber_source >= 0) ) {
3670+ warn "$My_name: Found biber source file(s) [@$Pbiber_source]\n"
3671 unless $silent;
3672 }
3673+ elsif ( ($#not_found == 0) && ($not_found[0] =~ /\.bib$/) ) {
3674+ # Special treatment if sole missing file is bib file
3675+ # I don't want to treat that as an error
3676+ warn "$My_name: Biber did't find bib file [$not_found[0]]\n";
3677+ return 5;
3678+ }
3679 else {
3680- warn "$My_name: Failed to find one or more biber source files ",
3681- "in [@$Pbiber_source]\n";
3682+ show_array( "$My_name: Failed to find one or more biber source files:",
3683+ @not_found );
3684 if ($force_mode) {
3685 warn "==== Force_mode is on, so I will continue. ",
3686 "But there may be problems ===\n";
3687 }
3688- else {
3689- #$failure = -1;
3690- #$failure_msg = 'Failed to find one or more biber source files';
3691- #warn "$My_name: Failed to find one or more biber source files\n";
3692- }
3693- return 3;
3694+ if ($control_file_missing) {
3695+ return 6;
3696+ }
3697+ return 4;
3698 }
3699 # print "$My_name: #Biber errors = $error_count, warning messages = $warning_count,\n ",
3700 # "missing citation messages = $missing_citations, no_citations = $no_citations\n";
3701@@ -2979,12 +3486,49 @@
3702
3703 #**************************************************
3704
3705+sub run_bibtex {
3706+ my $return = 999;
3707+ if ( $aux_dir ) {
3708+ if ( $$Psource =~ /^$aux_dir1/ ) {
3709+ # Run bibtex in $aux_dir, fixing input search path
3710+ # to allow for finding files in original directory
3711+ my ( $base, $path, $ext ) = fileparseA( $$Psource );
3712+ my $cwd = good_cwd();
3713+ foreach ( 'BIBINPUTS', 'BSTINPUTS' ) {
3714+ if ( exists $ENV{$_} ) {
3715+ $ENV{$_} = $cwd.$search_path_separator.$ENV{$_};
3716+ }
3717+ else {
3718+ $ENV{$_} = $cwd.$search_path_separator;
3719+ }
3720+ }
3721+ pushd( $path );
3722+ $return = &Run_subst( undef, undef, '', $base.$ext, '', $base );
3723+ popd();
3724+ }
3725+ else {
3726+ warn "$My_name: Directory in file name '$$Psource' for bibtex\n",
3727+ " but it is not the output directory '$aux_dir'\n";
3728+ $return = Run_subst();
3729+ }
3730+ }
3731+ else {
3732+ $return = Run_subst();
3733+ }
3734+ return $return;
3735+}
3736+
3737+
3738+#**************************************************
3739+
3740 sub check_bibtex_log {
3741 # Check for bibtex warnings:
3742 # Usage: check_bibtex_log( base_of_bibtex_run )
3743 # return 0: OK, 1: bibtex warnings, 2: bibtex errors,
3744 # 3: could not open .blg file.
3745- # 10: only error is missing \citation commands.
3746+ # 10: only error is missing \citation commands or a missing aux file
3747+ # (which would normally be corrected after a later run of
3748+ # (pdf)latex).
3749
3750 my $base = $_[0];
3751 my $log_name = "$base.blg";
3752@@ -2994,27 +3538,41 @@
3753 my $have_warning = 0;
3754 my $have_error = 0;
3755 my $missing_citations = 0;
3756+ my @missing_aux = ();
3757 my $error_count = 0;
3758 while (<$log_file>) {
3759 if (/^Warning--/) {
3760 #print "Bibtex warning: $_";
3761 $have_warning = 1;
3762 }
3763+ elsif ( /^I couldn\'t open auxiliary file (.*\.aux)/ ) {
3764+ push @missing_aux, $1;
3765+ }
3766 elsif ( /^I found no \\citation commands---while reading file/ ) {
3767- $missing_citations++;
3768+ $missing_citations++;
3769 }
3770- elsif (/There (were|was) (\d+) error message/) {
3771+ elsif (/There (were|was) (\d+) error message/) {
3772 $error_count = $2;
3773 #print "Bibtex error: count=$error_count $_";
3774 $have_error = 1;
3775 }
3776 }
3777 close $log_file;
3778- #print "Bibtex errors = $error_count, missing citations = $missing_citations\n";
3779- if ($have_error && ($error_count <= $missing_citations )
3780- && ($missing_citations > 0) ) {
3781- # If the only error is a missing citation line, that should only
3782+ my $missing = $missing_citations + $#missing_aux + 1;
3783+
3784+ if ( $#missing_aux > -1 ) {
3785+ # Need to make the missing files.
3786+ warn "$My_name: One or more aux files is missing for bibtex. I'll try\n",
3787+ " to get (pdf)latex to remake them.\n";
3788+ rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } );
3789+ }
3790+ #print "Bibtex errors = $error_count, missing aux files and citations = $missing\n";
3791+ if ($have_error && ($error_count <= $missing )
3792+ && ($missing > 0) ) {
3793+ # If the only error is a missing citation line, that should only
3794 # count as a warning.
3795+ # Also a missing aux file should be innocuous; it will be created on
3796+ # next run of (pdf)latex. ?? HAVE I HANDLED THAT CORRECTLY?
3797 # But have to deal with the problem that bibtex gives a non-zero
3798 # exit code. So leave things as they are so that the user gets
3799 # a better diagnostic ??????????????????????????
3800@@ -3029,26 +3587,25 @@
3801
3802 #**************************************************
3803
3804-sub clean_file_name {
3805- # Convert quoted filename as found in log file to filename without quotes
3806- # Allows arbitrarily embedded double-quoted substrings, includes the
3807- # cases
3808- # 1. `"string".ext', which arises e.g., from \jobname.bbl:
3809- # when the base filename contains spaces, \jobname has quotes.
3810- # and from \includegraphics with basename specified.
3811- # Also deals with filenames written by asymptote.sty
3812- # 2. Or "string.ext" from \includegraphcs with basename and ext specified.
3813- # and from MiKTeX logfile for input files with spaces.
3814- # Doubled quotes (e.g., A""B) don't get converted.
3815- # Neither do unmatched quotes.
3816- my $filename = $_[0];
3817- while ( $filename =~ s/^([^\"]*)\"([^\"]+)\"(.*)$/$1$2$3/ ) {}
3818- return $filename;
3819-}
3820+sub normalize_force_directory {
3821+ # Usage, normalize_force_directory( dir, filename )
3822+ # Perform the following operations:
3823+ # Clean filename
3824+ # If filename contains no path component, insert dir in front
3825+ # Normalize filename
3826+ # Return result
3827+ my $default_dir = $_[0];
3828+ my $filename = clean_filename( $_[1] );
3829+ my ($base_name, $path ) = fileparse( $filename );
3830+ if ( $base_name eq $filename ) {
3831+ $filename = "$default_dir$filename";
3832+ }
3833+ return normalize_filename( $filename );
3834+} #END normalize force_directory
3835
3836 # ------------------------------
3837
3838-sub parse_logB {
3839+sub parse_log {
3840 # Scan log file for: dependent files
3841 # reference_changed, bad_reference, bad_citation
3842 # Return value: 1 if success, 0 if no log file.
3843@@ -3109,7 +3666,6 @@
3844 $bad_reference = 0;
3845 $bad_citation = 0;
3846
3847- my $log_name = "$root_filename.log";
3848 my $log_file = new FileHandle;
3849 if ( ! open( $log_file, "<$log_name" ) ) {
3850 return 0;
3851@@ -3188,8 +3744,9 @@
3852 # First line OK
3853 next LINE;
3854 } else {
3855- warn "$My_name: Error on first line of '$log_name'. ".
3856- "This is apparently not a TeX log file.\n";
3857+ warn "$My_name: Error on first line of '$log_name'.\n".
3858+ "This is apparently not a TeX log file. ",
3859+ "The first line is:\n$_\n";
3860 $failure = 1;
3861 $failure_msg = "Log file '$log_name' appears to have wrong format.";
3862 return 0;
3863@@ -3202,7 +3759,7 @@
3864 if ( ($block_type eq 'conversion')
3865 && /^\($current_pkg\)\s+Output file: <([^>]+)>/ )
3866 {
3867- $delegated_output = $1;
3868+ $delegated_output = normalize_clean_filename($1);
3869 }
3870 next LINE;
3871 }
3872@@ -3216,20 +3773,20 @@
3873 }
3874 # Check for changed references, bad references and bad citations:
3875 if (/Rerun to get/) {
3876- warn "$My_name: References changed.\n";
3877+ warn "$My_name: References changed.\n" if ! $silent;
3878 $reference_changed = 1;
3879 }
3880 if (/LaTeX Warning: (Reference[^\001]*undefined)./) {
3881- warn "$My_name: $1 \n";
3882- $bad_reference = 1;
3883+ warn "$My_name: $1 \n" unless $silent;
3884+ $bad_reference++;
3885 }
3886 if (/LaTeX Warning: (Citation[^\001]*undefined)./) {
3887- warn "$My_name: $1 \n";
3888- $bad_citation = 1;
3889+ warn "$My_name: $1 \n" unless $silent;
3890+ $bad_citation++;
3891 }
3892 if (/Package natbib Warning: (Citation[^\001]*undefined)./) {
3893- warn "$My_name: $1 \n";
3894- $bad_citation = 1;
3895+ warn "$My_name: $1 \n" unless $silent;
3896+ $bad_citation++;
3897 }
3898 if ( /^Document Class: / ) {
3899 # Class sign-on line
3900@@ -3245,7 +3802,7 @@
3901 next LINE;
3902 }
3903 if ( /^Output written on\s+(.*)\s+\(\d+\s+page/ ) {
3904- $primary_out = clean_file_name($1);
3905+ $primary_out = normalize_clean_filename($1);
3906 warn "$My_name: Log file says output to '$primary_out'\n"
3907 unless $silent;
3908 next LINE;
3909@@ -3259,15 +3816,18 @@
3910 next LINE;
3911 }
3912 if ( /^\\openout\d+\s*=\s*\`([^\']+)\'\.$/ ) {
3913- $generated_log{clean_file_name($1)} = 1;
3914+ # When (pdf)latex is run with an -output-directory
3915+ # or an -aux_directory, the file name does not contain
3916+ # the output path; fix this, after removing quotes:
3917+ $generated_log{normalize_force_directory( $aux_dir1, $1 )} = 1;
3918 next LINE;
3919 }
3920 # Test for conversion produced by package:
3921 if ( /^Package (\S+) Info: Source file: <([^>]+)>/ ) {
3922 # Info. produced by epstopdf (and possibly others)
3923 # about file conversion
3924- $current_pkg = clean_file_name($1);
3925- $delegated_source = clean_file_name($2);
3926+ $current_pkg = normalize_clean_filename($1);
3927+ $delegated_source = normalize_clean_filename($2);
3928 $block_type = 'conversion';
3929 next LINE;
3930 }
3931@@ -3294,9 +3854,12 @@
3932 " '$_'\n";
3933 next LINE;
3934 }
3935- # Typically, there is trailing space, not part of filename:
3936+ # Typically, there is trailing space, not part of filename:
3937 $idx_file =~ s/\s*$//;
3938- $idx_file = clean_file_name($idx_file);
3939+ # When (pdf)latex is run with an -output-directory
3940+ # or an -aux_directory, the file name does not contain
3941+ # the output path; fix this, after removing quotes:
3942+ $idx_file = normalize_force_directory( $aux_dir1, $idx_file );
3943 my ($idx_base, $idx_path, $idx_ext) = fileparseA( $idx_file );
3944 $idx_base = $idx_path.$idx_base;
3945 $idx_file = $idx_base.$idx_ext;
3946@@ -3320,8 +3883,10 @@
3947 next LINE;
3948 }
3949 if ( /^No file (.*?\.bbl)./ ) {
3950- # Notice that the
3951- my $bbl_file = clean_file_name($1);
3952+ # When (pdf)latex is run with an -output-directory
3953+ # or an -aux_directory, the file name does not contain
3954+ # the output path; fix this, after removing quotes:
3955+ my $bbl_file = normalize_force_directory( $aux_dir1, $1 );
3956 warn "$My_name: Non-existent bbl file '$bbl_file'\n $_\n";
3957 $dependents{$bbl_file} = 0;
3958 push @bbl_files, $bbl_file;
3959@@ -3329,16 +3894,28 @@
3960 }
3961 foreach my $pattern (@file_not_found) {
3962 if ( /$pattern/ ) {
3963- my $file = clean_file_name($1);
3964+ my $file = clean_filename($1);
3965 warn "$My_name: Missing input file: '$file' from line\n '$_'\n"
3966 unless $silent;
3967- $dependents{$file} = 0;
3968+ $dependents{normalize_filename($file)} = 0;
3969+ my $file1 = $file;
3970+ if ( $aux_dir ) {
3971+ # Allow for the possibility that latex generated
3972+ # a file in $aux_dir, from which the missing file can
3973+ # be created by a cusdep (or other) rule that puts
3974+ # the result in $out_dir. If the announced missing file
3975+ # has no path, then it would be effectively a missing
3976+ # file in $aux_dir, with a path. So give this alternate
3977+ # location.
3978+ my $file1 = normalize_force_directory( $aux_dir1, $file );
3979+ $dependents{$file1} = 0;
3980+ }
3981 next LINE;
3982 }
3983 }
3984 if ( /^File: (.+) Graphic file \(type / ) {
3985 # First line of message from includegraphics/x
3986- $dependents{clean_file_name($1)} = 1;
3987+ $dependents{normalize_clean_filename($1)} = 1;
3988 next LINE;
3989 }
3990 # Now test for generic lines to ignore, only after special cases!
3991@@ -3467,6 +4044,7 @@
3992 }
3993 INCLUDE_NAME:
3994 foreach my $include_name (@new_includes) {
3995+ $include_name = normalize_filename( $include_name );
3996 my ($base, $path, $ext) = fileparseB( $include_name );
3997 if ( ($path eq './') || ($path eq '.\\') ) {
3998 $include_name = $base.$ext;
3999@@ -3654,23 +4232,45 @@
4000 }
4001 }
4002 return 1;
4003-} #END parse_logB
4004+} #END parse_log
4005
4006 #************************************************************
4007
4008 sub parse_fls {
4009- my ($fls_name, $Pinputs, $Poutputs ) = @_;
4010- %$Pinputs = %$Poutputs = ();
4011+ my ($fls_name, $Pinputs, $Poutputs, $Pfirst_read_after_write ) = @_;
4012+ %$Pinputs = %$Poutputs = %$Pfirst_read_after_write = ();
4013 my $fls_file = new FileHandle;
4014+ # Make a note of current working directory
4015+ # I'll update it from the fls file later
4016+ # Currently I don't use this, but it would be useful to use
4017+ # this when testing prefix for cwd in a filename, by
4018+ # giving (pdf)latex's best view of the cwd. Note that the
4019+ # value given by the cwd() function may be mangled, e.g., by cygwin
4020+ # compared with native MSWin32.
4021+ my $cwd = good_cwd();
4022 if ( ! open ($fls_file, "<$fls_name") ) {
4023 return 1;
4024 }
4025 foreach $_ ( <$fls_file> ) {
4026- if (/^\s*INPUT\s+(.*)\s+$/) {
4027- $$Pinputs{$1} = 1;
4028+ # Remove trailing CR and LF. Thus we get correct behavior when an fls file
4029+ # is produced by MS-Windows program (e.g., in MiKTeX) with CRLF line ends,
4030+ # but is read by Unix Perl (which treats LF as line end, and preserves CRLF
4031+ # in read-in lines):
4032+ $_ =~ s/[\n\r]*$//;
4033+ if (/^\s*PWD\s+(.*)$/) {
4034+ $cwd = $1;
4035+ }
4036+ elsif (/^\s*INPUT\s+(.*)$/) {
4037+ # Take precautions against aliasing of foo, ./foo and other possibilities for cwd.
4038+ my $file = normalize_filename( $1 );
4039+ if ( (exists $$Poutputs{$file}) && (! exists $$Pinputs{$file}) ) {
4040+ $$Pfirst_read_after_write{$file} = 1;
4041+ }
4042+ $$Pinputs{$file} = 1;
4043 }
4044- elsif (/^\s*OUTPUT\s+(.*)\s+$/) {
4045- $$Poutputs{$1} = 1;
4046+ elsif (/^\s*OUTPUT\s+(.*)$/) {
4047+ # Take precautions against aliasing of foo, ./foo and other possibilities for cwd.
4048+ $$Poutputs{ normalize_filename( $1 )} = 1;
4049 }
4050 }
4051 close( $fls_file );
4052@@ -3679,6 +4279,68 @@
4053
4054 #************************************************************
4055
4056+sub clean_filename {
4057+ # Convert quoted filename as found in log file to filename without quotes
4058+ # Allows arbitrarily embedded double-quoted substrings, includes the
4059+ # cases
4060+ # 1. `"string".ext', which arises e.g., from \jobname.bbl:
4061+ # when the base filename contains spaces, \jobname has quotes.
4062+ # and from \includegraphics with basename specified.
4063+ # Also deals with filenames written by asymptote.sty
4064+ # 2. Or "string.ext" from \includegraphcs with basename and ext specified.
4065+ # and from MiKTeX logfile for input files with spaces.
4066+ # Doubled quotes (e.g., A""B) don't get converted.
4067+ # Neither do unmatched quotes.
4068+ my $filename = $_[0];
4069+ while ( $filename =~ s/^([^\"]*)\"([^\"]+)\"(.*)$/$1$2$3/ ) {}
4070+ return $filename;
4071+}
4072+
4073+# ------------------------------
4074+
4075+sub normalize_filename {
4076+ # Remove various forms for cwd at start of filename.
4077+ # Convert to have directory separator = '/' only
4078+ my $file = $_[0];
4079+ my $file1 = $file; # Saved original value
4080+ my $cwd = good_cwd();
4081+ # Normalize files to use / to separate directory components:
4082+ # (Note both / and \ are allowed under MSWin.)
4083+ $cwd =~ s(\\)(/)g;
4084+ $file =~ s(\\)(/)g;
4085+
4086+ # Remove current directory string:
4087+ $file =~ s(^\./)();
4088+ $file =~ s(^$cwd/)();
4089+
4090+ return $file;
4091+}
4092+
4093+# ------------------------------
4094+
4095+sub normalize_clean_filename {
4096+ # Remove quotes around filename --- see clean_filename --- as from log file.
4097+ # Then remove any string for cwd, and convert to use '/' for directory separator,
4098+ # (and any other standardization) done by normalize_filename.
4099+ return normalize_filename( clean_filename( $_[0] ));
4100+}
4101+
4102+#************************************************************
4103+
4104+sub OS_preferred_filename {
4105+ # Usage: OS_preferred_filename(name)
4106+ # Returns filename with directory separator '/' converted
4107+ # to preferred conventions for current OS.
4108+ # Currently implemented: only '\' for MSWin32
4109+ my $file = $_[0];
4110+ if ( $^O eq 'MSWin32' ) {
4111+ $file =~ s(/)(\\)g;
4112+ }
4113+ return $file;
4114+}
4115+
4116+#************************************************************
4117+
4118 sub parse_aux {
4119 #Usage: parse_aux( $aux_file, \@new_bib_files, \@new_aux_files, \@new_bst_files )
4120 # Parse aux_file (recursively) for bib files, and bst files.
4121@@ -3712,18 +4374,18 @@
4122 warn "$My_name: No .bib files listed in .aux file '$aux_file' \n",
4123 return 2;
4124 }
4125- my $bibret = &find_file_list1( $Pbib_files, $Pbib_files,
4126- '.bib', \@BIBINPUTS );
4127+ my @not_found = &find_file_list1( $Pbib_files, $Pbib_files,
4128+ '.bib', \@BIBINPUTS );
4129 @$Pbib_files = uniqs( @$Pbib_files );
4130 &find_file_list1( $Pbst_files, $Pbst_files, '.bst' );
4131 @$Pbst_files = uniqs( @$Pbst_files );
4132- if ($bibret == 0) {
4133- warn "$My_name: Found bibliography file(s) [@$Pbib_files]\n"
4134+ if ( $#not_found < 0) {
4135+ warn "$My_name: Found bibliography file(s) [@$Pbib_files]\n"
4136 unless $silent;
4137 }
4138 else {
4139- warn "$My_name: Failed to find one or more bibliography files ",
4140- "in [@$Pbib_files]\n";
4141+ show_array( "$My_name: Failed to find one or more bibliography files ",
4142+ @not_found );
4143 if ($force_mode) {
4144 warn "==== Force_mode is on, so I will continue. ",
4145 "But there may be problems ===\n";
4146@@ -3771,7 +4433,7 @@
4147 }
4148 elsif ( /^\\\@input\{(.*)\}/ ) {
4149 # \\@input{next_aux_file_name}
4150- &parse_aux1( $1 );
4151+ &parse_aux1( $aux_dir1.$1 );
4152 }
4153 }
4154 close($aux_fh);
4155@@ -3789,11 +4451,12 @@
4156 #************************************************************
4157
4158 sub fdb_get {
4159- # Call: fdb_get(filename [, run_time])
4160+ # Call: fdb_get(filename [, check_time])
4161 # Returns an array (time, size, md5) for the current state of the
4162 # named file.
4163- # The optional argument run_time is the runtime of some command
4164- # associated with the use of the file --- see below.
4165+ # The optional argument check_time is either the run_time of some command
4166+ # that may have changed the file or the last time the file was checked
4167+ # for changes --- see below.
4168 # For non-existent file, deletes its entry in fdb_current,
4169 # and returns (0,-1,0)
4170 # As an optimization, the md5 value is taken from the cache in
4171@@ -3811,11 +4474,11 @@
4172 # at some runtime t, the file is rewritten later by the same or another
4173 # program, with timestamp t, and when the initial file also has
4174 # timestamp t.
4175- # A test is applied for this situation if the run_time argument is
4176+ # A test is applied for this situation if the check_time argument is
4177 # supplied and is nonzero.
4178
4179- my ($file, $run_time) = @_;
4180- if ( ! defined $run_time ) { $run_time = 0;}
4181+ my ($file, $check_time) = @_;
4182+ if ( ! defined $check_time ) { $check_time = 0;}
4183 my ($new_time, $new_size) = get_time_size($file);
4184 my @nofile = (0,-1,0); # What we use for initializing
4185 # a new entry in fdb or flagging
4186@@ -3833,23 +4496,27 @@
4187 my $file_data = $fdb_current{$file};
4188 my ( $time, $size, $md5 ) = @$file_data;
4189
4190-#warn "--------- Getting MD5: $file: (N,O,R) = $new_time, $time, $run_time\n";
4191-#warn "--------- $file: (OT,OS,OM) = @$file_data\n";
4192 if ( ($new_time != $time) || ($new_size != $size)
4193- || ( $run_time && ($run_time == $time ) )
4194+ || ( $check_time && ($check_time == $time ) )
4195 ) {
4196- # Only force recalculation of md5 if time or size changed
4197- # Or if the time equals run_time, so that the file may
4198- # have changed within the 1-second granularity of the time
4199+ # Only force recalculation of md5 if time or size changed.
4200+ # However, the physical file time may have changed without
4201+ # affecting the value of the time coded in $time, because
4202+ # times are computed with a 1-second granularity.
4203+ # The only case to treat specially is where the file was created,
4204+ # then used by the current rule, and then rewritten, all within
4205+ # the granularity size, otherwise the value of the reported file
4206+ # time changed, and we've handled it. But we may have already
4207+ # checked this at an earlier time than the current check. So the
4208+ # only dangerous case is where the file time equals a check_time,
4209+ # which is either the run_time of the command or the time of a
4210+ # previous check.
4211 # Else we assume file is really unchanged.
4212 $recalculate_md5 = 1;
4213 }
4214 if ($recalculate_md5) {
4215-#warn "--------- RECALC MD5: $rule $file: (N,O,R) = $new_time, $time, $run_time\n";
4216-#warn " ------- $file: (OT,OS,OM) = @$file_data\n";
4217-#&traceback;
4218+#warn "--------- RECALC MD5: $rule $file: (N,O,R,C) \n = $new_time, $time, $$Prun_time, $check_time\n";
4219 @$file_data = ( $new_time, $new_size, get_checksum_md5( $file ) );
4220-#warn " ------- $file: (NT,NS,NM) = @$file_data\n";
4221 }
4222 return @$file_data;;
4223 } #END fdb_get
4224@@ -3926,7 +4593,7 @@
4225 $rule = $1;
4226 my $tail = $'; #' Single quote in comment tricks the parser in
4227 # emacs from misparsing an isolated single quote
4228- $run_time = 0;
4229+ $run_time = $check_time = 0;
4230 $source = $dest = $base = '';
4231 if ( $tail =~ /^\s*(\S+)\s*$/ ) {
4232 $run_time = $1;
4233@@ -3937,13 +4604,19 @@
4234 $dest = $3;
4235 $base = $4;
4236 }
4237+ elsif ( $tail =~ /^\s*(\S+)\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+(\S+)\s*$/ ) {
4238+ $run_time = $1;
4239+ $source = $2;
4240+ $dest = $3;
4241+ $base = $4;
4242+ $check_time = $5;
4243+ }
4244 if ( rdb_rule_exists( $rule ) ) {
4245 rdb_one_rule( $rule,
4246- sub{ $$Ptest_kind = 1;
4247+ sub{
4248+ if ($$Ptest_kind == 3) { $$Ptest_kind = 1; }
4249 $$Prun_time = $run_time;
4250- #??if ($source) { $$Psource = $source; }
4251- #??if ($dest) { $$Pdest = $dest; }
4252- #??if ($base) { $$Pbase = $base; }
4253+ $$Pcheck_time = $check_time;
4254 }
4255 );
4256 }
4257@@ -3965,11 +4638,12 @@
4258 # If it existed on last run, it will be in later
4259 # lines of the fdb file
4260 rdb_create_rule( $rule, 'cusdep', '', $PAnew_cmd, 1,
4261- $source, $dest, $base, 0, $run_time, 1 );
4262+ $source, $dest, $base, 0, $run_time, $check_time, 1 );
4263 }
4264 elsif ( $rule =~ /^(makeindex|bibtex|biber)\s*(.*)$/ ) {
4265 my $PA_extra_gen = [];
4266 my $rule_generic = $1;
4267+ my $int_cmd = '';
4268 if ( ! $source ) {
4269 # If fdb_file was old-style (v. 1)
4270 $source = $2;
4271@@ -3991,18 +4665,20 @@
4272 }
4273 if ($rule =~ /^makeindex/) { $PA_extra_gen = [ "$base.ilg" ]; }
4274 if ($rule =~ /^(bibtex|biber)/) { $PA_extra_gen = [ "$base.blg" ]; }
4275+ if ($rule =~ /^bibtex/) { $int_cmd = "run_bibtex"; }
4276 warn "$My_name: File-database '$in_name': setting rule '$rule'\n"
4277 if $diagnostics;
4278 my $cmd_type = 'external';
4279 my $ext_cmd = ${$rule_generic};
4280 warn " Rule kind = '$rule_generic'; ext_cmd = '$ext_cmd';\n",
4281+ " int_cmd = '$int_cmd';\n",
4282 " source = '$source'; dest = '$dest'; base = '$base';\n"
4283 if $diagnostics;
4284 # Set source file as non-existent.
4285 # If it existed on last run, it will be in later
4286 # lines of the fdb file
4287- rdb_create_rule( $rule, $cmd_type, $ext_cmd, '', 1,
4288- $source, $dest, $base, 0, $run_time, 1, $PA_extra_gen );
4289+ rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, 1,
4290+ $source, $dest, $base, 0, $run_time, $check_time, 1, $PA_extra_gen );
4291 }
4292 else {
4293 warn "$My_name: In file-database '$in_name' rule '$rule'\n",
4294@@ -4059,7 +4735,7 @@
4295 }
4296 undef $in_handle;
4297 # Set cus dependencies.
4298- &rdb_set_dependentsA( keys %rule_db );
4299+ &rdb_set_dependents( keys %rule_db );
4300
4301 #?? Check from_rules exist.
4302
4303@@ -4112,7 +4788,7 @@
4304 {
4305 return;
4306 }
4307- print $out_handle "[\"$rule\"] $$Prun_time \"$$Psource\" \"$$Pdest\" \"$$Pbase\" \n";
4308+ print $out_handle "[\"$rule\"] $$Prun_time \"$$Psource\" \"$$Pdest\" \"$$Pbase\" $$Pcheck_time\n";
4309 rdb_do_files(
4310 sub { print $out_handle " \"$file\" $$Ptime $$Psize $$Pmd5 \"$$Pfrom_rule\"\n"; }
4311 );
4312@@ -4155,6 +4831,9 @@
4313 local %generated_log = (); # Lists generated files found in log file
4314 local %generated_fls = (); # Lists generated files found in fls file
4315 local %source_fls = (); # Lists source files found in fls file
4316+ local %first_read_after_write = (); # Lists source files that are only read
4317+ # after being written (so are not true
4318+ # source files.
4319 local $primary_out = $$Pdest; # output file (dvi or pdf)
4320 local %conversions = (); # (pdf)latex-performed conversions.
4321 # Maps output file created and read by (pdf)latex
4322@@ -4162,14 +4841,15 @@
4323 # The following are also returned, but are global, to be used by caller
4324 # $reference_changed, $bad_reference $bad_citation
4325
4326- &parse_logB;
4327- my $fls_file = "$root_filename.fls";
4328+ &parse_log;
4329+ my $fls_file = "$aux_dir1$root_filename.fls";
4330 if ($recorder && test_gen_file($fls_file) ) {
4331- parse_fls( $fls_file, \%source_fls, \%generated_fls );
4332+ parse_fls( $fls_file, \%source_fls, \%generated_fls, \%first_read_after_write );
4333 foreach (keys %source_fls) {
4334 $dependents{$_} = 4;
4335 }
4336 foreach (keys %generated_fls) {
4337+ $_ = normalize_filename($_);
4338 rdb_add_generated( $_ );
4339 if ( exists($dependents{$_}) ) {
4340 $dependents{$_} = 6;
4341@@ -4185,7 +4865,7 @@
4342 # missing input file might be correctable by a run of some
4343 # other program whose running is provoked AFTER a run of
4344 # (pdf)latex, we'll set a diagnostic and leave it to the
4345- # rdb_makeB to handle after all circular dependencies are
4346+ # rdb_make to handle after all circular dependencies are
4347 # resolved.
4348 # 2. The output file might be of a different kind than expected
4349 # (i.e., dvi instead of pdf, or vv). This could
4350@@ -4209,9 +4889,9 @@
4351 print "!!!===Creating rule '$from_rule': '$ind_file' from '$idx_file'\n"
4352 if ($diagnostics);
4353 rdb_create_rule( $from_rule, 'external', $makeindex, '', 1,
4354- $idx_file, $ind_file, $ind_base, 1, 0);
4355+ $idx_file, $ind_file, $ind_base, 1, 0, 0 );
4356 print " ===Source file '$ind_file' for '$rule'\n"
4357- if ($diagnostics > -1);
4358+ if ($diagnostics);
4359 rdb_ensure_file( $rule, $ind_file, $from_rule );
4360 }
4361 # Make sure the .ind file is treated as a detected source file;
4362@@ -4255,11 +4935,11 @@
4363 print " ===Creating rule '$from_rule'\n" if ($diagnostics);
4364 if ( $bib_program eq 'biber' ) {
4365 rdb_create_rule( $from_rule, 'external', $biber, '', 1,
4366- "$bbl_base.bcf", $bbl_file, $bbl_base, 1, 0);
4367+ "$bbl_base.bcf", $bbl_file, $bbl_base, 1, 0, 0 );
4368 }
4369 else {
4370- rdb_create_rule( $from_rule, 'external', $bibtex, '', 1,
4371- "$bbl_base.aux", $bbl_file, $bbl_base, 1, 0);
4372+ rdb_create_rule( $from_rule, 'external', $bibtex, 'run_bibtex', 1,
4373+ "$bbl_base.aux", $bbl_file, $bbl_base, 1, 0, 0 );
4374 }
4375 }
4376 local %old_sources = ();
4377@@ -4331,7 +5011,7 @@
4378 }
4379 }
4380
4381- my @more_sources = &rdb_set_dependentsA( $rule );
4382+ my @more_sources = &rdb_set_dependents( $rule );
4383 my $num_new = $#more_sources + 1;
4384 foreach (@more_sources) {
4385 $dependents{$_} = 4;
4386@@ -4342,6 +5022,9 @@
4387 $$Pchanged = 1; # New files can be made. Ignore error.
4388 }
4389 }
4390+ foreach (keys %first_read_after_write) {
4391+ delete $dependents{$_};
4392+ }
4393 if ($diagnostics) {
4394 if ($num_new > 0 ) {
4395 print "$num_new new source files for rule '$rule':\n";
4396@@ -4350,6 +5033,13 @@
4397 else {
4398 print "No new source files for rule '$rule':\n";
4399 }
4400+ my @first_read_after_write = sort keys %first_read_after_write;
4401+ if ($#first_read_after_write >= 0) {
4402+ print "The following files were only read after being written:\n";
4403+ foreach (@first_read_after_write) {
4404+ print " '$_'\n";
4405+ }
4406+ }
4407 }
4408 my @files_not_needed = ();
4409 foreach (keys %$PHsource) {
4410@@ -4383,8 +5073,8 @@
4411
4412 #************************************************************
4413
4414-sub rdb_find_new_filesB {
4415- # Call: rdb_find_new_filesB
4416+sub rdb_find_new_files {
4417+ # Call: rdb_find_new_files
4418 # Assumes rule context for primary rule.
4419 # Deal with files which were missing and for which a method
4420 # of finding them has become available:
4421@@ -4476,30 +5166,30 @@
4422 }
4423 }
4424 return $found;
4425-} # END rdb_find_new_filesB
4426+} # END rdb_find_new_files
4427
4428 #************************************************************
4429
4430-sub rdb_set_dependentsA {
4431- # Call rdb_set_dependentsA( rules ...)
4432+sub rdb_set_dependents {
4433+ # Call rdb_set_dependents( rules ...)
4434 # Returns array (sorted), of new source files.
4435 local @new_sources = ();
4436 local @deletions = ();
4437
4438 # Shouldn't recurse. The definite rules to be examined are given.
4439- rdb_for_some( [@_], 0, \&rdb_one_depA );
4440-# OLD rdb_recurseA( [@_], 0, \&rdb_one_depA );
4441+ rdb_for_some( [@_], 0, \&rdb_one_dep );
4442+# OLD rdb_recurse( [@_], 0, \&rdb_one_dep );
4443 foreach (@deletions) {
4444 my ($rule, $file) = @$_;
4445 rdb_remove_files( $rule, $file );
4446 }
4447 &rdb_make_links;
4448 return uniqs( @new_sources );
4449-} #END rdb_set_dependentsA
4450+} #END rdb_set_dependents
4451
4452 #************************************************************
4453
4454-sub rdb_one_depA {
4455+sub rdb_one_dep {
4456 # Helper for finding dependencies. One case, $rule and $file given
4457 # Assume file (and rule) context for DESTINATION file.
4458
4459@@ -4508,7 +5198,7 @@
4460 if ( (! exists $possible_primaries{$rule}) && ($rule !~ /^cusdep/) ) {
4461 return;
4462 }
4463-#print "=============ONE_DEPA: '$rule' '$file'\n";
4464+#print "=============ONE_DEP: '$rule' '$file'\n";
4465 local $new_dest = $file;
4466 my ($base_name, $path, $toext) = fileparseA( $new_dest );
4467 $base_name = $path.$base_name;
4468@@ -4580,7 +5270,7 @@
4469 local @PAnew_cmd = ( 'do_cusdep', $func_name );
4470 if (! rdb_rule_exists( $from_rule ) ) {
4471 rdb_create_rule( $from_rule, 'cusdep', '', \@PAnew_cmd, 3,
4472- $source, $new_dest, $base_name, 0);
4473+ $source, $new_dest, $base_name, 0 );
4474 }
4475 else {
4476 rdb_one_rule(
4477@@ -4600,10 +5290,9 @@
4478 # Try to make the missing file
4479 #Set character to surround filenames in commands:
4480 my $q = $quote_filenames ? '"' : '';
4481- if ($rule =~ /^cusdep/ ) { traceback(); }
4482 if ( $toext ne '' ) {
4483 print "$My_name: '$rule': source file '$file' doesn't exist. I'll try making it...\n";
4484- &Run_msg( "$make $q$file$q" );
4485+ &Run_subst( "$make $q$file$q" );
4486 if ( -e $file ) {
4487 return;
4488 }
4489@@ -4613,7 +5302,7 @@
4490 " I'll try making it with allowed extensions \n";
4491 foreach my $try_ext ( keys %$Pinput_extensions ) {
4492 my $new_dest = "$file.$try_ext";
4493- &Run_msg( "$make $q$new_dest$q" );
4494+ &Run_subst( "$make $q$new_dest$q" );
4495 if ( -e $new_dest ) {
4496 print "SUCCESS in making '$new_dest'\n";
4497 # Put file in rule, without a from_rule, but
4498@@ -4631,7 +5320,7 @@
4499 }
4500 }
4501 }
4502-} #END rdb_one_depA
4503+} #END rdb_one_dep
4504
4505 #************************************************************
4506
4507@@ -4688,13 +5377,24 @@
4508 delete $source{$_};
4509 }
4510 foreach my $dest (@dest) {
4511- print $fh "$root_filename$dest :";
4512+ if ($deps_file eq '-' ) {
4513+ print $fh "$root_filename$dest :";
4514+ } else {
4515+ print $fh "$root_filename$dest $deps_file :";
4516+ }
4517 foreach (sort keys %source) {
4518 print $fh "\\\n $_";
4519 }
4520 print $fh "\n";
4521 }
4522 print $fh "#===End dependents for $filename:\n";
4523+ if ($dependents_phony) {
4524+ print $fh "\n#===Phony rules for $filename:\n\n";
4525+ foreach (sort keys %source) {
4526+ print $fh "$_ :\n\n";
4527+ }
4528+ print $fh "#===End phony rules for $filename:\n";
4529+ }
4530 } #END deps_list
4531
4532 #************************************************************
4533@@ -4726,7 +5426,7 @@
4534 # Call: rdb_accessible( rule, ...)
4535 # Returns array of rules accessible from the given rules
4536 local @accessible = ();
4537- rdb_recurseA( [@_], sub{ push @accessible, $rule; } );
4538+ rdb_recurse( [@_], sub{ push @accessible, $rule; } );
4539 return @accessible;
4540 } #END rdb_accessible
4541
4542@@ -4734,8 +5434,8 @@
4543 #************************************************************
4544 #************************************************************
4545
4546-sub rdb_makeB {
4547- # Call: rdb_makeB( target, ... )
4548+sub rdb_make {
4549+ # Call: rdb_make( target, ... )
4550 # Makes the targets and prerequisites.
4551 # Leaves one-time rules to last.
4552 # Does appropriate repeated makes to resolve dependency loops
4553@@ -4895,7 +5595,7 @@
4554 local $failure = 0; # General accumulated error flag
4555 local $missing_dvi_pdf = ''; # Did primary run fail to make its output file?
4556 local $runs = 0;
4557- local $too_many_runs = 0;
4558+ local $too_many_passes = 0;
4559 local %rules_applied = ();
4560 my $retry_msg = 0; # Did I earlier say I was going to attempt
4561 # another pass after a failure?
4562@@ -4906,6 +5606,7 @@
4563 }
4564 PASS:
4565 while (1==1) {
4566+ # Exit condition at end of body of loop.
4567 $runs = 0;
4568 my $previous_failure = $failure;
4569 $failure = 0;
4570@@ -4916,25 +5617,20 @@
4571 if ($diagnostics) {
4572 print "MakeB: doing pre_primary and primary...\n";
4573 }
4574- rdb_for_some( [@pre_primary, $primary], \&rdb_makeB1 );
4575- if ( ($runs > 0) && ! $too_many_runs ) {
4576- $retry_msg = 0;
4577- if ( $failure && $newrule_nofile ) {
4578- $retry_msg = 1;
4579- print "$My_name: Error on run, but found possibility to ",
4580- "make new source files\n";
4581- next PASS;
4582- }
4583- elsif ( $force_mode || (! $failure) ) {
4584- next PASS;
4585- }
4586+ # Do the primary run if it is needed. On return $runs == 0
4587+ # signals that nothing was run (and hence no output
4588+ # files changed), either because no input files
4589+ # changed and no run was needed, or because the
4590+ # number of passes through the rule exceeded the
4591+ # limit. In the second case $too_many_runs is set.
4592+ rdb_for_some( [@pre_primary, $primary], \&rdb_make1 );
4593+ if ( ($runs > 0) && ! $too_many_passes ) {
4594+ next PASS;
4595 }
4596- elsif ($runs == 0) {
4597+ if ($runs == 0) {
4598 # $failure not set on this pass, so use value from previous pass:
4599 $failure = $previous_failure;
4600- if ($retry_msg) {
4601- print "But in fact no new files made\n";
4602- }
4603+ if ($failure && !$force_mode ) { last PASS; }
4604 }
4605 if ( $missing_dvi_pdf ) {
4606 # No output from primary, after completing circular dependence
4607@@ -4942,15 +5638,16 @@
4608 $failure = 1;
4609 last PASS;
4610 }
4611- if ($failure && !$force_mode ) { last PASS; }
4612 if ($diagnostics) {
4613 print "MakeB: doing post_primary...\n";
4614 }
4615- rdb_for_some( [@post_primary], \&rdb_makeB1 );
4616- if ($failure) { last PASS; }
4617- if ($runs > 0) { next PASS; }
4618- # Get here if nothing was run.
4619- last PASS;
4620+ rdb_for_some( [@post_primary], \&rdb_make1 );
4621+ if ( ($runs == 0) || $too_many_passes ) {
4622+ # If $too_many_passes is set, it should also be that
4623+ # $runs == 0; but for safety, I also checked
4624+ # $too_many_passes.
4625+ last PASS;
4626+ }
4627 }
4628 continue {
4629 # Re-evaluate rule classification and accessibility,
4630@@ -4962,18 +5659,11 @@
4631 &rdb_make_links;
4632 }
4633 }
4634- rdb_for_some( [@one_time], \&rdb_makeB1 );
4635- rdb_write( $fdb_file );
4636+ rdb_for_some( [@one_time], \&rdb_make1 );
4637+ rdb_write( $fdb_name );
4638
4639- if (! $silent) {
4640- # Diagnose of the runs
4641- if ( $#{keys %rules_applied } > -1 ) {
4642- print "$My_name: $runs runs. Rules applied:\n";
4643- foreach (sort keys %rules_applied) {
4644- print " '$_'\n";
4645- }
4646- }
4647- elsif ($failure && $force_mode) {
4648+ if (! $silent) {
4649+ if ($failure && $force_mode) {
4650 print "$My_name: Errors, in force_mode: so I tried finishing targets\n";
4651 }
4652 elsif ($failure) {
4653@@ -4986,43 +5676,54 @@
4654 }
4655 }
4656 return $failure;
4657-} #END rdb_makeB
4658+} #END rdb_make
4659
4660 #-------------------
4661
4662 sub rdb_show_rule_errors {
4663- local @messages = ();
4664+ local @errors = ();
4665+ local @warnings = ();
4666 rdb_for_all(
4667 sub{
4668 if ($$Plast_message ne '') {
4669- push @messages, "$rule: $$Plast_message";
4670+ if ($$Plast_result == 200) {
4671+ push @warnings, "$rule: $$Plast_message";
4672+ }
4673+ else {
4674+ push @errors, "$rule: $$Plast_message";
4675+ }
4676 }
4677 elsif ($$Plast_result == 1) {
4678- push @messages, "$rule: failed to create output file";
4679+ push @errors, "$rule: failed to create output file";
4680 }
4681 elsif ($$Plast_result == 2) {
4682- push @messages, "$rule: gave an error";
4683+ push @errors, "$rule: gave an error";
4684 }
4685 elsif ($$Prun_time == 0) {
4686-# This can have innocuous causes. So don't report
4687-# push @messages, "$rule: never run";
4688+ # This can have innocuous causes. So don't report
4689 }
4690 }
4691 );
4692- if ($#messages > -1) {
4693+ if ($#warnings > -1) {
4694+ warn "Collected warning summary (may duplicate other messages):\n";
4695+ foreach (@warnings){
4696+ warn " $_\n";
4697+ }
4698+ }
4699+ if ($#errors > -1) {
4700 warn "Collected error summary (may duplicate other messages):\n";
4701- foreach (@messages){
4702+ foreach (@errors){
4703 warn " $_\n";
4704 }
4705 }
4706- return $#messages+1;
4707+ return $#errors+1;
4708 }
4709
4710 #-------------------
4711
4712-sub rdb_makeB1 {
4713- # Call: rdb_makeB1
4714- # Helper routine for rdb_makeB.
4715+sub rdb_make1 {
4716+ # Call: rdb_make1
4717+ # Helper routine for rdb_make.
4718 # Carries out make at level of given rule (all data available).
4719 # Assumes contexts for recursion, make, and rule, and
4720 # assumes that source files for the rule are to be considered
4721@@ -5081,8 +5782,15 @@
4722 # not run the rule, but not set an error condition.
4723 # Any error will arise at the (pdf)latex level due to a
4724 # missing source file at that level.
4725- if ( ( $$Pcmd_type eq 'cusdep') && $$Psource && (! -e $$Psource) ) {
4726- # No action
4727+ if ( $$Psource && (! -e $$Psource)
4728+# OLD && ( ( $$Pcmd_type eq 'cusdep') )
4729+# NEW
4730+ && ( ( $$Pcmd_type ne 'primary') )
4731+ ) {
4732+ # Main source file doesn't exist, and rule is NOT primary.
4733+ # No action, since a run is pointless. Primary is different:
4734+ # file might be found elsewhere (by kpsearch from (pdf)latex),
4735+ # while non-existence of main source file is a clear error.
4736 }
4737 elsif ( $$Pcmd_type eq 'delegated' ) {
4738 # Delegate to destination rule
4739@@ -5111,9 +5819,6 @@
4740 &rdb_diagnose_changes( "Rule '$rule': " );
4741 }
4742
4743- $rules_applied{$rule} = 1;
4744- $runs++;
4745-
4746 # We are applying the rule, so its source file state for when it
4747 # was last made is as of now:
4748 # ??IS IT CORRECT TO DO NOTHING IN CURRENT VERSION?
4749@@ -5127,15 +5832,17 @@
4750 # Getting here represents some kind of weird error.
4751 warn "$My_name: Maximum runs of $rule reached ",
4752 "without getting stable files\n";
4753- warn " Use the -f option to force complete processing.\n"
4754- if (! $force_mode);
4755- $too_many_runs = 1;
4756+ $too_many_passes = 1;
4757 # Treat rule as completed, else in -pvc mode get infinite reruns:
4758 $$Pout_of_date = 0;
4759 $failure = 1;
4760 $failure_msg = "'$rule' needed too many passes";
4761 return;
4762 }
4763+
4764+ $rules_applied{$rule} = 1;
4765+ $runs++;
4766+
4767 $pass{$rule}++;
4768 if ($bibtex_not_run > 0) {
4769 if ($bibtex_not_run == 1 ) {
4770@@ -5150,7 +5857,7 @@
4771 else {
4772 warn_running( "Run number $pass{$rule} of rule '$rule'" );
4773 if ($$Pcmd_type eq 'primary' ) {
4774- $return = &rdb_primary_run;
4775+ $return = &rdb_primary_run;
4776 }
4777 else { $return = &rdb_run1; }
4778 }
4779@@ -5180,14 +5887,18 @@
4780 # For a primary rule, i.e., (pdf)latex, not to produce the
4781 # expected output file may not be an error condition.
4782 # Diagnostics were handled in parsing the log file.
4783- # Special action in main loop inrdb_makeB1
4784+ # Special action in main loop in rdb_make
4785 $missing_dvi_pdf = $$Pdest;
4786 }
4787+ elsif ($return == -2) {
4788+ # Missing output file was reported to be NOT an error
4789+ $$Pout_of_date = 0;
4790+ }
4791 else {
4792 $failure = 1;
4793 }
4794 }
4795- if ($return != 0) {
4796+ if ( ($return != 0) && ($return != -2) ) {
4797 $failure = 1;
4798 $$Plast_result = 2;
4799 if ( !$$Plast_message ) {
4800@@ -5196,24 +5907,22 @@
4801 # !!?? $failure_msg = $$Plast_message;
4802
4803 }
4804-} #END rdb_makeB1
4805-
4806-#************************************************************
4807-
4808-sub rdb_submakeB {
4809- # Call: rdb_submakeB
4810- # Makes all the source files for a given rule.
4811- # Assumes contexts for recursion, for make, and rule.
4812- %visited = %visited_at_rule_start;
4813- local $failure = 0; # Error flag
4814- my @v = keys %visited;
4815-#?? print "---submakeB $rule. @v \n";
4816- rdb_do_files( sub{ rdb_recurse_rule( $$Pfrom_rule, 0,0,0, \&rdb_makeB1 ) } );
4817- return $failure;
4818-} #END rdb_submakeB
4819-
4820-#************************************************************
4821-
4822+} #END rdb_make1
4823+
4824+#************************************************************
4825+
4826+#??sub rdb_submake {
4827+#?? # Call: rdb_submake
4828+#?? # Makes all the source files for a given rule.
4829+#?? # Assumes contexts for recursion, for make, and rule.
4830+#?? %visited = %visited_at_rule_start;
4831+#?? local $failure = 0; # Error flag
4832+#?? my @v = keys %visited;
4833+#?? rdb_do_files( sub{ rdb_recurse_rule( $$Pfrom_rule, 0,0,0, \&rdb_make1 ) } );
4834+#?? return $failure;
4835+#??} #END rdb_submake
4836+
4837+#************************************************************
4838
4839 sub rdb_classify_rules {
4840 # Usage: rdb_classify_rules( \%allowed_primaries, requested targets )
4841@@ -5238,7 +5947,7 @@
4842 @post_primary = ();
4843 @one_time = ();
4844
4845- rdb_recurseA( \@requested_targets, \&rdb_classify1, 0,0, \&rdb_classify2 );
4846+ rdb_recurse( \@requested_targets, \&rdb_classify1, 0,0, \&rdb_classify2 );
4847
4848 # Reverse, as tendency is to find last rules first.
4849 @pre_primary = reverse @pre_primary;
4850@@ -5327,11 +6036,13 @@
4851 # Assumes contexts for: rule.
4852 # Unconditionally apply the rule
4853 # Returns return code from applying the rule.
4854- # Otherwise: 0 on other kind of success, -1 on error.
4855+ # Otherwise: 0 on other kind of success,
4856+ # -1 on error,
4857+ # -2 when missing dest_file is to be ignored
4858
4859- # Source file data, by definition, correspond to the file state just before
4860- # the latest run, and the run_time to the time just before the run:
4861- &rdb_update_filesA;
4862+ # Source file data, by definition, correspond to the file state just
4863+ # before the latest run, and the run_time to the time just before the run:
4864+ &rdb_update_files;
4865 $$Prun_time = time;
4866 $$Pchanged = 0; # No special changes in files
4867 $$Plast_result = 0;
4868@@ -5352,7 +6063,7 @@
4869 $return = &$int_cmd( @int_args );
4870 }
4871 elsif ($$Pext_cmd) {
4872- $return = &rdb_ext_cmd;
4873+ $return = &Run_subst();
4874 }
4875 else {
4876 warn "$My_name: Either a bug OR a configuration error:\n",
4877@@ -5363,8 +6074,35 @@
4878 $$Plast_message = "Bug or configuration error; incorrect command type";
4879 }
4880 if ( $rule =~ /^biber/ ) {
4881- my $retcode = check_biber_log($$Pbase);
4882- if ($retcode == 3) {
4883+ my @biber_source = ( );
4884+ my $retcode = check_biber_log( $$Pbase, \@biber_source );
4885+ foreach my $source ( @biber_source ) {
4886+ print " === Source file '$source' for '$rule'\n"
4887+ if ($diagnostics);
4888+ rdb_ensure_file( $rule, $source );
4889+ }
4890+ if ($retcode == 5) {
4891+ # Special treatment if sole missing file is bib file
4892+ # I don't want to treat that as an error
4893+ $return = 0;
4894+ $$Plast_result = 200;
4895+ $$Plast_message = "Could not find bib file for '$$Pbase'";
4896+ push @warnings, "Bib file not found for '$$Pbase'";
4897+ }
4898+ elsif ($retcode == 6) {
4899+ # Missing control file. Need to remake it (if possible)
4900+ # Don't treat missing bbl file as error.
4901+ warn "$My_name: bibtex control file missing. Since that can\n",
4902+ " be recreated, I'll try to do so.\n";
4903+ $return = -2;
4904+ rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } );
4905+ }
4906+ elsif ($retcode == 4) {
4907+ $$Plast_result = 2;
4908+ $$Plast_message = "Could not find all biber source files for '$$Pbase'";
4909+ push @warnings, "Not all biber source files found for '$$Pbase'";
4910+ }
4911+ elsif ($retcode == 3) {
4912 $$Plast_result = 2;
4913 $$Plast_message = "Could not open biber log file for '$$Pbase'";
4914 push @warnings, $$Plast_message;
4915@@ -5378,13 +6116,16 @@
4916 }
4917 elsif ($retcode == 10) {
4918 push @warnings, "Biber found no citations for '$$Pbase'";
4919- # Biber doesn't generate a bbl file in this situation. So I cannot
4920- # ignore the error the way I do with bibtex.
4921- #$return = 0;
4922+ # Biber doesn't generate a bbl file in this situation.
4923+ $return = -2;
4924 }
4925 }
4926 if ( $rule =~ /^bibtex/ ) {
4927 my $retcode = check_bibtex_log($$Pbase);
4928+ if ( ! -e $$Psource ) {
4929+ $retcode = 10;
4930+ rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } );
4931+ }
4932 if ($retcode == 3) {
4933 $$Plast_result = 2;
4934 $$Plast_message = "Could not open bibtex log file for '$$Pbase'";
4935@@ -5392,15 +6133,23 @@
4936 }
4937 elsif ($retcode == 2) {
4938 $$Plast_message = "Bibtex errors: See file '$$Pbase.blg'";
4939+ $failure = 1;
4940 push @warnings, $$Plast_message;
4941 }
4942 elsif ($retcode == 1) {
4943 push @warnings, "Bibtex warnings for '$$Pbase'";
4944 }
4945 elsif ($retcode == 10) {
4946- push @warnings, "Bibtex found no citations for '$$Pbase'";
4947- # But this is an innocuous error, so fix return code
4948- $return = 0;
4949+ push @warnings, "Bibtex found no citations for '$$Pbase',\n",
4950+ " or bibtex found a missing aux file\n";
4951+ if (! -e $$Pdest ) {
4952+ warn "$My_name: Bibtex did not produce '$$Pdest'. But that\n",
4953+ " was because of missing files, so I will continue.\n";
4954+ $return = -2;
4955+ }
4956+ else {
4957+ $return = 0;
4958+ }
4959 }
4960 }
4961
4962@@ -5412,16 +6161,15 @@
4963 }
4964 $$Pout_of_date = $$Pout_of_date_user = 0;
4965
4966- if ( ($$Plast_result == 0) && ($return != 0) ) {
4967+ if ( ($$Plast_result == 0) && ($return != 0) && ($return != -2) ) {
4968 $$Plast_result = 2;
4969 if ($$Plast_message eq '') {
4970 $$Plast_message = "Command for '$rule' gave return code $return";
4971 }
4972 }
4973- elsif ( $$Pdest && (! -e $$Pdest) ) {
4974+ elsif ( $$Pdest && (! -e $$Pdest) && ($return != -2) ) {
4975 $$Plast_result = 1;
4976 }
4977-
4978 return $return;
4979 } # END rdb_run1
4980
4981@@ -5435,7 +6183,7 @@
4982
4983 # Source file data, by definition, correspond to the file state just before
4984 # the latest run, and the run_time to the time just before the run:
4985- &rdb_update_filesA;
4986+ &rdb_update_files;
4987 $$Prun_time = time;
4988 $$Pchanged = 0; # No special changes in files
4989 $$Plast_result = 0;
4990@@ -5453,41 +6201,59 @@
4991
4992 #-----------------
4993
4994-sub rdb_ext_cmd {
4995- # Call: rdb_ext_cmd
4996- # Assumes rule context. Runs external command with substitutions.
4997- # Uses defaults for the substitutions. See rdb_ext_cmd1.
4998- return rdb_ext_cmd1();
4999-} #END rdb_ext_cmd
5000-
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches