texlive[59081] trunk: latexmk (5may21)

commits+karl at tug.org commits+karl at tug.org
Wed May 5 00:31:39 CEST 2021


Revision: 59081
          http://tug.org/svn/texlive?view=revision&revision=59081
Author:   karl
Date:     2021-05-05 00:31:39 +0200 (Wed, 05 May 2021)
Log Message:
-----------
latexmk (5may21)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl
    trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl
    trunk/Build/source/texk/texlive/linked_scripts/texlive/updmap.pl
    trunk/Master/texmf-dist/doc/man/man1/latexmk.1
    trunk/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf
    trunk/Master/texmf-dist/doc/support/latexmk/CHANGES
    trunk/Master/texmf-dist/doc/support/latexmk/INSTALL
    trunk/Master/texmf-dist/doc/support/latexmk/README
    trunk/Master/texmf-dist/doc/support/latexmk/latexmk.pdf
    trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt
    trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl

Modified: trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl	2021-05-04 22:31:00 UTC (rev 59080)
+++ trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl	2021-05-04 22:31:39 UTC (rev 59081)
@@ -26,141 +26,38 @@
 ##
 ##
 ##
-##   Modification log from 1 Jan 2020 onwards in detail
+##   Modification log from 14 Apr 2021 onwards in detail
 ##
+##  3 May 2021 John Collins  Minor corrections
+## 30 Apr 2021 John Collins  Revert the change of 14-15 Apr, by removing the
+##                           of cwd().  That gave sometimes obnoxiously slow
+##                           parsing of big log files, because of the slowness
+##                           of large number of calls to cwd() caused by calls
+##                           to sub normalize_filename. I think I am mistaken
+##                           that cwd() could possibly give a different result
+##                           than getcwd(), whose cached result is used by
+##                           my goodcwd(). That idea was my motivation on 14 Apr.
+## 22 Apr 2021 John Collins  Clean up aux and out_dir code.
+## 21 Apr 2021 John Collins  Clean up some comments
+##                           Add in emulation of -aux-directory.  On by
+##                           default.
+## 20 Apr 2021 John Collins  Add -dALLOWPSTRANSPARENCY option to ps2pdf and
+##                           dvi2pdf. That avoids problems with recent
+##                           ghostscript versions when, e.g., pstricks is used.
+## 16 Apr 2021 John Collins  Better normalization of aux_dir and out_dir, so
+##                that TEXMFOUTPUT, and the source and dest names for bibtex
+##                and makeindex allow them to work always when the aux_dir
+##                is **not** below cwd, at least under TeX Live. With MiKTeX
+##                bibtex works even without special precautions for aux_dir
+##                not below cwd.  But makeindex doesn't work in this case,
+##                even if TEXMFOUTPUT is set correctly.
 ## 14-15 Apr 2021 John Collins  In normalize_filename, try both good_cwd() and
 ##                           cwd() for removing directory component.
-##                           That improves clean up.
-##                           V. 4.72b
-## 14 Apr 2021 John Collins  Allow index instead of makeindex in indexfudge options
-## 12 Apr 2021 John Collins  Start to fix bug on not-found files with out_dir = .
-## 11 Apr 2021 John Collins  V. 4.72a.
-##                           Modify contents of minimal aux file.
-##  9 Apr 2021 John Collins  Correct bug that if on one run of latexmk a
-##                           missing file was detected and the file was
-##                           later created, then a subsequent run of latexmk
-##                           didn't cause a recompilation.  The cause was an
-##                           error in latexmk's initialization of its file
-##                           database.
-##                           V. 4.72.
-## 12 Jan 2021 John Collins  Correct parse_log
-## 28 Dec 2020 John Collins  Process -output-format=fmt option rather than passing it to *latex
-## 26-27 Dec 2020 John Collins  Deal with bug exposed by chapterbib.  (It involved
-##                           incorrect attempt to deal with filenames specified
-##                           relative to aux_dir.
-## 14 Dec 2020 John Collins  Try to solve problems of normalization of source
-##                           name and general normalization of file names.
-## 10 Dec 2020 John Collins  Set up run_makeindex and $makeindex_fudge, just as
-##                           for bibtex, and corresponding CL options.
-##                           Revert changes to normalize_filename, they aren't
-##                           needed any more.
-##                           Normalize filenames in rdb_ensure_file.
-## 25 Nov 2020 John Collins  Revert to default $bibtex_fudge to 1
-##                           Rationale: 
-##                           There are enough annoying security-related
-##                           complications in many cases concerning
-##                           filenames with a path component given to
-##                           bibtex, that it is better to do the cd trick
-##                           by default.  In addition there are some
-##                           interesting incompatibilities between TeXLive
-##                           and MiKTeX.  In the rare (I suspect) cases
-##                           where the fudge fails, the user can always
-##                           turn it off, of course.
-##                           I should do same fudge for makeindex. 
-##                           Comment out warning when bibtex fudge is used.
-## 18 Nov 2020 John Collins  Add options -bibtexfudge, -bibtexfudge-, -nobibtexfudge,
-##                           so that the options are in agreement with documentation
-##                           including historical versions.
-##                           Set environmnent variable TEXMFOUTPUT to the
-##                           aux_dir.  This solves problem that bibtex and
-##                           makeindex sometimes cannot write to the
-##                           aux_dir (for their log and output files). This
-##                           problem occurs notably when the aux_dir is
-##                           specified by an absolute path to a directory that
-##                           is not a subdirectory of the cwd.
-## 12 Nov 2020 John Collins  Correct some aliasing of filenames.
-## 11 Nov 2020 John Collins  Remove some messages.
-##                           Don't allow log file as a source.
-##  2 Nov 2020 John Collins  Refuse to allow main pdf file or main output file to
-##                             be source of a primary rule, and give warning
-##                             about it.  (Concerns at least hyperxmp (2020/10/05 v. 5.6;
-##                             this accesses file system metadata, specifically file size,
-##                             and the fls file therefore lists the pdf file as a source.
-##                             This generally leads to an infinite loop, without a special
-##                             a configuration.)  Hyperxmp v. 5.7 2010/11/01 doesn't give
-##                             this problem.  But the test is still good to have.
-## 23 Oct 2020 John Collins  Fix incorrect $/ in reading rc files
-## 10-15 Oct 2020 John Collins  Correct bug in normalizing filename
-##                           Give .latexmkrc priority over latexmkrc in cwd
-##  8 Oct 2020 John Collins  Restore use Cwd "chdir";.  There's no longer
-##                             a problem with cd
-##  7 Oct 2020 John Collins  Extra diagnostics for reporting normalized aux/out dirs
-##  6 Oct 2020 John Collins  Better normalize etc.
-##  1 Oct 2020 John Collins  Improve some messages.
-## 30 Sep 2020 John Collins  V. 4.70c.
-##                           Clean up some comments.
-## 29 Sep 2020 John Collins  V. 4.70b.
-##                             Correct switch_output.
-##                             Try to ensure bibtex isn't given absolute pathname, when aux_dir
-##                               is under current directory.  (Otherwise bibtex isn't allowed
-##                               to write a bbl file under default TeXLive settings.)
-##                             Add options -bibfudge, -bibfudge-, -nobibfudge.
-## Current version (4.70b, 29 Sep 2020) to CTAN
-## 13 Sep 2020 John Collins  V. 4.70a.  Updates in comments about bibtex.
-## 28 Aug 2020 John Collins  Correct $biber and $bibtex to use %S not %B
-## 24 Aug 2020 John Collins  Make sure bibtex/biber rules when created for
-##                           missing bbl file have correct path for source
-##                           and destination when out/aux dir used.
-## 16 Jun 2020 John Collins  Warning when bibtex fudge is used.
-##                           Change default $bibtex_fudge to 0.  This is safe with
-##                           at least bibtex in TeXLive 2019 or later, and in current
-##                           MiKTeX.  This version of latexmk is distributed in TeXLive
-##                           and MiKTeX with a recent enough version of bibtex.
-##                           Previously, there was a bug in bibtex that prevented it
-##                           working correctly when -output-directory is used.  Latexmk
-##                           took special action to evade the bug, but at the expense
-##                           of problems when a .bib file is specified in a directory
-##                           relative to the document directory.
-##                           V. 4.69c
-##  9 Jun 2020 John Collins  Fix problems with excess calls to parse_log, and messages
-##                             about changing rule structure when .fdb_latexmk file
-##                             does not exist.
-##                           Making quoting (or not) of output and aux directories 
-##                             for option to *latex obey $quote_filenames.
-##  8 Jun 2020 John Collins  Engine detection: note that recent lualatex
-##                           uses luaHBtex, not luatex.  So I modified the one
-##                           place that the name of the $engine is used.
-##  6 May 2020 John Collins  Add diagnostic for changed environment variables
-## 27 Apr 2020 John Collins  Put ./ for latexmkrc files in current directory
-##                           V. 4.69b
-## Current version (4.69a, 17 Apr 2020) to CTAN
-## 16 Apr 2020 John Collins  Correct contents of "All targets (...) are up-to-date" message
-##                           V. 4.69a.
-## 12 Mar 2020 John Collins  Version is 4.69
-##  7 Feb 2020 John Collins  Report rc files read
-##  6 Feb 2020 John Collins  Fix bug when -cd and -outdir are used, and outdir is
-##                             same as document directory.  (Bug is caused by
-##                             problem in perl module Cwd.)
-##  2,3 Feb 2020 John Collins  Correction in find_basename.
-## 31 Jan 2020 John Collins  Cleanup sub exit_msg1: incorrect comment etc.
-##                           Extra @file_not_found entry for message from
-##                             \input on not-found-file
-##                           Remove use of $extension_treatment: Too hard to
-##                             check.  Always use what was called 'unix' method.
-##                           When command-line-specified tex file not found,
-##                             test for cusdep to make it, then try kpsewhich,
-##                             and only if all 3 fail report an error.
-## 15 Jan 2020 John Collins  Add -MSWinBackSlash -MSWinBackSlash- options to
-##                             control whether directory separator '\' is
-##                             used for filenames on command line for
-##                             called programs under MSWin.
-##  3 Jan 2020 John Collins  Add -E option to default command for xdvipdfmx, to
-##                             match call made by xetex (see XeTeX_ext.c in
-##                             xetex source).  This forces xdvipdfmx to always
-##                             try to embed fonts, ignoring licensing flags, etc.
+##                           That improves clean up.  At least it could.
+##                V. 4.73.
 ##
 ##
-## 1998-2019, John Collins:  Many improvements and fixes.
+## 1998-2021, John Collins:  Many improvements and fixes.
 ##   See CHANGE-log.txt for full list, and CHANGES for summaries
 ##
 ## Modified by Evan McLean (no longer available for support)
@@ -179,8 +76,8 @@
 
 $my_name = 'latexmk';
 $My_name = 'Latexmk';
-$version_num = '4.72b';
-$version_details = "$My_name, John Collins, 15 April 2021";
+$version_num = '4.73';
+$version_details = "$My_name, John Collins, 3 May 2021";
 
 use Config;
 use File::Basename;
@@ -192,10 +89,6 @@
 # The first does not exist in old versions of Perl, while the second
 # is deprecated in more recent versions and will be removed
 $have_bsd_glob = 0;
-sub my_glob {
-    if ($have_bsd_glob) { return bsd_glob( $_[0] ); }
-    else { return glob( $_[0] ); }
-}
 use File::Glob;
 if ( eval{ File::Glob->import('bsd_glob'); 1; } ) {
     # Success in importing bsd_glob
@@ -212,6 +105,11 @@
 else {
     die "Could not import 'File::Glob:bsd_glob' or 'File::Glob:glob'\n";
 }
+# How I use the result of loading glob routines:
+sub my_glob {
+    if ($have_bsd_glob) { return bsd_glob( $_[0] ); }
+    else { return glob( $_[0] ); }
+}
 
 use File::Path 2.08 qw( make_path );
 use FileHandle;
@@ -281,7 +179,9 @@
 #        See subroutine test_fix_texnames and its call for their use.
 $illegal_in_texname = "\x00\t\f\n\r\$%\\~\x7F";
 
-# Whether to normalize filenames where possible:
+# Whether to normalize aux_dir and out_dir where possible.
+# This is important when these directories aren't subdirectories of the cwd,
+# and TeXLive's makeindex and/or bibtex are used.
 $normalize_names = 2;  # Strongest kind.
 
 ## Hash mapping file extension (w/o period, e.g., 'eps') to a single regexp,
@@ -300,7 +200,6 @@
 #  are of a fixed size (as with a date/time stamp).
 %hash_calc_ignore_pattern =();
 
-
 # Specification of templates for extra rules.
 # See subroutine rdb_initialize_rules for examples of rule templates, and
 # how they get used to construct rules.
@@ -359,6 +258,10 @@
 $lualatex_silent_switch  = '-interaction=batchmode';
 $xelatex_silent_switch  = '-interaction=batchmode';
 
+# Whether to emulate -aux-directory, so we can use it on system(s) (TeXLive)
+# that don't support it:
+$emulate_aux = 1;
+
 %input_extensions = ();
 # %input_extensions maps primary_rule_name to pointer to hash of file extensions
 #    used for extensionless files specified in the source file by constructs
@@ -566,13 +469,14 @@
                       # makeindex writing to aux_dir when it is not specified
                       # as a subdirectory of cwd.
 
-## Command to convert dvi file to pdf file directly:
-$dvipdf  = 'dvipdf %O %S %D';
+## Command to convert dvi file to pdf file directly.
+#   Use option -dALLOWPSTRANSPARENCY so that it works with documents
+#   using pstricks etc:
+$dvipdf  = 'dvipdf -dALLOWPSTRANSPARENCY %O %S %D';
 # N.B. Standard dvipdf runs dvips and gs with their silent switch, so for
 #      standard dvipdf $dvipdf_silent_switch is unneeded, but innocuous. 
 #      But dvipdfmx can be used instead, and it has a silent switch (-q).
 #      So implementing $dvipdf_silent_switch is useful.
-
 $dvipdf_silent_switch  = '-q';
 
 ## Command to convert dvi file to ps file:
@@ -588,8 +492,10 @@
 # Switch(es) to make dvips silent:
 $dvips_silent_switch  = '-q';
 
-## Command to convert ps file to pdf file:
-$ps2pdf = 'ps2pdf  %O %S %D';
+## Command to convert ps file to pdf file.
+#   Use option -dALLOWPSTRANSPARENCY so that it works with documents
+#   using pstricks etc:
+$ps2pdf = 'ps2pdf -dALLOWPSTRANSPARENCY %O %S %D';
 
 ## Command to convert xdv file to pdf file
 $xdvipdfmx  = 'xdvipdfmx -E -o %D %O %S';
@@ -1100,10 +1006,13 @@
                         # invoked on multiple files.
 $out_dir = '';          # Directory for output files.  
                         # Cf. --output-directory of current *latex
+                        # Blank means default, i.e., cwd.
 $aux_dir = '';          # Directory for aux files (log, aux, etc).
                         # Cf. --aux-directory of current *latex in MiKTeX.
+                        # Blank means default, i.e., same as $out_dir.
+                        # Note that these values get modified when
+                        # processing a .tex file.
 
-
 ## default flag settings.
 $recorder = 1;          # Whether to use recorder option on latex/pdflatex
 $silent = 0;            # Silence latex's messages?
@@ -1692,6 +1601,8 @@
   elsif (/^-diagnostics/) { $diagnostics = 1; }
   elsif (/^-dvi$/)   { $dvi_mode = 1; }
   elsif (/^-dvi-$/)  { $dvi_mode = 0; }
+  elsif (/^-emulate-aux-dir$/) { $emulate_aux = 1; }
+  elsif (/^-emulate-aux-dir-$/) { $emulate_aux = 0; }
   elsif (/^-f$/)     { $force_mode = 1; }
   elsif (/^-f-$/)    { $force_mode = 0; }
   elsif (/^-g$/)     { $go_mode = 1; }
@@ -1752,6 +1663,7 @@
       # N.B. This has already been obeyed.
   }
   elsif (/^-nobib(tex|)fudge$/) { $bibtex_fudge = 0; }
+  elsif (/^-noemulate-aux-dir$/) { $emulate_aux = 0; }
   elsif (/^-no(make|)indexfudge$/) { $makeindex_fudge = 0; }
   elsif ( /^-output-directory=(.*)$/ ||/^-outdir=(.*)$/ ) {
       $out_dir = $1;
@@ -1958,7 +1870,8 @@
    unless $silent;
 
 
-if ( ($out_dir ne '') && ($aux_dir eq '') ){
+if ( $aux_dir eq '' ){
+# ????????????This may be wrong, given MiKTeX's behavior
     $aux_dir = $out_dir;
 }
 
@@ -2373,59 +2286,11 @@
     local $pdflatex = $pdflatex;
     local $xelatex = $xelatex;
 
-    # Ensure the output/auxiliary directories exist, if need be
-    if ( $out_dir ) {
-        if ( ! -e $out_dir ) {
-             warn "$My_name: making output directory '$out_dir'\n"
-                if ! $silent;
-             make_path $out_dir;
-        }
-        elsif ( ! -d $out_dir ) {
-            warn "$My_name: you requested output directory '$out_dir',\n",
-                 "     but an ordinary file of the same name exists, which will\n",
-                 "     probably give an error later\n";
-        }
-    }
+    &normalize_aux_out_ETC;
 
-    if ( $aux_dir && ($aux_dir ne $out_dir) ) {
-        # N.B. If $aux_dir and $out_dir are the same, then the -output-directory
-        # option is sufficient, especially because the -aux-directory exists
-        # only in MiKTeX, not in TeXLive.
-        if ( ! -e $aux_dir ) {
-            warn "$My_name: making auxiliary directory '$aux_dir'\n"
-               if ! $silent;
-            make_path $aux_dir;
-        }
-        elsif ( ! -d $aux_dir ) {
-            warn "$My_name: you requested aux directory '$aux_dir',\n",
-                 "     but an ordinary file of the same name exists, which will\n",
-                 "     probably give an error later\n";
-        }
-    }
+    # Set -output-directory and -aux-directory options for *latex
+    &set_aux_out_options;
 
-    if ($normalize_names) {
-        $aux_dir = normalize_filename($aux_dir);
-        $out_dir = normalize_filename($out_dir);
-    }
-    set_dirs_etc();
-    if ($diagnostics) {
-        warn "$My_name: Cwd: '", good_cwd(), "'\n";
-        warn "$My_name: Normalized aux dir and out dir: '$aux_dir', '$out_dir'\n";
-        warn "$My_name: and combining forms: '$aux_dir1', '$out_dir1'\n";
-    }
-    if ( $out_dir && ($out_dir ne '.') ) {
-        add_option( "-output-directory=$quote$out_dir$quote",
-                \$latex, \$pdflatex, \$lualatex, \$xelatex );
-    }
-    if ( $aux_dir && ($aux_dir ne '.') && ($aux_dir ne $out_dir) ) {
-        # N.B. If $aux_dir and $out_dir are the same, then the -output-directory
-        # option is sufficient, especially because the -aux-directory exists
-        # only in MiKTeX, not in TeXLive.
-        add_option( "-aux-directory=$quote%V$quote",
-                    \$latex, \$pdflatex, \$lualatex, \$xelatex );
-    }
-
-
     &set_names;
     
     # For use under error conditions:
@@ -2438,7 +2303,6 @@
     rdb_one_rule( 'view', sub{ $view_file = $$Psource; } );
 
     if ( $cleanup_mode > 0 ) {
-# ?? MAY NEED TO FIX THE FOLLOWING IF $aux_dir or $out_dir IS SET.
         my %other_generated = ();
         my @index_bibtex_generated = ();
         my @aux_files = ();
@@ -2742,14 +2606,10 @@
 }
 
 if ( $where_log == 2 ) {
-    warn "$My_name: You requested aux_dir '$aux_dir_requested',\n".
-         "  but '$aux_dir' was used by the *latex engine.\n".
-         "  That indicates a configuration error.\n";
-    if ( ($tex_distribution !~ /^MiKTeX/i) && ($aux_dir_requested ne $out_dir_requested) ) {
-        warn "  Probably you set different aux and out directories,\n".
-             "  but that is not supported by your TeX distribution.\n".
-             "  The only current distribution supporting this is MiKTeX.\n";
-    }
+    warn "$My_name: You requested aux_dir '$aux_dir_requested',\n",
+         "  but '$out_dir' was used for the .log file etc, and I couldn't\n",
+         "  correct the problem, even by setting emulation of aux_dir on.\n",
+         "  There is a strong suspicion of a bug in $my_name or a configuration error.\n";
 }
 
 
@@ -2850,27 +2710,27 @@
             print "Set environment variable $var='$ENV{$var}'\n";
         }
     }
-}
+} #END ensure_path
 
 #############################################################
 
-sub set_dirs_etc {
-    # Normalize $out_dir and $aux_dir, so that if they have a non-trivial last
-    # component, any trailing '/' is removed.
-    # Then set $out_dir1 and $aux_dir1 to have a directory separator character
-    # '/' added if needed to give forms suitable for direct concatenation with
-    # a filename.  These are needed for substitutions like %Y%R.
-    # Nasty cases of dir_name: "/"  on all systems,  "A:", "A:/" etc on MS-Win
-    # Then set some TeX-related environment variables.
+sub normalize_aux_out_ETC {
+    # 1. Normalize $out_dir and $aux_dir, so that if they have a non-trivial last
+    #    component, any trailing '/' is removed.
+    # 2. Set $out_dir1 and $aux_dir1 to have a directory separator character
+    #    '/' added if needed to give forms suitable for direct concatenation with
+    #    a filename.  These are needed for substitutions like %Y%R.
+    #    Nasty cases of dir_name: "/"  on all systems,  "A:", "A:/" etc on MS-Win
+    # 3. Set some TeX-related environment variables.
+    # 4. Ensure the aux and out directories exist
+    $aux_dir = dirname_no_tail( $aux_dir );
     $out_dir = dirname_no_tail( $out_dir );
-    $aux_dir = dirname_no_tail( $aux_dir );
+    if ($normalize_names) {
+        foreach ( $aux_dir, $out_dir ) { $_ = normalize_filename_abs($_); }
+    }
+    $aux_dir1 = $aux_dir;
     $out_dir1 = $out_dir;
-    $aux_dir1 = $aux_dir;
-    $out_dir_abs = abs_path($out_dir);
-    $out_dir1_abs = $out_dir_abs;
-    $aux_dir_abs = abs_path($aux_dir);
-    $aux_dir1_abs = $aux_dir_abs;
-    foreach ( $aux_dir1, $out_dir1, $aux_dir1_abs, $out_dir1_abs ) {
+    foreach ( $aux_dir1, $out_dir1 ) {
         if ( ($_ ne '')  && ! m([\\/\:]$) ) {
             # Add a trailing '/' if necessary to give a string that can be
             # correctly concatenated with a filename:
@@ -2891,33 +2751,91 @@
         # Convert $aux_dir to absolute path to make the search path invariant
         # under change of directory.
         foreach ( 'BIBINPUTS', 'TEXINPUTS' ) {
-            ensure_path( $_, $aux_dir_abs );
+            ensure_path( $_, $aux_dir );
         }
         # Set TEXMFOUTPUT  so that when the aux_dir is not a subdirectory
         # of the cwd (or below), bibtex and makeindex can write to it.
         # Otherwise, security precautions in these programs will prevent
-        # them from writing there.
+        # them from writing there, on TeXLive.  MiKTeX is different: see
+        # below.
         # The security issues concern **document-controlled** writing of
         # files, when bibtex or makeindex is invoked directly by a
         # document. In contrast, here $aux_dir is set by latexmk, not by
         # the document. (See the main texmf.cnf file in a TeXLive
-        # distribution for some information.)  The security issues here
-        # appear to be identical to those when giving an
-        # -output-directory=... option to *latex.
-        # CONSTRAINTS:
-        # 1. This works in the aux dir is an an absolute path pointing to a
-        #    higher-level directory, but NOT when it is a relative path, e.g.,
-        #    "../build".
-        # 2. The directories for files on the command line given to bibtex
-        #    and makeindex must be exactly the same as the value in $aux_dir.
-        #    This is ensured by the way in which the command strings are
-        #    constructed.
-        $ENV{TEXMFOUTPUT} = $aux_dir_abs;
+        # distribution for some information on security issues.)
+        #
+        # PROPERTIES:
+        # 1. In TeXLive, the use of TEXMFOUTPUT works if
+        #    (a) the directory given is an an absolute path,
+        #    AND (b) the path contains no .. pieces
+        #    AND (c) the directory component of the filename(s) on the command
+        #       line for makeindex and bibtex is exactly the same string as
+        #       for the directory named in TEXMFOUTPUT.
+        # 2. In MiKTeX, bibtex has none of the security restrictions; but
+        #    makeindex has, and the use of TEXMFOUTPUT has no effect.
+        # So the following is only needed for TeXLive.
+        $ENV{TEXMFOUTPUT} = $aux_dir;
     }
-}
+    
+    # Ensure the output/auxiliary directories exist, if need be
+    if ( $out_dir ) {
+        make_path_mod( $out_dir,  'output' );
+    }
 
+    if ( $aux_dir && ($aux_dir ne $out_dir) ) {
+        make_path_mod( $aux_dir,  'auxiliary' );
+    }
+
+    if ($diagnostics) {
+        warn "$My_name: Cwd: '", good_cwd(), "'\n";
+        warn "$My_name: Normalized aux dir and out dir: '$aux_dir', '$out_dir'\n";
+        warn "$My_name: and combining forms: '$aux_dir1', '$out_dir1'\n";
+    }
+
+}  #END normalize_aux_out_ETC
+
 #############################################################
 
+sub set_aux_out_options {
+    # Set -output-directory and -aux-directory options for *latex.  Use
+    # placeholders for substitutions so that correct value is put in at
+    # runtime.
+    # N.B. At this point, empty $aux_dir means cwd, unlike the definition
+    #      used in initialization stage of latexmk.
+    if ($emulate_aux) {
+        if ( $aux_dir && ($aux_dir ne '.') ) {
+            # N.B. Set **output** directory to **aux_dir**, rather than
+            # out_dir. If aux and out dirs are are different, then we'll move
+            # the relevant files (.pdf, .ps, .dvi, .xdv, .fls to the output
+            # directory after running *latex.
+            add_option( "-output-directory=%V",
+                        \$latex, \$pdflatex, \$lualatex, \$xelatex );
+        }
+    }
+    else {
+        if ( $out_dir && ($out_dir ne '.') ) {
+            add_option( "-output-directory=%W",
+                        \$latex, \$pdflatex, \$lualatex, \$xelatex );
+        }
+        if ( $aux_dir ne $out_dir ) {
+            # N.B. If $aux_dir and $out_dir are the same, then the
+            # -output-directory option is sufficient, especially because
+            # the -aux-directory exists only in MiKTeX, not in TeXLive.
+            if ($aux_dir) {
+                add_option( "-aux-directory=%V",
+                            \$latex, \$pdflatex, \$lualatex, \$xelatex );
+            }
+            else {
+                # Must have a non-empty string for argument of -aux-directory:
+                add_option( "-aux-directory=.",
+                            \$latex, \$pdflatex, \$lualatex, \$xelatex );
+            }
+        }
+    }
+} #END set_aux_out_options
+
+#############################################################
+
 sub fix_cmds {
    # If commands do not have placeholders for %S etc, put them in
     foreach ($latex, $lualatex, $pdflatex, $xelatex, $lpr, $lpr_dvi, $lpr_pdf,
@@ -3284,7 +3202,6 @@
         # Source does not exist.  Users of this rule will need to turn
         # it off when custom dependencies are reset
         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";
@@ -3976,6 +3893,8 @@
   "   -dvi-  - turn off required dvi\n",
   "   -e <code> - Execute specified Perl code (as part of latexmk start-up\n",
   "               code)\n",
+  "   -emulate-aux-dir  - emulate -aux-directory option for *latex\n",
+  "   -emulate-aux-dir- - use -aux-directory option with *latex\n",
   "   -f     - force continued processing past errors\n",
   "   -f-    - turn off forced continuing processing past errors\n",
   "   -gg    - Super go mode: clean out generated files (-CA), and then\n",
@@ -4014,6 +3933,7 @@
   "   -nobibtex      - never use bibtex\n",
   "   -nobibfudge or -nobibtexfudge - don't change directory when running bibtex\n",
   "   -nodependents  - Do not show list of dependent files after processing\n",
+  "   -noemulate-aux-dir - use -aux-directory option with *latex\n",
   "   -noindexfudge or -nomakeindexfudge - don't change directory when running makeindex\n",
   "   -norc          - omit automatic reading of system, user and project rc files\n",
   "   -output-directory=dir or -outdir=dir\n",
@@ -4519,6 +4439,25 @@
 
 #**************************************************
 
+sub move_out_files_from_aux {
+    # Move output and fls files to out_dir
+    # Omit 'xdv', that goes to aux_dir (as with MiKTeX). It's not final output.
+    foreach my $ext ( 'fls', 'dvi', 'pdf', 'ps' ) {
+        # Include fls file, because MiKTeX puts it in out_dir, rather than
+        # aux_dir, which would seem more natural.  We must maintain
+        # compatibility.
+        my $from =  "$aux_dir1$root_filename.$ext";
+        my $to = "$out_dir1$root_filename.$ext" ;
+        if ( test_gen_file( $from ) ) {
+            if (! $silent) { warn "$My_name: Moving '$from' to '$to'\n"; }
+            my $ret = move( $from, $to );
+            if ( ! $ret ) { die "  That failed, with message '$!'\n";}
+        }
+    }
+}
+
+#***************************************************
+
 sub parse_log {
 # Scan log file for: dependent files
 #    reference_changed, bad_reference, bad_citation
@@ -5335,10 +5274,11 @@
     #           to (*)latex.
     #        Use of $aux_dir different to $out_dir, when (*)latex doesn't support
     #           the -aux-directory option (notably with TeXLive distribution).
-    if ($where_log >= 0) {
-        # .log file was found on previous run.  No need to repeat search, since
-        # if the location were to change from run to run, we'd have other
-        # serious difficulties that are to hard to deal with.
+    if ($where_log == 1) {
+        # .log file was found in correct place on previous run.
+        # So there's no need to repeat search, since if the location were to
+        # change from run to run, we'd have other serious difficulties that are
+        # to hard to deal with.
         return;
     }
     if ( test_gen_file( "$aux_dir1$root_filename.log" ) ) {
@@ -5349,9 +5289,22 @@
         # .log file is in out_dir not in aux_dir.
         # Presumably there is a configuration error
         # that prevents aux_dir from being used by latex.
-        # So change $aux_dir to the actually used value.
-        $where_log = 2;
-        $aux_dir = $out_dir;
+        warn "$My_name: .log file in '$out_dir' instead of expected '$aux_dir'\n";
+        if ($emulate_aux) {
+            warn "    But emulate_aux is on, so that should not happen\n",
+                 "    I'll switch aux_dir to equal out_dir\n";
+            $where_log = 2;
+            $aux_dir = $out_dir;
+        }
+        else {
+            warn "    But emulate_aux is off.  So I'll turn it on.\n";
+            $emulate_aux = 1;
+            foreach ( $$Pext_cmd, $$Pint_cmd ) {
+                s/ -output-directory=[^ ]*(?= )//g;
+                s/ -aux(-directory=[^ ]*)(?= )/ -output$1/g;
+            }
+            print "========== '$$Pext_cmd' '$$Pint_cmd'\n";
+        }
     }
     elsif ( test_gen_file( "$root_filename.log" ) ) {
         # .log file is not in out_dir nor in aux_dir, but is in cwd.
@@ -5373,7 +5326,7 @@
         warn "$My_name: Changed aux_dir from '$aux_dir_requested' to '$aux_dir'\n".
              "          to allow for probable configuration error\n";
         # Allow for the changes associated with change of $aux_dir:
-        &set_dirs_etc;
+        &normalize_aux_out_ETC;
         &set_names;
         warn "$My_name: Actual .log file is\n",
              "     '$log_name'\n",
@@ -5381,11 +5334,12 @@
              "     '$aux_dir_requested/$root_filename.log'\n",
              "   that seemed to be intended.\n";
     }
-}
+} #END find_set_log
 
 #************************************************************
 
 sub parse_fls {
+    my $start_time = processing_time();  
     my ($fls_name, $Pinputs, $Poutputs, $Pfirst_read_after_write, $Ppwd_latex ) = @_;
     %$Pinputs = %$Poutputs = %$Pfirst_read_after_write = ();
     my $fls_file = new FileHandle;
@@ -5538,10 +5492,9 @@
    my ( $file, @dirs ) = @_;
    my $file1 = $file;   # Saved original value
    my $cwd = good_cwd();
-   my $cwd1 = cwd();
    # Normalize files to use / to separate directory components:
    # (Note both / and \ are allowed under MSWin.)
-   foreach ($cwd, $cwd1, $file,  @dirs) {
+   foreach ($cwd, $file,  @dirs) {
        s(\\)(/)g;
        $_ = dirname_no_tail( $_ );
    }
@@ -5549,7 +5502,7 @@
    # Remove initial component equal to current working directory.
    # Use \Q and \E round directory name in regex to avoid interpretation
    #   of metacharacters in directory name:
-   foreach my $dir ( @dirs, '.', $cwd, $cwd1 ) {
+   foreach my $dir ( @dirs, '.', $cwd ) {
        if ( $dir =~ /^\s*$/ ) {
            # All spaces, nothing to do.
            next;
@@ -5571,10 +5524,19 @@
        $file = '';
    }
    return $file;
-}
+} #END normalize_filename
 
 # ------------------------------
 
+sub normalize_filename_abs {
+    # Convert filename to be either
+    # absolute path in canonical form
+    # or relative to cwd.
+    return normalize_filename( abs_path($_[0]) );
+}
+
+#-----------------------------
+
 sub normalize_clean_filename {
    # Usage: normalize_clean_filename( filename [, extra forms of name of cwd] )
    # Same as normalize_filename, but first remove any double quotes, as
@@ -7647,8 +7609,6 @@
         if ( !$$Plast_message ) {
             $$Plast_message = "Run of rule '$rule' gave a non-zero error code";
         }
-# !!??        $failure_msg = $$Plast_message;
-        
     }
     foreach ( keys %$PHsource_rules ) {
         $$PHsource_rules{$_} = $pass{$_};
@@ -7935,6 +7895,9 @@
         }
     }
 
+    if ( ($$Pcmd_type eq 'primary') && ( $aux_dir ne $out_dir ) ) {
+        &move_out_files_from_aux;
+    }
     $updated = 1;
     if ($$Ptest_kind == 3) { 
         # We are time-criterion first time only.  Now switch to
@@ -8070,7 +8033,6 @@
 #-----------------
 
 sub rdb_primary_run {
-#?? See multipass_run in previous version Aug 2007 for issues
     # Call: rdb_primary_run
     # Assumes contexts for: recursion, make, & rule.
     # Assumes (a) the rule is a primary, 
@@ -8157,12 +8119,6 @@
 
     $updated = 1;    # Flag that some dependent file has been remade
 
-#??    # Fix the state of the files as of now: this will solve the
-#??    # problem of latex and pdflatex interfering with each other,
-#??    # at the expense of some non-optimality
-#??    #??  Check this is correct:
-#??    &rdb_update_files;
-
     if ( $diagnostics ) {
         print "$My_name: Rules after run: \n";
         rdb_show();
@@ -8251,7 +8207,6 @@
     if ($$Pout_of_date) {
         push @rules_to_apply, $rule;
     }
-#??     print "======== flag: $rule $$Pout_of_date ==========\n";
 } #END rdb_flag_changes_here
 
 #************************************************************
@@ -8405,7 +8360,6 @@
 #
 # When the action subroutine(s) are actually called, a context for the
 # rule and/or file (as appropriate) is given by setting named
-## NEW ??
 # variables to REFERENCES to the relevant data values.  These can be
 # used to retrieve and set the data values.  As a convention,
 # references to scalars are given by variables named start with "$P",
@@ -8413,12 +8367,6 @@
 # "$PAint_cmd", and references to hashes with "$PH", as in "$PHsource".
 # After the action subroutine has finished, checks for data
 # consistency may be made. 
-## ??? OLD
-# variables to the relevant data values.  After the action subroutine
-# has finished, the database is updated with the values of these named
-# variables, with any necessary consistency checks.  Thus the action
-# subroutines can act on sensibly named variables without needed to
-# know the database structure.  
 #
 # The only routines that actually use the database structure and need
 # to be changed if that is changed are:  (a) the routines rdb_one_rule
@@ -9417,9 +9365,6 @@
   my $ref_search = $_[3];
   my @not_found = ();
 
-#??  show_array( "=====find_file_list1.  Suffix: '$suffix'\n Source:",  @$ref_input );
-#??  show_array( " Bibinputs:",  @$ref_search );
-
   my @return_list = ();    # Generate list in local array, since input 
                            # and output arrays may be same
   my $retcode = 0;
@@ -9467,6 +9412,33 @@
 
 #************************************************************
 
+sub make_path_mod {
+    my $dir = $_[0];
+    my $title = $_[1];
+    my $ret = 0;
+    if ( (! -e $dir) && (! -l $dir) ) {
+        warn "$My_name: making $title directory '$dir'\n"
+            if ! $silent;
+        make_path( $dir );
+    }
+    elsif ( -l $dir ) {
+        $ret = 1;
+        warn "$My_name: you requested $title directory '$dir',\n",
+             "    but there exists a symlink that has the same name, but\n",
+             "    does not point to anything.  I won't create a directory, and\n",
+             "    that will probably give an error later.\n";
+    }
+    elsif ( ! -d $dir ) {
+        $ret = 2;
+        warn "$My_name: you requested $title directory '$dir',\n",
+             "    but an ordinary file of the same name exists, which will\n",
+             "    probably give an error later.\n";
+    }
+    return $ret;
+}
+
+#************************************************************
+
 sub kpsewhich {
 # Usage: kpsewhich( filespec, ...)
 # Returns array of files with paths as found by kpsewhich

Modified: trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl	2021-05-04 22:31:00 UTC (rev 59080)
+++ trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl	2021-05-04 22:31:39 UTC (rev 59081)
@@ -1,12 +1,12 @@
 #!/usr/bin/env perl
-# $Id: tlmgr.pl 58961 2021-04-22 00:55:07Z preining $
+# $Id: tlmgr.pl 59064 2021-05-03 17:37:44Z karl $
 #
 # Copyright 2008-2021 Norbert Preining
 # This file is licensed under the GNU General Public License version 2
 # or any later version.
 
-my $svnrev = '$Revision: 58961 $';
-my $datrev = '$Date: 2021-04-21 17:55:07 -0700 (Wed, 21 Apr 2021) $';
+my $svnrev = '$Revision: 59064 $';
+my $datrev = '$Date: 2021-05-03 19:37:44 +0200 (Mon, 03 May 2021) $';
 my $tlmgrrevision;
 my $tlmgrversion;
 my $prg;
@@ -5249,6 +5249,11 @@
   return if !check_on_writable();
 
   init_local_db(0);
+  if (defined($opts{"dry-run"})) {
+    # TODO: we should implement --dry-run for remove --all.
+    print "Sorry, no --dry-run with remove --all; goodbye.\n";
+    return ($F_OK | $F_NOPOSTACTION);
+  }
   my $force = defined($opts{"force"}) ? $opts{"force"} : 0;
   if (!$force) {
     print("If you answer yes here the whole TeX Live installation here,\n",
@@ -5255,7 +5260,7 @@
           "under ", $localtlpdb->root, ", will be removed!\n");
     print "Remove TeX Live (y/N): ";
     my $yesno = <STDIN>;
-    if ($yesno !~ m/^y(es)?$/i) {
+    if (!defined($yesno) || $yesno !~ m/^y(es)?$/i) {
       print "Ok, cancelling the removal!\n";
       return ($F_OK | $F_NOPOSTACTION);
     }
@@ -7215,14 +7220,16 @@
   # check for being frozen
   if ($remotetlpdb->config_frozen) {
     my $frozen_msg = <<FROZEN;
-TeX Live $TeXLive::TLConfig::ReleaseYear is frozen and will no longer
-be routinely updated. This happens when a new release is made.
+TeX Live $TeXLive::TLConfig::ReleaseYear is frozen
+and will no longer be routinely updated.  This happens when a new
+release is made, or will be made shortly.
 
-If you're willing to help with pretesting the new release, and we hope
-you are, (when pretests are available), please read
-https://tug.org/texlive/pretest.html.
+If you're willing to help with pretesting a new release, and we hope
+you are, please see https://tug.org/texlive/pretest.html.
 
-Otherwise, just wait, and the new release will be ready in due time.
+For general status information about TeX Live, see its home page:
+https://tug.org/texlive
+
 FROZEN
     # don't die here, we want to allow updates even if tlnet is frozen!
     tlwarn($frozen_msg);
@@ -8870,9 +8877,10 @@
 
 =back
 
-This action does not automatically remove symlinks to executables from
-system directories; you need to run C<tlmgr path remove> (L</path>)
-yourself if you are using this feature and want stale symlinks removed.
+Except with C<--all>, this C<remove> action does not automatically
+remove symlinks to executables from system directories; you need to run
+C<tlmgr path remove> (L</path>) yourself if you remove an individual
+package with a symlink in a system directory.
 
 =head2 repository
 
@@ -10116,7 +10124,7 @@
 distribution (L<https://tug.org/texlive>) and both are licensed under the
 GNU General Public License Version 2 or later.
 
-$Id: tlmgr.pl 58961 2021-04-22 00:55:07Z preining $
+$Id: tlmgr.pl 59064 2021-05-03 17:37:44Z karl $
 =cut
 
 # test HTML version: pod2html --cachedir=/tmp tlmgr.pl >/tmp/tlmgr.html

Modified: trunk/Build/source/texk/texlive/linked_scripts/texlive/updmap.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/texlive/updmap.pl	2021-05-04 22:31:00 UTC (rev 59080)
+++ trunk/Build/source/texk/texlive/linked_scripts/texlive/updmap.pl	2021-05-04 22:31:39 UTC (rev 59081)
@@ -1,5 +1,5 @@
 #!/usr/bin/env perl
-# $Id: updmap.pl 58960 2021-04-22 00:52:00Z preining $
+# $Id: updmap.pl 59062 2021-05-03 15:46:54Z karl $
 # updmap - maintain map files for outline fonts.
 # (Maintained in TeX Live:Master/texmf-dist/scripts/texlive.)
 # 
@@ -14,7 +14,7 @@
 # the original versions were licensed under the following agreement:
 # Anyone may freely use, modify, and/or distribute this file, without
 
-my $svnid = '$Id: updmap.pl 58960 2021-04-22 00:52:00Z preining $';
+my $svnid = '$Id: updmap.pl 59062 2021-05-03 15:46:54Z karl $';
 
 my $TEXMFROOT;
 BEGIN {
@@ -27,10 +27,10 @@
   unshift(@INC, "$TEXMFROOT/tlpkg");
 }
 
-my $lastchdate = '$Date: 2021-04-22 02:52:00 +0200 (Thu, 22 Apr 2021) $';
+my $lastchdate = '$Date: 2021-05-03 17:46:54 +0200 (Mon, 03 May 2021) $';
 $lastchdate =~ s/^\$Date:\s*//;
 $lastchdate =~ s/ \(.*$//;
-my $svnrev = '$Revision: 58960 $';
+my $svnrev = '$Revision: 59062 $';
 $svnrev =~ s/^\$Revision:\s*//;
 $svnrev =~ s/\s*\$$//;
 my $version = "r$svnrev ($lastchdate)";
@@ -1338,26 +1338,27 @@
     }
   }
 
-  # all kind of warning messages
+  # all kinds of warning messages
   if ($first_time_creation_in_usermode) {
     print_and_log("
 *************************************************************
 *                                                           *
 * WARNING: you are switching to updmap's per-user mappings. *
-*            Please read the following explanations.        *
+*         Please read the following warnings!               *
 *                                                           *
 *************************************************************
 
-You have run updmap-user (as opposed to updmap-sys) for the first time; this
-has created configuration files which are local to your personal account.
+You have run updmap-user (as opposed to updmap-sys) for the first time;
+this has created configuration files which are local to your personal account.
 
-Any changes in system map files will *not* be automatically reflected in
-your files; furthermore, running updmap-sys will no longer have any
-effect for you.  As a consequence, you have to rerun updmap-user yourself
-after any change in the system directories; for example, if a new font
-package is added.
+From now on, any changes in system map files will *not* be automatically
+reflected in your files; furthermore, running updmap-sys (as is done
+automatically) will no longer have any effect for you.
 
-See http://tug.org/texlive/scripts-sys-user.html for details.
+As a consequence, you yourself have to rerun updmap-user yourself after
+any change in the *system* directories! For example, if a new font
+package is added or existing mappings change, which happens frequently.
+See https://tug.org/texlive/scripts-sys-user.html for details.
 
 If you want to undo this, remove the files mentioned above.
 
@@ -2262,10 +2263,10 @@
    or: $prg-user [OPTION] ... [COMMAND]
    or: $prg-sys  [OPTION] ... [COMMAND]
 
-Update the default font map files used by pdftex (pdftex.map), dvips
-(psfonts.map), and dvipdfm(x), and optionally pxdvi, as determined by
-all configuration files updmap.cfg (the ones returned by running
-"kpsewhich --all updmap.cfg", but see below).
+Update the default font map files used by pdftex and dvipdfm(x)
+(pdftex.map), dvips (psfonts.map), and optionally pxdvi, as determined
+by all configuration files updmap.cfg (usually the ones returned by
+running "kpsewhich --all updmap.cfg", but see below).
 
 Among other things, these map files are used to determine which fonts
 should be used as bitmaps and which as outlines, and to determine which
@@ -2274,12 +2275,12 @@
 updmap-sys (or updmap -sys) is intended to affect the system-wide 
 configuration, while updmap-user (or updmap -user) affects personal
 configuration files only, overriding the system files.  
+
 As a consequence, once updmap-user has been run, even a single time,
-running updmap-sys no longer has any effect.  (updmap-sys issues a
-warning in this situation.)
+running updmap-sys no longer has any effect.  updmap-sys issues a
+warning about this, since it is rarely desirable.
+See https://tug.org/texlive/scripts-sys-user.html for details.
 
-See http://tug.org/texlive/scripts-sys-user.html for details.
-
 By default, the TeX filename database (ls-R) is also updated.
 
 The updmap system is regrettably complicated, for both inherent and
@@ -2295,8 +2296,6 @@
   installation time, by the system installer or the package manager or
   by hand, and not (by default) by updmap.
 
-Good luck.
-
 Options:
   --cnffile FILE            read FILE for the updmap configuration 
                              (can be given multiple times, in which case
@@ -2309,7 +2308,7 @@
   --copy                    cp generic files rather than using symlinks
   --force                   recreate files even if config hasn't changed
   --nomkmap                 do not recreate map files
-  --nohash                  do not run texhash
+  --nohash                  do not run mktexlsr (a.k.a. texhash)
   --sys                     affect system-wide files (equivalent to updmap-sys)
   --user                    affect personal files (equivalent to updmap-user)
   -n, --dry-run             only show the configuration, no output
@@ -2316,21 +2315,21 @@
   --quiet, --silent         reduce verbosity
 
 Commands:
-  --help                    show this message and exit
-  --version                 show version information and exit
-  --showoption OPTION       show the current setting of OPTION
-  --showoptions OPTION      show possible settings for OPTION
-  --setoption OPTION VALUE  set OPTION to value; option names below
-  --setoption OPTION=VALUE  as above, just different syntax
-  --enable MAPTYPE MAPFILE  add "MAPTYPE MAPFILE" to updmap.cfg,
-                             where MAPTYPE is Map, MixedMap, or KanjiMap
-  --enable Map=MAPFILE      add \"Map MAPFILE\" to updmap.cfg
-  --enable MixedMap=MAPFILE add \"MixedMap MAPFILE\" to updmap.cfg
-  --enable KanjiMap=MAPFILE add \"KanjiMap MAPFILE\" to updmap.cfg
-  --disable MAPFILE         disable MAPFILE, of whatever type
-  --listmaps                list all maps (details below)
-  --listavailablemaps       list available maps (details below)
-  --syncwithtrees           disable unavailable map files in updmap.cfg
+  --help                     show this message and exit
+  --version                  show version information and exit
+  --showoption OPTION        show the current setting of OPTION
+  --showoptions OPTION       show possible settings for OPTION
+  --setoption OPTION VALUE   set OPTION to value; option names below
+  --setoption OPTION=VALUE   as above, just different syntax
+  --enable MAPTYPE MAPFILE   add "MAPTYPE MAPFILE" to updmap.cfg,
+                              where MAPTYPE is Map, MixedMap, or KanjiMap
+  --enable Map=MAPFILE       add \"Map MAPFILE\" to updmap.cfg
+  --enable MixedMap=MAPFILE  add \"MixedMap MAPFILE\" to updmap.cfg
+  --enable KanjiMap=MAPFILE  add \"KanjiMap MAPFILE\" to updmap.cfg
+  --disable MAPFILE          disable MAPFILE, of whatever type
+  --listmaps                 list all maps (details below)
+  --listavailablemaps        list available maps (details below)
+  --syncwithtrees            disable unavailable map files in updmap.cfg
 
 The main output:
 
@@ -2360,7 +2359,7 @@
   
   The only difference between Map and MixedMap is that MixedMap entries
   are not added to psfonts_pk.map.  The purpose is to help users with
-  devices that render Type 1 outline fonts worse than mode-tuned Type 1
+  devices that render Type 1 outline fonts worse than mode-tuned Type 3
   bitmap fonts.  So, MixedMap is used for fonts that are available as
   both Type 1 and Metafont.
 
@@ -2463,7 +2462,7 @@
   config file, a higher-level one can be used.  That way, the
   distribution's settings can be overridden system-wide using
   TEXMFLOCAL, and system settings can be overridden again in a
-  particular user's TEXMFHOME.
+  particular user's TEXMFHOME or TEXMFCONFIG.
 
 Resolving multiple definitions of a font:
 
@@ -2522,11 +2521,11 @@
 The log file is written to TEXMFVAR/web2c/updmap.log.
 
 For step-by-step instructions on making new fonts known to TeX, read
-http://tug.org/fonts/fontinstall.html.  For even more terse
+https://tug.org/fonts/fontinstall.html.  For even more terse
 instructions, read the beginning of the main updmap.cfg file.
 
 Report bugs to: tex-live\@tug.org
-TeX Live home page: <http://tug.org/texlive/>
+TeX Live home page: <https://tug.org/texlive/>
 EOF
 ;
   print &version();

Modified: trunk/Master/texmf-dist/doc/man/man1/latexmk.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/latexmk.1	2021-05-04 22:31:00 UTC (rev 59080)
+++ trunk/Master/texmf-dist/doc/man/man1/latexmk.1	2021-05-04 22:31:39 UTC (rev 59081)
@@ -1,4 +1,4 @@
-.TH LATEXMK 1 "15 April 2021" ""
+.TH LATEXMK 1 "3 May 2021" ""
 .SH NAME
 latexmk \- generate LaTeX document
 .SH SYNOPSIS
@@ -2315,7 +2315,7 @@
 use the MS-Windows \fIstart\fR program, which will cause to be run
 whatever command the system has associated with .dvi files.]
 .TP
-.B $dvipdf ["dvipdf %O %S %D"]
+.B $dvipdf ["dvipdf -dALLOWPSTRANSPARENCY %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 different order:
 
@@ -3010,7 +3010,7 @@
 "ps -f -u $ENV{USER}" under other operating systems (including Linux).
 In these specifications "$ENV{USER}" is substituted by the username.
 .TP
-.B $ps2pdf ["ps2pdf  %O %S %D"]
+.B $ps2pdf ["ps2pdf -dALLOWPSTRANSPARENCY %O %S %D"]
 Command to convert .ps to .pdf file.  
 .TP
 .B $ps_filter [empty]
@@ -3919,7 +3919,7 @@
 harvested too easily.)
 .SH AUTHOR
 Current version, by John Collins 
-(Version 4.72b).
+(Version 4.73).
 Report bugs etc to his e-mail (jcc8 at psu.edu).
 
 Released version can be obtained from CTAN:

Modified: trunk/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/latexmk/CHANGES
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/CHANGES	2021-05-04 22:31:00 UTC (rev 59080)
+++ trunk/Master/texmf-dist/doc/support/latexmk/CHANGES	2021-05-04 22:31:39 UTC (rev 59081)
@@ -755,3 +755,10 @@
   Improve handling of situation when auxdir or outdir are specified as
     absolute paths. 
   Miscellaneous bug corrections, especially about consistent normalizations
+
+From v. 4.72b to 4.73
+  Correct slowness in parsing some log files.
+  Provide emulation of -aux-directory, so that it can be used with
+    implementation other than MiKTeX.  (At the moment the only documentation
+    of this feature is given by latexmk --help.)
+

Modified: trunk/Master/texmf-dist/doc/support/latexmk/INSTALL
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/INSTALL	2021-05-04 22:31:00 UTC (rev 59080)
+++ trunk/Master/texmf-dist/doc/support/latexmk/INSTALL	2021-05-04 22:31:39 UTC (rev 59081)
@@ -1,6 +1,6 @@
             INSTALLING latexmk
             ==================
-      (Version 4.72b, 15 April 2021)
+      (Version 4.73, 3 May 2021)
 
             John Collins
             Physics Department

Modified: trunk/Master/texmf-dist/doc/support/latexmk/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/README	2021-05-04 22:31:00 UTC (rev 59080)
+++ trunk/Master/texmf-dist/doc/support/latexmk/README	2021-05-04 22:31:39 UTC (rev 59081)
@@ -1,5 +1,5 @@
-Latexmk, version 4.72b, 15 April 2021
--------------------------------------
+Latexmk, version 4.73, 3 May 2021
+---------------------------------
 
 Latexmk completely automates the process of generating a LaTeX
 document.  Essentially, it is a highly specialized cousin of the
@@ -87,7 +87,7 @@
 
 John Collins
 ---------------------------- "latexmk -h" ----------------------------
-Latexmk 4.72b: Automatic LaTeX document generation routine
+Latexmk 4.73: Automatic LaTeX document generation routine
 
 Usage: latexmk [latexmk_options] [filename ...]
 
@@ -127,6 +127,8 @@
    -dvi-  - turn off required dvi
    -e <code> - Execute specified Perl code (as part of latexmk start-up
                code)
+   -emulate-aux-dir  - emulate -aux-directory option for *latex
+   -emulate-aux-dir- - use -aux-directory option with *latex
    -f     - force continued processing past errors
    -f-    - turn off forced continuing processing past errors
    -gg    - Super go mode: clean out generated files (-CA), and then
@@ -165,6 +167,7 @@
    -nobibtex      - never use bibtex
    -nobibfudge or -nobibtexfudge - don't change directory when running bibtex
    -nodependents  - Do not show list of dependent files after processing
+   -noemulate-aux-dir - use -aux-directory option with *latex
    -noindexfudge or -nomakeindexfudge - don't change directory when running makeindex
    -norc          - omit automatic reading of system, user and project rc files
    -output-directory=dir or -outdir=dir

Modified: trunk/Master/texmf-dist/doc/support/latexmk/latexmk.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt	2021-05-04 22:31:00 UTC (rev 59080)
+++ trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt	2021-05-04 22:31:39 UTC (rev 59081)
@@ -61,7 +61,7 @@
 
 
 
-                                 15 April 2021                               1
+                                  3 May 2021                                 1
 
 
 
@@ -127,7 +127,7 @@
 
 
 
-                                 15 April 2021                               2
+                                  3 May 2021                                 2
 
 
 
@@ -193,7 +193,7 @@
 
 
 
-                                 15 April 2021                               3
+                                  3 May 2021                                 3
 
 
 
@@ -259,7 +259,7 @@
 
 
 
-                                 15 April 2021                               4
+                                  3 May 2021                                 4
 
 
 
@@ -325,7 +325,7 @@
 
 
 
-                                 15 April 2021                               5
+                                  3 May 2021                                 5
 
 
 
@@ -391,7 +391,7 @@
 
 
 
-                                 15 April 2021                               6
+                                  3 May 2021                                 6
 
 
 
@@ -457,7 +457,7 @@
 
 
 
-                                 15 April 2021                               7
+                                  3 May 2021                                 7
 
 
 
@@ -523,7 +523,7 @@
 
 
 
-                                 15 April 2021                               8
+                                  3 May 2021                                 8
 
 
 
@@ -589,7 +589,7 @@
 
 
 
-                                 15 April 2021                               9
+                                  3 May 2021                                 9
 
 
 
@@ -655,7 +655,7 @@
 
 
 
-                                 15 April 2021                              10
+                                  3 May 2021                                10
 
 
 
@@ -721,7 +721,7 @@
 
 
 
-                                 15 April 2021                              11
+                                  3 May 2021                                11
 
 
 
@@ -787,7 +787,7 @@
 
 
 
-                                 15 April 2021                              12
+                                  3 May 2021                                12
 
 
 
@@ -853,7 +853,7 @@
 
 
 
-                                 15 April 2021                              13
+                                  3 May 2021                                13
 
 
 
@@ -919,7 +919,7 @@
 
 
 
-                                 15 April 2021                              14
+                                  3 May 2021                                14
 
 
 
@@ -985,7 +985,7 @@
 
 
 
-                                 15 April 2021                              15
+                                  3 May 2021                                15
 
 
 
@@ -1051,7 +1051,7 @@
 
 
 
-                                 15 April 2021                              16
+                                  3 May 2021                                16
 
 
 
@@ -1117,7 +1117,7 @@
 
 
 
-                                 15 April 2021                              17
+                                  3 May 2021                                17
 
 
 
@@ -1183,7 +1183,7 @@
 
 
 
-                                 15 April 2021                              18
+                                  3 May 2021                                18
 
 
 
@@ -1249,7 +1249,7 @@
 
 
 
-                                 15 April 2021                              19
+                                  3 May 2021                                19
 
 
 
@@ -1315,7 +1315,7 @@
 
 
 
-                                 15 April 2021                              20
+                                  3 May 2021                                20
 
 
 
@@ -1381,7 +1381,7 @@
 
 
 
-                                 15 April 2021                              21
+                                  3 May 2021                                21
 
 
 
@@ -1447,7 +1447,7 @@
 
 
 
-                                 15 April 2021                              22
+                                  3 May 2021                                22
 
 
 
@@ -1513,7 +1513,7 @@
 
 
 
-                                 15 April 2021                              23
+                                  3 May 2021                                23
 
 
 
@@ -1579,7 +1579,7 @@
 
 
 
-                                 15 April 2021                              24
+                                  3 May 2021                                24
 
 
 
@@ -1645,7 +1645,7 @@
 
 
 
-                                 15 April 2021                              25
+                                  3 May 2021                                25
 
 
 
@@ -1711,7 +1711,7 @@
 
 
 
-                                 15 April 2021                              26
+                                  3 May 2021                                26
 
 
 
@@ -1777,7 +1777,7 @@
 
 
 
-                                 15 April 2021                              27
+                                  3 May 2021                                27
 
 
 
@@ -1843,7 +1843,7 @@
 
 
 
-                                 15 April 2021                              28
+                                  3 May 2021                                28
 
 
 
@@ -1909,7 +1909,7 @@
 
 
 
-                                 15 April 2021                              29
+                                  3 May 2021                                29
 
 
 
@@ -1975,7 +1975,7 @@
 
 
 
-                                 15 April 2021                              30
+                                  3 May 2021                                30
 
 
 
@@ -2041,7 +2041,7 @@
 
 
 
-                                 15 April 2021                              31
+                                  3 May 2021                                31
 
 
 
@@ -2107,7 +2107,7 @@
 
 
 
-                                 15 April 2021                              32
+                                  3 May 2021                                32
 
 
 
@@ -2173,7 +2173,7 @@
 
 
 
-                                 15 April 2021                              33
+                                  3 May 2021                                33
 
 
 
@@ -2239,7 +2239,7 @@
 
 
 
-                                 15 April 2021                              34
+                                  3 May 2021                                34
 
 
 
@@ -2305,7 +2305,7 @@
 
 
 
-                                 15 April 2021                              35
+                                  3 May 2021                                35
 
 
 
@@ -2371,7 +2371,7 @@
 
 
 
-                                 15 April 2021                              36
+                                  3 May 2021                                36
 
 
 
@@ -2437,7 +2437,7 @@
 
 
 
-                                 15 April 2021                              37
+                                  3 May 2021                                37
 
 
 
@@ -2503,7 +2503,7 @@
 
 
 
-                                 15 April 2021                              38
+                                  3 May 2021                                38
 
 
 
@@ -2569,7 +2569,7 @@
 
 
 
-                                 15 April 2021                              39
+                                  3 May 2021                                39
 
 
 
@@ -2635,7 +2635,7 @@
 
 
 
-                                 15 April 2021                              40
+                                  3 May 2021                                40
 
 
 
@@ -2701,7 +2701,7 @@
 
 
 
-                                 15 April 2021                              41
+                                  3 May 2021                                41
 
 
 
@@ -2732,7 +2732,7 @@
               the MS-Windows start program, which will cause to be  run  what-
               ever command the system has associated with .dvi files.]
 
-       $dvipdf ["dvipdf %O %S %D"]
+       $dvipdf ["dvipdf -dALLOWPSTRANSPARENCY %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
               different order:
@@ -2767,7 +2767,7 @@
 
 
 
-                                 15 April 2021                              42
+                                  3 May 2021                                42
 
 
 
@@ -2833,7 +2833,7 @@
 
 
 
-                                 15 April 2021                              43
+                                  3 May 2021                                43
 
 
 
@@ -2899,7 +2899,7 @@
 
 
 
-                                 15 April 2021                              44
+                                  3 May 2021                                44
 
 
 
@@ -2965,7 +2965,7 @@
 
 
 
-                                 15 April 2021                              45
+                                  3 May 2021                                45
 
 
 
@@ -3031,7 +3031,7 @@
 
 
 
-                                 15 April 2021                              46
+                                  3 May 2021                                46
 
 
 
@@ -3097,7 +3097,7 @@
 
 
 
-                                 15 April 2021                              47
+                                  3 May 2021                                47
 
 
 
@@ -3163,7 +3163,7 @@
 
 
 
-                                 15 April 2021                              48
+                                  3 May 2021                                48
 
 
 
@@ -3229,7 +3229,7 @@
 
 
 
-                                 15 April 2021                              49
+                                  3 May 2021                                49
 
 
 
@@ -3295,7 +3295,7 @@
 
 
 
-                                 15 April 2021                              50
+                                  3 May 2021                                50
 
 
 
@@ -3361,7 +3361,7 @@
 
 
 
-                                 15 April 2021                              51
+                                  3 May 2021                                51
 
 
 
@@ -3427,7 +3427,7 @@
 
 
 
-                                 15 April 2021                              52
+                                  3 May 2021                                52
 
 
 
@@ -3493,7 +3493,7 @@
 
 
 
-                                 15 April 2021                              53
+                                  3 May 2021                                53
 
 
 
@@ -3559,7 +3559,7 @@
 
 
 
-                                 15 April 2021                              54
+                                  3 May 2021                                54
 
 
 
@@ -3601,7 +3601,7 @@
               (including Linux).  In these specifications "$ENV{USER}" is sub-
               stituted by the username.
 
-       $ps2pdf ["ps2pdf %O %S %D"]
+       $ps2pdf ["ps2pdf -dALLOWPSTRANSPARENCY %O %S %D"]
               Command to convert .ps to .pdf file.
 
        $ps_filter [empty]
@@ -3625,7 +3625,7 @@
 
 
 
-                                 15 April 2021                              55
+                                  3 May 2021                                55
 
 
 
@@ -3691,7 +3691,7 @@
 
 
 
-                                 15 April 2021                              56
+                                  3 May 2021                                56
 
 
 
@@ -3757,7 +3757,7 @@
 
 
 
-                                 15 April 2021                              57
+                                  3 May 2021                                57
 
 
 
@@ -3823,7 +3823,7 @@
 
 
 
-                                 15 April 2021                              58
+                                  3 May 2021                                58
 
 
 
@@ -3889,7 +3889,7 @@
 
 
 
-                                 15 April 2021                              59
+                                  3 May 2021                                59
 
 
 
@@ -3955,7 +3955,7 @@
 
 
 
-                                 15 April 2021                              60
+                                  3 May 2021                                60
 
 
 
@@ -4021,7 +4021,7 @@
 
 
 
-                                 15 April 2021                              61
+                                  3 May 2021                                61
 
 
 
@@ -4087,7 +4087,7 @@
 
 
 
-                                 15 April 2021                              62
+                                  3 May 2021                                62
 
 
 
@@ -4153,7 +4153,7 @@
 
 
 
-                                 15 April 2021                              63
+                                  3 May 2021                                63
 
 
 
@@ -4219,7 +4219,7 @@
 
 
 
-                                 15 April 2021                              64
+                                  3 May 2021                                64
 
 
 
@@ -4285,7 +4285,7 @@
 
 
 
-                                 15 April 2021                              65
+                                  3 May 2021                                65
 
 
 
@@ -4351,7 +4351,7 @@
 
 
 
-                                 15 April 2021                              66
+                                  3 May 2021                                66
 
 
 
@@ -4417,7 +4417,7 @@
 
 
 
-                                 15 April 2021                              67
+                                  3 May 2021                                67
 
 
 
@@ -4483,7 +4483,7 @@
 
 
 
-                                 15 April 2021                              68
+                                  3 May 2021                                68
 
 
 
@@ -4549,7 +4549,7 @@
 
 
 
-                                 15 April 2021                              69
+                                  3 May 2021                                69
 
 
 
@@ -4615,7 +4615,7 @@
 
 
 
-                                 15 April 2021                              70
+                                  3 May 2021                                70
 
 
 
@@ -4681,7 +4681,7 @@
 
 
 
-                                 15 April 2021                              71
+                                  3 May 2021                                71
 
 
 
@@ -4698,7 +4698,7 @@
        dard form to avoid being harvested too easily.)
 
 AUTHOR
-       Current  version,  by John Collins (Version 4.72b).  Report bugs etc to
+       Current  version,  by  John Collins (Version 4.73).  Report bugs etc to
        his e-mail (jcc8 at psu.edu).
 
        Released     version     can      be      obtained      from      CTAN:
@@ -4747,6 +4747,6 @@
 
 
 
-                                 15 April 2021                              72
+                                  3 May 2021                                72
 
 

Modified: trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl	2021-05-04 22:31:00 UTC (rev 59080)
+++ trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl	2021-05-04 22:31:39 UTC (rev 59081)
@@ -26,141 +26,38 @@
 ##
 ##
 ##
-##   Modification log from 1 Jan 2020 onwards in detail
+##   Modification log from 14 Apr 2021 onwards in detail
 ##
+##  3 May 2021 John Collins  Minor corrections
+## 30 Apr 2021 John Collins  Revert the change of 14-15 Apr, by removing the
+##                           of cwd().  That gave sometimes obnoxiously slow
+##                           parsing of big log files, because of the slowness
+##                           of large number of calls to cwd() caused by calls
+##                           to sub normalize_filename. I think I am mistaken
+##                           that cwd() could possibly give a different result
+##                           than getcwd(), whose cached result is used by
+##                           my goodcwd(). That idea was my motivation on 14 Apr.
+## 22 Apr 2021 John Collins  Clean up aux and out_dir code.
+## 21 Apr 2021 John Collins  Clean up some comments
+##                           Add in emulation of -aux-directory.  On by
+##                           default.
+## 20 Apr 2021 John Collins  Add -dALLOWPSTRANSPARENCY option to ps2pdf and
+##                           dvi2pdf. That avoids problems with recent
+##                           ghostscript versions when, e.g., pstricks is used.
+## 16 Apr 2021 John Collins  Better normalization of aux_dir and out_dir, so
+##                that TEXMFOUTPUT, and the source and dest names for bibtex
+##                and makeindex allow them to work always when the aux_dir
+##                is **not** below cwd, at least under TeX Live. With MiKTeX
+##                bibtex works even without special precautions for aux_dir
+##                not below cwd.  But makeindex doesn't work in this case,
+##                even if TEXMFOUTPUT is set correctly.
 ## 14-15 Apr 2021 John Collins  In normalize_filename, try both good_cwd() and
 ##                           cwd() for removing directory component.
-##                           That improves clean up.
-##                           V. 4.72b
-## 14 Apr 2021 John Collins  Allow index instead of makeindex in indexfudge options
-## 12 Apr 2021 John Collins  Start to fix bug on not-found files with out_dir = .
-## 11 Apr 2021 John Collins  V. 4.72a.
-##                           Modify contents of minimal aux file.
-##  9 Apr 2021 John Collins  Correct bug that if on one run of latexmk a
-##                           missing file was detected and the file was
-##                           later created, then a subsequent run of latexmk
-##                           didn't cause a recompilation.  The cause was an
-##                           error in latexmk's initialization of its file
-##                           database.
-##                           V. 4.72.
-## 12 Jan 2021 John Collins  Correct parse_log
-## 28 Dec 2020 John Collins  Process -output-format=fmt option rather than passing it to *latex
-## 26-27 Dec 2020 John Collins  Deal with bug exposed by chapterbib.  (It involved
-##                           incorrect attempt to deal with filenames specified
-##                           relative to aux_dir.
-## 14 Dec 2020 John Collins  Try to solve problems of normalization of source
-##                           name and general normalization of file names.
-## 10 Dec 2020 John Collins  Set up run_makeindex and $makeindex_fudge, just as
-##                           for bibtex, and corresponding CL options.
-##                           Revert changes to normalize_filename, they aren't
-##                           needed any more.
-##                           Normalize filenames in rdb_ensure_file.
-## 25 Nov 2020 John Collins  Revert to default $bibtex_fudge to 1
-##                           Rationale: 
-##                           There are enough annoying security-related
-##                           complications in many cases concerning
-##                           filenames with a path component given to
-##                           bibtex, that it is better to do the cd trick
-##                           by default.  In addition there are some
-##                           interesting incompatibilities between TeXLive
-##                           and MiKTeX.  In the rare (I suspect) cases
-##                           where the fudge fails, the user can always
-##                           turn it off, of course.
-##                           I should do same fudge for makeindex. 
-##                           Comment out warning when bibtex fudge is used.
-## 18 Nov 2020 John Collins  Add options -bibtexfudge, -bibtexfudge-, -nobibtexfudge,
-##                           so that the options are in agreement with documentation
-##                           including historical versions.
-##                           Set environmnent variable TEXMFOUTPUT to the
-##                           aux_dir.  This solves problem that bibtex and
-##                           makeindex sometimes cannot write to the
-##                           aux_dir (for their log and output files). This
-##                           problem occurs notably when the aux_dir is
-##                           specified by an absolute path to a directory that
-##                           is not a subdirectory of the cwd.
-## 12 Nov 2020 John Collins  Correct some aliasing of filenames.
-## 11 Nov 2020 John Collins  Remove some messages.
-##                           Don't allow log file as a source.
-##  2 Nov 2020 John Collins  Refuse to allow main pdf file or main output file to
-##                             be source of a primary rule, and give warning
-##                             about it.  (Concerns at least hyperxmp (2020/10/05 v. 5.6;
-##                             this accesses file system metadata, specifically file size,
-##                             and the fls file therefore lists the pdf file as a source.
-##                             This generally leads to an infinite loop, without a special
-##                             a configuration.)  Hyperxmp v. 5.7 2010/11/01 doesn't give
-##                             this problem.  But the test is still good to have.
-## 23 Oct 2020 John Collins  Fix incorrect $/ in reading rc files
-## 10-15 Oct 2020 John Collins  Correct bug in normalizing filename
-##                           Give .latexmkrc priority over latexmkrc in cwd
-##  8 Oct 2020 John Collins  Restore use Cwd "chdir";.  There's no longer
-##                             a problem with cd
-##  7 Oct 2020 John Collins  Extra diagnostics for reporting normalized aux/out dirs
-##  6 Oct 2020 John Collins  Better normalize etc.
-##  1 Oct 2020 John Collins  Improve some messages.
-## 30 Sep 2020 John Collins  V. 4.70c.
-##                           Clean up some comments.
-## 29 Sep 2020 John Collins  V. 4.70b.
-##                             Correct switch_output.
-##                             Try to ensure bibtex isn't given absolute pathname, when aux_dir
-##                               is under current directory.  (Otherwise bibtex isn't allowed
-##                               to write a bbl file under default TeXLive settings.)
-##                             Add options -bibfudge, -bibfudge-, -nobibfudge.
-## Current version (4.70b, 29 Sep 2020) to CTAN
-## 13 Sep 2020 John Collins  V. 4.70a.  Updates in comments about bibtex.
-## 28 Aug 2020 John Collins  Correct $biber and $bibtex to use %S not %B
-## 24 Aug 2020 John Collins  Make sure bibtex/biber rules when created for
-##                           missing bbl file have correct path for source
-##                           and destination when out/aux dir used.
-## 16 Jun 2020 John Collins  Warning when bibtex fudge is used.
-##                           Change default $bibtex_fudge to 0.  This is safe with
-##                           at least bibtex in TeXLive 2019 or later, and in current
-##                           MiKTeX.  This version of latexmk is distributed in TeXLive
-##                           and MiKTeX with a recent enough version of bibtex.
-##                           Previously, there was a bug in bibtex that prevented it
-##                           working correctly when -output-directory is used.  Latexmk
-##                           took special action to evade the bug, but at the expense
-##                           of problems when a .bib file is specified in a directory
-##                           relative to the document directory.
-##                           V. 4.69c
-##  9 Jun 2020 John Collins  Fix problems with excess calls to parse_log, and messages
-##                             about changing rule structure when .fdb_latexmk file
-##                             does not exist.
-##                           Making quoting (or not) of output and aux directories 
-##                             for option to *latex obey $quote_filenames.
-##  8 Jun 2020 John Collins  Engine detection: note that recent lualatex
-##                           uses luaHBtex, not luatex.  So I modified the one
-##                           place that the name of the $engine is used.
-##  6 May 2020 John Collins  Add diagnostic for changed environment variables
-## 27 Apr 2020 John Collins  Put ./ for latexmkrc files in current directory
-##                           V. 4.69b
-## Current version (4.69a, 17 Apr 2020) to CTAN
-## 16 Apr 2020 John Collins  Correct contents of "All targets (...) are up-to-date" message
-##                           V. 4.69a.
-## 12 Mar 2020 John Collins  Version is 4.69
-##  7 Feb 2020 John Collins  Report rc files read
-##  6 Feb 2020 John Collins  Fix bug when -cd and -outdir are used, and outdir is
-##                             same as document directory.  (Bug is caused by
-##                             problem in perl module Cwd.)
-##  2,3 Feb 2020 John Collins  Correction in find_basename.
-## 31 Jan 2020 John Collins  Cleanup sub exit_msg1: incorrect comment etc.
-##                           Extra @file_not_found entry for message from
-##                             \input on not-found-file
-##                           Remove use of $extension_treatment: Too hard to
-##                             check.  Always use what was called 'unix' method.
-##                           When command-line-specified tex file not found,
-##                             test for cusdep to make it, then try kpsewhich,
-##                             and only if all 3 fail report an error.
-## 15 Jan 2020 John Collins  Add -MSWinBackSlash -MSWinBackSlash- options to
-##                             control whether directory separator '\' is
-##                             used for filenames on command line for
-##                             called programs under MSWin.
-##  3 Jan 2020 John Collins  Add -E option to default command for xdvipdfmx, to
-##                             match call made by xetex (see XeTeX_ext.c in
-##                             xetex source).  This forces xdvipdfmx to always
-##                             try to embed fonts, ignoring licensing flags, etc.
+##                           That improves clean up.  At least it could.
+##                V. 4.73.
 ##
 ##
-## 1998-2019, John Collins:  Many improvements and fixes.
+## 1998-2021, John Collins:  Many improvements and fixes.
 ##   See CHANGE-log.txt for full list, and CHANGES for summaries
 ##
 ## Modified by Evan McLean (no longer available for support)
@@ -179,8 +76,8 @@
 
 $my_name = 'latexmk';
 $My_name = 'Latexmk';
-$version_num = '4.72b';
-$version_details = "$My_name, John Collins, 15 April 2021";
+$version_num = '4.73';
+$version_details = "$My_name, John Collins, 3 May 2021";
 
 use Config;
 use File::Basename;
@@ -192,10 +89,6 @@
 # The first does not exist in old versions of Perl, while the second
 # is deprecated in more recent versions and will be removed
 $have_bsd_glob = 0;
-sub my_glob {
-    if ($have_bsd_glob) { return bsd_glob( $_[0] ); }
-    else { return glob( $_[0] ); }
-}
 use File::Glob;
 if ( eval{ File::Glob->import('bsd_glob'); 1; } ) {
     # Success in importing bsd_glob
@@ -212,6 +105,11 @@
 else {
     die "Could not import 'File::Glob:bsd_glob' or 'File::Glob:glob'\n";
 }
+# How I use the result of loading glob routines:
+sub my_glob {
+    if ($have_bsd_glob) { return bsd_glob( $_[0] ); }
+    else { return glob( $_[0] ); }
+}
 
 use File::Path 2.08 qw( make_path );
 use FileHandle;
@@ -281,7 +179,9 @@
 #        See subroutine test_fix_texnames and its call for their use.
 $illegal_in_texname = "\x00\t\f\n\r\$%\\~\x7F";
 
-# Whether to normalize filenames where possible:
+# Whether to normalize aux_dir and out_dir where possible.
+# This is important when these directories aren't subdirectories of the cwd,
+# and TeXLive's makeindex and/or bibtex are used.
 $normalize_names = 2;  # Strongest kind.
 
 ## Hash mapping file extension (w/o period, e.g., 'eps') to a single regexp,
@@ -300,7 +200,6 @@
 #  are of a fixed size (as with a date/time stamp).
 %hash_calc_ignore_pattern =();
 
-
 # Specification of templates for extra rules.
 # See subroutine rdb_initialize_rules for examples of rule templates, and
 # how they get used to construct rules.
@@ -359,6 +258,10 @@
 $lualatex_silent_switch  = '-interaction=batchmode';
 $xelatex_silent_switch  = '-interaction=batchmode';
 
+# Whether to emulate -aux-directory, so we can use it on system(s) (TeXLive)
+# that don't support it:
+$emulate_aux = 1;
+
 %input_extensions = ();
 # %input_extensions maps primary_rule_name to pointer to hash of file extensions
 #    used for extensionless files specified in the source file by constructs
@@ -566,13 +469,14 @@
                       # makeindex writing to aux_dir when it is not specified
                       # as a subdirectory of cwd.
 
-## Command to convert dvi file to pdf file directly:
-$dvipdf  = 'dvipdf %O %S %D';
+## Command to convert dvi file to pdf file directly.
+#   Use option -dALLOWPSTRANSPARENCY so that it works with documents
+#   using pstricks etc:
+$dvipdf  = 'dvipdf -dALLOWPSTRANSPARENCY %O %S %D';
 # N.B. Standard dvipdf runs dvips and gs with their silent switch, so for
 #      standard dvipdf $dvipdf_silent_switch is unneeded, but innocuous. 
 #      But dvipdfmx can be used instead, and it has a silent switch (-q).
 #      So implementing $dvipdf_silent_switch is useful.
-
 $dvipdf_silent_switch  = '-q';
 
 ## Command to convert dvi file to ps file:
@@ -588,8 +492,10 @@
 # Switch(es) to make dvips silent:
 $dvips_silent_switch  = '-q';
 
-## Command to convert ps file to pdf file:
-$ps2pdf = 'ps2pdf  %O %S %D';
+## Command to convert ps file to pdf file.
+#   Use option -dALLOWPSTRANSPARENCY so that it works with documents
+#   using pstricks etc:
+$ps2pdf = 'ps2pdf -dALLOWPSTRANSPARENCY %O %S %D';
 
 ## Command to convert xdv file to pdf file
 $xdvipdfmx  = 'xdvipdfmx -E -o %D %O %S';
@@ -1100,10 +1006,13 @@
                         # invoked on multiple files.
 $out_dir = '';          # Directory for output files.  
                         # Cf. --output-directory of current *latex
+                        # Blank means default, i.e., cwd.
 $aux_dir = '';          # Directory for aux files (log, aux, etc).
                         # Cf. --aux-directory of current *latex in MiKTeX.
+                        # Blank means default, i.e., same as $out_dir.
+                        # Note that these values get modified when
+                        # processing a .tex file.
 
-
 ## default flag settings.
 $recorder = 1;          # Whether to use recorder option on latex/pdflatex
 $silent = 0;            # Silence latex's messages?
@@ -1692,6 +1601,8 @@
   elsif (/^-diagnostics/) { $diagnostics = 1; }
   elsif (/^-dvi$/)   { $dvi_mode = 1; }
   elsif (/^-dvi-$/)  { $dvi_mode = 0; }
+  elsif (/^-emulate-aux-dir$/) { $emulate_aux = 1; }
+  elsif (/^-emulate-aux-dir-$/) { $emulate_aux = 0; }
   elsif (/^-f$/)     { $force_mode = 1; }
   elsif (/^-f-$/)    { $force_mode = 0; }
   elsif (/^-g$/)     { $go_mode = 1; }
@@ -1752,6 +1663,7 @@
       # N.B. This has already been obeyed.
   }
   elsif (/^-nobib(tex|)fudge$/) { $bibtex_fudge = 0; }
+  elsif (/^-noemulate-aux-dir$/) { $emulate_aux = 0; }
   elsif (/^-no(make|)indexfudge$/) { $makeindex_fudge = 0; }
   elsif ( /^-output-directory=(.*)$/ ||/^-outdir=(.*)$/ ) {
       $out_dir = $1;
@@ -1958,7 +1870,8 @@
    unless $silent;
 
 
-if ( ($out_dir ne '') && ($aux_dir eq '') ){
+if ( $aux_dir eq '' ){
+# ????????????This may be wrong, given MiKTeX's behavior
     $aux_dir = $out_dir;
 }
 
@@ -2373,59 +2286,11 @@
     local $pdflatex = $pdflatex;
     local $xelatex = $xelatex;
 
-    # Ensure the output/auxiliary directories exist, if need be
-    if ( $out_dir ) {
-        if ( ! -e $out_dir ) {
-             warn "$My_name: making output directory '$out_dir'\n"
-                if ! $silent;
-             make_path $out_dir;
-        }
-        elsif ( ! -d $out_dir ) {
-            warn "$My_name: you requested output directory '$out_dir',\n",
-                 "     but an ordinary file of the same name exists, which will\n",
-                 "     probably give an error later\n";
-        }
-    }
+    &normalize_aux_out_ETC;
 
-    if ( $aux_dir && ($aux_dir ne $out_dir) ) {
-        # N.B. If $aux_dir and $out_dir are the same, then the -output-directory
-        # option is sufficient, especially because the -aux-directory exists
-        # only in MiKTeX, not in TeXLive.
-        if ( ! -e $aux_dir ) {
-            warn "$My_name: making auxiliary directory '$aux_dir'\n"
-               if ! $silent;
-            make_path $aux_dir;
-        }
-        elsif ( ! -d $aux_dir ) {
-            warn "$My_name: you requested aux directory '$aux_dir',\n",
-                 "     but an ordinary file of the same name exists, which will\n",
-                 "     probably give an error later\n";
-        }
-    }
+    # Set -output-directory and -aux-directory options for *latex
+    &set_aux_out_options;
 
-    if ($normalize_names) {
-        $aux_dir = normalize_filename($aux_dir);
-        $out_dir = normalize_filename($out_dir);
-    }
-    set_dirs_etc();
-    if ($diagnostics) {
-        warn "$My_name: Cwd: '", good_cwd(), "'\n";
-        warn "$My_name: Normalized aux dir and out dir: '$aux_dir', '$out_dir'\n";
-        warn "$My_name: and combining forms: '$aux_dir1', '$out_dir1'\n";
-    }
-    if ( $out_dir && ($out_dir ne '.') ) {
-        add_option( "-output-directory=$quote$out_dir$quote",
-                \$latex, \$pdflatex, \$lualatex, \$xelatex );
-    }
-    if ( $aux_dir && ($aux_dir ne '.') && ($aux_dir ne $out_dir) ) {
-        # N.B. If $aux_dir and $out_dir are the same, then the -output-directory
-        # option is sufficient, especially because the -aux-directory exists
-        # only in MiKTeX, not in TeXLive.
-        add_option( "-aux-directory=$quote%V$quote",
-                    \$latex, \$pdflatex, \$lualatex, \$xelatex );
-    }
-
-
     &set_names;
     
     # For use under error conditions:
@@ -2438,7 +2303,6 @@
     rdb_one_rule( 'view', sub{ $view_file = $$Psource; } );
 
     if ( $cleanup_mode > 0 ) {
-# ?? MAY NEED TO FIX THE FOLLOWING IF $aux_dir or $out_dir IS SET.
         my %other_generated = ();
         my @index_bibtex_generated = ();
         my @aux_files = ();
@@ -2742,14 +2606,10 @@
 }
 
 if ( $where_log == 2 ) {
-    warn "$My_name: You requested aux_dir '$aux_dir_requested',\n".
-         "  but '$aux_dir' was used by the *latex engine.\n".
-         "  That indicates a configuration error.\n";
-    if ( ($tex_distribution !~ /^MiKTeX/i) && ($aux_dir_requested ne $out_dir_requested) ) {
-        warn "  Probably you set different aux and out directories,\n".
-             "  but that is not supported by your TeX distribution.\n".
-             "  The only current distribution supporting this is MiKTeX.\n";
-    }
+    warn "$My_name: You requested aux_dir '$aux_dir_requested',\n",
+         "  but '$out_dir' was used for the .log file etc, and I couldn't\n",
+         "  correct the problem, even by setting emulation of aux_dir on.\n",
+         "  There is a strong suspicion of a bug in $my_name or a configuration error.\n";
 }
 
 
@@ -2850,27 +2710,27 @@
             print "Set environment variable $var='$ENV{$var}'\n";
         }
     }
-}
+} #END ensure_path
 
 #############################################################
 
-sub set_dirs_etc {
-    # Normalize $out_dir and $aux_dir, so that if they have a non-trivial last
-    # component, any trailing '/' is removed.
-    # Then set $out_dir1 and $aux_dir1 to have a directory separator character
-    # '/' added if needed to give forms suitable for direct concatenation with
-    # a filename.  These are needed for substitutions like %Y%R.
-    # Nasty cases of dir_name: "/"  on all systems,  "A:", "A:/" etc on MS-Win
-    # Then set some TeX-related environment variables.
+sub normalize_aux_out_ETC {
+    # 1. Normalize $out_dir and $aux_dir, so that if they have a non-trivial last
+    #    component, any trailing '/' is removed.
+    # 2. Set $out_dir1 and $aux_dir1 to have a directory separator character
+    #    '/' added if needed to give forms suitable for direct concatenation with
+    #    a filename.  These are needed for substitutions like %Y%R.
+    #    Nasty cases of dir_name: "/"  on all systems,  "A:", "A:/" etc on MS-Win
+    # 3. Set some TeX-related environment variables.
+    # 4. Ensure the aux and out directories exist
+    $aux_dir = dirname_no_tail( $aux_dir );
     $out_dir = dirname_no_tail( $out_dir );
-    $aux_dir = dirname_no_tail( $aux_dir );
+    if ($normalize_names) {
+        foreach ( $aux_dir, $out_dir ) { $_ = normalize_filename_abs($_); }
+    }
+    $aux_dir1 = $aux_dir;
     $out_dir1 = $out_dir;
-    $aux_dir1 = $aux_dir;
-    $out_dir_abs = abs_path($out_dir);
-    $out_dir1_abs = $out_dir_abs;
-    $aux_dir_abs = abs_path($aux_dir);
-    $aux_dir1_abs = $aux_dir_abs;
-    foreach ( $aux_dir1, $out_dir1, $aux_dir1_abs, $out_dir1_abs ) {
+    foreach ( $aux_dir1, $out_dir1 ) {
         if ( ($_ ne '')  && ! m([\\/\:]$) ) {
             # Add a trailing '/' if necessary to give a string that can be
             # correctly concatenated with a filename:
@@ -2891,33 +2751,91 @@
         # Convert $aux_dir to absolute path to make the search path invariant
         # under change of directory.
         foreach ( 'BIBINPUTS', 'TEXINPUTS' ) {
-            ensure_path( $_, $aux_dir_abs );
+            ensure_path( $_, $aux_dir );
         }
         # Set TEXMFOUTPUT  so that when the aux_dir is not a subdirectory
         # of the cwd (or below), bibtex and makeindex can write to it.
         # Otherwise, security precautions in these programs will prevent
-        # them from writing there.
+        # them from writing there, on TeXLive.  MiKTeX is different: see
+        # below.
         # The security issues concern **document-controlled** writing of
         # files, when bibtex or makeindex is invoked directly by a
         # document. In contrast, here $aux_dir is set by latexmk, not by
         # the document. (See the main texmf.cnf file in a TeXLive
-        # distribution for some information.)  The security issues here
-        # appear to be identical to those when giving an
-        # -output-directory=... option to *latex.
-        # CONSTRAINTS:
-        # 1. This works in the aux dir is an an absolute path pointing to a
-        #    higher-level directory, but NOT when it is a relative path, e.g.,
-        #    "../build".
-        # 2. The directories for files on the command line given to bibtex
-        #    and makeindex must be exactly the same as the value in $aux_dir.
-        #    This is ensured by the way in which the command strings are
-        #    constructed.
-        $ENV{TEXMFOUTPUT} = $aux_dir_abs;
+        # distribution for some information on security issues.)
+        #
+        # PROPERTIES:
+        # 1. In TeXLive, the use of TEXMFOUTPUT works if
+        #    (a) the directory given is an an absolute path,
+        #    AND (b) the path contains no .. pieces
+        #    AND (c) the directory component of the filename(s) on the command
+        #       line for makeindex and bibtex is exactly the same string as
+        #       for the directory named in TEXMFOUTPUT.
+        # 2. In MiKTeX, bibtex has none of the security restrictions; but
+        #    makeindex has, and the use of TEXMFOUTPUT has no effect.
+        # So the following is only needed for TeXLive.
+        $ENV{TEXMFOUTPUT} = $aux_dir;
     }
-}
+    
+    # Ensure the output/auxiliary directories exist, if need be
+    if ( $out_dir ) {
+        make_path_mod( $out_dir,  'output' );
+    }
 
+    if ( $aux_dir && ($aux_dir ne $out_dir) ) {
+        make_path_mod( $aux_dir,  'auxiliary' );
+    }
+
+    if ($diagnostics) {
+        warn "$My_name: Cwd: '", good_cwd(), "'\n";
+        warn "$My_name: Normalized aux dir and out dir: '$aux_dir', '$out_dir'\n";
+        warn "$My_name: and combining forms: '$aux_dir1', '$out_dir1'\n";
+    }
+
+}  #END normalize_aux_out_ETC
+
 #############################################################
 
+sub set_aux_out_options {
+    # Set -output-directory and -aux-directory options for *latex.  Use
+    # placeholders for substitutions so that correct value is put in at
+    # runtime.
+    # N.B. At this point, empty $aux_dir means cwd, unlike the definition
+    #      used in initialization stage of latexmk.
+    if ($emulate_aux) {
+        if ( $aux_dir && ($aux_dir ne '.') ) {
+            # N.B. Set **output** directory to **aux_dir**, rather than
+            # out_dir. If aux and out dirs are are different, then we'll move
+            # the relevant files (.pdf, .ps, .dvi, .xdv, .fls to the output
+            # directory after running *latex.
+            add_option( "-output-directory=%V",
+                        \$latex, \$pdflatex, \$lualatex, \$xelatex );
+        }
+    }
+    else {
+        if ( $out_dir && ($out_dir ne '.') ) {
+            add_option( "-output-directory=%W",
+                        \$latex, \$pdflatex, \$lualatex, \$xelatex );
+        }
+        if ( $aux_dir ne $out_dir ) {
+            # N.B. If $aux_dir and $out_dir are the same, then the
+            # -output-directory option is sufficient, especially because
+            # the -aux-directory exists only in MiKTeX, not in TeXLive.
+            if ($aux_dir) {
+                add_option( "-aux-directory=%V",
+                            \$latex, \$pdflatex, \$lualatex, \$xelatex );
+            }
+            else {
+                # Must have a non-empty string for argument of -aux-directory:
+                add_option( "-aux-directory=.",
+                            \$latex, \$pdflatex, \$lualatex, \$xelatex );
+            }
+        }
+    }
+} #END set_aux_out_options
+
+#############################################################
+
 sub fix_cmds {
    # If commands do not have placeholders for %S etc, put them in
     foreach ($latex, $lualatex, $pdflatex, $xelatex, $lpr, $lpr_dvi, $lpr_pdf,
@@ -3284,7 +3202,6 @@
         # Source does not exist.  Users of this rule will need to turn
         # it off when custom dependencies are reset
         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";
@@ -3976,6 +3893,8 @@
   "   -dvi-  - turn off required dvi\n",
   "   -e <code> - Execute specified Perl code (as part of latexmk start-up\n",
   "               code)\n",
+  "   -emulate-aux-dir  - emulate -aux-directory option for *latex\n",
+  "   -emulate-aux-dir- - use -aux-directory option with *latex\n",
   "   -f     - force continued processing past errors\n",
   "   -f-    - turn off forced continuing processing past errors\n",
   "   -gg    - Super go mode: clean out generated files (-CA), and then\n",
@@ -4014,6 +3933,7 @@
   "   -nobibtex      - never use bibtex\n",
   "   -nobibfudge or -nobibtexfudge - don't change directory when running bibtex\n",
   "   -nodependents  - Do not show list of dependent files after processing\n",
+  "   -noemulate-aux-dir - use -aux-directory option with *latex\n",
   "   -noindexfudge or -nomakeindexfudge - don't change directory when running makeindex\n",
   "   -norc          - omit automatic reading of system, user and project rc files\n",
   "   -output-directory=dir or -outdir=dir\n",
@@ -4519,6 +4439,25 @@
 
 #**************************************************
 
+sub move_out_files_from_aux {
+    # Move output and fls files to out_dir
+    # Omit 'xdv', that goes to aux_dir (as with MiKTeX). It's not final output.
+    foreach my $ext ( 'fls', 'dvi', 'pdf', 'ps' ) {
+        # Include fls file, because MiKTeX puts it in out_dir, rather than
+        # aux_dir, which would seem more natural.  We must maintain
+        # compatibility.
+        my $from =  "$aux_dir1$root_filename.$ext";
+        my $to = "$out_dir1$root_filename.$ext" ;
+        if ( test_gen_file( $from ) ) {
+            if (! $silent) { warn "$My_name: Moving '$from' to '$to'\n"; }
+            my $ret = move( $from, $to );
+            if ( ! $ret ) { die "  That failed, with message '$!'\n";}
+        }
+    }
+}
+
+#***************************************************
+
 sub parse_log {
 # Scan log file for: dependent files
 #    reference_changed, bad_reference, bad_citation
@@ -5335,10 +5274,11 @@
     #           to (*)latex.
     #        Use of $aux_dir different to $out_dir, when (*)latex doesn't support
     #           the -aux-directory option (notably with TeXLive distribution).
-    if ($where_log >= 0) {
-        # .log file was found on previous run.  No need to repeat search, since
-        # if the location were to change from run to run, we'd have other
-        # serious difficulties that are to hard to deal with.
+    if ($where_log == 1) {
+        # .log file was found in correct place on previous run.
+        # So there's no need to repeat search, since if the location were to
+        # change from run to run, we'd have other serious difficulties that are
+        # to hard to deal with.
         return;
     }
     if ( test_gen_file( "$aux_dir1$root_filename.log" ) ) {
@@ -5349,9 +5289,22 @@
         # .log file is in out_dir not in aux_dir.
         # Presumably there is a configuration error
         # that prevents aux_dir from being used by latex.
-        # So change $aux_dir to the actually used value.
-        $where_log = 2;
-        $aux_dir = $out_dir;
+        warn "$My_name: .log file in '$out_dir' instead of expected '$aux_dir'\n";
+        if ($emulate_aux) {
+            warn "    But emulate_aux is on, so that should not happen\n",
+                 "    I'll switch aux_dir to equal out_dir\n";
+            $where_log = 2;
+            $aux_dir = $out_dir;
+        }
+        else {
+            warn "    But emulate_aux is off.  So I'll turn it on.\n";
+            $emulate_aux = 1;
+            foreach ( $$Pext_cmd, $$Pint_cmd ) {
+                s/ -output-directory=[^ ]*(?= )//g;
+                s/ -aux(-directory=[^ ]*)(?= )/ -output$1/g;
+            }
+            print "========== '$$Pext_cmd' '$$Pint_cmd'\n";
+        }
     }
     elsif ( test_gen_file( "$root_filename.log" ) ) {
         # .log file is not in out_dir nor in aux_dir, but is in cwd.
@@ -5373,7 +5326,7 @@
         warn "$My_name: Changed aux_dir from '$aux_dir_requested' to '$aux_dir'\n".
              "          to allow for probable configuration error\n";
         # Allow for the changes associated with change of $aux_dir:
-        &set_dirs_etc;
+        &normalize_aux_out_ETC;
         &set_names;
         warn "$My_name: Actual .log file is\n",
              "     '$log_name'\n",
@@ -5381,11 +5334,12 @@
              "     '$aux_dir_requested/$root_filename.log'\n",
              "   that seemed to be intended.\n";
     }
-}
+} #END find_set_log
 
 #************************************************************
 
 sub parse_fls {
+    my $start_time = processing_time();  
     my ($fls_name, $Pinputs, $Poutputs, $Pfirst_read_after_write, $Ppwd_latex ) = @_;
     %$Pinputs = %$Poutputs = %$Pfirst_read_after_write = ();
     my $fls_file = new FileHandle;
@@ -5538,10 +5492,9 @@
    my ( $file, @dirs ) = @_;
    my $file1 = $file;   # Saved original value
    my $cwd = good_cwd();
-   my $cwd1 = cwd();
    # Normalize files to use / to separate directory components:
    # (Note both / and \ are allowed under MSWin.)
-   foreach ($cwd, $cwd1, $file,  @dirs) {
+   foreach ($cwd, $file,  @dirs) {
        s(\\)(/)g;
        $_ = dirname_no_tail( $_ );
    }
@@ -5549,7 +5502,7 @@
    # Remove initial component equal to current working directory.
    # Use \Q and \E round directory name in regex to avoid interpretation
    #   of metacharacters in directory name:
-   foreach my $dir ( @dirs, '.', $cwd, $cwd1 ) {
+   foreach my $dir ( @dirs, '.', $cwd ) {
        if ( $dir =~ /^\s*$/ ) {
            # All spaces, nothing to do.
            next;
@@ -5571,10 +5524,19 @@
        $file = '';
    }
    return $file;
-}
+} #END normalize_filename
 
 # ------------------------------
 
+sub normalize_filename_abs {
+    # Convert filename to be either
+    # absolute path in canonical form
+    # or relative to cwd.
+    return normalize_filename( abs_path($_[0]) );
+}
+
+#-----------------------------
+
 sub normalize_clean_filename {
    # Usage: normalize_clean_filename( filename [, extra forms of name of cwd] )
    # Same as normalize_filename, but first remove any double quotes, as
@@ -7647,8 +7609,6 @@
         if ( !$$Plast_message ) {
             $$Plast_message = "Run of rule '$rule' gave a non-zero error code";
         }
-# !!??        $failure_msg = $$Plast_message;
-        
     }
     foreach ( keys %$PHsource_rules ) {
         $$PHsource_rules{$_} = $pass{$_};
@@ -7935,6 +7895,9 @@
         }
     }
 
+    if ( ($$Pcmd_type eq 'primary') && ( $aux_dir ne $out_dir ) ) {
+        &move_out_files_from_aux;
+    }
     $updated = 1;
     if ($$Ptest_kind == 3) { 
         # We are time-criterion first time only.  Now switch to
@@ -8070,7 +8033,6 @@
 #-----------------
 
 sub rdb_primary_run {
-#?? See multipass_run in previous version Aug 2007 for issues
     # Call: rdb_primary_run
     # Assumes contexts for: recursion, make, & rule.
     # Assumes (a) the rule is a primary, 
@@ -8157,12 +8119,6 @@
 
     $updated = 1;    # Flag that some dependent file has been remade
 
-#??    # Fix the state of the files as of now: this will solve the
-#??    # problem of latex and pdflatex interfering with each other,
-#??    # at the expense of some non-optimality
-#??    #??  Check this is correct:
-#??    &rdb_update_files;
-
     if ( $diagnostics ) {
         print "$My_name: Rules after run: \n";
         rdb_show();
@@ -8251,7 +8207,6 @@
     if ($$Pout_of_date) {
         push @rules_to_apply, $rule;
     }
-#??     print "======== flag: $rule $$Pout_of_date ==========\n";
 } #END rdb_flag_changes_here
 
 #************************************************************
@@ -8405,7 +8360,6 @@
 #
 # When the action subroutine(s) are actually called, a context for the
 # rule and/or file (as appropriate) is given by setting named
-## NEW ??
 # variables to REFERENCES to the relevant data values.  These can be
 # used to retrieve and set the data values.  As a convention,
 # references to scalars are given by variables named start with "$P",
@@ -8413,12 +8367,6 @@
 # "$PAint_cmd", and references to hashes with "$PH", as in "$PHsource".
 # After the action subroutine has finished, checks for data
 # consistency may be made. 
-## ??? OLD
-# variables to the relevant data values.  After the action subroutine
-# has finished, the database is updated with the values of these named
-# variables, with any necessary consistency checks.  Thus the action
-# subroutines can act on sensibly named variables without needed to
-# know the database structure.  
 #
 # The only routines that actually use the database structure and need
 # to be changed if that is changed are:  (a) the routines rdb_one_rule
@@ -9417,9 +9365,6 @@
   my $ref_search = $_[3];
   my @not_found = ();
 
-#??  show_array( "=====find_file_list1.  Suffix: '$suffix'\n Source:",  @$ref_input );
-#??  show_array( " Bibinputs:",  @$ref_search );
-
   my @return_list = ();    # Generate list in local array, since input 
                            # and output arrays may be same
   my $retcode = 0;
@@ -9467,6 +9412,33 @@
 
 #************************************************************
 
+sub make_path_mod {
+    my $dir = $_[0];
+    my $title = $_[1];
+    my $ret = 0;
+    if ( (! -e $dir) && (! -l $dir) ) {
+        warn "$My_name: making $title directory '$dir'\n"
+            if ! $silent;
+        make_path( $dir );
+    }
+    elsif ( -l $dir ) {
+        $ret = 1;
+        warn "$My_name: you requested $title directory '$dir',\n",
+             "    but there exists a symlink that has the same name, but\n",
+             "    does not point to anything.  I won't create a directory, and\n",
+             "    that will probably give an error later.\n";
+    }
+    elsif ( ! -d $dir ) {
+        $ret = 2;
+        warn "$My_name: you requested $title directory '$dir',\n",
+             "    but an ordinary file of the same name exists, which will\n",
+             "    probably give an error later.\n";
+    }
+    return $ret;
+}
+
+#************************************************************
+
 sub kpsewhich {
 # Usage: kpsewhich( filespec, ...)
 # Returns array of files with paths as found by kpsewhich



More information about the tex-live-commits mailing list.