diff options
16 files changed, 3203 insertions, 2474 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/convbkmk/convbkmk.rb b/Build/source/texk/texlive/linked_scripts/convbkmk/convbkmk.rb index 66dc49095aa..c5bceb5a574 100755 --- a/Build/source/texk/texlive/linked_scripts/convbkmk/convbkmk.rb +++ b/Build/source/texk/texlive/linked_scripts/convbkmk/convbkmk.rb @@ -3,12 +3,12 @@ =begin -= convbkmk Ver.0.10 += convbkmk Ver.0.10a - 2014.03.08 + 2014.12.29 Takuji Tanaka - KXD02663 (at) nifty.ne.jp -((<URL:http://homepage3.nifty.com/ttk/comp/tex/uptex_en.html>)) + ttk (at) t-lab.opal.ne.jp +((<URL:http://www.t-lab.opal.ne.jp/tex/uptex_en.html>)) == Abstract @@ -113,6 +113,8 @@ THE SOFTWARE. * Bug fix: Conversion was not complete in some cases. : 2014.03.08 0.10 * Bug fix: Output of binary data might be broken in filter mode on Windows. +: 2014.12.29 0.10a + * Update the author's mail address and web site. =end diff --git a/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl b/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl index 95f302d82a1..1dbe4e7c00e 100755 --- a/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl +++ b/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl @@ -1,7 +1,14 @@ #!/usr/bin/env perl +# !!!!!!!!!! Don't forget to document $silence_logfile_warnings.!!! + # N.B. !!!!!!!!!!! See 17 July 2012 comments !!!!!!!!!!!!!!!!!! +# Re -cd issue !!!!!!!!!!!!! SEE "??!!" COMMENTS. +# If relative path is given for $out_dir or $aux_dir, and -cd is +# used, should it be interpreted w.r.t. initial cwd (i.e., cwd when +# latexmk is started), or w.r.t. to document directory??????? +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # On a UNIX-like system, the above enables latexmk to run independently # of the location of the perl executable. This line relies on the @@ -111,12 +118,13 @@ use warnings; $my_name = 'latexmk'; $My_name = 'Latexmk'; -$version_num = '4.39'; -$version_details = "$My_name, John Collins, 10 Nov 2013"; +$version_num = '4.41'; +$version_details = "$My_name, John Collins, 1 January 2015"; use Config; use File::Basename; use File::Copy; +use Cwd 'abs_path'; use File::Glob ':glob'; # Better glob. Does not use space as item separator. use File::Path 2.08 qw( make_path ); use FileHandle; @@ -147,8 +155,8 @@ else { warn "Something wrong with the perl configuration: No signals?\n"; } -## Copyright John Collins 1998-2013 -## (username collins at node phys.psu.edu) +## Copyright John Collins 1998-2015 +## (username jcc8 at node psu.edu) ## (and thanks to David Coppit (username david at node coppit.org) ## for suggestions) ## Copyright Evan McLean @@ -184,6 +192,50 @@ else { ## Modification log from 9 Dec 2011 onwards in detail ## ## 12 Jan 2012 STILL NEED TO DOCUMENT some items below +## +## 1 Jan 2015 John Collins V. 4.41 +## 18 Dec 2014 John Collins -c also deletes $deps_file if it is used. +## 16 Dec 2014 John Collins Finish change of e-mail +## 5 Dec 2014 John Collins Quote jobname when needed. +## 5 Sep 2014 John Collins Change my e-mail +## 30 Aug 2014 John Collins Change my e-mail +## 13 Aug 2014 John Collins Try to correct error handling to avoid +## repeated runs of latex after an error. +## Revert to some code from v. 4-32. +## Do I need $retry_msg? +## 8 Aug 2014 John Collins Fix up for the making of -eps-converted-to.pdf +## 4 Aug 2014 John Collins Sort and remove redundant xxx-undefined +## warning lines from log file. +## 23 Jul 2014 John Collins Fix failure when using both -cd and -output-directory +## 22 Jul 2014 John Collins If $HOME not set, then don't read ~/.latexmkrc +## Introduce $silence_logfile_warnings +## 21 Jul 2014 John Collins In setting $pscmd, allow for non-existent +### $ENV{USER} +## 29 May 2014 John Collins Correct sub Run for internal cmd w/o arguments +## 21 Mar 2014 John Collins Experimental: Add analysis hook for aux file. +## But I need to change rdb_create_rule in someway to +## allow correct handling of: (a) rule creation if +## rule doesn't exist, (b) either no change, or rule +## update, if the rule exists. No change is a bad +## idea, because conditions may change. Such a +## change, to effectively rdb_ensure_rule, would also +## help other dependencies, e.g., if a custom +## dependency has been created on one run of latexmk, +## and then on another run the definition is changed. +## With the old method, the old cus-dep is used unless +## the dependency cache fdb_latexmk is cleared; but +## with the new method the custom dependency will be +## changed correctly. +## 5 Mar 2014 John Collins System initialization files: allow them +## to be named latexmkrc as well as LatexMk, +## for more consistency with user directory +## names. Keep both cases, to preserve +## backward compatibility. +## 30 Jan 2014 John Collins Change sign-on message. Bug report info with help. V. 4.40a +## 15 Jan 2014 John Collins Fix failure to clean up correctly when +## root filename contains [, which is +## a glob metacharacter. +## V. 4.40 ## 10 Nov 2013 John Collins Change split / /, ... to split /\s*/, ... ## so as to be immune from extra white space. ## Clean up $clean_ext and $clean_full_ext by removing @@ -361,6 +413,17 @@ $log_wrap = 79; # (Documentation obviously needs to be improved!) %extra_rule_spec = (); + +# Hooks for customized extra processing on aux files. The following +# variable is an array of references to function. Each function is +# invoked in turn when a line of an aux file is processed (if none +# of the built-in actions have been done). On entry to the function, +# the following variables are set: +# $_ = current line of aux file +# $rule = name of rule during the invocation of which, the aux file +# was supposed to have been generated. +@aux_hooks = (); + ######################################################################### ## Default document processing programs, and related settings, ## These are mostly the same on all systems. @@ -620,6 +683,8 @@ $quote_filenames = 1; # Quote filenames in external commands $del_dir = ''; # Directory into which cleaned up files are to be put. # If $del_dir is '', just delete the files +@rc_system_files = (); + ######################################################################### ################################################################ @@ -665,6 +730,14 @@ $MSWin_fudge_break = 1; # Give special treatment to ctrl/C and ctrl/break # System-dependent overrides: +# Currently, the cases I have tests for are: MSWin32, cygwin, linux and +# darwin, with the main complications being for MSWin32 and cygwin. +# Special treatment may also be useful for MSYS (for which $^O reports +# "msys"). This is another *nix-emulation/system for MSWindows. At +# present it is treated as unix-like, but the environment variables +# are those of Windows. (The test for USERNAME as well as USER was +# to make latexmk work under MSYS's perl.) +# if ( $^O eq "MSWin32" ) { # Pure MSWindows configuration ## Configuration parameters: @@ -676,7 +749,7 @@ if ( $^O eq "MSWin32" ) { ## List of possibilities for the system-wide initialization file. ## The first one found (if any) is used. - @rc_system_files = ( 'C:/latexmk/LatexMk' ); + @rc_system_files = ( "C:/latexmk/LatexMk", "C:/latexmk/latexmkrc" ); $search_path_separator = ';'; # Separator of elements in search_path @@ -776,15 +849,19 @@ elsif ( $^O eq "cygwin" ) { ## List of possibilities for the system-wide initialization file. ## The first one found (if any) is used. ## We could stay with MSWin files here, since cygwin perl understands them - ## @rc_system_files = ( 'C:/latexmk/LatexMk' ); + ## @rc_system_files = ( 'C:/latexmk/LatexMk', 'C:/latexmk/latexmkrc' ); ## But they are deprecated in v. 1.7. So use the UNIX version, prefixed ## with a cygwin equivalent of the MSWin location - @rc_system_files = - ( '/cygdrive/c/latexmk/LatexMk', - '/opt/local/share/latexmk/LatexMk', - '/usr/local/share/latexmk/LatexMk', - '/usr/local/lib/latexmk/LatexMk' ); - + ## In addition, we need to add the same set of possible locations as with + ## unix, so that the user use a unix-style setup. + @rc_system_files = (); + foreach ( 'LatexMk', 'latexmkrc' ) { + push @rc_system_files, + ( "/cygdrive/c/latexmk/$_", + "/opt/local/share/latexmk/$_", + "/usr/local/share/latexmk/$_", + "/usr/local/lib/latexmk/$_" ); + } $search_path_separator = ';'; # Separator of elements in search_path # This is tricky. The search_path_separator depends on the kind # of executable: native NT v. cygwin. @@ -852,13 +929,15 @@ else { ## The first one found (if any) is used. ## Normally on a UNIX it will be in a subdirectory of /opt/local/share or ## /usr/local/share, depending on the local conventions. - ## /usr/local/lib/latexmk/LatexMk is put in the list for + ## But /usr/local/lib/latexmk is put in the list for ## compatibility with older versions of latexmk. - @rc_system_files = - ( '/opt/local/share/latexmk/LatexMk', - '/usr/local/share/latexmk/LatexMk', - '/usr/local/lib/latexmk/LatexMk' ); - + @rc_system_files = (); + foreach ( 'LatexMk', 'latexmkrc' ) { + push @rc_system_files, + ( "/opt/local/share/latexmk/$_", + "/usr/local/share/latexmk/$_", + "/usr/local/lib/latexmk/$_" ); + } $search_path_separator = ':'; # Separator of elements in search_path $dvi_update_signal = $signo{USR1} @@ -919,10 +998,21 @@ else { # # The following works on Solaris, LINUX, HP-UX, IRIX # Use -f to get full listing, including command line arguments. - # Use -u $ENV{CMD} to get all processes started by current user (not just + # Use -u $ENV{USER} to get all processes started by current user (not just # those associated with current terminal), but none of other users' # processes. - $pscmd = "ps -f -u $ENV{USER}"; + # However, the USER environment variable may not exist. Windows uses + # USERNAME instead. (And this propagates to a situation of + # unix-emulation software running under Windows.) + if ( exists $ENV{USER} ) { + $pscmd = "ps -f -u $ENV{USER}"; + } + elsif ( exists $ENV{USERNAME} ) { + $pscmd = "ps -f -u $ENV{USERNAME}"; + } + else { + $pscmd = "ps -f"; + } $pid_position = 1; # offset of PID in output of pscmd; first item is 0. if ( $^O eq "linux" ) { # Ps on Redhat (at least v. 7.2) appears to truncate its output @@ -974,12 +1064,12 @@ $max_repeat = 5; # Maximum times I repeat latex. Normally # occur, which mess up page numbers in the toc and lof, # Hence a 4th run is conceivably necessary. # At least one document class (JHEP.cls) works - # in such a way that a 4th run is needed. + # in such a way that a 4th run is needed. # We allow an extra run for safety for a - # maximum of 5. Needing further runs is - # usually an indication of a problem; further - # runs may not resolve the problem, and - # instead could cause an infinite loop. + # maximum of 5. Needing further runs is + # usually an indication of a problem; further + # runs may not resolve the problem, and + # instead could cause an infinite loop. $clean_ext = ""; # space separated extensions of files that are # to be deleted when doing cleanup, beyond # standard set @@ -1007,7 +1097,7 @@ $texfile_search = ""; # Specification for extra files to search for # backward compatibility. $fdb_ext = 'fdb_latexmk'; # Extension for the file for latexmk's - # file-database + # file-database # Make it long to avoid possible collisions. $fdb_ver = 3; # Version number for kind of fdb_file. @@ -1025,8 +1115,9 @@ $aux_dir = ''; # Directory for aux files (log, aux, etc). ## default flag settings. $recorder = 1; # Whether to use recorder option on latex/pdflatex -$silent = 0; # silence latex's messages? -$landscape_mode = 0; # default to portrait mode +$silent = 0; # Silence latex's messages? +$silence_logfile_warnings = 0; # Do list warnings in log file +$landscape_mode = 0; # default to portrait mode # The following two arrays contain lists of extensions (without # period) for files that are read in during a (pdf)LaTeX run but that @@ -1062,7 +1153,7 @@ $pdf_mode = 0; # No pdf file requested to be made by pdflatex # 2 to create pdf file by ps2pdf # 3 to create pdf file by dvipdf $view = 'default'; # Default preview is of highest of dvi, ps, pdf -$sleep_time = 2; # time to sleep b/w checks for file changes in -pvc mode +$sleep_time = 2; # time to sleep b/w checks for file changes in -pvc mode $banner = 0; # Non-zero if we have a banner to insert $banner_scale = 220; # Original default scale $banner_intensity = 0.95; # Darkness of the banner message @@ -1075,9 +1166,9 @@ $dependents_phony = 0; # Whether list(s) of dependencies includes phony targets $deps_file = '-'; # File for dependency list output. Default stdout. $rules_list = 0; # Whether to display list(s) of dependencies @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 - # to native MSWin path when cygwin is used. + # pointer to array [ cwd, good_cwd ], where + # good_cwd differs from cwd by being converted + # to native MSWin path when cygwin is used. $cleanup_mode = 0; # No cleanup of nonessential LaTex-related files. # $cleanup_mode = 0: no cleanup # $cleanup_mode = 1: full cleanup @@ -1092,8 +1183,8 @@ $cleanup_includes_cusdep_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 +$dvi_filter = ''; # DVI filter command +$ps_filter = ''; # Postscript filter command $force_mode = 0; # =1 to force processing past errors $go_mode = 0; # =1 to force processing regardless of time-stamps @@ -1124,6 +1215,7 @@ $waiting = 0; # Flags whether we are in loop waiting for an event # Used for some results of parsing log file: $reference_changed = 0; +$mult_defined = 0; $bad_reference = 0; $bad_citation = 0; @@ -1280,7 +1372,7 @@ if (!$BIBINPUTS) { $BIBINPUTS = '.'; } # Rule data: # 0: [ cmd_type, ext_cmd, int_cmd, test_kind, # source, dest, base, - # out_of_date, out_of_date_user, + # out_of_date, out_of_date_user, # time_of_last_run, time_of_last_file_check, # changed # last_result, last_message, @@ -1290,57 +1382,57 @@ if (!$BIBINPUTS) { $BIBINPUTS = '.'; } # cmd_type is 'primary', 'external', or 'cusdep' # ext_cmd is string for associated external command # 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, %O for options, + # for source, %B for base of current rule, + # %R for base of primary tex file, %T for + # 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 - # the external command, and it is the - # responsibility of the perl subroutine - # specified in intcmd to execute the - # external command if this is appropriate. - # This variable intcmd is a reference to an array, + # used to implement the application of the + # rule. If this is present, it overrides + # the external command, and it is the + # responsibility of the perl subroutine + # specified in intcmd to execute the + # external command if this is appropriate. + # This variable intcmd is a reference to an array, # $$intcmd[0] = internal routine # $$intcmd[1...] = its arguments (if any) # test_kind specifies method of determining # whether a file is out-of-date: # 0 for never # 1 for usual: whether there is a source - # file change + # file change # 2 for dest earlier than source # 3 for method 2 at first run, 1 thereafter # (used when don't have file data from - # previous run). + # previous run). # source = name of primary source file, if any # dest = name of primary destination file, - # if any + # if any # base = base name, if any, of files for - # this rule + # this rule # out_of_date = 1 if it has been detected that - # this rule needs to be run - # (typically because a source - # file has changed). + # this rule needs to be run + # (typically because a source + # file has changed). # 0 otherwise # out_of_date_user is like out_of_date, except # that the detection of out-of-dateness # has been made from a change of a - # putative user file, i.e., one that is - # not a generated file (e.g., aux). This - # kind of out-of-dateness should provoke a - # rerun whether or not there was an error - # during a run of (pdf)LaTeX. Normally, - # if there is an error, one should wait - # for the user to correct the error. But - # it is possible the error condition is - # already corrected during the run, e.g., - # by the user changing a source file in - # response to an error message. + # putative user file, i.e., one that is + # not a generated file (e.g., aux). This + # kind of out-of-dateness should provoke a + # rerun whether or not there was an error + # during a run of (pdf)LaTeX. Normally, + # if there is an error, one should wait + # for the user to correct the error. But + # it is possible the error condition is + # already corrected during the run, e.g., + # by the user changing a source file in + # response to an error message. # time_of_last_run = time that this rule was - # last applied. (In standard units - # from perl, to be directly compared - # with file modification times.) + # last applied. (In standard units + # from perl, to be directly compared + # with file modification times.) # time_of_last_file_check = last time that a check # was made for changes in source files. # changed flags whether special changes have been made @@ -1445,8 +1537,10 @@ if ( $auto_rc_use ) { # System rc file: read_first_rc_file_in_list( @rc_system_files ); } -if ( $auto_rc_use ) { +if ( $auto_rc_use && ($HOME ne "" ) ) { # User rc file: + # N.B. $HOME equals "" if latexmk couldn't determine a home directory. + # In that case, we shouldn't look for an rc file there. read_first_rc_file_in_list( "$HOME/.latexmkrc" ); } if ( $auto_rc_use ) { @@ -1508,10 +1602,14 @@ while ($_ = $ARGV[0]) push @extra_latex_options, $1; push @extra_pdflatex_options, $1; } + elsif ( /^-logfilewarninglist$/ || /^-logfilewarnings$/ ) + { $silence_logfile_warnings = 0; } + elsif ( /^-logfilewarninglist-$/ || /^-logfilewarnings-$/ ) + { $silence_logfile_warnings = 1; } # See above for -M elsif (/^-MF$/) { if ( $ARGV[0] eq '' ) { - &exit_help( "No file name specified after -MF switch"); + &exit_help( "No file name specified after -MF switch"); } $deps_file = $ARGV[0]; shift; @@ -1629,37 +1727,37 @@ while ($_ = $ARGV[0]) &exit_help( "No RC file specified after -r switch"); } if ( -e $ARGV[0] ) { - process_rc_file( $ARGV[0] ); + process_rc_file( $ARGV[0] ); } else { - die "$My_name: RC file [$ARGV[0]] does not exist\n"; + die "$My_name: RC file [$ARGV[0]] does not exist\n"; } shift; } elsif (/^-bm$/) { if ( $ARGV[0] eq '' ) { - &exit_help( "No message specified after -bm switch"); + &exit_help( "No message specified after -bm switch"); } $banner = 1; $banner_message = $ARGV[0]; shift; } elsif (/^-bi$/) { if ( $ARGV[0] eq '' ) { - &exit_help( "No intensity specified after -bi switch"); + &exit_help( "No intensity specified after -bi switch"); } $banner_intensity = $ARGV[0]; shift; } elsif (/^-bs$/) { if ( $ARGV[0] eq '' ) { - &exit_help( "No scale specified after -bs switch"); + &exit_help( "No scale specified after -bs switch"); } $banner_scale = $ARGV[0]; shift; } elsif (/^-dF$/) { if ( $ARGV[0] eq '' ) { - &exit_help( "No dvi filter specified after -dF switch"); + &exit_help( "No dvi filter specified after -dF switch"); } $dvi_filter = $ARGV[0]; shift; @@ -1692,17 +1790,30 @@ if ( $bad_options > 0 ) { } 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; } +# Initially $aux_dir and $out_dir are either absolute or relative to CURRENT +# directory. +# If we'll cd to directory of TeX file to do our work, we'll need to convert +# any relative directories to absolute, to preserve the user-requested +# directories after a cd. +# Otherwise, we need to normalize them in our standard way (to ensure +# standardization in the places we use them. + + foreach ($out_dir, $aux_dir) { - # Remove aliases to cwd: - $_ = normalize_filename( $_ ); - if ($_ eq '.' ) { $_ = ''; } + if ($do_cd) { + $_ = abs_path( $_ ); + } + else { + # Remove aliases to cwd: + $_ = normalize_filename( $_ ); + if ($_ eq '.' ) { $_ = ''; } + } } # Versions terminating in directory/path separator $out_dir1 = $out_dir; @@ -1725,7 +1836,7 @@ foreach ( 'BIBINPUTS' ) { $ENV{$_} = $aux_dir.$search_path_separator.$ENV{$_}; } else { - $ENV{$_} = $aux_dir.$search_path_separator; + $ENV{$_} = $aux_dir.$search_path_separator; } } @@ -1792,13 +1903,13 @@ else { # Make hash of excluded files, for easy checking: my %excl = (); foreach my $file (@excluded_file_list) { - $excl{$file} = ''; + $excl{$file} = ''; } foreach my $file (@file_list1) { - push( @file_list, $file) unless ( exists $excl{$file} ); + push( @file_list, $file) unless ( exists $excl{$file} ); } if ( !@file_list ) { - &exit_help( "No file name specified, and I couldn't find any"); + &exit_help( "No file name specified, and I couldn't find any"); } } @@ -1881,11 +1992,16 @@ if ( $recorder ) { add_option( "-recorder", \$latex, \$pdflatex ); } +# If the output and/or aux directories are specified: Fix the (pdf)latex +# commands to use them, and ensure that the directories exist. +# N.B. We are immune against cd'ing to directory of TeX file, because in +# that case we have forced the directories to be absolute. + if ( $out_dir ) { add_option( "-output-directory=\"$out_dir\"", \$latex, \$pdflatex ); if ( ! -e $out_dir ) { warn "$My_name: making output directory '$out_dir'\n" - if ! $silent; + if ! $silent; make_path $out_dir; } elsif ( ! -d $out_dir ) { @@ -1902,7 +2018,7 @@ if ( $aux_dir && ($aux_dir ne $out_dir) ) { add_option( "-aux-directory=\"$aux_dir\"", \$latex, \$pdflatex ); if ( ! -e $aux_dir ) { warn "$My_name: making auxiliary directory '$aux_dir'\n" - if ! $silent; + if ! $silent; make_path $aux_dir; } elsif ( ! -d $aux_dir ) { @@ -1913,7 +2029,7 @@ if ( $aux_dir && ($aux_dir ne $out_dir) ) { } if ( $jobname ne '' ) { - $jobstring = "--jobname=$jobname"; + $jobstring = "--jobname=\"$jobname\""; add_option( "$jobstring", \$latex, \$pdflatex ); } @@ -1965,7 +2081,7 @@ if ($print_type eq 'auto') { if ( $printout_mode ) { $one_time{'print'} = 1; if ($print_type eq 'none'){ - warn "$My_name: You have requested printout, but \$print_type is set to 'none'\n"; + warn "$My_name: You have requested printout, but \$print_type is set to 'none'\n"; } } if ( $preview_continuous_mode || $preview_mode ) { $one_time{'view'} = 1; } @@ -2010,15 +2126,15 @@ if ($aux_dir) { # Ensure $aux_dir is in TEXINPUTS search path. # This is used by dvips for files generated by mpost. if ( ! exists $ENV{TEXINPUTS} ) { - # Note the trailing ":" which ensures that the last item - # in the list of paths is the empty path, which actually - # means the default path, i.e., the following means that - # the TEXINPUTS search path is $aux_dir and the standard - # value. - $ENV{TEXINPUTS} = $aux_dir.$search_path_separator; + # Note the trailing ":" which ensures that the last item + # in the list of paths is the empty path, which actually + # means the default path, i.e., the following means that + # the TEXINPUTS search path is $aux_dir and the standard + # value. + $ENV{TEXINPUTS} = $aux_dir.$search_path_separator; } elsif ( $ENV{TEXINPUTS} !~ /$aux_dir$search_path_separator/ ) { - $ENV{TEXINPUTS} = $aux_dir.$search_path_separator.$ENV{TEXINPUTS}; + $ENV{TEXINPUTS} = $aux_dir.$search_path_separator.$ENV{TEXINPUTS}; } } @@ -2067,21 +2183,21 @@ foreach $filename ( @file_list ) pushd( $path ); } else { - $path = ''; + $path = ''; } ## remove extension from filename if was given. if ( &find_basename($filename, $root_filename, $texfile_name) ) { - if ( $force_mode ) { - warn "$My_name: Could not find file [$texfile_name]\n"; - } - else { + if ( $force_mode ) { + warn "$My_name: Could not find file [$texfile_name]\n"; + } + else { &ifcd_popd; - &exit_msg1( "Could not find file [$texfile_name]", - 11); - } + &exit_msg1( "Could not find file [$texfile_name]", + 11); + } } if ($jobname ne '' ) { $root_filename = $jobname; @@ -2120,11 +2236,11 @@ foreach $filename ( @file_list ) $base = $path.$base; if ( $rule =~ /^makeindex/ ) { push @index_bibtex_generated, $$Psource, $$Pdest, "$base.ilg"; - } + } elsif ( $rule =~ /^(bibtex|biber)/ ) { push @index_bibtex_generated, $$Pdest, "$base.blg"; push @aux_files, $$Psource; - } + } elsif ( exists $other_generated{$$Psource} ) { $other_generated{$$Pdest}; } @@ -2140,24 +2256,24 @@ foreach $filename ( @file_list ) 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. - local %idx_files = (); # Maps idx_file to (ind_file, base). Not used here. - local %conversions = (); # (pdf)latex-performed conversions. Not used here. - # Maps output file created and read by (pdf)latex - # to source file of conversion. - local $primary_out = ''; # Actual output file (dvi or pdf). Not used here. + local %dependents = (); # Maps files to status. Not used here. + local @bbl_files = (); # Not used here. + local %idx_files = (); # Maps idx_file to (ind_file, base). Not used here. + local %conversions = (); # (pdf)latex-performed conversions. Not used here. + # Maps output file created and read by (pdf)latex + # to source file of conversion. + local $primary_out = ''; # Actual output file (dvi or pdf). Not used here. &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; - } + } if ($bibtex_use < 2) { delete $generated_exts_all{'bbl'}; } @@ -2165,14 +2281,14 @@ foreach $filename ( @file_list ) my %index_bibtex_generated = (); my %aux_files = (); foreach (@index_bibtex_generated) { - $index_bibtex_generated{$_} = 1 + $index_bibtex_generated{$_} = 1 unless ( /\.bbl$/ && ($bibtex_use < 2) ); delete( $other_generated{$_} ); - } + } foreach (@aux_files) { $aux_files{$_} = 1; delete( $other_generated{$_} ); - } + } if ($diagnostics) { show_array( "For deletion, the following were determined from fdb file or log file:\n" ." Generated (from makeindex and bibtex):", @@ -2181,7 +2297,9 @@ foreach $filename ( @file_list ) show_array( " Other generated files:\n" ." (only deleted if \$cleanup_includes_generated is set): ", keys %other_generated ); - } + show_array( " Yet other generated files:\n", + keys %generated_exts_all ); + } &cleanup1( $aux_dir1, $fdb_ext, 'blg', 'ilg', 'log', 'aux.bak', 'idx.bak', split('\s+',$clean_ext), keys %generated_exts_all @@ -2189,12 +2307,15 @@ foreach $filename ( @file_list ) unlink_or_move( 'texput.log', "texput.aux", keys %index_bibtex_generated, keys %aux_files ); + if ( $dependents_list && ( $deps_file ne '-' ) ) { + unlink_or_move( $deps_file ); + } if ($cleanup_includes_generated) { - unlink_or_move( keys %other_generated ); - } + unlink_or_move( keys %other_generated ); + } if ( $cleanup_includes_cusdep_generated) { - &cleanup_cusdep_generated; - } + &cleanup_cusdep_generated; + } if ( $cleanup_mode == 1 ) { &cleanup1( $out_dir1, 'dvi', 'dviF', 'ps', 'psF', 'pdf', split('\s+', $clean_full_ext) @@ -2254,12 +2375,12 @@ foreach $filename ( @file_list ) # previous run. So use filetime criterion for make # instead of change from previous run, until we have # done our own make. - rdb_recurse( [keys %possible_primaries], - sub{ if ( $$Ptest_kind == 1 ) { $$Ptest_kind = 3;} } + rdb_recurse( [keys %possible_primaries], + sub{ if ( $$Ptest_kind == 1 ) { $$Ptest_kind = 3;} } ); if ( -e $log_name ) { - rdb_for_some( [keys %possible_primaries], \&rdb_set_latex_deps ); - } + rdb_for_some( [keys %possible_primaries], \&rdb_set_latex_deps ); + } } foreach $rule ( rdb_accessible( uniq1( keys %requested_filerules ) ) ){ # For all source files of all accessible rules, @@ -2267,12 +2388,12 @@ foreach $filename ( @file_list ) # file, set them from disk. rdb_one_rule ($rule, undef, sub{ if ( $$Ptime == 0) { &rdb_update1; } } - ); + ); } if ($go_mode) { # Force everything to be remade. - rdb_recurse( [keys %requested_filerules], sub{$$Pout_of_date=1;} ); + rdb_recurse( [keys %requested_filerules], sub{$$Pout_of_date=1;} ); } @@ -2443,16 +2564,16 @@ sub rdb_make_rule_list { my $print_file = ''; my $print_cmd = 'NONE'; if ( $print_type eq 'dvi' ) { - $print_file = $dvi_final; - $print_cmd = $lpr_dvi; + $print_file = $dvi_final; + $print_cmd = $lpr_dvi; } elsif ( $print_type eq 'pdf' ) { - $print_file = $pdf_final; - $print_cmd = $lpr_pdf; + $print_file = $pdf_final; + $print_cmd = $lpr_pdf; } elsif ( $print_type eq 'ps' ) { - $print_file = $ps_final; - $print_cmd = $lpr; + $print_file = $ps_final; + $print_cmd = $lpr; } elsif ( $print_type eq 'none' ) { $print_cmd = 'NONE echo NO PRINTING CONFIGURED'; @@ -2510,30 +2631,30 @@ sub rdb_set_rules { %rule_db = (); foreach my $Prule_list (@_) { - foreach my $rule ( keys %$Prule_list) { - my ( $cmd_type, $ext_cmd, $int_cmd, $source, $dest, $base, $test_kind, $PA_extra_gen ) = @{$$Prule_list{$rule}}; + foreach my $rule ( keys %$Prule_list) { + my ( $cmd_type, $ext_cmd, $int_cmd, $source, $dest, $base, $test_kind, $PA_extra_gen ) = @{$$Prule_list{$rule}}; if ( ! $PA_extra_gen ) { $PA_extra_gen = []; } - my $needs_making = 0; - # Substitute in the filename variables, since we will use - # those for determining filenames. But delay expanding $cmd - # 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/; - s/%T/$texfile_name/; - } + my $needs_making = 0; + # Substitute in the filename variables, since we will use + # those for determining filenames. But delay expanding $cmd + # 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/; + s/%T/$texfile_name/; + } # print "$rule: $cmd_type, EC='$ext_cmd', IC='$int_cmd', $test_kind,\n", # " S='$source', D='$dest', B='$base' $needs_making\n"; - rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $test_kind, - $source, $dest, $base, - $needs_making, undef, undef, 1, $PA_extra_gen ); + rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $test_kind, + $source, $dest, $base, + $needs_making, undef, undef, 1, $PA_extra_gen ); # !! ?? Last line was -# $needs_making, undef, ($test_kind==1) ); - } +# $needs_making, undef, ($test_kind==1) ); + } } # End arguments of subroutine &rdb_make_links; } # END rdb_set_rules @@ -2558,7 +2679,7 @@ sub rdb_make_links { ) { $$Pfrom_rule = $from_rules{$file}; } - } + } ); rdb_for_all( 0, @@ -2568,9 +2689,9 @@ sub rdb_make_links { } if ( $$Pfrom_rule && (! rdb_rule_exists( $$Pfrom_rule ) ) ) { $$Pfrom_rule = ''; - } + } #?? print "$rule: $file, $$Pfrom_rule\n"; - } + } ); } # END rdb_make_links @@ -2615,12 +2736,12 @@ sub do_cusdep { if ( !-e $$Psource ) { # Source does not exist. Users of this rule will need to turn # it off when custom dependencies are reset - if ( !$silent ) { + if ( !$silent ) { ## ??? Was commented out. 1 Sep. 2008 restored, for cusdep no-file-exists issue warn "$My_name: In trying to apply custom-dependency rule\n", " to make '$$Pdest' from '$$Psource'\n", " the source file has disappeared since the last run\n"; - } + } # Treat as successful } elsif ( !$func_name ) { @@ -2636,21 +2757,21 @@ sub do_cusdep { " function name '$func_name' does not exists.\n"; } else { - my $cusdep_ret = &$func_name( $$Pbase ); + my $cusdep_ret = &$func_name( $$Pbase ); if ( defined $cusdep_ret && ($cusdep_ret != 0) ) { - $return = $cusdep_ret; - if ($return) { + $return = $cusdep_ret; + if ($return) { warn "Rule '$rule', function '$func_name'\n", " failed with return code = $return\n"; - } - } + } + } elsif ( !-e $$Pdest ) { # Destination non-existent, but routine failed to give an error warn "$My_name: In running custom-dependency rule\n", " to make '$$Pdest' from '$$Psource'\n", " function '$func_name' did not make the destination.\n"; - $return = -1; - } + $return = -1; + } } return $return; } # END do_cusdep @@ -2673,9 +2794,9 @@ sub do_viewfile { 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"; + " to set the destination file, so I won't use a temporary file\n"; $return = &Run_subst(); - } + } } else { $return = &Run_subst(); @@ -2701,12 +2822,12 @@ sub do_update_view { my $Pneed_to_get_viewer_process = \${$PAint_cmd}[4]; if ($viewer_update_method == 2) { - if ($$Pneed_to_get_viewer_process) { + if ($$Pneed_to_get_viewer_process) { $$Pviewer_process = &find_process_id( $$Psource ); if ($$Pviewer_process != 0) { $$Pneed_to_get_viewer_process = 0; - } - } + } + } if ($$Pviewer_process == 0) { print "$My_name: need to signal viewer for file '$$Psource', but didn't get \n", " process ID for some reason, e.g., no viewer, bad configuration, bug\n" @@ -2715,8 +2836,8 @@ sub do_update_view { elsif ( defined $viewer_update_signal) { print "$My_name: signalling viewer, process ID $$Pviewer_process\n" if $diagnostics ; - kill $viewer_update_signal, $$Pviewer_process; - } + kill $viewer_update_signal, $$Pviewer_process; + } else { warn "$My_name: viewer is supposed to be sent a signal\n", " but no signal is defined. Misconfiguration or bug?\n"; @@ -2726,7 +2847,7 @@ sub do_update_view { elsif ($viewer_update_method == 4) { if (defined $$Pext_cmd) { $return = &Run_subst(); - } + } else { warn "$My_name: viewer is supposed to be updated by running a command,\n", " but no command is defined. Misconfiguration or bug?\n"; @@ -2745,7 +2866,7 @@ sub if_source { } else { warn "Needed source file '$$Psource' does not exist.\n"; - return -1; + return -1; } } #END if_source @@ -2908,7 +3029,7 @@ CHANGE: $SIG{BREAK} = $SIG{INT} = 'IGNORE'; } if ($compiling_cmd) { - Run_subst( $compiling_cmd ); + Run_subst( $compiling_cmd ); } $failure = rdb_make( @targets ); @@ -2920,25 +3041,25 @@ CHANGE: # Start viewer if needed. if ( ($failure > 0) && (! $force_mode) ) { # No viewer yet - } + } elsif ( ($view_file ne '') && (-e $view_file) && $updated && $viewer_running ) { # A viewer is running. Explicitly get it to update screen if we have to do it: rdb_one_rule( 'update_view', \&rdb_run1 ); } elsif ( ($view_file ne '') && (-e $view_file) && !$viewer_running ) { # Start the viewer - if ( !$silent ) { + if ( !$silent ) { if ($new_viewer_always) { warn "$My_name: starting previewer for '$view_file'\n", "------------\n"; - } + } else { warn "$My_name: I have not found a previewer that ", "is already running. \n", " So I will start it for '$view_file'\n", "------------\n"; - } - } + } + } local $retcode = 0; rdb_one_rule( 'view', sub { $retcode = &rdb_run1;} ); if ( $retcode != 0 ) { @@ -2952,11 +3073,11 @@ CHANGE: else { $viewer_running = 1; $$Pneed_to_get_viewer_process = 1; - } # end analyze result of trying to run viewer + } # end analyze result of trying to run viewer } # end start viewer if ( $failure > 0 ) { if ( !$failure_msg ) { - $failure_msg = 'Failure to make the files correctly'; + $failure_msg = 'Failure to make the files correctly'; } @pre_primary = (); # Array of rules @post_primary = (); # Array of rules @@ -2978,12 +3099,12 @@ CHANGE: warn "$My_name: $failure_msg\n", " ==> You will need to change a source file before I do another run <==\n"; if ($failure_cmd) { - Run_subst( $failure_cmd ); + Run_subst( $failure_cmd ); } - } + } else { if ($success_cmd) { - Run_subst( $success_cmd ); + Run_subst( $success_cmd ); } } rdb_show_rule_errors(); @@ -2997,8 +3118,8 @@ CHANGE: } else { warn "Cannot open '$deps_file' for output of dependency information\n"; - } - } + } + } if ( $first_time || $updated || $failure ) { print "\n=== Watching for updated files. Use ctrl/C to stop ...\n"; } @@ -3011,24 +3132,24 @@ CHANGE: $have_break = 0; WAIT: while (1) { sleep( $sleep_time ); - if ($have_break) { last WAIT; } + if ($have_break) { last WAIT; } if ( rdb_new_changes(keys %rules_to_watch) ) { - if (!$silent) { + if (!$silent) { warn "$My_name: Need to remake files.\n"; - &rdb_diagnose_changes( ' ' ); - } + &rdb_diagnose_changes( ' ' ); + } last WAIT; - } + } # Don't count waiting time in processing: $processing_time1 = processing_time(); # Does this do this job???? local $new_files = 0; rdb_for_some( [keys %current_primaries], sub{ $new_files += &rdb_find_new_files } ); if ($new_files > 0) { - warn "$My_name: New file(s) found.\n"; + warn "$My_name: New file(s) found.\n"; last WAIT; - } - if ($have_break) { last WAIT; } + } + if ($have_break) { last WAIT; } } # end WAIT: &default_break; if ($have_break) { @@ -3078,7 +3199,7 @@ sub process_rc_file { # PREVIOUS VERSION # if ( ! -r $rc_file ) { # warn "$My_name: I cannot read the rc-file '$rc_file'\n", -# " or at least that's what Perl (for $^O) reports\n"; +# " or at least that's what Perl (for $^O) reports\n"; # return 1; # } # do( $rc_file ); @@ -3128,11 +3249,12 @@ sub execute_code_string { sub cleanup1 { # Usage: cleanup1( directory, exts_without_period, ... ) # - # The directory is a fixed name, so I must escape any glob metacharacters - # in it: + # 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.$_") =~ s/%R/$dir$root_filename/; + (my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/$dir$root_fixed/; unlink_or_move( glob( "$name" ) ); } } #END cleanup1 @@ -3295,6 +3417,10 @@ sub print_help " -latex=<program> - set program used for latex.\n", " (replace '<program>' by the program name)\n", " -latexoption=<option> - add the given option to the (pdf)latex command\n", + " -logfilewarninglist or -logfilewarnings \n", + " give list of warnings after run of (pdf)latex\n", + " -logfilewarninglist- or -logfilewarnings- \n", + " do not give list of warnings after run of (pdf)latex\n", " -M - Show list of dependent files after processing\n", " -MF file - Specifies name of file to receives list dependent files\n", " -MP - List of dependent files includes phony target for each source file.\n", @@ -3363,7 +3489,9 @@ sub print_help " \n", "In addition, latexmk recognizes many other options that are passed to\n", "latex and/or pdflatex without interpretation by latexmk. Run latexmk\n", - "with the option -showextraoptions to see a list of these\n"; + "with the option -showextraoptions to see a list of these\n", + "\n", + "Report bugs etc to John Collins <jcc8 at psu.edu>.\n"; } #END print_help @@ -3465,7 +3593,7 @@ sub check_biber_log { $error_count ++; if ( /> (FATAL|ERROR) - The file '[^']+' does not contain any citations!/ ) { #' $no_citations++; - } + } } } elsif ( /> INFO - Found .* '([^']+)'\s*$/ @@ -3474,16 +3602,16 @@ sub check_biber_log { || /> INFO - Reading (.*)$/ || /> INFO - Processing .* file '([^']+)' .*$/ ) { - if ( defined $Pbiber_source ) { + if ( defined $Pbiber_source ) { 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; @@ -3498,7 +3626,7 @@ sub check_biber_log { # 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; + return 5; } else { show_array( "$My_name: Failed to find one or more biber source files:", @@ -3509,7 +3637,7 @@ sub check_biber_log { } if ($control_file_missing) { return 6; - } + } return 4; } # print "$My_name: #Biber errors = $error_count, warning messages = $warning_count,\n ", @@ -3538,13 +3666,13 @@ sub run_bibtex { my ( $base, $path, $ext ) = fileparseA( $$Psource ); my $cwd = good_cwd(); foreach ( 'BIBINPUTS', 'BSTINPUTS' ) { - if ( exists $ENV{$_} ) { - $ENV{$_} = $cwd.$search_path_separator.$ENV{$_}; - } - else { - $ENV{$_} = $cwd.$search_path_separator; - } - } + if ( exists $ENV{$_} ) { + $ENV{$_} = $cwd.$search_path_separator.$ENV{$_}; + } + else { + $ENV{$_} = $cwd.$search_path_separator; + } + } pushd( $path ); $return = &Run_subst( undef, undef, '', $base.$ext, '', $base ); popd(); @@ -3553,7 +3681,7 @@ sub run_bibtex { warn "$My_name: Directory in file name '$$Psource' for bibtex\n", " but it is not the output directory '$aux_dir'\n"; $return = Run_subst(); - } + } } else { $return = Run_subst(); @@ -3590,10 +3718,10 @@ sub check_bibtex_log { } elsif ( /^I couldn\'t open auxiliary file (.*\.aux)/ ) { push @missing_aux, $1; - } + } elsif ( /^I found no \\citation commands---while reading file/ ) { $missing_citations++; - } + } elsif (/There (were|was) (\d+) error message/) { $error_count = $2; #print "Bibtex error: count=$error_count $_"; @@ -3694,8 +3822,8 @@ sub parse_log { my %cusdep_to = (); foreach ( @cus_dep_list ) { my ($fromext, $toext) = split; - $cusdep_from{$fromext} = $cusdep_from{".$fromext"} = $_; - $cusdep_to{$toext} = $cusdep_to{".$toext"} = $_; + $cusdep_from{$fromext} = $cusdep_from{".$fromext"} = $_; + $cusdep_to{$toext} = $cusdep_to{".$toext"} = $_; } # print "==== Cusdep from-exts:"; foreach (keys %cusdep_from) {print " '$_'";} print "\n"; # print "==== Cusdep to-exts:"; foreach (keys %cusdep_to) {print " '$_'";} print "\n"; @@ -3714,6 +3842,7 @@ sub parse_log { # a sensible default in case of misparsing $reference_changed = 0; + $mult_defined = 0; $bad_reference = 0; $bad_citation = 0; @@ -3765,44 +3894,46 @@ sub parse_log { # data structure until block is ended.) my %new_conversions = (); my @retries = (); + my $log_silent = ($silent || $silence_logfile_warnings); + my @warning_list = (); LINE: while( ($line <= $#lines) || ($#retries > -1) ) { if ($#retries > -1) { - $_ = pop @retries; - } - else { + $_ = pop @retries; + } + else { $_ = $lines[$line]; $line ++; - } + } if ( /^! pdfTeX warning/ || /^pdfTeX warning/ ) { # This kind of warning is produced by some versions of pdftex # or produced by my reparse of warnings from other # versions. next; - } + } elsif ( /^(.+)(pdfTeX warning.*)$/ ) { # Line contains a pdfTeX warnings that may have been # inserted directly after other material without an # intervening new line. I think pdfTeX always inserts a # newline after the warning. (From examination of source # code.) - push @retries, $1; + push @retries, $1; # But continue parsing the original line, in case it was a # misparse, e.g., of a filename ending in 'pdfTeX'; - } + } if ( $line == 1 ){ - if ( /^This is / ) { - # First line OK + if ( /^This is / ) { + # First line OK next LINE; } else { warn "$My_name: Error on first line of '$log_name'.\n". "This is apparently not a TeX log file. ", - "The first line is:\n$_\n"; + "The first line is:\n$_\n"; $failure = 1; $failure_msg = "Log file '$log_name' appears to have wrong format."; return 0; - } - } + } + } if ( $block_type ) { # In middle of parsing block if ( /^\($current_pkg\)/ ) { @@ -3810,146 +3941,152 @@ LINE: if ( ($block_type eq 'conversion') && /^\($current_pkg\)\s+Output file: <([^>]+)>/ ) { - $delegated_output = normalize_clean_filename($1); + $delegated_output = normalize_clean_filename($1); } - next LINE; - } + next LINE; + } # Block has ended. if ($block_type eq 'conversion') { +print "=== $delegated_source -> $delegated_output\n"; $new_conversions{$delegated_source} = $delegated_output; - } + } $current_pkg = $block_type = $delegated_source = $delegated_output = ""; # Then process current line - } + } + # Check for changed references, bad references and bad citations: if (/Rerun to get/) { - warn "$My_name: References changed.\n" if ! $silent; + warn "$My_name: References changed.\n" if ! $log_silent; $reference_changed = 1; } - if (/LaTeX Warning: (Reference[^\001]*undefined)./) { - warn "$My_name: $1 \n" unless $silent; - $bad_reference++; - } - if (/LaTeX Warning: (Citation[^\001]*undefined)./) { - warn "$My_name: $1 \n" unless $silent; - $bad_citation++; - } - if (/Package natbib Warning: (Citation[^\001]*undefined)./) { - warn "$My_name: $1 \n" unless $silent; + if (/^LaTeX Warning: (Reference[^\001]*undefined on input line .*)\./) { + push @warning_list, $1; + $bad_reference++; + } + elsif (/^LaTeX Warning: (Label [^\001]* multiply defined.*)\./) { + push @warning_list, $1; + $mult_defined++; + } + elsif (/^LaTeX Warning: (Citation[^\001]*undefined on input line .*)\./) { + push @warning_list, $1; $bad_citation++; - } - if ( /^Document Class: / ) { - # Class sign-on line - next LINE; - } - if ( /^\(Font\)/ ) { - # Font info line - next LINE; - } - if (/^No pages of output\./) { + } + elsif (/^Package natbib Warning: (Citation[^\001]*undefined on input line .*)\./) { + push @warning_list, $1; + $bad_citation++; + } + elsif ( /^Document Class: / ) { + # Class sign-on line + next LINE; + } + elsif ( /^\(Font\)/ ) { + # Font info line + next LINE; + } + elsif (/^No pages of output\./) { $primary_out = ''; - warn "$My_name: Log file says no output from latex\n"; - next LINE; - } - if ( /^Output written on\s+(.*)\s+\(\d+\s+page/ ) { + warn "$My_name: Log file says no output from latex\n"; + next LINE; + } + elsif ( /^Output written on\s+(.*)\s+\(\d+\s+page/ ) { $primary_out = normalize_clean_filename($1); - warn "$My_name: Log file says output to '$primary_out'\n" - unless $silent; - next LINE; - } - if ( /^Overfull / - || /^Underfull / + warn "$My_name: Log file says output to '$primary_out'\n" + unless $silent; + next LINE; + } + elsif ( /^Overfull / + || /^Underfull / || /^or enter new name\. \(Default extension: .*\)/ || /^\*\*\* \(cannot \\read from terminal in nonstop modes\)/ ) { - # Latex error/warning, etc. - next LINE; - } - if ( /^\\openout\d+\s*=\s*\`([^\']+)\'\.$/ ) { + # Latex error/warning, etc. + next LINE; + } + elsif ( /^\\openout\d+\s*=\s*\`([^\']+)\'\.$/ ) { # 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{normalize_force_directory( $aux_dir1, $1 )} = 1; - next LINE; - } + next LINE; + } # Test for conversion produced by package: - if ( /^Package (\S+) Info: Source file: <([^>]+)>/ ) { - # Info. produced by epstopdf (and possibly others) + elsif ( /^Package (\S+) Info: Source file: <([^>]+)>/ ) { + # Info. produced by epstopdf (and possibly others) # about file conversion $current_pkg = normalize_clean_filename($1); $delegated_source = normalize_clean_filename($2); $block_type = 'conversion'; - next LINE; - } + 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. - if ( /Writing index file (.*)$/ ) { + elsif ( /Writing index file (.*)$/ ) { my $idx_file = ''; - if ( /^Writing index file (.*)$/ ) { + if ( /^Writing index file (.*)$/ ) { # From makeidx.sty or multind.sty $idx_file = $1; - } + } elsif ( /^index\.sty> Writing index file (.*)$/ ) { # From old versions of index.sty $idx_file = $1; - } + } elsif ( /^Package \S* Info: Writing index file (.*) on input line/ ) { # From new versions of index.sty $idx_file = $1; - } + } else { - warn "$My_name: Message indicates index file was written\n", - " ==> but I do not know how to understand it: <==\n", - " '$_'\n"; + warn "$My_name: Message indicates index file was written\n", + " ==> but I do not know how to understand it: <==\n", + " '$_'\n"; next LINE; - } - # Typically, there is trailing space, not part of filename: - $idx_file =~ s/\s*$//; + } + # Typically, there is trailing space, not part of filename: + $idx_file =~ s/\s*$//; # 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 = normalize_force_directory( $aux_dir1, $idx_file ); - my ($idx_base, $idx_path, $idx_ext) = fileparseA( $idx_file ); - $idx_base = $idx_path.$idx_base; + $idx_file = normalize_force_directory( $aux_dir1, $idx_file ); + my ($idx_base, $idx_path, $idx_ext) = fileparseA( $idx_file ); + $idx_base = $idx_path.$idx_base; $idx_file = $idx_base.$idx_ext; - if ( $idx_ext eq '.idx' ) { - warn "$My_name: Index file '$idx_file' was written\n" - unless $silent; - $idx_files{$idx_file} = [ "$idx_base.ind", $idx_base ]; - } - elsif ( exists $cusdep_from{$idx_ext} ) { + if ( $idx_ext eq '.idx' ) { + warn "$My_name: Index file '$idx_file' was written\n" + unless $silent; + $idx_files{$idx_file} = [ "$idx_base.ind", $idx_base ]; + } + elsif ( exists $cusdep_from{$idx_ext} ) { if ( !$silent ) { - warn "$My_name: Index file '$idx_file' was written\n"; + warn "$My_name: Index file '$idx_file' was written\n"; warn " Cusdep '$cusdep_from{$idx_ext}' should be used\n"; } # No action needed here - } - else { - warn "$My_name: Index file '$idx_file' written\n", - " ==> but it has an extension I do not know how to handle <==\n"; - } + } + else { + warn "$My_name: Index file '$idx_file' written\n", + " ==> but it has an extension I do not know how to handle <==\n"; + } - next LINE; - } - if ( /^No file (.*?\.bbl)./ ) { + next LINE; + } + elsif ( /^No file (.*?\.bbl)./ ) { # 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 = normalize_force_directory( $aux_dir1, $1 ); - warn "$My_name: Non-existent bbl file '$bbl_file'\n $_\n"; - $dependents{$bbl_file} = 0; - push @bbl_files, $bbl_file; - next LINE; - } - foreach my $pattern (@file_not_found) { - if ( /$pattern/ ) { + my $bbl_file = normalize_force_directory( $aux_dir1, $1 ); + warn "$My_name: Non-existent bbl file '$bbl_file'\n $_\n"; + $dependents{$bbl_file} = 0; + push @bbl_files, $bbl_file; + next LINE; + } + foreach my $pattern (@file_not_found) { + if ( /$pattern/ ) { my $file = clean_filename($1); - warn "$My_name: Missing input file: '$file' from line\n '$_'\n" - unless $silent; - $dependents{normalize_filename($file)} = 0; - my $file1 = $file; + warn "$My_name: Missing input file: '$file' from line\n '$_'\n" + unless $silent; + $dependents{normalize_filename($file)} = 0; + my $file1 = $file; if ( $aux_dir ) { # Allow for the possibility that latex generated # a file in $aux_dir, from which the missing file can @@ -3959,31 +4096,31 @@ LINE: # file in $aux_dir, with a path. So give this alternate # location. my $file1 = normalize_force_directory( $aux_dir1, $file ); - $dependents{$file1} = 0; - } - next LINE; - } - } - if ( /^File: (.+) Graphic file \(type / ) { - # First line of message from includegraphics/x - $dependents{normalize_clean_filename($1)} = 1; - next LINE; - } - # Now test for generic lines to ignore, only after special cases! - if ( /^File: / ) { - # Package sign-on line. Includegraphics/x also produces a line - # with this signature, but I've already handled it. - next LINE; - } - if ( /^Package: / ) { - # Package sign-on line - next LINE; - } - if (/^\! LaTeX Error: / ) { - next LINE; - } + $dependents{$file1} = 0; + } + next LINE; + } + } + if ( /^File: (.+) Graphic file \(type / ) { + # First line of message from includegraphics/x + $dependents{normalize_clean_filename($1)} = 1; + next LINE; + } + # Now test for generic lines to ignore, only after special cases! + if ( /^File: / ) { + # Package sign-on line. Includegraphics/x also produces a line + # with this signature, but I've already handled it. + next LINE; + } + if ( /^Package: / ) { + # Package sign-on line + next LINE; + } + if (/^\! LaTeX Error: / ) { + next LINE; + } if ( m[^! I can't write on file `(.*)/([^/']*)'.\s*$] ) { - my $dir = $1; + my $dir = $1; my $file = $2; my $full_dir = $aux_dir1.$dir; if ( ($aux_dir ne '') && (! -e $full_dir) && ( $file =~ /\.aux$/) ) { @@ -3991,13 +4128,13 @@ LINE: " I'll try to make the subdirectory later.\n" if $diagnostics; push @missing_subdirs, $full_dir; - } + } else { warn "$My_name: ====== There were problems writing to", "----- '$file' in '$full_dir'.\n", "----- But this is not the standard situation of\n", "----- aux file to subdir of output directory, with\n", - "----- non-existent subdir\n", + "----- non-existent subdir\n", } } INCLUDE_CANDIDATE: @@ -4026,23 +4163,23 @@ LINE: # anymore. # # Solution: use ' [', but not '[' as first try at delimiter. - # Then if candidate filename is of form 'name1[name2]', then - # try splitting it. If 'name1' and/or 'name2' exists, put - # it/them in list, else just put 'name1[name2]' in list. - # So form of filename is now: - # '(', - # then any number of characters that are NOT ')', '(', or '{' - # (these form the filename); - # then ' [', or ' (', or ')', or end-of-string. - # That fails for pdflatex - # In log file: - # '(' => start of reading of file, followed by filename - # ')' => end of reading of file - # '[' => start of page (normally preceeded by space) - # Remember: - # filename (on VAX/VMS) may include '[' and ']' (directory - # separators) - # filenames (on MS-Win) commonly include space. + # Then if candidate filename is of form 'name1[name2]', then + # try splitting it. If 'name1' and/or 'name2' exists, put + # it/them in list, else just put 'name1[name2]' in list. + # So form of filename is now: + # '(', + # then any number of characters that are NOT ')', '(', or '{' + # (these form the filename); + # then ' [', or ' (', or ')', or end-of-string. + # That fails for pdflatex + # In log file: + # '(' => start of reading of file, followed by filename + # ')' => end of reading of file + # '[' => start of page (normally preceeded by space) + # Remember: + # filename (on VAX/VMS) may include '[' and ']' (directory + # separators) + # filenames (on MS-Win) commonly include space. # filenames on UNIX can included space. # Miktex quotes filenames # But web2c doesn't. Then @@ -4052,15 +4189,15 @@ LINE: # are rare. System filenames with spaces are common, but # they are normally followed by a newline rather than messages. - # First step: replace $_ by whole of line after the '(' - # Thus $_ is putative filename followed by other stuff. + # First step: replace $_ by whole of line after the '(' + # Thus $_ is putative filename followed by other stuff. $_ = $1; # Array of new candidate include files; sometimes more than one. my @new_includes = (); my $quoted = 0; if ( /^\"([^\"]+)\"/ ) { # Quoted file name, as from MikTeX - $quoted = 1; + $quoted = 1; } elsif ( /^([^\(^\)]*?)\s+[\[\{\<]/ ) { # Terminator: space then '[' or '{' or '<' @@ -4074,7 +4211,7 @@ LINE: elsif ( /^([^\(^\)]*)(\))/ ) { # Terminator is ')' } - else { + else { #Terminator is end-of-string } $_ = $'; # Put $_ equal to the unmatched tail of string ' @@ -4085,7 +4222,7 @@ LINE: # followed by space followed by message # (Common) push @new_includes, $1; - } + } if ( $include_candidate eq "[]" ) { # Part of overfull hbox message next INCLUDE_CANDIDATE; @@ -4105,32 +4242,32 @@ LINE: # If the first component exists, we probably have the # pdflatex form push @new_includes, $1, $2; - } + } else { # We have something else. # So leave the original candidate in the list - } - } - INCLUDE_NAME: + } + } + INCLUDE_NAME: foreach my $include_name (@new_includes) { $include_name = normalize_filename( $include_name ); - my ($base, $path, $ext) = fileparseB( $include_name ); + my ($base, $path, $ext) = fileparseB( $include_name ); if ( ($path eq './') || ($path eq '.\\') ) { $include_name = $base.$ext; - } + } if ( $include_name !~ m'[/|\\]' ) { # Filename does not include a path character # High potential for misparsed line - $dependents{$include_name} = 2; - } else { - $dependents{$include_name} = 3; - } - if ( $ext eq '.bbl' ) { - warn "$My_name: Found input bbl file '$include_name'\n" - unless $silent; - push @bbl_files, $include_name; - } - } # INCLUDE_NAME + $dependents{$include_name} = 2; + } else { + $dependents{$include_name} = 3; + } + if ( $ext eq '.bbl' ) { + warn "$My_name: Found input bbl file '$include_name'\n" + unless $silent; + push @bbl_files, $include_name; + } + } # INCLUDE_NAME } # INCLUDE_CANDIDATE } # LINE @@ -4155,16 +4292,16 @@ CANDIDATE: } elsif ( -e $candidate ) { if ( exists $generated_log{$candidate} ){ - $dependents{$candidate} = 6; - } + $dependents{$candidate} = 6; + } elsif ($code == 0) { - $dependents{$candidate} = 5; - } - else { - $dependents{$candidate} = 4; - } - } - elsif ($code == 1) { + $dependents{$candidate} = 5; + } + else { + $dependents{$candidate} = 4; + } + } + elsif ($code == 1) { # Graphics file that is supposed to have been read. # Candidate name is as given in source file, not as path # to actual file. @@ -4173,14 +4310,14 @@ CANDIDATE: # If the file still is not found, assume non-existent; my @kpse_result = kpsewhich( $candidate ); if ($#kpse_result > -1) { - delete $dependents{$candidate}; + delete $dependents{$candidate}; $dependents{$kpse_result[0]} = 4; - next CANDIDATE; - } - else { - push @not_found, $candidate; - } - } + next CANDIDATE; + } + else { + push @not_found, $candidate; + } + } elsif ($code == 2) { # Candidate is from '(...' construct in log file, for input file # which should include pathname if valid input file. @@ -4188,9 +4325,9 @@ CANDIDATE: # $code==2. # We get here if candidate file does not exist with given name # Almost surely result of a misparsed line in log file. - delete $dependents{$candidate}; + delete $dependents{$candidate}; push @misparse, $candidate; - } + } elsif ($code == 3) { # Candidate is from '(...' construct in log file, for input file # which should include pathname if valid input file. @@ -4200,10 +4337,10 @@ CANDIDATE: # given name. # Almost surely result of a misparsed line in log file. # But with lower probability than $code == 2 - delete $dependents{$candidate}; + delete $dependents{$candidate}; push @misparse, $candidate; - } - elsif ($code == 0) { + } + elsif ($code == 0) { my ($base, $path, $ext) = fileparseA($candidate); $ext =~ s/^\.//; if ( ($ext eq '') && (-e "$path$base.tex") ) { @@ -4214,16 +4351,16 @@ CANDIDATE: # to the missing file, unless the .tex file was # created during the run. # OLD $dependents{"$path$base.tex"} = 4; - # OLD delete $dependents{$candidate}; + # OLD delete $dependents{$candidate}; # NEW: - $dependents{"$path$base.tex"} = 4; - } - push @missing, $candidate; - } + $dependents{"$path$base.tex"} = 4; + } + push @missing, $candidate; + } } CANDIDATE_PAIR: foreach my $delegated_source (keys %new_conversions) { - my $delegated_output = $new_conversions{$delegated_source}; + my $delegated_output = $new_conversions{$delegated_source}; my $rule = "Delegated $delegated_source, $delegated_output"; # N.B. $delegated_source eq '' means the output file # was created without a named input file. @@ -4234,30 +4371,35 @@ CANDIDATE_PAIR: my @kpse_result = kpsewhich( $candidate,); if ($#kpse_result > -1) { $candidate = $kpse_result[0]; - } - } - } + } + } + } if ( ( (-e $delegated_source) || ($delegated_source eq '') ) && (-e $delegated_output) ) { - $conversions{$delegated_output} = $delegated_source; - $dependents{$delegated_output} = 7; + $conversions{$delegated_output} = $delegated_source; + $dependents{$delegated_output} = 7; if ($delegated_source) { $dependents{$delegated_source} = 4; - } - } - elsif (!$silent) { + } + } + elsif (!$silent) { print "Logfile claimed conversion from '$delegated_source' ", - "to '$delegated_output'. But:\n"; + "to '$delegated_output'. But:\n"; if (! -e $delegated_output) { - print " Output file does not exist\n"; - } + print " Output file does not exist\n"; + } if ( ($delegated_source ne '') && (! -e $delegated_source) ) { - print " Input file does not exist\n"; - } - } + print " Input file does not exist\n"; + } + } } + if ( ($#warning_list >= 0) && !$log_silent ) { + @warning_list = uniqs( @warning_list ); + show_array( "$My_name: List of undefined refs and citations:", + @warning_list ); + } if ( $diagnostics ) { @misparse = uniqs( @misparse ); @@ -4274,22 +4416,22 @@ CANDIDATE_PAIR: print "$dependents dependent files detected, of which ", "$exist exist, $not_found were not found,\n", - " and $missing appear not to exist.\n"; + " and $missing appear not to exist.\n"; print "Dependents:\n"; foreach (@dependents) { print " '$_' "; if ( $dependents{$_} == 6 ) { print " written by (pdf)latex";} if ( $dependents{$_} == 7 ) { print " converted by (pdf)latex";} - print "\n"; + print "\n"; } if ($not_found > 0) { - print "Not found:\n"; - foreach (@not_found) { print " $_\n"; } - } + print "Not found:\n"; + foreach (@not_found) { print " $_\n"; } + } if ($missing > 0) { - print "Not existent:\n"; - foreach (@missing) { print " $_\n"; } - } + print "Not existent:\n"; + foreach (@missing) { print " $_\n"; } + } if ( $bbl > 0 ) { print "Input bbl files:\n"; foreach (@bbl_files) { print " $_\n"; } @@ -4335,12 +4477,12 @@ sub parse_fls { if ( (exists $$Poutputs{$file}) && (! exists $$Pinputs{$file}) ) { $$Pfirst_read_after_write{$file} = 1; } - $$Pinputs{$file} = 1; - } + $$Pinputs{$file} = 1; + } elsif (/^\s*OUTPUT\s+(.*)$/) { # Take precautions against aliasing of foo, ./foo and other possibilities for cwd. - $$Poutputs{ normalize_filename( $1 )} = 1; - } + $$Poutputs{ normalize_filename( $1 )} = 1; + } } close( $fls_file ); return 0; @@ -4515,7 +4657,12 @@ AUX_LINE: } elsif ( /^\\\@input\{(.*)\}/ ) { # \\@input{next_aux_file_name} - &parse_aux1( $aux_dir1.$1 ); + &parse_aux1( $aux_dir1.$1 ); + } + else { + foreach my $Psub (@aux_hooks) { + &$Psub; + } } } close($aux_fh); @@ -4563,8 +4710,8 @@ sub fdb_get { if ( ! defined $check_time ) { $check_time = 0;} my ($new_time, $new_size) = get_time_size($file); my @nofile = (0,-1,0); # What we use for initializing - # a new entry in fdb or flagging - # non-existent file + # a new entry in fdb or flagging + # non-existent file if ( $new_size < 0 ) { delete $fdb_current{$file}; return @nofile; @@ -4658,41 +4805,41 @@ LINE: s/^\s*//; s/\s*$//; if ($state == -1) { - if ( ! /^# Fdb version ([\d]+)$/ ) { - warn "$My_name: File-database '$in_name' is not of correct format\n"; + if ( ! /^# Fdb version ([\d]+)$/ ) { + warn "$My_name: File-database '$in_name' is not of correct format\n"; return 1; - } + } if ( $1 > $fdb_ver) { - warn "$My_name: File-database '$in_name' is of too new version, $1 > $fdb_ver\n"; + warn "$My_name: File-database '$in_name' is of too new version, $1 > $fdb_ver\n"; return 1; - } + } $state = 0; } # Ignore blank lines and comments if ( /^$/ || /^#/ || /^%/ ) { next LINE;} if ( /^\[\"([^\"]+)\"\]/ ) { # Start of section - $rule = $1; + $rule = $1; my $tail = $'; #' Single quote in comment tricks the parser in # emacs from misparsing an isolated single quote $run_time = $check_time = 0; $source = $dest = $base = ''; if ( $tail =~ /^\s*(\S+)\s*$/ ) { $run_time = $1; - } + } elsif ( $tail =~ /^\s*(\S+)\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s*$/ ) { $run_time = $1; $source = $2; $dest = $3; $base = $4; - } + } elsif ( $tail =~ /^\s*(\S+)\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+(\S+)\s*$/ ) { $run_time = $1; $source = $2; $dest = $3; $base = $4; $check_time = $5; - } + } if ( rdb_rule_exists( $rule ) ) { rdb_one_rule( $rule, sub{ @@ -4701,7 +4848,7 @@ LINE: $$Pcheck_time = $check_time; } ); - } + } elsif ($rule =~ /^cusdep\s+(\S+)\s+(\S+)\s+(.+)$/ ) { # Create custom dependency my $fromext = $1; @@ -4721,7 +4868,7 @@ LINE: # lines of the fdb file rdb_create_rule( $rule, 'cusdep', '', $PAnew_cmd, 1, $source, $dest, $base, 0, $run_time, $check_time, 1 ); - } + } elsif ( $rule =~ /^(makeindex|bibtex|biber)\s*(.*)$/ ) { my $PA_extra_gen = []; my $rule_generic = $1; @@ -4735,85 +4882,85 @@ LINE: $base = $path.$base; if ($rule_generic eq 'makeindex') { $dest = "$base.ind"; - } + } elsif ($rule_generic eq 'bibtex') { $dest = "$base.bbl"; $source = "$base.aux"; - } + } elsif ($rule_generic eq 'biber') { $dest = "$base.bbl"; $source = "$base.bcf"; - } - } + } + } if ($rule =~ /^makeindex/) { $PA_extra_gen = [ "$base.ilg" ]; } if ($rule =~ /^(bibtex|biber)/) { $PA_extra_gen = [ "$base.blg" ]; } if ($rule =~ /^bibtex/) { $int_cmd = "run_bibtex"; } - warn "$My_name: File-database '$in_name': setting rule '$rule'\n" + warn "$My_name: File-database '$in_name': setting rule '$rule'\n" if $diagnostics; my $cmd_type = 'external'; my $ext_cmd = ${$rule_generic}; - warn " Rule kind = '$rule_generic'; ext_cmd = '$ext_cmd';\n", + warn " Rule kind = '$rule_generic'; ext_cmd = '$ext_cmd';\n", " int_cmd = '$int_cmd';\n", - " source = '$source'; dest = '$dest'; base = '$base';\n" + " source = '$source'; dest = '$dest'; base = '$base';\n" if $diagnostics; # Set source file as non-existent. # If it existed on last run, it will be in later # lines of the fdb file rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, 1, $source, $dest, $base, 0, $run_time, $check_time, 1, $PA_extra_gen ); - } + } else { - warn "$My_name: In file-database '$in_name' rule '$rule'\n", + warn "$My_name: In file-database '$in_name' rule '$rule'\n", " is not in use in this session\n" if $diagnostics; - $new_source = undef; - $state = 10; - next LINE; - } + $new_source = undef; + $state = 10; + next LINE; + } $new_source = $new_sources{$rule} = {}; - $state = 1; #Reading a section, source part - } + $state = 1; #Reading a section, source part + } elsif ( ($state <=0) || ($state >= 3) ) { next LINE; - } + } elsif ( /^\(source\)/ ) { $state = 1; next LINE; } elsif ( /^\(generated\)/ ) { $state = 2; next LINE; } - elsif ( ($state == 1) && /^\"([^\"]*)\"\s+(\S+)\s+(\S+)\s+(\S+)\s+\"([^\"]*)\"/ ) { + elsif ( ($state == 1) && /^\"([^\"]*)\"\s+(\S+)\s+(\S+)\s+(\S+)\s+\"([^\"]*)\"/ ) { # Source file line - my $file = $1; - my $time = $2; - my $size = $3; - my $md5 = $4; + my $file = $1; + my $time = $2; + my $size = $3; + my $md5 = $4; my $from_rule = $5; #?? print " --- File '$file'\n"; if ($state != 1) { warn "$My_name: In file-database '$in_name' ", - "line $. is outside a section:\n '$_'\n"; - $errors++; - next LINE; - } + "line $. is outside a section:\n '$_'\n"; + $errors++; + next LINE; + } # Set file in database. But ensure we don't do an unnecessary # fdb_get, which can trigger a new MD5 calculation, which is # lengthy for a big file. Ininitially flagging the file # as non-existent solves the problem: - rdb_ensure_file( $rule, $file, undef, 1 ); + rdb_ensure_file( $rule, $file, undef, 1 ); rdb_set_file1( $rule, $file, $time, $size, $md5 ); fdb_set( $file, $time, $size, $md5 ); # Save the rest of the data, especially the from_fule until we know all # the rules, otherwise the from_rule may not exist. # Also we'll have a better chance of looping through files. - ${$new_source}{$file} = [ $time, $size, $md5, $from_rule ]; - } - elsif ( ($state == 2) && /^\"([^\"]*)\"/ ) { + ${$new_source}{$file} = [ $time, $size, $md5, $from_rule ]; + } + elsif ( ($state == 2) && /^\"([^\"]*)\"/ ) { my $file = $1; rdb_one_rule( $rule, sub{ rdb_add_generated($file); } ); } - else { - warn "$My_name: In file-database '$in_name' ", + else { + warn "$My_name: In file-database '$in_name' ", "line $. is of wrong format:\n '$_'\n"; - $errors++; - next LINE; - } + $errors++; + next LINE; + } } undef $in_handle; # Set cus dependencies. @@ -4863,7 +5010,7 @@ sub rdb_write { \@rules, sub { # Omit data on a unused and never-run primary rule: - if ( ($$Prun_time == 0) + if ( ($$Prun_time == 0) && exists( $possible_primaries{$rule} ) && ! exists( $current_primaries{$rule} ) ) @@ -4873,7 +5020,7 @@ sub rdb_write { print $out_handle "[\"$rule\"] $$Prun_time \"$$Psource\" \"$$Pdest\" \"$$Pbase\" $$Pcheck_time\n"; rdb_do_files( sub { print $out_handle " \"$file\" $$Ptime $$Psize $$Pmd5 \"$$Pfrom_rule\"\n"; } - ); + ); print $out_handle " (generated)\n"; foreach (keys %$PHdest) { print $out_handle " \"$_\"\n"; @@ -4895,7 +5042,7 @@ sub rdb_set_latex_deps { # Rules should only be primary if ( $$Pcmd_type ne 'primary' ) { - warn "\n$My_name: ==========$My_name: Probable BUG======= \n ", + warn "\n$My_name: ==========$My_name: Probable BUG======= \n ", " rdb_set_latex_deps called to set files ", "for non-primary rule '$rule'\n\n"; return; @@ -4923,7 +5070,13 @@ sub rdb_set_latex_deps { local @missing_subdirs = (); # Missing subdirectories in aux_dir # The following are also returned, but are global, to be used by caller - # $reference_changed, $bad_reference $bad_citation + # $reference_changed, $bad_reference $bad_citation, $mult_defined + + # Do I have my own eps-to-pdf conversion? + my $epspdf_cusdep = 0; + foreach (@cus_dep_list) { + if ( /^eps pdf / ) { $epspdf_cusdep = 1; last; } + } &parse_log; $missing_dirs = 'none'; # Status of missing directories @@ -4933,30 +5086,30 @@ sub rdb_set_latex_deps { foreach my $dir ( uniqs( @missing_subdirs ) ) { if ( -d $dir ) { $missing_dirs = 'failure'; - warn "$My_name: ==== Directory '$dir' is said to be missing\n", - " But it exists!\n"; + warn "$My_name: ==== Directory '$dir' is said to be missing\n", + " But it exists!\n"; } elsif ( (-e $dir) && (!-d $dir) ) { $missing_dirs = 'failure'; - warn "$My_name: ==== Directory '$dir' is said to be missing\n", - " But a non-directory file of this name exists!\n"; + warn "$My_name: ==== Directory '$dir' is said to be missing\n", + " But a non-directory file of this name exists!\n"; } else { if (mkdir $dir) { warn "$My_name: Directory '$dir' created\n"; - } + } else { $missing_dirs = 'failure'; warn "$My_name: Couldn't create directory '$dir'.\n", " System error: '$!'\n"; - } + } } } - } + } else { $missing_dirs = 'not allowed'; warn "$My_name: There are missing subdirectories, but their creation\n", - " is not allowed. The subdirectories are:\n"; + " is not allowed. The subdirectories are:\n"; foreach my $dir ( uniqs( @missing_subdirs ) ) { warn " '$dir'\n"; } @@ -4968,14 +5121,35 @@ sub rdb_set_latex_deps { parse_fls( $fls_file, \%source_fls, \%generated_fls, \%first_read_after_write ); foreach (keys %source_fls) { $dependents{$_} = 4; - } + } foreach (keys %generated_fls) { rdb_add_generated( $_ ); if ( exists($dependents{$_}) ) { $dependents{$_} = 6; - } + } } } + + for my $conv (sort keys %conversions) { + my $conv_source = $conversions{$conv}; + if ( $conv =~ /^(.*)-eps-converted-to\.pdf$/ ) { + # Check all the conditions for pdflatex's conversion eps to pdf + # are valid; if they are, treat the converted file as not a + # source file. + my $base = $1; + if ( (-e $conv_source) && (-e $conv) && ( $conv_source eq "$base.eps" ) ) { + # $conv isn't a real source of (pdf)latex + rdb_remove_files( $rule, $conv ); + delete $dependents{$conv}; + if ($epspdf_cusdep) { + $dependents{"$base.pdf"} = ((-e "$base.pdf") ? 4 : 0 ); + } + } + } + } + + + # ?? !! Should also deal with .run.xml file # Handle result on output file: @@ -5003,7 +5177,7 @@ sub rdb_set_latex_deps { IDX_FILE: foreach my $idx_file ( keys %idx_files ) { - my ($ind_file, $ind_base) = @{$idx_files{$idx_file}}; + my ($ind_file, $ind_base) = @{$idx_files{$idx_file}}; my $from_rule = "makeindex $idx_file"; if ( ! rdb_rule_exists( $from_rule ) ){ print "!!!===Creating rule '$from_rule': '$ind_file' from '$idx_file'\n" @@ -5013,7 +5187,7 @@ sub rdb_set_latex_deps { print " ===Source file '$ind_file' for '$rule'\n" if ($diagnostics); rdb_ensure_file( $rule, $ind_file, $from_rule ); - } + } # Make sure the .ind file is treated as a detected source file; # otherwise if the log file has it under a different name (as # with MiKTeX which gives full directory information), there @@ -5023,13 +5197,14 @@ sub rdb_set_latex_deps { if ( ! -e $ind_file ) { # Failure was non-existence of makable file # Leave failure issue to other rules. - $failure = 0; - } + $failure = 0; + } } + local %processed_aux_files = (); BBL_FILE: foreach my $bbl_file ( uniqs( @bbl_files ) ) { - my ($bbl_base, $bbl_path, $bbl_ext) = fileparseA( $bbl_file ); + my ($bbl_base, $bbl_path, $bbl_ext) = fileparseA( $bbl_file ); $bbl_base = $bbl_path.$bbl_base; my @new_bib_files = (); my @new_aux_files = (); @@ -5038,7 +5213,7 @@ sub rdb_set_latex_deps { my $bib_program = 'bibtex'; if ( test_gen_file( "$bbl_base.bcf" ) ) { $bib_program = 'biber'; - } + } my $from_rule = "$bib_program $bbl_base"; print "======= Dealing with '$from_rule'\n" if ($diagnostics); if ($bib_program eq 'biber') { @@ -5056,12 +5231,12 @@ sub rdb_set_latex_deps { if ( $bib_program eq 'biber' ) { rdb_create_rule( $from_rule, 'external', $biber, '', 1, "$bbl_base.bcf", $bbl_file, $bbl_base, 1, 0, 0 ); - } + } else { rdb_create_rule( $from_rule, 'external', $bibtex, 'run_bibtex', 1, "$bbl_base.aux", $bbl_file, $bbl_base, 1, 0, 0 ); - } - } + } + } local %old_sources = (); rdb_one_rule( $from_rule, sub { %old_sources = %$PHsource; } ); foreach my $source ( @new_bib_files, @new_aux_files, @new_bst_files, @biber_source ) { @@ -5070,6 +5245,9 @@ sub rdb_set_latex_deps { rdb_ensure_file( $from_rule, $source ); delete $old_sources{$source}; } + foreach my $source ( @new_aux_files ) { + $processed_aux_files{$source} = 1; + } if ($diagnostics) { foreach ( keys %old_sources ) { print "Removing no-longer-needed dependent '$_' from rule '$from_rule'\n"; @@ -5083,14 +5261,24 @@ sub rdb_set_latex_deps { # Failure was non-existence of makable file # Leave failure issue to other rules. $failure = 0; - } + } + } + + if ( ($#aux_hooks > -1) && ! exists $processed_aux_files{$aux_main} ) { + my @new_bib_files = (); + my @new_aux_files = (); + my @new_bst_files = (); + parse_aux( $aux_main, \@new_bib_files, \@new_aux_files, \@new_bst_files ); + foreach my $source ( @new_aux_files ) { + $processed_aux_files{$source} = 1; + } } NEW_SOURCE: - foreach my $new_source (keys %dependents, keys %conversions) { + foreach my $new_source (keys %dependents) { print " ===Source file for rule '$rule': '$new_source'\n" - if ($diagnostics); - if ( ($dependents{$new_source} == 5) + if ($diagnostics); + if ( ($dependents{$new_source} == 5) || ($dependents{$new_source} == 6) ) { # (a) File was detected in "No file..." line in log file. @@ -5104,37 +5292,37 @@ NEW_SOURCE: # database, then the previous version of the file should be # treated as non-existent, to ensure another run is forced. rdb_ensure_file( $rule, $new_source, undef, 1 ); - } - elsif ( $dependents{$new_source} == 7 ) { + } + elsif ( $dependents{$new_source} == 7 ) { # File was result of conversion by (pdf)latex. my $cnv_source = $conversions{$new_source}; rdb_ensure_file( $rule, $new_source ); - if ($cnv_source) { + if ($cnv_source) { # Conversion from $cnv_source to $new_source # implies that effectively $cnv_source is a source # of the (pdf)latex run. rdb_ensure_file( $rule, $cnv_source ); - } + } # Flag that changes of the generated file during a run # do not require a rerun: rdb_one_file( $new_source, sub{ $$Pcorrect_after_primary = 1; } ); - } - else { + } + else { # But we don't need special precautions for ordinary user files # (or for files that are generated outside of latex/pdflatex). rdb_ensure_file( $rule, $new_source ); - } - if ( ($dependents{$new_source} == 6) + } + if ( ($dependents{$new_source} == 6) || ($dependents{$new_source} == 7) ) { - rdb_add_generated($new_source); + rdb_add_generated($new_source); } } my @more_sources = &rdb_set_dependents( $rule ); my $num_new = $#more_sources + 1; foreach (@more_sources) { - $dependents{$_} = 4; + $dependents{$_} = 4; if ( ! -e $_ ) { # Failure was non-existence of makable file # Leave failure issue to other rules. @@ -5146,20 +5334,20 @@ NEW_SOURCE: delete $dependents{$_}; } if ($diagnostics) { - if ($num_new > 0 ) { - print "$num_new new source files for rule '$rule':\n"; - foreach (@more_sources) { print " '$_'\n"; } - } - else { - print "No new source files for rule '$rule':\n"; - } + if ($num_new > 0 ) { + print "$num_new new source files for rule '$rule':\n"; + foreach (@more_sources) { print " '$_'\n"; } + } + else { + print "No new source files for rule '$rule':\n"; + } my @first_read_after_write = sort keys %first_read_after_write; if ($#first_read_after_write >= 0) { print "The following files were only read after being written:\n"; foreach (@first_read_after_write) { print " '$_'\n"; - } - } + } + } } my @files_not_needed = (); foreach (keys %$PHsource) { @@ -5167,7 +5355,7 @@ NEW_SOURCE: print "Removing no-longer-needed dependent '$_' from rule '$rule'\n" if $diagnostics; push @files_not_needed, $_; - } + } } rdb_remove_files( $rule, @files_not_needed ); @@ -5215,24 +5403,24 @@ MISSING_FILE: $new_includes{"$missing.tex"} = 1; } if ( -e $missing ) { - $new_includes{$missing} = 1; + $new_includes{$missing} = 1; } if ( $ext ne "" ) { foreach my $dep (@cus_dep_list){ my ($fromext,$toext) = split('\s+',$dep); if ( ( "$ext" eq "$toext" ) && ( -e "$path$base.$fromext" ) - ) { + ) { # Source file for the missing file exists # So we have a real include file, and it will be made # next time by rdb_set_dependents $new_includes{$missing} = 1; } - else { + else { # no point testing the $toext if the file doesn't exist. - } + } next MISSING_FILE; - } + } } else { # $_ doesn't exist, $_.tex doesn't exist, @@ -5252,7 +5440,7 @@ MISSING_FILE: $new_includes{"$path$base.$toext"} = 1; # next MISSING_FILE; } - } + } } } # end MISSING_FILES @@ -5271,19 +5459,19 @@ MISSING_FILE: my $stripped = $file; $stripped =~ s{^\./}{}; if ( exists $PHsource{$file} ) { - delete $new_includes{$file}; - } + delete $new_includes{$file}; + } else { - $found ++; - rdb_ensure_file( $rule, $file ); - } + $found ++; + rdb_ensure_file( $rule, $file ); + } } if ( $diagnostics && ( $found > 0 ) ) { - warn "$My_name: Detected previously missing files:\n"; + warn "$My_name: Detected previously missing files:\n"; foreach ( sort keys %new_includes ) { warn " '$_'\n"; - } + } } return $found; } # END rdb_find_new_files @@ -5300,7 +5488,7 @@ sub rdb_set_dependents { rdb_for_some( [@_], 0, \&rdb_one_dep ); # OLD rdb_recurse( [@_], 0, \&rdb_one_dep ); foreach (@deletions) { - my ($rule, $file) = @$_; + my ($rule, $file) = @$_; rdb_remove_files( $rule, $file ); } &rdb_make_links; @@ -5329,30 +5517,30 @@ DEP: my ($fromext,$proptoext,$must,$func_name) = split('\s+',$dep); if ( $toext eq $proptoext ) { my $source = "$base_name.$fromext"; - # Found match of rule + # Found match of rule if ($diagnostics) { print "Found cusdep: $source to make $rule:$new_dest ====\n"; } - if ( -e $source ) { - $$Pfrom_rule = "cusdep $fromext $toext $base_name"; -#?? print "?? Ensuring rule for '$$Pfrom_rule'\n"; + if ( -e $source ) { + $$Pfrom_rule = "cusdep $fromext $toext $base_name"; +#?? print "?? Ensuring rule for '$$Pfrom_rule'\n"; local @PAnew_cmd = ( 'do_cusdep', $func_name ); if ( !-e $new_dest ) { - push @new_sources, $new_dest; - } + push @new_sources, $new_dest; + } if (! rdb_rule_exists( $$Pfrom_rule ) ) { print "=== Creating rule for '$$Pfrom_rule'\n"; rdb_create_rule( $$Pfrom_rule, 'cusdep', '', \@PAnew_cmd, 3, $source, $new_dest, $base_name, 0 ); - } + } else { - rdb_one_rule( + rdb_one_rule( $$Pfrom_rule, sub{ @$PAint_cmd = @PAnew_cmd; $$Pdest = $new_dest;} ); - } - return; - } + } + return; + } else { # Source file does not exist if ( !$force_mode && ( $must != 0 ) ) { @@ -5361,16 +5549,16 @@ DEP: $failure_msg = "File '$base_name.$fromext' does not exist ". "to build '$base_name.$toext'"; return; - } + } elsif ( $$Pfrom_rule =~ /^cusdep $fromext $toext / ) { # Source file does not exist, destination has the rule set. # So turn the from_rule off - $$Pfrom_rule = ''; - } - else { - } - } - } + $$Pfrom_rule = ''; + } + else { + } + } + } elsif ( ($toext eq '') && (! -e $file ) && (! -e "$base_name.$proptoext" ) @@ -5383,27 +5571,27 @@ DEP: my $source = "$base_name.$fromext"; if ( -e $source ) { $new_dest = "$base_name.$proptoext"; - my $from_rule = "cusdep $fromext $proptoext $base_name"; + my $from_rule = "cusdep $fromext $proptoext $base_name"; push @new_sources, $new_dest; - print "Ensuring rule for '$from_rule', to make '$new_dest'\n" - if $diagnostics > -1; + print "Ensuring rule for '$from_rule', to make '$new_dest'\n" + if $diagnostics > -1; local @PAnew_cmd = ( 'do_cusdep', $func_name ); if (! rdb_rule_exists( $from_rule ) ) { rdb_create_rule( $from_rule, 'cusdep', '', \@PAnew_cmd, 3, $source, $new_dest, $base_name, 0 ); - } + } else { - rdb_one_rule( + rdb_one_rule( $$Pfrom_rule, sub{ @$PAint_cmd = @PAnew_cmd; $$Pdest = $new_dest;} ); - } + } rdb_ensure_file( $rule, $new_dest, $from_rule ); # We've now got a spurious file in our rule. But don't mess # with deleting an item we are in the middle of! push @deletions, [$rule, $file]; - return; - } + return; + } } # End of Rule found } # End DEP if ( (! -e $file) && $use_make_for_missing_files ) { @@ -5415,8 +5603,8 @@ DEP: &Run_subst( "$make $q$file$q" ); if ( -e $file ) { return; - } - } + } + } else { print "$My_name: '$rule': source '$file' doesn't exist.\n", " I'll try making it with allowed extensions \n"; @@ -5436,9 +5624,9 @@ DEP: # the error due to a missing file. $$Pout_of_date_user = 1; return; - } - } - } + } + } + } } } #END rdb_one_dep @@ -5452,18 +5640,18 @@ sub rdb_list { my @accessible_all = rdb_accessible( keys %requested_filerules ); rdb_for_some( \@accessible_all, - sub{ $count_rules++; + sub{ $count_rules++; print "Rule '$rule' depends on:\n"; }, - sub{ print " '$file'\n"; }, - sub{ print " and generates:\n"; + sub{ print " '$file'\n"; }, + sub{ print " and generates:\n"; foreach (keys %$PHdest) { print " '$_'\n"; } # print " default_extra_generated:\n"; # foreach (@$PA_extra_generated) { print " '$_'\n"; } }, ); if ($count_rules <= 0) { - print " ---No rules defined\n"; + print " ---No rules defined\n"; } } #END rdb_list @@ -5483,11 +5671,11 @@ sub deps_list { my @accessible_all = rdb_accessible( keys %requested_filerules ); rdb_for_some( \@accessible_all, - sub{ + sub{ # foreach (keys %$PHdest) { print "----- $_\n"; } push @generated, keys %$PHdest; }, - sub{ $source{$file} = 1; } + sub{ $source{$file} = 1; } ); foreach (keys %generated_exts_all) { (my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/$root_filename/; @@ -5526,17 +5714,17 @@ sub rdb_show { print "===Rules:\n"; local $count_rules = 0; rdb_for_all( - sub{ $count_rules++; + sub{ $count_rules++; my @int_cmd = @$PAint_cmd; - foreach (@int_cmd) { - if ( !defined($_) ) { $_='undef';} - } + foreach (@int_cmd) { + if ( !defined($_) ) { $_='undef';} + } print " [$rule]: '$$Pcmd_type' '$$Pext_cmd' '@int_cmd' $$Ptest_kind ", "'$$Psource' '$$Pdest' '$$Pbase' $$Pout_of_date $$Pout_of_date_user\n"; }, - sub{ print " '$file': $$Ptime $$Psize $$Pmd5 '$$Pfrom_rule'\n"; } + sub{ print " '$file': $$Ptime $$Psize $$Pmd5 '$$Pfrom_rule'\n"; } ); if ($count_rules <= 0) { - print " ---No rules defined\n"; + print " ---No rules defined\n"; } } #END rdb_show @@ -5734,7 +5922,7 @@ sub rdb_make { # making currently non-existent file, which # could become a needed source file for a run # and therefore undo an error condition - if ($diagnostics) { + if ($diagnostics) { print "Make: doing pre_primary and primary...\n"; } # Do the primary run if it is needed. On return $runs == 0 @@ -5745,31 +5933,45 @@ sub rdb_make { # limit. In the second case $too_many_runs is set. rdb_for_some( [@pre_primary, $primary], \&rdb_make1 ); if ( ($runs > 0) && ! $too_many_passes ) { - next PASS; + $retry_msg = 0; + if ( $force_mode || (! $failure) ) { + next PASS; + } + # Get here on failure, without being in force_mode + if ( $newrule_nofile ) { + $retry_msg = 1; + print "$My_name: Error on run, but found possibility to ", + "make new source files\n"; + next PASS; + } + else { last PASS; } } if ($runs == 0) { # $failure not set on this pass, so use value from previous pass: $failure = $previous_failure; + if ($retry_msg) { + print "But in fact no new files made\n"; + } if ($failure && !$force_mode ) { last PASS; } - } + } if ( $missing_dvi_pdf ) { # No output from primary, after completing circular dependence warn "Failure to make '$missing_dvi_pdf'\n"; $failure = 1; last PASS; } - if ($diagnostics) { - print "Make: doing post_primary...\n"; - } + if ($diagnostics) { + print "Make: doing post_primary...\n"; + } rdb_for_some( [@post_primary], \&rdb_make1 ); if ( ($runs == 0) || $too_many_passes ) { # If $too_many_passes is set, it should also be that # $runs == 0; but for safety, I also checked # $too_many_passes. last PASS; - } - } - continue { + } + } + continue { # Re-evaluate rule classification and accessibility, # but do not change primaries. # Problem is that %current_primaries gets altered @@ -5777,23 +5979,23 @@ sub rdb_make { &rdb_classify_rules( \%possible_primaries, @requested_targets ); %current_primaries = %old_curr_prim; &rdb_make_links; - } + } } rdb_for_some( [@unusual_one_time], \&rdb_make1 ); rdb_write( $fdb_name ); if (! $silent) { - if ($failure && $force_mode) { + if ($failure && $force_mode) { print "$My_name: Errors, in force_mode: so I tried finishing targets\n"; - } - elsif ($failure) { + } + elsif ($failure) { print "$My_name: Errors, so I did not complete making targets\n"; - } - else { + } + else { local @dests = (); rdb_for_some( [@_], sub{ push @dests, $$Pdest if ($$Pdest); } ); print "$My_name: All targets (@dests) are up-to-date\n"; - } + } } return $failure; } #END rdb_make @@ -5804,37 +6006,37 @@ sub rdb_show_rule_errors { local @errors = (); local @warnings = (); rdb_for_all( - sub{ - if ($$Plast_message ne '') { + 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) { + 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 - } - } - ); + } + } + ); if ($#warnings > -1) { - warn "Collected warning summary (may duplicate other messages):\n"; - foreach (@warnings){ - warn " $_\n"; - } + warn "Collected warning summary (may duplicate other messages):\n"; + foreach (@warnings){ + warn " $_\n"; + } } if ($#errors > -1) { - warn "Collected error summary (may duplicate other messages):\n"; - foreach (@errors){ - warn " $_\n"; - } + warn "Collected error summary (may duplicate other messages):\n"; + foreach (@errors){ + warn " $_\n"; + } } return $#errors+1; } @@ -5867,15 +6069,15 @@ sub rdb_make1 { $bibtex_not_run = 0; if ($bibtex_use == 0) { $bibtex_not_run = 2; - } + } elsif ($bibtex_use == 1) { - foreach ( keys %$PHsource ) { - if ( ( /\.bib$/ ) && (! -e $_) ) { + foreach ( keys %$PHsource ) { + if ( ( /\.bib$/ ) && (! -e $_) ) { push @missing_bib_files, $_; $bibtex_not_run = 1; - } - } - } + } + } + } } if ( ($$Prun_time == 0) && exists($possible_primaries{$rule}) ) { @@ -5885,53 +6087,53 @@ sub rdb_make1 { } else { if ( $$Pdest && (! -e $$Pdest) ) { - # With a non-existent destination, if we haven't made any passes + # With a non-existent destination, if we haven't made any passes # through a rule, rerunning the rule is good, because the file # may fail to exist because of being deleted by the user (for ex.) # rather than because of a failure on a previous run. # (We could do better with a flag in fdb file.) - # But after the first pass, the situation is different. - # For a primary rule (pdf)latex, the lack of a destination file - # could result from there being zero content due to a missing - # essential input file. The input file could be generated - # by a program to be run later (e.g., a cusdep or bibtex), - # so we should wait until all passes are completed before + # But after the first pass, the situation is different. + # For a primary rule (pdf)latex, the lack of a destination file + # could result from there being zero content due to a missing + # essential input file. The input file could be generated + # by a program to be run later (e.g., a cusdep or bibtex), + # so we should wait until all passes are completed before # deciding a non-existent destination file is an error. - # For a custom dependency, the rule may be obsolete, and - # if the source file does not exist also, we should simply - # not run the rule, but not set an error condition. - # Any error will arise at the (pdf)latex level due to a - # missing source file at that level. - if ( $$Psource && (! -e $$Psource) + # For a custom dependency, the rule may be obsolete, and + # if the source file does not exist also, we should simply + # not run the rule, but not set an error condition. + # Any error will arise at the (pdf)latex level due to a + # missing source file at that level. + if ( $$Psource && (! -e $$Psource) # OLD && ( ( $$Pcmd_type eq 'cusdep') ) # NEW && ( ( $$Pcmd_type ne 'primary') ) ) { # Main source file doesn't exist, and rule is NOT primary. - # No action, since a run is pointless. Primary is different: + # No action, since a run is pointless. Primary is different: # file might be found elsewhere (by kpsearch from (pdf)latex), # while non-existence of main source file is a clear error. - } - elsif ( $$Pcmd_type eq 'delegated' ) { - # Delegate to destination rule - } - elsif ( $pass{$rule}==0) { - push @no_dest, $$Pdest; - $$Pout_of_date = 1; - } - if ( $$Pcmd_type eq 'primary' ) { - $missing_dvi_pdf = $$Pdest; - } - } + } + elsif ( $$Pcmd_type eq 'delegated' ) { + # Delegate to destination rule + } + elsif ( $pass{$rule}==0) { + push @no_dest, $$Pdest; + $$Pout_of_date = 1; + } + if ( $$Pcmd_type eq 'primary' ) { + $missing_dvi_pdf = $$Pdest; + } + } } &rdb_flag_changes_here(0); if (!$$Pout_of_date) { -#?? if ( ($$Pcmd_type eq 'primary') && (! $silent) ) { +#?? if ( ($$Pcmd_type eq 'primary') && (! $silent) ) { # print "Rule '$rule' up to date\n"; # } - return; + return; } if ($diagnostics) { print " remake\n"; } if (!$silent) { @@ -5956,7 +6158,7 @@ sub rdb_make1 { # Treat rule as completed, else in -pvc mode get infinite reruns: $$Pout_of_date = 0; $failure = 1; - $failure_msg = "'$rule' needed too many passes"; + $failure_msg = "'$rule' needed too many passes"; return; } @@ -5971,7 +6173,7 @@ sub rdb_make1 { } elsif ($bibtex_not_run == 2 ) { warn "$My_name: I AM CONFIGURED/INVOKED NOT TO RUN '$rule'\n"; - } + } $return = &rdb_dummy_run1; } else { @@ -6002,7 +6204,7 @@ sub rdb_make1 { # So in this case, do NOT report an error $$Pout_of_date = 0; - } + } elsif ($$Pcmd_type eq 'primary' ) { # For a primary rule, i.e., (pdf)latex, not to produce the # expected output file may not be an error condition. @@ -6013,7 +6215,7 @@ sub rdb_make1 { elsif ($return == -2) { # 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 @@ -6021,16 +6223,16 @@ sub rdb_make1 { # only error. $$Pout_of_date = 0; } - else { + else { $failure = 1; - } + } } if ( ($return != 0) && ($return != -2) ) { $failure = 1; - $$Plast_result = 2; + $$Plast_result = 2; if ( !$$Plast_message ) { $$Plast_message = "Run of rule '$rule' gave a non-zero error code"; - } + } # !!?? $failure_msg = $$Plast_message; } @@ -6081,45 +6283,45 @@ sub rdb_classify_rules { @post_primary = reverse @post_primary; if ($diagnostics) { - print "Rule classification: \n"; - if ($#requested_targets < 0) { - print " No requested rules\n"; - } - else { - print " Requested rules:\n"; - foreach ( @requested_targets ) { print " $_\n"; } - } - if ($#pre_primary < 0) { - print " No pre-primaries\n"; - } - else { - print " Pre-primaries:\n"; - foreach (@pre_primary) { print " $_\n"; } - } - print " Primaries:\n"; - foreach (keys %current_primaries) { print " $_\n"; } - if ($#post_primary < 0) { - print " No post-primaries\n"; - } - else { - print " Post-primaries:\n"; - foreach (@post_primary) { print " $_\n"; } - } - if ($#unusual_one_time < 0) { - print " No inner-level one_time rules, as expected\n"; - } - else { - print " Inner-level one_time rules:\n"; - foreach ( @unusual_one_time ) { print " $_\n"; } - } + print "Rule classification: \n"; + if ($#requested_targets < 0) { + print " No requested rules\n"; + } + else { + print " Requested rules:\n"; + foreach ( @requested_targets ) { print " $_\n"; } + } + if ($#pre_primary < 0) { + print " No pre-primaries\n"; + } + else { + print " Pre-primaries:\n"; + foreach (@pre_primary) { print " $_\n"; } + } + print " Primaries:\n"; + foreach (keys %current_primaries) { print " $_\n"; } + if ($#post_primary < 0) { + print " No post-primaries\n"; + } + else { + print " Post-primaries:\n"; + foreach (@post_primary) { print " $_\n"; } + } + if ($#unusual_one_time < 0) { + print " No inner-level one_time rules, as expected\n"; + } + else { + 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"; } - } + 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 } #END rdb_classify_rules @@ -6146,12 +6348,12 @@ sub rdb_classify1 { $current_primaries{ $rule } = 1; } else { - push @post_primary, $rule; + push @post_primary, $rule; } } else { $state = 2; # in post-primary rule - push @pre_primary, $rule; + push @pre_primary, $rule; } } #END rdb_classify1 @@ -6191,14 +6393,14 @@ sub rdb_run1 { my $int_cmd = shift @int_args; my @int_args_for_printing = @int_args; foreach (@int_args_for_printing) { - if ( ! defined $_ ) { $_ = 'undef'; } + if ( ! defined $_ ) { $_ = 'undef'; } } if ($int_cmd) { - print "For rule '$rule', running '\&$int_cmd( @int_args_for_printing )' ...\n"; + print "For rule '$rule', running '\&$int_cmd( @int_args_for_printing )' ...\n"; $return = &$int_cmd( @int_args ); } elsif ($$Pext_cmd) { - $return = &Run_subst(); + $return = &Run_subst(); } else { warn "$My_name: Either a bug OR a configuration error:\n", @@ -6231,7 +6433,7 @@ sub rdb_run1 { " be recreated, I'll try to do so.\n"; $return = -2; rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } ); - } + } elsif ($retcode == 4) { $$Plast_result = 2; $$Plast_message = "Could not find all biber source files for '$$Pbase'"; @@ -6260,7 +6462,7 @@ sub rdb_run1 { if ( ! -e $$Psource ) { $retcode = 10; rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } ); - } + } if ($retcode == 3) { $$Plast_result = 2; $$Plast_message = "Could not open bibtex log file for '$$Pbase'"; @@ -6281,17 +6483,17 @@ sub rdb_run1 { warn "$My_name: Bibtex did not produce '$$Pdest'. But that\n", " was because of missing files, so I will continue.\n"; $return = -2; - } + } else { $return = 0; - } + } } } $updated = 1; if ($$Ptest_kind == 3) { # We are time-criterion first time only. Now switch to - # file-change criterion + # file-change criterion $$Ptest_kind = 1; } $$Pout_of_date = $$Pout_of_date_user = 0; @@ -6299,11 +6501,11 @@ sub rdb_run1 { if ( ($$Plast_result == 0) && ($return != 0) && ($return != -2) ) { $$Plast_result = 2; if ($$Plast_message eq '') { - $$Plast_message = "Command for '$rule' gave return code $return"; - } + $$Plast_message = "Command for '$rule' gave return code $return"; + } } elsif ( $$Pdest && (! -e $$Pdest) && ($return != -2) ) { - $$Plast_result = 1; + $$Plast_result = 1; } return $return; } # END rdb_run1 @@ -6326,7 +6528,7 @@ sub rdb_dummy_run1 { if ($$Ptest_kind == 3) { # We are time-criterion first time only. Now switch to - # file-change criterion + # file-change criterion $$Ptest_kind = 1; } $$Pout_of_date = $$Pout_of_date_user = 0; @@ -6385,9 +6587,9 @@ sub Run_subst { '%%' => '%' # To allow literal %B, %R, etc, by %%B. ); if ( ($^O eq "MSWin32" ) && $MSWin_back_slash ) { - foreach ( '%R', '%B', '%T', '%S', '%D', '%Y', '%Z' ) { - $subst{$_} =~ s(/)(\\)g; - } + foreach ( '%R', '%B', '%T', '%S', '%D', '%Y', '%Z' ) { + $subst{$_} =~ s(/)(\\)g; + } } my @tokens = split /(%.)/, $ext_cmd; @@ -6437,13 +6639,13 @@ sub rdb_primary_run { my @other_fls_names = ( ); if ( $rule =~ /^pdflatex/ ) { push @other_fls_names, "pdflatex.fls"; - } + } else { push @other_fls_names, "latex.fls"; - } + } if ( $aux_dir1 ne '' ) { push @other_fls_names, "$root_filename.fls"; - } + } # 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 @@ -6454,10 +6656,10 @@ sub rdb_primary_run { copy $cand, $std_fls_file; last; } - } + } if ( ! test_gen_file( $std_fls_file ) ) { warn "$My_name: fls file doesn't appear to have been made\n"; - } + } } # Find current set of source files: @@ -6491,8 +6693,8 @@ sub rdb_primary_run { #?? &rdb_update_files; if ( $diagnostics ) { - print "$My_name: Rules after run: \n"; - rdb_show(); + print "$My_name: Rules after run: \n"; + rdb_show(); } $return = $return_latex; @@ -6504,17 +6706,19 @@ sub rdb_primary_run { if (! $silent); $return = 0; } - # Summarize issues that may have escaped notice: my @warnings = (); if ($bad_reference) { push @warnings, "Latex failed to resolve $bad_reference reference(s)"; } + if ($mult_defined) { + push @warnings, "Latex found $mult_defined multiply defined reference(s)"; + } if ($bad_citation) { push @warnings, "Latex failed to resolve $bad_citation citation(s)"; } if ($#warnings > -1) { - show_array( "$My_name: Summary of warnings:", @warnings ); + show_array( "$My_name: Summary of warnings:", @warnings ); } return $return; } #END rdb_primary_run @@ -6550,9 +6754,9 @@ sub rdb_flag_changes_here { $dest_mtime = get_mtime($$Pdest) if ($$Pdest); rdb_do_files( \&rdb_file_change1); if ($$Pout_of_date) { - push @rules_to_apply, $rule; + push @rules_to_apply, $rule; } -#?? print "======== flag: $rule $$Pout_of_date ==========\n"; +#?? print "======== flag: $rule $$Pout_of_date ==========\n"; } #END rdb_flag_changes_here #************************************************************ @@ -6573,7 +6777,7 @@ sub rdb_file_change1 { #?? " New $new_time, $new_size, $new_md5\n"; my $ext_no_period = ext_no_period( $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; @@ -6589,27 +6793,27 @@ sub rdb_file_change1 { return; } if ( ($new_size < 0) && ($$Psize < 0) ) { - return; + return; } if ( ($new_size != $$Psize) || ($new_md5 ne $$Pmd5) ) { #?? print "FC1: changed $file: ($new_size != $$Psize) $new_md5 ne $$Pmd5)\n"; - push @changed, $file; - $$Pout_of_date = 1; + push @changed, $file; + $$Pout_of_date = 1; if ( ! exists $generated_exts_all{$ext_no_period} ) { $$Pout_of_date_user = 1; - } + } } elsif ( $new_time != $$Ptime ) { #warn "--==-- Unchanged $file, changed time, update filetime in $rule\n"; - $$Ptime = $new_time; + $$Ptime = $new_time; } if ( ( ($$Ptest_kind == 2) || ($$Ptest_kind == 3) ) && (! exists $generated_exts_all{$ext_no_period} ) && ( $new_time > $dest_mtime ) ) { #?? print "FC1: changed $file: ($new_time > $dest_mtime)\n"; - push @changed, $file; - $$Pout_of_date = $$Pout_of_date_user = 1; + push @changed, $file; + $$Pout_of_date = $$Pout_of_date_user = 1; } } #END rdb_file_change1 @@ -6630,22 +6834,22 @@ sub rdb_diagnose_changes { my $heading = defined($_[0]) ? $_[0] : "$My_name: "; if ($#rules_never_run >= 0) { - warn "${heading}Rules & subrules not known to be previously run:\n"; + warn "${heading}Rules & subrules not known to be previously run:\n"; foreach (@rules_never_run) { warn " $_\n"; } } if ( ($#changed >= 0) || ($#disappeared >= 0) || ($#no_dest >= 0) ) { warn "${heading}File changes, etc:\n"; if ( $#changed >= 0 ) { - warn " Changed files, or newly in use since previous run(s):\n"; - foreach (uniqs(@changed)) { warn " '$_'\n"; } + warn " Changed files, or newly in use since previous run(s):\n"; + foreach (uniqs(@changed)) { warn " '$_'\n"; } } if ( $#disappeared >= 0 ) { - warn " No-longer-existing files:\n"; - foreach (uniqs(@disappeared)) { warn " '$_'\n"; } + warn " No-longer-existing files:\n"; + foreach (uniqs(@disappeared)) { warn " '$_'\n"; } } if ( $#no_dest >= 0 ) { - warn " Non-existent destination files:\n"; - foreach (uniqs(@no_dest)) { warn " '$_'\n"; } + warn " Non-existent destination files:\n"; + foreach (uniqs(@no_dest)) { warn " '$_'\n"; } } } elsif ($#rules_to_apply >=0) { @@ -6653,7 +6857,7 @@ sub rdb_diagnose_changes { foreach (@rules_to_apply) { warn " '$_'\n"; } } else { - warn "${heading}No file changes\n"; + warn "${heading}No file changes\n"; } } #END rdb_diagnose_changes @@ -6814,7 +7018,7 @@ sub rdb_for_some { foreach $rule ( @heads ) { # $rule is implicitly local - &rdb_one_rule( $rule, @_ ); + &rdb_one_rule( $rule, @_ ); } } #END rdb_for_some @@ -6843,7 +7047,7 @@ sub rdb_recurse_rule { # Assumes recursion context, i.e. that %visited, @heads, $depth. # We are overriding actions: my ($rule, $rule_act1, $new_file_act1, $new_file_act2, $rule_act2) - = @_; + = @_; # and must propagate the file actions: local $file_act1 = $new_file_act1; local $file_act2 = $new_file_act2; @@ -6869,7 +7073,7 @@ sub rdb_recurse_file { # Assumes contexts set for: Recursion, rule, and file &$file_act1 if $file_act1; rdb_recurse_rule( $$Pfrom_rule, $rule_act1, $file_act1, $file_act2, - $rule_act2 ) + $rule_act2 ) if $$Pfrom_rule; &$file_act2 if $file_act2; } #END rdb_recurse_file @@ -7000,7 +7204,7 @@ sub rdb_create_rule { -1, '', $PA_extra_gen ], {}, {} - ]; + ]; if ($source) { rdb_ensure_file( $rule, $source, undef, $set_file_not_exists ); } @@ -7046,27 +7250,27 @@ sub rdb_ensure_file { my $rule = shift; local ( $new_file, $new_from_rule, $set_not_exists ) = @_; if ( ! rdb_rule_exists( $rule ) ) { - die_trace( "$My_name: BUG in rdb_ensure_file: non-existent rule '$rule'" ); + die_trace( "$My_name: BUG in rdb_ensure_file: non-existent rule '$rule'" ); } if ( ! defined $new_file ) { - die_trace( "$My_name: BUG in rdb_ensure_file: undefined file for '$rule'" ); + die_trace( "$My_name: BUG in rdb_ensure_file: undefined file for '$rule'" ); } if ( ! defined $set_not_exists ) { $set_not_exists = 0; } rdb_one_rule( $rule, sub{ if (! exists ${$PHsource}{$new_file} ) { - if ( $set_not_exists ) { + if ( $set_not_exists ) { ${$PHsource}{$new_file} = [0, -1, 0, '', 0]; - } - else { + } + else { ${$PHsource}{$new_file} = [fdb_get($new_file, $$Prun_time), '', 0]; - } - } - } + } + } + } ); if (defined $new_from_rule ) { - rdb_for_one_file( $rule, $new_file, sub{ $$Pfrom_rule = $new_from_rule; }); + rdb_for_one_file( $rule, $new_file, sub{ $$Pfrom_rule = $new_from_rule; }); } } #END rdb_ensure_file @@ -7101,7 +7305,7 @@ sub rdb_file_exists { local $exists = 0; rdb_one_rule( $rule, sub{ $exists = exists( ${$PHsource}{$file} ) ? 1:0; } - ); + ); return $exists; } #END rdb_file_exists @@ -7111,7 +7315,7 @@ sub rdb_update_gen_files { # Assumes rule context. Update source files of rule to current state. rdb_do_files( sub{ - if ( exists $generated_exts_all{ ext_no_period($file) } ) {&rdb_update1;} + if ( exists $generated_exts_all{ ext_no_period($file) } ) {&rdb_update1;} } ); } #END rdb_update_gen_files @@ -7312,28 +7516,28 @@ sub parse_quotes { while() { /\G\s*/gc; if ( /\G$/ ) { - last ITEM; - } + last ITEM; + } # Now pos (and \G) is at start of item: PART: while () { - if (/\G([^\s\"]*)/gc) { - $item .= $1; - } + if (/\G([^\s\"]*)/gc) { + $item .= $1; + } if ( /\G\"([^\"]*)\"/gc ) { # Match balanced quotes - $item .= $1; - next PART; - } + $item .= $1; + next PART; + } elsif ( /\G\"(.*)$/gc ) { # Match unbalanced quote - $item .= $1; + $item .= $1; warn "====Non-matching quotes in\n '$_'\n"; - } + } push @results, $item; $item = ''; last PART; - } + } } return @results; } #END parse_quotes @@ -7471,8 +7675,8 @@ sub get_checksum_md5 { if ( $ignore_pattern ) { while (<$input>) { if ( /$ignore_pattern/ ){ - $_= ''; - } + $_= ''; + } $md5->add($_); } } @@ -7566,7 +7770,7 @@ sub find_file_list1 { 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; + push @return_list, $tmp_file; } if ( $find_retcode != 0 ) { push @not_found, $file.$suffix; @@ -7586,9 +7790,9 @@ sub unlink_or_move { } else { foreach (@_) { - if (-e $_ && ! rename $_, "$del_dir/$_" ) { + if (-e $_ && ! rename $_, "$del_dir/$_" ) { warn "$My_name:Cannot move '$_' to '$del_dir/$_'\n"; - } + } } } } @@ -7606,7 +7810,7 @@ sub kpsewhich { foreach (@args) { if ( ! /^-/ ) { $_ = "\"$_\""; - } + } } foreach ($cmd) { s/%[RBTDO]//g; @@ -7617,7 +7821,7 @@ sub kpsewhich { open $fh, "$cmd|" or die "Cannot open pipe for \"$cmd\"\n"; while ( <$fh> ) { - s/^\s*//; + s/^\s*//; s/\s*$//; push @found, $_; } @@ -7645,12 +7849,12 @@ sub remove_cus_dep { while ($i <= $#cus_dep_list) { # Use \Q and \E round directory name in regex to avoid interpretation # of metacharacters in directory name: - if ( $cus_dep_list[$i] =~ /^\Q$from_ext $to_ext \E/ ) { - splice @cus_dep_list, $i, 1; - } - else { - $i++; - } + if ( $cus_dep_list[$i] =~ /^\Q$from_ext $to_ext \E/ ) { + splice @cus_dep_list, $i, 1; + } + else { + $i++; + } } } @@ -7662,6 +7866,22 @@ sub show_cus_dep { #################################################### +sub add_aux_hook { + # Usage: add_aux_hook( sub_name ) + # Add the name subroutine to the array of hooks for + # processing lines of aux files. + # The argument is either a string naming the subroutine, e.g. + # add_aux_hook( 'subname' ); + # or a Perl reference to the subroutine, e.g., + # add_aux_hook( \&subname ); + # It is also possible to use an anonymous subroutine, e.g., + # add_aux_hook( sub{ code of subroutine... } ); + my ($sub_name) = @_; + push @aux_hooks, $sub_name; +} + +#################################################### + sub add_input_ext { # Usage: add_input_ext( rule, ext, ... ) # Add extension(s) (specified without a leading period) to the @@ -7724,8 +7944,8 @@ sub find_dirs { = sub { ## Subroutine for use in File::find ## Check to see if we have a directory - if (-d) { push @result, $File::Find::name; } - }; + if (-d) { push @result, $File::Find::name; } + }; foreach my $directory (@_) { my $recurse = ( $directory =~ m[//$] ); # Remove all trailing /s, since directory name with trailing / @@ -7733,16 +7953,16 @@ sub find_dirs { $directory =~ s[/+$][]; # Similarly for MSWin reverse slash $directory =~ s[\\+$][]; - if ( ! -e $directory ){ + if ( ! -e $directory ){ next; - } - elsif ( $recurse ){ + } + elsif ( $recurse ){ # Recursively search directory find( $find_action, $directory ); - } + } else { push @result, $directory; - } + } } return @result; } @@ -7758,9 +7978,9 @@ sub uniq my $first = 1; while (@_) { - $current = shift; + $current = shift; if ($first || ($current ne $prev) ) - { + { push @sort, $current; $prev = $current; $first = 0; @@ -7855,7 +8075,7 @@ sub split_search_path my @list = split( /$separator/, $search_path); if ( $search_path =~ /$separator$/ ) { # If search path ends in a blank item, the split subroutine - # won't have picked it up. + # won't have picked it up. # So add it to the list by hand: push @list, ""; } @@ -7885,7 +8105,7 @@ sub tempfile1 { or next; close(TMP); return $tmp_file; - } + } } die "$My_name.tempfile1: BUG TO ARRIVE HERE\n"; } @@ -7965,7 +8185,7 @@ sub Run { # or the return value of the Perl subroutine. my $cmd_line = $_[0]; if ( $cmd_line eq '' ) { - traceback( "$My_name: Bug OR configuration error\n". + traceback( "$My_name: Bug OR configuration error\n". " In run of '$rule', attempt to run a null program" ); return (0, 1); } @@ -7975,22 +8195,27 @@ sub Run { while ( $cmd_line =~ s/^start +// ) { # But first remove extra starts (which may have been inserted # to force a command to be run detached, when the command - # already contained a "start"). + # already contained a "start"). $detach = 1; } if ( $cmd_line =~ s/^nostart +// ) { $detach = 0; } if ( $cmd_line =~ /^internal\s+([a-zA-Z_]\w*)\s+(.*)$/ ) { - my $routine = $1; - my @args = parse_quotes( $2 ); - warn "$My_name: calling $routine( @args )\n"; + my $routine = $1; + my @args = parse_quotes( $2 ); + warn "$My_name: calling $routine( @args )\n"; return ( 0, &$routine( @args ) ); } + elsif ( $cmd_line =~ /^internal\s+([a-zA-Z_]\w*)\s*$/ ) { + my $routine = $1; + warn "$My_name: calling $routine()\n"; + return ( 0, &$routine() ); + } elsif ( $cmd_line =~ /^NONE/ ) { warn "$My_name: ", "Program not implemented for this version. Command line:\n"; - warn " '$cmd_line'\n"; + warn " '$cmd_line'\n"; return (0, 1); } elsif ($detach) { @@ -8027,7 +8252,7 @@ sub Run_Detached { if ( $cmd_line =~ /^NONE / ) { warn "$My_name: ", "Program not implemented for this version. Command line:\n"; - warn " '$cmd_line'\n"; + warn " '$cmd_line'\n"; return (0, 1); } @@ -8044,10 +8269,10 @@ sub Run_Detached { ## warn "Run_Detached.UNIX: B pid=$pid\n"; if ( ! defined $pid ) { ## warn "Run_Detached.UNIX: C\n"; - warn "$My_name: Could not fork to run the following command:\n"; + warn "$My_name: Could not fork to run the following command:\n"; warn " '$cmd_line'\n"; return (0, 1); - } + } elsif( $pid == 0 ){ ## warn "Run_Detached.UNIX: D\n"; # Forked child process arrives here @@ -8096,7 +8321,7 @@ sub find_process_id { shift(@ps_output); # Discard the header line from ps foreach (@ps_output) { - next unless ( /$looking_for/ ) ; + next unless ( /$looking_for/ ) ; my @ps_line = split ('\s+'); # OLD return($ps_line[$pid_position]); push @found, $ps_line[$pid_position]; @@ -8133,7 +8358,7 @@ sub cache_good_cwd { chomp $Win_cwd; if ( $Win_cwd ) { $cwd = $Win_cwd; - } + } else { warn "$My_name: Could not correctly run command\n", " '$cmd'\n", @@ -8141,7 +8366,7 @@ sub cache_good_cwd { " '$cwd'\n", " The result was\n", " 'Win_cwd'\n"; - } + } } $cache{cwd} = $cwd; } # END cache_good_cwd diff --git a/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl b/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl index 47aa78664d1..102f0a97102 100755 --- a/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl +++ b/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl @@ -376,7 +376,7 @@ for the full story.\n"; } if (@notvalidargs) { my $msg = - "The following arguments are not supported for the action $action:\n"; + "The following options are not supported for the action $action:\n"; for my $c (@notvalidargs) { $msg .= " $c"; } diff --git a/Master/texmf-dist/doc/man/man1/latexmk.1 b/Master/texmf-dist/doc/man/man1/latexmk.1 index f9778ed60ca..a6d01b71c72 100644 --- a/Master/texmf-dist/doc/man/man1/latexmk.1 +++ b/Master/texmf-dist/doc/man/man1/latexmk.1 @@ -1,4 +1,4 @@ -.TH LATEXMK 1L "2 December 2013" "" +.TH LATEXMK 1L "1 January 2015" "" .SH NAME latexmk \- generate LaTeX document .SH SYNOPSIS @@ -542,15 +542,15 @@ Turn off the automatic reading of initialization (rc) files. N.B. Normally the initialization files are read and obeyed, and then command line options are obeyed in the order they are encountered. -Then \fB-norc\fR is an exception to this rule: it is acted on first, -no matter where is occurs on the command line. +But \fB-norc\fR is an exception to this rule: it is acted on first, +no matter where it occurs on the command line. .TP .B -outdir=FOO or -output-directory=FOO Sets the directory for the output files of (pdf)latex. This achieves its effect by the \fB-output-directory\fR option of (pdf)latex, which -currently (Dec. 2011) is implemented on the common versions of +currently (Dec. 2011 and later) is implemented on the common versions of (pdf)latex, i.e., MiKTeX and TeXLive. It may not be present in other versions. @@ -808,11 +808,30 @@ documentation. These options are: \fB-output-directory=DIR\fR, \fB-quiet\fR, and \fB-recorder\fR. .TP +.B -logfilewarninglist +.B -logfilewarnings +After a run of (pdf)latex, give a list of warnings about +undefined citations and references (unless silent mode is on). + +See also the $silence_logfile_warnings configuration variable. + +.TP +.B -logfilewarninglist- +.B -logfilewarnings- +After a run of (pdf)latex, do not give a list of warnings about +undefined citations and references. (Default) + +See also the $silence_logfile_warnings configuration variable. + +.TP .B -silent Run commands silently, i.e., with options that reduce the amount of diagnostics generated. For example, with the default settings, the command "latex -interaction=batchmode" is used for latex. +See also the \fB-logfilewarninglist\fR and \fB-logfilewarninglist-\fR +options. + Also reduce the number of informational messages that \fIlatexmk\fR generates. @@ -969,6 +988,8 @@ that of cygwin), \fIlatexmk\fR reads for the first it finds of "/opt/local/share/latexmk/LatexMk", "/usr/local/share/latexmk/LatexMk", "/usr/local/lib/latexmk/LatexMk". + In addition, it then tries the same set of locations, but with the +file name replaced "LatexMk" replaced by "latexmkrc". .PP 2) The user's RC file, "$HOME/.latexmkrc", if it exists. Here $HOME is the user's home directory. [\fILatexmk\fR determines the user's @@ -1301,7 +1322,7 @@ written. \fBImportant note\fR: The effect of \fI$aux_dir\fR, if different from \fI$out_dir\fR, is achieved by giving (pdf)latex the -\fB-aux-directory\fR. Currently (Dec. 2011) this only works on the +\fB-aux-directory\fR. Currently (Dec. 2011 and later) this only works on the MiKTeX version of (pdf)latex. See also the documentation of \fI$out_dir\fR for some complications on @@ -1519,6 +1540,11 @@ match. .B $dependents_list [0] Whether to display a list(s) of dependencies at the end of a run. .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 "-", +then the dependency list is set to stdout (i.e., normally the screen). +.TP .B $do_cd [0] Whether to change working directory to the directory specified for the main source file before processing it. The default behavior is not to @@ -1879,7 +1905,7 @@ The directory in which output files are to be written by a run of The effect of this variable (when non-blank) is achieved by using the \fB-output-directory\fR option of (pdf)latex. This exists in the -usual current (Dec. 2011) implementations of TeX, i.e., MiKTeX and +usual current (Dec. 2011 and later) implementations of TeX, i.e., MiKTeX and TeXLive. But it may not be present in other versions. Commonly, the directory specified for output files is a subdirectory @@ -2234,6 +2260,27 @@ for unusual operating systems that are not in the MSWin, Linux, OS-X, Unix collection.) .TP +.B $silence_logfile_warnings [0] +Whether after a run of (pdf)latex to summarize warnings in the log +file about undefined citations and references. Setting +$silence_logfile_warnings=0 gives the summary of warnings (provided +silent mode isn't also set), and this is useful to locate undefined +citations and references without searching through the much more +verbose log file or the screen output of (pdf)latex. But the summary +can also be excessively annoying. The default is not to give these +warnings. The command line options +\fB-silence_logfile_warning_list\fR and +\fB-silence_logfile_warning_list-\fR also set this variable. + +Note that multiple occurrences for the same undefined object on the +same page and same line will be compressed to a single warning. + +.TP +.B $silent [0] +Whether to run silently. Setting $silent to 1 has the same effect as +the \fB-quiet\fR of \fB-silent\fR options on the command line. + +.TP .B $sleep_time [2] The time to sleep (in seconds) between checking for source file changes when running with the \fB-pvc\fR option. This is subject to a @@ -2649,8 +2696,8 @@ suggestions that contributed to version 3, and Herbert Schulz. e-mail addresses are not written in their standard form to avoid being harvested by worms and viruses.) .SH AUTHOR -Current version, by John Collins (username collins at node phys.psu.edu). -(Version 4.39). +Current version, by John Collins (username jcc8 at node psu.edu). +(Version 4.41). Released version can be obtained from CTAN: <http://www.ctan.org/tex-archive/support/latexmk/>, and from the diff --git a/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf b/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf Binary files differindex 88a913a54fb..333e9b8fa59 100644 --- a/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf +++ b/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf diff --git a/Master/texmf-dist/doc/support/latexmk/CHANGES b/Master/texmf-dist/doc/support/latexmk/CHANGES index 61c1db82295..6e3368f0a13 100644 --- a/Master/texmf-dist/doc/support/latexmk/CHANGES +++ b/Master/texmf-dist/doc/support/latexmk/CHANGES @@ -438,3 +438,25 @@ From v. 4.37 to 4.39 From v. 4.39 to 4.39 documentation update of 2 Dec 2013 Correct two errors in documentation and in the file COPYING. +From v. 4.39 to 4.40 + Fix failure to clean up correctly when root filename contains [, + which is a glob metacharacter. + +From v. 4.40 to 4.41 + -c also deletes $deps_file if it is used + Quote jobname when needed. + Change maintainer's preferred e-mail + Attempt to improve handling of errors from (pdf)latex. + Fix up for the making of -eps-converted-to.pdf + Improve listing of warning lines from log file. + Fix failure when using both -cd and -output-directory + If user's home directory can't be determined, then don't read ~/.latexmkrc + Introduce configuration variable $silence_logfile_warnings + In setting $pscmd, allow for non-existent environment variable USER + Correct subroutine Run for internal cmd w/o arguments + Experimental: Add analysis hook for aux file. + System initialization files: allow them to be named latexmkrc as + well as LatexMk, for more consistency with user directory names. + Keep both cases, to preserve backward compatibility. + Change sign-on message. Bug report info with help. + diff --git a/Master/texmf-dist/doc/support/latexmk/INSTALL b/Master/texmf-dist/doc/support/latexmk/INSTALL index a5d4b08ee36..00e50f8ca0b 100644 --- a/Master/texmf-dist/doc/support/latexmk/INSTALL +++ b/Master/texmf-dist/doc/support/latexmk/INSTALL @@ -1,6 +1,6 @@ INSTALLING latexmk ================== - (Version 4.39, 10 November 2013) + (Version 4.41, 1 January 2015) John Collins Physics Department @@ -11,8 +11,7 @@ http://www.phys.psu.edu/~collins/ http://www.phys.psu.edu/~collins/latexmk/ - username collins at node phys.psu.edu -(E-mail address obfuscated to avoid being harvested by worms and spammers) + username jcc8 at node psu.edu Latexmk is a "make" tool for building latex documents. It runs latex and/or pdflatex the appropriate number of times to resolve cross @@ -301,7 +300,7 @@ Other systems For other systems you are on your own. The instructions for UNIX/LINUX and MS-Windows should help you to see what to do. Let me -know (username collins at node phys.psu.edu) what happens, so that I +know (username jcc8 at node psu.edu) what happens, so that I can update these instructions and possibly latexmk as well. @@ -357,8 +356,8 @@ University of Michigan. Version 2 was modified by Evan McLean. -The current version is by John Collins (username collins at node -phys.psu.edu) -- other contact details at the top. It is copyright +The current version is by John Collins (username jcc8 at node +psu.edu) -- other contact details at the top. It is copyright 1998-2011 by John Collins, and the previous authors; see the copyright notice in the latexmk.pl file, which gives permission to use, copy, modify, and distribute this software and its documentation under the diff --git a/Master/texmf-dist/doc/support/latexmk/README b/Master/texmf-dist/doc/support/latexmk/README index 645f6ea20ca..238b1cfaed5 100644 --- a/Master/texmf-dist/doc/support/latexmk/README +++ b/Master/texmf-dist/doc/support/latexmk/README @@ -1,5 +1,5 @@ -Latexmk, version 4.39, 10 November 2013 ---------------------------------------- +Latexmk, version 4.41, 1 January 2015 +------------------------------------- Latexmk completely automates the process of generating a LaTeX document. Essentially, it is a highly specialized cousin of the @@ -38,8 +38,7 @@ written by David J. Musliner. Now it is supported by U.S.A. http://www.phys.psu.edu/~collins/ - username collins at node phys.psu.edu -(E-mail address obfuscated to reduce harvesting by worms and spammers.) + username jcc8 at node psu.edu The start of the script file has copyright notices and disclaimers. It also has a modification history for those who are interested. @@ -92,7 +91,7 @@ NOTES:- John Collins ---------------------------- "latexmk -h" ---------------------------- -Latexmk 4.39: Automatic LaTeX document generation routine +Latexmk 4.41: Automatic LaTeX document generation routine Usage: latexmk [latexmk_options] [filename ...] @@ -144,6 +143,10 @@ Usage: latexmk [latexmk_options] [filename ...] -latex=<program> - set program used for latex. (replace '<program>' by the program name) -latexoption=<option> - add the given option to the (pdf)latex command + -logfilewarninglist or -logfilewarnings + give list of warnings after run of (pdf)latex + -logfilewarninglist- or -logfilewarnings- + do not give list of warnings after run of (pdf)latex -M - Show list of dependent files after processing -MF file - Specifies name of file to receives list dependent files -MP - List of dependent files includes phony target for each source file. @@ -213,3 +216,5 @@ All options can be introduced by '-' or '--'. (E.g., --help or -help.) In addition, latexmk recognizes many other options that are passed to latex and/or pdflatex without interpretation by latexmk. Run latexmk with the option -showextraoptions to see a list of these + +Report bugs etc to John Collins <jcc8 at psu.edu>. diff --git a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/Sweave_latexmkrc b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/Sweave_latexmkrc new file mode 100644 index 00000000000..19f046be6be --- /dev/null +++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/Sweave_latexmkrc @@ -0,0 +1,57 @@ +# This is to allow the use of Sweave with latexmk, and in addition to +# make synctex work properly with it. +# SEE THE IMPORTANT NOTES below. +# +# Sweave (http://www.stat.uni-muenchen.de/~leisch/Sweave/) is a tool +# that allows to embed the R code for complete data analyses in latex +# documents. The user edits a file with an extension like .Rnw, and +# the .tex file is generated from this. +# +# Four problems are solved by the code below: +# 1. Generate the .tex file automatically. +# 2. Arrange not to re-run unmodified chunks of R code. (A pure +# optimization.) +# 3. Fix the execution environment for (pdf)latex. +# 4. Deal with synctex: If the user wants to use synctex +# (www.tug.org/TUGboat/tb29-3/tb93laurens.pdf) to synchronize the +# pdf file with the source file, by default synctex does the +# synchronization with the generated .tex file, not the original +# source file. Postprocessing of the .synctex.gz file is necessary +# to fix this. +# +# The following version was worked out and tested by a user (thanks +# to Brian Beitzel) on MSWindows. It will need at least one change to +# work on UNIX-like operating systems (which include Linux and OS-X). + +# N.B. ===> IMPORTANT NOTES <=== +# +# 1. The patchDVI package for R needs to be installed from R-Forge, as +# follows: +# +# install.packages("patchDVI", repos="http://R-Forge.R-project.org") +# +# 2. In all Sweave (.Rnw) documents, the following lines must be included: +# +# \usepackage{Sweave} +# \SweaveOpts{concordance=TRUE} + + +# Fix the pdflatex command to run Sweave first, and to postprocess the +# .synctex.gz file: +# !!!!! THIS IS THE VERSION FOR MS-WINDOWS, with && as a command +# separator +$pdflatex = "cmd /c " + . "Rscript -e \"library(cacheSweave); setCacheDir(getwd()); " + . "Sweave('%S', driver=cacheSweaveDriver)\"" + . " && R CMD pdflatex -interaction=nonstopmode -synctex=1 %O %B.tex" + . " && Rscript -e " + . "\"library('patchDVI');patchSynctex('%B.synctex.gz')\""; +# +# !!!TO FIX THIS FOR Linux/OS-X/UNIX, try uncommenting the following: +# (this version hasn't been tested). +#$pdflatex = "Rscript -e \"library(cacheSweave); setCacheDir(getwd()); " +# . "Sweave('%S', driver=cacheSweaveDriver)\"" +# . " ; R CMD pdflatex -interaction=nonstopmode -synctex=1 %O %B.tex" +# . " ; Rscript -e " +# . "\"library('patchDVI');patchSynctex('%B.synctex.gz')\""; + diff --git a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/TeX4ht-latexmkrc b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/TeX4ht-latexmkrc new file mode 100644 index 00000000000..de486d8d8be --- /dev/null +++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/TeX4ht-latexmkrc @@ -0,0 +1,33 @@ +# Sometime in the future, latexmk will directly support the use of +# TeX4ht to obtain html from tex. Meanwhile, here is how to use +# latexmk with TeX4ht. There is a script htlatex supplied by the +# TeX4ht package: It simply runs latex a fixed number of times and +# then the programs tex4ht and t4ht. To use latexmk to get optimal +# processing use the following instructions (under UNIX-like operating +# systems, e.g., OS-X and linux): +# +# 1. Put the scripts htlatexonly and myhtlatex2 somewhere in the PATH +# for executables (and make sure they have excutable permissions +# set). +# 2. Set up an initialization file for latexmk like this one. +# +# 3. To process file.tex to make file.html, run +# +# myhtlatex2 file +# + +# Since these instructions use scripts that are UNIX shell scripts, +# the instructions work as written for UNIX-like operating +# systems. Users of other operating systems will have to adjust them +# and modify the scripts suitably. + + +warn "latexmkrc for htlatex\n"; + +$dvi_mode = 1; +$pdf_mode = 0; +$quote_filenames = 0; +$latex = 'htlatexonly %S'; + +$clean_ext .= ' 4ct 4tc idv lg tmp xref'; +$clean_full_ext .= ' css html'; diff --git a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/mpost_latexmkrc b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/mpost_latexmkrc index 5bcfeb0fdfd..c1b3e13d4fc 100644 --- a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/mpost_latexmkrc +++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/mpost_latexmkrc @@ -1,3 +1,6 @@ +# N.B. ===> (3, 4 Mar 2014) This file contains a correction relative to +# the previous version + # This shows how to use mpost, as used by the feynmp package. # The feynmp package writes files with extension .mp, e.g., foo.mp, # and these are to be converted by mpost to make postscript files, @@ -5,7 +8,7 @@ # # A more complicated custom dependency is needed than normal, because: # if the output directory ($out_dir) or the auxiliary directory -# ($out_dir) is set, mpost doesn't put its output in the correct +# ($aux_dir) is set, mpost doesn't put its output in the correct # place. add_cus_dep( 'mp', '1', 0, 'mpost' ); @@ -15,12 +18,11 @@ sub mpost { my $file = $_[0]; my ($name, $path) = fileparse( $file ); my $return = system "mpost \"$file\""; - # Fix the problem that mpost puts its output and log files - # in the current directory, not in the auxiliary directory - # (which is often the same as the output directory): - if ( ($path ne '') && ($path ne '.\\') && ($path ne './') ) { - foreach ( "$name.1", "$name.log" ) { move $_, $aux_dir; } - } + # Fix the problem that mpost puts its output and log files + # in the current directory, not in the auxiliary directory + # (which is often the same as the output directory): + move "$name.1", $path; + move "$name.log", $aux_dir; return $return; } diff --git a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/nomenclature_latexmkrc b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/nomenclature_latexmkrc new file mode 100644 index 00000000000..e16ee40f869 --- /dev/null +++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/nomenclature_latexmkrc @@ -0,0 +1,10 @@ +# This shows how to use the nomencl package for making a nomenclature +# with latexmk. +# (See http://www.ctan.org/tex-archive/macros/latex/contrib/nomencl +# for information on the nomencl package.) + + +add_cus_dep("nlo", "nls", 0, "nlo2nls"); +sub nlo2nls { + system("makeindex $_[0].nlo -s nomencl.ist -o $_[0].nls -t $_[0].nlg"); +} diff --git a/Master/texmf-dist/doc/support/latexmk/latexmk.pdf b/Master/texmf-dist/doc/support/latexmk/latexmk.pdf Binary files differindex 8b8f227c55d..41cefde7cbb 100644 --- a/Master/texmf-dist/doc/support/latexmk/latexmk.pdf +++ b/Master/texmf-dist/doc/support/latexmk/latexmk.pdf diff --git a/Master/texmf-dist/doc/support/latexmk/latexmk.txt b/Master/texmf-dist/doc/support/latexmk/latexmk.txt index bda111a4768..73089bea4b6 100644 --- a/Master/texmf-dist/doc/support/latexmk/latexmk.txt +++ b/Master/texmf-dist/doc/support/latexmk/latexmk.txt @@ -1,4 +1,9 @@ + + +LATEXMK(1L) LATEXMK(1L) + + NAME latexmk - generate LaTeX document @@ -53,15 +58,10 @@ DESCRIPTION gv) will then automatically update its display. Thus the user can sim- ply edit a file and, when the changes are written to disk, latexmk com- pletely automates the cycle of updating the .dvi (and possibly the .ps - and .pdf) file, and refreshing the previewer's display. It's not quite - WYSIWYG, but usefully close. - - For other previewers, the user may have to manually make the previewer - update its display, which can be (some versions of xdvi and gsview) as - 1 + 1 January 2015 1 @@ -70,6 +70,11 @@ DESCRIPTION LATEXMK(1L) LATEXMK(1L) + and .pdf) file, and refreshing the previewer's display. It's not quite + WYSIWYG, but usefully close. + + For other previewers, the user may have to manually make the previewer + update its display, which can be (some versions of xdvi and gsview) as simple as forcing a redraw of its display. Latexmk has the ability to print a banner in gray diagonally across @@ -119,15 +124,10 @@ LATEXMK OPTIONS AND ARGUMENTS ON COMMAND LINE tions. Some of the options for these programs also trigger special action or behavior by latexmk, in which case they have specific expla- nations in this document. Otherwise, they are just passed through to a - called latex or pdflatex program. Run latexmk with the -showextraop- - tions to get a list of the options that latexmk accepts and that are - simply passed through to latex or pdflatex (etc). See also the expla- - nation of the -showextraoptions option for more information. - - 2 December 2013 2 + 1 January 2015 2 @@ -136,6 +136,11 @@ LATEXMK OPTIONS AND ARGUMENTS ON COMMAND LINE LATEXMK(1L) LATEXMK(1L) + called latex or pdflatex program. Run latexmk with the -showextraop- + tions to get a list of the options that latexmk accepts and that are + simply passed through to latex or pdflatex (etc). See also the expla- + nation of the -showextraoptions option for more information. + Note 2: In this documentation, the program pdflatex is often referred to. Users of programs like lualatex and xelatex should know that from latexmk's point of view, these other programs behave like pdflatex, @@ -186,23 +191,22 @@ LATEXMK(1L) LATEXMK(1L) When the source file uses bbl files for bibliography, run bibtex or biber as needed to regenerate the bbl files. - This property can also be configured by setting the $bibtex_use - variable to 2 in a configuration file - - -bibtex- - Never run bibtex or biber. + 1 January 2015 3 - 2 December 2013 3 +LATEXMK(1L) LATEXMK(1L) -LATEXMK(1L) LATEXMK(1L) + This property can also be configured by setting the $bibtex_use + variable to 2 in a configuration file + -bibtex- + Never run bibtex or biber. A common use for this option is when a document comes from an external source, complete with its bbl file(s), and the user @@ -232,8 +236,8 @@ LATEXMK(1L) LATEXMK(1L) -bm <message> A banner message to print diagonally across each page when con- verting the dvi file to postscript. The message must be a sin- - gle argument on the command line so be careful with quoting - spaces and such. + gle argument on the command line so be careful with quoting spa- + ces and such. Note that if the -bm option is specified, the -ps option is assumed. @@ -251,19 +255,11 @@ LATEXMK(1L) LATEXMK(1L) message. The default is 220.0 which is just right for 5 charac- ter messages. - -commands - List the commands used by latexmk for processing files, and then - exit. - -c Clean up (remove) all regeneratable files generated by latex and - bibtex or biber except dvi, postscript and pdf. These files are - a combination of log files, aux files, latexmk's database file - of source file information, and those with extensions specified - in the @generated_exts configuration variable. In addition, - 2 December 2013 4 + 1 January 2015 4 @@ -272,6 +268,15 @@ LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) + -commands + List the commands used by latexmk for processing files, and then + exit. + + -c Clean up (remove) all regeneratable files generated by latex and + bibtex or biber except dvi, postscript and pdf. These files are + a combination of log files, aux files, latexmk's database file + of source file information, and those with extensions specified + in the @generated_exts configuration variable. In addition, files specified by the $clean_ext configuration variable are removed. @@ -318,29 +323,28 @@ LATEXMK(1L) LATEXMK(1L) dvi, pdf, etc) will be relative to the current directory rather than the source file. - This is the default behavior and corresponds to the behavior of - the latex and pdflatex programs. However, it is not desirable - behavior when latexmk is invoked by a GUI configured to invoke - latexmk with a full pathname for the source file. See the -cd - option. - - -CF Remove the file containing the database of source file informa- - tion, before doing the other actions requested. - -d Set draft mode. This prints the banner message "DRAFT" across - your page when converting the dvi file to postscript. Size and + 1 January 2015 5 - 2 December 2013 5 +LATEXMK(1L) LATEXMK(1L) -LATEXMK(1L) LATEXMK(1L) + This is the default behavior and corresponds to the behavior of + the latex and pdflatex programs. However, it is not desirable + behavior when latexmk is invoked by a GUI configured to invoke + latexmk with a full pathname for the source file. See the -cd + option. + -CF Remove the file containing the database of source file informa- + tion, before doing the other actions requested. + -d Set draft mode. This prints the banner message "DRAFT" across + your page when converting the dvi file to postscript. Size and intensity can be modified with the -bs and -bi options. The -bm option will override this option as this is really just a short way of specifying: @@ -384,6 +388,18 @@ LATEXMK(1L) LATEXMK(1L) the output is sent to stdout. Use of this option also turns on the output of the list of + + + + 1 January 2015 6 + + + + + +LATEXMK(1L) LATEXMK(1L) + + dependent files after processing. -dF Dvi file filtering. The argument to this option is a filter @@ -399,20 +415,8 @@ LATEXMK(1L) LATEXMK(1L) -diagnostics Print detailed diagnostics during a run. This may help for - debugging problems or to understand latexmk's behavior in - - - - 2 December 2013 6 - - - - - -LATEXMK(1L) LATEXMK(1L) - - - difficult situations. + debugging problems or to understand latexmk's behavior in diffi- + cult situations. -dvi Generate dvi version of document. @@ -451,6 +455,17 @@ LATEXMK(1L) LATEXMK(1L) string in a way that is independent of both the shell and the operating-system.) + + + 1 January 2015 7 + + + + + +LATEXMK(1L) LATEXMK(1L) + + The above command line will NOT work under MS-Windows with cmd.exe or command.com or 4nt.exe. For MS-Windows with these command shells you could use @@ -471,18 +486,6 @@ LATEXMK(1L) LATEXMK(1L) Note: "Further processing" means the running of other programs or the rerunning of latex (etc) that would be done if no errors - - - - 2 December 2013 7 - - - - - -LATEXMK(1L) LATEXMK(1L) - - had occurred. If instead, or additionally, you want the latex (etc) program not to pause for user input after an error, you should arrange this by an option that is passed to the program, @@ -516,7 +519,20 @@ LATEXMK(1L) LATEXMK(1L) programs is part of latexmk's implementation of -jobname. - -l Run in landscape mode, using the landscape mode for the preview- + -l + + + + 1 January 2015 8 + + + + + +LATEXMK(1L) LATEXMK(1L) + + + Run in landscape mode, using the landscape mode for the preview- ers and the dvi to postscript converters. This option is not normally needed nowadays, since current previewers normally determine this information automatically. @@ -543,17 +559,6 @@ LATEXMK(1L) LATEXMK(1L) using the -e option with a suitable line of Perl code to set the $latex variable. See the explanation of the -e option. - - - 2 December 2013 8 - - - - - -LATEXMK(1L) LATEXMK(1L) - - -lualatex Use lualatex. That is, use lualatex to process the source file(s) to pdf (in place of pdflatex). This option is exactly @@ -581,6 +586,18 @@ LATEXMK(1L) LATEXMK(1L) 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 + + + + 1 January 2015 9 + + + + + +LATEXMK(1L) LATEXMK(1L) + + name as the current file, but in a different directory). This option turns off the default behavior. @@ -603,29 +620,17 @@ LATEXMK(1L) LATEXMK(1L) N.B. Normally the initialization files are read and obeyed, and then command line options are obeyed in the order they are - encountered. Then -norc is an exception to this rule: it is - acted on first, no matter where is occurs on the command line. + encountered. But -norc is an exception to this rule: it is + acted on first, no matter where it occurs on the command line. -outdir=FOO or -output-directory=FOO Sets the directory for the output files of (pdf)latex. This achieves its effect by the -output-directory option of - (pdf)latex, which currently (Dec. 2011) is implemented on the - common versions of (pdf)latex, i.e., MiKTeX and TeXLive. It may - - - - 2 December 2013 9 - - - - - -LATEXMK(1L) LATEXMK(1L) - - - not be present in other versions. + (pdf)latex, which currently (Dec. 2011 and later) is implemented + on the common versions of (pdf)latex, i.e., MiKTeX and TeXLive. + It may not be present in other versions. See also the -auxdir/-aux-directory options, and the $aux_dir, $out_dir, and $search_path_separator configuration variables of @@ -647,6 +652,18 @@ LATEXMK(1L) LATEXMK(1L) under MS-Windows you must have suitable program(s) available, and you must have configured the print commands used by latexmk. This can be non-trivial. See the documentation on the $lpr, + + + + 1 January 2015 10 + + + + + +LATEXMK(1L) LATEXMK(1L) + + $lpr_dvi, and $lpr_pdf configuration variables to see how to set the commands for printing. @@ -684,18 +701,6 @@ LATEXMK(1L) LATEXMK(1L) The specification of the contents of the string are the same as for the $pdflatex configuration variable. Depending on your operating system and the command-line shell you are using, you - - - - 2 December 2013 10 - - - - - -LATEXMK(1L) LATEXMK(1L) - - may need to change the single quotes to double quotes (or some- thing else). @@ -713,6 +718,18 @@ LATEXMK(1L) LATEXMK(1L) To set the command for running latex (rather than the command for pdflatex) see the -latex option. + + + + 1 January 2015 11 + + + + + +LATEXMK(1L) LATEXMK(1L) + + Note that the effect of this option can also be achieved by using the -e option with a suitable line of Perl code to set the $pdflatex variable. See the explanation of the -e option. @@ -754,31 +771,31 @@ LATEXMK(1L) LATEXMK(1L) select the kind of file to be previewed (dvi, ps or pdf). Oth- erwise the viewer views the "highest" kind of file selected, by the -dvi, -ps, -pdf, -pdfps options, in the order dvi, ps, pdf - (low to high). If no file type has been selected, the dvi + (low to high). If no file type has been selected, the dvi pre- + viewer will be used. This option is incompatible with the -p + and -pvc options, so it turns them off. + -pv- Turn off -pv. + -pvc Run a file previewer and continually update the .dvi, .ps, + and/or .pdf files whenever changes are made to source files (see + the Description above). Which of these files is generated and + which is viewed is governed by the other options, and is the + same as for the -pv option. The preview-continuous option -pvc + can only work with one file. So in this case you will normally + only specify one filename on the command line. It is also - 2 December 2013 11 + 1 January 2015 12 -LATEXMK(1L) LATEXMK(1L) - previewer will be used. This option is incompatible with the -p - and -pvc options, so it turns them off. +LATEXMK(1L) LATEXMK(1L) - -pv- Turn off -pv. - -pvc Run a file previewer and continually update the .dvi, .ps, - and/or .pdf files whenever changes are made to source files (see - the Description above). Which of these files is generated and - which is viewed is governed by the other options, and is the - same as for the -pv option. The preview-continuous option -pvc - can only work with one file. So in this case you will normally - only specify one filename on the command line. It is also incompatible with the -p and -pv options, so it turns these options off. @@ -826,10 +843,17 @@ LATEXMK(1L) LATEXMK(1L) line are acted on in the order they are given. Therefore if an initialization file is specified by the -r option, it is read during this second step. Thus an initialization file specified + with the -r option can override both the standard initialization + files and previously specified options. But all of these can be + overridden by later options. + + The contents of the RC file just comprise a piece of code in the + Perl programming language (typically a sequence of assignment + statements); they are executed when the -r option is encountered - 2 December 2013 12 + 1 January 2015 13 @@ -838,13 +862,6 @@ LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) - with the -r option can override both the standard initialization - files and previously specified options. But all of these can be - overridden by later options. - - The contents of the RC file just comprise a piece of code in the - Perl programming language (typically a sequence of assignment - statements); they are executed when the -r option is encountered during latexmk's parsing of its command line. See the -e option for a way of giving initialization code directly on latexmk's command line. An error results in latexmk stopping. Multiple @@ -868,39 +885,41 @@ LATEXMK(1L) LATEXMK(1L) -rules Show a list of latemk's rules and dependencies after processing. -rules- - Do not show a list of latexmk's rules and dependencies after + Do not show a list of latexmk's rules and dependencies after processing. (This is the default.) -showextraoptions - Show the list of extra latex and pdflatex options that latexmk - recognizes. These are options for the latex and pdflatex that - latexmk recognizes, but simply passes through to these programs - when they are run. These options are (currently) a combination + Show the list of extra latex and pdflatex options that latexmk + recognizes. These are options for the latex and pdflatex that + latexmk recognizes, but simply passes through to these programs + when they are run. These options are (currently) a combination of those allowed by the TeXLive and MiKTeX implementations. (If - a particular option is given to latexmk but is not handled by + a particular option is given to latexmk but is not handled by the particular implementation of latex or pdflatex that is being - used, that program will probably give an error message.) These + used, that program will probably give an error message.) These options are very numerous, but are not listed in this documenta- tion because they have no effect on latexmk's actions. - There are a few options (-includedirectory=dir, -initialize, - -ini) that are not recognized, either because they don't fit + There are a few options (-includedirectory=dir, -initialize, + -ini) that are not recognized, either because they don't fit with latexmk's intended operations, or because they need special - processing by latexmk that isn't implemented (at least, not + processing by latexmk that isn't implemented (at least, not yet). - There are also options that are accepted by latex etc, but + There are also options that are accepted by latex etc, but instead trigger actions by latexmk: -help, -version. Finally, there are certain options for latex and pdflatex (e.g., - -recorder) that trigger special actions or behavior by latexmk - itself as well as being passed in some form to the called latex - and pdflatex program, or that affect other programs as well. - These options do have entries in this documentation. These + -recorder) that trigger special actions or behavior by latexmk + itself as well as being passed in some form to the called latex + and pdflatex program, or that affect other programs as well. + These options do have entries in this documentation. These + options are: -jobname=STRING, -aux-directory=dir, -output-direc- + tory=DIR, -quiet, and -recorder. - 2 December 2013 13 + 1 January 2015 14 @@ -909,8 +928,19 @@ LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) - options are: -jobname=STRING, -aux-directory=dir, -output-direc- - tory=DIR, -quiet, and -recorder. + -logfilewarninglist + -logfilewarnings After a run of (pdf)latex, give a list of warn- + ings about undefined citations and references (unless silent + mode is on). + + See also the $silence_logfile_warnings configuration variable. + + + -logfilewarninglist- + -logfilewarnings- After a run of (pdf)latex, do not give a list + of warnings about undefined citations and references. (Default) + + See also the $silence_logfile_warnings configuration variable. -silent @@ -919,36 +949,51 @@ LATEXMK(1L) LATEXMK(1L) tings, the command "latex -interaction=batchmode" is used for latex. - Also reduce the number of informational messages that latexmk + See also the -logfilewarninglist and -logfilewarninglist- + options. + + Also reduce the number of informational messages that latexmk generates. - To change the options used to make the commands run silently, + To change the options used to make the commands run silently, you need to configure latexmk with changed values of its config- - uration variables, the relevant ones being $bib- - tex_silent_switch, $biber_silent_switch, $dvipdf_silent_switch, + uration variables, the relevant ones being $bib- + tex_silent_switch, $biber_silent_switch, $dvipdf_silent_switch, $dvips_silent_switch, $latex_silent_switch, $makein- dex_silent_switch, and $pdflatex_silent_switch. -use-make - When after a run of latex or pdflatex, there are warnings about + When after a run of latex or pdflatex, there are warnings about missing files (e.g., as requested by the LaTeX \input, \include, - and \includgraphics), latexmk tries to make them by a custom + and \includgraphics), latexmk tries to make them by a custom dependency. If no relevant custom dependency with an appropriate - source file is found, and if the -use-make option is set, then - latexmk will try as a resort using the make program to try to + source file is found, and if the -use-make option is set, then + latexmk will try as a resort using the make program to try to make the missing files. - Note that the filename may be specified without an extension, - e.g., by \includegraphics{drawing} in a LaTeX file. In that - case, latexmk will try making drawing.ext with ext set in turn - to the possible extensions that are relevant for latex (or as + Note that the filename may be specified without an extension, + e.g., by \includegraphics{drawing} in a LaTeX file. In that + case, latexmk will try making drawing.ext with ext set in turn + to the possible extensions that are relevant for latex (or as appropriate pdflatex). - See also the documentation for the $use_make_for_missing_files + See also the documentation for the $use_make_for_missing_files configuration variable. -use-make- - Do not use the make program to try to make missing files. + Do not use the make program to try to make missing files. + + + + 1 January 2015 15 + + + + + +LATEXMK(1L) LATEXMK(1L) + + (Default.) -v, -version @@ -965,31 +1010,19 @@ LATEXMK(1L) LATEXMK(1L) -xelatex Use xelatex. That is, use xelatex to process the source file(s) - to pdf (in place of pdflatex). This option is exactly equiva- + to pdf (in place of pdflatex). This option is exactly equiva- lent to specifying the following sequence of options: - - - - 2 December 2013 14 - - - - - -LATEXMK(1L) LATEXMK(1L) - - -pdflatex="xelatex %O %S" -pdf -dvi- -ps- Compatibility between options - The preview-continuous option -pvc can only work with one file. So in - this case you will normally only specify one filename on the command + The preview-continuous option -pvc can only work with one file. So in + this case you will normally only specify one filename on the command line. - Options -p, -pv and -pvc are mutually exclusive. So each of these + Options -p, -pv and -pvc are mutually exclusive. So each of these options turns the others off. @@ -1014,70 +1047,84 @@ EXAMPLES + + + + + 1 January 2015 16 + + + + + +LATEXMK(1L) LATEXMK(1L) + + HOW TO CHANGE THE WAY LATEXMK BEHAVES, DEALING WITH PROBLEMS, ETC Some possibilities: - a. If you get a strange error, do look carefully at the output that is - on the screen and in log files. While there is much that is notori- + a. If you get a strange error, do look carefully at the output that is + on the screen and in log files. While there is much that is notori- ously verbose in the output of latex (and that is added to by latexmk), - the verbosity is there for a reason: to enable the user to diagnose - problems. Latexmk does repeat some messages at the end of a run that - it thinks would otherwise be easy to miss in the middle of other out- + the verbosity is there for a reason: to enable the user to diagnose + problems. Latexmk does repeat some messages at the end of a run that + it thinks would otherwise be easy to miss in the middle of other out- put. - b. If latexmk doesn't do things the way you would like, the first step - in finding out what to do is to look in this documentation at the list - of command line options and then at the sections on configuration/ini- + b. If latexmk doesn't do things the way you would like, the first step + in finding out what to do is to look in this documentation at the list + of command line options and then at the sections on configuration/ini- tialization files. A lot of latexmk's behavior is configurable to deal with particular situations. (But there is a lot of reading.) - c. Further tricks can involve replacing the standard commands that + c. Further tricks can involve replacing the standard commands that latexmk by other commands or scripts. - d. For possible examples of code for use in an RC file, see the direc- - tory example_rcfiles in the distribution of latexmk (e.g., at + d. For possible examples of code for use in an RC file, see the direc- + tory example_rcfiles in the distribution of latexmk (e.g., at http://www.ctan.org/tex-archive/support/latexmk/example_rcfiles). Even - if these examples don't do what you want, they may provide suitable + if these examples don't do what you want, they may provide suitable inspiration. + e. There's a useful trick that can be used when you are lualatex + instead of pdflatex (and in some related situations). The problem is + that latexmk won't notice a dependency on a file, bar.baz say, that is + input by the lua code in your document instead of by the LaTeX part. + (Thus if you change bar.baz and rerun latexmk, then latexmk will think + no files have changed and not rerun lualatex, whereas if you had + '\input{bar.baz}' in the LaTeX part of the document, latexmk would + notice the change.) One solution is just to put the following some- + where in the LaTeX part of the document: + \typeout{(bar.baz)} - 2 December 2013 15 + This puts a line in the log file that latexmk will treat as implying + that the file bar.baz was read. (At present I don't know a way of + doing this automatically.) Of course, if the file has a different + name, change bar.baz to the name of your file. + f. Look on tex.stackexchange, i.e., at http://tex.stackex- + change.com/questions/tagged/latexmk Someone may have already solved + your problem. + g. Ask a question at tex.stackexchange.com. + h. Or ask me (the author of latexmk). My e-mail is at the end of this + documentation. -LATEXMK(1L) LATEXMK(1L) - e. There's a useful trick that can be used when you are lualatex - instead of pdflatex (and in some related situations). The problem is - that latexmk won't notice a dependency on a file, bar.baz say, that is - input by the lua code in your document instead of by the LaTeX part. - (Thus if you change bar.baz and rerun latexmk, then latexmk will think - no files have changed and not rerun lualatex, whereas if you had - '\input{bar.baz}' in the LaTeX part of the document, latexmk would - notice the change.) One solution is just to put the following some- - where in the LaTeX part of the document: - \typeout{(bar.baz)} - This puts a line in the log file that latexmk will treat as implying - that the file bar.baz was read. (At present I don't know a way of - doing this automatically.) Of course, if the file has a different - name, change bar.baz to the name of your file. + 1 January 2015 17 - f. Look on tex.stackexchange, i.e., at http://tex.stackex- - change.com/questions/tagged/latexmk Someone may have already solved - your problem. - g. Ask a question at tex.stackexchange.com. - h. Or ask me (the author of latexmk). My e-mail is at the end of this - documentation. +LATEXMK(1L) LATEXMK(1L) + CONFIGURATION/INITIALIZATION (RC) FILES Latexmk can be customized using initialization files, which are read at @@ -1090,12 +1137,14 @@ CONFIGURATION/INITIALIZATION (RC) FILES "/usr/local/share/latexmk/LatexMk", "/usr/local/lib/latexmk/LatexMk". On a MS-WINDOWS system it looks for "C:\latexmk\LatexMk". - On a cygwin system (i.e., a MS-Windows system in which Perl is that + On a cygwin system (i.e., a MS-Windows system in which Perl is that of cygwin), latexmk reads for the first it finds of "/cygdrive/c/latexmk/LatexMk", "/opt/local/share/latexmk/LatexMk", "/usr/local/share/latexmk/LatexMk", "/usr/local/lib/latexmk/LatexMk". + In addition, it then tries the same set of locations, but with the + file name replaced "LatexMk" replaced by "latexmkrc". 2) The user's RC file, "$HOME/.latexmkrc", if it exists. Here $HOME is the user's home directory. [Latexmk determines the user's home direc- @@ -1111,17 +1160,6 @@ CONFIGURATION/INITIALIZATION (RC) FILES 4) Any RC file(s) specified on the command line with the -r option. - - - 2 December 2013 16 - - - - - -LATEXMK(1L) LATEXMK(1L) - - Each RC file is a sequence of Perl commands. Naturally, a user can use this in creative ways. But for most purposes, one simply uses a sequence of assignment statements that override some of the built-in @@ -1142,6 +1180,18 @@ LATEXMK(1L) LATEXMK(1L) HOW TO SET VARIABLES IN INITIALIZATION FILES The important variables that can be configured are described in the + + + + 1 January 2015 18 + + + + + +LATEXMK(1L) LATEXMK(1L) + + section "List of configuration variables usable in initialization files". Syntax for setting these variables is of the following forms: @@ -1182,17 +1232,6 @@ FORMAT OF COMMAND SPECIFICATIONS view a postscript file. This section describes some important features of how the commands are specified. - - - 2 December 2013 17 - - - - - -LATEXMK(1L) LATEXMK(1L) - - Placeholders: Supposed you wanted latexmk to use the command elatex in place of the regular latex command, and suppose moreover that you wanted to give it the option "--shell-escape". You could do this by @@ -1207,6 +1246,18 @@ LATEXMK(1L) LATEXMK(1L) for this command. (E.g., if you used the -silent option it would replace %O by "-interaction=batchmode".) + + + + 1 January 2015 19 + + + + + +LATEXMK(1L) LATEXMK(1L) + + The available placeholders are: %B base of filename for current command. E.g., if a postscript @@ -1252,81 +1303,85 @@ LATEXMK(1L) LATEXMK(1L) on your system, you can turn it off -- see the documentation for the variable $quote_filenames. + The distinction between %B and %R needs a bit of care, since they are + often the same, but not always. For example on a simple document, the + basename of a bibtex run is the same as for the texfile. But in a doc- + ument with several bibliographies, the bibliography files will have a + variety of names. Since bibtex is invoked with the basename of the + bibliography file, the setting for the bibtex command should therefore + be + $bibtex = 'bibtex %O %B'; - 2 December 2013 18 - + 1 January 2015 20 -LATEXMK(1L) LATEXMK(1L) - The distinction between %B and %R needs a bit of care, since they are - often the same, but not always. For example on a simple document, the - basename of a bibtex run is the same as for the texfile. But in a doc- - ument with several bibliographies, the bibliography files will have a - variety of names. Since bibtex is invoked with the basename of the - bibliography file, the setting for the bibtex command should therefore - be +LATEXMK(1L) LATEXMK(1L) - $bibtex = 'bibtex %O %B'; Generally, you should use %B rather than %R. Similarly for most pur- - poses, the name %T of the primary texfile is not a useful placeholder. + poses, the name %T of the primary texfile is not a useful placeholder. - See the default values in the section "List of configuration variables + See the default values in the section "List of configuration variables usable in initialization files" for what is normally the most appropri- ate usage. If you omit to supply any placeholders whatever in the specification of - a command, latexmk will supply what its author thinks are appropriate + a command, latexmk will supply what its author thinks are appropriate defaults. This gives compatibility with configuration files for previ- ous versions of latexmk, which didn't use placeholders. - "Detaching" a command: Normally when latexmk runs a command, it waits + "Detaching" a command: Normally when latexmk runs a command, it waits for the command to run to completion. This is appropriate for commands like latex, of course. But for previewers, the command should normally - run detached, so that latexmk gets the previewer running and then + run detached, so that latexmk gets the previewer running and then returns to its next task (or exits if there is nothing else to do). To - achieve this effect of detaching a command, you need to precede the + achieve this effect of detaching a command, you need to precede the command name with "start ", as in $dvi_previewer = 'start xdvi %O %S'; - This will be translated to whatever is appropriate for your operating + This will be translated to whatever is appropriate for your operating system. - Notes: (1) In some circumstances, latex will always run a command + Notes: (1) In some circumstances, latex will always run a command detached. This is the case for a previewer in preview continuous mode, - since otherwise previewing continuously makes no sense. (2) This pre- - cludes the possibility of running a command named start. (3) If the - word start occurs more than once at the beginning of the command - string, that is equivalent to having just one. (4) Under cygwin, some - complications happen, since cygwin amounts to a complicated merging of - UNIX and MS-Windows. See the source code for how I've handled the + since otherwise previewing continuously makes no sense. (2) This pre- + cludes the possibility of running a command named start. (3) If the + word start occurs more than once at the beginning of the command + string, that is equivalent to having just one. (4) Under cygwin, some + complications happen, since cygwin amounts to a complicated merging of + UNIX and MS-Windows. See the source code for how I've handled the problem. Command names containing spaces: Under MS-Windows it is common that the name of a command includes spaces, since software is often installed in - a subdirectory of "C:\Program Files". Such command names should be + a subdirectory of "C:\Program Files". Such command names should be enclosed in double quotes, as in $lpr_pdf = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p %S'; $pdf_previewer = 'start "c:/Program Files/SumatraPDF/Suma- traPDF.exe" %O %S'; - $pdf_previewer = 'start "c:/Program Files/SumatraPDF (x86)/Suma- + $pdf_previewer = 'start "c:/Program Files/SumatraPDF (x86)/Suma- traPDF.exe" %O %S'; - (Note about the above example: Forward slashes are equivalent to + (Note about the above example: Forward slashes are equivalent to back- + slashes in filenames under MS-Windows, provided that the filename is + inside double quotes. It is easier to use forward slashes in examples + like the one above, since then one does not have to worry about the + rules for dealing with forward slashes in strings in the Perl lan- + guage.) - 2 December 2013 19 + 1 January 2015 21 @@ -1335,32 +1390,26 @@ LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) - backslashes in filenames under MS-Windows, provided that the filename - is inside double quotes. It is easier to use forward slashes in exam- - ples like the one above, since then one does not have to worry about - the rules for dealing with forward slashes in strings in the Perl lan- - guage.) - - Command names under Cygwin: If latexmk is executed by Cygwin's Perl, + Command names under Cygwin: If latexmk is executed by Cygwin's Perl, be particularly certain that pathnames in commands have forward slashes - not the usual backslashes for the separator of pathname components. - See the above examples. Backslashes often get misinterpreted by the + not the usual backslashes for the separator of pathname components. + See the above examples. Backslashes often get misinterpreted by the Unix shell used by Cygwin's Perl to execute external commands. Forward slashes don't suffer from this problem, and (when quoted, as above) are equally acceptable to MS-Windows. - Using MS-Windows file associations: A useful trick under modern ver- + Using MS-Windows file associations: A useful trick under modern ver- sions of MS-Windows (e.g., WinXP) is to use just the command 'start' by itself: $dvi_previewer = 'start %S'; Under recent versions of MS-Windows, this will cause to be run whatever - program the system has associated with dvi files. (The same applies + program the system has associated with dvi files. (The same applies for a postscript viewer and a pdf viewer.) But note that this trick is - not always suitable for the pdf previwer, if your system has acroread + not always suitable for the pdf previwer, if your system has acroread for the default pdf viewer. As explained elsewhere, acroread under MS- - Windows does not work well with latex and latexmk, because acroread + Windows does not work well with latex and latexmk, because acroread locks the pdf file. Not using a certain command: If a command is not to be run, the command @@ -1368,19 +1417,18 @@ LATEXMK(1L) LATEXMK(1L) $lpr = 'NONE lpr'; - This typically is used when an appropriate command does not exist on + This typically is used when an appropriate command does not exist on your system. The string after the "NONE" is effectively a comment. Options to commands: Setting the name of a command can be used not only for changing the name of the command called, but also to add options to - command. Suppose you want latexmk to use latex with source specials - enabled. Then you might use the following line in an initialization + command. Suppose you want latexmk to use latex with source specials + enabled. Then you might use the following line in an initialization file: $latex = 'latex --src-specials %O %S'; - - Running a subroutine instead of an external command: Use a specifica- + Running a subroutine instead of an external command: Use a specifica- tion starting with "internal", as in $latex = 'internal mylatex %O %S'; @@ -1390,14 +1438,16 @@ LATEXMK(1L) LATEXMK(1L) return system 'latex', @args; } - - Advanced tricks: Normally one specifies a single command for the com- - mands invoked by latexmk. Naturally, if there is some complicated + Advanced tricks: Normally one specifies a single command for the com- + mands invoked by latexmk. Naturally, if there is some complicated additional processing you need to do in your special situation, you can + write a script (or batch file) to do the processing, and then configure + latexmk to use your script in place of the standard program. + - 2 December 2013 20 + 1 January 2015 22 @@ -1406,19 +1456,16 @@ LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) - write a script (or batch file) to do the processing, and then configure - latexmk to use your script in place of the standard program. - It is also possible to configure latexmk to run multiple commands. For - example, if when running pdflatex to generate a pdf file from a tex - file you need to run another program after pdflatex to perform some + example, if when running pdflatex to generate a pdf file from a tex + file you need to run another program after pdflatex to perform some extra processing, you could do something like: - $pdflatex = 'pdflatex --shell-escape %O %S; pst2pdf_for_latexmk + $pdflatex = 'pdflatex --shell-escape %O %S; pst2pdf_for_latexmk %B'; - This definition assumes you are using a UNIX-like system (which - includes Linux and OS-X), so that the two commands to be run are sepa- + This definition assumes you are using a UNIX-like system (which + includes Linux and OS-X), so that the two commands to be run are sepa- rated by the semicolon in the middle of the string. If you are using MS-Windows, you would replace the above line by @@ -1426,9 +1473,9 @@ LATEXMK(1L) LATEXMK(1L) $pdflatex = 'cmd /c pdflatex --shell-escape %O %S' . '&& pst2pdf_for_latexmk %B'; - Here, the UNIX command separator ; is replaced by &&. In addition, + Here, the UNIX command separator ; is replaced by &&. In addition, there is a problem that some versions of Perl on MS-Windows do not obey - the command separator; this problem is overcome by explicitly invoking + the command separator; this problem is overcome by explicitly invoking the MS-Windows command-line processor cmd.exe. @@ -1437,38 +1484,36 @@ LIST OF CONFIGURATION VARIABLES USABLE IN INITIALIZATION FILES $always_view_file_via_temporary [0] Whether ps and pdf files are initially to be made in a temporary - directory and then moved to the final location. (This applies + directory and then moved to the final location. (This applies to dvips, dvipdf, and ps2pdf operations, and the filtering oper- - ators on dvi and ps files. It does not apply to pdflatex, + ators on dvi and ps files. It does not apply to pdflatex, unfortunately.) This use of a temporary file solves a problem that the making of - these files can occupy a substantial time. If a viewer sees - that the file has changed, it reads the new file, and this can + these files can occupy a substantial time. If a viewer sees + that the file has changed, it reads the new file, and this can cause havoc if the program writing the file has not yet finished its work. See the $pvc_view_file_via_temporary variable for a setting that - applies only if preview-continuous mode (-pvc option) is used. + applies only if preview-continuous mode (-pvc option) is used. See $tmpdir for the setting of the directory where the temporary file is created. $auto_rc_use [1] - Whether to automatically read the standard initialization (rc) + Whether to automatically read the standard initialization (rc) files, which are the system RC file, the user's RC file, and the RC file in the current directory. The command line option -norc - can be used to turn this setting off. Each RC file could also - turn this setting off, i.e., it could set $auto_rc_use to zero + can be used to turn this setting off. Each RC file could also + turn this setting off, i.e., it could set $auto_rc_use to zero to prevent automatic reading of the later RC files. - This variable does not affect the reading of RC files specified - on the command line by the -r option. - + This variable does not affect the reading of RC files specified - 2 December 2013 21 + 1 January 2015 23 @@ -1477,25 +1522,28 @@ LIST OF CONFIGURATION VARIABLES USABLE IN INITIALIZATION FILES LATEXMK(1L) LATEXMK(1L) + on the command line by the -r option. + + $aux_dir [""] The directory in which auxiliary files (aux, log, etc) are to be - written by a run of (pdf)latex. If this variable is not set, - but $out_dir is set, then $aux_dir is set to $out_dir, which is + written by a run of (pdf)latex. If this variable is not set, + but $out_dir is set, then $aux_dir is set to $out_dir, which is the directory to which general output files are to be written. - Important note: The effect of $aux_dir, if different from - $out_dir, is achieved by giving (pdf)latex the -aux-directory. - Currently (Dec. 2011) this only works on the MiKTeX version of - (pdf)latex. + Important note: The effect of $aux_dir, if different from + $out_dir, is achieved by giving (pdf)latex the -aux-directory. + Currently (Dec. 2011 and later) this only works on the MiKTeX + version of (pdf)latex. See also the documentation of $out_dir for some complications on what directory names are suitable. $banner [0] - If nonzero, the banner message is printed across each page when - converting the dvi file to postscript. Without modifying the - variable $banner_message, this is equivalent to specifying the + If nonzero, the banner message is printed across each page when + converting the dvi file to postscript. Without modifying the + variable $banner_message, this is equivalent to specifying the -d option. Note that if $banner is nonzero, the $postscript_mode is assumed @@ -1504,7 +1552,7 @@ LATEXMK(1L) LATEXMK(1L) $banner_intensity [0.95] Equivalent to the -bi option, this is a decimal number between 0 - and 1 that specifies how dark to print the banner message. 0 is + and 1 that specifies how dark to print the banner message. 0 is black, 1 is white. The default is just right if your toner car- tridge isn't running too low. @@ -1513,33 +1561,25 @@ LATEXMK(1L) LATEXMK(1L) dvi file to postscript. This is equivalent to the -bm option. $banner_scale [220.0] - A decimal number that specifies how large the banner message - will be printed. Experimentation is necessary to get the right - scale for your message, as a rule of thumb the scale should be - about equal to 1100 divided by the number of characters in the - message. The Default is just right for 5 character messages. + A decimal number that specifies how large the banner message + will be printed. Experimentation is necessary to get the right + scale for your message, as a rule of thumb the scale should be + about equal to 1100 divided by the number of characters in the + message. The Default is just right for 5 character messages. This is equivalent to the -bs option. @BIBINPUTS - This is an array variable, now mostly obsolete, that specifies - directories where latexmk should look for .bib files. By + This is an array variable, now mostly obsolete, that specifies + directories where latexmk should look for .bib files. By default it is set from the BIBINPUTS environment variable of the - operating system. If that environment variable is not set, a - single element list consisting of the current directory is set. + operating system. If that environment variable is not set, a + single element list consisting of the current directory is set. The format of the directory names depends on your operating sys- tem, of course. Examples for setting this variable are: - @BIBINPUTS = ( ".", "C:\bibfiles" ); - @BIBINPUTS = ( ".", "\\server\bibfiles" ); - @BIBINPUTS = ( ".", "C:/bibfiles" ); - @BIBINPUTS = ( ".", "//server/bibfiles" ); - @BIBINPUTS = ( ".", "/usr/local/texmf/bibtex/bib" ); - - Note that under MS Windows, either a forward slash "/" or a - - 2 December 2013 22 + 1 January 2015 24 @@ -1548,22 +1588,29 @@ LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) - backward slash "\" can be used to separate pathname components, - so the first two and the second two examples are equivalent. - Each backward slash should be doubled to avoid running afoul of + @BIBINPUTS = ( ".", "C:\bibfiles" ); + @BIBINPUTS = ( ".", "\\server\bibfiles" ); + @BIBINPUTS = ( ".", "C:/bibfiles" ); + @BIBINPUTS = ( ".", "//server/bibfiles" ); + @BIBINPUTS = ( ".", "/usr/local/texmf/bibtex/bib" ); + + Note that under MS Windows, either a forward slash "/" or a + backward slash "\" can be used to separate pathname components, + so the first two and the second two examples are equivalent. + Each backward slash should be doubled to avoid running afoul of Perl's rules for writing strings. Important note: This variable is now mostly obsolete in the cur- rent version of latexmk, since it has a better method of search- - ing for files using the kpsewhich command. However, if your - system is an unusual one without the kpsewhich command, you may + ing for files using the kpsewhich command. However, if your + system is an unusual one without the kpsewhich command, you may need to set the variable @BIBINPUTS. $biber ["biber %O %S"] The biber processing program. $biber_silent_switch ["--onlylog"] - Switch(es) for the biber processing program when silent mode is + Switch(es) for the biber processing program when silent mode is on. $bibtex ["bibtex %O %S"] @@ -1575,42 +1622,30 @@ LATEXMK(1L) LATEXMK(1L) $bibtex_use [1] Under what conditions to run BibTeX or biber. When latexmk dis- - covers from the log file that one (or more) BibTeX/biber-gener- - ated bibliographies are used, it can run BibTeX or biber when- - ever it appears necessary to regenerate the bbl file(s) from + covers from the log file that one (or more) BibTeX/biber-gener- + ated bibliographies are used, it can run BibTeX or biber when- + ever it appears necessary to regenerate the bbl file(s) from their source bib database file(s). - But sometimes, the bib file(s) are not available (e.g., for a - document obtained from an external archive), but the bbl files - are provided. In that case use of BibTeX or biber will result - in incorrect overwriting of the precious bbl files. The vari- - able $bibtex_use controls whether this happens. Its possible + But sometimes, the bib file(s) are not available (e.g., for a + document obtained from an external archive), but the bbl files + are provided. In that case use of BibTeX or biber will result + in incorrect overwriting of the precious bbl files. The vari- + able $bibtex_use controls whether this happens. Its possible values are: 0: never use BibTeX or biber. 1: only use BibTeX or - biber if the bib files exist. 2: run BibTeX or biber whenever - it appears necessary to update the bbl files, without testing + biber if the bib files exist. 2: run BibTeX or biber whenever + it appears necessary to update the bbl files, without testing for the existence of the bib files. $cleanup_includes_cusdep_generated [0] - If nonzero, specifies that cleanup also deletes files that are + If nonzero, specifies that cleanup also deletes files that are generated by custom dependencies. (When doing a clean up, e.g., by use of the -C option, custom dependencies are those listed in the .fdb_latexmk file from a previous run.) - $cleanup_includes_generated [0] - If nonzero, specifies that cleanup also deletes files that are - detected in log file as being generated (see the \openout lines - in the log file). It will also include files made from these - first generation generated files. - - $cleanup_mode [0] - If nonzero, specifies cleanup mode: 1 for full cleanup, 2 for - cleanup except for dvi, ps and pdf files, 3 for cleanup except - for dep and aux files. (There is also extra cleaning as speci- - fied by the $clean_ext, $clean_full_ext and @generated_exts - - 2 December 2013 23 + 1 January 2015 25 @@ -1619,17 +1654,28 @@ LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) + $cleanup_includes_generated [0] + If nonzero, specifies that cleanup also deletes files that are + detected in log file as being generated (see the \openout lines + in the log file). It will also include files made from these + first generation generated files. + + $cleanup_mode [0] + If nonzero, specifies cleanup mode: 1 for full cleanup, 2 for + cleanup except for dvi, ps and pdf files, 3 for cleanup except + for dep and aux files. (There is also extra cleaning as speci- + fied by the $clean_ext, $clean_full_ext and @generated_exts variables.) - This variable is equivalent to specifying one of the -c or -C - options. But there should be no need to set this variable from + This variable is equivalent to specifying one of the -c or -C + options. But there should be no need to set this variable from an RC file. $clean_ext [""] - Extra extensions of files for latexmk to remove when any of the - clean-up options (-c or -C) is selected. The value of this - variable is a string containing the extensions separated by - spaces. + Extra extensions of files for latexmk to remove when any of the + clean-up options (-c or -C) is selected. The value of this + variable is a string containing the extensions separated by spa- + ces. It is also possible to specify a more general pattern of file to be deleted, by using the place holder %R, as in commands, and it @@ -1638,21 +1684,21 @@ LATEXMK(1L) LATEXMK(1L) $clean_ext = "out %R-blx.bib %R-figures*.log"; in an initialization file will imply that when a clean-up opera- - tion is specified, not only is the standard set of files - deleted, but also files of the form FOO.out, FOO-blx.bib, and - %R-figures*.log, where FOO stands for the basename of the file + tion is specified, not only is the standard set of files + deleted, but also files of the form FOO.out, FOO-blx.bib, and + %R-figures*.log, where FOO stands for the basename of the file being processed (as in FOO.tex). $clean_full_ext [""] - Extra extensions of files for latexmk to remove when the -C + Extra extensions of files for latexmk to remove when the -C option is selected, i.e., extensions of files to remove when the .dvi, etc files are to be cleaned-up. More general patterns are allowed, as for $clean_ext. - $compiling_cmd [undefined], $failure_cmd [undefined], $success_cmd + $compiling_cmd [undefined], $failure_cmd [undefined], $success_cmd [undefined] These variables specify commands that are executed at certain @@ -1661,53 +1707,53 @@ LATEXMK(1L) LATEXMK(1L) indications of compilation status even when the window receiving the screen output of the compilation is hidden. - The commands are executed at the following points: $compil- - ing_cmd at the start of compilation, $success_cmd at the end of - a successful compilation, and $failure_cmd at the end of an - unsuccessful compilation. If any of above variables is unde- - fined (the default situation) or blank, then the corresponding - command is not executed. + The commands are executed at the following points: - An example of a typical setting of these variables is as follows - $compiling_cmd = "xdotool search --name \"%D\" set_window - --name \"%D compiling\""; - $success_cmd = "xdotool search --name \"%D\" set_window - --name \"%D OK\""; - $failure_cmd = "xdotool search --name \"%D\" set_window - --name \"%D FAILURE\""; - These assume that the program xdotool is installed, that the + 1 January 2015 26 - 2 December 2013 24 +LATEXMK(1L) LATEXMK(1L) + $compiling_cmd at the start of compilation, $success_cmd at the + end of a successful compilation, and $failure_cmd at the end of + an unsuccessful compilation. If any of above variables is unde- + fined (the default situation) or blank, then the corresponding + command is not executed. -LATEXMK(1L) LATEXMK(1L) + An example of a typical setting of these variables is as follows + $compiling_cmd = "xdotool search --name \"%D\" set_window + --name \"%D compiling\""; + $success_cmd = "xdotool search --name \"%D\" set_window + --name \"%D OK\""; + $failure_cmd = "xdotool search --name \"%D\" set_window + --name \"%D FAILURE\""; - previewer is using an X-Window system for display, and that the - title of the window contains the name of the displayed file, as - it normally does. When the commands are executed, the place- - holder string %D is replaced by the name of the destination + These assume that the program xdotool is installed, that the + previewer is using an X-Window system for display, and that the + title of the window contains the name of the displayed file, as + it normally does. When the commands are executed, the place- + holder string %D is replaced by the name of the destination file, which is the previewed file. The above commands result in an appropriate string being appended to the filename in the win- dow title: " compiling", " OK", or " FAILURE". - Other placeholders that can be used are %S, %T, and %R, with %S - and %T normally being identical. These can be useful for a com- - mand changing the title of the edit window. The visual indica- - tion in a window title can useful, since the user does not have - to keep shifting attention to the (possibly hidden) compilation + Other placeholders that can be used are %S, %T, and %R, with %S + and %T normally being identical. These can be useful for a com- + mand changing the title of the edit window. The visual indica- + tion in a window title can useful, since the user does not have + to keep shifting attention to the (possibly hidden) compilation window to know the status of the compilation. @cus_dep_list [()] - Custom dependency list -- see section on "Custom Dependencies". + Custom dependency list -- see section on "Custom Dependencies". @default_files [("*.tex")] @@ -1728,6 +1774,18 @@ LATEXMK(1L) LATEXMK(1L) @default_files = ("paper_current"); + + + + 1 January 2015 27 + + + + + +LATEXMK(1L) LATEXMK(1L) + + @default_files = ("paper1", "paper2.tex"); @default_files = ("*.tex", "*.dtx"); @@ -1748,139 +1806,144 @@ LATEXMK(1L) LATEXMK(1L) Whether to display a list(s) of dependencies at the end of a run. + $deps_file ["-"] + Name of file to receive list(s) of dependencies at the end of a + run, to be used if $dependesnt_list is set. If the filename is + "-", then the dependency list is set to stdout (i.e., normally + the screen). + $do_cd [0] - Whether to change working directory to the directory specified - for the main source file before processing it. The default + Whether to change working directory to the directory specified + for the main source file before processing it. The default + behavior is not to do this, which is the same as the behavior of + latex and pdflatex programs. This variable is set by the -cd + and -cd- options on latexmk's command line. + $dvi_filter [empty] + The dvi file filter to be run on the newly produced dvi file + before other processing. Equivalent to specifying the -dF + option. + $dvi_mode [See below for default] + If nonzero, generate a dvi version of the document. Equivalent + to the -dvi option. - 2 December 2013 25 + The variable $dvi_mode defaults to 0, but if no explicit + requests are made for other types of file (postscript, pdf), + then $dvi_mode will be set to 1. In addition, if a request for + a file for which a .dvi file is a prerequisite, then $dvi_mode + will be set to 1. + $dvi_previewer ["start xdvi %O %S" under UNIX] + The command to invoke a dvi-previewer. [Default is "start" + under MS-WINDOWS; under more recent versions of Windows, this + will cause to be run whatever command the system has associated + with .dvi files.] -LATEXMK(1L) LATEXMK(1L) + 1 January 2015 28 - behavior is not to do this, which is the same as the behavior of - latex and pdflatex programs. This variable is set by the -cd - and -cd- options on latexmk's command line. - $dvi_filter [empty] - The dvi file filter to be run on the newly produced dvi file - before other processing. Equivalent to specifying the -dF - option. - $dvi_mode [See below for default] - If nonzero, generate a dvi version of the document. Equivalent - to the -dvi option. - The variable $dvi_mode defaults to 0, but if no explicit - requests are made for other types of file (postscript, pdf), - then $dvi_mode will be set to 1. In addition, if a request for - a file for which a .dvi file is a prerequisite, then $dvi_mode - will be set to 1. +LATEXMK(1L) LATEXMK(1L) - $dvi_previewer ["start xdvi %O %S" under UNIX] - The command to invoke a dvi-previewer. [Default is "start" - under MS-WINDOWS; under more recent versions of Windows, this - will cause to be run whatever command the system has associated - with .dvi files.] - Important note: Normally you will want to have a previewer run + Important note: Normally you will want to have a previewer run detached, so that latexmk doesn't wait for the previewer to ter- - minate before continuing its work. So normally you should pre- - fix the command by "start ", which flags to latexmk that it - should do the detaching of the previewer itself (by whatever - method is appropriate to the operating system). But sometimes + minate before continuing its work. So normally you should pre- + 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 letting latexmk do the detaching is not appropriate (for a vari- - ety of non-trivial reasons), so you should put the "start " bit + ety of non-trivial reasons), so you should put the "start " bit in yourself, whenever it is needed. $dvi_previewer_landscape ["start xdvi %O %S"] The command to invoke a dvi-previewer in landscape mode. [Default is "start" under MS-WINDOWS; under more recent versions - of Windows, this will cause to be run whatever command the sys- + of Windows, this will cause to be run whatever command the sys- tem has associated with .dvi files.] $dvipdf ["dvipdf %O %S %D"] Command to convert dvi to pdf file. A common reconfiguration is - to use the dvipdfm command, which needs its arguments in a dif- + to use the dvipdfm command, which needs its arguments in a dif- ferent order: $dvipdf = "dvipdfm %O -o %D %S"; - WARNING: The default dvipdf script generates pdf files with + WARNING: The default dvipdf script generates pdf files with bitmapped fonts, which do not look good when viewed by acroread. - That script should be modified to give dvips the options "-P + That script should be modified to give dvips the options "-P pdf" to ensure that type 1 fonts are used in the pdf file. $dvipdf_silent_switch ["-q"] Switch(es) for dvipdf program when silent mode is on. - 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 - switch has an effect. The default setting is correct for - - - - 2 December 2013 26 - - - - - -LATEXMK(1L) LATEXMK(1L) - - + 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 + switch has an effect. The default setting is correct for dvipdfm and dvipdfmx. $dvips ["dvips %O -o %D %S"] - The program to used as a filter to convert a .dvi file to a .ps - file. If pdf is going to be generated from pdf, then the value + The program to used as a filter to convert a .dvi file to a .ps + file. If pdf is going to be generated from pdf, then the value of the $dvips_pdf_switch -- see below -- will be included in the options substituted for "%O". $dvips_landscape ["dvips -tlandscape %O -o %D %S"] - The program to used as a filter to convert a .dvi file to a .ps + The program to used as a filter to convert a .dvi file to a .ps file in landscape mode. $dvips_pdf_switch ["-P pdf"] - Switch(es) for dvips program when pdf file is to be generated + Switch(es) for dvips program when pdf file is to be generated from ps file. $dvips_silent_switch ["-q"] Switch(es) for dvips program when silent mode is on. + + + 1 January 2015 29 + + + + + +LATEXMK(1L) LATEXMK(1L) + + $dvi_update_command [""] - When the dvi previewer is set to be updated by running a com- - mand, this is the command that is run. See the information for + When the dvi previewer is set to be updated by running a com- + mand, this is the command that is run. See the information for the variable $dvi_update_method for further information, and see - information on the variable $pdf_update_method for an example + information on the variable $pdf_update_method for an example for the analogous case of a pdf previewer. $dvi_update_method [2 under UNIX, 1 under MS-Windows] - How the dvi viewer updates its display when the dvi file has - changed. The values here apply equally to the + How the dvi viewer updates its display when the dvi file has + changed. The values here apply equally to the $pdf_update_method and to the $ps_update_method variables. 0 => update is automatic, 1=> manual update by user, which may only mean a mouse click on the viewer's window or may mean a more serious action. - 2 => Send the signal, whose number is in the variable - $dvi_update_signal. The default value under UNIX is suitable + 2 => Send the signal, whose number is in the variable + $dvi_update_signal. The default value under UNIX is suitable for xdvi. - 3 => Viewer cannot do an update, because it locks the file. + 3 => Viewer cannot do an update, because it locks the file. (As with acroread under MS-Windows.) - 4 => run a command to do the update. The command is speci- + 4 => run a command to do the update. The command is speci- fied by the variable $dvi_update_command. - See information on the variable $pdf_update_method for an exam- + See information on the variable $pdf_update_method for an exam- ple of updating by command. - $dvi_update_signal [Under UNIX: SIGUSR1, which is a system-dependent + $dvi_update_signal [Under UNIX: SIGUSR1, which is a system-dependent value] The number of the signal that is sent to the dvi viewer when it is updated by sending a signal -- see the information on the @@ -1898,67 +1961,67 @@ LATEXMK(1L) LATEXMK(1L) $force_mode [0] If nonzero, continue processing past minor latex errors includ- ing unrecognized cross references. Equivalent to specifying the + -f option. + @generated_exts [( aux , bbl , idx , ind , lof , lot , out , toc , + $fdb_ext )] + This contains a list of extensions for files that are generated + during a LaTeX run and that are read in by LaTeX in later runs, + either directly or indirectly. + This list has two uses: (a) to set the kinds of file to be + deleted in a cleanup operation (with the -c, -C, -CA, -g and -gg + options), and (b) in the determination of whether a rerun of - 2 December 2013 27 + 1 January 2015 30 -LATEXMK(1L) LATEXMK(1L) - -f option. +LATEXMK(1L) LATEXMK(1L) - @generated_exts [( aux , bbl , idx , ind , lof , lot , out , toc , - $fdb_ext )] - This contains a list of extensions for files that are generated - during a LaTeX run and that are read in by LaTeX in later runs, - either directly or indirectly. - This list has two uses: (a) to set the kinds of file to be - deleted in a cleanup operation (with the -c, -C, -CA, -g and -gg - options), and (b) in the determination of whether a rerun of (pdf)LaTeX is needed after a run that gives an error. (Normally, a change of a source file during a run should provoke - a rerun. This includes a file generated by LaTeX, e.g., an aux - file, that is read in on subsequent runs. But after a run that - results in an error, a new run should occur until the user has - made a change in the files. But the user may have corrected an + a rerun. This includes a file generated by LaTeX, e.g., an aux + file, that is read in on subsequent runs. But after a run that + results in an error, a new run should occur until the user has + made a change in the files. But the user may have corrected an error in a source .tex file during the run. So latexmk needs to distinguish user-generated and automatically generated files; it - determines the automatically generated files as those with + determines the automatically generated files as those with extensions in the list in @generated_exts.) - A convenient way to add an extra extension to the list, without - losing the already defined ones is to use a push command in the + A convenient way to add an extra extension to the list, without + losing the already defined ones is to use a push command in the line in an RC file. E.g., push @generated_exts, "end"; - adds the extension "end" to the list of predefined generated - extensions. (This extension is used by the RevTeX package, for + adds the extension "end" to the list of predefined generated + extensions. (This extension is used by the RevTeX package, for example.) $go_mode [0] - If nonzero, process files regardless of timestamps, and is then + If nonzero, process files regardless of timestamps, and is then equivalent to the -g option. %hash_calc_ignore_pattern !!!This variable is for experts only!!! - The general rule latexmk uses for determining when an extra run - of some program is needed is that one of the source files has - changed. But consider for example a latex package that causes - an encapsulated postscript file (an "eps" file) to be made that - is to be read in on the next run. The file contains a comment - line giving its creation date and time. On the next run the - time changes, latex sees that the eps file has changed, and - therefore reruns latex. This causes an infinite loop, that is - only terminated because latexmk has a limit on the number of + The general rule latexmk uses for determining when an extra run + of some program is needed is that one of the source files has + changed. But consider for example a latex package that causes + an encapsulated postscript file (an "eps" file) to be made that + is to be read in on the next run. The file contains a comment + line giving its creation date and time. On the next run the + time changes, latex sees that the eps file has changed, and + therefore reruns latex. This causes an infinite loop, that is + only terminated because latexmk has a limit on the number of runs to guard against pathological situations. But the changing line has no real effect, since it is a comment. @@ -1967,15 +2030,18 @@ LATEXMK(1L) LATEXMK(1L) $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: '; This creates a rule for files with extension .eps about lines to - ignore. The left-hand side is a Perl idiom for setting an item - in a hash. Note that the file extension is specified without a + ignore. The left-hand side is a Perl idiom for setting an item + in a hash. Note that the file extension is specified without a period. The value, on the right-hand side, is a string contain- - ing a regular expresssion. (See documentation on Perl for how - they are to be specified in general.) This particular regular + ing a regular expresssion. (See documentation on Perl for how + they are to be specified in general.) This particular regular + expression specifies that lines beginning with "%%CreationDate: + " are to be ignored in deciding whether a file of the given + extension .eps has changed. - 2 December 2013 28 + 1 January 2015 31 @@ -1984,25 +2050,21 @@ LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) - expression specifies that lines beginning with "%%CreationDate: - " are to be ignored in deciding whether a file of the given - extension .eps has changed. - - There is only one regular expression available for each exten- - sion. If you need more one pattern to specify lines to ignore, - then you need to combine the patterns into a single regular - expression. The simplest method is separate the different sim- - ple patterns by a vertical bar character (indicating "alterna- + There is only one regular expression available for each exten- + sion. If you need more one pattern to specify lines to ignore, + then you need to combine the patterns into a single regular + expression. The simplest method is separate the different sim- + ple patterns by a vertical bar character (indicating "alterna- tion" in the jargon of regular expressions). For example, - $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: + $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: |^%%Title: '; - causes lines starting with either "^%%CreationDate: " or + causes lines starting with either "^%%CreationDate: " or "^%%Title: " to be ignored. - It may happen that a pattern to be ignored is specified in, for - example, in a system or user initialization file, and you wish + It may happen that a pattern to be ignored is specified in, for + example, in a system or user initialization file, and you wish to remove this in a file read later. To do this, you use Perl's delete function, e.g., @@ -2010,46 +2072,42 @@ LATEXMK(1L) LATEXMK(1L) $kpsewhich ["kpsewhich %S"] - The program called to locate a source file when the name alone - is not sufficient. Most filenames used by latexmk have suffi- - cient path information to be found directly. But sometimes, - notably when .bib files are found from the log file of a bibtex - or biber run, the name of the file, but not its path is known. + The program called to locate a source file when the name alone + is not sufficient. Most filenames used by latexmk have suffi- + cient path information to be found directly. But sometimes, + notably when .bib files are found from the log file of a bibtex + or biber run, the name of the file, but not its path is known. The program specified by $kpsewhich is used to find it. - See also the @BIBINPUTS variable for another way that latexmk + See also the @BIBINPUTS variable for another way that latexmk also uses to try to locate files; it applies only in the case of .bib files. $landscape_mode [0] If nonzero, run in landscape mode, using the landscape mode pre- - viewers and dvi to postscript converters. Equivalent to the -l + viewers and dvi to postscript converters. Equivalent to the -l option. Normally not needed with current previewers. $latex ["latex %O %S"] The LaTeX processing program. Note that as with other programs, - you can use this variable not just to change the name of the + you can use this variable not just to change the name of the program used, but also specify options to the program. E.g., $latex = "latex --src-specials"; %latex_input_extensions - This variable specifies the extensions tried by latexmk when it - finds that a LaTeX run resulted in an error that a file has not - been found, and the file is given without an extension. This - typically happens when LaTeX commands of the form \input{file} - or \includegraphics{figure}, when the relevant source file does + This variable specifies the extensions tried by latexmk when it + finds that a LaTeX run resulted in an error that a file has not + been found, and the file is given without an extension. This + typically happens when LaTeX commands of the form \input{file} + or \includegraphics{figure}, when the relevant source file does not exist. - In this situation, latexmk searches for custom dependencies to - make the missing file(s), but restricts it to the extensions - specified by the variable %latex_input_extensions. The default - extensions are 'tex' and 'eps'. - + In this situation, latexmk searches for custom dependencies to - 2 December 2013 29 + 1 January 2015 32 @@ -2058,11 +2116,15 @@ LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) - (For Perl experts: %latex_input_extensions is a hash whose keys - are the extensions. The values are irrelevant.) Two subrou- - tines are provided for manipulating this and the related vari- - able %pdflatex_input_extensions, add_input_ext and - remove_input_ext. They are used as in the following examples + make the missing file(s), but restricts it to the extensions + specified by the variable %latex_input_extensions. The default + extensions are 'tex' and 'eps'. + + (For Perl experts: %latex_input_extensions is a hash whose keys + are the extensions. The values are irrelevant.) Two subrou- + tines are provided for manipulating this and the related vari- + able %pdflatex_input_extensions, add_input_ext and + remove_input_ext. They are used as in the following examples are possible lines in an initialization file: remove_input_ext( 'latex', 'tex' ); @@ -2071,20 +2133,20 @@ LATEXMK(1L) LATEXMK(1L) add_input_ext( 'latex', 'asdf' ); - add the extension 'asdf to latex_input_extensions. (Naturally + 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 + 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. $latex_silent_switch ["-interaction=batchmode"] - Switch(es) for the LaTeX processing program when silent mode is + 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 + 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- @@ -2094,7 +2156,7 @@ LATEXMK(1L) LATEXMK(1L) $lpr ["lpr %O %S" under UNIX/LINUX, "NONE lpr" under MS-WINDOWS] The command to print postscript files. - Under MS-Windows (unlike UNIX/LINUX), there is no standard pro- + Under MS-Windows (unlike UNIX/LINUX), there is no standard pro- gram for printing files. But there are ways you can do it. For example, if you have gsview installed, you could use it with the option "/p": @@ -2107,33 +2169,34 @@ LATEXMK(1L) LATEXMK(1L) that this is a string to be assigned to the configuration vari- able $lpr. The double quotes are part of the string passed to the operating system to get the command obeyed; this is neces- - sary because one part of the command name ("Program Files") con- - tains a space which would otherwise be misinterpreted. + sary because one part of the command name ("Program Files") - $lpr_dvi ["NONE lpr_dvi"] - The printing program to print dvi files. - $lpr_pdf ["NONE lpr_pdf"] - The printing program to print pdf files. - Under MS-Windows you could set this to use gsview, if it is - installed, e.g., + 1 January 2015 33 - $lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p'; - 2 December 2013 30 +LATEXMK(1L) LATEXMK(1L) + contains a space which would otherwise be misinterpreted. + $lpr_dvi ["NONE lpr_dvi"] + The printing program to print dvi files. -LATEXMK(1L) LATEXMK(1L) + $lpr_pdf ["NONE lpr_pdf"] + The printing program to print pdf files. + Under MS-Windows you could set this to use gsview, if it is + installed, e.g., - If gsview is installed in a different directory, you will need - to make the appropriate change. Note the double quotes around + $lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p'; + + If gsview is installed in a different directory, you will need + to make the appropriate change. Note the double quotes around the name: this is necessary because one part of the command name ("Program Files") contains a space which would otherwise be mis- interpreted. @@ -2147,107 +2210,119 @@ LATEXMK(1L) LATEXMK(1L) The index processing program. $makeindex_silent_switch ["-q"] - Switch(es) for the index processing program when silent mode is + Switch(es) for the index processing program when silent mode is on. $max_repeat [5] - The maximum number of times latexmk will run latex/pdflatex - before deciding that there may be an infinite loop and that it + The maximum number of times latexmk will run latex/pdflatex + before deciding that there may be an infinite loop and that it needs to bail out, rather than rerunning latex/pdflatex again to - resolve cross-references, etc. The default value covers all + resolve cross-references, etc. The default value covers all normal cases. - (Note that the "etc" covers a lot of cases where one run of + (Note that the "etc" covers a lot of cases where one run of latex/pdflatex generates files to be read in on a later run.) $MSWin_back_slash [1] - This configuration variable only has an effect when latexmk is + This configuration variable only has an effect when latexmk is running under MS-Windows. It determines whether, when a command - is executed under MS-Windows, there should be substituted "\" - for the separator character between components of a directory - name. Internally, latexmk uses "/" for the directory separator + is executed under MS-Windows, there should be substituted "\" + for the separator character between components of a directory + name. Internally, latexmk uses "/" for the directory separator character, which is the character used by Unix-like systems. For many programs under MS-Windows, both "\" and "/" are accept- - able as the directory separator character. But some programs - only accept "\". So for safety latexmk makes a translation, by - default. It is conceivable that under certain situations this - is undesirable, so the configuration can be changed. (A possi- - ble example might be when some of the software is implemented - using Cygwin, which provides an Unix-like environment inside MS- - Windows.) + able as the directory separator character. But some programs + only accept "\". So for safety latexmk makes a translation, by + default. It is conceivable that under certain situations this + is undesirable, so the configuration can be changed. (A - $new_viewer_always [0] - This variable applies to latexmk only in continuous-preview - mode. If $new_viewer_always is 0, latexmk will check for a pre- - viously running previewer on the same file, and if one is run- - ning will not start a new one. If $new_viewer_always is non- - zero, this check will be skipped, and latexmk will behave as if - no viewer is running. + 1 January 2015 34 - $out_dir [""] - The directory in which output files are to be written by a run - of (pdf)latex. See also the variable $aux_dir. - The effect of this variable (when non-blank) is achieved by - using the -output-directory option of (pdf)latex. This exists - in the usual current (Dec. 2011) implementations of TeX, i.e., - 2 December 2013 31 +LATEXMK(1L) LATEXMK(1L) + possible example might be when some of the software is imple- + mented using Cygwin, which provides an Unix-like environment + inside MS-Windows.) + $new_viewer_always [0] + This variable applies to latexmk only in continuous-preview + mode. If $new_viewer_always is 0, latexmk will check for a pre- + viously running previewer on the same file, and if one is run- + ning will not start a new one. If $new_viewer_always is non- + zero, this check will be skipped, and latexmk will behave as if + no viewer is running. -LATEXMK(1L) LATEXMK(1L) + $out_dir [""] + The directory in which output files are to be written by a run + of (pdf)latex. See also the variable $aux_dir. - MiKTeX and TeXLive. But it may not be present in other versions. + The effect of this variable (when non-blank) is achieved by + using the -output-directory option of (pdf)latex. This exists + in the usual current (Dec. 2011 and later) implementations of + TeX, i.e., MiKTeX and TeXLive. But it may not be present in + other versions. - Commonly, the directory specified for output files is a subdi- + Commonly, the directory specified for output files is a subdi- rectory of the current working directory. However, if you spec- - ify some other directory, e.g., "/tmp/foo" or "../output", be - aware that this could cause problems, e.g., with makeindex or - bibtex. This is because modern versions of these programs, by - default, will refuse to work when they find that they are asked - to write to a file in a directory that appears not to be the + ify some other directory, e.g., "/tmp/foo" or "../output", be + aware that this could cause problems, e.g., with makeindex or + bibtex. This is because modern versions of these programs, by + default, will refuse to work when they find that they are asked + to write to a file in a directory that appears not to be the current working directory or one of its subdirectories. This is - part of security measures by the whole TeX system that try to + part of security measures by the whole TeX system that try to prevent malicious or errant TeX documents from incorrectly mess- ing with a user's files. If for $out_dir or $aux_dir you really - do need to specify an absolute pathname (e.g., "/tmp/foo") or a + do need to specify an absolute pathname (e.g., "/tmp/foo") or a path (e.g., "../output") that includes a higher-level directory, - then you need to disable the security measures (and assume any - risks). This can be done by temporarily setting the operating - system's environment variable openout_any to "a" (as in "all"), + then you need to disable the security measures (and assume any + risks). This can be done by temporarily setting the operating + system's environment variable openout_any to "a" (as in "all"), to override the default "paranoid" setting. $pdf_mode [0] - If zero, do NOT generate a pdf version of the document. If - equal to 1, generate a pdf version of the document using pdfla- + If zero, do NOT generate a pdf version of the document. If + equal to 1, generate a pdf version of the document using pdfla- tex. If equal to 2, generate a pdf version of the document from the ps file, by using the command specified by the $ps2pdf vari- - able. If equal to 3, generate a pdf version of the document + able. If equal to 3, generate a pdf version of the document from the dvi file, by using the command specified by the $dvipdf variable. Equivalent to the -pdf-, -pdf, -pdfdvi, -pdfps options. + + + 1 January 2015 35 + + + + + +LATEXMK(1L) LATEXMK(1L) + + $pdflatex ["pdflatex %O %S"] - The LaTeX processing program in a version that makes a pdf file + The LaTeX processing program in a version that makes a pdf file instead of a dvi file. - An example of the use of this variable is to arrange for luala- - tex, xelatex or some similar program to be used instead of - pdflatex. Note that lualatex and xelatex only produce .pdf - files (and not .dvi), so to use them you will also need to turn - on production of .pdf files, and to turn off the production of + An example of the use of this variable is to arrange for luala- + tex, xelatex or some similar program to be used instead of + pdflatex. Note that lualatex and xelatex only produce .pdf + files (and not .dvi), so to use them you will also need to turn + on production of .pdf files, and to turn off the production of .dvi (and .ps) files, either by command line options or by suit- able settings in a configuration file. Thus to use lualatex, the following settings are appropriate: @@ -2260,7 +2335,7 @@ LATEXMK(1L) LATEXMK(1L) $pdflatex = "xelatex %O %S"; $pdf_mode = 1; $postscript_mode = $dvi_mode = 0; - Another use of the same variable is to add certain options to + Another use of the same variable is to add certain options to the command line for the program, e.g., $pdflatex = "pdflatex --shell-escape %O %S"; @@ -2268,57 +2343,57 @@ LATEXMK(1L) LATEXMK(1L) %pdflatex_input_extensions - This variable specifies the extensions tried by latexmk when it - finds that a pdflatex run resulted in an error that a file has + This variable specifies the extensions tried by latexmk when it + finds that a pdflatex run resulted in an error that a file has + not been found, and the file is given without an extension. + This typically happens when LaTeX commands of the form + \input{file} or \includegraphics{figure}, when the relevant + source file does not exist. + In this situation, latexmk searches for custom dependencies to + make the missing file(s), but restricts it to the extensions + specified by the variable %pdflatex_input_extensions. The + default extensions are 'tex', 'pdf', 'jpg, and 'png'. + (For Perl experts: %pdflatex_input_extensions is a hash whose + keys are the extensions. The values are irrelevant.) Two sub- + routines are provided for manipulating this and the related + variable %latex_input_extensions, add_input_ext and + remove_input_ext. They are used as in the following examples + are possible lines in an initialization file: - 2 December 2013 32 + remove_input_ext( 'pdflatex', 'tex' ); + removes the extension 'tex' from pdflatex_input_extensions + add_input_ext( 'pdflatex', 'asdf' ); -LATEXMK(1L) LATEXMK(1L) + 1 January 2015 36 - not been found, and the file is given without an extension. - This typically happens when LaTeX commands of the form - \input{file} or \includegraphics{figure}, when the relevant - source file does not exist. - In this situation, latexmk searches for custom dependencies to - make the missing file(s), but restricts it to the extensions - specified by the variable %pdflatex_input_extensions. The - default extensions are 'tex', 'pdf', 'jpg, and 'png'. - (For Perl experts: %pdflatex_input_extensions is a hash whose - keys are the extensions. The values are irrelevant.) Two sub- - routines are provided for manipulating this and the related - variable %latex_input_extensions, add_input_ext and - remove_input_ext. They are used as in the following examples - are possible lines in an initialization file: - remove_input_ext( 'pdflatex', 'tex' ); - removes the extension 'tex' from pdflatex_input_extensions +LATEXMK(1L) LATEXMK(1L) - add_input_ext( 'pdflatex', 'asdf' ); - add the extension 'asdf to pdflatex_input_extensions. (Natu- - rally with such an extension, you should have made an appropri- + add the extension 'asdf to pdflatex_input_extensions. (Natu- + rally with such an extension, you should have made an appropri- ate custom dependency for latexmk, and should also have done the - appropriate programming in the LaTeX source file to enable the - file to be read. The standard extensions are handled by pdfla- + appropriate programming in the LaTeX source file to enable the + file to be read. The standard extensions are handled by pdfla- tex and its graphics/graphicx packages.) $pdflatex_silent_switch ["-interaction=batchmode"] - Switch(es) for the pdflatex program (specified in the variable + Switch(es) for the pdflatex program (specified in the variable $pdflatex 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 + 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- @@ -2328,59 +2403,59 @@ LATEXMK(1L) LATEXMK(1L) $pdf_previewer ["start acroread %O %S"] The command to invoke a pdf-previewer. - On MS-WINDOWS, the default is changed to "cmd /c start """; + On MS-WINDOWS, the default is changed to "cmd /c start """; under more recent versions of Windows, this will cause to be run whatever command the system has associated with .pdf files. But - this may be undesirable if this association is to acroread -- + this may be undesirable if this association is to acroread -- see the notes in the explanation of the -pvc option.] - 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 + 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 preview, which is quite satisfactory. - WARNING: Problem under MS-Windows: if acroread is used as the - pdf previewer, and it is actually viewing a pdf file, the pdf - file cannot be updated. Thus makes acroread a bad choice of - previewer if you use latexmk's previous-continuous mode (option - -pvc) under MS-windows. This problem does not occur if, for + WARNING: Problem under MS-Windows: if acroread is used as the + pdf previewer, and it is actually viewing a pdf file, the pdf + file cannot be updated. Thus makes acroread a bad choice of + previewer if you use latexmk's previous-continuous mode (option + -pvc) under MS-windows. This problem does not occur if, for example, SumatraPDF or gsview is used to view pdf files. + Important note: Normally you will want to have a previewer run + detached, so that latexmk doesn't wait for the previewer to ter- + minate before continuing its work. So normally you should pre- + fix the command by "start ", which flags to latexmk that it + should do the detaching of the previewer itself (by whatever + method is appropriate to the operating system). But sometimes + 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. + $pdf_update_command [""] + When the pdf previewer is set to be updated by running a - 2 December 2013 33 + 1 January 2015 37 -LATEXMK(1L) LATEXMK(1L) - Important note: Normally you will want to have a previewer run - detached, so that latexmk doesn't wait for the previewer to ter- - minate before continuing its work. So normally you should pre- - fix the command by "start ", which flags to latexmk that it - should do the detaching of the previewer itself (by whatever - method is appropriate to the operating system). But sometimes - 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. +LATEXMK(1L) LATEXMK(1L) - $pdf_update_command [""] - When the pdf previewer is set to be updated by running a com- - mand, this is the command that is run. See the information for - the variable $pdf_update_method. + command, this is the command that is run. See the information + for the variable $pdf_update_method. $pdf_update_method [1 under UNIX, 3 under MS-Windows] - How the pdf viewer updates its display when the pdf file has - changed. See the information on the variable $dvi_update_method + How the pdf viewer updates its display when the pdf file has + changed. See the information on the variable $dvi_update_method for the codes. (Note that information needs be changed slightly - so that for the value 4, to run a command to do the update, the - command is specified by the variable $pdf_update_command, and - for the value 2, to specify update by signal, the signal is + so that for the value 4, to run a command to do the update, the + command is specified by the variable $pdf_update_command, and + for the value 2, to specify update by signal, the signal is specified by $pdf_update_signal.) Note that acroread under MS-Windows (but not UNIX) locks the pdf @@ -2393,14 +2468,14 @@ LATEXMK(1L) LATEXMK(1L) $pdf_update_method = 4; $pdf_update_command = "xpdf -remote %R -reload"; - The first setting arranges for the xpdf program to be used in - its "remote server mode", with the server name specified as the - rootname of the TeX file. The second setting arranges for + The first setting arranges for the xpdf program to be used in + its "remote server mode", with the server name specified as the + rootname of the TeX file. The second setting arranges for updating to be done in response to a command, and the third set- ting sets the update command. - $pdf_update_signal [Under UNIX: SIGHUP, which is a system-dependent + $pdf_update_signal [Under UNIX: SIGHUP, which is a system-dependent value] 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 @@ -2422,10 +2497,13 @@ LATEXMK(1L) LATEXMK(1L) If some other request is made for which a postscript file is needed, then $postscript_mode will be set to 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 - 2 December 2013 34 + 1 January 2015 38 @@ -2434,9 +2512,6 @@ LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) - $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 option. Which previewer is run depends on the other settings, see the command line options -view=, and the variable $view. @@ -2463,8 +2538,8 @@ LATEXMK(1L) LATEXMK(1L) the previewer about file changes). Each line of the output of this command is assumed to correspond - to one process. See the $pid_position variable for how the pro- - cess number is determined. + to one process. See the $pid_position variable for how the + process number is determined. The default for pscmd is "NONE" under MS-Windows and cygwin (i.e., the command is not used), "ps --width 200 -f -u @@ -2477,9 +2552,9 @@ LATEXMK(1L) LATEXMK(1L) Command to convert ps to pdf file. $ps_filter [empty] - The postscript file filter to be run on the newly produced - postscript file before other processing. Equivalent to specify- - ing the -pF option. + The postscript file filter to be run on the newly produced post- + script file before other processing. Equivalent to specifying + the -pF option. $ps_previewer ["start gv %O %S", but start %O %S under MS-WINDOWS] The command to invoke a ps-previewer. (The default under MS- @@ -2492,16 +2567,9 @@ LATEXMK(1L) LATEXMK(1L) ferent ways of writing this option. You can configure this variable appropriately. - WARNING: Linux systems may have installed one (or more) versions - of gv under different names, e.g., ggv, kghostview, etc, but - perhaps not one called gv. - - Important note: Normally you will want to have a previewer run - detached, so that latexmk doesn't wait for the previewer to - - 2 December 2013 35 + 1 January 2015 39 @@ -2510,8 +2578,14 @@ LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) - terminate before continuing its work. So normally you should - prefix the command by "start ", which flags to latexmk that it + WARNING: Linux systems may have installed one (or more) versions + of gv under different names, e.g., ggv, kghostview, etc, but + perhaps not one called gv. + + Important note: Normally you will want to have a previewer run + detached, so that latexmk doesn't wait for the previewer to ter- + minate before continuing its work. So normally you should pre- + fix the command by "start ", which flags to latexmk that it should do the detaching of the previewer itself (by whatever method is appropriate to the operating system). But sometimes letting latexmk do the detaching is not appropriate (for a vari- @@ -2524,21 +2598,21 @@ LATEXMK(1L) LATEXMK(1L) The command to invoke a ps-previewer in landscape mode. $ps_update_command [""] - When the postscript previewer is set to be updated by running a - command, this is the command that is run. See the information + When the postscript previewer is set to be updated by running a + command, this is the command that is run. See the information for the variable $ps_update_method. $ps_update_method [0 under UNIX, 1 under MS-Windows] - How the postscript viewer updates its display when the ps file - has changed. See the information on the variable - $dvi_update_method for the codes. (Note that information needs + How the postscript viewer updates its display when the ps file + has changed. See the information on the variable + $dvi_update_method for the codes. (Note that information needs be changed slightly so that for the value 4, to run a command to do the update, the command is specified by the variable - $ps_update_command, and for the value 2, to specify update by + $ps_update_command, and for the value 2, to specify update by signal, the signal is specified by $ps_update_signal.) - $ps_update_signal [Under UNIX: SIGHUP, which is a system-dependent + $ps_update_signal [Under UNIX: SIGHUP, which is a system-dependent value] The number of the signal that is sent to the pdf viewer when it is updated by sending a signal -- see $ps_update_method. The @@ -2558,6 +2632,18 @@ LATEXMK(1L) LATEXMK(1L) The quoting method used by latexmk is tested to work correctly under UNIX systems (including Linux and Mac OS-X) and under MS- + + + + 1 January 2015 40 + + + + + +LATEXMK(1L) LATEXMK(1L) + + Windows. It allows the use of filenames containing special characters, notably spaces. (But note that many versions of LaTeX and PdfLaTeX cannot correctly deal with TeX files whose @@ -2574,18 +2660,6 @@ LATEXMK(1L) LATEXMK(1L) tex. It is generally recommended to use this option (or to configure - - - - 2 December 2013 36 - - - - - -LATEXMK(1L) LATEXMK(1L) - - the $recorder variable to be on.) But it only works if (pdf)latex supports the -recorder option, which is true for most current implementations @@ -2625,6 +2699,39 @@ LATEXMK(1L) LATEXMK(1L) the MSWin, Linux, OS-X, Unix collection.) + + + 1 January 2015 41 + + + + + +LATEXMK(1L) LATEXMK(1L) + + + $silence_logfile_warnings [0] + Whether after a run of (pdf)latex to summarize warnings in the + log file about undefined citations and references. Setting + $silence_logfile_warnings=0 gives the summary of warnings (pro- + vided silent mode isn't also set), and this is useful to locate + undefined citations and references without searching through the + much more verbose log file or the screen output of (pdf)latex. + But the summary can also be excessively annoying. The default + is not to give these warnings. The command line options + -silence_logfile_warning_list and -silence_logfile_warning_list- + also set this variable. + + Note that multiple occurrences for the same undefined object on + the same page and same line will be compressed to a single warn- + ing. + + + $silent [0] + Whether to run silently. Setting $silent to 1 has the same + effect as the -quiet of -silent options on the command line. + + $sleep_time [2] The time to sleep (in seconds) between checking for source file changes when running with the -pvc option. This is subject to a @@ -2652,9 +2759,15 @@ LATEXMK(1L) LATEXMK(1L) Directory to store temporary files that latexmk may generate while running. + The default under MSWindows (including cygwin), is to set + $tmpdir to the value of the first of whichever of the system + environment variables TMPDIR or TEMP exists, otherwise to the + current directory. Under other operating systems (expected to + be UNIX/Linux, including OS-X), the default is the value of the + - 2 December 2013 37 + 1 January 2015 42 @@ -2663,11 +2776,6 @@ LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) - The default under MSWindows (including cygwin), is to set - $tmpdir to the value of the first of whichever of the system - environment variables TMPDIR or TEMP exists, otherwise to the - current directory. Under other operating systems (expected to - be UNIX/Linux, including OS-X), the default is the value of the system environment variable TMPDIR if it exists, otherwise "/tmp". @@ -2722,16 +2830,10 @@ CUSTOM DEPENDENCIES must: If non-zero, the file from which we are converting must exist, if it doesn't exist latexmk will give an error message and exit unless the -f option is specified. If must is zero and the file - we are converting from doesn't exist, then no action is taken. - - function: - The name of the subroutine that latexmk should call to perform - the file conversion. The first argument to the subroutine is - the base name of the file to be converted without any extension. - 2 December 2013 38 + 1 January 2015 43 @@ -2740,6 +2842,12 @@ CUSTOM DEPENDENCIES LATEXMK(1L) LATEXMK(1L) + we are converting from doesn't exist, then no action is taken. + + function: + The name of the subroutine that latexmk should call to perform + the file conversion. The first argument to the subroutine is + the base name of the file to be converted without any extension. The subroutines are declared in the syntax of Perl. The func- tion should return 0 if it was successful and a nonzero number if it failed. @@ -2788,6 +2896,18 @@ LATEXMK(1L) LATEXMK(1L) of the form of a variable name, $_[0] in this case, is to be substi- tuted by its value. + + + + 1 January 2015 44 + + + + + +LATEXMK(1L) LATEXMK(1L) + + 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 @@ -2805,18 +2925,6 @@ LATEXMK(1L) LATEXMK(1L) Note 1: In the command lines given in the system commands in the above examples, double quotes have been inserted around the file names - - - - 2 December 2013 39 - - - - - -LATEXMK(1L) LATEXMK(1L) - - (implemented by '\"' in the Perl language). They immunize the running of the program against special characters in filenames. Very often these quotes are not necessary, i.e., they can be omitted. But it is @@ -2854,6 +2962,18 @@ LATEXMK(1L) LATEXMK(1L) latexmk concerning index files. The only index-file conversion built- in to latexmk is from an ".idx" file written on one run of latex/pdfla- tex to an ".ind" file to be read in on a subsequent run. But with the + + + + 1 January 2015 45 + + + + + +LATEXMK(1L) LATEXMK(1L) + + index.sty package you can create extra indexes with extensions that you configure. Latexmk does not know how to deduce the extensions from the information it has. But you can easily write a custom dependency. For @@ -2882,18 +3002,6 @@ LATEXMK(1L) LATEXMK(1L) Of course if you choose to write random data to the .nnd (or and .aux file, etc) that changes on each new run, then you will have a problem. For real experts: See the %hash_cal_ignore_pattern if you have to deal - - - - 2 December 2013 40 - - - - - -LATEXMK(1L) LATEXMK(1L) - - with such problems. Glossaries can be dealt with similarly. @@ -2920,6 +3028,18 @@ OLD METHOD OF DEFINING CUSTOM DEPENDENCIES This method still works, and is equivalent to the earlier code using the add_cus_dep subroutine, except that it doesn't delete any previous custom-dependency for the same conversion. So the new method is + + + + 1 January 2015 46 + + + + + +LATEXMK(1L) LATEXMK(1L) + + preferable. @@ -2958,55 +3078,56 @@ USING latexmk WITH make 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. + OS-X systems. They may need modifications for other versions of make. + The simplest method is simply to delegate all the relevant tasks to + latexmk, 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- $< - 2 December 2013 41 + (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, + 1 January 2015 47 -LATEXMK(1L) LATEXMK(1L) - The simplest method is simply to delegate all the relevant tasks to - latexmk, 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- $< +LATEXMK(1L) LATEXMK(1L) + - (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 - latexmk is always run. It is latexmk that decides whether any action - is needed, e.g., a rerun of pdflatex. Effectively the Makefile dele- + 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 + latexmk is always run. It is latexmk that decides whether any action + is needed, e.g., a rerun of pdflatex. Effectively the Makefile dele- gates 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 + 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 custom dependencies configured in latexmk. - But something better is needed in more complicated situations, for - example, 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 + But something better is needed in more complicated situations, for + example, 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 following: TARGETS = document1.pdf document2.pdf @@ -3036,10 +3157,13 @@ LATEXMK(1L) LATEXMK(1L) 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 + .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 - 2 December 2013 42 + 1 January 2015 48 @@ -3048,9 +3172,6 @@ LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) LATEXMK(1L) - 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 output a dependency file after each run. It is given the -recorder option, which improves its detection of files generated during a run of @@ -3100,23 +3221,15 @@ THANKS TO their standard form to avoid being harvested by worms and viruses.) AUTHOR - Current version, by John Collins (username collins at node - phys.psu.edu). (Version 4.39). + Current version, by John Collins (username jcc8 at node psu.edu). + (Version 4.41). Released version can be obtained from CTAN: <http://www.ctan.org/tex- archive/support/latexmk/>, and from the author's website - <http://www.phys.psu.edu/~collins/software/latexmk/>. - Modifications and enhancements by Evan McLean (Version 2.0) - Original script called "go" by David J. Musliner (RCS Version 3.2) - - - - - - 2 December 2013 43 + 1 January 2015 49 @@ -3125,6 +3238,9 @@ AUTHOR LATEXMK(1L) LATEXMK(1L) + <http://www.phys.psu.edu/~collins/software/latexmk/>. + Modifications and enhancements by Evan McLean (Version 2.0) + Original script called "go" by David J. Musliner (RCS Version 3.2) @@ -3179,20 +3295,6 @@ LATEXMK(1L) LATEXMK(1L) - - - - - - - - - - - - - - - 2 December 2013 44 + 1 January 2015 50 diff --git a/Master/texmf-dist/scripts/latexmk/latexmk.pl b/Master/texmf-dist/scripts/latexmk/latexmk.pl index 95f302d82a1..1dbe4e7c00e 100755 --- a/Master/texmf-dist/scripts/latexmk/latexmk.pl +++ b/Master/texmf-dist/scripts/latexmk/latexmk.pl @@ -1,7 +1,14 @@ #!/usr/bin/env perl +# !!!!!!!!!! Don't forget to document $silence_logfile_warnings.!!! + # N.B. !!!!!!!!!!! See 17 July 2012 comments !!!!!!!!!!!!!!!!!! +# Re -cd issue !!!!!!!!!!!!! SEE "??!!" COMMENTS. +# If relative path is given for $out_dir or $aux_dir, and -cd is +# used, should it be interpreted w.r.t. initial cwd (i.e., cwd when +# latexmk is started), or w.r.t. to document directory??????? +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # On a UNIX-like system, the above enables latexmk to run independently # of the location of the perl executable. This line relies on the @@ -111,12 +118,13 @@ use warnings; $my_name = 'latexmk'; $My_name = 'Latexmk'; -$version_num = '4.39'; -$version_details = "$My_name, John Collins, 10 Nov 2013"; +$version_num = '4.41'; +$version_details = "$My_name, John Collins, 1 January 2015"; use Config; use File::Basename; use File::Copy; +use Cwd 'abs_path'; use File::Glob ':glob'; # Better glob. Does not use space as item separator. use File::Path 2.08 qw( make_path ); use FileHandle; @@ -147,8 +155,8 @@ else { warn "Something wrong with the perl configuration: No signals?\n"; } -## Copyright John Collins 1998-2013 -## (username collins at node phys.psu.edu) +## Copyright John Collins 1998-2015 +## (username jcc8 at node psu.edu) ## (and thanks to David Coppit (username david at node coppit.org) ## for suggestions) ## Copyright Evan McLean @@ -184,6 +192,50 @@ else { ## Modification log from 9 Dec 2011 onwards in detail ## ## 12 Jan 2012 STILL NEED TO DOCUMENT some items below +## +## 1 Jan 2015 John Collins V. 4.41 +## 18 Dec 2014 John Collins -c also deletes $deps_file if it is used. +## 16 Dec 2014 John Collins Finish change of e-mail +## 5 Dec 2014 John Collins Quote jobname when needed. +## 5 Sep 2014 John Collins Change my e-mail +## 30 Aug 2014 John Collins Change my e-mail +## 13 Aug 2014 John Collins Try to correct error handling to avoid +## repeated runs of latex after an error. +## Revert to some code from v. 4-32. +## Do I need $retry_msg? +## 8 Aug 2014 John Collins Fix up for the making of -eps-converted-to.pdf +## 4 Aug 2014 John Collins Sort and remove redundant xxx-undefined +## warning lines from log file. +## 23 Jul 2014 John Collins Fix failure when using both -cd and -output-directory +## 22 Jul 2014 John Collins If $HOME not set, then don't read ~/.latexmkrc +## Introduce $silence_logfile_warnings +## 21 Jul 2014 John Collins In setting $pscmd, allow for non-existent +### $ENV{USER} +## 29 May 2014 John Collins Correct sub Run for internal cmd w/o arguments +## 21 Mar 2014 John Collins Experimental: Add analysis hook for aux file. +## But I need to change rdb_create_rule in someway to +## allow correct handling of: (a) rule creation if +## rule doesn't exist, (b) either no change, or rule +## update, if the rule exists. No change is a bad +## idea, because conditions may change. Such a +## change, to effectively rdb_ensure_rule, would also +## help other dependencies, e.g., if a custom +## dependency has been created on one run of latexmk, +## and then on another run the definition is changed. +## With the old method, the old cus-dep is used unless +## the dependency cache fdb_latexmk is cleared; but +## with the new method the custom dependency will be +## changed correctly. +## 5 Mar 2014 John Collins System initialization files: allow them +## to be named latexmkrc as well as LatexMk, +## for more consistency with user directory +## names. Keep both cases, to preserve +## backward compatibility. +## 30 Jan 2014 John Collins Change sign-on message. Bug report info with help. V. 4.40a +## 15 Jan 2014 John Collins Fix failure to clean up correctly when +## root filename contains [, which is +## a glob metacharacter. +## V. 4.40 ## 10 Nov 2013 John Collins Change split / /, ... to split /\s*/, ... ## so as to be immune from extra white space. ## Clean up $clean_ext and $clean_full_ext by removing @@ -361,6 +413,17 @@ $log_wrap = 79; # (Documentation obviously needs to be improved!) %extra_rule_spec = (); + +# Hooks for customized extra processing on aux files. The following +# variable is an array of references to function. Each function is +# invoked in turn when a line of an aux file is processed (if none +# of the built-in actions have been done). On entry to the function, +# the following variables are set: +# $_ = current line of aux file +# $rule = name of rule during the invocation of which, the aux file +# was supposed to have been generated. +@aux_hooks = (); + ######################################################################### ## Default document processing programs, and related settings, ## These are mostly the same on all systems. @@ -620,6 +683,8 @@ $quote_filenames = 1; # Quote filenames in external commands $del_dir = ''; # Directory into which cleaned up files are to be put. # If $del_dir is '', just delete the files +@rc_system_files = (); + ######################################################################### ################################################################ @@ -665,6 +730,14 @@ $MSWin_fudge_break = 1; # Give special treatment to ctrl/C and ctrl/break # System-dependent overrides: +# Currently, the cases I have tests for are: MSWin32, cygwin, linux and +# darwin, with the main complications being for MSWin32 and cygwin. +# Special treatment may also be useful for MSYS (for which $^O reports +# "msys"). This is another *nix-emulation/system for MSWindows. At +# present it is treated as unix-like, but the environment variables +# are those of Windows. (The test for USERNAME as well as USER was +# to make latexmk work under MSYS's perl.) +# if ( $^O eq "MSWin32" ) { # Pure MSWindows configuration ## Configuration parameters: @@ -676,7 +749,7 @@ if ( $^O eq "MSWin32" ) { ## List of possibilities for the system-wide initialization file. ## The first one found (if any) is used. - @rc_system_files = ( 'C:/latexmk/LatexMk' ); + @rc_system_files = ( "C:/latexmk/LatexMk", "C:/latexmk/latexmkrc" ); $search_path_separator = ';'; # Separator of elements in search_path @@ -776,15 +849,19 @@ elsif ( $^O eq "cygwin" ) { ## List of possibilities for the system-wide initialization file. ## The first one found (if any) is used. ## We could stay with MSWin files here, since cygwin perl understands them - ## @rc_system_files = ( 'C:/latexmk/LatexMk' ); + ## @rc_system_files = ( 'C:/latexmk/LatexMk', 'C:/latexmk/latexmkrc' ); ## But they are deprecated in v. 1.7. So use the UNIX version, prefixed ## with a cygwin equivalent of the MSWin location - @rc_system_files = - ( '/cygdrive/c/latexmk/LatexMk', - '/opt/local/share/latexmk/LatexMk', - '/usr/local/share/latexmk/LatexMk', - '/usr/local/lib/latexmk/LatexMk' ); - + ## In addition, we need to add the same set of possible locations as with + ## unix, so that the user use a unix-style setup. + @rc_system_files = (); + foreach ( 'LatexMk', 'latexmkrc' ) { + push @rc_system_files, + ( "/cygdrive/c/latexmk/$_", + "/opt/local/share/latexmk/$_", + "/usr/local/share/latexmk/$_", + "/usr/local/lib/latexmk/$_" ); + } $search_path_separator = ';'; # Separator of elements in search_path # This is tricky. The search_path_separator depends on the kind # of executable: native NT v. cygwin. @@ -852,13 +929,15 @@ else { ## The first one found (if any) is used. ## Normally on a UNIX it will be in a subdirectory of /opt/local/share or ## /usr/local/share, depending on the local conventions. - ## /usr/local/lib/latexmk/LatexMk is put in the list for + ## But /usr/local/lib/latexmk is put in the list for ## compatibility with older versions of latexmk. - @rc_system_files = - ( '/opt/local/share/latexmk/LatexMk', - '/usr/local/share/latexmk/LatexMk', - '/usr/local/lib/latexmk/LatexMk' ); - + @rc_system_files = (); + foreach ( 'LatexMk', 'latexmkrc' ) { + push @rc_system_files, + ( "/opt/local/share/latexmk/$_", + "/usr/local/share/latexmk/$_", + "/usr/local/lib/latexmk/$_" ); + } $search_path_separator = ':'; # Separator of elements in search_path $dvi_update_signal = $signo{USR1} @@ -919,10 +998,21 @@ else { # # The following works on Solaris, LINUX, HP-UX, IRIX # Use -f to get full listing, including command line arguments. - # Use -u $ENV{CMD} to get all processes started by current user (not just + # Use -u $ENV{USER} to get all processes started by current user (not just # those associated with current terminal), but none of other users' # processes. - $pscmd = "ps -f -u $ENV{USER}"; + # However, the USER environment variable may not exist. Windows uses + # USERNAME instead. (And this propagates to a situation of + # unix-emulation software running under Windows.) + if ( exists $ENV{USER} ) { + $pscmd = "ps -f -u $ENV{USER}"; + } + elsif ( exists $ENV{USERNAME} ) { + $pscmd = "ps -f -u $ENV{USERNAME}"; + } + else { + $pscmd = "ps -f"; + } $pid_position = 1; # offset of PID in output of pscmd; first item is 0. if ( $^O eq "linux" ) { # Ps on Redhat (at least v. 7.2) appears to truncate its output @@ -974,12 +1064,12 @@ $max_repeat = 5; # Maximum times I repeat latex. Normally # occur, which mess up page numbers in the toc and lof, # Hence a 4th run is conceivably necessary. # At least one document class (JHEP.cls) works - # in such a way that a 4th run is needed. + # in such a way that a 4th run is needed. # We allow an extra run for safety for a - # maximum of 5. Needing further runs is - # usually an indication of a problem; further - # runs may not resolve the problem, and - # instead could cause an infinite loop. + # maximum of 5. Needing further runs is + # usually an indication of a problem; further + # runs may not resolve the problem, and + # instead could cause an infinite loop. $clean_ext = ""; # space separated extensions of files that are # to be deleted when doing cleanup, beyond # standard set @@ -1007,7 +1097,7 @@ $texfile_search = ""; # Specification for extra files to search for # backward compatibility. $fdb_ext = 'fdb_latexmk'; # Extension for the file for latexmk's - # file-database + # file-database # Make it long to avoid possible collisions. $fdb_ver = 3; # Version number for kind of fdb_file. @@ -1025,8 +1115,9 @@ $aux_dir = ''; # Directory for aux files (log, aux, etc). ## default flag settings. $recorder = 1; # Whether to use recorder option on latex/pdflatex -$silent = 0; # silence latex's messages? -$landscape_mode = 0; # default to portrait mode +$silent = 0; # Silence latex's messages? +$silence_logfile_warnings = 0; # Do list warnings in log file +$landscape_mode = 0; # default to portrait mode # The following two arrays contain lists of extensions (without # period) for files that are read in during a (pdf)LaTeX run but that @@ -1062,7 +1153,7 @@ $pdf_mode = 0; # No pdf file requested to be made by pdflatex # 2 to create pdf file by ps2pdf # 3 to create pdf file by dvipdf $view = 'default'; # Default preview is of highest of dvi, ps, pdf -$sleep_time = 2; # time to sleep b/w checks for file changes in -pvc mode +$sleep_time = 2; # time to sleep b/w checks for file changes in -pvc mode $banner = 0; # Non-zero if we have a banner to insert $banner_scale = 220; # Original default scale $banner_intensity = 0.95; # Darkness of the banner message @@ -1075,9 +1166,9 @@ $dependents_phony = 0; # Whether list(s) of dependencies includes phony targets $deps_file = '-'; # File for dependency list output. Default stdout. $rules_list = 0; # Whether to display list(s) of dependencies @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 - # to native MSWin path when cygwin is used. + # pointer to array [ cwd, good_cwd ], where + # good_cwd differs from cwd by being converted + # to native MSWin path when cygwin is used. $cleanup_mode = 0; # No cleanup of nonessential LaTex-related files. # $cleanup_mode = 0: no cleanup # $cleanup_mode = 1: full cleanup @@ -1092,8 +1183,8 @@ $cleanup_includes_cusdep_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 +$dvi_filter = ''; # DVI filter command +$ps_filter = ''; # Postscript filter command $force_mode = 0; # =1 to force processing past errors $go_mode = 0; # =1 to force processing regardless of time-stamps @@ -1124,6 +1215,7 @@ $waiting = 0; # Flags whether we are in loop waiting for an event # Used for some results of parsing log file: $reference_changed = 0; +$mult_defined = 0; $bad_reference = 0; $bad_citation = 0; @@ -1280,7 +1372,7 @@ if (!$BIBINPUTS) { $BIBINPUTS = '.'; } # Rule data: # 0: [ cmd_type, ext_cmd, int_cmd, test_kind, # source, dest, base, - # out_of_date, out_of_date_user, + # out_of_date, out_of_date_user, # time_of_last_run, time_of_last_file_check, # changed # last_result, last_message, @@ -1290,57 +1382,57 @@ if (!$BIBINPUTS) { $BIBINPUTS = '.'; } # cmd_type is 'primary', 'external', or 'cusdep' # ext_cmd is string for associated external command # 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, %O for options, + # for source, %B for base of current rule, + # %R for base of primary tex file, %T for + # 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 - # the external command, and it is the - # responsibility of the perl subroutine - # specified in intcmd to execute the - # external command if this is appropriate. - # This variable intcmd is a reference to an array, + # used to implement the application of the + # rule. If this is present, it overrides + # the external command, and it is the + # responsibility of the perl subroutine + # specified in intcmd to execute the + # external command if this is appropriate. + # This variable intcmd is a reference to an array, # $$intcmd[0] = internal routine # $$intcmd[1...] = its arguments (if any) # test_kind specifies method of determining # whether a file is out-of-date: # 0 for never # 1 for usual: whether there is a source - # file change + # file change # 2 for dest earlier than source # 3 for method 2 at first run, 1 thereafter # (used when don't have file data from - # previous run). + # previous run). # source = name of primary source file, if any # dest = name of primary destination file, - # if any + # if any # base = base name, if any, of files for - # this rule + # this rule # out_of_date = 1 if it has been detected that - # this rule needs to be run - # (typically because a source - # file has changed). + # this rule needs to be run + # (typically because a source + # file has changed). # 0 otherwise # out_of_date_user is like out_of_date, except # that the detection of out-of-dateness # has been made from a change of a - # putative user file, i.e., one that is - # not a generated file (e.g., aux). This - # kind of out-of-dateness should provoke a - # rerun whether or not there was an error - # during a run of (pdf)LaTeX. Normally, - # if there is an error, one should wait - # for the user to correct the error. But - # it is possible the error condition is - # already corrected during the run, e.g., - # by the user changing a source file in - # response to an error message. + # putative user file, i.e., one that is + # not a generated file (e.g., aux). This + # kind of out-of-dateness should provoke a + # rerun whether or not there was an error + # during a run of (pdf)LaTeX. Normally, + # if there is an error, one should wait + # for the user to correct the error. But + # it is possible the error condition is + # already corrected during the run, e.g., + # by the user changing a source file in + # response to an error message. # time_of_last_run = time that this rule was - # last applied. (In standard units - # from perl, to be directly compared - # with file modification times.) + # last applied. (In standard units + # from perl, to be directly compared + # with file modification times.) # time_of_last_file_check = last time that a check # was made for changes in source files. # changed flags whether special changes have been made @@ -1445,8 +1537,10 @@ if ( $auto_rc_use ) { # System rc file: read_first_rc_file_in_list( @rc_system_files ); } -if ( $auto_rc_use ) { +if ( $auto_rc_use && ($HOME ne "" ) ) { # User rc file: + # N.B. $HOME equals "" if latexmk couldn't determine a home directory. + # In that case, we shouldn't look for an rc file there. read_first_rc_file_in_list( "$HOME/.latexmkrc" ); } if ( $auto_rc_use ) { @@ -1508,10 +1602,14 @@ while ($_ = $ARGV[0]) push @extra_latex_options, $1; push @extra_pdflatex_options, $1; } + elsif ( /^-logfilewarninglist$/ || /^-logfilewarnings$/ ) + { $silence_logfile_warnings = 0; } + elsif ( /^-logfilewarninglist-$/ || /^-logfilewarnings-$/ ) + { $silence_logfile_warnings = 1; } # See above for -M elsif (/^-MF$/) { if ( $ARGV[0] eq '' ) { - &exit_help( "No file name specified after -MF switch"); + &exit_help( "No file name specified after -MF switch"); } $deps_file = $ARGV[0]; shift; @@ -1629,37 +1727,37 @@ while ($_ = $ARGV[0]) &exit_help( "No RC file specified after -r switch"); } if ( -e $ARGV[0] ) { - process_rc_file( $ARGV[0] ); + process_rc_file( $ARGV[0] ); } else { - die "$My_name: RC file [$ARGV[0]] does not exist\n"; + die "$My_name: RC file [$ARGV[0]] does not exist\n"; } shift; } elsif (/^-bm$/) { if ( $ARGV[0] eq '' ) { - &exit_help( "No message specified after -bm switch"); + &exit_help( "No message specified after -bm switch"); } $banner = 1; $banner_message = $ARGV[0]; shift; } elsif (/^-bi$/) { if ( $ARGV[0] eq '' ) { - &exit_help( "No intensity specified after -bi switch"); + &exit_help( "No intensity specified after -bi switch"); } $banner_intensity = $ARGV[0]; shift; } elsif (/^-bs$/) { if ( $ARGV[0] eq '' ) { - &exit_help( "No scale specified after -bs switch"); + &exit_help( "No scale specified after -bs switch"); } $banner_scale = $ARGV[0]; shift; } elsif (/^-dF$/) { if ( $ARGV[0] eq '' ) { - &exit_help( "No dvi filter specified after -dF switch"); + &exit_help( "No dvi filter specified after -dF switch"); } $dvi_filter = $ARGV[0]; shift; @@ -1692,17 +1790,30 @@ if ( $bad_options > 0 ) { } 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; } +# Initially $aux_dir and $out_dir are either absolute or relative to CURRENT +# directory. +# If we'll cd to directory of TeX file to do our work, we'll need to convert +# any relative directories to absolute, to preserve the user-requested +# directories after a cd. +# Otherwise, we need to normalize them in our standard way (to ensure +# standardization in the places we use them. + + foreach ($out_dir, $aux_dir) { - # Remove aliases to cwd: - $_ = normalize_filename( $_ ); - if ($_ eq '.' ) { $_ = ''; } + if ($do_cd) { + $_ = abs_path( $_ ); + } + else { + # Remove aliases to cwd: + $_ = normalize_filename( $_ ); + if ($_ eq '.' ) { $_ = ''; } + } } # Versions terminating in directory/path separator $out_dir1 = $out_dir; @@ -1725,7 +1836,7 @@ foreach ( 'BIBINPUTS' ) { $ENV{$_} = $aux_dir.$search_path_separator.$ENV{$_}; } else { - $ENV{$_} = $aux_dir.$search_path_separator; + $ENV{$_} = $aux_dir.$search_path_separator; } } @@ -1792,13 +1903,13 @@ else { # Make hash of excluded files, for easy checking: my %excl = (); foreach my $file (@excluded_file_list) { - $excl{$file} = ''; + $excl{$file} = ''; } foreach my $file (@file_list1) { - push( @file_list, $file) unless ( exists $excl{$file} ); + push( @file_list, $file) unless ( exists $excl{$file} ); } if ( !@file_list ) { - &exit_help( "No file name specified, and I couldn't find any"); + &exit_help( "No file name specified, and I couldn't find any"); } } @@ -1881,11 +1992,16 @@ if ( $recorder ) { add_option( "-recorder", \$latex, \$pdflatex ); } +# If the output and/or aux directories are specified: Fix the (pdf)latex +# commands to use them, and ensure that the directories exist. +# N.B. We are immune against cd'ing to directory of TeX file, because in +# that case we have forced the directories to be absolute. + if ( $out_dir ) { add_option( "-output-directory=\"$out_dir\"", \$latex, \$pdflatex ); if ( ! -e $out_dir ) { warn "$My_name: making output directory '$out_dir'\n" - if ! $silent; + if ! $silent; make_path $out_dir; } elsif ( ! -d $out_dir ) { @@ -1902,7 +2018,7 @@ if ( $aux_dir && ($aux_dir ne $out_dir) ) { add_option( "-aux-directory=\"$aux_dir\"", \$latex, \$pdflatex ); if ( ! -e $aux_dir ) { warn "$My_name: making auxiliary directory '$aux_dir'\n" - if ! $silent; + if ! $silent; make_path $aux_dir; } elsif ( ! -d $aux_dir ) { @@ -1913,7 +2029,7 @@ if ( $aux_dir && ($aux_dir ne $out_dir) ) { } if ( $jobname ne '' ) { - $jobstring = "--jobname=$jobname"; + $jobstring = "--jobname=\"$jobname\""; add_option( "$jobstring", \$latex, \$pdflatex ); } @@ -1965,7 +2081,7 @@ if ($print_type eq 'auto') { if ( $printout_mode ) { $one_time{'print'} = 1; if ($print_type eq 'none'){ - warn "$My_name: You have requested printout, but \$print_type is set to 'none'\n"; + warn "$My_name: You have requested printout, but \$print_type is set to 'none'\n"; } } if ( $preview_continuous_mode || $preview_mode ) { $one_time{'view'} = 1; } @@ -2010,15 +2126,15 @@ if ($aux_dir) { # Ensure $aux_dir is in TEXINPUTS search path. # This is used by dvips for files generated by mpost. if ( ! exists $ENV{TEXINPUTS} ) { - # Note the trailing ":" which ensures that the last item - # in the list of paths is the empty path, which actually - # means the default path, i.e., the following means that - # the TEXINPUTS search path is $aux_dir and the standard - # value. - $ENV{TEXINPUTS} = $aux_dir.$search_path_separator; + # Note the trailing ":" which ensures that the last item + # in the list of paths is the empty path, which actually + # means the default path, i.e., the following means that + # the TEXINPUTS search path is $aux_dir and the standard + # value. + $ENV{TEXINPUTS} = $aux_dir.$search_path_separator; } elsif ( $ENV{TEXINPUTS} !~ /$aux_dir$search_path_separator/ ) { - $ENV{TEXINPUTS} = $aux_dir.$search_path_separator.$ENV{TEXINPUTS}; + $ENV{TEXINPUTS} = $aux_dir.$search_path_separator.$ENV{TEXINPUTS}; } } @@ -2067,21 +2183,21 @@ foreach $filename ( @file_list ) pushd( $path ); } else { - $path = ''; + $path = ''; } ## remove extension from filename if was given. if ( &find_basename($filename, $root_filename, $texfile_name) ) { - if ( $force_mode ) { - warn "$My_name: Could not find file [$texfile_name]\n"; - } - else { + if ( $force_mode ) { + warn "$My_name: Could not find file [$texfile_name]\n"; + } + else { &ifcd_popd; - &exit_msg1( "Could not find file [$texfile_name]", - 11); - } + &exit_msg1( "Could not find file [$texfile_name]", + 11); + } } if ($jobname ne '' ) { $root_filename = $jobname; @@ -2120,11 +2236,11 @@ foreach $filename ( @file_list ) $base = $path.$base; if ( $rule =~ /^makeindex/ ) { push @index_bibtex_generated, $$Psource, $$Pdest, "$base.ilg"; - } + } elsif ( $rule =~ /^(bibtex|biber)/ ) { push @index_bibtex_generated, $$Pdest, "$base.blg"; push @aux_files, $$Psource; - } + } elsif ( exists $other_generated{$$Psource} ) { $other_generated{$$Pdest}; } @@ -2140,24 +2256,24 @@ foreach $filename ( @file_list ) 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. - local %idx_files = (); # Maps idx_file to (ind_file, base). Not used here. - local %conversions = (); # (pdf)latex-performed conversions. Not used here. - # Maps output file created and read by (pdf)latex - # to source file of conversion. - local $primary_out = ''; # Actual output file (dvi or pdf). Not used here. + local %dependents = (); # Maps files to status. Not used here. + local @bbl_files = (); # Not used here. + local %idx_files = (); # Maps idx_file to (ind_file, base). Not used here. + local %conversions = (); # (pdf)latex-performed conversions. Not used here. + # Maps output file created and read by (pdf)latex + # to source file of conversion. + local $primary_out = ''; # Actual output file (dvi or pdf). Not used here. &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; - } + } if ($bibtex_use < 2) { delete $generated_exts_all{'bbl'}; } @@ -2165,14 +2281,14 @@ foreach $filename ( @file_list ) my %index_bibtex_generated = (); my %aux_files = (); foreach (@index_bibtex_generated) { - $index_bibtex_generated{$_} = 1 + $index_bibtex_generated{$_} = 1 unless ( /\.bbl$/ && ($bibtex_use < 2) ); delete( $other_generated{$_} ); - } + } foreach (@aux_files) { $aux_files{$_} = 1; delete( $other_generated{$_} ); - } + } if ($diagnostics) { show_array( "For deletion, the following were determined from fdb file or log file:\n" ." Generated (from makeindex and bibtex):", @@ -2181,7 +2297,9 @@ foreach $filename ( @file_list ) show_array( " Other generated files:\n" ." (only deleted if \$cleanup_includes_generated is set): ", keys %other_generated ); - } + show_array( " Yet other generated files:\n", + keys %generated_exts_all ); + } &cleanup1( $aux_dir1, $fdb_ext, 'blg', 'ilg', 'log', 'aux.bak', 'idx.bak', split('\s+',$clean_ext), keys %generated_exts_all @@ -2189,12 +2307,15 @@ foreach $filename ( @file_list ) unlink_or_move( 'texput.log', "texput.aux", keys %index_bibtex_generated, keys %aux_files ); + if ( $dependents_list && ( $deps_file ne '-' ) ) { + unlink_or_move( $deps_file ); + } if ($cleanup_includes_generated) { - unlink_or_move( keys %other_generated ); - } + unlink_or_move( keys %other_generated ); + } if ( $cleanup_includes_cusdep_generated) { - &cleanup_cusdep_generated; - } + &cleanup_cusdep_generated; + } if ( $cleanup_mode == 1 ) { &cleanup1( $out_dir1, 'dvi', 'dviF', 'ps', 'psF', 'pdf', split('\s+', $clean_full_ext) @@ -2254,12 +2375,12 @@ foreach $filename ( @file_list ) # previous run. So use filetime criterion for make # instead of change from previous run, until we have # done our own make. - rdb_recurse( [keys %possible_primaries], - sub{ if ( $$Ptest_kind == 1 ) { $$Ptest_kind = 3;} } + rdb_recurse( [keys %possible_primaries], + sub{ if ( $$Ptest_kind == 1 ) { $$Ptest_kind = 3;} } ); if ( -e $log_name ) { - rdb_for_some( [keys %possible_primaries], \&rdb_set_latex_deps ); - } + rdb_for_some( [keys %possible_primaries], \&rdb_set_latex_deps ); + } } foreach $rule ( rdb_accessible( uniq1( keys %requested_filerules ) ) ){ # For all source files of all accessible rules, @@ -2267,12 +2388,12 @@ foreach $filename ( @file_list ) # file, set them from disk. rdb_one_rule ($rule, undef, sub{ if ( $$Ptime == 0) { &rdb_update1; } } - ); + ); } if ($go_mode) { # Force everything to be remade. - rdb_recurse( [keys %requested_filerules], sub{$$Pout_of_date=1;} ); + rdb_recurse( [keys %requested_filerules], sub{$$Pout_of_date=1;} ); } @@ -2443,16 +2564,16 @@ sub rdb_make_rule_list { my $print_file = ''; my $print_cmd = 'NONE'; if ( $print_type eq 'dvi' ) { - $print_file = $dvi_final; - $print_cmd = $lpr_dvi; + $print_file = $dvi_final; + $print_cmd = $lpr_dvi; } elsif ( $print_type eq 'pdf' ) { - $print_file = $pdf_final; - $print_cmd = $lpr_pdf; + $print_file = $pdf_final; + $print_cmd = $lpr_pdf; } elsif ( $print_type eq 'ps' ) { - $print_file = $ps_final; - $print_cmd = $lpr; + $print_file = $ps_final; + $print_cmd = $lpr; } elsif ( $print_type eq 'none' ) { $print_cmd = 'NONE echo NO PRINTING CONFIGURED'; @@ -2510,30 +2631,30 @@ sub rdb_set_rules { %rule_db = (); foreach my $Prule_list (@_) { - foreach my $rule ( keys %$Prule_list) { - my ( $cmd_type, $ext_cmd, $int_cmd, $source, $dest, $base, $test_kind, $PA_extra_gen ) = @{$$Prule_list{$rule}}; + foreach my $rule ( keys %$Prule_list) { + my ( $cmd_type, $ext_cmd, $int_cmd, $source, $dest, $base, $test_kind, $PA_extra_gen ) = @{$$Prule_list{$rule}}; if ( ! $PA_extra_gen ) { $PA_extra_gen = []; } - my $needs_making = 0; - # Substitute in the filename variables, since we will use - # those for determining filenames. But delay expanding $cmd - # 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/; - s/%T/$texfile_name/; - } + my $needs_making = 0; + # Substitute in the filename variables, since we will use + # those for determining filenames. But delay expanding $cmd + # 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/; + s/%T/$texfile_name/; + } # print "$rule: $cmd_type, EC='$ext_cmd', IC='$int_cmd', $test_kind,\n", # " S='$source', D='$dest', B='$base' $needs_making\n"; - rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $test_kind, - $source, $dest, $base, - $needs_making, undef, undef, 1, $PA_extra_gen ); + rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $test_kind, + $source, $dest, $base, + $needs_making, undef, undef, 1, $PA_extra_gen ); # !! ?? Last line was -# $needs_making, undef, ($test_kind==1) ); - } +# $needs_making, undef, ($test_kind==1) ); + } } # End arguments of subroutine &rdb_make_links; } # END rdb_set_rules @@ -2558,7 +2679,7 @@ sub rdb_make_links { ) { $$Pfrom_rule = $from_rules{$file}; } - } + } ); rdb_for_all( 0, @@ -2568,9 +2689,9 @@ sub rdb_make_links { } if ( $$Pfrom_rule && (! rdb_rule_exists( $$Pfrom_rule ) ) ) { $$Pfrom_rule = ''; - } + } #?? print "$rule: $file, $$Pfrom_rule\n"; - } + } ); } # END rdb_make_links @@ -2615,12 +2736,12 @@ sub do_cusdep { if ( !-e $$Psource ) { # Source does not exist. Users of this rule will need to turn # it off when custom dependencies are reset - if ( !$silent ) { + if ( !$silent ) { ## ??? Was commented out. 1 Sep. 2008 restored, for cusdep no-file-exists issue warn "$My_name: In trying to apply custom-dependency rule\n", " to make '$$Pdest' from '$$Psource'\n", " the source file has disappeared since the last run\n"; - } + } # Treat as successful } elsif ( !$func_name ) { @@ -2636,21 +2757,21 @@ sub do_cusdep { " function name '$func_name' does not exists.\n"; } else { - my $cusdep_ret = &$func_name( $$Pbase ); + my $cusdep_ret = &$func_name( $$Pbase ); if ( defined $cusdep_ret && ($cusdep_ret != 0) ) { - $return = $cusdep_ret; - if ($return) { + $return = $cusdep_ret; + if ($return) { warn "Rule '$rule', function '$func_name'\n", " failed with return code = $return\n"; - } - } + } + } elsif ( !-e $$Pdest ) { # Destination non-existent, but routine failed to give an error warn "$My_name: In running custom-dependency rule\n", " to make '$$Pdest' from '$$Psource'\n", " function '$func_name' did not make the destination.\n"; - $return = -1; - } + $return = -1; + } } return $return; } # END do_cusdep @@ -2673,9 +2794,9 @@ sub do_viewfile { 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"; + " to set the destination file, so I won't use a temporary file\n"; $return = &Run_subst(); - } + } } else { $return = &Run_subst(); @@ -2701,12 +2822,12 @@ sub do_update_view { my $Pneed_to_get_viewer_process = \${$PAint_cmd}[4]; if ($viewer_update_method == 2) { - if ($$Pneed_to_get_viewer_process) { + if ($$Pneed_to_get_viewer_process) { $$Pviewer_process = &find_process_id( $$Psource ); if ($$Pviewer_process != 0) { $$Pneed_to_get_viewer_process = 0; - } - } + } + } if ($$Pviewer_process == 0) { print "$My_name: need to signal viewer for file '$$Psource', but didn't get \n", " process ID for some reason, e.g., no viewer, bad configuration, bug\n" @@ -2715,8 +2836,8 @@ sub do_update_view { elsif ( defined $viewer_update_signal) { print "$My_name: signalling viewer, process ID $$Pviewer_process\n" if $diagnostics ; - kill $viewer_update_signal, $$Pviewer_process; - } + kill $viewer_update_signal, $$Pviewer_process; + } else { warn "$My_name: viewer is supposed to be sent a signal\n", " but no signal is defined. Misconfiguration or bug?\n"; @@ -2726,7 +2847,7 @@ sub do_update_view { elsif ($viewer_update_method == 4) { if (defined $$Pext_cmd) { $return = &Run_subst(); - } + } else { warn "$My_name: viewer is supposed to be updated by running a command,\n", " but no command is defined. Misconfiguration or bug?\n"; @@ -2745,7 +2866,7 @@ sub if_source { } else { warn "Needed source file '$$Psource' does not exist.\n"; - return -1; + return -1; } } #END if_source @@ -2908,7 +3029,7 @@ CHANGE: $SIG{BREAK} = $SIG{INT} = 'IGNORE'; } if ($compiling_cmd) { - Run_subst( $compiling_cmd ); + Run_subst( $compiling_cmd ); } $failure = rdb_make( @targets ); @@ -2920,25 +3041,25 @@ CHANGE: # Start viewer if needed. if ( ($failure > 0) && (! $force_mode) ) { # No viewer yet - } + } elsif ( ($view_file ne '') && (-e $view_file) && $updated && $viewer_running ) { # A viewer is running. Explicitly get it to update screen if we have to do it: rdb_one_rule( 'update_view', \&rdb_run1 ); } elsif ( ($view_file ne '') && (-e $view_file) && !$viewer_running ) { # Start the viewer - if ( !$silent ) { + if ( !$silent ) { if ($new_viewer_always) { warn "$My_name: starting previewer for '$view_file'\n", "------------\n"; - } + } else { warn "$My_name: I have not found a previewer that ", "is already running. \n", " So I will start it for '$view_file'\n", "------------\n"; - } - } + } + } local $retcode = 0; rdb_one_rule( 'view', sub { $retcode = &rdb_run1;} ); if ( $retcode != 0 ) { @@ -2952,11 +3073,11 @@ CHANGE: else { $viewer_running = 1; $$Pneed_to_get_viewer_process = 1; - } # end analyze result of trying to run viewer + } # end analyze result of trying to run viewer } # end start viewer if ( $failure > 0 ) { if ( !$failure_msg ) { - $failure_msg = 'Failure to make the files correctly'; + $failure_msg = 'Failure to make the files correctly'; } @pre_primary = (); # Array of rules @post_primary = (); # Array of rules @@ -2978,12 +3099,12 @@ CHANGE: warn "$My_name: $failure_msg\n", " ==> You will need to change a source file before I do another run <==\n"; if ($failure_cmd) { - Run_subst( $failure_cmd ); + Run_subst( $failure_cmd ); } - } + } else { if ($success_cmd) { - Run_subst( $success_cmd ); + Run_subst( $success_cmd ); } } rdb_show_rule_errors(); @@ -2997,8 +3118,8 @@ CHANGE: } else { warn "Cannot open '$deps_file' for output of dependency information\n"; - } - } + } + } if ( $first_time || $updated || $failure ) { print "\n=== Watching for updated files. Use ctrl/C to stop ...\n"; } @@ -3011,24 +3132,24 @@ CHANGE: $have_break = 0; WAIT: while (1) { sleep( $sleep_time ); - if ($have_break) { last WAIT; } + if ($have_break) { last WAIT; } if ( rdb_new_changes(keys %rules_to_watch) ) { - if (!$silent) { + if (!$silent) { warn "$My_name: Need to remake files.\n"; - &rdb_diagnose_changes( ' ' ); - } + &rdb_diagnose_changes( ' ' ); + } last WAIT; - } + } # Don't count waiting time in processing: $processing_time1 = processing_time(); # Does this do this job???? local $new_files = 0; rdb_for_some( [keys %current_primaries], sub{ $new_files += &rdb_find_new_files } ); if ($new_files > 0) { - warn "$My_name: New file(s) found.\n"; + warn "$My_name: New file(s) found.\n"; last WAIT; - } - if ($have_break) { last WAIT; } + } + if ($have_break) { last WAIT; } } # end WAIT: &default_break; if ($have_break) { @@ -3078,7 +3199,7 @@ sub process_rc_file { # PREVIOUS VERSION # if ( ! -r $rc_file ) { # warn "$My_name: I cannot read the rc-file '$rc_file'\n", -# " or at least that's what Perl (for $^O) reports\n"; +# " or at least that's what Perl (for $^O) reports\n"; # return 1; # } # do( $rc_file ); @@ -3128,11 +3249,12 @@ sub execute_code_string { sub cleanup1 { # Usage: cleanup1( directory, exts_without_period, ... ) # - # The directory is a fixed name, so I must escape any glob metacharacters - # in it: + # 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.$_") =~ s/%R/$dir$root_filename/; + (my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/$dir$root_fixed/; unlink_or_move( glob( "$name" ) ); } } #END cleanup1 @@ -3295,6 +3417,10 @@ sub print_help " -latex=<program> - set program used for latex.\n", " (replace '<program>' by the program name)\n", " -latexoption=<option> - add the given option to the (pdf)latex command\n", + " -logfilewarninglist or -logfilewarnings \n", + " give list of warnings after run of (pdf)latex\n", + " -logfilewarninglist- or -logfilewarnings- \n", + " do not give list of warnings after run of (pdf)latex\n", " -M - Show list of dependent files after processing\n", " -MF file - Specifies name of file to receives list dependent files\n", " -MP - List of dependent files includes phony target for each source file.\n", @@ -3363,7 +3489,9 @@ sub print_help " \n", "In addition, latexmk recognizes many other options that are passed to\n", "latex and/or pdflatex without interpretation by latexmk. Run latexmk\n", - "with the option -showextraoptions to see a list of these\n"; + "with the option -showextraoptions to see a list of these\n", + "\n", + "Report bugs etc to John Collins <jcc8 at psu.edu>.\n"; } #END print_help @@ -3465,7 +3593,7 @@ sub check_biber_log { $error_count ++; if ( /> (FATAL|ERROR) - The file '[^']+' does not contain any citations!/ ) { #' $no_citations++; - } + } } } elsif ( /> INFO - Found .* '([^']+)'\s*$/ @@ -3474,16 +3602,16 @@ sub check_biber_log { || /> INFO - Reading (.*)$/ || /> INFO - Processing .* file '([^']+)' .*$/ ) { - if ( defined $Pbiber_source ) { + if ( defined $Pbiber_source ) { 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; @@ -3498,7 +3626,7 @@ sub check_biber_log { # 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; + return 5; } else { show_array( "$My_name: Failed to find one or more biber source files:", @@ -3509,7 +3637,7 @@ sub check_biber_log { } if ($control_file_missing) { return 6; - } + } return 4; } # print "$My_name: #Biber errors = $error_count, warning messages = $warning_count,\n ", @@ -3538,13 +3666,13 @@ sub run_bibtex { my ( $base, $path, $ext ) = fileparseA( $$Psource ); my $cwd = good_cwd(); foreach ( 'BIBINPUTS', 'BSTINPUTS' ) { - if ( exists $ENV{$_} ) { - $ENV{$_} = $cwd.$search_path_separator.$ENV{$_}; - } - else { - $ENV{$_} = $cwd.$search_path_separator; - } - } + if ( exists $ENV{$_} ) { + $ENV{$_} = $cwd.$search_path_separator.$ENV{$_}; + } + else { + $ENV{$_} = $cwd.$search_path_separator; + } + } pushd( $path ); $return = &Run_subst( undef, undef, '', $base.$ext, '', $base ); popd(); @@ -3553,7 +3681,7 @@ sub run_bibtex { warn "$My_name: Directory in file name '$$Psource' for bibtex\n", " but it is not the output directory '$aux_dir'\n"; $return = Run_subst(); - } + } } else { $return = Run_subst(); @@ -3590,10 +3718,10 @@ sub check_bibtex_log { } elsif ( /^I couldn\'t open auxiliary file (.*\.aux)/ ) { push @missing_aux, $1; - } + } elsif ( /^I found no \\citation commands---while reading file/ ) { $missing_citations++; - } + } elsif (/There (were|was) (\d+) error message/) { $error_count = $2; #print "Bibtex error: count=$error_count $_"; @@ -3694,8 +3822,8 @@ sub parse_log { my %cusdep_to = (); foreach ( @cus_dep_list ) { my ($fromext, $toext) = split; - $cusdep_from{$fromext} = $cusdep_from{".$fromext"} = $_; - $cusdep_to{$toext} = $cusdep_to{".$toext"} = $_; + $cusdep_from{$fromext} = $cusdep_from{".$fromext"} = $_; + $cusdep_to{$toext} = $cusdep_to{".$toext"} = $_; } # print "==== Cusdep from-exts:"; foreach (keys %cusdep_from) {print " '$_'";} print "\n"; # print "==== Cusdep to-exts:"; foreach (keys %cusdep_to) {print " '$_'";} print "\n"; @@ -3714,6 +3842,7 @@ sub parse_log { # a sensible default in case of misparsing $reference_changed = 0; + $mult_defined = 0; $bad_reference = 0; $bad_citation = 0; @@ -3765,44 +3894,46 @@ sub parse_log { # data structure until block is ended.) my %new_conversions = (); my @retries = (); + my $log_silent = ($silent || $silence_logfile_warnings); + my @warning_list = (); LINE: while( ($line <= $#lines) || ($#retries > -1) ) { if ($#retries > -1) { - $_ = pop @retries; - } - else { + $_ = pop @retries; + } + else { $_ = $lines[$line]; $line ++; - } + } if ( /^! pdfTeX warning/ || /^pdfTeX warning/ ) { # This kind of warning is produced by some versions of pdftex # or produced by my reparse of warnings from other # versions. next; - } + } elsif ( /^(.+)(pdfTeX warning.*)$/ ) { # Line contains a pdfTeX warnings that may have been # inserted directly after other material without an # intervening new line. I think pdfTeX always inserts a # newline after the warning. (From examination of source # code.) - push @retries, $1; + push @retries, $1; # But continue parsing the original line, in case it was a # misparse, e.g., of a filename ending in 'pdfTeX'; - } + } if ( $line == 1 ){ - if ( /^This is / ) { - # First line OK + if ( /^This is / ) { + # First line OK next LINE; } else { warn "$My_name: Error on first line of '$log_name'.\n". "This is apparently not a TeX log file. ", - "The first line is:\n$_\n"; + "The first line is:\n$_\n"; $failure = 1; $failure_msg = "Log file '$log_name' appears to have wrong format."; return 0; - } - } + } + } if ( $block_type ) { # In middle of parsing block if ( /^\($current_pkg\)/ ) { @@ -3810,146 +3941,152 @@ LINE: if ( ($block_type eq 'conversion') && /^\($current_pkg\)\s+Output file: <([^>]+)>/ ) { - $delegated_output = normalize_clean_filename($1); + $delegated_output = normalize_clean_filename($1); } - next LINE; - } + next LINE; + } # Block has ended. if ($block_type eq 'conversion') { +print "=== $delegated_source -> $delegated_output\n"; $new_conversions{$delegated_source} = $delegated_output; - } + } $current_pkg = $block_type = $delegated_source = $delegated_output = ""; # Then process current line - } + } + # Check for changed references, bad references and bad citations: if (/Rerun to get/) { - warn "$My_name: References changed.\n" if ! $silent; + warn "$My_name: References changed.\n" if ! $log_silent; $reference_changed = 1; } - if (/LaTeX Warning: (Reference[^\001]*undefined)./) { - warn "$My_name: $1 \n" unless $silent; - $bad_reference++; - } - if (/LaTeX Warning: (Citation[^\001]*undefined)./) { - warn "$My_name: $1 \n" unless $silent; - $bad_citation++; - } - if (/Package natbib Warning: (Citation[^\001]*undefined)./) { - warn "$My_name: $1 \n" unless $silent; + if (/^LaTeX Warning: (Reference[^\001]*undefined on input line .*)\./) { + push @warning_list, $1; + $bad_reference++; + } + elsif (/^LaTeX Warning: (Label [^\001]* multiply defined.*)\./) { + push @warning_list, $1; + $mult_defined++; + } + elsif (/^LaTeX Warning: (Citation[^\001]*undefined on input line .*)\./) { + push @warning_list, $1; $bad_citation++; - } - if ( /^Document Class: / ) { - # Class sign-on line - next LINE; - } - if ( /^\(Font\)/ ) { - # Font info line - next LINE; - } - if (/^No pages of output\./) { + } + elsif (/^Package natbib Warning: (Citation[^\001]*undefined on input line .*)\./) { + push @warning_list, $1; + $bad_citation++; + } + elsif ( /^Document Class: / ) { + # Class sign-on line + next LINE; + } + elsif ( /^\(Font\)/ ) { + # Font info line + next LINE; + } + elsif (/^No pages of output\./) { $primary_out = ''; - warn "$My_name: Log file says no output from latex\n"; - next LINE; - } - if ( /^Output written on\s+(.*)\s+\(\d+\s+page/ ) { + warn "$My_name: Log file says no output from latex\n"; + next LINE; + } + elsif ( /^Output written on\s+(.*)\s+\(\d+\s+page/ ) { $primary_out = normalize_clean_filename($1); - warn "$My_name: Log file says output to '$primary_out'\n" - unless $silent; - next LINE; - } - if ( /^Overfull / - || /^Underfull / + warn "$My_name: Log file says output to '$primary_out'\n" + unless $silent; + next LINE; + } + elsif ( /^Overfull / + || /^Underfull / || /^or enter new name\. \(Default extension: .*\)/ || /^\*\*\* \(cannot \\read from terminal in nonstop modes\)/ ) { - # Latex error/warning, etc. - next LINE; - } - if ( /^\\openout\d+\s*=\s*\`([^\']+)\'\.$/ ) { + # Latex error/warning, etc. + next LINE; + } + elsif ( /^\\openout\d+\s*=\s*\`([^\']+)\'\.$/ ) { # 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{normalize_force_directory( $aux_dir1, $1 )} = 1; - next LINE; - } + next LINE; + } # Test for conversion produced by package: - if ( /^Package (\S+) Info: Source file: <([^>]+)>/ ) { - # Info. produced by epstopdf (and possibly others) + elsif ( /^Package (\S+) Info: Source file: <([^>]+)>/ ) { + # Info. produced by epstopdf (and possibly others) # about file conversion $current_pkg = normalize_clean_filename($1); $delegated_source = normalize_clean_filename($2); $block_type = 'conversion'; - next LINE; - } + 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. - if ( /Writing index file (.*)$/ ) { + elsif ( /Writing index file (.*)$/ ) { my $idx_file = ''; - if ( /^Writing index file (.*)$/ ) { + if ( /^Writing index file (.*)$/ ) { # From makeidx.sty or multind.sty $idx_file = $1; - } + } elsif ( /^index\.sty> Writing index file (.*)$/ ) { # From old versions of index.sty $idx_file = $1; - } + } elsif ( /^Package \S* Info: Writing index file (.*) on input line/ ) { # From new versions of index.sty $idx_file = $1; - } + } else { - warn "$My_name: Message indicates index file was written\n", - " ==> but I do not know how to understand it: <==\n", - " '$_'\n"; + warn "$My_name: Message indicates index file was written\n", + " ==> but I do not know how to understand it: <==\n", + " '$_'\n"; next LINE; - } - # Typically, there is trailing space, not part of filename: - $idx_file =~ s/\s*$//; + } + # Typically, there is trailing space, not part of filename: + $idx_file =~ s/\s*$//; # 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 = normalize_force_directory( $aux_dir1, $idx_file ); - my ($idx_base, $idx_path, $idx_ext) = fileparseA( $idx_file ); - $idx_base = $idx_path.$idx_base; + $idx_file = normalize_force_directory( $aux_dir1, $idx_file ); + my ($idx_base, $idx_path, $idx_ext) = fileparseA( $idx_file ); + $idx_base = $idx_path.$idx_base; $idx_file = $idx_base.$idx_ext; - if ( $idx_ext eq '.idx' ) { - warn "$My_name: Index file '$idx_file' was written\n" - unless $silent; - $idx_files{$idx_file} = [ "$idx_base.ind", $idx_base ]; - } - elsif ( exists $cusdep_from{$idx_ext} ) { + if ( $idx_ext eq '.idx' ) { + warn "$My_name: Index file '$idx_file' was written\n" + unless $silent; + $idx_files{$idx_file} = [ "$idx_base.ind", $idx_base ]; + } + elsif ( exists $cusdep_from{$idx_ext} ) { if ( !$silent ) { - warn "$My_name: Index file '$idx_file' was written\n"; + warn "$My_name: Index file '$idx_file' was written\n"; warn " Cusdep '$cusdep_from{$idx_ext}' should be used\n"; } # No action needed here - } - else { - warn "$My_name: Index file '$idx_file' written\n", - " ==> but it has an extension I do not know how to handle <==\n"; - } + } + else { + warn "$My_name: Index file '$idx_file' written\n", + " ==> but it has an extension I do not know how to handle <==\n"; + } - next LINE; - } - if ( /^No file (.*?\.bbl)./ ) { + next LINE; + } + elsif ( /^No file (.*?\.bbl)./ ) { # 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 = normalize_force_directory( $aux_dir1, $1 ); - warn "$My_name: Non-existent bbl file '$bbl_file'\n $_\n"; - $dependents{$bbl_file} = 0; - push @bbl_files, $bbl_file; - next LINE; - } - foreach my $pattern (@file_not_found) { - if ( /$pattern/ ) { + my $bbl_file = normalize_force_directory( $aux_dir1, $1 ); + warn "$My_name: Non-existent bbl file '$bbl_file'\n $_\n"; + $dependents{$bbl_file} = 0; + push @bbl_files, $bbl_file; + next LINE; + } + foreach my $pattern (@file_not_found) { + if ( /$pattern/ ) { my $file = clean_filename($1); - warn "$My_name: Missing input file: '$file' from line\n '$_'\n" - unless $silent; - $dependents{normalize_filename($file)} = 0; - my $file1 = $file; + warn "$My_name: Missing input file: '$file' from line\n '$_'\n" + unless $silent; + $dependents{normalize_filename($file)} = 0; + my $file1 = $file; if ( $aux_dir ) { # Allow for the possibility that latex generated # a file in $aux_dir, from which the missing file can @@ -3959,31 +4096,31 @@ LINE: # file in $aux_dir, with a path. So give this alternate # location. my $file1 = normalize_force_directory( $aux_dir1, $file ); - $dependents{$file1} = 0; - } - next LINE; - } - } - if ( /^File: (.+) Graphic file \(type / ) { - # First line of message from includegraphics/x - $dependents{normalize_clean_filename($1)} = 1; - next LINE; - } - # Now test for generic lines to ignore, only after special cases! - if ( /^File: / ) { - # Package sign-on line. Includegraphics/x also produces a line - # with this signature, but I've already handled it. - next LINE; - } - if ( /^Package: / ) { - # Package sign-on line - next LINE; - } - if (/^\! LaTeX Error: / ) { - next LINE; - } + $dependents{$file1} = 0; + } + next LINE; + } + } + if ( /^File: (.+) Graphic file \(type / ) { + # First line of message from includegraphics/x + $dependents{normalize_clean_filename($1)} = 1; + next LINE; + } + # Now test for generic lines to ignore, only after special cases! + if ( /^File: / ) { + # Package sign-on line. Includegraphics/x also produces a line + # with this signature, but I've already handled it. + next LINE; + } + if ( /^Package: / ) { + # Package sign-on line + next LINE; + } + if (/^\! LaTeX Error: / ) { + next LINE; + } if ( m[^! I can't write on file `(.*)/([^/']*)'.\s*$] ) { - my $dir = $1; + my $dir = $1; my $file = $2; my $full_dir = $aux_dir1.$dir; if ( ($aux_dir ne '') && (! -e $full_dir) && ( $file =~ /\.aux$/) ) { @@ -3991,13 +4128,13 @@ LINE: " I'll try to make the subdirectory later.\n" if $diagnostics; push @missing_subdirs, $full_dir; - } + } else { warn "$My_name: ====== There were problems writing to", "----- '$file' in '$full_dir'.\n", "----- But this is not the standard situation of\n", "----- aux file to subdir of output directory, with\n", - "----- non-existent subdir\n", + "----- non-existent subdir\n", } } INCLUDE_CANDIDATE: @@ -4026,23 +4163,23 @@ LINE: # anymore. # # Solution: use ' [', but not '[' as first try at delimiter. - # Then if candidate filename is of form 'name1[name2]', then - # try splitting it. If 'name1' and/or 'name2' exists, put - # it/them in list, else just put 'name1[name2]' in list. - # So form of filename is now: - # '(', - # then any number of characters that are NOT ')', '(', or '{' - # (these form the filename); - # then ' [', or ' (', or ')', or end-of-string. - # That fails for pdflatex - # In log file: - # '(' => start of reading of file, followed by filename - # ')' => end of reading of file - # '[' => start of page (normally preceeded by space) - # Remember: - # filename (on VAX/VMS) may include '[' and ']' (directory - # separators) - # filenames (on MS-Win) commonly include space. + # Then if candidate filename is of form 'name1[name2]', then + # try splitting it. If 'name1' and/or 'name2' exists, put + # it/them in list, else just put 'name1[name2]' in list. + # So form of filename is now: + # '(', + # then any number of characters that are NOT ')', '(', or '{' + # (these form the filename); + # then ' [', or ' (', or ')', or end-of-string. + # That fails for pdflatex + # In log file: + # '(' => start of reading of file, followed by filename + # ')' => end of reading of file + # '[' => start of page (normally preceeded by space) + # Remember: + # filename (on VAX/VMS) may include '[' and ']' (directory + # separators) + # filenames (on MS-Win) commonly include space. # filenames on UNIX can included space. # Miktex quotes filenames # But web2c doesn't. Then @@ -4052,15 +4189,15 @@ LINE: # are rare. System filenames with spaces are common, but # they are normally followed by a newline rather than messages. - # First step: replace $_ by whole of line after the '(' - # Thus $_ is putative filename followed by other stuff. + # First step: replace $_ by whole of line after the '(' + # Thus $_ is putative filename followed by other stuff. $_ = $1; # Array of new candidate include files; sometimes more than one. my @new_includes = (); my $quoted = 0; if ( /^\"([^\"]+)\"/ ) { # Quoted file name, as from MikTeX - $quoted = 1; + $quoted = 1; } elsif ( /^([^\(^\)]*?)\s+[\[\{\<]/ ) { # Terminator: space then '[' or '{' or '<' @@ -4074,7 +4211,7 @@ LINE: elsif ( /^([^\(^\)]*)(\))/ ) { # Terminator is ')' } - else { + else { #Terminator is end-of-string } $_ = $'; # Put $_ equal to the unmatched tail of string ' @@ -4085,7 +4222,7 @@ LINE: # followed by space followed by message # (Common) push @new_includes, $1; - } + } if ( $include_candidate eq "[]" ) { # Part of overfull hbox message next INCLUDE_CANDIDATE; @@ -4105,32 +4242,32 @@ LINE: # If the first component exists, we probably have the # pdflatex form push @new_includes, $1, $2; - } + } else { # We have something else. # So leave the original candidate in the list - } - } - INCLUDE_NAME: + } + } + INCLUDE_NAME: foreach my $include_name (@new_includes) { $include_name = normalize_filename( $include_name ); - my ($base, $path, $ext) = fileparseB( $include_name ); + my ($base, $path, $ext) = fileparseB( $include_name ); if ( ($path eq './') || ($path eq '.\\') ) { $include_name = $base.$ext; - } + } if ( $include_name !~ m'[/|\\]' ) { # Filename does not include a path character # High potential for misparsed line - $dependents{$include_name} = 2; - } else { - $dependents{$include_name} = 3; - } - if ( $ext eq '.bbl' ) { - warn "$My_name: Found input bbl file '$include_name'\n" - unless $silent; - push @bbl_files, $include_name; - } - } # INCLUDE_NAME + $dependents{$include_name} = 2; + } else { + $dependents{$include_name} = 3; + } + if ( $ext eq '.bbl' ) { + warn "$My_name: Found input bbl file '$include_name'\n" + unless $silent; + push @bbl_files, $include_name; + } + } # INCLUDE_NAME } # INCLUDE_CANDIDATE } # LINE @@ -4155,16 +4292,16 @@ CANDIDATE: } elsif ( -e $candidate ) { if ( exists $generated_log{$candidate} ){ - $dependents{$candidate} = 6; - } + $dependents{$candidate} = 6; + } elsif ($code == 0) { - $dependents{$candidate} = 5; - } - else { - $dependents{$candidate} = 4; - } - } - elsif ($code == 1) { + $dependents{$candidate} = 5; + } + else { + $dependents{$candidate} = 4; + } + } + elsif ($code == 1) { # Graphics file that is supposed to have been read. # Candidate name is as given in source file, not as path # to actual file. @@ -4173,14 +4310,14 @@ CANDIDATE: # If the file still is not found, assume non-existent; my @kpse_result = kpsewhich( $candidate ); if ($#kpse_result > -1) { - delete $dependents{$candidate}; + delete $dependents{$candidate}; $dependents{$kpse_result[0]} = 4; - next CANDIDATE; - } - else { - push @not_found, $candidate; - } - } + next CANDIDATE; + } + else { + push @not_found, $candidate; + } + } elsif ($code == 2) { # Candidate is from '(...' construct in log file, for input file # which should include pathname if valid input file. @@ -4188,9 +4325,9 @@ CANDIDATE: # $code==2. # We get here if candidate file does not exist with given name # Almost surely result of a misparsed line in log file. - delete $dependents{$candidate}; + delete $dependents{$candidate}; push @misparse, $candidate; - } + } elsif ($code == 3) { # Candidate is from '(...' construct in log file, for input file # which should include pathname if valid input file. @@ -4200,10 +4337,10 @@ CANDIDATE: # given name. # Almost surely result of a misparsed line in log file. # But with lower probability than $code == 2 - delete $dependents{$candidate}; + delete $dependents{$candidate}; push @misparse, $candidate; - } - elsif ($code == 0) { + } + elsif ($code == 0) { my ($base, $path, $ext) = fileparseA($candidate); $ext =~ s/^\.//; if ( ($ext eq '') && (-e "$path$base.tex") ) { @@ -4214,16 +4351,16 @@ CANDIDATE: # to the missing file, unless the .tex file was # created during the run. # OLD $dependents{"$path$base.tex"} = 4; - # OLD delete $dependents{$candidate}; + # OLD delete $dependents{$candidate}; # NEW: - $dependents{"$path$base.tex"} = 4; - } - push @missing, $candidate; - } + $dependents{"$path$base.tex"} = 4; + } + push @missing, $candidate; + } } CANDIDATE_PAIR: foreach my $delegated_source (keys %new_conversions) { - my $delegated_output = $new_conversions{$delegated_source}; + my $delegated_output = $new_conversions{$delegated_source}; my $rule = "Delegated $delegated_source, $delegated_output"; # N.B. $delegated_source eq '' means the output file # was created without a named input file. @@ -4234,30 +4371,35 @@ CANDIDATE_PAIR: my @kpse_result = kpsewhich( $candidate,); if ($#kpse_result > -1) { $candidate = $kpse_result[0]; - } - } - } + } + } + } if ( ( (-e $delegated_source) || ($delegated_source eq '') ) && (-e $delegated_output) ) { - $conversions{$delegated_output} = $delegated_source; - $dependents{$delegated_output} = 7; + $conversions{$delegated_output} = $delegated_source; + $dependents{$delegated_output} = 7; if ($delegated_source) { $dependents{$delegated_source} = 4; - } - } - elsif (!$silent) { + } + } + elsif (!$silent) { print "Logfile claimed conversion from '$delegated_source' ", - "to '$delegated_output'. But:\n"; + "to '$delegated_output'. But:\n"; if (! -e $delegated_output) { - print " Output file does not exist\n"; - } + print " Output file does not exist\n"; + } if ( ($delegated_source ne '') && (! -e $delegated_source) ) { - print " Input file does not exist\n"; - } - } + print " Input file does not exist\n"; + } + } } + if ( ($#warning_list >= 0) && !$log_silent ) { + @warning_list = uniqs( @warning_list ); + show_array( "$My_name: List of undefined refs and citations:", + @warning_list ); + } if ( $diagnostics ) { @misparse = uniqs( @misparse ); @@ -4274,22 +4416,22 @@ CANDIDATE_PAIR: print "$dependents dependent files detected, of which ", "$exist exist, $not_found were not found,\n", - " and $missing appear not to exist.\n"; + " and $missing appear not to exist.\n"; print "Dependents:\n"; foreach (@dependents) { print " '$_' "; if ( $dependents{$_} == 6 ) { print " written by (pdf)latex";} if ( $dependents{$_} == 7 ) { print " converted by (pdf)latex";} - print "\n"; + print "\n"; } if ($not_found > 0) { - print "Not found:\n"; - foreach (@not_found) { print " $_\n"; } - } + print "Not found:\n"; + foreach (@not_found) { print " $_\n"; } + } if ($missing > 0) { - print "Not existent:\n"; - foreach (@missing) { print " $_\n"; } - } + print "Not existent:\n"; + foreach (@missing) { print " $_\n"; } + } if ( $bbl > 0 ) { print "Input bbl files:\n"; foreach (@bbl_files) { print " $_\n"; } @@ -4335,12 +4477,12 @@ sub parse_fls { if ( (exists $$Poutputs{$file}) && (! exists $$Pinputs{$file}) ) { $$Pfirst_read_after_write{$file} = 1; } - $$Pinputs{$file} = 1; - } + $$Pinputs{$file} = 1; + } elsif (/^\s*OUTPUT\s+(.*)$/) { # Take precautions against aliasing of foo, ./foo and other possibilities for cwd. - $$Poutputs{ normalize_filename( $1 )} = 1; - } + $$Poutputs{ normalize_filename( $1 )} = 1; + } } close( $fls_file ); return 0; @@ -4515,7 +4657,12 @@ AUX_LINE: } elsif ( /^\\\@input\{(.*)\}/ ) { # \\@input{next_aux_file_name} - &parse_aux1( $aux_dir1.$1 ); + &parse_aux1( $aux_dir1.$1 ); + } + else { + foreach my $Psub (@aux_hooks) { + &$Psub; + } } } close($aux_fh); @@ -4563,8 +4710,8 @@ sub fdb_get { if ( ! defined $check_time ) { $check_time = 0;} my ($new_time, $new_size) = get_time_size($file); my @nofile = (0,-1,0); # What we use for initializing - # a new entry in fdb or flagging - # non-existent file + # a new entry in fdb or flagging + # non-existent file if ( $new_size < 0 ) { delete $fdb_current{$file}; return @nofile; @@ -4658,41 +4805,41 @@ LINE: s/^\s*//; s/\s*$//; if ($state == -1) { - if ( ! /^# Fdb version ([\d]+)$/ ) { - warn "$My_name: File-database '$in_name' is not of correct format\n"; + if ( ! /^# Fdb version ([\d]+)$/ ) { + warn "$My_name: File-database '$in_name' is not of correct format\n"; return 1; - } + } if ( $1 > $fdb_ver) { - warn "$My_name: File-database '$in_name' is of too new version, $1 > $fdb_ver\n"; + warn "$My_name: File-database '$in_name' is of too new version, $1 > $fdb_ver\n"; return 1; - } + } $state = 0; } # Ignore blank lines and comments if ( /^$/ || /^#/ || /^%/ ) { next LINE;} if ( /^\[\"([^\"]+)\"\]/ ) { # Start of section - $rule = $1; + $rule = $1; my $tail = $'; #' Single quote in comment tricks the parser in # emacs from misparsing an isolated single quote $run_time = $check_time = 0; $source = $dest = $base = ''; if ( $tail =~ /^\s*(\S+)\s*$/ ) { $run_time = $1; - } + } elsif ( $tail =~ /^\s*(\S+)\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s*$/ ) { $run_time = $1; $source = $2; $dest = $3; $base = $4; - } + } elsif ( $tail =~ /^\s*(\S+)\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s+(\S+)\s*$/ ) { $run_time = $1; $source = $2; $dest = $3; $base = $4; $check_time = $5; - } + } if ( rdb_rule_exists( $rule ) ) { rdb_one_rule( $rule, sub{ @@ -4701,7 +4848,7 @@ LINE: $$Pcheck_time = $check_time; } ); - } + } elsif ($rule =~ /^cusdep\s+(\S+)\s+(\S+)\s+(.+)$/ ) { # Create custom dependency my $fromext = $1; @@ -4721,7 +4868,7 @@ LINE: # lines of the fdb file rdb_create_rule( $rule, 'cusdep', '', $PAnew_cmd, 1, $source, $dest, $base, 0, $run_time, $check_time, 1 ); - } + } elsif ( $rule =~ /^(makeindex|bibtex|biber)\s*(.*)$/ ) { my $PA_extra_gen = []; my $rule_generic = $1; @@ -4735,85 +4882,85 @@ LINE: $base = $path.$base; if ($rule_generic eq 'makeindex') { $dest = "$base.ind"; - } + } elsif ($rule_generic eq 'bibtex') { $dest = "$base.bbl"; $source = "$base.aux"; - } + } elsif ($rule_generic eq 'biber') { $dest = "$base.bbl"; $source = "$base.bcf"; - } - } + } + } if ($rule =~ /^makeindex/) { $PA_extra_gen = [ "$base.ilg" ]; } if ($rule =~ /^(bibtex|biber)/) { $PA_extra_gen = [ "$base.blg" ]; } if ($rule =~ /^bibtex/) { $int_cmd = "run_bibtex"; } - warn "$My_name: File-database '$in_name': setting rule '$rule'\n" + warn "$My_name: File-database '$in_name': setting rule '$rule'\n" if $diagnostics; my $cmd_type = 'external'; my $ext_cmd = ${$rule_generic}; - warn " Rule kind = '$rule_generic'; ext_cmd = '$ext_cmd';\n", + warn " Rule kind = '$rule_generic'; ext_cmd = '$ext_cmd';\n", " int_cmd = '$int_cmd';\n", - " source = '$source'; dest = '$dest'; base = '$base';\n" + " source = '$source'; dest = '$dest'; base = '$base';\n" if $diagnostics; # Set source file as non-existent. # If it existed on last run, it will be in later # lines of the fdb file rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, 1, $source, $dest, $base, 0, $run_time, $check_time, 1, $PA_extra_gen ); - } + } else { - warn "$My_name: In file-database '$in_name' rule '$rule'\n", + warn "$My_name: In file-database '$in_name' rule '$rule'\n", " is not in use in this session\n" if $diagnostics; - $new_source = undef; - $state = 10; - next LINE; - } + $new_source = undef; + $state = 10; + next LINE; + } $new_source = $new_sources{$rule} = {}; - $state = 1; #Reading a section, source part - } + $state = 1; #Reading a section, source part + } elsif ( ($state <=0) || ($state >= 3) ) { next LINE; - } + } elsif ( /^\(source\)/ ) { $state = 1; next LINE; } elsif ( /^\(generated\)/ ) { $state = 2; next LINE; } - elsif ( ($state == 1) && /^\"([^\"]*)\"\s+(\S+)\s+(\S+)\s+(\S+)\s+\"([^\"]*)\"/ ) { + elsif ( ($state == 1) && /^\"([^\"]*)\"\s+(\S+)\s+(\S+)\s+(\S+)\s+\"([^\"]*)\"/ ) { # Source file line - my $file = $1; - my $time = $2; - my $size = $3; - my $md5 = $4; + my $file = $1; + my $time = $2; + my $size = $3; + my $md5 = $4; my $from_rule = $5; #?? print " --- File '$file'\n"; if ($state != 1) { warn "$My_name: In file-database '$in_name' ", - "line $. is outside a section:\n '$_'\n"; - $errors++; - next LINE; - } + "line $. is outside a section:\n '$_'\n"; + $errors++; + next LINE; + } # Set file in database. But ensure we don't do an unnecessary # fdb_get, which can trigger a new MD5 calculation, which is # lengthy for a big file. Ininitially flagging the file # as non-existent solves the problem: - rdb_ensure_file( $rule, $file, undef, 1 ); + rdb_ensure_file( $rule, $file, undef, 1 ); rdb_set_file1( $rule, $file, $time, $size, $md5 ); fdb_set( $file, $time, $size, $md5 ); # Save the rest of the data, especially the from_fule until we know all # the rules, otherwise the from_rule may not exist. # Also we'll have a better chance of looping through files. - ${$new_source}{$file} = [ $time, $size, $md5, $from_rule ]; - } - elsif ( ($state == 2) && /^\"([^\"]*)\"/ ) { + ${$new_source}{$file} = [ $time, $size, $md5, $from_rule ]; + } + elsif ( ($state == 2) && /^\"([^\"]*)\"/ ) { my $file = $1; rdb_one_rule( $rule, sub{ rdb_add_generated($file); } ); } - else { - warn "$My_name: In file-database '$in_name' ", + else { + warn "$My_name: In file-database '$in_name' ", "line $. is of wrong format:\n '$_'\n"; - $errors++; - next LINE; - } + $errors++; + next LINE; + } } undef $in_handle; # Set cus dependencies. @@ -4863,7 +5010,7 @@ sub rdb_write { \@rules, sub { # Omit data on a unused and never-run primary rule: - if ( ($$Prun_time == 0) + if ( ($$Prun_time == 0) && exists( $possible_primaries{$rule} ) && ! exists( $current_primaries{$rule} ) ) @@ -4873,7 +5020,7 @@ sub rdb_write { print $out_handle "[\"$rule\"] $$Prun_time \"$$Psource\" \"$$Pdest\" \"$$Pbase\" $$Pcheck_time\n"; rdb_do_files( sub { print $out_handle " \"$file\" $$Ptime $$Psize $$Pmd5 \"$$Pfrom_rule\"\n"; } - ); + ); print $out_handle " (generated)\n"; foreach (keys %$PHdest) { print $out_handle " \"$_\"\n"; @@ -4895,7 +5042,7 @@ sub rdb_set_latex_deps { # Rules should only be primary if ( $$Pcmd_type ne 'primary' ) { - warn "\n$My_name: ==========$My_name: Probable BUG======= \n ", + warn "\n$My_name: ==========$My_name: Probable BUG======= \n ", " rdb_set_latex_deps called to set files ", "for non-primary rule '$rule'\n\n"; return; @@ -4923,7 +5070,13 @@ sub rdb_set_latex_deps { local @missing_subdirs = (); # Missing subdirectories in aux_dir # The following are also returned, but are global, to be used by caller - # $reference_changed, $bad_reference $bad_citation + # $reference_changed, $bad_reference $bad_citation, $mult_defined + + # Do I have my own eps-to-pdf conversion? + my $epspdf_cusdep = 0; + foreach (@cus_dep_list) { + if ( /^eps pdf / ) { $epspdf_cusdep = 1; last; } + } &parse_log; $missing_dirs = 'none'; # Status of missing directories @@ -4933,30 +5086,30 @@ sub rdb_set_latex_deps { foreach my $dir ( uniqs( @missing_subdirs ) ) { if ( -d $dir ) { $missing_dirs = 'failure'; - warn "$My_name: ==== Directory '$dir' is said to be missing\n", - " But it exists!\n"; + warn "$My_name: ==== Directory '$dir' is said to be missing\n", + " But it exists!\n"; } elsif ( (-e $dir) && (!-d $dir) ) { $missing_dirs = 'failure'; - warn "$My_name: ==== Directory '$dir' is said to be missing\n", - " But a non-directory file of this name exists!\n"; + warn "$My_name: ==== Directory '$dir' is said to be missing\n", + " But a non-directory file of this name exists!\n"; } else { if (mkdir $dir) { warn "$My_name: Directory '$dir' created\n"; - } + } else { $missing_dirs = 'failure'; warn "$My_name: Couldn't create directory '$dir'.\n", " System error: '$!'\n"; - } + } } } - } + } else { $missing_dirs = 'not allowed'; warn "$My_name: There are missing subdirectories, but their creation\n", - " is not allowed. The subdirectories are:\n"; + " is not allowed. The subdirectories are:\n"; foreach my $dir ( uniqs( @missing_subdirs ) ) { warn " '$dir'\n"; } @@ -4968,14 +5121,35 @@ sub rdb_set_latex_deps { parse_fls( $fls_file, \%source_fls, \%generated_fls, \%first_read_after_write ); foreach (keys %source_fls) { $dependents{$_} = 4; - } + } foreach (keys %generated_fls) { rdb_add_generated( $_ ); if ( exists($dependents{$_}) ) { $dependents{$_} = 6; - } + } } } + + for my $conv (sort keys %conversions) { + my $conv_source = $conversions{$conv}; + if ( $conv =~ /^(.*)-eps-converted-to\.pdf$/ ) { + # Check all the conditions for pdflatex's conversion eps to pdf + # are valid; if they are, treat the converted file as not a + # source file. + my $base = $1; + if ( (-e $conv_source) && (-e $conv) && ( $conv_source eq "$base.eps" ) ) { + # $conv isn't a real source of (pdf)latex + rdb_remove_files( $rule, $conv ); + delete $dependents{$conv}; + if ($epspdf_cusdep) { + $dependents{"$base.pdf"} = ((-e "$base.pdf") ? 4 : 0 ); + } + } + } + } + + + # ?? !! Should also deal with .run.xml file # Handle result on output file: @@ -5003,7 +5177,7 @@ sub rdb_set_latex_deps { IDX_FILE: foreach my $idx_file ( keys %idx_files ) { - my ($ind_file, $ind_base) = @{$idx_files{$idx_file}}; + my ($ind_file, $ind_base) = @{$idx_files{$idx_file}}; my $from_rule = "makeindex $idx_file"; if ( ! rdb_rule_exists( $from_rule ) ){ print "!!!===Creating rule '$from_rule': '$ind_file' from '$idx_file'\n" @@ -5013,7 +5187,7 @@ sub rdb_set_latex_deps { print " ===Source file '$ind_file' for '$rule'\n" if ($diagnostics); rdb_ensure_file( $rule, $ind_file, $from_rule ); - } + } # Make sure the .ind file is treated as a detected source file; # otherwise if the log file has it under a different name (as # with MiKTeX which gives full directory information), there @@ -5023,13 +5197,14 @@ sub rdb_set_latex_deps { if ( ! -e $ind_file ) { # Failure was non-existence of makable file # Leave failure issue to other rules. - $failure = 0; - } + $failure = 0; + } } + local %processed_aux_files = (); BBL_FILE: foreach my $bbl_file ( uniqs( @bbl_files ) ) { - my ($bbl_base, $bbl_path, $bbl_ext) = fileparseA( $bbl_file ); + my ($bbl_base, $bbl_path, $bbl_ext) = fileparseA( $bbl_file ); $bbl_base = $bbl_path.$bbl_base; my @new_bib_files = (); my @new_aux_files = (); @@ -5038,7 +5213,7 @@ sub rdb_set_latex_deps { my $bib_program = 'bibtex'; if ( test_gen_file( "$bbl_base.bcf" ) ) { $bib_program = 'biber'; - } + } my $from_rule = "$bib_program $bbl_base"; print "======= Dealing with '$from_rule'\n" if ($diagnostics); if ($bib_program eq 'biber') { @@ -5056,12 +5231,12 @@ sub rdb_set_latex_deps { if ( $bib_program eq 'biber' ) { rdb_create_rule( $from_rule, 'external', $biber, '', 1, "$bbl_base.bcf", $bbl_file, $bbl_base, 1, 0, 0 ); - } + } else { rdb_create_rule( $from_rule, 'external', $bibtex, 'run_bibtex', 1, "$bbl_base.aux", $bbl_file, $bbl_base, 1, 0, 0 ); - } - } + } + } local %old_sources = (); rdb_one_rule( $from_rule, sub { %old_sources = %$PHsource; } ); foreach my $source ( @new_bib_files, @new_aux_files, @new_bst_files, @biber_source ) { @@ -5070,6 +5245,9 @@ sub rdb_set_latex_deps { rdb_ensure_file( $from_rule, $source ); delete $old_sources{$source}; } + foreach my $source ( @new_aux_files ) { + $processed_aux_files{$source} = 1; + } if ($diagnostics) { foreach ( keys %old_sources ) { print "Removing no-longer-needed dependent '$_' from rule '$from_rule'\n"; @@ -5083,14 +5261,24 @@ sub rdb_set_latex_deps { # Failure was non-existence of makable file # Leave failure issue to other rules. $failure = 0; - } + } + } + + if ( ($#aux_hooks > -1) && ! exists $processed_aux_files{$aux_main} ) { + my @new_bib_files = (); + my @new_aux_files = (); + my @new_bst_files = (); + parse_aux( $aux_main, \@new_bib_files, \@new_aux_files, \@new_bst_files ); + foreach my $source ( @new_aux_files ) { + $processed_aux_files{$source} = 1; + } } NEW_SOURCE: - foreach my $new_source (keys %dependents, keys %conversions) { + foreach my $new_source (keys %dependents) { print " ===Source file for rule '$rule': '$new_source'\n" - if ($diagnostics); - if ( ($dependents{$new_source} == 5) + if ($diagnostics); + if ( ($dependents{$new_source} == 5) || ($dependents{$new_source} == 6) ) { # (a) File was detected in "No file..." line in log file. @@ -5104,37 +5292,37 @@ NEW_SOURCE: # database, then the previous version of the file should be # treated as non-existent, to ensure another run is forced. rdb_ensure_file( $rule, $new_source, undef, 1 ); - } - elsif ( $dependents{$new_source} == 7 ) { + } + elsif ( $dependents{$new_source} == 7 ) { # File was result of conversion by (pdf)latex. my $cnv_source = $conversions{$new_source}; rdb_ensure_file( $rule, $new_source ); - if ($cnv_source) { + if ($cnv_source) { # Conversion from $cnv_source to $new_source # implies that effectively $cnv_source is a source # of the (pdf)latex run. rdb_ensure_file( $rule, $cnv_source ); - } + } # Flag that changes of the generated file during a run # do not require a rerun: rdb_one_file( $new_source, sub{ $$Pcorrect_after_primary = 1; } ); - } - else { + } + else { # But we don't need special precautions for ordinary user files # (or for files that are generated outside of latex/pdflatex). rdb_ensure_file( $rule, $new_source ); - } - if ( ($dependents{$new_source} == 6) + } + if ( ($dependents{$new_source} == 6) || ($dependents{$new_source} == 7) ) { - rdb_add_generated($new_source); + rdb_add_generated($new_source); } } my @more_sources = &rdb_set_dependents( $rule ); my $num_new = $#more_sources + 1; foreach (@more_sources) { - $dependents{$_} = 4; + $dependents{$_} = 4; if ( ! -e $_ ) { # Failure was non-existence of makable file # Leave failure issue to other rules. @@ -5146,20 +5334,20 @@ NEW_SOURCE: delete $dependents{$_}; } if ($diagnostics) { - if ($num_new > 0 ) { - print "$num_new new source files for rule '$rule':\n"; - foreach (@more_sources) { print " '$_'\n"; } - } - else { - print "No new source files for rule '$rule':\n"; - } + if ($num_new > 0 ) { + print "$num_new new source files for rule '$rule':\n"; + foreach (@more_sources) { print " '$_'\n"; } + } + else { + print "No new source files for rule '$rule':\n"; + } my @first_read_after_write = sort keys %first_read_after_write; if ($#first_read_after_write >= 0) { print "The following files were only read after being written:\n"; foreach (@first_read_after_write) { print " '$_'\n"; - } - } + } + } } my @files_not_needed = (); foreach (keys %$PHsource) { @@ -5167,7 +5355,7 @@ NEW_SOURCE: print "Removing no-longer-needed dependent '$_' from rule '$rule'\n" if $diagnostics; push @files_not_needed, $_; - } + } } rdb_remove_files( $rule, @files_not_needed ); @@ -5215,24 +5403,24 @@ MISSING_FILE: $new_includes{"$missing.tex"} = 1; } if ( -e $missing ) { - $new_includes{$missing} = 1; + $new_includes{$missing} = 1; } if ( $ext ne "" ) { foreach my $dep (@cus_dep_list){ my ($fromext,$toext) = split('\s+',$dep); if ( ( "$ext" eq "$toext" ) && ( -e "$path$base.$fromext" ) - ) { + ) { # Source file for the missing file exists # So we have a real include file, and it will be made # next time by rdb_set_dependents $new_includes{$missing} = 1; } - else { + else { # no point testing the $toext if the file doesn't exist. - } + } next MISSING_FILE; - } + } } else { # $_ doesn't exist, $_.tex doesn't exist, @@ -5252,7 +5440,7 @@ MISSING_FILE: $new_includes{"$path$base.$toext"} = 1; # next MISSING_FILE; } - } + } } } # end MISSING_FILES @@ -5271,19 +5459,19 @@ MISSING_FILE: my $stripped = $file; $stripped =~ s{^\./}{}; if ( exists $PHsource{$file} ) { - delete $new_includes{$file}; - } + delete $new_includes{$file}; + } else { - $found ++; - rdb_ensure_file( $rule, $file ); - } + $found ++; + rdb_ensure_file( $rule, $file ); + } } if ( $diagnostics && ( $found > 0 ) ) { - warn "$My_name: Detected previously missing files:\n"; + warn "$My_name: Detected previously missing files:\n"; foreach ( sort keys %new_includes ) { warn " '$_'\n"; - } + } } return $found; } # END rdb_find_new_files @@ -5300,7 +5488,7 @@ sub rdb_set_dependents { rdb_for_some( [@_], 0, \&rdb_one_dep ); # OLD rdb_recurse( [@_], 0, \&rdb_one_dep ); foreach (@deletions) { - my ($rule, $file) = @$_; + my ($rule, $file) = @$_; rdb_remove_files( $rule, $file ); } &rdb_make_links; @@ -5329,30 +5517,30 @@ DEP: my ($fromext,$proptoext,$must,$func_name) = split('\s+',$dep); if ( $toext eq $proptoext ) { my $source = "$base_name.$fromext"; - # Found match of rule + # Found match of rule if ($diagnostics) { print "Found cusdep: $source to make $rule:$new_dest ====\n"; } - if ( -e $source ) { - $$Pfrom_rule = "cusdep $fromext $toext $base_name"; -#?? print "?? Ensuring rule for '$$Pfrom_rule'\n"; + if ( -e $source ) { + $$Pfrom_rule = "cusdep $fromext $toext $base_name"; +#?? print "?? Ensuring rule for '$$Pfrom_rule'\n"; local @PAnew_cmd = ( 'do_cusdep', $func_name ); if ( !-e $new_dest ) { - push @new_sources, $new_dest; - } + push @new_sources, $new_dest; + } if (! rdb_rule_exists( $$Pfrom_rule ) ) { print "=== Creating rule for '$$Pfrom_rule'\n"; rdb_create_rule( $$Pfrom_rule, 'cusdep', '', \@PAnew_cmd, 3, $source, $new_dest, $base_name, 0 ); - } + } else { - rdb_one_rule( + rdb_one_rule( $$Pfrom_rule, sub{ @$PAint_cmd = @PAnew_cmd; $$Pdest = $new_dest;} ); - } - return; - } + } + return; + } else { # Source file does not exist if ( !$force_mode && ( $must != 0 ) ) { @@ -5361,16 +5549,16 @@ DEP: $failure_msg = "File '$base_name.$fromext' does not exist ". "to build '$base_name.$toext'"; return; - } + } elsif ( $$Pfrom_rule =~ /^cusdep $fromext $toext / ) { # Source file does not exist, destination has the rule set. # So turn the from_rule off - $$Pfrom_rule = ''; - } - else { - } - } - } + $$Pfrom_rule = ''; + } + else { + } + } + } elsif ( ($toext eq '') && (! -e $file ) && (! -e "$base_name.$proptoext" ) @@ -5383,27 +5571,27 @@ DEP: my $source = "$base_name.$fromext"; if ( -e $source ) { $new_dest = "$base_name.$proptoext"; - my $from_rule = "cusdep $fromext $proptoext $base_name"; + my $from_rule = "cusdep $fromext $proptoext $base_name"; push @new_sources, $new_dest; - print "Ensuring rule for '$from_rule', to make '$new_dest'\n" - if $diagnostics > -1; + print "Ensuring rule for '$from_rule', to make '$new_dest'\n" + if $diagnostics > -1; local @PAnew_cmd = ( 'do_cusdep', $func_name ); if (! rdb_rule_exists( $from_rule ) ) { rdb_create_rule( $from_rule, 'cusdep', '', \@PAnew_cmd, 3, $source, $new_dest, $base_name, 0 ); - } + } else { - rdb_one_rule( + rdb_one_rule( $$Pfrom_rule, sub{ @$PAint_cmd = @PAnew_cmd; $$Pdest = $new_dest;} ); - } + } rdb_ensure_file( $rule, $new_dest, $from_rule ); # We've now got a spurious file in our rule. But don't mess # with deleting an item we are in the middle of! push @deletions, [$rule, $file]; - return; - } + return; + } } # End of Rule found } # End DEP if ( (! -e $file) && $use_make_for_missing_files ) { @@ -5415,8 +5603,8 @@ DEP: &Run_subst( "$make $q$file$q" ); if ( -e $file ) { return; - } - } + } + } else { print "$My_name: '$rule': source '$file' doesn't exist.\n", " I'll try making it with allowed extensions \n"; @@ -5436,9 +5624,9 @@ DEP: # the error due to a missing file. $$Pout_of_date_user = 1; return; - } - } - } + } + } + } } } #END rdb_one_dep @@ -5452,18 +5640,18 @@ sub rdb_list { my @accessible_all = rdb_accessible( keys %requested_filerules ); rdb_for_some( \@accessible_all, - sub{ $count_rules++; + sub{ $count_rules++; print "Rule '$rule' depends on:\n"; }, - sub{ print " '$file'\n"; }, - sub{ print " and generates:\n"; + sub{ print " '$file'\n"; }, + sub{ print " and generates:\n"; foreach (keys %$PHdest) { print " '$_'\n"; } # print " default_extra_generated:\n"; # foreach (@$PA_extra_generated) { print " '$_'\n"; } }, ); if ($count_rules <= 0) { - print " ---No rules defined\n"; + print " ---No rules defined\n"; } } #END rdb_list @@ -5483,11 +5671,11 @@ sub deps_list { my @accessible_all = rdb_accessible( keys %requested_filerules ); rdb_for_some( \@accessible_all, - sub{ + sub{ # foreach (keys %$PHdest) { print "----- $_\n"; } push @generated, keys %$PHdest; }, - sub{ $source{$file} = 1; } + sub{ $source{$file} = 1; } ); foreach (keys %generated_exts_all) { (my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/$root_filename/; @@ -5526,17 +5714,17 @@ sub rdb_show { print "===Rules:\n"; local $count_rules = 0; rdb_for_all( - sub{ $count_rules++; + sub{ $count_rules++; my @int_cmd = @$PAint_cmd; - foreach (@int_cmd) { - if ( !defined($_) ) { $_='undef';} - } + foreach (@int_cmd) { + if ( !defined($_) ) { $_='undef';} + } print " [$rule]: '$$Pcmd_type' '$$Pext_cmd' '@int_cmd' $$Ptest_kind ", "'$$Psource' '$$Pdest' '$$Pbase' $$Pout_of_date $$Pout_of_date_user\n"; }, - sub{ print " '$file': $$Ptime $$Psize $$Pmd5 '$$Pfrom_rule'\n"; } + sub{ print " '$file': $$Ptime $$Psize $$Pmd5 '$$Pfrom_rule'\n"; } ); if ($count_rules <= 0) { - print " ---No rules defined\n"; + print " ---No rules defined\n"; } } #END rdb_show @@ -5734,7 +5922,7 @@ sub rdb_make { # making currently non-existent file, which # could become a needed source file for a run # and therefore undo an error condition - if ($diagnostics) { + if ($diagnostics) { print "Make: doing pre_primary and primary...\n"; } # Do the primary run if it is needed. On return $runs == 0 @@ -5745,31 +5933,45 @@ sub rdb_make { # limit. In the second case $too_many_runs is set. rdb_for_some( [@pre_primary, $primary], \&rdb_make1 ); if ( ($runs > 0) && ! $too_many_passes ) { - next PASS; + $retry_msg = 0; + if ( $force_mode || (! $failure) ) { + next PASS; + } + # Get here on failure, without being in force_mode + if ( $newrule_nofile ) { + $retry_msg = 1; + print "$My_name: Error on run, but found possibility to ", + "make new source files\n"; + next PASS; + } + else { last PASS; } } if ($runs == 0) { # $failure not set on this pass, so use value from previous pass: $failure = $previous_failure; + if ($retry_msg) { + print "But in fact no new files made\n"; + } if ($failure && !$force_mode ) { last PASS; } - } + } if ( $missing_dvi_pdf ) { # No output from primary, after completing circular dependence warn "Failure to make '$missing_dvi_pdf'\n"; $failure = 1; last PASS; } - if ($diagnostics) { - print "Make: doing post_primary...\n"; - } + if ($diagnostics) { + print "Make: doing post_primary...\n"; + } rdb_for_some( [@post_primary], \&rdb_make1 ); if ( ($runs == 0) || $too_many_passes ) { # If $too_many_passes is set, it should also be that # $runs == 0; but for safety, I also checked # $too_many_passes. last PASS; - } - } - continue { + } + } + continue { # Re-evaluate rule classification and accessibility, # but do not change primaries. # Problem is that %current_primaries gets altered @@ -5777,23 +5979,23 @@ sub rdb_make { &rdb_classify_rules( \%possible_primaries, @requested_targets ); %current_primaries = %old_curr_prim; &rdb_make_links; - } + } } rdb_for_some( [@unusual_one_time], \&rdb_make1 ); rdb_write( $fdb_name ); if (! $silent) { - if ($failure && $force_mode) { + if ($failure && $force_mode) { print "$My_name: Errors, in force_mode: so I tried finishing targets\n"; - } - elsif ($failure) { + } + elsif ($failure) { print "$My_name: Errors, so I did not complete making targets\n"; - } - else { + } + else { local @dests = (); rdb_for_some( [@_], sub{ push @dests, $$Pdest if ($$Pdest); } ); print "$My_name: All targets (@dests) are up-to-date\n"; - } + } } return $failure; } #END rdb_make @@ -5804,37 +6006,37 @@ sub rdb_show_rule_errors { local @errors = (); local @warnings = (); rdb_for_all( - sub{ - if ($$Plast_message ne '') { + 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) { + 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 - } - } - ); + } + } + ); if ($#warnings > -1) { - warn "Collected warning summary (may duplicate other messages):\n"; - foreach (@warnings){ - warn " $_\n"; - } + warn "Collected warning summary (may duplicate other messages):\n"; + foreach (@warnings){ + warn " $_\n"; + } } if ($#errors > -1) { - warn "Collected error summary (may duplicate other messages):\n"; - foreach (@errors){ - warn " $_\n"; - } + warn "Collected error summary (may duplicate other messages):\n"; + foreach (@errors){ + warn " $_\n"; + } } return $#errors+1; } @@ -5867,15 +6069,15 @@ sub rdb_make1 { $bibtex_not_run = 0; if ($bibtex_use == 0) { $bibtex_not_run = 2; - } + } elsif ($bibtex_use == 1) { - foreach ( keys %$PHsource ) { - if ( ( /\.bib$/ ) && (! -e $_) ) { + foreach ( keys %$PHsource ) { + if ( ( /\.bib$/ ) && (! -e $_) ) { push @missing_bib_files, $_; $bibtex_not_run = 1; - } - } - } + } + } + } } if ( ($$Prun_time == 0) && exists($possible_primaries{$rule}) ) { @@ -5885,53 +6087,53 @@ sub rdb_make1 { } else { if ( $$Pdest && (! -e $$Pdest) ) { - # With a non-existent destination, if we haven't made any passes + # With a non-existent destination, if we haven't made any passes # through a rule, rerunning the rule is good, because the file # may fail to exist because of being deleted by the user (for ex.) # rather than because of a failure on a previous run. # (We could do better with a flag in fdb file.) - # But after the first pass, the situation is different. - # For a primary rule (pdf)latex, the lack of a destination file - # could result from there being zero content due to a missing - # essential input file. The input file could be generated - # by a program to be run later (e.g., a cusdep or bibtex), - # so we should wait until all passes are completed before + # But after the first pass, the situation is different. + # For a primary rule (pdf)latex, the lack of a destination file + # could result from there being zero content due to a missing + # essential input file. The input file could be generated + # by a program to be run later (e.g., a cusdep or bibtex), + # so we should wait until all passes are completed before # deciding a non-existent destination file is an error. - # For a custom dependency, the rule may be obsolete, and - # if the source file does not exist also, we should simply - # not run the rule, but not set an error condition. - # Any error will arise at the (pdf)latex level due to a - # missing source file at that level. - if ( $$Psource && (! -e $$Psource) + # For a custom dependency, the rule may be obsolete, and + # if the source file does not exist also, we should simply + # not run the rule, but not set an error condition. + # Any error will arise at the (pdf)latex level due to a + # missing source file at that level. + if ( $$Psource && (! -e $$Psource) # OLD && ( ( $$Pcmd_type eq 'cusdep') ) # NEW && ( ( $$Pcmd_type ne 'primary') ) ) { # Main source file doesn't exist, and rule is NOT primary. - # No action, since a run is pointless. Primary is different: + # No action, since a run is pointless. Primary is different: # file might be found elsewhere (by kpsearch from (pdf)latex), # while non-existence of main source file is a clear error. - } - elsif ( $$Pcmd_type eq 'delegated' ) { - # Delegate to destination rule - } - elsif ( $pass{$rule}==0) { - push @no_dest, $$Pdest; - $$Pout_of_date = 1; - } - if ( $$Pcmd_type eq 'primary' ) { - $missing_dvi_pdf = $$Pdest; - } - } + } + elsif ( $$Pcmd_type eq 'delegated' ) { + # Delegate to destination rule + } + elsif ( $pass{$rule}==0) { + push @no_dest, $$Pdest; + $$Pout_of_date = 1; + } + if ( $$Pcmd_type eq 'primary' ) { + $missing_dvi_pdf = $$Pdest; + } + } } &rdb_flag_changes_here(0); if (!$$Pout_of_date) { -#?? if ( ($$Pcmd_type eq 'primary') && (! $silent) ) { +#?? if ( ($$Pcmd_type eq 'primary') && (! $silent) ) { # print "Rule '$rule' up to date\n"; # } - return; + return; } if ($diagnostics) { print " remake\n"; } if (!$silent) { @@ -5956,7 +6158,7 @@ sub rdb_make1 { # Treat rule as completed, else in -pvc mode get infinite reruns: $$Pout_of_date = 0; $failure = 1; - $failure_msg = "'$rule' needed too many passes"; + $failure_msg = "'$rule' needed too many passes"; return; } @@ -5971,7 +6173,7 @@ sub rdb_make1 { } elsif ($bibtex_not_run == 2 ) { warn "$My_name: I AM CONFIGURED/INVOKED NOT TO RUN '$rule'\n"; - } + } $return = &rdb_dummy_run1; } else { @@ -6002,7 +6204,7 @@ sub rdb_make1 { # So in this case, do NOT report an error $$Pout_of_date = 0; - } + } elsif ($$Pcmd_type eq 'primary' ) { # For a primary rule, i.e., (pdf)latex, not to produce the # expected output file may not be an error condition. @@ -6013,7 +6215,7 @@ sub rdb_make1 { elsif ($return == -2) { # 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 @@ -6021,16 +6223,16 @@ sub rdb_make1 { # only error. $$Pout_of_date = 0; } - else { + else { $failure = 1; - } + } } if ( ($return != 0) && ($return != -2) ) { $failure = 1; - $$Plast_result = 2; + $$Plast_result = 2; if ( !$$Plast_message ) { $$Plast_message = "Run of rule '$rule' gave a non-zero error code"; - } + } # !!?? $failure_msg = $$Plast_message; } @@ -6081,45 +6283,45 @@ sub rdb_classify_rules { @post_primary = reverse @post_primary; if ($diagnostics) { - print "Rule classification: \n"; - if ($#requested_targets < 0) { - print " No requested rules\n"; - } - else { - print " Requested rules:\n"; - foreach ( @requested_targets ) { print " $_\n"; } - } - if ($#pre_primary < 0) { - print " No pre-primaries\n"; - } - else { - print " Pre-primaries:\n"; - foreach (@pre_primary) { print " $_\n"; } - } - print " Primaries:\n"; - foreach (keys %current_primaries) { print " $_\n"; } - if ($#post_primary < 0) { - print " No post-primaries\n"; - } - else { - print " Post-primaries:\n"; - foreach (@post_primary) { print " $_\n"; } - } - if ($#unusual_one_time < 0) { - print " No inner-level one_time rules, as expected\n"; - } - else { - print " Inner-level one_time rules:\n"; - foreach ( @unusual_one_time ) { print " $_\n"; } - } + print "Rule classification: \n"; + if ($#requested_targets < 0) { + print " No requested rules\n"; + } + else { + print " Requested rules:\n"; + foreach ( @requested_targets ) { print " $_\n"; } + } + if ($#pre_primary < 0) { + print " No pre-primaries\n"; + } + else { + print " Pre-primaries:\n"; + foreach (@pre_primary) { print " $_\n"; } + } + print " Primaries:\n"; + foreach (keys %current_primaries) { print " $_\n"; } + if ($#post_primary < 0) { + print " No post-primaries\n"; + } + else { + print " Post-primaries:\n"; + foreach (@post_primary) { print " $_\n"; } + } + if ($#unusual_one_time < 0) { + print " No inner-level one_time rules, as expected\n"; + } + else { + 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"; } - } + 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 } #END rdb_classify_rules @@ -6146,12 +6348,12 @@ sub rdb_classify1 { $current_primaries{ $rule } = 1; } else { - push @post_primary, $rule; + push @post_primary, $rule; } } else { $state = 2; # in post-primary rule - push @pre_primary, $rule; + push @pre_primary, $rule; } } #END rdb_classify1 @@ -6191,14 +6393,14 @@ sub rdb_run1 { my $int_cmd = shift @int_args; my @int_args_for_printing = @int_args; foreach (@int_args_for_printing) { - if ( ! defined $_ ) { $_ = 'undef'; } + if ( ! defined $_ ) { $_ = 'undef'; } } if ($int_cmd) { - print "For rule '$rule', running '\&$int_cmd( @int_args_for_printing )' ...\n"; + print "For rule '$rule', running '\&$int_cmd( @int_args_for_printing )' ...\n"; $return = &$int_cmd( @int_args ); } elsif ($$Pext_cmd) { - $return = &Run_subst(); + $return = &Run_subst(); } else { warn "$My_name: Either a bug OR a configuration error:\n", @@ -6231,7 +6433,7 @@ sub rdb_run1 { " be recreated, I'll try to do so.\n"; $return = -2; rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } ); - } + } elsif ($retcode == 4) { $$Plast_result = 2; $$Plast_message = "Could not find all biber source files for '$$Pbase'"; @@ -6260,7 +6462,7 @@ sub rdb_run1 { if ( ! -e $$Psource ) { $retcode = 10; rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } ); - } + } if ($retcode == 3) { $$Plast_result = 2; $$Plast_message = "Could not open bibtex log file for '$$Pbase'"; @@ -6281,17 +6483,17 @@ sub rdb_run1 { warn "$My_name: Bibtex did not produce '$$Pdest'. But that\n", " was because of missing files, so I will continue.\n"; $return = -2; - } + } else { $return = 0; - } + } } } $updated = 1; if ($$Ptest_kind == 3) { # We are time-criterion first time only. Now switch to - # file-change criterion + # file-change criterion $$Ptest_kind = 1; } $$Pout_of_date = $$Pout_of_date_user = 0; @@ -6299,11 +6501,11 @@ sub rdb_run1 { if ( ($$Plast_result == 0) && ($return != 0) && ($return != -2) ) { $$Plast_result = 2; if ($$Plast_message eq '') { - $$Plast_message = "Command for '$rule' gave return code $return"; - } + $$Plast_message = "Command for '$rule' gave return code $return"; + } } elsif ( $$Pdest && (! -e $$Pdest) && ($return != -2) ) { - $$Plast_result = 1; + $$Plast_result = 1; } return $return; } # END rdb_run1 @@ -6326,7 +6528,7 @@ sub rdb_dummy_run1 { if ($$Ptest_kind == 3) { # We are time-criterion first time only. Now switch to - # file-change criterion + # file-change criterion $$Ptest_kind = 1; } $$Pout_of_date = $$Pout_of_date_user = 0; @@ -6385,9 +6587,9 @@ sub Run_subst { '%%' => '%' # To allow literal %B, %R, etc, by %%B. ); if ( ($^O eq "MSWin32" ) && $MSWin_back_slash ) { - foreach ( '%R', '%B', '%T', '%S', '%D', '%Y', '%Z' ) { - $subst{$_} =~ s(/)(\\)g; - } + foreach ( '%R', '%B', '%T', '%S', '%D', '%Y', '%Z' ) { + $subst{$_} =~ s(/)(\\)g; + } } my @tokens = split /(%.)/, $ext_cmd; @@ -6437,13 +6639,13 @@ sub rdb_primary_run { my @other_fls_names = ( ); if ( $rule =~ /^pdflatex/ ) { push @other_fls_names, "pdflatex.fls"; - } + } else { push @other_fls_names, "latex.fls"; - } + } if ( $aux_dir1 ne '' ) { push @other_fls_names, "$root_filename.fls"; - } + } # 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 @@ -6454,10 +6656,10 @@ sub rdb_primary_run { copy $cand, $std_fls_file; last; } - } + } if ( ! test_gen_file( $std_fls_file ) ) { warn "$My_name: fls file doesn't appear to have been made\n"; - } + } } # Find current set of source files: @@ -6491,8 +6693,8 @@ sub rdb_primary_run { #?? &rdb_update_files; if ( $diagnostics ) { - print "$My_name: Rules after run: \n"; - rdb_show(); + print "$My_name: Rules after run: \n"; + rdb_show(); } $return = $return_latex; @@ -6504,17 +6706,19 @@ sub rdb_primary_run { if (! $silent); $return = 0; } - # Summarize issues that may have escaped notice: my @warnings = (); if ($bad_reference) { push @warnings, "Latex failed to resolve $bad_reference reference(s)"; } + if ($mult_defined) { + push @warnings, "Latex found $mult_defined multiply defined reference(s)"; + } if ($bad_citation) { push @warnings, "Latex failed to resolve $bad_citation citation(s)"; } if ($#warnings > -1) { - show_array( "$My_name: Summary of warnings:", @warnings ); + show_array( "$My_name: Summary of warnings:", @warnings ); } return $return; } #END rdb_primary_run @@ -6550,9 +6754,9 @@ sub rdb_flag_changes_here { $dest_mtime = get_mtime($$Pdest) if ($$Pdest); rdb_do_files( \&rdb_file_change1); if ($$Pout_of_date) { - push @rules_to_apply, $rule; + push @rules_to_apply, $rule; } -#?? print "======== flag: $rule $$Pout_of_date ==========\n"; +#?? print "======== flag: $rule $$Pout_of_date ==========\n"; } #END rdb_flag_changes_here #************************************************************ @@ -6573,7 +6777,7 @@ sub rdb_file_change1 { #?? " New $new_time, $new_size, $new_md5\n"; my $ext_no_period = ext_no_period( $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; @@ -6589,27 +6793,27 @@ sub rdb_file_change1 { return; } if ( ($new_size < 0) && ($$Psize < 0) ) { - return; + return; } if ( ($new_size != $$Psize) || ($new_md5 ne $$Pmd5) ) { #?? print "FC1: changed $file: ($new_size != $$Psize) $new_md5 ne $$Pmd5)\n"; - push @changed, $file; - $$Pout_of_date = 1; + push @changed, $file; + $$Pout_of_date = 1; if ( ! exists $generated_exts_all{$ext_no_period} ) { $$Pout_of_date_user = 1; - } + } } elsif ( $new_time != $$Ptime ) { #warn "--==-- Unchanged $file, changed time, update filetime in $rule\n"; - $$Ptime = $new_time; + $$Ptime = $new_time; } if ( ( ($$Ptest_kind == 2) || ($$Ptest_kind == 3) ) && (! exists $generated_exts_all{$ext_no_period} ) && ( $new_time > $dest_mtime ) ) { #?? print "FC1: changed $file: ($new_time > $dest_mtime)\n"; - push @changed, $file; - $$Pout_of_date = $$Pout_of_date_user = 1; + push @changed, $file; + $$Pout_of_date = $$Pout_of_date_user = 1; } } #END rdb_file_change1 @@ -6630,22 +6834,22 @@ sub rdb_diagnose_changes { my $heading = defined($_[0]) ? $_[0] : "$My_name: "; if ($#rules_never_run >= 0) { - warn "${heading}Rules & subrules not known to be previously run:\n"; + warn "${heading}Rules & subrules not known to be previously run:\n"; foreach (@rules_never_run) { warn " $_\n"; } } if ( ($#changed >= 0) || ($#disappeared >= 0) || ($#no_dest >= 0) ) { warn "${heading}File changes, etc:\n"; if ( $#changed >= 0 ) { - warn " Changed files, or newly in use since previous run(s):\n"; - foreach (uniqs(@changed)) { warn " '$_'\n"; } + warn " Changed files, or newly in use since previous run(s):\n"; + foreach (uniqs(@changed)) { warn " '$_'\n"; } } if ( $#disappeared >= 0 ) { - warn " No-longer-existing files:\n"; - foreach (uniqs(@disappeared)) { warn " '$_'\n"; } + warn " No-longer-existing files:\n"; + foreach (uniqs(@disappeared)) { warn " '$_'\n"; } } if ( $#no_dest >= 0 ) { - warn " Non-existent destination files:\n"; - foreach (uniqs(@no_dest)) { warn " '$_'\n"; } + warn " Non-existent destination files:\n"; + foreach (uniqs(@no_dest)) { warn " '$_'\n"; } } } elsif ($#rules_to_apply >=0) { @@ -6653,7 +6857,7 @@ sub rdb_diagnose_changes { foreach (@rules_to_apply) { warn " '$_'\n"; } } else { - warn "${heading}No file changes\n"; + warn "${heading}No file changes\n"; } } #END rdb_diagnose_changes @@ -6814,7 +7018,7 @@ sub rdb_for_some { foreach $rule ( @heads ) { # $rule is implicitly local - &rdb_one_rule( $rule, @_ ); + &rdb_one_rule( $rule, @_ ); } } #END rdb_for_some @@ -6843,7 +7047,7 @@ sub rdb_recurse_rule { # Assumes recursion context, i.e. that %visited, @heads, $depth. # We are overriding actions: my ($rule, $rule_act1, $new_file_act1, $new_file_act2, $rule_act2) - = @_; + = @_; # and must propagate the file actions: local $file_act1 = $new_file_act1; local $file_act2 = $new_file_act2; @@ -6869,7 +7073,7 @@ sub rdb_recurse_file { # Assumes contexts set for: Recursion, rule, and file &$file_act1 if $file_act1; rdb_recurse_rule( $$Pfrom_rule, $rule_act1, $file_act1, $file_act2, - $rule_act2 ) + $rule_act2 ) if $$Pfrom_rule; &$file_act2 if $file_act2; } #END rdb_recurse_file @@ -7000,7 +7204,7 @@ sub rdb_create_rule { -1, '', $PA_extra_gen ], {}, {} - ]; + ]; if ($source) { rdb_ensure_file( $rule, $source, undef, $set_file_not_exists ); } @@ -7046,27 +7250,27 @@ sub rdb_ensure_file { my $rule = shift; local ( $new_file, $new_from_rule, $set_not_exists ) = @_; if ( ! rdb_rule_exists( $rule ) ) { - die_trace( "$My_name: BUG in rdb_ensure_file: non-existent rule '$rule'" ); + die_trace( "$My_name: BUG in rdb_ensure_file: non-existent rule '$rule'" ); } if ( ! defined $new_file ) { - die_trace( "$My_name: BUG in rdb_ensure_file: undefined file for '$rule'" ); + die_trace( "$My_name: BUG in rdb_ensure_file: undefined file for '$rule'" ); } if ( ! defined $set_not_exists ) { $set_not_exists = 0; } rdb_one_rule( $rule, sub{ if (! exists ${$PHsource}{$new_file} ) { - if ( $set_not_exists ) { + if ( $set_not_exists ) { ${$PHsource}{$new_file} = [0, -1, 0, '', 0]; - } - else { + } + else { ${$PHsource}{$new_file} = [fdb_get($new_file, $$Prun_time), '', 0]; - } - } - } + } + } + } ); if (defined $new_from_rule ) { - rdb_for_one_file( $rule, $new_file, sub{ $$Pfrom_rule = $new_from_rule; }); + rdb_for_one_file( $rule, $new_file, sub{ $$Pfrom_rule = $new_from_rule; }); } } #END rdb_ensure_file @@ -7101,7 +7305,7 @@ sub rdb_file_exists { local $exists = 0; rdb_one_rule( $rule, sub{ $exists = exists( ${$PHsource}{$file} ) ? 1:0; } - ); + ); return $exists; } #END rdb_file_exists @@ -7111,7 +7315,7 @@ sub rdb_update_gen_files { # Assumes rule context. Update source files of rule to current state. rdb_do_files( sub{ - if ( exists $generated_exts_all{ ext_no_period($file) } ) {&rdb_update1;} + if ( exists $generated_exts_all{ ext_no_period($file) } ) {&rdb_update1;} } ); } #END rdb_update_gen_files @@ -7312,28 +7516,28 @@ sub parse_quotes { while() { /\G\s*/gc; if ( /\G$/ ) { - last ITEM; - } + last ITEM; + } # Now pos (and \G) is at start of item: PART: while () { - if (/\G([^\s\"]*)/gc) { - $item .= $1; - } + if (/\G([^\s\"]*)/gc) { + $item .= $1; + } if ( /\G\"([^\"]*)\"/gc ) { # Match balanced quotes - $item .= $1; - next PART; - } + $item .= $1; + next PART; + } elsif ( /\G\"(.*)$/gc ) { # Match unbalanced quote - $item .= $1; + $item .= $1; warn "====Non-matching quotes in\n '$_'\n"; - } + } push @results, $item; $item = ''; last PART; - } + } } return @results; } #END parse_quotes @@ -7471,8 +7675,8 @@ sub get_checksum_md5 { if ( $ignore_pattern ) { while (<$input>) { if ( /$ignore_pattern/ ){ - $_= ''; - } + $_= ''; + } $md5->add($_); } } @@ -7566,7 +7770,7 @@ sub find_file_list1 { 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; + push @return_list, $tmp_file; } if ( $find_retcode != 0 ) { push @not_found, $file.$suffix; @@ -7586,9 +7790,9 @@ sub unlink_or_move { } else { foreach (@_) { - if (-e $_ && ! rename $_, "$del_dir/$_" ) { + if (-e $_ && ! rename $_, "$del_dir/$_" ) { warn "$My_name:Cannot move '$_' to '$del_dir/$_'\n"; - } + } } } } @@ -7606,7 +7810,7 @@ sub kpsewhich { foreach (@args) { if ( ! /^-/ ) { $_ = "\"$_\""; - } + } } foreach ($cmd) { s/%[RBTDO]//g; @@ -7617,7 +7821,7 @@ sub kpsewhich { open $fh, "$cmd|" or die "Cannot open pipe for \"$cmd\"\n"; while ( <$fh> ) { - s/^\s*//; + s/^\s*//; s/\s*$//; push @found, $_; } @@ -7645,12 +7849,12 @@ sub remove_cus_dep { while ($i <= $#cus_dep_list) { # Use \Q and \E round directory name in regex to avoid interpretation # of metacharacters in directory name: - if ( $cus_dep_list[$i] =~ /^\Q$from_ext $to_ext \E/ ) { - splice @cus_dep_list, $i, 1; - } - else { - $i++; - } + if ( $cus_dep_list[$i] =~ /^\Q$from_ext $to_ext \E/ ) { + splice @cus_dep_list, $i, 1; + } + else { + $i++; + } } } @@ -7662,6 +7866,22 @@ sub show_cus_dep { #################################################### +sub add_aux_hook { + # Usage: add_aux_hook( sub_name ) + # Add the name subroutine to the array of hooks for + # processing lines of aux files. + # The argument is either a string naming the subroutine, e.g. + # add_aux_hook( 'subname' ); + # or a Perl reference to the subroutine, e.g., + # add_aux_hook( \&subname ); + # It is also possible to use an anonymous subroutine, e.g., + # add_aux_hook( sub{ code of subroutine... } ); + my ($sub_name) = @_; + push @aux_hooks, $sub_name; +} + +#################################################### + sub add_input_ext { # Usage: add_input_ext( rule, ext, ... ) # Add extension(s) (specified without a leading period) to the @@ -7724,8 +7944,8 @@ sub find_dirs { = sub { ## Subroutine for use in File::find ## Check to see if we have a directory - if (-d) { push @result, $File::Find::name; } - }; + if (-d) { push @result, $File::Find::name; } + }; foreach my $directory (@_) { my $recurse = ( $directory =~ m[//$] ); # Remove all trailing /s, since directory name with trailing / @@ -7733,16 +7953,16 @@ sub find_dirs { $directory =~ s[/+$][]; # Similarly for MSWin reverse slash $directory =~ s[\\+$][]; - if ( ! -e $directory ){ + if ( ! -e $directory ){ next; - } - elsif ( $recurse ){ + } + elsif ( $recurse ){ # Recursively search directory find( $find_action, $directory ); - } + } else { push @result, $directory; - } + } } return @result; } @@ -7758,9 +7978,9 @@ sub uniq my $first = 1; while (@_) { - $current = shift; + $current = shift; if ($first || ($current ne $prev) ) - { + { push @sort, $current; $prev = $current; $first = 0; @@ -7855,7 +8075,7 @@ sub split_search_path my @list = split( /$separator/, $search_path); if ( $search_path =~ /$separator$/ ) { # If search path ends in a blank item, the split subroutine - # won't have picked it up. + # won't have picked it up. # So add it to the list by hand: push @list, ""; } @@ -7885,7 +8105,7 @@ sub tempfile1 { or next; close(TMP); return $tmp_file; - } + } } die "$My_name.tempfile1: BUG TO ARRIVE HERE\n"; } @@ -7965,7 +8185,7 @@ sub Run { # or the return value of the Perl subroutine. my $cmd_line = $_[0]; if ( $cmd_line eq '' ) { - traceback( "$My_name: Bug OR configuration error\n". + traceback( "$My_name: Bug OR configuration error\n". " In run of '$rule', attempt to run a null program" ); return (0, 1); } @@ -7975,22 +8195,27 @@ sub Run { while ( $cmd_line =~ s/^start +// ) { # But first remove extra starts (which may have been inserted # to force a command to be run detached, when the command - # already contained a "start"). + # already contained a "start"). $detach = 1; } if ( $cmd_line =~ s/^nostart +// ) { $detach = 0; } if ( $cmd_line =~ /^internal\s+([a-zA-Z_]\w*)\s+(.*)$/ ) { - my $routine = $1; - my @args = parse_quotes( $2 ); - warn "$My_name: calling $routine( @args )\n"; + my $routine = $1; + my @args = parse_quotes( $2 ); + warn "$My_name: calling $routine( @args )\n"; return ( 0, &$routine( @args ) ); } + elsif ( $cmd_line =~ /^internal\s+([a-zA-Z_]\w*)\s*$/ ) { + my $routine = $1; + warn "$My_name: calling $routine()\n"; + return ( 0, &$routine() ); + } elsif ( $cmd_line =~ /^NONE/ ) { warn "$My_name: ", "Program not implemented for this version. Command line:\n"; - warn " '$cmd_line'\n"; + warn " '$cmd_line'\n"; return (0, 1); } elsif ($detach) { @@ -8027,7 +8252,7 @@ sub Run_Detached { if ( $cmd_line =~ /^NONE / ) { warn "$My_name: ", "Program not implemented for this version. Command line:\n"; - warn " '$cmd_line'\n"; + warn " '$cmd_line'\n"; return (0, 1); } @@ -8044,10 +8269,10 @@ sub Run_Detached { ## warn "Run_Detached.UNIX: B pid=$pid\n"; if ( ! defined $pid ) { ## warn "Run_Detached.UNIX: C\n"; - warn "$My_name: Could not fork to run the following command:\n"; + warn "$My_name: Could not fork to run the following command:\n"; warn " '$cmd_line'\n"; return (0, 1); - } + } elsif( $pid == 0 ){ ## warn "Run_Detached.UNIX: D\n"; # Forked child process arrives here @@ -8096,7 +8321,7 @@ sub find_process_id { shift(@ps_output); # Discard the header line from ps foreach (@ps_output) { - next unless ( /$looking_for/ ) ; + next unless ( /$looking_for/ ) ; my @ps_line = split ('\s+'); # OLD return($ps_line[$pid_position]); push @found, $ps_line[$pid_position]; @@ -8133,7 +8358,7 @@ sub cache_good_cwd { chomp $Win_cwd; if ( $Win_cwd ) { $cwd = $Win_cwd; - } + } else { warn "$My_name: Could not correctly run command\n", " '$cmd'\n", @@ -8141,7 +8366,7 @@ sub cache_good_cwd { " '$cwd'\n", " The result was\n", " 'Win_cwd'\n"; - } + } } $cache{cwd} = $cwd; } # END cache_good_cwd diff --git a/Master/texmf-dist/source/support/latexmk/latexmk.bat b/Master/texmf-dist/source/support/latexmk/latexmk.bat index 48e01d6e5e1..f119082adac 100755 --- a/Master/texmf-dist/source/support/latexmk/latexmk.bat +++ b/Master/texmf-dist/source/support/latexmk/latexmk.bat @@ -1,5 +1,5 @@ -Rem Execute latexmk.pl, searching for it in the PATH -Rem Assume perl is in the PATH. If not, you should replace 'perl' by -Rem the full pathname of the perl executable, e.g., 'C:\perl\bin\perl.exe' - -perl -S latexmk.pl %1 %2 %3 %4 %5 %6 %7 %8 %9 +Rem Execute latexmk.pl, searching for it in the PATH
+Rem Assume perl is in the PATH. If not, you should replace 'perl' by
+Rem the full pathname of the perl executable, e.g., 'C:\perl\bin\perl.exe'
+
+perl -S latexmk.pl %1 %2 %3 %4 %5 %6 %7 %8 %9
|