summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-07-03 22:51:15 +0000
committerKarl Berry <karl@freefriends.org>2013-07-03 22:51:15 +0000
commit6f3c3fa59abecd6b5efdc4bc76dd364cfa16d1da (patch)
tree68963723244d29f9adb7e27ce3087a495a70ee52 /Build
parent52145c9a54e8526420e0c231bdc344828f2f70a5 (diff)
latexmk (3jul13)
git-svn-id: svn://tug.org/texlive/trunk@31087 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rwxr-xr-xBuild/source/texk/texlive/linked_scripts/latexmk/latexmk.pl242
1 files changed, 172 insertions, 70 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl b/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl
index f479b742785..e27ced4d9eb 100755
--- a/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl
+++ b/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl
@@ -111,8 +111,8 @@ use warnings;
$my_name = 'latexmk';
$My_name = 'Latexmk';
-$version_num = '4.35';
-$version_details = "$My_name, John Collins, 11 Nov. 2012";
+$version_num = '4.37';
+$version_details = "$My_name, John Collins, 2 July 2013";
use Config;
use File::Copy;
@@ -145,7 +145,7 @@ else {
warn "Something wrong with the perl configuration: No signals?\n";
}
-## Copyright John Collins 1998-2012
+## Copyright John Collins 1998-2013
## (username collins at node phys.psu.edu)
## (and thanks to David Coppit (username david at node coppit.org)
## for suggestions)
@@ -182,6 +182,46 @@ else {
## Modification log from 9 Dec 2011 onwards in detail
##
## 12 Jan 2012 STILL NEED TO DOCUMENT some items below
+## 2 Jul 2013 John Collins V. 4.37
+## 1 Jul 2013 John Collins Correct bug that gave fatal error when the
+## name of current directory contains a
+## character with special meaning in a regexp.
+## 24 May 2013 John Collins Break in pvc returns to main program rather than
+## halting. Thus -rules option now works with -pvc.
+## 24 May 2013 John Collins File specifications in $clean_ext and
+## $clean_full_ext are allowed wildcards
+## 2 May 2013 John Collins TRY to fix problem when extension .bib in \bibliography,
+## as in \bibliography{references.bib}.
+## WHAT IS CORRECT BEHAVIOR OF sub find_file_list1?
+## Must test bibtex in all conditions on bst and bib files
+## regarding extensions
+## 28 Apr 2013 John Collins Warnings when rc file is a directory instead
+## of a file.
+## 24 Apr 2013 John Collins Add -lualatex option, like -xelatex
+## 9 Apr 2013 John Collins Correction of misleading variable names
+## in rdb_create_rule
+## 1 Apr 2013 John Collins Minor correction of misprint in comment
+## 26 Dec 2012 John Collins Correct diagnostics ("MakeB" --> "Make")
+## Rename @one_time to @unusual_one_time
+## to indicate this array is about inner-level
+## one_time rules, of which there are normally
+## none.
+## Fix diagnostics on one-time rules, to include
+## separately inner- and outer-level rules
+## Fix non-call of viewer when $force_mode on.
+## Remove some unused code
+## 14 Nov 2012 John Collins Correction on copying of fls (with MiKTeX)
+## 13 Nov 2012 John Collins V. 4.36
+## Remove redundant call to normalize_filename
+## in rdb_set_latex_deps
+## Set BIBINPUTS to include aux_dir.
+## This corrects a bug when
+## revtex4-1 is used with footnotes
+## in the bibliography: Previously
+## latexmk failed to run bibtex
+## because of a not-found bibfile
+## when the bibfile is in aux_dir
+## (or out_dir).
## 11 Nov 2012 John Collins V. 4.35
## Correct bug that under some combinations of
## MS-Windows, cygwin and distributions of
@@ -1124,7 +1164,7 @@ $cleanup_mode = 0; # No cleanup of nonessential LaTex-related files.
# $cleanup_mode = 2: cleanup except for dvi,
# dviF, pdf, ps, & psF
$cleanup_fdb = 0; # No removal of file for latexmk's file-database
-$cleanup_only = 0; # When doing cleanup, do not go-on to making files
+$cleanup_only = 0; # When doing cleanup, do not go on to making files
$cleanup_includes_generated = 0;
# Determines whether cleanup deletes files generated by
# custom dependencies
@@ -1464,7 +1504,13 @@ foreach $_ ( @ARGV )
sub read_first_rc_file_in_list {
foreach my $rc_file ( @_ ) {
#print "===Testing for rc file \"$rc_file\" ...\n";
- if ( -e $rc_file ) {
+ if ( -d $rc_file ) {
+ warn "$My_name: I have found a DIRECTORY named \"$rc_file\".\n",
+ " Have you perhaps misunderstood latexmk's documentation?\n",
+ " This name is normally used for a latexmk configuration (rc) file,\n",
+ " and in that case it should be a regular text file, not a directory.\n";
+ }
+ elsif ( -e $rc_file ) {
#print "===Reading rc file \"$rc_file\" ...\n";
process_rc_file( $rc_file );
return;
@@ -1572,6 +1618,11 @@ while ($_ = $ARGV[0])
elsif (/^-pdf$/) { $pdf_mode = 1; }
elsif (/^-pdf-$/) { $pdf_mode = 0; }
elsif (/^-pdfdvi$/){ $pdf_mode = 3; }
+# elsif (/^-pdflatex$/) {
+# $pdflatex = "pdflatex %O %S";
+# $pdf_mode = 1;
+# $dvi_mode = $postscript_mode = 0;
+# }
elsif (/^-pdflatex=(.*)$/) {
$pdflatex = $1;
}
@@ -1636,6 +1687,11 @@ while ($_ = $ARGV[0])
elsif (/^-view=none$/) { $view = "none";}
elsif (/^-view=ps$/) { $view = "ps";}
elsif (/^-view=pdf$/) { $view = "pdf"; }
+ elsif (/^-lualatex$/) {
+ $pdflatex = "lualatex %O %S";
+ $pdf_mode = 1;
+ $dvi_mode = $postscript_mode = 0;
+ }
elsif (/^-xelatex$/) {
$pdflatex = "xelatex %O %S";
$pdf_mode = 1;
@@ -1737,6 +1793,23 @@ foreach ( $aux_dir1, $out_dir1 ) {
}
}
+# At least one widely package (revtex4-1) generates a bib file
+# (which is used in revtex4-1 for putting footnotes in the reference
+# list), and bibtex must be run to use it. But latexmk needs to
+# determine the existence of the bib file by use of kpsewhich, otherwise
+# there is an error. So cope with this situation (and any analogous
+# cases by adding the aux_dir to the relevant path search environment
+# variables. BIBINPUTS seems to be the only one currently affected.
+foreach ( 'BIBINPUTS' ) {
+ if ( exists $ENV{$_} ) {
+ $ENV{$_} = $aux_dir.$search_path_separator.$ENV{$_};
+ }
+ else {
+ $ENV{$_} = $aux_dir.$search_path_separator;
+ }
+}
+
+
if ($bibtex_use > 1) {
push @generated_exts, 'bbl';
}
@@ -2094,7 +2167,8 @@ foreach $filename ( @file_list )
my @aux_files = ();
$have_fdb = 0;
if ( -e $fdb_name ) {
- print "$My_name: Examining fdb file '$fdb_name' for rules ...\n";
+ print "$My_name: Examining fdb file '$fdb_name' for rules ...\n"
+ if $diagnostics;
$have_fdb = ( 0 == rdb_read( $fdb_name ) );
}
if ( $have_fdb ) {
@@ -2118,11 +2192,11 @@ foreach $filename ( @file_list )
}
);
}
- else {
- # No fdb file, so do inferior job by parse_log
- print "$My_name: Examining log file '$log_name' for generated files...\n";
-
- # Variables set by parse_log. Can I remove them
+ elsif ( -e $log_name ) {
+ # No fdb file, but log file exists, so do inferior job by parse_log
+ print "$My_name: Examining log file '$log_name' for generated files...\n"
+ if $diagnostics;
+ # Variables set by parse_log. Can I remove them?
local %generated_log = ();
local %dependents = (); # Maps files to status. Not used here.
local @bbl_files = (); # Not used here.
@@ -2134,6 +2208,10 @@ foreach $filename ( @file_list )
&parse_log;
%other_generated = %generated_log;
}
+ else {
+ print "$My_name: No fdb or log file, so clean up default set of files ...\n"
+ if $diagnostics;
+ }
if ( ($go_mode == 2) && !$silent ) {
warn "$My_name: Removing all generated files\n" unless $silent;
@@ -2154,11 +2232,11 @@ foreach $filename ( @file_list )
delete( $other_generated{$_} );
}
if ($diagnostics) {
- show_array( "For deletion:\n"
+ show_array( "For deletion, the following were determined from fdb file or log file:\n"
." Generated (from makeindex and bibtex):",
keys %index_bibtex_generated );
show_array( " Aux files:", keys %aux_files );
- show_array( "Other generated files:\n"
+ show_array( " Other generated files:\n"
." (only deleted if \$cleanup_includes_generated is set): ",
keys %other_generated );
}
@@ -2265,7 +2343,6 @@ foreach $filename ( @file_list )
if ( $preview_continuous_mode ) {
&make_preview_continuous;
- # Will probably exit by ctrl/C and never arrive here.
next FILE;
}
@@ -2286,12 +2363,16 @@ foreach $filename ( @file_list )
$failure = 0;
$failure_msg = '';
$failure = rdb_make( keys %requested_filerules );
+ if ( ( $failure <= 0 ) || $force_mode ) {
+ rdb_for_some( [keys %one_time], \&rdb_run1 );
+ }
if ($failure > 0) { next FILE; }
- rdb_for_some( [keys %one_time], \&rdb_run1 );
} # end FILE
continue {
if ($dependents_list) { deps_list($deps_handle); }
- if ($rules_list) { rdb_list(); }
+ # If requested, print the list of rules. But don't do this in -pvc
+ # mode, since the rules list has already been printed.
+ if ($rules_list && ! $preview_continuous_mode) { rdb_list(); }
# Handle any errors
$error_message_count = rdb_show_rule_errors();
if ( ($error_message_count == 0) || ($failure > 0) ) {
@@ -2465,15 +2546,6 @@ sub rdb_make_rule_list {
$view_file, "", "", 2 ],
'view' => [ 'external', "$viewer", 'if_source', $view_file, "", "", 2 ],
);
- %source_list = ();
- foreach my $rule (keys %rule_list) {
- $source_list{$rule} = [];
- my $PAsources = $source_list{$rule};
- my ( $cmd_type, $cmd, $source, $dest, $root ) = @{$rule_list{$rule}};
- if ($source) {
- push @$PAsources, [ $rule, $source, '' ];
- }
- }
# Ensure we only have one way to make pdf file, and that it is appropriate:
if ($pdf_mode == 1) { delete $rule_list{'dvipdf'}; delete $rule_list{'ps2pdf'}; }
@@ -2941,7 +3013,7 @@ CHANGE:
}
@pre_primary = (); # Array of rules
@post_primary = (); # Array of rules
- @one_time = (); # Array of rules
+ @unusual_one_time = (); # Array of rules
&rdb_classify_rules( \%possible_primaries, keys %requested_filerules );
# There will be files changed during the run that are irrelevant.
# We need to wait for the user to change the files.
@@ -2968,6 +3040,7 @@ CHANGE:
}
}
rdb_show_rule_errors();
+ if ($rules_list) { rdb_list(); }
if ($show_time && ! $first_time) { show_timing(); }
if ( $first_time || $updated || $failure ) {
print "\n=== Watching for updated files. Use ctrl/C to stop ...\n";
@@ -3002,8 +3075,8 @@ CHANGE:
} # end WAIT:
&default_break;
if ($have_break) {
- print "$My_name: User typed ctrl/C or ctrl/break. I'll stop.\n";
- exit;
+ print "$My_name: User typed ctrl/C or ctrl/break. I'll finish.\n";
+ return;
}
$waiting = 0; if ($diagnostics) { warn "NOT WAITING\n"; }
} #end infinite_loop CHANGE:
@@ -3032,6 +3105,11 @@ sub process_rc_file {
warn "$My_name: The rc-file '$rc_file' does not exist\n";
return 1;
}
+ elsif ( -d $rc_file ) {
+ warn "$My_name: The supposed rc-file '$rc_file' is a directory; but it\n",
+ " should be a normal text file\n";
+ return 1;
+ }
elsif ( open $RCH, "<$rc_file" ) {
{ local $/; eval <$RCH>; }
close $RCH;
@@ -3095,7 +3173,7 @@ sub cleanup1 {
my $dir = shift;
foreach (@_) {
(my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/$dir$root_filename/;
- unlink_or_move("$name");
+ unlink_or_move( glob( "$name" ) );
}
} #END cleanup1
@@ -3311,7 +3389,10 @@ sub print_help
" -view=none - no viewer is used\n",
" -view=ps - viewer is for ps\n",
" -view=pdf - viewer is for pdf\n",
+ " -lualatex - use lualatex for processing files to pdf\n",
+ " and turn pdf mode on, dvi/ps modes off\n",
" -xelatex - use xelatex for processing files to pdf\n",
+ " and turn pdf mode on, dvi/ps modes off\n",
"\n",
" filename = the root filename of LaTeX document\n",
"\n",
@@ -4311,8 +4392,13 @@ sub normalize_filename {
# Remove current directory string:
$file =~ s(^\./)();
- $file =~ s(^$cwd/)();
-
+ # It would be natural to use a regexp to do the replacement of cwd:
+ # $file =~ s(^$cwd/)();
+ # But the string in $cwd may contain characters that have special
+ # meaning in a regexp. So we must do it the hard way:
+ if ( substr( $file, 0, length($cwd)+1 ) eq $cwd.'/' ) {
+ $file = substr( $file, length($cwd)+1 );
+ }
return $file;
}
@@ -4423,13 +4509,13 @@ AUX_LINE:
while (<$aux_fh>) {
if ( /^\\bibdata\{(.*)\}/ ) {
# \\bibdata{comma_separated_list_of_bib_file_names}
- # (Without the '.bib' extension)
- push( @$Pbib_files, split /,/, $1 );
+ # These are normally without the '.bib' extension.
+ push @$Pbib_files, split /,/, $1;
}
elsif ( /^\\bibstyle\{(.*)\}/ ) {
# \\bibstyle{bst_file_name}
- # (Without the '.bst' extension)
- push( @$Pbst_files, $1 );
+ # Normally without the '.bst' extension.
+ push @$Pbst_files, split /,/, $1;
}
elsif ( /^\\\@input\{(.*)\}/ ) {
# \\@input{next_aux_file_name}
@@ -4768,7 +4854,7 @@ sub rdb_write {
# circular dependencies
local @pre_primary = (); # Array of rules
local @post_primary = (); # Array of rules
- local @one_time = (); # Array of rules
+ local @unusual_one_time = (); # Array of rules
&rdb_classify_rules( \%possible_primaries, keys %requested_filerules );
print $out_handle "# Fdb version $fdb_ver\n";
@@ -4849,7 +4935,6 @@ sub rdb_set_latex_deps {
$dependents{$_} = 4;
}
foreach (keys %generated_fls) {
- $_ = normalize_filename($_);
rdb_add_generated( $_ );
if ( exists($dependents{$_}) ) {
$dependents{$_} = 6;
@@ -5579,7 +5664,7 @@ sub rdb_make {
# circular dependencies
local @pre_primary = (); # Array of rules
local @post_primary = (); # Array of rules
- local @one_time = (); # Array of rules
+ local @unusual_one_time = (); # Array of rules
# For diagnostics on changed files, etc:
@@ -5615,7 +5700,7 @@ sub rdb_make {
# could become a needed source file for a run
# and therefore undo an error condition
if ($diagnostics) {
- print "MakeB: doing pre_primary and primary...\n";
+ print "Make: doing pre_primary and primary...\n";
}
# Do the primary run if it is needed. On return $runs == 0
# signals that nothing was run (and hence no output
@@ -5639,7 +5724,7 @@ sub rdb_make {
last PASS;
}
if ($diagnostics) {
- print "MakeB: doing post_primary...\n";
+ print "Make: doing post_primary...\n";
}
rdb_for_some( [@post_primary], \&rdb_make1 );
if ( ($runs == 0) || $too_many_passes ) {
@@ -5659,7 +5744,7 @@ sub rdb_make {
&rdb_make_links;
}
}
- rdb_for_some( [@one_time], \&rdb_make1 );
+ rdb_for_some( [@unusual_one_time], \&rdb_make1 );
rdb_write( $fdb_name );
if (! $silent) {
@@ -5728,7 +5813,7 @@ sub rdb_make1 {
# Assumes contexts for recursion, make, and rule, and
# assumes that source files for the rule are to be considered
# up-to-date.
- if ($diagnostics) { print " MakeB1 $rule\n"; }
+ if ($diagnostics) { print " Make1 $rule\n"; }
if ($failure & ! $force_mode) {return;}
if ( ! defined $pass{$rule} ) {$pass{$rule} = 0; }
&rdb_clear_change_record;
@@ -5869,7 +5954,7 @@ sub rdb_make1 {
# If there is a destination to make, but for some reason
# it did not get made, and no other error was reported,
# then a priori there appears to be an error condition:
- # the run failed. But there are two important cases in
+ # the run failed. But there are some important cases in
# which this is a wrong diagnosis.
if ( ( $$Pcmd_type eq 'cusdep') && $$Psource && (! -e $$Psource) ) {
# However, if the rule is a custom dependency, this is not by
@@ -5894,6 +5979,13 @@ sub rdb_make1 {
# Missing output file was reported to be NOT an error
$$Pout_of_date = 0;
}
+ elsif ( ($bibtex_use <= 1) && ($bibtex_not_run > 0) ) {
+ # Lack of destination file is not to be treated as an error
+ # for a bibtex rule when latexmk is configured not to treat
+ # this as an error, and the lack of a destination file is the
+ # only error.
+ $$Pout_of_date = 0;
+ }
else {
$failure = 1;
}
@@ -5934,7 +6026,7 @@ sub rdb_classify_rules {
# %current_primaries # Keys are actual primaries
# @pre_primary # Array of rules
# @post_primary # Array of rules
- # @one_time # Array of rules
+ # @unusual_one_time # Array of rules
# @pre_primary and @post_primary are in natural order of application.
local $P_allowed_primaries = shift;
@@ -5945,7 +6037,7 @@ sub rdb_classify_rules {
%current_primaries = ();
@pre_primary = ();
@post_primary = ();
- @one_time = ();
+ @unusual_one_time = ();
rdb_recurse( \@requested_targets, \&rdb_classify1, 0,0, \&rdb_classify2 );
@@ -5978,12 +6070,20 @@ sub rdb_classify_rules {
print " Post-primaries:\n";
foreach (@post_primary) { print " $_\n"; }
}
- if ($#one_time < 0) {
- print " No one_time rules\n";
+ if ($#unusual_one_time < 0) {
+ print " No inner-level one_time rules, as expected\n";
}
else {
- print " One_time rules:\n";
- foreach ( @one_time ) { print " $_\n"; }
+ print " Inner-level one_time rules:\n";
+ foreach ( @unusual_one_time ) { print " $_\n"; }
+ }
+ my @normal_one_time = keys %one_time;
+ if ($#normal_one_time < 0) {
+ print " No outer-level one_time rules\n";
+ }
+ else {
+ print " Outer-level one_time rules:\n";
+ foreach ( @normal_one_time ) { print " $_\n"; }
}
} #end diagnostics
@@ -6003,7 +6103,7 @@ sub rdb_classify1 {
if ($depth > 1) {
warn "ONE TIME rule not at outer level '$rule'\n";
}
- push @one_time, $rule;
+ push @unusual_one_time, $rule;
}
elsif ($state == 0) {
if ( exists ${$P_allowed_primaries}{$rule} ) {
@@ -6309,20 +6409,18 @@ sub rdb_primary_run {
if ( $aux_dir1 ne '' ) {
push @other_fls_names, "$root_filename.fls";
}
- my $have_fls = 0;
- if ( test_gen_file($std_fls_file) ) {
- $have_fls = 1;
+ # Find the first non-standard fls file and copy it to the standard
+ # place. But only do this if the file time is compatible with being
+ # generated in the current run, as tested by the use of
+ # test_gen_file; that avoids problems with fls files leftover from
+ # earlier runs with other versions of latex.
+ foreach my $cand (@other_fls_names) {
+ if ( test_gen_file( $cand ) ) {
+ copy $cand, $std_fls_file;
+ last;
+ }
}
- else {
- foreach my $cand (@other_fls_names) {
- if ( test_gen_file($cand) ) {
- copy $cand, $std_fls_file;
- $have_fls = 1;
- last;
- }
- }
- }
- if (! $have_fls) {
+ if ( ! test_gen_file( $std_fls_file ) ) {
warn "$My_name: fls file doesn't appear to have been made\n";
}
}
@@ -6831,13 +6929,13 @@ sub rdb_create_rule {
# Makes rule. Error if it already exists.
# Omitted arguments: replaced by 0 or '' as needed.
# ==== Sets rule data ====
- my ( $rule, $cmd_type, $int_cmd, $PAext_cmd, $test_kind,
+ my ( $rule, $cmd_type, $ext_cmd, $PAint_cmd, $test_kind,
$source, $dest, $base,
$needs_making, $run_time, $check_time, $set_file_not_exists, $extra_gen ) = @_;
my $changed = 0;
# Set defaults, and normalize parameters:
- foreach ( $cmd_type, $int_cmd, $PAext_cmd, $source, $dest, $base,
+ foreach ( $cmd_type, $ext_cmd, $PAint_cmd, $source, $dest, $base,
$set_file_not_exists ) {
if (! defined $_) { $_ = ''; }
}
@@ -6848,20 +6946,20 @@ sub rdb_create_rule {
# Default to test on file change
$test_kind = 1;
}
- if ( ref( $PAext_cmd ) eq '' ) {
+ if ( ref( $PAint_cmd ) eq '' ) {
# It is a single command. Convert to array reference:
- $PAext_cmd = [ $PAext_cmd ];
+ $PAint_cmd = [ $PAint_cmd ];
}
else {
# COPY the referenced array:
- $PAext_cmd = [ @$PAext_cmd ];
+ $PAint_cmd = [ @$PAint_cmd ];
}
my $PA_extra_gen = [];
if ($extra_gen) {
@$PA_extra_gen = @$extra_gen;
}
$rule_db{$rule} =
- [ [$cmd_type, $int_cmd, $PAext_cmd, $test_kind,
+ [ [$cmd_type, $ext_cmd, $PAint_cmd, $test_kind,
$source, $dest, $base,
$needs_making, 0, $run_time, $check_time, $changed,
-1, '', $PA_extra_gen ],
@@ -7417,6 +7515,8 @@ sub find_file_list1 {
# suffix,
# ref_to_array_search_path
# )
+ # SPECIAL TREATMENT TO .bib extension, because of behavior of bibtex
+ # OTHER SPECIAL TREATMENT IF EXTENSION IS GIVEN.
my $ref_output = $_[0];
my $ref_input = $_[1];
@@ -7430,7 +7530,9 @@ sub find_file_list1 {
my @return_list = (); # Generate list in local array, since input
# and output arrays may be same
my $retcode = 0;
- foreach my $file (@$ref_input) {
+ foreach my $file1 (@$ref_input) {
+ my $file = $file1;
+ if ($suffix eq '.bib') { $file =~ s/\.bib$//; }
my ($tmp_file, $find_retcode) = &find_file1( "$file$suffix", $ref_search );
if ($tmp_file) {
push @return_list, $tmp_file;