texlive[66766] trunk: latexmk (4apr23)
commits+karl at tug.org
commits+karl at tug.org
Tue Apr 4 22:14:52 CEST 2023
Revision: 66766
http://tug.org/svn/texlive?view=revision&revision=66766
Author: karl
Date: 2023-04-04 22:14:52 +0200 (Tue, 04 Apr 2023)
Log Message:
-----------
latexmk (4apr23)
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/schultz-texshop-latexmkrc
trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/xr_latexmkrc
Removed Paths:
-------------
trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pdflatexmkrc
Modified: trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl 2023-04-04 20:14:23 UTC (rev 66765)
+++ trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl 2023-04-04 20:14:52 UTC (rev 66766)
@@ -1,43 +1,6 @@
#!/usr/bin/env perl
use warnings;
-# ???!!! TO DO 9 Aug 2022:
-# 0. RETHINK warning listing handling etc, including warnings as
-# errors, bad warnings as errors. Must systematize. Code is too split
-# up.
-# 1b. ===> In any case, check treatment of runs that give an error.
-# 2. Think generally through logic of error handling. E.g., error in
-# xelatex: should dvipdfmx be run? (Or with config. variable for the
-# post-primaries.) Currently it's run. Probably correct: viewed file,
-# if it can be made, can be useful for error diagnosis. Also:
-# consistency between direct making of pdf file and indirect.
-# But abort after error can also be useful.
-# DONE 3. Are post-primaries guaranteed to be run in correct order?
-# YES: See definition of @post_primary.
-# 4. Clean up rdb_diagnose_changes2.
-# COMMENTED OUT FOR NOW 5. Perhaps, remove use of kpsewhich in case of disappeared files?
-# 6. Review rdb_make and rdb_make1 again.
-# 7. Start in -pvc when prior run gave error: There's an error report after
-# the first make. Same outside -pvc if have error run, then run
-# latexmk; it reports error from previous run.
-# 9, Re %pass and rdb_rerun_needed: Perhaps remove outside_make_loop, and
-# have separate subroutine for use by make_preview_continuous, and
-# standard rdb_rerun_needed calls it and then does its source_rule
-# stuff.
-# 10. Do I need to make rdb_user_changes better?
-#
-# OK 12. Is classification of post_primary watertight? They are intended to
-# be outside any loop. Start with target files, and call encountered
-# rules post_primary until a primary is encountered. That assumes that
-# on the pathway to target from primary, source files are not generated
-# by non-primary rules.
-# There's no requirement for post_primaries to be outside dependency
-# loops. The make algorithm handles that. All that matters is that this
-# commonly so, and therefore we are doing an appropriate ordering of
-# examination of rules, by pre-primary, primary, post-primary.
-# Post-primaries always have primary as a prerequisite for the source
-# files.
-
## Copyright John Collins 1998-2023
## (username jcc8 at node psu.edu)
## (and thanks to David Coppit (username david at node coppit.org)
@@ -79,8 +42,8 @@
$my_name = 'latexmk';
$My_name = 'Latexmk';
-$version_num = '4.79';
-$version_details = "$My_name, John Collins, 7 Jan. 2023. Version $version_num";
+$version_num = '4.80';
+$version_details = "$My_name, John Collins, 4 Apr. 2023. Version $version_num";
use Config;
use File::Basename;
@@ -410,6 +373,7 @@
## will give match to line starting "No data file found `filename'"
@file_not_found = (
'^No file\\s*(.*)\\.$',
+ '^No file\\s*(.+)\s*$',
'^\\! LaTeX Error: File `([^\\\']*)\\\' not found\\.',
'^\\! I can\\\'t find file `([^\\\']*)\\\'\\.',
'.*?:\\d*: LaTeX Error: File `([^\\\']*)\\\' not found\\.',
@@ -946,7 +910,64 @@
$tmpdir = ".";
+# Latexmk does tests on whether a particular generated file, e.g., log or
+# fls, has been generated on a current run of a rule, especially *latex, or
+# is leftover from previous runs. This is done by finding whether or not
+# the modification time of the file is at least as recent as the system
+# time at the start of the run. A file with a modification time
+# significantly less than the time at the start of the run is presumably
+# left over from a previous run and not generated in the currrent run. (An
+# allowance is made in this comparison for the effects of granularity of
+# file-system times. Such granularity can make a file time a second or two
+# earlier than the system time at which the file was last modified.)
+#
+# But generated files may be on a file system hosted by a server computer
+# that is different than the computer running latexmk. There may there may
+# be an offset between the time on the two computers; this can make it
+# appear that the generated files were made before the run. Most of the
+# time, this problem does not arise, since (a) typical usage of latexmk is
+# with a local file system, and (b) current-day computers and operating
+# systems have their time synchronized accurately with a time server.
+#
+# But when latexmk sees symptoms of an excessive offset, it measures the
+# offset between the filesystem time and the system time. This involves
+# writing a temporary file, getting its modification time, and deleting
+# it. The following variables are used for this purpose.
+
+#
+our $filetime_offset_measured = 0; # Measurement not yet done.
+our $filetime_offset = 0; # Filetime relative to system time.
+our $filetime_offset_report_threshold = 10; # Threshold beyond which filetime offsets
+ # are reported; large offsets indicate
+ # incorrect system time on at least one system.
+# The following variable gives the threshold for detection of left-over
+# file. It allows for (a) different granularity between system time and
+# filesystem time, (b) for some mismatch between file and system time.
+# Note that the making or not making of a file is controlled by the
+# state of the document being compiled and by latexmk's configuration.
+# So a file that is left over from a previous run and not overwritten
+# on the current run will have a file time at least many seconds less
+# than the current time, corresponding to the time scale for a human
+# run-edit-run cycle.
+#
+# Note that the making or not making of a file is controlled by the
+# state of the document being compiled and by latexmk's configuration.
+# So a file that is left over from a previous run and not overwritten
+# on the current run will have a file time at least many seconds less
+# than the current time, corresponding to the time scale for a human
+# run-edit-run cycle. So one does NOT have to tune this variable
+# precisely.
+#
+# Concerning granularity of file system
+# FAT file system: 2 sec granularity. Others 1 sec or less.
+# Perl CORE's mtime in stat: 1 sec.
+# Perl CORE's time(): 1 sec. Time::HiRes::time(): Much less than 1 sec.
+
+our $filetime_causality_threshold = 5;
+
+
################################################################
+################################################################
# System-dependent overrides:
@@ -1387,6 +1408,11 @@
# (as with 'gcc -MP').
$deps_file = '-'; # File for dependency list output. Default stdout.
$rules_list = 0; # Whether to display list(s) of dependencies
+# Kind of escaping in names of files written to deps file.
+$deps_escape = 'none';
+# Allowed kinds of escape:
+%deps_escape_kinds = ( 'none' => ' ', 'unix' => '\ ', 'nmake' => '^ ');
+
@dir_stack = (); # Stack of pushed directories, each of form of
# pointer to array [ cwd, good_cwd ], where
# good_cwd differs from cwd by being converted
@@ -1431,14 +1457,7 @@
# appears not to included subprocess times, so we use clock time instead.
our $times_are_clock = ($^O eq "MSWin32" );
-# Allowance for different granularity in time since Epoch and file mtime.
-# Needed in testing whether a file was generated during a run of a program.
-# FAT file system: 2 sec granularity. Others 1 sec or less.
-# Perl CORE's mtime in stat: 1 sec.
-# Perl CORE's time(): 1 sec. Time::HiRes::time(): Much less than 1 sec.
-our $filetime_slop = 2;
-
# Data for 1 run and global (ending in '0'):
our ( $processing_time1, $processing_time0, @timings1, @timings0);
&init_timing_all;
@@ -1650,7 +1669,7 @@
# out_of_date, out_of_date_user,
# time_of_last_run, time_of_last_file_check,
# changed
- # last_result, last_message,
+ # last_result, last_result_info, last_message,
# default_extra_generated,
# ]
# where
@@ -1727,6 +1746,19 @@
# important enough to be reported with
# the error summary. The warning
# message is stored in last_message.
+ # last_result_info is info about run that gave
+ # code in last_result. Currently used values:
+ # '' No record of this rule being run
+ # 'CURR' Run of rule was in current
+ # round of compilation.
+ # 'PREV' Run of rule was in a previous
+ # round of compilation (as with
+ # -pvc), but in current invocation
+ # of latexmk.
+ # 'CACHE' Run of rule was in a previous
+ # invocation of latexmk, with
+ # last_result having been read
+ # from fdb_latexmk file.
# last_message is error message for last run
# default_extra_generated is a reference to an array
# of specifications of extra generated files (beyond
@@ -1950,8 +1982,7 @@
@command_line_file_list = ();
$bad_options = 0;
-while ($_ = $ARGV[0])
-{
+while (defined($_ = $ARGV[0])) {
# Make -- and - equivalent at beginning of option,
# but save original for possible use in *latex command line
$original = $_;
@@ -1976,6 +2007,12 @@
elsif (/^-d$/) { $banner = 1; }
elsif (/^-dependents$/ || /^-deps$/ || /^-M$/ ) { $dependents_list = 1; }
elsif (/^-nodependents$/ || /^-dependents-$/ || /^-deps-$/) { $dependents_list = 0; }
+ elsif (/^-deps-escape=(.*)$/) {
+ if ( $deps_escape_kinds{$1} ) { $deps_escape = $1; }
+ else { warn "$My_name: In '$_', kind of escape is not one of those I know, which are\n",
+ " ", join( ' ', sort( keys %deps_escape_kinds )), "\n";
+ }
+ }
elsif (/^-deps-out=(.*)$/) {
$deps_file = $1;
$dependents_list = 1;
@@ -2758,8 +2795,7 @@
# assisted by dependency information from log files about previous
# run, if the log file exists.
- if ( $cleanup_mode ) { &do_small_cleanup; }
- if ( $cleanup_mode == 1 ) { &do_extra_cleanup; }
+ if ( $cleanup_mode ) { do_cleanup( $cleanup_mode ); }
if ($cleanup_only) { next FILE; }
if ( ! -e $aux_main ) {
@@ -2877,6 +2913,27 @@
&finish_dir_stack;
}
+if ($filetime_offset_measured) {
+ if ( (abs($filetime_offset) >= $filetime_offset_report_threshold)
+ && ($diagnostics || ! $silent) )
+ {
+ warn "$My_name: I am working around an offset relative to my system time by\n",
+ " $filetime_offset secs for file times in directory '$aux_dir1'.\n",
+ " This **probably** indicates that \n",
+ " (a) I ($my_name) am running on one computer, while the filesystem is\n",
+ " hosted on a different computer/\n",
+ " (b) There is a substantial time offset between system times on the two\n",
+ " computers.\n",
+ " (c) Therefore at least one of the computers has a misconfigured operating\n",
+ " system such that its system time is not correctly synchronized with a\n",
+ " time server.\n",
+ " These issues are likely to cause problems with other software, and any\n",
+ " such operating-system misconfigurations should be corrected. By default\n",
+ " current operating systems are configured to correctly synchronize system\n",
+ " time when they are connected to the Internet\n";
+ }
+}
+
if ($failure_count > 0) {
if ( $#file_list > 0 ) {
# Error occured, but multiple files were processed, so
@@ -2961,9 +3018,13 @@
sub set_tex_cmds {
# Usage, e.g., set_tex_cmds( '%O %S' )
+ # or set_tex_cmds( '%C-dev %O %S' )
my $args = $_[0];
foreach my $cmd ( keys %possible_primaries ) {
- ${$cmd} = "$cmd $args";
+ my $spec = $args;
+ if ( $spec =~ /%C/ ) { $spec =~ s/%C/$cmd/g; }
+ else { $spec = "$cmd $args"; }
+ ${$cmd} = $spec;
}
# N.B. See setting of $latex_default_switches, ...,
# $xelatex_default_switches, etc, for any special options needed.
@@ -3646,17 +3707,65 @@
#************************************************************
#************************************************************
-sub do_extra_cleanup {
- print "$My_name: Doing extra clean up (of final output files) for '$texfile_name'\n"
- if ! $silent;
- cleanup1( $aux_dir1, @final_output_exts );
- if ( $out_dir1 ne $aux_dir1 ) { cleanup1( $out_dir1, @final_output_exts ); }
-} # END do_extra_cleanup
+sub do_cleanup {
+ my $kind = $_[0];
+ if (! $kind ) { return; }
+ my @files_to_delete = ();
+ @dirs = ($aux_dir1);
+ if ($out_dir1 ne $aux_dir1) { push @dirs, $out_dir1; }
+
+ push @files_to_delete, &get_small_cleanup;
+ if ($kind == 1) {
+ foreach my $dir1 (@dirs) {
+ push @files_to_delete, cleanup_get1( $dir1, @final_output_exts );
+ }
+ }
+ # show_array( "Files to delete", sort @files_to_delete );
-#************************************************************
+ # Names of contents of directory are longer than the name of the directory,
+ # but contain the directory name as an initial segment.
+ # Therefore deleting files and directories in the order given by reverse
+ # sort deletes contents of directory before attempting to delete the
+ # directory:
+ unlink_or_move( reverse sort @files_to_delete );
+
+ # If the fdb file (or log, fls and/or aux files) exist, it/they will have
+ # been used to make a changed rule database. But a cleanup implies
+ # that we need a virgin rule database, corresponding to current state
+ # of files (after cleanup) so we reset the rule database and rule net:
+ &rdb_initialize_rules;
+}
-sub do_small_cleanup {
- # Assume dependency information from previous run has been obtained.
+#----------------------------------------
+
+sub cleanup_get1 {
+ # Usage: cleanup_get1( directory, patterns_or_exts_without_period, ... )
+ # Return array of files obeying the specification in the given directory.
+ # Specifications are either extensions to be appended to root_filename
+ # or are patterns containing %R for root_filename of job, with possible
+ # wildcards.
+ # Directory name must include directory separator, e.g., './' or 'output/',
+ # or be blank, i.e., suitable for prepending to file name.
+
+ # The directory and the root file name are fixed names, so I must escape
+ # any glob metacharacters in them:
+ my $dir = fix_pattern( shift );
+ my $root_fixed = fix_pattern( $root_filename );
+ my @files = ();
+ foreach (@_) {
+ my $name = ( /%R/ ? $_ : "%R.$_" );
+ $name =~ s/%R/${root_fixed}/;
+ $name = $dir.$name;
+ push @files, my_glob( "$name" );
+ }
+ return @files;
+} #END cleanup_get1
+
+#----------------------------------------
+
+sub get_small_cleanup {
+ # Get list of files to be deleted in a small cleanup.
+ # Assume dependency information from previous run has been obtained.
my %other_generated = ();
my %cusdep_generated = ();
my @index_bibtex_generated = ();
@@ -3759,32 +3868,22 @@
}
my @clean_args = keys %generated_exts;
- cleanup1( $aux_dir1, @clean_args );
- if ( $out_dir1 ne $aux_dir1 ) { cleanup1( $out_dir1, @clean_args ); }
+ push @files, cleanup_get1( $aux_dir1, @clean_args );
+ if ( $out_dir1 ne $aux_dir1 ) { push @files, cleanup_get1( $out_dir1, @clean_args ); }
- my @specific_deletions = @std_small_cleanup_files;
+ push @files, @std_small_cleanup_files;
foreach my $file (@std_small_cleanup_files) {
foreach my $dir ($aux_dir1, $out_dir1 ) {
- if ($dir) { push @specific_deletions, "$dir$file"; }
+ if ($dir) { push @files, "$dir$file"; }
}
}
- unlink_or_move( @specific_deletions,
- keys %index_bibtex_generated,
- keys %aux_files );
+ push @files, keys %index_bibtex_generated, keys %aux_files;
- if ($cleanup_includes_generated) {
- unlink_or_move( keys %other_generated );
- }
- if ( $cleanup_includes_cusdep_generated) {
- unlink_or_move( keys %cusdep_generated );
- }
- unlink_or_move( $fdb_name );
- # If the fdb file (or log, fls and/or aux files), it/they will have been
- # used to make a changed rule database. But a cleanup implies that we
- # need a virgin rule database, corresponding to current state of files,
- # so we reset the rule database and net:
- &rdb_initialize_rules;
-} # END do_small_cleanup
+ if ($cleanup_includes_generated) { push @files, keys %other_generated; }
+ if ( $cleanup_includes_cusdep_generated) { push @files, keys %cusdep_generated; }
+ push @files, $fdb_name;
+ return @files;
+} # END get_small_cleanup
#************************************************************
@@ -4211,6 +4310,14 @@
$have_break = 0;
$last_action_time = time();
$waiting = 1;
+ rdb_for_some(
+ [keys %rule_db],
+ sub{
+ if ($$Plast_result_info eq 'CURR') {
+ $$Plast_result_info = 'PREV';
+ }
+ }
+ );
print "\n=== Watching for updated files. Use ctrl/C to stop ...\n";
WAIT: while (1) {
sleep( $sleep_time );
@@ -4369,23 +4476,6 @@
#************************************************************
-sub cleanup1 {
- # Usage: cleanup1( directory, exts_without_period, ... )
- #
- # The directory and the root file name are fixed names, so I must escape
- # any glob metacharacters in them:
- my $dir = fix_pattern( shift );
- my $root_fixed = fix_pattern( $root_filename );
- foreach (@_) {
- my $name = /%R/ ? $_ : "%R.$_";
- $name =~ s/%R/${root_fixed}/;
- $name = $dir.$name;
- unlink_or_move( my_glob( "$name" ) );
- }
-} #END cleanup1
-
-#************************************************************
-
sub cleanup_cusdep_generated {
# Remove files generated by custom dependencies
rdb_for_actives( \&cleanup_one_cusdep_generated );
@@ -4523,6 +4613,8 @@
" -cd- - Do NOT change to directory of source file when processing it\n",
" -dependents or -deps - Show list of dependent files after processing\n",
" -dependents- or -deps- - Do not show list of dependent files\n",
+ " -deps-escape=<kind> - Set kind of escaping of spaces in names in deps file\n",
+ " (Possible values: ", join( ' ', sort keys %deps_escape_kinds ), ")\n",
" -deps-out=file - Set name of output file for dependency list,\n",
" and turn on showing of dependency list\n",
" -dF <filter> - Filter to apply to dvi file\n",
@@ -5100,15 +5192,24 @@
# Deal with situations after a *latex run where files are in different
# directories than expected (specifically aux v. output directory).
# Do minimal fix ups to allow latexmk to analyze dependencies with log
- # and fls files in expected places
+ # and fls files in expected places.
+
+
+ # Deal with log file in unexpected place (e.g., lack of support by *latex
+ # of -aux-directory option. This is to be done first, since a run of
+ # *latex always produces a log file unless there is a bad error, so
+ # this gives the best chance of diagnosing errors.
+ my $where_log = &find_set_log;
+
if ( $emulate_aux && ($aux_dir ne $out_dir) ) {
- # Move output and fls files to out_dir
+ # Move output files from aux_dir to out_dir
+ # Move fls file also, if the configuration is for fls in out_dir.
# Omit 'xdv', that goes to aux_dir (as with MiKTeX). It's not final output.
foreach my $ext ( 'fls', 'dvi', 'pdf', 'ps', 'synctex', 'synctex.gz' ) {
if ( ($ext eq 'fls') && ! $fls_uses_out_dir ) {next;}
my $from = "$aux_dir1$root_filename.$ext";
my $to = "$out_dir1$root_filename.$ext" ;
- if ( test_gen_file( $from ) ) {
+ if ( test_gen_file_time( $from ) ) {
if (! $silent) { print "$My_name: Moving '$from' to '$to'\n"; }
my $ret = move( $from, $to );
if ( ! $ret ) { die " That failed, with message '$!'\n";}
@@ -5116,10 +5217,6 @@
}
}
- # Deal with log file in unexpected place (e.g., lack of support by *latex
- # of -aux-directory option.
- &find_set_log;
-
# Fix ups on fls file:
if ($recorder) {
# Deal with following special cases:
@@ -5167,11 +5264,11 @@
# place. But only do this if the file time is compatible with being
# generated in the current run, and if the standard fls file hasn't
# been made in the current run, as tested by the use of
- # test_gen_file; that avoids problems with fls files left over from
+ # test_gen_file_time; that avoids problems with fls files left over from
# earlier runs with other versions of latex.
- if ( ! test_gen_file( $std_fls_file ) ) {
+ if ( ! test_gen_file_time ( $std_fls_file ) ) {
foreach my $cand (@other_fls_names) {
- if ( test_gen_file( $cand ) ) {
+ if ( test_gen_file_time( $cand ) ) {
print "$My_name: Copying '$cand' to '$std_fls_file'.\n";
copy $cand, $std_fls_file;
last;
@@ -5178,7 +5275,7 @@
}
}
}
- if ( ! test_gen_file( $std_fls_file ) ) {
+ if ( ! test_gen_file_time( $std_fls_file ) ) {
warn "$My_name: fls file doesn't appear to have been made.\n";
}
}
@@ -5186,37 +5283,120 @@
#-----------------
+sub find_log {
+ # Locate log file generated on this run.
+ # Side effect: measure filetime offset if necessary.
+ # Don't take other actions.
+ # Returns
+ # 0 log file not found;
+ # 1 log file in aux_dir i.e., correct place;
+ # 2 log file **not** in aux_dir but in out_dir
+ # (only applies if $emulate_aux off)
+ # 3 log file is in ., not aux_dir or out_dir.
+ # 4 log file in aux_dir, but out-of-date
+ # 5 log file in out_dir, but out-of-date,
+ # (only applies if $emulate_aux off)
+ # 6 log file is in ., but out-of-date
+
+
+ my $where_log = -1; # Nothing analyzed yet
+ my $log_aux = "$aux_dir1$root_filename.log";
+ my $log_out = "$out_dir1$root_filename.log";
+ my $log_cwd = "./$root_filename.log";
+
+ # Basic tests first that assume accuracy of time of file system:
+ if ( test_gen_file_time( $log_aux ) ) {
+ # Expected case
+ return 1;
+ }
+ elsif ( (! $emulate_aux) && test_gen_file_time( $log_out ) ) {
+ # *latex was called with -aux-directory option, but does not
+ # implement it (e.g., TeXLive's version)
+ return 2;
+ }
+ elsif ( test_gen_file_time( $log_cwd ) ) {
+ # Arrive here typically with configuration error so that aux_dir
+ # and/or out_dir aren't supplied to *latex.
+ return 3;
+ }
+
+ # Arrive here only if a log file with a time stamp not too much earlier
+ # than the run time has not found in a relevant place.
+ # If relevant files exist, then we must test for a serious offset
+ # between system time and filesystem time (i.e., filesystem server
+ # time).
+ if ( ! $filetime_offset_measured ) {
+ $filetime_offset = get_filetime_offset( $aux_dir1."tmp" );
+ $filetime_offset_measured = 1;
+ }
+
+ my @candidates = ( );
+ my $latest_mtime = undef;
+ my $latest_log = undef;
+
+ if ( -e $log_aux ) {
+ if ( test_gen_file_time( $log_aux ) ) { return 1; }
+ return 4;
+ }
+ # Get here if log file in aux doesn't exist or is apparently too old.
+ if ( (! $emulate_aux) && ( -e $log_out ) ) {
+ if (test_gen_file_time( $log_out ) ) { return 2; }
+ return 5;
+ }
+ if ( -e $log_cwd ) {
+ if (test_gen_file_time( $log_cwd ) ) { return 3; }
+ return 6;
+ }
+ return 0;
+}
+
sub find_set_log {
# Locate the log file, generated on this run.
# It should be in aux_dir. But:
- # 1. With a sufficiently severe error in *latex, no log file was generated.
- # 2. With aux_dir ne out_dir and emulate_aux off and a (TeXLive) *latex
+ # a. With aux_dir ne out_dir and emulate_aux off and a (TeXLive) *latex
# that doesn't support aux_dir, the log file is in out_dir.
- # 3. If the specified command has no %O or if *latex doesn't support
+ # b. If the specified command has no %O or if *latex doesn't support
# out_dir (hence not TeXLive and not MiKTeX), the log file would
# be in cwd.
+ # c. With a sufficiently severe error in *latex, no log file was generated.
+ # Any log file that exists will be a left over from a previous run,
+ # and hence have a filetime less than the system time at the start of
+ # the current run. (The strict filetime criterion is modified in the
+ # implementation to allow for issues from file system's time
+ # granularity, and mismatch of time on server hosting file system.)
#
- # 3 is fatal error.
- # 2 is handled by turning emulate_aux on, after which next run of *latex
- # handles problem.
- # 1 is like any other error.
- # 4 is treated like 1 (log file not found).
- #
- # Returns
+ # Possible return values, and side effects.
# 0 log file not found;
# 1 log file in aux_dir i.e., correct place;
- # 2 log file **not** in aux_dir but in out_dir,
- # emulate_aux turned on, commands fixed,
- # and log file copied to aux_dir
- # If the log file is found in cwd, report it and give fatal error.
-
- my $where_log = -1; # Nothing analyzed yet
+ # 2 log file **not** in aux_dir but in out_dir
+ # (only applies if $emulate_aux off)
+ # $emulate_aux turned on, commands fixed, log file copied to
+ # aux_dir, and flags set to cause rerun
+ # 3 log file is in ., not aux_dir or out_dir.
+ # Fatal error raised here, since cause is normally a configuration error
+ # not an error caused by contents of user file.
+ # 4 log file in aux_dir, but out-of-date
+ # 5 log file in out_dir, but out-of-date,
+ # (only applies if $emulate_aux off)
+ # 6 log file is in ., but out-of-date
+ #
+ # Cases: 0, 4, 5, 6 are error conditions to be handled by caller
+ # 2 is to be handled by caller by a rerun
+ # 1 is success.
- if ( test_gen_file( "$aux_dir1$root_filename.log" ) ) {
- # .log file is in expected place.
- $where_log = 1;
+
+ my $log_aux = "$aux_dir1$root_filename.log";
+ my $log_out = "$out_dir1$root_filename.log";
+ my $log_cwd = "./$root_filename.log";
+
+ my $where_log = &find_log;
+ my $good_log_found = 0;
+
+ if ($where_log == 1 ) {
+ # As expected
+ $good_log_found = 1;
}
- elsif ( (! $emulate_aux) && test_gen_file( "$out_dir1$root_filename.log" ) ) {
+ elsif ($where_log == 2 ) {
warn "$My_name: .log file in '$out_dir' instead of expected '$aux_dir'\n",
" But emulate_aux is off. So I'll turn it on.\n",
" I'll copy the log file to the correct place.\n",
@@ -5231,8 +5411,9 @@
s/ -output-directory=[^ ]*(?= )//g;
s/ -aux(-directory=[^ ]*)(?= )/ -output$1/g;
}
+ $good_log_found = 1;
}
- elsif ( test_gen_file( "$root_filename.log" ) ) {
+ if ($where_log == 3 ) {
# .log file is not in out_dir nor in aux_dir, but is in cwd.
# Presumably there is a configuration error
# that prevents the directories from being used by latex.
@@ -5242,14 +5423,35 @@
" options with the *latex command.\n",
" I'll stop.\n";
}
- else {
- # No .log file found
+ elsif ($where_log == 4 ) {
+ warn "$My_name: The expected log file, '$log_aux', does exist, but it appears\n",
+ " to be left over from a previous run: The time at the start of the\n",
+ " current run was $$Prun_time, but the log file appears to have been\n",
+ " created significantly earlier, at ", get_mtime($log_aux), ".\n";
+ }
+ elsif ($where_log == 5 ) {
+ warn "$My_name: The expected log file, '$log_aux', does not exist, but one is found\n",
+ " in '$out_dir', but it apears to be left over from a previous run. The time\n",
+ " at the start of the current run was $$Prun_time, but the log file appears to\n",
+ " have been created significantly earlier, at ", get_mtime($log_out), ".\n";
+ }
+ elsif ($where_log == 6 ) {
+ warn "$My_name: The expected log file, '$log_aux', does not exist, but one is found\n",
+ " in '.', but it apears to be left over from a previous run. The time\n",
+ " at the start of the current run was $$Prun_time, but the log file appears to\n",
+ " have been created significantly earlier, at ", get_mtime($log_cwd), ".\n";
+ }
+ elsif ($where_log == 0) {
+ warn "$My_name: No log file was found, neither the expected one, '$log_aux', nor one in '.'.\n";
+ if (! $emulate_aux) { warn " I also looked in '$out_dir'\n"; }
+ }
+ if ( ! $good_log_found ) {
$failure = 1;
$$Plast_result = 2;
- $where_log = 0;
$failure_msg
= "*LaTeX didn't generate the expected log file '$log_name'\n";
}
+
return $where_log;
} #END find_set_log
@@ -6960,6 +7162,7 @@
$$Prun_time = $run_time;
$$Pcheck_time = $check_time;
$$Plast_result = $last_result;
+ $$Plast_result_info = 'CACHE';
# Deal with possibility that destination file in fdb_latexmk from
# run differs from what is currently set. Often that just reflects a
@@ -7249,7 +7452,7 @@
# But we'll use the results later, so that they take priority over the findings
# from the log file.
local $fls_file_analyzed = 0;
- if ($recorder && test_gen_file($fls_name) ) {
+ if ($recorder && test_gen_file_time($fls_name) ) {
$fls_file_analyzed =
(0== parse_fls( $fls_name, \%source_fls, \%generated_fls, \%first_read_after_write, \$pwd_latex ));
if (! $fls_file_analyzed ) {
@@ -7590,7 +7793,7 @@
}
if ($diagnostics) {
if ($num_new > 0 ) {
- show_array( "$num_new new source files for rule '$rule':", @more_sources );k { print " '$_'\n"; }
+ show_array( "$num_new new source files for rule '$rule':", @more_sources );
}
else {
print "No new source files for rule '$rule':\n";
@@ -7684,24 +7887,29 @@
sub test_gen_file {
# Usage: test_gen_file( filename )
- # Tests whether the file was generated during a run of *latex.
+ # Tests whether a file of given name was generated during current run
+ # of *latex, with override of comparison of file and run time by
+ # file being listed in %generated_log or %generated_fls
# Assumes context for primary rule.
- # Two kinds of test are used:
- # a. From %generated_log and %generated_fls, which works after the fls and
- # log files hav been parsed, but in the log file only for certain files
- # and for those TeX engines (not MiKTeX) that put \openout lines in log
- # file.
- # b. By the file existing and being at least as new as the system
- # time at the start of the run. But make an allowance ($filetime_slop) for
- # differences in granularity between reported system time and reported
- # file mtimes.
my $file = shift;
return exists $generated_log{$file} || $generated_fls{$file}
- || ( -e $file && ( get_mtime( $file ) >= $$Prun_time - $filetime_slop ));
+ || test_gen_file_time($file);
}
#************************************************************
+sub test_gen_file_time {
+ # Usage: test_gen_file_time( filename )
+ # Tests whether a file of given name exists and was generated during
+ # current run of *latex. Comparison of file and run time used for
+ # testing whether file was generated or is left over from a previous run.
+ #
+ my $file = shift;
+ return (-e $file) && ( get_mtime( $file ) >= $$Prun_time + $filetime_offset - $filetime_causality_threshold );
+}
+
+#************************************************************
+
sub dep_at_start {
# Usage: dep_at_start( filename )
# Tests whether the file was source file and existed at start of run.
@@ -7855,6 +8063,11 @@
return;
}
local $new_dest = $file;
+ if ($$PHdest{$new_dest} ) {
+ # We already have a way of making the file.
+ # No need to find another one.
+ return;
+ }
my ($base_name, $path, $toext) = fileparseA( $new_dest );
$base_name = $path.$base_name;
$toext =~ s/^\.//;
@@ -7863,6 +8076,7 @@
foreach my $dep ( @cus_dep_list ) {
my ($fromext,$proptoext,$must,$func_name) = split('\s+',$dep);
if ( $toext eq $proptoext ) {
+ # Look in search path for file of correct name:
$base_name = rdb_find_source_file($base_name, $fromext);
my $source = "$base_name.$fromext";
# Found match of rule
@@ -7872,6 +8086,11 @@
if ( -e $source ) {
my $from_rule = "cusdep $fromext $toext $base_name";
my $new_new_dest = "$base_name.$toext";
+ if ($$PHdest{$new_new_dest} ) {
+ # We already have a way of making the file.
+ # No need to find another one.
+ return;
+ }
if ($new_new_dest ne $new_dest) {
rdb_ensure_file( $rule, $new_new_dest );
$new_dest = $new_new_dest;
@@ -7919,6 +8138,11 @@
if ( -e $source ) {
$new_dest = "$base_name.$proptoext";
my $from_rule = "cusdep $fromext $proptoext $base_name";
+ if ( $$PHdest{$new_dest} ) {
+ # We already have a way of making the file.
+ # No need to find another one.
+ return;
+ }
push @new_sources, $new_dest;
print "$My_name: Ensuring rule for '$from_rule', to make '$new_dest'\n"
if $diagnostics > -1;
@@ -8009,6 +8233,15 @@
if ($dvi_mode) {push @dest_exts, '.dvi';}
if ($postscript_mode) {push @dest_exts, '.ps';}
+ my $deps_space = ' ';
+ if ($deps_escape eq 'unix' ) { $deps_space = '\ '; }
+ elsif ($deps_escape eq 'nmake' ) { $deps_space = '^ '; }
+ $Pescape = sub {
+ my $name = shift;
+ $name =~ s/ /$deps_space/g;
+ return $name;
+ };
+
my %source = ( $texfile_name => 1 );
my @accessible_all = &rdb_accessible;
rdb_for_some(
@@ -8036,9 +8269,9 @@
# deps file out-of-date are the same as those that make the real
# target file (e.g., .pdf) out-of-date. So the GNU method seems
# completely unnecessary.
- fprint8 $fh, "${out_dir1}${root_filename}${ext} :";
+ fprint8 $fh, &$Pescape(${out_dir1}.${root_filename}.${ext}), " :";
foreach (sort keys %source) {
- fprint8 $fh, "\\\n $_";
+ fprint8 $fh, "\\\n ", &$Pescape($_);
}
fprint8 $fh, "\n";
}
@@ -8067,7 +8300,8 @@
if ( !defined($_) ) { $_='undef';}
}
print " [$rule]: '$$Pcmd_type' '$$Pext_cmd' '@int_cmd' $$Pno_history ",
- "'$$Psource' '$$Pdest' '$$Pbase' $$Pout_of_date $$Pout_of_date_user\n"; },
+ "'$$Psource' '$$Pdest' '$$Pbase' $$Pout_of_date $$Pout_of_date_user\n";
+ },
sub{ print " '$file': $$Ptime $$Psize $$Pmd5 '", ($from_rules{$file} || ''), "'\n"; }
);
if ($count_rules <= 0) {
@@ -8554,26 +8788,33 @@
local @errors = ();
local @warnings = ();
rdb_for_actives(
- sub{
- if ($$Plast_message ne '') {
- if ($$Plast_result == 200) {
- push @warnings, "$rule: $$Plast_message";
- }
- else {
- push @errors, "$rule: $$Plast_message";
- }
- }
- elsif ($$Plast_result == 1) {
- push @errors, "$rule: failed to create output file";
- }
- elsif ($$Plast_result == 2) {
- push @errors, "$rule: gave an error";
- }
- elsif ($$Prun_time == 0) {
- # This can have innocuous causes. So don't report
- }
- }
- );
+ sub {
+ my $message_tail = "";
+ if ( $$Plast_result_info eq 'PREV' ) {
+ $message_tail = " in previous round of document compilation.";
+ }
+ elsif ( $$Plast_result_info eq 'CACHE' ) {
+ $message_tail = " in previous invocation of $my_name.";
+ }
+ if ($$Plast_message ne '') {
+ if ($$Plast_result == 200) {
+ push @warnings, "$rule: $$Plast_message";
+ }
+ else {
+ push @errors, "$rule: $$Plast_message";
+ }
+ }
+ elsif ($$Plast_result == 1) {
+ push @errors, "$rule: failed to create output file$message_tail";
+ }
+ elsif ($$Plast_result == 2) {
+ push @errors, "$rule: gave an error$message_tail";
+ }
+ elsif ($$Prun_time == 0) {
+ # This can have innocuous causes. So don't report
+ }
+ }
+ );
if ($#warnings > -1) {
show_array( "Collected warning summary (may duplicate other messages):". @warnings );
}
@@ -8761,6 +9002,7 @@
$$Pchanged = 0; # No special changes in files
$$Plast_result = 0;
+ $$Plast_result_info = 'CURR';
$$Plast_message = '';
my $latex_like = ($$Pcmd_type eq 'primary');
@@ -8983,6 +9225,7 @@
$$Prun_time = time();
$$Pchanged = 0; # No special changes in files
$$Plast_result = 0;
+ $$Plast_result_info = 'CURR';
$$Plast_message = '';
$$Pout_of_date = $$Pout_of_date_user = 0;
@@ -9343,7 +9586,7 @@
}
# Non-source-file-change reasons for rerun:
- if ( ( ($$Prun_time == 0) || ( $$Plast_result == -1 ) )
+ if ( ( ($$Prun_time == 0) || ( $$Plast_result =~ /^-1/ ) )
&& ( $$Pcmd_type eq 'primary' ) )
{
# Never run. Only use this test with primary, so we can get
@@ -9736,7 +9979,7 @@
$Psource, $Pdest, $Pbase,
$Pout_of_date, $Pout_of_date_user, $Prun_time, $Pcheck_time,
$Pchanged,
- $Plast_result, $Plast_message, $PA_extra_gen )
+ $Plast_result, $Plast_result_info, $Plast_message, $PA_extra_gen )
= Parray( $PArule_data );
&$rule_act1 if $rule_act1;
@@ -9830,7 +10073,6 @@
#************************************************************
sub rdb_create_rule {
- # ???!!! 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,
@@ -9842,7 +10084,12 @@
# Makes rule. Update rule if it already exists.
# Omitted arguments: replaced by 0, '', or [] as needed.
# Rule is made active
-# ==== Sets rule data ====
+ # 5th argument DUMMY is argument that used to be used (test_kind), but
+ # is not used any more. But I keep it there to avoid having to change
+ # calls, which are not only in the latexmk code itself, but may be in
+ # latexmkrc files created by others.
+
+# ==== Set rule data from arguments ====
my ( $rule, $cmd_type, $ext_cmd, $PAint_cmd, $DUMMY,
$source, $dest, $base,
$needs_making, $run_time, $check_time, $set_file_not_exists,
@@ -9859,6 +10106,7 @@
if (! defined $_) { $_ = []; }
}
my $last_result = -1;
+ my $last_result_info = '';
my $no_history = ($run_time <= 0);
my $active = 1;
my $changed = 0;
@@ -9884,7 +10132,7 @@
[ [$cmd_type, $ext_cmd, $PAint_cmd, $no_history,
$source, $dest, $base,
$needs_making, 0, $run_time, $check_time, $changed,
- $last_result, '', $PAextra_gen ],
+ $last_result, $last_result_info, '', $PAextra_gen ],
{},
{},
{},
@@ -10540,12 +10788,14 @@
if (!-e) {next;}
if (-d) {
if (!rmdir) {
- warn "$My_name: Cannot remove directory '$_'\n";
+ warn "$My_name: Cannot remove directory '$_'\n",
+ " Error message = '$!'\n";
}
}
else {
if (!unlink) {
- warn "$My_name: Cannot remove file '$_'\n";
+ warn "$My_name: Cannot remove file '$_'\n",
+ " Error message = '$!'\n";
}
}
}
@@ -10553,7 +10803,8 @@
else {
foreach (@_) {
if (-e $_ && ! move $_, "$del_dir/$_" ) {
- warn "$My_name: Cannot move '$_' to '$del_dir/$_'\n";
+ warn "$My_name: Cannot move '$_' to '$del_dir/$_'\n",
+ " Error message = '$!'\n";
}
}
}
@@ -10981,6 +11232,36 @@
#################################
+sub get_filetime_offset {
+ # Usage: get_filetime_offset( prefix, [suffix] )
+ # Measures offset between filetime in a directory and system time
+ # Makes a temporary file of a unique name, and deletes in.
+ # Filename is of form concatenation of prefix, an integer, suffix.
+ # Prefix is normally of form dir/ or dir/tmp.
+ # Default default suffix ".tmp".
+ my $prefix = $_[0];
+ my $suffix = $_[1] || '.tmp';
+ my $tmp_file_count = 0;
+ while (1==1) {
+ # Find a new temporary file, and make it.
+ $tmp_file_count++;
+ my $tmp_file = "${prefix}${tmp_file_count}${suffix}";
+ if ( ! -e $tmp_file ) {
+ open( TMP, ">$tmp_file" )
+ or die "$My_name.get_filetime_offset: In measuring filetime offset, couldn't write to\n",
+ " temporary file '$tmp_file'\n";
+ my $time = time();
+ close(TMP);
+ my $offset = get_mtime($tmp_file) - $time;
+ unlink $tmp_file;
+ return $offset;
+ }
+ }
+ die "$My_name.get_filetime_offset: BUG TO ARRIVE HERE\n";
+}
+
+#################################
+
sub tempfile1 {
# Makes a temporary file of a unique name. I could use file::temp,
# but it is not present in all versions of perl.
Modified: trunk/Master/texmf-dist/doc/man/man1/latexmk.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/latexmk.1 2023-04-04 20:14:23 UTC (rev 66765)
+++ trunk/Master/texmf-dist/doc/man/man1/latexmk.1 2023-04-04 20:14:52 UTC (rev 66766)
@@ -1,4 +1,4 @@
-.TH LATEXMK 1 "7 January 2023" ""
+.TH LATEXMK 1 "4 April 2023" ""
.SH NAME
latexmk \- generate LaTeX document
.SH SYNOPSIS
@@ -431,6 +431,13 @@
Equivalent to \fB-deps-\fR.
.TP
+.B -deps-escape=<string>
+Set the kind of escaping used for spaces in the dependency list. The
+possible values are "none", "unix", "nmake", corresponding respectively to
+no escaping, escaping with a "\\" suitable for standard Unix make, and
+escaping with "^", suitable for Microsoft's nmake.
+
+.TP
.B -deps-out=FILENAME
Set the filename to which the list of dependent files is written. If
the FILENAME argument is omitted or set to "-", then the output is
@@ -2029,7 +2036,7 @@
}
.PP
For some of the more exotic possibilities that then become available,
-see the section "ADVANCED CONFIGURATION: Some extra resources and
+see the section "Advanced configuration: Some extra resources and
advanced tricks". Also see some of the examples in the directory
\fIexample_rcfiles\fR in the \fIlatexmk\fR distribution.
@@ -2390,7 +2397,7 @@
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";
+ $clean_ext = "pythontex-files-%R/* pythontex-files-%R";
See also the (array) variable \fI at generated_exts\fR. In the past, this
variable had certain uses beyond that of \fI$clean_ext\fR. But now, they
@@ -2536,10 +2543,26 @@
.TP
.B $dependents_list [0]
Whether to display a list(s) of dependencies at the end of a run.
+
.TP
+.B $deps_escape ["none"]
+This variable determines which kind of escaping of space characters to use
+in dependency lists. The possible values are "none", "unix", "nmake",
+corresponding respectively to no escaping, escaping with a "\\" suitable
+for standard Unix make, and escaping with "^", suitable for Microsoft's
+nmake.
+
+Currently the only character escaped is a space, since that is particularly
+common in file names and directory names. There are other characters that
+would need escaping if a dependency list is to be used as-is by a make
+program; but those characters (e.g., "$") commonly cause difficulties when
+used for .tex documents. Moreover, the detailed rules for which characters
+need to be escaped depends on the version of make.
+
+.TP
.B $deps_file ["-"]
Name of file to receive list(s) of dependencies at the end of a run,
-to be used if \fI$dependesnt_list\fR is set. If the filename is "-",
+to be used if \fI$dependents_list\fR is set. If the filename is "-",
then the dependency list is set to stdout (i.e., normally the screen).
.TP
@@ -3903,7 +3926,7 @@
conversion. So the new method is preferable.
-.SH ADVANCED CONFIGURATION: Some extra resources and advanced tricks
+.SH Advanced configuration: Some extra resources and advanced tricks
For most purposes, simple configuration for \fIlatexmk\fR along the
lines of the examples given is sufficient. But sometimes you need
@@ -4025,7 +4048,7 @@
\fI$xelatex\fR to a common pattern, you can use one of the following
subroutines, std_tex_cmds, alt_tex_cmds, and set_tex_cmds.
-They work as follows
+To get the standard commands, use
&std_tex_cmds;
@@ -4032,24 +4055,52 @@
This results in \fI$latex = 'latex %O %S'\fR, and similarly for
\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.
+subroutine is being called. (The use of this subroutine enables you to
+override previous redefinitions of the \fI$latex\fR, etc variables, which
+might have occurred in an earlier-read rc file.)
+To be able to use the string provided by the -pretex option (if any), you
+can use
+
&alt_tex_cmds;
-This results in \fI$latex = 'latex %O %P'\fR, and similarly for
-\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.
+This results in \fI$latex = 'latex %O %P'\fR, etc. Again note the
+ampersand in the invocation; this indicates to Perl that a subroutine is
+being called.
- set_tex_cmds( CMD_SPEC );
+A more general way of specifying the variables is using
+ set_tex_cmds( 'CMD_SPEC' );
+
Here CMD_SPEC is the command line without the program name. This
results in \fI$latex = 'latex CMD_SPEC'\fR, and similarly for
-\fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR. An example would
-be
+\fI$pdflatex\fR, etc. (An ampersand preceding the subroutine name is not
+necessary here, since the parentheses show Perl that a subroutine is being
+invoked.)
+An example that provides the \fI--interaction=batchmode\fR option to the
+*latex commands would be
+
set_tex_cmds( '--interaction=batchmode %O %S' );
+This results in \fI$latex = 'latex --interaction=batchmode %O %S '\fR, etc.
+Note that when '%O' appears after the added option, as here, options
+provided on the command line to \fIlatexmk\fR can override the supplied
+one.
+
+A more general command line can be set up by using the placeholder '%C' in
+CMD_SPEC. The '%C' is substituted by the basic name of the command, i.e.,
+whichever of 'latex', 'pdflatex', etc is appropriate. (More than one
+occurrence of '%C' is allowed.) For example to use the
+development/pre-release versions of latex, etc, which have
+names, 'latex-dev', 'pdflatex-dev', etc, you could use
+
+ set_tex_cmds( '%C-dev %O %S' );
+
+This results in \fI$latex = 'latex-dev %O %S'\fR, etc. (The pre-release
+programs latex-dev etc are provided in current distributions of TeXLive and
+MiKTeX.)
+
.PP
.SS Advanced configuration: Using \fIlatexmk\fB with \fImake\fR
@@ -4182,8 +4233,24 @@
then reruns \fIlatexmk\fR.
Thus we now have a method by which all the subsidiary processing is
-delegated to \fImake\fR.
+delegated to \fImake\fR.
+\fBEscaping of characters in dependency lists\fR: There are certain special
+characters that need to be escaped when names of files and directories
+containing them appear in a dependency list used by a make program.
+Generally, such special characters are best avoided.
+
+By default, latexmk does no escaping of this kind, and the user will have
+to arrange to deal with the issue separately, if the relevant special
+characters are used. Note that the rules for escaping depend on which make
+program is used, and on its version.
+
+One special case is of spaces, since those are particularly prevalent,
+notably in standard choices of name for a user's home directory. So
+latexmk does provide an option to escape spaces. See the option
+\fB-deps_escape=...\fR and the variable \fB$deps_escape\fR for details.
+
+
.SH NON_ASCII CHARACTERS IN FILENAMES, RC FILES, ETC
Modern operating systems and file systems allow non-ASCII characters in
@@ -4229,7 +4296,7 @@
harvested too easily.)
.SH AUTHOR
Current version, by John Collins
-(Version 4.79).
+(Version 4.80).
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 2023-04-04 20:14:23 UTC (rev 66765)
+++ trunk/Master/texmf-dist/doc/support/latexmk/CHANGES 2023-04-04 20:14:52 UTC (rev 66766)
@@ -804,6 +804,12 @@
log file according to whether latex/pdflatex, lualatex or xelatex is
used, thereby reducing misparses of information in log file.
Reinstate Windows batch file for running latexmk, now called latexmk.cmd.
+ Remove code that automatically measured a possible offset between clock
+ time for the system on which latexmk runs and the system on which files
+ are stored. (This was used to adjust a test for whether an expected
+ file is generated on the current run of *latex or is a relic from a
+ past time.) Modern OSs, by default, synchronize system time with a time
+ server.
From v. 4.77 to 4.78
Option -dvilua to generate dvi file by lualatex
@@ -811,7 +817,7 @@
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
+ Configuration variable $bad_warning_is_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
@@ -830,4 +836,26 @@
Configurably change default location of fls file to aux directory, to match
behavior of recent versions of MiKTeX.
Update documentation especially about aux and output directories.
+ Add configuration variable (not yet documented) $filetime_slop, with
+ default value 2. When a test for whether a file was generated on the
+ current run of *latex, the file modification time is permitted to be
+ $filetime_slop seconds older than the system time at the start of a
+ run of *latex while still being treated as a generated file. This
+ allows for differences in granularity between the different times
+ involved, and especially the 2 sec granularity on FAT file systems.
+From v. 4.79 to 4.80
+ Improved treatment of detection of whether files (e.g., .log) have been
+ generated on current run or are leftover from an earlier run. Code now
+ compensates (and diagnoses) time offset between computer running
+ latexmk and file server.
+ Allow placeholder %C in argument to set_tex_cmds, to allow more flexible
+ construction of command lines for all *latex.
+ Fix problems of compatibility with the xr package.
+ Allow escaping of spaces in names of files in deps files, as needed by
+ make. Escaping can be unix-style or nmake-style.
+ Various bug fixes and corrections, improvements in error and warning
+ messages, and corrections to documentation.
+
+
+
Modified: trunk/Master/texmf-dist/doc/support/latexmk/INSTALL
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/INSTALL 2023-04-04 20:14:23 UTC (rev 66765)
+++ trunk/Master/texmf-dist/doc/support/latexmk/INSTALL 2023-04-04 20:14:52 UTC (rev 66766)
@@ -1,6 +1,6 @@
INSTALLING latexmk
==================
- (Version 4.79, 7 Jan. 2023)
+ (Version 4.80, 4 Apr. 2023)
John Collins
Physics Department
Modified: trunk/Master/texmf-dist/doc/support/latexmk/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/README 2023-04-04 20:14:23 UTC (rev 66765)
+++ trunk/Master/texmf-dist/doc/support/latexmk/README 2023-04-04 20:14:52 UTC (rev 66766)
@@ -1,4 +1,4 @@
-Latexmk, version 4.79, 7 Jan 2023
+Latexmk, version 4.80, 4 Apr 2023
---------------------------------
Latexmk completely automates the process of generating a LaTeX
Deleted: trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pdflatexmkrc
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pdflatexmkrc 2023-04-04 20:14:23 UTC (rev 66765)
+++ trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pdflatexmkrc 2023-04-04 20:14:52 UTC (rev 66766)
@@ -1,77 +0,0 @@
-# Use of glossaries, extra indexes, epstopdf, and other images conversions
-# Thanks to Herb Schulz
-
-
-$pdflatex = 'pdflatex --shell-escape %O %S';
-
-# Custom dependency for glossary/glossaries package
-# if you make custom glossaries you may have to add items to the @cus_dep_list and corresponding sub-routines
-add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' );
-sub makeglo2gls {
- system( "makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" );
-}
-# The glossaries package, with the [acronym] option, produces a .acn file when processed with (xe/pdf)latex and
-# then makeindex to process the .acn into .acr and finally runs of (xe/pdf)latex to read in the .acr file. Unfortunately
-# the glossary package does just the reverse; i.e. (xe/pdf)latex processing produces a .acr files and makeindex then
-# is used to convert the .acr file to a .acn file which is then ... . This dependency assumes the glossaries package.
-add_cus_dep( 'acn', 'acr', 0, 'makeacn2acr' );
-sub makeacn2acr {
- system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acr\" \"$_[0].acn\"" );
-}
-# for glossary package (Sigh...) --- they can co-exist!
-add_cus_dep( 'acr', 'acn', 0, 'makeacr2acn' );
-sub makeacr2acn {
- system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acn\" \"$_[0].acr\"" );
-}
-# example of an added custom glossary type that is used in some of the glossary/glossaries example files:
-# this is for the new glossary type command \newglossary[nlg]{notation}{not}{ntn}{Notation} from the glossaries package
-# NOTE: the glossary package uses a very different command: the <in-ext> and <out-ext>
-# are reversed in the calling sequence :-(
-add_cus_dep( 'ntn', 'not', 0, 'makentn2not' );
-sub makentn2not {
- system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].not\" \"$_[0].ntn\"" );
-}
-# for the glossary package (Sigh...) --- they can co-exist!
-add_cus_dep( 'not', 'ntn', 0, 'makenot2ntn' );
-sub makenot2ntn {
- system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].ntn\" \"$_[0].not\"" );
-}
-
-# dependencies for custom indexes using the index package
-# examples for sample.tex for index package:
- add_cus_dep( 'adx', 'and', 0, 'makeadx2and' );
-sub makeadx2and {
- system( "makeindex -o \"$_[0].and\" \"$_[0].adx\"" );
-}
-add_cus_dep( 'ndx', 'nnd', 0, 'makendx2nnd' );
-sub makendx2nnd {
- system( "makeindex -o \"$_[0].nnd\" \"$_[0].ndx\"" );
-}
-add_cus_dep( 'ldx', 'lnd', 0, 'makeldx2lnd' );
-sub makeldx2lnd {
- system( "makeindex -o \"$_[0].lnd\" \"$_[0].ldx\"" );
-}
-
-# Custom dependency and function for nomencl package
-add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' );
-sub makenlo2nls {
- system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" );
-}
-
-# Custom dependency and function(s) for epstopdf package
-
-# FOR USERS OF epstopf v1.4 and before: should also work with v1.5 and later
-# note: you may get extras runs if you use the .eps extension in the \includgraphics command
-# deletes an outdated pdf-image, and triggers a pdflatex-run
-add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_delete_dest' );
-
-# FOR USERS OF epstopdf v1.5 and later only:
-# load it as \usepackage[update,prepend]{epstopdf}
-# detects an outdated pdf-image, and triggers a pdflatex-run
-#add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_require_primary_run' );
-
-# Custom dependecy to convert tif to png
-add_cus_dep( 'tif', 'png', 0, 'maketif2png' );
-sub maketif2png {
- system( "convert \"$_[0].tif\" \"$_[0].png\"" );
-}
Added: trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/schultz-texshop-latexmkrc
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/schultz-texshop-latexmkrc (rev 0)
+++ trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/schultz-texshop-latexmkrc 2023-04-04 20:14:52 UTC (rev 66766)
@@ -0,0 +1,77 @@
+# Use of glossaries, extra indexes, epstopdf, and other images conversions
+# Thanks to Herb Schulz
+
+
+$pdflatex = 'pdflatex --shell-escape %O %S';
+
+# Custom dependency for glossary/glossaries package
+# if you make custom glossaries you may have to add items to the @cus_dep_list and corresponding sub-routines
+add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' );
+sub makeglo2gls {
+ system( "makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" );
+}
+# The glossaries package, with the [acronym] option, produces a .acn file when processed with (xe/pdf)latex and
+# then makeindex to process the .acn into .acr and finally runs of (xe/pdf)latex to read in the .acr file. Unfortunately
+# the glossary package does just the reverse; i.e. (xe/pdf)latex processing produces a .acr files and makeindex then
+# is used to convert the .acr file to a .acn file which is then ... . This dependency assumes the glossaries package.
+add_cus_dep( 'acn', 'acr', 0, 'makeacn2acr' );
+sub makeacn2acr {
+ system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acr\" \"$_[0].acn\"" );
+}
+# for glossary package (Sigh...) --- they can co-exist!
+add_cus_dep( 'acr', 'acn', 0, 'makeacr2acn' );
+sub makeacr2acn {
+ system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acn\" \"$_[0].acr\"" );
+}
+# example of an added custom glossary type that is used in some of the glossary/glossaries example files:
+# this is for the new glossary type command \newglossary[nlg]{notation}{not}{ntn}{Notation} from the glossaries package
+# NOTE: the glossary package uses a very different command: the <in-ext> and <out-ext>
+# are reversed in the calling sequence :-(
+add_cus_dep( 'ntn', 'not', 0, 'makentn2not' );
+sub makentn2not {
+ system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].not\" \"$_[0].ntn\"" );
+}
+# for the glossary package (Sigh...) --- they can co-exist!
+add_cus_dep( 'not', 'ntn', 0, 'makenot2ntn' );
+sub makenot2ntn {
+ system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].ntn\" \"$_[0].not\"" );
+}
+
+# dependencies for custom indexes using the index package
+# examples for sample.tex for index package:
+ add_cus_dep( 'adx', 'and', 0, 'makeadx2and' );
+sub makeadx2and {
+ system( "makeindex -o \"$_[0].and\" \"$_[0].adx\"" );
+}
+add_cus_dep( 'ndx', 'nnd', 0, 'makendx2nnd' );
+sub makendx2nnd {
+ system( "makeindex -o \"$_[0].nnd\" \"$_[0].ndx\"" );
+}
+add_cus_dep( 'ldx', 'lnd', 0, 'makeldx2lnd' );
+sub makeldx2lnd {
+ system( "makeindex -o \"$_[0].lnd\" \"$_[0].ldx\"" );
+}
+
+# Custom dependency and function for nomencl package
+add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' );
+sub makenlo2nls {
+ system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" );
+}
+
+# Custom dependency and function(s) for epstopdf package
+
+# FOR USERS OF epstopf v1.4 and before: should also work with v1.5 and later
+# note: you may get extras runs if you use the .eps extension in the \includgraphics command
+# deletes an outdated pdf-image, and triggers a pdflatex-run
+add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_delete_dest' );
+
+# FOR USERS OF epstopdf v1.5 and later only:
+# load it as \usepackage[update,prepend]{epstopdf}
+# detects an outdated pdf-image, and triggers a pdflatex-run
+#add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_require_primary_run' );
+
+# Custom dependecy to convert tif to png
+add_cus_dep( 'tif', 'png', 0, 'maketif2png' );
+sub maketif2png {
+ system( "convert \"$_[0].tif\" \"$_[0].png\"" );
+}
Added: trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/xr_latexmkrc
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/xr_latexmkrc (rev 0)
+++ trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/xr_latexmkrc 2023-04-04 20:14:52 UTC (rev 66766)
@@ -0,0 +1,85 @@
+# This shows how to use the xr package with latexmk.
+# John Collins 2023-03-29
+#
+# The xr package ("a system for eXternal References") is used by a document
+# to make references to sections, equations, etc in other external
+# documents.
+# The definitions in this file enable latexmk to apply latexmk to
+# automatically update an external document whenever its .tex file changes,
+# so that the references in the main document stay up to date.
+
+# Notes:
+# 1. This version is defined to put the files from the compilations of
+# the external documents into a defined subdirectory, to segregate
+# potentially many generated files from the main document
+# directories.
+# 2. But for latexmk's custom dependency mechanism to be used, as here,
+# the aux file from compilation of a subdocument must be generated in
+# the same directory as the corresponding source .tex file. So the
+# .aux file is copied.
+# 3. It is assumed that the external documents are to be compiled by
+# pdflatex. This can be changed, of course, by changing the '-pdf'
+# option given to the invoked latexmk to whatever is needed.
+# 4. An ideal implementation would also ensure that recompilation of an
+# external document also happens whenever any of its other source
+# files changes. But this is not done in the present version, and
+# would probably entail either the use of internal latexmk variables
+# or extra enhancements to latexmk.
+# 5. The code uses subroutines copy and fileparse that are loaded by
+# latexmk from the Perl packages File::Copy and File::Basename.
+# 6. It also uses some not-yet-documented features of latexmk: an array
+# variable @file_not_found and subroutines popd, pushd, and
+# rdb_add_generated.
+
+
+#--------------------
+# Configurable choices for compilation of external documents
+
+# Subdirectory for output files from compilation of external documents:
+$sub_doc_output = 'output-subdoc';
+
+# Options to supply to latexmk for compilation of external documents:
+ at sub_doc_options = ();
+
+push @sub_doc_options, '-pdf'; # Use pdflatex for compilation of external documents.
+# Replace '-pdf' by '-pdfdvi', 'pdfxe', or 'pdflua' if needed.
+
+#--------------------
+
+# Add a pattern for xr's log-file message about missing files to latexmk's
+# list. Latexmk's variable @file_not_found is not yet documented.
+# This line isn't necessary for v. 4.80 or later of latexmk.
+push @file_not_found, '^No file\\s*(.+)\s*$';
+
+add_cus_dep( 'tex', 'aux', 0, 'makeexternaldocument' );
+sub makeexternaldocument {
+ if ( $root_filename ne $_[0] ) {
+ my ($base_name, $path) = fileparse( $_[0] );
+ pushd $path;
+ my $return = system "latexmk",
+ @sub_doc_options,
+ "-aux-directory=$sub_doc_output",
+ "-output-directory=$sub_doc_output",
+ $base_name;
+ if ( ($sub_doc_output ne ' ') && ($sub_doc_output ne '.') ) {
+ # In this case, .aux file generated by pdflatex isn't in same
+ # directory as the .tex file.
+ # Therefore:
+ # 1. Actual generated aux file must be listed as produced by this
+ # rule, so that latexmk deals with dependencies correctly.
+ # (Problem to overcome: If $sub_dir_output is same as $aux_dir
+ # for the main document, xr may read the .aux file in the
+ # aux_dir rather than the one the cus dep is assumed by latexmk
+ # to produce, which is in the same directory as the .tex source
+ # file for this custom dependency.)
+ # Use not-yet-documented latexmk subroutine rdb_add_generated
+ # to do this:
+ # 2. A copy of the .aux file must be in same directory as .tex file
+ # to satisfy latexmk's definition of a custom dependency.
+ rdb_add_generated( "$sub_doc_output/$base_name.aux" );
+ copy "$sub_doc_output/$base_name.aux", ".";
+ }
+ popd;
+ return $return;
+ }
+}
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 2023-04-04 20:14:23 UTC (rev 66765)
+++ trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt 2023-04-04 20:14:52 UTC (rev 66766)
@@ -61,7 +61,7 @@
- 7 January 2023 1
+ 4 April 2023 1
@@ -127,7 +127,7 @@
- 7 January 2023 2
+ 4 April 2023 2
@@ -193,7 +193,7 @@
- 7 January 2023 3
+ 4 April 2023 3
@@ -259,7 +259,7 @@
- 7 January 2023 4
+ 4 April 2023 4
@@ -325,7 +325,7 @@
- 7 January 2023 5
+ 4 April 2023 5
@@ -391,7 +391,7 @@
- 7 January 2023 6
+ 4 April 2023 6
@@ -457,7 +457,7 @@
- 7 January 2023 7
+ 4 April 2023 7
@@ -504,6 +504,14 @@
Equivalent to -deps-.
+ -deps-escape=<string>
+ Set the kind of escaping used for spaces in the dependency list.
+ The possible values are "none", "unix", "nmake", corresponding
+ respectively to no escaping, escaping with a "\" suitable for
+ standard Unix make, and escaping with "^", suitable for Micro-
+ soft's nmake.
+
+
-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
@@ -513,25 +521,24 @@
pendent files after processing.
- -dF Dvi file filtering. The argument to this option is a filter
- which will generate a filtered dvi file with the extension
- ".dviF". All extra processing (e.g. conversion to postscript,
- preview, printing) will then be performed on this filtered dvi
- file.
- Example usage: To use dviselect to select only the even pages of
+ 4 April 2023 8
- 7 January 2023 8
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ -dF Dvi file filtering. The argument to this option is a filter
+ which will generate a filtered dvi file with the extension
+ ".dviF". All extra processing (e.g. conversion to postscript,
+ preview, printing) will then be performed on this filtered dvi
+ file.
-
+ Example usage: To use dviselect to select only the even pages of
the dvi file:
latexmk -dF "dviselect even" foo.tex
@@ -580,25 +587,24 @@
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
+ 4 April 2023 9
- 7 January 2023 9
-
LATEXMK(1) General Commands Manual LATEXMK(1)
- assignment statements separated by semicolons.
+ -e <code>
+ Execute the specified initialization code before processing.
+ The code is Perl code of the same form as is used in latexmk's
+ initialization files. For more details, see the information on
+ the -r option, and the section about "Configuration/initializa-
+ tion (RC) files". The code is typically a sequence of assign-
+ ment statements separated by semicolons.
The code is executed when the -e option is encountered during
latexmk's parsing of its command line. See the -r option for a
@@ -646,24 +652,24 @@
*latex programs to do it. (MiKTeX supports -aux-directory, but
TeXLive doesn't.)
- See the section AUXILIARY AND OUTPUT DIRECTORIES for more de-
- tails.
- -emulate-aux-dir-
- Turn off emulation to implement an aux directory and leave it to
+ 4 April 2023 10
- 7 January 2023 10
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ See the section AUXILIARY AND OUTPUT DIRECTORIES for more de-
+ tails.
+ -emulate-aux-dir-
+ Turn off emulation to implement an aux directory and leave it to
the *latex program to handle the case that the aux directory is
different from the output directory. Note that if you use
TeXLive, which doesn't support -aux-directory, latexmk will au-
@@ -713,32 +719,31 @@
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
- *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
+ 4 April 2023 11
- 7 January 2023 11
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ 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
- placeholder '%A'. This will be substituted by the basename of
- the TeX file. The primary purpose is when multiple files are
- specified on the command line to latexmk, and you wish to use a
- jobname with a different file-dependent value for each file.
- For example, suppose you had .tex files test1.tex and test2.tex,
- and you wished to compare the results of compilation by *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
@@ -779,23 +784,23 @@
latexmk -latex="latex --shell-escape %O %S" foo.tex
The specification of the contents of the string are the same as
- for the $latex configuration variable. Depending on your oper-
- ating system and the command-line shell you are using, you may
- need to change the single quotes to double quotes (or something
- else).
+ 4 April 2023 12
- 7 January 2023 12
-
LATEXMK(1) General Commands Manual LATEXMK(1)
+ 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
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
@@ -845,23 +850,22 @@
ization file.
- -M Show list of dependent files after processing. This is equiva-
- lent to the -deps option.
+ 4 April 2023 13
- 7 January 2023 13
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ -M Show list of dependent files after processing. This is equiva-
+ lent to the -deps option.
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-MF file
If a list of dependents is made, the -MF specifies the file to
write it to.
@@ -911,15 +915,11 @@
-new-viewer
When in continuous-preview mode, always start a new viewer to
- view the generated file. By default, latexmk will, in continu-
- ous-preview mode, test for a previously running previewer for
- the same file and not start a new one if a previous previewer is
- running. However, its test sometimes fails (notably if there is
- an already-running previewer that is viewing a file of the same
+ view the generated file. By default, latexmk will, in
- 7 January 2023 14
+ 4 April 2023 14
@@ -928,8 +928,12 @@
LATEXMK(1) General Commands Manual LATEXMK(1)
- name as the current file, but in a different directory). This
- option turns off the default behavior.
+ continuous-preview mode, test for a previously running previewer
+ for the same file and not start a new one if a previous pre-
+ viewer 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 direc-
+ tory). This option turns off the default behavior.
-new-viewer-
@@ -977,23 +981,22 @@
(.dvi, .ps, .pdf, .synctex, .synctex.gz) are sent to the output
directory. Other generated files are sent to the aux directory.
- See the section AUXILIARY AND OUTPUT DIRECTORIES for more de-
- tails.
+ See the section AUXILIARY AND OUTPUT DIRECTORIES for more
+ 4 April 2023 15
- 7 January 2023 15
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ details.
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-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-
@@ -1048,15 +1051,12 @@
+ 4 April 2023 16
- 7 January 2023 16
-
-
-
LATEXMK(1) General Commands Manual LATEXMK(1)
@@ -1117,7 +1117,7 @@
- 7 January 2023 17
+ 4 April 2023 17
@@ -1183,7 +1183,7 @@
- 7 January 2023 18
+ 4 April 2023 18
@@ -1249,7 +1249,7 @@
- 7 January 2023 19
+ 4 April 2023 19
@@ -1315,7 +1315,7 @@
- 7 January 2023 20
+ 4 April 2023 20
@@ -1381,7 +1381,7 @@
- 7 January 2023 21
+ 4 April 2023 21
@@ -1447,7 +1447,7 @@
- 7 January 2023 22
+ 4 April 2023 22
@@ -1513,7 +1513,7 @@
- 7 January 2023 23
+ 4 April 2023 23
@@ -1579,7 +1579,7 @@
- 7 January 2023 24
+ 4 April 2023 24
@@ -1645,7 +1645,7 @@
- 7 January 2023 25
+ 4 April 2023 25
@@ -1711,7 +1711,7 @@
- 7 January 2023 26
+ 4 April 2023 26
@@ -1777,7 +1777,7 @@
- 7 January 2023 27
+ 4 April 2023 27
@@ -1843,7 +1843,7 @@
- 7 January 2023 28
+ 4 April 2023 28
@@ -1909,7 +1909,7 @@
- 7 January 2023 29
+ 4 April 2023 29
@@ -1975,7 +1975,7 @@
- 7 January 2023 30
+ 4 April 2023 30
@@ -2041,7 +2041,7 @@
- 7 January 2023 31
+ 4 April 2023 31
@@ -2107,7 +2107,7 @@
- 7 January 2023 32
+ 4 April 2023 32
@@ -2173,7 +2173,7 @@
- 7 January 2023 33
+ 4 April 2023 33
@@ -2239,7 +2239,7 @@
- 7 January 2023 34
+ 4 April 2023 34
@@ -2305,7 +2305,7 @@
- 7 January 2023 35
+ 4 April 2023 35
@@ -2371,7 +2371,7 @@
- 7 January 2023 36
+ 4 April 2023 36
@@ -2398,7 +2398,7 @@
}
For some of the more exotic possibilities that then become available,
- see the section "ADVANCED CONFIGURATION: Some extra resources and ad-
+ see the section "Advanced configuration: Some extra resources and ad-
vanced tricks". Also see some of the examples in the directory exam-
ple_rcfiles in the latexmk distribution.
@@ -2437,7 +2437,7 @@
- 7 January 2023 37
+ 4 April 2023 37
@@ -2503,7 +2503,7 @@
- 7 January 2023 38
+ 4 April 2023 38
@@ -2569,7 +2569,7 @@
- 7 January 2023 39
+ 4 April 2023 39
@@ -2635,7 +2635,7 @@
- 7 January 2023 40
+ 4 April 2023 40
@@ -2701,7 +2701,7 @@
- 7 January 2023 41
+ 4 April 2023 41
@@ -2767,7 +2767,7 @@
- 7 January 2023 42
+ 4 April 2023 42
@@ -2833,7 +2833,7 @@
- 7 January 2023 43
+ 4 April 2023 43
@@ -2849,7 +2849,7 @@
You can arrange to remove both the files and the directory by
setting
- $clean_ext = "pythontex-files-%R pythontex-files-%R";
+ $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
@@ -2899,7 +2899,7 @@
- 7 January 2023 44
+ 4 April 2023 44
@@ -2965,7 +2965,7 @@
- 7 January 2023 45
+ 4 April 2023 45
@@ -3031,7 +3031,7 @@
- 7 January 2023 46
+ 4 April 2023 46
@@ -3040,9 +3040,25 @@
LATEXMK(1) General Commands Manual LATEXMK(1)
+ $deps_escape ["none"]
+ This variable determines which kind of escaping of space charac-
+ ters to use in dependency lists. The possible values are "none",
+ "unix", "nmake", corresponding respectively to no escaping, es-
+ caping with a "\" suitable for standard Unix make, and escaping
+ with "^", suitable for Microsoft's nmake.
+
+ Currently the only character escaped is a space, since that is
+ particularly common in file names and directory names. There
+ are other characters that would need escaping if a dependency
+ list is to be used as-is by a make program; but those characters
+ (e.g., "$") commonly cause difficulties when used for .tex docu-
+ ments. Moreover, the detailed rules for which characters need
+ to be escaped depends on the version of make.
+
+
$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
+ run, to be used if $dependents_list is set. If the filename is
"-", then the dependency list is set to stdout (i.e., normally
the screen).
@@ -3077,9 +3093,21 @@
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.
+ If 2, generate a dvi version of the document by use of
+
+
+ 4 April 2023 47
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ dvilualatex. 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
@@ -3096,16 +3124,6 @@
that equally applies to $dvilualatex_silent_switch.
-
- 7 January 2023 47
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
$dvi_previewer ["start xdvi %O %S" under UNIX]
The command to invoke a dvi-previewer. [Under MS-Windows the
default is "start"; then latexmk arranges to use the MS-Windows
@@ -3143,6 +3161,17 @@
$dvipdf_silent_switch ["-q"]
Switch(es) for dvipdf program when silent mode is on.
+
+
+ 4 April 2023 48
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
N.B. The standard dvipdf program runs silently, so adding the
silent switch has no effect, but is actually innocuous. But if
an alternative program is used, e.g., dvipdfmx, then the silent
@@ -3159,19 +3188,6 @@
The program to used as a filter to convert a .dvi file to a .ps
file in landscape mode.
-
-
-
-
- 7 January 2023 48
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
$dvips_pdf_switch ["-P pdf"]
Switch(es) for dvips program when pdf file is to be generated
from .ps file.
@@ -3211,6 +3227,17 @@
variable $dvi_update_method. The default value is the one ap-
propriate for xdvi on a UNIX system.
+
+
+ 4 April 2023 49
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$emulate_aux [0]
Whether to emulate the use of aux directory when $aux_dir and
$out_dir are different, rather than using the -aux-directory op-
@@ -3226,18 +3253,6 @@
MiKTeX.
Aux directory emulation means that when *latex is invoked, the
-
-
-
- 7 January 2023 49
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
output directory provided to *latex is set to be the desired aux
directory. After that, any files that need to be in the output
directory will be moved there by latexmk. (These are the files
@@ -3276,6 +3291,19 @@
of the .fls file to be generated.
+
+
+
+
+ 4 April 2023 50
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$force_mode [0]
If nonzero, continue processing past minor latex errors includ-
ing unrecognized cross references. Equivalent to specifying the
@@ -3292,18 +3320,6 @@
The default values are extensions for standard files generated
by *latex, bibtex, and the like. (Note that the clean up also
-
-
-
- 7 January 2023 50
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
deletes the fdb_latexmk file, but that's separately coded into
latexmk, currently.)
@@ -3343,6 +3359,17 @@
If nonzero, process files regardless of timestamps, and is then
equivalent to the -g option.
+
+
+ 4 April 2023 51
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
%hash_calc_ignore_pattern
!!!This variable is for experts only!!!
@@ -3358,18 +3385,6 @@
runs to guard against pathological situations.
But the changing line has no real effect, since it is a comment.
-
-
-
- 7 January 2023 51
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
You can instruct latex to ignore the offending line as follows:
$hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: ';
@@ -3409,6 +3424,18 @@
This specifies the jobname, i.e., the basename that is used for
generated files (.aux, .log, .dvi, .ps, .pdf, etc). If this
+
+
+
+ 4 April 2023 52
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
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.)
@@ -3424,18 +3451,6 @@
$jobname = "%A-$^O";
in an initialization file. (Here $^O is a variable provided by
-
-
-
- 7 January 2023 52
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
perl that contains perl's name for the operating system.)
Suppose you had .tex files test1.tex and test2.tex. Then when
@@ -3475,6 +3490,18 @@
$kpsewhich_show [0]
Whether to show diagnostics about invocations of kpsewhich: the
+
+
+
+ 4 April 2023 53
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
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
@@ -3490,18 +3517,6 @@
$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
-
-
-
- 7 January 2023 53
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
just to change the name of the program used, but also specify
options to the program. E.g.,
@@ -3540,34 +3555,35 @@
add the extension 'asdf to latex_input_extensions. (Naturally
with such an extension, you should have made an appropriate cus-
- tom dependency for latexmk, and should also have done the appro-
- priate programming in the LaTeX source file to enable the file
- to be read. The standard extensions are handled by LaTeX and
- its graphics/graphicx packages.)
+ tom dependency for latexmk, and should also have done the
- $latex_silent_switch ["-interaction=batchmode"]
- Switch(es) for the LaTeX processing program when silent mode is
- on.
- If you use MikTeX, you may prefer the results if you configure
- the options to include -c-style-errors, e.g., by the following
- line in an initialization file
- $latex_silent_switch = "-interaction=batchmode -c-style-er-
- rors";
+ 4 April 2023 54
- 7 January 2023 54
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ appropriate programming in the LaTeX source file to enable the
+ file to be read. The standard extensions are handled by LaTeX
+ and its graphics/graphicx packages.)
+ $latex_silent_switch ["-interaction=batchmode"]
+ Switch(es) for the LaTeX processing program when silent mode is
+ on.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ If you use MikTeX, you may prefer the results if you configure
+ the options to include -c-style-errors, e.g., by the following
+ line in an initialization file
+ $latex_silent_switch = "-interaction=batchmode -c-style-er-
+ rors";
+
$lpr ["lpr %O %S" under UNIX/Linux, "NONE lpr" under MS-Windows]
The command to print postscript files.
@@ -3606,6 +3622,18 @@
$lualatex ["lualatex %O %S"]
Specifies the command line for the LaTeX processing program that
+
+
+
+ 4 April 2023 55
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
is to be used when the lualatex program is called for (e.g., by
the option -lualatex.
@@ -3622,18 +3650,6 @@
put{file} or \includegraphics{figure}, when the relevant source
file does not exist.
-
-
-
- 7 January 2023 55
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
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-
@@ -3672,6 +3688,18 @@
bail out, rather than rerunning *latex again to resolve cross-
references, etc. The default value covers all normal cases.
+
+
+
+ 4 April 2023 56
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
(Note that the "etc" covers a lot of cases where one run of *la-
tex generates files to be read in on a later run.)
@@ -3688,18 +3716,6 @@
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
-
-
-
- 7 January 2023 56
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
"\" 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.
@@ -3739,6 +3755,17 @@
+
+
+ 4 April 2023 57
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$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-
@@ -3754,18 +3781,6 @@
fied by the $xelatex and xdvipdfmx variables.
In $pdf_mode=2, it is ensured that .dvi and .ps files are also
-
-
-
- 7 January 2023 57
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
made. In $pdf_mode=3, it is ensured that a .dvi file is also
made. But this may be overridden by the document.
@@ -3805,6 +3820,18 @@
See details of the %latex_input_extensions for other information
that equally applies to %pdflatex_input_extensions.
+
+
+
+ 4 April 2023 58
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$pdflatex_silent_switch ["-interaction=batchmode"]
Switch(es) for the pdflatex program (specified in the variable
$pdflatex) when silent mode is on.
@@ -3821,17 +3848,6 @@
this may be undesirable if this association is to acroread --
see the notes in the explanation of the -pvc option.]
-
-
- 7 January 2023 58
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
On OS-X the default is changed to "open %S", which results in
OS-X starting up (and detaching) the viewer associated with the
file. By default, for pdf files this association is to OS-X's
@@ -3871,6 +3887,17 @@
Note that acroread under MS-Windows (but not UNIX) locks the pdf
file, so the default value is then 3.
+
+
+ 4 April 2023 59
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
Arranging to use a command to get a previewer explicitly updated
requires three variables to be set. For example:
@@ -3886,18 +3913,6 @@
$pdf_update_signal [Under UNIX: SIGHUP, which is a system-dependent
value]
-
-
-
- 7 January 2023 59
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
The number of the signal that is sent to the pdf viewer when it
is updated by sending a signal -- see the information on the
variable $pdf_update_method. The default value is the one ap-
@@ -3938,6 +3953,17 @@
+
+
+ 4 April 2023 60
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$preview_continuous_mode [0]
If nonzero, run a previewer to view the document, and continue
running latexmk to keep .dvi up-to-date. Equivalent to the -pvc
@@ -3952,18 +3978,6 @@
$printout_mode [0]
If nonzero, print the document using the command specified in
-
-
-
- 7 January 2023 60
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
the $lpr variable. Equivalent to the -p option. This is recom-
mended not to be set from an RC file, otherwise you could waste
lots of paper.
@@ -4004,6 +4018,18 @@
Note that gv could be used with the -watch option updates its
display whenever the postscript file changes, whereas ghostview
+
+
+
+ 4 April 2023 61
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
does not. However, different versions of gv have slightly dif-
ferent ways of writing this option. You can configure this
variable appropriately.
@@ -4018,18 +4044,6 @@
fix the command by "start ", which flags to latexmk that it
should do the detaching of the previewer itself (by whatever
method is appropriate to the operating system). But sometimes
-
-
-
- 7 January 2023 61
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
letting latexmk do the detaching is not appropriate (for a vari-
ety of non-trivial reasons), so you should put the "start " bit
in yourself, whenever it is needed.
@@ -4071,6 +4085,17 @@
The period of inactivity, in minutes, after which pvc mode times
out. This is used if $pvc_timeout is nonzero.
+
+
+ 4 April 2023 62
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$pvc_view_file_via_temporary [1]
The same as $always_view_file_via_temporary, except that it only
applies in preview-continuous mode (-pvc option).
@@ -4084,18 +4109,6 @@
The quoting method used by latexmk is tested to work correctly
under UNIX systems (including Linux and Mac OS-X) and under MS-
Windows. It allows the use of filenames containing special
-
-
-
- 7 January 2023 62
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
characters, notably spaces. (But note that many versions of
*latex cannot correctly deal with TeX files whose names contain
spaces. Latexmk's quoting only ensures that such filenames are
@@ -4137,6 +4150,18 @@
[Comment to technically savvy readers: *latex doesn't actually
need the modified search path. But, surprisingly, dvipdf and
+
+
+
+ 4 April 2023 63
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
dvips do, because sometimes graphics files get generated in the
output or aux directories.]
@@ -4150,18 +4175,6 @@
goes, of course, for unusual operating systems that are not in
the MSWin, Linux, OS-X, Unix collection.)
-
-
-
- 7 January 2023 63
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
$show_time [0]
Whether to show time used, both the total and for individual
steps.
@@ -4204,6 +4217,17 @@
A value of exactly 0 gives no delay, and typically results in
100% CPU usage, which may not be desirable.
+
+
+ 4 April 2023 64
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$texfile_search [""]
This is an obsolete variable, replaced by the @default_files
variable.
@@ -4216,18 +4240,6 @@
$success_cmd [undefined]
See the documentation for $compiling_cmd.
-
-
-
- 7 January 2023 64
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
$tmpdir [See below for default]
Directory to store temporary files that latexmk may generate
while running.
@@ -4270,6 +4282,18 @@
When the variable is non-zero, latexmk at the end of its run
will return a non-zero status code to the operating system if
+
+
+
+ 4 April 2023 65
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
any of the files processed gives a warning about problems with
citations or references (i.e., undefined citations or references
or multiply defined references). This is after latexmk has com-
@@ -4282,18 +4306,6 @@
The default behavior is normally satisfactory in the usual edit-
compile-edit cycle. But, for example, latexmk can also be used
-
-
-
- 7 January 2023 65
-
-
-
-
-
-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-
@@ -4336,28 +4348,28 @@
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
- insert the -no-pdf option automatically, otherwise you must pro-
- 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 $dvilualatex, $latex,
- $pdflatex, $lualatex, and $xelatex, see the section "Advanced
- Configuration".
+ 4 April 2023 66
- 7 January 2023 66
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ 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
+ insert the -no-pdf option automatically, otherwise you must pro-
+ 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.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ To do a coordinated setting of all of $dvilualatex, $latex,
+ $pdflatex, $lualatex, and $xelatex, see the section "Advanced
+ Configuration".
%xelatex_input_extensions
@@ -4403,29 +4415,27 @@
A better method is to use the subroutines that allow convenient manipu-
lations of the custom dependency list. These are
- add_cus_dep( fromextension, toextension, must, subroutine )
- remove_cus_dep( fromextension, toextension )
- show_cus_dep()
- The arguments are as follows:
- from extension:
- The extension of the file we are converting from (e.g. "fig").
- It is specified without a period.
+ 4 April 2023 67
- 7 January 2023 67
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ add_cus_dep( fromextension, toextension, must, subroutine )
+ remove_cus_dep( fromextension, toextension )
+ show_cus_dep()
+ The arguments are as follows:
+ from extension:
+ The extension of the file we are converting from (e.g. "fig").
+ It is specified without a period.
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
to extension:
The extension of the file we are converting to (e.g. "eps"). It
is specified without a period.
@@ -4470,28 +4480,28 @@
rule is invoked, with an argument that is the base name of the files in
question. Simple cases just involve a subroutine invoking an external
program; this can be done by following the templates below, even by
- those without knowledge of the Perl programming language. Of course,
- experts could do something much more elaborate.
- One item in the specification of each custom-dependency rule, labeled
- "must" above, specifies how the rule should be applied when the source
- file fails to exist.
- When latex reports that an input file (e.g., a graphics file) does not
- exist, latexmk tries to find a source file and a custom dependency that
- can be used to make it. If it succeeds, then it creates an instance of
+ 4 April 2023 68
- 7 January 2023 68
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ those without knowledge of the Perl programming language. Of course,
+ experts could do something much more elaborate.
+ One item in the specification of each custom-dependency rule, labeled
+ "must" above, specifies how the rule should be applied when the source
+ file fails to exist.
+ When latex reports that an input file (e.g., a graphics file) does not
+ exist, latexmk tries to find a source file and a custom dependency that
+ can be used to make it. If it succeeds, then it creates an instance of
the custom dependency and invokes it to make the missing file, after
which the next pass of latex etc will be able to read the newly created
file.
@@ -4536,6 +4546,18 @@
of the form of a variable name, $_[0] in this case, is to be substi-
tuted by its value.
+
+
+
+ 4 April 2023 69
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
If the return value of the subroutine is non-zero, then latexmk will
assume an error occurred during the execution of the subroutine. In
the above example, no explicit return value is given, and instead the
@@ -4547,17 +4569,6 @@
which case you would replace the above code in an initialization file
by
-
-
- 7 January 2023 69
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
add_cus_dep( 'fig', 'pdf, 0, 'fig2pdf' );
sub fig2pdf {
system( "fig2dev -Lpdf \"$_[0].fig\" \"$_[0].pdf\"" );
@@ -4602,28 +4613,26 @@
remove_cus_dep( 'fig', 'eps' );
- If you have complicated sets of custom dependencies, you may want to
- get a listing of the custom dependencies. This is done by using the
- line
- show_cus_dep();
- in an initialization file.
+ 4 April 2023 70
+LATEXMK(1) General Commands Manual LATEXMK(1)
- 7 January 2023 70
+ If you have complicated sets of custom dependencies, you may want to
+ get a listing of the custom dependencies. This is done by using the
+ line
+ show_cus_dep();
+ in an initialization file.
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
Function implementing custom dependency, alternative methods:
So far the examples for functions to implement custom dependencies have
used the argument of the function to specify the base name of converted
@@ -4669,27 +4678,27 @@
function to simplify the definitions to use a single function:
add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
- add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
- sub dx2nd {
- return Run_subst( "makeindex -o %D %S" );
- }
- push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
- You could also instead use
- add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
+ 4 April 2023 71
- 7 January 2023 71
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
+ sub dx2nd {
+ return Run_subst( "makeindex -o %D %S" );
+ }
+ push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
+ You could also instead use
+ add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
sub dx2nd {
return Run_subst( $makeindex );
@@ -4735,27 +4744,27 @@
}
This method still works, and is almost equivalent to the code given
- earlier that used the add_cus_dep subroutine. However, the old method
- doesn't delete any previous custom-dependency for the same conversion.
- So the new method is preferable.
-ADVANCED CONFIGURATION: Some extra resources and advanced tricks
- For most purposes, simple configuration for latexmk along the lines of
- the examples given is sufficient. But sometimes you need something
+ 4 April 2023 72
- 7 January 2023 72
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ earlier that used the add_cus_dep subroutine. However, the old method
+ doesn't delete any previous custom-dependency for the same conversion.
+ So the new method is preferable.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+Advanced configuration: Some extra resources and advanced tricks
+ For most purposes, simple configuration for latexmk along the lines of
+ the examples given is sufficient. But sometimes you need something
harder. In this section, I indicate some extra possibilities. Gener-
ally to use these, you need to be fluent in the Perl language, since
this is what is used in the rc files.
@@ -4800,28 +4809,28 @@
nal" -- see the section FORMAT OF COMMAND SPECIFICATIONS.
When you use a subroutine for processing a rule, all the possibilities
- of Perl programming are available, of course. In addition, some of la-
- texmk's internal variables and subroutines are available. The ones
- listed below are intended to be available to (advanced) users, and
- their specifications will generally have stability under upgrades. Gen-
- erally, the variables should be treated as read-only: Changing their
- values can have bad consequences, since it is liable to mess up the
- consistency of what latexmk is doing.
+ of Perl programming are available, of course. In addition, some of
- $rule This variable has the name of the rule, as known to latexmk.
- Note that the exact contents of this variable for a given rule
+ 4 April 2023 73
- 7 January 2023 73
-
LATEXMK(1) General Commands Manual LATEXMK(1)
+ latexmk's internal variables and subroutines are available. The ones
+ listed below are intended to be available to (advanced) users, and
+ their specifications will generally have stability under upgrades. Gen-
+ erally, the variables should be treated as read-only: Changing their
+ values can have bad consequences, since it is liable to mess up the
+ consistency of what latexmk is doing.
+
+ $rule This variable has the name of the rule, as known to latexmk.
+ Note that the exact contents of this variable for a given rule
may be dependent on the version of latexmk
$$Psource
@@ -4866,20 +4875,11 @@
in the newly specified list of files are removed from the depen-
dency list.
- Run_subst( command_spec )
- This subroutine runs the command specified by command_spec. The
- specification is a string in the format listed in the section
- "Format of Command Specifications". An important action of the
- Run_subst is to make substitutions of placeholders, e.g., %S and
- %D for source and destination files; these get substituted be-
- fore the command is run. In addition, the command after substi-
- tution is printed to the screen unless latexmk is running in
- silent mode.
- 7 January 2023 74
+ 4 April 2023 74
@@ -4888,117 +4888,169 @@
LATEXMK(1) General Commands Manual LATEXMK(1)
+ Run_subst( command_spec )
+ This subroutine runs the command specified by command_spec. The
+ specification is a string in the format listed in the section
+ "Format of Command Specifications". An important action of the
+ Run_subst is to make substitutions of placeholders, e.g., %S and
+ %D for source and destination files; these get substituted be-
+ fore the command is run. In addition, the command after substi-
+ tution is printed to the screen unless latexmk is running in
+ silent mode.
+
+
Coordinated Setting of Commands for *latex
To set all of $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
+ To get the standard commands, use
&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.
+ tion; this indicates to Perl that a subroutine is being called. (The
+ use of this subroutine enables you to override previous redefinitions
+ of the $latex, etc variables, which might have occurred in an earlier-
+ read rc file.)
+ To be able to use the string provided by the -pretex option (if any),
+ you can use
+
&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.
+ This results in $latex = 'latex %O %P', etc. Again note the ampersand
+ in the invocation; this indicates to Perl that a subroutine is being
+ called.
- set_tex_cmds( CMD_SPEC );
+ A more general way of specifying the variables is using
+ 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
+ sults in $latex = 'latex CMD_SPEC', and similarly for $pdflatex, etc.
+ (An ampersand preceding the subroutine name is not necessary here,
+ since the parentheses show Perl that a subroutine is being invoked.)
+ An example that provides the --interaction=batchmode option to the *la-
+ tex commands would be
+
set_tex_cmds( '--interaction=batchmode %O %S' );
+ This results in $latex = 'latex --interaction=batchmode %O %S ', etc.
+ Note that when '%O' appears after the added option, as here, options
+ provided on the command line to latexmk can override the supplied one.
+
+
+
+ 4 April 2023 75
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ A more general command line can be set up by using the placeholder '%C'
+ in CMD_SPEC. The '%C' is substituted by the basic name of the command,
+ i.e., whichever of 'latex', 'pdflatex', etc is appropriate. (More than
+ one occurrence of '%C' is allowed.) For example to use the develop-
+ ment/pre-release versions of latex, etc, which have names, 'latex-dev',
+ 'pdflatex-dev', etc, you could use
+
+ set_tex_cmds( '%C-dev %O %S' );
+
+ This results in $latex = 'latex-dev %O %S', etc. (The pre-release pro-
+ grams latex-dev etc are provided in current distributions of TeXLive
+ and MiKTeX.)
+
+
Advanced configuration: Using latexmk with make
- This section is targeted only at advanced users who use the make pro-
+ This section is targeted only at advanced users who use the make pro-
gram for complex projects, as for software development, with the depen-
dencies specified by a Makefile.
- Now the basic task of latexmk is to run the appropriate programs to
- make a viewable version of a LaTeX document. However, the usual make
- program is not suited to this purpose for at least two reasons. First
+ Now the basic task of latexmk is to run the appropriate programs to
+ make a viewable version of a LaTeX document. However, the usual make
+ program is not suited to this purpose for at least two reasons. First
is that the use of LaTeX involves circular dependencies (e.g., via .aux
files), and these cannot be handled by the standard make program. Sec-
- ond is that in a large document the set of source files can change
- quite frequently, particularly with included graphics files; in this
- situation keeping a Makefile manually updated is inappropriate and er-
+ ond is that in a large document the set of source files can change
+ quite frequently, particularly with included graphics files; in this
+ situation keeping a Makefile manually updated is inappropriate and er-
ror-prone, especially when the dependencies can be determined automati-
cally. Latexmk solves both of these problems robustly.
- Thus for many standard LaTeX documents latexmk can be used by itself
- without the make program. In a complex project it simply needs to be
- suitably configured. A standard configuration would be to define cus-
- tom dependencies to make graphics files from their source files (e.g.,
- as created by the xfig program). Custom dependencies are latexmk's
+ Thus for many standard LaTeX documents latexmk can be used by itself
+ without the make program. In a complex project it simply needs to be
+ suitably configured. A standard configuration would be to define cus-
+ tom dependencies to make graphics files from their source files (e.g.,
+ as created by the xfig program). Custom dependencies are latexmk's
equivalent of pattern rules in Makefiles.
- Nevertheless there are projects for which a Makefile is appropriate,
+ Nevertheless there are projects for which a Makefile is appropriate,
and it is useful to know how to use latexmk from a Makefile. A typical
- example would be to generate documentation for a software project.
+ example would be to generate documentation for a software project. Po-
+ tentially the interaction with the rest of the rules in the Makefile
+ could be quite complicated, for example if some of the source files for
+ a LaTeX document are generated by the project's software.
+ In this section, I give a couple of examples of how latexmk can be use-
+ fully invoked from a Makefile. The examples use specific features of
+ current versions of GNU make, which is the default on both linux and
+ OS-X systems. They may need modifications for other versions of make.
+ The simplest method is simply to delegate all the relevant tasks to la-
+ texmk, as is suitable for a straightforward LaTeX document. For this a
+ suitable Makefile is like
- 7 January 2023 75
+ .PHONY : FORCE_MAKE
+ 4 April 2023 76
-LATEXMK(1) General Commands Manual LATEXMK(1)
- Potentially the interaction with the rest of the rules in the Makefile
- could be quite complicated, for example if some of the source files for
- a LaTeX document are generated by the project's software.
- In this section, I give a couple of examples of how 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.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- The simplest method is simply to delegate all the relevant tasks to la-
- texmk, as is suitable for a straightforward LaTeX document. For this a
- suitable Makefile is like
- .PHONY : FORCE_MAKE
all : try.pdf
%.pdf : %.tex FORCE_MAKE
latexmk -pdf -dvi- -ps- $<
- (Note: the last line must be introduced by a tab for the Makefile to
- function correctly!) Naturally, if making try.pdf from its associated
- LaTeX file try.tex were the only task to be performed, a direct use of
- latexmk without a Makefile would normally be better. The benefit of
- using a Makefile for a LaTeX document would be in a larger project,
+ (Note: the last line must be introduced by a tab for the Makefile to
+ function correctly!) Naturally, if making try.pdf from its associated
+ LaTeX file try.tex were the only task to be performed, a direct use of
+ latexmk without a Makefile would normally be better. The benefit of
+ using a Makefile for a LaTeX document would be in a larger project,
where lines such as the above would be only be a small part of a larger
Makefile.
The above example has a pattern rule for making a .pdf file from a .tex
- file, and it is defined to use latexmk in the obvious way. There is a
+ file, and it is defined to use latexmk in the obvious way. There is a
conventional default target named "all", with a prerequisite of
- try.pdf. So when make is invoked, by default it makes try.pdf. The
- only complication is that there may be many source files beyond
+ try.pdf. So when make is invoked, by default it makes try.pdf. The
+ only complication is that there may be many source files beyond
try.tex, but these aren't specified in the Makefile, so changes in them
- will not by themselves cause latexmk to be invoked. Instead, the pat-
- tern rule is equipped with a "phony" prerequisite FORCE_MAKE; this has
- the effect of causing the rule to be always out-of-date, so that la-
- texmk is always run. It is latexmk that decides whether any action is
- needed, e.g., a rerun of pdflatex. Effectively the Makefile delegates
- all decisions to latexmk, while make has no knowledge of the list of
+ will not by themselves cause latexmk to be invoked. Instead, the pat-
+ tern rule is equipped with a "phony" prerequisite FORCE_MAKE; this has
+ the effect of causing the rule to be always out-of-date, so that la-
+ texmk is always run. It is latexmk that decides whether any action is
+ needed, e.g., a rerun of pdflatex. Effectively the Makefile delegates
+ all decisions to latexmk, while make has no knowledge of the list of
source files except for primary LaTeX file for the document. If there
are, for example, graphics files to be made, these must be made by cus-
tom dependencies configured in latexmk.
- But something better is needed in more complicated situations, for ex-
+ But something better is needed in more complicated situations, for ex-
ample, when the making of graphics files needs to be specified by rules
- in the Makefile. To do this, one can use a Makefile like the follow-
+ in the Makefile. To do this, one can use a Makefile like the follow-
ing:
TARGETS = document1.pdf document2.pdf
@@ -5008,18 +5060,6 @@
-e '@cus_dep_list = ();' \
-e 'show_cus_dep();'
all : $(TARGETS)
-
-
-
- 7 January 2023 76
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
$(foreach file,$(TARGETS),$(eval -include $(DEPS_DIR)/$(file)P))
$(DEPS_DIR) :
mkdir $@
@@ -5029,40 +5069,68 @@
%.pdf : %.fig
fig2dev -Lpdf $< $@
- (Again, the lines containing the commands for the rules should be
+ (Again, the lines containing the commands for the rules should be
started with tabs.) This example was inspired by how GNU automake han-
dles automatic dependency tracking of C source files.
- After each run of latexmk, dependency information is put in a file in
- the .deps subdirectory. The Makefile causes these dependency files to
+ After each run of latexmk, dependency information is put in a file in
+
+
+
+ 4 April 2023 77
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ the .deps subdirectory. The Makefile causes these dependency files to
be read by make, which now has the full dependency information for each
- target .pdf file. To make things less trivial it is specificed that
- two files document1.pdf and document2.pdf are the targets. The depen-
+ target .pdf file. To make things less trivial it is specificed that
+ two files document1.pdf and document2.pdf are the targets. The depen-
dency files are .deps/document1.pdfP and .deps/document2.pdfP.
- There is now no need for the phony prerequisite for the rule to make
+ There is now no need for the phony prerequisite for the rule to make
.pdf files from .tex files. But I have added a rule to make .pdf files
- from .fig files produced by the xfig program; these are commonly used
- for graphics insertions in LaTeX documents. Latexmk is arranged to
+ from .fig files produced by the xfig program; these are commonly used
+ for graphics insertions in LaTeX documents. Latexmk is arranged to
output a dependency file after each run. It is given the -recorder op-
- tion, which improves its detection of files generated during a run of
- pdflatex; such files should not be in the dependency list. The -e op-
- tions are used to turn off all custom dependencies, and to document
- this. Instead the -use-make is used to delegate the making of missing
+ tion, which improves its detection of files generated during a run of
+ pdflatex; such files should not be in the dependency list. The -e op-
+ tions are used to turn off all custom dependencies, and to document
+ this. Instead the -use-make is used to delegate the making of missing
files to make itself.
- Suppose in the LaTeX file there is a command \includegraphics{graph},
- and an xfig file "graph.fig" exists. On a first run, pdflatex reports
- a missing file, named "graph". Latexmk succeeds in making "graph.pdf"
+ Suppose in the LaTeX file there is a command \includegraphics{graph},
+ and an xfig file "graph.fig" exists. On a first run, pdflatex reports
+ a missing file, named "graph". Latexmk succeeds in making "graph.pdf"
by calling "make graph.pdf", and after completion of its work, it lists
"fig.pdf" among the dependents of the file latexmk is making. Then let
- "fig.fig" be updated, and then let make be run. Make first remakes
+ "fig.fig" be updated, and then let make be run. Make first remakes
"fig.pdf", and only then reruns latexmk.
- Thus we now have a method by which all the subsidiary processing is
+ Thus we now have a method by which all the subsidiary processing is
delegated to make.
+ Escaping of characters in dependency lists: There are certain special
+ characters that need to be escaped when names of files and directories
+ containing them appear in a dependency list used by a make program.
+ Generally, such special characters are best avoided.
+ By default, latexmk does no escaping of this kind, and the user will
+ have to arrange to deal with the issue separately, if the relevant spe-
+ cial characters are used. Note that the rules for escaping depend on
+ which make program is used, and on its version.
+
+ One special case is of spaces, since those are particularly prevalent,
+ notably in standard choices of name for a user's home directory. So
+ latexmk does provide an option to escape spaces. See the option
+ -deps_escape=... and the variable $deps_escape for details.
+
+
+
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
@@ -5072,20 +5140,22 @@
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
+ 4 April 2023 78
- 7 January 2023 77
-
LATEXMK(1) General Commands Manual LATEXMK(1)
+ DETAILS TO BE FILLED IN
+
+
+
SEE ALSO
latex(1), bibtex(1), lualatex(1), pdflatex(1), xelatex(1).
@@ -5116,7 +5186,7 @@
dard form to avoid being harvested too easily.)
AUTHOR
- Current version, by John Collins (Version 4.79). Report bugs etc to
+ Current version, by John Collins (Version 4.80). Report bugs etc to
his e-mail (jcc8 at psu.edu).
Released version can be obtained from CTAN:
@@ -5139,10 +5209,6 @@
+ 4 April 2023 79
-
-
- 7 January 2023 78
-
-
Modified: trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl 2023-04-04 20:14:23 UTC (rev 66765)
+++ trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl 2023-04-04 20:14:52 UTC (rev 66766)
@@ -1,43 +1,6 @@
#!/usr/bin/env perl
use warnings;
-# ???!!! TO DO 9 Aug 2022:
-# 0. RETHINK warning listing handling etc, including warnings as
-# errors, bad warnings as errors. Must systematize. Code is too split
-# up.
-# 1b. ===> In any case, check treatment of runs that give an error.
-# 2. Think generally through logic of error handling. E.g., error in
-# xelatex: should dvipdfmx be run? (Or with config. variable for the
-# post-primaries.) Currently it's run. Probably correct: viewed file,
-# if it can be made, can be useful for error diagnosis. Also:
-# consistency between direct making of pdf file and indirect.
-# But abort after error can also be useful.
-# DONE 3. Are post-primaries guaranteed to be run in correct order?
-# YES: See definition of @post_primary.
-# 4. Clean up rdb_diagnose_changes2.
-# COMMENTED OUT FOR NOW 5. Perhaps, remove use of kpsewhich in case of disappeared files?
-# 6. Review rdb_make and rdb_make1 again.
-# 7. Start in -pvc when prior run gave error: There's an error report after
-# the first make. Same outside -pvc if have error run, then run
-# latexmk; it reports error from previous run.
-# 9, Re %pass and rdb_rerun_needed: Perhaps remove outside_make_loop, and
-# have separate subroutine for use by make_preview_continuous, and
-# standard rdb_rerun_needed calls it and then does its source_rule
-# stuff.
-# 10. Do I need to make rdb_user_changes better?
-#
-# OK 12. Is classification of post_primary watertight? They are intended to
-# be outside any loop. Start with target files, and call encountered
-# rules post_primary until a primary is encountered. That assumes that
-# on the pathway to target from primary, source files are not generated
-# by non-primary rules.
-# There's no requirement for post_primaries to be outside dependency
-# loops. The make algorithm handles that. All that matters is that this
-# commonly so, and therefore we are doing an appropriate ordering of
-# examination of rules, by pre-primary, primary, post-primary.
-# Post-primaries always have primary as a prerequisite for the source
-# files.
-
## Copyright John Collins 1998-2023
## (username jcc8 at node psu.edu)
## (and thanks to David Coppit (username david at node coppit.org)
@@ -79,8 +42,8 @@
$my_name = 'latexmk';
$My_name = 'Latexmk';
-$version_num = '4.79';
-$version_details = "$My_name, John Collins, 7 Jan. 2023. Version $version_num";
+$version_num = '4.80';
+$version_details = "$My_name, John Collins, 4 Apr. 2023. Version $version_num";
use Config;
use File::Basename;
@@ -410,6 +373,7 @@
## will give match to line starting "No data file found `filename'"
@file_not_found = (
'^No file\\s*(.*)\\.$',
+ '^No file\\s*(.+)\s*$',
'^\\! LaTeX Error: File `([^\\\']*)\\\' not found\\.',
'^\\! I can\\\'t find file `([^\\\']*)\\\'\\.',
'.*?:\\d*: LaTeX Error: File `([^\\\']*)\\\' not found\\.',
@@ -946,7 +910,64 @@
$tmpdir = ".";
+# Latexmk does tests on whether a particular generated file, e.g., log or
+# fls, has been generated on a current run of a rule, especially *latex, or
+# is leftover from previous runs. This is done by finding whether or not
+# the modification time of the file is at least as recent as the system
+# time at the start of the run. A file with a modification time
+# significantly less than the time at the start of the run is presumably
+# left over from a previous run and not generated in the currrent run. (An
+# allowance is made in this comparison for the effects of granularity of
+# file-system times. Such granularity can make a file time a second or two
+# earlier than the system time at which the file was last modified.)
+#
+# But generated files may be on a file system hosted by a server computer
+# that is different than the computer running latexmk. There may there may
+# be an offset between the time on the two computers; this can make it
+# appear that the generated files were made before the run. Most of the
+# time, this problem does not arise, since (a) typical usage of latexmk is
+# with a local file system, and (b) current-day computers and operating
+# systems have their time synchronized accurately with a time server.
+#
+# But when latexmk sees symptoms of an excessive offset, it measures the
+# offset between the filesystem time and the system time. This involves
+# writing a temporary file, getting its modification time, and deleting
+# it. The following variables are used for this purpose.
+
+#
+our $filetime_offset_measured = 0; # Measurement not yet done.
+our $filetime_offset = 0; # Filetime relative to system time.
+our $filetime_offset_report_threshold = 10; # Threshold beyond which filetime offsets
+ # are reported; large offsets indicate
+ # incorrect system time on at least one system.
+# The following variable gives the threshold for detection of left-over
+# file. It allows for (a) different granularity between system time and
+# filesystem time, (b) for some mismatch between file and system time.
+# Note that the making or not making of a file is controlled by the
+# state of the document being compiled and by latexmk's configuration.
+# So a file that is left over from a previous run and not overwritten
+# on the current run will have a file time at least many seconds less
+# than the current time, corresponding to the time scale for a human
+# run-edit-run cycle.
+#
+# Note that the making or not making of a file is controlled by the
+# state of the document being compiled and by latexmk's configuration.
+# So a file that is left over from a previous run and not overwritten
+# on the current run will have a file time at least many seconds less
+# than the current time, corresponding to the time scale for a human
+# run-edit-run cycle. So one does NOT have to tune this variable
+# precisely.
+#
+# Concerning granularity of file system
+# FAT file system: 2 sec granularity. Others 1 sec or less.
+# Perl CORE's mtime in stat: 1 sec.
+# Perl CORE's time(): 1 sec. Time::HiRes::time(): Much less than 1 sec.
+
+our $filetime_causality_threshold = 5;
+
+
################################################################
+################################################################
# System-dependent overrides:
@@ -1387,6 +1408,11 @@
# (as with 'gcc -MP').
$deps_file = '-'; # File for dependency list output. Default stdout.
$rules_list = 0; # Whether to display list(s) of dependencies
+# Kind of escaping in names of files written to deps file.
+$deps_escape = 'none';
+# Allowed kinds of escape:
+%deps_escape_kinds = ( 'none' => ' ', 'unix' => '\ ', 'nmake' => '^ ');
+
@dir_stack = (); # Stack of pushed directories, each of form of
# pointer to array [ cwd, good_cwd ], where
# good_cwd differs from cwd by being converted
@@ -1431,14 +1457,7 @@
# appears not to included subprocess times, so we use clock time instead.
our $times_are_clock = ($^O eq "MSWin32" );
-# Allowance for different granularity in time since Epoch and file mtime.
-# Needed in testing whether a file was generated during a run of a program.
-# FAT file system: 2 sec granularity. Others 1 sec or less.
-# Perl CORE's mtime in stat: 1 sec.
-# Perl CORE's time(): 1 sec. Time::HiRes::time(): Much less than 1 sec.
-our $filetime_slop = 2;
-
# Data for 1 run and global (ending in '0'):
our ( $processing_time1, $processing_time0, @timings1, @timings0);
&init_timing_all;
@@ -1650,7 +1669,7 @@
# out_of_date, out_of_date_user,
# time_of_last_run, time_of_last_file_check,
# changed
- # last_result, last_message,
+ # last_result, last_result_info, last_message,
# default_extra_generated,
# ]
# where
@@ -1727,6 +1746,19 @@
# important enough to be reported with
# the error summary. The warning
# message is stored in last_message.
+ # last_result_info is info about run that gave
+ # code in last_result. Currently used values:
+ # '' No record of this rule being run
+ # 'CURR' Run of rule was in current
+ # round of compilation.
+ # 'PREV' Run of rule was in a previous
+ # round of compilation (as with
+ # -pvc), but in current invocation
+ # of latexmk.
+ # 'CACHE' Run of rule was in a previous
+ # invocation of latexmk, with
+ # last_result having been read
+ # from fdb_latexmk file.
# last_message is error message for last run
# default_extra_generated is a reference to an array
# of specifications of extra generated files (beyond
@@ -1950,8 +1982,7 @@
@command_line_file_list = ();
$bad_options = 0;
-while ($_ = $ARGV[0])
-{
+while (defined($_ = $ARGV[0])) {
# Make -- and - equivalent at beginning of option,
# but save original for possible use in *latex command line
$original = $_;
@@ -1976,6 +2007,12 @@
elsif (/^-d$/) { $banner = 1; }
elsif (/^-dependents$/ || /^-deps$/ || /^-M$/ ) { $dependents_list = 1; }
elsif (/^-nodependents$/ || /^-dependents-$/ || /^-deps-$/) { $dependents_list = 0; }
+ elsif (/^-deps-escape=(.*)$/) {
+ if ( $deps_escape_kinds{$1} ) { $deps_escape = $1; }
+ else { warn "$My_name: In '$_', kind of escape is not one of those I know, which are\n",
+ " ", join( ' ', sort( keys %deps_escape_kinds )), "\n";
+ }
+ }
elsif (/^-deps-out=(.*)$/) {
$deps_file = $1;
$dependents_list = 1;
@@ -2758,8 +2795,7 @@
# assisted by dependency information from log files about previous
# run, if the log file exists.
- if ( $cleanup_mode ) { &do_small_cleanup; }
- if ( $cleanup_mode == 1 ) { &do_extra_cleanup; }
+ if ( $cleanup_mode ) { do_cleanup( $cleanup_mode ); }
if ($cleanup_only) { next FILE; }
if ( ! -e $aux_main ) {
@@ -2877,6 +2913,27 @@
&finish_dir_stack;
}
+if ($filetime_offset_measured) {
+ if ( (abs($filetime_offset) >= $filetime_offset_report_threshold)
+ && ($diagnostics || ! $silent) )
+ {
+ warn "$My_name: I am working around an offset relative to my system time by\n",
+ " $filetime_offset secs for file times in directory '$aux_dir1'.\n",
+ " This **probably** indicates that \n",
+ " (a) I ($my_name) am running on one computer, while the filesystem is\n",
+ " hosted on a different computer/\n",
+ " (b) There is a substantial time offset between system times on the two\n",
+ " computers.\n",
+ " (c) Therefore at least one of the computers has a misconfigured operating\n",
+ " system such that its system time is not correctly synchronized with a\n",
+ " time server.\n",
+ " These issues are likely to cause problems with other software, and any\n",
+ " such operating-system misconfigurations should be corrected. By default\n",
+ " current operating systems are configured to correctly synchronize system\n",
+ " time when they are connected to the Internet\n";
+ }
+}
+
if ($failure_count > 0) {
if ( $#file_list > 0 ) {
# Error occured, but multiple files were processed, so
@@ -2961,9 +3018,13 @@
sub set_tex_cmds {
# Usage, e.g., set_tex_cmds( '%O %S' )
+ # or set_tex_cmds( '%C-dev %O %S' )
my $args = $_[0];
foreach my $cmd ( keys %possible_primaries ) {
- ${$cmd} = "$cmd $args";
+ my $spec = $args;
+ if ( $spec =~ /%C/ ) { $spec =~ s/%C/$cmd/g; }
+ else { $spec = "$cmd $args"; }
+ ${$cmd} = $spec;
}
# N.B. See setting of $latex_default_switches, ...,
# $xelatex_default_switches, etc, for any special options needed.
@@ -3646,17 +3707,65 @@
#************************************************************
#************************************************************
-sub do_extra_cleanup {
- print "$My_name: Doing extra clean up (of final output files) for '$texfile_name'\n"
- if ! $silent;
- cleanup1( $aux_dir1, @final_output_exts );
- if ( $out_dir1 ne $aux_dir1 ) { cleanup1( $out_dir1, @final_output_exts ); }
-} # END do_extra_cleanup
+sub do_cleanup {
+ my $kind = $_[0];
+ if (! $kind ) { return; }
+ my @files_to_delete = ();
+ @dirs = ($aux_dir1);
+ if ($out_dir1 ne $aux_dir1) { push @dirs, $out_dir1; }
+
+ push @files_to_delete, &get_small_cleanup;
+ if ($kind == 1) {
+ foreach my $dir1 (@dirs) {
+ push @files_to_delete, cleanup_get1( $dir1, @final_output_exts );
+ }
+ }
+ # show_array( "Files to delete", sort @files_to_delete );
-#************************************************************
+ # Names of contents of directory are longer than the name of the directory,
+ # but contain the directory name as an initial segment.
+ # Therefore deleting files and directories in the order given by reverse
+ # sort deletes contents of directory before attempting to delete the
+ # directory:
+ unlink_or_move( reverse sort @files_to_delete );
+
+ # If the fdb file (or log, fls and/or aux files) exist, it/they will have
+ # been used to make a changed rule database. But a cleanup implies
+ # that we need a virgin rule database, corresponding to current state
+ # of files (after cleanup) so we reset the rule database and rule net:
+ &rdb_initialize_rules;
+}
-sub do_small_cleanup {
- # Assume dependency information from previous run has been obtained.
+#----------------------------------------
+
+sub cleanup_get1 {
+ # Usage: cleanup_get1( directory, patterns_or_exts_without_period, ... )
+ # Return array of files obeying the specification in the given directory.
+ # Specifications are either extensions to be appended to root_filename
+ # or are patterns containing %R for root_filename of job, with possible
+ # wildcards.
+ # Directory name must include directory separator, e.g., './' or 'output/',
+ # or be blank, i.e., suitable for prepending to file name.
+
+ # The directory and the root file name are fixed names, so I must escape
+ # any glob metacharacters in them:
+ my $dir = fix_pattern( shift );
+ my $root_fixed = fix_pattern( $root_filename );
+ my @files = ();
+ foreach (@_) {
+ my $name = ( /%R/ ? $_ : "%R.$_" );
+ $name =~ s/%R/${root_fixed}/;
+ $name = $dir.$name;
+ push @files, my_glob( "$name" );
+ }
+ return @files;
+} #END cleanup_get1
+
+#----------------------------------------
+
+sub get_small_cleanup {
+ # Get list of files to be deleted in a small cleanup.
+ # Assume dependency information from previous run has been obtained.
my %other_generated = ();
my %cusdep_generated = ();
my @index_bibtex_generated = ();
@@ -3759,32 +3868,22 @@
}
my @clean_args = keys %generated_exts;
- cleanup1( $aux_dir1, @clean_args );
- if ( $out_dir1 ne $aux_dir1 ) { cleanup1( $out_dir1, @clean_args ); }
+ push @files, cleanup_get1( $aux_dir1, @clean_args );
+ if ( $out_dir1 ne $aux_dir1 ) { push @files, cleanup_get1( $out_dir1, @clean_args ); }
- my @specific_deletions = @std_small_cleanup_files;
+ push @files, @std_small_cleanup_files;
foreach my $file (@std_small_cleanup_files) {
foreach my $dir ($aux_dir1, $out_dir1 ) {
- if ($dir) { push @specific_deletions, "$dir$file"; }
+ if ($dir) { push @files, "$dir$file"; }
}
}
- unlink_or_move( @specific_deletions,
- keys %index_bibtex_generated,
- keys %aux_files );
+ push @files, keys %index_bibtex_generated, keys %aux_files;
- if ($cleanup_includes_generated) {
- unlink_or_move( keys %other_generated );
- }
- if ( $cleanup_includes_cusdep_generated) {
- unlink_or_move( keys %cusdep_generated );
- }
- unlink_or_move( $fdb_name );
- # If the fdb file (or log, fls and/or aux files), it/they will have been
- # used to make a changed rule database. But a cleanup implies that we
- # need a virgin rule database, corresponding to current state of files,
- # so we reset the rule database and net:
- &rdb_initialize_rules;
-} # END do_small_cleanup
+ if ($cleanup_includes_generated) { push @files, keys %other_generated; }
+ if ( $cleanup_includes_cusdep_generated) { push @files, keys %cusdep_generated; }
+ push @files, $fdb_name;
+ return @files;
+} # END get_small_cleanup
#************************************************************
@@ -4211,6 +4310,14 @@
$have_break = 0;
$last_action_time = time();
$waiting = 1;
+ rdb_for_some(
+ [keys %rule_db],
+ sub{
+ if ($$Plast_result_info eq 'CURR') {
+ $$Plast_result_info = 'PREV';
+ }
+ }
+ );
print "\n=== Watching for updated files. Use ctrl/C to stop ...\n";
WAIT: while (1) {
sleep( $sleep_time );
@@ -4369,23 +4476,6 @@
#************************************************************
-sub cleanup1 {
- # Usage: cleanup1( directory, exts_without_period, ... )
- #
- # The directory and the root file name are fixed names, so I must escape
- # any glob metacharacters in them:
- my $dir = fix_pattern( shift );
- my $root_fixed = fix_pattern( $root_filename );
- foreach (@_) {
- my $name = /%R/ ? $_ : "%R.$_";
- $name =~ s/%R/${root_fixed}/;
- $name = $dir.$name;
- unlink_or_move( my_glob( "$name" ) );
- }
-} #END cleanup1
-
-#************************************************************
-
sub cleanup_cusdep_generated {
# Remove files generated by custom dependencies
rdb_for_actives( \&cleanup_one_cusdep_generated );
@@ -4523,6 +4613,8 @@
" -cd- - Do NOT change to directory of source file when processing it\n",
" -dependents or -deps - Show list of dependent files after processing\n",
" -dependents- or -deps- - Do not show list of dependent files\n",
+ " -deps-escape=<kind> - Set kind of escaping of spaces in names in deps file\n",
+ " (Possible values: ", join( ' ', sort keys %deps_escape_kinds ), ")\n",
" -deps-out=file - Set name of output file for dependency list,\n",
" and turn on showing of dependency list\n",
" -dF <filter> - Filter to apply to dvi file\n",
@@ -5100,15 +5192,24 @@
# Deal with situations after a *latex run where files are in different
# directories than expected (specifically aux v. output directory).
# Do minimal fix ups to allow latexmk to analyze dependencies with log
- # and fls files in expected places
+ # and fls files in expected places.
+
+
+ # Deal with log file in unexpected place (e.g., lack of support by *latex
+ # of -aux-directory option. This is to be done first, since a run of
+ # *latex always produces a log file unless there is a bad error, so
+ # this gives the best chance of diagnosing errors.
+ my $where_log = &find_set_log;
+
if ( $emulate_aux && ($aux_dir ne $out_dir) ) {
- # Move output and fls files to out_dir
+ # Move output files from aux_dir to out_dir
+ # Move fls file also, if the configuration is for fls in out_dir.
# Omit 'xdv', that goes to aux_dir (as with MiKTeX). It's not final output.
foreach my $ext ( 'fls', 'dvi', 'pdf', 'ps', 'synctex', 'synctex.gz' ) {
if ( ($ext eq 'fls') && ! $fls_uses_out_dir ) {next;}
my $from = "$aux_dir1$root_filename.$ext";
my $to = "$out_dir1$root_filename.$ext" ;
- if ( test_gen_file( $from ) ) {
+ if ( test_gen_file_time( $from ) ) {
if (! $silent) { print "$My_name: Moving '$from' to '$to'\n"; }
my $ret = move( $from, $to );
if ( ! $ret ) { die " That failed, with message '$!'\n";}
@@ -5116,10 +5217,6 @@
}
}
- # Deal with log file in unexpected place (e.g., lack of support by *latex
- # of -aux-directory option.
- &find_set_log;
-
# Fix ups on fls file:
if ($recorder) {
# Deal with following special cases:
@@ -5167,11 +5264,11 @@
# place. But only do this if the file time is compatible with being
# generated in the current run, and if the standard fls file hasn't
# been made in the current run, as tested by the use of
- # test_gen_file; that avoids problems with fls files left over from
+ # test_gen_file_time; that avoids problems with fls files left over from
# earlier runs with other versions of latex.
- if ( ! test_gen_file( $std_fls_file ) ) {
+ if ( ! test_gen_file_time ( $std_fls_file ) ) {
foreach my $cand (@other_fls_names) {
- if ( test_gen_file( $cand ) ) {
+ if ( test_gen_file_time( $cand ) ) {
print "$My_name: Copying '$cand' to '$std_fls_file'.\n";
copy $cand, $std_fls_file;
last;
@@ -5178,7 +5275,7 @@
}
}
}
- if ( ! test_gen_file( $std_fls_file ) ) {
+ if ( ! test_gen_file_time( $std_fls_file ) ) {
warn "$My_name: fls file doesn't appear to have been made.\n";
}
}
@@ -5186,37 +5283,120 @@
#-----------------
+sub find_log {
+ # Locate log file generated on this run.
+ # Side effect: measure filetime offset if necessary.
+ # Don't take other actions.
+ # Returns
+ # 0 log file not found;
+ # 1 log file in aux_dir i.e., correct place;
+ # 2 log file **not** in aux_dir but in out_dir
+ # (only applies if $emulate_aux off)
+ # 3 log file is in ., not aux_dir or out_dir.
+ # 4 log file in aux_dir, but out-of-date
+ # 5 log file in out_dir, but out-of-date,
+ # (only applies if $emulate_aux off)
+ # 6 log file is in ., but out-of-date
+
+
+ my $where_log = -1; # Nothing analyzed yet
+ my $log_aux = "$aux_dir1$root_filename.log";
+ my $log_out = "$out_dir1$root_filename.log";
+ my $log_cwd = "./$root_filename.log";
+
+ # Basic tests first that assume accuracy of time of file system:
+ if ( test_gen_file_time( $log_aux ) ) {
+ # Expected case
+ return 1;
+ }
+ elsif ( (! $emulate_aux) && test_gen_file_time( $log_out ) ) {
+ # *latex was called with -aux-directory option, but does not
+ # implement it (e.g., TeXLive's version)
+ return 2;
+ }
+ elsif ( test_gen_file_time( $log_cwd ) ) {
+ # Arrive here typically with configuration error so that aux_dir
+ # and/or out_dir aren't supplied to *latex.
+ return 3;
+ }
+
+ # Arrive here only if a log file with a time stamp not too much earlier
+ # than the run time has not found in a relevant place.
+ # If relevant files exist, then we must test for a serious offset
+ # between system time and filesystem time (i.e., filesystem server
+ # time).
+ if ( ! $filetime_offset_measured ) {
+ $filetime_offset = get_filetime_offset( $aux_dir1."tmp" );
+ $filetime_offset_measured = 1;
+ }
+
+ my @candidates = ( );
+ my $latest_mtime = undef;
+ my $latest_log = undef;
+
+ if ( -e $log_aux ) {
+ if ( test_gen_file_time( $log_aux ) ) { return 1; }
+ return 4;
+ }
+ # Get here if log file in aux doesn't exist or is apparently too old.
+ if ( (! $emulate_aux) && ( -e $log_out ) ) {
+ if (test_gen_file_time( $log_out ) ) { return 2; }
+ return 5;
+ }
+ if ( -e $log_cwd ) {
+ if (test_gen_file_time( $log_cwd ) ) { return 3; }
+ return 6;
+ }
+ return 0;
+}
+
sub find_set_log {
# Locate the log file, generated on this run.
# It should be in aux_dir. But:
- # 1. With a sufficiently severe error in *latex, no log file was generated.
- # 2. With aux_dir ne out_dir and emulate_aux off and a (TeXLive) *latex
+ # a. With aux_dir ne out_dir and emulate_aux off and a (TeXLive) *latex
# that doesn't support aux_dir, the log file is in out_dir.
- # 3. If the specified command has no %O or if *latex doesn't support
+ # b. If the specified command has no %O or if *latex doesn't support
# out_dir (hence not TeXLive and not MiKTeX), the log file would
# be in cwd.
+ # c. With a sufficiently severe error in *latex, no log file was generated.
+ # Any log file that exists will be a left over from a previous run,
+ # and hence have a filetime less than the system time at the start of
+ # the current run. (The strict filetime criterion is modified in the
+ # implementation to allow for issues from file system's time
+ # granularity, and mismatch of time on server hosting file system.)
#
- # 3 is fatal error.
- # 2 is handled by turning emulate_aux on, after which next run of *latex
- # handles problem.
- # 1 is like any other error.
- # 4 is treated like 1 (log file not found).
- #
- # Returns
+ # Possible return values, and side effects.
# 0 log file not found;
# 1 log file in aux_dir i.e., correct place;
- # 2 log file **not** in aux_dir but in out_dir,
- # emulate_aux turned on, commands fixed,
- # and log file copied to aux_dir
- # If the log file is found in cwd, report it and give fatal error.
-
- my $where_log = -1; # Nothing analyzed yet
+ # 2 log file **not** in aux_dir but in out_dir
+ # (only applies if $emulate_aux off)
+ # $emulate_aux turned on, commands fixed, log file copied to
+ # aux_dir, and flags set to cause rerun
+ # 3 log file is in ., not aux_dir or out_dir.
+ # Fatal error raised here, since cause is normally a configuration error
+ # not an error caused by contents of user file.
+ # 4 log file in aux_dir, but out-of-date
+ # 5 log file in out_dir, but out-of-date,
+ # (only applies if $emulate_aux off)
+ # 6 log file is in ., but out-of-date
+ #
+ # Cases: 0, 4, 5, 6 are error conditions to be handled by caller
+ # 2 is to be handled by caller by a rerun
+ # 1 is success.
- if ( test_gen_file( "$aux_dir1$root_filename.log" ) ) {
- # .log file is in expected place.
- $where_log = 1;
+
+ my $log_aux = "$aux_dir1$root_filename.log";
+ my $log_out = "$out_dir1$root_filename.log";
+ my $log_cwd = "./$root_filename.log";
+
+ my $where_log = &find_log;
+ my $good_log_found = 0;
+
+ if ($where_log == 1 ) {
+ # As expected
+ $good_log_found = 1;
}
- elsif ( (! $emulate_aux) && test_gen_file( "$out_dir1$root_filename.log" ) ) {
+ elsif ($where_log == 2 ) {
warn "$My_name: .log file in '$out_dir' instead of expected '$aux_dir'\n",
" But emulate_aux is off. So I'll turn it on.\n",
" I'll copy the log file to the correct place.\n",
@@ -5231,8 +5411,9 @@
s/ -output-directory=[^ ]*(?= )//g;
s/ -aux(-directory=[^ ]*)(?= )/ -output$1/g;
}
+ $good_log_found = 1;
}
- elsif ( test_gen_file( "$root_filename.log" ) ) {
+ if ($where_log == 3 ) {
# .log file is not in out_dir nor in aux_dir, but is in cwd.
# Presumably there is a configuration error
# that prevents the directories from being used by latex.
@@ -5242,14 +5423,35 @@
" options with the *latex command.\n",
" I'll stop.\n";
}
- else {
- # No .log file found
+ elsif ($where_log == 4 ) {
+ warn "$My_name: The expected log file, '$log_aux', does exist, but it appears\n",
+ " to be left over from a previous run: The time at the start of the\n",
+ " current run was $$Prun_time, but the log file appears to have been\n",
+ " created significantly earlier, at ", get_mtime($log_aux), ".\n";
+ }
+ elsif ($where_log == 5 ) {
+ warn "$My_name: The expected log file, '$log_aux', does not exist, but one is found\n",
+ " in '$out_dir', but it apears to be left over from a previous run. The time\n",
+ " at the start of the current run was $$Prun_time, but the log file appears to\n",
+ " have been created significantly earlier, at ", get_mtime($log_out), ".\n";
+ }
+ elsif ($where_log == 6 ) {
+ warn "$My_name: The expected log file, '$log_aux', does not exist, but one is found\n",
+ " in '.', but it apears to be left over from a previous run. The time\n",
+ " at the start of the current run was $$Prun_time, but the log file appears to\n",
+ " have been created significantly earlier, at ", get_mtime($log_cwd), ".\n";
+ }
+ elsif ($where_log == 0) {
+ warn "$My_name: No log file was found, neither the expected one, '$log_aux', nor one in '.'.\n";
+ if (! $emulate_aux) { warn " I also looked in '$out_dir'\n"; }
+ }
+ if ( ! $good_log_found ) {
$failure = 1;
$$Plast_result = 2;
- $where_log = 0;
$failure_msg
= "*LaTeX didn't generate the expected log file '$log_name'\n";
}
+
return $where_log;
} #END find_set_log
@@ -6960,6 +7162,7 @@
$$Prun_time = $run_time;
$$Pcheck_time = $check_time;
$$Plast_result = $last_result;
+ $$Plast_result_info = 'CACHE';
# Deal with possibility that destination file in fdb_latexmk from
# run differs from what is currently set. Often that just reflects a
@@ -7249,7 +7452,7 @@
# But we'll use the results later, so that they take priority over the findings
# from the log file.
local $fls_file_analyzed = 0;
- if ($recorder && test_gen_file($fls_name) ) {
+ if ($recorder && test_gen_file_time($fls_name) ) {
$fls_file_analyzed =
(0== parse_fls( $fls_name, \%source_fls, \%generated_fls, \%first_read_after_write, \$pwd_latex ));
if (! $fls_file_analyzed ) {
@@ -7590,7 +7793,7 @@
}
if ($diagnostics) {
if ($num_new > 0 ) {
- show_array( "$num_new new source files for rule '$rule':", @more_sources );k { print " '$_'\n"; }
+ show_array( "$num_new new source files for rule '$rule':", @more_sources );
}
else {
print "No new source files for rule '$rule':\n";
@@ -7684,24 +7887,29 @@
sub test_gen_file {
# Usage: test_gen_file( filename )
- # Tests whether the file was generated during a run of *latex.
+ # Tests whether a file of given name was generated during current run
+ # of *latex, with override of comparison of file and run time by
+ # file being listed in %generated_log or %generated_fls
# Assumes context for primary rule.
- # Two kinds of test are used:
- # a. From %generated_log and %generated_fls, which works after the fls and
- # log files hav been parsed, but in the log file only for certain files
- # and for those TeX engines (not MiKTeX) that put \openout lines in log
- # file.
- # b. By the file existing and being at least as new as the system
- # time at the start of the run. But make an allowance ($filetime_slop) for
- # differences in granularity between reported system time and reported
- # file mtimes.
my $file = shift;
return exists $generated_log{$file} || $generated_fls{$file}
- || ( -e $file && ( get_mtime( $file ) >= $$Prun_time - $filetime_slop ));
+ || test_gen_file_time($file);
}
#************************************************************
+sub test_gen_file_time {
+ # Usage: test_gen_file_time( filename )
+ # Tests whether a file of given name exists and was generated during
+ # current run of *latex. Comparison of file and run time used for
+ # testing whether file was generated or is left over from a previous run.
+ #
+ my $file = shift;
+ return (-e $file) && ( get_mtime( $file ) >= $$Prun_time + $filetime_offset - $filetime_causality_threshold );
+}
+
+#************************************************************
+
sub dep_at_start {
# Usage: dep_at_start( filename )
# Tests whether the file was source file and existed at start of run.
@@ -7855,6 +8063,11 @@
return;
}
local $new_dest = $file;
+ if ($$PHdest{$new_dest} ) {
+ # We already have a way of making the file.
+ # No need to find another one.
+ return;
+ }
my ($base_name, $path, $toext) = fileparseA( $new_dest );
$base_name = $path.$base_name;
$toext =~ s/^\.//;
@@ -7863,6 +8076,7 @@
foreach my $dep ( @cus_dep_list ) {
my ($fromext,$proptoext,$must,$func_name) = split('\s+',$dep);
if ( $toext eq $proptoext ) {
+ # Look in search path for file of correct name:
$base_name = rdb_find_source_file($base_name, $fromext);
my $source = "$base_name.$fromext";
# Found match of rule
@@ -7872,6 +8086,11 @@
if ( -e $source ) {
my $from_rule = "cusdep $fromext $toext $base_name";
my $new_new_dest = "$base_name.$toext";
+ if ($$PHdest{$new_new_dest} ) {
+ # We already have a way of making the file.
+ # No need to find another one.
+ return;
+ }
if ($new_new_dest ne $new_dest) {
rdb_ensure_file( $rule, $new_new_dest );
$new_dest = $new_new_dest;
@@ -7919,6 +8138,11 @@
if ( -e $source ) {
$new_dest = "$base_name.$proptoext";
my $from_rule = "cusdep $fromext $proptoext $base_name";
+ if ( $$PHdest{$new_dest} ) {
+ # We already have a way of making the file.
+ # No need to find another one.
+ return;
+ }
push @new_sources, $new_dest;
print "$My_name: Ensuring rule for '$from_rule', to make '$new_dest'\n"
if $diagnostics > -1;
@@ -8009,6 +8233,15 @@
if ($dvi_mode) {push @dest_exts, '.dvi';}
if ($postscript_mode) {push @dest_exts, '.ps';}
+ my $deps_space = ' ';
+ if ($deps_escape eq 'unix' ) { $deps_space = '\ '; }
+ elsif ($deps_escape eq 'nmake' ) { $deps_space = '^ '; }
+ $Pescape = sub {
+ my $name = shift;
+ $name =~ s/ /$deps_space/g;
+ return $name;
+ };
+
my %source = ( $texfile_name => 1 );
my @accessible_all = &rdb_accessible;
rdb_for_some(
@@ -8036,9 +8269,9 @@
# deps file out-of-date are the same as those that make the real
# target file (e.g., .pdf) out-of-date. So the GNU method seems
# completely unnecessary.
- fprint8 $fh, "${out_dir1}${root_filename}${ext} :";
+ fprint8 $fh, &$Pescape(${out_dir1}.${root_filename}.${ext}), " :";
foreach (sort keys %source) {
- fprint8 $fh, "\\\n $_";
+ fprint8 $fh, "\\\n ", &$Pescape($_);
}
fprint8 $fh, "\n";
}
@@ -8067,7 +8300,8 @@
if ( !defined($_) ) { $_='undef';}
}
print " [$rule]: '$$Pcmd_type' '$$Pext_cmd' '@int_cmd' $$Pno_history ",
- "'$$Psource' '$$Pdest' '$$Pbase' $$Pout_of_date $$Pout_of_date_user\n"; },
+ "'$$Psource' '$$Pdest' '$$Pbase' $$Pout_of_date $$Pout_of_date_user\n";
+ },
sub{ print " '$file': $$Ptime $$Psize $$Pmd5 '", ($from_rules{$file} || ''), "'\n"; }
);
if ($count_rules <= 0) {
@@ -8554,26 +8788,33 @@
local @errors = ();
local @warnings = ();
rdb_for_actives(
- sub{
- if ($$Plast_message ne '') {
- if ($$Plast_result == 200) {
- push @warnings, "$rule: $$Plast_message";
- }
- else {
- push @errors, "$rule: $$Plast_message";
- }
- }
- elsif ($$Plast_result == 1) {
- push @errors, "$rule: failed to create output file";
- }
- elsif ($$Plast_result == 2) {
- push @errors, "$rule: gave an error";
- }
- elsif ($$Prun_time == 0) {
- # This can have innocuous causes. So don't report
- }
- }
- );
+ sub {
+ my $message_tail = "";
+ if ( $$Plast_result_info eq 'PREV' ) {
+ $message_tail = " in previous round of document compilation.";
+ }
+ elsif ( $$Plast_result_info eq 'CACHE' ) {
+ $message_tail = " in previous invocation of $my_name.";
+ }
+ if ($$Plast_message ne '') {
+ if ($$Plast_result == 200) {
+ push @warnings, "$rule: $$Plast_message";
+ }
+ else {
+ push @errors, "$rule: $$Plast_message";
+ }
+ }
+ elsif ($$Plast_result == 1) {
+ push @errors, "$rule: failed to create output file$message_tail";
+ }
+ elsif ($$Plast_result == 2) {
+ push @errors, "$rule: gave an error$message_tail";
+ }
+ elsif ($$Prun_time == 0) {
+ # This can have innocuous causes. So don't report
+ }
+ }
+ );
if ($#warnings > -1) {
show_array( "Collected warning summary (may duplicate other messages):". @warnings );
}
@@ -8761,6 +9002,7 @@
$$Pchanged = 0; # No special changes in files
$$Plast_result = 0;
+ $$Plast_result_info = 'CURR';
$$Plast_message = '';
my $latex_like = ($$Pcmd_type eq 'primary');
@@ -8983,6 +9225,7 @@
$$Prun_time = time();
$$Pchanged = 0; # No special changes in files
$$Plast_result = 0;
+ $$Plast_result_info = 'CURR';
$$Plast_message = '';
$$Pout_of_date = $$Pout_of_date_user = 0;
@@ -9343,7 +9586,7 @@
}
# Non-source-file-change reasons for rerun:
- if ( ( ($$Prun_time == 0) || ( $$Plast_result == -1 ) )
+ if ( ( ($$Prun_time == 0) || ( $$Plast_result =~ /^-1/ ) )
&& ( $$Pcmd_type eq 'primary' ) )
{
# Never run. Only use this test with primary, so we can get
@@ -9736,7 +9979,7 @@
$Psource, $Pdest, $Pbase,
$Pout_of_date, $Pout_of_date_user, $Prun_time, $Pcheck_time,
$Pchanged,
- $Plast_result, $Plast_message, $PA_extra_gen )
+ $Plast_result, $Plast_result_info, $Plast_message, $PA_extra_gen )
= Parray( $PArule_data );
&$rule_act1 if $rule_act1;
@@ -9830,7 +10073,6 @@
#************************************************************
sub rdb_create_rule {
- # ???!!! 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,
@@ -9842,7 +10084,12 @@
# Makes rule. Update rule if it already exists.
# Omitted arguments: replaced by 0, '', or [] as needed.
# Rule is made active
-# ==== Sets rule data ====
+ # 5th argument DUMMY is argument that used to be used (test_kind), but
+ # is not used any more. But I keep it there to avoid having to change
+ # calls, which are not only in the latexmk code itself, but may be in
+ # latexmkrc files created by others.
+
+# ==== Set rule data from arguments ====
my ( $rule, $cmd_type, $ext_cmd, $PAint_cmd, $DUMMY,
$source, $dest, $base,
$needs_making, $run_time, $check_time, $set_file_not_exists,
@@ -9859,6 +10106,7 @@
if (! defined $_) { $_ = []; }
}
my $last_result = -1;
+ my $last_result_info = '';
my $no_history = ($run_time <= 0);
my $active = 1;
my $changed = 0;
@@ -9884,7 +10132,7 @@
[ [$cmd_type, $ext_cmd, $PAint_cmd, $no_history,
$source, $dest, $base,
$needs_making, 0, $run_time, $check_time, $changed,
- $last_result, '', $PAextra_gen ],
+ $last_result, $last_result_info, '', $PAextra_gen ],
{},
{},
{},
@@ -10540,12 +10788,14 @@
if (!-e) {next;}
if (-d) {
if (!rmdir) {
- warn "$My_name: Cannot remove directory '$_'\n";
+ warn "$My_name: Cannot remove directory '$_'\n",
+ " Error message = '$!'\n";
}
}
else {
if (!unlink) {
- warn "$My_name: Cannot remove file '$_'\n";
+ warn "$My_name: Cannot remove file '$_'\n",
+ " Error message = '$!'\n";
}
}
}
@@ -10553,7 +10803,8 @@
else {
foreach (@_) {
if (-e $_ && ! move $_, "$del_dir/$_" ) {
- warn "$My_name: Cannot move '$_' to '$del_dir/$_'\n";
+ warn "$My_name: Cannot move '$_' to '$del_dir/$_'\n",
+ " Error message = '$!'\n";
}
}
}
@@ -10981,6 +11232,36 @@
#################################
+sub get_filetime_offset {
+ # Usage: get_filetime_offset( prefix, [suffix] )
+ # Measures offset between filetime in a directory and system time
+ # Makes a temporary file of a unique name, and deletes in.
+ # Filename is of form concatenation of prefix, an integer, suffix.
+ # Prefix is normally of form dir/ or dir/tmp.
+ # Default default suffix ".tmp".
+ my $prefix = $_[0];
+ my $suffix = $_[1] || '.tmp';
+ my $tmp_file_count = 0;
+ while (1==1) {
+ # Find a new temporary file, and make it.
+ $tmp_file_count++;
+ my $tmp_file = "${prefix}${tmp_file_count}${suffix}";
+ if ( ! -e $tmp_file ) {
+ open( TMP, ">$tmp_file" )
+ or die "$My_name.get_filetime_offset: In measuring filetime offset, couldn't write to\n",
+ " temporary file '$tmp_file'\n";
+ my $time = time();
+ close(TMP);
+ my $offset = get_mtime($tmp_file) - $time;
+ unlink $tmp_file;
+ return $offset;
+ }
+ }
+ die "$My_name.get_filetime_offset: BUG TO ARRIVE HERE\n";
+}
+
+#################################
+
sub tempfile1 {
# Makes a temporary file of a unique name. I could use file::temp,
# but it is not present in all versions of perl.
More information about the tex-live-commits
mailing list.