texlive[65054] trunk: latexmk (19nov22)
commits+karl at tug.org
commits+karl at tug.org
Sat Nov 19 22:12:10 CET 2022
Revision: 65054
http://tug.org/svn/texlive?view=revision&revision=65054
Author: karl
Date: 2022-11-19 22:12:09 +0100 (Sat, 19 Nov 2022)
Log Message:
-----------
latexmk (19nov22)
Modified Paths:
--------------
trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl
trunk/Master/texmf-dist/doc/man/man1/latexmk.1
trunk/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf
trunk/Master/texmf-dist/doc/support/latexmk/CHANGES
trunk/Master/texmf-dist/doc/support/latexmk/INSTALL
trunk/Master/texmf-dist/doc/support/latexmk/README
trunk/Master/texmf-dist/doc/support/latexmk/latexmk.pdf
trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt
trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl
Added Paths:
-----------
trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/glossary_latexmkrc
Removed Paths:
-------------
trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/fix-aux.latexmkrc
Modified: trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl 2022-11-19 00:49:28 UTC (rev 65053)
+++ trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl 2022-11-19 21:12:09 UTC (rev 65054)
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
-
use warnings;
+
## Copyright John Collins 1998-2022
## (username jcc8 at node psu.edu)
## (and thanks to David Coppit (username david at node coppit.org)
@@ -43,13 +43,13 @@
$my_name = 'latexmk';
$My_name = 'Latexmk';
-$version_num = '4.77';
-$version_details = "$My_name, John Collins, 17 Mar. 2022. Version $version_num";
+$version_num = '4.78';
+$version_details = "$My_name, John Collins, 18 Nov. 2022. Version $version_num";
use Config;
use File::Basename;
use File::Copy;
-use File::Spec;
+use File::Spec::Functions qw( catfile file_name_is_absolute rel2abs );
# If possible, use better glob, which does not use space as item separator.
# It's either File::Glob::bsd_glob or File::Glob::glob
@@ -91,16 +91,13 @@
use utf8; # For UTF-8 strings in **this** script
use feature 'unicode_strings';
use feature 'say';
-use bytes; # To avoid messes when we use string operations on byte-coded/encoded
- # filename strings.
+
# Coding:
# 1. $CS_system = CS for file names in file system calls, and for CL.
# It's to be UTF-8 on all except: MSWin when the MSWin system code page is
# not 65001.
# 2. Internally use CS_system generally, and especially for filenames.
-# Note with "use bytes;", even **de**coded strings have length and contents
-# in terms of bytes with UTF-8 coding.
# Then standard file system calls, print to terminal don't need encoding,
# and things in rc files work unchanged from earlier versions of latexmk,
# when I didn't treat non-ASCII coding issues explicitly.
@@ -113,10 +110,11 @@
# the PWD is in CS_system on all but most recent *latex (that's a bug).
# Convert file/path names to CS_system.
# 7. Don't support non-UTF-8 on *nix.
-# 8. Do NOT do any conversion to a NF for Unicode: File systems are **either**
-# normalization-sensitive (NTFS, ext4) and we need to preserve
-# normalization, **or** they are normalization-insensitve (hfs+, apfs),
-# in which case we can access a file with any normalization for its name.
+# 8. Do NOT do any conversion to a NF for Unicode: File systems and OS calls
+# to access them are **either** normalization-sensitive (I think, e.g.,
+# ext4) and we need to preserve normalization, **or** they are
+# normalization-insensitve (e.g., hfs+, apfs), in which case we can access
+# a file with any normalization for its name.
#
# N.B. I18N::Langinfo often doesn't give useful enough information.
@@ -126,7 +124,7 @@
our $CS_system;
$CS_system = 'UTF-8';
# Quick short cut for tests of whether conversions needed:
-our $utf8_used = 1;
+our $no_CP_conversions = 1;
# Win32 specific CP **numbers**. Initialize to 65001 (utf-8), and change
# by results of system calls.
@@ -152,18 +150,19 @@
};
if ($@) { warn "Trouble finding and setting code pages used by Windows:\n",
" $@",
- " ILL CONTINUE WITH UTF-8.\n";
+ " I'LL CONTINUE WITH UTF-8.\n";
}
else {
$Win_revert_settings =
($CP_init_Win_console_in ne $CP_Win_system)
|| ($CP_init_Win_console_out ne $CP_Win_system);
+ print
+ "Initial Win CP for (console input, console output, system): ",
+ "(CP$CP_init_Win_console_in, CP$CP_init_Win_console_out, CP$CP_Win_system)\n",
+ "I changed them all to CP$CP_Win_system\n";
}
- print "Win CP console initial and current in/out Win: ",
- "($CP_init_Win_console_in, $CP_init_Win_console_out), ",
- "($CP_Win_system, $CP_Win_system)\n";
}
-$utf8_used = ($CS_system eq 'UTF-8') || ($CS_system eq 'CP65001');
+$no_CP_conversions = ($CS_system eq 'UTF-8') || ($CS_system eq 'CP65001');
# Ensure that on ctrl/C interruption, etc, Windows console CPs are restored:
use sigtrap qw(die untrapped normal-signals);
@@ -176,45 +175,105 @@
}
}
-print "Coding system for system and terminal: '$CS_system'\n---\n"
- unless $utf8_used;
-
########################################################
#************************************************************
#************************************************************
# Unicode manipuation and normalization
+# Notes about Perl strings:
+# 1. Strings have a flag utf8.
+# a. If the utf8 flag is on, the string is to be interpreted as a sequence
+# of code points.
+# When "use utf8;" is used, a string containing non-ASCII characters
+# has the utf8 flag set.
+# If 'no bytes;' is in effect, the ordinal value for each item in the
+# string is the Unicode code point value.
+# b. If the utf8 flag is off for a string, the string is a sequence of
+# bytes, to be interpreted according to whatever CS the user happens
+# to choose to use.
+# c. The utf8 flag is NOT to be interpreted as saying that the string is
+# encoded as UTF-8, even though under the hood that may be the case.
+# d. Indeed, setting 'use bytes;' appears to expose the internal
+# byte-level representation of a string with the utf8 flag set, and
+# that appears to be UTF-8.
+# 2. The utf8 flag is quite confusing in its meaning.
+# 3. When encode is applied to a string whose utf8 flag is on, the result
+# is a string with the utf8 flag off, and the result consists of a sequence
+# of bytes in the chosen encoding scheme, which may be chosen as UTF-8.
+# 4. Strings received from the command line have the utf8 flag off and are
+# encoded in whatever CS the OS/terminal is using.
+# 5. When a string is supplied to print (or c), by default:
+# a. If the utf8 flag is off or if 'use bytes;' is in effect, then the
+# string is sent as a sequence of bytes. They are UTF-8 coded if
+# the utf8 flag is on and 'use bytes;' is in effect.
+# b. If the utf8 flag is on and if 'no bytes;' is in effect, then mostly
+# garbage results for non-ASCII characters; the string must first be
+# encoded as a byte string, in the CS suitable for the OS.
+# c. Correct results are obtained when the utf8 flag is on and 'no bytes'
+# is used when the binmode for the file handle is set suitably.
+# 6. Generally OS calls and interactions with the OS need encoded byte strings.
+# 7. Even more generally, interaction with the external world, including file
+# contents is in terms of byte strings, with some CS chosen by default, by
+# the user, or the OS. Unix-like OSs: Default is UTF-8, but as much by
+# convention as by a requirement of the OS.
-
#-------------------------------------
-sub analyze_string {
- # Useful for debugging encoding issues.
- my ($m,$s) = @_;
- say "=== $m '$s':";
- say(
- 'Perl flag = ',
- (utf8::is_utf8($s) ? 'utf8' : 'NOT utf8'),
- ", len = ", length($s)
- );
- my @code = unpack( 'U*', $s );
- @code = map { sprintf('%4X', $_) } @code;
- say join( ' ', @code );
+sub utf8_to_mine {
+ # Given string encoded in UTF-8, return encoded string in my current CS.
+ # Don't use Encode::from_to, which does in-place conversion.
+ if ($no_CP_conversions) { return $_[0]; }
+ else { return encode( $CS_system, decode('UTF-8', $_[0])); }
}
-#==================
+#-------------------------------------
-sub utf8_to_mine {
+sub utf8_to_mine_errors {
# Given string encoded in UTF-8, return encoded string in my current CS.
- if ($utf8_used) { return $_[0]; }
- else { return encode( $CS_system, decode('UTF-8', $_[0])); }
+ # Don't use Encode::from_to, which does in-place conversion.
+ # Assume coding of input string is correctly UTF-8, but
+ # check for correct encoding in CS_system.
+ # Error message is returned in $@. No error => $@ is null string.
+ # (Same style as eval!)
+ $@ = '';
+ if ($no_CP_conversions) { return $_[0]; }
+ else {
+ my $result = '';
+ eval {
+ $result = encode( $CS_system,
+ decode('UTF-8', $_[0]),
+ Encode::FB_CROAK | Encode::LEAVE_SRC
+ );
+ };
+ return $result;
+ }
}
#-------------------------------------
+sub config_to_mine {
+ # Ensure that configuration strings about files and directories are
+ # encoded in system CS.
+ # Configuration strings set in an rc file SHOULD either be:
+ # a. ASCII only, with Perl's utf8 flag off.
+ # b. Containing non-ASCII characters, with utf8 flag on.
+ # These need to be converted to encoded strings in system CS (and
+ # hence with utf8 flag off).
+ # Configuration variables set from the command line, e.g., from an
+ # -outdir=... option, are already in the system CS, because that is
+ # how strings are passed on the command line.
+ # So we just need to do a conversion for strings with utf8 flag on:
+ foreach ( $out_dir, $aux_dir, @default_files, @default_excluded_files ) {
+ if (utf8::is_utf8($_)) { $_ = encode( $CS_system, $_ ); }
+ }
+} #END config_to_mine
+
+#************************************************************
+
sub mine_to_utf8 {
# Given string encoded in my current CS, return utf-8 encoded string.
- if ($utf8_used) { return $_[0]; }
+ # Don't use Encode::from_to, which does in-place conversion.
+ if ($no_CP_conversions) { return $_[0]; }
else { return encode( 'UTF-8', decode($CS_system, $_[0])); }
}
@@ -255,15 +314,15 @@
if ($invoked_name ne 'latexmk');
# Map my invoked name to pointer to array of default values for $dvi_mode,
-# $postscript_mode, $pdf_mode. These are used if after processing rc files
-# and CL args, no values are set for any of these variables.
+# $postscript_mode, $pdf_mode, $xdv_mode. These are used if after processing
+# rc files and CL args, no values are set for any of these variables.
# Thus default compilation for latexmk is by latex,
# for pdflatexmk is by pdflatex, etc.
%compilation_defaults =
- ( 'latexmk' => [1,0,0],
- 'lualatexmk' => [0,0,4],
- 'pdflatexmk' => [0,0,1],
- 'xelatexmk' => [0,0,5],
+ ( 'latexmk' => [1,0,0,0],
+ 'lualatexmk' => [0,0,4,0],
+ 'pdflatexmk' => [0,0,1,0],
+ 'xelatexmk' => [0,0,5,0],
);
# If name isn't in canonical set, change it to a good default:
unless (exists $compilation_defaults{$invoked_name}) { $invoked_name = 'latexmk'; }
@@ -320,7 +379,19 @@
'Error: pdflatex \(file ([^\)]*)\): cannot find image file',
': File (.*) not found:\s*$',
'! Unable to load picture or PDF file \\\'([^\\\']+)\\\'.',
+ );
+
+# Array of reg-exps for patterns in log file for certain latex warnings
+# that we will call bad warnings. They are not treated as errors by
+# *latex, but depending on the $bad_warning_is_error setting
+# we will treat as if they were actual errors.
+ at bad_warnings = (
+ # Remember: \\ in perl inside single quotes gives a '\', so we need
+ # '\\\\' to get '\\' in the regexp.
+ '^\(\\\\end occurred when .* was incomplete\)',
+ '^\(\\\\end occurred inside .*\)',
);
+$bad_warning_is_error = 0;
# Characters that we won't allow in the name of a TeX file.
# Notes: Some are disallowed by TeX itself.
@@ -401,6 +472,10 @@
## "" means not determined. Obtain from first line of .log file.
$tex_distribution = '';
+# List of known *latex rules:
+%possible_primaries = ( 'dvilualatex' => 'primary', 'latex' => 'primary',
+ 'lualatex' => 'primary', 'pdflatex' => 'primary',
+ 'xelatex' => 'primary' );
&std_tex_cmds;
# Possible code to execute by *latex before inputting source file.
@@ -410,6 +485,7 @@
## Default switches:
$latex_default_switches = '';
$pdflatex_default_switches = '';
+$dvilualatex_default_switches = '';
$lualatex_default_switches = '';
# Note that xelatex is used to give xdv file, not pdf file, hence
# we need the -no-pdf option.
@@ -418,12 +494,13 @@
## Switch(es) to make them silent:
$latex_silent_switch = '-interaction=batchmode';
$pdflatex_silent_switch = '-interaction=batchmode';
+$dvilualatex_silent_switch = '-interaction=batchmode';
$lualatex_silent_switch = '-interaction=batchmode';
$xelatex_silent_switch = '-interaction=batchmode';
# Whether to emulate -aux-directory, so we can use it on system(s) (TeXLive)
# that don't support it:
-$emulate_aux = 0;
+$emulate_aux = 1;
# Whether emulate_aux had to be switched on during a run:
$emulate_aux_switched = 0;
@@ -637,6 +714,7 @@
# These need to be stored until after the command line parsing is finished,
# in case the values of $latex and/or $pdflatex change after an option
# is added.
+ at extra_dvilualatex_options = ();
@extra_latex_options = ();
@extra_pdflatex_options = ();
@extra_lualatex_options = ();
@@ -1118,6 +1196,15 @@
## default parameters
$auto_rc_use = 1; # Whether to read rc files automatically
+$user_deleted_file_treated_as_changed = 0; # Whether when testing for changed
+ # files, a user file that changes status from existing
+ # to non-existing should be regarded as changed.
+ # Value 1: only in non-preview-continuous mode.
+ # Value 2: always.
+ # Primary purpose is to cover cases where behavior of
+ # compilation of .tex file tests for file existence and
+ # adjusts behavior accordingly, instead of simply giving an
+ # error.
$max_repeat = 5; # Maximum times I repeat latex. Normally
# 3 would be sufficient: 1st run generates aux file,
# 2nd run picks up aux file, and maybe toc, lof which
@@ -1159,7 +1246,7 @@
$fdb_ext = 'fdb_latexmk'; # Extension for the file for latexmk's
# file-database
# Make it long to avoid possible collisions.
-$fdb_ver = 3; # Version number for kind of fdb_file.
+$fdb_ver = 4; # Version number for kind of fdb_file.
$jobname = ''; # Jobname: as with current tex, etc indicates
# basename of generated files. Defined so
@@ -1221,19 +1308,27 @@
# Which kinds of file do I have requests to make?
+our ($dvi_mode, $pdf_mode, $postscript_mode, $xdv_mode,
+ $cleanup_mode, $force_mode, $go_mode, $landscape_mode, $preview_mode, $preview_continuous_mode, $printout_mode );
# If no requests at all are made, then I will make dvi file
# If particular requests are made then other files may also have to be
# made. E.g., ps file requires a dvi file
-$dvi_mode = 0; # No dvi file requested
+$dvi_mode = 0; # No dvi file requested.
+ # Possible values:
+ # 0: no request for dvi file
+ # 1: use latex to make dvi file
+ # 2: use dvilualatex to make dvi file
$postscript_mode = 0; # No postscript file requested
$pdf_mode = 0; # No pdf file requested to be made by pdflatex
# Possible values:
# 0 don't create pdf file
# 1 to create pdf file by pdflatex
- # 2 to create pdf file by ps2pdf
- # 3 to create pdf file by dvipdf
+ # 2 to create pdf file by compile-to-dvi+dvips+ps2pdf
+ # 3 to create pdf file by compile-to-dvi+dvipdf
# 4 to create pdf file by lualatex
# 5 to create pdf file by xelatex + xdvipdfmx
+$xdv_mode = 0; # No xdv file requested
+
$view = 'default'; # Default preview is of highest of dvi, ps, pdf
$sleep_time = 2; # time to sleep b/w checks for file changes in -pvc mode
$banner = 0; # Non-zero if we have a banner to insert
@@ -1269,9 +1364,10 @@
$dvi_filter = ''; # DVI filter command
$ps_filter = ''; # Postscript filter command
-$force_mode = 0; # =1 to force processing past errors
-$go_mode = 0; # =1 to force processing regardless of time-stamps
- # =2 full clean-up first
+$force_mode = 0; # =1: to force processing past errors
+$go_mode = 0; # =1: to force processing regardless of time-stamps
+ # =2: full clean-up first
+ # =3: Just force primary rule(s) to run
$preview_mode = 0;
$preview_continuous_mode = 0;
$printout_mode = 0; # Don't print the file
@@ -1280,10 +1376,14 @@
$pvc_timeout = 0;
$pvc_timeout_mins = 30;
-$show_time = 0;
- at timings = ();
-$processing_time1 = processing_time();
+# Timing information
+# Whether to report processing time:
+our $show_time = 0;
+# Data for 1 run and global (ending in '0'):
+our ( $processing_time1, $processing_time0, @timings1, @timings0);
+&init_timing_all;
+
$use_make_for_missing_files = 0; # Whether to use make to try to make missing files.
# Do we make view file in temporary then move to final destination?
@@ -1319,12 +1419,26 @@
$BIBINPUTS = $ENV{'BIBINPUTS'};
if (!$BIBINPUTS) { $BIBINPUTS = '.'; }
+# ???!!!
+# Old configuration variable @BIBINPUTS to be equivalent to environment
+# variable BIBINPUTS. It was to be easier to work with inside latexmk. But
+# under present conditions, it's better to manipulate $ENV{BIBINPUTS}.
+# ??? Need to explain better.
+# Why only for BIBINPUTS, not TEXINPUTS.
+#
+# But retain @BIBINPUTS for backward compatibility, since users may have
+# configured it. We'll save the values, allow for possible user changes in
+# @BIBINPUTS or $ENV{BIBINPUTS} in rc files and from command line
+# arguments. Then funnel changes back to $ENV{BIBINPUTS}, ...
+#
# Convert search paths to arrays:
# If any of the paths end in '//' then recursively search the
# directory. After these operations, @BIBINPUTS should
# have all the directories that need to be searched
-
+#
@BIBINPUTS = find_dirs1( $BIBINPUTS );
+our @BIBINPUTS_SAVE = @BIBINPUTS;
+our $BIBINPUTS_ENV_SAVE = $ENV{BIBINPUTS};
######################################################################
@@ -1438,12 +1552,7 @@
# non-existent file.
-# List of known rules. Rule types: primary,
-# external (calls program), internal (calls routine), cusdep.
-%possible_primaries = ( 'latex' => 'primary', 'pdflatex' => 'primary',
- 'lualatex' => 'primary', 'xelatex' => 'primary' );
-
# Hashes, whose keys give names of particular kinds of rule, and targets.
# We use hashes for ease of lookup.
%possible_one_time = ( 'view' => 1, 'print' => 1, 'update_view' => 1, );
@@ -1455,8 +1564,9 @@
# currently irrelevant.
# The target **files** can only be set inside the FILE loop.
$current_primary = 'latex'; # Rule to compile .tex file.
- # Subject to document-dependent override if .tex document
- # uses metcommands andobeying them is enabled.
+ # It will be overridden at rule-initialization time, and
+ # is subject to document-dependent override if .tex document
+ # uses metcommands and obeying them is implemented/enabled.
$pdf_method = ''; # How to make pdf file. '' if not requested,
# else 'ps2pdf', 'dvipdf', 'pdflatex', 'lualatex' or 'xelatex'
# Subject to document-dependent override if .tex document
@@ -1475,7 +1585,7 @@
%rule_db = (); # Database of all rules:
# Hash: rulename -> [array of rule data]
# Rule data:
- # 0: [ cmd_type, ext_cmd, int_cmd, test_kind,
+ # 0: [ cmd_type, ext_cmd, int_cmd, no_history,
# source, dest, base,
# out_of_date, out_of_date_user,
# time_of_last_run, time_of_last_file_check,
@@ -1502,15 +1612,18 @@
# This variable intcmd is a reference to an array,
# $$intcmd[0] = internal routine
# $$intcmd[1...] = its arguments (if any)
- # test_kind specifies method of determining
- # whether a file is out-of-date:
- # 0 for never
- # 1 for usual: whether there is a source
- # file change
- # 2 for dest earlier than source
- # 3 for method 2 at first run, 1 thereafter
- # (used when don't have file data from
- # previous run).
+ # no_history being true indicates that there was no
+ # data on the file state from a previous run. In
+ # this case the implication is that when the next
+ # test for whether a run of the rule is needed,
+ # the file-contents criterion won't be useful.
+ # Then a time-based criterion (as in normal make)
+ # is used, i.e., if a source file is newer than
+ # the destination file, then a rerun is needed.
+ # After that first test for a rerun has been
+ # done, a run or no run is made according as
+ # appropriate. After that the file-change
+ # criterion works, and no_history is turned off.
# source = name of primary source file, if any
# dest = name of primary destination file,
# if any
@@ -1545,7 +1658,7 @@
# changed flags whether special changes have been made
# that require file-existence status to be ignored
# last_result is
- # -1 if no run has been made,
+ # -1 if no run has been made
# 0 if the last run was successful
# 1 if last run was successful, but
# failed to create an output file
@@ -1588,9 +1701,38 @@
# can be avoided by changing the file's time
# in the source-file list.
# 2: {Hash generated_file -> 1 }
- # This lists all generated files; the values
- # are currently unused, only the keys
- # 3: {Hash source_rule -> last_pass }
+ # This lists all generated files.
+ # The values for the hash are currently unused, only the keys.
+ # 3: {Hash rewritten_before_read_file -> 1 }
+ # This lists all files that are only read after being
+ # written **and** that existed before being
+ # written, i.e., that existed at the beginning of
+ # the run. These are listed in both the source-
+ # and generated-file hashes, but do not need
+ # to be checked for changes in testing whether
+ # another run is needed, i.e., they aren't true
+ # source files. **IMPORTANT NOTE:** If a file is
+ # read only after being written, but the file didn't
+ # exist at the beginning of the run, it is
+ # possible (and often true) that on a subsequent
+ # run the file would be read, then written, and
+ # perhaps read again. That is, it can be that
+ # before the file is written, there is a test for
+ # file existence, and the file is read, but only
+ # if it exists. Examples: .aux and .toc
+ # files. Such files are true dependencies and must
+ # be checked for changes. Only when the file
+ # existed at the start of the run and was then
+ # written before being read, do we know that
+ # write-before-read shows that the file is not a
+ # true source-dependency.
+ # This issue is significant: under some situations,
+ # like the use of latexmk and tex4ht, the file may
+ # be changed by other software before the next run
+ # of the current rule. That must not trigger
+ # another run.
+ # The values for the hash are currently unused, only the keys.
+ # 4: {Hash source_rule -> last_pass }
# This lists rules that are to be considered source
# rules for the current rule, separately from the
# source_rules of the source files. Its main use
@@ -1642,8 +1784,6 @@
# not defined (or possibly the null string '').
# Classification of rules, for determining order of application
-%current_primaries = (); # Keys are primary rules (latex, etc) that are
- # currently in use.
@pre_primary = (); # Array of rules that are thought of as pre-primary,
# Should be in an appropriate order for invoking
# them, to optimize making.
@@ -1693,7 +1833,6 @@
sub read_first_rc_file_in_list {
foreach my $rc_file ( @_ ) {
- #print "===Testing for rc file \"$rc_file\" ...\n";
if ( -d $rc_file ) {
warn "$My_name: I have found a DIRECTORY named \"$rc_file\".\n",
" Have you perhaps misunderstood latexmk's documentation?\n",
@@ -1745,6 +1884,8 @@
read_first_rc_file_in_list( ".latexmkrc", "latexmkrc" );
}
+
+
## Process command line args.
@command_line_file_list = ();
$bad_options = 0;
@@ -1782,8 +1923,12 @@
elsif (/^-diagnostics/) { $diagnostics = 1; }
elsif (/^-dir-report$/) { $aux_out_dir_report = 1; }
elsif (/^-dir-report-$/) { $aux_out_dir_report = 0; }
- elsif (/^-dvi$/) { $dvi_mode = 1; }
- elsif (/^-dvi-$/) { $dvi_mode = 0; }
+ elsif (/^-dvi$/) { $dvi_mode = 1; }
+ elsif (/^-dvilua$/) { $dvi_mode = 2; }
+ elsif (/^-dvi-$/) { $dvi_mode = 0; }
+ elsif ( /^-dvilualatex=(.*)$/ ) {
+ $dvilualatex = $1;
+ }
elsif (/^-emulate-aux-dir$/) { $emulate_aux = 1; }
elsif (/^-emulate-aux-dir-$/) { $emulate_aux = 0; }
elsif (/^-f$/) { $force_mode = 1; }
@@ -1793,6 +1938,9 @@
elsif (/^-gg$/) {
$go_mode = 2; $cleanup_mode = 1; $cleanup_only = 0;
}
+ elsif (/^-gt$/) {
+ $go_mode = 3;
+ }
elsif ( /^-h$/ || /^-help$/ ) { &print_help; exit;}
elsif (/^-jobname=(.*)$/) {
$jobname = $1;
@@ -1808,6 +1956,7 @@
$latex = $1;
}
elsif (/^-latexoption=(.*)$/) {
+ push @extra_dvilualatex_options, $1;
push @extra_latex_options, $1;
push @extra_pdflatex_options, $1;
push @extra_lualatex_options, $1;
@@ -1967,6 +2116,8 @@
elsif (/^-view=ps$/) { $view = "ps";}
elsif (/^-view=pdf$/) { $view = "pdf"; }
elsif (/^-Werror$/){ $warnings_as_errors = 1; }
+ elsif (/^-xdv$/) { $xdv_mode = 1; }
+ elsif (/^-xdv-$/) { $xdv_mode = 0; }
elsif ( /^-xelatex$/ || /^-pdfxelatex$/ ) {
$pdf_mode = 5;
$dvi_mode = $postscript_mode = 0;
@@ -2032,6 +2183,7 @@
|| ( /^(-.+)=/ && exists( $allowed_latex_options_with_arg{$1} ) )
)
{
+ push @extra_dvilualatex_options, $original;
push @extra_latex_options, $original;
push @extra_pdflatex_options, $original;
push @extra_lualatex_options, $original;
@@ -2057,6 +2209,8 @@
print "$My_name: This is $version_details, version: $version_num.\n",
unless $silent;
+&config_to_mine;
+
if ($out_dir eq '' ){
# Default to cwd
$out_dir = '.';
@@ -2198,11 +2352,13 @@
&fix_cmds;
# Add common options
+add_option( $dvilualatex_default_switches, \$dvilualatex );
add_option( $latex_default_switches, \$latex );
add_option( $pdflatex_default_switches, \$pdflatex );
add_option( $lualatex_default_switches, \$lualatex );
add_option( $xelatex_default_switches, \$xelatex );
+foreach (@extra_dvilualatex_options) { add_option( $_, \$dvilualatex ); }
foreach (@extra_latex_options) { add_option( $_, \$latex ); }
foreach (@extra_pdflatex_options) { add_option( $_, \$pdflatex ); }
foreach (@extra_lualatex_options) { add_option( $_, \$lualatex ); }
@@ -2217,7 +2373,23 @@
$ps_previewer = $ps_previewer_landscape;
}
+{ my $array_changed = 0;
+ if ($#BIBINPUTS != $#BIBINPUTS_SAVE) { $array_changed = 1; }
+ else {
+ for( my $i = 0; $i <= $#BIBINPUTS; $i++ ) {
+ if ($BIBINPUTS[$i] ne $BIBINPUTS_SAVE[$i]) {
+ $array_changed = 1;
+ last;
+ }
+ }
+ }
+ if ($array_changed) {
+ foreach (@BIBINPUTS) { ensure_path( 'BIBINPUTS', $_ ); }
+ }
+}
+
if ( $silent ) {
+ add_option( "$dvilualatex_silent_switch", \$dvilualatex );
add_option( "$latex_silent_switch", \$latex );
add_option( "$pdflatex_silent_switch", \$pdflatex );
add_option( "$lualatex_silent_switch", \$lualatex );
@@ -2231,7 +2403,7 @@
}
if ( $recorder ) {
- add_option( "-recorder", \$latex, \$pdflatex, \$lualatex, \$xelatex );
+ add_option( "-recorder", \$dvilualatex, \$latex, \$pdflatex, \$lualatex, \$xelatex );
}
# If the output and/or aux directories are specified, fix the *latex
@@ -2243,11 +2415,11 @@
if ( $jobname ne '' ) {
# Since $jobname may include placeholder(s), put %R placeholder
# in option, and let %R be substituted by actual jobname at runtime.
- add_option( "--jobname=%R", \$latex, \$lualatex, \$pdflatex, \$xelatex );
+ add_option( "--jobname=%R", \$dvilualatex, \$latex, \$lualatex, \$pdflatex, \$xelatex );
}
# Make sure we make the kind of file we want to view:
-if ($view eq 'dvi') { $dvi_mode = 1; }
+if ( ($view eq 'dvi') && ($dvi_mode == 0) ) { $dvi_mode = 1; }
if ($view eq 'ps') { $postscript_mode = 1; }
if ( ($view eq 'pdf') && ($pdf_mode == 0) ) {
$pdf_mode = 1;
@@ -2254,9 +2426,9 @@
}
# Make sure that we make something if all requests are turned off
-unless ( $dvi_mode || $pdf_mode || $postscript_mode || $printout_mode ) {
+unless ( $dvi_mode || $pdf_mode || $postscript_mode || $printout_mode || $xdv_mode ) {
print "No specific requests made, so using default for $invoked_name.\n";
- ($dvi_mode, $postscript_mode, $pdf_mode)
+ ($dvi_mode, $postscript_mode, $pdf_mode, $xdv_mode )
= @{$compilation_defaults{$invoked_name}};
}
@@ -2274,12 +2446,10 @@
# Determine requests.
if ( $banner ) { $postscript_mode = 1; }
if ( $dvi_mode ) {
- $current_primary = 'latex';
$requested_filetypes{'dvi'} = 1;
if ( length($dvi_filter) != 0 ) { $requested_filetypes{'dviF'} = 1; }
}
if ( $postscript_mode ) {
- $current_primary = 'latex';
$requested_filetypes{'ps'} = 1;
if ( length($ps_filter) != 0 ) { $requested_filetypes{'psF'} = 1; }
}
@@ -2293,11 +2463,13 @@
my %disallowed = ();
foreach (1,4,5) { $disallowed{$_} = 1; }
if ($disallowed{$pdf_mode}) {
- warn "$My_name: \$pdf_mode = $pdf_mode is incompatible with dvi and postscript modes\n",
- " which are required by other requests.\n";
- if ($postscript_mode) {$pdf_mode = 2;}
+ warn
+ "$My_name: \$pdf_mode = $pdf_mode is incompatible with dvi and postscript modes\n",
+ " which are required by other requests.\n";
+ if ($postscript_mode) { $pdf_mode = 2; }
else { $pdf_mode = 3; }
- warn " I replaced it by $pdf_mode.\n";
+ warn
+ " I replaced it by $pdf_mode, to be compatible with those other requests.\n";
}
}
if ( $pdf_mode == 0 ) {
@@ -2339,7 +2511,7 @@
if ( $preview_continuous_mode || $preview_mode ) { $one_time{'view'} = 1; }
$can_switch = $allow_switch;
-if ( $dvi_mode || $postscript_mode
+if ( $dvi_mode || $postscript_mode || $xdv_mode
|| ( $printout_mode && ($print_type eq 'ps') || ($print_type eq 'dvi') )
|| ( ($preview_mode || $preview_continuous_mode) && ( ($view eq 'ps') || ($view eq 'dvi') ) )
) {
@@ -2461,6 +2633,8 @@
# Use of $do_cd, which can affect how $aux_dir and $out_dir get normalized.
local $aux_dir = $aux_dir;
local $out_dir = $out_dir;
+
+ local $dvilualatex = $dvilualatex;
local $latex = $latex;
local $lualatex = $lualatex;
local $pdflatex = $pdflatex;
@@ -2502,8 +2676,9 @@
# data may be incorrect.
# So use filetime criterion for make instead of file change from
# previous run, until we have done our own make.
- rdb_recurse( [keys %possible_primaries],
- sub{ if ( $$Ptest_kind == 1 ) { $$Ptest_kind = 3;} }
+ # ???!!! CHECK: WHY ONLY PRIMARIES????
+ rdb_recurse( [$current_primary],
+ sub{ $$Pno_history = 1; }
);
}
}
@@ -2511,7 +2686,7 @@
# At least we can use dependency information from previous run of
# *latex, which may not have been under latexmk control, otherwise
# the fdb_latexmk file would have been made.
- rdb_for_some( [keys %current_primaries],
+ rdb_for_some( [$current_primary],
sub{ rdb_set_latex_deps($cleanup_mode) }
);
&rdb_set_rule_net;
@@ -2545,8 +2720,14 @@
- if ($go_mode) {
+ if ($go_mode == 3) {
+ # Force primaries to be remade.
+ if (!$silent) { print "Force *latex to be remade.\n"; }
+ rdb_for_some( [keys %possible_primaries], sub{$$Pout_of_date=1;} );
+ }
+ elsif ($go_mode) {
# Force everything to be remade.
+ if (!$silent) { print "Force everything to be remade.\n"; }
rdb_recurse( [ &rdb_target_array], sub{$$Pout_of_date=1;} );
}
@@ -2579,6 +2760,8 @@
#Initialize failure flags now.
$failure = 0;
$failure_msg = '';
+ &init_timing1;
+
if ($compiling_cmd) { Run_subst( $compiling_cmd ); }
$failure = &rdb_make;
if ( ( $failure <= 0 ) || $force_mode ) {
@@ -2623,10 +2806,15 @@
push @failed_primaries, $filename;
}
&ifcd_popd;
+ if ($show_time) { &show_timing1; };
+ print "\n";
}
close($deps_handle) if ( $deps_handle );
-if ($show_time) { show_timing();}
+if ( $show_time && ( ($#file_list > 0) || $preview_continuous_mode ) ) {
+ print "\n";
+ show_timing_grand();
+}
# If we get here without going through the continue section:
if ( $do_cd && ($#dir_stack > -1) ) {
@@ -2664,21 +2852,63 @@
#############################################################
#############################################################
-sub show_timing {
+# Subroutines for working with processing time
+
+############################
+
+sub add_timing {
+ # Usage: add_timing( time_for_run, rule );
+ # Adds time_for_run to @timings1, @timings0
+ my ( $time, $rule ) = @_;
+ push @timings1, "'$rule': time = " . sprintf('%.2f',$time) . "\n";
+ push @timings0, "'$rule': time = " . sprintf('%.2f',$time) . "\n";
+}
+
+############################
+
+sub init_timing1 {
+ # Initialize timing for one run.
+ @timings1 = ();
+ $processing_time1 = processing_time();
+}
+
+############################
+
+sub init_timing_all {
+ # Initialize timing for totals and for one run:
+ @timings0 = ();
+ $processing_time0 = processing_time();
+ &init_timing1;
+}
+
+############################
+
+sub show_timing1 {
+ # Show timing for one run.
my $processing_time = processing_time() - $processing_time1;
- print @timings, "Accumulated processing time = ",
+ print @timings1, "Processing time = ",
sprintf('%.2f', $processing_time), "\n";
- print "Number of rules run = ", 1+$#timings, "\n";
- @timings = ();
- $processing_time1 = processing_time();
+ print "Number of rules run = ", 1+$#timings1, "\n";
}
+############################
+
+sub show_timing_grand {
+ # Show grand total timing.
+ my $processing_time = processing_time() - $processing_time0;
+ print # @timings0,
+ "Grand total processing time = ",
+ sprintf('%.2f', $processing_time), "\n";
+ print "Total number of rules run = ", 1+$#timings0, "\n";
+}
+
#############################################################
+#############################################################
sub set_tex_cmds {
# Usage, e.g., set_tex_cmds( '%O %S' )
my $args = $_[0];
- foreach my $cmd ('latex', 'lualatex', 'pdflatex', 'xelatex' ) {
+ foreach my $cmd ( keys %possible_primaries ) {
${$cmd} = "$cmd $args";
}
# N.B. See setting of $latex_default_switches, ...,
@@ -2745,8 +2975,8 @@
#############################################################
sub ensure_path {
- # Usage: ensure_path( $var, values ...)
- # $ENV{$var} is an environment variable (e.g. $ENV{TEXINPUTS}.
+ # Usage: ensure_path( var, values ...)
+ # $ENV{var} is an environment variable (e.g. $ENV{TEXINPUTS}.
# Ensure the values are in it, prepending them if not, and
# creating the environment variable if it doesn't already exist.
my $var = shift;
@@ -2772,6 +3002,63 @@
#############################################################
+sub path_fudge {
+ # Usage: path_fudge( var1[, var2 ...])
+ # For each argument, $ENV{var} is an environment variable
+ # (e.g. $ENV{BIBINPUTS}, that is a search path.
+ # Adjust each of these environment variables so that it is
+ # appropriately set for use when a program is run with a changed wd,
+ # as with bibtex when $bibtex_fudge is set.
+ # Specifically:
+ # 1. Prepend current wd to each $ENV{var}, if it exists; otherwise
+ # set $ENV{var} to current wd followed by search-path separator,
+ # so that search path is cwd and then default.
+ # Hence files in cwd are found by a program run in another
+ # directory.
+ # 2. For each item in $ENV{var} that isn't an absolute path, i.e.,
+ # that is relative, replace it by itself followed by the same path
+ # converted to an absolute path, with the relative path being
+ # assumed to be relative to the current wd.
+ # Hence a program run in another directory finds files that were
+ # originally intended to be in a directory relative to the orginal
+ # cwd. In addition, in the conceivable case that the item in the
+ # search path is actually intended to be relative to the directory
+ # in which the program is run (normally the aux dir), it also
+ # works correctly.
+
+ my $cwd = good_cwd();
+ foreach my $var ( @_ ) {
+ if ( exists $ENV{$var} ) {
+ $ENV{$var} = $cwd.$search_path_separator.$ENV{$var};
+ }
+ else {
+ $ENV{$var} = $cwd.$search_path_separator;
+ }
+
+ my @items = split_search_path( $search_path_separator, '', $ENV{$var} );
+ my $changed = 0;
+
+ foreach (@items) {
+ if ($_ eq '' ) {
+ # Empty item => std search path => nothing to do.
+ }
+ elsif ( ! file_name_is_absolute($_) ) {
+ my $abs = rel2abs($_);
+ $_ .= $search_path_separator.$abs;
+ $changed = 1;
+ }
+ }
+
+ if ($changed) {
+ # Correct the env. var.
+ $ENV{$var} = join( $search_path_separator, @items );
+ print "====== ENV{$var} changed to '$ENV{$var}'\n";
+ }
+ } # END loop over env. vars.
+} #END path_fudge
+
+#############################################################
+
sub normalize_aux_out_ETC {
# 1. Normalize $out_dir and $aux_dir, so that if they have a non-trivial last
# component, any trailing '/' is removed.
@@ -2879,13 +3166,13 @@
# the relevant files (.pdf, .ps, .dvi, .xdv, .fls to the output
# directory after running *latex.
add_option( "-output-directory=%V",
- \$latex, \$pdflatex, \$lualatex, \$xelatex );
+ \$dvilualatex, \$latex, \$pdflatex, \$lualatex, \$xelatex );
}
}
else {
if ( $out_dir && ($out_dir ne '.') ) {
add_option( "-output-directory=%W",
- \$latex, \$pdflatex, \$lualatex, \$xelatex );
+ \$dvilualatex, \$latex, \$pdflatex, \$lualatex, \$xelatex );
}
if ( $aux_dir ne $out_dir ) {
# N.B. If $aux_dir and $out_dir are the same, then the
@@ -2892,7 +3179,7 @@
# -output-directory option is sufficient, especially because
# the -aux-directory exists only in MiKTeX, not in TeXLive.
add_option( "-aux-directory=%V",
- \$latex, \$pdflatex, \$lualatex, \$xelatex );
+ \$dvilualatex, \$latex, \$pdflatex, \$lualatex, \$xelatex );
}
}
} #END set_aux_out_options
@@ -2966,8 +3253,9 @@
while ( my ($key, $value) = each %extra_rule_spec ) {
$rule_template{$key} = $value;
}
+ # ???!!! REVISE
foreach my $rule ( keys %rule_template ) {
- my ( $cmd_type, $ext_cmd, $int_cmd, $source, $dest, $base, $test_kind, $PA_extra_gen ) = @{$rule_template{$rule}};
+ my ( $cmd_type, $ext_cmd, $int_cmd, $source, $dest, $base, $DUMMY, $PA_extra_gen ) = @{$rule_template{$rule}};
if ( ! $PA_extra_gen ) { $PA_extra_gen = []; }
my $needs_making = 0;
# Substitute in the filename variables, since we will use
@@ -2982,28 +3270,43 @@
s/%B/$base/;
s/%T/$texfile_name/;
}
- rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $test_kind,
+ rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $DUMMY,
$source, $dest, $base,
$needs_making, undef, undef, 1, $PA_extra_gen );
} # End rule iteration
- # Ensure we only have one way to make pdf file, and that it is appropriate. Remove other incompatibilities
- if ($pdf_mode == 1) { rdb_deactivate( 'dvipdf', 'ps2pdf', 'latex', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
- elsif ($pdf_mode == 2) { rdb_deactivate( 'dvipdf', 'pdflatex', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
- elsif ($pdf_mode == 3) { rdb_deactivate( 'pdflatex', 'ps2pdf', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
- elsif ($pdf_mode == 4) { rdb_deactivate( 'pdflatex', 'ps2pdf', 'dvipdf', 'xdvipdfmx', 'xelatex' ); }
- elsif ($pdf_mode == 5) { rdb_deactivate( 'pdflatex', 'ps2pdf', 'dvipdf', 'lualatex' ); }
- else { rdb_deactivate( 'dvipdf', 'pdflatex', 'ps2pdf', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
+ # At this point, all the rules are active.
+ # The rules that are used are determined by starting with the desired
+ # final files and going backwards in the rule network to find what rules
+ # have to be run to make the final files.
+ # The only problem in doing this is if there is more than one way of making
+ # a given file. This arises only for rules that make pdf or dvi files,
+ # since we have multiple rules for making them.
- if ($dvi_mode == 1) {
- rdb_activate( 'latex' );
- $target_files{$dvi_final} = 1;
- }
- if ($postscript_mode == 1) {
- rdb_activate( 'latex' );
- $target_files{$ps_final} = 1;
- }
+ # Ensure we only have one way to make pdf file, and only one active primary:
+ # Deactivate pdf-making rules and primary rules,
+ # then reactivating only one pdf producing rule and current primary,
+ # setting $current_primary as side-effect.
+
+ rdb_deactivate( 'dvipdf', 'ps2pdf', 'xdvipdfmx', keys %possible_primaries );
+
+ $current_primary = 'latex'; #
+ # Activate needed non-primary pdf-making rules, set current primary (if
+ # it isn't latex, and activate the current primary:
+ if ($pdf_mode == 1) { $current_primary = 'pdflatex'; }
+ elsif ($pdf_mode == 2) { rdb_activate( 'ps2pdf' ); }
+ elsif ($pdf_mode == 3) { rdb_activate( 'dvipdf' ); }
+ elsif ($pdf_mode == 4) { $current_primary = 'lualatex'; }
+ elsif ($pdf_mode == 5) { rdb_activate( 'xdvipdfmx' ); $current_primary = 'xelatex'; }
+ if ($dvi_mode == 2) { $current_primary = 'dvilualatex'; }
+
+ rdb_activate( $current_primary );
+
+ if ($dvi_mode) { $target_files{$dvi_final} = 1; }
+ if ($postscript_mode) { $target_files{$ps_final} = 1; }
if ($pdf_mode) { $target_files{$pdf_final} = 1; }
+ if ($xdv_mode) { $target_files{$xdv_final} = 1; }
+
&rdb_set_rule_net;
} # END rdb_initialize_rules
@@ -3052,21 +3355,19 @@
# Specification of internal command for viewer update:
my $PA_update = ['do_update_view', $viewer_update_method, $viewer_update_signal, 0, 1];
-# For test_kind: Use file contents for latex and friends, but file time for the others.
-# This is because, especially for dvi file, the contents of the file may contain
-# a pointer to a file to be included, not the contents of the file!
%rule_list = (
+ 'dvilualatex' => [ 'primary', "$dvilualatex", '', "%T", $dvi_name, "%R", 1, [$log_name] ],
'latex' => [ 'primary', "$latex", '', "%T", $dvi_name, "%R", 1, [$log_name] ],
+ 'lualatex' => [ 'primary', "$lualatex", '', "%T", $pdf_name, "%R", 1, [$log_name] ],
'pdflatex' => [ 'primary', "$pdflatex", '', "%T", $pdf_name, "%R", 1, [$log_name] ],
- 'lualatex' => [ 'primary', "$lualatex", '', "%T", $pdf_name, "%R", 1, [$log_name] ],
'xelatex' => [ 'primary', "$xelatex", '', "%T", $xdv_name, "%R", 1, [$log_name] ],
- 'dvipdf' => [ 'external', "$dvipdf", 'do_viewfile', $dvi_final, $pdf_name, "%Z%R", 2 ],
- 'xdvipdfmx' => [ 'external', "$xdvipdfmx", 'do_viewfile', $xdv_final, $pdf_name, "%Z%R", 2 ],
- 'dvips' => [ 'external', "$dvips", 'do_viewfile', $dvi_final, $ps_name, "%Z%R", 2 ],
- 'dvifilter' => [ 'external', $dvi_filter, 'do_viewfile', $dvi_name, $dviF_name, "%Z%R", 2 ],
- 'ps2pdf' => [ 'external', "$ps2pdf", 'do_viewfile', $ps_final, $pdf_name, "%Z%R", 2 ],
- 'psfilter' => [ 'external', $ps_filter, 'do_viewfile', $ps_name, $psF_name, "%Z%R", 2 ],
- 'print' => [ 'external', "$print_cmd", 'if_source', $print_file, "", "", 2 ],
+ 'dvipdf' => [ 'external', "$dvipdf", 'do_viewfile', $dvi_final, $pdf_name, "%Z%R", 1 ],
+ 'xdvipdfmx' => [ 'external', "$xdvipdfmx", 'do_viewfile', $xdv_final, $pdf_name, "%Z%R", 1 ],
+ 'dvips' => [ 'external', "$dvips", 'do_viewfile', $dvi_final, $ps_name, "%Z%R", 1 ],
+ 'dvifilter' => [ 'external', $dvi_filter, 'do_viewfile', $dvi_name, $dviF_name, "%Z%R", 1 ],
+ 'ps2pdf' => [ 'external', "$ps2pdf", 'do_viewfile', $ps_final, $pdf_name, "%Z%R", 1 ],
+ 'psfilter' => [ 'external', $ps_filter, 'do_viewfile', $ps_name, $psF_name, "%Z%R", 1 ],
+ 'print' => [ 'external', "$print_cmd", 'if_source', $print_file, "", "", 1 ],
'update_view' => [ 'external', $viewer_update_command, $PA_update,
$view_file, "", "", 2 ],
'view' => [ 'external', "$viewer", 'if_source', $view_file, "", "", 2 ],
@@ -3097,7 +3398,6 @@
rdb_for_actives( \&set_file_links_for_rule );
rdb_for_actives( \&rdb_set_source_rules );
&rdb_classify_rules;
- # print "=========In rdb_make_links: rules\n"; &rdb_show;
}
#------------
@@ -3183,7 +3483,6 @@
# %possible_primaries
# Output:
- # %current_primaries # Keys are actual primaries
# @pre_primary # Array of rules
# @post_primary # Array of rules
# @unusual_one_time # Array of rules
@@ -3193,7 +3492,6 @@
local $state = 0; # Post-primary
local @classify_stack = ();
- %current_primaries = ();
@pre_primary = ();
@post_primary = ();
@unusual_one_time = ();
@@ -3204,21 +3502,11 @@
@pre_primary = reverse @pre_primary;
@post_primary = reverse @post_primary;
- my @current_primaries = keys %current_primaries;
- if ($#current_primaries < 0) {
- die "$My_name: No active primary rules found. I have to stop.\n";
- }
- elsif ($#current_primaries > 0) {
- die "$My_name: More than one active primary rule found. I have to stop.\n",
- " Primary rules: @current_primaries\n";
- }
- $current_primary = $current_primaries[0];
-
if ($diagnostics) {
print "Rule classification: \n";
show_array( " Requested rules:", @requested_targets );
show_array( " Pre-primaries:", @pre_primary );
- show_array( " Primaries:", keys %current_primaries );
+ show_array( " Primary:", $current_primary );
show_array( " Post-primaries:", @post_primary );
show_array( " Inner-level one_time rules:", @unusual_one_time );
show_array( " Outer-level one_time rules:", keys %one_time );
@@ -3245,7 +3533,6 @@
elsif ($state == 0) {
if ( exists $possible_primaries{$rule} ) {
$state = 1; # In primary rule
- $current_primaries{ $rule } = 1;
}
else {
push @post_primary, $rule;
@@ -3289,6 +3576,7 @@
fprint8 $aux_file, "\\gdef \\\@abspage\@last{1}\n";
close($aux_file);
+ if (!$silent) { print "After making new aux file, require run of *latex.\n"; }
foreach my $rule (keys %possible_primaries ) {
rdb_ensure_file( $rule, $texfile_name );
rdb_ensure_file( $rule, $aux_main );
@@ -3681,18 +3969,11 @@
#************************************************************
sub make_preview_continuous {
- local @changed = ();
- local %changed_rules = ();
- local @changed_user = ();
- local @disappeared = ();
- local @no_dest = (); # Non-existent destination files
- local @rules_never_run = ();
- local @rules_to_apply = ();
local $failure = 0;
- local %rules_applied = ();
local $updated = 0;
+ # ???!!!
print "======= Need to update make_preview_continuous for target files\n";
$quell_uptodate_msgs = 1;
@@ -3723,7 +4004,7 @@
);
# Note that we don't get the previewer process number from the program
# that starts it; that might only be a script to get things set up and the
- # actual previewer could be (and sometimes IS) another process.
+ # actual previewer could be (and sometimes **is**) another process.
if ( ($view_file ne '') && (-e $view_file) && !$new_viewer_always ) {
# Is a viewer already running?
@@ -3745,7 +4026,8 @@
for (my $first_time = 1; 1; $first_time = 0 ) {
my %rules_to_watch = array_to_hash( &rdb_accessible );
-
+
+ &init_timing1;
$updated = 0;
$failure = 0;
$failure_msg = '';
@@ -3801,24 +4083,16 @@
$$Pneed_to_get_viewer_process = 1;
} # end analyze result of trying to run viewer
} # end start viewer
+
+ # Updated rule collection, and the set of rules whose source files
+ # the WAIT loop examines for changes:
+ &rdb_set_rule_net;
+ %rules_to_watch = array_to_hash( &rdb_accessible );
+
if ( $failure > 0 ) {
if ( !$failure_msg ) {
$failure_msg = 'Failure to make the files correctly';
}
- &rdb_set_rule_net;
- %rules_to_watch = array_to_hash( &rdb_accessible );
-
- # There will be files changed during the run that are irrelevant.
- # We need to wait for the user to change the files.
-
- # So set the GENERATED files from *latex as up-to-date:
- rdb_for_some( [keys %current_primaries], \&rdb_update_gen_files );
- # And don't watch for changes for post_primary rules (ps and pdf
- # from dvi, etc haven't been run after an error in *latex, so
- # are out-of-date by filetime criterion, but they should not be run
- # until after another *latex run:
- foreach (@post_primary) { delete $rules_to_watch{$_}; }
-
$failure_msg =~ s/\s*$//; #Remove trailing space
warn "$My_name: $failure_msg\n",
" ==> You will need to change a source file before I do another run <==\n";
@@ -3825,6 +4099,27 @@
if ($failure_cmd) {
Run_subst( $failure_cmd );
}
+
+ # In the WAIT loop, we will test for changes in source files
+ # that trigger a remake. Special considerations after an error:
+ # 1. State of **user** source files for a rule is that before
+ # the last run of the rule. Any changes since trigger
+ # rerun.
+ # 2. .aux files etc may have changed during an error run of a
+ # rule, but no further runs were made to get them
+ # stabilized. So they can have changed since start of
+ # run. To avoid triggering an incorrect remake, rdb_make
+ # has updated generated source files to their current state
+ # after the whole make. User changes (e.g., deletion of aux
+ # file) are still able to trigger a remake.
+ # 3. Post_primary rules may not have been run (e.g., to make ps
+ # and pdf from dvi). Depending on the criterion for rerun,
+ # they may be out-of-date by some criterion, but they should
+ # not be run until after another *latex run. Such rules
+ # must be excluded from the rules whose source files the
+ # WAIT loop scans for changes.
+ # Set this up as follows:
+ foreach (@post_primary) { delete $rules_to_watch{$_}; }
}
else {
if ( ($#primary_warning_summary > -1) && $warning_cmd ) {
@@ -3839,7 +4134,6 @@
}
rdb_show_rule_errors();
if ($rules_list) { rdb_list(); }
- if ($show_time && ! $first_time) { show_timing(); }
if ( $dependents_list && ($updated || $failure) ) {
if ( open( my $deps_handle, ">$deps_file" ) ) {
deps_list($deps_handle);
@@ -3849,10 +4143,10 @@
warn "Cannot open '$deps_file' for output of dependency information\n";
}
}
+ if ($show_time) { &show_timing1; };
+
# Now wait for a file to change...
- # &rdb_cache_generated;
- &rdb_set_rule_net;
# During waiting for file changes, handle ctrl/C and ctrl/break here,
# rather than letting system handle them by terminating script (and
# code in the following command line to work: any script that calls
@@ -3867,16 +4161,18 @@
WAIT: while (1) {
sleep( $sleep_time );
if ($have_break) { last WAIT; }
- if ( rdb_user_changes(keys %rules_to_watch) ) {
+ my %changes = ();
+ if ( rdb_remake_needed(\%changes, 1, keys %rules_to_watch) ) {
if (!$silent) {
- print "$My_name: Need to remake files.\n";
- &rdb_diagnose_changes( ' ' );
+ print "\n$My_name: Need to remake files.\n";
+ &rdb_diagnose_changes2( \%changes, "", 1 );
+ print "\n";
}
last WAIT;
}
# Don't count waiting time in processing:
$processing_time1 = processing_time();
- # Does this do this job????
+ # Does this do this job????!!!
local $new_files = 0;
rdb_for_some( [keys %current_primaries], sub{ $new_files += &rdb_find_new_files } );
if ($new_files > 0) {
@@ -4133,7 +4429,7 @@
" Latexmk_options:\n",
" -aux-directory=dir or -auxdir=dir \n",
" - set name of directory for auxiliary files (aux, log)\n",
- " - Currently this only works with MiKTeX\n",
+ " - See also the -emulate-aux-dir option\n",
" -bibtex - use bibtex when needed (default)\n",
" -bibtex- - never use bibtex\n",
" -bibtex-cond - use bibtex when needed, but only if the bib file exists\n",
@@ -4164,11 +4460,16 @@
" -dF <filter> - Filter to apply to dvi file\n",
" -dir-report - Before processing a tex file, report aux and out dir settings\n",
" -dir-report- - Before processing a tex file, do not report aux and out dir settings\n",
- " -dvi - generate dvi\n",
- " -dvi- - turn off required dvi\n",
+ " -dvi - generate dvi by latex\n",
+ " -dvilua - generate dvi by dvilualatex\n",
+ " -dvi- - turn off required dvi\n",
+ " -dvilualatex=<program> - set program used for dvilualatex.\n",
+ " (replace '<program>' by the program name)\n",
" -e <code> - Execute specified Perl code (as part of latexmk start-up\n",
" code)\n",
" -emulate-aux-dir - emulate -aux-directory option for *latex\n",
+ " This enables the -aux-directory option to work properly with TeX\n",
+ " Live as well as MiKTeX\n",
" -emulate-aux-dir- - use -aux-directory option with *latex\n",
" -f - force continued processing past errors\n",
" -f- - turn off forced continuing processing past errors\n",
@@ -4218,19 +4519,19 @@
" - if FORMAT is pdf, turn on pdf output, turn off others\n",
" - otherwise error\n",
" -pdf - generate pdf by pdflatex\n",
- " -pdfdvi - generate pdf by dvipdf\n",
+ " -pdfdvi - generate pdf by latex (or dvilualatex) + dvipdf\n",
+ " -- see -dvilua for how to get dvilualatex used\n",
" -pdflatex=<program> - set program used for pdflatex.\n",
" (replace '<program>' by the program name)\n",
" -pdflualatex=<program> - set program used for lualatex.\n",
" (replace '<program>' by the program name)\n",
- " -pdfps - generate pdf by ps2pdf\n",
+ " -pdfps - generate pdf by latex (or dvilualatex) + dvips + ps2pdf\n",
+ " -- see -dvilua for how to get dvilualatex used\n",
" -pdflua - generate pdf by lualatex\n",
" -pdfxe - generate pdf by xelatex\n",
" -pdfxelatex=<program> - set program used for xelatex.\n",
" (replace '<program>' by the program name)\n",
" -pdf- - turn off pdf\n",
- " -ps - generate postscript\n",
- " -ps- - turn off postscript\n",
" -pF <filter> - Filter to apply to postscript file\n",
" -p - print document after generating postscript.\n",
" (Can also .dvi or .pdf files -- see documentation)\n",
@@ -4239,6 +4540,8 @@
" -print=dvi - when file is to be printed, print the dvi file\n",
" -print=ps - when file is to be printed, print the ps file (default)\n",
" -print=pdf - when file is to be printed, print the pdf file\n",
+ " -ps - generate postscript\n",
+ " -ps- - turn off postscript\n",
" -pv - preview document. (Side effect turn off continuous preview)\n",
" -pv- - turn off preview mode\n",
" -pvc - preview document and continuously update. (This also turns\n",
@@ -4279,6 +4582,8 @@
" -view=ps - viewer is for ps\n",
" -view=pdf - viewer is for pdf\n",
" -Werror - treat warnings from called programs as errors\n",
+ " -xdv - generate xdv by xelatex\n",
+ " -xdv- - turn off required xdv\n",
" -xelatex - use xelatex for processing files to pdf\n",
" and turn dvi/ps modes off\n",
"\n",
@@ -4303,6 +4608,7 @@
print "Commands used by $my_name:\n",
" To run latex, I use \"$latex\"\n",
" To run pdflatex, I use \"$pdflatex\"\n",
+ " To run dvilualatex, I use \"$dvilualatex\"\n",
" To run lualatex, I use \"$lualatex\"\n",
" To run xelatex, I use \"$xelatex\"\n",
" To run biber, I use \"$biber\"\n",
@@ -4359,6 +4665,9 @@
# 10: only error is missing \citation commands.
# 11: Malformed bcf file (normally due to error in pdflatex run)
# Side effect: add source files @biber_source
+ # N.B. @biber_source is already initialized by caller to contain
+ # whatever source files (currently .bcf) it already knows about.
+ # So do **not** initialize it here.
my $base = $_[0];
my $Pbiber_source = $_[1];
my $blg_name = "$base.blg";
@@ -4377,6 +4686,7 @@
my $control_file_missing = 0;
my $control_file_malformed = 0;
my %remote = (); # List of extensions of remote files
+ my @not_found = (); # Files, normally .bib files, not found.
while (<$blg_file>) {
$_ = utf8_to_mine($_);
if (/> WARN /) {
@@ -4389,12 +4699,12 @@
if ( /> (FATAL|ERROR) - Cannot find file '([^']+)'/ #'
|| /> (FATAL|ERROR) - Cannot find '([^']+)'/ ) { #'
$not_found_count++;
- push @$Pbiber_source, $2;
+ push @not_found, $2;
}
elsif ( /> (FATAL|ERROR) - Cannot find control file '([^']+)'/ ) { #'
$not_found_count++;
$control_file_missing = 1;
- push @$Pbiber_source, $2;
+ push @not_found, $2;
}
elsif ( /> ERROR - .*\.bcf is malformed/ ) {
# Special treatment: Malformed .bcf file commonly results from error
@@ -4429,7 +4739,7 @@
# be misleading, since it will normally have been deleted by
# biber itself.
}
- elsif ( (defined $Pbiber_source) && (-e $file) ) {
+ elsif ( -e $file ) {
# Note that biber log file gives full path to file. (No search is
# needed to find it.) The file must have existed when biber was
# run. If it doesn't exist now, a few moments later, it must
@@ -4448,12 +4758,12 @@
}
}
close $blg_file;
+ @$Pbiber_source = uniqs( @$Pbiber_source );
+ @not_found = uniqs( @not_found );
+ push @$Pbiber_source, @not_found;
+
if ($control_file_malformed){return 11;}
- my @not_found = &find_file_list1( $Pbiber_source, $Pbiber_source,
- '', \@BIBINPUTS );
- @$Pbiber_source = uniqs( @$Pbiber_source );
-
if ( ($#not_found < 0) && ($#$Pbiber_source >= 0) ) {
print "$My_name: Found biber source file(s) [@$Pbiber_source]\n"
unless $silent;
@@ -4511,20 +4821,16 @@
# There is also another problem: Depending on the exact
# specification of the aux dir, bibtex may refuse to write to the
# aux dir, for security reasons.
- my $cwd = good_cwd();
- foreach ( 'BIBINPUTS', 'BSTINPUTS' ) {
- if ( exists $ENV{$_} ) {
- $ENV{$_} = $cwd.$search_path_separator.$ENV{$_};
- }
- else {
- $ENV{$_} = $cwd.$search_path_separator;
- }
- }
+ # This prevents changing the default $bibtex_fudge to off,
+ # without breaking backward compatibility. (???!!! Perhaps I
+ # should change the default, and give a special message if the
+ # security issue of not being able to write arises.)
+
+ path_fudge( 'BIBINPUTS', 'BSTINPUTS' );
pushd( $path );
if (!$silent) {
print "$My_name: Change directory to '$path'.\n",
- "To assist finding of files in document\n",
- "directory, I set\n",
+ "To assist finding of files in document directory, I set\n",
" BIBINPUTS='$ENV{BIBINPUTS}'\n",
" BSTINPUTS='$ENV{BSTINPUTS}'.\n";
}
@@ -4764,8 +5070,10 @@
# reported by epstopdf et al.
# 5 = Had a missing file line. Now the file exists.
# 6 = File was written during run. (Overrides 5)
-# 7 = File was created during run to be read in. (Overrides 5 and 6)
-# (e.g., by epstopdf)
+# 7 = File was created during run to be read in, as a conversion
+# from some other file (e.g., by epstopdf package).
+# (Overrides 5 and 6)
+# 8 = File was rewritten during run to be read in. (Overrides 5 and 6)
# Treat the following specially, since they have special rules
# @bbl_files to list of .bbl files.
# %idx_files to map from .idx files to .ind files.
@@ -4791,9 +5099,9 @@
# Input globals: $primary_out, $fls_file_analyzed
#
-my ($log_name, $PAlines, $PHinfo) = @_;
+ my ($log_name, $PAlines, $PHinfo) = @_;
-# Give a quick way of looking up custom-dependency extensions
+ # Give a quick way of looking up custom-dependency extensions
my %cusdep_from = ();
my %cusdep_to = ();
foreach ( @cus_dep_list ) {
@@ -4812,6 +5120,11 @@
$bad_character = 0;
$bad_citation = 0;
+ # ???!!! I don't know whether I will actually use these
+ our @multiply_defined_references = ();
+ our @undefined_citations = ();
+ our @undefined_references = ();
+
print "$My_name: Examining '$log_name'\n"
if not $silent;
@@ -4902,7 +5215,6 @@
}
# Block has ended.
if ($block_type eq 'conversion') {
-#print "=== $delegated_source -> $delegated_output\n";
$new_conversions{$delegated_source} = $delegated_output;
}
$current_pkg = $block_type
@@ -4910,31 +5222,39 @@
# Then process current line
}
+ # ???!!! Use the extra items.
# Check for changed references, bad references and bad citations:
if (/Rerun to get/) {
print "$My_name: References changed.\n" if ! $log_silent;
$reference_changed = 1;
}
- if (/^LaTeX Warning: (Reference[^\001]*undefined on input line .*)\./) {
+# if (/^LaTeX Warning: (Reference[^\001]*undefined on input line .*)\./) {
+ if (/^LaTeX Warning: (Reference `([^']+)' on page .+ undefined on input line .*)\./) {
push @warning_list, $1;
+ push @undefined_references, $2;
$bad_reference++;
}
- elsif (/^LaTeX Warning: (Label [^\001]* multiply defined.*)\./) {
+ elsif (/^LaTeX Warning: (Label `([^']+)' multiply defined.*)\./) {
push @warning_list, $1;
+ push @multiply_defined_references, $2;
$mult_defined++;
}
- elsif (/^LaTeX Warning: (Citation[^\001]*undefined on input line .*)\./) {
+ elsif (/^LaTeX Warning: (Citation `([^']+)' on page .* undefined on input line .*)\./) {
push @warning_list, $1;
+ push @undefined_citations, $2;
$bad_citation++;
}
elsif (/^Package natbib Warning: (Citation[^\001]*undefined on input line .*)\./) {
push @warning_list, $1;
+ push @undefined_citations, $2;
$bad_citation++;
}
elsif ( /^Missing character: There is no /
|| /^! Package inputenc Error: Unicode character /
|| /^! Bad character code /
+ || /^! LaTeX Error: Unicode character /
) {
+ push @warning_list, $_;
$bad_character++;
}
elsif ( /^Document Class: / ) {
@@ -5046,19 +5366,18 @@
next LINE;
}
- elsif ( /^No file (.*?\.bbl)./ ) {
- # Filename is always relative to aux_dir, given standard security
- # settings in TeXLive.
- my $bbl_file = normalize_force_directory( $aux_dir1, $1 );
- warn "$My_name: Missing bbl file '$bbl_file' in following:\n $_\n";
- $dependents{$bbl_file} = 0;
- push @bbl_files, $bbl_file;
- next LINE;
- }
foreach my $pattern (@file_not_found) {
if ( /$pattern/ ) {
my $file = clean_filename($1);
- warn "$My_name: Missing input file '$file' (or dependence on it) from following:\n '$_'\n"
+ if ( $file =~ /\.bbl$/ ) {
+ # Note that bbl's filename is always relative to aux_dir.
+ my $bbl_file = normalize_force_directory( $aux_dir1, $file );
+ warn "$My_name: Missing bbl file '$bbl_file' in following:\n $_\n";
+ $dependents{$bbl_file} = 0;
+ push @bbl_files, $bbl_file;
+ next LINE;
+ }
+ warn "$My_name: Missing input file '$file' (or dependence on it) from following:\n $_\n"
unless $silent;
$dependents{normalize_filename($file, @pwd_log)} = 0;
my $file1 = $file;
@@ -5078,6 +5397,13 @@
next LINE;
}
}
+ foreach my $pattern (@bad_warnings) {
+ if ( /$pattern/ ) {
+ $log_info{bad_warning} = 1;
+ warn "$My_name: Important warning:\n $_\n"
+ unless $silent;
+ }
+ }
if ( (! $fls_file_analyzed)
&& /^File: (.+) Graphic file \(type / ) {
# First line of message from includegraphics/x
@@ -5459,10 +5785,6 @@
my ($file, $PAlines, $PHinfo) = @_;
- # Essential to use byte semantics, since (pdf)latex & lualatex
- # wrap by bytes, not characters
- use bytes;
-
# Where lines are wrapped at. We'll sometimes override.
local $log_wrap = $log_wrap;
@@ -5480,8 +5802,12 @@
# luatex: UTF-8 but with wrapping at APPROXIMATELY
# $log_wrap bytes. Rest as pdftex
# xetex: UTF-8 with wrapping at $log_wrap codepoints.
- # So start reading file as bytes; first line gives which program,
- # and for xetex we switch to reading file as UTF-8.
+ # So we read file as bytes
+ # first line gives which program was used and hence whether to wrap
+ # according to byte or codepoint count.
+ # wrapping is always performed on the encoded byte strings, but the
+ # place to wrap is determined according to the length in bytes or
+ # in codepoints, as needed.
print "$My_name: Getting log file '$file'\n";
open( my $fh, '<', $file )
or return 0;
@@ -5637,7 +5963,6 @@
my $cwd = good_cwd();
if ( ! open($fls_file, "<", $fls_name) ) {
-# if ( ! open($fls_file, "<:encoding(UTF-8)", $fls_name) ) {
return 1;
}
@@ -5650,6 +5975,9 @@
my $pwd_subst = undef; # Initial string for pwd that is to be removed to
# make relative paths, when possible. It must end
# in '/', if defined.
+ my $line_no = 0;
+ my $coding_errors = 0;
+ my $coding_errors_max_print = 2;
for ( <$fls_file> ) {
# Remove trailing CR and LF. Thus we get correct behavior when an fls file
# is produced by MS-Windows program (e.g., in MiKTeX) with CRLF line ends,
@@ -5658,13 +5986,37 @@
# And convert '\'
s/\r?\n$//;
s[\\][/]g;
- if (($^O eq 'MSWin32') && /PWD/ && is_valid_utf8($_) ) {
- # TeXLive produces PWD in CS_system not UTF-8.
- # ???? Later get tex_distribution before analyzing fls file, so do better test.
- print "PWD line not in UTF-8\n";
- # Assume in CS_system, no change needed.
+ $line_no++;
+ if ($no_CP_conversions) {
+ # Assume same byte representations for filenames in .fls file as
+ # for file system calls. No conversions needed.
}
- else { $_ = utf8_to_mine($_); }
+ else {
+ # Deal with MS-Win issues when system CP isn't UTF-8
+ if ( ($^O eq 'MSWin32') && /PWD/ && ! is_valid_utf8($_) ) {
+ # TeXLive on MSWin produces PWD in CS_system not UTF-8.
+ # ???? Later get tex_distribution before analyzing fls file, so do better test.
+ print "PWD line not in UTF-8. This is normal for TeXLive. I will handle it.\n";
+ # Assume in CS_system, no change needed.
+ }
+ elsif ( ! is_valid_utf8($_) ) {
+ $coding_errors++;
+ warn "$My_name: In '$fls_name' =====Line $line_no is not in expected UTF-8 coding:\n$_\n"
+ unless ($coding_errors > $coding_errors_max_print);
+ }
+ else {
+ my $orig = $_;
+ $_ = utf8_to_mine_errors($_);
+ if ($@) {
+ $coding_errors++;
+ if (!$silent) {
+ warn "$@in conversion UTF-8 to system code page of line $line_no of $fls_name\n",
+ "$orig\n"
+ unless ($coding_errors > $coding_errors_max_print);
+ }
+ }
+ }
+ } # End of fudge on MS-Win code page.
if (/^\s*PWD\s+(.*)$/) {
my $cwd_fls = $1;
$pwd_subst = $$Ppwd_latex = $cwd_fls;
@@ -5730,6 +6082,12 @@
}
}
close( $fls_file );
+ if ($coding_errors) {
+ warn "$My_name.$fls_name. There were $coding_errors line(s) with character coding\n",
+ " errors: Characters not available in system code page and/or non-UTF-8 in\n",
+ " file when expected. Dependency information may be incomplete.\n";
+ warn "The first few error lines are listed above\n";
+ }
return 0;
} #END parse_fls
@@ -5858,11 +6216,12 @@
#************************************************************
sub parse_aux {
- #Usage: parse_aux( $aux_file, \@new_bib_files, \@new_aux_files, \@new_bst_files )
+ # Usage: parse_aux( $aux_file, \@new_bib_files, \@new_aux_files, \@new_bst_files )
# Parse aux_file (recursively) for bib files, and bst files.
# If can't open aux file, then
# Return 0 and leave @new_bib_files empty
- # Else set @new_bib_files from information in the aux files
+ # Else set @new_bib_files and @new_bst_files from information in the
+ # aux files
# And:
# Return 1 if no problems
# Return 2 with @new_bib_files empty if there are no \bibdata
@@ -5874,47 +6233,65 @@
local $Pbib_files = $_[1];
local $Paux_files = $_[2];
local $Pbst_files = $_[3];
-
+ # Default return values
@$Pbib_files = ();
@$Pbst_files = ();
@$Paux_files = ();
+
+ # Map file specs (in \bibdata and \bibstyle lines) to actual filenames:
+ local %bib_files = ();
+ local %bst_files = ();
+
+ # Flag bad \bibdata lines in aux files:
+ local @bad_bib_data = ( );
+ # This array contains the offending lines, with trailing space (and
+ # line terminator) removed. (Currently detected problems: Arguments
+ # containing spaces, which bibtex refuses to accept.)
+
parse_aux1( $aux_file );
if ($#{$Paux_files} < 0) {
- return 0;
+ # No aux files found/read.
+ return 0;
}
- @$Pbib_files = uniqs( @$Pbib_files );
- @$Pbst_files = uniqs( @$Pbst_files );
+ my @not_found_bib = ();
+ my @not_found_bst = ();
+ find_files( \%bib_files, 'bib', 'bib', $Pbib_files, \@not_found_bib );
+ find_files( \%bst_files, 'bst', 'bst', $Pbst_files, \@not_found_bst );
+ # ???!!! Should only get one bst file, of course.
- if ( $#{$Pbib_files} == -1 ) {
- print "$My_name: No .bib files listed in .aux file '$aux_file' \n",
+ if ( $#{$Pbib_files} + $#bad_bib_data == -2 ) {
+ #
+ print "$My_name: No .bib files listed in .aux file '$aux_file'\n";
return 2;
}
- my @not_found = &find_file_list1( $Pbib_files, $Pbib_files,
- '.bib', \@BIBINPUTS );
- @$Pbib_files = uniqs( @$Pbib_files );
- &find_file_list1( $Pbst_files, $Pbst_files, '.bst' );
- @$Pbst_files = uniqs( @$Pbst_files );
- my @bad_bib = ();
- foreach ( @$Pbib_files ) {
- if ( /\s/ ) { push @bad_bib, $_; }
+
+ show_array( "$My_name: Found bibliography file(s):", @$Pbib_files )
+ unless $silent;
+ if (@not_found_bib) {
+ show_array(
+ "Bib file(s) not found in search path:",
+ @not_found_bib );
}
- if ($#bad_bib >= 0) {
- warn "$My_name: White space in an argument list for \\bibliography.\n",
- " which is not allowed by bibtex. Bad arguments:\n";
- foreach (@bad_bib ) { warn " '$_'\n"; }
- return 3;
+
+ if (@not_found_bst) {
+ show_array( "$My_name: Bst file not found in search path:", @not_found_bst);
}
- if ( $#not_found < 0) {
- print "$My_name: Found bibliography file(s) [@$Pbib_files]\n"
- unless $silent;
+
+
+ if ($#bad_bib_data >= 0) {
+ warn
+ "$My_name: White space in the argument for \\bibdata line(s) in an .aux file.\n",
+ " This is caused by the combination of spaces in a \\bibliography line in\n",
+ " a tex source file and the use of a pre-2018 version of *latex.\n",
+ " The spaces will give a fatal error when bibtex is used. Bad lines:\n";
+ foreach (@bad_bib_data ) { s/\s$//; warn " '$_'\n"; }
+ return 3;
}
- else {
- warn "$My_name: Failed to find one or more bibliography files:\n";
- foreach (@not_found) { warn " '$_'\n"; }
+ if (@not_found_bib) {
if ($force_mode) {
- warn "==== Force_mode is on, so I will continue. ",
- "But there may be problems ===\n";
+ warn "$My_name: Failed to find one or more bibliography files in search path.\n";
+ warn "====BUT force_mode is on, so I will continue. There may be problems ===\n";
}
return 3;
}
@@ -5921,6 +6298,8 @@
return 1;
} #END parse_aux
+
+
#************************************************************
sub parse_aux1
@@ -5942,24 +6321,43 @@
push @$Paux_files, $aux_file;
AUX_LINE:
while (<$aux_fh>) {
- $_ = utf8_to_mine($_);
- if ( /^\\bibdata\{(.*)\}/ ) {
- # \\bibdata{comma_separated_list_of_bib_file_names}
- # These are normally without the '.bib' extension.
- push @$Pbib_files, split /,/, $1;
- }
- elsif ( /^\\bibstyle\{(.*)\}/ ) {
- # \\bibstyle{bst_file_name}
- # Normally without the '.bst' extension.
- push @$Pbst_files, split /,/, $1;
- }
- elsif ( /^\\\@input\{(.*)\}/ ) {
- # \\@input{next_aux_file_name}
- &parse_aux1( $aux_dir1.$1 );
- }
- else {
- run_hooks( 'aux_hooks' );
- }
+ $_ = utf8_to_mine($_);
+ s/\s$//;
+ if ( /^\\bibdata\{(.*)\}/ ) {
+ # \\bibdata{comma_separated_list_of_bib_file_names}
+ # This results from a \bibliography command in the document.
+ my $arg = $1;
+ if ($arg =~ /\s/) {
+ # Bibtex will choke when the argument to \bibdata contains
+ # spaces, so flag the error here.
+ # N.B. *latex in TeX Live 2018 and later removes spaces from
+ # the argument to \bibliography before placing it as the
+ # argument to \bibdata in an aux file, so this error only
+ # appears if a *latex from TeX Live 2017 or earlier is used.
+ # Current MiKTeX's *latex (2022) also removes the space.
+ push @bad_bib_data, $_;
+ }
+ else {
+ foreach ( split /,/, $arg ) {
+ # bib files are always required to have an extension .bib,
+ # so provide the extension:
+ if ( ! /\.bib$/ ) { $_ .= '.bib'; }
+ $bib_files{$_} = '';
+ }
+ }
+ }
+ elsif ( /^\\bibstyle\{(.*)\}/ ) {
+ # \\bibstyle{bst_file_name}
+ # Normally without the '.bst' extension.
+ $bst_files{$1} = '';
+ }
+ elsif ( /^\\\@input\{(.*)\}/ ) {
+ # \\@input{next_aux_file_name}
+ &parse_aux1( $aux_dir1.$1 );
+ }
+ else {
+ run_hooks( 'aux_hooks' );
+ }
}
close($aux_fh);
return 1;
@@ -6108,10 +6506,6 @@
#
local ($in_name, $inhibit_output_switch) = @_;
- # We'll have conversions between encodings, and pattern,
- # so byte semantics will be safest.
- use bytes;
-
my $in_handle;
if ( ! -e $in_name ) {
# Note: This is NOT an error condition, since the fdb_latexmk file
@@ -6130,9 +6524,11 @@
# 0: outside rule;
# 1: in source section;
# 2: in generated file section;
+ # 3: in rewritten-before-read file section;
# 10: ignored rule.
my $rule = '';
local $run_time = 0;
+ local $last_result = -1;
local $source = '';
local $dest = '';
my $base = '';
@@ -6152,7 +6548,7 @@
return 1;
}
if ( $1 ne $fdb_ver) {
- warn "$My_name: File-database '$in_name' is of incompatible version, $1 v. $fdb_ver\n";
+ warn "$My_name: File-database '$in_name' is of incompatible version, $1 v. current version $fdb_ver\n";
return 1;
}
$state = 0;
@@ -6167,12 +6563,14 @@
$run_time = $check_time = 0;
$source = $dest = $base = '';
$old_actives{$rule} = 1;
- if ( $tail =~ /^\s*(\S+)\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+(\S+)\s*$/ ) {
+ $last_result = -1;
+ if ( $tail =~ /^\s*(\S+)\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+(\S+)\s+(\S+)/ ) {
$run_time = $1;
$source = $2;
$dest = $3;
$base = $4;
$check_time = $5;
+ $last_result = $6;
}
else {
# Line is not in correct format
@@ -6184,7 +6582,9 @@
next LINE;
}
if ( rdb_rule_exists( $rule ) ) {
- rdb_one_rule( $rule, \&rdb_read_set_rule );
+ # We need to set rule data from contents of fdb_latex file,
+ # but we'll do that later, so that it can be done for both
+ # existing and newly created rules.
}
elsif ($rule =~ /^cusdep\s+(\S+)\s+(\S+)\s+(.+)$/ ) {
# create custom dependency
@@ -6267,14 +6667,18 @@
$state = 10;
next LINE;
}
+ if ( rdb_rule_exists( $rule ) ) {
+ rdb_one_rule( $rule, \&rdb_read_set_rule );
+ }
$new_source = $new_sources{$rule} = {};
$state = 1; #Reading a section, source part
}
- elsif ( ($state <=0) || ($state >= 3) ) {
+ elsif ( ($state <=0) || ($state >= 4) ) {
next LINE;
}
elsif ( /^\(source\)/ ) { $state = 1; next LINE; }
elsif ( /^\(generated\)/ ) { $state = 2; next LINE; }
+ elsif ( /^\(rewritten before read\)/ ) { $state = 3; next LINE; }
elsif ( ($state == 1) && /^\"([^\"]*)\"\s+(\S+)\s+(\S+)\s+(\S+)\s+\"([^\"]*)\"/ ) {
# Source file line
my $file = $1;
@@ -6304,6 +6708,10 @@
my $file = $1;
rdb_one_rule( $rule, sub{ rdb_add_generated($file); } );
}
+ elsif ( ($state == 3) && /^\"([^\"]*)\"/ ) {
+ my $file = $1;
+ rdb_one_rule( $rule, sub{ rdb_add_rewritten_before_read($file); } );
+ }
else {
warn "$My_name: In file-database '$in_name' ",
"line $. is of wrong format:\n '$_'\n";
@@ -6326,9 +6734,11 @@
# Rule context assumed. Implicit passing of $dest, $run_time, $check_time,
# $in_name used as local variables in calling routine rdb_read.
#
- if ($$Ptest_kind == 3) { $$Ptest_kind = 1; }
+ $$Pno_history = 0;
$$Prun_time = $run_time;
$$Pcheck_time = $check_time;
+ $$Plast_result = $last_result;
+
# Deal with possibility that destination file in fdb_latexmk from
# run differs from what is currently set. Often that just reflects a
# difference between the end result of the last run and what the user
@@ -6389,8 +6799,6 @@
# Returns 1 on success, 0 if file couldn't be opened.
local $out_name = $_[0];
- use bytes;
-
local $out_handle;
if ( ($out_name eq "") || ($out_name eq "-") ) {
# Open STDOUT
@@ -6417,16 +6825,20 @@
{
return;
}
- fprint8( $out_handle, "[\"$rule\"] $$Prun_time \"$$Psource\" \"$$Pdest\" \"$$Pbase\" $$Pcheck_time\n" );
+ fprint8( $out_handle, "[\"$rule\"] $$Prun_time \"$$Psource\" \"$$Pdest\" \"$$Pbase\" $$Pcheck_time $$Plast_result\n" );
rdb_do_files(
sub { my $from_rule = $from_rules{$file} || '';
fprint8( $out_handle, " \"$file\" $$Ptime $$Psize $$Pmd5 \"$from_rule\"\n" );
}
- );
+ );
fprint8( $out_handle, " (generated)\n" );
foreach (sort keys %$PHdest) {
fprint8( $out_handle, " \"$_\"\n" );
}
+ fprint8( $out_handle, " (rewritten before read)\n" );
+ foreach (sort keys %$PHrewritten_before_read) {
+ fprint8( $out_handle, " \"$_\"\n" );
+ }
}
);
close $out_handle;
@@ -6442,6 +6854,7 @@
# Set its dependents etc, using information from log, aux, and fls files.
# Use fls file only if $recorder is set, and the fls file was generated
# on this run.
+ # Return:
# N.B. A complication which we try and handle in determining
# dependent files is that there may be aliasing of file names,
@@ -6563,7 +6976,7 @@
local %source_fls = (); # Lists source files found in fls file
local %first_read_after_write = (); # Lists source files that are only read
# after being written (so are not true
- # source files.
+ # source files).
local $primary_out = $$Pdest; # output file (dvi or pdf)
local %conversions = (); # *latex-performed conversions.
# Maps output file created and read by *latex
@@ -6872,11 +7285,9 @@
if ($diagnostics);
if ( exists $first_read_after_write{$new_source} ) {
if ( dep_at_start($new_source) ) {
- #print "--- READ ONLY AFTER WRITE OF '$new_source'\n";
- $dependents{$new_source} = 7;
+ $dependents{$new_source} = 8;
}
else {
- #print "--- READ ONLY AFTER CREATE OF '$new_source'\n";
$dependents{$new_source} = 6;
}
}
@@ -6897,6 +7308,7 @@
}
elsif ( $dependents{$new_source} == 7 ) {
# File was result of conversion by *latex.
+ # start of run. S
my $cnv_source = $conversions{$new_source};
rdb_ensure_file( $rule, $new_source );
# if ($cnv_source && ($cnv_source !~ /\"/ ) ) {
@@ -6910,6 +7322,14 @@
# do not require a rerun:
rdb_one_file( $new_source, sub{ $$Pcorrect_after_primary = 1; } );
}
+ elsif ( $dependents{$new_source} == 8 ) {
+ print "================= REWRITE '$new_source'\n";
+ # File was read only after being written
+ # and the file existed at the beginning of the run
+ rdb_ensure_file( $rule, $new_source );
+ rdb_add_generated( $new_source );
+ rdb_add_rewritten_before_read( $new_source );
+ }
else {
# But we don't need special precautions for ordinary user files
# (or for files that are generated outside of latex/pdflatex).
@@ -6957,7 +7377,7 @@
}
}
my @files_not_needed = ();
- foreach (keys %$PHsource) {
+ foreach (keys %$PHsource) {
if ( ! exists $dependents{$_} ) {
print "Removing no-longer-needed dependent '$_' from rule '$rule'\n"
if $diagnostics;
@@ -6966,7 +7386,8 @@
}
rdb_remove_files( $rule, @files_not_needed );
- return ($missing_dirs, [@missing_subdirs] );
+ return ($missing_dirs, [@missing_subdirs],
+ ( $log_info{bad_warning} ? 1 : 0 ) );
} # END rdb_set_latex_deps
@@ -6976,7 +7397,9 @@
# Usage: switch_output( primary_rule, actual_ext, intended_ext )
# Rearrange rules to deal with changed extension of output file of
# the specified primary rule (one of *latex).
- # Return 0 on success, non-zero error code on failure
+ # The switching only works if no request was made for dvi, ps or xdv
+ # files, but only if the requested file was pdf.
+ # Return 0 on success, non-zero error code on failure.
my ( $rule, $actual_ext, $intended_ext ) = @_;
if ( $actual_ext eq $intended_ext ) { return 0; }
@@ -6987,6 +7410,12 @@
return 1;
}
+ # Turn off all pdf producers and all primaries (pdf producing or not).
+ # Then reactivate what we need: current rule and whatever else is needed
+ # to produce a pdf file.
+ # Given that we get here if the rule is not producing the intended kind
+ # of output file, it's best to turn off all primaries, so as to make the
+ # primary in use unambiguous.
rdb_deactivate_derequest( 'dvipdf', 'pspdf', 'xdvipdfmx', keys %possible_primaries );
rdb_activate_request( $rule );
@@ -7178,7 +7607,7 @@
}
if ( exists $ENV{TEXINPUTS} ) {
foreach my $searchpath (split $search_path_separator, $ENV{TEXINPUTS}) {
- my $file = File::Spec->catfile($searchpath,$_[0]);
+ my $file = catfile($searchpath,$_[0]);
my $test = "$file.$_[1]";
if ( -e $test ) {
return $file;
@@ -7298,7 +7727,8 @@
my $new_dest = "$file.$try_ext";
&Run_subst( "$make $quote$new_dest$quote" );
if ( -e $new_dest ) {
- print "SUCCESS in making '$new_dest'\n";
+ print "SUCCESS in making '$new_dest'\n",
+ "I'll ensure '$rule' is rerun.\n";
# Put file in rule, without a from_rule, but
# set its state as non-existent, to correspond
# to file's state before the file was made
@@ -7352,23 +7782,21 @@
if ($pdf_mode) {push @dest_exts, '.pdf';}
if ($dvi_mode) {push @dest_exts, '.dvi';}
if ($postscript_mode) {push @dest_exts, '.ps';}
+
my %source = ( $texfile_name => 1 );
- my @generated = ();
my @accessible_all = &rdb_accessible;
rdb_for_some(
\@accessible_all,
- sub{ push @generated, keys %$PHdest; },
+ sub{},
sub{ $source{$file} = 1; }
);
- foreach (keys %generated_exts) {
- (my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/${aux_dir1}${root_filename}/;
- push @generated, $name;
- }
- show_array( "Generated:", @generated ) if $diagnostics;
- foreach (@generated) {
+ foreach (keys %from_rules) {
+ # Remove known generated files from list of source files.
delete $source{$_};
}
- show_array( "Sources:", keys %source ) if $diagnostics;
+
+ show_array( "Sources:", sort keys %source ) if $diagnostics;
+
foreach my $ext (@dest_exts) {
# Don't insert name of deps file in targets.
# The previous behavior of inserting the name of the deps file
@@ -7412,7 +7840,7 @@
foreach (@int_cmd) {
if ( !defined($_) ) { $_='undef';}
}
- print " [$rule]: '$$Pcmd_type' '$$Pext_cmd' '@int_cmd' $$Ptest_kind ",
+ print " [$rule]: '$$Pcmd_type' '$$Pext_cmd' '@int_cmd' $$Pno_history ",
"'$$Psource' '$$Pdest' '$$Pbase' $$Pout_of_date $$Pout_of_date_user\n"; },
sub{ print " '$file': $$Ptime $$Psize $$Pmd5 '", ($from_rules{$file} || ''), "'\n"; }
);
@@ -7487,10 +7915,15 @@
# a typical postscript file), or for a non-trivial reason (e.g., a
# stochastic algorithm, as in abcm2ps).
#
- # This caused me some actual trouble. In general, circular
- # dependencies produce non-termination, and the the following
- # situation is an example of a generic situation where certain
- # rules must be obeyed in order to obtain proper results:
+ # This caused me some actual trouble in certain cases, with circular
+ # dependencies causing non-termination when the standard
+ # stability-of-source-file algorithm is applied, together with
+ # non-optimality if the depedence isn't actually circular: e.g., from a
+ # rerun of X-to-pdf cusdep, where the pdf file is unchanged from
+ # previous one aside from a time of generation comment. The following
+ # situation is an example of a generic situation where a change from
+ # the standard stability-of-input-files criterion must be modified in
+ # order to obtain proper results:
# 1. A/the latex source file contains specifications for
# certain postprocessing operations. Standard *latex
# already has this, for indexing and bibliography.
@@ -7499,11 +7932,11 @@
# in external source files not directly input to
# *latex. But in the original version, there was a
# style file (abc.sty) that caused latex itself to call
- # abcm2ps to make .eps files for each tune that were to be
- # read in on the next run of latex.
+ # abcm2ps **un**conditionally to make .eps files for each tune
+ # that was to be read in on the next run of latex.
# 3. Thus the specification can cause a non-terminating loop
# for latexmk, because the output files of abcm2ps changed
- # even with identical input.
+ # on every run, even with identical input.
# 4. The solution was to
# a. Use a style file abc_get.sty that simply wrote the
# specification on the tunes to the .aux file in a
@@ -7518,106 +7951,190 @@
# changes.
# This solves the problem. Latexmk works. Also, it is no
# longer necessary to enable write18 in latex, and multiple
- # unnecessary runs of abcm2ps are no longer used.
+ # unnecessary runs of abcm2ps are no longer used.
+
+ # [**N.B.** Other sty files have similar problems, of
+ # unconditional write18s to make eps, pdf or other files. That's
+ # always non-optimal, often highly so --- see at least one of
+ # the example_latexmkrc files for real cases. But work is needed
+ # on the package to do better, which has been done in some
+ # packages. It is also possible to do better with a suitable
+ # configuration of latexmk with write18 turned off. E,g,,
+ # perhaps a cusdep, or a fancy used of a subroutine for *latex
+ # --- see the example_latexmkrc files for examples.]
#
- # The order of testing and applying rules is chosen by the
- # following heuristics:
- # 1. Both latex and pdflatex may be used, but the resulting
- # aux files etc may not be completely identical. Define
- # latex and pdflatex as primary rules. Apply the general
- # method of repeated circulating through all rules until
- # the source files are stable for each primary rule
- # separately. Naturally the rules are all accessible
- # rules, but excluding primary rules except for the current
- # primary.
- # 2. Assume that the primary rules are relatively
- # time-consuming, so that unnecessary passes through them
- # to check stability of the source files should be avoided.
- # 3. Assume that although circular dependencies exist, the
- # rules can nevertheless be thought of as basically
- # non-circular, and that many rules are strictly or
- # normally non-circular. In particular cusdep rules are
- # typically non-circular (e.g., fig2eps), as are normal
- # output processing rules like dvi2ps.
- # 4. The order for the non-circular approximation is
- # determined by applying the assumption that an output file
- # from one rule that is read in for an earlier stage is
- # unchanged.
- # HOWEVER, at a first attempt, the ordering is not needed. It
- # only gives an optimization
- # 5. (Note that these assumptions could be violated, e.g., if
- # $dvips is arranged not only to do the basic dvips
- # command, but also to extract information from the ps file
- # and feed it back to an input file for *latex.)
- # 6. Nevertheless, the overall algorithm should allow
- # circularities. Then the general criterion of stability
- # of source files covers the general case, and also
- # robustly handles the case that the USER changes source
- # files during a run. This is particularly important in
- # -pvc mode, given that a full make on a large document can
- # be quite lengthy in time, and moreover that a user
- # naturally wishes to make corrections in response to
- # errors, particularly latex errors, and have them apply
- # right away.
+ # The method used is conditioned on:
+ # 1. The network of active rules is constructed, with dependencies
+ # linking the rules. The network may change during the
+ # make. Notably, dependency information can be discovered from
+ # the results of runs of rules, especially *latex. This involves
+ # addition (and deletion) of items in the source-file list of a
+ # rule. It also involves addition (or deletion) of rule-nodes
+ # for e.g., cusdeps, bibtex, makeindex. Bigger changes
+ # sometimes occur --- e.g., when a .tex document chooses a
+ # kind of output file from the expected one: e.g., pdf to dvi or
+ # vice versa.
+ # 2. The *latex rules are called primary rules, and are the core
+ # source of dependency information (as ultimately determined by
+ # the .tex file(s). Only one primary rule is active. That was
+ # enforced by initialization.
+ # 3. There are generally loops of dependencies. The overall aim is
+ # to keep looping through rules until the content of the source
+ # files for each rule is unchanged from the previous run. Given
+ # the basic assumption that it is the content of these files
+ # that determines the output, stability of input files gives
+ # stability of output.
+ # 4. During the loop, the main criterion for running a rule is
+ # that the current contents of the source files are changed
+ # compared with the state saved in the rule. This is
+ # supplemented by the condition that a rule not previously run
+ # (under latexmk control) is to be run unconditionally.
+ # 5. In addition, there are specified dependencies not going via a
+ # set of files not known to latexmk as source files of the
+ # target rule. The primary examples are dvips, dvipdf, etc,
+ # which use graphics files; these are specified to have a dvi
+ # producing fule (e.g., latex) as a source rule. Such a rule is
+ # to be run after the source rule has been run.
+ # 6. There are special cases, coded in rdb_rerun_needed and
+ # rdb_file_change1.
+ # 7. Immediately before running a rule, the saved state of its
+ # source files is updated to their current state. If there is
+ # no error in the run, the source-file-state is **not** updated
+ # after the rule is run. Then on a subsequent pass through
+ # rdb_make's main loop, when the rule is tested for a rerun, any
+ # change in source file contents is cause for running the rule
+ # again.
+ # 8. But after a run giving an error, the state of the generated
+ # files (i.e., non-user files) is updated to the current state.
+ # This is because the error (under normal circumstances) must be
+ # corrected by user action: e.g., correcting a source file, and
+ # possibly deleting some corrupted auxiliary file. Files (e.g.,
+ # .aux by *latex) generated by the rule just run may well have
+ # changed, so updating their state to the current state prevents
+ # another run before a user change. If a file was generated by
+ # another rule, it won't have changed its state, so updating its
+ # state won't matter. But a non-generated file is a
+ # user-created file, and a rerun is entailed if its contents
+ # changed compared with the start of the run; it's the
+ # start-of-run contents that were used in the error run.
+ # 9. Note: an error may be caused by a problem with a file
+ # generated by another rule, e.g., a bbl file created by bibtex
+ # and read by *latex, but with no error reported by bibtex. To
+ # correct the error a source file (possibly more than once
+ # removed must be changed). That triggers a rerun of the
+ # producing rule, and after that the resulting change causes a
+ # rerun of the original rule that had the error. E.g.,
+ # correcting a .bib file causes bibtex to run, producing a
+ # corrected .bbl file, after which *latex is caused to be run.
+ # 10. With circular dependencies, there is a choice of which order
+ # to examine the rules. Generally, primary rules are more
+ # time-consuming than most others, so the choice of the order of
+ # examination of rules to check out-of-dateness is to try to
+ # minimize the number of primary runs. The other time-consuming
+ # rules are things like xdvipdfmx in documents with much
+ # graphics. These are normally outside a dependency loop, so
+ # those are left to last. Even if they are inside a dependency
+ # loop, they need the primary rule to have been run first.
+ # 11. After rdb_make is run, all non-user source files are updated
+ # to their current state. Rules are considered up-to-date
+ # here. On a subsequent call to rdb_make, subsequent changes are
+ # relevant to what is to be done. Note: the states of user
+ # files aren't updated. This guards against user caused changes
+ # that are made between the start of the run of a rule and the
+ # end of rdb_make.
+ #
+ # [Comment: Possible scenario for dvips, xdvipdfmx etc in loop:
+ # Document is documentation for viewer. At some page, the result
+ # in the viewer is to be displayed, with the display in the
+ # viewer being a neighboring page of the document, so the
+ # relevant page is extracted from the pdf file (or ...), and
+ # then processed into a graphics file to be included in the
+ # document.]
+ #
# This leads to the following approach:
# 1. Classify accessible rules as: primary, pre-primary
# (typically cusdep, bibtex, makeindex, etc), post-primary
- # (typically dvips, etc), and one-time
- # 2. Then stratify the rules into an order of application that
- # corresponds to the basic feedforward structure, with the
- # exclusion of one-time rules.
- # 3. Always require that one-time rules are among the
- # explicitly requested rules, i.e., the last to be applied,
- # were we to apply them. Anything else would not match the
- # idea of a one-time rule.
- # 4. Then work as follows:
- # a. Loop over primaries
- # b. For each primary, examine each pre-primary rule and
- # apply if needed, then the primary rule and then each
- # post-primary rule. The ordering of the pre-primary
- # and post-primary rules was found in step 2.
- # BUT applying the ordering is not essential
- # c. Any time that a pre-primary or primary rule is
- # applied, loop back to the beginning of step b. This
- # ensures that bibtex etc are applied before rerunning
- # *latex, and also covers changing source files, and
- # gives priority to quick pre-primary rules for changing
- # source files against slow reruns of latex.
- # d. Then apply post-primary rules in order, but not
- # looping back after each rule. This non-looping back
- # is because the rules are normally feed-forward only.
- # BUT applying the ordering is not essential
- # e. But after completing post-primary rules do loop back
- # to b if any rules were applied. This covers exotic
- # circular dependence (and as a byproduct, changing
- # source files).
- # f. On each case of looping back to b, re-evaluate the
- # dependence setup to allow for the effect of changing
- # source files.
- #
+ # (typically dvips, etc), and one-time.
+ # This step is the start of rdb_make's main "PASS" loop.
+ # 2. Go over the pre-primaries, the primary and the
+ # post-primaries. Examine each rule for out-of-dateness; if
+ # out-of-date run it.
+ # 3. Just before a run of a rule, update its source file state to
+ # the current state of the files.
+ # 4. After the rule is run, at least after a primary rule is run,
+ # examine the dependency information available (.fls, .log, .aux
+ # files) and updated the rule configuration. This can involve
+ # radical changes in the rule network: E.g., a newly found use
+ # of bibtex or makeindex, or even more radical rearrangements,
+ # if for example (under document control) *latex produces a .dvi
+ # file instead of an expected .pdf file.
+ # 5. If in any pass through the loop one (or more) of the
+ # pre-primary and primary rules is run, don't go on to examine
+ # the post-primaries. Not only are these are sometimes
+ # time-consuming and are almost always outside the dependency
+ # loops involving the primary, but, most importantly, dealing
+ # with the dependency information from a primary rule can change
+ # the rule network a lot.
+ # Instead go back to step 1.
+ # 6. Once visiting the pre-primaries and primaries no longer
+ # triggers any run, i.e., those rules are all stable, go on to
+ # the post-primaries.
+ # 7. If one or more of the post-primaries has been run, go back to
+ # 1. This allows for the possibility that a post-primary rule is
+ # part of a dependency loop. This is highly unusual for a
+ # normal document, but not impossible in principle. See earlier
+ # for a conceivable example.
+ # 10. Thus we finish the looping when no further run has been
+ # triggered by an examination of all of the pre-primary,
+ # primary, post-primary rules.
+ # 11. In addition, the loop is terminated if the number of
+ # applications of a rule exceeds a configured maximum. This
+ # guards agains the possibility that it may never be possible to
+ # get stable output, i.e., there is an infinite loop. It is
+ # impossible for an algorithm to determine in general whether
+ # there is an infinite loop. (An example of the Turing halting
+ # theorem.) But normal documents need a decidable modest number
+ # of passes through the loop. Any exceeding of the limit on the
+ # number of passes needs examination.
+ # 12. Finally apply one-time rules. These are rules that by their
+ # nature are both outside of any dependency a loop and are ones
+ # that should be applied last. Standard ones including running
+ # a viewer or causing it to be updated. The standard ones are
+ # not actually in the class of rules that rdb_make runs. Instead
+ # they are run by the calling routines, since the needs may be
+ # quite special.
- # ??? Overkill?
+ # ???!!! Overkill?
&rdb_set_rule_net;
- local %pass = ();
+ local %pass = (); # Counts runs on each rule: Used for testing for
+ # exceeding maximum runs and for determining
+ # whether to run rules that have a list of source
+ # rules. (E.g., dvips, which is to be run
+ # whenever latex has been run to make a dvi
+ # file. This because the list of source files of
+ # dvips misses all graphics files, and so the
+ # source file method is insufficient for deciding
+ # on a rerun.)
+ rdb_for_some( [keys %rule_db],
+ sub{ $pass{$rule} = 0;
+ foreach (keys %$PHsource_rules) {
+ $$PHsource_rules{$_} = 0;
+ }
+ }
+ );
+
local $failure = 0; # General accumulated error flag
local $missing_dvi_pdf = ''; # Did primary run fail to make its output file?
local $runs = 0;
local $runs_total = 0;
local $too_many_passes = 0;
- local %rules_applied = ();
local $switched_primary_output = 0;
local @warning_list = (); # Undef refs etc reported in last primary run
my $retry_msg = 0; # Did I earlier say I was going to attempt
# another pass after a failure?
- rdb_for_some ( [keys %rule_db],
- sub{ $pass{$rule} = 0;
- foreach (keys %$PHsource_rules) {
- $$PHsource_rules{$_} = 0;
- }
- }
- );
- PASS:
+ my %changes = (); # For reporting of changes
+ PASS:
while (1==1) {
# Exit condition at end of body of loop.
$runs = 0;
@@ -7658,6 +8175,12 @@
"make new source files\n";
next PASS;
}
+ elsif ( rdb_user_changes( \%changes, @pre_primary, $current_primary )) {
+ print "$My_name: Some rule(s) failed, but user file(s) changed ",
+ "so keep trying\n";
+ rdb_diagnose_changes2( \%changes, "", 1 ) if (!$silent);
+ next PASS;
+ }
else { last PASS; }
}
if ($runs == 0) {
@@ -7665,7 +8188,7 @@
$failure = $previous_failure;
if ($retry_msg) {
print "But in fact no new files made\n";
- }
+ }
if ($failure && !$force_mode ) { last PASS; }
}
if ( $missing_dvi_pdf ) {
@@ -7694,9 +8217,62 @@
rdb_for_some( [@unusual_one_time], \&rdb_make1 );
- if ($runs_total > 0) { rdb_write( $fdb_name ); }
+ #---------------------------------------
+ # All of make done. Finish book-keeping:
+ # 1. Update state of source files suitably.
+ # 2. Update fdb_latexmk file, if needed.
+ # 3. Diagnostics.
+ # 4. Other book-keeping and clean up.
+
+ ############ Update state of source files. Complications:
+ # **Either** success. Then the algorithms arrange that the contents of
+ # source files have stabilized between start and end of run of rule,
+ # so that output files have also stabilized.
+ # **or** failure. Then processing is normally aborted, so source files
+ # that are generated may not have stabilized, e.g., .aux file.
+ # At the next round of compilation (or test for a need for a rerun, as in
+ # make_preview_continuous), the criterion for a rerun of a rule is that
+ # source file(s) have changed relative to the saved state.
+ # At this point the saved file state for each rule is the state just
+ # before its last run. After a successful make, that gives correct
+ # behavior, including for user files (i.e., non-generated files). But
+ # not always after a failure.
+ #
+ # **So at this point we set state of generated source files to current
+ # state.**
+ #
+ # Normally there are no further changes in generated files, so they
+ # won't trigger reruns, only changes in user files will do that.
+ # That's correct behavior.
+ # But occasionally generated files have errors that block further
+ # processing, as is known for .aux and .bbl files. Then user can
+ # delete .aux and .bbl and thereby trigger a rerun. It also optimizes
+ # testing for changes, since, e.g., an .aux file of the same content but
+ # a different time than the current file will have its md5 signature
+ # recomputed during a check for a rerun. But when both time and size
+ # are unchanged, the test is optimized by assuming no change, and it
+ # doesn't do the md5 calculation.
+ #
+ # **However**, we will not update the state of the user files (i.e.,
+ # the non-generated files). This is because when the user notices an
+ # error during a run, they may correct the error in a .tex file say,
+ # but both too late to trigger a *latex and too early to be a post-make
+ # changed. Then it is correct to compare the current state of a user
+ # source file with its state just before the last run.
+ #
+ # In addition, we only update the file state for active rules, i.e.,
+ # those that the current use of make is supposed to have made
+ # up-to-date.
+ # Only do file-state update if something was run, otherwise it's work
+ # for nothing.
+
+ if ($runs_total > 0) {
+ rdb_for_some( [rdb_accessible()], \&rdb_update_gen_files );
+ rdb_write( $fdb_name );
+ }
else { print "$My_name: Nothing to do for '$texfile_name'.\n"; }
+ # Diagnostics
if ($#primary_warning_summary > -1) {
# N.B. $mult_defined, $bad_reference, $bad_character, $bad_citation also available here.
show_array( "$My_name: Summary of warnings from last run of *latex:",
@@ -7728,13 +8304,21 @@
print "$My_name: All targets (@dests) are up-to-date\n";
}
}
- rdb_for_some ( [keys %rule_db],
+
+ # ???!!! Rethink use of %pass, and it's scoping.
+ # Currently %pass is local in rdb_make and is used only to determine
+ # whether a rule needs to be run because a source rule has been run,
+ # and this would be within the same call to rdb_make.
+ # OLD COMMENT: Update source_rules. Is this too late? I don't think so, it's
+ # internal to make and to multiple calls to it (pvc). Is this
+ # necessary?
+ rdb_for_some( [keys %rule_db],
sub{
foreach my $s_rule (keys %$PHsource_rules) {
$$PHsource_rules{$s_rule} = $pass{$s_rule};
}
}
- );
+ );
return $failure;
} #END rdb_make
@@ -7776,6 +8360,7 @@
#-------------------
sub rdb_make1 {
+ # ???!!! Rethink how $$Pout_of_date is reset at end.
# Call: rdb_make1
# Helper routine for rdb_make.
# Carries out make at level of given rule (all data available).
@@ -7782,10 +8367,17 @@
# Assumes contexts for recursion, make, and rule, and
# assumes that source files for the rule are to be considered
# up-to-date.
+ our $rule;
if ($diagnostics) { print " Make for rule '$rule'\n"; }
+ # Is this needed? Yes; rdb_make1 is called on a sequence of rules and
+ # if one gives an error, then it provides source files directly or
+ # indirectly to later rules, which should not be run.
if ($failure & ! $force_mode) {return;}
- if ( ! defined $pass{$rule} ) {$pass{$rule} = 0; }
+ # Rule may have been created since last run. Just in case we didn't,
+ # define $pass{$rule} elsewhere, do it here:
+ if ( ! defined $pass{$rule} ) {$pass{$rule} = 0; }
+
# Special fix up for bibtex:
my $bibtex_not_run = -1; # Flags status as to whether this is a
# bibtex rule and if it is, whether out-of-date condition is to
@@ -7801,81 +8393,41 @@
if ($bibtex_use == 0) {
$bibtex_not_run = 2;
}
- elsif ( ($bibtex_use == 1) || ($bibtex_use == 1.5) ) {
- foreach ( keys %$PHsource ) {
- if ( ( /\.bib$/ ) && (! -e $_) ) {
- push @missing_bib_files, $_;
- $bibtex_not_run = 1;
+ else {
+ if ( $rule =~ /^biber/ ) {
+ warn "$My_name: ???!!!==== Using biber OMITTING TEST on missing bib files\n";
+ }
+ elsif ( ($bibtex_use == 1) || ($bibtex_use == 1.5) ) {
+ foreach ( keys %$PHsource ) {
+ if ( ( /\.bib$/ ) && (! -e $_) ) {
+ push @missing_bib_files, $_;
+ $bibtex_not_run = 1;
+ }
}
}
}
}
- if ( ($$Prun_time == 0) && exists($possible_primaries{$rule}) ) {
- push @rules_never_run, $rule;
- $$Pout_of_date = 1;
- $$Plast_result = -1;
+ if ( ! rdb_rerun_needed(\%changes, 0) ) { return; }
+
+ # Set this in case of early exit:
+ # ???!!! Check I am setting $missing_dvi_pdf correctly.
+ if ( $$Pdest && (! -e $$Pdest) && ( $$Pcmd_type eq 'primary' ) ) {
+ $missing_dvi_pdf = $$Pdest;
}
- else {
- if ( $$Pdest && (! -e $$Pdest) ) {
- # With a non-existent destination, if we haven't made any passes
- # through a rule, rerunning the rule is good, because the file
- # may fail to exist because of being deleted by the user (for ex.)
- # rather than because of a failure on a previous run.
- # (We could do better with a flag in fdb file.)
- # But after the first pass, the situation is different.
- # For a primary rule *latex, the lack of a destination file
- # could result from there being zero content due to a missing
- # essential input file. The input file could be generated
- # by a program to be run later (e.g., a cusdep or bibtex),
- # so we should wait until all passes are completed before
- # deciding a non-existent destination file is an error.
- # For a custom dependency, the rule may be obsolete, and
- # if the source file does not exist also, we should simply
- # not run the rule, but not set an error condition.
- # Any error will arise at the *latex level due to a
- # missing source file at that level.
- if ( $$Psource && (! -e $$Psource)
- && ( $$Pcmd_type ne 'primary' )
- ) {
- # Main source file doesn't exist, and rule is NOT primary.
- # No action, since a run is pointless. Primary is different:
- # file might be found elsewhere (by kpsearch from *latex),
- # while non-existence of main source file is a clear error.
- }
- elsif ( $$Pcmd_type eq 'delegated' ) {
- # Delegate to destination rule
- }
- elsif ( $pass{$rule}==0) {
- push @no_dest, $$Pdest;
- $$Pout_of_date = 1;
- }
- if ( $$Pcmd_type eq 'primary' ) {
- $missing_dvi_pdf = $$Pdest;
- }
- }
- }
- &rdb_clear_change_record;
- &rdb_flag_changes_here(0);
-
- if (!$$Pout_of_date) {
- return;
- }
- if ($diagnostics) { print " remake\n"; }
if (!$silent) {
- print "$My_name: applying rule '$rule'...\n";
- &rdb_diagnose_changes( "Rule '$rule': " );
+ print "$My_name: applying rule '$rule'...\n";
+ &rdb_diagnose_changes2( \%changes, "Rule '$rule': ", 0 );
}
- # We are applying the rule, so its source file state for when it
- # was last made is as of now:
- # ??IS IT CORRECT TO DO NOTHING IN CURRENT VERSION?
+ # We are applying the rule, so its source file state for when it was
+ # last made is as of now. This is do in the subroutines that do the
+ # actual run, to allow for possible calls to them from other places.
# The actual run
my $return = 0; # Return code from called routine
- # Rule may have been created since last run:
- if ( ! defined $pass{$rule} ) {$pass{$rule} = 0; }
+
if ( $pass{$rule} >= $max_repeat ) {
# Avoid infinite loop by having a maximum repeat count
# Getting here represents some kind of weird error.
@@ -7889,7 +8441,6 @@
return;
}
- $rules_applied{$rule} = 1;
$runs++;
$runs_total++;
@@ -7927,7 +8478,7 @@
# latex run and the consequent analysis of the log file, the
# cusdep rule will no longer be needed, and will be removed.
- # So in this case, do NOT report an error
+ # So in this case, do NOT report an error
$$Pout_of_date = 0;
}
elsif ($$Pcmd_type eq 'primary' ) {
@@ -7958,6 +8509,15 @@
if ( !$$Plast_message ) {
$$Plast_message = "Run of rule '$rule' gave a non-zero error code";
}
+ # Update state of generated source files, but not non-generated,
+ # i.e., user source files. Thus any change in the rule's own
+ # generated source files during the run will not cause a
+ # rerun. Files generated by another rule should not have been
+ # changed during the run, so updating their saved state in this
+ # rule is a NOP. But any change in user files since the **start**
+ # of the run is a cause for a rerun, so their saved state must not
+ # be updated.
+ rdb_update_gen_files();
}
foreach ( keys %$PHsource_rules ) {
$$PHsource_rules{$_} = $pass{$_};
@@ -7976,7 +8536,7 @@
# Defaults for summary of results of run.
$$Prun_time = time();
-
+
$$Pchanged = 0; # No special changes in files
$$Plast_result = 0;
$$Plast_message = '';
@@ -8038,7 +8598,7 @@
$$Plast_message = "Bug or configuration error; incorrect command type";
}
$time = processing_time() - $time;
- push @timings, "'$_[0]': time = " . sprintf('%.2f',$time) . "\n";
+ add_timing( $time, $rule );
#============================================================================
@@ -8137,6 +8697,10 @@
my $retcode = check_bibtex_log($$Pbase);
if ( ! -e $$Psource ) {
$retcode = 10;
+ if (!$silent) {
+ print "Source '$$Psource' for '$rule' doesn't exist,\n",
+ "so I'll force *latex to run to try and make it.\n";
+ }
rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } );
}
if ($retcode == 3) {
@@ -8171,12 +8735,6 @@
# General
$updated = 1;
- if ($$Ptest_kind == 3) {
- # We are time-criterion first time only. Now switch to
- # file-change criterion
- $$Ptest_kind = 1;
- }
-
if ( ($$Plast_result == 0) && ($return != 0) && ($return != -2) ) {
$$Plast_result = 2;
if ($$Plast_message eq '') {
@@ -8183,7 +8741,8 @@
$$Plast_message = "Command for '$rule' gave return code $return";
if ($rule =~ /^(pdf|lua|xe|)latex/) {
if ( test_gen_file($log_name) ) {
- $$Plast_message .= "\n Refer to '$log_name' for details";
+ $$Plast_message .=
+ "\n Refer to '$log_name' and/or above output for details";
}
else {
$$Plast_message .=
@@ -8217,11 +8776,6 @@
$$Plast_result = 0;
$$Plast_message = '';
- if ($$Ptest_kind == 3) {
- # We are time-criterion first time only. Now switch to
- # file-change criterion
- $$Ptest_kind = 1;
- }
$$Pout_of_date = $$Pout_of_date_user = 0;
return 0;
@@ -8244,7 +8798,7 @@
# This is a globally usable subroutine, and works in a rule context,
# and outside.
# Defaults:
- # cmd: $PPext_cmd if defined, else '';
+ # cmd: $$Pext_cmd if defined, else '';
# msg: 1
# options: ''
# source: $$Psource if defined, else $texfile_name;
@@ -8323,7 +8877,7 @@
#
# Assumes contexts for: recursion, make, & rule.
# Assumes (a) the rule is a primary,
- # (b) a run has to be made,
+ # (b) a run has been made,
my $return_latex = shift;
my $return = $return_latex;
@@ -8335,7 +8889,7 @@
# Handle case that log file is caused to be in an unexpected place,
# from a configuration error:
&find_set_log;
-
+
if ($recorder) {
# Handle problem that some version of *latex give fls files
# of name latex.fls or pdflatex.fls instead of $root_filename.fls.
@@ -8377,7 +8931,11 @@
}
# Find current set of source files:
- my ($missing_dirs, $PA_missing_subdirs) = &rdb_set_latex_deps;
+ my ($missing_dirs, $PA_missing_subdirs, $bad_warnings) = &rdb_set_latex_deps;
+ if ($bad_warning_is_error && $bad_warnings) {
+ warn "$My_name: Serious warnings in .log configured to be errors\n";
+ $return ||= $bad_warnings;
+ }
# For each file of the kind made by epstopdf.sty during a run,
# if the file has changed during a run, then the new version of
@@ -8429,54 +8987,248 @@
#************************************************************
-sub rdb_clear_change_record {
- # Initialize diagnostics for reasons for running rule.
- @changed = ();
- %changed_rules = ();
- @changed_user = ();
- @disappeared = ();
- @no_dest = (); # We are not now using this
- @rules_never_run = ();
- @rules_to_apply = (); # This is used in recursive application
- # of rdb_flag_changes_here, to list
- # rules that were out-of-date for some reason.
-} #END rdb_clear_change_record
+sub rdb_remake_needed {
+ # Usage: rdb_remake_needed( \%change_record, outside-make-loop, rules ...)
+ # Determine whether one or more of the rules needs to be rerun, and
+ # return corresponding value.
+ #
+ # Report diagnostics (reasons for remake) in the hash referenced by the
+ # first argument (the hash maps kinds of reason to refs to arrays).
+ #
+ # If second argument is true, use rerun criterion suitable to e.g.,
+ # initial tests in rdb_make, rerun test in
+ # make_preview_continuous. Otherwise use rerun criterion suitable for
+ # with rdb_make's looping through rules.
+ # In the first case, the file state recorded in each rule corresponds
+ # to the files **after** the of the previous invocation of rdb_make. In
+ # the second case it corresponds to the state immediately **before**
+ # the latest run of the rule.
+ my $PHchanges = shift;
+ my $outside_make_loop = shift;
+
+ my $remake_needed = 0;
+
+ %$PHchanges = ();
+
+ # ???!!! Need fancier tests: SEE NOTES.
+
+ rdb_recurse( [@_],
+ sub {
+ my %changes_rule = ();
+ if( rdb_rerun_needed(\%changes_rule, $outside_make_loop)) {
+ $remake_needed = 1;
+ foreach my $kind (keys %changes_rule ) {
+ push @{$$PHchanges{$kind}}, @{$changes_rule{$kind}};
+ }
+ }
+ }
+ );
+
+ return $remake_needed;
+} #END rdb_remake_needed
+
#************************************************************
-sub rdb_flag_changes_here {
- # Flag changes in current rule.
- # Assumes rule context.
- # Usage: rdb_flag_changes_here( ignore_run_time )
- # Argument: if true then fdb_get shouldn't do runtime test
- # for recalculation of md5
- local $ignore_run_time = $_[0];
- if ( ! defined $ignore_run_time ) { $ignore_run_time = 0; }
+sub rdb_user_changes {
+ # Usage: rdb_user_changes( \%change_record, rules ...)
+ # Return value: whether any user files changed.
+ # Report changes in hash pointed to by first argument.
+ # Side effect: out-of-date rules flagged in $$Pout_of_date.
+ #
+ # ???!!!
+ # Ideally, need specialized versions of rdb_rerun_needed and
+ # rdb_file_change1 (or special option to those), to restrict attention
+ # to user_changed files. But for now, fudge our way around that.
+ my $PHchanges = shift;
+ my $user_changes = 0;
+ %$PHchanges = ( 'changed_user' => [],
+ 'rules_to_apply' => []
+ );
+
+ rdb_recurse(
+ [@_],
+ sub {
+ my %changes_rule = ( 'changed_user' => [] );
+ if ( rdb_rerun_needed(\%changes_rule, 0 )
+ && @{$changes_rule{changed_user}}
+ ) {
+ push @{$$PHchanges{changed_user}},
+ @{$changes_rule{changed_user}};
+ push @{$$PHchanges{rules_to_apply}}, $rule;
+ $user_changes = 1;
+ $$Pout_of_date = $$Pout_of_date_user = $user_changes;
+ }
+ }
+ );
+
+ return $user_changes;
+}
+
+#************************************************************
+
+sub rdb_rerun_needed {
+ # Usage: rdb_rerun_needed( \%change_record, outside-make-loop )
+ # Rule context assumed.
+ # Determines whether a rerun of the rule is needed.
+ # Return value is whether a rerun is needed.
+ #
+ # Report diagnostics (reasons for remake) in the hash referenced by the
+ # first argument (the hash maps kinds of reason to refs to arrays).
+ #
+ # If second argument is true, use rerun criterion suitable to e.g.,
+ # initial tests in rdb_make, rerun test in
+ # make_preview_continuous. Otherwise use rerun criterion suitable for
+ # with rdb_make's looping through rules.
+ #
+ # ???!!!!
+ # Check all uses!!!!!!!!!!!!!
+
+ our ($rule, %pass);
+
+ local our $PHchanges = shift;
+ local our $outside_make_loop = shift;
+
+ # File level routine reports its results in %$PHchanges: maps kind of
+ # change to ref to array of files with that kind of change.
+ %$PHchanges = ();
+ foreach ('changed', 'changed_source_rules', 'changed_user',
+ 'disappeared_gen_other', 'disappeared_gen_this',
+ 'disappeared_user', 'no_dest', 'other', 'rules_to_apply' )
+ { $$PHchanges{$_} = []; }
+
+ my $rerun_needed = $$Pout_of_date;
+ if ($rerun_needed) {
+ push @{$$PHchanges{other}},
+ "Rerun of '$rule' forced or previously required";
+ goto rdb_rerun_needed_CLEAN_UP;
+ }
+
+ my $user_deleted_is_changed =
+ ( ($user_deleted_file_treated_as_changed == 1)
+ && (! $preview_continuous_mode)
+ )
+ || ($user_deleted_file_treated_as_changed == 2);
+
$$Pcheck_time = time();
local $dest_mtime = 0;
$dest_mtime = get_mtime($$Pdest) if ($$Pdest);
+
rdb_do_files( \&rdb_file_change1);
- while ( my ($s_rule, $l_pass) = each %$PHsource_rules ) {
- # %$PHsource_rules is about rules on which the current rule
- # depends, but for which this dependence is not determined by
- # the source rules of the set of known source files.
- # Use pass-count criterion to determine out-of-dateness for these.
- #
- if ( defined $pass{$s_rule}
- && ($pass{$s_rule} > $l_pass)
- )
- {
- $changed_rules{$s_rule} = $rule;
- $$Pout_of_date = 1;
+ if (! $outside_make_loop) {
+ while ( my ($s_rule, $l_pass) = each %$PHsource_rules ) {
+ # %$PHsource_rules is about rules on which the current rule
+ # depends, but for which this dependence is not determined by
+ # the source rules of the set of known source files.
+ # Use pass-count criterion to determine out-of-dateness for these.
+ #
+ if ( defined $pass{$s_rule}
+ && ($pass{$s_rule} > $l_pass)
+ )
+ {
+ push @{$$PHchanges{changed_source_rules}}, $s_rule;
+ $rerun_needed = 1;
+ }
}
}
- if ($$Pout_of_date) {
- push @rules_to_apply, $rule;
+
+ # ???!!!: Comments about disappeared files.
+ # Relevant situations I know of:
+ # a. \input (or c.) of a file, and file deleted. No other version.
+ # b. Like a., but file of the correct name exists in
+ # source-file-search path; the earlier source file version may for
+ # example have been an override for a standard file.
+ # c. There's a chain of input-if-file-exists cases, where the first
+ # file found in a list of files is used. Then deleting the file
+ # found on the previous run merely results in the next run using
+ # the next file in the list (if there is one, else the situation
+ # is as at a..
+ # d. File was deleted, either by user or automatically by something,
+ # and the file can be regenerated. (Note: If an aux or bbl file
+ # (etc) persistently causes errors, then after correcting, e.g., a
+ # relevant .tex file, then a clean rerun can be triggered by
+ # deleting the offending file.)
+ # Need tests: Has the file a from rule? If so it can be made, and
+ # current rule shouldn't be rerun now.
+ # **But** it's different if the rule that makes in
+ # Is the file the main source file? If so problems will
+ # normally happen when trying to run rule.
+ # Can the file be found by kpsewhich? If so, is it the
+ # main source of the rule?
+ # Need to mention missing files at end of run.
+
+ foreach my $kind (keys %$PHchanges) {
+ if (($kind eq 'disappeared_user') && !$user_deleted_is_changed)
+ { #???!!! Delete entry, as it is no longer a reason for rerun.
+ $$PHchanges{$kind} = [];
+ }
+ elsif ($kind eq 'disappeared_gen_other') {
+ # It's the generating rule of the file that needs to be run,
+ # not this rule, to remake the missing file. So we should not
+ # set the current rule to be rerun. A rerun of the current rule
+ # will be triggered once the file-generating rule has generates
+ # the file, unless, of course, the generated file is identical
+ # to the version that got deleted.
+ # ????!!! should the disappeared_gen_other item in the hash be
+ # emptied out?
+ }
+ elsif ( @{$$PHchanges{$kind}} ) {
+ $rerun_needed = 1;
+ }
}
-} #END rdb_flag_changes_here
+ # Non-source-file-change reasons for rerun:
+ if ( ( ($$Prun_time == 0) || ( $$Plast_result == -1 ) )
+ && ( $$Pcmd_type eq 'primary' ) )
+ {
+ # Never run. Only use this test with primary, so we can get
+ # dependency information, which is essential to latexmk's
+ # functioning. Other rules: there appears to be danger
+ # of, e.g., rerunning many cusdeps when their destinations have
+ # already been made and we used time criterion for deciding whether
+ # to run the rule.
+ push @{$$PHchanges{never_run}}, $rule;
+ $rerun_needed = $rule;
+ }
+ if ( $$Pdest && (! -e $$Pdest) && ( $$Plast_result <= 0 ) ) {
+ # No dest. But not if last run gave error, for then we should not
+ # rerun rule until there's a change in source file(s), which
+ # presumably contain the cause of the error.
+ # But there are other reasons for not rerunning:
+ if ( $$Psource && (! -e $$Psource)
+ && ( $$Pcmd_type ne 'primary' )
+ ) {
+ # Main source file doesn't exist, and rule is NOT primary.
+ # No action, since a run is pointless. Primary is different:
+ # file might be found elsewhere (by kpsearch from *latex),
+ # while non-existence of main source file is a clear error.
+ }
+ elsif ( $$Pcmd_type eq 'delegated' ) {
+ # Delegate to destination rule
+ }
+ else {
+ $rerun_needed = 1;
+ push @{$$PHchanges{no_dest}}, $rule;
+ }
+ }
+
+ rdb_rerun_needed_CLEAN_UP:
+ foreach my $file ( @{$$PHchanges{changed}} ) {
+ if ( ! $from_rules{$file} ) {
+ push @{$$PHchanges{changed_user}}, $file;
+ }
+ }
+ $$Pno_history = 0; # See comments in definition of %rule_db.
+ if ($rerun_needed) {
+ $$Pout_of_date = 1;
+ push @{$$PHchanges{rules_to_apply}}, $rule;
+ if (@{$$PHchanges{changed_user}}) {$$Pout_of_date_user = 1;}
+ }
+ return $rerun_needed;
+} #END rdb_rerun_needed
+
#************************************************************
sub rdb_file_change1 {
@@ -8483,109 +9235,135 @@
# Call: &rdb_file_change1
# Assumes rule and file context. Assumes $dest_mtime set.
# Flag whether $file in $rule has changed or disappeared.
- # Set rule's make flag if there's a change.
+ our ($rule, $file, $PHchanges);
- my $check_time_argument = 0;
- if (! $ignore_run_time ) {
- $check_time_argument = max( $$Pcheck_time, $$Prun_time );
+ my $check_time_argument =
+ ($outside_make_loop ? 0 : max($$Pcheck_time, $$Prun_time) );
+
+
+ # For files that won't be read until after they are written, ignore any changes:
+ if (exists $$PHrewritten_before_read{$file}) {
+ return;
}
my ($new_time, $new_size, $new_md5) = fdb_get($file, $check_time_argument );
my $ext_no_period = ext_no_period( $file );
- my $generated = exists $from_rules{$file};
- if ( ($new_size < 0) && ($$Psize >= 0) ) {
- # print "Disappeared '$file' in '$rule'\n";
- push @disappeared, $file;
- # No reaction is good.
- #$$Pout_of_date = 1;
- # ??? 1 Sep. 2008: I do NOT think so, for cusdep no-file-exists issue
- # ??? 30 Sep 2008: I think I have this fixed. There were other changes
- # needed. No-change-flagged is correct. The array @disappeared flags
- # files that have disappeared, if I need to know. But having a source
- # file disappear is not a reason for a remake unless I know how to
- # make the file. If the file is a destination of a rule, that rule
- # will be rerun. It may be that the user is changing another source
- # in such a way that the disappeared file won't be needed. Before the
- # change is applied we get a superfluous infinite loop.
- return;
+
+ my $generated = 0;
+ if (exists $from_rules{$file}) {
+ if ($from_rules{$file} eq $rule) { $generated = 1; }
+ else { $generated = 2; }
}
+
if ( ($new_size < 0) && ($$Psize < 0) ) {
return;
}
- # Primarily use md5 signature to determine whether file contents have
- # changed.
+
+ if ( ($new_size < 0) && ($$Psize >= 0) ) {
+ if ($generated == 2) {
+ # Non-existent file generated by another rule. It's up to that
+ # rule to remake it.
+ push @{$$PHchanges{disappeared_gen_other}}, $file;
+ }
+ elsif ($generated == 1) {
+ # Non-existent file generated by this rule.
+ push @{$$PHchanges{disappeared_gen_this}}, $file;
+ }
+ # ???!!! Keep this, or only for primary, or not?
+# elsif ( my @kpse = kpsewhich( $file ) ) {
+# print "After '$file' disappeared for '$rule', kpsewhich found it at\n:",
+# " '$kpse[0]'.\n";
+# push @{$$PHchanges{changed}}, $file;
+# }
+ else {
+ push @{$$PHchanges{disappeared_user}}, $file;
+ }
+ }
+ # For other kinds of file change, primarily use md5 signature to
+ # determine whether file contents have changed.
# Backup by file size change, but only in the case where there is
- # no pattern of lines to ignore in testing for a change
- if ( ($new_md5 ne $$Pmd5)
- || (
- (! exists $hash_calc_ignore_pattern{$ext_no_period})
- && ($new_size != $$Psize)
+ # no pattern of lines to ignore in testing for a change
+ elsif ( ($new_md5 ne $$Pmd5)
+ || (
+ (! exists $hash_calc_ignore_pattern{$ext_no_period})
+ && ($new_size != $$Psize)
)
) {
- push @changed, $file;
- $$Pout_of_date = 1;
- if ( ! $generated ) {
- push @changed_user, $file;
- $$Pout_of_date_user = 1;
- }
+ push @{$$PHchanges{changed}}, $file;
}
elsif ( $new_time != $$Ptime ) {
$$Ptime = $new_time;
}
- if ( ( ($$Ptest_kind == 2) || ($$Ptest_kind == 3) )
- && (! $generated)
- && ( $new_time > $dest_mtime )
- ) {
- push @changed, $file;
- $$Pout_of_date = $$Pout_of_date_user = 1;
+ # If there's no history, supplement by file-time criterion, i.e., is
+ # this source file time later than destination file file
+ if ( $$Pno_history && ( $new_time > $dest_mtime ) ) {
+ push @{$$PHchanges{changed}}, $file;
}
+
} #END rdb_file_change1
#************************************************************
-sub rdb_user_changes {
- # Argument(s): a set of top level rules.
- # Aim: Find any changed user files for those rules and all ancestors.
- # Assumption: List of source_rules for files is up-to-date.
- &rdb_clear_change_record;
- rdb_recurse( [@_], sub{ &rdb_flag_changes_here(1); } );
- if ($#changed_user >=0) { show_array( 'User changed files', @changed_user ); }
- return ($#changed_user >= 0);
-} #END rdb_user_changes
+#sub rdb_diagnose_changes {
+# # ???!!! delete after using ideas in rdb_diagnose_changes2
+# # Call: rdb_diagnose_changes or rdb_diagnose_changes( heading, show_out_of_date_rules )
+# # Precede the message by the optional heading, else by "$My_name: "
+# my ($heading, $show_out_of_date_rules) = @_;
+# our ( @changed, %changed_rules, @disappeared, @no_dest, @rules_to_apply,
+# @rules_never_run );
+#
+# if ($#rules_never_run >= 0) {
+# show_array( "${heading}Rules & subrules not known to be previously run:", @rules_never_run );
+# }
+# if ( ($#changed >= 0) || (keys %changed_rules > 0) || ($#disappeared >= 0) || ($#no_dest >= 0) ) {
+# print "${heading}File changes, etc:\n";
+# if ( $#changed >= 0 ) {
+# # ???!!! Modify to allow for case of
+# show_array( " Changed files, or newly in use/created since previous run(s):", uniqs(@changed) );
+# }
+# if ( $#disappeared >= 0 ) {
+# show_array( " No-longer-existing files:", uniqs(@disappeared) );
+# }
+# if ( $#no_dest >= 0 ) {
+# show_array( " Non-existent destination for:", uniqs(@no_dest) );
+# }
+# if ( keys %changed_rules > 0 ) {
+# print " Rule(s) that have been run and require run of dependent rule:\n";
+# while (my ($s_rule, $d_rule) = each %changed_rules) {
+# print " '$s_rule' which requires run of '$d_rule'\n";
+# }
+# }
+# }
+# if ($show_out_of_date_rules) {
+# show_array( "${heading}Overall, the following rules became out-of-date:",
+# uniqs(@rules_to_apply));
+# }
+#} #END rdb_diagnose_changes
-#************************************************************
+#----------------------------
-sub rdb_diagnose_changes {
- # Call: rdb_diagnose_changes or rdb_diagnose_changes( heading )
- # List changes on STDERR
- # Precede the message by the optional heading, else by "$My_name: "
- my $heading = defined($_[0]) ? $_[0] : "$My_name: ";
+sub rdb_diagnose_changes2 {
+ # ???!!! Examine rdb_diagnose_changes for ideas in old version to use here.
+ # Call: rdb_diagnose_changes2( \%changes, heading, show_out_of_date_rules )
- if ($#rules_never_run >= 0) {
- show_array( "${heading}Rules & subrules not known to be previously run:", @rules_never_run );
- }
- if ( ($#changed >= 0) || (keys %changed_rules > 0) || ($#disappeared >= 0) || ($#no_dest >= 0) ) {
- print "${heading}File changes, etc:\n";
- if ( $#changed >= 0 ) {
- show_array( " Changed files, or newly in use since previous run(s):", uniqs(@changed) );
+ my ($PHchanges, $heading, $show_out_of_date_rules) = @_;
+
+ my %labels = (
+ 'changed' => 'Changed files or newly in use/created',
+ );
+
+ print "$heading Reasons for rerun\n";
+ foreach my $kind (sort keys %$PHchanges) {
+ if ( (! $show_out_of_date_rules) && ($kind eq 'rules_to_apply' ) )
+ { next; }
+ my $label = $labels{$kind} || "Category '$kind'";
+ if ( @{$$PHchanges{$kind}} ) {
+ show_array( "$label:",
+ uniqs( @{$$PHchanges{$kind}} ) );
}
- if ( $#disappeared >= 0 ) {
- show_array( " No-longer-existing files:", uniqs(@disappeared) );
- }
- if ( $#no_dest >= 0 ) {
- show_array( " Non-existent destination files:", uniqs(@no_dest) );
- }
- if ( keys %changed_rules > 0 ) {
- print " Rule(s) that have been run and require run of dependent rule:\n";
- while (my ($s_rule, $d_rule) = each %changed_rules) {
- print " '$s_rule' which requires run of '$d_rule'\n";
- }
- }
}
- show_array( "${heading}The following rules & subrules became out-of-date:",
- @rules_to_apply);
-} #END rdb_diagnose_changes
+ print "\n";
+} #END rdb_diagnose_changes2
-
#************************************************************
#************************************************************
#************************************************************
@@ -8829,8 +9607,8 @@
local ( $rule, $rule_act1, $file_act, $rule_act2 ) = @_;
if ( (! $rule) || ! rdb_rule_exists($rule) ) { return; }
- local ( $PArule_data, $PHsource, $PHdest, $PHsource_rules ) = @{$rule_db{$rule}};
- local ($Pcmd_type, $Pext_cmd, $PAint_cmd, $Ptest_kind,
+ local ( $PArule_data, $PHsource, $PHdest, $PHrewritten_before_read, $PHsource_rules ) = @{$rule_db{$rule}};
+ local ($Pcmd_type, $Pext_cmd, $PAint_cmd, $Pno_history,
$Psource, $Pdest, $Pbase,
$Pout_of_date, $Pout_of_date_user, $Prun_time, $Pcheck_time,
$Pchanged,
@@ -8928,7 +9706,8 @@
#************************************************************
sub rdb_create_rule {
- # rdb_create_rule( rule, command_type, ext_cmd, int_cmd, test_kind,
+ # ???!!! OUT OF DATE. PLACE HOLDER for what was test_kind
+ # rdb_create_rule( rule, command_type, ext_cmd, int_cmd, DUMMY,
# source, dest, base,
# needs_making, run_time, check_time, set_file_not_exists,
# ref_to_array_of_specs_of_extra_generated_files )
@@ -8939,9 +9718,15 @@
# Omitted arguments: replaced by 0 or '' as needed.
# Rule is made active
# ==== Sets rule data ====
- my ( $rule, $cmd_type, $ext_cmd, $PAint_cmd, $test_kind,
+ my ( $rule, $cmd_type, $ext_cmd, $PAint_cmd, $DUMMY,
$source, $dest, $base,
- $needs_making, $run_time, $check_time, $set_file_not_exists, $extra_gen ) = @_;
+ $needs_making, $run_time, $check_time, $set_file_not_exists,
+ $extra_gen ) = @_;
+ foreach ( $needs_making, $run_time, $check_time, $DUMMY ) {
+ if (! defined $_) { $_ = 0; }
+ }
+ my $last_result = -1;
+ my $no_history = ($run_time <= 0);
my $active = 1;
my $changed = 0;
@@ -8959,13 +9744,6 @@
" '$base'\n",
" I cannot handle this. Cause is probably a latexmk bug. Please report it.\n";
}
- foreach ( $needs_making, $run_time, $check_time, $test_kind ) {
- if (! defined $_) { $_ = 0; }
- }
- if (!defined $test_kind) {
- # Default to test on file change
- $test_kind = 1;
- }
if ( ref( $PAint_cmd ) eq '' ) {
# It is a single command. Convert to array reference:
$PAint_cmd = [ $PAint_cmd ];
@@ -8979,12 +9757,13 @@
@$PA_extra_gen = @$extra_gen;
}
$rule_db{$rule} =
- [ [$cmd_type, $ext_cmd, $PAint_cmd, $test_kind,
+ [ [$cmd_type, $ext_cmd, $PAint_cmd, $no_history,
$source, $dest, $base,
$needs_making, 0, $run_time, $check_time, $changed,
- -1, '', $PA_extra_gen ],
+ $last_result, '', $PA_extra_gen ],
{},
{},
+ {},
{}
];
if ($source) {
@@ -8999,10 +9778,12 @@
sub rdb_initialize_generated {
# Assume rule context.
-# Initialize hash of generated files
+# Initialize hashes of generated files, and of files rewritten before read
%$PHdest = ();
if ($$Pdest) { rdb_add_generated($$Pdest); }
rdb_add_generated(@$PA_extra_gen);
+
+ %$PHrewritten_before_read = ();
} #END rdb_initialize_generated
#************************************************************
@@ -9018,6 +9799,14 @@
#************************************************************
+sub rdb_add_rewritten_before_read {
+# Assume rule context.
+# Add arguments to hash of files rewritten before being read
+ foreach (@_) { $$PHrewritten_before_read{$_} = 1; }
+} #END rdb_add_rewritten_before_read
+
+#************************************************************
+
sub rdb_remove_generated {
# Assume rule context.
# Remove arguments from hash of generated files
@@ -9026,6 +9815,14 @@
#************************************************************
+sub rdb_remove_rewritten_before_read {
+# Assume rule context.
+# Remove arguments from hash of files rewritten before being read
+ foreach (@_) { delete $$PHrewritten_before_read{$_}; }
+} #END rdb_add_rewritten_before_read
+
+#************************************************************
+
sub rdb_ensure_file {
# rdb_ensure_file( rule, file[, fromrule[, set_not_exists]] )
# Ensures the source file item exists in the given rule.
@@ -9140,15 +9937,10 @@
#************************************************************
sub rdb_update_gen_files {
- # Assumes rule context. Update source files of rule to current state.
+ # Assumes rule context. Update source files of rule to current state,
+ # but only for source files that are generated by this or another rule.
rdb_do_files(
- sub{
- if ( exists $generated_exts{ ext_no_period($file) }
- || exists $$PHdest{$file}
- ) {
- &rdb_update1;
- }
- }
+ sub{ if ( exists $from_rules{$file} ) { &rdb_update1; } }
);
} #END rdb_update_gen_files
@@ -9156,7 +9948,7 @@
sub rdb_update_files {
# Call: rdb_update_files
- # Assumes rule context. Update source files of rule to current state.
+ # Assumes rule context. Update all source files of rule to current state.
rdb_do_files( \&rdb_update1 );
}
@@ -9201,7 +9993,15 @@
# primary run) doesn't exist.
# It is assumed that the resulting file will be read by the
# primary run.
+ # N.B.
+ # The subroutine is not used by latexmk itself. It is here to support
+ # a need in TeXShop's pdflatexmk engine as the subroutine for a cusdep
+ # to work with the epspdf package.
+ print "I am delegating making of '$$Pdest' to *latex (e.g., by epspdf).\n",
+ " So I'll delete '$$Pdest' to flag it needs to be remade,\n",
+ " and flagging the rules using it to be rerun\n"
+ if (!$silent);
# Remove the destination file, to indicate it needs to be remade:
unlink_or_move( $$Pdest );
# Arrange that the non-existent destination file is not treated as
@@ -9225,7 +10025,7 @@
# primary run.
local $cus_dep_target = $$Pdest;
- # Loop over all rules and source files:
+ # Loop over all active rules and source files:
rdb_for_actives( 0,
sub { if ($file eq $cus_dep_target) {
$$Pout_of_date = 1;
@@ -9266,7 +10066,7 @@
#************************************************************
sub show_hash {
- my ($msg, $PH ) = @_;
+ my ($msg, $PH) = @_;
print "$msg\n";
if (! %$PH ) {
print " NONE\n";
@@ -9325,6 +10125,37 @@
#************************************************************
+sub analyze_string {
+ # Show information about string: utf8 flag or not, length(s!), byte content
+ my ($m,$s) = @_;
+
+ print "=== $m ";
+ my $length = length($s);
+ if (utf8::is_utf8($s)) {
+ my $encoded = encode( $CS_system, $s, Encode::FB_WARN | Encode::LEAVE_SRC );
+ my $len_chars = 0;
+ my $len_bytes = 0;
+ { no bytes; $len_chars = length($s); }
+ { use bytes; $len_bytes = length($s); }
+ print "'$encoded':\n",
+ "utf8, len = $length; chars = $len_chars; bytes = $len_bytes\n";
+ }
+ else {
+ print "'$s':\n",
+ "NOT utf8, len = $length\n";
+ }
+
+ print join ' ', to_hex($s), "\n";
+}
+
+#----------------------------
+
+sub to_hex {
+ return map { sprintf('%4X', $_) } unpack( 'U*', shift );
+}
+
+#==================
+
sub glob_list1 {
# Glob a collection of filenames.
# But no sorting or elimination of duplicates
@@ -9451,9 +10282,10 @@
sub get_time_size {
# Return time and size of file named in argument
# If file does not exist, return (0,-1);
- # Argument _ to stat: use values from previous call, to save disk access..
- return ( ( ( stat($_[0]) )[9] || 0 ),
- ( ( stat(_) )[7] || -1 ) );
+ # Argument _ to stat: use values from previous call, to save disk access.
+ my @result = stat($_[0]);
+ if (@result) { return ($result[9], $result[7]); }
+ else { return (0,-1); }
}
#************************************************************
@@ -9471,7 +10303,6 @@
my $md5 = Digest::MD5->new;
my $ignore_pattern = undef;
-#print "======= GETTING MD5: $source\n";
if ( -d $source ) {
# We won't use checksum for directory
return 0;
@@ -9513,89 +10344,58 @@
#************************************************************
#************************************************************
-sub find_file1 {
- # Usage: find_file1(name, ref_to_array_search_path)
- # Modified find_file, which doesn't die.
- # Given filename and path, return array of:
- # full name
- # retcode
- # On success: full_name = full name with path, retcode = 0
- # On failure: full_name = given name, retcode = 1
+sub find_files {
+ # Usage: find_files( \%files, format, default_ext, \@files, \@not_found )
+ # ???!!! This may be too elaborate. The hash is there to have all the
+ # necessary information, but I don't actually use it.
+ # The files hash, referred to by the 1st argument, has as its keys
+ # specified file names, as specified for example in \bibliography.
+ # The values are to be the names of the corresponding actual files,
+ # as found by kpsewhich, or '' if kpsewhich doesn't find a file.
+ # The format is used in a -format=... option to kpsewhich, e.g., 'bib'
+ # for bib files, 'bst' for bst files.
+ # The 3rd argument contains the default extension to use for not-found files.
+ # The array @files, referred to by the 4th argument, contains the
+ # sorted names of the found files, and then the specifications of the
+ # not-found files.
+ # But
+ # The array @not_found, referred to by the 5th argument, contains the
+ # sorted names of the specified names for the not-found files.
+ # The value of each item in the hash is set to the found filename
+ # corresponding to the key, if a file is found; otherwise it is set to
+ # the empty string.
+ # Return number of files not found.
+ #
+ # ???!!! Ideally use only 1 call to kpsewhich. But KISS for now. The
+ # main use of this subroutine is for bib, bst files (and maybe index
+ # files), which are few in number. Only likely conceivable case for
+ # having many files is with a big document, for which *latex running
+ # time is large, so almost certainly that dwarfs run time for several
+ # runs of kpsewhich.
- my $name = $_[0];
- # Make local copy of path, since we may rewrite it!
- my @path = ();
- if ($_[1]) {
- @path = @{$_[1]};
- }
- if ( $name =~ /^\// ) {
- # Absolute path (if under UNIX)
- # This needs fixing, in general
- if (-e $name) { return( $name, 0 );}
- else { return( $name, 1 );}
- }
- foreach my $dir ( @path ) {
- # Make $dir concatenatable, and empty for current dir:
- if ( $dir eq '.' ) {
- $dir = '';
+ my ($PHfiles, $format, $ext, $PAfiles, $PAnot_found) = @_;
+ @$PAfiles = @$PAnot_found = ();
+ foreach my $name (keys %$PHfiles) {
+ if (my @lines = kpsewhich( "-format=$format", $name ) ) {
+ $$PHfiles{$name} = $lines[0];
+ push @$PAfiles, $lines[0];
}
- elsif ( $dir =~ /[\/\\:]$/ ) {
- #OK if dir ends in / or \ or :
+ else {
+ $$PHfiles{$name} = '';
+ push @$PAnot_found, $name;
}
- elsif ( $dir ne '' ) {
- #Append directory separator only to non-empty dir
- $dir = "$dir/";
- }
- if (-e "$dir$name") {
- return("$dir$name", 0);
- }
}
- my @kpse_result = kpsewhich( $name );
- if ($#kpse_result > -1) {
- return( $kpse_result[0], 0);
+ @$PAnot_found = sort @$PAnot_found;
+ @$PAfiles = sort @$PAfiles;
+ foreach (@$PAnot_found) {
+ if ( ! /\..*$/ ) { $_ .= ".$ext"; }
+ push @$PAfiles, $_;
}
- return("$name" , 1);
-} #END find_file1
+
+ return 1 + $#{$PAnot_found};
+} #END find_files
#************************************************************
-
-sub find_file_list1 {
- # Modified version of find_file_list that doesn't die.
- # Given output and input arrays of filenames, a file suffix, and a path,
- # fill the output array with full filenames
- # Return array of not-found files.
- # Usage: find_file_list1( ref_to_output_file_array,
- # ref_to_input_file_array,
- # suffix,
- # ref_to_array_search_path
- # )
- # SPECIAL TREATMENT TO .bib extension, because of behavior of bibtex
- # OTHER SPECIAL TREATMENT IF EXTENSION IS GIVEN.
-
- my $ref_output = $_[0];
- my $ref_input = $_[1];
- my $suffix = $_[2];
- my $ref_search = $_[3];
- my @not_found = ();
-
- my @return_list = (); # Generate list in local array, since input
- # and output arrays may be same
- my $retcode = 0;
- foreach my $file1 (@$ref_input) {
- my $file = $file1;
- if ($suffix eq '.bib') { $file =~ s/\.bib$//; }
- my ($tmp_file, $find_retcode) = &find_file1( "$file$suffix", $ref_search );
- if ($tmp_file) {
- push @return_list, $tmp_file;
- }
- if ( $find_retcode != 0 ) {
- push @not_found, $file.$suffix;
- }
- }
- @$ref_output = @return_list;
- return @not_found;
-} #END find_file_list1
-
#************************************************************
sub unlink_or_move {
@@ -9662,13 +10462,20 @@
#************************************************************
sub kpsewhich {
-# Usage: kpsewhich( filespec, ...)
-# Returns array of files with paths as found by kpsewhich
-# kpsewhich( 'try.sty', 'jcc.bib' );
-# With standard use of kpsewhich (i.e., without -all option), the array
-# has either 0 or 1 element.
-# Can also do, e.g.,
-# kpsewhich( '-format=bib', 'trial.bib', 'file with spaces');
+ # Usage: kpsewhich( [options, ] filespec, ...)
+ # The arguments are the command line arguments to kpsewhich, and the
+ # return value is the array of filenames that are returned by
+ # kpsewhich.
+ # N.B. kpsewhich returns one line per found file; this routine removes
+ # trailing line ends (\r\n or \n) before putting the line in the
+ # returned array.
+ # The arguments can just be names: e.g.,
+ # kpsewhich( 'try.sty', 'jcc.bib' );
+ # or can include options, e.g.,
+ # kpsewhich( '-format=bib', 'trial.bib', 'file with spaces');
+ # With standard use of kpsewhich (i.e., without -all option), the array
+ # has either 0 or 1 element for each filespec argument.
+
my $cmd = $kpsewhich;
my @args = @_;
if ( ($cmd eq '') || ( $cmd =~ /^NONE($| )/ ) ) {
@@ -9682,7 +10489,7 @@
}
}
$cmd =~ s/%[RBTDO]//g;
- $cmd =~ s/%S/@args/g;
+ $cmd =~ s/%S/@_/g;
my @found = ();
local $fh;
if ( $kpsewhich_show || $diagnostics ) {
@@ -9865,6 +10672,7 @@
sub find_dirs1 {
# Same as find_dirs, but argument is single string with directories
# separated by $search_path_separator
+ # ???!!! WRONG DEFAULT?
find_dirs( &split_search_path( $search_path_separator, ".", $_[0] ) );
}
@@ -10017,7 +10825,7 @@
# Usage: &split_search_path( separator, default, string )
# Splits string by separator and returns array of the elements
# Allow empty last component.
-# Replace empty terms by the default.
+ # Replace empty terms by the default. ???!!! WRONG DEFAULT?
my $separator = $_[0];
my $default = $_[1];
my $search_path = $_[2];
Modified: trunk/Master/texmf-dist/doc/man/man1/latexmk.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/latexmk.1 2022-11-19 00:49:28 UTC (rev 65053)
+++ trunk/Master/texmf-dist/doc/man/man1/latexmk.1 2022-11-19 21:12:09 UTC (rev 65054)
@@ -1,4 +1,4 @@
-.TH LATEXMK 1 "17 March 2022" ""
+.TH LATEXMK 1 "18 November 2022" ""
.SH NAME
latexmk \- generate LaTeX document
.SH SYNOPSIS
@@ -172,11 +172,10 @@
.TP
.B -auxdir=FOO \fRor\fB -aux-directory=FOO
-Sets the directory for auxiliary output files of *latex
-(.aux, .log etc). This
-achieves its effect by the \fB-aux-directory\fR option of *latex,
-which currently is only implemented on the MiKTeX version of
-*latex.
+Sets the directory for auxiliary output files of *latex (.aux, .log etc).
+See the description of the \fI$aux_dir\fR variable, the
+\fB-emulate-aux-dir\fR, and the \fI$emulate_aux\fR variables for some
+complications in using this option with the TeX Live distribution.
See also the \fB-outdir\fR/\fB-output-directory\fR options, and the
\fI$aux_dir\fR, \fI$out_dir\fR, and \fI$search_path_separator\fR
@@ -213,42 +212,30 @@
.TP
.B -bibtex-cond
-When the source file uses bbl file(s) for the bibliography, run
-\fIbibtex\fR or \fIbiber\fR as needed to regenerate the bbl files, but
-only if the
-relevant bib file(s) exist. Thus when the bib files are not
-available, \fIbibtex\fR or \fIbiber\fR is not run, thereby avoiding
-overwriting of
-the bbl file(s).
-Also, always treat .bbl files as precious,
+When the source file uses a bbl file for the bibliography and \fIbibtex\fR
+is used to generate the bibliography, run \fIbibtex\fR as needed to
+regenerate the bbl files only if the relevant bib file(s) exist. Thus when
+the bib file(s) are not available, \fIbibtex\fR is not run, thereby avoiding
+overwriting of the bbl file. Also, always treat .bbl files as precious,
i.e., do not delete them in a cleanup operation.
-This is the default setting.
-It can also be configured by setting the \fI$bibtex_use\fR
-variable to 1 in a configuration file.
+This is the default setting. It can also be configured by setting the
+\fI$bibtex_use\fR variable to 1 in a configuration file.
-The reason for using this setting is that sometimes a .bbl file is
-available containing the bibliography for a document, but the .bib
-file is not available. An example would be for a scientific journal
-where authors submit .tex and .bbl files, but not the original .bib
-file. In that case, running \fIbibtex\fR or \fIbiber\fR would not
-work, and the .bbl file should be treated as a user source file, and
-not as a file that can be regenerated on demand.
+The reason for using this setting is first to allow automatic switching
+between the use and non-use of \fIbibtex\fR depending on the existence or
+not of a bib file. In addition, when submitting articles to a scientific
+journal, it is common to submit only .tex and .bbl files (plus graphics
+files), but not a .bib file. Hence it is often useful to treat .bbl files
+as true source files, that should be preserved under a clean up operation.
-(Note that it is possible for \fIlatexmk\fR to decide that the bib
-file does not exist, even though the bib file does exist and
-\fIbibtex\fR or \fIbiber\fR finds it. The problem is that the bib
-file may not be in
-the current directory but in some search path; the places
-\fIlatexmk\fR and \fIbibtex\fR or \fIbiber\fR cause to be searched need not be
-identical. On modern installations of TeX and related programs this
-problem should not arise, since \fIlatexmk\fR uses the \fIkpsewhich\fR
-program to do the search, and \fIkpsewhich\fR should use the same
-search path as \fIbibtex\fR and \fIbiber\fR. If this problem arises, use the
-\fB-bibtex\fR option when invoking \fIlatexmk\fR.)
+This property can also be configured by setting the \fI$bibtex_use\fR
+variable to 1 in a configuration file.
-Note that this value does \fInot\fR work properly if the document uses
-\fIbiber\fR instead of \fIbibtex\fR. (There's a long story why not.)
+\fBNote\fR that when \fBbiber\fR is used, and a bib file doesn't exist, this
+option does not currently prevent \fIbiber\fR from being run. See the
+documentation on \fI$bibtex_use\fR for more details. However, a bbl file
+is treated as precious.
.TP
.B -bibtex-cond1
@@ -255,13 +242,17 @@
The same as \fB-bibtex-cond\fR except that .bbl files are only
treated as precious if one or more bibfiles fails to exist.
-Thus if all the bib files exist, \fIbibtex\fR or \fIbiber\fR is run to
-generate .bbl files as needed, and then it is appropriate to delete
-the bbl files in a cleanup operation since they can be re-generated.
+Thus if all the bib files exist, \fIbibtex\fR is run to generate .bbl files
+as needed, and then it is appropriate to delete the bbl files in a cleanup
+operation since they can be re-generated.
This property can also be configured by setting the \fI$bibtex_use\fR
variable to 1.5 in a configuration file.
+\fBNote\fR that when \fBbiber\fR is used, and a bib file doesn't exist, this
+option does not currently prevent \fIbiber\fR from being run. See the
+documentation on \fI$bibtex_use\fR for more details.
+
.TP
.B -bibtexfudge\fR or\fB -bibfudge
Turn on the change-directory fudge for bibtex. See documentation of
@@ -477,9 +468,13 @@
.TP
.B -dvi
-Generate dvi version of document.
+Generate dvi version of document using latex.
.TP
+.B -dvilua
+Generate dvi version of document using lualatex instead of latex.
+
+.TP
.B -dvi-
Turn off generation of dvi version of document. (This may get
overridden, if some other file is made (e.g., a .ps file) that is
@@ -487,6 +482,16 @@
requested.)
.TP
+.B -dvilualatex="COMMAND"
+This sets the string specifying the command to run \fIdvi lualatex\fR. It
+behaves like the \fB-pdflatex\fR option, but sets the variable
+\fI$dvilualatex\fR.
+
+\fINote: This option when provided with the COMMAND argument only sets the
+command for invoking dvilualatex; it does not turn on the use of
+dvilualatex. That is done by other options or in an initialization file.\fR
+
+.TP
.B -e <code>
Execute the specified initialization code before processing. The code
is \fIPerl\fR code of the same form as is used in \fIlatexmk\fR's
@@ -872,8 +877,13 @@
.TP
.B -pdfdvi
-Generate pdf version of document from the dvi file, by default using dvipdf.
+Generate dvi file and then pdf version of document from the dvi file, by
+default using dvipdf.
+The program used to compile the document to dvi is \fIlatex\fR by default,
+but this can be changed to \fIdvilulatex\fR by the use of the \fB-dvilua\fR
+option or by setting \fI$dvi_mode\fR to 2.
+
.TP
.B -pdflua
Generate pdf version of document using \fIlualatex\fR.
@@ -880,9 +890,13 @@
.TP
.B -pdfps
-Generate pdf version of document from the .ps file, by default using
-\fIps2pdf\fR.
+Generate dvi file, ps file from the dvi file, and then pdf file from the
+ps file.
+The program used to compile the document to dvi is \fIlatex\fR by default,
+but this can be changed to \fIdvilulatex\fR by the use of the \fB-dvilua\fR
+option or by setting \fI$dvi_mode\fR to 2.
+
.TP
.B -pdfxe
Generate pdf version of document using \fIxelatex\fR. Note that to
@@ -1202,8 +1216,8 @@
to configure \fIlatexmk\fR with changed values of its configuration
variables, the relevant ones being \fI$bibtex_silent_switch\fR,
\fI$biber_silent_switch\fR, \fI$dvipdf_silent_switch\fR,
-\fI$dvips_silent_switch\fR, \fI$latex_silent_switch\fR,
-\fI$lualatex_silent_switch\fR
+\fI$dvips_silent_switch\fR, \fI$dvilualatex_silent_switch\fR,
+\fI$latex_silent_switch\fR, \fI$lualatex_silent_switch\fR
\fI$makeindex_silent_switch\fR, \fI$pdflatex_silent_switch\fR,
and \fI$xelatex_silent_switch\fR
@@ -1301,6 +1315,10 @@
configuration variable \fI$warnings_as_errors\fR.
.TP
+.B -xdv
+Generate xdv version of document using xelatex.
+
+.TP
.B -xelatex
Use \fIxelatex\fR. That is, use \fIxelatex\fR to process the source file(s) to
pdf. The generation of dvi and postscript files is turned off.
@@ -1968,10 +1986,12 @@
which is the directory to which general output files are to be
written.
-\fBImportant note\fR: The effect of \fI$aux_dir\fR, if different from
-\fI$out_dir\fR, is achieved by giving \fI*latex\fR the
-\fB-aux-directory\fR. Currently (Dec. 2011 and later) this only works on the
-MiKTeX version of \fI*latex\fR.
+\fBImportant note\fR: The default implementation of the aux dir is to give
+\fI*latex\fR the \fB-aux-directory\fR option. But that only works with the
+MiKTeX distribution, not with the TeX Live distribution. Latexmk has an
+alternative implementation that avoids this problem: See the description of
+\fB-emulate-aux-dir\fR option and the \fI$emulate_aux\fR variable for
+details.
See also the documentation of \fI$out_dir\fR for some complications on
what directory names are suitable.
@@ -1997,6 +2017,20 @@
.TP
+.B $bad_warning_is_error [0]
+Whether to treat bad warnings reported by *latex in log file as errors. The
+specifications of the warning messages are in \fI at bad_warnings\fR.
+
+.TP
+.B @bad_warnings
+Array of regular expressions specifying messages in log file that are
+officially treated as warnings rather than errors by *latex, but which a
+user may treat as errors: See \fI$bad_warning_is_error\fR.
+
+Currently the default set of these warnings is those about \\end occuring
+inside constructs.
+
+.TP
.B $banner [0]
If nonzero, the banner message is printed across each page when
converting the dvi file to postscript. Without modifying the variable
@@ -2100,21 +2134,24 @@
whether or not .bbl files are deleted in a cleanup operation.
The possible values of \fI$bibtex_use\fR are:
- 0: never use BibTeX or biber;
-never delete .bbl files in a cleanup.
- 1: only use \fIbibtex\fR or \fIbiber\fR if the bib files exist;
-never delete .bbl files in a cleanup.
- 1.5: only use \fIbibtex\fR or \fIbiber\fR if the bib files exist;
-conditionally delete .bbl files in a cleanup (i.e., delete them only
-when the bib files all exist).
+ 0: never use \fIbibtex\fR or \fIbiber\fR; never delete .bbl files in a cleanup.
+ 1: only use \fIbibtex\fR if the bib file(s) exist; never delete .bbl
+files in a cleanup.
+ 1.5: only use \fIbibtex\fR if the bib files exist; conditionally
+delete .bbl files in a cleanup (i.e., delete them only when the bib files
+all exist).
2: run \fIbibtex\fR or \fIbiber\fR whenever it appears necessary to
-update the bbl
-files, without testing for the existence of the bib files;
-always delete .bbl files in a cleanup.
+update the bbl file(s), without testing for the existence of the bib
+files; always delete .bbl files in a cleanup.
-Note that the value 1.5 does \fInot\fR work properly if the document
-uses \fIbiber\fR instead of \fIbibtex\fR. (There's a long story why
-not.)
+\fBImportant note:\fR Currently, the values 1 and 1.5 do \fInot\fR work
+properly if the document uses \fIbiber\fR instead of \fIbibtex\fR. When
+\fIbiber\fR is used, the values 1 and 1.5 for \fI$bibtex_use\fR are
+equivalent to 2 as regards the running of \fIbiber\fR. (There's a long
+story why not. Basically, the problem is that when \fIbiber\fR is used,
+\fIlatexmk\fR only knows the names and status of the bibfiles after running
+\fIbiber\fR. In contrast, when \fIbibtex\fR is used, the information is
+available after a run of *latex. It is a problem for the future to correct this.)
.TP
.B $cleanup_includes_cusdep_generated [0]
@@ -2176,7 +2213,7 @@
\fI$out_dir\fR, which is the only case directly supported by TeXLive,
unlike MiKTeX. Note that even with TeXLive latexmk does now support
different values for the directories -- see the explanation of the
-\fI$emulate_aux variable.
+\fI$emulate_aux\fR variable.
If \fI$out_dir\fR and \fI$aux_dir\fR different, latexmk actually deletes
any files of the specified names in both \fI$aux_dir\fR and \fI$out_dir\fR;
@@ -2353,16 +2390,43 @@
.B $dvi_filter [empty]
The dvi file filter to be run on the newly produced dvi file before
other processing. Equivalent to specifying the \fB-dF\fR option.
+
.TP
+.B $dvilualatex ["dvilualatex %O %S"]
+Specifies the command line to invoke
+the dvilualatex program. Note that as with other programs, you
+can use this variable not just to change the name of the program used,
+but also specify options to the program. E.g.,
+
+ $dvilualatex = "dvilualatex --src-specials %O %S";
+
+To do a coordinated setting of all of \fI$dvilualatex\fR, \fI$latex\fR,
+\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR, see the section
+"Advanced Configuration".
+
+.TP
.B $dvi_mode [See below for default]
-If nonzero, generate a dvi version of the document.
+If one, generate a dvi version of the document by use of latex.
Equivalent to the \fB-dvi\fR option.
+If 2, generate a dvi version of the document by use of dvilualatex.
+Equivalent to the \fB-dvilua\fR option.
+
The variable $dvi_mode defaults to 0, but if no explicit requests are
made for other types of file (postscript, pdf), then $dvi_mode will be
set to 1. In addition, if a request for a file for which a .dvi file
-is a prerequisite, then $dvi_mode will be set to 1.
+is a prerequisite and $dvi_mode is zero, then $dvi_mode is set to 1.
+
+
.TP
+.B $dvilualatex_silent_switch ["-interaction=batchmode"]
+Switch(es) for the \fIdvilualatex\fR program (specified in the variable
+\fI$dvilualatex\fR) when silent mode is on.
+
+See details of the \fI$latex_silent_switch\fR for other information
+that equally applies to \fI$dvilualatex_silent_switch\fR.
+
+.TP
.B $dvi_previewer ["start xdvi %O %S" under UNIX]
The command to invoke a dvi-previewer.
[Under MS-Windows the default is "start"; then \fIlatexmk\fR arranges to
@@ -2461,7 +2525,9 @@
If you use a version of *latex that doesn't support -aux-directory, e.g.,
TeXLive, latexmk will automatically switch aux_dir emulation on after the
first run of *latex, because it will find the .log file in the wrong
-place.
+place. But it is better to set \fI$emulate_aux\fR to 1 in an rc file, or
+equivalently to use the \fB-emulate-aux-dir\fR option. This emulation mode
+works equally well with MiKTeX.
Aux_directory emulation means that when *latex is invoked, the \fIoutput\fR
directory provided to *latex is set to be the aux_dir. After that, any
@@ -2704,9 +2770,9 @@
$latex = "latex --src-specials %O %S";
-To do a coordinated setting of all of \fI$latex\fR, \fI$pdflatex\fR,
-\fI$lualatex\fR, and \fI$xelatex\fR, see the section "Advanced
-Configuration".
+To do a coordinated setting of all of \fI$dvilualatex\fR, \fI$latex\fR,
+\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR, see the section
+"Advanced Configuration".
.TP
.B %latex_input_extensions
@@ -2790,9 +2856,9 @@
the LaTeX processing program that is to be used when the \fIlualatex\fR
program is called for (e.g., by the option \fB-lualatex\fR.
-To do a coordinated setting of all of \fI$latex\fR, \fI$pdflatex\fR,
-\fI$lualatex\fR, and \fI$xelatex\fR, see the section "Advanced
-Configuration".
+To do a coordinated setting of all of \fI$dvilualatex\fR, \fI$latex\fR,
+\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR, see the section
+"Advanced Configuration".
.TP
.B %lualatex_input_extensions
@@ -2938,9 +3004,10 @@
variables for the use of \fIlualatex\fR or \fIxelatex\fR. See
\fI$lualatex\fR and \fI$xelatex\fR.)
-To do a coordinated setting of all of \fI$latex\fR, \fI$pdflatex\fR,
-\fI$lualatex\fR, and \fI$xelatex\fR, see the section "Advanced
-Configuration".
+To do a coordinated setting of all of \fI$dvilualatex\fR, \fI$latex\fR,
+\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR, see the section
+"Advanced Configuration".
+
.TP
.B %pdflatex_input_extensions
This variable specifies the extensions tried by \fIlatexmk\fR when it finds
@@ -3195,7 +3262,7 @@
After initialization, whether to give a list of the RC files read.
.TP
.B $recorder [1]
-Whether to use the \fB-recorder\fR option to \fI(latex\fR
+Whether to use the \fB-recorder\fR option to \fI*latex\fR.
Use of this option results in a file of extension
\fI.fls\fR containing a list of the files that these programs have
read and written. \fILatexmk\fR will then use this file to improve
@@ -3356,6 +3423,10 @@
commands isn't set.)
.TP
+.B $xdv_mode [0]
+If one, generate an xdv version of the document by use of xelatex.
+
+.TP
.B $xdvipdfmx ["xdvipdfmx -E -o %D %O %S"]
The program to make a pdf file from an xdv file (used in conjunction
@@ -3380,9 +3451,9 @@
\fIlatexmk\fR makes a .xdv file rather than a .pdf file when \fIxelatex\fR
is used.
-To do a coordinated setting of all of \fI$latex\fR, \fI$pdflatex\fR,
-\fI$lualatex\fR, and \fI$xelatex\fR, see the section "Advanced
-Configuration".
+To do a coordinated setting of all of \fI$dvilualatex\fR, \fI$latex\fR,
+\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR, see the section
+"Advanced Configuration".
.TP
.B %xelatex_input_extensions
@@ -3824,7 +3895,8 @@
.SS Coordinated Setting of Commands for *latex
-To set all of \fI$latex\fR, \fI$pdflatex\fR, \fI$lualatex\fR, and
+To set all of \fI$dvilualatex\fR, \fI$latex\fR, \fI$pdflatex\fR,
+\fI$lualatex\fR, and
\fI$xelatex\fR to a common pattern, you can use one of the following
subroutines, std_tex_cmds, alt_tex_cmds, and set_tex_cmds.
@@ -3833,16 +3905,16 @@
&std_tex_cmds;
This results in \fI$latex = 'latex %O %S'\fR, and similarly for
-\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR. Note the
-ampersand in the invocation; this indicates to Perl that a subroutine
-is being called.
+\fI$dvilualatex\fR, \fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR.
+Note the ampersand in the invocation; this indicates to Perl that a
+subroutine is being called.
&alt_tex_cmds;
This results in \fI$latex = 'latex %O %P'\fR, and similarly for
-\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR. Note the
-ampersand in the invocation; this indicates to Perl that a subroutine
-is being called.
+\fI$dvilualatex\fR, \fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR.
+Note the ampersand in the invocation; this indicates to Perl that a
+subroutine is being called.
set_tex_cmds( CMD_SPEC );
@@ -3987,9 +4059,23 @@
Thus we now have a method by which all the subsidiary processing is
delegated to \fImake\fR.
+.SH NON_ASCII CHARACTERS IN FILENAMES, RC FILES, ETC
+
+Modern operating systems and file systems allow non-ASCII characters in
+the names of files and directories that encompass the full Unicode range.
+Mostly, \fIlatexmk\fR deals with these correctly. However, there are some
+situations in which there are problems, notably on Microsoft Windows.
+Prior to version 4.77, \fIlatexmk\fR had problems with non-ASCII filenames
+on Windows, even though there were no corresponding problems on macOS and
+Linux. These problems are corrected in the present version.
+
+\fBDETAILS TO BE FILLED IN\fR
+
+
.SH SEE ALSO
latex(1), bibtex(1), lualatex(1), pdflatex(1), xelatex(1).
-.SH BUGS
+
+.SH BUGS (SELECTED)
Sometimes a viewer (gv) tries to read an updated .ps or .pdf file
after its creation is started but before the file is complete. Work
around: manually refresh (or reopen) display. Or use one of the other
@@ -4018,7 +4104,7 @@
harvested too easily.)
.SH AUTHOR
Current version, by John Collins
-(Version 4.77).
+(Version 4.78).
Report bugs etc to his e-mail (jcc8 at psu.edu).
Released version can be obtained from CTAN:
Modified: trunk/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/support/latexmk/CHANGES
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/CHANGES 2022-11-19 00:49:28 UTC (rev 65053)
+++ trunk/Master/texmf-dist/doc/support/latexmk/CHANGES 2022-11-19 21:12:09 UTC (rev 65054)
@@ -785,7 +785,8 @@
From v. 4.75 to 4.76
In fdb_latexmk file, sort generated file list by name.
- If nothing is done in a rerun, don't do the unnecessary rewrite of fdb_latexmk file.
+ If nothing is done in a rerun, don't do the unnecessary rewrite of
+ fdb_latexmk file.
Improve some diagnostics.
Add /etc to list of locations for system rc files (with Unix-like OSs).
@@ -804,3 +805,16 @@
used, thereby reducing misparses of information in log file.
Reinstate Windows batch file for running latexmk, now called latexmk.cmd.
+From v. 4.77 to 4.78
+ Option -dvilua to generate dvi file by lualatex
+ Option -xdv to generate xdv file by xelatex
+ To support these, change in definition of $dvi_mode, and new variables
+ $dvilualatex, $xdv_mode.
+ Bug corrections etc.
+ Configuration variable $bad_warnings_as_error to allow certain bad warnings
+ in log file (e.g., '\end inside ...') to be treated by latexmk as if
+ *latex had reported an actual error.
+ On MS-Windows, correctly handle non-ASCII names for file and directory
+ variables set in rc files.
+ Other improvements in treatment of non-ASCII characters in filenames.
+
Modified: trunk/Master/texmf-dist/doc/support/latexmk/INSTALL
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/INSTALL 2022-11-19 00:49:28 UTC (rev 65053)
+++ trunk/Master/texmf-dist/doc/support/latexmk/INSTALL 2022-11-19 21:12:09 UTC (rev 65054)
@@ -1,6 +1,6 @@
INSTALLING latexmk
==================
- (Version 4.77, 17 Mar. 2022)
+ (Version 4.78, 18 Nov. 2022)
John Collins
Physics Department
Modified: trunk/Master/texmf-dist/doc/support/latexmk/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/README 2022-11-19 00:49:28 UTC (rev 65053)
+++ trunk/Master/texmf-dist/doc/support/latexmk/README 2022-11-19 21:12:09 UTC (rev 65054)
@@ -1,4 +1,4 @@
-Latexmk, version 4.77, 17 Mar 2022
+Latexmk, version 4.78, 18 Nov 2022
----------------------------------
Latexmk completely automates the process of generating a LaTeX
Deleted: trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/fix-aux.latexmkrc
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/fix-aux.latexmkrc 2022-11-19 00:49:28 UTC (rev 65053)
+++ trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/fix-aux.latexmkrc 2022-11-19 21:12:09 UTC (rev 65054)
@@ -1,110 +0,0 @@
-# This shows how to implement the use of different values for $aux_dir and
-# $out_dir when the latex (etc) engines don't support the -aux-directory
-# option. (Of the standard distributions, MiKTeX supports -aux-directory,
-# but TeXLive does not.)
-
-# !!!IMPORTANT: THIS CONFIGURATION IS NO LONGER NECESSARY. From V. 4.74b onwards,
-# latexmk can handle the aux_dir isssue itself --- see the documentation on the
-# $emulate_aux variable.
-
-
-foreach my $cmd ('latex', 'lualatex', 'pdflatex', 'xelatex' ) {
- ${$cmd} = "internal latex_fix_aux $cmd %O %S";
-}
-$xelatex =~ s/%O/-no-pdf %O/;
-
-
-#---------------------------
-
-sub latex_fix_aux {
- # Fudge to allow use of -aux_directory option with non-MiKTeX system.
- # This subroutine is called to do a compilation by one of latex, pdflatex,
- # etc. It's arguments are the command name, and the command-line arguments,
- # including possible uses of the options -aux-directory, -output-directory.
- # Functioning:
- # 1. Obtain the values of the aux and output directories from the options
- # on the command line, with appropriate defaults if one or both options
- # is not used.
- # 2. Change the command line (a) to avoid the use of the -aux-directory
- # option, and (b) to use the -output-directory to get all output
- # sent to the intended aux-directory. If neither an -aux-directory
- # nor an -output-directory option is used, no change is made to the
- # command line.
- # 3. Run the command.
- # 4. If the aux and output directories are different, move any of the dvi,
- # fls, pdf, ps and synctex.gz files that are present in the intended aux
- # directory to the intended output directory.
- # N.B. It might seem more appropriate to keep the fls file in the aux
- # directory. But MiKTeX puts it in the output directory, so we must do
- # the same to copy its behavior.
- # It might also seem appropriate for an xdv file to go in the output
- # directory, like a dvi file. But xelatex under MiKTeX puts it in the
- # aux directory, so we must copy that behavior.
-
- my @move_exts = ('dvi', 'fls', 'pdf', 'ps', 'synctex.gz' );
-
- # Determine aux and output directories from command line:
- my $auxD = '';
- my $outD = '';
- foreach (@_) {
- if ( /^-{1,2}aux-directory=(.*)$/ ) {
- $auxD = $1;
- }
- elsif ( /^-{1,2}output-directory=(.*)$/ ) {
- $outD = $1;
- }
- }
- if ( $outD eq '' ) { $outD = '.'; }
- if ( $auxD eq '' ) { $auxD = $outD; }
-
-# Construct modified command line, with at most one occurrence of -output-directory
- my @args_act = ();
- my $set_outD = 0;
- foreach (@_) {
- if ( /^-{1,2}(aux|output)-directory=.*$/ ) {
- if ( ! $set_outD ) {
- push @args_act, "-output-directory=$auxD";
- $set_outD = 1;
- }
- }
- else {
- push @args_act, $_;
- }
- }
-
-# Construct strings for aux and output directories that are suitable
-# for prepending to a file name, so that they have any necessary
-# directory separators:
- my $outD1 = $outD;
- my $auxD1 = $auxD;
- foreach ( $auxD1, $outD1 ) {
- # Append directory separator '/', but only for a non-empty name
- # that isn't simple an MSWin drive name.
- if ( ($_ ne '') && ! m([\\/\:]$) ) {
- $_ .= '/';
- }
- # Clean up by removing any sequence of './'. These refer to
- # current directory.
- while ( s[^\.\/][] ) {}
- }
-
- print "Running: '@args_act'\n";
- my $ret = system @args_act;
- if ($auxD ne $outD) {
- print "Move @move_exts files from '$auxD' to '$outD'\n";
- # Use copy and unlink, not rename, since some viewers appear to keep the
- # viewed file open. So if rename were used, such viewers would see the
- # old version of the file, rather than the new one. With copy, the
- # contents of the old file are normally overwritten by the new contents.
- #
- # In addition, copy works across file system boundaries, but rename
- # doesn't.
- foreach my $ext (@move_exts) {
- copy "$auxD1$root_filename.$ext", "$outD1$root_filename.$ext";
- unlink "$auxD1$root_filename.$ext";
- }
- }
- return $ret;
-}
-
-#---------------------------
Added: trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/glossary_latexmkrc
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/glossary_latexmkrc (rev 0)
+++ trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/glossary_latexmkrc 2022-11-19 21:12:09 UTC (rev 65054)
@@ -0,0 +1,39 @@
+# This shows how to use the glossaries package
+# (http://www.ctan.org/pkg/glossaries) and the glossaries-extra package
+# (http://www.ctan.org/pkg/glossaries-extra) with latexmk.
+
+# N.B. There is also the OBSOLETE glossary package
+# (http://www.ctan.org/pkg/glossary), which has some differences. See item 2.
+
+# 1. If you use the glossaries or the glossaries-extra package, then you can use:
+
+ add_cus_dep( 'acn', 'acr', 0, 'makeglossaries' );
+ add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' );
+ $clean_ext .= " acr acn alg glo gls glg";
+
+ sub makeglossaries {
+ my ($base_name, $path) = fileparse( $_[0] );
+ my @args = ( "-q", "-d", $path, $base_name );
+ if ($silent) { unshift @args, "-q"; }
+ return system "makeglossaries", "-d", $path, $base_name;
+ }
+
+# 2. The above will tend to run makeglossaries more often than needed, since
+# each out of date file will trigger the use of makeglossaries, even
+# though makeglossaries makes all the glossaries. The following solution
+# solves this, but at the expense of not having the convenience that
+# makeglossaries can change how it makes the glossaries depending on the
+# settings of the glossaries package.
+# A better solution will need more advanced work.
+#
+# add_cus_dep( 'acn', 'acr', 0, 'makeglossaries' );
+# add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' );
+# $clean_ext .= " acr acn alg glo gls glg";
+#
+# sub makeglossaries {
+# my @args = ( "-s", "$_[0].ist", "-t", "$$Psource.ilg",
+# "-o", $$Pdest, $$Psource );
+# if ($silent) { unshift @args, "-q"; }
+# return system "makeindex", @args;
+# }
+
Modified: trunk/Master/texmf-dist/doc/support/latexmk/latexmk.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt 2022-11-19 00:49:28 UTC (rev 65053)
+++ trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt 2022-11-19 21:12:09 UTC (rev 65054)
@@ -61,7 +61,7 @@
- 17 March 2022 1
+ 18 November 2022 1
@@ -127,7 +127,7 @@
- 17 March 2022 2
+ 18 November 2022 2
@@ -193,7 +193,7 @@
- 17 March 2022 3
+ 18 November 2022 3
@@ -204,9 +204,9 @@
-auxdir=FOO or -aux-directory=FOO
Sets the directory for auxiliary output files of *latex (.aux,
- .log etc). This achieves its effect by the -aux-directory op-
- tion of *latex, which currently is only implemented on the MiK-
- TeX version of *latex.
+ .log etc). See the description of the $aux_dir variable, the
+ -emulate-aux-dir, and the $emulate_aux variables for some com-
+ plications in using this option with the TeX Live distribution.
See also the -outdir/-output-directory options, and the
$aux_dir, $out_dir, and $search_path_separator configuration
@@ -243,23 +243,23 @@
-bibtex-cond
- When the source file uses bbl file(s) for the bibliography, run
- bibtex or biber as needed to regenerate the bbl files, but only
- if the relevant bib file(s) exist. Thus when the bib files are
- not available, bibtex or biber is not run, thereby avoiding
- overwriting of the bbl file(s). Also, always treat .bbl files
- as precious, i.e., do not delete them in a cleanup operation.
+ When the source file uses a bbl file for the bibliography and
+ bibtex is used to generate the bibliography, run bibtex as
+ needed to regenerate the bbl files only if the relevant bib
+ file(s) exist. Thus when the bib file(s) are not available,
+ bibtex is not run, thereby avoiding overwriting of the bbl file.
+ Also, always treat .bbl files as precious, i.e., do not delete
+ them in a cleanup operation.
- This is the default setting. It can also be configured by set-
+ This is the default setting. It can also be configured by set-
ting the $bibtex_use variable to 1 in a configuration file.
- The reason for using this setting is that sometimes a .bbl file
- is available containing the bibliography for a document, but the
- .bib file is not available. An example would be for a
+ The reason for using this setting is first to allow automatic
+ switching between the use and non-use of bibtex depending on the
- 17 March 2022 4
+ 18 November 2022 4
@@ -268,25 +268,19 @@
LATEXMK(1) General Commands Manual LATEXMK(1)
- scientific journal where authors submit .tex and .bbl files, but
- not the original .bib file. In that case, running bibtex or
- biber would not work, and the .bbl file should be treated as a
- user source file, and not as a file that can be regenerated on
- demand.
+ existence or not of a bib file. In addition, when submitting
+ articles to a scientific journal, it is common to submit only
+ .tex and .bbl files (plus graphics files), but not a .bib file.
+ Hence it is often useful to treat .bbl files as true source
+ files, that should be preserved under a clean up operation.
- (Note that it is possible for latexmk to decide that the bib
- file does not exist, even though the bib file does exist and
- bibtex or biber finds it. The problem is that the bib file may
- not be in the current directory but in some search path; the
- places latexmk and bibtex or biber cause to be searched need not
- be identical. On modern installations of TeX and related pro-
- grams this problem should not arise, since latexmk uses the
- kpsewhich program to do the search, and kpsewhich should use the
- same search path as bibtex and biber. If this problem arises,
- use the -bibtex option when invoking latexmk.)
+ This property can also be configured by setting the $bibtex_use
+ variable to 1 in a configuration file.
- Note that this value does not work properly if the document uses
- biber instead of bibtex. (There's a long story why not.)
+ Note that when biber is used, and a bib file doesn't exist, this
+ option does not currently prevent biber from being run. See the
+ documentation on $bibtex_use for more details. However, a bbl
+ file is treated as precious.
-bibtex-cond1
@@ -293,39 +287,45 @@
The same as -bibtex-cond except that .bbl files are only treated
as precious if one or more bibfiles fails to exist.
- Thus if all the bib files exist, bibtex or biber is run to gen-
- erate .bbl files as needed, and then it is appropriate to delete
- the bbl files in a cleanup operation since they can be re-gener-
- ated.
+ Thus if all the bib files exist, bibtex is run to generate .bbl
+ files as needed, and then it is appropriate to delete the bbl
+ files in a cleanup operation since they can be re-generated.
- This property can also be configured by setting the $bibtex_use
+ This property can also be configured by setting the $bibtex_use
variable to 1.5 in a configuration file.
+ Note that when biber is used, and a bib file doesn't exist, this
+ option does not currently prevent biber from being run. See the
+ documentation on $bibtex_use for more details.
+
-bibtexfudge or -bibfudge
- Turn on the change-directory fudge for bibtex. See documenta-
+ Turn on the change-directory fudge for bibtex. See documenta-
tion of $bibtex_fudge for details.
-bibtexfudge- or -bibfudge-
- Turn off the change-directory fudge for bibtex. See documenta-
+ Turn off the change-directory fudge for bibtex. See documenta-
tion of $bibtex_fudge for details.
-bm <message>
- A banner message to print diagonally across each page when con-
- verting the dvi file to postscript. The message must be a sin-
+ A banner message to print diagonally across each page when con-
+ verting the dvi file to postscript. The message must be a sin-
gle argument on the command line so be careful with quoting spa-
ces and such.
- Note that if the -bm option is specified, the -ps option is as-
+ Note that if the -bm option is specified, the -ps option is as-
sumed.
+ -bi <intensity>
+ How dark to print the banner message. A decimal number between
+ 0 and 1. 0 is black and 1 is white. The default is 0.95, which
- 17 March 2022 5
+ 18 November 2022 5
@@ -334,17 +334,14 @@
LATEXMK(1) General Commands Manual LATEXMK(1)
- -bi <intensity>
- How dark to print the banner message. A decimal number between
- 0 and 1. 0 is black and 1 is white. The default is 0.95, which
is OK unless your toner cartridge is getting low.
-bs <scale>
- A decimal number that specifies how large the banner message
- will be printed. Experimentation is necessary to get the right
- scale for your message, as a rule of thumb the scale should be
- about equal to 1100 divided by the number of characters in the
+ A decimal number that specifies how large the banner message
+ will be printed. Experimentation is necessary to get the right
+ scale for your message, as a rule of thumb the scale should be
+ about equal to 1100 divided by the number of characters in the
message. The default is 220.0 which is just right for 5 charac-
ter messages.
@@ -356,139 +353,140 @@
-c Clean up (remove) all regeneratable files generated by latex and
bibtex or biber except dvi, postscript and pdf. These files are
- a combination of log files, aux files, latexmk's database file
- of source file information, and those with extensions specified
- in the @generated_exts configuration variable. In addition,
+ a combination of log files, aux files, latexmk's database file
+ of source file information, and those with extensions specified
+ in the @generated_exts configuration variable. In addition,
files specified by the $clean_ext and @generated_exts configura-
tion variables are removed.
- This cleanup is instead of a regular make. See the -gg option
+ This cleanup is instead of a regular make. See the -gg option
if you want to do a cleanup followed by a make.
- Treatment of .bbl files: If $bibtex_use is set to 0 or 1, bbl
- files are always treated as non-regeneratable. If $bibtex_use
+ Treatment of .bbl files: If $bibtex_use is set to 0 or 1, bbl
+ files are always treated as non-regeneratable. If $bibtex_use
is set to 1.5, bbl files are counted as non-regeneratable condi-
- tionally: If the bib file exists, then bbl files are regenerat-
- able, and are deleted in a clean up. But if $bibtex_use is 1.5
- and a bib file doesn't exist, then the bbl files are treated as
+ tionally: If the bib file exists, then bbl files are regenerat-
+ able, and are deleted in a clean up. But if $bibtex_use is 1.5
+ and a bib file doesn't exist, then the bbl files are treated as
non-regeneratable and hence are not deleted.
- In contrast, if $bibtex_use is set to 2, bbl files are always
+ In contrast, if $bibtex_use is set to 2, bbl files are always
treated as regeneratable, and are deleted in a cleanup.
- Treatment of files generated by custom dependencies: If
- $cleanup_includes_cusdep_generated is nonzero, regeneratable
- files are considered as including those generated by custom de-
- pendencies and are also deleted. Otherwise these files are not
+ Treatment of files generated by custom dependencies: If
+ $cleanup_includes_cusdep_generated is nonzero, regeneratable
+ files are considered as including those generated by custom de-
+ pendencies and are also deleted. Otherwise these files are not
deleted.
-C Clean up (remove) all regeneratable files generated by latex and
bibtex or biber. This is the same as the -c option with the ad-
- dition of dvi, postscript and pdf files, and those specified in
+ dition of dvi, postscript and pdf files, and those specified in
the $clean_full_ext configuration variable.
+ This cleanup is instead of a regular make. See the -gg option
+ if you want to do a cleanup followed by a make.
- 17 March 2022 6
+ 18 November 2022 6
+
LATEXMK(1) General Commands Manual LATEXMK(1)
- This cleanup is instead of a regular make. See the -gg option
- if you want to do a cleanup followed by a make.
-
- See the -c option for the specification of whether or not .bbl
+ See the -c option for the specification of whether or not .bbl
files are treated as non-regeneratable or regeneratable.
- If $cleanup_includes_cusdep_generated is nonzero, regeneratable
- files are considered as including those generated by custom de-
- pendencies and are also deleted. Otherwise these files are not
+ If $cleanup_includes_cusdep_generated is nonzero, regeneratable
+ files are considered as including those generated by custom de-
+ pendencies and are also deleted. Otherwise these files are not
deleted.
- -CA (Obsolete). Now equivalent to the -C option. See that option
+ -CA (Obsolete). Now equivalent to the -C option. See that option
for details.
- -cd Change to the directory containing the main source file before
- processing it. Then all the generated files (.aux, .log, .dvi,
+ -cd Change to the directory containing the main source file before
+ processing it. Then all the generated files (.aux, .log, .dvi,
.pdf, etc) will be relative to the source file.
- This option is particularly useful when latexmk is invoked from
- a GUI configured to invoke latexmk with a full pathname for the
+ This option is particularly useful when latexmk is invoked from
+ a GUI configured to invoke latexmk with a full pathname for the
source file.
- This option works by setting the $do_cd configuration variable
- to one; you can set that variable if you want to configure la-
+ This option works by setting the $do_cd configuration variable
+ to one; you can set that variable if you want to configure la-
texmk to have the effect of the -cd option without specifying it
on the command line. See the documentation for that variable.
- -cd- Do NOT change to the directory containing the main source file
+ -cd- Do NOT change to the directory containing the main source file
before processing it. Then all the generated files (.aux, .log,
- .dvi, .pdf, etc) will be relative to the current directory
+ .dvi, .pdf, etc) will be relative to the current directory
rather than the source file.
- This is the default behavior and corresponds to the behavior of
+ This is the default behavior and corresponds to the behavior of
the *latex programs. However, it is not desirable behavior when
- latexmk is invoked by a GUI configured to invoke latexmk with a
+ latexmk is invoked by a GUI configured to invoke latexmk with a
full pathname for the source file. See the -cd option.
- This option works by setting the $do_cd configuration variable
- to zero. See the documentation for that variable for more in-
+ This option works by setting the $do_cd configuration variable
+ to zero. See the documentation for that variable for more in-
formation.
- -CF Remove the file containing the database of source file informa-
+ -CF Remove the file containing the database of source file informa-
tion, before doing the other actions requested.
- -d Set draft mode. This prints the banner message "DRAFT" across
- your page when converting the dvi file to postscript. Size and
+ -d Set draft mode. This prints the banner message "DRAFT" across
+ your page when converting the dvi file to postscript. Size and
intensity can be modified with the -bs and -bi options. The -bm
- option will override this option as this is really just a short
+ option will override this option as this is really just a short
way of specifying:
+ latexmk -bm DRAFT
- 17 March 2022 7
+ 18 November 2022 7
+
+
LATEXMK(1) General Commands Manual LATEXMK(1)
- latexmk -bm DRAFT
-
- Note that if the -d option is specified, the -ps option is as-
+ Note that if the -d option is specified, the -ps option is as-
sumed.
-deps Show a list of dependent files after processing. This is in the
- form of a dependency list of the form used by the make program,
+ form of a dependency list of the form used by the make program,
and it is therefore suitable for use in a Makefile. It gives an
overall view of the files without listing intermediate files, as
well as latexmk can determine them.
- By default the list of dependent files is sent to stdout (i.e.,
- normally to the screen unless you've redirected latexmk's out-
+ By default the list of dependent files is sent to stdout (i.e.,
+ normally to the screen unless you've redirected latexmk's out-
put). But you can set the filename where the list is sent by the
-deps-out= option.
- See the section "USING latexmk WITH make" for an example of how
+ See the section "USING latexmk WITH make" for an example of how
to use a dependency list with make.
- Users familiar with GNU automake and gcc will find that the
- -deps option is very similar in its purpose and results to the
- -M option to gcc. (In fact, latexmk also has options -M, -MF,
+ Users familiar with GNU automake and gcc will find that the
+ -deps option is very similar in its purpose and results to the
+ -M option to gcc. (In fact, latexmk also has options -M, -MF,
and -MP options that behave like those of gcc.)
@@ -496,7 +494,7 @@
Equivalent to -deps.
- -deps- Do not show a list of dependent files after processing. (This
+ -deps- Do not show a list of dependent files after processing. (This
is the default.)
@@ -505,59 +503,64 @@
-deps-out=FILENAME
- Set the filename to which the list of dependent files is writ-
- ten. If the FILENAME argument is omitted or set to "-", then
+ Set the filename to which the list of dependent files is writ-
+ ten. If the FILENAME argument is omitted or set to "-", then
the output is sent to stdout.
- Use of this option also turns on the output of the list of de-
+ Use of this option also turns on the output of the list of de-
pendent files after processing.
- -dF Dvi file filtering. The argument to this option is a filter
- which will generate a filtered dvi file with the extension
- ".dviF". All extra processing (e.g. conversion to postscript,
- preview, printing) will then be performed on this filtered dvi
+ -dF Dvi file filtering. The argument to this option is a filter
+ which will generate a filtered dvi file with the extension
+ ".dviF". All extra processing (e.g. conversion to postscript,
+ preview, printing) will then be performed on this filtered dvi
file.
Example usage: To use dviselect to select only the even pages of
+ the dvi file:
- 17 March 2022 8
+ 18 November 2022 8
+
LATEXMK(1) General Commands Manual LATEXMK(1)
- the dvi file:
-
latexmk -dF "dviselect even" foo.tex
-diagnostics
- Print detailed diagnostics during a run. This may help for de-
- bugging problems or to understand latexmk's behavior in diffi-
+ Print detailed diagnostics during a run. This may help for de-
+ bugging problems or to understand latexmk's behavior in diffi-
cult situations.
-dir-report
- For each .tex file processed, list the settings for aux and out
- directories, after they have been normalized from the settings
- specified during initialization. See the description of the
+ For each .tex file processed, list the settings for aux and out
+ directories, after they have been normalized from the settings
+ specified during initialization. See the description of the
variable $aux_out_dir_report for more details.
-dir-report-
- Do not report the settings for aux and out directories. (De-
+ Do not report the settings for aux and out directories. (De-
fault)
- -dvi Generate dvi version of document.
+ -dvi Generate dvi version of document using latex.
+ -dvilua
+ Generate dvi version of document using lualatex instead of la-
+ tex.
+
+
-dvi- Turn off generation of dvi version of document. (This may get
overridden, if some other file is made (e.g., a .ps file) that
is generated from the dvi file, or if no generated file at all
@@ -564,50 +567,61 @@
is requested.)
+ -dvilualatex="COMMAND"
+ This sets the string specifying the command to run dvi lualatex.
+ It behaves like the -pdflatex option, but sets the variable
+ $dvilualatex.
+
+ Note: This option when provided with the COMMAND argument only
+ sets the command for invoking dvilualatex; it does not turn on
+ the use of dvilualatex. That is done by other options or in an
+ initialization file.
+
+
-e <code>
- Execute the specified initialization code before processing.
- The code is Perl code of the same form as is used in latexmk's
- initialization files. For more details, see the information on
- the -r option, and the section about "Configuration/initializa-
- tion (RC) files". The code is typically a sequence of assign-
+ Execute the specified initialization code before processing.
+ The code is Perl code of the same form as is used in latexmk's
+ initialization files. For more details, see the information on
+ the -r option, and the section about "Configuration/initializa-
+ tion (RC) files". The code is typically a sequence of assign-
ment statements separated by semicolons.
- The code is executed when the -e option is encountered during
- latexmk's parsing of its command line. See the -r option for a
- way of executing initialization code from a file. An error re-
- sults in latexmk stopping. Multiple instances of the -r and -e
- options can be used, and they are executed in the order they ap-
- pear on the command line.
- Some care is needed to deal with proper quoting of special char-
- acters in the code on the command line. For example, suppose
- you want to set the latex command to use its -shell-escape op-
- tion, then under UNIX/Linux you could use the line
- latexmk -e '$latex=q/latex %O -shell-escape %S/' file.tex
+ 18 November 2022 9
- 17 March 2022 9
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ The code is executed when the -e option is encountered during
+ latexmk's parsing of its command line. See the -r option for a
+ way of executing initialization code from a file. An error re-
+ sults in latexmk stopping. Multiple instances of the -r and -e
+ options can be used, and they are executed in the order they ap-
+ pear on the command line.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ Some care is needed to deal with proper quoting of special char-
+ acters in the code on the command line. For example, suppose
+ you want to set the latex command to use its -shell-escape op-
+ tion, then under UNIX/Linux you could use the line
+ latexmk -e '$latex=q/latex %O -shell-escape %S/' file.tex
- Note that the single quotes block normal UNIX/Linux command
- shells from treating the characters inside the quotes as spe-
- cial. (In this example, the q/.../ construct is a Perl idiom
- equivalent to using single quotes. This avoids the complica-
- tions of getting a quote character inside an already quoted
- string in a way that is independent of both the shell and the
+ Note that the single quotes block normal UNIX/Linux command
+ shells from treating the characters inside the quotes as spe-
+ cial. (In this example, the q/.../ construct is a Perl idiom
+ equivalent to using single quotes. This avoids the complica-
+ tions of getting a quote character inside an already quoted
+ string in a way that is independent of both the shell and the
operating-system.)
- The above command line will NOT work under MS-Windows with
- cmd.exe or command.com or 4nt.exe. For MS-Windows with these
+ The above command line will NOT work under MS-Windows with
+ cmd.exe or command.com or 4nt.exe. For MS-Windows with these
command shells you could use
latexmk -e "$latex=q/latex %O -shell-escape %S/" file.tex
@@ -616,18 +630,18 @@
latexmk -e "$latex='latex %O -shell-escape %S'" file.tex
- The last two examples will NOT work with UNIX/Linux command
+ The last two examples will NOT work with UNIX/Linux command
shells.
- (Note: the above examples show are to show how to use the -e to
- specify initialization code to be executed. But the particular
+ (Note: the above examples show are to show how to use the -e to
+ specify initialization code to be executed. But the particular
effect can be achieved also by the use of the -latex option with
less problems in dealing with quoting.)
-emulate-aux-dir
- Emulate -aux-directory instead of leaving it to the *latex pro-
- grams to do it. (MiKTeX supports -aux-directory, but TeXLive
+ Emulate -aux-directory instead of leaving it to the *latex pro-
+ grams to do it. (MiKTeX supports -aux-directory, but TeXLive
doesn't.)
For more details see the explanation for the configuration vari-
@@ -635,49 +649,49 @@
-emulate-aux-dir-
- Turn off emulatation -aux-directory and leave it to the *latex
+ Turn off emulatation -aux-directory and leave it to the *latex
program to handle the case that aux_dir is not equal to out_dir.
- Note that if you use TeXLive, which doesn't support -aux-direc-
- tory, latexmk will automatically switch aux_dir emulation on af-
- ter the first run of *latex, because it will find the .log file
- in the wrong place.
+ Note that if you use TeXLive, which doesn't support -aux-
- -f Force latexmk to continue document processing despite errors.
- Normally, when latexmk detects that LaTeX or another program has
- found an error which will not be resolved by further processing,
- no further processing is carried out.
- Note: "Further processing" means the running of other programs
- or the rerunning of latex (etc) that would be done if no errors
- had occurred. If instead, or additionally, you want the latex
- (etc) program not to pause for user input after an error, you
+ 18 November 2022 10
- 17 March 2022 10
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ directory, latexmk will automatically switch aux_dir emulation
+ on after the first run of *latex, because it will find the .log
+ file in the wrong place.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ -f Force latexmk to continue document processing despite errors.
+ Normally, when latexmk detects that LaTeX or another program has
+ found an error which will not be resolved by further processing,
+ no further processing is carried out.
- should arrange this by an option that is passed to the program,
- e.g., by latexmk's option -interaction=nonstopmode (which la-
+ Note: "Further processing" means the running of other programs
+ or the rerunning of latex (etc) that would be done if no errors
+ had occurred. If instead, or additionally, you want the latex
+ (etc) program not to pause for user input after an error, you
+ should arrange this by an option that is passed to the program,
+ e.g., by latexmk's option -interaction=nonstopmode (which la-
texmk passes to *latex).
-f- Turn off the forced processing-past-errors such as is set by the
- -f option. This could be used to override a setting in a con-
+ -f option. This could be used to override a setting in a con-
figuration file.
- -g Force latexmk to process document fully, even under situations
- where latexmk would normally decide that no changes in the
- source files have occurred since the previous run. This option
- is useful, for example, if you change some options and wish to
+ -g Force latexmk to process document fully, even under situations
+ where latexmk would normally decide that no changes in the
+ source files have occurred since the previous run. This option
+ is useful, for example, if you change some options and wish to
reprocess the files.
@@ -693,45 +707,46 @@
-jobname=STRING
- Set the basename of output files(s) to STRING, instead of the
- default, which is the basename of the specified TeX file. (At
+ Set the basename of output files(s) to STRING, instead of the
+ default, which is the basename of the specified TeX file. (At
present, STRING should not contain spaces.)
- This is like the same option for current implementations of the
+ This is like the same option for current implementations of the
*latex, and the passing of this option to these programs is part
of latexmk's implementation of -jobname.
There is one enhancement, that the STRING may contain the place-
holder '%A'. This will be substituted by the basename of the TeX
- file. The primary purpose is when multiple files are specified
- on the command line to latexmk, and you wish to use a jobname
- with a different file-dependent value for each file. For exam-
- ple, suppose you had .tex files test1.tex and test2.tex, and you
- wished to compare the results of compilation by *latex and those
- with xelatex. Then under a unix-type operating system you could
- use the command line
+ file. The primary purpose is when multiple files are specified
- latexmk -pdf -jobname=%A-pdflatex *.tex
- latexmk -pdfxe -jobname=%A-xelatex *.tex
- Then the .aux, .log, and .pdf files from the use of pdflatex
- would have basenames test1-pdflatex and test2-pdflatex, while
- from xelatex, the basenames would be test1-xelatex and test2-xe-
- latex.
+ 18 November 2022 11
- 17 March 2022 11
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ on the command line to latexmk, and you wish to use a jobname
+ with a different file-dependent value for each file. For exam-
+ ple, suppose you had .tex files test1.tex and test2.tex, and you
+ wished to compare the results of compilation by *latex and those
+ with xelatex. Then under a unix-type operating system you could
+ use the command line
+ latexmk -pdf -jobname=%A-pdflatex *.tex
+ latexmk -pdfxe -jobname=%A-xelatex *.tex
+ Then the .aux, .log, and .pdf files from the use of pdflatex
+ would have basenames test1-pdflatex and test2-pdflatex, while
+ from xelatex, the basenames would be test1-xelatex and test2-xe-
+ latex.
+
Under MS-Windows with cmd.exe, you would need to double the per-
- cent sign, so that the percent character is passed to latexmk
+ cent sign, so that the percent character is passed to latexmk
rather than being used to substitute an environment variable:
latexmk -pdf -jobname=%%A-pdflatex *.tex
@@ -739,8 +754,8 @@
-l Run in landscape mode, using the landscape mode for the preview-
- ers and the dvi to postscript converters. This option is not
- normally needed nowadays, since current previewers normally de-
+ ers and the dvi to postscript converters. This option is not
+ normally needed nowadays, since current previewers normally de-
termine this information automatically.
@@ -747,57 +762,57 @@
-l- Turn off -l.
- -latex This sets the generation of dvi files by latex, and turns off
+ -latex This sets the generation of dvi files by latex, and turns off
the generation of pdf and ps files.
- Note: to set the command used when latex is specified, see the
+ Note: to set the command used when latex is specified, see the
-latex="COMMAND" option.
-latex="COMMAND"
This sets the string specifying the command to run latex, and is
- typically used to add desired options. Since the string nor-
+ typically used to add desired options. Since the string nor-
mally contains spaces, it should be quoted, e.g.,
latexmk -latex="latex --shell-escape %O %S" foo.tex
- The specification of the contents of the string are the same as
- for the $latex configuration variable. Depending on your oper-
- ating system and the command-line shell you are using, you may
- need to change the single quotes to double quotes (or something
+ The specification of the contents of the string are the same as
+ for the $latex configuration variable. Depending on your oper-
+ ating system and the command-line shell you are using, you may
+ need to change the single quotes to double quotes (or something
else).
- Note: This option when provided with the COMMAND argument only
+ Note: This option when provided with the COMMAND argument only
sets the command for invoking latex; it does not turn on the use
- of latex. That is done by other options or in an initialization
- file.
- To set the command for running pdflatex (rather than the command
- for latex) see the -pdflatex option.
- -logfilewarninglist
- -logfilewarnings After a run of *latex, give a list of warnings
- about undefined citations and references (unless silent mode is
- on).
+ 18 November 2022 12
- See also the $silence_logfile_warnings configuration variable.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- 17 March 2022 12
+ of latex. That is done by other options or in an initialization
+ file.
+ To set the command for running pdflatex (rather than the command
+ for latex) see the -pdflatex option.
+ -logfilewarninglist
+ -logfilewarnings After a run of *latex, give a list of warnings
+ about undefined citations and references (unless silent mode is
+ on).
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ See also the $silence_logfile_warnings configuration variable.
-logfilewarninglist-
- -logfilewarnings- After a run of *latex, do not give a list of
+ -logfilewarnings- After a run of *latex, do not give a list of
warnings about undefined citations and references. (Default)
See also the $silence_logfile_warnings configuration variable.
@@ -804,8 +819,8 @@
-lualatex
- Use lualatex. That is, use lualatex to process the source
- file(s) to pdf. The generation of dvi and postscript files is
+ Use lualatex. That is, use lualatex to process the source
+ file(s) to pdf. The generation of dvi and postscript files is
turned off.
This option is equivalent to using the following set of options
@@ -812,8 +827,8 @@
-pdflua -dvi- -ps-
- (Note: Note that the method of implementation of this option,
- but not its intended effect, differ from some earlier versions
+ (Note: Note that the method of implementation of this option,
+ but not its intended effect, differ from some earlier versions
of latexmk.)
@@ -822,59 +837,57 @@
behaves like the -pdflatex option, but sets the variable $luala-
tex.
- Note: This option when provided with the COMMAND argument only
- sets the command for invoking lualatex; it does not turn on the
+ Note: This option when provided with the COMMAND argument only
+ sets the command for invoking lualatex; it does not turn on the
use of lualatex. That is done by other options or in an initial-
ization file.
- -M Show list of dependent files after processing. This is equiva-
+ -M Show list of dependent files after processing. This is equiva-
lent to the -deps option.
-MF file
- If a list of dependents is made, the -MF specifies the file to
+ If a list of dependents is made, the -MF specifies the file to
write it to.
- -MP If a list of dependents is made, include a phony target for each
- source file. If you use the dependents list in a Makefile, the
- dummy rules work around errors the program make gives if you re-
- move header files without updating the Makefile to match.
+ 18 November 2022 13
- -makeindexfudge
- Turn on the change-directory fudge for makeindex. See documen-
- tation of $makeindex_fudge for details.
- -makeindexfudge-
- Turn off the change-directory fudge for makeindex. See
+LATEXMK(1) General Commands Manual LATEXMK(1)
- 17 March 2022 13
+ -MP If a list of dependents is made, include a phony target for each
+ source file. If you use the dependents list in a Makefile, the
+ dummy rules work around errors the program make gives if you re-
+ move header files without updating the Makefile to match.
+ -makeindexfudge
+ Turn on the change-directory fudge for makeindex. See documen-
+ tation of $makeindex_fudge for details.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ -makeindexfudge-
+ Turn off the change-directory fudge for makeindex. See documen-
+ tation of $makeindex_fudge for details.
- documentation of $makeindex_fudge for details.
-
-
-MSWinBackSlash
This option only has an effect when latexmk is running under MS-
Windows. This is that when latexmk runs a command under MS-Win-
- dows, the Windows standard directory separator "\" is used to
- separate directory components in a file name. Internally, la-
- texmk uses "/" for the directory separator character, which is
+ dows, the Windows standard directory separator "\" is used to
+ separate directory components in a file name. Internally, la-
+ texmk uses "/" for the directory separator character, which is
the character used by Unix-like systems.
This is the default behavior. However the default may have been
- overridden by a configuration file (latexmkrc file) which sets
+ overridden by a configuration file (latexmkrc file) which sets
$MSWin_back_slash=0.
@@ -881,8 +894,8 @@
-MSWinBackSlash-
This option only has an effect when latexmk is running under MS-
Windows. This is that when latexmk runs a command under MS-Win-
- dows, the substitution of "\" for the separator character be-
- tween directory components of a file name is not done. Instead
+ dows, the substitution of "\" for the separator character be-
+ tween directory components of a file name is not done. Instead
the forward slash "/" is used, the same as on Unix-like systems.
This is acceptable in most situations under MS-Windows, provided
that filenames are properly quoted, as latexmk does by default.
@@ -892,42 +905,44 @@
-new-viewer
- When in continuous-preview mode, always start a new viewer to
- view the generated file. By default, latexmk will, in continu-
- ous-preview mode, test for a previously running previewer for
+ When in continuous-preview mode, always start a new viewer to
+ view the generated file. By default, latexmk will, in continu-
+ ous-preview mode, test for a previously running previewer for
the same file and not start a new one if a previous previewer is
running. However, its test sometimes fails (notably if there is
- an already-running previewer that is viewing a file of the same
- name as the current file, but in a different directory). This
+ an already-running previewer that is viewing a file of the same
+ name as the current file, but in a different directory). This
option turns off the default behavior.
- -new-viewer-
- The inverse of the -new-viewer option. It puts latexmk in its
- normal behavior that in preview-continuous mode it checks for an
- already-running previewer.
- -nobibtex
- Never run bibtex or biber. Equivalent to the -bibtex- option.
- -nobibtexfudge or -nobibfudge
- Turn off the change-directory fudge for bibtex. See documenta-
- tion of $bibtex_fudge for details.
+ 18 November 2022 14
- 17 March 2022 14
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ -new-viewer-
+ The inverse of the -new-viewer option. It puts latexmk in its
+ normal behavior that in preview-continuous mode it checks for an
+ already-running previewer.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ -nobibtex
+ Never run bibtex or biber. Equivalent to the -bibtex- option.
+ -nobibtexfudge or -nobibfudge
+ Turn off the change-directory fudge for bibtex. See documenta-
+ tion of $bibtex_fudge for details.
+
+
-noemulate-aux-dir
Turn aux_dir emulation off. Same as -emulate-aux-dir-.
@@ -939,72 +954,72 @@
-norc Turn off the automatic reading of initialization (rc) files.
- N.B. Normally the initialization files are read and obeyed, and
- then command line options are obeyed in the order they are en-
- countered. But -norc is an exception to this rule: it is acted
+ N.B. Normally the initialization files are read and obeyed, and
+ then command line options are obeyed in the order they are en-
+ countered. But -norc is an exception to this rule: it is acted
on first, no matter where it occurs on the command line.
-outdir=FOO or -output-directory=FOO
- Sets the directory for the output files of *latex. This
- achieves its effect by the -output-directory option of *latex,
+ Sets the directory for the output files of *latex. This
+ achieves its effect by the -output-directory option of *latex,
which currently (Dec. 2011 and later) is implemented on the com-
mon versions of *latex, i.e., MiKTeX and TeXLive. It may not be
present in other versions.
- See also the -auxdir/-aux-directory options, and the $aux_dir,
- $out_dir, and $search_path_separator configuration variables of
- latexmk. In particular, see the documentation of $out_dir for
+ See also the -auxdir/-aux-directory options, and the $aux_dir,
+ $out_dir, and $search_path_separator configuration variables of
+ latexmk. In particular, see the documentation of $out_dir for
some complications on what directory names are suitable.
- If you also use the -cd option, and the specified output direc-
- tory is a relative path, then the path is interpreted relative
+ If you also use the -cd option, and the specified output direc-
+ tory is a relative path, then the path is interpreted relative
to the document directory.
-output-format=FORMAT
- This option is one that is allowed for latex, lualatex, and
- pdflatex. But it is not passed to these programs. Instead la-
- texmk emulates it in a way suitable for the context of latexmk
- and its workflows.
+ This option is one that is allowed for latex, lualatex, and
+ pdflatex. But it is not passed to these programs. Instead la-
+ texmk emulates it in a way suitable for the context of latexmk
- If FORMAT is dvi, then dvi output is turned on, and postscript
- and pdf output are turned off. This is equivalent to using the
- options -dvi -ps- -pdf-.
- If FORMAT is pdf, then pdf output is turned on, and dvi and
- postscript output are turned off. This is equivalent to using
- the options -pdf -ps- -dvi-.
- If FORMAT is anything else, latexmk gives an error.
+ 18 November 2022 15
- -p Print out the document. By default the file to be printed is
- the first in the list postscript, pdf, dvi that is being made.
- 17 March 2022 15
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ and its workflows.
+ If FORMAT is dvi, then dvi output is turned on, and postscript
+ and pdf output are turned off. This is equivalent to using the
+ options -dvi -ps- -pdf-.
+ If FORMAT is pdf, then pdf output is turned on, and dvi and
+ postscript output are turned off. This is equivalent to using
+ the options -pdf -ps- -dvi-.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ If FORMAT is anything else, latexmk gives an error.
+ -p Print out the document. By default the file to be printed is
+ the first in the list postscript, pdf, dvi that is being made.
But you can use the -print=... option to change the type of file
to be printed, and you can configure this in a start up file (by
setting the $print_type variable).
- However, printing is enabled by default only under UNIX/Linux
+ However, printing is enabled by default only under UNIX/Linux
systems, where the default is to use the lpr command and only on
postscript files. In general, the correct behavior for printing
very much depends on your system's software. In particular, un-
- der MS-Windows you must have suitable program(s) available, and
- you must have configured the print commands used by latexmk.
- This can be non-trivial. See the documentation on the $lpr,
+ der MS-Windows you must have suitable program(s) available, and
+ you must have configured the print commands used by latexmk.
+ This can be non-trivial. See the documentation on the $lpr,
$lpr_dvi, and $lpr_pdf configuration variables to see how to set
the commands for printing.
@@ -1012,63 +1027,72 @@
turns them off.
- -pdf Generate pdf version of document using pdflatex. (If you wish
+ -pdf Generate pdf version of document using pdflatex. (If you wish
to use lualatex or xelatex, you can use whichever of the options
- -pdflua, -pdfxe, -lualatex or -xelatex applies.) To configure
- latexmk to have such behavior by default, see the section on
+ -pdflua, -pdfxe, -lualatex or -xelatex applies.) To configure
+ latexmk to have such behavior by default, see the section on
"Configuration/initialization (rc) files".
-pdfdvi
- Generate pdf version of document from the dvi file, by default
- using dvipdf.
+ Generate dvi file and then pdf version of document from the dvi
+ file, by default using dvipdf.
+ The program used to compile the document to dvi is latex by de-
+ fault, but this can be changed to dvilulatex by the use of the
+ -dvilua option or by setting $dvi_mode to 2.
+
-pdflua
Generate pdf version of document using lualatex.
- -pdfps Generate pdf version of document from the .ps file, by default
- using ps2pdf.
+ -pdfps
- -pdfxe Generate pdf version of document using xelatex. Note that to
- optimize processing time, latexmk uses xelatex to generate an
- .xdv file rather than a pdf file directly. Only after possibly
- multiple runs to generate a fully up-to-date .xdv file does la-
- texmk then call xdvipdfmx to generate the final .pdf file.
- (Note: The reason why latexmk arranges for xelatex to make an
- .xdv file instead of the xelatex's default of a .pdf file is as
- follows: When the document includes large graphics files, espe-
- cially .png files, the production of a .pdf file can be quite
- time consuming, even when the creation of the .xdv file by xela-
- tex is fast. So the use of the intermediate .xdv file can re-
- sult in substantial gains in procesing time, since the .pdf file
- is produced once rather than on every run of xelatex.)
+ 18 November 2022 16
- 17 March 2022 16
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ Generate dvi file, ps file from the dvi file, and then pdf file
+ from the ps file.
+ The program used to compile the document to dvi is latex by de-
+ fault, but this can be changed to dvilulatex by the use of the
+ -dvilua option or by setting $dvi_mode to 2.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ -pdfxe Generate pdf version of document using xelatex. Note that to
+ optimize processing time, latexmk uses xelatex to generate an
+ .xdv file rather than a pdf file directly. Only after possibly
+ multiple runs to generate a fully up-to-date .xdv file does la-
+ texmk then call xdvipdfmx to generate the final .pdf file.
+ (Note: The reason why latexmk arranges for xelatex to make an
+ .xdv file instead of the xelatex's default of a .pdf file is as
+ follows: When the document includes large graphics files, espe-
+ cially .png files, the production of a .pdf file can be quite
+ time consuming, even when the creation of the .xdv file by xela-
+ tex is fast. So the use of the intermediate .xdv file can re-
+ sult in substantial gains in procesing time, since the .pdf file
+ is produced once rather than on every run of xelatex.)
- -pdf- Turn off generation of pdf version of document. (This can be
- used to override a setting in a configuration file. It may get
+
+ -pdf- Turn off generation of pdf version of document. (This can be
+ used to override a setting in a configuration file. It may get
overridden if some other option requires the generation of a pdf
file.)
- If after all options have been processed, pdf generation is
- still turned off, then generation of a dvi file will be turned
+ If after all options have been processed, pdf generation is
+ still turned off, then generation of a dvi file will be turned
on, and then the program used to compiled a document will be la-
- tex (or, more precisely, whatever program is configured to be
+ tex (or, more precisely, whatever program is configured to be
used in the $latex configuration variable).
@@ -1076,7 +1100,7 @@
This sets the generation of pdf files by pdflatex, and turns off
the generation of dvi and ps files.
- Note: to set the command used when pdflatex is specified, see
+ Note: to set the command used when pdflatex is specified, see
the -pdflatex="COMMAND" option.
@@ -1088,19 +1112,31 @@
latexmk -pdf -pdflatex="pdflatex --shell-escape %O %S"
foo.tex
- The specification of the contents of the string are the same as
+ The specification of the contents of the string are the same as
for the $pdflatex configuration variable. (The option -pdflatex
+
+
+
+ 18 November 2022 17
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
in fact sets the variable $pdflatex.) Depending on your operat-
- ing system and the command-line shell you are using, you may
- need to change the single quotes to double quotes (or something
+ ing system and the command-line shell you are using, you may
+ need to change the single quotes to double quotes (or something
else).
- Note: This option when provided with the COMMAND argument only
- sets the command for invoking pdflatex; it does not turn on the
+ Note: This option when provided with the COMMAND argument only
+ sets the command for invoking pdflatex; it does not turn on the
use of pdflatex. That is done by other options or in an initial-
ization file.
- To set the command for running latex (rather than the command
+ To set the command for running latex (rather than the command
for pdflatex) see the -latex option.
@@ -1114,23 +1150,11 @@
-pretex=CODE
-
-
-
- 17 March 2022 17
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
Given that CODE is some TeX code, this options sets that code to
- be executed before inputting source file. This only works if
+ be executed before inputting source file. This only works if
the command for invoking the relevant *latex is suitably config-
- ured. See the documentation of the variable $pre_tex_code, and
- the substitution strings %P and %U for more details. This op-
+ ured. See the documentation of the variable $pre_tex_code, and
+ the substitution strings %P and %U for more details. This op-
tion works by setting the variable $pre_tex_code.
See also the -usepretex option.
@@ -1150,12 +1174,24 @@
-print=dvi, -print=ps, -print=pdf, -print=auto,
- Define which kind of file is printed. This option also ensures
+ Define which kind of file is printed. This option also ensures
that the requisite file is made, and turns on printing.
The (default) case -print=auto determines the kind of print file
- automatically from the set of files that is being made. The
- first in the list postscript, pdf, dvi that is among the files
+ automatically from the set of files that is being made. The
+ first in the list postscript, pdf, dvi that is among the files
+
+
+
+ 18 November 2022 18
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
to be made is the one used for print out.
@@ -1163,13 +1199,13 @@
-ps- Turn off generation of postscript version of document. This can
- be used to override a setting in a configuration file. (It may
- get overridden by some other option that requires a postscript
+ be used to override a setting in a configuration file. (It may
+ get overridden by some other option that requires a postscript
file, for example a request for printing.)
- -pF Postscript file filtering. The argument to this option is a
- filter which will generate a filtered postscript file with the
+ -pF Postscript file filtering. The argument to this option is a
+ filter which will generate a filtered postscript file with the
extension ".psF". All extra processing (e.g. preview, printing)
will then be performed on this filtered postscript file.
@@ -1181,27 +1217,16 @@
latexmk -ps -pF "psnup -2" foo.tex
-
-
- 17 March 2022 18
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
Whether to use single or double quotes round the "psnup -2" will
- depend on your command interpreter, as used by the particular
+ depend on your command interpreter, as used by the particular
version of perl and the operating system on your computer.
- -pv Run file previewer. If the -view option is used, this will se-
+ -pv Run file previewer. If the -view option is used, this will se-
lect the kind of file to be previewed (.dvi, .ps or .pdf). Oth-
- erwise the viewer views the "highest" kind of file selected, by
- the -dvi, -ps, -pdf, -pdfps options, in the order .dvi, .ps,
- .pdf (low to high). If no file type has been selected, the dvi
+ erwise the viewer views the "highest" kind of file selected, by
+ the -dvi, -ps, -pdf, -pdfps options, in the order .dvi, .ps,
+ .pdf (low to high). If no file type has been selected, the dvi
previewer will be used. This option is incompatible with the -p
and -pvc options, so it turns them off.
@@ -1209,56 +1234,56 @@
-pv- Turn off -pv.
- -pvc Run a file previewer and continually update the .dvi, .ps,
+ -pvc Run a file previewer and continually update the .dvi, .ps,
and/or .pdf files whenever changes are made to source files (see
- the Description above). Which of these files is generated and
- which is viewed is governed by the other options, and is the
- same as for the -pv option. The preview-continuous option -pvc
- can only work with one file. So in this case you will normally
- only specify one filename on the command line. It is also in-
- compatible with the -p and -pv options, so it turns these op-
+ the Description above). Which of these files is generated and
+ which is viewed is governed by the other options, and is the
+ same as for the -pv option. The preview-continuous option -pvc
+ can only work with one file. So in this case you will normally
+ only specify one filename on the command line. It is also in-
+ compatible with the -p and -pv options, so it turns these op-
tions off.
- The -pvc option also turns off force mode (-f), as is normally
- best for continuous preview mode. If you really want force
- mode, use the options in the order -pvc -f.
+ The -pvc option also turns off force mode (-f), as is normally
+ best for continuous preview mode. If you really want force
- With a good previewer the display will be automatically updated.
- (Under some but not all versions of UNIX/Linux "gv -watch" does
- this for postscript files; this can be set by a configuration
- variable. This would also work for pdf files except for an ap-
- parent bug in gv that causes an error when the newly updated pdf
- file is read.) Many other previewers will need a manual update.
- Important note: the acroread program on MS-Windows locks the pdf
- file, and prevents new versions being written, so it is a bad
- idea to use acroread to view pdf files in preview-continuous
- mode. It is better to use a different viewer: SumatraPDF and
- gsview are good possibilities.
- There are some other methods for arranging an update, notably
- useful for many versions of xdvi and xpdf. These are best set
- in latexmk's configuration; see below.
+ 18 November 2022 19
- Note that if latexmk dies or is stopped by the user, the
- "forked" previewer will continue to run. Successive invocations
- with the -pvc option will not fork new previewers, but latexmk
- will normally use the existing previewer. (At least this will
- happen when latexmk is running under an operating system where
- it knows how to determine whether an existing previewer is
- 17 March 2022 19
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ mode, use the options in the order -pvc -f.
+ With a good previewer the display will be automatically updated.
+ (Under some but not all versions of UNIX/Linux "gv -watch" does
+ this for postscript files; this can be set by a configuration
+ variable. This would also work for pdf files except for an ap-
+ parent bug in gv that causes an error when the newly updated pdf
+ file is read.) Many other previewers will need a manual update.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ Important note: the acroread program on MS-Windows locks the pdf
+ file, and prevents new versions being written, so it is a bad
+ idea to use acroread to view pdf files in preview-continuous
+ mode. It is better to use a different viewer: SumatraPDF and
+ gsview are good possibilities.
+ There are some other methods for arranging an update, notably
+ useful for many versions of xdvi and xpdf. These are best set
+ in latexmk's configuration; see below.
- running.)
+ Note that if latexmk dies or is stopped by the user, the
+ "forked" previewer will continue to run. Successive invocations
+ with the -pvc option will not fork new previewers, but latexmk
+ will normally use the existing previewer. (At least this will
+ happen when latexmk is running under an operating system where
+ it knows how to determine whether an existing previewer is run-
+ ning.)
-pvc- Turn off -pvc.
@@ -1265,9 +1290,9 @@
-pvctimeout
- Do timeout in pvc mode after period of inactivity, which is 30
+ Do timeout in pvc mode after period of inactivity, which is 30
min. by default. Inactivity means a period when latexmk has de-
- tected no file changes and hence has not taken any actions like
+ tected no file changes and hence has not taken any actions like
compiling the document.
@@ -1283,56 +1308,55 @@
-r <rcfile>
- Read the specified initialization file ("RC file") before pro-
+ Read the specified initialization file ("RC file") before pro-
cessing.
Be careful about the ordering: (1) Standard initialization files
- -- see the section below on "Configuration/initialization (RC)
- files" -- are read first. (2) Then the options on the command
- line are acted on in the order they are given. Therefore if an
- initialization file is specified by the -r option, it is read
- during this second step. Thus an initialization file specified
+
+
+
+ 18 November 2022 20
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ -- see the section below on "Configuration/initialization (RC)
+ files" -- are read first. (2) Then the options on the command
+ line are acted on in the order they are given. Therefore if an
+ initialization file is specified by the -r option, it is read
+ during this second step. Thus an initialization file specified
with the -r option can override both the standard initialization
files and previously specified options. But all of these can be
overridden by later options.
The contents of the RC file just comprise a piece of code in the
- Perl programming language (typically a sequence of assignment
+ Perl programming language (typically a sequence of assignment
statements); they are executed when the -r option is encountered
during latexmk's parsing of its command line. See the -e option
- for a way of giving initialization code directly on latexmk's
- command line. An error results in latexmk stopping. Multiple
+ for a way of giving initialization code directly on latexmk's
+ command line. An error results in latexmk stopping. Multiple
instances of the -r and -e options can be used, and they are ex-
ecuted in the order they appear on the command line.
-rc-report
- After initialization, give a list of the RC files read. (De-
+ After initialization, give a list of the RC files read. (De-
fault)
-
-
-
-
- 17 March 2022 20
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
-rc-report-
After initialization, do not give a list of the RC files read.
-recorder
- Give the -recorder option with *latex. In (most) modern ver-
- sions of these programs, this results in a file of extension
- .fls containing a list of the files that these programs have
- read and written. Latexmk will then use this file to improve
+ Give the -recorder option with *latex. In (most) modern ver-
+ sions of these programs, this results in a file of extension
+ .fls containing a list of the files that these programs have
+ read and written. Latexmk will then use this file to improve
its detection of source files and generated files after a run of
*latex. This is the default setting of latexmk, unless overrid-
den in an initialization file.
@@ -1349,70 +1373,72 @@
-rules-
- Do not show a list of latexmk's rules and dependencies after
+ Do not show a list of latexmk's rules and dependencies after
processing. (This is the default.)
- -showextraoptions
- Show the list of extra *latex options that latexmk recognizes,
- but that it simply passes through to the programs *latex when
- they are run. These options are (currently) a combination of
- those allowed by the TeXLive and MiKTeX implementations. (If a
- particular option is given to latexmk but is not handled by the
- particular implementation of *latex that is being used, that
- program will probably give a warning or an error.) These op-
- tions are very numerous, but are not listed in this documenta-
- tion because they have no effect on latexmk's actions.
- There are a few options (e.g., -includedirectory=dir, -initial-
- ize, -ini) that are not recognized, either because they don't
- fit with latexmk's intended operations, or because they need
- special processing by latexmk that isn't implemented (at least,
- not yet).
- There are certain options for *latex (e.g., -recorder) that
- trigger special actions or behavior by latexmk itself. Depending
- on the action, they may also be passed in some form to the
- called *latex program, and/or may affect other programs as well.
- These options do have entries in this documentation. Among
- these options are: -jobname=STRING, -aux-directory=dir, -output-
- directory=DIR, -quiet, and -recorder.
+ 18 November 2022 21
- 17 March 2022 21
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ -showextraoptions
+ Show the list of extra *latex options that latexmk recognizes,
+ but that it simply passes through to the programs *latex when
+ they are run. These options are (currently) a combination of
+ those allowed by the TeXLive and MiKTeX implementations. (If a
+ particular option is given to latexmk but is not handled by the
+ particular implementation of *latex that is being used, that
+ program will probably give a warning or an error.) These op-
+ tions are very numerous, but are not listed in this documenta-
+ tion because they have no effect on latexmk's actions.
+ There are a few options (e.g., -includedirectory=dir, -initial-
+ ize, -ini) that are not recognized, either because they don't
+ fit with latexmk's intended operations, or because they need
+ special processing by latexmk that isn't implemented (at least,
+ not yet).
- There are also options that are accepted by *latex, but instead
+ There are certain options for *latex (e.g., -recorder) that
+ trigger special actions or behavior by latexmk itself. Depending
+ on the action, they may also be passed in some form to the
+ called *latex program, and/or may affect other programs as well.
+ These options do have entries in this documentation. Among
+ these options are: -jobname=STRING, -aux-directory=dir, -output-
+ directory=DIR, -quiet, and -recorder.
+
+ There are also options that are accepted by *latex, but instead
trigger actions purely by latexmk: -help, -version.
-silent
Run commands silently, i.e., with options that reduce the amount
- of diagnostics generated. For example, with the default set-
- tings, the command "latex -interaction=batchmode" is used for
+ of diagnostics generated. For example, with the default set-
+ tings, the command "latex -interaction=batchmode" is used for
latex, and similarly for its friends.
- See also the -logfilewarninglist and -logfilewarninglist- op-
+ See also the -logfilewarninglist and -logfilewarninglist- op-
tions.
- Also reduce the number of informational messages that latexmk
+ Also reduce the number of informational messages that latexmk
itself generates.
- To change the options used to make the commands run silently,
+ To change the options used to make the commands run silently,
you need to configure latexmk with changed values of its config-
- uration variables, the relevant ones being $bib-
- tex_silent_switch, $biber_silent_switch, $dvipdf_silent_switch,
- $dvips_silent_switch, $latex_silent_switch, $luala-
- tex_silent_switch $makeindex_silent_switch, $pdfla-
- tex_silent_switch, and $xelatex_silent_switch
+ uration variables, the relevant ones being $bib-
+ tex_silent_switch, $biber_silent_switch, $dvipdf_silent_switch,
+ $dvips_silent_switch, $dvilualatex_silent_switch, $la-
+ tex_silent_switch, $lualatex_silent_switch $makein-
+ dex_silent_switch, $pdflatex_silent_switch, and $xela-
+ tex_silent_switch
-stdtexcmds
@@ -1419,6 +1445,17 @@
Sets the commands for latex, etc, so that they are the standard
ones. This is useful to override special configurations.
+
+
+ 18 November 2022 22
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
The result is that $latex = 'latex %O %S', and similarly for
$pdflatex, $lualatex, and $xelatex. (The option -no-pdf needed
for $xelatex is provided automatically, given that %O appears in
@@ -1444,18 +1481,6 @@
Note that the filename may be specified without an extension,
e.g., by \includegraphics{drawing} in a LaTeX file. In that
-
-
-
- 17 March 2022 22
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
case, latexmk will try making drawing.ext with ext set in turn
to the possible extensions that are relevant for latex (or as
appropriate pdflatex, lualatex, xelatex).
@@ -1485,6 +1510,18 @@
-usepretex=CODE
Equivalent to -pretex=CODE -usepretex. Example
+
+
+
+ 18 November 2022 23
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
latexmk -usepretex='\AtBeginDocument{Message\par}' foo.tex
@@ -1509,19 +1546,6 @@
be opened.
-
-
-
-
- 17 March 2022 23
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
-Werror
This causes latexmk to return a non-zero status code if any of
the files processed gives a warning about problems with cita-
@@ -1534,6 +1558,9 @@
the configuration variable $warnings_as_errors.
+ -xdv Generate xdv version of document using xelatex.
+
+
-xelatex
Use xelatex. That is, use xelatex to process the source file(s)
to pdf. The generation of dvi and postscript files is turned
@@ -1549,6 +1576,18 @@
file, and does all the extra runs needed (including those of
bibtex, etc). Only after that does it make the pdf file from
the .xdv file, using xdvipdfmx. See the documentation for the
+
+
+
+ 18 November 2022 24
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
-pdfxe for why this is done.]
@@ -1576,18 +1615,6 @@
Compatibility between options
-
-
-
- 17 March 2022 24
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
The preview-continuous option -pvc can only work with one file. So in
this case you will normally only specify one filename on the command
line.
@@ -1617,6 +1644,16 @@
+
+ 18 November 2022 25
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
DEALING WITH ERRORS, PROBLEMS, ETC
Some possibilities:
@@ -1642,18 +1679,6 @@
tions. (But there is a lot of reading!)
The remainder of these notes consists of ideas for dealing with more
-
-
-
- 17 March 2022 25
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
difficult situations.
d. Further tricks can involve replacing the standard commands that la-
@@ -1683,6 +1708,18 @@
g. See also the section "Advanced Configuration: Some extra resources".
+
+
+
+ 18 November 2022 26
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
h. Look on tex.stackexchange, i.e., at http://tex.stackex-
change.com/questions/tagged/latexmk Someone may have already solved
your problem.
@@ -1707,22 +1744,10 @@
tion. The difference in output file type can happen for two reasons:
One is that for latex, pdflatex and lualatex the document itself can
override the defaults. The other is that there may be a configuration,
- or misconfiguration, such that the program that latexmk invokes to
+ or misconfiguration, such that the program that latexmk invokes to com-
+ pile the document is not the expected one, or is given options incom-
+ patible with what latexmk initially expects.
-
-
- 17 March 2022 26
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- compile the document is not the expected one, or is given options in-
- compatible with what latexmk initially expects.
-
Under latex and pdflatex, control of the output format by the document
is done by setting the \pdfoutput macro. Under lualatex, the \output-
mode macro is used instead.
@@ -1749,6 +1774,18 @@
of .pdf, .dvi, .xdv) and the initially expected output, if possible.
Latexmk does this provided the following conditions are met.
+
+
+
+ 18 November 2022 27
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
The first is that latexmk's $allow_switch configuration variable is set
to a non-zero value as it is by default. If this variable is zero, a
mismatch of filetypes in the compilation results in an error.
@@ -1774,18 +1811,6 @@
-
-
-
- 17 March 2022 27
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
CONFIGURATION/INITIALIZATION (RC) FILES
In this section is explained which configuration files are read by la-
texmk. Subsequent sections "How to Set Variables in Initialization
@@ -1816,6 +1841,17 @@
"/usr/local/share/latexmk",
"/usr/local/lib/latexmk".
+
+
+ 18 November 2022 28
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
If the environment variable LATEXMKRCSYS is set, its value is used as
the name of the system RC file, instead of any of the above.
@@ -1842,16 +1878,6 @@
texmk does not look for an RC file under it.
-
- 17 March 2022 28
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
3) The RC file in the current working directory. This file can be
named either "latexmkrc" or ".latexmkrc", and the first of these to be
found is used, if any.
@@ -1880,6 +1906,18 @@
The important variables that can be configured are described in the
section "List of configuration variables usable in initialization
files". (See the earlier section "Configuration/Initialization (rc)
+
+
+
+ 18 November 2022 29
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
Files" for the files where the configurations are done.) Syntax for
setting these variables is of the following forms:
@@ -1906,18 +1944,6 @@
quotes, as in many programming languages. But then the Perl program-
ming language brings into play some special rules for interpolating
variables into strings. People not fluent in Perl will want to avoid
-
-
-
- 17 March 2022 29
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
these complications.)
You can do much more complicated things, but for this you will need to
@@ -1945,10 +1971,22 @@
are substituted by appropriate values before the command is run. Thus
%S will be replaced by the source file that elatex will be applied to,
and %O will be replaced by any options that latexmk has decided to use
- for this command. (E.g., if you used the -silent option in the invoca-
- tion of latexmk, it results in the replacement of %O by "-interac-
- tion=batchmode".)
+ for this command. (E.g., if you used the -silent option in the
+
+
+ 18 November 2022 30
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ invocation of latexmk, it results in the replacement of %O by "-inter-
+ action=batchmode".)
+
The available placeholders are:
%A basename of the main tex file. Unlike %R, this is unaffected by
@@ -1972,18 +2010,6 @@
source file is read.
If the variable $pre_tex_code is the empty string, then %P is
-
-
-
- 17 March 2022 30
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
equivalent to %S.
%R root filename. This is the base name for the main tex file.
@@ -2011,8 +2037,20 @@
value $out_dir.
%Z Name of directory for output files (see the configuration vari-
- able $out_dir). A directory separation character ('/') is ap-
- pended if $out_dir is non-empty and does not end in a suitable
+ able $out_dir). A directory separation character ('/') is
+
+
+
+ 18 November 2022 31
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ appended if $out_dir is non-empty and does not end in a suitable
character, with suitable characters being those appropriate to
UNIX and MS-Windows, i.e., ':', '/' and '\'.
@@ -2038,18 +2076,6 @@
"Detaching" a command: Normally when latexmk runs a command, it waits
for the command to run to completion. This is appropriate for commands
-
-
-
- 17 March 2022 31
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
like latex, of course. But for previewers, the command should normally
run detached, so that latexmk gets the previewer running and then re-
turns to its next task (or exits if there is nothing else to do). To
@@ -2078,6 +2104,18 @@
$lpr_pdf = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p
%S';
+
+
+
+ 18 November 2022 32
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$pdf_previewer = 'start "c:/Program Files/SumatraPDF/Suma-
traPDF.exe" %O %S';
$pdf_previewer = 'start "c:/Program Files/SumatraPDF (x86)/Suma-
@@ -2105,17 +2143,6 @@
$dvi_previewer = 'start %S';
-
-
- 17 March 2022 32
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
Under MS-Windows, this will cause to be run whatever program the system
has associated with dvi files. (The same applies for a postscript
viewer and a pdf viewer.) But note that this trick is not always suit-
@@ -2143,6 +2170,18 @@
tion starting with "internal", as in
$latex = 'internal mylatex %O %S';
+
+
+
+ 18 November 2022 33
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
sub mylatex {
my @args = @_;
# Possible preprocessing here
@@ -2171,17 +2210,6 @@
$pdflatex = 'pdflatex --shell-escape %O %S; pst2pdf_for_latexmk
%B';
-
-
- 17 March 2022 33
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
This definition assumes you are using a UNIX-like system (which in-
cludes Linux and OS-X), so that the two commands to be run are sepa-
rated by the semicolon in the middle of the string.
@@ -2210,6 +2238,16 @@
i.e., the behavior does not occur.
+
+ 18 November 2022 34
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$allow_switch [1]
This controls what happens when the output extension of latex,
@@ -2236,18 +2274,6 @@
chosen name for the output file.)
This use of a temporary file solves a problem that the making of
-
-
-
- 17 March 2022 34
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
these files can occupy a substantial time. If a viewer (notably
gv) sees that the file has changed, it may read the new file be-
fore the program writing the file has not yet finished its work,
@@ -2276,6 +2302,18 @@
doesn't always generate lines in the .fls file for input lua
files. (The situation with lualatex is HIGHLY version depen-
dent, e.g., there was a big change between TeXLive 2016 and
+
+
+
+ 18 November 2022 35
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
TeXLive 2017.)
To keep backward compatibility with older versions of latexmk,
@@ -2299,23 +2337,13 @@
$out_dir is set, then $aux_dir is set to $out_dir, which is the
directory to which general output files are to be written.
- Important note: The effect of $aux_dir, if different from
- $out_dir, is achieved by giving *latex the -aux-directory. Cur-
- rently (Dec. 2011 and later) this only works on the MiKTeX
+ Important note: The default implementation of the aux dir is to
+ give *latex the -aux-directory option. But that only works with
+ the MiKTeX distribution, not with the TeX Live distribution.
+ Latexmk has an alternative implementation that avoids this prob-
+ lem: See the description of -emulate-aux-dir option and the $em-
+ ulate_aux variable for details.
-
-
- 17 March 2022 35
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- version of *latex.
-
See also the documentation of $out_dir for some complications on
what directory names are suitable.
@@ -2342,6 +2370,32 @@
+
+ 18 November 2022 36
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ $bad_warning_is_error [0]
+ Whether to treat bad warnings reported by *latex in log file as
+ errors. The specifications of the warning messages are in
+ @bad_warnings.
+
+
+ @bad_warnings
+ Array of regular expressions specifying messages in log file
+ that are officially treated as warnings rather than errors by
+ *latex, but which a user may treat as errors: See $bad_warn-
+ ing_is_error.
+
+ Currently the default set of these warnings is those about \end
+ occuring inside constructs.
+
+
$banner [0]
If nonzero, the banner message is printed across each page when
converting the dvi file to postscript. Without modifying the
@@ -2368,30 +2422,30 @@
scale for your message, as a rule of thumb the scale should be
about equal to 1100 divided by the number of characters in the
message. The Default is just right for 5 character messages.
+ This is equivalent to the -bs option.
+ @BIBINPUTS
+ This is an array variable, now mostly obsolete, that specifies
+ directories where latexmk should look for .bib files. By de-
+ fault it is set from the BIBINPUTS environment variable of the
+ operating system. If that environment variable is not set, a
+ single element list consisting of the current directory is set.
+ The format of the directory names depends on your operating sys-
+ tem, of course. Examples for setting this variable are:
+ @BIBINPUTS = ( ".", "C:\\bibfiles" );
- 17 March 2022 36
+ 18 November 2022 37
-LATEXMK(1) General Commands Manual LATEXMK(1)
- This is equivalent to the -bs option.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- @BIBINPUTS
- This is an array variable, now mostly obsolete, that specifies
- directories where latexmk should look for .bib files. By de-
- fault it is set from the BIBINPUTS environment variable of the
- operating system. If that environment variable is not set, a
- single element list consisting of the current directory is set.
- The format of the directory names depends on your operating sys-
- tem, of course. Examples for setting this variable are:
- @BIBINPUTS = ( ".", "C:\\bibfiles" );
@BIBINPUTS = ( ".", "\\server\bibfiles" );
@BIBINPUTS = ( ".", "C:/bibfiles" );
@BIBINPUTS = ( ".", "//server/bibfiles" );
@@ -2434,32 +2488,32 @@
refuse to write its bbl and blg files, for security reasons, for
certain cases of the path component of the filename given to it.
+ However, there are also rare cases where the change-directory
+ method prevents bibtex from finding certain bib or bst files.
+ Then $bibtex_fudge needs to be set to 0.
+ $bibtex_silent_switch ["-terse"]
+ Switch(es) for the BibTeX processing program when silent mode is
+ on.
- 17 March 2022 37
+ $bibtex_use [1]
+ Under what conditions to run bibtex or biber. When latexmk dis-
+ covers from the log file that one (or more) bibtex/biber-
+ 18 November 2022 38
-LATEXMK(1) General Commands Manual LATEXMK(1)
- However, there are also rare cases where the change-directory
- method prevents bibtex from finding certain bib or bst files.
- Then $bibtex_fudge needs to be set to 0.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- $bibtex_silent_switch ["-terse"]
- Switch(es) for the BibTeX processing program when silent mode is
- on.
- $bibtex_use [1]
- Under what conditions to run bibtex or biber. When latexmk dis-
- covers from the log file that one (or more) bibtex/biber-gener-
- ated bibliographies are used, it can run bibtex or biber when-
- ever it appears necessary to regenerate the bbl file(s) from
+ generated bibliographies are used, it can run bibtex or biber
+ whenever it appears necessary to regenerate the bbl file(s) from
their source bib database file(s). But sometimes, the bib
file(s) are not available (e.g., for a document obtained from an
external archive), but the bbl files are provided. In that case
@@ -2469,41 +2523,53 @@
files are deleted in a cleanup operation.
The possible values of $bibtex_use are:
- 0: never use BibTeX or biber; never delete .bbl files in a
+ 0: never use bibtex or biber; never delete .bbl files in a
cleanup.
- 1: only use bibtex or biber if the bib files exist; never
- delete .bbl files in a cleanup.
- 1.5: only use bibtex or biber if the bib files exist; condi-
- tionally delete .bbl files in a cleanup (i.e., delete them only
- when the bib files all exist).
+ 1: only use bibtex if the bib file(s) exist; never delete .bbl
+ files in a cleanup.
+ 1.5: only use bibtex if the bib files exist; conditionally
+ delete .bbl files in a cleanup (i.e., delete them only when the
+ bib files all exist).
2: run bibtex or biber whenever it appears necessary to update
- the bbl files, without testing for the existence of the bib
+ the bbl file(s), without testing for the existence of the bib
files; always delete .bbl files in a cleanup.
- Note that the value 1.5 does not work properly if the document
- uses biber instead of bibtex. (There's a long story why not.)
+ Important note: Currently, the values 1 and 1.5 do not work
+ properly if the document uses biber instead of bibtex. When
+ biber is used, the values 1 and 1.5 for $bibtex_use are equiva-
+ lent to 2 as regards the running of biber. (There's a long
+ story why not. Basically, the problem is that when biber is
+ used, latexmk only knows the names and status of the bibfiles
+ after running biber. In contrast, when bibtex is used, the in-
+ formation is available after a run of *latex. It is a problem
+ for the future to correct this.)
$cleanup_includes_cusdep_generated [0]
- If nonzero, specifies that cleanup also deletes files that are
+ If nonzero, specifies that cleanup also deletes files that are
generated by custom dependencies. (When doing a clean up, e.g.,
by use of the -C option, custom dependencies are those listed in
the .fdb_latexmk file from a previous run.)
$cleanup_includes_generated [0]
- If nonzero, specifies that cleanup also deletes files that are
+ If nonzero, specifies that cleanup also deletes files that are
detected in the fls file (or failing that, in log file) as being
- generated. It will also include files made from these first
+ generated. It will also include files made from these first
generation generated files.
- This operation is somewhat dangerous, and can have unintended
- consequences, since the files to be deleted are determined from
- a file created by *latex, which can contain erroneous informa-
+ This operation is somewhat dangerous, and can have unintended
+ consequences, since the files to be deleted are determined from
+ a file created by *latex, which can contain erroneous informa-
tion. Therefore this variable is turned off by default, and then
+ files to be deleted are restricted to those explicitly specified
+ by patterns configured in the variables clean_ext,
+ clean_full_ext, and @generated_exts. Standard cases (e.g., .log
+ files) appear in latexmk's initial value for the array @gener-
+ ated_exts.
- 17 March 2022 38
+ 18 November 2022 39
@@ -2512,26 +2578,20 @@
LATEXMK(1) General Commands Manual LATEXMK(1)
- files to be deleted are restricted to those explicitly specified
- by patterns configured in the variables clean_ext,
- clean_full_ext, and @generated_exts. Standard cases (e.g., .log
- files) appear in latexmk's initial value for the array @gener-
- ated_exts.
-
$cleanup_mode [0]
- If nonzero, specifies cleanup mode: 1 for full cleanup, 2 for
- cleanup except for .dvi, .ps and .pdf files, 3 for cleanup ex-
- cept for dep and aux files. (There is also extra cleaning as
+ If nonzero, specifies cleanup mode: 1 for full cleanup, 2 for
+ cleanup except for .dvi, .ps and .pdf files, 3 for cleanup ex-
+ cept for dep and aux files. (There is also extra cleaning as
specified by the $clean_ext, $clean_full_ext and @generated_exts
variables.)
- This variable is equivalent to specifying one of the -c or -C
- options. But there should be no need to set this variable from
+ This variable is equivalent to specifying one of the -c or -C
+ options. But there should be no need to set this variable from
an RC file.
$clean_ext [""]
- Extra extensions of files for latexmk to remove when any of the
- clean-up options (-c or -C) is selected. The value of this
+ Extra extensions of files for latexmk to remove when any of the
+ clean-up options (-c or -C) is selected. The value of this
variable is a string containing the extensions separated by spa-
ces.
@@ -2543,62 +2603,62 @@
files-%R/*";
in an initialization file will imply that when a clean-up opera-
- tion is specified, not only is the standard set of files
- deleted, but also files of the form FOO.out, FOO-blx.bib, FOO-
- figures*.log, and pythontex-files-FOO/*, where FOO stands for
+ tion is specified, not only is the standard set of files
+ deleted, but also files of the form FOO.out, FOO-blx.bib, FOO-
+ figures*.log, and pythontex-files-FOO/*, where FOO stands for
the basename of the file being processed (as in FOO.tex).
- Most of the files to be deleted are relative to the directory
- specified by $aux_dir. Note that if $out_dir but not $aux_dir
- is set, then in its initialization, latexmk sets $aux_dir equal
- to $out_dir. A normal situation is therefore that $aux_dir
- equals $out_dir, which is the only case directly supported by
- TeXLive, unlike MiKTeX. Note that even with TeXLive latexmk
+ Most of the files to be deleted are relative to the directory
+ specified by $aux_dir. Note that if $out_dir but not $aux_dir
+ is set, then in its initialization, latexmk sets $aux_dir equal
+ to $out_dir. A normal situation is therefore that $aux_dir
+ equals $out_dir, which is the only case directly supported by
+ TeXLive, unlike MiKTeX. Note that even with TeXLive latexmk
does now support different values for the directories -- see the
explanation of the $emulate_aux variable.
If $out_dir and $aux_dir different, latexmk actually deletes any
files of the specified names in both $aux_dir and $out_dir; this
- is because under certain error conditions, the files may be put
- in $out_dir instead of $aux_dir. This also handles the case of
+ is because under certain error conditions, the files may be put
+ in $out_dir instead of $aux_dir. This also handles the case of
deleting any fls file, since that file is in $out_dir.
- The filenames specified for a clean-up operation can refer not
- only to regular files but also to directories. Directories are
+ The filenames specified for a clean-up operation can refer not
+ only to regular files but also to directories. Directories are
only deleted if they are empty. An example of an application is
+ to pythontex, which creates files in a particular directory.
+ You can arrange to remove both the files and the directory by
+ setting
+ $clean_ext = "pythontex-files-%R pythontex-files-%R";
- 17 March 2022 39
+ 18 November 2022 40
-LATEXMK(1) General Commands Manual LATEXMK(1)
- to pythontex, which creates files in a particular directory.
- You can arrange to remove both the files and the directory by
- setting
+LATEXMK(1) General Commands Manual LATEXMK(1)
- $clean_ext = "pythontex-files-%R pythontex-files-%R";
- See also the (array) variable @generated_exts. In the past,
- this variable had certain uses beyond that of $clean_ext. But
- now, they accomplish the same things. In fact, after initial-
- ization including the processing of command line options, la-
+ See also the (array) variable @generated_exts. In the past,
+ this variable had certain uses beyond that of $clean_ext. But
+ now, they accomplish the same things. In fact, after initial-
+ ization including the processing of command line options, la-
texmk simply appends the list of extensions in $clean_ext to the
array @generated_exts.
$clean_full_ext [""]
- Extra extensions of files for latexmk to remove when the -C op-
- tion is selected, i.e., extensions of files to remove when the
+ Extra extensions of files for latexmk to remove when the -C op-
+ tion is selected, i.e., extensions of files to remove when the
.dvi, etc files are to be cleaned-up.
More general patterns are allowed, as for $clean_ext.
- The files specified by $clean_full_ext to be deleted are rela-
+ The files specified by $clean_full_ext to be deleted are rela-
tive to the directory specified by $out_dir.
@@ -2605,75 +2665,75 @@
$compiling_cmd [""], $failure_cmd [""], $warning_cmd [""], $success_cmd
[""]
- These variables specify commands that are executed at certain
- points of compilations. One motivation for their existence is
- to allow very useful convenient visual indications of compila-
- tion status even when the window receiving the screen output of
- the compilation is hidden. This is particularly useful in pre-
+ These variables specify commands that are executed at certain
+ points of compilations. One motivation for their existence is
+ to allow very useful convenient visual indications of compila-
+ tion status even when the window receiving the screen output of
+ the compilation is hidden. This is particularly useful in pre-
view-continuous mode.
- The commands are executed at the following points: $compil-
- ing_cmd at the start of compilation, $success_cmd at the end of
- a completely successful compilation, $failure_cmd at the end of
+ The commands are executed at the following points: $compil-
+ ing_cmd at the start of compilation, $success_cmd at the end of
+ a completely successful compilation, $failure_cmd at the end of
an unsuccessful compilation, $warning_cmd at the of an otherwise
successful compilation that gives warnings about undefined cita-
tions or references or about multiply defined references. If any
- of above variables is undefined or blank (the default situa-
+ of above variables is undefined or blank (the default situa-
tion), then the corresponding command is not executed.
- However, when $warning_cmd is not set, then in the case of a
- compilation with warnings about references or citations, but
- with no other error, one or other of $success_cmd or $fail-
- ure_cmd is used (if it is set) according to the setting of
+ However, when $warning_cmd is not set, then in the case of a
+ compilation with warnings about references or citations, but
+ with no other error, one or other of $success_cmd or $fail-
+ ure_cmd is used (if it is set) according to the setting of
$warnings_as_errors.
An example of a simple setting of these variables is as follows
- $compiling_cmd = "xdotool search --name \"%D\" set_window
+ $compiling_cmd = "xdotool search --name \"%D\" set_window
--name \"%D compiling\"";
- $success_cmd = "xdotool search --name \"%D\" set_window
+ $success_cmd = "xdotool search --name \"%D\" set_window
+ --name \"%D OK\"";
+ $warning_cmd = "xdotool search --name \"%D\" ".
+ "set_window --name \"%D CITE/REF ISSUE\"";
+ $failure_cmd = "xdotool search --name \"%D\" set_window
+ --name \"%D FAILURE\"";
- 17 March 2022 40
+ 18 November 2022 41
+
LATEXMK(1) General Commands Manual LATEXMK(1)
- --name \"%D OK\"";
- $warning_cmd = "xdotool search --name \"%D\" ".
- "set_window --name \"%D CITE/REF ISSUE\"";
- $failure_cmd = "xdotool search --name \"%D\" set_window
- --name \"%D FAILURE\"";
-
- These assume that the program xdotool is installed, that the
- previewer is using an X-Window system for display, and that the
- title of the window contains the name of the displayed file, as
- it normally does. When the commands are executed, the place-
- holder string %D is replaced by the name of the destination
+ These assume that the program xdotool is installed, that the
+ previewer is using an X-Window system for display, and that the
+ title of the window contains the name of the displayed file, as
+ it normally does. When the commands are executed, the place-
+ holder string %D is replaced by the name of the destination
file, which is the previewed file. The above commands result in
an appropriate string being appended to the filename in the win-
dow title: " compiling", " OK", or " FAILURE".
- Other placeholders that can be used are %S, %T, and %R, with %S
- and %T normally being identical. These can be useful for a com-
- mand changing the title of the edit window. The visual indica-
- tion in a window title can useful, since the user does not have
- to keep shifting attention to the (possibly hidden) compilation
+ Other placeholders that can be used are %S, %T, and %R, with %S
+ and %T normally being identical. These can be useful for a com-
+ mand changing the title of the edit window. The visual indica-
+ tion in a window title can useful, since the user does not have
+ to keep shifting attention to the (possibly hidden) compilation
window to know the status of the compilation.
- More complicated situations can best be handled by defining a
- Perl subroutine to invoke the necessary commands, and using the
- "internal" keyword in the definitions to get the subroutine to
+ More complicated situations can best be handled by defining a
+ Perl subroutine to invoke the necessary commands, and using the
+ "internal" keyword in the definitions to get the subroutine to
be invoked. (See the section "Format of Command Specifications"
for how to do this.)
- Naturally, the above settings that invoke the xdotool program
- are only applicable when the X-Window system is used for the
+ Naturally, the above settings that invoke the xdotool program
+ are only applicable when the X-Window system is used for the
relevant window(s). For other cases, you will have to find what
software solutions are available.
@@ -2682,15 +2742,15 @@
Custom dependency list -- see section on "Custom Dependencies".
@default_excluded_files [()]
- When latexmk is invoked with no files specified on the command
+ When latexmk is invoked with no files specified on the command
line, then, by default, it will process all files in the current
directory with the extension .tex. (In general, it will process
the files specified in the @default_files variable.)
But sometimes you want to exclude particular files from this de-
- fault list. In that case you can specify the excluded files in
+ fault list. In that case you can specify the excluded files in
the array @default_excluded_files. For example if you wanted to
- process all .tex files with the exception of common.tex, which
+ process all .tex files with the exception of common.tex, which
is a not a standard alone LaTeX file but a file input by some or
all of the others, you could do
@@ -2698,24 +2758,24 @@
@default_excluded_files = ("common.tex");
+ If you have a variable or large number of files to be processed,
+ this method saves you from having to list them in detail in @de-
+ fault_files and having to update the list every time you change
+ the set of files to be processed.
+ Notes: 1. This variable has no effect except when no files are
- 17 March 2022 41
+ 18 November 2022 42
+
LATEXMK(1) General Commands Manual LATEXMK(1)
- If you have a variable or large number of files to be processed,
- this method saves you from having to list them in detail in @de-
- fault_files and having to update the list every time you change
- the set of files to be processed.
-
- Notes: 1. This variable has no effect except when no files are
specified on the latexmk command line. 2. Wildcards are allowed
in @default_excluded_files.
@@ -2722,16 +2782,16 @@
@default_files [("*.tex")]
Default list of files to be processed.
- If no filenames are specified on the command line, latexmk pro-
- cesses all tex files specified in the @default_files variable,
- which by default is set to all tex files ("*.tex") in the cur-
- rent directory. This is a convenience: just run latexmk and it
- will process an appropriate set of files. But sometimes you
+ If no filenames are specified on the command line, latexmk pro-
+ cesses all tex files specified in the @default_files variable,
+ which by default is set to all tex files ("*.tex") in the cur-
+ rent directory. This is a convenience: just run latexmk and it
+ will process an appropriate set of files. But sometimes you
want only some of these files to be processed. In this case you
- can list the files to be processed by setting @default_files in
- an initialization file (e.g., the file "latexmkrc" in the cur-
- rent directory). Then if no files are specified on the command
- line then the files you specify by setting @default_files are
+ can list the files to be processed by setting @default_files in
+ an initialization file (e.g., the file "latexmkrc" in the cur-
+ rent directory). Then if no files are specified on the command
+ line then the files you specify by setting @default_files are
processed.
Three examples:
@@ -2742,49 +2802,49 @@
@default_files = ("*.tex", "*.dtx");
- Note that more than file may be given, and that the default ex-
+ Note that more than file may be given, and that the default ex-
tension is ".tex". Wild cards are allowed. The parentheses are
because @default_files is an array variable, i.e., a sequence of
filename specifications is possible.
- If you want latexmk to process all .tex files with a few excep-
+ If you want latexmk to process all .tex files with a few excep-
tions, see the @default_excluded_files array variable.
$dependents_phony [0]
- If a list of dependencies is output, this variable determines
- whether to include a phony target for each source file. If you
- use the dependents list in a Makefile, the dummy rules work
- around errors make gives if you remove header files without up-
+ If a list of dependencies is output, this variable determines
+ whether to include a phony target for each source file. If you
+ use the dependents list in a Makefile, the dummy rules work
+ around errors make gives if you remove header files without up-
dating the Makefile to match.
$dependents_list [0]
- Whether to display a list(s) of dependencies at the end of a
+ Whether to display a list(s) of dependencies at the end of a
run.
$deps_file ["-"]
- Name of file to receive list(s) of dependencies at the end of a
- run, to be used if $dependesnt_list is set. If the filename is
+ Name of file to receive list(s) of dependencies at the end of a
+ run, to be used if $dependesnt_list is set. If the filename is
+ "-", then the dependency list is set to stdout (i.e., normally
+ the screen).
+ $do_cd [0]
+ Whether to change working directory to the directory specified
- 17 March 2022 42
+ 18 November 2022 43
-LATEXMK(1) General Commands Manual LATEXMK(1)
- "-", then the dependency list is set to stdout (i.e., normally
- the screen).
+LATEXMK(1) General Commands Manual LATEXMK(1)
- $do_cd [0]
- Whether to change working directory to the directory specified
- for the main source file before processing it. The default be-
- havior is not to do this, which is the same as the behavior of
- *latex programs. This variable is set by the -cd and -cd- op-
+ for the main source file before processing it. The default be-
+ havior is not to do this, which is the same as the behavior of
+ *latex programs. This variable is set by the -cd and -cd- op-
tions on latexmk's command line.
$dvi_filter [empty]
@@ -2791,16 +2851,44 @@
The dvi file filter to be run on the newly produced dvi file be-
fore other processing. Equivalent to specifying the -dF option.
+
+ $dvilualatex ["dvilualatex %O %S"]
+ Specifies the command line to invoke the dvilualatex program.
+ Note that as with other programs, you can use this variable not
+ just to change the name of the program used, but also specify
+ options to the program. E.g.,
+
+ $dvilualatex = "dvilualatex --src-specials
+ %O %S";
+
+ To do a coordinated setting of all of $dvilualatex, $latex,
+ $pdflatex, $lualatex, and $xelatex, see the section "Advanced
+ Configuration".
+
+
$dvi_mode [See below for default]
- If nonzero, generate a dvi version of the document. Equivalent
- to the -dvi option.
+ If one, generate a dvi version of the document by use of latex.
+ Equivalent to the -dvi option.
+ If 2, generate a dvi version of the document by use of dviluala-
+ tex. Equivalent to the -dvilua option.
+
The variable $dvi_mode defaults to 0, but if no explicit re-
quests are made for other types of file (postscript, pdf), then
$dvi_mode will be set to 1. In addition, if a request for a
- file for which a .dvi file is a prerequisite, then $dvi_mode
- will be set to 1.
+ file for which a .dvi file is a prerequisite and $dvi_mode is
+ zero, then $dvi_mode is set to 1.
+
+
+ $dvilualatex_silent_switch ["-interaction=batchmode"]
+ Switch(es) for the dvilualatex program (specified in the vari-
+ able $dvilualatex) when silent mode is on.
+
+ See details of the $latex_silent_switch for other information
+ that equally applies to $dvilualatex_silent_switch.
+
+
$dvi_previewer ["start xdvi %O %S" under UNIX]
The command to invoke a dvi-previewer. [Under MS-Windows the
default is "start"; then latexmk arranges to use the MS-Windows
@@ -2808,6 +2896,18 @@
system has associated with .dvi files.]
Important note: Normally you will want to have a previewer run
+
+
+
+ 18 November 2022 44
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
detached, so that latexmk doesn't wait for the previewer to ter-
minate before continuing its work. So normally you should pre-
fix the command by "start ", which flags to latexmk that it
@@ -2830,18 +2930,6 @@
$dvipdf = "dvipdfm %O -o %D %S";
-
-
-
- 17 March 2022 43
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
WARNING: The default dvipdf script generates pdf files with
bitmapped fonts, which do not look good when viewed by acroread.
That script should be modified to give dvips the options "-P
@@ -2873,6 +2961,19 @@
$dvips_silent_switch ["-q"]
Switch(es) for dvips program when silent mode is on.
+
+
+
+
+ 18 November 2022 45
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$dvi_update_command [""]
When the dvi previewer is set to be updated by running a com-
mand, this is the command that is run. See the information for
@@ -2895,21 +2996,9 @@
4 => run a command to do the update. The command is speci-
fied by the variable $dvi_update_command.
- See information on the variable $pdf_update_method for an
+ See information on the variable $pdf_update_method for an exam-
+ ple of updating by command.
-
-
- 17 March 2022 44
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- example of updating by command.
-
$dvi_update_signal [Under UNIX: SIGUSR1, which is a system-dependent
value]
The number of the signal that is sent to the dvi viewer when it
@@ -2926,168 +3015,184 @@
If you use a version of *latex that doesn't support -aux-direc-
tory, e.g., TeXLive, latexmk will automatically switch aux_dir
emulation on after the first run of *latex, because it will find
- the .log file in the wrong place.
+ the .log file in the wrong place. But it is better to set $emu-
+ late_aux to 1 in an rc file, or equivalently to use the -emu-
+ late-aux-dir option. This emulation mode works equally well with
+ MiKTeX.
- Aux_directory emulation means that when *latex is invoked, the
- output directory provided to *latex is set to be the aux_dir.
- After that, any files that need to be in the output directory
- will be moved there. (These are the files with extensions .dvi,
+ Aux_directory emulation means that when *latex is invoked, the
+ output directory provided to *latex is set to be the aux_dir.
+ After that, any files that need to be in the output directory
+ will be moved there. (These are the files with extensions .dvi,
.ps, .pdf, .fls, .synctex, .synctex.gz.)
+
+
+
+
+ 18 November 2022 46
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$failure_cmd [undefined]
See the documentation for $compiling_cmd.
$fdb_ext ["fdb_latexmk"]
- The extension of the file which latexmk generates to contain a
- database of information on source files. You will not normally
+ The extension of the file which latexmk generates to contain a
+ database of information on source files. You will not normally
need to change this.
- $filetime_causality_threshold [5]; $filetime_offset_report_threshold
+ $filetime_causality_threshold [5]; $filetime_offset_report_threshold
[30]. (Units of seconds.)
These variables control how latexmk deals with the following is-
- sue, which can affect the use of files that are on a remote
+ sue, which can affect the use of files that are on a remote
filesystem (network share) instead of being on a file system lo-
cal to the computer running latexmk. Almost users will not have
- to worry about these settings, and can ignore the following ex-
+ to worry about these settings, and can ignore the following ex-
planation.
- In almost all situations, latexmk does not need to use the time
- stamps of the files it works with. However, there are a couple
- of situations when it needs to know whether a certain file was
- created in the current run of a program (e.g., *latex) or is a
+ In almost all situations, latexmk does not need to use the time
+ stamps of the files it works with. However, there are a couple
+ of situations when it needs to know whether a certain file was
+ created in the current run of a program (e.g., *latex) or is a
leftover file from a previous run. It does this by comparing the
- modification time of the file with the system time just before
- the program was started. If the modification time is earlier
- than when the program was started, the file is a leftover file,
+ modification time of the file with the system time just before
+ the program was started. If the modification time is earlier
+ than when the program was started, the file is a leftover file,
which latexmk treats as if it were not created. If the filetime
+ is at least the program start time, then it can be assumed that
+ the file was created in the current run.
+ Unfortunately, this test can fail if the file is on a remote
+ system, since its system time is not necessarily synchronized
+ with that of the local system; the timestamps on the remote
+ files are set by the remote system, not the local system. Gen-
+ erally, modern operating systems regularly synchronize their
+ time with a server, so the non-synchronization is mostly small
+ (a second or so, or a few seconds). But even a small difference
+ can mess up latexmk's test.
+ Latexmk measures the time difference between the time on the two
+ systems and compensates for this. But the measurement (in a
+ system-independent way) is only accurate to a second or two. So
+ latexmk allows for a threshold on the difference between file
+ and system time before it concludes that a file is a leftover
+ file from a previous run. The configuration variable $file-
+ time_causality_theshhold, which in units of seconds, specifies
+ this threshold. Luckily high precision is not needed. The pre-
+ vious run is normally the previous run in a human run-edit-run
+ cycle, and is at least many seconds back. A few seconds is
+ therefore appropriate for the threshold, $filetime_causal-
+ ity_theshhold; it should be non-negative always, and should be
+ bigger than 2 if a remote filesystem or network share is used.
- 17 March 2022 45
+ If the difference in system times on the two systems is large,
+ 18 November 2022 47
-LATEXMK(1) General Commands Manual LATEXMK(1)
- is at least the program start time, then it can be assumed that
- the file was created in the current run.
- Unfortunately, this test can fail if the file is on a remote
- system, since its system time is not necessarily synchronized
- with that of the local system; the timestamps on the remote
- files are set by the remote system, not the local system. Gen-
- erally, modern operating systems regularly synchronize their
- time with a server, so the non-synchronization is mostly small
- (a second or so, or a few seconds). But even a small difference
- can mess up latexmk's test.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- Latexmk measures the time difference between the time on the two
- systems and compensates for this. But the measurement (in a
- system-independent way) is only accurate to a second or two. So
- latexmk allows for a threshold on the difference between file
- and system time before it concludes that a file is a leftover
- file from a previous run. The configuration variable $file-
- time_causality_theshhold, which in units of seconds, specifies
- this threshold. Luckily high precision is not needed. The pre-
- vious run is normally the previous run in a human run-edit-run
- cycle, and is at least many seconds back. A few seconds is
- therefore appropriate for the threshold, $filetime_causal-
- ity_theshhold; it should be non-negative always, and should be
- bigger than 2 if a remote filesystem or network share is used.
- If the difference in system times on the two systems is large,
- it normally indicates that at least one of the systems is mis-
- configured. The variable $filetime_offset_report_threshold
- specifies the smallest size of the difference (or offset) in
- seconds between the times of the local and remote system beyond
- which the offset is reported. This is reported at the point in
- the latexmk's progress that it measures the offset. The report
+ it normally indicates that at least one of the systems is mis-
+ configured. The variable $filetime_offset_report_threshold
+ specifies the smallest size of the difference (or offset) in
+ seconds between the times of the local and remote system beyond
+ which the offset is reported. This is reported at the point in
+ the latexmk's progress that it measures the offset. The report
is made if silent mode is used and diagnostic mode is not on.
$force_mode [0]
- If nonzero, continue processing past minor latex errors includ-
+ If nonzero, continue processing past minor latex errors includ-
ing unrecognized cross references. Equivalent to specifying the
-f option.
- @generated_exts [( 'aux', 'bcf', 'fls', 'idx', 'ind', 'lof', 'lot',
+ @generated_exts [( 'aux', 'bcf', 'fls', 'idx', 'ind', 'lof', 'lot',
'out', 'toc', 'blg', 'ilg', 'log', 'xdv' )]
- This contains a list of extensions for files that are generated
- during processing, and that should be deleted during a main
- clean up operation, as invoked by the command line option -c.
+ This contains a list of extensions for files that are generated
+ during processing, and that should be deleted during a main
+ clean up operation, as invoked by the command line option -c.
(The use of -C or -gg gives this clean up and more.)
- The default values are extensions for standard files generated
- by *latex, bibtex, and the like. (Note that the clean up also
- deletes the fdb_latexmk file, but that's separately coded into
+ The default values are extensions for standard files generated
+ by *latex, bibtex, and the like. (Note that the clean up also
+ deletes the fdb_latexmk file, but that's separately coded into
latexmk, currently.)
+ After initialization of latexmk and the processing of its com-
+ mand line, the items in clean_ext are appended to @gener-
+ ated_exts. So these two variables have the same meaning (con-
+ trary to older versions of latexmk).
+ The items in @generated_exts are normally extensions of files,
+ whose base name is the same as the main tex file. But it is
+ also possible to specify patterns including that basename ---
+ see the explanation of the variable $clean_ext.
- 17 March 2022 46
+ In addition to specifying files to be deleted in a clean up, la-
+ texmk uses the same specification to assist its examination of
+ changes in source files: Under some situations it needs to find
+ those changes in files (since a previous run) that are expected
+ to be due to the user editing a file. This contrasts with the
+ cases of files that are generated by some program run by latexmk
+ and that differ from the results of the previous run. This use
+ of @generated_exts is normally unimportant, given the usual ac-
+ curacy of latexmk's other ways of determining these generated
+ files.
+ A convenient way to add an extra extension to the list, without
+ losing the already defined ones is to use a push command in the
+ line in an RC file. E.g.,
+ push @generated_exts, "end";
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ 18 November 2022 48
- After initialization of latexmk and the processing of its com-
- mand line, the items in clean_ext are appended to @gener-
- ated_exts. So these two variables have the same meaning (con-
- trary to older versions of latexmk).
- The items in @generated_exts are normally extensions of files,
- whose base name is the same as the main tex file. But it is
- also possible to specify patterns including that basename ---
- see the explanation of the variable $clean_ext.
- In addition to specifying files to be deleted in a clean up, la-
- texmk uses the same specification to assist its examination of
- changes in source files: Under some situations it needs to find
- those changes in files (since a previous run) that are expected
- to be due to the user editing a file. This contrasts with the
- cases of files that are generated by some program run by latexmk
- and that differ from the results of the previous run. This use
- of @generated_exts is normally unimportant, given the usual ac-
- curacy of latexmk's other ways of determining these generated
- files.
- A convenient way to add an extra extension to the list, without
- losing the already defined ones is to use a push command in the
- line in an RC file. E.g.,
+LATEXMK(1) General Commands Manual LATEXMK(1)
- push @generated_exts, "end";
adds the extension "end" to the list of predefined generated ex-
- tensions. (This extension is used by the RevTeX package, for
+ tensions. (This extension is used by the RevTeX package, for
example.)
$go_mode [0]
- If nonzero, process files regardless of timestamps, and is then
+ If nonzero, process files regardless of timestamps, and is then
equivalent to the -g option.
%hash_calc_ignore_pattern
!!!This variable is for experts only!!!
- The general rule latexmk uses for determining when an extra run
- of some program is needed is that one of the source files has
- changed. But consider for example a latex package that causes
- an encapsulated postscript file (an "eps" file) to be made that
- is to be read in on the next run. The file contains a comment
- line giving its creation date and time. On the next run the
- time changes, latex sees that the eps file has changed, and
- therefore reruns latex. This causes an infinite loop, that is
- only terminated because latexmk has a limit on the number of
+ The general rule latexmk uses for determining when an extra run
+ of some program is needed is that one of the source files has
+ changed. But consider for example a latex package that causes
+ an encapsulated postscript file (an "eps" file) to be made that
+ is to be read in on the next run. The file contains a comment
+ line giving its creation date and time. On the next run the
+ time changes, latex sees that the eps file has changed, and
+ therefore reruns latex. This causes an infinite loop, that is
+ only terminated because latexmk has a limit on the number of
runs to guard against pathological situations.
But the changing line has no real effect, since it is a comment.
@@ -3095,43 +3200,44 @@
$hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: ';
+ This creates a rule for files with extension .eps about lines to
+ ignore. The left-hand side is a Perl idiom for setting an item
+ in a hash. Note that the file extension is specified without a
+ period. The value, on the right-hand side, is a string contain-
+ ing a regular expression. (See documentation on Perl for how
+ they are to be specified in general.) This particular regular
+ expression specifies that lines beginning with "%%CreationDate:
+ " are to be ignored in deciding whether a file of the given ex-
+ tension .eps has changed.
+ There is only one regular expression available for each exten-
+ sion. If you need more one pattern to specify lines to ignore,
+ then you need to combine the patterns into a single regular ex-
+ pression. The simplest method is separate the different simple
+ patterns by a vertical bar character (indicating "alternation"
+ in the jargon of regular expressions). For example,
- 17 March 2022 47
+ $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: |^%%Ti-
+ tle: ';
+ causes lines starting with either "^%%CreationDate: " or "^%%Ti-
+ tle: " to be ignored.
+ It may happen that a pattern to be ignored is specified in, for
+ example, in a system or user initialization file, and you wish
+ to remove this in a file that is read later. To do this, you
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ 18 November 2022 49
- This creates a rule for files with extension .eps about lines to
- ignore. The left-hand side is a Perl idiom for setting an item
- in a hash. Note that the file extension is specified without a
- period. The value, on the right-hand side, is a string contain-
- ing a regular expression. (See documentation on Perl for how
- they are to be specified in general.) This particular regular
- expression specifies that lines beginning with "%%CreationDate:
- " are to be ignored in deciding whether a file of the given ex-
- tension .eps has changed.
- There is only one regular expression available for each exten-
- sion. If you need more one pattern to specify lines to ignore,
- then you need to combine the patterns into a single regular ex-
- pression. The simplest method is separate the different simple
- patterns by a vertical bar character (indicating "alternation"
- in the jargon of regular expressions). For example,
- $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: |^%%Ti-
- tle: ';
- causes lines starting with either "^%%CreationDate: " or "^%%Ti-
- tle: " to be ignored.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- It may happen that a pattern to be ignored is specified in, for
- example, in a system or user initialization file, and you wish
- to remove this in a file that is read later. To do this, you
+
use Perl's delete function, e.g.,
delete $hash_calc_ignore_pattern{'eps'};
@@ -3139,109 +3245,99 @@
$jobname [""]
- This specifies the jobname, i.e., the basename that is used for
- generated files (.aux, .log, .dvi, .ps, .pdf, etc). If this
- variable is a null string, then the basename is the basename of
- the main tex file. (At present, the string in $jobname should
+ This specifies the jobname, i.e., the basename that is used for
+ generated files (.aux, .log, .dvi, .ps, .pdf, etc). If this
+ variable is a null string, then the basename is the basename of
+ the main tex file. (At present, the string in $jobname should
not contain spaces.)
- The placeholder '%A' is permitted. This will be substituted by
+ The placeholder '%A' is permitted. This will be substituted by
the basename of the TeX file. The primary purpose is when a va-
- riety of tex files are to be processed, and you want to use a
- different jobname for each but one that is distinct for each.
- Thus if you wanted to compare compilations of a set of files on
+ riety of tex files are to be processed, and you want to use a
+ different jobname for each but one that is distinct for each.
+ Thus if you wanted to compare compilations of a set of files on
different operating systems, with distinct filenames for all the
cases, you could set
$jobname = "%A-$^O";
- in an initialization file. (Here $^O is a variable provided by
+ in an initialization file. (Here $^O is a variable provided by
perl that contains perl's name for the operating system.)
- Suppose you had .tex files test1.tex and test2.tex. Then when
+ Suppose you had .tex files test1.tex and test2.tex. Then when
you run
-
-
- 17 March 2022 48
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
latexmk -pdf *.tex
- both files will be compiled. The .aux, .log, and .pdf files
- will have basenames test1-MSWin32 ante test2-MSWin32 on a MS-
+ both files will be compiled. The .aux, .log, and .pdf files
+ will have basenames test1-MSWin32 ante test2-MSWin32 on a MS-
Windows system, test1-darwin and test2-darwin on an OS-X system,
and a variety of similar cases on linux systems.
$kpsewhich ["kpsewhich %S"]
- The program called to locate a source file when the name alone
- is not sufficient. Most filenames used by latexmk have suffi-
+ The program called to locate a source file when the name alone
+ is not sufficient. Most filenames used by latexmk have suffi-
cient path information to be found directly. But sometimes, no-
tably when a .bib or a .bst file is found from the log file of a
- bibtex or biber run, only the base name of the file is known,
+ bibtex or biber run, only the base name of the file is known,
but not its path. The program specified by $kpsewhich is used to
find it.
- (For advanced users: Because of the different way in which la-
+ (For advanced users: Because of the different way in which la-
texmk uses the command specified in $kpsewhich, some of the pos-
sibilities listed in the FORMAT OF COMMAND SPECIFICATIONS do not
- apply. The internal and start keywords are not available. A
+ apply. The internal and start keywords are not available. A
simple command specification with possible options and then "%S"
- is all that is guaranteed to work. Note that for other com-
+ is all that is guaranteed to work. Note that for other com-
mands, "%S" is substituted by a single source file. In contrast,
for $kpsewhich, "%S" may be substituted by a long list of space-
- separated filenames, each of which is quoted. The result on
+
+
+
+ 18 November 2022 50
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ separated filenames, each of which is quoted. The result on
STDOUT of running the command is then piped to latexmk.)
- See also the @BIBINPUTS variable for another way that latexmk
+ See also the @BIBINPUTS variable for another way that latexmk
also uses to try to locate files; it applies only in the case of
.bib files.
$kpsewhich_show [0]
- Whether to show diagnostics about invocations of kpsewhich: the
- command line use to invoke it and the results. These diagnos-
- tics are shown if $kpsewhich_show is non-zero or if diagnostics
- mode is on. (But in the second case, lots of other diagnostics
- are also shown.) Without these diagnostics there is nothing
- visible in latexmk's screen output about invocations of kpse-
+ Whether to show diagnostics about invocations of kpsewhich: the
+ command line use to invoke it and the results. These diagnos-
+ tics are shown if $kpsewhich_show is non-zero or if diagnostics
+ mode is on. (But in the second case, lots of other diagnostics
+ are also shown.) Without these diagnostics there is nothing
+ visible in latexmk's screen output about invocations of kpse-
which.
$landscape_mode [0]
If nonzero, run in landscape mode, using the landscape mode pre-
- viewers and dvi to postscript converters. Equivalent to the -l
+ viewers and dvi to postscript converters. Equivalent to the -l
option. Normally not needed with current previewers.
$latex ["latex %O %S"]
- Specifies the command line for the LaTeX processing program.
- Note that as with other programs, you can use this variable not
- just to change the name of the program used, but also specify
+ Specifies the command line for the LaTeX processing program.
+ Note that as with other programs, you can use this variable not
+ just to change the name of the program used, but also specify
options to the program. E.g.,
$latex = "latex --src-specials %O %S";
+ To do a coordinated setting of all of $dvilualatex, $latex,
+ $pdflatex, $lualatex, and $xelatex, see the section "Advanced
+ Configuration".
-
- 17 March 2022 49
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- To do a coordinated setting of all of $latex, $pdflatex, $luala-
- tex, and $xelatex, see the section "Advanced Configuration".
-
-
%latex_input_extensions
This variable specifies the extensions tried by latexmk when it
finds that a LaTeX run resulted in an error that a file has not
@@ -3262,6 +3358,18 @@
put_ext. They are used as in the following examples are possi-
ble lines in an initialization file:
+
+
+
+ 18 November 2022 51
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
remove_input_ext( 'latex', 'tex' );
removes the extension 'tex' from latex_input_extensions
@@ -3292,18 +3400,6 @@
Under MS-Windows (unlike UNIX/Linux), there is no standard pro-
gram for printing files. But there are ways you can do it. For
-
-
-
- 17 March 2022 50
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
example, if you have gsview installed, you could use it with the
option "/p":
@@ -3329,6 +3425,17 @@
$lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p';
+
+
+ 18 November 2022 52
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
If gsview is installed in a different directory, you will need
to make the appropriate change. Note the double quotes around
the name: this is necessary because one part of the command name
@@ -3340,43 +3447,32 @@
is to be used when the lualatex program is called for (e.g., by
the option -lualatex.
- To do a coordinated setting of all of $latex, $pdflatex, $luala-
- tex, and $xelatex, see the section "Advanced Configuration".
+ To do a coordinated setting of all of $dvilualatex, $latex,
+ $pdflatex, $lualatex, and $xelatex, see the section "Advanced
+ Configuration".
%lualatex_input_extensions
- This variable specifies the extensions tried by latexmk when it
- finds that a lualatex run resulted in an error that a file has
- not been found, and the file is given without an extension.
- This typically happens when LaTeX commands of the form \in-
- put{file} or \includegraphics{figure}, when the relevant source
+ This variable specifies the extensions tried by latexmk when it
+ finds that a lualatex run resulted in an error that a file has
+ not been found, and the file is given without an extension.
+ This typically happens when LaTeX commands of the form \in-
+ put{file} or \includegraphics{figure}, when the relevant source
file does not exist.
- In this situation, latexmk searches for custom dependencies to
- make the missing file(s), but restricts it to the extensions
- specified by the variable %pdflatex_input_extensions. The de-
+ In this situation, latexmk searches for custom dependencies to
+ make the missing file(s), but restricts it to the extensions
+ specified by the variable %pdflatex_input_extensions. The de-
fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
See details of the %latex_input_extensions for other information
-
-
-
- 17 March 2022 51
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
that equally applies to %lualatex_input_extensions.
$lualatex_silent_switch ["-interaction=batchmode"]
- Switch(es) for the lualatex program (specified in the variable
+ Switch(es) for the lualatex program (specified in the variable
$lualatex) when silent mode is on.
- See details of the $latex_silent_switch for other information
+ See details of the $latex_silent_switch for other information
that equally applies to $lualatex_silent_switch.
$make ["make"]
@@ -3386,20 +3482,32 @@
The index processing program.
$makeindex_fudge [0]
- When using makeindex, whether to change directory to $aux_dir
- before running makeindex. Set to 1 if $aux_dir is not an ex-
- plicit subdirectory of current directory, otherwise makeindex
+ When using makeindex, whether to change directory to $aux_dir
+ before running makeindex. Set to 1 if $aux_dir is not an ex-
+ plicit subdirectory of current directory, otherwise makeindex
will refuse to write its output and log files, for security rea-
sons.
$makeindex_silent_switch ["-q"]
- Switch(es) for the index processing program when silent mode is
+ Switch(es) for the index processing program when silent mode is
+
+
+
+ 18 November 2022 53
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
on.
$max_repeat [5]
- The maximum number of times latexmk will run *latex before de-
- ciding that there may be an infinite loop and that it needs to
- bail out, rather than rerunning *latex again to resolve cross-
+ The maximum number of times latexmk will run *latex before de-
+ ciding that there may be an infinite loop and that it needs to
+ bail out, rather than rerunning *latex again to resolve cross-
references, etc. The default value covers all normal cases.
(Note that the "etc" covers a lot of cases where one run of *la-
@@ -3406,113 +3514,101 @@
tex generates files to be read in on a later run.)
$MSWin_back_slash [1]
- This configuration variable only has an effect when latexmk is
- running under MS-Windows. With the default value of 1 for this
- variable, when a command is executed under MS-Windows, latexmk
- substitutes "\" for the separator character between components
- of a directory name. Internally, latexmk uses "/" for the di-
- rectory separator character, which is the character used by
+ This configuration variable only has an effect when latexmk is
+ running under MS-Windows. With the default value of 1 for this
+ variable, when a command is executed under MS-Windows, latexmk
+ substitutes "\" for the separator character between components
+ of a directory name. Internally, latexmk uses "/" for the di-
+ rectory separator character, which is the character used by
Unix-like systems.
- For almost all programs and for almost all filenames under MS-
- Windows, both "\" and "/" are acceptable as the directory sepa-
- rator character, provided at least that filenames are properly
+ For almost all programs and for almost all filenames under MS-
+ Windows, both "\" and "/" are acceptable as the directory sepa-
+ rator character, provided at least that filenames are properly
quoted. But it is possible that programs exist that only accept
- "\" on the command line, since that is the standard directory
- separator for MS-Windows. So for safety latexmk makes the sub-
+ "\" on the command line, since that is the standard directory
+ separator for MS-Windows. So for safety latexmk makes the sub-
stitution from "/" to "\", by default.
- However there are also programs on MS-Windows for which a back
- slash "\" is interpreted differently than as a directory
+ However there are also programs on MS-Windows for which a back
+ slash "\" is interpreted differently than as a directory separa-
+ tor; for these the directory separator should be "/". Programs
+ with this behavior include all the *latex programs in the
+ TeXLive implementation (but not the MiKTeX implementation).
+ Hence if you use TeXLive on MS-Windows, then $MSWin_back_slash
+ should be set to zero.
+ $new_viewer_always [0]
+ This variable applies to latexmk only in continuous-preview
+ mode. If $new_viewer_always is 0, latexmk will check for a pre-
+ viously running previewer on the same file, and if one is run-
+ ning will not start a new one. If $new_viewer_always is non-
+ zero, this check will be skipped, and latexmk will behave as if
+ no viewer is running.
- 17 March 2022 52
+ $out_dir [""]
+ If non-blank, this variable specifies the directory in which
+ output files are to be written by a run of *latex. See also the
+ variable $aux_dir.
+ The effect of this variable (when non-blank) is achieved by us-
+ ing the -output-directory option of *latex. This exists in the
+ usual current (Dec. 2011 and later) implementations of TeX,
+ i.e., MiKTeX and TeXLive. But it may not be present in other
+ 18 November 2022 54
-LATEXMK(1) General Commands Manual LATEXMK(1)
- separator; for these the directory separator should be "/".
- Programs with this behavior include all the *latex programs in
- the TeXLive implementation (but not the MiKTeX implementation).
- Hence if you use TeXLive on MS-Windows, then $MSWin_back_slash
- should be set to zero.
- $new_viewer_always [0]
- This variable applies to latexmk only in continuous-preview
- mode. If $new_viewer_always is 0, latexmk will check for a pre-
- viously running previewer on the same file, and if one is run-
- ning will not start a new one. If $new_viewer_always is non-
- zero, this check will be skipped, and latexmk will behave as if
- no viewer is running.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- $out_dir [""]
- If non-blank, this variable specifies the directory in which
- output files are to be written by a run of *latex. See also the
- variable $aux_dir.
- The effect of this variable (when non-blank) is achieved by us-
- ing the -output-directory option of *latex. This exists in the
- usual current (Dec. 2011 and later) implementations of TeX,
- i.e., MiKTeX and TeXLive. But it may not be present in other
versions.
- If you also use the -cd option, and $out_dir (or $aux_dir) con-
- tains a relative path, then the path is interpreted relative to
+ If you also use the -cd option, and $out_dir (or $aux_dir) con-
+ tains a relative path, then the path is interpreted relative to
the document directory.
- Commonly, the directory specified for output files is a subdi-
+ Commonly, the directory specified for output files is a subdi-
rectory of the current working directory. However, if you spec-
- ify some other directory, e.g., "/tmp/foo" or "../output", be
- aware that this could cause problems, e.g., with makeindex or
- bibtex. This is because modern versions of these programs, by
- default, will refuse to work when they find that they are asked
- to write to a file in a directory that appears not to be the
+ ify some other directory, e.g., "/tmp/foo" or "../output", be
+ aware that this could cause problems, e.g., with makeindex or
+ bibtex. This is because modern versions of these programs, by
+ default, will refuse to work when they find that they are asked
+ to write to a file in a directory that appears not to be the
current working directory or one of its subdirectories. This is
- part of security measures by the whole TeX system that try to
+ part of security measures by the whole TeX system that try to
prevent malicious or errant TeX documents from incorrectly mess-
ing with a user's files. If for $out_dir or $aux_dir you really
- do need to specify an absolute pathname (e.g., "/tmp/foo") or a
+ do need to specify an absolute pathname (e.g., "/tmp/foo") or a
path (e.g., "../output") that includes a higher-level directory,
- and you need to use makeindex or bibtex, then you need to dis-
- able the security measures (and assume any risks). One way of
+ and you need to use makeindex or bibtex, then you need to dis-
+ able the security measures (and assume any risks). One way of
doing this is to temporarily set an operating system environment
- variable openout_any to "a" (as in "all"), to override the de-
+ variable openout_any to "a" (as in "all"), to override the de-
fault "paranoid" setting.
$pdf_mode [0]
- If zero, do NOT generate a pdf version of the document. If
- equal to 1, generate a pdf version of the document using pdfla-
- tex, using the command specified by the $pdflatex variable. If
- equal to 2, generate a pdf version of the document from the ps
-
-
-
- 17 March 2022 53
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- file, by using the command specified by the $ps2pdf variable.
- If equal to 3, generate a pdf version of the document from the
- dvi file, by using the command specified by the $dvipdf vari-
+ If zero, do NOT generate a pdf version of the document. If
+ equal to 1, generate a pdf version of the document using pdfla-
+ tex, using the command specified by the $pdflatex variable. If
+ equal to 2, generate a pdf version of the document from the ps
+ file, by using the command specified by the $ps2pdf variable.
+ If equal to 3, generate a pdf version of the document from the
+ dvi file, by using the command specified by the $dvipdf vari-
able. If equal to 4, generate a pdf version of the document us-
ing lualatex, using the command specified by the $lualatex vari-
- able. If equal to 5, generate a pdf version (and an xdv ver-
- sion) of the document using xelatex, using the commands speci-
+ able. If equal to 5, generate a pdf version (and an xdv ver-
+ sion) of the document using xelatex, using the commands speci-
fied by the $xelatex and xdvipdfmx variables.
- In $pdf_mode=2, it is ensured that .dvi and .ps files are also
- made. In $pdf_mode=3, it is ensured that a .dvi file is also
+ In $pdf_mode=2, it is ensured that .dvi and .ps files are also
+ made. In $pdf_mode=3, it is ensured that a .dvi file is also
made. But this may be overridden by the document.
$pdflatex ["pdflatex %O %S"]
@@ -3524,15 +3620,29 @@
$pdflatex = "pdflatex --shell-escape %O %S";
- (In some earlier versions of latexmk, you needed to use an as-
- signment to $pdflatex to allow the use of lualatex or xelatex
+ (In some earlier versions of latexmk, you needed to use an as-
+ signment to $pdflatex to allow the use of lualatex or xelatex
+
+
+
+ 18 November 2022 55
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
instead of pdflatex. There are now separate configuration vari-
- ables for the use of lualatex or xelatex. See $lualatex and
+ ables for the use of lualatex or xelatex. See $lualatex and
$xelatex.)
- To do a coordinated setting of all of $latex, $pdflatex, $luala-
- tex, and $xelatex, see the section "Advanced Configuration".
+ To do a coordinated setting of all of $dvilualatex, $latex,
+ $pdflatex, $lualatex, and $xelatex, see the section "Advanced
+ Configuration".
+
%pdflatex_input_extensions
This variable specifies the extensions tried by latexmk when it
finds that a pdflatex run resulted in an error that a file has
@@ -3556,18 +3666,6 @@
See details of the $latex_silent_switch for other information
that equally applies to $pdflatex_silent_switch.
-
-
-
- 17 March 2022 54
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
$pdf_previewer ["start acroread %O %S"]
The command to invoke a pdf-previewer.
@@ -3590,6 +3688,18 @@
ample, SumatraPDF or gsview is used to view pdf files.
Important note: Normally you will want to have a previewer run
+
+
+
+ 18 November 2022 56
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
detached, so that latexmk doesn't wait for the previewer to ter-
minate before continuing its work. So normally you should pre-
fix the command by "start ", which flags to latexmk that it
@@ -3623,17 +3733,6 @@
$pdf_update_method = 4;
$pdf_update_command = "xpdf -remote %R -reload";
-
-
- 17 March 2022 55
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
The first setting arranges for the xpdf program to be used in
its "remote server mode", with the server name specified as the
rootname of the TeX file. The second setting arranges for up-
@@ -3655,6 +3754,18 @@
with their default settings of $pscmd.
Setting the variable to -1 is used to indicate that $pscmd is
+
+
+
+ 18 November 2022 57
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
not to be used.
$postscript_mode [0]
@@ -3688,18 +3799,6 @@
option. Which previewer is run depends on the other settings,
see the command line options -view=, and the variable $view.
-
-
-
- 17 March 2022 56
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
$preview_mode [0]
If nonzero, run a previewer to preview the document. Equivalent
to the -pv option. Which previewer is run depends on the other
@@ -3721,6 +3820,18 @@
The -pvc option uses the command specified by the variable
$pscmd to determine if there is an already running previewer,
and to find the process ID (needed if latexmk needs to signal
+
+
+
+ 18 November 2022 58
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
the previewer about file changes).
Each line of the output of this command is assumed to correspond
@@ -3754,18 +3865,6 @@
WARNING: Linux systems may have installed one (or more) versions
of gv under different names, e.g., ggv, kghostview, etc, but
-
-
-
- 17 March 2022 57
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
perhaps not one actually called gv.
Important note: Normally you will want to have a previewer run
@@ -3788,6 +3887,17 @@
command, this is the command that is run. See the information
for the variable $ps_update_method.
+
+
+ 18 November 2022 59
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$ps_update_method [0 under UNIX, 1 under MS-Windows]
How the postscript viewer updates its display when the .ps file
has changed. See the information on the variable $dvi_up-
@@ -3819,19 +3929,6 @@
The same as $always_view_file_via_temporary, except that it only
applies in preview-continuous mode (-pvc option).
-
-
-
-
- 17 March 2022 58
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
$quote_filenames [1]
This specifies whether substitutions for placeholders in command
specifications (as in $pdflatex) are surrounded by double
@@ -3852,12 +3949,24 @@
read.
$recorder [1]
- Whether to use the -recorder option to (latex Use of this option
- results in a file of extension .fls containing a list of the
- files that these programs have read and written. Latexmk will
- then use this file to improve its detection of source files and
- generated files after a run of *latex.
+ Whether to use the -recorder option to *latex. Use of this op-
+ tion results in a file of extension .fls containing a list of
+ the files that these programs have read and written. Latexmk
+
+
+ 18 November 2022 60
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ will then use this file to improve its detection of source files
+ and generated files after a run of *latex.
+
It is generally recommended to use this option (or to configure
the $recorder variable to be on.) But it only works if *latex
supports the -recorder option, which is true for most current
@@ -3886,18 +3995,6 @@
output or aux directories.]
The default under MSWin and Cygwin is ';' and under UNIX-like
-
-
-
- 17 March 2022 59
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
operating systems (including Linux and OS-X) is ':'. Normally
the defaults give correct behavior. But there can be difficul-
ties if your operating system is of one kind, but some of your
@@ -3922,6 +4019,17 @@
lence_logfile_warning_list and -silence_logfile_warning_list-
also set this variable.
+
+
+ 18 November 2022 61
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
Note that multiple occurrences for the same undefined object on
the same page and same line will be compressed to a single warn-
ing.
@@ -3951,19 +4059,6 @@
$success_cmd [undefined]
See the documentation for $compiling_cmd.
-
-
-
-
- 17 March 2022 60
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
$tmpdir [See below for default]
Directory to store temporary files that latexmk may generate
while running.
@@ -3990,6 +4085,17 @@
do this. The intent of calling make from latexmk is merely to
detect dependencies.
+
+
+ 18 November 2022 62
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$view ["default"]
Which kind of file is to be previewed if a previewer is used.
The possible values are "default", "dvi", "ps", "pdf". The
@@ -4018,18 +4124,6 @@
The default behavior is normally satisfactory in the usual edit-
compile-edit cycle. But, for example, latexmk can also be used
-
-
-
- 17 March 2022 61
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
as part of a build process for some bigger project, e.g., for
creating documentation in the build of a software application.
Then it is often sensible to treat citation and reference warn-
@@ -4051,9 +4145,26 @@
that one or more of the commands isn't set.)
+ $xdv_mode [0]
+ If one, generate an xdv version of the document by use of xela-
+ tex.
+
+
+
+
+
+ 18 November 2022 63
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$xdvipdfmx ["xdvipdfmx -E -o %D %O %S"]
- The program to make a pdf file from an xdv file (used in con-
+ The program to make a pdf file from an xdv file (used in con-
junction with xelatex when $pdf_mode=5).
$xdvipdfmx_silent_switch ["-q"]
@@ -4060,22 +4171,23 @@
Switch(es) for the xdvipdfmx program when silent mode is on.
$xelatex ["xelatex %O %S"]
- Specifies the command line for the LaTeX processing program of
- when the xelatex program is called for. See the documentation
- of the -xelatex option for some special properties of latexmk's
+ Specifies the command line for the LaTeX processing program of
+ when the xelatex program is called for. See the documentation
+ of the -xelatex option for some special properties of latexmk's
use of xelatex.
- Note about xelatex: latexmk uses xelatex to make an .xdv rather
- than .pdf file, with the .pdf file being created in a separate
+ Note about xelatex: latexmk uses xelatex to make an .xdv rather
+ than .pdf file, with the .pdf file being created in a separate
step. This is enforced by the use of the -no-pdf option. If %O
- is part of the command for invoking xelatex, then latexmk will
+ is part of the command for invoking xelatex, then latexmk will
insert the -no-pdf option automatically, otherwise you must pro-
- vide the option yourself. See the documentation for the -pdfxe
+ vide the option yourself. See the documentation for the -pdfxe
option for why latexmk makes a .xdv file rather than a .pdf file
when xelatex is used.
- To do a coordinated setting of all of $latex, $pdflatex, $luala-
- tex, and $xelatex, see the section "Advanced Configuration".
+ To do a coordinated setting of all of $dvilualatex, $latex,
+ $pdflatex, $lualatex, and $xelatex, see the section "Advanced
+ Configuration".
%xelatex_input_extensions
@@ -4084,18 +4196,6 @@
not been found, and the file is given without an extension.
This typically happens when LaTeX commands of the form \in-
put{file} or \includegraphics{figure}, when the relevant source
-
-
-
- 17 March 2022 62
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
file does not exist.
In this situation, latexmk searches for custom dependencies to
@@ -4116,6 +4216,18 @@
+
+
+
+ 18 November 2022 64
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
CUSTOM DEPENDENCIES
In any RC file a set of custom dependencies can be set up to convert a
file with one extension to a file with another. An example use of this
@@ -4150,18 +4262,6 @@
must: If non-zero, the file from which we are converting must exist,
if it doesn't exist latexmk will give an error message and exit
unless the -f option is specified. If must is zero and the file
-
-
-
- 17 March 2022 63
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
we are converting from doesn't exist, then no action is taken.
Generally, the appropriate value of must is zero.
@@ -4184,6 +4284,16 @@
tom dependencies to be sent to the screen output.
+
+ 18 November 2022 65
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
How custom dependencies are used:
An instance of a custom dependency rule is created whenever latexmk de-
tects that a run of *latex needs to read a file, like a graphics file,
@@ -4216,18 +4326,6 @@
Note for advanced usage: The operating system's environment variable
TEXINPUTS can be used to specify a search path for finding files by la-
tex etc. Correspondingly, when a missing file is reported, latexmk
-
-
-
- 17 March 2022 64
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
looks in the directories specified in TEXINPUTS as well as in the cur-
rent directory, to find a source file from which an instance of a cus-
tom dependency can be used to make the missing file.
@@ -4249,8 +4347,20 @@
The first line adds a custom dependency that converts a file with ex-
tension "fig", as created by the xfig program, to an encapsulated post-
- script file, with extension "eps". The remaining lines define a sub-
- routine that carries out the conversion. If a rule for converting
+ script file, with extension "eps". The remaining lines define a
+
+
+
+ 18 November 2022 66
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ subroutine that carries out the conversion. If a rule for converting
"fig" to "eps" files already exists (e.g., from a previously read-in
initialization file), the latexmk will delete this rule before making
the new one.
@@ -4282,18 +4392,6 @@
}
Note 1: In the command lines given in the system commands in the above
-
-
-
- 17 March 2022 65
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
examples, double quotes have been inserted around the file names (im-
plemented by '\"' in the Perl language). They immunize the running of
the program against special characters in filenames. Very often these
@@ -4316,6 +4414,18 @@
Note 3: The subroutines implementing custom dependencies in the exam-
ples given just have a single line invoking an external program.
That's the usual situation. But since the subroutines are in the Perl
+
+
+
+ 18 November 2022 67
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
language, you can implement much more complicated processing if you
need it.
@@ -4347,26 +4457,14 @@
file. This method has been available since very old versions of la-
texmk, and many examples can be found, e.g., on the web.
- However in later versions of latexmk the internal structure of the
+ However in later versions of latexmk the internal structure of the im-
+ plementation of its "rules" for the steps of processing, including cus-
+ tom dependencies, became much more powerful. The function implementing
+ a custom dependency is executed within a special context where a number
+ of extra variables and subroutines are defined. Publicly documented
+ ones, intended to be long-term stable, are listed below, under the
+ heading "Variables and subroutines for processing a rule".
-
-
- 17 March 2022 66
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- implementation of its "rules" for the steps of processing, including
- custom dependencies, became much more powerful. The function imple-
- menting a custom dependency is executed within a special context where
- a number of extra variables and subroutines are defined. Publicly doc-
- umented ones, intended to be long-term stable, are listed below, under
- the heading "Variables and subroutines for processing a rule".
-
Examples of their use is given in the following examples, concerning
multiple index files and glossaries.
@@ -4382,6 +4480,18 @@
follows:
add_cus_dep( 'ndx', 'nnd', 0, 'ndx2nnd' );
+
+
+
+ 18 November 2022 68
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
sub ndx2nnd {
return system( "makeindex -o \"$_[0].nnd\" \"$_[0].ndx\"" );
}
@@ -4414,18 +4524,6 @@
push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
This last example uses the command specification in $makeindex, and so
-
-
-
- 17 March 2022 67
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
any customization you have made for the standard index also applies to
your extra indexes.
@@ -4447,13 +4545,25 @@
Old Method of Defining Custom Dependencies:
In much older versions of latexmk, the only method of defining custom
- dependencies was to directly manipulate the table of custom dependen-
- cies. This is contained in the @cus_dep_list array. It is an array of
- strings, and each string in the array has four items in it, each sepa-
- rated by a space, the from-extension, the to-extension, the "must"
- item, and the name of the subroutine for the custom dependency. These
- were all defined above.
+ dependencies was to directly manipulate the table of custom
+
+
+ 18 November 2022 69
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ dependencies. This is contained in the @cus_dep_list array. It is an
+ array of strings, and each string in the array has four items in it,
+ each separated by a space, the from-extension, the to-extension, the
+ "must" item, and the name of the subroutine for the custom dependency.
+ These were all defined above.
+
An example of the old method of defining custom dependencies is as fol-
lows. It is the code in an RC file to ensure automatic conversion of
.fig files to .eps files:
@@ -4479,22 +4589,10 @@
See also the section DEALING WITH ERRORS, PROBLEMS, ETC. See also the
examples in the directory example_rcfiles in the latexmk distributions.
- Even if none of the examples apply to your case, they may give you
+ Even if none of the examples apply to your case, they may give you use-
+ ful ideas
-
- 17 March 2022 68
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- useful ideas
-
-
Utility subroutines
ensure_path( var, values ...)
@@ -4515,6 +4613,17 @@
to mean that *latex search for files in the specified directory
and in all subdirectories.)
+
+
+ 18 November 2022 70
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
Technically ensure_path works by setting Perl's variable
$ENV{var}, where var is the name of the target variable. The
changed value is then passed as an environment variable to any
@@ -4545,19 +4654,6 @@
This gives the name of the primary source file. Note the double
dollar signs.
-
-
-
-
- 17 March 2022 69
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
$$Pdest
This gives the name of the main output file if any. Note the
double dollar signs.
@@ -4582,6 +4678,18 @@
This subroutine removes one or more files from the dependency
list for the given rule.
+
+
+
+ 18 November 2022 71
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
rdb_list_source( $rule )
This subroutine returns the list of source files (i.e., the de-
pendency list) for the given rule.
@@ -4608,45 +4716,46 @@
Coordinated Setting of Commands for *latex
- To set all of $latex, $pdflatex, $lualatex, and $xelatex to a common
- pattern, you can use one of the following subroutines, std_tex_cmds,
- alt_tex_cmds, and set_tex_cmds.
+ To set all of $dvilualatex, $latex, $pdflatex, $lualatex, and $xelatex
+ to a common pattern, you can use one of the following subroutines,
+ std_tex_cmds, alt_tex_cmds, and set_tex_cmds.
+ They work as follows
+ &std_tex_cmds;
+ This results in $latex = 'latex %O %S', and similarly for $dvilualatex,
+ $pdflatex, $lualatex, and $xelatex. Note the ampersand in the invoca-
+ tion; this indicates to Perl that a subroutine is being called.
- 17 March 2022 70
+ &alt_tex_cmds;
+ This results in $latex = 'latex %O %P', and similarly for $dvilualatex,
+ $pdflatex, $lualatex, and $xelatex. Note the ampersand in the invoca-
+ tion; this indicates to Perl that a subroutine is being called.
+ set_tex_cmds( CMD_SPEC );
+ Here CMD_SPEC is the command line without the program name. This re-
+ sults in $latex = 'latex CMD_SPEC', and similarly for $pdflatex, $lu-
+ alatex, and $xelatex. An example would be
+ set_tex_cmds( '--interaction=batchmode %O %S' );
-LATEXMK(1) General Commands Manual LATEXMK(1)
- They work as follows
- &std_tex_cmds;
- This results in $latex = 'latex %O %S', and similarly for $pdflatex,
- $lualatex, and $xelatex. Note the ampersand in the invocation; this
- indicates to Perl that a subroutine is being called.
- &alt_tex_cmds;
+ 18 November 2022 72
- This results in $latex = 'latex %O %P', and similarly for $pdflatex,
- $lualatex, and $xelatex. Note the ampersand in the invocation; this
- indicates to Perl that a subroutine is being called.
- set_tex_cmds( CMD_SPEC );
- Here CMD_SPEC is the command line without the program name. This re-
- sults in $latex = 'latex CMD_SPEC', and similarly for $pdflatex, $lu-
- alatex, and $xelatex. An example would be
- set_tex_cmds( '--interaction=batchmode %O %S' );
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
Advanced configuration: Using latexmk with make
This section is targeted only at advanced users who use the make pro-
gram for complex projects, as for software development, with the depen-
@@ -4677,21 +4786,9 @@
could be quite complicated, for example if some of the source files for
a LaTeX document are generated by the project's software.
- In this section, I give a couple of examples of how latexmk can be
-
-
-
- 17 March 2022 71
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- usefully invoked from a Makefile. The examples use specific features
- of current versions of GNU make, which is the default on both linux and
+ In this section, I give a couple of examples of how latexmk can be use-
+ fully invoked from a Makefile. The examples use specific features of
+ current versions of GNU make, which is the default on both linux and
OS-X systems. They may need modifications for other versions of make.
The simplest method is simply to delegate all the relevant tasks to la-
@@ -4713,6 +4810,18 @@
The above example has a pattern rule for making a .pdf file from a .tex
file, and it is defined to use latexmk in the obvious way. There is a
+
+
+
+ 18 November 2022 73
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
conventional default target named "all", with a prerequisite of
try.pdf. So when make is invoked, by default it makes try.pdf. The
only complication is that there may be many source files beyond
@@ -4744,18 +4853,6 @@
mkdir $@
%.pdf : %.tex
if [ ! -e $(DEPS_DIR) ]; then mkdir $(DEPS_DIR); fi
-
-
-
- 17 March 2022 72
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
$(LATEXMK) -pdf -dvi- -ps- -deps-out=$(DEPS_DIR)/$@P $<
%.pdf : %.fig
fig2dev -Lpdf $< $@
@@ -4779,6 +4876,18 @@
tion, which improves its detection of files generated during a run of
pdflatex; such files should not be in the dependency list. The -e op-
tions are used to turn off all custom dependencies, and to document
+
+
+
+ 18 November 2022 74
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
this. Instead the -use-make is used to delegate the making of missing
files to make itself.
@@ -4794,10 +4903,24 @@
delegated to make.
+NON_ASCII CHARACTERS IN FILENAMES, RC FILES, ETC
+ Modern operating systems and file systems allow non-ASCII characters in
+ the names of files and directories that encompass the full Unicode
+ range. Mostly, latexmk deals with these correctly. However, there are
+ some situations in which there are problems, notably on Microsoft Win-
+ dows. Prior to version 4.77, latexmk had problems with non-ASCII file-
+ names on Windows, even though there were no corresponding problems on
+ macOS and Linux. These problems are corrected in the present version.
+
+ DETAILS TO BE FILLED IN
+
+
+
SEE ALSO
latex(1), bibtex(1), lualatex(1), pdflatex(1), xelatex(1).
-BUGS
+
+BUGS (SELECTED)
Sometimes a viewer (gv) tries to read an updated .ps or .pdf file after
its creation is started but before the file is complete. Work around:
manually refresh (or reopen) display. Or use one of the other preview-
@@ -4810,32 +4933,32 @@
manual update (reopen); it views postscript and pdf. Gsview under MS-
Windows works for both postscript and pdf, but only reads the updated
file when its screen is refreshed. Acroread under UNIX/Linux views
+ pdf, but the file needs to be closed and reopened to view an updated
+ version. Under MS-Windows, acroread locks its input file and so the
+ pdf file cannot be updated. (Remedy: configure latexmk to use suma-
+ trapdf instead.)
+THANKS TO
+ Authors of previous versions. Many users with their feedback, and es-
+ pecially David Coppit (username david at node coppit.org) who made many
+ useful suggestions that contributed to version 3, and Herbert Schulz.
- 17 March 2022 73
+ 18 November 2022 75
+
LATEXMK(1) General Commands Manual LATEXMK(1)
- pdf, but the file needs to be closed and reopened to view an updated
- version. Under MS-Windows, acroread locks its input file and so the
- pdf file cannot be updated. (Remedy: configure latexmk to use suma-
- trapdf instead.)
-
-THANKS TO
- Authors of previous versions. Many users with their feedback, and es-
- pecially David Coppit (username david at node coppit.org) who made many
- useful suggestions that contributed to version 3, and Herbert Schulz.
(Please note that the e-mail addresses are not written in their stan-
dard form to avoid being harvested too easily.)
AUTHOR
- Current version, by John Collins (Version 4.77). Report bugs etc to
+ Current version, by John Collins (Version 4.78). Report bugs etc to
his e-mail (jcc8 at psu.edu).
Released version can be obtained from CTAN:
@@ -4879,6 +5002,15 @@
- 17 March 2022 74
+
+
+
+
+
+
+
+ 18 November 2022 76
+
+
Modified: trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl 2022-11-19 00:49:28 UTC (rev 65053)
+++ trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl 2022-11-19 21:12:09 UTC (rev 65054)
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
-
use warnings;
+
## Copyright John Collins 1998-2022
## (username jcc8 at node psu.edu)
## (and thanks to David Coppit (username david at node coppit.org)
@@ -43,13 +43,13 @@
$my_name = 'latexmk';
$My_name = 'Latexmk';
-$version_num = '4.77';
-$version_details = "$My_name, John Collins, 17 Mar. 2022. Version $version_num";
+$version_num = '4.78';
+$version_details = "$My_name, John Collins, 18 Nov. 2022. Version $version_num";
use Config;
use File::Basename;
use File::Copy;
-use File::Spec;
+use File::Spec::Functions qw( catfile file_name_is_absolute rel2abs );
# If possible, use better glob, which does not use space as item separator.
# It's either File::Glob::bsd_glob or File::Glob::glob
@@ -91,16 +91,13 @@
use utf8; # For UTF-8 strings in **this** script
use feature 'unicode_strings';
use feature 'say';
-use bytes; # To avoid messes when we use string operations on byte-coded/encoded
- # filename strings.
+
# Coding:
# 1. $CS_system = CS for file names in file system calls, and for CL.
# It's to be UTF-8 on all except: MSWin when the MSWin system code page is
# not 65001.
# 2. Internally use CS_system generally, and especially for filenames.
-# Note with "use bytes;", even **de**coded strings have length and contents
-# in terms of bytes with UTF-8 coding.
# Then standard file system calls, print to terminal don't need encoding,
# and things in rc files work unchanged from earlier versions of latexmk,
# when I didn't treat non-ASCII coding issues explicitly.
@@ -113,10 +110,11 @@
# the PWD is in CS_system on all but most recent *latex (that's a bug).
# Convert file/path names to CS_system.
# 7. Don't support non-UTF-8 on *nix.
-# 8. Do NOT do any conversion to a NF for Unicode: File systems are **either**
-# normalization-sensitive (NTFS, ext4) and we need to preserve
-# normalization, **or** they are normalization-insensitve (hfs+, apfs),
-# in which case we can access a file with any normalization for its name.
+# 8. Do NOT do any conversion to a NF for Unicode: File systems and OS calls
+# to access them are **either** normalization-sensitive (I think, e.g.,
+# ext4) and we need to preserve normalization, **or** they are
+# normalization-insensitve (e.g., hfs+, apfs), in which case we can access
+# a file with any normalization for its name.
#
# N.B. I18N::Langinfo often doesn't give useful enough information.
@@ -126,7 +124,7 @@
our $CS_system;
$CS_system = 'UTF-8';
# Quick short cut for tests of whether conversions needed:
-our $utf8_used = 1;
+our $no_CP_conversions = 1;
# Win32 specific CP **numbers**. Initialize to 65001 (utf-8), and change
# by results of system calls.
@@ -152,18 +150,19 @@
};
if ($@) { warn "Trouble finding and setting code pages used by Windows:\n",
" $@",
- " ILL CONTINUE WITH UTF-8.\n";
+ " I'LL CONTINUE WITH UTF-8.\n";
}
else {
$Win_revert_settings =
($CP_init_Win_console_in ne $CP_Win_system)
|| ($CP_init_Win_console_out ne $CP_Win_system);
+ print
+ "Initial Win CP for (console input, console output, system): ",
+ "(CP$CP_init_Win_console_in, CP$CP_init_Win_console_out, CP$CP_Win_system)\n",
+ "I changed them all to CP$CP_Win_system\n";
}
- print "Win CP console initial and current in/out Win: ",
- "($CP_init_Win_console_in, $CP_init_Win_console_out), ",
- "($CP_Win_system, $CP_Win_system)\n";
}
-$utf8_used = ($CS_system eq 'UTF-8') || ($CS_system eq 'CP65001');
+$no_CP_conversions = ($CS_system eq 'UTF-8') || ($CS_system eq 'CP65001');
# Ensure that on ctrl/C interruption, etc, Windows console CPs are restored:
use sigtrap qw(die untrapped normal-signals);
@@ -176,45 +175,105 @@
}
}
-print "Coding system for system and terminal: '$CS_system'\n---\n"
- unless $utf8_used;
-
########################################################
#************************************************************
#************************************************************
# Unicode manipuation and normalization
+# Notes about Perl strings:
+# 1. Strings have a flag utf8.
+# a. If the utf8 flag is on, the string is to be interpreted as a sequence
+# of code points.
+# When "use utf8;" is used, a string containing non-ASCII characters
+# has the utf8 flag set.
+# If 'no bytes;' is in effect, the ordinal value for each item in the
+# string is the Unicode code point value.
+# b. If the utf8 flag is off for a string, the string is a sequence of
+# bytes, to be interpreted according to whatever CS the user happens
+# to choose to use.
+# c. The utf8 flag is NOT to be interpreted as saying that the string is
+# encoded as UTF-8, even though under the hood that may be the case.
+# d. Indeed, setting 'use bytes;' appears to expose the internal
+# byte-level representation of a string with the utf8 flag set, and
+# that appears to be UTF-8.
+# 2. The utf8 flag is quite confusing in its meaning.
+# 3. When encode is applied to a string whose utf8 flag is on, the result
+# is a string with the utf8 flag off, and the result consists of a sequence
+# of bytes in the chosen encoding scheme, which may be chosen as UTF-8.
+# 4. Strings received from the command line have the utf8 flag off and are
+# encoded in whatever CS the OS/terminal is using.
+# 5. When a string is supplied to print (or c), by default:
+# a. If the utf8 flag is off or if 'use bytes;' is in effect, then the
+# string is sent as a sequence of bytes. They are UTF-8 coded if
+# the utf8 flag is on and 'use bytes;' is in effect.
+# b. If the utf8 flag is on and if 'no bytes;' is in effect, then mostly
+# garbage results for non-ASCII characters; the string must first be
+# encoded as a byte string, in the CS suitable for the OS.
+# c. Correct results are obtained when the utf8 flag is on and 'no bytes'
+# is used when the binmode for the file handle is set suitably.
+# 6. Generally OS calls and interactions with the OS need encoded byte strings.
+# 7. Even more generally, interaction with the external world, including file
+# contents is in terms of byte strings, with some CS chosen by default, by
+# the user, or the OS. Unix-like OSs: Default is UTF-8, but as much by
+# convention as by a requirement of the OS.
-
#-------------------------------------
-sub analyze_string {
- # Useful for debugging encoding issues.
- my ($m,$s) = @_;
- say "=== $m '$s':";
- say(
- 'Perl flag = ',
- (utf8::is_utf8($s) ? 'utf8' : 'NOT utf8'),
- ", len = ", length($s)
- );
- my @code = unpack( 'U*', $s );
- @code = map { sprintf('%4X', $_) } @code;
- say join( ' ', @code );
+sub utf8_to_mine {
+ # Given string encoded in UTF-8, return encoded string in my current CS.
+ # Don't use Encode::from_to, which does in-place conversion.
+ if ($no_CP_conversions) { return $_[0]; }
+ else { return encode( $CS_system, decode('UTF-8', $_[0])); }
}
-#==================
+#-------------------------------------
-sub utf8_to_mine {
+sub utf8_to_mine_errors {
# Given string encoded in UTF-8, return encoded string in my current CS.
- if ($utf8_used) { return $_[0]; }
- else { return encode( $CS_system, decode('UTF-8', $_[0])); }
+ # Don't use Encode::from_to, which does in-place conversion.
+ # Assume coding of input string is correctly UTF-8, but
+ # check for correct encoding in CS_system.
+ # Error message is returned in $@. No error => $@ is null string.
+ # (Same style as eval!)
+ $@ = '';
+ if ($no_CP_conversions) { return $_[0]; }
+ else {
+ my $result = '';
+ eval {
+ $result = encode( $CS_system,
+ decode('UTF-8', $_[0]),
+ Encode::FB_CROAK | Encode::LEAVE_SRC
+ );
+ };
+ return $result;
+ }
}
#-------------------------------------
+sub config_to_mine {
+ # Ensure that configuration strings about files and directories are
+ # encoded in system CS.
+ # Configuration strings set in an rc file SHOULD either be:
+ # a. ASCII only, with Perl's utf8 flag off.
+ # b. Containing non-ASCII characters, with utf8 flag on.
+ # These need to be converted to encoded strings in system CS (and
+ # hence with utf8 flag off).
+ # Configuration variables set from the command line, e.g., from an
+ # -outdir=... option, are already in the system CS, because that is
+ # how strings are passed on the command line.
+ # So we just need to do a conversion for strings with utf8 flag on:
+ foreach ( $out_dir, $aux_dir, @default_files, @default_excluded_files ) {
+ if (utf8::is_utf8($_)) { $_ = encode( $CS_system, $_ ); }
+ }
+} #END config_to_mine
+
+#************************************************************
+
sub mine_to_utf8 {
# Given string encoded in my current CS, return utf-8 encoded string.
- if ($utf8_used) { return $_[0]; }
+ # Don't use Encode::from_to, which does in-place conversion.
+ if ($no_CP_conversions) { return $_[0]; }
else { return encode( 'UTF-8', decode($CS_system, $_[0])); }
}
@@ -255,15 +314,15 @@
if ($invoked_name ne 'latexmk');
# Map my invoked name to pointer to array of default values for $dvi_mode,
-# $postscript_mode, $pdf_mode. These are used if after processing rc files
-# and CL args, no values are set for any of these variables.
+# $postscript_mode, $pdf_mode, $xdv_mode. These are used if after processing
+# rc files and CL args, no values are set for any of these variables.
# Thus default compilation for latexmk is by latex,
# for pdflatexmk is by pdflatex, etc.
%compilation_defaults =
- ( 'latexmk' => [1,0,0],
- 'lualatexmk' => [0,0,4],
- 'pdflatexmk' => [0,0,1],
- 'xelatexmk' => [0,0,5],
+ ( 'latexmk' => [1,0,0,0],
+ 'lualatexmk' => [0,0,4,0],
+ 'pdflatexmk' => [0,0,1,0],
+ 'xelatexmk' => [0,0,5,0],
);
# If name isn't in canonical set, change it to a good default:
unless (exists $compilation_defaults{$invoked_name}) { $invoked_name = 'latexmk'; }
@@ -320,7 +379,19 @@
'Error: pdflatex \(file ([^\)]*)\): cannot find image file',
': File (.*) not found:\s*$',
'! Unable to load picture or PDF file \\\'([^\\\']+)\\\'.',
+ );
+
+# Array of reg-exps for patterns in log file for certain latex warnings
+# that we will call bad warnings. They are not treated as errors by
+# *latex, but depending on the $bad_warning_is_error setting
+# we will treat as if they were actual errors.
+ at bad_warnings = (
+ # Remember: \\ in perl inside single quotes gives a '\', so we need
+ # '\\\\' to get '\\' in the regexp.
+ '^\(\\\\end occurred when .* was incomplete\)',
+ '^\(\\\\end occurred inside .*\)',
);
+$bad_warning_is_error = 0;
# Characters that we won't allow in the name of a TeX file.
# Notes: Some are disallowed by TeX itself.
@@ -401,6 +472,10 @@
## "" means not determined. Obtain from first line of .log file.
$tex_distribution = '';
+# List of known *latex rules:
+%possible_primaries = ( 'dvilualatex' => 'primary', 'latex' => 'primary',
+ 'lualatex' => 'primary', 'pdflatex' => 'primary',
+ 'xelatex' => 'primary' );
&std_tex_cmds;
# Possible code to execute by *latex before inputting source file.
@@ -410,6 +485,7 @@
## Default switches:
$latex_default_switches = '';
$pdflatex_default_switches = '';
+$dvilualatex_default_switches = '';
$lualatex_default_switches = '';
# Note that xelatex is used to give xdv file, not pdf file, hence
# we need the -no-pdf option.
@@ -418,12 +494,13 @@
## Switch(es) to make them silent:
$latex_silent_switch = '-interaction=batchmode';
$pdflatex_silent_switch = '-interaction=batchmode';
+$dvilualatex_silent_switch = '-interaction=batchmode';
$lualatex_silent_switch = '-interaction=batchmode';
$xelatex_silent_switch = '-interaction=batchmode';
# Whether to emulate -aux-directory, so we can use it on system(s) (TeXLive)
# that don't support it:
-$emulate_aux = 0;
+$emulate_aux = 1;
# Whether emulate_aux had to be switched on during a run:
$emulate_aux_switched = 0;
@@ -637,6 +714,7 @@
# These need to be stored until after the command line parsing is finished,
# in case the values of $latex and/or $pdflatex change after an option
# is added.
+ at extra_dvilualatex_options = ();
@extra_latex_options = ();
@extra_pdflatex_options = ();
@extra_lualatex_options = ();
@@ -1118,6 +1196,15 @@
## default parameters
$auto_rc_use = 1; # Whether to read rc files automatically
+$user_deleted_file_treated_as_changed = 0; # Whether when testing for changed
+ # files, a user file that changes status from existing
+ # to non-existing should be regarded as changed.
+ # Value 1: only in non-preview-continuous mode.
+ # Value 2: always.
+ # Primary purpose is to cover cases where behavior of
+ # compilation of .tex file tests for file existence and
+ # adjusts behavior accordingly, instead of simply giving an
+ # error.
$max_repeat = 5; # Maximum times I repeat latex. Normally
# 3 would be sufficient: 1st run generates aux file,
# 2nd run picks up aux file, and maybe toc, lof which
@@ -1159,7 +1246,7 @@
$fdb_ext = 'fdb_latexmk'; # Extension for the file for latexmk's
# file-database
# Make it long to avoid possible collisions.
-$fdb_ver = 3; # Version number for kind of fdb_file.
+$fdb_ver = 4; # Version number for kind of fdb_file.
$jobname = ''; # Jobname: as with current tex, etc indicates
# basename of generated files. Defined so
@@ -1221,19 +1308,27 @@
# Which kinds of file do I have requests to make?
+our ($dvi_mode, $pdf_mode, $postscript_mode, $xdv_mode,
+ $cleanup_mode, $force_mode, $go_mode, $landscape_mode, $preview_mode, $preview_continuous_mode, $printout_mode );
# If no requests at all are made, then I will make dvi file
# If particular requests are made then other files may also have to be
# made. E.g., ps file requires a dvi file
-$dvi_mode = 0; # No dvi file requested
+$dvi_mode = 0; # No dvi file requested.
+ # Possible values:
+ # 0: no request for dvi file
+ # 1: use latex to make dvi file
+ # 2: use dvilualatex to make dvi file
$postscript_mode = 0; # No postscript file requested
$pdf_mode = 0; # No pdf file requested to be made by pdflatex
# Possible values:
# 0 don't create pdf file
# 1 to create pdf file by pdflatex
- # 2 to create pdf file by ps2pdf
- # 3 to create pdf file by dvipdf
+ # 2 to create pdf file by compile-to-dvi+dvips+ps2pdf
+ # 3 to create pdf file by compile-to-dvi+dvipdf
# 4 to create pdf file by lualatex
# 5 to create pdf file by xelatex + xdvipdfmx
+$xdv_mode = 0; # No xdv file requested
+
$view = 'default'; # Default preview is of highest of dvi, ps, pdf
$sleep_time = 2; # time to sleep b/w checks for file changes in -pvc mode
$banner = 0; # Non-zero if we have a banner to insert
@@ -1269,9 +1364,10 @@
$dvi_filter = ''; # DVI filter command
$ps_filter = ''; # Postscript filter command
-$force_mode = 0; # =1 to force processing past errors
-$go_mode = 0; # =1 to force processing regardless of time-stamps
- # =2 full clean-up first
+$force_mode = 0; # =1: to force processing past errors
+$go_mode = 0; # =1: to force processing regardless of time-stamps
+ # =2: full clean-up first
+ # =3: Just force primary rule(s) to run
$preview_mode = 0;
$preview_continuous_mode = 0;
$printout_mode = 0; # Don't print the file
@@ -1280,10 +1376,14 @@
$pvc_timeout = 0;
$pvc_timeout_mins = 30;
-$show_time = 0;
- at timings = ();
-$processing_time1 = processing_time();
+# Timing information
+# Whether to report processing time:
+our $show_time = 0;
+# Data for 1 run and global (ending in '0'):
+our ( $processing_time1, $processing_time0, @timings1, @timings0);
+&init_timing_all;
+
$use_make_for_missing_files = 0; # Whether to use make to try to make missing files.
# Do we make view file in temporary then move to final destination?
@@ -1319,12 +1419,26 @@
$BIBINPUTS = $ENV{'BIBINPUTS'};
if (!$BIBINPUTS) { $BIBINPUTS = '.'; }
+# ???!!!
+# Old configuration variable @BIBINPUTS to be equivalent to environment
+# variable BIBINPUTS. It was to be easier to work with inside latexmk. But
+# under present conditions, it's better to manipulate $ENV{BIBINPUTS}.
+# ??? Need to explain better.
+# Why only for BIBINPUTS, not TEXINPUTS.
+#
+# But retain @BIBINPUTS for backward compatibility, since users may have
+# configured it. We'll save the values, allow for possible user changes in
+# @BIBINPUTS or $ENV{BIBINPUTS} in rc files and from command line
+# arguments. Then funnel changes back to $ENV{BIBINPUTS}, ...
+#
# Convert search paths to arrays:
# If any of the paths end in '//' then recursively search the
# directory. After these operations, @BIBINPUTS should
# have all the directories that need to be searched
-
+#
@BIBINPUTS = find_dirs1( $BIBINPUTS );
+our @BIBINPUTS_SAVE = @BIBINPUTS;
+our $BIBINPUTS_ENV_SAVE = $ENV{BIBINPUTS};
######################################################################
@@ -1438,12 +1552,7 @@
# non-existent file.
-# List of known rules. Rule types: primary,
-# external (calls program), internal (calls routine), cusdep.
-%possible_primaries = ( 'latex' => 'primary', 'pdflatex' => 'primary',
- 'lualatex' => 'primary', 'xelatex' => 'primary' );
-
# Hashes, whose keys give names of particular kinds of rule, and targets.
# We use hashes for ease of lookup.
%possible_one_time = ( 'view' => 1, 'print' => 1, 'update_view' => 1, );
@@ -1455,8 +1564,9 @@
# currently irrelevant.
# The target **files** can only be set inside the FILE loop.
$current_primary = 'latex'; # Rule to compile .tex file.
- # Subject to document-dependent override if .tex document
- # uses metcommands andobeying them is enabled.
+ # It will be overridden at rule-initialization time, and
+ # is subject to document-dependent override if .tex document
+ # uses metcommands and obeying them is implemented/enabled.
$pdf_method = ''; # How to make pdf file. '' if not requested,
# else 'ps2pdf', 'dvipdf', 'pdflatex', 'lualatex' or 'xelatex'
# Subject to document-dependent override if .tex document
@@ -1475,7 +1585,7 @@
%rule_db = (); # Database of all rules:
# Hash: rulename -> [array of rule data]
# Rule data:
- # 0: [ cmd_type, ext_cmd, int_cmd, test_kind,
+ # 0: [ cmd_type, ext_cmd, int_cmd, no_history,
# source, dest, base,
# out_of_date, out_of_date_user,
# time_of_last_run, time_of_last_file_check,
@@ -1502,15 +1612,18 @@
# This variable intcmd is a reference to an array,
# $$intcmd[0] = internal routine
# $$intcmd[1...] = its arguments (if any)
- # test_kind specifies method of determining
- # whether a file is out-of-date:
- # 0 for never
- # 1 for usual: whether there is a source
- # file change
- # 2 for dest earlier than source
- # 3 for method 2 at first run, 1 thereafter
- # (used when don't have file data from
- # previous run).
+ # no_history being true indicates that there was no
+ # data on the file state from a previous run. In
+ # this case the implication is that when the next
+ # test for whether a run of the rule is needed,
+ # the file-contents criterion won't be useful.
+ # Then a time-based criterion (as in normal make)
+ # is used, i.e., if a source file is newer than
+ # the destination file, then a rerun is needed.
+ # After that first test for a rerun has been
+ # done, a run or no run is made according as
+ # appropriate. After that the file-change
+ # criterion works, and no_history is turned off.
# source = name of primary source file, if any
# dest = name of primary destination file,
# if any
@@ -1545,7 +1658,7 @@
# changed flags whether special changes have been made
# that require file-existence status to be ignored
# last_result is
- # -1 if no run has been made,
+ # -1 if no run has been made
# 0 if the last run was successful
# 1 if last run was successful, but
# failed to create an output file
@@ -1588,9 +1701,38 @@
# can be avoided by changing the file's time
# in the source-file list.
# 2: {Hash generated_file -> 1 }
- # This lists all generated files; the values
- # are currently unused, only the keys
- # 3: {Hash source_rule -> last_pass }
+ # This lists all generated files.
+ # The values for the hash are currently unused, only the keys.
+ # 3: {Hash rewritten_before_read_file -> 1 }
+ # This lists all files that are only read after being
+ # written **and** that existed before being
+ # written, i.e., that existed at the beginning of
+ # the run. These are listed in both the source-
+ # and generated-file hashes, but do not need
+ # to be checked for changes in testing whether
+ # another run is needed, i.e., they aren't true
+ # source files. **IMPORTANT NOTE:** If a file is
+ # read only after being written, but the file didn't
+ # exist at the beginning of the run, it is
+ # possible (and often true) that on a subsequent
+ # run the file would be read, then written, and
+ # perhaps read again. That is, it can be that
+ # before the file is written, there is a test for
+ # file existence, and the file is read, but only
+ # if it exists. Examples: .aux and .toc
+ # files. Such files are true dependencies and must
+ # be checked for changes. Only when the file
+ # existed at the start of the run and was then
+ # written before being read, do we know that
+ # write-before-read shows that the file is not a
+ # true source-dependency.
+ # This issue is significant: under some situations,
+ # like the use of latexmk and tex4ht, the file may
+ # be changed by other software before the next run
+ # of the current rule. That must not trigger
+ # another run.
+ # The values for the hash are currently unused, only the keys.
+ # 4: {Hash source_rule -> last_pass }
# This lists rules that are to be considered source
# rules for the current rule, separately from the
# source_rules of the source files. Its main use
@@ -1642,8 +1784,6 @@
# not defined (or possibly the null string '').
# Classification of rules, for determining order of application
-%current_primaries = (); # Keys are primary rules (latex, etc) that are
- # currently in use.
@pre_primary = (); # Array of rules that are thought of as pre-primary,
# Should be in an appropriate order for invoking
# them, to optimize making.
@@ -1693,7 +1833,6 @@
sub read_first_rc_file_in_list {
foreach my $rc_file ( @_ ) {
- #print "===Testing for rc file \"$rc_file\" ...\n";
if ( -d $rc_file ) {
warn "$My_name: I have found a DIRECTORY named \"$rc_file\".\n",
" Have you perhaps misunderstood latexmk's documentation?\n",
@@ -1745,6 +1884,8 @@
read_first_rc_file_in_list( ".latexmkrc", "latexmkrc" );
}
+
+
## Process command line args.
@command_line_file_list = ();
$bad_options = 0;
@@ -1782,8 +1923,12 @@
elsif (/^-diagnostics/) { $diagnostics = 1; }
elsif (/^-dir-report$/) { $aux_out_dir_report = 1; }
elsif (/^-dir-report-$/) { $aux_out_dir_report = 0; }
- elsif (/^-dvi$/) { $dvi_mode = 1; }
- elsif (/^-dvi-$/) { $dvi_mode = 0; }
+ elsif (/^-dvi$/) { $dvi_mode = 1; }
+ elsif (/^-dvilua$/) { $dvi_mode = 2; }
+ elsif (/^-dvi-$/) { $dvi_mode = 0; }
+ elsif ( /^-dvilualatex=(.*)$/ ) {
+ $dvilualatex = $1;
+ }
elsif (/^-emulate-aux-dir$/) { $emulate_aux = 1; }
elsif (/^-emulate-aux-dir-$/) { $emulate_aux = 0; }
elsif (/^-f$/) { $force_mode = 1; }
@@ -1793,6 +1938,9 @@
elsif (/^-gg$/) {
$go_mode = 2; $cleanup_mode = 1; $cleanup_only = 0;
}
+ elsif (/^-gt$/) {
+ $go_mode = 3;
+ }
elsif ( /^-h$/ || /^-help$/ ) { &print_help; exit;}
elsif (/^-jobname=(.*)$/) {
$jobname = $1;
@@ -1808,6 +1956,7 @@
$latex = $1;
}
elsif (/^-latexoption=(.*)$/) {
+ push @extra_dvilualatex_options, $1;
push @extra_latex_options, $1;
push @extra_pdflatex_options, $1;
push @extra_lualatex_options, $1;
@@ -1967,6 +2116,8 @@
elsif (/^-view=ps$/) { $view = "ps";}
elsif (/^-view=pdf$/) { $view = "pdf"; }
elsif (/^-Werror$/){ $warnings_as_errors = 1; }
+ elsif (/^-xdv$/) { $xdv_mode = 1; }
+ elsif (/^-xdv-$/) { $xdv_mode = 0; }
elsif ( /^-xelatex$/ || /^-pdfxelatex$/ ) {
$pdf_mode = 5;
$dvi_mode = $postscript_mode = 0;
@@ -2032,6 +2183,7 @@
|| ( /^(-.+)=/ && exists( $allowed_latex_options_with_arg{$1} ) )
)
{
+ push @extra_dvilualatex_options, $original;
push @extra_latex_options, $original;
push @extra_pdflatex_options, $original;
push @extra_lualatex_options, $original;
@@ -2057,6 +2209,8 @@
print "$My_name: This is $version_details, version: $version_num.\n",
unless $silent;
+&config_to_mine;
+
if ($out_dir eq '' ){
# Default to cwd
$out_dir = '.';
@@ -2198,11 +2352,13 @@
&fix_cmds;
# Add common options
+add_option( $dvilualatex_default_switches, \$dvilualatex );
add_option( $latex_default_switches, \$latex );
add_option( $pdflatex_default_switches, \$pdflatex );
add_option( $lualatex_default_switches, \$lualatex );
add_option( $xelatex_default_switches, \$xelatex );
+foreach (@extra_dvilualatex_options) { add_option( $_, \$dvilualatex ); }
foreach (@extra_latex_options) { add_option( $_, \$latex ); }
foreach (@extra_pdflatex_options) { add_option( $_, \$pdflatex ); }
foreach (@extra_lualatex_options) { add_option( $_, \$lualatex ); }
@@ -2217,7 +2373,23 @@
$ps_previewer = $ps_previewer_landscape;
}
+{ my $array_changed = 0;
+ if ($#BIBINPUTS != $#BIBINPUTS_SAVE) { $array_changed = 1; }
+ else {
+ for( my $i = 0; $i <= $#BIBINPUTS; $i++ ) {
+ if ($BIBINPUTS[$i] ne $BIBINPUTS_SAVE[$i]) {
+ $array_changed = 1;
+ last;
+ }
+ }
+ }
+ if ($array_changed) {
+ foreach (@BIBINPUTS) { ensure_path( 'BIBINPUTS', $_ ); }
+ }
+}
+
if ( $silent ) {
+ add_option( "$dvilualatex_silent_switch", \$dvilualatex );
add_option( "$latex_silent_switch", \$latex );
add_option( "$pdflatex_silent_switch", \$pdflatex );
add_option( "$lualatex_silent_switch", \$lualatex );
@@ -2231,7 +2403,7 @@
}
if ( $recorder ) {
- add_option( "-recorder", \$latex, \$pdflatex, \$lualatex, \$xelatex );
+ add_option( "-recorder", \$dvilualatex, \$latex, \$pdflatex, \$lualatex, \$xelatex );
}
# If the output and/or aux directories are specified, fix the *latex
@@ -2243,11 +2415,11 @@
if ( $jobname ne '' ) {
# Since $jobname may include placeholder(s), put %R placeholder
# in option, and let %R be substituted by actual jobname at runtime.
- add_option( "--jobname=%R", \$latex, \$lualatex, \$pdflatex, \$xelatex );
+ add_option( "--jobname=%R", \$dvilualatex, \$latex, \$lualatex, \$pdflatex, \$xelatex );
}
# Make sure we make the kind of file we want to view:
-if ($view eq 'dvi') { $dvi_mode = 1; }
+if ( ($view eq 'dvi') && ($dvi_mode == 0) ) { $dvi_mode = 1; }
if ($view eq 'ps') { $postscript_mode = 1; }
if ( ($view eq 'pdf') && ($pdf_mode == 0) ) {
$pdf_mode = 1;
@@ -2254,9 +2426,9 @@
}
# Make sure that we make something if all requests are turned off
-unless ( $dvi_mode || $pdf_mode || $postscript_mode || $printout_mode ) {
+unless ( $dvi_mode || $pdf_mode || $postscript_mode || $printout_mode || $xdv_mode ) {
print "No specific requests made, so using default for $invoked_name.\n";
- ($dvi_mode, $postscript_mode, $pdf_mode)
+ ($dvi_mode, $postscript_mode, $pdf_mode, $xdv_mode )
= @{$compilation_defaults{$invoked_name}};
}
@@ -2274,12 +2446,10 @@
# Determine requests.
if ( $banner ) { $postscript_mode = 1; }
if ( $dvi_mode ) {
- $current_primary = 'latex';
$requested_filetypes{'dvi'} = 1;
if ( length($dvi_filter) != 0 ) { $requested_filetypes{'dviF'} = 1; }
}
if ( $postscript_mode ) {
- $current_primary = 'latex';
$requested_filetypes{'ps'} = 1;
if ( length($ps_filter) != 0 ) { $requested_filetypes{'psF'} = 1; }
}
@@ -2293,11 +2463,13 @@
my %disallowed = ();
foreach (1,4,5) { $disallowed{$_} = 1; }
if ($disallowed{$pdf_mode}) {
- warn "$My_name: \$pdf_mode = $pdf_mode is incompatible with dvi and postscript modes\n",
- " which are required by other requests.\n";
- if ($postscript_mode) {$pdf_mode = 2;}
+ warn
+ "$My_name: \$pdf_mode = $pdf_mode is incompatible with dvi and postscript modes\n",
+ " which are required by other requests.\n";
+ if ($postscript_mode) { $pdf_mode = 2; }
else { $pdf_mode = 3; }
- warn " I replaced it by $pdf_mode.\n";
+ warn
+ " I replaced it by $pdf_mode, to be compatible with those other requests.\n";
}
}
if ( $pdf_mode == 0 ) {
@@ -2339,7 +2511,7 @@
if ( $preview_continuous_mode || $preview_mode ) { $one_time{'view'} = 1; }
$can_switch = $allow_switch;
-if ( $dvi_mode || $postscript_mode
+if ( $dvi_mode || $postscript_mode || $xdv_mode
|| ( $printout_mode && ($print_type eq 'ps') || ($print_type eq 'dvi') )
|| ( ($preview_mode || $preview_continuous_mode) && ( ($view eq 'ps') || ($view eq 'dvi') ) )
) {
@@ -2461,6 +2633,8 @@
# Use of $do_cd, which can affect how $aux_dir and $out_dir get normalized.
local $aux_dir = $aux_dir;
local $out_dir = $out_dir;
+
+ local $dvilualatex = $dvilualatex;
local $latex = $latex;
local $lualatex = $lualatex;
local $pdflatex = $pdflatex;
@@ -2502,8 +2676,9 @@
# data may be incorrect.
# So use filetime criterion for make instead of file change from
# previous run, until we have done our own make.
- rdb_recurse( [keys %possible_primaries],
- sub{ if ( $$Ptest_kind == 1 ) { $$Ptest_kind = 3;} }
+ # ???!!! CHECK: WHY ONLY PRIMARIES????
+ rdb_recurse( [$current_primary],
+ sub{ $$Pno_history = 1; }
);
}
}
@@ -2511,7 +2686,7 @@
# At least we can use dependency information from previous run of
# *latex, which may not have been under latexmk control, otherwise
# the fdb_latexmk file would have been made.
- rdb_for_some( [keys %current_primaries],
+ rdb_for_some( [$current_primary],
sub{ rdb_set_latex_deps($cleanup_mode) }
);
&rdb_set_rule_net;
@@ -2545,8 +2720,14 @@
- if ($go_mode) {
+ if ($go_mode == 3) {
+ # Force primaries to be remade.
+ if (!$silent) { print "Force *latex to be remade.\n"; }
+ rdb_for_some( [keys %possible_primaries], sub{$$Pout_of_date=1;} );
+ }
+ elsif ($go_mode) {
# Force everything to be remade.
+ if (!$silent) { print "Force everything to be remade.\n"; }
rdb_recurse( [ &rdb_target_array], sub{$$Pout_of_date=1;} );
}
@@ -2579,6 +2760,8 @@
#Initialize failure flags now.
$failure = 0;
$failure_msg = '';
+ &init_timing1;
+
if ($compiling_cmd) { Run_subst( $compiling_cmd ); }
$failure = &rdb_make;
if ( ( $failure <= 0 ) || $force_mode ) {
@@ -2623,10 +2806,15 @@
push @failed_primaries, $filename;
}
&ifcd_popd;
+ if ($show_time) { &show_timing1; };
+ print "\n";
}
close($deps_handle) if ( $deps_handle );
-if ($show_time) { show_timing();}
+if ( $show_time && ( ($#file_list > 0) || $preview_continuous_mode ) ) {
+ print "\n";
+ show_timing_grand();
+}
# If we get here without going through the continue section:
if ( $do_cd && ($#dir_stack > -1) ) {
@@ -2664,21 +2852,63 @@
#############################################################
#############################################################
-sub show_timing {
+# Subroutines for working with processing time
+
+############################
+
+sub add_timing {
+ # Usage: add_timing( time_for_run, rule );
+ # Adds time_for_run to @timings1, @timings0
+ my ( $time, $rule ) = @_;
+ push @timings1, "'$rule': time = " . sprintf('%.2f',$time) . "\n";
+ push @timings0, "'$rule': time = " . sprintf('%.2f',$time) . "\n";
+}
+
+############################
+
+sub init_timing1 {
+ # Initialize timing for one run.
+ @timings1 = ();
+ $processing_time1 = processing_time();
+}
+
+############################
+
+sub init_timing_all {
+ # Initialize timing for totals and for one run:
+ @timings0 = ();
+ $processing_time0 = processing_time();
+ &init_timing1;
+}
+
+############################
+
+sub show_timing1 {
+ # Show timing for one run.
my $processing_time = processing_time() - $processing_time1;
- print @timings, "Accumulated processing time = ",
+ print @timings1, "Processing time = ",
sprintf('%.2f', $processing_time), "\n";
- print "Number of rules run = ", 1+$#timings, "\n";
- @timings = ();
- $processing_time1 = processing_time();
+ print "Number of rules run = ", 1+$#timings1, "\n";
}
+############################
+
+sub show_timing_grand {
+ # Show grand total timing.
+ my $processing_time = processing_time() - $processing_time0;
+ print # @timings0,
+ "Grand total processing time = ",
+ sprintf('%.2f', $processing_time), "\n";
+ print "Total number of rules run = ", 1+$#timings0, "\n";
+}
+
#############################################################
+#############################################################
sub set_tex_cmds {
# Usage, e.g., set_tex_cmds( '%O %S' )
my $args = $_[0];
- foreach my $cmd ('latex', 'lualatex', 'pdflatex', 'xelatex' ) {
+ foreach my $cmd ( keys %possible_primaries ) {
${$cmd} = "$cmd $args";
}
# N.B. See setting of $latex_default_switches, ...,
@@ -2745,8 +2975,8 @@
#############################################################
sub ensure_path {
- # Usage: ensure_path( $var, values ...)
- # $ENV{$var} is an environment variable (e.g. $ENV{TEXINPUTS}.
+ # Usage: ensure_path( var, values ...)
+ # $ENV{var} is an environment variable (e.g. $ENV{TEXINPUTS}.
# Ensure the values are in it, prepending them if not, and
# creating the environment variable if it doesn't already exist.
my $var = shift;
@@ -2772,6 +3002,63 @@
#############################################################
+sub path_fudge {
+ # Usage: path_fudge( var1[, var2 ...])
+ # For each argument, $ENV{var} is an environment variable
+ # (e.g. $ENV{BIBINPUTS}, that is a search path.
+ # Adjust each of these environment variables so that it is
+ # appropriately set for use when a program is run with a changed wd,
+ # as with bibtex when $bibtex_fudge is set.
+ # Specifically:
+ # 1. Prepend current wd to each $ENV{var}, if it exists; otherwise
+ # set $ENV{var} to current wd followed by search-path separator,
+ # so that search path is cwd and then default.
+ # Hence files in cwd are found by a program run in another
+ # directory.
+ # 2. For each item in $ENV{var} that isn't an absolute path, i.e.,
+ # that is relative, replace it by itself followed by the same path
+ # converted to an absolute path, with the relative path being
+ # assumed to be relative to the current wd.
+ # Hence a program run in another directory finds files that were
+ # originally intended to be in a directory relative to the orginal
+ # cwd. In addition, in the conceivable case that the item in the
+ # search path is actually intended to be relative to the directory
+ # in which the program is run (normally the aux dir), it also
+ # works correctly.
+
+ my $cwd = good_cwd();
+ foreach my $var ( @_ ) {
+ if ( exists $ENV{$var} ) {
+ $ENV{$var} = $cwd.$search_path_separator.$ENV{$var};
+ }
+ else {
+ $ENV{$var} = $cwd.$search_path_separator;
+ }
+
+ my @items = split_search_path( $search_path_separator, '', $ENV{$var} );
+ my $changed = 0;
+
+ foreach (@items) {
+ if ($_ eq '' ) {
+ # Empty item => std search path => nothing to do.
+ }
+ elsif ( ! file_name_is_absolute($_) ) {
+ my $abs = rel2abs($_);
+ $_ .= $search_path_separator.$abs;
+ $changed = 1;
+ }
+ }
+
+ if ($changed) {
+ # Correct the env. var.
+ $ENV{$var} = join( $search_path_separator, @items );
+ print "====== ENV{$var} changed to '$ENV{$var}'\n";
+ }
+ } # END loop over env. vars.
+} #END path_fudge
+
+#############################################################
+
sub normalize_aux_out_ETC {
# 1. Normalize $out_dir and $aux_dir, so that if they have a non-trivial last
# component, any trailing '/' is removed.
@@ -2879,13 +3166,13 @@
# the relevant files (.pdf, .ps, .dvi, .xdv, .fls to the output
# directory after running *latex.
add_option( "-output-directory=%V",
- \$latex, \$pdflatex, \$lualatex, \$xelatex );
+ \$dvilualatex, \$latex, \$pdflatex, \$lualatex, \$xelatex );
}
}
else {
if ( $out_dir && ($out_dir ne '.') ) {
add_option( "-output-directory=%W",
- \$latex, \$pdflatex, \$lualatex, \$xelatex );
+ \$dvilualatex, \$latex, \$pdflatex, \$lualatex, \$xelatex );
}
if ( $aux_dir ne $out_dir ) {
# N.B. If $aux_dir and $out_dir are the same, then the
@@ -2892,7 +3179,7 @@
# -output-directory option is sufficient, especially because
# the -aux-directory exists only in MiKTeX, not in TeXLive.
add_option( "-aux-directory=%V",
- \$latex, \$pdflatex, \$lualatex, \$xelatex );
+ \$dvilualatex, \$latex, \$pdflatex, \$lualatex, \$xelatex );
}
}
} #END set_aux_out_options
@@ -2966,8 +3253,9 @@
while ( my ($key, $value) = each %extra_rule_spec ) {
$rule_template{$key} = $value;
}
+ # ???!!! REVISE
foreach my $rule ( keys %rule_template ) {
- my ( $cmd_type, $ext_cmd, $int_cmd, $source, $dest, $base, $test_kind, $PA_extra_gen ) = @{$rule_template{$rule}};
+ my ( $cmd_type, $ext_cmd, $int_cmd, $source, $dest, $base, $DUMMY, $PA_extra_gen ) = @{$rule_template{$rule}};
if ( ! $PA_extra_gen ) { $PA_extra_gen = []; }
my $needs_making = 0;
# Substitute in the filename variables, since we will use
@@ -2982,28 +3270,43 @@
s/%B/$base/;
s/%T/$texfile_name/;
}
- rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $test_kind,
+ rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $DUMMY,
$source, $dest, $base,
$needs_making, undef, undef, 1, $PA_extra_gen );
} # End rule iteration
- # Ensure we only have one way to make pdf file, and that it is appropriate. Remove other incompatibilities
- if ($pdf_mode == 1) { rdb_deactivate( 'dvipdf', 'ps2pdf', 'latex', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
- elsif ($pdf_mode == 2) { rdb_deactivate( 'dvipdf', 'pdflatex', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
- elsif ($pdf_mode == 3) { rdb_deactivate( 'pdflatex', 'ps2pdf', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
- elsif ($pdf_mode == 4) { rdb_deactivate( 'pdflatex', 'ps2pdf', 'dvipdf', 'xdvipdfmx', 'xelatex' ); }
- elsif ($pdf_mode == 5) { rdb_deactivate( 'pdflatex', 'ps2pdf', 'dvipdf', 'lualatex' ); }
- else { rdb_deactivate( 'dvipdf', 'pdflatex', 'ps2pdf', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
+ # At this point, all the rules are active.
+ # The rules that are used are determined by starting with the desired
+ # final files and going backwards in the rule network to find what rules
+ # have to be run to make the final files.
+ # The only problem in doing this is if there is more than one way of making
+ # a given file. This arises only for rules that make pdf or dvi files,
+ # since we have multiple rules for making them.
- if ($dvi_mode == 1) {
- rdb_activate( 'latex' );
- $target_files{$dvi_final} = 1;
- }
- if ($postscript_mode == 1) {
- rdb_activate( 'latex' );
- $target_files{$ps_final} = 1;
- }
+ # Ensure we only have one way to make pdf file, and only one active primary:
+ # Deactivate pdf-making rules and primary rules,
+ # then reactivating only one pdf producing rule and current primary,
+ # setting $current_primary as side-effect.
+
+ rdb_deactivate( 'dvipdf', 'ps2pdf', 'xdvipdfmx', keys %possible_primaries );
+
+ $current_primary = 'latex'; #
+ # Activate needed non-primary pdf-making rules, set current primary (if
+ # it isn't latex, and activate the current primary:
+ if ($pdf_mode == 1) { $current_primary = 'pdflatex'; }
+ elsif ($pdf_mode == 2) { rdb_activate( 'ps2pdf' ); }
+ elsif ($pdf_mode == 3) { rdb_activate( 'dvipdf' ); }
+ elsif ($pdf_mode == 4) { $current_primary = 'lualatex'; }
+ elsif ($pdf_mode == 5) { rdb_activate( 'xdvipdfmx' ); $current_primary = 'xelatex'; }
+ if ($dvi_mode == 2) { $current_primary = 'dvilualatex'; }
+
+ rdb_activate( $current_primary );
+
+ if ($dvi_mode) { $target_files{$dvi_final} = 1; }
+ if ($postscript_mode) { $target_files{$ps_final} = 1; }
if ($pdf_mode) { $target_files{$pdf_final} = 1; }
+ if ($xdv_mode) { $target_files{$xdv_final} = 1; }
+
&rdb_set_rule_net;
} # END rdb_initialize_rules
@@ -3052,21 +3355,19 @@
# Specification of internal command for viewer update:
my $PA_update = ['do_update_view', $viewer_update_method, $viewer_update_signal, 0, 1];
-# For test_kind: Use file contents for latex and friends, but file time for the others.
-# This is because, especially for dvi file, the contents of the file may contain
-# a pointer to a file to be included, not the contents of the file!
%rule_list = (
+ 'dvilualatex' => [ 'primary', "$dvilualatex", '', "%T", $dvi_name, "%R", 1, [$log_name] ],
'latex' => [ 'primary', "$latex", '', "%T", $dvi_name, "%R", 1, [$log_name] ],
+ 'lualatex' => [ 'primary', "$lualatex", '', "%T", $pdf_name, "%R", 1, [$log_name] ],
'pdflatex' => [ 'primary', "$pdflatex", '', "%T", $pdf_name, "%R", 1, [$log_name] ],
- 'lualatex' => [ 'primary', "$lualatex", '', "%T", $pdf_name, "%R", 1, [$log_name] ],
'xelatex' => [ 'primary', "$xelatex", '', "%T", $xdv_name, "%R", 1, [$log_name] ],
- 'dvipdf' => [ 'external', "$dvipdf", 'do_viewfile', $dvi_final, $pdf_name, "%Z%R", 2 ],
- 'xdvipdfmx' => [ 'external', "$xdvipdfmx", 'do_viewfile', $xdv_final, $pdf_name, "%Z%R", 2 ],
- 'dvips' => [ 'external', "$dvips", 'do_viewfile', $dvi_final, $ps_name, "%Z%R", 2 ],
- 'dvifilter' => [ 'external', $dvi_filter, 'do_viewfile', $dvi_name, $dviF_name, "%Z%R", 2 ],
- 'ps2pdf' => [ 'external', "$ps2pdf", 'do_viewfile', $ps_final, $pdf_name, "%Z%R", 2 ],
- 'psfilter' => [ 'external', $ps_filter, 'do_viewfile', $ps_name, $psF_name, "%Z%R", 2 ],
- 'print' => [ 'external', "$print_cmd", 'if_source', $print_file, "", "", 2 ],
+ 'dvipdf' => [ 'external', "$dvipdf", 'do_viewfile', $dvi_final, $pdf_name, "%Z%R", 1 ],
+ 'xdvipdfmx' => [ 'external', "$xdvipdfmx", 'do_viewfile', $xdv_final, $pdf_name, "%Z%R", 1 ],
+ 'dvips' => [ 'external', "$dvips", 'do_viewfile', $dvi_final, $ps_name, "%Z%R", 1 ],
+ 'dvifilter' => [ 'external', $dvi_filter, 'do_viewfile', $dvi_name, $dviF_name, "%Z%R", 1 ],
+ 'ps2pdf' => [ 'external', "$ps2pdf", 'do_viewfile', $ps_final, $pdf_name, "%Z%R", 1 ],
+ 'psfilter' => [ 'external', $ps_filter, 'do_viewfile', $ps_name, $psF_name, "%Z%R", 1 ],
+ 'print' => [ 'external', "$print_cmd", 'if_source', $print_file, "", "", 1 ],
'update_view' => [ 'external', $viewer_update_command, $PA_update,
$view_file, "", "", 2 ],
'view' => [ 'external', "$viewer", 'if_source', $view_file, "", "", 2 ],
@@ -3097,7 +3398,6 @@
rdb_for_actives( \&set_file_links_for_rule );
rdb_for_actives( \&rdb_set_source_rules );
&rdb_classify_rules;
- # print "=========In rdb_make_links: rules\n"; &rdb_show;
}
#------------
@@ -3183,7 +3483,6 @@
# %possible_primaries
# Output:
- # %current_primaries # Keys are actual primaries
# @pre_primary # Array of rules
# @post_primary # Array of rules
# @unusual_one_time # Array of rules
@@ -3193,7 +3492,6 @@
local $state = 0; # Post-primary
local @classify_stack = ();
- %current_primaries = ();
@pre_primary = ();
@post_primary = ();
@unusual_one_time = ();
@@ -3204,21 +3502,11 @@
@pre_primary = reverse @pre_primary;
@post_primary = reverse @post_primary;
- my @current_primaries = keys %current_primaries;
- if ($#current_primaries < 0) {
- die "$My_name: No active primary rules found. I have to stop.\n";
- }
- elsif ($#current_primaries > 0) {
- die "$My_name: More than one active primary rule found. I have to stop.\n",
- " Primary rules: @current_primaries\n";
- }
- $current_primary = $current_primaries[0];
-
if ($diagnostics) {
print "Rule classification: \n";
show_array( " Requested rules:", @requested_targets );
show_array( " Pre-primaries:", @pre_primary );
- show_array( " Primaries:", keys %current_primaries );
+ show_array( " Primary:", $current_primary );
show_array( " Post-primaries:", @post_primary );
show_array( " Inner-level one_time rules:", @unusual_one_time );
show_array( " Outer-level one_time rules:", keys %one_time );
@@ -3245,7 +3533,6 @@
elsif ($state == 0) {
if ( exists $possible_primaries{$rule} ) {
$state = 1; # In primary rule
- $current_primaries{ $rule } = 1;
}
else {
push @post_primary, $rule;
@@ -3289,6 +3576,7 @@
fprint8 $aux_file, "\\gdef \\\@abspage\@last{1}\n";
close($aux_file);
+ if (!$silent) { print "After making new aux file, require run of *latex.\n"; }
foreach my $rule (keys %possible_primaries ) {
rdb_ensure_file( $rule, $texfile_name );
rdb_ensure_file( $rule, $aux_main );
@@ -3681,18 +3969,11 @@
#************************************************************
sub make_preview_continuous {
- local @changed = ();
- local %changed_rules = ();
- local @changed_user = ();
- local @disappeared = ();
- local @no_dest = (); # Non-existent destination files
- local @rules_never_run = ();
- local @rules_to_apply = ();
local $failure = 0;
- local %rules_applied = ();
local $updated = 0;
+ # ???!!!
print "======= Need to update make_preview_continuous for target files\n";
$quell_uptodate_msgs = 1;
@@ -3723,7 +4004,7 @@
);
# Note that we don't get the previewer process number from the program
# that starts it; that might only be a script to get things set up and the
- # actual previewer could be (and sometimes IS) another process.
+ # actual previewer could be (and sometimes **is**) another process.
if ( ($view_file ne '') && (-e $view_file) && !$new_viewer_always ) {
# Is a viewer already running?
@@ -3745,7 +4026,8 @@
for (my $first_time = 1; 1; $first_time = 0 ) {
my %rules_to_watch = array_to_hash( &rdb_accessible );
-
+
+ &init_timing1;
$updated = 0;
$failure = 0;
$failure_msg = '';
@@ -3801,24 +4083,16 @@
$$Pneed_to_get_viewer_process = 1;
} # end analyze result of trying to run viewer
} # end start viewer
+
+ # Updated rule collection, and the set of rules whose source files
+ # the WAIT loop examines for changes:
+ &rdb_set_rule_net;
+ %rules_to_watch = array_to_hash( &rdb_accessible );
+
if ( $failure > 0 ) {
if ( !$failure_msg ) {
$failure_msg = 'Failure to make the files correctly';
}
- &rdb_set_rule_net;
- %rules_to_watch = array_to_hash( &rdb_accessible );
-
- # There will be files changed during the run that are irrelevant.
- # We need to wait for the user to change the files.
-
- # So set the GENERATED files from *latex as up-to-date:
- rdb_for_some( [keys %current_primaries], \&rdb_update_gen_files );
- # And don't watch for changes for post_primary rules (ps and pdf
- # from dvi, etc haven't been run after an error in *latex, so
- # are out-of-date by filetime criterion, but they should not be run
- # until after another *latex run:
- foreach (@post_primary) { delete $rules_to_watch{$_}; }
-
$failure_msg =~ s/\s*$//; #Remove trailing space
warn "$My_name: $failure_msg\n",
" ==> You will need to change a source file before I do another run <==\n";
@@ -3825,6 +4099,27 @@
if ($failure_cmd) {
Run_subst( $failure_cmd );
}
+
+ # In the WAIT loop, we will test for changes in source files
+ # that trigger a remake. Special considerations after an error:
+ # 1. State of **user** source files for a rule is that before
+ # the last run of the rule. Any changes since trigger
+ # rerun.
+ # 2. .aux files etc may have changed during an error run of a
+ # rule, but no further runs were made to get them
+ # stabilized. So they can have changed since start of
+ # run. To avoid triggering an incorrect remake, rdb_make
+ # has updated generated source files to their current state
+ # after the whole make. User changes (e.g., deletion of aux
+ # file) are still able to trigger a remake.
+ # 3. Post_primary rules may not have been run (e.g., to make ps
+ # and pdf from dvi). Depending on the criterion for rerun,
+ # they may be out-of-date by some criterion, but they should
+ # not be run until after another *latex run. Such rules
+ # must be excluded from the rules whose source files the
+ # WAIT loop scans for changes.
+ # Set this up as follows:
+ foreach (@post_primary) { delete $rules_to_watch{$_}; }
}
else {
if ( ($#primary_warning_summary > -1) && $warning_cmd ) {
@@ -3839,7 +4134,6 @@
}
rdb_show_rule_errors();
if ($rules_list) { rdb_list(); }
- if ($show_time && ! $first_time) { show_timing(); }
if ( $dependents_list && ($updated || $failure) ) {
if ( open( my $deps_handle, ">$deps_file" ) ) {
deps_list($deps_handle);
@@ -3849,10 +4143,10 @@
warn "Cannot open '$deps_file' for output of dependency information\n";
}
}
+ if ($show_time) { &show_timing1; };
+
# Now wait for a file to change...
- # &rdb_cache_generated;
- &rdb_set_rule_net;
# During waiting for file changes, handle ctrl/C and ctrl/break here,
# rather than letting system handle them by terminating script (and
# code in the following command line to work: any script that calls
@@ -3867,16 +4161,18 @@
WAIT: while (1) {
sleep( $sleep_time );
if ($have_break) { last WAIT; }
- if ( rdb_user_changes(keys %rules_to_watch) ) {
+ my %changes = ();
+ if ( rdb_remake_needed(\%changes, 1, keys %rules_to_watch) ) {
if (!$silent) {
- print "$My_name: Need to remake files.\n";
- &rdb_diagnose_changes( ' ' );
+ print "\n$My_name: Need to remake files.\n";
+ &rdb_diagnose_changes2( \%changes, "", 1 );
+ print "\n";
}
last WAIT;
}
# Don't count waiting time in processing:
$processing_time1 = processing_time();
- # Does this do this job????
+ # Does this do this job????!!!
local $new_files = 0;
rdb_for_some( [keys %current_primaries], sub{ $new_files += &rdb_find_new_files } );
if ($new_files > 0) {
@@ -4133,7 +4429,7 @@
" Latexmk_options:\n",
" -aux-directory=dir or -auxdir=dir \n",
" - set name of directory for auxiliary files (aux, log)\n",
- " - Currently this only works with MiKTeX\n",
+ " - See also the -emulate-aux-dir option\n",
" -bibtex - use bibtex when needed (default)\n",
" -bibtex- - never use bibtex\n",
" -bibtex-cond - use bibtex when needed, but only if the bib file exists\n",
@@ -4164,11 +4460,16 @@
" -dF <filter> - Filter to apply to dvi file\n",
" -dir-report - Before processing a tex file, report aux and out dir settings\n",
" -dir-report- - Before processing a tex file, do not report aux and out dir settings\n",
- " -dvi - generate dvi\n",
- " -dvi- - turn off required dvi\n",
+ " -dvi - generate dvi by latex\n",
+ " -dvilua - generate dvi by dvilualatex\n",
+ " -dvi- - turn off required dvi\n",
+ " -dvilualatex=<program> - set program used for dvilualatex.\n",
+ " (replace '<program>' by the program name)\n",
" -e <code> - Execute specified Perl code (as part of latexmk start-up\n",
" code)\n",
" -emulate-aux-dir - emulate -aux-directory option for *latex\n",
+ " This enables the -aux-directory option to work properly with TeX\n",
+ " Live as well as MiKTeX\n",
" -emulate-aux-dir- - use -aux-directory option with *latex\n",
" -f - force continued processing past errors\n",
" -f- - turn off forced continuing processing past errors\n",
@@ -4218,19 +4519,19 @@
" - if FORMAT is pdf, turn on pdf output, turn off others\n",
" - otherwise error\n",
" -pdf - generate pdf by pdflatex\n",
- " -pdfdvi - generate pdf by dvipdf\n",
+ " -pdfdvi - generate pdf by latex (or dvilualatex) + dvipdf\n",
+ " -- see -dvilua for how to get dvilualatex used\n",
" -pdflatex=<program> - set program used for pdflatex.\n",
" (replace '<program>' by the program name)\n",
" -pdflualatex=<program> - set program used for lualatex.\n",
" (replace '<program>' by the program name)\n",
- " -pdfps - generate pdf by ps2pdf\n",
+ " -pdfps - generate pdf by latex (or dvilualatex) + dvips + ps2pdf\n",
+ " -- see -dvilua for how to get dvilualatex used\n",
" -pdflua - generate pdf by lualatex\n",
" -pdfxe - generate pdf by xelatex\n",
" -pdfxelatex=<program> - set program used for xelatex.\n",
" (replace '<program>' by the program name)\n",
" -pdf- - turn off pdf\n",
- " -ps - generate postscript\n",
- " -ps- - turn off postscript\n",
" -pF <filter> - Filter to apply to postscript file\n",
" -p - print document after generating postscript.\n",
" (Can also .dvi or .pdf files -- see documentation)\n",
@@ -4239,6 +4540,8 @@
" -print=dvi - when file is to be printed, print the dvi file\n",
" -print=ps - when file is to be printed, print the ps file (default)\n",
" -print=pdf - when file is to be printed, print the pdf file\n",
+ " -ps - generate postscript\n",
+ " -ps- - turn off postscript\n",
" -pv - preview document. (Side effect turn off continuous preview)\n",
" -pv- - turn off preview mode\n",
" -pvc - preview document and continuously update. (This also turns\n",
@@ -4279,6 +4582,8 @@
" -view=ps - viewer is for ps\n",
" -view=pdf - viewer is for pdf\n",
" -Werror - treat warnings from called programs as errors\n",
+ " -xdv - generate xdv by xelatex\n",
+ " -xdv- - turn off required xdv\n",
" -xelatex - use xelatex for processing files to pdf\n",
" and turn dvi/ps modes off\n",
"\n",
@@ -4303,6 +4608,7 @@
print "Commands used by $my_name:\n",
" To run latex, I use \"$latex\"\n",
" To run pdflatex, I use \"$pdflatex\"\n",
+ " To run dvilualatex, I use \"$dvilualatex\"\n",
" To run lualatex, I use \"$lualatex\"\n",
" To run xelatex, I use \"$xelatex\"\n",
" To run biber, I use \"$biber\"\n",
@@ -4359,6 +4665,9 @@
# 10: only error is missing \citation commands.
# 11: Malformed bcf file (normally due to error in pdflatex run)
# Side effect: add source files @biber_source
+ # N.B. @biber_source is already initialized by caller to contain
+ # whatever source files (currently .bcf) it already knows about.
+ # So do **not** initialize it here.
my $base = $_[0];
my $Pbiber_source = $_[1];
my $blg_name = "$base.blg";
@@ -4377,6 +4686,7 @@
my $control_file_missing = 0;
my $control_file_malformed = 0;
my %remote = (); # List of extensions of remote files
+ my @not_found = (); # Files, normally .bib files, not found.
while (<$blg_file>) {
$_ = utf8_to_mine($_);
if (/> WARN /) {
@@ -4389,12 +4699,12 @@
if ( /> (FATAL|ERROR) - Cannot find file '([^']+)'/ #'
|| /> (FATAL|ERROR) - Cannot find '([^']+)'/ ) { #'
$not_found_count++;
- push @$Pbiber_source, $2;
+ push @not_found, $2;
}
elsif ( /> (FATAL|ERROR) - Cannot find control file '([^']+)'/ ) { #'
$not_found_count++;
$control_file_missing = 1;
- push @$Pbiber_source, $2;
+ push @not_found, $2;
}
elsif ( /> ERROR - .*\.bcf is malformed/ ) {
# Special treatment: Malformed .bcf file commonly results from error
@@ -4429,7 +4739,7 @@
# be misleading, since it will normally have been deleted by
# biber itself.
}
- elsif ( (defined $Pbiber_source) && (-e $file) ) {
+ elsif ( -e $file ) {
# Note that biber log file gives full path to file. (No search is
# needed to find it.) The file must have existed when biber was
# run. If it doesn't exist now, a few moments later, it must
@@ -4448,12 +4758,12 @@
}
}
close $blg_file;
+ @$Pbiber_source = uniqs( @$Pbiber_source );
+ @not_found = uniqs( @not_found );
+ push @$Pbiber_source, @not_found;
+
if ($control_file_malformed){return 11;}
- my @not_found = &find_file_list1( $Pbiber_source, $Pbiber_source,
- '', \@BIBINPUTS );
- @$Pbiber_source = uniqs( @$Pbiber_source );
-
if ( ($#not_found < 0) && ($#$Pbiber_source >= 0) ) {
print "$My_name: Found biber source file(s) [@$Pbiber_source]\n"
unless $silent;
@@ -4511,20 +4821,16 @@
# There is also another problem: Depending on the exact
# specification of the aux dir, bibtex may refuse to write to the
# aux dir, for security reasons.
- my $cwd = good_cwd();
- foreach ( 'BIBINPUTS', 'BSTINPUTS' ) {
- if ( exists $ENV{$_} ) {
- $ENV{$_} = $cwd.$search_path_separator.$ENV{$_};
- }
- else {
- $ENV{$_} = $cwd.$search_path_separator;
- }
- }
+ # This prevents changing the default $bibtex_fudge to off,
+ # without breaking backward compatibility. (???!!! Perhaps I
+ # should change the default, and give a special message if the
+ # security issue of not being able to write arises.)
+
+ path_fudge( 'BIBINPUTS', 'BSTINPUTS' );
pushd( $path );
if (!$silent) {
print "$My_name: Change directory to '$path'.\n",
- "To assist finding of files in document\n",
- "directory, I set\n",
+ "To assist finding of files in document directory, I set\n",
" BIBINPUTS='$ENV{BIBINPUTS}'\n",
" BSTINPUTS='$ENV{BSTINPUTS}'.\n";
}
@@ -4764,8 +5070,10 @@
# reported by epstopdf et al.
# 5 = Had a missing file line. Now the file exists.
# 6 = File was written during run. (Overrides 5)
-# 7 = File was created during run to be read in. (Overrides 5 and 6)
-# (e.g., by epstopdf)
+# 7 = File was created during run to be read in, as a conversion
+# from some other file (e.g., by epstopdf package).
+# (Overrides 5 and 6)
+# 8 = File was rewritten during run to be read in. (Overrides 5 and 6)
# Treat the following specially, since they have special rules
# @bbl_files to list of .bbl files.
# %idx_files to map from .idx files to .ind files.
@@ -4791,9 +5099,9 @@
# Input globals: $primary_out, $fls_file_analyzed
#
-my ($log_name, $PAlines, $PHinfo) = @_;
+ my ($log_name, $PAlines, $PHinfo) = @_;
-# Give a quick way of looking up custom-dependency extensions
+ # Give a quick way of looking up custom-dependency extensions
my %cusdep_from = ();
my %cusdep_to = ();
foreach ( @cus_dep_list ) {
@@ -4812,6 +5120,11 @@
$bad_character = 0;
$bad_citation = 0;
+ # ???!!! I don't know whether I will actually use these
+ our @multiply_defined_references = ();
+ our @undefined_citations = ();
+ our @undefined_references = ();
+
print "$My_name: Examining '$log_name'\n"
if not $silent;
@@ -4902,7 +5215,6 @@
}
# Block has ended.
if ($block_type eq 'conversion') {
-#print "=== $delegated_source -> $delegated_output\n";
$new_conversions{$delegated_source} = $delegated_output;
}
$current_pkg = $block_type
@@ -4910,31 +5222,39 @@
# Then process current line
}
+ # ???!!! Use the extra items.
# Check for changed references, bad references and bad citations:
if (/Rerun to get/) {
print "$My_name: References changed.\n" if ! $log_silent;
$reference_changed = 1;
}
- if (/^LaTeX Warning: (Reference[^\001]*undefined on input line .*)\./) {
+# if (/^LaTeX Warning: (Reference[^\001]*undefined on input line .*)\./) {
+ if (/^LaTeX Warning: (Reference `([^']+)' on page .+ undefined on input line .*)\./) {
push @warning_list, $1;
+ push @undefined_references, $2;
$bad_reference++;
}
- elsif (/^LaTeX Warning: (Label [^\001]* multiply defined.*)\./) {
+ elsif (/^LaTeX Warning: (Label `([^']+)' multiply defined.*)\./) {
push @warning_list, $1;
+ push @multiply_defined_references, $2;
$mult_defined++;
}
- elsif (/^LaTeX Warning: (Citation[^\001]*undefined on input line .*)\./) {
+ elsif (/^LaTeX Warning: (Citation `([^']+)' on page .* undefined on input line .*)\./) {
push @warning_list, $1;
+ push @undefined_citations, $2;
$bad_citation++;
}
elsif (/^Package natbib Warning: (Citation[^\001]*undefined on input line .*)\./) {
push @warning_list, $1;
+ push @undefined_citations, $2;
$bad_citation++;
}
elsif ( /^Missing character: There is no /
|| /^! Package inputenc Error: Unicode character /
|| /^! Bad character code /
+ || /^! LaTeX Error: Unicode character /
) {
+ push @warning_list, $_;
$bad_character++;
}
elsif ( /^Document Class: / ) {
@@ -5046,19 +5366,18 @@
next LINE;
}
- elsif ( /^No file (.*?\.bbl)./ ) {
- # Filename is always relative to aux_dir, given standard security
- # settings in TeXLive.
- my $bbl_file = normalize_force_directory( $aux_dir1, $1 );
- warn "$My_name: Missing bbl file '$bbl_file' in following:\n $_\n";
- $dependents{$bbl_file} = 0;
- push @bbl_files, $bbl_file;
- next LINE;
- }
foreach my $pattern (@file_not_found) {
if ( /$pattern/ ) {
my $file = clean_filename($1);
- warn "$My_name: Missing input file '$file' (or dependence on it) from following:\n '$_'\n"
+ if ( $file =~ /\.bbl$/ ) {
+ # Note that bbl's filename is always relative to aux_dir.
+ my $bbl_file = normalize_force_directory( $aux_dir1, $file );
+ warn "$My_name: Missing bbl file '$bbl_file' in following:\n $_\n";
+ $dependents{$bbl_file} = 0;
+ push @bbl_files, $bbl_file;
+ next LINE;
+ }
+ warn "$My_name: Missing input file '$file' (or dependence on it) from following:\n $_\n"
unless $silent;
$dependents{normalize_filename($file, @pwd_log)} = 0;
my $file1 = $file;
@@ -5078,6 +5397,13 @@
next LINE;
}
}
+ foreach my $pattern (@bad_warnings) {
+ if ( /$pattern/ ) {
+ $log_info{bad_warning} = 1;
+ warn "$My_name: Important warning:\n $_\n"
+ unless $silent;
+ }
+ }
if ( (! $fls_file_analyzed)
&& /^File: (.+) Graphic file \(type / ) {
# First line of message from includegraphics/x
@@ -5459,10 +5785,6 @@
my ($file, $PAlines, $PHinfo) = @_;
- # Essential to use byte semantics, since (pdf)latex & lualatex
- # wrap by bytes, not characters
- use bytes;
-
# Where lines are wrapped at. We'll sometimes override.
local $log_wrap = $log_wrap;
@@ -5480,8 +5802,12 @@
# luatex: UTF-8 but with wrapping at APPROXIMATELY
# $log_wrap bytes. Rest as pdftex
# xetex: UTF-8 with wrapping at $log_wrap codepoints.
- # So start reading file as bytes; first line gives which program,
- # and for xetex we switch to reading file as UTF-8.
+ # So we read file as bytes
+ # first line gives which program was used and hence whether to wrap
+ # according to byte or codepoint count.
+ # wrapping is always performed on the encoded byte strings, but the
+ # place to wrap is determined according to the length in bytes or
+ # in codepoints, as needed.
print "$My_name: Getting log file '$file'\n";
open( my $fh, '<', $file )
or return 0;
@@ -5637,7 +5963,6 @@
my $cwd = good_cwd();
if ( ! open($fls_file, "<", $fls_name) ) {
-# if ( ! open($fls_file, "<:encoding(UTF-8)", $fls_name) ) {
return 1;
}
@@ -5650,6 +5975,9 @@
my $pwd_subst = undef; # Initial string for pwd that is to be removed to
# make relative paths, when possible. It must end
# in '/', if defined.
+ my $line_no = 0;
+ my $coding_errors = 0;
+ my $coding_errors_max_print = 2;
for ( <$fls_file> ) {
# Remove trailing CR and LF. Thus we get correct behavior when an fls file
# is produced by MS-Windows program (e.g., in MiKTeX) with CRLF line ends,
@@ -5658,13 +5986,37 @@
# And convert '\'
s/\r?\n$//;
s[\\][/]g;
- if (($^O eq 'MSWin32') && /PWD/ && is_valid_utf8($_) ) {
- # TeXLive produces PWD in CS_system not UTF-8.
- # ???? Later get tex_distribution before analyzing fls file, so do better test.
- print "PWD line not in UTF-8\n";
- # Assume in CS_system, no change needed.
+ $line_no++;
+ if ($no_CP_conversions) {
+ # Assume same byte representations for filenames in .fls file as
+ # for file system calls. No conversions needed.
}
- else { $_ = utf8_to_mine($_); }
+ else {
+ # Deal with MS-Win issues when system CP isn't UTF-8
+ if ( ($^O eq 'MSWin32') && /PWD/ && ! is_valid_utf8($_) ) {
+ # TeXLive on MSWin produces PWD in CS_system not UTF-8.
+ # ???? Later get tex_distribution before analyzing fls file, so do better test.
+ print "PWD line not in UTF-8. This is normal for TeXLive. I will handle it.\n";
+ # Assume in CS_system, no change needed.
+ }
+ elsif ( ! is_valid_utf8($_) ) {
+ $coding_errors++;
+ warn "$My_name: In '$fls_name' =====Line $line_no is not in expected UTF-8 coding:\n$_\n"
+ unless ($coding_errors > $coding_errors_max_print);
+ }
+ else {
+ my $orig = $_;
+ $_ = utf8_to_mine_errors($_);
+ if ($@) {
+ $coding_errors++;
+ if (!$silent) {
+ warn "$@in conversion UTF-8 to system code page of line $line_no of $fls_name\n",
+ "$orig\n"
+ unless ($coding_errors > $coding_errors_max_print);
+ }
+ }
+ }
+ } # End of fudge on MS-Win code page.
if (/^\s*PWD\s+(.*)$/) {
my $cwd_fls = $1;
$pwd_subst = $$Ppwd_latex = $cwd_fls;
@@ -5730,6 +6082,12 @@
}
}
close( $fls_file );
+ if ($coding_errors) {
+ warn "$My_name.$fls_name. There were $coding_errors line(s) with character coding\n",
+ " errors: Characters not available in system code page and/or non-UTF-8 in\n",
+ " file when expected. Dependency information may be incomplete.\n";
+ warn "The first few error lines are listed above\n";
+ }
return 0;
} #END parse_fls
@@ -5858,11 +6216,12 @@
#************************************************************
sub parse_aux {
- #Usage: parse_aux( $aux_file, \@new_bib_files, \@new_aux_files, \@new_bst_files )
+ # Usage: parse_aux( $aux_file, \@new_bib_files, \@new_aux_files, \@new_bst_files )
# Parse aux_file (recursively) for bib files, and bst files.
# If can't open aux file, then
# Return 0 and leave @new_bib_files empty
- # Else set @new_bib_files from information in the aux files
+ # Else set @new_bib_files and @new_bst_files from information in the
+ # aux files
# And:
# Return 1 if no problems
# Return 2 with @new_bib_files empty if there are no \bibdata
@@ -5874,47 +6233,65 @@
local $Pbib_files = $_[1];
local $Paux_files = $_[2];
local $Pbst_files = $_[3];
-
+ # Default return values
@$Pbib_files = ();
@$Pbst_files = ();
@$Paux_files = ();
+
+ # Map file specs (in \bibdata and \bibstyle lines) to actual filenames:
+ local %bib_files = ();
+ local %bst_files = ();
+
+ # Flag bad \bibdata lines in aux files:
+ local @bad_bib_data = ( );
+ # This array contains the offending lines, with trailing space (and
+ # line terminator) removed. (Currently detected problems: Arguments
+ # containing spaces, which bibtex refuses to accept.)
+
parse_aux1( $aux_file );
if ($#{$Paux_files} < 0) {
- return 0;
+ # No aux files found/read.
+ return 0;
}
- @$Pbib_files = uniqs( @$Pbib_files );
- @$Pbst_files = uniqs( @$Pbst_files );
+ my @not_found_bib = ();
+ my @not_found_bst = ();
+ find_files( \%bib_files, 'bib', 'bib', $Pbib_files, \@not_found_bib );
+ find_files( \%bst_files, 'bst', 'bst', $Pbst_files, \@not_found_bst );
+ # ???!!! Should only get one bst file, of course.
- if ( $#{$Pbib_files} == -1 ) {
- print "$My_name: No .bib files listed in .aux file '$aux_file' \n",
+ if ( $#{$Pbib_files} + $#bad_bib_data == -2 ) {
+ #
+ print "$My_name: No .bib files listed in .aux file '$aux_file'\n";
return 2;
}
- my @not_found = &find_file_list1( $Pbib_files, $Pbib_files,
- '.bib', \@BIBINPUTS );
- @$Pbib_files = uniqs( @$Pbib_files );
- &find_file_list1( $Pbst_files, $Pbst_files, '.bst' );
- @$Pbst_files = uniqs( @$Pbst_files );
- my @bad_bib = ();
- foreach ( @$Pbib_files ) {
- if ( /\s/ ) { push @bad_bib, $_; }
+
+ show_array( "$My_name: Found bibliography file(s):", @$Pbib_files )
+ unless $silent;
+ if (@not_found_bib) {
+ show_array(
+ "Bib file(s) not found in search path:",
+ @not_found_bib );
}
- if ($#bad_bib >= 0) {
- warn "$My_name: White space in an argument list for \\bibliography.\n",
- " which is not allowed by bibtex. Bad arguments:\n";
- foreach (@bad_bib ) { warn " '$_'\n"; }
- return 3;
+
+ if (@not_found_bst) {
+ show_array( "$My_name: Bst file not found in search path:", @not_found_bst);
}
- if ( $#not_found < 0) {
- print "$My_name: Found bibliography file(s) [@$Pbib_files]\n"
- unless $silent;
+
+
+ if ($#bad_bib_data >= 0) {
+ warn
+ "$My_name: White space in the argument for \\bibdata line(s) in an .aux file.\n",
+ " This is caused by the combination of spaces in a \\bibliography line in\n",
+ " a tex source file and the use of a pre-2018 version of *latex.\n",
+ " The spaces will give a fatal error when bibtex is used. Bad lines:\n";
+ foreach (@bad_bib_data ) { s/\s$//; warn " '$_'\n"; }
+ return 3;
}
- else {
- warn "$My_name: Failed to find one or more bibliography files:\n";
- foreach (@not_found) { warn " '$_'\n"; }
+ if (@not_found_bib) {
if ($force_mode) {
- warn "==== Force_mode is on, so I will continue. ",
- "But there may be problems ===\n";
+ warn "$My_name: Failed to find one or more bibliography files in search path.\n";
+ warn "====BUT force_mode is on, so I will continue. There may be problems ===\n";
}
return 3;
}
@@ -5921,6 +6298,8 @@
return 1;
} #END parse_aux
+
+
#************************************************************
sub parse_aux1
@@ -5942,24 +6321,43 @@
push @$Paux_files, $aux_file;
AUX_LINE:
while (<$aux_fh>) {
- $_ = utf8_to_mine($_);
- if ( /^\\bibdata\{(.*)\}/ ) {
- # \\bibdata{comma_separated_list_of_bib_file_names}
- # These are normally without the '.bib' extension.
- push @$Pbib_files, split /,/, $1;
- }
- elsif ( /^\\bibstyle\{(.*)\}/ ) {
- # \\bibstyle{bst_file_name}
- # Normally without the '.bst' extension.
- push @$Pbst_files, split /,/, $1;
- }
- elsif ( /^\\\@input\{(.*)\}/ ) {
- # \\@input{next_aux_file_name}
- &parse_aux1( $aux_dir1.$1 );
- }
- else {
- run_hooks( 'aux_hooks' );
- }
+ $_ = utf8_to_mine($_);
+ s/\s$//;
+ if ( /^\\bibdata\{(.*)\}/ ) {
+ # \\bibdata{comma_separated_list_of_bib_file_names}
+ # This results from a \bibliography command in the document.
+ my $arg = $1;
+ if ($arg =~ /\s/) {
+ # Bibtex will choke when the argument to \bibdata contains
+ # spaces, so flag the error here.
+ # N.B. *latex in TeX Live 2018 and later removes spaces from
+ # the argument to \bibliography before placing it as the
+ # argument to \bibdata in an aux file, so this error only
+ # appears if a *latex from TeX Live 2017 or earlier is used.
+ # Current MiKTeX's *latex (2022) also removes the space.
+ push @bad_bib_data, $_;
+ }
+ else {
+ foreach ( split /,/, $arg ) {
+ # bib files are always required to have an extension .bib,
+ # so provide the extension:
+ if ( ! /\.bib$/ ) { $_ .= '.bib'; }
+ $bib_files{$_} = '';
+ }
+ }
+ }
+ elsif ( /^\\bibstyle\{(.*)\}/ ) {
+ # \\bibstyle{bst_file_name}
+ # Normally without the '.bst' extension.
+ $bst_files{$1} = '';
+ }
+ elsif ( /^\\\@input\{(.*)\}/ ) {
+ # \\@input{next_aux_file_name}
+ &parse_aux1( $aux_dir1.$1 );
+ }
+ else {
+ run_hooks( 'aux_hooks' );
+ }
}
close($aux_fh);
return 1;
@@ -6108,10 +6506,6 @@
#
local ($in_name, $inhibit_output_switch) = @_;
- # We'll have conversions between encodings, and pattern,
- # so byte semantics will be safest.
- use bytes;
-
my $in_handle;
if ( ! -e $in_name ) {
# Note: This is NOT an error condition, since the fdb_latexmk file
@@ -6130,9 +6524,11 @@
# 0: outside rule;
# 1: in source section;
# 2: in generated file section;
+ # 3: in rewritten-before-read file section;
# 10: ignored rule.
my $rule = '';
local $run_time = 0;
+ local $last_result = -1;
local $source = '';
local $dest = '';
my $base = '';
@@ -6152,7 +6548,7 @@
return 1;
}
if ( $1 ne $fdb_ver) {
- warn "$My_name: File-database '$in_name' is of incompatible version, $1 v. $fdb_ver\n";
+ warn "$My_name: File-database '$in_name' is of incompatible version, $1 v. current version $fdb_ver\n";
return 1;
}
$state = 0;
@@ -6167,12 +6563,14 @@
$run_time = $check_time = 0;
$source = $dest = $base = '';
$old_actives{$rule} = 1;
- if ( $tail =~ /^\s*(\S+)\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+(\S+)\s*$/ ) {
+ $last_result = -1;
+ if ( $tail =~ /^\s*(\S+)\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+(\S+)\s+(\S+)/ ) {
$run_time = $1;
$source = $2;
$dest = $3;
$base = $4;
$check_time = $5;
+ $last_result = $6;
}
else {
# Line is not in correct format
@@ -6184,7 +6582,9 @@
next LINE;
}
if ( rdb_rule_exists( $rule ) ) {
- rdb_one_rule( $rule, \&rdb_read_set_rule );
+ # We need to set rule data from contents of fdb_latex file,
+ # but we'll do that later, so that it can be done for both
+ # existing and newly created rules.
}
elsif ($rule =~ /^cusdep\s+(\S+)\s+(\S+)\s+(.+)$/ ) {
# create custom dependency
@@ -6267,14 +6667,18 @@
$state = 10;
next LINE;
}
+ if ( rdb_rule_exists( $rule ) ) {
+ rdb_one_rule( $rule, \&rdb_read_set_rule );
+ }
$new_source = $new_sources{$rule} = {};
$state = 1; #Reading a section, source part
}
- elsif ( ($state <=0) || ($state >= 3) ) {
+ elsif ( ($state <=0) || ($state >= 4) ) {
next LINE;
}
elsif ( /^\(source\)/ ) { $state = 1; next LINE; }
elsif ( /^\(generated\)/ ) { $state = 2; next LINE; }
+ elsif ( /^\(rewritten before read\)/ ) { $state = 3; next LINE; }
elsif ( ($state == 1) && /^\"([^\"]*)\"\s+(\S+)\s+(\S+)\s+(\S+)\s+\"([^\"]*)\"/ ) {
# Source file line
my $file = $1;
@@ -6304,6 +6708,10 @@
my $file = $1;
rdb_one_rule( $rule, sub{ rdb_add_generated($file); } );
}
+ elsif ( ($state == 3) && /^\"([^\"]*)\"/ ) {
+ my $file = $1;
+ rdb_one_rule( $rule, sub{ rdb_add_rewritten_before_read($file); } );
+ }
else {
warn "$My_name: In file-database '$in_name' ",
"line $. is of wrong format:\n '$_'\n";
@@ -6326,9 +6734,11 @@
# Rule context assumed. Implicit passing of $dest, $run_time, $check_time,
# $in_name used as local variables in calling routine rdb_read.
#
- if ($$Ptest_kind == 3) { $$Ptest_kind = 1; }
+ $$Pno_history = 0;
$$Prun_time = $run_time;
$$Pcheck_time = $check_time;
+ $$Plast_result = $last_result;
+
# Deal with possibility that destination file in fdb_latexmk from
# run differs from what is currently set. Often that just reflects a
# difference between the end result of the last run and what the user
@@ -6389,8 +6799,6 @@
# Returns 1 on success, 0 if file couldn't be opened.
local $out_name = $_[0];
- use bytes;
-
local $out_handle;
if ( ($out_name eq "") || ($out_name eq "-") ) {
# Open STDOUT
@@ -6417,16 +6825,20 @@
{
return;
}
- fprint8( $out_handle, "[\"$rule\"] $$Prun_time \"$$Psource\" \"$$Pdest\" \"$$Pbase\" $$Pcheck_time\n" );
+ fprint8( $out_handle, "[\"$rule\"] $$Prun_time \"$$Psource\" \"$$Pdest\" \"$$Pbase\" $$Pcheck_time $$Plast_result\n" );
rdb_do_files(
sub { my $from_rule = $from_rules{$file} || '';
fprint8( $out_handle, " \"$file\" $$Ptime $$Psize $$Pmd5 \"$from_rule\"\n" );
}
- );
+ );
fprint8( $out_handle, " (generated)\n" );
foreach (sort keys %$PHdest) {
fprint8( $out_handle, " \"$_\"\n" );
}
+ fprint8( $out_handle, " (rewritten before read)\n" );
+ foreach (sort keys %$PHrewritten_before_read) {
+ fprint8( $out_handle, " \"$_\"\n" );
+ }
}
);
close $out_handle;
@@ -6442,6 +6854,7 @@
# Set its dependents etc, using information from log, aux, and fls files.
# Use fls file only if $recorder is set, and the fls file was generated
# on this run.
+ # Return:
# N.B. A complication which we try and handle in determining
# dependent files is that there may be aliasing of file names,
@@ -6563,7 +6976,7 @@
local %source_fls = (); # Lists source files found in fls file
local %first_read_after_write = (); # Lists source files that are only read
# after being written (so are not true
- # source files.
+ # source files).
local $primary_out = $$Pdest; # output file (dvi or pdf)
local %conversions = (); # *latex-performed conversions.
# Maps output file created and read by *latex
@@ -6872,11 +7285,9 @@
if ($diagnostics);
if ( exists $first_read_after_write{$new_source} ) {
if ( dep_at_start($new_source) ) {
- #print "--- READ ONLY AFTER WRITE OF '$new_source'\n";
- $dependents{$new_source} = 7;
+ $dependents{$new_source} = 8;
}
else {
- #print "--- READ ONLY AFTER CREATE OF '$new_source'\n";
$dependents{$new_source} = 6;
}
}
@@ -6897,6 +7308,7 @@
}
elsif ( $dependents{$new_source} == 7 ) {
# File was result of conversion by *latex.
+ # start of run. S
my $cnv_source = $conversions{$new_source};
rdb_ensure_file( $rule, $new_source );
# if ($cnv_source && ($cnv_source !~ /\"/ ) ) {
@@ -6910,6 +7322,14 @@
# do not require a rerun:
rdb_one_file( $new_source, sub{ $$Pcorrect_after_primary = 1; } );
}
+ elsif ( $dependents{$new_source} == 8 ) {
+ print "================= REWRITE '$new_source'\n";
+ # File was read only after being written
+ # and the file existed at the beginning of the run
+ rdb_ensure_file( $rule, $new_source );
+ rdb_add_generated( $new_source );
+ rdb_add_rewritten_before_read( $new_source );
+ }
else {
# But we don't need special precautions for ordinary user files
# (or for files that are generated outside of latex/pdflatex).
@@ -6957,7 +7377,7 @@
}
}
my @files_not_needed = ();
- foreach (keys %$PHsource) {
+ foreach (keys %$PHsource) {
if ( ! exists $dependents{$_} ) {
print "Removing no-longer-needed dependent '$_' from rule '$rule'\n"
if $diagnostics;
@@ -6966,7 +7386,8 @@
}
rdb_remove_files( $rule, @files_not_needed );
- return ($missing_dirs, [@missing_subdirs] );
+ return ($missing_dirs, [@missing_subdirs],
+ ( $log_info{bad_warning} ? 1 : 0 ) );
} # END rdb_set_latex_deps
@@ -6976,7 +7397,9 @@
# Usage: switch_output( primary_rule, actual_ext, intended_ext )
# Rearrange rules to deal with changed extension of output file of
# the specified primary rule (one of *latex).
- # Return 0 on success, non-zero error code on failure
+ # The switching only works if no request was made for dvi, ps or xdv
+ # files, but only if the requested file was pdf.
+ # Return 0 on success, non-zero error code on failure.
my ( $rule, $actual_ext, $intended_ext ) = @_;
if ( $actual_ext eq $intended_ext ) { return 0; }
@@ -6987,6 +7410,12 @@
return 1;
}
+ # Turn off all pdf producers and all primaries (pdf producing or not).
+ # Then reactivate what we need: current rule and whatever else is needed
+ # to produce a pdf file.
+ # Given that we get here if the rule is not producing the intended kind
+ # of output file, it's best to turn off all primaries, so as to make the
+ # primary in use unambiguous.
rdb_deactivate_derequest( 'dvipdf', 'pspdf', 'xdvipdfmx', keys %possible_primaries );
rdb_activate_request( $rule );
@@ -7178,7 +7607,7 @@
}
if ( exists $ENV{TEXINPUTS} ) {
foreach my $searchpath (split $search_path_separator, $ENV{TEXINPUTS}) {
- my $file = File::Spec->catfile($searchpath,$_[0]);
+ my $file = catfile($searchpath,$_[0]);
my $test = "$file.$_[1]";
if ( -e $test ) {
return $file;
@@ -7298,7 +7727,8 @@
my $new_dest = "$file.$try_ext";
&Run_subst( "$make $quote$new_dest$quote" );
if ( -e $new_dest ) {
- print "SUCCESS in making '$new_dest'\n";
+ print "SUCCESS in making '$new_dest'\n",
+ "I'll ensure '$rule' is rerun.\n";
# Put file in rule, without a from_rule, but
# set its state as non-existent, to correspond
# to file's state before the file was made
@@ -7352,23 +7782,21 @@
if ($pdf_mode) {push @dest_exts, '.pdf';}
if ($dvi_mode) {push @dest_exts, '.dvi';}
if ($postscript_mode) {push @dest_exts, '.ps';}
+
my %source = ( $texfile_name => 1 );
- my @generated = ();
my @accessible_all = &rdb_accessible;
rdb_for_some(
\@accessible_all,
- sub{ push @generated, keys %$PHdest; },
+ sub{},
sub{ $source{$file} = 1; }
);
- foreach (keys %generated_exts) {
- (my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/${aux_dir1}${root_filename}/;
- push @generated, $name;
- }
- show_array( "Generated:", @generated ) if $diagnostics;
- foreach (@generated) {
+ foreach (keys %from_rules) {
+ # Remove known generated files from list of source files.
delete $source{$_};
}
- show_array( "Sources:", keys %source ) if $diagnostics;
+
+ show_array( "Sources:", sort keys %source ) if $diagnostics;
+
foreach my $ext (@dest_exts) {
# Don't insert name of deps file in targets.
# The previous behavior of inserting the name of the deps file
@@ -7412,7 +7840,7 @@
foreach (@int_cmd) {
if ( !defined($_) ) { $_='undef';}
}
- print " [$rule]: '$$Pcmd_type' '$$Pext_cmd' '@int_cmd' $$Ptest_kind ",
+ print " [$rule]: '$$Pcmd_type' '$$Pext_cmd' '@int_cmd' $$Pno_history ",
"'$$Psource' '$$Pdest' '$$Pbase' $$Pout_of_date $$Pout_of_date_user\n"; },
sub{ print " '$file': $$Ptime $$Psize $$Pmd5 '", ($from_rules{$file} || ''), "'\n"; }
);
@@ -7487,10 +7915,15 @@
# a typical postscript file), or for a non-trivial reason (e.g., a
# stochastic algorithm, as in abcm2ps).
#
- # This caused me some actual trouble. In general, circular
- # dependencies produce non-termination, and the the following
- # situation is an example of a generic situation where certain
- # rules must be obeyed in order to obtain proper results:
+ # This caused me some actual trouble in certain cases, with circular
+ # dependencies causing non-termination when the standard
+ # stability-of-source-file algorithm is applied, together with
+ # non-optimality if the depedence isn't actually circular: e.g., from a
+ # rerun of X-to-pdf cusdep, where the pdf file is unchanged from
+ # previous one aside from a time of generation comment. The following
+ # situation is an example of a generic situation where a change from
+ # the standard stability-of-input-files criterion must be modified in
+ # order to obtain proper results:
# 1. A/the latex source file contains specifications for
# certain postprocessing operations. Standard *latex
# already has this, for indexing and bibliography.
@@ -7499,11 +7932,11 @@
# in external source files not directly input to
# *latex. But in the original version, there was a
# style file (abc.sty) that caused latex itself to call
- # abcm2ps to make .eps files for each tune that were to be
- # read in on the next run of latex.
+ # abcm2ps **un**conditionally to make .eps files for each tune
+ # that was to be read in on the next run of latex.
# 3. Thus the specification can cause a non-terminating loop
# for latexmk, because the output files of abcm2ps changed
- # even with identical input.
+ # on every run, even with identical input.
# 4. The solution was to
# a. Use a style file abc_get.sty that simply wrote the
# specification on the tunes to the .aux file in a
@@ -7518,106 +7951,190 @@
# changes.
# This solves the problem. Latexmk works. Also, it is no
# longer necessary to enable write18 in latex, and multiple
- # unnecessary runs of abcm2ps are no longer used.
+ # unnecessary runs of abcm2ps are no longer used.
+
+ # [**N.B.** Other sty files have similar problems, of
+ # unconditional write18s to make eps, pdf or other files. That's
+ # always non-optimal, often highly so --- see at least one of
+ # the example_latexmkrc files for real cases. But work is needed
+ # on the package to do better, which has been done in some
+ # packages. It is also possible to do better with a suitable
+ # configuration of latexmk with write18 turned off. E,g,,
+ # perhaps a cusdep, or a fancy used of a subroutine for *latex
+ # --- see the example_latexmkrc files for examples.]
#
- # The order of testing and applying rules is chosen by the
- # following heuristics:
- # 1. Both latex and pdflatex may be used, but the resulting
- # aux files etc may not be completely identical. Define
- # latex and pdflatex as primary rules. Apply the general
- # method of repeated circulating through all rules until
- # the source files are stable for each primary rule
- # separately. Naturally the rules are all accessible
- # rules, but excluding primary rules except for the current
- # primary.
- # 2. Assume that the primary rules are relatively
- # time-consuming, so that unnecessary passes through them
- # to check stability of the source files should be avoided.
- # 3. Assume that although circular dependencies exist, the
- # rules can nevertheless be thought of as basically
- # non-circular, and that many rules are strictly or
- # normally non-circular. In particular cusdep rules are
- # typically non-circular (e.g., fig2eps), as are normal
- # output processing rules like dvi2ps.
- # 4. The order for the non-circular approximation is
- # determined by applying the assumption that an output file
- # from one rule that is read in for an earlier stage is
- # unchanged.
- # HOWEVER, at a first attempt, the ordering is not needed. It
- # only gives an optimization
- # 5. (Note that these assumptions could be violated, e.g., if
- # $dvips is arranged not only to do the basic dvips
- # command, but also to extract information from the ps file
- # and feed it back to an input file for *latex.)
- # 6. Nevertheless, the overall algorithm should allow
- # circularities. Then the general criterion of stability
- # of source files covers the general case, and also
- # robustly handles the case that the USER changes source
- # files during a run. This is particularly important in
- # -pvc mode, given that a full make on a large document can
- # be quite lengthy in time, and moreover that a user
- # naturally wishes to make corrections in response to
- # errors, particularly latex errors, and have them apply
- # right away.
+ # The method used is conditioned on:
+ # 1. The network of active rules is constructed, with dependencies
+ # linking the rules. The network may change during the
+ # make. Notably, dependency information can be discovered from
+ # the results of runs of rules, especially *latex. This involves
+ # addition (and deletion) of items in the source-file list of a
+ # rule. It also involves addition (or deletion) of rule-nodes
+ # for e.g., cusdeps, bibtex, makeindex. Bigger changes
+ # sometimes occur --- e.g., when a .tex document chooses a
+ # kind of output file from the expected one: e.g., pdf to dvi or
+ # vice versa.
+ # 2. The *latex rules are called primary rules, and are the core
+ # source of dependency information (as ultimately determined by
+ # the .tex file(s). Only one primary rule is active. That was
+ # enforced by initialization.
+ # 3. There are generally loops of dependencies. The overall aim is
+ # to keep looping through rules until the content of the source
+ # files for each rule is unchanged from the previous run. Given
+ # the basic assumption that it is the content of these files
+ # that determines the output, stability of input files gives
+ # stability of output.
+ # 4. During the loop, the main criterion for running a rule is
+ # that the current contents of the source files are changed
+ # compared with the state saved in the rule. This is
+ # supplemented by the condition that a rule not previously run
+ # (under latexmk control) is to be run unconditionally.
+ # 5. In addition, there are specified dependencies not going via a
+ # set of files not known to latexmk as source files of the
+ # target rule. The primary examples are dvips, dvipdf, etc,
+ # which use graphics files; these are specified to have a dvi
+ # producing fule (e.g., latex) as a source rule. Such a rule is
+ # to be run after the source rule has been run.
+ # 6. There are special cases, coded in rdb_rerun_needed and
+ # rdb_file_change1.
+ # 7. Immediately before running a rule, the saved state of its
+ # source files is updated to their current state. If there is
+ # no error in the run, the source-file-state is **not** updated
+ # after the rule is run. Then on a subsequent pass through
+ # rdb_make's main loop, when the rule is tested for a rerun, any
+ # change in source file contents is cause for running the rule
+ # again.
+ # 8. But after a run giving an error, the state of the generated
+ # files (i.e., non-user files) is updated to the current state.
+ # This is because the error (under normal circumstances) must be
+ # corrected by user action: e.g., correcting a source file, and
+ # possibly deleting some corrupted auxiliary file. Files (e.g.,
+ # .aux by *latex) generated by the rule just run may well have
+ # changed, so updating their state to the current state prevents
+ # another run before a user change. If a file was generated by
+ # another rule, it won't have changed its state, so updating its
+ # state won't matter. But a non-generated file is a
+ # user-created file, and a rerun is entailed if its contents
+ # changed compared with the start of the run; it's the
+ # start-of-run contents that were used in the error run.
+ # 9. Note: an error may be caused by a problem with a file
+ # generated by another rule, e.g., a bbl file created by bibtex
+ # and read by *latex, but with no error reported by bibtex. To
+ # correct the error a source file (possibly more than once
+ # removed must be changed). That triggers a rerun of the
+ # producing rule, and after that the resulting change causes a
+ # rerun of the original rule that had the error. E.g.,
+ # correcting a .bib file causes bibtex to run, producing a
+ # corrected .bbl file, after which *latex is caused to be run.
+ # 10. With circular dependencies, there is a choice of which order
+ # to examine the rules. Generally, primary rules are more
+ # time-consuming than most others, so the choice of the order of
+ # examination of rules to check out-of-dateness is to try to
+ # minimize the number of primary runs. The other time-consuming
+ # rules are things like xdvipdfmx in documents with much
+ # graphics. These are normally outside a dependency loop, so
+ # those are left to last. Even if they are inside a dependency
+ # loop, they need the primary rule to have been run first.
+ # 11. After rdb_make is run, all non-user source files are updated
+ # to their current state. Rules are considered up-to-date
+ # here. On a subsequent call to rdb_make, subsequent changes are
+ # relevant to what is to be done. Note: the states of user
+ # files aren't updated. This guards against user caused changes
+ # that are made between the start of the run of a rule and the
+ # end of rdb_make.
+ #
+ # [Comment: Possible scenario for dvips, xdvipdfmx etc in loop:
+ # Document is documentation for viewer. At some page, the result
+ # in the viewer is to be displayed, with the display in the
+ # viewer being a neighboring page of the document, so the
+ # relevant page is extracted from the pdf file (or ...), and
+ # then processed into a graphics file to be included in the
+ # document.]
+ #
# This leads to the following approach:
# 1. Classify accessible rules as: primary, pre-primary
# (typically cusdep, bibtex, makeindex, etc), post-primary
- # (typically dvips, etc), and one-time
- # 2. Then stratify the rules into an order of application that
- # corresponds to the basic feedforward structure, with the
- # exclusion of one-time rules.
- # 3. Always require that one-time rules are among the
- # explicitly requested rules, i.e., the last to be applied,
- # were we to apply them. Anything else would not match the
- # idea of a one-time rule.
- # 4. Then work as follows:
- # a. Loop over primaries
- # b. For each primary, examine each pre-primary rule and
- # apply if needed, then the primary rule and then each
- # post-primary rule. The ordering of the pre-primary
- # and post-primary rules was found in step 2.
- # BUT applying the ordering is not essential
- # c. Any time that a pre-primary or primary rule is
- # applied, loop back to the beginning of step b. This
- # ensures that bibtex etc are applied before rerunning
- # *latex, and also covers changing source files, and
- # gives priority to quick pre-primary rules for changing
- # source files against slow reruns of latex.
- # d. Then apply post-primary rules in order, but not
- # looping back after each rule. This non-looping back
- # is because the rules are normally feed-forward only.
- # BUT applying the ordering is not essential
- # e. But after completing post-primary rules do loop back
- # to b if any rules were applied. This covers exotic
- # circular dependence (and as a byproduct, changing
- # source files).
- # f. On each case of looping back to b, re-evaluate the
- # dependence setup to allow for the effect of changing
- # source files.
- #
+ # (typically dvips, etc), and one-time.
+ # This step is the start of rdb_make's main "PASS" loop.
+ # 2. Go over the pre-primaries, the primary and the
+ # post-primaries. Examine each rule for out-of-dateness; if
+ # out-of-date run it.
+ # 3. Just before a run of a rule, update its source file state to
+ # the current state of the files.
+ # 4. After the rule is run, at least after a primary rule is run,
+ # examine the dependency information available (.fls, .log, .aux
+ # files) and updated the rule configuration. This can involve
+ # radical changes in the rule network: E.g., a newly found use
+ # of bibtex or makeindex, or even more radical rearrangements,
+ # if for example (under document control) *latex produces a .dvi
+ # file instead of an expected .pdf file.
+ # 5. If in any pass through the loop one (or more) of the
+ # pre-primary and primary rules is run, don't go on to examine
+ # the post-primaries. Not only are these are sometimes
+ # time-consuming and are almost always outside the dependency
+ # loops involving the primary, but, most importantly, dealing
+ # with the dependency information from a primary rule can change
+ # the rule network a lot.
+ # Instead go back to step 1.
+ # 6. Once visiting the pre-primaries and primaries no longer
+ # triggers any run, i.e., those rules are all stable, go on to
+ # the post-primaries.
+ # 7. If one or more of the post-primaries has been run, go back to
+ # 1. This allows for the possibility that a post-primary rule is
+ # part of a dependency loop. This is highly unusual for a
+ # normal document, but not impossible in principle. See earlier
+ # for a conceivable example.
+ # 10. Thus we finish the looping when no further run has been
+ # triggered by an examination of all of the pre-primary,
+ # primary, post-primary rules.
+ # 11. In addition, the loop is terminated if the number of
+ # applications of a rule exceeds a configured maximum. This
+ # guards agains the possibility that it may never be possible to
+ # get stable output, i.e., there is an infinite loop. It is
+ # impossible for an algorithm to determine in general whether
+ # there is an infinite loop. (An example of the Turing halting
+ # theorem.) But normal documents need a decidable modest number
+ # of passes through the loop. Any exceeding of the limit on the
+ # number of passes needs examination.
+ # 12. Finally apply one-time rules. These are rules that by their
+ # nature are both outside of any dependency a loop and are ones
+ # that should be applied last. Standard ones including running
+ # a viewer or causing it to be updated. The standard ones are
+ # not actually in the class of rules that rdb_make runs. Instead
+ # they are run by the calling routines, since the needs may be
+ # quite special.
- # ??? Overkill?
+ # ???!!! Overkill?
&rdb_set_rule_net;
- local %pass = ();
+ local %pass = (); # Counts runs on each rule: Used for testing for
+ # exceeding maximum runs and for determining
+ # whether to run rules that have a list of source
+ # rules. (E.g., dvips, which is to be run
+ # whenever latex has been run to make a dvi
+ # file. This because the list of source files of
+ # dvips misses all graphics files, and so the
+ # source file method is insufficient for deciding
+ # on a rerun.)
+ rdb_for_some( [keys %rule_db],
+ sub{ $pass{$rule} = 0;
+ foreach (keys %$PHsource_rules) {
+ $$PHsource_rules{$_} = 0;
+ }
+ }
+ );
+
local $failure = 0; # General accumulated error flag
local $missing_dvi_pdf = ''; # Did primary run fail to make its output file?
local $runs = 0;
local $runs_total = 0;
local $too_many_passes = 0;
- local %rules_applied = ();
local $switched_primary_output = 0;
local @warning_list = (); # Undef refs etc reported in last primary run
my $retry_msg = 0; # Did I earlier say I was going to attempt
# another pass after a failure?
- rdb_for_some ( [keys %rule_db],
- sub{ $pass{$rule} = 0;
- foreach (keys %$PHsource_rules) {
- $$PHsource_rules{$_} = 0;
- }
- }
- );
- PASS:
+ my %changes = (); # For reporting of changes
+ PASS:
while (1==1) {
# Exit condition at end of body of loop.
$runs = 0;
@@ -7658,6 +8175,12 @@
"make new source files\n";
next PASS;
}
+ elsif ( rdb_user_changes( \%changes, @pre_primary, $current_primary )) {
+ print "$My_name: Some rule(s) failed, but user file(s) changed ",
+ "so keep trying\n";
+ rdb_diagnose_changes2( \%changes, "", 1 ) if (!$silent);
+ next PASS;
+ }
else { last PASS; }
}
if ($runs == 0) {
@@ -7665,7 +8188,7 @@
$failure = $previous_failure;
if ($retry_msg) {
print "But in fact no new files made\n";
- }
+ }
if ($failure && !$force_mode ) { last PASS; }
}
if ( $missing_dvi_pdf ) {
@@ -7694,9 +8217,62 @@
rdb_for_some( [@unusual_one_time], \&rdb_make1 );
- if ($runs_total > 0) { rdb_write( $fdb_name ); }
+ #---------------------------------------
+ # All of make done. Finish book-keeping:
+ # 1. Update state of source files suitably.
+ # 2. Update fdb_latexmk file, if needed.
+ # 3. Diagnostics.
+ # 4. Other book-keeping and clean up.
+
+ ############ Update state of source files. Complications:
+ # **Either** success. Then the algorithms arrange that the contents of
+ # source files have stabilized between start and end of run of rule,
+ # so that output files have also stabilized.
+ # **or** failure. Then processing is normally aborted, so source files
+ # that are generated may not have stabilized, e.g., .aux file.
+ # At the next round of compilation (or test for a need for a rerun, as in
+ # make_preview_continuous), the criterion for a rerun of a rule is that
+ # source file(s) have changed relative to the saved state.
+ # At this point the saved file state for each rule is the state just
+ # before its last run. After a successful make, that gives correct
+ # behavior, including for user files (i.e., non-generated files). But
+ # not always after a failure.
+ #
+ # **So at this point we set state of generated source files to current
+ # state.**
+ #
+ # Normally there are no further changes in generated files, so they
+ # won't trigger reruns, only changes in user files will do that.
+ # That's correct behavior.
+ # But occasionally generated files have errors that block further
+ # processing, as is known for .aux and .bbl files. Then user can
+ # delete .aux and .bbl and thereby trigger a rerun. It also optimizes
+ # testing for changes, since, e.g., an .aux file of the same content but
+ # a different time than the current file will have its md5 signature
+ # recomputed during a check for a rerun. But when both time and size
+ # are unchanged, the test is optimized by assuming no change, and it
+ # doesn't do the md5 calculation.
+ #
+ # **However**, we will not update the state of the user files (i.e.,
+ # the non-generated files). This is because when the user notices an
+ # error during a run, they may correct the error in a .tex file say,
+ # but both too late to trigger a *latex and too early to be a post-make
+ # changed. Then it is correct to compare the current state of a user
+ # source file with its state just before the last run.
+ #
+ # In addition, we only update the file state for active rules, i.e.,
+ # those that the current use of make is supposed to have made
+ # up-to-date.
+ # Only do file-state update if something was run, otherwise it's work
+ # for nothing.
+
+ if ($runs_total > 0) {
+ rdb_for_some( [rdb_accessible()], \&rdb_update_gen_files );
+ rdb_write( $fdb_name );
+ }
else { print "$My_name: Nothing to do for '$texfile_name'.\n"; }
+ # Diagnostics
if ($#primary_warning_summary > -1) {
# N.B. $mult_defined, $bad_reference, $bad_character, $bad_citation also available here.
show_array( "$My_name: Summary of warnings from last run of *latex:",
@@ -7728,13 +8304,21 @@
print "$My_name: All targets (@dests) are up-to-date\n";
}
}
- rdb_for_some ( [keys %rule_db],
+
+ # ???!!! Rethink use of %pass, and it's scoping.
+ # Currently %pass is local in rdb_make and is used only to determine
+ # whether a rule needs to be run because a source rule has been run,
+ # and this would be within the same call to rdb_make.
+ # OLD COMMENT: Update source_rules. Is this too late? I don't think so, it's
+ # internal to make and to multiple calls to it (pvc). Is this
+ # necessary?
+ rdb_for_some( [keys %rule_db],
sub{
foreach my $s_rule (keys %$PHsource_rules) {
$$PHsource_rules{$s_rule} = $pass{$s_rule};
}
}
- );
+ );
return $failure;
} #END rdb_make
@@ -7776,6 +8360,7 @@
#-------------------
sub rdb_make1 {
+ # ???!!! Rethink how $$Pout_of_date is reset at end.
# Call: rdb_make1
# Helper routine for rdb_make.
# Carries out make at level of given rule (all data available).
@@ -7782,10 +8367,17 @@
# Assumes contexts for recursion, make, and rule, and
# assumes that source files for the rule are to be considered
# up-to-date.
+ our $rule;
if ($diagnostics) { print " Make for rule '$rule'\n"; }
+ # Is this needed? Yes; rdb_make1 is called on a sequence of rules and
+ # if one gives an error, then it provides source files directly or
+ # indirectly to later rules, which should not be run.
if ($failure & ! $force_mode) {return;}
- if ( ! defined $pass{$rule} ) {$pass{$rule} = 0; }
+ # Rule may have been created since last run. Just in case we didn't,
+ # define $pass{$rule} elsewhere, do it here:
+ if ( ! defined $pass{$rule} ) {$pass{$rule} = 0; }
+
# Special fix up for bibtex:
my $bibtex_not_run = -1; # Flags status as to whether this is a
# bibtex rule and if it is, whether out-of-date condition is to
@@ -7801,81 +8393,41 @@
if ($bibtex_use == 0) {
$bibtex_not_run = 2;
}
- elsif ( ($bibtex_use == 1) || ($bibtex_use == 1.5) ) {
- foreach ( keys %$PHsource ) {
- if ( ( /\.bib$/ ) && (! -e $_) ) {
- push @missing_bib_files, $_;
- $bibtex_not_run = 1;
+ else {
+ if ( $rule =~ /^biber/ ) {
+ warn "$My_name: ???!!!==== Using biber OMITTING TEST on missing bib files\n";
+ }
+ elsif ( ($bibtex_use == 1) || ($bibtex_use == 1.5) ) {
+ foreach ( keys %$PHsource ) {
+ if ( ( /\.bib$/ ) && (! -e $_) ) {
+ push @missing_bib_files, $_;
+ $bibtex_not_run = 1;
+ }
}
}
}
}
- if ( ($$Prun_time == 0) && exists($possible_primaries{$rule}) ) {
- push @rules_never_run, $rule;
- $$Pout_of_date = 1;
- $$Plast_result = -1;
+ if ( ! rdb_rerun_needed(\%changes, 0) ) { return; }
+
+ # Set this in case of early exit:
+ # ???!!! Check I am setting $missing_dvi_pdf correctly.
+ if ( $$Pdest && (! -e $$Pdest) && ( $$Pcmd_type eq 'primary' ) ) {
+ $missing_dvi_pdf = $$Pdest;
}
- else {
- if ( $$Pdest && (! -e $$Pdest) ) {
- # With a non-existent destination, if we haven't made any passes
- # through a rule, rerunning the rule is good, because the file
- # may fail to exist because of being deleted by the user (for ex.)
- # rather than because of a failure on a previous run.
- # (We could do better with a flag in fdb file.)
- # But after the first pass, the situation is different.
- # For a primary rule *latex, the lack of a destination file
- # could result from there being zero content due to a missing
- # essential input file. The input file could be generated
- # by a program to be run later (e.g., a cusdep or bibtex),
- # so we should wait until all passes are completed before
- # deciding a non-existent destination file is an error.
- # For a custom dependency, the rule may be obsolete, and
- # if the source file does not exist also, we should simply
- # not run the rule, but not set an error condition.
- # Any error will arise at the *latex level due to a
- # missing source file at that level.
- if ( $$Psource && (! -e $$Psource)
- && ( $$Pcmd_type ne 'primary' )
- ) {
- # Main source file doesn't exist, and rule is NOT primary.
- # No action, since a run is pointless. Primary is different:
- # file might be found elsewhere (by kpsearch from *latex),
- # while non-existence of main source file is a clear error.
- }
- elsif ( $$Pcmd_type eq 'delegated' ) {
- # Delegate to destination rule
- }
- elsif ( $pass{$rule}==0) {
- push @no_dest, $$Pdest;
- $$Pout_of_date = 1;
- }
- if ( $$Pcmd_type eq 'primary' ) {
- $missing_dvi_pdf = $$Pdest;
- }
- }
- }
- &rdb_clear_change_record;
- &rdb_flag_changes_here(0);
-
- if (!$$Pout_of_date) {
- return;
- }
- if ($diagnostics) { print " remake\n"; }
if (!$silent) {
- print "$My_name: applying rule '$rule'...\n";
- &rdb_diagnose_changes( "Rule '$rule': " );
+ print "$My_name: applying rule '$rule'...\n";
+ &rdb_diagnose_changes2( \%changes, "Rule '$rule': ", 0 );
}
- # We are applying the rule, so its source file state for when it
- # was last made is as of now:
- # ??IS IT CORRECT TO DO NOTHING IN CURRENT VERSION?
+ # We are applying the rule, so its source file state for when it was
+ # last made is as of now. This is do in the subroutines that do the
+ # actual run, to allow for possible calls to them from other places.
# The actual run
my $return = 0; # Return code from called routine
- # Rule may have been created since last run:
- if ( ! defined $pass{$rule} ) {$pass{$rule} = 0; }
+
if ( $pass{$rule} >= $max_repeat ) {
# Avoid infinite loop by having a maximum repeat count
# Getting here represents some kind of weird error.
@@ -7889,7 +8441,6 @@
return;
}
- $rules_applied{$rule} = 1;
$runs++;
$runs_total++;
@@ -7927,7 +8478,7 @@
# latex run and the consequent analysis of the log file, the
# cusdep rule will no longer be needed, and will be removed.
- # So in this case, do NOT report an error
+ # So in this case, do NOT report an error
$$Pout_of_date = 0;
}
elsif ($$Pcmd_type eq 'primary' ) {
@@ -7958,6 +8509,15 @@
if ( !$$Plast_message ) {
$$Plast_message = "Run of rule '$rule' gave a non-zero error code";
}
+ # Update state of generated source files, but not non-generated,
+ # i.e., user source files. Thus any change in the rule's own
+ # generated source files during the run will not cause a
+ # rerun. Files generated by another rule should not have been
+ # changed during the run, so updating their saved state in this
+ # rule is a NOP. But any change in user files since the **start**
+ # of the run is a cause for a rerun, so their saved state must not
+ # be updated.
+ rdb_update_gen_files();
}
foreach ( keys %$PHsource_rules ) {
$$PHsource_rules{$_} = $pass{$_};
@@ -7976,7 +8536,7 @@
# Defaults for summary of results of run.
$$Prun_time = time();
-
+
$$Pchanged = 0; # No special changes in files
$$Plast_result = 0;
$$Plast_message = '';
@@ -8038,7 +8598,7 @@
$$Plast_message = "Bug or configuration error; incorrect command type";
}
$time = processing_time() - $time;
- push @timings, "'$_[0]': time = " . sprintf('%.2f',$time) . "\n";
+ add_timing( $time, $rule );
#============================================================================
@@ -8137,6 +8697,10 @@
my $retcode = check_bibtex_log($$Pbase);
if ( ! -e $$Psource ) {
$retcode = 10;
+ if (!$silent) {
+ print "Source '$$Psource' for '$rule' doesn't exist,\n",
+ "so I'll force *latex to run to try and make it.\n";
+ }
rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } );
}
if ($retcode == 3) {
@@ -8171,12 +8735,6 @@
# General
$updated = 1;
- if ($$Ptest_kind == 3) {
- # We are time-criterion first time only. Now switch to
- # file-change criterion
- $$Ptest_kind = 1;
- }
-
if ( ($$Plast_result == 0) && ($return != 0) && ($return != -2) ) {
$$Plast_result = 2;
if ($$Plast_message eq '') {
@@ -8183,7 +8741,8 @@
$$Plast_message = "Command for '$rule' gave return code $return";
if ($rule =~ /^(pdf|lua|xe|)latex/) {
if ( test_gen_file($log_name) ) {
- $$Plast_message .= "\n Refer to '$log_name' for details";
+ $$Plast_message .=
+ "\n Refer to '$log_name' and/or above output for details";
}
else {
$$Plast_message .=
@@ -8217,11 +8776,6 @@
$$Plast_result = 0;
$$Plast_message = '';
- if ($$Ptest_kind == 3) {
- # We are time-criterion first time only. Now switch to
- # file-change criterion
- $$Ptest_kind = 1;
- }
$$Pout_of_date = $$Pout_of_date_user = 0;
return 0;
@@ -8244,7 +8798,7 @@
# This is a globally usable subroutine, and works in a rule context,
# and outside.
# Defaults:
- # cmd: $PPext_cmd if defined, else '';
+ # cmd: $$Pext_cmd if defined, else '';
# msg: 1
# options: ''
# source: $$Psource if defined, else $texfile_name;
@@ -8323,7 +8877,7 @@
#
# Assumes contexts for: recursion, make, & rule.
# Assumes (a) the rule is a primary,
- # (b) a run has to be made,
+ # (b) a run has been made,
my $return_latex = shift;
my $return = $return_latex;
@@ -8335,7 +8889,7 @@
# Handle case that log file is caused to be in an unexpected place,
# from a configuration error:
&find_set_log;
-
+
if ($recorder) {
# Handle problem that some version of *latex give fls files
# of name latex.fls or pdflatex.fls instead of $root_filename.fls.
@@ -8377,7 +8931,11 @@
}
# Find current set of source files:
- my ($missing_dirs, $PA_missing_subdirs) = &rdb_set_latex_deps;
+ my ($missing_dirs, $PA_missing_subdirs, $bad_warnings) = &rdb_set_latex_deps;
+ if ($bad_warning_is_error && $bad_warnings) {
+ warn "$My_name: Serious warnings in .log configured to be errors\n";
+ $return ||= $bad_warnings;
+ }
# For each file of the kind made by epstopdf.sty during a run,
# if the file has changed during a run, then the new version of
@@ -8429,54 +8987,248 @@
#************************************************************
-sub rdb_clear_change_record {
- # Initialize diagnostics for reasons for running rule.
- @changed = ();
- %changed_rules = ();
- @changed_user = ();
- @disappeared = ();
- @no_dest = (); # We are not now using this
- @rules_never_run = ();
- @rules_to_apply = (); # This is used in recursive application
- # of rdb_flag_changes_here, to list
- # rules that were out-of-date for some reason.
-} #END rdb_clear_change_record
+sub rdb_remake_needed {
+ # Usage: rdb_remake_needed( \%change_record, outside-make-loop, rules ...)
+ # Determine whether one or more of the rules needs to be rerun, and
+ # return corresponding value.
+ #
+ # Report diagnostics (reasons for remake) in the hash referenced by the
+ # first argument (the hash maps kinds of reason to refs to arrays).
+ #
+ # If second argument is true, use rerun criterion suitable to e.g.,
+ # initial tests in rdb_make, rerun test in
+ # make_preview_continuous. Otherwise use rerun criterion suitable for
+ # with rdb_make's looping through rules.
+ # In the first case, the file state recorded in each rule corresponds
+ # to the files **after** the of the previous invocation of rdb_make. In
+ # the second case it corresponds to the state immediately **before**
+ # the latest run of the rule.
+ my $PHchanges = shift;
+ my $outside_make_loop = shift;
+
+ my $remake_needed = 0;
+
+ %$PHchanges = ();
+
+ # ???!!! Need fancier tests: SEE NOTES.
+
+ rdb_recurse( [@_],
+ sub {
+ my %changes_rule = ();
+ if( rdb_rerun_needed(\%changes_rule, $outside_make_loop)) {
+ $remake_needed = 1;
+ foreach my $kind (keys %changes_rule ) {
+ push @{$$PHchanges{$kind}}, @{$changes_rule{$kind}};
+ }
+ }
+ }
+ );
+
+ return $remake_needed;
+} #END rdb_remake_needed
+
#************************************************************
-sub rdb_flag_changes_here {
- # Flag changes in current rule.
- # Assumes rule context.
- # Usage: rdb_flag_changes_here( ignore_run_time )
- # Argument: if true then fdb_get shouldn't do runtime test
- # for recalculation of md5
- local $ignore_run_time = $_[0];
- if ( ! defined $ignore_run_time ) { $ignore_run_time = 0; }
+sub rdb_user_changes {
+ # Usage: rdb_user_changes( \%change_record, rules ...)
+ # Return value: whether any user files changed.
+ # Report changes in hash pointed to by first argument.
+ # Side effect: out-of-date rules flagged in $$Pout_of_date.
+ #
+ # ???!!!
+ # Ideally, need specialized versions of rdb_rerun_needed and
+ # rdb_file_change1 (or special option to those), to restrict attention
+ # to user_changed files. But for now, fudge our way around that.
+ my $PHchanges = shift;
+ my $user_changes = 0;
+ %$PHchanges = ( 'changed_user' => [],
+ 'rules_to_apply' => []
+ );
+
+ rdb_recurse(
+ [@_],
+ sub {
+ my %changes_rule = ( 'changed_user' => [] );
+ if ( rdb_rerun_needed(\%changes_rule, 0 )
+ && @{$changes_rule{changed_user}}
+ ) {
+ push @{$$PHchanges{changed_user}},
+ @{$changes_rule{changed_user}};
+ push @{$$PHchanges{rules_to_apply}}, $rule;
+ $user_changes = 1;
+ $$Pout_of_date = $$Pout_of_date_user = $user_changes;
+ }
+ }
+ );
+
+ return $user_changes;
+}
+
+#************************************************************
+
+sub rdb_rerun_needed {
+ # Usage: rdb_rerun_needed( \%change_record, outside-make-loop )
+ # Rule context assumed.
+ # Determines whether a rerun of the rule is needed.
+ # Return value is whether a rerun is needed.
+ #
+ # Report diagnostics (reasons for remake) in the hash referenced by the
+ # first argument (the hash maps kinds of reason to refs to arrays).
+ #
+ # If second argument is true, use rerun criterion suitable to e.g.,
+ # initial tests in rdb_make, rerun test in
+ # make_preview_continuous. Otherwise use rerun criterion suitable for
+ # with rdb_make's looping through rules.
+ #
+ # ???!!!!
+ # Check all uses!!!!!!!!!!!!!
+
+ our ($rule, %pass);
+
+ local our $PHchanges = shift;
+ local our $outside_make_loop = shift;
+
+ # File level routine reports its results in %$PHchanges: maps kind of
+ # change to ref to array of files with that kind of change.
+ %$PHchanges = ();
+ foreach ('changed', 'changed_source_rules', 'changed_user',
+ 'disappeared_gen_other', 'disappeared_gen_this',
+ 'disappeared_user', 'no_dest', 'other', 'rules_to_apply' )
+ { $$PHchanges{$_} = []; }
+
+ my $rerun_needed = $$Pout_of_date;
+ if ($rerun_needed) {
+ push @{$$PHchanges{other}},
+ "Rerun of '$rule' forced or previously required";
+ goto rdb_rerun_needed_CLEAN_UP;
+ }
+
+ my $user_deleted_is_changed =
+ ( ($user_deleted_file_treated_as_changed == 1)
+ && (! $preview_continuous_mode)
+ )
+ || ($user_deleted_file_treated_as_changed == 2);
+
$$Pcheck_time = time();
local $dest_mtime = 0;
$dest_mtime = get_mtime($$Pdest) if ($$Pdest);
+
rdb_do_files( \&rdb_file_change1);
- while ( my ($s_rule, $l_pass) = each %$PHsource_rules ) {
- # %$PHsource_rules is about rules on which the current rule
- # depends, but for which this dependence is not determined by
- # the source rules of the set of known source files.
- # Use pass-count criterion to determine out-of-dateness for these.
- #
- if ( defined $pass{$s_rule}
- && ($pass{$s_rule} > $l_pass)
- )
- {
- $changed_rules{$s_rule} = $rule;
- $$Pout_of_date = 1;
+ if (! $outside_make_loop) {
+ while ( my ($s_rule, $l_pass) = each %$PHsource_rules ) {
+ # %$PHsource_rules is about rules on which the current rule
+ # depends, but for which this dependence is not determined by
+ # the source rules of the set of known source files.
+ # Use pass-count criterion to determine out-of-dateness for these.
+ #
+ if ( defined $pass{$s_rule}
+ && ($pass{$s_rule} > $l_pass)
+ )
+ {
+ push @{$$PHchanges{changed_source_rules}}, $s_rule;
+ $rerun_needed = 1;
+ }
}
}
- if ($$Pout_of_date) {
- push @rules_to_apply, $rule;
+
+ # ???!!!: Comments about disappeared files.
+ # Relevant situations I know of:
+ # a. \input (or c.) of a file, and file deleted. No other version.
+ # b. Like a., but file of the correct name exists in
+ # source-file-search path; the earlier source file version may for
+ # example have been an override for a standard file.
+ # c. There's a chain of input-if-file-exists cases, where the first
+ # file found in a list of files is used. Then deleting the file
+ # found on the previous run merely results in the next run using
+ # the next file in the list (if there is one, else the situation
+ # is as at a..
+ # d. File was deleted, either by user or automatically by something,
+ # and the file can be regenerated. (Note: If an aux or bbl file
+ # (etc) persistently causes errors, then after correcting, e.g., a
+ # relevant .tex file, then a clean rerun can be triggered by
+ # deleting the offending file.)
+ # Need tests: Has the file a from rule? If so it can be made, and
+ # current rule shouldn't be rerun now.
+ # **But** it's different if the rule that makes in
+ # Is the file the main source file? If so problems will
+ # normally happen when trying to run rule.
+ # Can the file be found by kpsewhich? If so, is it the
+ # main source of the rule?
+ # Need to mention missing files at end of run.
+
+ foreach my $kind (keys %$PHchanges) {
+ if (($kind eq 'disappeared_user') && !$user_deleted_is_changed)
+ { #???!!! Delete entry, as it is no longer a reason for rerun.
+ $$PHchanges{$kind} = [];
+ }
+ elsif ($kind eq 'disappeared_gen_other') {
+ # It's the generating rule of the file that needs to be run,
+ # not this rule, to remake the missing file. So we should not
+ # set the current rule to be rerun. A rerun of the current rule
+ # will be triggered once the file-generating rule has generates
+ # the file, unless, of course, the generated file is identical
+ # to the version that got deleted.
+ # ????!!! should the disappeared_gen_other item in the hash be
+ # emptied out?
+ }
+ elsif ( @{$$PHchanges{$kind}} ) {
+ $rerun_needed = 1;
+ }
}
-} #END rdb_flag_changes_here
+ # Non-source-file-change reasons for rerun:
+ if ( ( ($$Prun_time == 0) || ( $$Plast_result == -1 ) )
+ && ( $$Pcmd_type eq 'primary' ) )
+ {
+ # Never run. Only use this test with primary, so we can get
+ # dependency information, which is essential to latexmk's
+ # functioning. Other rules: there appears to be danger
+ # of, e.g., rerunning many cusdeps when their destinations have
+ # already been made and we used time criterion for deciding whether
+ # to run the rule.
+ push @{$$PHchanges{never_run}}, $rule;
+ $rerun_needed = $rule;
+ }
+ if ( $$Pdest && (! -e $$Pdest) && ( $$Plast_result <= 0 ) ) {
+ # No dest. But not if last run gave error, for then we should not
+ # rerun rule until there's a change in source file(s), which
+ # presumably contain the cause of the error.
+ # But there are other reasons for not rerunning:
+ if ( $$Psource && (! -e $$Psource)
+ && ( $$Pcmd_type ne 'primary' )
+ ) {
+ # Main source file doesn't exist, and rule is NOT primary.
+ # No action, since a run is pointless. Primary is different:
+ # file might be found elsewhere (by kpsearch from *latex),
+ # while non-existence of main source file is a clear error.
+ }
+ elsif ( $$Pcmd_type eq 'delegated' ) {
+ # Delegate to destination rule
+ }
+ else {
+ $rerun_needed = 1;
+ push @{$$PHchanges{no_dest}}, $rule;
+ }
+ }
+
+ rdb_rerun_needed_CLEAN_UP:
+ foreach my $file ( @{$$PHchanges{changed}} ) {
+ if ( ! $from_rules{$file} ) {
+ push @{$$PHchanges{changed_user}}, $file;
+ }
+ }
+ $$Pno_history = 0; # See comments in definition of %rule_db.
+ if ($rerun_needed) {
+ $$Pout_of_date = 1;
+ push @{$$PHchanges{rules_to_apply}}, $rule;
+ if (@{$$PHchanges{changed_user}}) {$$Pout_of_date_user = 1;}
+ }
+ return $rerun_needed;
+} #END rdb_rerun_needed
+
#************************************************************
sub rdb_file_change1 {
@@ -8483,109 +9235,135 @@
# Call: &rdb_file_change1
# Assumes rule and file context. Assumes $dest_mtime set.
# Flag whether $file in $rule has changed or disappeared.
- # Set rule's make flag if there's a change.
+ our ($rule, $file, $PHchanges);
- my $check_time_argument = 0;
- if (! $ignore_run_time ) {
- $check_time_argument = max( $$Pcheck_time, $$Prun_time );
+ my $check_time_argument =
+ ($outside_make_loop ? 0 : max($$Pcheck_time, $$Prun_time) );
+
+
+ # For files that won't be read until after they are written, ignore any changes:
+ if (exists $$PHrewritten_before_read{$file}) {
+ return;
}
my ($new_time, $new_size, $new_md5) = fdb_get($file, $check_time_argument );
my $ext_no_period = ext_no_period( $file );
- my $generated = exists $from_rules{$file};
- if ( ($new_size < 0) && ($$Psize >= 0) ) {
- # print "Disappeared '$file' in '$rule'\n";
- push @disappeared, $file;
- # No reaction is good.
- #$$Pout_of_date = 1;
- # ??? 1 Sep. 2008: I do NOT think so, for cusdep no-file-exists issue
- # ??? 30 Sep 2008: I think I have this fixed. There were other changes
- # needed. No-change-flagged is correct. The array @disappeared flags
- # files that have disappeared, if I need to know. But having a source
- # file disappear is not a reason for a remake unless I know how to
- # make the file. If the file is a destination of a rule, that rule
- # will be rerun. It may be that the user is changing another source
- # in such a way that the disappeared file won't be needed. Before the
- # change is applied we get a superfluous infinite loop.
- return;
+
+ my $generated = 0;
+ if (exists $from_rules{$file}) {
+ if ($from_rules{$file} eq $rule) { $generated = 1; }
+ else { $generated = 2; }
}
+
if ( ($new_size < 0) && ($$Psize < 0) ) {
return;
}
- # Primarily use md5 signature to determine whether file contents have
- # changed.
+
+ if ( ($new_size < 0) && ($$Psize >= 0) ) {
+ if ($generated == 2) {
+ # Non-existent file generated by another rule. It's up to that
+ # rule to remake it.
+ push @{$$PHchanges{disappeared_gen_other}}, $file;
+ }
+ elsif ($generated == 1) {
+ # Non-existent file generated by this rule.
+ push @{$$PHchanges{disappeared_gen_this}}, $file;
+ }
+ # ???!!! Keep this, or only for primary, or not?
+# elsif ( my @kpse = kpsewhich( $file ) ) {
+# print "After '$file' disappeared for '$rule', kpsewhich found it at\n:",
+# " '$kpse[0]'.\n";
+# push @{$$PHchanges{changed}}, $file;
+# }
+ else {
+ push @{$$PHchanges{disappeared_user}}, $file;
+ }
+ }
+ # For other kinds of file change, primarily use md5 signature to
+ # determine whether file contents have changed.
# Backup by file size change, but only in the case where there is
- # no pattern of lines to ignore in testing for a change
- if ( ($new_md5 ne $$Pmd5)
- || (
- (! exists $hash_calc_ignore_pattern{$ext_no_period})
- && ($new_size != $$Psize)
+ # no pattern of lines to ignore in testing for a change
+ elsif ( ($new_md5 ne $$Pmd5)
+ || (
+ (! exists $hash_calc_ignore_pattern{$ext_no_period})
+ && ($new_size != $$Psize)
)
) {
- push @changed, $file;
- $$Pout_of_date = 1;
- if ( ! $generated ) {
- push @changed_user, $file;
- $$Pout_of_date_user = 1;
- }
+ push @{$$PHchanges{changed}}, $file;
}
elsif ( $new_time != $$Ptime ) {
$$Ptime = $new_time;
}
- if ( ( ($$Ptest_kind == 2) || ($$Ptest_kind == 3) )
- && (! $generated)
- && ( $new_time > $dest_mtime )
- ) {
- push @changed, $file;
- $$Pout_of_date = $$Pout_of_date_user = 1;
+ # If there's no history, supplement by file-time criterion, i.e., is
+ # this source file time later than destination file file
+ if ( $$Pno_history && ( $new_time > $dest_mtime ) ) {
+ push @{$$PHchanges{changed}}, $file;
}
+
} #END rdb_file_change1
#************************************************************
-sub rdb_user_changes {
- # Argument(s): a set of top level rules.
- # Aim: Find any changed user files for those rules and all ancestors.
- # Assumption: List of source_rules for files is up-to-date.
- &rdb_clear_change_record;
- rdb_recurse( [@_], sub{ &rdb_flag_changes_here(1); } );
- if ($#changed_user >=0) { show_array( 'User changed files', @changed_user ); }
- return ($#changed_user >= 0);
-} #END rdb_user_changes
+#sub rdb_diagnose_changes {
+# # ???!!! delete after using ideas in rdb_diagnose_changes2
+# # Call: rdb_diagnose_changes or rdb_diagnose_changes( heading, show_out_of_date_rules )
+# # Precede the message by the optional heading, else by "$My_name: "
+# my ($heading, $show_out_of_date_rules) = @_;
+# our ( @changed, %changed_rules, @disappeared, @no_dest, @rules_to_apply,
+# @rules_never_run );
+#
+# if ($#rules_never_run >= 0) {
+# show_array( "${heading}Rules & subrules not known to be previously run:", @rules_never_run );
+# }
+# if ( ($#changed >= 0) || (keys %changed_rules > 0) || ($#disappeared >= 0) || ($#no_dest >= 0) ) {
+# print "${heading}File changes, etc:\n";
+# if ( $#changed >= 0 ) {
+# # ???!!! Modify to allow for case of
+# show_array( " Changed files, or newly in use/created since previous run(s):", uniqs(@changed) );
+# }
+# if ( $#disappeared >= 0 ) {
+# show_array( " No-longer-existing files:", uniqs(@disappeared) );
+# }
+# if ( $#no_dest >= 0 ) {
+# show_array( " Non-existent destination for:", uniqs(@no_dest) );
+# }
+# if ( keys %changed_rules > 0 ) {
+# print " Rule(s) that have been run and require run of dependent rule:\n";
+# while (my ($s_rule, $d_rule) = each %changed_rules) {
+# print " '$s_rule' which requires run of '$d_rule'\n";
+# }
+# }
+# }
+# if ($show_out_of_date_rules) {
+# show_array( "${heading}Overall, the following rules became out-of-date:",
+# uniqs(@rules_to_apply));
+# }
+#} #END rdb_diagnose_changes
-#************************************************************
+#----------------------------
-sub rdb_diagnose_changes {
- # Call: rdb_diagnose_changes or rdb_diagnose_changes( heading )
- # List changes on STDERR
- # Precede the message by the optional heading, else by "$My_name: "
- my $heading = defined($_[0]) ? $_[0] : "$My_name: ";
+sub rdb_diagnose_changes2 {
+ # ???!!! Examine rdb_diagnose_changes for ideas in old version to use here.
+ # Call: rdb_diagnose_changes2( \%changes, heading, show_out_of_date_rules )
- if ($#rules_never_run >= 0) {
- show_array( "${heading}Rules & subrules not known to be previously run:", @rules_never_run );
- }
- if ( ($#changed >= 0) || (keys %changed_rules > 0) || ($#disappeared >= 0) || ($#no_dest >= 0) ) {
- print "${heading}File changes, etc:\n";
- if ( $#changed >= 0 ) {
- show_array( " Changed files, or newly in use since previous run(s):", uniqs(@changed) );
+ my ($PHchanges, $heading, $show_out_of_date_rules) = @_;
+
+ my %labels = (
+ 'changed' => 'Changed files or newly in use/created',
+ );
+
+ print "$heading Reasons for rerun\n";
+ foreach my $kind (sort keys %$PHchanges) {
+ if ( (! $show_out_of_date_rules) && ($kind eq 'rules_to_apply' ) )
+ { next; }
+ my $label = $labels{$kind} || "Category '$kind'";
+ if ( @{$$PHchanges{$kind}} ) {
+ show_array( "$label:",
+ uniqs( @{$$PHchanges{$kind}} ) );
}
- if ( $#disappeared >= 0 ) {
- show_array( " No-longer-existing files:", uniqs(@disappeared) );
- }
- if ( $#no_dest >= 0 ) {
- show_array( " Non-existent destination files:", uniqs(@no_dest) );
- }
- if ( keys %changed_rules > 0 ) {
- print " Rule(s) that have been run and require run of dependent rule:\n";
- while (my ($s_rule, $d_rule) = each %changed_rules) {
- print " '$s_rule' which requires run of '$d_rule'\n";
- }
- }
}
- show_array( "${heading}The following rules & subrules became out-of-date:",
- @rules_to_apply);
-} #END rdb_diagnose_changes
+ print "\n";
+} #END rdb_diagnose_changes2
-
#************************************************************
#************************************************************
#************************************************************
@@ -8829,8 +9607,8 @@
local ( $rule, $rule_act1, $file_act, $rule_act2 ) = @_;
if ( (! $rule) || ! rdb_rule_exists($rule) ) { return; }
- local ( $PArule_data, $PHsource, $PHdest, $PHsource_rules ) = @{$rule_db{$rule}};
- local ($Pcmd_type, $Pext_cmd, $PAint_cmd, $Ptest_kind,
+ local ( $PArule_data, $PHsource, $PHdest, $PHrewritten_before_read, $PHsource_rules ) = @{$rule_db{$rule}};
+ local ($Pcmd_type, $Pext_cmd, $PAint_cmd, $Pno_history,
$Psource, $Pdest, $Pbase,
$Pout_of_date, $Pout_of_date_user, $Prun_time, $Pcheck_time,
$Pchanged,
@@ -8928,7 +9706,8 @@
#************************************************************
sub rdb_create_rule {
- # rdb_create_rule( rule, command_type, ext_cmd, int_cmd, test_kind,
+ # ???!!! OUT OF DATE. PLACE HOLDER for what was test_kind
+ # rdb_create_rule( rule, command_type, ext_cmd, int_cmd, DUMMY,
# source, dest, base,
# needs_making, run_time, check_time, set_file_not_exists,
# ref_to_array_of_specs_of_extra_generated_files )
@@ -8939,9 +9718,15 @@
# Omitted arguments: replaced by 0 or '' as needed.
# Rule is made active
# ==== Sets rule data ====
- my ( $rule, $cmd_type, $ext_cmd, $PAint_cmd, $test_kind,
+ my ( $rule, $cmd_type, $ext_cmd, $PAint_cmd, $DUMMY,
$source, $dest, $base,
- $needs_making, $run_time, $check_time, $set_file_not_exists, $extra_gen ) = @_;
+ $needs_making, $run_time, $check_time, $set_file_not_exists,
+ $extra_gen ) = @_;
+ foreach ( $needs_making, $run_time, $check_time, $DUMMY ) {
+ if (! defined $_) { $_ = 0; }
+ }
+ my $last_result = -1;
+ my $no_history = ($run_time <= 0);
my $active = 1;
my $changed = 0;
@@ -8959,13 +9744,6 @@
" '$base'\n",
" I cannot handle this. Cause is probably a latexmk bug. Please report it.\n";
}
- foreach ( $needs_making, $run_time, $check_time, $test_kind ) {
- if (! defined $_) { $_ = 0; }
- }
- if (!defined $test_kind) {
- # Default to test on file change
- $test_kind = 1;
- }
if ( ref( $PAint_cmd ) eq '' ) {
# It is a single command. Convert to array reference:
$PAint_cmd = [ $PAint_cmd ];
@@ -8979,12 +9757,13 @@
@$PA_extra_gen = @$extra_gen;
}
$rule_db{$rule} =
- [ [$cmd_type, $ext_cmd, $PAint_cmd, $test_kind,
+ [ [$cmd_type, $ext_cmd, $PAint_cmd, $no_history,
$source, $dest, $base,
$needs_making, 0, $run_time, $check_time, $changed,
- -1, '', $PA_extra_gen ],
+ $last_result, '', $PA_extra_gen ],
{},
{},
+ {},
{}
];
if ($source) {
@@ -8999,10 +9778,12 @@
sub rdb_initialize_generated {
# Assume rule context.
-# Initialize hash of generated files
+# Initialize hashes of generated files, and of files rewritten before read
%$PHdest = ();
if ($$Pdest) { rdb_add_generated($$Pdest); }
rdb_add_generated(@$PA_extra_gen);
+
+ %$PHrewritten_before_read = ();
} #END rdb_initialize_generated
#************************************************************
@@ -9018,6 +9799,14 @@
#************************************************************
+sub rdb_add_rewritten_before_read {
+# Assume rule context.
+# Add arguments to hash of files rewritten before being read
+ foreach (@_) { $$PHrewritten_before_read{$_} = 1; }
+} #END rdb_add_rewritten_before_read
+
+#************************************************************
+
sub rdb_remove_generated {
# Assume rule context.
# Remove arguments from hash of generated files
@@ -9026,6 +9815,14 @@
#************************************************************
+sub rdb_remove_rewritten_before_read {
+# Assume rule context.
+# Remove arguments from hash of files rewritten before being read
+ foreach (@_) { delete $$PHrewritten_before_read{$_}; }
+} #END rdb_add_rewritten_before_read
+
+#************************************************************
+
sub rdb_ensure_file {
# rdb_ensure_file( rule, file[, fromrule[, set_not_exists]] )
# Ensures the source file item exists in the given rule.
@@ -9140,15 +9937,10 @@
#************************************************************
sub rdb_update_gen_files {
- # Assumes rule context. Update source files of rule to current state.
+ # Assumes rule context. Update source files of rule to current state,
+ # but only for source files that are generated by this or another rule.
rdb_do_files(
- sub{
- if ( exists $generated_exts{ ext_no_period($file) }
- || exists $$PHdest{$file}
- ) {
- &rdb_update1;
- }
- }
+ sub{ if ( exists $from_rules{$file} ) { &rdb_update1; } }
);
} #END rdb_update_gen_files
@@ -9156,7 +9948,7 @@
sub rdb_update_files {
# Call: rdb_update_files
- # Assumes rule context. Update source files of rule to current state.
+ # Assumes rule context. Update all source files of rule to current state.
rdb_do_files( \&rdb_update1 );
}
@@ -9201,7 +9993,15 @@
# primary run) doesn't exist.
# It is assumed that the resulting file will be read by the
# primary run.
+ # N.B.
+ # The subroutine is not used by latexmk itself. It is here to support
+ # a need in TeXShop's pdflatexmk engine as the subroutine for a cusdep
+ # to work with the epspdf package.
+ print "I am delegating making of '$$Pdest' to *latex (e.g., by epspdf).\n",
+ " So I'll delete '$$Pdest' to flag it needs to be remade,\n",
+ " and flagging the rules using it to be rerun\n"
+ if (!$silent);
# Remove the destination file, to indicate it needs to be remade:
unlink_or_move( $$Pdest );
# Arrange that the non-existent destination file is not treated as
@@ -9225,7 +10025,7 @@
# primary run.
local $cus_dep_target = $$Pdest;
- # Loop over all rules and source files:
+ # Loop over all active rules and source files:
rdb_for_actives( 0,
sub { if ($file eq $cus_dep_target) {
$$Pout_of_date = 1;
@@ -9266,7 +10066,7 @@
#************************************************************
sub show_hash {
- my ($msg, $PH ) = @_;
+ my ($msg, $PH) = @_;
print "$msg\n";
if (! %$PH ) {
print " NONE\n";
@@ -9325,6 +10125,37 @@
#************************************************************
+sub analyze_string {
+ # Show information about string: utf8 flag or not, length(s!), byte content
+ my ($m,$s) = @_;
+
+ print "=== $m ";
+ my $length = length($s);
+ if (utf8::is_utf8($s)) {
+ my $encoded = encode( $CS_system, $s, Encode::FB_WARN | Encode::LEAVE_SRC );
+ my $len_chars = 0;
+ my $len_bytes = 0;
+ { no bytes; $len_chars = length($s); }
+ { use bytes; $len_bytes = length($s); }
+ print "'$encoded':\n",
+ "utf8, len = $length; chars = $len_chars; bytes = $len_bytes\n";
+ }
+ else {
+ print "'$s':\n",
+ "NOT utf8, len = $length\n";
+ }
+
+ print join ' ', to_hex($s), "\n";
+}
+
+#----------------------------
+
+sub to_hex {
+ return map { sprintf('%4X', $_) } unpack( 'U*', shift );
+}
+
+#==================
+
sub glob_list1 {
# Glob a collection of filenames.
# But no sorting or elimination of duplicates
@@ -9451,9 +10282,10 @@
sub get_time_size {
# Return time and size of file named in argument
# If file does not exist, return (0,-1);
- # Argument _ to stat: use values from previous call, to save disk access..
- return ( ( ( stat($_[0]) )[9] || 0 ),
- ( ( stat(_) )[7] || -1 ) );
+ # Argument _ to stat: use values from previous call, to save disk access.
+ my @result = stat($_[0]);
+ if (@result) { return ($result[9], $result[7]); }
+ else { return (0,-1); }
}
#************************************************************
@@ -9471,7 +10303,6 @@
my $md5 = Digest::MD5->new;
my $ignore_pattern = undef;
-#print "======= GETTING MD5: $source\n";
if ( -d $source ) {
# We won't use checksum for directory
return 0;
@@ -9513,89 +10344,58 @@
#************************************************************
#************************************************************
-sub find_file1 {
- # Usage: find_file1(name, ref_to_array_search_path)
- # Modified find_file, which doesn't die.
- # Given filename and path, return array of:
- # full name
- # retcode
- # On success: full_name = full name with path, retcode = 0
- # On failure: full_name = given name, retcode = 1
+sub find_files {
+ # Usage: find_files( \%files, format, default_ext, \@files, \@not_found )
+ # ???!!! This may be too elaborate. The hash is there to have all the
+ # necessary information, but I don't actually use it.
+ # The files hash, referred to by the 1st argument, has as its keys
+ # specified file names, as specified for example in \bibliography.
+ # The values are to be the names of the corresponding actual files,
+ # as found by kpsewhich, or '' if kpsewhich doesn't find a file.
+ # The format is used in a -format=... option to kpsewhich, e.g., 'bib'
+ # for bib files, 'bst' for bst files.
+ # The 3rd argument contains the default extension to use for not-found files.
+ # The array @files, referred to by the 4th argument, contains the
+ # sorted names of the found files, and then the specifications of the
+ # not-found files.
+ # But
+ # The array @not_found, referred to by the 5th argument, contains the
+ # sorted names of the specified names for the not-found files.
+ # The value of each item in the hash is set to the found filename
+ # corresponding to the key, if a file is found; otherwise it is set to
+ # the empty string.
+ # Return number of files not found.
+ #
+ # ???!!! Ideally use only 1 call to kpsewhich. But KISS for now. The
+ # main use of this subroutine is for bib, bst files (and maybe index
+ # files), which are few in number. Only likely conceivable case for
+ # having many files is with a big document, for which *latex running
+ # time is large, so almost certainly that dwarfs run time for several
+ # runs of kpsewhich.
- my $name = $_[0];
- # Make local copy of path, since we may rewrite it!
- my @path = ();
- if ($_[1]) {
- @path = @{$_[1]};
- }
- if ( $name =~ /^\// ) {
- # Absolute path (if under UNIX)
- # This needs fixing, in general
- if (-e $name) { return( $name, 0 );}
- else { return( $name, 1 );}
- }
- foreach my $dir ( @path ) {
- # Make $dir concatenatable, and empty for current dir:
- if ( $dir eq '.' ) {
- $dir = '';
+ my ($PHfiles, $format, $ext, $PAfiles, $PAnot_found) = @_;
+ @$PAfiles = @$PAnot_found = ();
+ foreach my $name (keys %$PHfiles) {
+ if (my @lines = kpsewhich( "-format=$format", $name ) ) {
+ $$PHfiles{$name} = $lines[0];
+ push @$PAfiles, $lines[0];
}
- elsif ( $dir =~ /[\/\\:]$/ ) {
- #OK if dir ends in / or \ or :
+ else {
+ $$PHfiles{$name} = '';
+ push @$PAnot_found, $name;
}
- elsif ( $dir ne '' ) {
- #Append directory separator only to non-empty dir
- $dir = "$dir/";
- }
- if (-e "$dir$name") {
- return("$dir$name", 0);
- }
}
- my @kpse_result = kpsewhich( $name );
- if ($#kpse_result > -1) {
- return( $kpse_result[0], 0);
+ @$PAnot_found = sort @$PAnot_found;
+ @$PAfiles = sort @$PAfiles;
+ foreach (@$PAnot_found) {
+ if ( ! /\..*$/ ) { $_ .= ".$ext"; }
+ push @$PAfiles, $_;
}
- return("$name" , 1);
-} #END find_file1
+
+ return 1 + $#{$PAnot_found};
+} #END find_files
#************************************************************
-
-sub find_file_list1 {
- # Modified version of find_file_list that doesn't die.
- # Given output and input arrays of filenames, a file suffix, and a path,
- # fill the output array with full filenames
- # Return array of not-found files.
- # Usage: find_file_list1( ref_to_output_file_array,
- # ref_to_input_file_array,
- # suffix,
- # ref_to_array_search_path
- # )
- # SPECIAL TREATMENT TO .bib extension, because of behavior of bibtex
- # OTHER SPECIAL TREATMENT IF EXTENSION IS GIVEN.
-
- my $ref_output = $_[0];
- my $ref_input = $_[1];
- my $suffix = $_[2];
- my $ref_search = $_[3];
- my @not_found = ();
-
- my @return_list = (); # Generate list in local array, since input
- # and output arrays may be same
- my $retcode = 0;
- foreach my $file1 (@$ref_input) {
- my $file = $file1;
- if ($suffix eq '.bib') { $file =~ s/\.bib$//; }
- my ($tmp_file, $find_retcode) = &find_file1( "$file$suffix", $ref_search );
- if ($tmp_file) {
- push @return_list, $tmp_file;
- }
- if ( $find_retcode != 0 ) {
- push @not_found, $file.$suffix;
- }
- }
- @$ref_output = @return_list;
- return @not_found;
-} #END find_file_list1
-
#************************************************************
sub unlink_or_move {
@@ -9662,13 +10462,20 @@
#************************************************************
sub kpsewhich {
-# Usage: kpsewhich( filespec, ...)
-# Returns array of files with paths as found by kpsewhich
-# kpsewhich( 'try.sty', 'jcc.bib' );
-# With standard use of kpsewhich (i.e., without -all option), the array
-# has either 0 or 1 element.
-# Can also do, e.g.,
-# kpsewhich( '-format=bib', 'trial.bib', 'file with spaces');
+ # Usage: kpsewhich( [options, ] filespec, ...)
+ # The arguments are the command line arguments to kpsewhich, and the
+ # return value is the array of filenames that are returned by
+ # kpsewhich.
+ # N.B. kpsewhich returns one line per found file; this routine removes
+ # trailing line ends (\r\n or \n) before putting the line in the
+ # returned array.
+ # The arguments can just be names: e.g.,
+ # kpsewhich( 'try.sty', 'jcc.bib' );
+ # or can include options, e.g.,
+ # kpsewhich( '-format=bib', 'trial.bib', 'file with spaces');
+ # With standard use of kpsewhich (i.e., without -all option), the array
+ # has either 0 or 1 element for each filespec argument.
+
my $cmd = $kpsewhich;
my @args = @_;
if ( ($cmd eq '') || ( $cmd =~ /^NONE($| )/ ) ) {
@@ -9682,7 +10489,7 @@
}
}
$cmd =~ s/%[RBTDO]//g;
- $cmd =~ s/%S/@args/g;
+ $cmd =~ s/%S/@_/g;
my @found = ();
local $fh;
if ( $kpsewhich_show || $diagnostics ) {
@@ -9865,6 +10672,7 @@
sub find_dirs1 {
# Same as find_dirs, but argument is single string with directories
# separated by $search_path_separator
+ # ???!!! WRONG DEFAULT?
find_dirs( &split_search_path( $search_path_separator, ".", $_[0] ) );
}
@@ -10017,7 +10825,7 @@
# Usage: &split_search_path( separator, default, string )
# Splits string by separator and returns array of the elements
# Allow empty last component.
-# Replace empty terms by the default.
+ # Replace empty terms by the default. ???!!! WRONG DEFAULT?
my $separator = $_[0];
my $default = $_[1];
my $search_path = $_[2];
More information about the tex-live-commits
mailing list.