summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/latexmk
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-11-17 01:23:55 +0000
committerKarl Berry <karl@freefriends.org>2008-11-17 01:23:55 +0000
commit4a5b7eaf919cce085598cf22a5715b1f1ce9f8f7 (patch)
tree833ff8493eeea1a1a4902eb44be49ee3bfb36440 /Master/texmf-dist/scripts/latexmk
parent3ff3de6f9871e3d4b2fba4c616fa3a83e2ee39ab (diff)
latexmk update (15nov08)
git-svn-id: svn://tug.org/texlive/trunk@11313 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/latexmk')
-rwxr-xr-xMaster/texmf-dist/scripts/latexmk/latexmk.pl169
1 files changed, 139 insertions, 30 deletions
diff --git a/Master/texmf-dist/scripts/latexmk/latexmk.pl b/Master/texmf-dist/scripts/latexmk/latexmk.pl
index 4d124a67893..acadd33c844 100755
--- a/Master/texmf-dist/scripts/latexmk/latexmk.pl
+++ b/Master/texmf-dist/scripts/latexmk/latexmk.pl
@@ -45,6 +45,12 @@ if 0;
## ?? Need to set dependence of extra bibtex rules on .bib file
## ?? Put $pass as variable in rule.
+## ?? Issues with clean-up
+## List of aux files deleted is those read, not those generated.
+## Other files are generated by (pdf)latex; should they be deleted?
+## (I have hooks for this).
+
+
#=======================================
@@ -142,8 +148,8 @@ if 0;
$my_name = 'latexmk';
$My_name = 'Latexmk';
-$version_num = '4.01';
-$version_details = "$My_name, John Collins, 24 September 2008";
+$version_num = '4.02';
+$version_details = "$My_name, John Collins, 15 November 2008";
use Config;
@@ -210,8 +216,34 @@ else {
## 5. Parsing of log file instead of source file is used to
## obtain dependencies, by default.
##
-## Modification log for 28 Mar 2007 onwards in detail
+## Modification log for 24 Sep 2008 onwards in detail
##
+## 15 Nov 2008, John Collins Make version # 4.02, for release
+## 12 Nov 2008, John Collins Deal with quoted filenames in log file
+## (as with MikTeX)
+## 10 Nov 2008, John Collins Start fixing bug about -ps -pdfps
+## running ps2pdf before dvips
+## 30 Sep 2008, John Collins V. 4.01a
+## Correct problem that aux files not of
+## same basename are not deleted on clean-up
+## Primary problem: fdb file was deleted before
+## being read
+## ?? Remaining issues on this:
+## List of aux files deleted is those read,
+## not those generated
+## Other files are generated by (pdf)latex
+## should they be deleted?
+## Solution of problem that if a source file
+## for (pdf)latex disappears, that is treated
+## as a change requiring a rerun. This gives
+## an infinite loop of unnecessary runs in
+## -pvc mode
+## Cleanup can also apply to all files
+## generated during (pdf)latex run,
+## as diagnosed by \openout lines,
+## and also to files generated from
+## these. Controlling variable
+## $cleanup_includes_generated.
## 24 Sep 2008, John Collins Release version 4.01.
##
## 1998-2008, John Collins. Many improvements and fixes.
@@ -840,6 +872,9 @@ $cleanup_mode = 0; # No cleanup of nonessential LaTex-related files.
# 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_includes_generated = 0;
+ # Determines whether cleanup deletes files generated by
+ # (pdf)latex (found from \openout lines in log file).
$diagnostics = 0;
$dvi_filter = ''; # DVI filter command
$ps_filter = ''; # Postscript filter command
@@ -1446,16 +1481,25 @@ if ( ! ( $dvi_mode || $pdf_mode || $postscript_mode || $printout_mode) ) {
# Set new-style requested rules:
if ( $dvi_mode ) { $requested_filerules{'latex'} = 1; }
if ( $pdf_mode == 1 ) { $requested_filerules{'pdflatex'} = 1; }
-elsif ( $pdf_mode == 2 ) { $requested_filerules{'ps2pdf'} = 1; }
-elsif ( $pdf_mode == 3 ) { $requested_filerules{'dvipdf'} = 1; }
-if ( $postscript_mode ) { $requested_filerules{'dvips'} = 1; }
+elsif ( $pdf_mode == 2 ) {
+ $requested_filerules{'latex'} = 1;
+ $requested_filerules{'dvips'} = 1;
+ $requested_filerules{'ps2pdf'} = 1;
+}
+elsif ( $pdf_mode == 3 ) {
+ $requested_filerules{'latex'} = 1;
+ $requested_filerules{'dvipdf'} = 1;
+}
+if ( $postscript_mode ) {
+ $requested_filerules{'latex'} = 1;
+ $requested_filerules{'dvips'} = 1;
+}
if ( $printout_mode ) { $one_time{'print'} = 1; }
if ( $preview_continuous_mode || $preview_mode ) { $one_time{'view'} = 1; }
if ( length($dvi_filter) != 0 ) { $requested_filerules{'dvi_filter'} = 1; }
if ( length($ps_filter) != 0 ) { $requested_filerules{'ps_filter'} = 1; }
if ( $banner ) { $requested_filerules{'dvips'} = 1; }
-
%possible_primaries = ();
foreach (&rdb_possible_primaries) {
$possible_primaries{$_} = 1;
@@ -1539,31 +1583,55 @@ foreach $filename ( @file_list )
$fdb_file = "$root_filename.$fdb_ext";
- if ($cleanup_fdb) { unlink $fdb_file; }
if ( $cleanup_mode > 0 ) {
- my @extra_generated = ();
+ # Use parse_logB to get names of generated files.
+ # It returns its results in the following variables:
+ local %dependents = (); # Maps files to status
+ local @bbl_files = ();
+ local %idx_files = (); # Maps idx_file to (ind_file, base)
+ local %generated_log = (); # Lists generated files
+ print "$My_name: Examining log file for generated files...\n";
+ &parse_logB;
+
+ my @index_bibtex_generated = ();
my @aux_files = ();
- rdb_read_generatedB( $fdb_file, \@extra_generated, \@aux_files );
+ my %other_generated = %generated_log;
+
+ rdb_read_generatedB( $fdb_file, \@index_bibtex_generated, \@aux_files,
+ \%other_generated );
if ( ($go_mode == 2) && !$silent ) {
warn "$My_name: Removing all generated files\n" unless $silent;
}
+ foreach (@index_bibtex_generated, @aux_files) {
+ delete( $other_generated{$_} );
+ }
if ($diagnostics) {
- show_array( "For deletion:\n Extra_generated:", @extra_generated );
+ show_array( "For deletion:\n"
+ ." Generated (from makeindex and bibtex):",
+ @index_bibtex_generated );
show_array( " Aux files:", @aux_files );
+ show_array( "Other generated files:\n"
+ ." (only deleted if \$cleanup_includes_generated is set): ",
+ keys %other_generated );
}
+
# Add to the generated files, some log file and some backup
# files used in previous versions of latexmk
&cleanup1( 'blg', 'ilg', 'log', 'aux.bak', 'idx.bak',
split(' ',$clean_ext),
@generated_exts
);
- unlink( 'texput.log', @extra_generated, "texput.aux", @aux_files );
+ unlink( 'texput.log', @index_bibtex_generated, "texput.aux", @aux_files );
+ if ($cleanup_includes_generated) {
+ unlink( keys %other_generated );
+ }
if ( $cleanup_mode == 1 ) {
&cleanup1( 'dvi', 'dviF', 'ps', 'psF', 'pdf',
split(' ', $clean_full_ext)
);
}
}
+ if ($cleanup_fdb) { unlink $fdb_file; }
if ($cleanup_only) { next FILE; }
# Initialize file and rule databases.
@@ -2666,6 +2734,8 @@ sub parse_logB {
# Treat the following specially, since they have special rules
# @bbl_files to list of .bbl files.
# %idx_files to map from .idx files to .ind files.
+# %generated_log: keys give set of files written by (pdf)latex (e.g., aux, idx)
+# as determined by \openout = ... lines in log file.
# Also set
# $reference_changed, $bad_reference, $bad_citation
# Trivial or default values if log file does not exist/cannot be opened
@@ -2686,6 +2756,7 @@ sub parse_logB {
foreach (@default_includes) { $dependents{$_} = 4; }
@bbl_files = ();
%idx_files = (); # Maps idx_file to (ind_file, base)
+ %generated_log = ();
$reference_changed = 0;
$bad_reference = 0;
@@ -2760,6 +2831,10 @@ LINE:
# Latex error/warning, etc.
next LINE;
}
+ if ( /^\\openout\d+\s*=\s*\`([^\']+)\'\.$/ ) {
+ $generated_log{$1} = 1;
+ next LINE;
+ }
# Test for writing of index file. The precise format of the message
# depends on which package (makeidx.sty , multind.sty or index.sty) and
# which version writes the message.
@@ -2895,19 +2970,22 @@ LINE:
# First step: replace $_ by whole of line after the '('
# Thus $_ is putative filename followed by other stuff.
$_ = $1;
- if ( /^([^\(^\)^\{]*?)\s\[/ ) {
+ if ( /^\"([^\(^\)^\"]+)\"/ ) {
+ # Quoted file name, as from MikTeX
+ }
+ elsif ( /^([^\(^\)]*?)\s\[/ ) {
# Terminator: space then '['
# Use *? in condition: to pick up first ' [' as terminator
# 'file [' should give good filename.
}
- elsif ( /^([^\(^\)^\{]*)\s(?=\()/ ) {
+ elsif ( /^([^\(^\)]*)\s(?=\()/ ) {
# Terminator is ' (', but '(' isn't in matched string,
# so we keep the '(' ready for the next match
}
- elsif ( /^([^\(^\)^\{]*)(\))/ ) {
+ elsif ( /^([^\(^\)]*)(\))/ ) {
# Terminator is ')'
}
- elsif ( /^([^\(^\)^\{]*?)\s*\{/ ) {
+ elsif ( /^([^\(^\)]*?)\s*\{/ ) {
# Terminator: arbitrary space then '{'
# Use *? in condition: to pick up first ' [' as terminator
# 'file [' should give good filename.
@@ -2926,6 +3004,10 @@ LINE:
# Part of font message
next INCLUDE_CANDIDATE;
}
+ # Remove quotes around filename, as for MikTeX. I've already
+ # treated this as a special case. For safety check here:
+ $include_candidate =~ s/^\"(.*)\"$/$1/;
+
# Make list of new include files; sometimes more than one.
my @new_includes = ($include_candidate);
if ( $include_candidate =~ /^(.+)\[([^\]]+)\]$/ ) {
@@ -3053,6 +3135,11 @@ CANDIDATE:
print "Apparent input files appearently from misunderstood lines in .log file:\n";
foreach ( @misparse ) { print " $_\n"; }
}
+ print "Log file shows the following generated files: ";
+ foreach (keys %generated_log) {
+ print "'$_' ";
+ }
+ print "\n";
}
return 1;
@@ -3364,13 +3451,20 @@ LINE:
#************************************************************
sub rdb_read_generatedB {
- # Call: rdb_read_generatedB( $in_name, \@extra_generated, \@aux_files )
+ # Call: rdb_read_generatedB( $in_name, \@generated1, \@aux_files.
+ # \%other_generated )
# From rule database in saved file, in format written by rdb_write,
- # finds the non-basic generated files that are to be deleted by a cleanup.
- # Returns an array of these files, or an empty array if the file
- # does not exist or cannot be opened.
- my ($in_name, $Pgenerated, $Paux_files) = @_;
- @$Pgenerated = ();
+ # finds the non-trivial generated files that are to be deleted by a cleanup.
+ # On entry:
+ # Keys of %other_generated: any detected generated files, from \openout
+ # lines log file, usually.
+ # At exit:
+ # Array @generated1: files associated with makeindex and bibtex
+ # Array @aux_files: aux files
+ # Added to keys of %other_generated: any files that are destinations of rules
+ # whose source is in %other_generated. (One stage only.)
+ my ($in_name, $Pgenerated1, $Paux_files, $Pother_generated) = @_;
+ @$Pgenerated1 = ();
@$Paux_files = ();
my $in_handle = new FileHandle;
@@ -3384,6 +3478,7 @@ sub rdb_read_generatedB {
my $ext = '';
my $path = '';
my $state = 0; # Outside a section
+ my @other_additions = ();
LINE:
while ( <$in_handle> ) {
# Remove leading and trailing white space.
@@ -3405,12 +3500,15 @@ LINE:
}
else { next LINE; }
if ( $rule =~ /^makeindex/ ) {
- push @$Pgenerated, $source, $dest, "$base.ilg";
+ push @$Pgenerated1, $source, $dest, "$base.ilg";
}
elsif ( $rule =~ /^bibtex/ ) {
- push @$Pgenerated, $dest, "$base.blg";
+ push @$Pgenerated1, $dest, "$base.blg";
push @$Paux_files, $source;
}
+ elsif ( exists ${$Pother_generated}{$source} ) {
+ push @other_additions, $dest;
+ }
$state = 1; #Reading a section
}
elsif ( /^\"([^\"]*)\"\s+(\S+)\s+(\S+)\s+(\S+)\s+\"([^\"]*)\"/ ) {
@@ -3433,7 +3531,9 @@ LINE:
}
} # LINE
undef $in_handle;
-
+ foreach (@other_additions) {
+ ${$Pother_generated}{$_} = 1;
+ }
} # END rdb_read_generatedB
#************************************************************
@@ -3496,9 +3596,10 @@ sub rdb_set_from_logB {
# Parse log file to find relevant filenames
# Result in the following variables:
- local %dependents = (); # Maps files to status
+ local %dependents = (); # Maps files to status
local @bbl_files = ();
- local %idx_files = (); # Maps idx_file to (ind_file, base)
+ local %idx_files = (); # Maps idx_file to (ind_file, base)
+ local %generated_log = (); # Lists generated files found in log file
# The following are also returned, but are global, to be used by caller
# $reference_changed, $bad_reference $bad_citation
@@ -4100,6 +4201,7 @@ sub rdb_makeB {
print "MakeB: doing pre_primary and primary...\n";
}
rdb_for_some( [@pre_primary, $primary], \&rdb_makeB1 );
+
if ( ($runs > 0) && ! $too_many_runs ) {
$retry_msg = 0;
if ( $failure && $newrule_nofile ) {
@@ -4607,12 +4709,19 @@ sub rdb_file_change1 {
#?? " New $new_time, $new_size, $new_md5\n";
my $ext = ext( $file );
if ( ($new_size < 0) && ($$Psize >= 0) ) {
- print "Disappeared '$file' in '$rule'\n";
+ # print "Disappeared '$file' in '$rule'\n";
push @disappeared, $file;
# No reaction is good.
#$$Pout_of_date = 1;
# ??? 1 Sep. 2008: I do NOT think so, for cusdep no-file-exists issue
- $$Pout_of_date = 1;
+ # ??? 30 Sep 2008: I think I have this fixed. There were other changes
+ # needed. No-change-flagged is correct. The array @disappeared flags
+ # files that have disappeared, if I need to know. But having a source
+ # file disappear is not a reason for a remake unless I know how to
+ # make the file. If the file is a destination of a rule, that rule
+ # will be rerun. It may be that the user is changing another source
+ # in such a way that the disappeared file won't be needed. Before the
+ # change is applied we get a superfluous infinite loop.
return;
}
if ( ($new_size < 0) && ($$Psize < 0) ) {
@@ -4639,7 +4748,7 @@ sub rdb_file_change1 {
#************************************************************
sub rdb_count_changes {
- return $#changed + $#disappeared + $#no_dest + $#rules_to_apply + 4;
+ return $#changed + $#no_dest + $#rules_to_apply + 3;
} #END rdb_count_changes
#************************************************************