summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-10-19 22:22:35 +0000
committerKarl Berry <karl@freefriends.org>2011-10-19 22:22:35 +0000
commit44c1398c0b03b47993aa72f98c08cde01fe53fa6 (patch)
tree4d892b20655cd0af6fd4f2fdad63eaf63f02ec3b /Master/texmf-dist/scripts
parent82f6f2a2d389acca8659d6e6d74fbccbfea3a055 (diff)
latexmk 4.27a (18oct11)
git-svn-id: svn://tug.org/texlive/trunk@24326 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-xMaster/texmf-dist/scripts/latexmk/latexmk.pl440
1 files changed, 308 insertions, 132 deletions
diff --git a/Master/texmf-dist/scripts/latexmk/latexmk.pl b/Master/texmf-dist/scripts/latexmk/latexmk.pl
index d0a41d5d76e..2bceb1e803d 100755
--- a/Master/texmf-dist/scripts/latexmk/latexmk.pl
+++ b/Master/texmf-dist/scripts/latexmk/latexmk.pl
@@ -1,4 +1,9 @@
#!/usr/bin/env perl
+
+## ????????????????????? biber source file issue fatal or not:
+## Check generation of retcode 4, and ITS USE, which is source of latexmk stop.
+
+
# On a UNIX-like system, the above enables latexmk to run independently
# of the location of the perl executable. This line relies on the
# existence of the program /usr/bin/env
@@ -22,6 +27,7 @@ use warnings;
## (I have hooks for this).
+
#=======================================
#?? Force mode doesn't appear to do force (if error in latex file)
@@ -107,8 +113,8 @@ use warnings;
$my_name = 'latexmk';
$My_name = 'Latexmk';
-$version_num = '4.26';
-$version_details = "$My_name, John Collins, 9 August 2011";
+$version_num = '4.27a';
+$version_details = "$My_name, John Collins, 10 October 2011";
use Config;
@@ -177,6 +183,26 @@ else {
##
## Modification log from 1 Jan 2011 onwards in detail
##
+## 10 Oct 2011, John Collins Corrections to new options:
+## Substitutions in commands
+## Locate .fls correctly
+## 9 Oct 2011, John Collins Add options -aux-directory -output-directory
+## 2 Oct 2011, John Collins Parse summary of warnings and errors from
+## biber v. 0.9.6
+## 1 Oct 2011, John Collins Add -norc option that prevents auto reading
+## of rc files.
+## The lines adding (or not) 'bbl' to
+## @generated_exts: move them to after parsing
+## of command line options, so that they can
+## respect setting of $bibtex_use from command
+## line options.
+## 20 Sep 2011, John Collins Add png to list of graphics extensions for
+## pdflatex
+## 23 Aug 2011, John Collins Warning about making view file via temporary
+## Deal with the case that the command for
+## making the view file has no %D placeholder
+## Version 4.27
+## 15 Aug 2011, John Collins Missing file error in biber non-fatal
## 9 Aug 2011, John Collins Fix bug in error reporting by check_biber_log
## Handle log file from biber 0.9.4
## 7 Jul 2011, John Collins Fix process_rc_file to evade cygwin bug.
@@ -383,7 +409,7 @@ $pdflatex_silent_switch = '-interaction=batchmode';
# 'pdflatex' => { 'tex' => 1, 'pdf' => 1, 'jpg' => 1, 'png' => 1 }; );
# Instead we'll exercise the user-friendly access routines:
add_input_ext( 'latex', 'tex', 'eps' );
-add_input_ext( 'pdflatex', 'tex', 'jpg', 'pdf' );
+add_input_ext( 'pdflatex', 'tex', 'jpg', 'pdf', 'png' );
#show_input_ext( 'latex' ); show_input_ext( 'pdflatex' );
## Command to invoke biber & bibtex
@@ -473,7 +499,7 @@ $log_file_binary = 0; # Whether to treat log file as binary
$MSWin_fudge_break = 1; # Give special treatment to ctrl/C and ctrl/break
# in -pvc mode under MSWin
# Under MSWin32 (at least with perl 5.8 and WinXP)
- # when latemk is running another program, and the
+ # when latexmk is running another program, and the
# user gives ctrl/C or ctrl/break, to stop the
# daughter program, not only does it reach
# the daughter, but also latexmk/perl, so
@@ -783,6 +809,7 @@ else {
}
## default parameters
+$auto_rc_use = 1; # Whether to read rc files automatically
$max_repeat = 5; # Maximum times I repeat latex. Normally
# 3 would be sufficient: 1st run generates aux file,
# 2nd run picks up aux file, and maybe toc, lof which
@@ -838,6 +865,10 @@ $jobname = ''; # Jobname: as with current tex, etc indicates
# command line has same effect as with current
# tex, etc. (If $jobname is non-empty, then
# the --jobname=... option is used on tex.)
+$out_dir = ''; # Directory for output files.
+ # Cf. --output-directory of current (pdf)latex
+$aux_dir = ''; # Directory for aux files (log, aux, etc).
+ # Cf. --aux-directory of current (pdf)latex in MiKTeX.
## default flag settings.
@@ -1101,7 +1132,8 @@ if (!$TEXINPUTS) { $TEXINPUTS = '.'; }
# with substitutions (%D for destination, %S
# for source, %B for base of current rule,
# %R for base of primary tex file, %T for
- # texfile name, and %O for options.
+ # texfile name, %O for options,
+ # %Y for $aux_dir1, and %Z for $out_dir1
# int_cmd specifies any internal command to be
# used to implement the application of the
# rule. If this is present, it overrides
@@ -1161,7 +1193,7 @@ if (!$TEXINPUTS) { $TEXINPUTS = '.'; }
# default_extra_generated is a reference to an array
# of specifications of extra generated files (beyond
# the main dest file. Standard place holders are used.
- # Example ['%R.log'] for (pdf)latex, and ['%R.blg']
+ # Example ['%Y%R.log'] for (pdf)latex, and ['%R.blg']
# for bibtex. (There's no need for '%R.aux', here,
# since such generated files are detected dynamically.)
# 1: {Hash sourcefile -> [source-file data] }
@@ -1199,9 +1231,6 @@ if (!$TEXINPUTS) { $TEXINPUTS = '.'; }
%fdb_current = (); # Fdb-hash for all files used.
-#==================================================
-## Read rc files:
-
# User's home directory
$HOME = '';
if (exists $ENV{'HOME'} ) {
@@ -1212,6 +1241,21 @@ elsif (exists $ENV{'USERPROFILE'} ) {
}
+#==================================================
+
+# Options that are to be obeyed before rc files are read:
+
+foreach $_ ( @ARGV )
+{
+ # Make -- and - equivalent at beginning of option:
+ s/^--/-/;
+ if (/^-norc$/ ) {
+ $auto_rc_use = 0;
+ }
+}
+
+#==================================================
+## Read rc files with this subroutine
sub read_first_rc_file_in_list {
foreach my $rc_file ( @_ ) {
@@ -1224,33 +1268,35 @@ sub read_first_rc_file_in_list {
}
}
-# Read system rc file:
-read_first_rc_file_in_list( @rc_system_files );
-# Read user rc file.
-read_first_rc_file_in_list( "$HOME/.latexmkrc" );
-# Read rc file in current directory.
-read_first_rc_file_in_list( "latexmkrc", ".latexmkrc" );
-
-#==================================================
-
-if ($bibtex_use > 1) {
- push @generated_exts, 'bbl';
+# Note that each rc file may unset $auto_rc_use to
+# prevent lower-level rc files from being read.
+# So test on $auto_rc_use in each case.
+if ( $auto_rc_use ) {
+ # System rc file:
+ read_first_rc_file_in_list( @rc_system_files );
+}
+if ( $auto_rc_use ) {
+ # User rc file:
+ read_first_rc_file_in_list( "$HOME/.latexmkrc" );
+}
+if ( $auto_rc_use ) {
+ # Rc file in current directory:
+ read_first_rc_file_in_list( "latexmkrc", ".latexmkrc" );
}
-
-#show_array ("BIBINPUTS", @BIBINPUTS); die;
## Process command line args.
@command_line_file_list = ();
$bad_options = 0;
-#print "Command line arguments:\n"; for ($i = 0; $i <= $#ARGV; $i++ ) { print "$i: '$ARGV[$i]'\n"; }
-
while ($_ = $ARGV[0])
{
# Make -- and - equivalent at beginning of option:
s/^--/-/;
shift;
- if (/^-bibtex$/) { $bibtex_use = 2; }
+ if ( /^-aux-directory=(.*)$/ || /^-auxdir=(.*)$/ ) {
+ $aux_dir = $1;
+ }
+ elsif (/^-bibtex$/) { $bibtex_use = 2; }
elsif (/^-bibtex-$/) { $bibtex_use = 0; }
elsif (/^-nobibtex$/) { $bibtex_use = 0; }
elsif (/^-bibtex-cond$/) { $bibtex_use = 1; }
@@ -1267,6 +1313,7 @@ while ($_ = $ARGV[0])
$deps_file = $1;
$dependents_list = 1;
}
+ elsif (/^-diagnostics/) { $diagnostics = 1; }
elsif (/^-dvi$/) { $dvi_mode = 1; }
elsif (/^-dvi-$/) { $dvi_mode = 0; }
elsif (/^-f$/) { $force_mode = 1; }
@@ -1277,7 +1324,6 @@ while ($_ = $ARGV[0])
$go_mode = 2; $cleanup_mode = 1; $cleanup_fdb = 1; $cleanup_only = 0;
}
elsif ( /^-h$/ || /^-help$/ ) { &print_help; exit;}
- elsif (/^-diagnostics/) { $diagnostics = 1; }
elsif (/^-jobname=(.*)$/) {
$jobname = $1;
}
@@ -1286,24 +1332,31 @@ while ($_ = $ARGV[0])
elsif (/^-latex=(.*)$/) {
$latex = $1;
}
- elsif (/^-pdflatex=(.*)$/) {
- $pdflatex = $1;
- }
elsif (/^-new-viewer$/) {
- $new_viewer_always = 1;
+ $new_viewer_always = 1;
}
elsif (/^-new-viewer-$/) {
- $new_viewer_always = 0;
+ $new_viewer_always = 0;
+ }
+ elsif (/^-norc$/ ) {
+ $auto_rc_use = 0;
+ # N.B. This has already been obeyed.
+ }
+ elsif ( /^-output-directory=(.*)$/ ||/^-outdir=(.*)$/ ) {
+ $out_dir = $1;
}
elsif (/^-p$/) { $printout_mode = 1;
$preview_continuous_mode = 0; # to avoid conflicts
$preview_mode = 0;
}
elsif (/^-p-$/) { $printout_mode = 0; }
- elsif (/^-pdfdvi$/){ $pdf_mode = 3; }
- elsif (/^-pdfps$/) { $pdf_mode = 2; }
elsif (/^-pdf$/) { $pdf_mode = 1; }
elsif (/^-pdf-$/) { $pdf_mode = 0; }
+ elsif (/^-pdfdvi$/){ $pdf_mode = 3; }
+ elsif (/^-pdflatex=(.*)$/) {
+ $pdflatex = $1;
+ }
+ elsif (/^-pdfps$/) { $pdf_mode = 2; }
elsif (/^-print=(.*)$/) {
$value = $1;
if ( $value =~ /^dvi$|^ps$|^pdf$/ ) {
@@ -1334,12 +1387,12 @@ while ($_ = $ARGV[0])
elsif (/^-silent$/ || /^-quiet$/ ){ $silent = 1; }
elsif (/^-time$/) { $show_time = 1;}
elsif (/^-time-$/) { $show_time = 0;}
- elsif (/^-v$/ || /^-version$/) {
- print "\n$version_details. Version $version_num\n";
- exit;
- }
elsif (/^-use-make$/) { $use_make_for_missing_files = 1; }
elsif (/^-use-make-$/) { $use_make_for_missing_files = 0; }
+ elsif (/^-v$/ || /^-version$/) {
+ print "\n$version_details. Version $version_num\n";
+ exit;
+ }
elsif (/^-verbose$/) { $silent = 0; }
elsif (/^-view=default$/) { $view = "default";}
elsif (/^-view=dvi$/) { $view = "dvi";}
@@ -1417,6 +1470,23 @@ warn "$My_name: This is $version_details, version: $version_num.\n",
"**** Report bugs etc to John Collins <collins at phys.psu.edu>. ****\n"
unless $silent;
+if ( ($out_dir ne '') && ($aux_dir eq '') ){
+ $aux_dir = $out_dir;
+}
+
+# Versions terminating in directory/path separator
+$out_dir1 = $out_dir;
+$aux_dir1 = $aux_dir;
+foreach ( $aux_dir1, $out_dir1 ) {
+ if ( ($_ ne '') && ! m([\\/\:]$) ) {
+ $_ .= '/';
+ }
+}
+
+if ($bibtex_use > 1) {
+ push @generated_exts, 'bbl';
+}
+
# For backward compatibility, convert $texfile_search to @default_files
# Since $texfile_search is initialized to "", a nonzero value indicates
# that an initialization file has set it.
@@ -1540,8 +1610,8 @@ if ( ($jobname ne '') && ($num_files > 1) ) {
&fix_cmds;
# Add common options
-add_option( \$latex, $latex_default_switches );
-add_option( \$pdflatex, $pdflatex_default_switches );
+add_option( $latex_default_switches, \$latex );
+add_option( $pdflatex_default_switches, \$pdflatex );
# If landscape mode, change dvips processor, and the previewers:
@@ -1553,23 +1623,32 @@ if ( $landscape_mode )
}
if ( $silent ) {
- add_option( \$latex, " $latex_silent_switch" );
- add_option( \$pdflatex, " $pdflatex_silent_switch" );
- add_option( \$biber, " $biber_silent_switch" );
- add_option( \$bibtex, " $bibtex_silent_switch" );
- add_option( \$makeindex, " $makeindex_silent_switch" );
- add_option( \$dvips, " $dvips_silent_switch" );
+ add_option( "$latex_silent_switch", \$latex );
+ add_option( "$pdflatex_silent_switch", \$pdflatex );
+ add_option( "$biber_silent_switch", \$biber );
+ add_option( "$bibtex_silent_switch", \$bibtex );
+ add_option( "$makeindex_silent_switch", \$makeindex );
+ add_option( "$dvips_silent_switch", \$dvips );
}
if ( $recorder ) {
- add_option( \$latex, "-recorder" );
- add_option( \$pdflatex, "-recorder" );
+ add_option( "-recorder", \$latex, \$pdflatex );
+}
+
+if ( $out_dir ) {
+ add_option( "-output-directory=\"$out_dir\"", \$latex, \$pdflatex );
+}
+
+if ( $aux_dir && ($aux_dir ne $out_dir) ) {
+ # N.B. If $aux_dir and $out_dir are the same, then the -output-directory
+ # option is sufficient, especially because the -aux-directory exists
+ # only in MiKTeX, not in TeXLive.
+ add_option( "-aux-directory=\"$aux_dir\"", \$latex, \$pdflatex );
}
if ( $jobname ne '' ) {
$jobstring = "--jobname=$jobname";
- add_option( \$latex, " $jobstring" );
- add_option( \$pdflatex, " $jobstring" );
+ add_option( "$jobstring", \$latex, \$pdflatex );
}
# Which kind of file do we preview?
@@ -1620,7 +1699,7 @@ if ( $banner ) { $requested_filerules{'dvips'} = 1; }
if ( $pdf_mode == 2 ) {
# We generate pdf from ps. Make sure we have the correct kind of ps.
- add_option( \$dvips, " $dvips_pdf_switch" );
+ add_option( "$dvips_pdf_switch", \$dvips );
}
# Note sleep has granularity of 1 second.
@@ -1704,26 +1783,29 @@ foreach $filename ( @file_list )
$root_filename = $jobname;
}
+ $aux_main = "$aux_dir1$root_filename.aux";
+ $log_name = "$aux_dir1$root_filename.log";
+ $fdb_name = "$aux_dir1$root_filename.$fdb_ext";
+
# Initialize basic dependency information:
# For use under error conditions:
- @default_includes = ($texfile_name, "$root_filename.aux");
+ @default_includes = ($texfile_name, $aux_main);
- $fdb_file = "$root_filename.$fdb_ext";
-
# Initialize file and rule databases.
%rule_list = ();
&rdb_make_rule_list;
&rdb_set_rules(\%rule_list);
if ( $cleanup_mode > 0 ) {
+# ?? MAY NEED TO FIX THE FOLLOWING IF $aux_dir or $out_dir IS SET.
my %other_generated = ();
my @index_bibtex_generated = ();
my @aux_files = ();
$have_fdb = 0;
- if ( -e $fdb_file ) {
- print "$My_name: Examining fdb file '$fdb_file' for rules ...\n";
- $have_fdb = ( 0 == rdb_read( $fdb_file ) );
+ if ( -e $fdb_name ) {
+ print "$My_name: Examining fdb file '$fdb_name' for rules ...\n";
+ $have_fdb = ( 0 == rdb_read( $fdb_name ) );
}
if ( $have_fdb ) {
rdb_for_all(
@@ -1748,7 +1830,7 @@ foreach $filename ( @file_list )
}
else {
# No fdb file, so do inferior job by parse_logB
- print "$My_name: Examining log file '$root_filename.log' for generated files...\n";
+ print "$My_name: Examining log file '$log_name' for generated files...\n";
# Variables set by parse_logB. Can I remove them
local %generated_log = ();
@@ -1790,8 +1872,7 @@ foreach $filename ( @file_list )
." (only deleted if \$cleanup_includes_generated is set): ",
keys %other_generated );
}
- # files used in previous versions of latexmk
- &cleanup1( $fdb_ext, 'blg', 'ilg', 'log', 'aux.bak', 'idx.bak',
+ &cleanup1( $aux_dir1, $fdb_ext, 'blg', 'ilg', 'log', 'aux.bak', 'idx.bak',
split(' ',$clean_ext),
keys %generated_exts_all
);
@@ -1805,12 +1886,12 @@ foreach $filename ( @file_list )
&cleanup_cusdep_generated;
}
if ( $cleanup_mode == 1 ) {
- &cleanup1( 'dvi', 'dviF', 'ps', 'psF', 'pdf',
+ &cleanup1( $out_dir1, 'dvi', 'dviF', 'ps', 'psF', 'pdf',
split(' ', $clean_full_ext)
);
}
}
- if ($cleanup_fdb) { unlink $fdb_file; }
+ if ($cleanup_fdb) { unlink $fdb_name; }
if ($cleanup_only) { next FILE; }
@@ -1840,7 +1921,7 @@ foreach $filename ( @file_list )
}
$have_fdb = 0;
- if ( (! -e $fdb_file) && (! -e "$root_filename.aux") ) {
+ if ( (! -e $fdb_name) && (! -e $aux_main ) ) {
# No aux and no fdb file => set up trivial aux file
# and corresponding fdb_file. Arrange them to provoke one run
# as minimum, but no more if actual aux file is trivial.
@@ -1848,8 +1929,8 @@ foreach $filename ( @file_list )
&set_trivial_aux_fdb;
}
- if ( -e $fdb_file ) {
- $rdb_errors = rdb_read( $fdb_file );
+ if ( -e $fdb_name ) {
+ $rdb_errors = rdb_read( $fdb_name );
$have_fdb = ($rdb_errors == 0);
}
if (!$have_fdb) {
@@ -1860,7 +1941,7 @@ foreach $filename ( @file_list )
rdb_recurseA( [keys %possible_primaries],
sub{ if ( $$Ptest_kind == 1 ) { $$Ptest_kind = 3;} }
);
- if ( -e "$root_filename.log" ) {
+ if ( -e $log_name ) {
rdb_for_some( [keys %possible_primaries], \&rdb_set_latex_deps );
}
}
@@ -2000,10 +2081,14 @@ sub fix_cmds {
#############################################################
sub add_option {
- # Call add_option( \$cmd, $opt )
- # Add option to command
- if ( ${$_[0]} !~ /%/ ) { &fix_cmds; }
- ${$_[0]} =~ s/%O/$_[1] %O/;
+ # Call add_option( $opt, \$cmd ... )
+ # Add option to one or more commands
+ my $option = shift;
+ while (@_) {
+ if ( ${$_[0]} !~ /%/ ) { &fix_cmds; }
+ ${$_[0]} =~ s/%O/$option %O/;
+ shift;
+ }
} #END add_option
#############################################################
@@ -2011,17 +2096,18 @@ sub add_option {
sub rdb_make_rule_list {
# Substitutions: %S = source, %D = dest, %B = this rule's base
# %T = texfile, %R = root = base for latex.
+# %Y for $aux_dir1, %Z for $out_dir1
# Defaults for dvi, ps, and pdf files
# Use local, not my, so these variables can be referenced
- local $dvi_final = "%R.dvi";
- local $ps_final = "%R.ps";
- local $pdf_final = "%R.pdf";
+ local $dvi_final = "%Z%R.dvi";
+ local $ps_final = "%Z%R.ps";
+ local $pdf_final = "%Z%R.pdf";
if ( length($dvi_filter) > 0) {
- $dvi_final = "%R.dviF";
+ $dvi_final = "%Z%R.dviF";
}
if ( length($ps_filter) > 0) {
- $ps_final = "%R.psF";
+ $ps_final = "%Z%R.psF";
}
my $print_file = '';
@@ -2061,14 +2147,14 @@ sub rdb_make_rule_list {
# This is because, especially for dvi file, the contents of the file may contain
# a pointer to a file to be included, not the contents of the file!
%rule_list = (
- 'latex' => [ 'primary', "$latex", '', "%T", "%B.dvi", "%R", 1, ["%R.log"] ],
- 'pdflatex' => [ 'primary', "$pdflatex", '', "%T", "%B.pdf", "%R", 1, ["%R.log"] ],
- 'dvipdf' => [ 'external', "$dvipdf", 'do_viewfile', $dvi_final, "%B.pdf", "%R", 2 ],
- 'dvips' => [ 'external', "$dvips", 'do_viewfile', $dvi_final, "%B.ps", "%R", 2 ],
- 'dvifilter'=> [ 'external', $dvi_filter, 'do_viewfile', "%B.dvi", "%B.dviF", "%R", 2 ],
- 'ps2pdf' => [ 'external', "$ps2pdf", 'do_viewfile', $ps_final, "%B.pdf", "%R", 2 ],
- 'psfilter' => [ 'external', $ps_filter, 'do_viewfile', "%B.ps", "%B.psF", "%R", 2 ],
- 'print' => [ 'external', "$print_cmd", 'if_source', $print_file, "", "", 2 ],
+ 'latex' => [ 'primary', "$latex", '', "%T", "%Z%B.dvi", "%R", 1, ["%Y%R.log"] ],
+ 'pdflatex' => [ 'primary', "$pdflatex", '', "%T", "%Z%B.pdf", "%R", 1, ["%Y%R.log"] ],
+ 'dvipdf' => [ 'external', "$dvipdf", 'do_viewfile', $dvi_final, "%B.pdf", "%Z%R", 2 ],
+ 'dvips' => [ 'external', "$dvips", 'do_viewfile', $dvi_final, "%B.ps", "%Z%R", 2 ],
+ 'dvifilter'=> [ 'external', $dvi_filter, 'do_viewfile', "%B.dvi", "%B.dviF", "%Z%R", 2 ],
+ 'ps2pdf' => [ 'external', "$ps2pdf", 'do_viewfile', $ps_final, "%B.pdf", "%Z%R", 2 ],
+ 'psfilter' => [ 'external', $ps_filter, 'do_viewfile', "%B.ps", "%B.psF", "%Z%R", 2 ],
+ 'print' => [ 'external', "$print_cmd", 'if_source', $print_file, "", "", 2 ],
'update_view' => [ 'external', $viewer_update_command, $PA_update,
$view_file, "", "", 2 ],
'view' => [ 'external', "$viewer", 'if_source', $view_file, "", "", 2 ],
@@ -2109,6 +2195,8 @@ sub rdb_set_rules {
# until run time, in case of changes.
foreach ($base, $source, $dest, @$PA_extra_gen ) {
s/%R/$root_filename/;
+ s/%Y/$aux_dir1/;
+ s/%Z/$out_dir1/;
}
foreach ($source, $dest ) {
s/%B/$base/;
@@ -2170,20 +2258,20 @@ sub set_trivial_aux_fdb {
# 2. Write a corresponding fdb file
# 3. Provoke a run of (pdf)latex (actually of all primaries).
- local $aux_file = "$root_filename.aux";
- open( aux_file, '>', $aux_file )
- or die "Cannot write file '$aux_file'\n";
+ local *aux_file;
+ open( aux_file, '>', $aux_main )
+ or die "Cannot write file '$aux_main'\n";
print aux_file "\\relax \n";
close(aux_file);
foreach my $rule (keys %primaries ) {
rdb_ensure_file( $rule, $texfile_name );
- rdb_ensure_file( $rule, $aux_file );
+ rdb_ensure_file( $rule, $aux_main );
rdb_one_rule( $rule,
sub{ $$Pout_of_date = 1; }
);
}
- &rdb_write( $fdb_file );
+ &rdb_write( $fdb_name );
} #END set_trivial_aux_fdb
#************************************************************
@@ -2252,12 +2340,22 @@ sub do_viewfile {
my $return = 0;
my ($base, $path, $ext) = fileparseA( $$Pdest );
if ( &view_file_via_temporary ) {
- my $tmpfile = tempfile1( "${root_filename}_tmp", $ext );
- $return = &rdb_ext_cmd1( '', '', $tmpfile );
- move( $tmpfile, $$Pdest );
+ if ( $$Pext_cmd =~ /%D/ ) {
+ my $tmpfile = tempfile1( "${root_filename}_tmp", $ext );
+ warn "$My_name: Making '$$Pdest' via temporary '$tmpfile'...\n";
+ $return = &rdb_ext_cmd1( '', '', $tmpfile );
+ move( $tmpfile, $$Pdest );
+ }
+ else {
+ warn "$My_name is configured to make '$$Pdest' via a temporary file\n",
+ " but the command template '$$Pext_cmd' does not have a slot\n",
+ " to set the destination file, so I won't use a temporary file\n";
+ $return = &rdb_ext_cmd;
+ }
}
else {
$return = &rdb_ext_cmd;
+ $return = &rdb_ext_cmd;
}
return $return;
} #END do_viewfile
@@ -2674,9 +2772,10 @@ sub execute_code_string {
#************************************************************
sub cleanup1 {
- # Usage: cleanup1( exts_without_period, ... )
+ # Usage: cleanup1( directory, exts_without_period, ... )
+ my $dir = shift;
foreach (@_) {
- (my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/$root_filename/;
+ (my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/$dir$root_filename/;
unlink("$name");
}
} #END cleanup1
@@ -2792,9 +2891,12 @@ sub print_help
"$My_name $version_num: Automatic LaTeX document generation routine\n\n",
"Usage: $my_name [latexmk_options] [filename ...]\n\n",
" Latexmk_options:\n",
- " -bibtex - use bibtex when needed (default)\n",
- " -bibtex- - never use bibtex\n",
- " -bibtex-cond - use bibtex when needed, but only if the bib files exist\n",
+ " -aux-directory=dir or -auxdir=dir \n",
+ " - set name of directory for auxiliary files (aux, log)\n",
+ " - Currently this only works with MiKTeX\n",
+ " -bibtex - use bibtex when needed (default)\n",
+ " -bibtex- - never use bibtex\n",
+ " -bibtex-cond - use bibtex when needed, but only if the bib files exist\n",
" -bm <message> - Print message across the page when converting to postscript\n",
" -bi <intensity> - Set contrast or intensity of banner\n",
" -bs <scale> - Set scale for banner\n",
@@ -2839,6 +2941,9 @@ sub print_help
" -new-viewer- - in -pvc mode, start a new viewer only if needed\n",
" -nobibtex - never use bibtex\n",
" -nodependents - Do not show list of dependent files after processing\n",
+ " -norc - omit automatic reading of system, user and project rc files\n",
+ " -output-directory=dir or -outdir=dir\n",
+ " - set name of directory for output files\n",
" -pdf - generate pdf by pdflatex\n",
" -pdfdvi - generate pdf by dvipdf\n",
" -pdflatex=<program> - set program used for pdflatex.\n",
@@ -2860,6 +2965,8 @@ sub print_help
" (Side effect: turn off ordinary preview mode.)\n",
" -pvc- - turn off -pvc\n",
" -r <file> - Read custom RC file\n",
+ " (N.B. This file could override options specified earlier\n",
+ " on the command line.)\n",
" -recorder - Use -recorder option for (pdf)latex\n",
" (to give list of input and output files)\n",
" -recorder- - Do not use -recorder option for (pdf)latex\n",
@@ -2883,9 +2990,7 @@ sub print_help
"-p, -pv and -pvc are mutually exclusive\n",
"-h, -c and -C override all other options.\n",
"-pv and -pvc require one and only one filename specified\n",
- "All options can be introduced by '-' or '--'. (E.g., --help or -help.)\n",
- "Contents of RC file specified by -r overrides options specified\n",
- " before the -r option on the command line\n";
+ "All options can be introduced by '-' or '--'. (E.g., --help or -help.)\n";
} #END print_help
@@ -2937,12 +3042,13 @@ sub view_file_via_temporary {
sub check_biber_log {
# Check for biber warnings:
- # Usage: check_biber_log( base_of_biber_run[, \@biber_source )
+ # Usage: check_biber_log( base_of_biber_run, \@biber_source )
# return 0: OK;
# 1: biber warnings;
# 2: biber errors;
# 3: could not open .blg file;
- # 4: failed to find one or more source files;
+ # 4: failed to find one or more source files, except for bibfile;
+ # 5: failed to find bib file;
# 10: only error is missing \citation commands.
# Side effect: add source files @biber_source
my $base = $_[0];
@@ -2955,8 +3061,12 @@ sub check_biber_log {
my $have_error = 0;
my $missing_citations = 0;
my $no_citations = 0;
- my $error_count = 0;
- my $warning_count = 0;
+ my $error_count = 0; # From my counting of error messages
+ my $warning_count = 0; # From my counting of warning messages
+ # The next two occur only from biber v >
+ my $bibers_error_count = 0; # From biber's counting of errors
+ my $bibers_warning_count = 0; # From biber's counting of warnings
+ my $not_found_count = 0;
while (<$log_file>) {
if (/> WARN /) {
print "Biber warning: $_";
@@ -2965,10 +3075,16 @@ sub check_biber_log {
}
elsif (/> FATAL /) {
print "Biber error: $_";
- $have_error = 1;
- $error_count ++;
- if ( /> FATAL - The file '[^']+' does not contain any citations!/ ) {
- $no_citations++;
+ if ( /> FATAL - Cannot find file '([^']+)'/ ) { #'
+ $not_found_count++;
+ push @$Pbiber_source, $1;
+ }
+ else {
+ $have_error = 1;
+ $error_count ++;
+ if ( /> FATAL - The file '[^']+' does not contain any citations!/ ) { #'
+ $no_citations++;
+ }
}
}
elsif ( /> INFO - Found .* '([^']+)'\s*$/
@@ -2981,6 +3097,12 @@ sub check_biber_log {
push @$Pbiber_source, $1;
}
}
+ elsif ( /> INFO - WARNINGS: ([\d]+)\s*$/ ) {
+ $bibers_warning_count = $1;
+ }
+ elsif ( /> INFO - ERRORS: ([\d]+)\s*$/ ) {
+ $bibers_error_count = $1;
+ }
}
close $log_file;
@@ -2988,9 +3110,15 @@ sub check_biber_log {
'', \@BIBINPUTS );
@$Pbiber_source = uniqs( @$Pbiber_source );
if ( $#not_found < 0) {
- warn "$My_name: Found biber source file(s) [@$Pbiber_source]\n"
+ warn "$My_name: Found biber source file(s) [@$Pbiber_source]\n"
unless $silent;
}
+ elsif ( ($#not_found == 0) && ($not_found[0] =~ /\.bib$/) ) {
+ # Special treatment if sole missing file is bib file
+ # I don't want to treat that as an error
+ warn "$My_name: Biber did't find bib file [$not_found[0]]\n";
+ return 5;
+ }
else {
show_array( "$My_name: Failed to find one or more biber source files:",
@not_found );
@@ -2998,11 +3126,6 @@ sub check_biber_log {
warn "==== Force_mode is on, so I will continue. ",
"But there may be problems ===\n";
}
- else {
- #$failure = -1;
- #$failure_msg = 'Failed to find one or more biber source files';
- #warn "$My_name: Failed to find one or more biber source files\n";
- }
return 4;
}
# print "$My_name: #Biber errors = $error_count, warning messages = $warning_count,\n ",
@@ -3070,6 +3193,21 @@ sub check_bibtex_log {
#**************************************************
+sub force_directory {
+ # Usage, force_directory( dir, filename )
+ # If filename contains no path component, return concatenation
+ # of dir and filename,
+ # else return filename
+ my $default_dir = $_[0];
+ my $filename = $_[1];
+ my ($base_name, $path ) = fileparse( $filename );
+ if ( $path ne '' ) { $filename = "$default_dir$filename"; }
+ print "$filename\n";
+ return $filename;
+}
+
+# ------------------------------
+
sub clean_file_name {
# Convert quoted filename as found in log file to filename without quotes
# Allows arbitrarily embedded double-quoted substrings, includes the
@@ -3150,7 +3288,6 @@ sub parse_logB {
$bad_reference = 0;
$bad_citation = 0;
- my $log_name = "$root_filename.log";
my $log_file = new FileHandle;
if ( ! open( $log_file, "<$log_name" ) ) {
return 0;
@@ -3300,7 +3437,10 @@ LINE:
next LINE;
}
if ( /^\\openout\d+\s*=\s*\`([^\']+)\'\.$/ ) {
- $generated_log{clean_file_name($1)} = 1;
+ # When (pdf)latex is run with an -output-directory
+ # or an -aux_directory, the file name does not contain
+ # the output path; fix this, after removing quotes:
+ $generated_log{ force_directory( $aux_dir1, clean_file_name($1) )} = 1;
next LINE;
}
# Test for conversion produced by package:
@@ -3335,9 +3475,12 @@ LINE:
" '$_'\n";
next LINE;
}
- # Typically, there is trailing space, not part of filename:
+ # Typically, there is trailing space, not part of filename:
$idx_file =~ s/\s*$//;
- $idx_file = clean_file_name($idx_file);
+ # When (pdf)latex is run with an -output-directory
+ # or an -aux_directory, the file name does not contain
+ # the output path; fix this, after removing quotes:
+ $idx_file = force_directory( $aux_dir1, clean_file_name($idx_file) );
my ($idx_base, $idx_path, $idx_ext) = fileparseA( $idx_file );
$idx_base = $idx_path.$idx_base;
$idx_file = $idx_base.$idx_ext;
@@ -3361,8 +3504,10 @@ LINE:
next LINE;
}
if ( /^No file (.*?\.bbl)./ ) {
- # Notice that the
- my $bbl_file = clean_file_name($1);
+ # When (pdf)latex is run with an -output-directory
+ # or an -aux_directory, the file name does not contain
+ # the output path; fix this, after removing quotes:
+ my $bbl_file = force_directory( $aux_dir1, clean_file_name($1) );
warn "$My_name: Non-existent bbl file '$bbl_file'\n $_\n";
$dependents{$bbl_file} = 0;
push @bbl_files, $bbl_file;
@@ -4018,6 +4163,7 @@ LINE:
my $ext = '';
($base, $path, $ext) = fileparseA( $source );
$base = $path.$base;
+# ?? MAY NEED TO FIX THE FOLLOWING IF $aux_dir IS SET.
if ($rule_generic eq 'makeindex') {
$dest = "$base.ind";
}
@@ -4204,7 +4350,7 @@ sub rdb_set_latex_deps {
# $reference_changed, $bad_reference $bad_citation
&parse_logB;
- my $fls_file = "$root_filename.fls";
+ my $fls_file = "$aux_dir1$root_filename.fls";
if ($recorder && test_gen_file($fls_file) ) {
parse_fls( $fls_file, \%source_fls, \%generated_fls );
foreach (keys %source_fls) {
@@ -4288,6 +4434,7 @@ sub rdb_set_latex_deps {
rdb_remove_rule( "bibtex $bbl_base" );
}
else {
+# ?? MAY NEED TO FIX IF $aux_dir IS SET:
parse_aux( "$bbl_base.aux", \@new_bib_files, \@new_aux_files, \@new_bst_files );
# Remove OPPOSITE kind of bbl generation:
rdb_remove_rule( "biber $bbl_base" );
@@ -4722,6 +4869,7 @@ sub deps_list {
sub{ $source{$file} = 1; }
);
foreach (keys %generated_exts_all) {
+# ?? MAY NEED TO FIX THE FOLLOWING IF $aux_dir or $out_dir IS SET.
(my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/$root_filename/;
push @generated, $name;
}
@@ -5008,7 +5156,7 @@ sub rdb_makeB {
}
}
rdb_for_some( [@one_time], \&rdb_makeB1 );
- rdb_write( $fdb_file );
+ rdb_write( $fdb_name );
if (! $silent) {
# Diagnose of the runs
@@ -5415,7 +5563,16 @@ sub rdb_run1 {
if ($diagnostics);
rdb_ensure_file( $rule, $source );
}
- if ($retcode == 4) {
+ if ($retcode == 5) {
+ # Special treatment if sole missing file is bib file
+ # I don't want to treat that as an error
+ warn " =============== bib missing special case\n";
+# $return = 0;
+ $$Plast_result = 200;
+# $$Plast_message = "Could not find bib file for '$$Pbase'";
+ push @warnings, "Bib file not found for '$$Pbase'";
+ }
+ elsif ($retcode == 4) {
$$Plast_result = 2;
$$Plast_message = "Could not find all biber source files for '$$Pbase'";
push @warnings, "Not all biber source files found for '$$Pbase'";
@@ -5522,7 +5679,8 @@ sub rdb_ext_cmd1 {
# Call: rdb_ext_cmd1( options, source, dest, base ) or rdb_ext_cmd1() or ...
# Assumes rule context. Returns command with substitutions.
# Null arguments or unprovided arguments => use defaults.
- # for %S=source, %D=dest, %B=base, %R=root=base for latex, %O='', %T=texfile
+ # for %S=source, %D=dest, %B=base, %R=root=base for latex, %O='',
+ # %T=texfile, %Y for $aux_dir1, %Z for $out_dir1
my ($options, $source, $dest, $base ) = @_;
# Apply defaults
$options ||= '';
@@ -5542,6 +5700,8 @@ sub rdb_ext_cmd1 {
'%T' => $q.$texfile_name.$q,
'%S' => $q.$source.$q,
'%D' => $q.$dest.$q,
+ '%Y' => $q.$aux_dir1.$q,
+ '%Z' => $q.$out_dir1.$q,
'%%' => '%' # To allow literal %B, %R, etc, by %%B.
);
@@ -5573,28 +5733,44 @@ sub rdb_primary_run {
if (-e $$Pdest) { $missing_dvi_pdf = '';}
######### Analyze results of run:
- if ( ! -e "$root_filename.log" ) {
+ if ( ! -e $log_name ) {
$failure = 1;
$$Plast_result = 2;
- $$Plast_message = $failure_msg = "(Pdf)LaTeX failed to generate a log file";
+ $$Plast_message = $failure_msg
+ = "(Pdf)LaTeX failed to generate the expected log file '$log_name'";
return -1;
}
if ($recorder) {
# Handle problem that some version of (pdf)latex give fls files
- # of name latex.fls or pdflatex.fls instead of $root_filename.fls:
- my $std_fls_file = "$root_filename.fls";
- my $other_fls_file = "latex.fls";
+ # of name latex.fls or pdflatex.fls instead of $root_filename.fls.
+ # Also that setting of -output-directory -aux-directory is not
+ # respected by (pdf)latex, at least in some versions.
+ my $std_fls_file = "$aux_dir1$root_filename.fls";
+ my @other_fls_names = ( );
if ( $rule =~ /^pdflatex/ ) {
- $other_fls_file = "pdflatex.fls";
+ push @other_fls_names, "pdflatex.fls";
+ }
+ else {
+ push @other_fls_names, "latex.fls";
}
+ if ( $aux_dir1 ne '' ) {
+ push @other_fls_names, "$root_filename.fls";
+ }
+ my $have_fls = 0;
if ( test_gen_file($std_fls_file) ) {
- # Good filename
+ $have_fls = 1;
}
- elsif ( test_gen_file($other_fls_file) ) {
- copy $other_fls_file, $std_fls_file;
- }
else {
+ foreach my $cand (@other_fls_names) {
+ if ( test_gen_file($cand) ) {
+ copy $cand, $std_fls_file;
+ $have_fls = 1;
+ last;
+ }
+ }
+ }
+ if (! $have_fls) {
warn "$My_name: fls file doesn't appear to have been made\n";
}
}