texlive[58886] trunk: latexmk (16apr21)

commits+karl at tug.org commits+karl at tug.org
Fri Apr 16 22:15:34 CEST 2021


Revision: 58886
          http://tug.org/svn/texlive?view=revision&revision=58886
Author:   karl
Date:     2021-04-16 22:15:34 +0200 (Fri, 16 Apr 2021)
Log Message:
-----------
latexmk (16apr21)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl
    trunk/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl
    trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.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/example_rcfiles/chapterbib-latexmkrc
    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

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/hyperxmp-latexmkrc

Removed Paths:
-------------
    trunk/Master/texmf-dist/source/support/latexmk/

Modified: trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl	2021-04-16 20:15:03 UTC (rev 58885)
+++ trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl	2021-04-16 20:15:34 UTC (rev 58886)
@@ -1,130 +1,7 @@
 #!/usr/bin/env perl
 
-#!!!!!!!!!!!!!!!!!!!????????? CLEAN UP INITIALIZATION
-#!!! See all FIX items.
 
-# Perhaps add subroutine rdb_change_active( (rules to deactivate), (rules to activate))
-
-# ?? Still need to fix bcf error issue.
-# Don't keep looping after error
-# pvc: Only re-run on USER FILE CHANGE.
-# See # ??????? BCF
-
-
-#!!!!!!!!???  Check @pwd_log
-
-
-# !!!!!!!!!! Don't forget to document $silence_logfile_warnings.!!!
-
-# N.B. !!!!!!!!!!!  See 17 July 2012 comments !!!!!!!!!!!!!!!!!!
-
-# On a UNIX-like system, the above enables latexmk to run independently
-#   of the location of the perl executable.  This line relies on the 
-#   existence of the program /usr/bin/env
-# If there is a problem for any reason, you can replace the first line of 
-#   this file by:
-
-#!/usr/bin/perl -w
-
-# with the path of the perl executable adjusted for your system. 
-
-use warnings;
-
-# Delete #??!! when working
-
-# See ?? <===============================
-
-## ?? Issues with clean-up
-## List of aux files deleted is those read, not those generated.
-## Other files are generated by *latex; should they be deleted?
-## (I have hooks for this).
-
-
-
-#=======================================
-
-#??  Force mode doesn't appear to do force (if error in latex file)
-#??? Get banner back in.
-#??  CORRECT DIAGNOSTICS ON CHANGED FILES IF THEY DIDN'T EXIST BEFORE
-#??  Further corrections to deal with disappeared source files for custom dependencies.
-#       Message repeatedly appears about remake when source file of cusdep doesn't exist.
-#??  logfile w/o fdb file: don't set changed file, perhaps for generated exts.
-#    Reconsider
-#??  Do proper run-stuff for bibtex, makeindex, cus-deps.  OK I think
-#    Parse and correctly find ist files
-
-
-# ATTEMPT TO ALLOW FILENAMES WITH SPACES:
-#    (as of 1 Apr 2006, and then 14 Sep. 2007)
-
-# Problems:
-# A.  Quoting filenames will not always work.  
-#        a.  Under UNIX, quotes are legal in filenames, so when PERL
-#            directly runs a binary, a quoted filename will be treated as
-#            as a filename containing a quote character.  But when it calls
-#            a shell, the quotes are handled by the shell as quotes.
-#        b.  Under MSWin32, quotes are illegal filename characters, and tend
-#            to be handled correctly.
-#        c.  But under cygwin, results are not so clear (there are many 
-#            combinations: native v. cygwin perl, native v cygwin programs
-#            NT v. unix scripts, which shell is called.
-# B.  TeX doesn't always handle filenames with spaces gracefully.
-#        a.  UNIX/LINUX: The version on gluon2 Mar 31, 2006 to Sep. 2007) 
-#            doesn't handle them at all.  (TeX treats space as separator.)
-#        b.  At least some later versions actually do (Brad Miller e-mail, 
-#            Sep. 2007).
-#        c.  fptex [[e-TeXk, Version 3.141592-2.1 (Web2c 7.5.2)] does, on 
-#            my MSWin at home.  In \input the filename must be in quotes.
-#        d.  Bibtex [BibTeX (Web2c 7.5.2) 0.99c on my MSWin system at home,
-#            Sep. 2007] does not allow names of bibfiles to have spaces.
-# C.  =====> Using the shell for command lines is not safe, since special 
-#     characters can cause lots of mayhem.
-#     It will therefore be a good idea to sanitize filenames. 
-#
-# I've sanitized all calls out:
-#     a. system and exec use a single argument, which forces
-#        use of shell, under all circumstances
-#        Thus I can safely use quotes on filenames:  They will be handled by 
-#        the shell under UNIX, and simply passed on to the program under MSWin32.
-#     b. I reorganized Run, Run_Detached to use single command line
-#     c. All calls to Run and Run_Detached have quoted filenames.
-#     d. So if a space-free filename with wildcards is given on latexmk's
-#        command line, and it globs to space-containing filename(s), that
-#        works (fptex on home computer, native NT tex)
-#     e. ====> But globbing fails: the glob function takes space as filename 
-#        separator.   ====================
-
-#================= TO DO ================
-#
-# 1.  See ??  ESPECIALLY $MSWin_fudge_break
-# 2.  Check fudged conditions in looping and make_files 
-# 3.  Should not completely abort after a run that ends in failure from latex
-#     Missing input files (including via custom dependency) should be checked for
-#     a change in status
-#         If sources for missing files from custom dependency 
-#             are available, then do a rerun
-#         If sources of any kind become available rerun (esp. for pvc)
-#             rerun
-#         Must parse log_file after unsuccessful run of latex: it may give
-#             information about missing files. 
-# 4.  Check file of bug reports and requests
-# 5.  Rationalize bibtex warnings and errors.  Two almost identical routines.
-#         Should 1. Use single routine
-#                2. Convert errors to failure only in calling routine
-#                3. Save first warning/error.
-
-# ?? Use of generated_exts arrays and hashes needs rationalization
-
-# To do: 
-#   Rationalize again handling of include files.
-#     Now I use kpsewhich to do searches, if file not found
-#        (How do I avoid getting slowed down too much?)
-#   Document the assumptions at each stage of processing algorithm.
-#   Option to restart previewer automatically, if it dies under -pvc
-#   Test for already running previewer gets wrong answer if another
-#     process has the viewed file in its command line
-
-## Copyright John Collins 1998-2020
+## Copyright John Collins 1998-2021
 ##           (username jcc8 at node psu.edu)
 ##      (and thanks to David Coppit (username david at node coppit.org) 
 ##           for suggestions) 
@@ -149,19 +26,79 @@
 ##
 ##
 ##
-##   NEW FEATURES, since v. 2.0:
-##     1.  Correct algorithm for deciding how many times to run latex:
-##         based on whether source file(s) change between runs
-##     2.  Continuous preview works, and can be of ps file or dvi file
-##     3.  pdf creation by pdflatex possible
-##     4.  Defaults for commands are OS dependent.
-##     5.  Parsing of log file instead of source file is used to
-##         obtain dependencies, by default.
+##   Modification log from 1 Jan 2020 onwards in detail
 ##
-##   Modification log from 9 Dec 2011 onwards in detail
-##
-## 12 Jan 2012 STILL NEED TO DOCUMENT some items below
-##
+## 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
@@ -168,6 +105,7 @@
 ##                               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
@@ -221,81 +159,9 @@
 ##                             xetex source).  This forces xdvipdfmx to always
 ##                             try to embed fonts, ignoring licensing flags, etc.
 ##
-## Current version (4.67, 26 Dec 2019) to CTAN
-## 26 Dec 2019 John Collins  Change place of setting of $view_file
-##                           Make fully consistent set of options for engines:
-##                               -latex, -latex=...,
-##                           preserving backward compatibility, and avoiding suprises. 
-## 11 Dec 2019 John Collins  Change rules for wrapping in log file: This deals
-##                             with xelatex wrapping at > standard number of
-##                             bytes in presence of non-ASCII Unicode characters.
-##  4 Dec 2019 John Collins  If there were missing subdirectories in output/aux
-##                           directories, and these were successfully created,
-##                           then ignore error from *latex, since rerun may
-##                           succeed.
-## 14 Nov 2019 John Collins  Add comment.
-## 12 Nov 2019 John Collins  Use $compiling_cmd, $warning_cmd, $success_cmd
-#                            on normal make, rather than just in -pvc mode.
-##  5 Aug 2019 John Collins  The changing of '\' to '/' in filenames is now
-##                             done for msys as well as MSWin32.
-##  8 Jul 2019 John Collins  Allow addition of hook for processing lists of
-##                             missing source files, used after run of *latex.
-##  2 Jul 2019 John Collins  Silence message about disallowing change of output
-##                            file type.
-##                           V. 4.66
-## 28 Jun 2019 John Collins  Try to deal with log file parsing problems
-##                           V. 4.65
-## 21 May 2019 John Collins  Fix incorrect listings by -rules and by -deps
-## 21 May 2019 John Collins  V. 4.64a.
-## 20,21 May 2019 John Collins Fix problem with not always running dvipdf,
-##                             dvips, xdvpdf because of missing information
-##                             on source files.  Do this by adding a
-##                             source_rule hash to each rule and adding a
-##                             pass-based criterion for out-of-dateness
-## 20 May 2019 John Collins  V. 4.64.
-## 17 Mar 2019 John Collins  V. 4.63c.
-## 18 Mar 2019 John Collins  Update copyright date
-## 17 Mar 2019 John Collins  Further test for problems when linking rules
-## 17 Mar 2019 John Collins  V. 4.63b.
-## 17 Mar 2019 John Collins  Fix problem revealed by bibtopic package
-## 15 Mar 2019 John Collins  Corrections
-## 14 Mar 2019 John Collins  Version to 4.63a
-## 12-14 Mar 2019 John Collins  Jobname has placeholder
-##  8-11 Mar 2019 John Collins  Correct aux-dir bugs 
-##  8 Mar 2019 John Collins  Version to 4.63
-##  1 Jan 2019 John Collins  Correct bug in output switching code
-## 31 Dec 2018 John Collins  Correct bug that with $cleanup_includes_generated
-##                              -c mode deletes final output files (e.g., .dvi, .pdf).
-## 13 Dec 2018 John Collins  Fixes, cleanup
-## 12 Dec 2018 John Collins  Fix rdb_read
-## 11 Dec 2018 John Collins  For output-switch: Reorganize initialization
-##                           Remove possibility of more than one primary.
-##  1 Dec 2018 John Collins  Clean up some code.
-## 30 Nov 2018 John Collins  Allow any characters in directory part of tex
-##                             filename when cd mode on.  (Still standard
-##                             set of disallowed characters applies basename.)
-## 21 Nov 2018 John Collins  Infrastructure finished, I think, for active flag
-##                           Start on output switch
-## 16 Nov 2018 John Collins  Remove in non-diagnostics mode a warning about
-##                             rule not in use in this session that is given
-##                             when reading an fdb_latexmk file.
-##  2 Nov 2018 John Collins  Start implementing active flag for rules.
-##  1 Nov 2018 John Collins  Fix finding of missing files that are relative to aux_dir
-## 29-31 Oct 2018 John Collins  Some cleanup.
-## 27,28 Oct 2018 John Collins  Fix bug that in -pvc mode, after an error in
-##                             certain rules, new rounds of compilation 
-##                             are triggered because of changes in generated
-##                             files, instead of only by later user-generated
-##                             changes.
-##                           Improve linking of rules.
-## 25 Oct 2018 John Collins  V. 4.62
-##                           Clean up can remove (empty) directories
-## 25 Oct 2018 John Collins  Fix definition of clean up substitution for %R
-##                             so that something with intermediate %R works,
-##                             as in 'pythontex-files-%R/*'.
 ##
-## 1998-2018, John Collins.  Many improvements and fixes.
-##   See CHANGE-log.txt for full list, and CHANGES for summary
+## 1998-2019, 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)
 ## Original script (RCS version 2.3) called "go" written by David J. Musliner
@@ -313,8 +179,8 @@
 
 $my_name = 'latexmk';
 $My_name = 'Latexmk';
-$version_num = '4.70b';
-$version_details = "$My_name, John Collins, 29 September 2020";
+$version_num = '4.72b';
+$version_details = "$My_name, John Collins, 15 April 2021";
 
 use Config;
 use File::Basename;
@@ -351,8 +217,9 @@
 use FileHandle;
 use File::Find;
 use List::Util qw( max );
-use Cwd;            # To be able to change cwd
-#use Cwd "chdir";    # Ensure $ENV{PWD}  tracks cwd.  NO NEED, and it messes up -cd -outdir=
+use Cwd;
+use Cwd "abs_path"; 
+use Cwd "chdir";    # Ensure $ENV{PWD}  tracks cwd.
 use Digest::MD5;
 
 #use strict;
@@ -414,6 +281,8 @@
 #        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:
+$normalize_names = 2;  # Strongest kind.
 
 ## Hash mapping file extension (w/o period, e.g., 'eps') to a single regexp,
 #  whose matching by a line in a file with that extension indicates that the 
@@ -539,7 +408,6 @@
     "-mltex                  enable MLTeX extensions such as \charsubdef",
     "-output-comment=STRING  use STRING for DVI file comment instead of date\n".
     "                           (no effect for PDF)",
-    "-output-format=FORMAT   use FORMAT for job output; FORMAT is `dvi\" or `pdf\"",
     "-parse-first-line       enable parsing of first line of input file",
     "-no-parse-first-line    disable parsing of first line of input file",
     "-progname=STRING        set program (and fmt) name to STRING",
@@ -621,6 +489,7 @@
     #-jobname=STRING         set the job name to STRING
     #-aux-directory=dir    Set the directory dir to which auxiliary files are written
     #-output-directory=DIR   use existing DIR as the directory to write files in
+    # "-output-format=FORMAT   use FORMAT for job output; FORMAT is `dvi\" or `pdf\"",
     #-quiet
     #-recorder               enable filename recorder
     #
@@ -659,12 +528,6 @@
 $biber  = 'biber %O %S';
 $bibtex  = 'bibtex %O %S';
 # Switch(es) to make biber & bibtex silent:
-$bibtex_fudge = 0; # Don't use hack to get bibtex working in old versions that
-                   #    don't handle output-directory.  When this version of
-                   #    latexmk is part of a distribution of TeX, the
-                   #    accompanying bibtex should also be recent enough
-                   #    (e.g., TeXLive 2019 or later, current MiKTeX) not to
-                   #    need the  hack/fudge.
 $biber_silent_switch  = '--onlylog';
 $bibtex_silent_switch  = '-terse';
 $bibtex_use = 1;   # Whether to actually run bibtex to update bbl files.
@@ -685,11 +548,23 @@
                    #
                    # In any event bibtex is only run if the log file
                    #   indicates that the document uses bbl files.
+$bibtex_fudge = 1; #  Whether or not to cd to aux dir when running bibtex.
+                   #  If the cd is not done, and bibtex is passed a
+                   #  filename with a path component, then it can easily
+                   #  happen that (a) bibtex refuses to write bbl and blg
+                   #  files to the aux directory, for security reasons,
+                   #  and/or (b) bibtex in pre-2019 versions fails to find
+                   #  some input file(s).  But in some other cases, the cd
+                   #  method fails. 
 
 ## Command to invoke makeindex
 $makeindex  = 'makeindex %O -o %D %S';
 # Switch(es) to make makeinex silent:
 $makeindex_silent_switch  = '-q';
+$makeindex_fudge = 1; # Whether or not to cd to aux dir when running makeindex.
+                      # Set to 1 to avoid security-related prohibition on
+                      # 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';
@@ -1548,13 +1423,14 @@
                     #       for source, %B for base of current rule,
                     #       %R for base of primary tex file, %T for
                     #       texfile name, %O for options,
+                    #       %V=$aux_dir, %W=$out_dir,
                     #       %Y for $aux_dir1, and %Z for $out_dir1
                     #     int_cmd specifies any internal command to be
                     #       used to implement the application of the
                     #       rule.  If this is present, it overrides
-                    #       the external command, and it is the
-                    #       responsibility of the perl subroutine
-                    #       specified in intcmd to execute the
+                    #       **direct** execution of the external command, and
+                    #       it is the responsibility of the perl subroutine
+                    #       specified in intcmd to execute the specified
                     #       external command if this is appropriate.
                     #       This variable intcmd is a reference to an array,  
                     #       $$intcmd[0] = internal routine
@@ -1776,7 +1652,7 @@
 }
 if ( $auto_rc_use ) { 
     # Rc file in current directory:
-    read_first_rc_file_in_list( "./latexmkrc", "./.latexmkrc" );
+    read_first_rc_file_in_list( ".latexmkrc", "latexmkrc" );
 }
 
 ## Process command line args.
@@ -1793,8 +1669,8 @@
   if ( /^-aux-directory=(.*)$/ || /^-auxdir=(.*)$/ ) {
       $aux_dir = $1;
   }
-  elsif (/^-bibfudge$/) { $bibtex_fudge = 1; }
-  elsif (/^-bibfudge-$/) { $bibtex_fudge = 0; }
+  elsif (/^-bib(tex|)fudge$/) { $bibtex_fudge = 1; }
+  elsif (/^-bib(tex|)fudge-$/) { $bibtex_fudge = 0; }
   elsif (/^-bibtex$/) { $bibtex_use = 2; }
   elsif (/^-bibtex-$/) { $bibtex_use = 0; }
   elsif (/^-nobibtex$/) { $bibtex_use = 0; }
@@ -1861,6 +1737,8 @@
      shift; 
   }
   elsif ( /^-MP$/ ) { $dependents_phony = 1; }
+  elsif (/^-(make|)indexfudge$/) { $makeindex_fudge = 1; }
+  elsif (/^-(make|)indexfudge-$/) { $makeindex_fudge = 0; }
   elsif ( /-MSWinBackSlash$/ ) { $MSWin_back_slash = 1; }
   elsif ( /-MSWinBackSlash-$/ ) { $MSWin_back_slash = 0; }
   elsif (/^-new-viewer$/) {
@@ -1873,10 +1751,26 @@
       $auto_rc_use = 0;
       # N.B. This has already been obeyed.
   }
-  elsif (/^-nobibfudge$/) { $bibtex_fudge = 0; }
+  elsif (/^-nobib(tex|)fudge$/) { $bibtex_fudge = 0; }
+  elsif (/^-no(make|)indexfudge$/) { $makeindex_fudge = 0; }
   elsif ( /^-output-directory=(.*)$/ ||/^-outdir=(.*)$/ ) {
       $out_dir = $1;
   }
+  elsif ( /^-output-format=(.*)$/ ) {
+      my $format = $1;
+      if ($format eq 'dvi' ) {
+          $dvi_mode = 1;
+          $pdf_mode = $postscript_mode = 0;
+      }
+      elsif ($format eq 'pdf' ) {
+          $pdf_mode = 1;
+          $dvi_mode = $postscript_mode = 0;
+      }
+      else {
+          warn "$My_name: unknown format in option '$_'\n";
+          $bad_options++;
+      }
+  }
   elsif (/^-p$/)     { $printout_mode = 1; 
                        $preview_continuous_mode = 0; # to avoid conflicts
                        $preview_mode = 0;  
@@ -2045,7 +1939,7 @@
       push @extra_xelatex_options, $original;
   }
   elsif (/^-/) {
-     warn "$My_name: $_ bad option\n"; 
+     warn "$My_name: $_ unknown option\n"; 
      $bad_options++;
   }
   else {
@@ -2083,8 +1977,6 @@
 #          3 log file **not** in aux_dir or out_dir, but in cwd.
 $where_log = -1;  
 
-&set_dirs_etc;
-
 if ($bibtex_use > 1) {
     push @generated_exts, 'bbl';
 }
@@ -2253,19 +2145,6 @@
 #   possible cd to the document directory, since the directories can be
 #   relative to the document.
 
-$q = $quote_filenames ? '"' : '';
-if ( $out_dir ) {
-    add_option( "-output-directory=$q$out_dir$q",
-                \$latex, \$pdflatex, \$lualatex, \$xelatex );
-}
-if ( $aux_dir && ($aux_dir ne $out_dir) ) {
-    # N.B. If $aux_dir and $out_dir are the same, then the -output-directory
-    # option is sufficient, especially because the -aux-directory exists
-    # only in MiKTeX, not in TeXLive.
-    add_option( "-aux-directory=$q$aux_dir$q",
-                \$latex, \$pdflatex, \$lualatex, \$xelatex );
-}
-
 if ( $jobname ne '' ) {
     # Since $jobname may include placeholder(s), put %R placeholder
     # in option, and let %R be substituted by actual jobname at runtime.
@@ -2467,6 +2346,8 @@
 # Deal with illegal and problematic characters in filename:
 test_fix_texnames( @file_list );
 
+$quote = $quote_filenames ? '"' : '';
+
 FILE:
 foreach $filename ( @file_list )
 {
@@ -2479,12 +2360,18 @@
     if ( $do_cd ) {
        ($filename, $path) = fileparse( $filename );
        warn "$My_name: Changing directory to '$path'\n"
-          if !$silent;
+           if !$silent;
        pushd( dirname_no_tail( $path ) );
     }
     else {
         $path = '';
     }
+    local $aux_dir = $aux_dir;
+    local $out_dir = $out_dir;
+    local $latex = $latex;
+    local $lualatex = $lualatex;
+    local $pdflatex = $pdflatex;
+    local $xelatex = $xelatex;
 
     # Ensure the output/auxiliary directories exist, if need be
     if ( $out_dir ) {
@@ -2516,7 +2403,31 @@
         }
     }
 
+    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:
     @default_includes = ($texfile_name, $aux_main);
     # N.B. Do **not** apply local %rule_db here.  It might appear appropriate,
@@ -2710,15 +2621,13 @@
             rdb_for_some( [keys %current_primaries], \&rdb_set_latex_deps );
         }
     }
-    foreach $rule ( &rdb_accessible ) {
-        # For all source files of all accessible rules, 
-        #    if the file data are not already set (e.g., from fdb_latexmk
-        #    file, set them from disk.
-        rdb_one_rule ($rule, undef, 
-                      sub{ if ( $$Ptime == 0) { &rdb_update1; } }
-        );
-    }
-
+    # At this point, we assume that the file database was correctly
+    # initialized from fdb_latexmk database (corresponding to the state at
+    # the end of the previous run of latexmk, if the fdb_latexmk file exists.
+    # PERHAPS if fdb_latexmk doesn't exist we ought to assume there was
+    # a previous run that completed, if the appropriate output files exist,
+    # so a new run of *latex etc isn't needed; then we should set the file
+    # data from the on-disk state.
     if ($go_mode) {
         # Force everything to be remade.
         rdb_recurse( [ &rdb_target_array], sub{$$Pout_of_date=1;}  );
@@ -2937,7 +2846,7 @@
         else {
             $ENV{$var} = $_ . $search_path_separator;
         }
-        if (!$silent) {
+        if ($diagnostics) {
             print "Set environment variable $var='$ENV{$var}'\n";
         }
     }
@@ -2946,18 +2855,27 @@
 #############################################################
 
 sub set_dirs_etc {
-    # Normalize versions terminating in directory/path separator
-    # and versions referring to current directory
-    # These actions in a subroutine so they can be used elsewhere.
+    # 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.
     $out_dir = dirname_no_tail( $out_dir );
     $aux_dir = dirname_no_tail( $aux_dir );
     $out_dir1 = $out_dir;
     $aux_dir1 = $aux_dir;
-    foreach ( $aux_dir1, $out_dir1 ) {
+    $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 ) {
         if ( ($_ ne '')  && ! m([\\/\:]$) ) {
+            # Add a trailing '/' if necessary to give a string that can be
+            # correctly concatenated with a filename:
             $_ .= '/';
         }
-        while ( s[^\.\/][] ) {}
     }
     if ($aux_dir) {
         # Ensure $aux_dir is in BIBINPUTS and TEXINPUTS search paths.
@@ -2970,9 +2888,31 @@
         # there is an error.  So cope with this situation (and any analogous
         # cases by adding the aux_dir to the relevant path search environment
         # variables.  BIBINPUTS seems to be the only one currently affected.
+        # Convert $aux_dir to absolute path to make the search path invariant
+        # under change of directory.
         foreach ( 'BIBINPUTS', 'TEXINPUTS' ) {
-            ensure_path( $_, $aux_dir );
+            ensure_path( $_, $aux_dir_abs );
         }
+        # 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.
+        # 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;
     }
 }
 
@@ -3179,6 +3119,7 @@
 #  over non-main generated files from other rules.
     local %from_rules_old = %from_rules;
     &rdb_cache_generated;
+    
     rdb_for_actives( 
         0,
         sub{ 
@@ -3194,7 +3135,7 @@
         }
         );
     rdb_for_actives( \&rdb_set_source_rules );
-#    &rdb_show;
+#    print "=========In rdb_make_links: rules\n"; &rdb_show;
 } # END rdb_make_links
 
 #************************************************************
@@ -3296,8 +3237,13 @@
 #************************************************************
 
 sub set_trivial_aux_fdb {
-    # 1. Write aux file EXACTLY as would be written if the tex file
-    #    had no cross references, etc. I.e., a minimal .aux file. 
+    # 1. Write aux file as would be written if the tex file had no cross
+    #    cross references, etc. i.e., a minimal .aux file, as would be
+    #    written by latex with a simple document.
+    #    That saves a run of latex on such simple documents.
+    #    Before about 2020, latex only wrote one line, containing '\relax '
+    #    in the aux file.  After that a reference to the last page was
+    #    added.  So now I write what is written for a one page document.
     # 2. Write a corresponding fdb file
     # 3. Provoke a run of *latex (actually of all primaries). 
 
@@ -3305,6 +3251,9 @@
     open( aux_file, '>', $aux_main )
         or die "Cannot write file '$aux_main'\n";
     print aux_file "\\relax \n";
+    # The following is added by recent versions of latex for a
+    # one page document
+    print aux_file "\\gdef \\\@abspage\@last{1}\n";
     close(aux_file);
 
     foreach my $rule (keys %possible_primaries ) { 
@@ -3807,8 +3756,10 @@
         return 1;
     }
     elsif ( open $RCH, "<$rc_file" ) {
-        { local $/; eval <$RCH>; }
+        my $code = '';
+        { local $/; $code = <$RCH>;}
         close $RCH;
+        eval $code;
     }
     else {
         warn "$My_name: I cannot read the rc-file '$rc_file'\n";
@@ -3998,8 +3949,8 @@
   "   -bibtex-cond  - use bibtex when needed, but only if the bib file exists\n",
   "   -bibtex-cond1 - use bibtex when needed, but only if the bib file exists;\n",
   "                   on cleanup delete bbl file only if bib file exists\n",
-  "   -bibfudge     - use change-directory fudge needed for old bibtexs\n",
-  "   -bibfudge-    - don't use change-directory fudge needed for old bibtexs\n",
+  "   -bibfudge or -bibtexfudge - change directory to output directory when running bibtex\n",
+  "   -bibfudge- or -bibtexfudge- - don't change directory when running bibtex\n",
   "   -bm <message> - Print message across the page when converting to postscript\n",
   "   -bi <intensity> - Set contrast or intensity of banner\n",
   "   -bs <scale> - Set scale for banner\n",
@@ -4033,6 +3984,8 @@
   "   -g-    - Turn off -g\n",
   "   -h     - print help\n",
   "   -help - print help\n",
+  "   -indexfudge or -makeindexfudge - change directory to output directory when running makeindex\n",
+  "   -indexfudge- or -makeindexfudge- - don't change directory when running makeindex\n",
   "   -jobname=STRING - set basename of output file(s) to STRING.\n",
   "            (Like --jobname=STRING on command line for many current\n",
   "            implementations of latex/pdflatex.)\n",
@@ -4050,6 +4003,8 @@
   "   -M     - Show list of dependent files after processing\n",
   "   -MF file - Specifies name of file to receives list dependent files\n",
   "   -MP    - List of dependent files includes phony target for each source file.\n",
+  "   -makeindexfudge - change directory to output directory when running makeindex\n",
+  "   -makeindexfudge-- don't change directory to output directory when running makeindex\n",
   "   -MSWinBackSlash  under MSWin use backslash (\\) for directory separators\n",
   "                    for filenames given to called programs\n",
   "   -MSWinBackSlash-  under MSWin use forward slash (/) for directory separators\n",
@@ -4057,11 +4012,16 @@
   "   -new-viewer    - in -pvc mode, always start a new viewer\n",
   "   -new-viewer-   - in -pvc mode, start a new viewer only if needed\n",
   "   -nobibtex      - never use bibtex\n",
-  "   -nobibfudge    - don't use change-directory fudge needed for old bibtexs\n",
+  "   -nobibfudge or -nobibtexfudge - don't change directory when running bibtex\n",
   "   -nodependents  - Do not show list of dependent files after processing\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",
   "                  - set name of directory for output files\n",
+  "   -output-format=FORMAT\n",
+  "                  - if FORMAT is dvi, turn on dvi output, turn off others\n",
+  "                  - if FORMAT is pdf, turn on pdf output, turn off others\n",
+  "                  - otherwise error\n",    
   "   -pdf   - generate pdf by pdflatex\n",
   "   -pdfdvi - generate pdf by dvipdf\n",
   "   -pdflatex=<program> - set program used for pdflatex.\n",
@@ -4337,7 +4297,11 @@
     my $return = 999;
     # Prevent changes we make to environment becoming global:
     local %ENV = %ENV;
+
     my ( $base, $path, $ext ) = fileparseA( $$Psource );
+    # Define source and dest base to include extension, no path.
+    my $source_base = $base.$ext;
+    my $dest_base = basename( $$Pdest );
     if ( $path && $bibtex_fudge ) {
         # Up to TeXLive 2018, the following was true; situation has changed since.
         #   When an output directory is specified and with a bibtex from 2018 or
@@ -4346,6 +4310,9 @@
         #   directory to the directory of the top-level .aux file to run bibtex.
         #   But we have to fix search paths for .bib and .bst, since they may be
         #   specified relative to the document directory.
+        # There is also another problem: Depending on the exact
+        #   specification of the aux dir, bibtex may refuse to write to the
+        #   aux dir, for security reasons.
         my $cwd = good_cwd();
         foreach ( 'BIBINPUTS', 'BSTINPUTS' ) {
             if ( exists $ENV{$_} ) {
@@ -4357,32 +4324,57 @@
         }
         pushd( $path );
         if (!$silent) {
-            print "$My_name: ==========WARNING:=================\n",
-                  "I am taking action to evade a bug/feature in older versions of bibtex\n",
-                  "This may give problems under some situations, symptomized by bibtex not\n",
-                 "finding a .bib file or an aux file.\n",
-                "Provided you have a recent version of bibtex (about 2019 or later) you\n",
-                "can avoid the problems by  putting '\$bibtex_fudge = 0;' in an\n",
-                "initialization file (a latexmrc file for $my_name.\n",
-                  "\n",
-                  "Here my bug-evading action:\n",
-                  "I temporarily changed directory to '$path'\n",
-                  "Set BIBINPUTS='$ENV{BIBINPUTS}'\n",
-                  "Set BSTINPUTS='$ENV{BSTINPUTS}'\n";
+            print "$My_name: Change directory to '$path'.\n",
+                  "To assist finding of files in document\n",
+                  "directory, I set\n",
+                  "  BIBINPUTS='$ENV{BIBINPUTS}'\n",
+                  "  BSTINPUTS='$ENV{BSTINPUTS}'.\n";
         }
-        $return = &Run_subst( undef, undef, '', $base.$ext, '', $base );
+        # Override standard substitutions for source, dest, and base names in
+        # default external command:
+        $return = &Run_subst( undef, undef, '', $source_base, $dest_base, $base );
         popd();
         if (!$silent) {
-            print "$My_name: changed directory back to '", cwd(), "'\n";
+            print "$My_name: Change directory back to '", cwd(), "'\n";
         }
     }
     else {
+        # Use default substitutions etc for rule:
         $return = Run_subst();
     }
     return $return;
-}
+} #END run_bibtex
 
+#**************************************************
 
+sub run_makeindex {
+    my $return = 999;
+    my ( $base, $path, $ext ) = fileparseA( $$Psource );
+
+    # Define source and dest base to include extension, no path.
+    my $source_base = $base.$ext;
+    my $dest_base = basename( $$Pdest );
+    if ( $path && $makeindex_fudge ) {
+        my $cwd = good_cwd();
+        pushd( $path );
+        if (!$silent) {
+            print "$My_name: Change directory to '$path'.\n";
+        }
+        # Override standard substitutions for source, dest, and base names in
+        # default external command:
+        $return = &Run_subst( undef, undef, '', $source_base, $dest_base, $base );
+        popd();
+        if (!$silent) {
+            print "$My_name: Change directory back to '", cwd(), "'\n";
+        }
+    }
+    else {
+        # Use default substitutions etc for rule:
+        $return = Run_subst();
+    }
+    return $return;
+} #END run_makeindex
+
 #**************************************************
 
 sub check_bibtex_log {
@@ -4423,7 +4415,6 @@
     }
     close $blg_file;
     my $missing = $missing_citations + $#missing_aux + 1;
-
     if ( $#missing_aux > -1 ) {
         # Need to make the missing files.
         warn "$My_name: One or more aux files is missing for bibtex. I'll try\n",
@@ -4453,17 +4444,15 @@
 
 sub normalize_force_directory {
     #  Usage, normalize_force_directory( dir, filename )
+    #  Filename is assumed to be relative to dir (terminated with directory separator).
     #  Perform the following operations:
     #    Clean filename
-    #    If filename contains no path component, insert dir in front
+    #    Prefix filename with dir
     #    Normalize filename
     #  Return result
-    my $default_dir = $_[0];
+    my $dir = $_[0];
     my $filename = clean_filename( $_[1] );
-    my ($base_name, $path ) = fileparse( $filename );
-    if ( $base_name eq $filename ) {
-       $filename = "$default_dir$filename";
-    }
+    $filename = "$dir$filename";
     return normalize_filename( $filename );
 } #END normalize force_directory
 
@@ -4595,22 +4584,6 @@
 #    print "==== Cusdep to-exts:"; foreach (keys %cusdep_to) {print " '$_'";} print "\n";
 
 
-    # Filenames given in log file may be preceded by a pathname
-    #   denoting current directory.  In MiKTeX, this is an absolute
-    #   pathname; in TeXLive, it is './'. Either way, we'll want to
-    #   remove this pathname string --- see the comments in sub
-    #   rdb_set_latex_deps.  In order of reliability for use in
-    #   normalizing filenames from the log file, the following forms
-    #   of the cwd are used:
-    # (a) internally deduced pwd from log file from sequence of lines
-    #                  **file
-    #                  (dir/file
-    #     if possible.  NO THAT'S WRONG if kpsearch is done.
-    # (b) from PWD line in fls file (if available), passed as $pwd_latex
-    # (c) system-given cwd as interpreted by sub good_cwd.
-    # We'll put the first two in  @pwd_log
-    my @pwd_log = ();
-    if ($pwd_latex) { push @pwd_log, $pwd_latex; }
 
     # $primary_out is actual output file (dvi or pdf)
     # It is initialized before the call to this routine, to ensure
@@ -4851,6 +4824,8 @@
             # \openout followed by filename followed by line end.
             # pdflatex and xelatex quote it and wrap,
             # lualatex leaves filename as is, and doesn't wrap.
+            # Filename is always relative to aux_dir, given standard security
+            # settings in TeXLive.
             my $cand = $1;
             if ( $cand =~ /\`\"([^\'\"]+)\"\'\.$/ ) {
                 # One form of quoting by pdflatex, xelatex: `"..."'.
@@ -4864,7 +4839,7 @@
                 # Bad quotes: e.g., incomplete wrapped line
                 next LINE;
             }
-            $generated_log{normalize_force_directory( $aux_dir1, $cand )} = 1;
+            $generated_log{ normalize_force_directory($aux_dir1, $cand) } = 1;
             next LINE;
         }
         # Test for conversion produced by package:
@@ -4903,7 +4878,7 @@
             $idx_file =~ s/\s*$//;
                 #  When *latex is run with an -output-directory 
                 #    or an -aux_directory, the file name does not contain
-                #    the output path; fix this, after removing quotes:
+                #    the path. Fix this:
             $idx_file = normalize_force_directory( $aux_dir1, $idx_file );
             my ($idx_base, $idx_path, $idx_ext) = fileparseA( $idx_file );
             $idx_base = $idx_path.$idx_base;
@@ -4928,10 +4903,10 @@
             next LINE;
         }
         elsif ( /^No file (.*?\.bbl)./ ) {
-            my $bbl_file = normalize_force_directory( $aux_dir1, $1);
-            my $aux_file = $bbl_file;
-            $aux_file =~ s/\.bbl$/\.aux/;
-            warn "$My_name: Non-existent bbl file '$bbl_file in line'\n $_\n";
+            # Filename is always relative to aux_dir, given standard security
+            # settings in TeXLive.
+            my $bbl_file = normalize_force_directory( $aux_dir1, $1 );
+            warn "$My_name: Missing bbl file '$bbl_file' in following:\n $_\n";
             $dependents{$bbl_file} = 0;
             push @bbl_files, $bbl_file;
             next LINE;
@@ -4939,11 +4914,11 @@
         foreach my $pattern (@file_not_found) {
             if ( /$pattern/ ) {
                 my $file = clean_filename($1);
-                warn "$My_name: Missing input file: '$file' from line\n  '$_'\n"
+                warn "$My_name: Missing input file: '$file' from following:\n  '$_'\n"
                     unless $silent;
                 $dependents{normalize_filename($file, @pwd_log)} = 0;
                 my $file1 = $file;
-                if ( $aux_dir ) {
+                if ( $aux_dir && ($aux_dir ne '.') ) {
                     # Allow for the possibility that latex generated
                     # a file in $aux_dir, from which the missing file can
                     # be created by a cusdep (or other) rule that puts
@@ -4955,8 +4930,6 @@
                     # relative to the aux_dir, so allow for that as well
                     my $file1 = normalize_force_directory( $aux_dir1, $file );
                     $dependents{$file1} = 0;
-                    $dependents{$aux_dir1.$file} = 0;
-                    
                 }
                 next LINE;
             }
@@ -5147,6 +5120,7 @@
                 next INCLUDE_NAME;
             }
             $include_name = normalize_filename( $include_name, @pwd_log );
+            if ( ! defined $include_name )  { next INCLUDE_NAME; }
             my ($base, $path, $ext) = fileparseB( $include_name );
             if ( ($path eq './') || ($path eq '.\\') ) {
                 $include_name = $base.$ext;
@@ -5434,6 +5408,11 @@
     if ( ! open ($fls_file, "<$fls_name") ) {
         return 1;
     }
+
+    my $pdf_base = basename($pdf_name);
+    my $log_base = basename($log_name);
+    my $out_base = basename($$Pdest);
+
     foreach $_ ( <$fls_file> ) {
         # Remove trailing CR and LF. Thus we get correct behavior when an fls file
         #  is produced by MS-Windows program (e.g., in MiKTeX) with CRLF line ends,
@@ -5441,12 +5420,15 @@
         #  in read-in lines):
         $_ =~ s/[\n\r]*$//;
         if (/^\s*PWD\s+(.*)$/) {
-            $cwd = $1;
-            $$Ppwd_latex = $cwd;
-            if ( $cwd =~ /\"/ ) {
+            my $cwd_fls = $1;
+            $$Ppwd_latex = $cwd_fls;
+            if ( $cwd_fls =~ /\"/ ) {
                 warn "$My_name: The working directory has a '\"' character in its name:\n",
                      "  '$cwd'\n  This can cause me trouble. Beware!\n";
             }
+            if ( normalize_filename($cwd_fls) ne normalize_filename($cwd) ) {
+                print "$My_name: ============== Inequiv cwd_fls cwd '$cwd_fls' '$cwd'\n";
+            }
         }
         elsif (/^\s*INPUT\s+(.*)$/) {
             # Take precautions against aliasing of foo, ./foo and other possibilities for cwd.
@@ -5463,7 +5445,34 @@
             if ( (exists $$Poutputs{$file}) && (! exists $$Pinputs{$file}) ) {
                 $$Pfirst_read_after_write{$file} = 1;
             }
-            $$Pinputs{$file} = 1;
+            # Take precautions against main destination file being listed as INPUT file
+            # This results, e.g., from hyperxmp (2020/10/05 v. 5.6) reading the pdf file
+            # size, and triggers an infinite loop, unless we omit the pdf file from the 
+            # list of input files.  (Hyperxmp v. 5.7 2010/11/01 doesn't give this problem.)
+            # There's a related issue with the log file, when acmart.cls is used with
+            # xelatex.  (I don't work out what causes this, e.g., what package.)
+            # Test on basenames rather than full name to evade in a simple-minded way
+            # alias issues with the directory part.
+            if ( basename($file) eq $pdf_base ) {
+                warn "$My_name: !!!!!!!!!!! Fls file lists main pdf **output** file as an input\n",
+                     "   file for rule '$rule'. I won't treat as a source file, since that leads\n",
+                     "   to an infinite loop.\n",
+                    "    This can be caused by the hyperxmp package in an old version.\n",
+                    "    You should update to hyperxmp in ver. 5.7 or higher\n";
+            } elsif ( basename($file) eq $out_base ) {
+                warn "$My_name: !!!!!!!!!!! Fls file lists main **output** file as an input\n",
+                     "   file for rule '$rule'. I won't treat as a source file, since that leads\n",
+                     "   to an infinite loop.\n",
+                    "    This can be caused by the hyperxmp package in an old version.\n",
+                    "    You should update to hyperxmp in ver. 5.7 or higher\n";
+            } elsif ( basename($file) eq $log_base ) {
+                warn "$My_name: !!!!!!!!!!! Fls file lists log file as an input\n",
+                     "   file for rule '$rule'. I won't treat it as a source file, since\n",
+                    "   there appear to be no good uses for it.\n",
+                    "   This behavior happens at least under acmart.cls with xelatex\n";
+            } else {
+                $$Pinputs{$file} = 1;
+            }
         }
         elsif (/^\s*OUTPUT\s+(.*)$/) {
             # Take precautions against aliasing of foo, ./foo and other possibilities for cwd.
@@ -5481,7 +5490,6 @@
 
 sub dirname_no_tail {
     my $dirname = $_[0];
-#    print "DNT1 = '$dirname'\n";
     foreach ($dirname) {
         # Normalize name to use / to separate directory components:
         #   (Note both / and \ are allowed under MSWin.)
@@ -5497,7 +5505,6 @@
             }
         }
     }
-#    print "DNT2 = '$dirname'\n";
     return $dirname;
 }
 
@@ -5525,28 +5532,44 @@
 sub normalize_filename {
    # Usage: normalize_filename( filename [, extra forms of name of cwd] )
    # Returns filename with removal of various forms for cwd, and
-   # with conversion of directory separator to '/' only
+   # with conversion of directory separator to '/' only.
+   # Works also when filename is name of a directory.
    #
    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, $file,  @dirs) {
+   foreach ($cwd, $cwd1, $file,  @dirs) {
        s(\\)(/)g;
        $_ = dirname_no_tail( $_ );
    }
+   if ($filename eq '.') { $filename = ''; }
    # 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 ) {
+   foreach my $dir ( @dirs, '.', $cwd, $cwd1 ) {
        if ( $dir =~ /^\s*$/ ) {
+           # All spaces, nothing to do.
            next;
        }
+       if ($file eq $dir) {
+           # Filename equals cwd, so it is . relative to cwd:
+           $file = '.';
+           last;
+       }
        if ( $file =~ s(^\Q$dir\E/)() ) {
            last;
      }
    }
+   if ($file eq '.' ) {
+       # This only occurs for a directory that is the cwd.
+       # Our convention is always to replace this by a blank.
+       # Watch out for tests of existence that will go wrong,
+       # and for a form for concatenating this with a filename.
+       $file = '';
+   }
    return $file;
 }
 
@@ -5556,7 +5579,7 @@
    # Usage: normalize_clean_filename( filename [, extra forms of name of cwd] )
    # Same as normalize_filename, but first remove any double quotes, as
    # done by clean_filename, which is appropriate for filenames from log file.
-    my ($file, @dirs) = @_;
+    my ($file, @dirs) = shift;
     return normalize_filename( clean_filename( $file ) , @dirs );
 }
 
@@ -5934,6 +5957,7 @@
                 if ($rule =~ /^makeindex/) { $PA_extra_gen = [ "$base.ilg" ]; }
                 if ($rule =~ /^(bibtex|biber)/) { $PA_extra_gen = [ "$base.blg" ]; }
                 if ($rule =~ /^bibtex/) { $int_cmd = "run_bibtex"; }
+                if ($rule =~ /^makeindex/) { $int_cmd = "run_makeindex"; }
                 warn "$My_name: File-database '$in_name': setting rule '$rule'\n"
                    if $diagnostics;
                 my $cmd_type = 'external';
@@ -5972,7 +5996,6 @@
             my $size = $3;
             my $md5 = $4;
             my $from_rule = $5;
-#??            print "  --- File '$file'\n";
             if ($state != 1) {
                 warn "$My_name: In file-database '$in_name' ",
                      "line $. is outside a section:\n   '$_'\n";
@@ -6425,7 +6448,7 @@
         if ( ! rdb_rule_exists( $from_rule ) ){
             print "!!!===Creating rule '$from_rule': '$ind_file' from '$idx_file'\n"
                   if ($diagnostics);
-            rdb_create_rule( $from_rule, 'external', $makeindex, '', 1, 
+            rdb_create_rule( $from_rule, 'external', $makeindex, 'run_makeindex', 1, 
                              $idx_file, $ind_file, $ind_base, 1, 0, 0, 1, [ "$ind_base.ilg" ] );
             print "  ===Source file '$ind_file' for '$rule'\n"
                   if ($diagnostics);
@@ -6959,10 +6982,9 @@
     if ( (! -e $file) && $use_make_for_missing_files ) {
         # Try to make the missing file
         #Set character to surround filenames in commands:
-        my $q = $quote_filenames ? '"' : '';
         if ( $toext ne '' ) {
              print "$My_name: '$rule': source file '$file' doesn't exist. I'll try making it...\n";
-             &Run_subst( "$make $q$file$q" );
+             &Run_subst( "$make $quote$file$quote" );
              if ( -e $file ) {
                  return;
              }
@@ -6972,7 +6994,7 @@
                    "   I'll try making it with allowed extensions \n";
              foreach my $try_ext ( keys %$Pinput_extensions ) {
                  my $new_dest = "$file.$try_ext";
-                 &Run_subst( "$make $q$new_dest$q" );
+                 &Run_subst( "$make $quote$new_dest$quote" );
                  if ( -e $new_dest ) {
                      print "SUCCESS in making '$new_dest'\n";
                      # Put file in rule, without a from_rule, but
@@ -7763,7 +7785,7 @@
 
 
 sub rdb_run1 {
-    # Assumes contexts for: rule.
+    # Assumes context for: rule.
     # Unconditionally apply the rule
     # Returns return code from applying the rule.
     # Otherwise: 0 on other kind of success, 
@@ -7790,7 +7812,8 @@
         if ( ! defined $_ ) { $_ = 'undef'; }
     }
     if ($int_cmd) {
-        print "For rule '$rule', running '\&$int_cmd( @int_args_for_printing )' ...\n";
+        print "For rule '$rule', use internal command '\&$int_cmd( @int_args_for_printing )' ...\n"
+            if $diagnostics;
         $return = &$int_cmd( @int_args ); 
     }
     elsif ($$Pext_cmd) {
@@ -7976,7 +7999,8 @@
     #    options, source, dest, base: correspond to placeholders.
     # Substitutions:
     #    %S=source, %D=dest, %B=base, %R=root=base for latex, %O=options, 
-    #    %T=texfile, %Y=$aux_dir1, %Z=$out_dir1
+    #    %T=texfile,
+    #    %V=$aux_dir, %W=$out_dir, %Y=$aux_dir1, %Z=$out_dir1
     # This is a globally usable subroutine, and works in a rule context,
     #    and outside.
     # Defaults:
@@ -8001,24 +8025,24 @@
     }
 
     #Set character to surround filenames:
-    my $q = $quote_filenames ? '"' : '';
-
     my %subst = ( 
-       '%A' => $q.$tex_basename.$q,
-       '%B' => $q.$base.$q,
-       '%D' => $q.$dest.$q,
+       '%A' => $quote.$tex_basename.$quote,
+       '%B' => $quote.$base.$quote,
+       '%D' => $quote.$dest.$quote,
        '%O' => $options,
-       '%S' => $q.$source.$q,
-       '%R' => $q.$root_filename.$q,
-       '%S' => $q.$source.$q,
-       '%T' => $q.$texfile_name.$q,
-       '%Y' => $q.$aux_dir1.$q,
-       '%Z' => $q.$out_dir1.$q,
+       '%S' => $quote.$source.$quote,
+       '%R' => $quote.$root_filename.$quote,
+       '%S' => $quote.$source.$quote,
+       '%T' => $quote.$texfile_name.$quote,
+       '%V' => $quote.$aux_dir.$quote,
+       '%W' => $quote.$out_dir.$quote,
+       '%Y' => $quote.$aux_dir1.$quote,
+       '%Z' => $quote.$out_dir1.$quote,
        '%%' => '%'         # To allow literal %B, %R, etc, by %%B.
         );
     if ($pre_tex_code) {
-        $subst{'%U'} = $q.$pre_tex_code.$q;
-        $subst{'%P'} = "$q$pre_tex_code\\input{$source}$q";
+        $subst{'%U'} = $quote.$pre_tex_code.$quote;
+        $subst{'%P'} = "$quote$pre_tex_code\\input{$source}$quote";
     }
     else {
         $subst{'%U'} = '';
@@ -8594,7 +8618,6 @@
 #===== Accesses rule part of database structure =======
 
     local ( $rule, $rule_act1, $file_act, $rule_act2 ) = @_;
-#??    &R1;
     if ( (! $rule) || ! rdb_rule_exists($rule) ) { return; }
 
     local ( $PArule_data, $PHsource, $PHdest, $PHsource_rules ) = @{$rule_db{$rule}};
@@ -8608,7 +8631,6 @@
     &$rule_act1 if $rule_act1;
     &rdb_do_files( $file_act ) if $file_act;
     &$rule_act2 if $rule_act2;
-#??    &R2;
 } #END rdb_one_rule
 
 #************************************************************
@@ -8671,7 +8693,6 @@
     # Assumes $rule context set.
 #===== Accesses file part of database structure =======
     local ($file, $file_act) = @_;
-#??    &F1;
     if ( (!$file) ||(!exists ${$PHsource}{$file}) ) { return; }
     local $PAfile_data = ${$PHsource}{$file};
     local ($Ptime, $Psize, $Pmd5, $Pfrom_rule, $Pcorrect_after_primary ) 
@@ -8680,7 +8701,6 @@
     if ( ! rdb_rule_exists( $$Pfrom_rule ) ) {
         $$Pfrom_rule = '';
     }
-#??    &F2;
 } #END rdb_one_file
 
 #************************************************************
@@ -9354,7 +9374,6 @@
         else { return( $name, 1 );}
     }
     foreach my $dir ( @path ) {
-        #??print "-------------dir='$dir',  ";
         # Make $dir concatenatable, and empty for current dir:
         if ( $dir eq '.' ) { 
             $dir = ''; 
@@ -9366,7 +9385,6 @@
             #Append directory separator only to non-empty dir
             $dir = "$dir/"; 
         }
-        #?? print " newdir='$dir'\n";
         if (-e "$dir$name") {
             return("$dir$name", 0);
         }
@@ -9417,8 +9435,6 @@
     }
   }
   @$ref_output = @return_list;
-#??  show_array( " Output", @$ref_output );
-#??  foreach (@$ref_output) { if ( /\/\// ) {  print " ====== double slash in  '$_'\n"; }  }
   return @not_found;
 } #END find_file_list1
 
@@ -10021,10 +10037,12 @@
 
 sub find_process_id {
 # find_process_id(string) finds id of process containing string and
-# being run by the present user.  Typically the string will be the
-# name of the process or part of its command line.
+# being run by the present user.  In all the uses in latexmk, the string is
+# the name of a file that is expected to be on the command line.
+#
 # On success, this subroutine returns the process ID.
 # On failure, it returns 0.
+#
 # This subroutine only works on UNIX systems at the moment.
 
     if ( $pid_position < 0 ) {
@@ -10079,7 +10097,7 @@
     # that the result can be used for input to MSWin programs as well
     # as cygwin programs.
     # Similarly for msys.
-    my $cwd = cwd();
+    my $cwd = getcwd();
     if ( $^O eq "cygwin" ) {
         my $cmd = "cygpath -w \"$cwd\"";
         my $Win_cwd = `$cmd`;
@@ -10099,6 +10117,10 @@
     elsif ( $^O eq "msys" ) {
         $cwd =~ s[^/([a-z])/][\u$1:/];
     }
+    # Normalized
+    if ($normalize_names) {
+        $cwd = abs_path($cwd);
+    }
     $cache{cwd} = $cwd;
 }  # END cache_good_cwd
 

Modified: trunk/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl	2021-04-16 20:15:03 UTC (rev 58885)
+++ trunk/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl	2021-04-16 20:15:34 UTC (rev 58886)
@@ -1,9 +1,9 @@
 #!/usr/bin/env perl
-# $Id: fmtutil.pl 58784 2021-04-07 07:30:50Z kakuto $
+# $Id: fmtutil.pl 58847 2021-04-12 01:00:22Z preining $
 # fmtutil - utility to maintain format files.
 # (Maintained in TeX Live:Master/texmf-dist/scripts/texlive.)
 # 
-# Copyright 2014-2020 Norbert Preining
+# Copyright 2014-2021 Norbert Preining
 # This file is licensed under the GNU General Public License version 2
 # or any later version.
 #
@@ -24,11 +24,11 @@
   TeX::Update->import();
 }
 
-my $svnid = '$Id: fmtutil.pl 58784 2021-04-07 07:30:50Z kakuto $';
-my $lastchdate = '$Date: 2021-04-07 09:30:50 +0200 (Wed, 07 Apr 2021) $';
+my $svnid = '$Id: fmtutil.pl 58847 2021-04-12 01:00:22Z preining $';
+my $lastchdate = '$Date: 2021-04-12 03:00:22 +0200 (Mon, 12 Apr 2021) $';
 $lastchdate =~ s/^\$Date:\s*//;
 $lastchdate =~ s/ \(.*$//;
-my $svnrev = '$Revision: 58784 $';
+my $svnrev = '$Revision: 58847 $';
 $svnrev =~ s/^\$Revision:\s*//;
 $svnrev =~ s/\s*\$$//;
 my $version = "r$svnrev ($lastchdate)";
@@ -103,7 +103,6 @@
 my @cmdline_cmds = (  # in same order as help message
   "all",
   "missing",
-  "refresh",
   "byengine=s",
   "byfmt=s",
   "byhyphen=s",
@@ -123,6 +122,7 @@
   "no-error-if-no-format",
   "nohash",
   "recorder",
+  "refresh",
   "strict!",
   "quiet|silent|q",
   "catcfg",
@@ -202,8 +202,16 @@
                   . "Try $prg --help if you need it.\n");
       return 1;
     } elsif (@cmds == 0) {
-      print_error("no command specified; try $prg --help if you need it.\n");
-      return 1;
+      if ($opts{'refresh'}) {
+        # backward compatibility: till 2021 we had --refresh as a command
+        # but now we allow combining it with --byfmt etc
+        # In case that --refresh was given without any other command, we
+        # treat it as --all --refresh as it was the case till the change.
+        $opts{'all'} = 1;
+      } else {
+        print_error("no command specified; try $prg --help if you need it.\n");
+        return 1;
+      }
     }
   }
   
@@ -288,9 +296,6 @@
   } elsif ($opts{'byhyphen'}) {
     return callback_build_formats('byhyphen', $opts{'byhyphen'});
 
-  } elsif ($opts{'refresh'}) {
-    return callback_build_formats('refresh');
-
   } elsif ($opts{'missing'}) {
     return callback_build_formats('missing');
 
@@ -473,6 +478,12 @@
   $doit = 1 if ($what eq 'missing' && ! -r "$destdir/$fmtfile");
   $doit = 1 if ($what eq 'byengine' && $eng eq $whatarg);
   $doit = 1 if ($what eq 'byfmt' && $fmt eq $whatarg);
+  #
+  # Deal with the --refresh option
+  # 2021 changed behavior that --refresh can be used with all other format
+  # selection cmd line args.
+  $doit = 0 if ($opts{'refresh'} && ! -r "$destdir/$fmtfile");
+  #
   # TODO
   # original fmtutil.sh was stricter about existence of the hyphen file
   # not sure how we proceed here; let's implicitly ignore.
@@ -1338,6 +1349,7 @@
   --no-strict             exit successfully even if a format fails to build
   --nohash                don't update ls-R files
   --recorder              pass the -recorder option and save .fls files
+  --refresh               recreate only existing format files
   --quiet                 be silent
   --catcfg                (does nothing, exists for compatibility)
   --dolinks               (does nothing, exists for compatibility)
@@ -1347,7 +1359,6 @@
 Commands:
   --all                   recreate all format files
   --missing               create all missing format files
-  --refresh               recreate only existing format files
   --byengine ENGINE       (re)create formats built with ENGINE
   --byfmt FORMAT          (re)create format FORMAT
   --byhyphen HYPHENFILE   (re)create formats that depend on HYPHENFILE

Modified: trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl	2021-04-16 20:15:03 UTC (rev 58885)
+++ trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl	2021-04-16 20:15:34 UTC (rev 58886)
@@ -1,12 +1,12 @@
 #!/usr/bin/env perl
-# $Id: tlmgr.pl 57970 2021-02-27 14:17:34Z siepo $
+# $Id: tlmgr.pl 58862 2021-04-13 01:01:37Z preining $
 #
 # Copyright 2008-2021 Norbert Preining
 # This file is licensed under the GNU General Public License version 2
 # or any later version.
 
-my $svnrev = '$Revision: 57970 $';
-my $datrev = '$Date: 2021-02-27 15:17:34 +0100 (Sat, 27 Feb 2021) $';
+my $svnrev = '$Revision: 58862 $';
+my $datrev = '$Date: 2021-04-13 03:01:37 +0200 (Tue, 13 Apr 2021) $';
 my $tlmgrrevision;
 my $tlmgrversion;
 my $prg;
@@ -869,6 +869,13 @@
   my $sysmode = ($opts{"usermode"} ? "-user" : "-sys");
   my $invoke_fmtutil = "fmtutil$sysmode $common_fmtutil_args";
 
+  # of create_formats is unset (NOT the default) we add --refresh so that
+  # only existing formats are recreated
+  if (!$localtlpdb->option("create_formats")) {
+    $invoke_fmtutil .= " --refresh";
+    info("only existing formats will be refreshed per user option (create_formats=0)\n");
+  }
+
   if ($::files_changed) {
     $errors += do_cmd_and_check("mktexlsr");
     if (defined($localtlpdb->get_package('context'))
@@ -931,9 +938,8 @@
       }
     }
 
-    # format-regenerate is used when the paper size changes.  In that
-    # case, if option("create_formats") is set, we simply want to generate
-    # all formats
+    # format-regenerate is used when the paper size changes.
+    # In that case we simply want to generate all formats
     #
     my %done_formats;
     my %updated_engines;
@@ -957,13 +963,12 @@
     for my $m (keys %{$::execute_actions{'disable'}{'formats'}}) {
       $do_full = 1;
     }
-    my $opt_fmt = $localtlpdb->option("create_formats");
     if ($do_full) {
       info("regenerating fmtutil.cnf in $TEXMFDIST\n");
       TeXLive::TLUtils::create_fmtutil($localtlpdb,
                                        "$TEXMFDIST/web2c/fmtutil.cnf");
     }
-    if ($opt_fmt && !$::regenerate_all_formats) {
+    if (!$::regenerate_all_formats) {
       # first regenerate all formats --byengine 
       for my $e (keys %updated_engines) {
         debug ("updating formats based on $e\n");
@@ -994,20 +999,21 @@
           # Use full path for external command, except on Windows.
           $lang = "$TEXMFSYSVAR/tex/generic/config/$lang";
         }
-        if ($localtlpdb->option("create_formats")
-            && !$::regenerate_all_formats) {
+        if (!$::regenerate_all_formats) {
           $errors += do_cmd_and_check ("$invoke_fmtutil --byhyphen \"$lang\"");
         }
       }
     }
-  }
 
-  #
-  if ($::regenerate_all_formats) {
-    info("Regenerating all formats, this may take some time ...");
-    $errors += do_cmd_and_check("$invoke_fmtutil --all");
-    info("done\n");
-    $::regenerate_all_formats = 0;
+    # ::regenerate_all_formats comes from TLPaper updates
+    # so we just refresh formats instead of generating all that have not been there
+    if ($::regenerate_all_formats) {
+      info("Regenerating available formats, this may take some time ...");
+      # --refresh might already be in $invoke_fmtutil, but we don't care
+      $errors += do_cmd_and_check("$invoke_fmtutil --refresh --all");
+      info("done\n");
+      $::regenerate_all_formats = 0;
+    }
   }
 
   # undefine the global var, otherwise in GUI mode the actions
@@ -10110,7 +10116,7 @@
 distribution (L<https://tug.org/texlive>) and both are licensed under the
 GNU General Public License Version 2 or later.
 
-$Id: tlmgr.pl 57970 2021-02-27 14:17:34Z siepo $
+$Id: tlmgr.pl 58862 2021-04-13 01:01:37Z preining $
 =cut
 
 # test HTML version: pod2html --cachedir=/tmp tlmgr.pl >/tmp/tlmgr.html

Modified: trunk/Master/texmf-dist/doc/man/man1/latexmk.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/latexmk.1	2021-04-16 20:15:03 UTC (rev 58885)
+++ trunk/Master/texmf-dist/doc/man/man1/latexmk.1	2021-04-16 20:15:34 UTC (rev 58886)
@@ -1,4 +1,4 @@
-.TH LATEXMK 1 "29 September 2020" ""
+.TH LATEXMK 1 "15 April 2021" ""
 .SH NAME
 latexmk \- generate LaTeX document
 .SH SYNOPSIS
@@ -116,36 +116,23 @@
 supported engines, i.e., currently \fIlatex\fR, \fIlualatex\fR,
 \fIpdflatex\fR, \fIxelatex\fR.  Mention of a specific one of these normally
 refers that specific engines.  Earlier versions of this documentation
-weren't so consistent.
+weren't so consistent.  Which of these is used to compile a document,
+depends on the configuration and the command line arguments.
 
 \fBNote 2\fR: \fBIn addition to the options in the list below,
 \fIlatexmk\fR recognizes almost all the options recognized by the
-\fI*latex\fR in their 
+\fI*latex\fR programs in their 
 current TeXLive and MiKTeX implementations.  Some of the options for
-these programs also trigger special action or behavior by
+these programs trigger special action or behavior by
 \fIlatexmk\fR, in which case they have specific explanations in this
-document.  Otherwise, they 
-are just passed through to a called \fI*latex\fR
-program. Run \fIlatexmk\fR with the \fB-showextraoptions\fR to get a
+document; in this case they may or may not be passed to *latex as well.
+
+Run \fIlatexmk\fR with the \fB-showextraoptions\fR to get a
 list of the options that \fIlatexmk\fR accepts and that are simply
 passed through to \fI*latex\fR.  See also the
 explanation of the \fB-showextraoptions\fR option for more
 information.
 
-\fBNote 3\fR: In this documentation, the term \fI*latex\fR is often
-referred to, which refers to all the supported \fIlatex\fR-like programs,
-whether the original \fIlatex\fR, or the later \fIpdflatex\fR,
-\fIxelatex\fR, and \fIlualatex\fR.  Users should know that from
-\fIlatexmk\fR's point of view, all of these programs behave very much
-alike, with the sole exception that by default \fIlatex\fR produces a dvi
-file and all the others produce a pdf file.  \fILatexmk\fR can be easily
-configured to use whichever of these programs is needed.  See the
-documentation for the following options: \fB-pdflua\fR, \fB-pdfxe\fR,
-\fB-lualatex\fR, and \fB-xelatex\fR, and also see the documentation for the
-\fI$latex\fR, \fI$pdflatex\fR, \fI$lualatex\fR, and \fI$xelatex\fR
-configuration variables.  At present \fIlatexmk\fR does not do automatic
-detection of which program is to be used.
- 
 
 \fBDefinitions of options and arguments\fR
 
@@ -184,7 +171,7 @@
 Windows, and is accepted by \fIlatex\fR etc.
 
 .TP
-.B -auxdir=FOO or -aux-directory=FOO
+.B -auxdir=FOO \fRor\fB -aux-directory=FOO
 Sets the directory for auxiliary output files of *latex 
 (.aux, .log etc).  This
 achieves its effect by the \fB-aux-directory\fR option of *latex,
@@ -276,11 +263,16 @@
 variable to 1.5 in a configuration file.
 
 .TP
-.B -bibtexfudge, -bibtexfudge-
-Turn on/off the change-directory fudge needed for old versions (pre-2019)
-of bibtex.  See documentation of \fI$bibtex_fudge\fR for details.
+.B -bibtexfudge\fR or\fB -bibfudge
+Turn on the change-directory fudge for bibtex.  See documentation of
+\fI$bibtex_fudge\fR for details.
 
 .TP
+.B -bibtexfudge-\fR or\fB -bibfudge-
+Turn off the change-directory fudge for
+bibtex.  See documentation of \fI$bibtex_fudge\fR for details.
+
+.TP
 .B -bm <message>
 A banner message to print diagonally across each page when converting
 the dvi file to postscript.  The message must be a single argument on
@@ -320,7 +312,7 @@
 configuration variables are removed.
 
 This cleanup is instead of a regular make.  See the \fB-gg\fR option
-if you want to do a cleanup then a make.
+if you want to do a cleanup followed by a make.
 
 \fITreatment of .bbl files: \fR If \fI$bibtex_use\fR is set to 0 or 1,
 bbl files are always treated as non-regeneratable.  If
@@ -347,7 +339,7 @@
 in the \fI$clean_full_ext\fR configuration variable.
 
 This cleanup is instead of a regular make.  See the \fB-gg\fR option
-if you want to do a cleanup than a make.
+if you want to do a cleanup followed by a make.
 
 See the \fB-c\fR option for the specification of whether or not .bbl
 files are treated as non-regeneratable or regeneratable. 
@@ -544,7 +536,8 @@
 occurred.  If instead, or additionally, you want the \fIlatex\fR (etc)
 program not to pause for user input after an error, you should arrange
 this by an option that is passed to the program, e.g., by
-\fIlatexmk\fR's option \fB-interaction=nonstopmode\fR.
+\fIlatexmk\fR's option \fB-interaction=nonstopmode\fR (which \fIlatexmk\fR
+passes to \fI*latex\fR). 
 
 .TP
 .B -f-
@@ -570,7 +563,7 @@
 \fB-C\fR had been given, and then do a regular make.
 
 .TP
-.B -h, -help
+.B -h \fRor\fB-non-help
 Print help information.
 
 .TP
@@ -705,6 +698,16 @@
 files without updating the Makefile to match.
 
 .TP
+.B -makeindexfudge
+Turn on the change-directory fudge for makeindex.  See documentation of
+\fI$makeindex_fudge\fR for details.
+
+.TP
+.B -makeindexfudge-
+Turn off the change-directory fudge for makeindex.  See documentation of
+\fI$makeindex_fudge\fR for details.
+
+.TP
 .B -MSWinBackSlash
 This option only has an effect when \fIlatexmk\fR is running under
 MS-Windows.  This is that when \fIlatexmk\fR runs a command under
@@ -751,9 +754,9 @@
 Never run bibtex or biber.  Equivalent to the \fB-bibtex-\fR option.
 
 .TP
-.B -nobibtexfudge
-Turn off the change-directory fudge needed for old versions (pre-2019)
-of bibtex.  See documentation of \fI$bibtex_fudge\fR for details.
+.B -nobibtexfudge \fRor\fB -nobibfudge
+Turn off the change-directory fudge for
+bibtex.  See documentation of \fI$bibtex_fudge\fR for details.
 
 .TP
 .B -norc
@@ -765,8 +768,13 @@
 no matter where it occurs on the command line.
 
 .TP
-.B -outdir=FOO or -output-directory=FOO
+.B -nomakeindexfudge
+Turn off the change-directory fudge for makeindex.  See documentation of
+\fI$makeindex_fudge\fR for details.
 
+.TP
+.B -outdir=FOO \fRor\fB -output-directory=FOO
+
 Sets the directory for the output files of *latex.  This achieves
 its effect by the \fB-output-directory\fR option of *latex, which
 currently (Dec. 2011 and later) is implemented on the common versions of
@@ -784,6 +792,23 @@
 the document directory.
 
 .TP
+.B -output-format=FORMAT
+This option is one that is allowed for \fIlatex\fR, \fIlualatex\fR, and
+\fIpdflatex\fR. But it is not passed to these programs.  Instead
+\fIlatexmk\fR emulates it in a way suitable for the context of
+\fIlatexmk\fR and its workflows.
+
+If FORMAT is dvi, then dvi output is turned on, and postscript and pdf
+output are turned off. This is equivalent to using the options \fB-dvi -ps-
+-pdf-\fR.
+
+If FORMAT is pdf, then pdf output is turned on, and dvi and postscript
+output are turned off. This is equivalent to using the options \fB-pdf -ps-
+-dvi-\fR.
+
+If FORMAT is anything else, \fIlatexmk\fR gives an error.
+
+.TP
 .B -p
 Print out the document.  By default the file to be printed is
 the first in the list postscript, pdf, dvi that is being made.
@@ -921,7 +946,7 @@
     latexmk -pretex='\\AtBeginDocument{Message\\par}' foo.tex
 
 .TP
-.B -print=dvi, -print=ps, -print=pdf, -print=auto,
+.B -print=dvi\fR,\fB -print=ps\fR,\fB -print=pdf\fR,\fB -print=auto,
 Define which kind of file is printed.  This option also ensures that
 the requisite file is made, and turns on printing.
 
@@ -1098,30 +1123,29 @@
 (currently) a combination of those allowed by the TeXLive and MiKTeX
 implementations.  (If a particular option is given to \fIlatexmk\fR
 but is not handled by the particular implementation of \fI*latex\fR
-that is being used, that program will probably give an
-error message.)  These options are very numerous, but are not listed
+that is being used, that program will probably give a warning or an
+error.)  These options are very numerous, but are not listed
 in this documentation because they have no effect on \fIlatexmk\fR's
 actions.
 
-There are a few options (\fB-includedirectory=dir\fR,
+There are a few options (e.g., \fB-includedirectory=dir\fR,
 \fB-initialize\fR, \fB-ini\fR) that are not recognized, either because
 they don't fit with \fIlatexmk\fR's intended operations, or because
 they need special processing by \fIlatexmk\fR that isn't implemented
 (at least, not yet).
 
-There are also options that are accepted by \fIlatex\fR etc, but
-instead trigger actions by \fIlatexmk\fR: \fB-help\fR,
-\fB-version\fR. 
-
-Finally, there are certain options for \fI*latex\fR
-(e.g., \fB-recorder\fR) that trigger special actions or behavior by
-\fIlatexmk\fR itself as well as being passed in some form to the
-called \fI*latex\fR program, or that affect other
-programs as well.  These options do have entries in this
-documentation.  These options are:
+There are certain options for \fI*latex\fR (e.g., \fB-recorder\fR) that
+trigger special actions or behavior by \fIlatexmk\fR itself. Depending on
+the action, they may also be passed in some form to the called \fI*latex\fR
+program, and/or may affect other programs as well.  These options do have
+entries in this documentation.  Among these options are:
 \fB-jobname=STRING\fR, \fB-aux-directory=dir\fR,
 \fB-output-directory=DIR\fR, \fB-quiet\fR, and \fB-recorder\fR.
 
+There are also options that are accepted by \fI*latex\fR, but
+instead trigger actions purely by \fIlatexmk\fR: \fB-help\fR,
+\fB-version\fR. 
+
 .TP
 .B -silent
 Run commands silently, i.e., with options that reduce the amount of
@@ -1207,7 +1231,7 @@
   latexmk -usepretex='\\AtBeginDocument{Message\\par}' foo.tex
 
 .TP
-.B -v, -version
+.B -v \fRor\fB -version
 Print version number of \fIlatexmk\fR.
 
 .TP
@@ -1215,7 +1239,7 @@
 Opposite of \fB-silent\fR.  This is the default setting.
 
 .TP
-.B -view=default, -view=dvi, -view=ps, -view=pdf, -view=none
+.B -view=default\fR,\fB -view=dvi\fR,\fB -view=ps\fR,\fB -view=pdf\fR,\fB -view=none
 Set the kind of file used when previewing is requested (e.g., by the
 \fB-pv\fR or \fB-pvc\fR switches).  The default is to view the "highest"
 kind of requested file (in the low-to-high order .dvi, .ps, .pdf).  
@@ -1392,9 +1416,7 @@
 other is that there may be a configuration, or misconfiguration, such
 that the program that \fIlatexmk\fR invokes to compile the document is
 not the expected one, or is given options incompatible with what
-\fIlatexmk\fR initially expects.  (E.g., the \fB-output-format=...\fR
-option could be used with \fIlualatex\fR, or \fIxelatex\fR gets
-invoked without the \fB-no-pdf\fR option.)
+\fIlatexmk\fR initially expects.
 
 Under \fIlatex\fR and \fIpdflatex\fR, control of the output format by
 the document is done by setting the \\pdfoutput macro.  Under
@@ -1983,12 +2005,24 @@
 .B $bibtex ["bibtex %O %S"]
 The BibTeX processing program.
 .TP
-.B $bibtex_fudge [0]
-When using bibtex, whether to take special action to allow older
-versions of bibtex to
-work when $out_dir or $aux_dir is specified.  With bibtex from about 2019,
-this special action is longer be required; hence the default is not to do
-it. 
+.B $bibtex_fudge [1]
+When using bibtex, whether to change directory to $aux_dir before running
+bibtex.
+
+The need arises as follows:
+
+a. With bibtex before about 2019, if the filename given to it contains a
+path component, there was a bug that bibtex would not find extra aux files,
+as produced by the \\include command in TeX.
+
+b. With all moderately recent versions of bibtex, bibtex may refuse to
+write its bbl and blg files, for security reasons, for certain cases of the
+path component of the filename given to it.
+
+However, there are also rare cases where the change-directory method
+prevents bibtex from finding certain bib or bst files. Then
+\fI$bibtex_fudge\fR needs to be set to 0.
+
 .TP
 .B $bibtex_silent_switch ["-terse"]
 Switch(es) for the BibTeX processing program when silent mode is on.
@@ -2074,7 +2108,7 @@
 
 in an initialization file will imply that when a clean-up operation is
 specified, not only is the standard set of files deleted, but also
-files of the form FOO.out, FOO-blx.bib, %R-figures*.log, and
+files of the form FOO.out, FOO-blx.bib, FOO-figures*.log, and
 pythontex-files-FOO/*, where FOO stands for the basename of the file
 being processed (as in FOO.tex).
 
@@ -2693,6 +2727,12 @@
 .B $makeindex ["makeindex %O -o %D %S"]
 The index processing program.
 .TP
+.B $makeindex_fudge [0]
+When using makeindex, whether to change directory to $aux_dir before running
+makeindex.  Set to 1 if $aux_dir is not an explicit subdirectory of current
+directory, otherwise makeindex will refuse to write its output and log
+files, for security reasons. 
+.TP
 .B $makeindex_silent_switch ["-q"]
 \fBSwitch(es)\fR for the index processing program when silent mode is on.
 .TP
@@ -3879,7 +3919,7 @@
 harvested too easily.)
 .SH AUTHOR
 Current version, by John Collins 
-(Version 4.70b).
+(Version 4.72b).
 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-04-16 20:15:03 UTC (rev 58885)
+++ trunk/Master/texmf-dist/doc/support/latexmk/CHANGES	2021-04-16 20:15:34 UTC (rev 58886)
@@ -743,4 +743,15 @@
     longer causes a bibtex error.
   Add options -bibfudge, -bibfudge-, -nobibfudge.
 
-
+From v. 4.70b to 4.72b
+  For bibtex, revert to change-directory default when running bibtex.
+  Add similar procedure for makeindex, but leave old default.
+  Add options -indexfudge, -indexfudge-, -noindexfudge.
+  Solve bug that transition from non-existent file to existent file didn't
+    trigger rerun of *latex.  (This concerns file that were flagged as
+    missing in the .log file.
+  Give .latexmkrc priority of latexmkrc in finding rc files.
+  Correct bug when chapterbib used with non-trivial out or aux dir.
+  Improve handling of situation when auxdir or outdir are specified as
+    absolute paths. 
+  Miscellaneous bug corrections, especially about consistent normalizations

Modified: trunk/Master/texmf-dist/doc/support/latexmk/INSTALL
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/INSTALL	2021-04-16 20:15:03 UTC (rev 58885)
+++ trunk/Master/texmf-dist/doc/support/latexmk/INSTALL	2021-04-16 20:15:34 UTC (rev 58886)
@@ -1,6 +1,6 @@
             INSTALLING latexmk
             ==================
-      (Version 4.70b, 29 September 2020)
+      (Version 4.72b, 15 April 2021)
 
             John Collins
             Physics Department

Modified: trunk/Master/texmf-dist/doc/support/latexmk/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/README	2021-04-16 20:15:03 UTC (rev 58885)
+++ trunk/Master/texmf-dist/doc/support/latexmk/README	2021-04-16 20:15:34 UTC (rev 58886)
@@ -1,5 +1,5 @@
-Latexmk, version 4.70b, 29 September 2020
------------------------------------------
+Latexmk, version 4.72b, 15 April 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.70b: Automatic LaTeX document generation routine
+Latexmk 4.72b: Automatic LaTeX document generation routine
 
 Usage: latexmk [latexmk_options] [filename ...]
 
@@ -100,8 +100,8 @@
    -bibtex-cond  - use bibtex when needed, but only if the bib file exists
    -bibtex-cond1 - use bibtex when needed, but only if the bib file exists;
                    on cleanup delete bbl file only if bib file exists
-   -bibfudge     - use change-directory fudge needed for old bibtexs
-   -bibfudge-    - don't use change-directory fudge needed for old bibtexs
+   -bibfudge or -bibtexfudge - change directory to output directory when running bibtex
+   -bibfudge- or -bibtexfudge- - don't change directory when running bibtex
    -bm <message> - Print message across the page when converting to postscript
    -bi <intensity> - Set contrast or intensity of banner
    -bs <scale> - Set scale for banner
@@ -135,6 +135,8 @@
    -g-    - Turn off -g
    -h     - print help
    -help - print help
+   -indexfudge or -makeindexfudge - change directory to output directory when running makeindex
+   -indexfudge- or -makeindexfudge- - don't change directory when running makeindex
    -jobname=STRING - set basename of output file(s) to STRING.
             (Like --jobname=STRING on command line for many current
             implementations of latex/pdflatex.)
@@ -152,6 +154,8 @@
    -M     - Show list of dependent files after processing
    -MF file - Specifies name of file to receives list dependent files
    -MP    - List of dependent files includes phony target for each source file.
+   -makeindexfudge - change directory to output directory when running makeindex
+   -makeindexfudge-- don't change directory to output directory when running makeindex
    -MSWinBackSlash  under MSWin use backslash (\) for directory separators
                     for filenames given to called programs
    -MSWinBackSlash-  under MSWin use forward slash (/) for directory separators
@@ -159,11 +163,16 @@
    -new-viewer    - in -pvc mode, always start a new viewer
    -new-viewer-   - in -pvc mode, start a new viewer only if needed
    -nobibtex      - never use bibtex
-   -nobibfudge    - don't use change-directory fudge needed for old bibtexs
+   -nobibfudge or -nobibtexfudge - don't change directory when running bibtex
    -nodependents  - Do not show list of dependent files after processing
+   -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
                   - set name of directory for output files
+   -output-format=FORMAT
+                  - if FORMAT is dvi, turn on dvi output, turn off others
+                  - if FORMAT is pdf, turn on pdf output, turn off others
+                  - otherwise error
    -pdf   - generate pdf by pdflatex
    -pdfdvi - generate pdf by dvipdf
    -pdflatex=<program> - set program used for pdflatex.

Modified: trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/chapterbib-latexmkrc
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/chapterbib-latexmkrc	2021-04-16 20:15:03 UTC (rev 58885)
+++ trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/chapterbib-latexmkrc	2021-04-16 20:15:34 UTC (rev 58886)
@@ -15,32 +15,33 @@
 $bibtex_save = $bibtex;
 $bibtex = 'internal bibtex_fix %R %D %S';
 
-# MUST NOT use bibtex_fudge (i.e., change of directory before running bibtex).
-# That's not needed in post-2019 versions of bibtex, and messes up
-# things with chapterbib.  So turn it off:
-$bibtex_fudge = 0;
-
 $clean_ext .= " %R-mod.blg %R-mod.aux %R-mod.bbl";
 
 sub bibtex_fix {
     my ($root, $dest, $source) = @_;
-    local ($base_tex, $path, $ext) = fileparse( $source, '\.[^\.]*' );
+    local ($base_bare, $path, $ext) = fileparse( $source, '\.[^\.]*' );
+    if ($path eq './') { $path = ''; }
+    local $base = $path.$base_bare;
     my $ret = 0;
-    if ( $base_tex eq $root ) {
+    if ( $base_bare eq $root ) {
         print "--- Will run bibtex on modified '$root.aux' file\n";
-        my $aux_mod_base = $path.$base_tex."-mod";
+        my $aux_mod_base = $base."-mod";
         local $out_fh = new FileHandle "> $aux_mod_base$ext";
         if (!$out_fh) { die "Cannot write to '$aux_mod_base$ext'\n"; }
         local $level = 0;
         fix_aux( $source );
         close $out_fh;
-        $ret = Run_subst( $bibtex_save, 2, undef, "$aux_mod_base.aux", undef, $aux_mod_base );
+        # Override source, dest, and basenames, since they are to have the path given
+        # in the arguments to this subroutine, instead of the path given in the
+        # corresponding names in the rule.  Latexmk may change directory before
+        # calling this subroutine, and adjusts the arguments accordingly:
+        $ret = Run_subst( $bibtex_save, 2, undef, "$aux_mod_base$ext", "$aux_mod_base.bbl", $aux_mod_base );
         foreach ( 'bbl', 'blg' ) {
            copy "$aux_mod_base.$_", "$path$root.$_";
         }
     }
     else {
-        $ret = Run_subst( $bibtex_save );
+        $ret = Run_subst( $bibtex_save, 2, undef, $source, $dest, $base );
     }
     return $ret;
 }

Added: trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/hyperxmp-latexmkrc
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/hyperxmp-latexmkrc	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/hyperxmp-latexmkrc	2021-04-16 20:15:34 UTC (rev 58886)
@@ -0,0 +1,200 @@
+# Configuration of latexmk so that it works with the hyperxmp package.
+# Hyperxmp puts document xmp metadata in the pdf file, and one of the
+# fields in that metadata is byteCount, which is the size of the pdf file.
+# This configuration ensures that the byteCount is present and correctly
+# equals the pdf file's size.
+#
+# Method of operation:
+# For any command that might produce a pdf file, prepend "internal mycmd3 "
+# to the previously configured command, so that a subroutine mycmd3 is
+# called.  It runs the expected command and then does post-processing if
+# the output file is a pdf file.
+
+foreach my $cmd ( "latex", "lualatex", "pdflatex", "xelatex",
+                  "dvipdf", "xdvipdfmx", "ps2pdf" ) {
+    ${$cmd} = "internal mycmd ${$cmd}";
+}
+
+#======================================================
+
+sub mycmd {
+  # Run command, and do extra processing of output file, if it is a pdf
+  # file.
+  # This subroutine is run in a rule context, so that $rule is the name of
+  # the rule and $$Pdest is the destination file name. 
+
+  # Identification string for messages:
+  local $name = "$My_name.mycmd";
+
+  my $retval = system @_;
+
+  if ( $$Pdest =~ /\.pdf$/ ) {
+     fix_pdf( $$Pdest );
+  }
+  return $retval;
+}
+
+#======================================================
+
+sub fix_pdf {
+  # Change/insert byteCount field with correct file length, while preserving
+  # the file size and the length of the stream containing xmp metadata.
+  # Return 1 on success, else 0.
+
+  local $pdf_name = shift;
+  local $tmp_name = "$pdf_name.new.pdf";
+  local $pdf_size  = (stat($pdf_name))[7];
+  warn "Inserting/correcting byteCount field in '$pdf_name' ...\n";
+
+  # Strings surrounding (and identifying) the byteCount field, and other
+  # parts of the xmp packet:
+  local $xmp_start = '<x:xmpmeta xmlns:x="adobe:ns:meta/">';
+  local $decl_bC = '<pdfaProperty:name>byteCount</pdfaProperty:name>';
+  local $pre_bC = '<prism:byteCount>';
+  local $post_bC = '</prism:byteCount>';
+  local $pC = '<prism:pageCount>';
+  local $rd_end = '</rdf:Description>';
+  local $xmp_end = '</x:xmpmeta>';
+
+  local *PDF;
+  local *TMP;
+
+  if (! open PDF, "<", $pdf_name ) {
+      warn "  Cannot read '$pdf_name'\n";
+      return 0;
+  }
+  if ( ! open TMP, ">", $tmp_name ) {
+      warn "  Cannot write temporary file '$tmp_name'\n";
+      close PDF;
+      return 0;
+  }
+  local $status = 0;  # 0 = no XMP packet, 1 = success, >= errors
+  while ( <PDF> ) {
+      # Only examine first XMP packet:
+      if ( ($status == 0)  &&  /^\s*\Q$xmp_start\E/ ) {
+         local @xmp = $_;
+         local $len_padding = 0;
+         local $xmp_after_line = '';
+         &xmp_get_mod;
+         print TMP @xmp;
+         # Insert correct padding to leave file size unchanged:
+         while ( $len_padding > 0 ) {
+             my $len_line = 64;
+             if ( $len_line > $len_padding ) { $len_line = $len_padding; }
+             $len_padding -= $len_line;
+             print TMP (' ' x ($len_line - 1) ), "\n";
+         }
+         print TMP $xmp_after_line;
+         $xmp_after_line = '';
+     }
+     else {
+         print TMP "$_";
+     }
+  }
+  close PDF;
+  close TMP;
+
+  if ($status == 0) {
+      warn "  Could not insert/modify byteCount, since no XMP packet was found.\n";
+      warn "  So '$pdf_name' is unchanged,\n",
+           "  and I will delete temporary file '$tmp_name'.\n";
+      unlink $tmp_name;
+  } elsif ($status == 1)  {
+      rename $tmp_name, $pdf_name
+        or die "  Cannot move temporary file '$tmp_name' to '$pdf_name'.\n",
+               "  Error is '$!'\n";
+  } else {
+      warn "  Could not insert correct byteCount. See above for reason.\n";
+      warn "  So '$pdf_name' is unchanged,\n",
+           "  and I will delete temporary file '$tmp_name'.\n";
+      unlink $tmp_name;
+  }
+  return ($status == 1);
+}
+
+#======================================================
+
+sub xmp_get_mod {
+    # Get xmp packet, given that @xmp contains its first line.
+    # Get amount of trailing padding, and line after that.
+    # If possible, insert a byteCount field:
+    #    Either replace existing specification, if it exists,
+    #    or insert one in expected place for hyperxmp, if the XMP packet
+    #      matches what hyperxmp would produce.
+    # Return xmp packet in @xmp, amount of padding needed in $len_padding,
+    # line after that in $xmp_after_line, and error code in $error.
+    # Set $status appropriately: 1 for success; >=1 for failure.
+
+    $len_padding = 0;
+    $xmp_after_line = '';
+    
+    my $bC_index = -1;
+    my $xmp_end_found = 0;
+    my $decl_bC_found = 0;
+    while ( <PDF> ) {
+        push @xmp, $_;
+        if ( /^\s*\Q$xmp_end\E/ ) {
+            $xmp_end_found = 1;
+            # Get amount of padding;
+            while (<PDF>) {
+                if ( /^\s*$/ ) {
+                    $len_padding += length($_);
+                } else {
+                    $xmp_after_line = $_;
+                    last;
+                }
+            }
+            last;
+        }
+        elsif ( $bC_index >= 0 ){
+            next;
+        }
+        # Rest of conditions only apply if no place yet found for byteCount
+        # specification.
+        elsif ( /^(\s*)\Q$pre_bC\E.*?\Q$post_bC\E\s*$/ ) {
+            $bC_index = $#xmp;
+        }
+        elsif ( /^\s*\Q$decl_bC\E/ ) {
+            $decl_bC_found = 1;
+        }
+        elsif ( /^(\s*)\Q$rd_end\E/ ){
+            # End of rdf:Description block.
+            # So having previous declaration of byteCount is irrelevant.
+            $decl_bC_found = 0;
+        }
+        elsif ( $decl_bC_found  &&  /^(\s*)\Q$pC\E/ ){
+            $bC_index = $#xmp;
+            pop @xmp;
+            push @xmp, '', $_;
+        }
+
+    } # End reading of XMP
+
+    if ($bC_index < 0) {
+        if ( ! $xmp_end_found ) {
+            warn "  End of XMP packet not found.\n";
+            $status = 2;
+        }
+        elsif ( ! $decl_bC_found ) {
+            warn "  XMP packet not in appropriate hyperxmp-compatible format.\n";
+            $status = 3;
+        }
+        return;
+    }
+    my $new_line = '      ' . $pre_bC . $pdf_size . $post_bC . "\n";
+    my $old_line = $xmp[$bC_index];
+    my $delta_len = length($new_line) - length($old_line);
+    if ($delta_len > $len_padding) {
+        warn "  Cannot get padding correct for '$pdf_name'.\n",
+             "    Length change of bC line = $delta_len; ",
+             "    Padding bytes available = $len_padding.\n";
+        $status = 4;
+        return;
+    } else {
+        $len_padding -= $delta_len;
+        $xmp[$bC_index] = $new_line;
+        $status = 1;
+    }
+}
+
+#======================================================

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-04-16 20:15:03 UTC (rev 58885)
+++ trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt	2021-04-16 20:15:34 UTC (rev 58886)
@@ -61,7 +61,7 @@
 
 
 
-                               29 September 2020                             1
+                                 15 April 2021                               1
 
 
 
@@ -127,7 +127,7 @@
 
 
 
-                               29 September 2020                             2
+                                 15 April 2021                               2
 
 
 
@@ -137,29 +137,21 @@
 
 
        a specific one of these normally refers that specific engines.  Earlier
-       versions of this documentation weren't so consistent.
+       versions  of  this documentation weren't so consistent.  Which of these
+       is used to compile a document, depends on  the  configuration  and  the
+       command line arguments.
 
        Note  2:  In  addition to the options in the list below, latexmk recog-
-       nizes almost all the options recognized by the *latex in their  current
-       TeXLive and MiKTeX implementations.  Some of the options for these pro-
-       grams also trigger special action or behavior by latexmk, in which case
-       they  have specific explanations in this document.  Otherwise, they are
-       just passed through to a called *latex program. Run  latexmk  with  the
-       -showextraoptions to get a list of the options that latexmk accepts and
-       that are simply passed through to *latex.  See also the explanation  of
-       the -showextraoptions option for more information.
+       nizes almost all the options recognized by the *latex programs in their
+       current  TeXLive  and  MiKTeX implementations.  Some of the options for
+       these programs trigger special action or behavior by latexmk, in  which
+       case  they  have  specific  explanations in this document; in this case
+       they may or may not be passed to *latex as well.
 
-       Note  3:  In  this documentation, the term *latex is often referred to,
-       which refers to all the  supported  latex-like  programs,  whether  the
-       original  latex,  or  the later pdflatex, xelatex, and lualatex.  Users
-       should know that from latexmk's point of view, all  of  these  programs
-       behave  very  much alike, with the sole exception that by default latex
-       produces a dvi file and all the others produce a pdf file.  Latexmk can
-       be easily configured to use whichever of these programs is needed.  See
-       the documentation for the following options: -pdflua,  -pdfxe,  -luala-
-       tex,  and  -xelatex,  and  also  see  the documentation for the $latex,
-       $pdflatex, $lualatex, and $xelatex configuration variables.  At present
-       latexmk does not do automatic detection of which program is to be used.
+       Run latexmk with the -showextraoptions to get a  list  of  the  options
+       that latexmk accepts and that are simply passed through to *latex.  See
+       also the explanation of the -showextraoptions option for more  informa-
+       tion.
 
 
        Definitions of options and arguments
@@ -190,10 +182,18 @@
 
               Latexmk gives a fatal error when it detects  any  of  the  above
               characters in the TeX filename(s) specified on the command line.
+              However before testing for illegal characters,  latexmk  removes
+              matching  pairs  of double quotes from a filename.  This matches
+              the behavior of latex etc, and deals with  problems  that  occa-
+              sionally result from filenames that have been incorrectly quoted
+              on the command line.  In addition, under Microsoft Windows,  the
+              forward slash character "\" is a directory separator, so latexmk
+              replaces it by a backward slash "/", which is also a  legal  di-
+              rectory separator in Windows, and is accepted by latex etc.
 
 
 
-                               29 September 2020                             3
+                                 15 April 2021                               3
 
 
 
@@ -202,16 +202,6 @@
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              However before testing for illegal characters,  latexmk  removes
-              matching  pairs  of double quotes from a filename.  This matches
-              the behavior of latex etc, and deals with  problems  that  occa-
-              sionally result from filenames that have been incorrectly quoted
-              on the command line.  In addition, under Microsoft Windows,  the
-              forward slash character "\" is a directory separator, so latexmk
-              replaces it by a backward slash "/", which is also a  legal  di-
-              rectory separator in Windows, and is accepted by latex etc.
-
-
        -auxdir=FOO or -aux-directory=FOO
               Sets  the  directory for auxiliary output files of *latex (.aux,
               .log etc).  This achieves its effect by the  -aux-directory  op-
@@ -256,33 +246,33 @@
               When  the source file uses bbl file(s) for the bibliography, run
               bibtex or biber as needed to regenerate the bbl files, but  only
               if  the relevant bib file(s) exist.  Thus when the bib files are
+              not available, bibtex or biber  is  not  run,  thereby  avoiding
+              overwriting  of  the bbl file(s).  Also, always treat .bbl files
+              as precious, i.e., do not delete them in a cleanup operation.
 
+              This is the default setting.  It can also be configured by  set-
+              ting the $bibtex_use variable to 1 in a configuration file.
 
+              The  reason for using this setting is that sometimes a .bbl file
+              is available containing the bibliography for a document, but the
+              .bib  file  is  not  available.   An  example  would  be  for  a
 
-                               29 September 2020                             4
 
 
+                                 15 April 2021                               4
 
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              not available, bibtex or biber  is  not  run,  thereby  avoiding
-              overwriting  of  the bbl file(s).  Also, always treat .bbl files
-              as precious, i.e., do not delete them in a cleanup operation.
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-              This is the default setting.  It can also be configured by  set-
-              ting the $bibtex_use variable to 1 in a configuration file.
 
-              The  reason for using this setting is that sometimes a .bbl file
-              is available containing the bibliography for a document, but the
-              .bib  file  is  not available.  An example would be for a scien-
-              tific journal where authors submit .tex and .bbl files, but  not
-              the  original  .bib file.  In that case, running bibtex or biber
-              would not work, and the .bbl file should be treated  as  a  user
-              source  file,  and  not as a file that can be regenerated on de-
-              mand.
+              scientific journal where authors submit .tex and .bbl files, but
+              not  the  original  .bib  file.  In that case, running bibtex or
+              biber would not work, and the .bbl file should be treated  as  a
+              user  source  file, and not as a file that can be regenerated on
+              demand.
 
               (Note that it is possible for latexmk to  decide  that  the  bib
               file  does  not  exist,  even though the bib file does exist and
@@ -312,32 +302,36 @@
               variable to 1.5 in a configuration file.
 
 
-       -bibtexfudge, -bibtexfudge-
-              Turn  on/off  the change-directory fudge needed for old versions
-              (pre-2019) of bibtex.  See documentation  of  $bibtex_fudge  for
-              details.
+       -bibtexfudge or -bibfudge
+              Turn  on  the change-directory fudge for bibtex.  See documenta-
+              tion of $bibtex_fudge for details.
 
 
+       -bibtexfudge- or -bibfudge-
+              Turn off the change-directory fudge for bibtex.  See  documenta-
+              tion of $bibtex_fudge for details.
+
+
        -bm <message>
               A  banner message to print diagonally across each page when con-
               verting the dvi file to postscript.  The message must be a  sin-
-              gle  argument  on  the  command  line so be careful with quoting
+              gle argument on the command line so be careful with quoting spa-
+              ces and such.
 
+              Note that if the -bm option is specified, the -ps option is  as-
+              sumed.
 
 
-                               29 September 2020                             5
 
 
 
+                                 15 April 2021                               5
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              spaces and such.
 
-              Note that if the -bm option is specified, the -ps option is  as-
-              sumed.
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
        -bi <intensity>
@@ -369,7 +363,7 @@
               tion variables are removed.
 
               This  cleanup  is instead of a regular make.  See the -gg option
-              if you want to do a cleanup then a make.
+              if you want to do a cleanup followed by a make.
 
               Treatment of .bbl files:  If $bibtex_use is set to 0 or  1,  bbl
               files  are  always treated as non-regeneratable.  If $bibtex_use
@@ -389,24 +383,25 @@
               deleted.
 
 
+       -C     Clean up (remove) all regeneratable files generated by latex and
+              bibtex or biber.  This is the same as the -c option with the ad-
+              dition  of dvi, postscript and pdf files, and those specified in
+              the $clean_full_ext configuration variable.
 
 
-                               29 September 2020                             6
 
 
+                                 15 April 2021                               6
 
 
 
+
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       -C     Clean up (remove) all regeneratable files generated by latex and
-              bibtex or biber.  This is the same as the -c option with the ad-
-              dition  of dvi, postscript and pdf files, and those specified in
-              the $clean_full_ext configuration variable.
-
               This cleanup is instead of a regular make.  See the  -gg  option
-              if you want to do a cleanup than a make.
+              if you want to do a cleanup followed by a make.
 
               See  the  -c option for the specification of whether or not .bbl
               files are treated as non-regeneratable or regeneratable.
@@ -454,10 +449,15 @@
               tion, before doing the other actions requested.
 
 
+       -d     Set draft mode.  This prints the banner message  "DRAFT"  across
+              your  page when converting the dvi file to postscript.  Size and
+              intensity can be modified with the -bs and -bi options.  The -bm
+              option  will override this option as this is really just a short
+              way of specifying:
 
 
 
-                               29 September 2020                             7
+                                 15 April 2021                               7
 
 
 
@@ -466,12 +466,6 @@
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       -d     Set draft mode.  This prints the banner message  "DRAFT"  across
-              your  page when converting the dvi file to postscript.  Size and
-              intensity can be modified with the -bs and -bi options.  The -bm
-              option  will override this option as this is really just a short
-              way of specifying:
-
                    latexmk -bm DRAFT
 
               Note that if the -d option is specified, the -ps option  is  as-
@@ -519,26 +513,25 @@
               pendent files after processing.
 
 
-       -dF
+       -dF    Dvi file filtering.  The argument to this  option  is  a  filter
+              which  will  generate  a  filtered  dvi  file with the extension
+              ".dviF".  All extra processing (e.g. conversion  to  postscript,
+              preview,  printing)  will then be performed on this filtered dvi
+              file.
 
+              Example usage: To use dviselect to select only the even pages of
 
 
-                               29 September 2020                             8
 
+                                 15 April 2021                               8
 
 
 
 
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              Dvi file filtering.  The argument to this  option  is  a  filter
-              which  will  generate  a  filtered  dvi  file with the extension
-              ".dviF".  All extra processing (e.g. conversion  to  postscript,
-              preview,  printing)  will then be performed on this filtered dvi
-              file.
-
-              Example usage: To use dviselect to select only the even pages of
               the dvi file:
 
                    latexmk -dF "dviselect even" foo.tex
@@ -586,24 +579,24 @@
               cial.   (In  this  example, the q/.../ construct is a Perl idiom
               equivalent to using single quotes.  This  avoids  the  complica-
               tions  of  getting  a  quote  character inside an already quoted
+              string in a way that is independent of both the  shell  and  the
+              operating-system.)
 
+              The  above  command  line  will  NOT  work under MS-Windows with
+              cmd.exe or command.com or 4nt.exe.  For  MS-Windows  with  these
+              command shells you could use
 
 
-                               29 September 2020                             9
 
 
+                                 15 April 2021                               9
 
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              string in a way that is independent of both the  shell  and  the
-              operating-system.)
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-              The  above  command  line  will  NOT  work under MS-Windows with
-              cmd.exe or command.com or 4nt.exe.  For  MS-Windows  with  these
-              command shells you could use
 
                    latexmk -e "$latex=q/latex %O -shell-escape %S/" file.tex
 
@@ -630,18 +623,19 @@
               had occurred.  If instead, or additionally, you want  the  latex
               (etc)  program  not  to pause for user input after an error, you
               should arrange this by an option that is passed to the  program,
-              e.g., by latexmk's option -interaction=nonstopmode.
+              e.g.,  by  latexmk's  option -interaction=nonstopmode (which la-
+              texmk passes to *latex).
 
 
        -f-    Turn off the forced processing-past-errors such as is set by the
-              -f option.  This could be used to override a setting in  a  con-
+              -f  option.   This could be used to override a setting in a con-
               figuration file.
 
 
-       -g     Force  latexmk  to process document fully, even under situations
-              where latexmk would normally  decide  that  no  changes  in  the
-              source  files have occurred since the previous run.  This option
-              is useful, for example, if you change some options and  wish  to
+       -g     Force latexmk to process document fully, even  under  situations
+              where  latexmk  would  normally  decide  that  no changes in the
+              source files have occurred since the previous run.  This  option
+              is  useful,  for example, if you change some options and wish to
               reprocess the files.
 
 
@@ -652,36 +646,36 @@
               -C had been given, and then do a regular make.
 
 
+       -h or-non-help
+              Print help information.
 
 
+       -jobname=STRING
+              Set  the  basename  of output files(s) to STRING, instead of the
 
-                               29 September 2020                            10
 
 
+                                 15 April 2021                              10
 
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       -h, -help
-              Print help information.
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       -jobname=STRING
-              Set the basename of output files(s) to STRING,  instead  of  the
-              default,  which  is the basename of the specified TeX file.  (At
+              default, which is the basename of the specified TeX  file.   (At
               present, STRING should not contain spaces.)
 
-              This is like the same option for current implementations of  the
+              This  is like the same option for current implementations of the
               *latex, and the passing of this option to these programs is part
               of latexmk's implementation of -jobname.
 
               There is one enhancement, that the STRING may contain the place-
               holder '%A'. This will be substituted by the basename of the TeX
-              file.  The primary purpose is when multiple files are  specified
-              on  the  command  line to latexmk, and you wish to use a jobname
-              with a different file-dependent value for each file.  For  exam-
+              file.   The primary purpose is when multiple files are specified
+              on the command line to latexmk, and you wish to  use  a  jobname
+              with  a different file-dependent value for each file.  For exam-
               ple, suppose you had .tex files test1.tex and test2.tex, and you
               wished to compare the results of compilation by *latex and those
               with xelatex.  Then under a unix-type operating system you could
@@ -690,13 +684,13 @@
                   latexmk -pdf -jobname=%A-pdflatex *.tex
                   latexmk -pdfxe -jobname=%A-xelatex *.tex
 
-              Then the .aux, .log, and .pdf files from  the  use  of  pdflatex
-              would  have  basenames  test1-pdflatex and test2-pdflatex, while
+              Then  the  .aux,  .log,  and .pdf files from the use of pdflatex
+              would have basenames test1-pdflatex  and  test2-pdflatex,  while
               from xelatex, the basenames would be test1-xelatex and test2-xe-
               latex.
 
               Under MS-Windows with cmd.exe, you would need to double the per-
-              cent sign, so that the percent character is  passed  to  latexmk
+              cent  sign,  so  that the percent character is passed to latexmk
               rather than being used to substitute an environment variable:
 
                   latexmk -pdf -jobname=%%A-pdflatex *.tex
@@ -704,8 +698,8 @@
 
 
        -l     Run in landscape mode, using the landscape mode for the preview-
-              ers and the dvi to postscript converters.  This  option  is  not
-              normally  needed nowadays, since current previewers normally de-
+              ers  and  the  dvi to postscript converters.  This option is not
+              normally needed nowadays, since current previewers normally  de-
               termine this information automatically.
 
 
@@ -712,40 +706,41 @@
        -l-    Turn off -l.
 
 
-       -latex This sets the generation of dvi files by latex,  and  turns  off
+       -latex This  sets  the  generation of dvi files by latex, and turns off
               the generation of pdf and ps files.
 
-              Note:  to  set the command used when latex is specified, see the
+              Note: to set the command used when latex is specified,  see  the
               -latex="COMMAND" option.
 
 
+       -latex="COMMAND"
+              This sets the string specifying the command to run latex, and is
+              typically used to add desired options.  Since  the  string  nor-
+              mally contains spaces, it should be quoted, e.g.,
 
 
-                               29 September 2020                            11
 
 
+                                 15 April 2021                              11
 
 
 
+
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       -latex="COMMAND"
-              This sets the string specifying the command to run latex, and is
-              typically  used  to  add desired options.  Since the string nor-
-              mally contains spaces, it should be quoted, e.g.,
-
                    latexmk -latex="latex --shell-escape %O %S"  foo.tex
 
-              The specification of the contents of the string are the same  as
-              for  the $latex configuration variable.  Depending on your oper-
-              ating system and the command-line shell you are using,  you  may
-              need  to change the single quotes to double quotes (or something
+              The  specification of the contents of the string are the same as
+              for the $latex configuration variable.  Depending on your  oper-
+              ating  system  and the command-line shell you are using, you may
+              need to change the single quotes to double quotes (or  something
               else).
 
-              Note: This option when provided with the COMMAND  argument  only
+              Note:  This  option when provided with the COMMAND argument only
               sets the command for invoking latex; it does not turn on the use
-              of latex. That is done by other options or in an  initialization
+              of  latex. That is done by other options or in an initialization
               file.
 
               To set the command for running pdflatex (rather than the command
@@ -753,8 +748,8 @@
 
 
        -logfilewarninglist
-              -logfilewarnings After a run of *latex, give a list of  warnings
-              about  undefined citations and references (unless silent mode is
+              -logfilewarnings  After a run of *latex, give a list of warnings
+              about undefined citations and references (unless silent mode  is
               on).
 
               See also the $silence_logfile_warnings configuration variable.
@@ -761,7 +756,7 @@
 
 
        -logfilewarninglist-
-              -logfilewarnings- After a run of *latex, do not give a  list  of
+              -logfilewarnings-  After  a run of *latex, do not give a list of
               warnings about undefined citations and references.  (Default)
 
               See also the $silence_logfile_warnings configuration variable.
@@ -768,8 +763,8 @@
 
 
        -lualatex
-              Use  lualatex.   That  is,  use  lualatex  to process the source
-              file(s) to pdf.  The generation of dvi and postscript  files  is
+              Use lualatex.  That is,  use  lualatex  to  process  the  source
+              file(s)  to  pdf.  The generation of dvi and postscript files is
               turned off.
 
               This option is equivalent to using the following set of options
@@ -776,59 +771,69 @@
 
                    -pdflua -dvi- -ps-
 
-              (Note:  Note  that  the method of implementation of this option,
-              but not its intended effect, differ from some  earlier  versions
+              (Note: Note that the method of implementation  of  this  option,
+              but  not  its intended effect, differ from some earlier versions
               of latexmk.)
 
 
        -lualatex="COMMAND"
               This sets the string specifying the command to run lualatex.  It
-              behaves  like  the  -pdflatex  option,  but  sets  the  variable
+              behaves like the -pdflatex option, but sets the variable $luala-
+              tex.
 
+              Note: This option when provided with the COMMAND  argument  only
+              sets  the command for invoking lualatex; it does not turn on the
+              use of lualatex.  That  is  done  by  other  options  or  in  an
 
 
-                               29 September 2020                            12
 
+                                 15 April 2021                              12
 
 
 
 
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              $lualatex.
+              initialization file.
 
-              Note:  This  option when provided with the COMMAND argument only
-              sets the command for invoking lualatex; it does not turn on  the
-              use of lualatex. That is done by other options or in an initial-
-              ization file.
 
-
-       -M     Show list of dependent files after processing.  This is  equiva-
+       -M     Show  list of dependent files after processing.  This is equiva-
               lent to the -deps option.
 
 
        -MF file
-              If  a  list of dependents is made, the -MF specifies the file to
+              If a list of dependents is made, the -MF specifies the  file  to
               write it to.
 
 
        -MP    If a list of dependents is made, include a phony target for each
-              source  file.  If you use the dependents list in a Makefile, the
+              source file.  If you use the dependents list in a Makefile,  the
               dummy rules work around errors the program make gives if you re-
               move header files without updating the Makefile to match.
 
 
+       -makeindexfudge
+              Turn on the change-directory fudge for makeindex.  See  documen-
+              tation of $makeindex_fudge for details.
+
+
+       -makeindexfudge-
+              Turn off the change-directory fudge for makeindex.  See documen-
+              tation of $makeindex_fudge for details.
+
+
        -MSWinBackSlash
               This option only has an effect when latexmk is running under MS-
               Windows.  This is that when latexmk runs a command under MS-Win-
-              dows,  the  Windows  standard directory separator "\" is used to
-              separate directory components in a file name.   Internally,  la-
-              texmk  uses  "/" for the directory separator character, which is
+              dows, the Windows standard directory separator "\"  is  used  to
+              separate  directory  components in a file name.  Internally, la-
+              texmk uses "/" for the directory separator character,  which  is
               the character used by Unix-like systems.
 
               This is the default behavior.  However the default may have been
-              overridden  by  a configuration file (latexmkrc file) which sets
+              overridden by a configuration file (latexmkrc file)  which  sets
               $MSWin_back_slash=0.
 
 
@@ -835,8 +840,8 @@
        -MSWinBackSlash-
               This option only has an effect when latexmk is running under MS-
               Windows.  This is that when latexmk runs a command under MS-Win-
-              dows, the substitution of "\" for the  separator  character  be-
-              tween  directory  components of a file name is not done. Instead
+              dows,  the  substitution  of "\" for the separator character be-
+              tween directory components of a file name is not  done.  Instead
               the forward slash "/" is used, the same as on Unix-like systems.
               This is acceptable in most situations under MS-Windows, provided
               that filenames are properly quoted, as latexmk does by default.
@@ -845,15 +850,10 @@
               $MSWin_back_slash for more details.
 
 
-       -new-viewer
-              When  in  continuous-preview  mode, always start a new viewer to
-              view the generated file.  By default, latexmk will, in  continu-
-              ous-preview  mode,  test  for a previously running previewer for
-              the same file and not start a new one if a previous previewer is
 
 
 
-                               29 September 2020                            13
+                                 15 April 2021                              13
 
 
 
@@ -862,14 +862,19 @@
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
+       -new-viewer
+              When in continuous-preview mode, always start a  new  viewer  to
+              view  the generated file.  By default, latexmk will, in continu-
+              ous-preview mode, test for a previously  running  previewer  for
+              the same file and not start a new one if a previous previewer is
               running.  However, its test sometimes fails (notably if there is
-              an already-running previewer that is viewing a file of the  same
-              name  as  the current file, but in a different directory).  This
+              an  already-running previewer that is viewing a file of the same
+              name as the current file, but in a different  directory).   This
               option turns off the default behavior.
 
 
        -new-viewer-
-              The inverse of the -new-viewer option.  It puts latexmk  in  its
+              The  inverse  of the -new-viewer option.  It puts latexmk in its
               normal behavior that in preview-continuous mode it checks for an
               already-running previewer.
 
@@ -878,10 +883,9 @@
               Never run bibtex or biber.  Equivalent to the -bibtex- option.
 
 
-       -nobibtexfudge
-              Turn off the change-directory  fudge  needed  for  old  versions
-              (pre-2019)  of  bibtex.   See documentation of $bibtex_fudge for
-              details.
+       -nobibtexfudge or -nobibfudge
+              Turn  off the change-directory fudge for bibtex.  See documenta-
+              tion of $bibtex_fudge for details.
 
 
        -norc  Turn off the automatic reading of initialization (rc) files.
@@ -892,42 +896,64 @@
               on first, no matter where it occurs on the command line.
 
 
+       -nomakeindexfudge
+              Turn off the change-directory fudge for makeindex.  See documen-
+              tation of $makeindex_fudge for details.
+
+
        -outdir=FOO or -output-directory=FOO
 
-              Sets  the  directory  for  the  output  files  of  *latex.  This
-              achieves its effect by the -output-directory option  of  *latex,
+              Sets the  directory  for  the  output  files  of  *latex.   This
+              achieves  its  effect by the -output-directory option of *latex,
               which currently (Dec. 2011 and later) is implemented on the com-
               mon versions of *latex, i.e., MiKTeX and TeXLive.  It may not be
               present in other versions.
 
-              See  also  the -auxdir/-aux-directory options, and the $aux_dir,
-              $out_dir, and $search_path_separator configuration variables  of
-              latexmk.   In  particular, see the documentation of $out_dir for
+              See also the -auxdir/-aux-directory options, and  the  $aux_dir,
+              $out_dir,  and $search_path_separator configuration variables of
+              latexmk.  In particular, see the documentation of  $out_dir  for
               some complications on what directory names are suitable.
 
-              If you also use the -cd option, and the specified output  direc-
-              tory  is  a relative path, then the path is interpreted relative
-              to the document directory.
+              If  you also use the -cd option, and the specified output direc-
+              tory is a relative path, then the path is  interpreted  relative
 
 
-       -p     Print out the document.  By default the file to  be  printed  is
-              the  first  in the list postscript, pdf, dvi that is being made.
-              But you can use the -print=... option to change the type of file
-              to be printed, and you can configure this in a start up file (by
-              setting the $print_type variable).
 
+                                 15 April 2021                              14
 
 
 
-                               29 September 2020                            14
 
 
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
+              to the document directory.
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
+       -output-format=FORMAT
+              This  option  is  one  that  is allowed for latex, lualatex, and
+              pdflatex. But it is not passed to these programs.   Instead  la-
+              texmk  emulates  it in a way suitable for the context of latexmk
+              and its workflows.
 
+              If FORMAT is dvi, then dvi output is turned on,  and  postscript
+              and  pdf  output are turned off. This is equivalent to using the
+              options -dvi -ps- -pdf-.
+
+              If FORMAT is pdf, then pdf output is  turned  on,  and  dvi  and
+              postscript  output  are  turned off. This is equivalent to using
+              the options -pdf -ps- -dvi-.
+
+              If FORMAT is anything else, latexmk gives an error.
+
+
+       -p     Print out the document.  By default the file to  be  printed  is
+              the  first  in the list postscript, pdf, dvi that is being made.
+              But you can use the -print=... option to change the type of file
+              to be printed, and you can configure this in a start up file (by
+              setting the $print_type variable).
+
               However, printing is enabled by default  only  under  UNIX/Linux
               systems, where the default is to use the lpr command and only on
               postscript files.  In general, the correct behavior for printing
@@ -958,6 +984,16 @@
               Generate pdf version of document using lualatex.
 
 
+
+                                 15 April 2021                              15
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        -pdfps Generate pdf version of document from the .ps file,  by  default
               using ps2pdf.
 
@@ -983,17 +1019,6 @@
               overridden if some other option requires the generation of a pdf
               file.)
 
-
-
-                               29 September 2020                            15
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               If  after  all  options  have  been processed, pdf generation is
               still turned off, then generation of a dvi file will  be  turned
               on, and then the program used to compiled a document will be la-
@@ -1024,6 +1049,17 @@
               need to change the single quotes to double quotes (or  something
               else).
 
+
+
+                                 15 April 2021                              16
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               Note:  This  option when provided with the COMMAND argument only
               sets the command for invoking pdflatex; it does not turn on  the
               use of pdflatex. That is done by other options or in an initial-
@@ -1047,21 +1083,9 @@
               be executed before inputting source file.  This  only  works  if
               the command for invoking the relevant *latex is suitably config-
               ured.  See the documentation of the variable $pre_tex_code,  and
-              the  substitution  strings  %P  and  %U  for more details.  This
+              the  substitution  strings %P and %U for more details.  This op-
+              tion works by setting the variable $pre_tex_code.
 
-
-
-                               29 September 2020                            16
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
-              option works by setting the variable $pre_tex_code.
-
               See also the -usepretex option.
 
               An example:
@@ -1091,6 +1115,17 @@
        -ps    Generate postscript version of document.
 
 
+
+
+                                 15 April 2021                              17
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        -ps-   Turn off generation of postscript version of document.  This can
               be used to override a setting in a configuration file.  (It  may
               get  overridden  by some other option that requires a postscript
@@ -1115,17 +1150,6 @@
               version of perl and the operating system on your computer.
 
 
-
-
-                               29 September 2020                            17
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        -pv    Run  file previewer.  If the -view option is used, this will se-
               lect the kind of file to be previewed (.dvi, .ps or .pdf).  Oth-
               erwise  the viewer views the "highest" kind of file selected, by
@@ -1155,47 +1179,49 @@
               With a good previewer the display will be automatically updated.
               (Under some but not all versions of UNIX/Linux "gv -watch"  does
               this  for  postscript  files; this can be set by a configuration
-              variable.  This would also work for pdf files except for an  ap-
-              parent bug in gv that causes an error when the newly updated pdf
-              file is read.)  Many other previewers will need a manual update.
+              variable.  This would also work for  pdf  files  except  for  an
 
-              Important note: the acroread program on MS-Windows locks the pdf
-              file,  and  prevents  new versions being written, so it is a bad
-              idea to use acroread to view  pdf  files  in  preview-continuous
-              mode.   It  is  better to use a different viewer: SumatraPDF and
-              gsview are good possibilities.
 
-              There are some other methods for arranging  an  update,  notably
-              useful  for  many versions of xdvi and xpdf.  These are best set
-              in latexmk's configuration; see below.
 
-              Note that if latexmk  dies  or  is  stopped  by  the  user,  the
-              "forked" previewer will continue to run.  Successive invocations
-              with the -pvc option will not fork new previewers,  but  latexmk
-              will  normally  use the existing previewer.  (At least this will
-              happen when latexmk is running under an operating  system  where
-              it  knows how to determine whether an existing previewer is run-
-              ning.)
+                                 15 April 2021                              18
 
 
-       -pvc-  Turn off -pvc.
 
 
 
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-                               29 September 2020                            18
 
+              apparent  bug  in gv that causes an error when the newly updated
+              pdf file is read.)  Many other previewers will need a manual up-
+              date.
 
+              Important note: the acroread program on MS-Windows locks the pdf
+              file, and prevents new versions being written, so it  is  a  bad
+              idea  to  use  acroread  to view pdf files in preview-continuous
+              mode.  It is better to use a different  viewer:  SumatraPDF  and
+              gsview are good possibilities.
 
+              There  are  some  other methods for arranging an update, notably
+              useful for many versions of xdvi and xpdf.  These are  best  set
+              in latexmk's configuration; see below.
 
+              Note  that  if  latexmk  dies  or  is  stopped  by the user, the
+              "forked" previewer will continue to run.  Successive invocations
+              with  the  -pvc option will not fork new previewers, but latexmk
+              will normally use the existing previewer.  (At least  this  will
+              happen  when  latexmk is running under an operating system where
+              it knows how to determine whether an existing previewer is  run-
+              ning.)
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
+       -pvc-  Turn off -pvc.
 
+
        -pvctimeout
-              Do timeout in pvc mode after period of inactivity, which  is  30
+              Do  timeout  in pvc mode after period of inactivity, which is 30
               min. by default.  Inactivity means a period when latexmk has de-
-              tected no file changes and hence has not taken any actions  like
+              tected  no file changes and hence has not taken any actions like
               compiling the document.
 
 
@@ -1211,34 +1237,46 @@
 
 
        -r <rcfile>
-              Read  the  specified initialization file ("RC file") before pro-
+              Read the specified initialization file ("RC file")  before  pro-
               cessing.
 
               Be careful about the ordering: (1) Standard initialization files
-              --  see  the section below on "Configuration/initialization (RC)
-              files" -- are read first.  (2) Then the options on  the  command
-              line  are acted on in the order they are given.  Therefore if an
-              initialization file is specified by the -r option,  it  is  read
-              during  this second step.  Thus an initialization file specified
+              -- see the section below on  "Configuration/initialization  (RC)
+              files"  --  are read first.  (2) Then the options on the command
+              line are acted on in the order they are given.  Therefore if  an
+              initialization  file  is  specified by the -r option, it is read
+              during this second step.  Thus an initialization file  specified
+
+
+
+                                 15 April 2021                              19
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               with the -r option can override both the standard initialization
               files and previously specified options.  But all of these can be
               overridden by later options.
 
               The contents of the RC file just comprise a piece of code in the
-              Perl  programming  language  (typically a sequence of assignment
+              Perl programming language (typically a  sequence  of  assignment
               statements); they are executed when the -r option is encountered
               during latexmk's parsing of its command line.  See the -e option
-              for a way of giving initialization code  directly  on  latexmk's
-              command  line.   An error results in latexmk stopping.  Multiple
+              for  a  way  of giving initialization code directly on latexmk's
+              command line.  An error results in latexmk  stopping.   Multiple
               instances of the -r and -e options can be used, and they are ex-
               ecuted in the order they appear on the command line.
 
 
        -recorder
-              Give  the  -recorder  option with *latex.  In (most) modern ver-
-              sions of these programs, this results in  a  file  of  extension
-              .fls  containing  a  list  of the files that these programs have
-              read and written.  Latexmk will then use this  file  to  improve
+              Give the -recorder option with *latex.  In  (most)  modern  ver-
+              sions  of  these  programs,  this results in a file of extension
+              .fls containing a list of the files  that  these  programs  have
+              read  and  written.   Latexmk will then use this file to improve
               its detection of source files and generated files after a run of
               *latex.  This is the default setting of latexmk, unless overrid-
               den in an initialization file.
@@ -1247,17 +1285,6 @@
               configuration variable.
 
 
-
-
-                               29 September 2020                            19
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        -recorder-
               Do not supply the -recorder option with *latex.
 
@@ -1266,78 +1293,78 @@
 
 
        -rules-
-              Do not show a list of latexmk's  rules  and  dependencies  after
+              Do  not  show  a  list of latexmk's rules and dependencies after
               processing.  (This is the default.)
 
 
        -showextraoptions
-              Show  the  list of extra *latex options that latexmk recognizes,
-              but that it simply passes through to the programs  *latex   when
-              they  are  run.   These options are (currently) a combination of
-              those allowed by the TeXLive and MiKTeX implementations.  (If  a
-              particular  option is given to latexmk but is not handled by the
-              particular implementation of *latex that  is  being  used,  that
-              program will probably give an error message.)  These options are
-              very numerous, but are not listed in this documentation  because
-              they have no effect on latexmk's actions.
+              Show the list of extra *latex options that  latexmk  recognizes,
+              but  that  it simply passes through to the programs *latex  when
+              they are run.  These options are (currently)  a  combination  of
+              those  allowed by the TeXLive and MiKTeX implementations.  (If a
+              particular option is given to latexmk but is not handled by  the
+              particular  implementation  of  *latex  that is being used, that
+              program will probably give a warning or an  error.)   These  op-
+              tions  are  very numerous, but are not listed in this documenta-
+              tion because they have no effect on latexmk's actions.
 
-              There  are  a  few  options (-includedirectory=dir, -initialize,
-              -ini) that are not recognized, either  because  they  don't  fit
-              with latexmk's intended operations, or because they need special
-              processing by latexmk that  isn't  implemented  (at  least,  not
-              yet).
+              There are a few options (e.g., -includedirectory=dir,  -initial-
+              ize,  -ini)  that  are not recognized, either because they don't
+              fit with latexmk's intended operations,  or  because  they  need
+              special  processing by latexmk that isn't implemented (at least,
 
-              There  are  also options that are accepted by latex etc, but in-
-              stead trigger actions by latexmk: -help, -version.
 
-              Finally, there are certain options for *latex (e.g.,  -recorder)
-              that  trigger  special  actions or behavior by latexmk itself as
-              well as being passed in some form to the called *latex  program,
-              or  that  affect  other programs as well.  These options do have
-              entries  in  this  documentation.   These  options  are:   -job-
-              name=STRING,  -aux-directory=dir, -output-directory=DIR, -quiet,
-              and -recorder.
 
+                                 15 April 2021                              20
 
-       -silent
-              Run commands silently, i.e., with options that reduce the amount
-              of  diagnostics  generated.   For example, with the default set-
-              tings, the command "latex -interaction=batchmode"  is  used  for
-              latex, and similarly for its friends.
 
-              See  also  the  -logfilewarninglist and -logfilewarninglist- op-
-              tions.
 
-              Also reduce the number of informational  messages  that  latexmk
-              itself generates.
 
-              To  change  the  options used to make the commands run silently,
 
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-                               29 September 2020                            20
+              not yet).
 
+              There are certain options  for  *latex  (e.g.,  -recorder)  that
+              trigger special actions or behavior by latexmk itself. Depending
+              on the action, they may also be  passed  in  some  form  to  the
+              called *latex program, and/or may affect other programs as well.
+              These options do have  entries  in  this  documentation.   Among
+              these options are: -jobname=STRING, -aux-directory=dir, -output-
+              directory=DIR, -quiet, and -recorder.
 
+              There are also options that are accepted by *latex, but  instead
+              trigger actions purely by latexmk: -help, -version.
 
 
+       -silent
+              Run commands silently, i.e., with options that reduce the amount
+              of diagnostics generated.  For example, with  the  default  set-
+              tings,  the  command  "latex -interaction=batchmode" is used for
+              latex, and similarly for its friends.
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+              See also the -logfilewarninglist  and  -logfilewarninglist-  op-
+              tions.
 
+              Also  reduce  the  number of informational messages that latexmk
+              itself generates.
 
+              To change the options used to make the  commands  run  silently,
               you need to configure latexmk with changed values of its config-
-              uration    variables,    the    relevant    ones   being   $bib-
-              tex_silent_switch, $biber_silent_switch,  $dvipdf_silent_switch,
-              $dvips_silent_switch,        $latex_silent_switch,       $luala-
-              tex_silent_switch       $makeindex_silent_switch,        $pdfla-
+              uration   variables,   the    relevant    ones    being    $bib-
+              tex_silent_switch,  $biber_silent_switch, $dvipdf_silent_switch,
+              $dvips_silent_switch,       $latex_silent_switch,        $luala-
+              tex_silent_switch        $makeindex_silent_switch,       $pdfla-
               tex_silent_switch, and $xelatex_silent_switch
 
 
        -stdtexcmds
-              Sets  the commands for latex, etc, so that they are the standard
+              Sets the commands for latex, etc, so that they are the  standard
               ones. This is useful to override special configurations.
 
-              The result is that $latex = 'latex %O  %S',  and  similarly  for
-              $pdflatex,  $lualatex, and $xelatex.  (The option -no-pdf needed
+              The  result  is  that  $latex = 'latex %O %S', and similarly for
+              $pdflatex, $lualatex, and $xelatex.  (The option -no-pdf  needed
               for $xelatex is provided automatically, given that %O appears in
               the definition.)
 
@@ -1346,55 +1373,56 @@
               $show_time.
 
 
-       -time- Do not show CPU time used.  See also the configuration  variable
+       -time- Do  not show CPU time used.  See also the configuration variable
               $show_time.
 
 
+
+
+
+
+                                 15 April 2021                              21
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        -use-make
-              When  after  a  run  of *latex, there are warnings about missing
-              files (e.g., as requested by the  LaTeX  \input,  \include,  and
-              \includgraphics  commands), latexmk tries to make them by a cus-
-              tom dependency. If no relevant custom dependency with an  appro-
+              When after a run of *latex, there  are  warnings  about  missing
+              files  (e.g.,  as  requested  by the LaTeX \input, \include, and
+              \includgraphics commands), latexmk tries to make them by a  cus-
+              tom  dependency. If no relevant custom dependency with an appro-
               priate source file is found, and if the -use-make option is set,
-              then as a last resort latexmk will try to use the  make  program
+              then  as  a last resort latexmk will try to use the make program
               to try to make the missing files.
 
-              Note  that  the  filename may be specified without an extension,
-              e.g., by \includegraphics{drawing} in a  LaTeX  file.   In  that
-              case,  latexmk  will try making drawing.ext with ext set in turn
-              to the possible extensions that are relevant for  latex  (or  as
+              Note that the filename may be specified  without  an  extension,
+              e.g.,  by  \includegraphics{drawing}  in  a LaTeX file.  In that
+              case, latexmk will try making drawing.ext with ext set  in  turn
+              to  the  possible  extensions that are relevant for latex (or as
               appropriate pdflatex, lualatex, xelatex).
 
-              See  also  the documentation for the $use_make_for_missing_files
+              See also the documentation for  the  $use_make_for_missing_files
               configuration variable.
 
 
        -use-make-
-              Do not use the make program to try to make missing files.   (De-
+              Do  not use the make program to try to make missing files.  (De-
               fault.)
 
 
        -usepretex
               Sets the command lines for latex, etc, so that they use the code
-              that is defined by the variable $pre_tex_code or that is set  by
+              that  is defined by the variable $pre_tex_code or that is set by
               the option -pretex=CODE to execute the specified TeX code before
-
-
-
-                               29 September 2020                            21
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
-              the source file is read.  This  option  overrides  any  previous
+              the  source  file  is  read.  This option overrides any previous
               definition of the command lines.
 
-              The  result  is  that  $latex = 'latex %O %P', and similarly for
-              $pdflatex, $lualatex, and $xelatex.  (The option -no-pdf  needed
+              The result is that $latex = 'latex %O  %P',  and  similarly  for
+              $pdflatex,  $lualatex, and $xelatex.  (The option -no-pdf needed
               for $xelatex is provided automatically, given that %O appears in
               the definition.)
 
@@ -1405,7 +1433,7 @@
                 latexmk -usepretex='\AtBeginDocument{Message\par}' foo.tex
 
 
-       -v, -version
+       -v or -version
               Print version number of latexmk.
 
 
@@ -1416,75 +1444,88 @@
        -view=default, -view=dvi, -view=ps, -view=pdf, -view=none
               Set the kind of file used when previewing is requested (e.g., by
               the -pv or -pvc switches).  The default is to view the "highest"
-              kind of requested file (in  the  low-to-high  order  .dvi,  .ps,
+
+
+
+                                 15 April 2021                              22
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
+              kind  of  requested  file  (in  the low-to-high order .dvi, .ps,
               .pdf).
 
-              Note  the  possibility  -view=none  where no viewer is opened at
-              all.  One example of is use is in conjunction with the -pvc  op-
-              tion,  when  you  want latexmk to do a compilation automatically
-              whenever source file(s) change, but do not want a  previewer  to
+              Note the possibility -view=none where no  viewer  is  opened  at
+              all.   One example of is use is in conjunction with the -pvc op-
+              tion, when you want latexmk to do  a  compilation  automatically
+              whenever  source  file(s) change, but do not want a previewer to
               be opened.
 
 
        -Werror
-              This  causes  latexmk to return a non-zero status code if any of
-              the files processed gives a warning about  problems  with  cita-
-              tions  or references (i.e., undefined citations or references or
-              about multiply defined references).  This is after  latexmk  has
-              completed  all  the  runs it needs to try and resolve references
-              and citations.  Thus -Werror causes latexmk to treat such  warn-
+              This causes latexmk to return a non-zero status code if  any  of
+              the  files  processed  gives a warning about problems with cita-
+              tions or references (i.e., undefined citations or references  or
+              about  multiply  defined references).  This is after latexmk has
+              completed all the runs it needs to try  and  resolve  references
+              and  citations.  Thus -Werror causes latexmk to treat such warn-
               ings as errors, but only when they occur on the last run of *la-
-              tex and only after processing is complete.  Also can be  set  by
+              tex  and  only after processing is complete.  Also can be set by
               the configuration variable $warnings_as_errors.
 
 
        -xelatex
               Use xelatex.  That is, use xelatex to process the source file(s)
-              to pdf.  The generation of dvi and postscript  files  is  turned
+              to  pdf.   The  generation of dvi and postscript files is turned
               off.
 
               This option is equivalent to using the following set of options
 
+                   -pdfxe -dvi- -ps-
 
+              [Note: Note that the method of implementation  of  this  option,
+              but  not  its  intended primary effect, differ from some earlier
+              versions of latexmk. Latexmk first uses xelatex to make an  .xdv
+              file,  and  does  all  the extra runs needed (including those of
+              bibtex, etc).  Only after that does it make the  pdf  file  from
+              the  .xdv  file, using xdvipdfmx.  See the documentation for the
+              -pdfxe for why this is done.]
 
-                               29 September 2020                            22
 
+       -xelatex="COMMAND"
+              This sets the string specifying the command to run xelatex.   It
+              sets the variable $xelatex.
 
+              Warning: It is important to ensure that the -no-pdf is used when
+              xelatex is invoked, since latexmk expects xelatex to produce  an
+              .xdv  file,  not  a  .pdf file. If you provide %O in the command
+              specification, this will be done automatically.  See  the  docu-
+              mentation  for  the  -pdfxe  option for why latexmk makes a .xdv
+              file rather than a .pdf file when xelatex is used.
 
+              An example of the use of the -pdfxelatex option:
 
+                   latexmk -pdfxe -pdfxelatex="xelatex --shell-escape  %O  %S"
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-                   -pdfxe -dvi- -ps-
+                                 15 April 2021                              23
 
-              [Note:  Note  that  the method of implementation of this option,
-              but not its intended primary effect, differ  from  some  earlier
-              versions  of latexmk. Latexmk first uses xelatex to make an .xdv
-              file, and does all the extra runs  needed  (including  those  of
-              bibtex,  etc).   Only  after that does it make the pdf file from
-              the .xdv file, using xdvipdfmx.  See the documentation  for  the
-              -pdfxe for why this is done.]
 
 
-       -xelatex="COMMAND"
-              This  sets the string specifying the command to run xelatex.  It
-              sets the variable $xelatex.
 
-              Warning: It is important to ensure that the -no-pdf is used when
-              xelatex  is invoked, since latexmk expects xelatex to produce an
-              .xdv file, not a .pdf file. If you provide  %O  in  the  command
-              specification,  this  will be done automatically.  See the docu-
-              mentation for the -pdfxe option for why  latexmk  makes  a  .xdv
-              file rather than a .pdf file when xelatex is used.
 
-              An example of the use of the -pdfxelatex option:
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-                   latexmk  -pdfxe  -pdfxelatex="xelatex --shell-escape %O %S"
+
               foo.tex
 
-              Note: This option when provided with the COMMAND  argument  only
-              sets  the command for invoking lualatex; it does not turn on the
+              Note:  This  option when provided with the COMMAND argument only
+              sets the command for invoking lualatex; it does not turn on  the
               use of lualatex. That is done by other options or in an initial-
               ization file.
 
@@ -1491,11 +1532,11 @@
 
        Compatibility between options
 
-       The  preview-continuous option -pvc can only work with one file.  So in
-       this case you will normally only specify one filename  on  the  command
+       The preview-continuous option -pvc can only work with one file.  So  in
+       this  case  you  will normally only specify one filename on the command
        line.
 
-       Options  -p, -pv and -pvc are mutually exclusive.  So each of these op-
+       Options -p, -pv and -pvc are mutually exclusive.  So each of these  op-
        tions turns the others off.
 
 
@@ -1510,18 +1551,6 @@
                            file thesis.tex and any files it
                            uses.  After any changes rerun latex
                            the appropriate number of times and
-
-
-
-                               29 September 2020                            23
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
                            remake the postscript file.  If latex
                            encounters an error, latexmk will
                            keep running, watching for
@@ -1535,156 +1564,167 @@
 DEALING WITH ERRORS, PROBLEMS, ETC
        Some possibilities:
 
-       a. If you get a strange error, do look carefully at the output that  is
-       on  the  screen  and in log files.  While there is much that is notori-
+       a.  If you get a strange error, do look carefully at the output that is
+       on the screen and in log files.  While there is much  that  is  notori-
        ously verbose in the output of latex (and that is added to by latexmk),
-       the  verbosity  is  there  for a reason: to enable the user to diagnose
-       problems.  Latexmk does repeat some messages at the end of a  run  that
-       it  thinks  would otherwise be easy to miss in the middle of other out-
+       the verbosity is there for a reason: to enable  the  user  to  diagnose
+       problems.   Latexmk  does repeat some messages at the end of a run that
+       it thinks would otherwise be easy to miss in the middle of  other  out-
        put.
 
        b. Generally, remember that latexmk does its work by running other pro-
        grams.  Your first priority in dealing with errors should be to examine
        what went wrong with the individual programs.  Then you need to correct
-       the  causes of errors in the runs of these programs.  (Often these come
-       from errors in the source document, but they could also be about  miss-
+       the causes of errors in the runs of these programs.  (Often these  come
+
+
+
+                                 15 April 2021                              24
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
+       from  errors in the source document, but they could also be about miss-
        ing LaTeX packages, etc.)
 
        c. If latexmk doesn't run the programs the way you would like, then you
-       need to look in this documentation at the list of command line  options
-       and  then at the sections on configuration/initialization files.  A lot
-       of latexmk's behavior is configurable to deal  with  particular  situa-
+       need  to look in this documentation at the list of command line options
+       and then at the sections on configuration/initialization files.  A  lot
+       of  latexmk's  behavior  is configurable to deal with particular situa-
        tions.  (But there is a lot of reading!)
 
-       The  remainder  of  these notes consists of ideas for dealing with more
+       The remainder of these notes consists of ideas for  dealing  with  more
        difficult situations.
 
-       d. Further tricks can involve replacing the standard commands that  la-
+       d.  Further tricks can involve replacing the standard commands that la-
        texmk runs by other commands or scripts.
 
-       e.  For possible examples of code for use in an RC file, see the direc-
-       tory  example_rcfiles  in  the  distribution  of  latexmk   (e.g.,   at
+       e. For possible examples of code for use in an RC file, see the  direc-
+       tory   example_rcfiles   in  the  distribution  of  latexmk  (e.g.,  at
        http://mirror.ctan.org/support/latexmk/example_rcfiles).  Even if these
        examples don't do what you want, they may provide suitable inspiration.
 
-       f. There's a useful trick that can be used when you  use  lualatex  in-
-       stead  of  pdflatex  (and  in some related situations).  The problem is
-       that latexmk won't notice a dependency on a file, bar.baz say, that  is
-       input  by  the  lua code in your document instead of by the LaTeX part.
-       (Thus if you change bar.baz and rerun latexmk, then latexmk will  think
-       no  files have changed and not rerun lualatex, whereas if you had '\in-
-       put{bar.baz}' in the LaTeX part of the document, latexmk  would  notice
-       the  change.)   One  solution is just to put the following somewhere in
+       f.  There's  a  useful trick that can be used when you use lualatex in-
+       stead of pdflatex (and in some related  situations).   The  problem  is
+       that  latexmk won't notice a dependency on a file, bar.baz say, that is
+       input by the lua code in your document instead of by  the  LaTeX  part.
+       (Thus  if you change bar.baz and rerun latexmk, then latexmk will think
+       no files have changed and not rerun lualatex, whereas if you had  '\in-
+       put{bar.baz}'  in  the LaTeX part of the document, latexmk would notice
+       the change.)  One solution is just to put the  following  somewhere  in
        the LaTeX part of the document:
 
+                     \typeout{(bar.baz)}
 
+       This  puts  a  line in the log file that latexmk will treat as implying
+       that the file bar.baz was read.  (At present I don't know a way of  do-
+       ing  this automatically.)  Of course, if the file has a different name,
+       change bar.baz to the name of your file.
 
-                               29 September 2020                            24
+       g. See also the section "Advanced Configuration: Some extra resources".
 
+       h.   Look   on   tex.stackexchange,   i.e.,   at    http://tex.stackex-
+       change.com/questions/tagged/latexmk   Someone  may  have already solved
+       your problem.
 
+       i. Ask a question at tex.stackexchange.com.
 
+       j. Or ask me (the author of latexmk).  My e-mail is at the end of  this
+       documentation.
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
+ALLOWING FOR CHANGE OF OUTPUT FILE TYPE
+       When one of the latex engines is run, the usual situation is that latex
+       produces a .dvi file, while pdflatex and lualatex produce a .pdf  file.
+       For  xelatex  the  default  is  to produce a .pdf file, but to optimize
 
-                     \typeout{(bar.baz)}
 
-       This puts a line in the log file that latexmk will  treat  as  implying
-       that  the file bar.baz was read.  (At present I don't know a way of do-
-       ing this automatically.)  Of course, if the file has a different  name,
-       change bar.baz to the name of your file.
 
-       g. See also the section "Advanced Configuration: Some extra resources".
+                                 15 April 2021                              25
 
-       h.    Look   on   tex.stackexchange,   i.e.,   at   http://tex.stackex-
-       change.com/questions/tagged/latexmk  Someone may  have  already  solved
-       your problem.
 
-       i. Ask a question at tex.stackexchange.com.
 
-       j.  Or ask me (the author of latexmk).  My e-mail is at the end of this
-       documentation.
 
 
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-ALLOWING FOR CHANGE OF OUTPUT FILE TYPE
-       When one of the latex engines is run, the usual situation is that latex
-       produces  a .dvi file, while pdflatex and lualatex produce a .pdf file.
-       For xelatex the default is to produce a .pdf file, but to optimize pro-
-       cessing  time  latexmk  runs xelatex its -no-pdf option so that it pro-
-       duces an .xdv file.  Further processing by  latexmk  takes  this  as  a
+
+       processing time latexmk runs xelatex its -no-pdf option so that it pro-
+       duces  an  .xdv  file.   Further  processing by latexmk takes this as a
        starting point.
 
        However, the actual output file may differ from the normal expectation;
-       and then latexmk can adjust its processing to accommodate  this  situa-
-       tion.   The  difference in output file type can happen for two reasons:
-       One is that for latex, pdflatex and lualatex the  document  itself  can
-       override  the defaults. The other is that there may be a configuration,
+       and  then  latexmk can adjust its processing to accommodate this situa-
+       tion.  The difference in output file type can happen for  two  reasons:
+       One  is  that  for latex, pdflatex and lualatex the document itself can
+       override the defaults. The other is that there may be a  configuration,
        or misconfiguration, such that the program that latexmk invokes to com-
-       pile  the  document is not the expected one, or is given options incom-
-       patible with what latexmk initially expects.  (E.g.,  the  -output-for-
-       mat=...   option  could  be used with lualatex, or xelatex gets invoked
-       without the -no-pdf option.)
+       pile the document is not the expected one, or is given  options  incom-
+       patible with what latexmk initially expects.
 
-       Under latex and pdflatex, control of the output format by the  document
-       is  done by setting the \pdfoutput macro.  Under lualatex, the \output-
+       Under  latex and pdflatex, control of the output format by the document
+       is done by setting the \pdfoutput macro.  Under lualatex, the  \output-
        mode macro is used instead.
 
        One example of an important use-case for document control of the output
-       format  is  a document that uses the psfrag package to insert graphical
+       format is a document that uses the psfrag package to  insert  graphical
        elements in the output file. The psfrag package achieves its effects by
        inserting postscript code in the output of the compilation of the docu-
-       ment.  This entails the use of compilation to a .dvi file, followed  by
-       the  use  of  conversion  to  a postscript file (either directly, as by
-       dvips or implicitly, as an intermediate step by dvipdf).   Then  it  is
-       useful  to  force output to be of the .dvi format by inserting \pdfout-
+       ment.   This entails the use of compilation to a .dvi file, followed by
+       the use of conversion to a postscript  file  (either  directly,  as  by
+       dvips  or  implicitly,  as an intermediate step by dvipdf).  Then it is
+       useful to force output to be of the .dvi format by  inserting  \pdfout-
        put=0 in the preamble of the document.
 
-       Another example is where the document uses graphics file of  the  .pdf,
+       Another  example  is where the document uses graphics file of the .pdf,
+       .jpg, and png types.  With the default setting for the  graphicx  pack-
+       age,  these can be processed in compilation to .pdf but not with compi-
+       lation to .dvi.  In this case, it is useful to insert  \pdfoutput=1  in
+       the  preamble  of the document to force compilation to .pdf output for-
+       mat.
 
+       In all of these cases, it is needed that latexmk has to adjust its pro-
+       cessing  to  deal with a mismatch between the actual output format (out
+       of .pdf, .dvi, .xdv) and the initially expected  output,  if  possible.
+       Latexmk does this provided the following conditions are met.
 
+       The first is that latexmk's $allow_switch configuration variable is set
+       to a non-zero value as it is by default.  If this variable is  zero,  a
+       mismatch of filetypes in the compilation results in an erro.
 
-                               29 September 2020                            25
+       The  second condition for latexmk to be able to handle a change of out-
+       put type is that no explicit requests for .dvi or .ps output files  are
+       made.    Explicit  requests  are  by  the  -dvi  and  -ps,  -print=dvi,
+       -print=ps, -view=dvi, and -view=ps options, and by  corresponding  set-
+       tings  of  the $dvi_mode, $postscript_mode, $print_type, and $view con-
+       figuration variables.  The print-type and view-type  restrictions  only
+       apply when printing and viewing are explicitly requested, respectively.
+       For this purpose, the use of the -pdfdvi and -pdfps  options  (and  the
+       corresponding  setting  of the $pdf_mode variable) does not count as an
+       explicit request for the .dvi and .ps files; they are  merely  regarded
+       as  a  request for making a .pdf file together with an initial proposal
 
 
 
+                                 15 April 2021                              26
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       .jpg,  and  png types.  With the default setting for the graphicx pack-
-       age, these can be processed in compilation to .pdf but not with  compi-
-       lation  to  .dvi.  In this case, it is useful to insert \pdfoutput=1 in
-       the preamble of the document to force compilation to .pdf  output  for-
-       mat.
 
-       In all of these cases, it is needed that latexmk has to adjust its pro-
-       cessing to deal with a mismatch between the actual output  format  (out
-       of  .pdf,  .dvi,  .xdv) and the initially expected output, if possible.
-       Latexmk does this provided the following conditions are met.
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-       The first is that latexmk's $allow_switch configuration variable is set
-       to  a  non-zero value as it is by default.  If this variable is zero, a
-       mismatch of filetypes in the compilation results in an erro.
 
-       The second condition for latexmk to be able to handle a change of  out-
-       put  type is that no explicit requests for .dvi or .ps output files are
-       made.   Explicit  requests  are  by  the  -dvi  and  -ps,   -print=dvi,
-       -print=ps,  -view=dvi,  and -view=ps options, and by corresponding set-
-       tings of the $dvi_mode, $postscript_mode, $print_type, and  $view  con-
-       figuration  variables.   The print-type and view-type restrictions only
-       apply when printing and viewing are explicitly requested, respectively.
-       For  this  purpose,  the use of the -pdfdvi and -pdfps options (and the
-       corresponding setting of the $pdf_mode variable) does not count  as  an
-       explicit  request  for the .dvi and .ps files; they are merely regarded
-       as a request for making a .pdf file together with an  initial  proposal
        for the processing route to make it.
 
        Note that when accommodating a change in output file type, there is in-
-       volved a substantial change in the network of rules that  latexmk  uses
-       in  its  actions.  The second condition applied to accommodate a change
+       volved  a  substantial change in the network of rules that latexmk uses
+       in its actions.  The second condition applied to accommodate  a  change
        is to avoid situations where the change in the rule network is too rad-
        ical to be readily handled automatically.
 
@@ -1691,11 +1731,11 @@
 
 
 CONFIGURATION/INITIALIZATION (RC) FILES
-       In  this section is explained which configuration files are read by la-
-       texmk. Subsequent sections "How  to  Set  Variables  in  Initialization
-       Files",  "Format  of  Command  Specifications",  "List of Configuration
-       Variables Usable in Initialization Files", "Custom  Dependencies",  and
-       "Advanced  Configuration"  give  details  on what can be configured and
+       In this section is explained which configuration files are read by  la-
+       texmk.  Subsequent  sections  "How  to  Set Variables in Initialization
+       Files", "Format of  Command  Specifications",  "List  of  Configuration
+       Variables  Usable  in Initialization Files", "Custom Dependencies", and
+       "Advanced Configuration" give details on what  can  be  configured  and
        how.
 
        Latexmk can be customized using initialization files, which are read at
@@ -1708,19 +1748,7 @@
           "/usr/local/share/latexmk/LatexMk",
           "/usr/local/lib/latexmk/LatexMk".
           On a MS-Windows system it looks for "C:\latexmk\LatexMk".
-
-
-
-                               29 September 2020                            26
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
-          On a cygwin system (i.e., a MS-Windows system in which Perl is  that
+          On  a cygwin system (i.e., a MS-Windows system in which Perl is that
        of cygwin), latexmk reads the first it finds of
           "/cygdrive/c/latexmk/LatexMk",
           "/opt/local/share/latexmk/LatexMk",
@@ -1730,72 +1758,73 @@
        In addition, it then tries the same set of locations, but with the file
        name replaced "LatexMk" replaced by "latexmkrc".
 
-       If the environment variable LATEXMKRCSYS is set, its value is  used  as
+       If  the  environment variable LATEXMKRCSYS is set, its value is used as
        the name of the system RC file, instead of any of the above.
 
        2) The user's RC file, if it exists.  This can be in one of two places.
-       The traditional one is ".latexmkrc" in the user's home directory.   The
-       other  possibility  is "latexmk/latexmkrc" in the user's XDG configura-
-       tion home directory.  The actual file read is the first  of  "$XDG_CON-
-       FIG_HOME/latexmk/latexmkrc"  or  "$HOME/.latexmkrc" which exists.  (See
+       The  traditional one is ".latexmkrc" in the user's home directory.  The
+       other possibility is "latexmk/latexmkrc" in the user's  XDG  configura-
+       tion  home  directory.  The actual file read is the first of "$XDG_CON-
+       FIG_HOME/latexmk/latexmkrc" or "$HOME/.latexmkrc" which  exists.   (See
        https://specifications.freedesktop.org/basedir-spec/basedir-spec-lat-
        est.html for details on the XDG Base Directory Specification.)
 
-       Here  $HOME  is  the  user's  home  directory.  [Latexmk determines the
-       user's home directory as follows:  It is the value of  the  environment
-       variable  HOME,  if this variable exists, which normally is the case on
-       UNIX-like systems (including Linux and OS-X).  Otherwise  the  environ-
-       ment  variable USERPROFILE is used, if it exists, which normally is the
+       Here $HOME is the  user's  home  directory.   [Latexmk  determines  the
+       user's  home  directory as follows:  It is the value of the environment
+       variable HOME, if this variable exists, which normally is the  case  on
+       UNIX-like  systems  (including Linux and OS-X).  Otherwise the environ-
+       ment variable USERPROFILE is used, if it exists, which normally is  the
+
+
+
+                                 15 April 2021                              27
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        case on MS-Windows systems. Otherwise a blank string is used instead of
        $HOME, in which case latexmk does not look for an RC file in it.]
 
-       $XDG_CONFIG_HOME  is  the  value  of  the environment variable XDG_CON-
-       FIG_HOME if it exists.  If this environment variable  does  not  exist,
-       but  $HOME  is  non-blank,  then $XDG_CONFIG_HOME is set to the default
-       value of $HOME/.config.  Otherwise $XDG_CONFIG_HOME is blank,  and  la-
+       $XDG_CONFIG_HOME is the value  of  the  environment  variable  XDG_CON-
+       FIG_HOME  if  it  exists.  If this environment variable does not exist,
+       but $HOME is non-blank, then $XDG_CONFIG_HOME is  set  to  the  default
+       value  of  $HOME/.config.  Otherwise $XDG_CONFIG_HOME is blank, and la-
        texmk does not look for an RC file under it.
 
 
-       3)  The  RC  file  in  the current working directory.  This file can be
-       named either "latexmkrc" or ".latexmkrc", and the first of these to  be
+       3) The RC file in the current working  directory.   This  file  can  be
+       named  either "latexmkrc" or ".latexmkrc", and the first of these to be
        found is used, if any.
 
        4) Any RC file(s) specified on the command line with the -r option.
 
        Each RC file is a sequence of Perl commands.  Naturally, a user can use
-       this in creative ways.  But for most purposes, one simply  uses  a  se-
+       this  in  creative  ways.  But for most purposes, one simply uses a se-
        quence of assignment statements that override some of the built-in set-
-       tings of Latexmk.  Straightforward cases can be handled without  knowl-
-       edge  of  the  Perl  language by using the examples in this document as
+       tings  of Latexmk.  Straightforward cases can be handled without knowl-
+       edge of the Perl language by using the examples  in  this  document  as
        templates.  Comment lines are introduced by the "#" character.
 
-       Note that command line options are obeyed in the order  in  which  they
+       Note  that  command  line options are obeyed in the order in which they
        are written; thus any RC file specified on the command line with the -r
-       option can override previous options but can be  itself  overridden  by
-       later  options on the command line.  There is also the -e option, which
+       option  can  override  previous options but can be itself overridden by
+       later options on the command line.  There is also the -e option,  which
        allows initialization code to be specified in latexmk's command line.
 
-
-
-                               29 September 2020                            27
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
         For possible examples of code for in an RC file, see the directory ex-
-       ample_rcfiles  in  the  distribution  of  latexmk (e.g., at http://mir-
+       ample_rcfiles in the distribution  of  latexmk  (e.g.,  at  http://mir-
        ror.ctan.org/support/latexmk/example_rcfiles).
 
 
 HOW TO SET VARIABLES IN INITIALIZATION FILES
-       The important variables that can be configured  are  described  in  the
-       section  "List  of  configuration  variables  usable  in initialization
-       files".  (See the earlier  section  "Configuration/Initialization  (rc)
-       Files"  for  the  files where the configurations are done.)  Syntax for
+       The  important  variables  that  can be configured are described in the
+       section "List  of  configuration  variables  usable  in  initialization
+       files".   (See  the  earlier section "Configuration/Initialization (rc)
+       Files" for the files where the configurations are  done.)   Syntax  for
        setting these variables is of the following forms:
 
                            $bibtex = 'bibtex %O %S';
@@ -1808,60 +1837,60 @@
 
                            @default_files = ('paper', 'paper1');
 
-       for the setting of an array of strings.  It is possible  to  append  an
+       for  the  setting  of an array of strings.  It is possible to append an
        item to an array variable as follows:
 
-                           push @default_files, 'paper2';
 
-       Note  that  simple  "scalar"  variables  have names that begin with a $
-       character and array variables have names that begin with a @ character.
-       Each statement ends with a semicolon.
 
-       Strings  should  be  enclosed  in single quotes.  (You could use double
-       quotes, as in many programming languages.  But then the  Perl  program-
-       ming  language  brings  into  play some special rules for interpolating
-       variables into strings.  People not fluent in Perl will want  to  avoid
-       these complications.)
 
-       You  can do much more complicated things, but for this you will need to
-       consult a manual for the Perl programming language.
+                                 15 April 2021                              28
 
 
 
 
-FORMAT OF COMMAND SPECIFICATIONS
-       Some of the variables set the commands that latexmk uses  for  carrying
-       out  its  work, for example to generate a .dvi file from a .tex file or
-       to view a postscript file.  This section describes some important  fea-
-       tures of how the commands are specified.  (Note that some of the possi-
-       bilities listed here do not apply to the $kpsewhich variable;  see  its
-       documentation.)
 
-       Placeholders:  Supposed you wanted latexmk to use the command elatex in
-       place of the regular latex  command,  and  suppose  moreover  that  you
-       wanted  to  give  it the option "--shell-escape".  You could do this by
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
+                           push @default_files, 'paper2';
 
-                               29 September 2020                            28
+       Note that simple "scalar" variables have names  that  begin  with  a  $
+       character and array variables have names that begin with a @ character.
+       Each statement ends with a semicolon.
 
+       Strings should be enclosed in single quotes.   (You  could  use  double
+       quotes,  as  in many programming languages.  But then the Perl program-
+       ming language brings into play some  special  rules  for  interpolating
+       variables  into  strings.  People not fluent in Perl will want to avoid
+       these complications.)
 
+       You can do much more complicated things, but for this you will need  to
+       consult a manual for the Perl programming language.
 
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
+FORMAT OF COMMAND SPECIFICATIONS
+       Some  of  the variables set the commands that latexmk uses for carrying
+       out its work, for example to generate a .dvi file from a .tex  file  or
+       to  view a postscript file.  This section describes some important fea-
+       tures of how the commands are specified.  (Note that some of the possi-
+       bilities  listed  here do not apply to the $kpsewhich variable; see its
+       documentation.)
 
+       Placeholders:  Supposed you wanted latexmk to use the command elatex in
+       place  of  the  regular  latex  command,  and suppose moreover that you
+       wanted to give it the option "--shell-escape".  You could  do  this  by
        the following setting:
 
             $latex = 'elatex --shell-escape %O %S';
 
-       The two items starting with the % character  are  placeholders.   These
-       are  substituted by appropriate values before the command is run.  Thus
-       %S will be replaced by the source file that elatex will be applied  to,
-       and  %O will be replaced by any options that latexmk has decided to use
+       The  two  items  starting with the % character are placeholders.  These
+       are substituted by appropriate values before the command is run.   Thus
+       %S  will be replaced by the source file that elatex will be applied to,
+       and %O will be replaced by any options that latexmk has decided to  use
        for this command.  (E.g., if you used the -silent option in the invoca-
-       tion  of  latexmk,   it  results in the replacement of %O by "-interac-
+       tion of latexmk,  it results in the replacement  of  %O  by  "-interac-
        tion=batchmode".)
 
        The available placeholders are:
@@ -1870,120 +1899,120 @@
               the setting of a jobname by  the -jobname option or the $jobname
               configuration value.
 
-       %B     base of filename for current command.   E.g.,  if  a  postscript
-              file  document.ps  is being made from the dvi file document.dvi,
+       %B     base  of  filename  for  current command.  E.g., if a postscript
+              file document.ps is being made from the dvi  file  document.dvi,
               then the basename is document.
 
-       %D     destination file (e.g., the name of  the  postscript  file  when
+       %D     destination  file  (e.g.,  the  name of the postscript file when
               converting a dvi file to postscript).
 
+
+
+
+                                 15 April 2021                              29
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        %O     options
 
-       %P     If  the  variable $pre_tex_code is non-empty, then %P is substi-
-              tuted  by  the  contents  of  $pre_tex_code  followed  by   \in-
-              put{SOURCE},  where  SOURCE  stands  for  the name of the source
+       %P     If the variable $pre_tex_code is non-empty, then %P  is  substi-
+              tuted   by  the  contents  of  $pre_tex_code  followed  by  \in-
+              put{SOURCE}, where SOURCE stands for  the  name  of  the  source
               file.  Appropriate quoting is done.  This enables TeX code to be
-              passed  to  one  of the *latex engines to be executed before the
+              passed to one of the *latex engines to be  executed  before  the
               source file is read.
 
-              If the variable $pre_tex_code is the empty string,  then  %P  is
+              If  the  variable  $pre_tex_code is the empty string, then %P is
               equivalent to %S.
 
        %R     root filename.  This is the base name for the main tex file.
 
-              By  default  this is the basename of the main tex file.  However
-              the value can be changed by the use of the  -jobname  option  or
+              By default this is the basename of the main tex  file.   However
+              the  value  can  be changed by the use of the -jobname option or
               the $jobname configuration variable.
 
-       %S     source  file  (e.g.,  the name of the dvi file when converting a
+       %S     source file (e.g., the name of the dvi file  when  converting  a
               .dvi file to ps).
 
        %T     The name of the primary tex file.
 
-       %U     If the variable $pre_tex_code is non-empty, then  its  value  is
-              substituted  for %U (appropriately quoted).  Otherwise it is re-
+       %U     If  the  variable  $pre_tex_code is non-empty, then its value is
+              substituted for %U (appropriately quoted).  Otherwise it is  re-
               placed by a null string.
 
        %Y     Name of directory for auxiliary output files (see the configura-
               tion variable $aux_dir).  A directory separation character ('/')
+              is appended if $aux_dir is non-empty and does not end in a suit-
+              able character, with suitable characters being those appropriate
+              to  UNIX  and MS-Windows, i.e., ':', '/' and '\'.   Note that if
+              after initialization,  $out_dir is set, but $aux_dir is not  set
+              (i.e.,  it  is  blank),  then  latexmk sets $aux_dir to the same
+              value $out_dir.
 
+       %Z     Name of directory for output files (see the configuration  vari-
+              able  $out_dir).   A directory separation character ('/') is ap-
+              pended if $out_dir is non-empty and does not end in  a  suitable
+              character,  with  suitable characters being those appropriate to
+              UNIX and MS-Windows, i.e., ':', '/' and '\'.
 
+       If for some reason you need a literal % character in  your  string  not
+       subject to the above rules, use "%%".
 
-                               29 September 2020                            29
+       Appropriate  quoting  will be applied to the filename substitutions, so
+       you mustn't supply them yourself even if the names of your  files  have
+       spaces in them.  (But if your TeX filenames have spaces in them, beware
+       that some older versions of the TeX  program  cannot  correctly  handle
+       filenames  containing spaces.)  In case latexmk's quoting does not work
+       correctly on your system, you can turn it off -- see the  documentation
+       for the variable $quote_filenames.
 
+       See  the default values in the section "List of configuration variables
 
 
 
+                                 15 April 2021                              30
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              is appended if $aux_dir is non-empty and does not end in a suit-
-              able character, with suitable characters being those appropriate
-              to UNIX and MS-Windows, i.e., ':', '/' and '\'.   Note  that  if
-              after  initialization,  $out_dir is set, but $aux_dir is not set
-              (i.e., it is blank), then latexmk  sets  $aux_dir  to  the  same
-              value $out_dir.
 
-       %Z     Name  of directory for output files (see the configuration vari-
-              able $out_dir).  A directory separation character ('/')  is  ap-
-              pended  if  $out_dir is non-empty and does not end in a suitable
-              character, with suitable characters being those  appropriate  to
-              UNIX and MS-Windows, i.e., ':', '/' and '\'.
 
-       If  for  some  reason you need a literal % character in your string not
-       subject to the above rules, use "%%".
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-       Appropriate quoting will be applied to the filename  substitutions,  so
-       you  mustn't  supply them yourself even if the names of your files have
-       spaces in them.  (But if your TeX filenames have spaces in them, beware
-       that  some  older  versions  of the TeX program cannot correctly handle
-       filenames containing spaces.)  In case latexmk's quoting does not  work
-       correctly  on your system, you can turn it off -- see the documentation
-       for the variable $quote_filenames.
 
-       See the default values in the section "List of configuration  variables
        usable in initialization files" for what is normally the most appropri-
        ate usage.
 
        If you omit to supply any placeholders whatever in the specification of
-       a  command,  latexmk will supply what its author thinks are appropriate
+       a command, latexmk will supply what its author thinks  are  appropriate
        defaults.  This gives compatibility with configuration files for previ-
        ous versions of latexmk, which didn't use placeholders.
 
-       "Detaching"  a  command: Normally when latexmk runs a command, it waits
+       "Detaching" a command: Normally when latexmk runs a command,  it  waits
        for the command to run to completion.  This is appropriate for commands
        like latex, of course.  But for previewers, the command should normally
-       run detached, so that latexmk gets the previewer running and  then  re-
-       turns  to  its next task (or exits if there is nothing else to do).  To
-       achieve this effect of detaching a command, you  need  to  precede  the
+       run  detached,  so that latexmk gets the previewer running and then re-
+       turns to its next task (or exits if there is nothing else to  do).   To
+       achieve  this  effect  of  detaching a command, you need to precede the
        command name with "start ", as in
 
             $dvi_previewer = 'start xdvi %O %S';
 
-       This  will  be translated to whatever is appropriate for your operating
+       This will be translated to whatever is appropriate for  your  operating
        system.
 
        Notes: (1) In some circumstances, latexmk will always run a command de-
-       tached.   This  is the case for a previewer in preview continuous mode,
-       since otherwise previewing continuously makes no sense.  (2) This  pre-
-       cludes  the  possibility  of running a command named start.  (3) If the
-       word start occurs more than  once  at  the  beginning  of  the  command
-       string,  that is equivalent to having just one.  (4) Under cygwin, some
-       complications happen, since cygwin amounts to a complicated merging  of
-       UNIX  and  MS-Windows.   See  the  source code for how I've handled the
-
-
-
-                               29 September 2020                            30
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
+       tached.  This is the case for a previewer in preview  continuous  mode,
+       since  otherwise previewing continuously makes no sense.  (2) This pre-
+       cludes the possibility of running a command named start.   (3)  If  the
+       word  start  occurs  more  than  once  at  the beginning of the command
+       string, that is equivalent to having just one.  (4) Under cygwin,  some
+       complications  happen, since cygwin amounts to a complicated merging of
+       UNIX and MS-Windows.  See the source code  for  how  I've  handled  the
        problem.
 
        Command names containing spaces: Under MS-Windows it is common that the
@@ -1995,26 +2024,38 @@
        %S';
             $pdf_previewer   =   'start   "c:/Program   Files/SumatraPDF/Suma-
        traPDF.exe" %O %S';
-            $pdf_previewer  =  'start "c:/Program Files/SumatraPDF (x86)/Suma-
+            $pdf_previewer = 'start "c:/Program  Files/SumatraPDF  (x86)/Suma-
        traPDF.exe" %O %S';
 
 
-       (Note about the above example: Under  MS-Windows  forward  slashes  are
+       (Note  about  the  above  example: Under MS-Windows forward slashes are
        equivalent to backslashes in a filename under almost all circumstances,
-       provided that the filename is inside double quotes.  It  is  easier  to
+       provided  that  the  filename is inside double quotes.  It is easier to
        use forward slashes in examples like the one above, since then one does
-       not have to worry about the rules for dealing with forward  slashes  in
+       not  have  to worry about the rules for dealing with forward slashes in
        strings in the Perl language.)
 
-       Command  names  under  Cygwin: If latexmk is executed by Cygwin's Perl,
+       Command names under Cygwin: If latexmk is executed  by  Cygwin's  Perl,
        be particularly certain that pathnames in commands have forward slashes
-       not  the  usual  backslashes  for the separator of pathname components.
-       See the above examples.  Backslashes often get  misinterpreted  by  the
+       not the usual backslashes for the  separator  of  pathname  components.
+
+
+
+                                 15 April 2021                              31
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
+       See  the  above  examples.  Backslashes often get misinterpreted by the
        Unix shell used by Cygwin's Perl to execute external commands.  Forward
        slashes don't suffer from this problem, and (when quoted, as above) are
        equally acceptable to MS-Windows.
 
-       Using  MS-Windows  file  associations: A useful trick under modern ver-
+       Using MS-Windows file associations: A useful trick  under  modern  ver-
        sions of MS-Windows (e.g., WinXP) is to use just the command 'start' by
        itself:
 
@@ -2021,9 +2062,9 @@
             $dvi_previewer = 'start %S';
 
        Under MS-Windows, this will cause to be run whatever program the system
-       has associated with dvi files.  (The  same  applies  for  a  postscript
+       has  associated  with  dvi  files.   (The same applies for a postscript
        viewer and a pdf viewer.)  But note that this trick is not always suit-
-       able for the pdf previwer, if your system has acroread for the  default
+       able  for the pdf previwer, if your system has acroread for the default
        pdf viewer.  As explained elsewhere, acroread under MS-Windows does not
        work well with latex and latexmk, because acroread locks the pdf file.
 
@@ -2032,30 +2073,18 @@
 
             $lpr  = 'NONE lpr';
 
-       This  typically  is  used when an appropriate command does not exist on
+       This typically is used when an appropriate command does  not  exist  on
        your system.  The string after the "NONE" is effectively a comment.
 
        Options to commands: Setting the name of a command can be used not only
        for changing the name of the command called, but also to add options to
-       command.  Suppose you want latexmk to use latex  with  source  specials
-
-
-
-                               29 September 2020                            31
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
-       enabled.   Then  you  might use the following line in an initialization
+       command.   Suppose  you  want latexmk to use latex with source specials
+       enabled.  Then you might use the following line  in  an  initialization
        file:
 
             $latex = 'latex --src-specials %O %S';
 
-       Running a subroutine instead of an external command: Use  a  specifica-
+       Running  a  subroutine instead of an external command: Use a specifica-
        tion starting with "internal", as in
 
             $latex = 'internal mylatex %O %S';
@@ -2065,30 +2094,41 @@
                 return system 'latex', @args;
             }
 
-       For  some  of the more exotic possibilities that then become available,
-       see the section "ADVANCED CONFIGURATION: Some extra resources  and  ad-
-       vanced  tricks".  Also  see some of the examples in the directory exam-
+       For some of the more exotic possibilities that then  become  available,
+       see  the  section "ADVANCED CONFIGURATION: Some extra resources and ad-
+       vanced tricks". Also see some of the examples in  the  directory  exam-
        ple_rcfiles in the latexmk distribution.
 
-       Advanced tricks: Normally one specifies a single command for  the  com-
-       mands  invoked by latexmk.  Naturally, if there is some complicated ad-
-       ditional processing you need to do in your special situation,  you  can
+       Advanced  tricks:  Normally one specifies a single command for the com-
+       mands invoked by latexmk.  Naturally, if there is some complicated  ad-
+       ditional  processing  you need to do in your special situation, you can
        write a script (or batch file) to do the processing, and then configure
        latexmk to use your script in place of the standard program.
 
-       You can also use a Perl subroutine instead of a script  --  see  above.
+
+
+                                 15 April 2021                              32
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
+       You  can  also  use a Perl subroutine instead of a script -- see above.
        This is generally the most flexible and portable solution.
 
        It is also possible to configure latexmk to run multiple commands.  For
-       example, if when running pdflatex to generate a pdf  file  from  a  tex
+       example,  if  when  running  pdflatex to generate a pdf file from a tex
        file you need to run another program after pdflatex to perform some ex-
        tra processing, you could do something like:
 
-            $pdflatex = 'pdflatex --shell-escape  %O  %S;  pst2pdf_for_latexmk
+            $pdflatex  =  'pdflatex  --shell-escape %O %S; pst2pdf_for_latexmk
        %B';
 
-       This  definition  assumes  you  are using a UNIX-like system (which in-
-       cludes Linux and OS-X), so that the two commands to be  run  are  sepa-
+       This definition assumes you are using a  UNIX-like  system  (which  in-
+       cludes  Linux  and  OS-X), so that the two commands to be run are sepa-
        rated by the semicolon in the middle of the string.
 
        If you are using MS-Windows, you would replace the above line by
@@ -2096,48 +2136,36 @@
           $pdflatex = 'cmd /c pdflatex --shell-escape %O %S'
                       . '&& pst2pdf_for_latexmk %B';
 
-       Here,  the  UNIX  command  separator ; is replaced by &&.  In addition,
+       Here, the UNIX command separator ; is replaced  by  &&.   In  addition,
        there is a problem that some versions of Perl on MS-Windows do not obey
-       the  command separator; this problem is overcome by explicitly invoking
+       the command separator; this problem is overcome by explicitly  invoking
        the MS-Windows command-line processor cmd.exe.
 
 
 LIST OF CONFIGURATION VARIABLES USABLE IN INITIALIZATION FILES
-       In this section  are  specified  the  variables  whose  values  can  be
-
-
-
-                               29 September 2020                            32
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
-       adjusted  to  configure  latexmk.  (See the earlier section "Configura-
-       tion/Initialization (rc) Files" for the files where the  configurations
+       In  this  section  are  specified the variables whose values can be ad-
+       justed to configure latexmk.   (See  the  earlier  section  "Configura-
+       tion/Initialization  (rc) Files" for the files where the configurations
        are done.)
 
        Default values are indicated in brackets.  Note that for variables that
-       are boolean in character, concerning whether latexmk does or  does  not
-       behave  in a certain way, a non-zero value, normally 1, indicates true,
-       i.e., the behavior occurs, while a zero value indicates a false  value,
+       are  boolean  in character, concerning whether latexmk does or does not
+       behave in a certain way, a non-zero value, normally 1, indicates  true,
+       i.e.,  the behavior occurs, while a zero value indicates a false value,
        i.e., the behavior does not occur.
 
 
        $allow_switch [1]
 
-              This  controls  what happens when the output extension of latex,
-              pdflatex, lualatex or xelatex differs  from  what  is  expected.
+              This controls what happens when the output extension  of  latex,
+              pdflatex,  lualatex  or  xelatex  differs from what is expected.
               (The possible extensions are .dvi, .pdf, .xdv.)  This can happen
-              with the use of the \pdfoutput macro in a document compiled  un-
-              der  latex or pdflatex, or with the use of the \outputmode macro
+              with  the use of the \pdfoutput macro in a document compiled un-
+              der latex or pdflatex, or with the use of the \outputmode  macro
               under lualatex.  It can also happen with certain kinds of incor-
               rect configuration.
 
-              In  such a case, latexmk can appropriately adjust its network of
+              In such a case, latexmk can appropriately adjust its network  of
               rules.  The adjustment is made if $allow_switch is on, and if no
               request for a dvi or ps file has been made.
 
@@ -2144,12 +2172,22 @@
               See the section ALLOWING FOR CHANGE OF OUTPUT EXTENSION.
 
 
+
+                                 15 April 2021                              33
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        $always_view_file_via_temporary [0]
-              Whether  .ps and .pdf files are initially to be made in a tempo-
-              rary directory and then moved to the final location.  (This  ap-
+              Whether .ps and .pdf files are initially to be made in a  tempo-
+              rary  directory and then moved to the final location.  (This ap-
               plies to dvips, dvipdf, and ps2pdf operations, and the filtering
               operators on .dvi and .ps files.  It does not apply to pdflatex,
-              unfortunately,  since  pdflatex  provides no way of specifying a
+              unfortunately, since pdflatex provides no way  of  specifying  a
               chosen name for the output file.)
 
               This use of a temporary file solves a problem that the making of
@@ -2159,7 +2197,7 @@
               which  can cause havoc.
 
               See the $pvc_view_file_via_temporary variable for a setting that
-              applies  only  if preview-continuous mode (-pvc option) is used.
+              applies only if preview-continuous mode (-pvc option)  is  used.
               See $tmpdir for the setting of the directory where the temporary
               file is created.
 
@@ -2166,93 +2204,81 @@
 
        $analyze_input_log_always [1]
 
-              After  a run of latex (etc), always analyze .log for input files
-              in the <...> and (...) constructions.  Otherwise,  only  do  the
+              After a run of latex (etc), always analyze .log for input  files
+              in  the  <...>  and (...) constructions.  Otherwise, only do the
               analysis when fls file doesn't exist or is out of date.
 
+              Under normal circumstances, the data in the fls  file  is  reli-
+              able, and the test of the log file gets lots of false positives;
+              usually $analyze_input_log_always is best set to zero.  But  the
+              test  of the log file is needed at least in the following situa-
+              tion: When a user needs to persuade latexmk that a certain  file
+              is  a  source file, and latexmk doesn't otherwise find it.  Then
+              the user can write code that causes a  line  with  (...)  to  be
+              written  to log file.  One important case is for lualatex, which
+              doesn't always generate lines in the .fls  file  for  input  lua
+              files.   (The  situation  with lualatex is HIGHLY version depen-
+              dent, e.g., there was a big  change  between  TeXLive  2016  and
+              TeXLive 2017.)
 
+              To  keep  backward compatibility with older versions of latexmk,
+              the default is to set $analyze_input_log_always to 1.
 
 
-                               29 September 2020                            33
+       $auto_rc_use [1]
+              Whether to automatically read the standard  initialization  (rc)
+              files, which are the system RC file, the user's RC file, and the
+              RC file in the current directory.  The command line option -norc
+              can  be  used to turn this setting off.  Each RC file could also
+              turn this setting off, i.e., it could set $auto_rc_use  to  zero
+              to prevent automatic reading of the later RC files.
 
+              This  variable does not affect the reading of RC files specified
+              on the command line by the -r option.
 
 
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+                                 15 April 2021                              34
 
 
-              Under  normal  circumstances,  the data in the fls file is reli-
-              able, and the test of the log file gets lots of false positives;
-              usually  $analyze_input_log_always is best set to zero.  But the
-              test of the log file is needed at least in the following  situa-
-              tion:  When a user needs to persuade latexmk that a certain file
-              is a source file, and latexmk doesn't otherwise find  it.   Then
-              the  user  can  write  code  that causes a line with (...) to be
-              written to log file.  One important case is for lualatex,  which
-              doesn't  always  generate  lines  in the .fls file for input lua
-              files.  (The situation with lualatex is  HIGHLY  version  depen-
-              dent,  e.g.,  there  was  a  big change between TeXLive 2016 and
-              TeXLive 2017.)
 
-              To keep backward compatibility with older versions  of  latexmk,
-              the default is to set $analyze_input_log_always to 1.
 
 
-       $auto_rc_use [1]
-              Whether  to  automatically read the standard initialization (rc)
-              files, which are the system RC file, the user's RC file, and the
-              RC file in the current directory.  The command line option -norc
-              can be used to turn this setting off.  Each RC file  could  also
-              turn  this  setting off, i.e., it could set $auto_rc_use to zero
-              to prevent automatic reading of the later RC files.
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-              This variable does not affect the reading of RC files  specified
-              on the command line by the -r option.
 
        $aux_dir [""]
               The directory in which auxiliary files (aux, log, etc) are to be
-              written by a run of *latex.  If this variable is  not  set,  but
-              $out_dir  is set, then $aux_dir is set to $out_dir, which is the
+              written  by  a  run of *latex.  If this variable is not set, but
+              $out_dir is set, then $aux_dir is set to $out_dir, which is  the
               directory to which general output files are to be written.
 
-              Important note:  The  effect  of  $aux_dir,  if  different  from
+              Important  note:   The  effect  of  $aux_dir,  if different from
               $out_dir, is achieved by giving *latex the -aux-directory.  Cur-
-              rently (Dec. 2011 and later) this only works on the MiKTeX  ver-
+              rently  (Dec. 2011 and later) this only works on the MiKTeX ver-
               sion of *latex.
 
               See also the documentation of $out_dir for some complications on
               what directory names are suitable.
 
-              If you also use the -cd option, and $out_dir (or $aux_dir)  con-
-              tains  a relative path, then the path is interpreted relative to
+              If  you also use the -cd option, and $out_dir (or $aux_dir) con-
+              tains a relative path, then the path is interpreted relative  to
               the document directory.
 
        $banner [0]
-              If nonzero, the banner message is printed across each page  when
-              converting  the  dvi  file to postscript.  Without modifying the
-              variable $banner_message, this is equivalent to  specifying  the
+              If  nonzero, the banner message is printed across each page when
+              converting the dvi file to postscript.   Without  modifying  the
+              variable  $banner_message,  this is equivalent to specifying the
               -d option.
 
               Note that if $banner is nonzero, the $postscript_mode is assumed
               and the postscript file is always generated, even if it is newer
-
-
-
-                               29 September 2020                            34
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               than the dvi file.
 
        $banner_intensity [0.95]
               Equivalent to the -bi option, this is a decimal number between 0
-              and 1 that specifies how dark to print the banner message. 0  is
+              and  1 that specifies how dark to print the banner message. 0 is
               black, 1 is white.  The default is just right if your toner car-
               tridge isn't running too low.
 
@@ -2261,22 +2287,33 @@
               dvi file to postscript.  This is equivalent to the -bm option.
 
        $banner_scale [220.0]
-              A  decimal  number  that  specifies how large the banner message
-              will be printed.  Experimentation is necessary to get the  right
-              scale  for  your message, as a rule of thumb the scale should be
-              about equal to 1100 divided by the number of characters  in  the
-              message.   The  Default  is just right for 5 character messages.
+              A decimal number that specifies how  large  the  banner  message
+              will  be printed.  Experimentation is necessary to get the right
+              scale for your message, as a rule of thumb the scale  should  be
+              about  equal  to 1100 divided by the number of characters in the
+              message.  The Default is just right for  5  character  messages.
               This is equivalent to the -bs option.
 
        @BIBINPUTS
-              This is an array variable, now mostly obsolete,  that  specifies
-              directories  where  latexmk  should look for .bib files.  By de-
-              fault it is set from the BIBINPUTS environment variable  of  the
-              operating  system.   If  that environment variable is not set, a
-              single element list consisting of the current directory is  set.
+              This  is  an array variable, now mostly obsolete, that specifies
+              directories where latexmk should look for .bib  files.   By  de-
+              fault  it  is set from the BIBINPUTS environment variable of the
+              operating system.  If that environment variable is  not  set,  a
+              single  element list consisting of the current directory is set.
               The format of the directory names depends on your operating sys-
               tem, of course.  Examples for setting this variable are:
 
+
+
+                                 15 April 2021                              35
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
                       @BIBINPUTS = ( ".", "C:\\bibfiles" );
                       @BIBINPUTS = ( ".", "\\server\bibfiles" );
                       @BIBINPUTS = ( ".", "C:/bibfiles" );
@@ -2283,16 +2320,16 @@
                       @BIBINPUTS = ( ".", "//server/bibfiles" );
                       @BIBINPUTS = ( ".", "/usr/local/texmf/bibtex/bib" );
 
-              Note that under MS Windows, either a  forward  slash  "/"  or  a
-              backward  slash "\" can be used to separate pathname components,
-              so the first two and the second  two  examples  are  equivalent.
-              Each  backward slash should be doubled to avoid running afoul of
+              Note  that  under  MS  Windows,  either a forward slash "/" or a
+              backward slash "\" can be used to separate pathname  components,
+              so  the  first  two  and the second two examples are equivalent.
+              Each backward slash should be doubled to avoid running afoul  of
               Perl's rules for writing strings.
 
               Important note: This variable is now mostly obsolete in the cur-
               rent version of latexmk, since it has a better method of search-
-              ing for files using the kpsewhich  command.   However,  if  your
-              system  is an unusual one without the kpsewhich command, you may
+              ing  for  files  using  the kpsewhich command.  However, if your
+              system is an unusual one without the kpsewhich command, you  may
               need to set the variable @BIBINPUTS.
 
        $biber ["biber %O %S"]
@@ -2299,38 +2336,52 @@
               The biber processing program.
 
        $biber_silent_switch ["--onlylog"]
-              Switch(es) for the biber processing program when silent mode  is
+              Switch(es)  for the biber processing program when silent mode is
               on.
 
+       $bibtex ["bibtex %O %S"]
+              The BibTeX processing program.
 
+       $bibtex_fudge [1]
+              When using bibtex, whether to change directory to  $aux_dir  be-
+              fore running bibtex.
 
+              The need arises as follows:
 
-                               29 September 2020                            35
+              a.  With  bibtex  before about 2019, if the filename given to it
+              contains a path component, there was a bug that bibtex would not
+              find  extra  aux  files,  as produced by the \include command in
+              TeX.
 
+              b. With all moderately recent versions  of  bibtex,  bibtex  may
+              refuse to write its bbl and blg files, for security reasons, for
+              certain cases of the path component of the filename given to it.
 
+              However, there are also rare cases  where  the  change-directory
+              method  prevents  bibtex  from finding certain bib or bst files.
+              Then $bibtex_fudge needs to be set to 0.
 
 
+       $bibtex_silent_switch ["-terse"]
+              Switch(es) for the BibTeX processing program when silent mode is
+              on.
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+       $bibtex_use [1]
+              Under  what  conditions  to  run  bibtex or biber.  When latexmk
 
 
-       $bibtex ["bibtex %O %S"]
-              The BibTeX processing program.
 
-       $bibtex_fudge [0]
-              When using bibtex, whether to take special action to allow older
-              versions of bibtex to work when $out_dir or $aux_dir  is  speci-
-              fied.   With  bibtex  from  about  2019,  this special action is
-              longer be required; hence the default is not to do it.
+                                 15 April 2021                              36
 
-       $bibtex_silent_switch ["-terse"]
-              Switch(es) for the BibTeX processing program when silent mode is
-              on.
 
-       $bibtex_use [1]
-              Under what conditions to run bibtex or biber.  When latexmk dis-
-              covers from the log file that one (or more)  bibtex/biber-gener-
-              ated  bibliographies  are used, it can run bibtex or biber when-
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
+              discovers from the log file that one (or more) bibtex/biber-gen-
+              erated bibliographies are used, it can run bibtex or biber when-
               ever it appears necessary to regenerate  the  bbl  file(s)  from
               their  source  bib  database  file(s).   But  sometimes, the bib
               file(s) are not available (e.g., for a document obtained from an
@@ -2368,18 +2419,6 @@
               generated.   It  will  also  include files made from these first
               generation generated files.
 
-
-
-
-                               29 September 2020                            36
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               This operation is somewhat dangerous, and  can  have  unintended
               consequences,  since the files to be deleted are determined from
               a file created by *latex, which can contain  erroneous  informa-
@@ -2395,6 +2434,18 @@
               cleanup  except  for .dvi, .ps and .pdf files, 3 for cleanup ex-
               cept for dep and aux files.  (There is also  extra  cleaning  as
               specified by the $clean_ext, $clean_full_ext and @generated_exts
+
+
+
+                                 15 April 2021                              37
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               variables.)
 
               This variable is equivalent to specifying one of the  -c  or  -C
@@ -2416,7 +2467,7 @@
 
               in an initialization file will imply that when a clean-up opera-
               tion  is  specified,  not  only  is  the  standard  set of files
-              deleted, but also files of the form  FOO.out,  FOO-blx.bib,  %R-
+              deleted, but also files of the form FOO.out,  FOO-blx.bib,  FOO-
               figures*.log,  and  pythontex-files-FOO/*,  where FOO stands for
               the basename of the file being processed (as in FOO.tex).
 
@@ -2434,31 +2485,31 @@
               You  can  arrange  to remove both the files and the directory by
               setting
 
+                  $clean_ext = "pythontex-files-%R pythontex-files-%R";
 
+              See also the variable @generated_exts.
 
+       $clean_full_ext [""]
+              Extra extensions of files for latexmk to remove when the -C  op-
+              tion  is  selected, i.e., extensions of files to remove when the
+              .dvi, etc files are to be cleaned-up.
 
-                               29 September 2020                            37
+              More general patterns are allowed, as for $clean_ext.
 
+              The files specified by $clean_full_ext to be deleted  are  rela-
+              tive to the directory specified by $out_dir.
 
 
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
+                                 15 April 2021                              38
 
-                  $clean_ext = "pythontex-files-%R pythontex-files-%R";
 
-              See also the variable @generated_exts.
 
-       $clean_full_ext [""]
-              Extra extensions of files for latexmk to remove when the -C  op-
-              tion  is  selected, i.e., extensions of files to remove when the
-              .dvi, etc files are to be cleaned-up.
 
-              More general patterns are allowed, as for $clean_ext.
 
-              The files specified by $clean_full_ext to be deleted  are  rela-
-              tive to the directory specified by $out_dir.
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
        $compiling_cmd [""], $failure_cmd [""], $warning_cmd [""], $success_cmd
@@ -2500,18 +2551,6 @@
               These  assume  that  the  program xdotool is installed, that the
               previewer is using an X-Window system for display, and that  the
               title  of the window contains the name of the displayed file, as
-
-
-
-                               29 September 2020                            38
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               it normally does.  When the commands are  executed,  the  place-
               holder  string  %D  is  replaced  by the name of the destination
               file, which is the previewed file.  The above commands result in
@@ -2527,6 +2566,18 @@
 
               More  complicated  situations  can best be handled by defining a
               Perl subroutine to invoke the necessary commands, and using  the
+
+
+
+                                 15 April 2021                              39
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               "internal"  keyword  in the definitions to get the subroutine to
               be invoked.  (See the section "Format of Command Specifications"
               for how to do this.)
@@ -2566,18 +2617,6 @@
               specified on the latexmk command line.  2. Wildcards are allowed
               in @default_excluded_files.
 
-
-
-
-                               29 September 2020                            39
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        @default_files [("*.tex")]
               Default list of files to be processed.
 
@@ -2593,6 +2632,18 @@
               line then the files you specify by  setting  @default_files  are
               processed.
 
+
+
+
+                                 15 April 2021                              40
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               Three examples:
 
                    @default_files = ("paper_current");
@@ -2633,17 +2684,6 @@
               *latex programs.  This variable is set by the -cd and  -cd-  op-
               tions on latexmk's command line.
 
-
-
-                               29 September 2020                            40
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        $dvi_filter [empty]
               The dvi file filter to be run on the newly produced dvi file be-
               fore other processing.  Equivalent to specifying the -dF option.
@@ -2658,6 +2698,18 @@
               file for which a .dvi file is  a  prerequisite,  then  $dvi_mode
               will be set to 1.
 
+
+
+
+                                 15 April 2021                              41
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        $dvi_previewer ["start xdvi %O %S" under UNIX]
               The  command  to  invoke a dvi-previewer.  [Under MS-Windows the
               default is "start"; then latexmk arranges to use the  MS-Windows
@@ -2698,18 +2750,6 @@
               N.B. The standard dvipdf program runs silently,  so  adding  the
               silent  switch has no effect, but is actually innocuous.  But if
               an alternative program is used, e.g., dvipdfmx, then the  silent
-
-
-
-                               29 September 2020                            41
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               switch  has  an  effect.   The  default  setting  is correct for
               dvipdfm and dvipdfmx.
 
@@ -2723,6 +2763,19 @@
               The  program to used as a filter to convert a .dvi file to a .ps
               file in landscape mode.
 
+
+
+
+
+                                 15 April 2021                              42
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        $dvips_pdf_switch ["-P pdf"]
               Switch(es) for dvips program when pdf file is  to  be  generated
               from .ps file.
@@ -2765,17 +2818,6 @@
        $failure_cmd [undefined]
               See the documentation for $compiling_cmd.
 
-
-
-                               29 September 2020                            42
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        $fdb_ext ["fdb_latexmk"]
               The  extension  of the file which latexmk generates to contain a
               database of information on source files.  You will not  normally
@@ -2788,6 +2830,18 @@
               sue,  which  can  affect  the  use of files that are on a remote
               filesystem (network share) instead of being on a file system lo-
               cal to the computer running latexmk.  Almost users will not have
+
+
+
+                                 15 April 2021                              43
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               to worry about these settings, and can ignore the following  ex-
               planation.
 
@@ -2830,29 +2884,30 @@
               it  normally  indicates that at least one of the systems is mis-
               configured.   The   variable   $filetime_offset_report_threshold
               specifies  the  smallest  size  of the difference (or offset) in
+              seconds between the times of the local and remote system  beyond
+              which  the offset is reported.  This is reported at the point in
+              the latexmk's progress that it measures the offset.  The  report
+              is made if silent mode is used and diagnostic mode is not on.
 
 
+       $force_mode [0]
+              If  nonzero, continue processing past minor latex errors includ-
+              ing unrecognized cross references.  Equivalent to specifying the
+              -f option.
 
-                               29 September 2020                            43
 
 
 
 
+                                 15 April 2021                              44
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              seconds between the times of the local and remote system  beyond
-              which  the offset is reported.  This is reported at the point in
-              the latexmk's progress that it measures the offset.  The  report
-              is made if silent mode is used and diagnostic mode is not on.
 
 
-       $force_mode [0]
-              If  nonzero, continue processing past minor latex errors includ-
-              ing unrecognized cross references.  Equivalent to specifying the
-              -f option.
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
+
        @generated_exts  [(  aux  ,  bbl  , idx , ind , lof , lot , out , toc ,
        $fdb_ext )]
               This contains a list of extensions for files that are  generated
@@ -2896,28 +2951,28 @@
               The general rule latexmk uses for determining when an extra  run
               of  some  program  is needed is that one of the source files has
               changed.  But consider for example a latex package  that  causes
+              an  encapsulated postscript file (an "eps" file) to be made that
+              is to be read in on the next run.  The file contains  a  comment
+              line  giving  its  creation  date and time.  On the next run the
+              time changes, latex sees that the  eps  file  has  changed,  and
+              therefore  reruns  latex.  This causes an infinite loop, that is
+              only terminated because latexmk has a limit  on  the  number  of
+              runs to guard against pathological situations.
 
+              But the changing line has no real effect, since it is a comment.
+              You can instruct latex to ignore the offending line as follows:
 
 
-                               29 September 2020                            44
 
 
+                                 15 April 2021                              45
 
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              an  encapsulated postscript file (an "eps" file) to be made that
-              is to be read in on the next run.  The file contains  a  comment
-              line  giving  its  creation  date and time.  On the next run the
-              time changes, latex sees that the  eps  file  has  changed,  and
-              therefore  reruns  latex.  This causes an infinite loop, that is
-              only terminated because latexmk has a limit  on  the  number  of
-              runs to guard against pathological situations.
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-              But the changing line has no real effect, since it is a comment.
-              You can instruct latex to ignore the offending line as follows:
 
                  $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: ';
 
@@ -2961,29 +3016,29 @@
               not contain spaces.)
 
               The placeholder '%A' is permitted. This will be  substituted  by
-              the  basename  of  the  TeX file.  The primary purpose is when a
+              the basename of the TeX file.  The primary purpose is when a va-
+              riety of tex files are to be processed, and you want  to  use  a
+              different  jobname  for  each but one that is distinct for each.
+              Thus if you wanted to compare compilations of a set of files  on
+              different operating systems, with distinct filenames for all the
+              cases, you could set
 
+                 $jobname = "%A-$^O";
 
+              in an initialization file.  (Here $^O is a variable provided  by
+              perl that contains perl's name for the operating system.)
 
-                               29 September 2020                            45
 
 
 
+                                 15 April 2021                              46
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              variety of tex files are to be processed, and you want to use  a
-              different  jobname  for  each but one that is distinct for each.
-              Thus if you wanted to compare compilations of a set of files  on
-              different operating systems, with distinct filenames for all the
-              cases, you could set
 
-                 $jobname = "%A-$^O";
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-              in an initialization file.  (Here $^O is a variable provided  by
-              perl that contains perl's name for the operating system.)
 
               Suppose  you  had .tex files test1.tex and test2.tex.  Then when
               you run
@@ -3029,17 +3084,6 @@
               visible  in  latexmk's  screen output about invocations of kpse-
               which.
 
-
-
-                               29 September 2020                            46
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        $landscape_mode [0]
               If nonzero, run in landscape mode, using the landscape mode pre-
               viewers  and dvi to postscript converters.  Equivalent to the -l
@@ -3051,6 +3095,17 @@
               just to change the name of the program used,  but  also  specify
               options to the program.  E.g.,
 
+
+
+                                 15 April 2021                              47
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
                                   $latex = "latex --src-specials %O %S";
 
               To do a coordinated setting of all of $latex, $pdflatex, $luala-
@@ -3094,28 +3149,28 @@
               Switch(es) for the LaTeX processing program when silent mode  is
               on.
 
+              If  you  use MikTeX, you may prefer the results if you configure
+              the options to include -c-style-errors, e.g., by  the  following
+              line in an initialization file
 
+                $latex_silent_switch  =  "-interaction=batchmode  -c-style-er-
+              rors";
 
 
-                               29 September 2020                            47
+       $lpr ["lpr %O %S" under UNIX/Linux, "NONE lpr" under MS-Windows]
+              The command to print postscript files.
 
 
 
 
+                                 15 April 2021                              48
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              If  you  use MikTeX, you may prefer the results if you configure
-              the options to include -c-style-errors, e.g., by  the  following
-              line in an initialization file
 
-                $latex_silent_switch  =  "-interaction=batchmode  -c-style-er-
-              rors";
 
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-       $lpr ["lpr %O %S" under UNIX/Linux, "NONE lpr" under MS-Windows]
-              The command to print postscript files.
 
               Under MS-Windows (unlike UNIX/Linux), there is no standard  pro-
               gram for printing files.  But there are ways you can do it.  For
@@ -3159,19 +3214,6 @@
               tex, and $xelatex, see the section "Advanced Configuration".
 
 
-
-
-
-
-                               29 September 2020                            48
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        %lualatex_input_extensions
               This variable specifies the extensions tried by latexmk when  it
               finds  that  a lualatex run resulted in an error that a file has
@@ -3185,6 +3227,17 @@
               specified  by  the variable %pdflatex_input_extensions.  The de-
               fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
 
+
+
+                                 15 April 2021                              49
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               See details of the %latex_input_extensions for other information
               that equally applies to %lualatex_input_extensions.
 
@@ -3201,6 +3254,13 @@
        $makeindex ["makeindex %O -o %D %S"]
               The index processing program.
 
+       $makeindex_fudge [0]
+              When  using  makeindex,  whether to change directory to $aux_dir
+              before running makeindex.  Set to 1 if $aux_dir is  not  an  ex-
+              plicit  subdirectory  of  current directory, otherwise makeindex
+              will refuse to write its output and log files, for security rea-
+              sons.
+
        $makeindex_silent_switch ["-q"]
               Switch(es)  for the index processing program when silent mode is
               on.
@@ -3226,24 +3286,24 @@
               For almost all programs and for almost all filenames  under  MS-
               Windows,  both "\" and "/" are acceptable as the directory sepa-
               rator character, provided at least that filenames  are  properly
+              quoted.  But it is possible that programs exist that only accept
+              "\" on the command line, since that is  the  standard  directory
+              separator  for MS-Windows.  So for safety latexmk makes the sub-
+              stitution from "/" to "\", by default.
 
+              However there are also programs on MS-Windows for which  a  back
 
 
-                               29 September 2020                            49
 
+                                 15 April 2021                              50
 
 
 
 
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              quoted.  But it is possible that programs exist that only accept
-              "\" on the command line, since that is  the  standard  directory
-              separator  for MS-Windows.  So for safety latexmk makes the sub-
-              stitution from "/" to "\", by default.
-
-              However there are also programs on MS-Windows for which  a  back
               slash "\" is interpreted differently than as a directory separa-
               tor; for these the directory separator should be "/".   Programs
               with  this  behavior  include  all  the  *latex  programs in the
@@ -3291,25 +3351,25 @@
               and you need to use makeindex or bibtex, then you need  to  dis-
               able  the  security measures (and assume any risks).  One way of
               doing this is to temporarily set an operating system environment
-              variable  openout_any  to  "a"  (as  in  "all"), to override the
+              variable  openout_any  to "a" (as in "all"), to override the de-
+              fault "paranoid" setting.
 
+       $pdf_mode [0]
+              If zero, do NOT generate a pdf  version  of  the  document.   If
+              equal  to 1, generate a pdf version of the document using pdfla-
+              tex, using the command specified by the $pdflatex variable.   If
 
 
-                               29 September 2020                            50
 
+                                 15 April 2021                              51
 
 
 
 
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              default "paranoid" setting.
-
-       $pdf_mode [0]
-              If zero, do NOT generate a pdf  version  of  the  document.   If
-              equal  to 1, generate a pdf version of the document using pdfla-
-              tex, using the command specified by the $pdflatex variable.   If
               equal  to  2, generate a pdf version of the document from the ps
               file, by using the command specified by  the  $ps2pdf  variable.
               If  equal  to 3, generate a pdf version of the document from the
@@ -3358,25 +3418,24 @@
               See details of the %latex_input_extensions for other information
               that equally applies to %pdflatex_input_extensions.
 
+       $pdflatex_silent_switch ["-interaction=batchmode"]
+              Switch(es)  for  the pdflatex program (specified in the variable
+              $pdflatex) when silent mode is on.
 
+              See details of the $latex_silent_switch  for  other  information
+              that equally applies to $pdflatex_silent_switch.
 
 
-                               29 September 2020                            51
 
+                                 15 April 2021                              52
 
 
 
 
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       $pdflatex_silent_switch ["-interaction=batchmode"]
-              Switch(es)  for  the pdflatex program (specified in the variable
-              $pdflatex) when silent mode is on.
-
-              See details of the $latex_silent_switch  for  other  information
-              that equally applies to $pdflatex_silent_switch.
-
        $pdf_previewer ["start acroread %O %S"]
               The command to invoke a pdf-previewer.
 
@@ -3425,23 +3484,23 @@
               Note that acroread under MS-Windows (but not UNIX) locks the pdf
               file, so the default value is then 3.
 
+              Arranging to use a command to get a previewer explicitly updated
+              requires three variables to be set.  For example:
 
+                  $pdf_previewer = "start xpdf -remote %R %O %S";
+                  $pdf_update_method = 4;
+                  $pdf_update_command = "xpdf -remote %R -reload";
 
-                               29 September 2020                            52
 
 
+                                 15 April 2021                              53
 
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              Arranging to use a command to get a previewer explicitly updated
-              requires three variables to be set.  For example:
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-                  $pdf_previewer = "start xpdf -remote %R %O %S";
-                  $pdf_update_method = 4;
-                  $pdf_update_command = "xpdf -remote %R -reload";
 
               The  first  setting  arranges for the xpdf program to be used in
               its "remote server mode", with the server name specified as  the
@@ -3491,23 +3550,24 @@
 
 
 
+       $preview_continuous_mode [0]
+              If nonzero, run a previewer to view the document,  and  continue
+              running latexmk to keep .dvi up-to-date.  Equivalent to the -pvc
+              option.  Which previewer is run depends on the  other  settings,
+              see the command line options -view=, and the variable $view.
 
 
-                               29 September 2020                            53
 
 
+                                 15 April 2021                              54
 
 
 
+
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       $preview_continuous_mode [0]
-              If nonzero, run a previewer to view the document,  and  continue
-              running latexmk to keep .dvi up-to-date.  Equivalent to the -pvc
-              option.  Which previewer is run depends on the  other  settings,
-              see the command line options -view=, and the variable $view.
-
        $preview_mode [0]
               If nonzero, run a previewer to preview the document.  Equivalent
               to the -pv option.  Which previewer is run depends on the  other
@@ -3556,24 +3616,24 @@
 
               Note  that  gv  could be used with the -watch option updates its
               display whenever the postscript file changes, whereas  ghostview
+              does  not.  However, different versions of gv have slightly dif-
+              ferent ways of writing this  option.   You  can  configure  this
+              variable appropriately.
 
+              WARNING: Linux systems may have installed one (or more) versions
+              of gv under different names, e.g.,  ggv,  kghostview,  etc,  but
 
 
-                               29 September 2020                            54
 
+                                 15 April 2021                              55
 
 
 
 
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              does  not.  However, different versions of gv have slightly dif-
-              ferent ways of writing this  option.   You  can  configure  this
-              variable appropriately.
-
-              WARNING: Linux systems may have installed one (or more) versions
-              of gv under different names, e.g.,  ggv,  kghostview,  etc,  but
               perhaps not one actually called gv.
 
               Important  note:  Normally you will want to have a previewer run
@@ -3623,21 +3683,23 @@
               The period of inactivity, in minutes, after which pvc mode times
               out.  This is used if $pvc_timeout is nonzero.
 
+       $pvc_view_file_via_temporary [1]
+              The same as $always_view_file_via_temporary, except that it only
+              applies in preview-continuous mode (-pvc option).
 
 
-                               29 September 2020                            55
 
 
 
+                                 15 April 2021                              56
 
 
+
+
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       $pvc_view_file_via_temporary [1]
-              The same as $always_view_file_via_temporary, except that it only
-              applies in preview-continuous mode (-pvc option).
-
        $quote_filenames [1]
               This specifies whether substitutions for placeholders in command
               specifications  (as  in  $pdflatex)  are  surrounded  by  double
@@ -3688,10 +3750,14 @@
               output or aux directories.]
 
               The  default  under  MSWin and Cygwin is ';' and under UNIX-like
+              operating systems (including Linux and OS-X) is  ':'.   Normally
+              the  defaults give correct behavior.  But there can be difficul-
+              ties if your operating system is of one kind, but some  of  your
+              software  is  running  under  an  emulator for the other kind of
 
 
 
-                               29 September 2020                            56
+                                 15 April 2021                              57
 
 
 
@@ -3700,11 +3766,7 @@
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              operating systems (including Linux and OS-X) is  ':'.   Normally
-              the  defaults give correct behavior.  But there can be difficul-
-              ties if your operating system is of one kind, but some  of  your
-              software  is running under an emulator for the other kind of op-
-              erating system; in that case you'll need to  find  out  what  is
+              operating system; in that case you'll need to find out  what  is
               needed,  and  set  $search_path_separator explicitly.  (The same
               goes, of course, for unusual operating systems that are  not  in
               the MSWin, Linux, OS-X, Unix collection.)
@@ -3753,11 +3815,15 @@
        $success_cmd [undefined]
               See the documentation for $compiling_cmd.
 
+       $tmpdir [See below for default]
+              Directory  to  store  temporary  files that latexmk may generate
+              while running.
 
+              The default  under  MSWindows  (including  cygwin),  is  to  set
 
 
 
-                               29 September 2020                            57
+                                 15 April 2021                              58
 
 
 
@@ -3766,13 +3832,8 @@
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       $tmpdir [See below for default]
-              Directory  to  store  temporary  files that latexmk may generate
-              while running.
-
-              The default under MSWindows (including cygwin), is to  set  $tm-
-              pdir  to the value of the first of whichever of the system envi-
-              ronment variables TMPDIR or TEMP exists, otherwise to  the  cur-
+              $tmpdir to the value of the first of whichever of the system en-
+              vironment variables TMPDIR or TEMP exists, otherwise to the cur-
               rent  directory.   Under other operating systems (expected to be
               UNIX/Linux, including OS-X), the default is  the  value  of  the
               system  environment  variable  TMPDIR  if  it  exists, otherwise
@@ -3820,10 +3881,15 @@
 
               The default behavior is normally satisfactory in the usual edit-
               compile-edit  cycle.  But, for example, latexmk can also be used
+              as part of a build process for some bigger  project,  e.g.,  for
+              creating  documentation  in the build of a software application.
+              Then it is often sensible to treat citation and reference  warn-
+              ings  as  errors  that  require  the overall build process to be
+              aborted.  Of course, since multiple runs of *latex are generally
 
 
 
-                               29 September 2020                            58
+                                 15 April 2021                              59
 
 
 
@@ -3832,11 +3898,6 @@
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              as part of a build process for some bigger  project,  e.g.,  for
-              creating  documentation  in the build of a software application.
-              Then it is often sensible to treat citation and reference  warn-
-              ings  as  errors  that  require  the overall build process to be
-              aborted.  Of course, since multiple runs of *latex are generally
               needed  to resolve references and citations, what matters is not
               the warnings on the first run, but the warnings on the last run;
               latexmk takes this into account appropriately.
@@ -3886,25 +3947,25 @@
               not been found, and the file  is  given  without  an  extension.
               This  typically  happens  when  LaTeX  commands of the form \in-
               put{file} or \includegraphics{figure}, when the relevant  source
+              file does not exist.
 
+              In  this  situation, latexmk searches for custom dependencies to
+              make the missing file(s), but restricts  it  to  the  extensions
+              specified   by   the  variable  %xelatex_input_extensions.   The
 
 
-                               29 September 2020                            59
 
+                                 15 April 2021                              60
 
 
 
 
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              file does not exist.
+              default extensions are 'tex', 'pdf', 'jpg, and 'png'.
 
-              In  this  situation, latexmk searches for custom dependencies to
-              make the missing file(s), but restricts  it  to  the  extensions
-              specified  by  the  variable %xelatex_input_extensions.  The de-
-              fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
-
               See details of the %latex_input_extensions for other information
               that equally applies to %xelatex_input_extensions.
 
@@ -3952,23 +4013,23 @@
        must:  If  non-zero,  the file from which we are converting must exist,
               if it doesn't exist latexmk will give an error message and  exit
               unless the -f option is specified.  If must is zero and the file
+              we are converting from doesn't exist, then no action  is  taken.
+              Generally, the appropriate value of must is zero.
 
+       function:
+              The  name  of the subroutine that latexmk should call to perform
 
 
-                               29 September 2020                            60
 
+                                 15 April 2021                              61
 
 
 
 
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-              we are converting from doesn't exist, then no action  is  taken.
-              Generally, the appropriate value of must is zero.
-
-       function:
-              The  name  of the subroutine that latexmk should call to perform
               the file conversion.  The first argument to  the  subroutine  is
               the base name of the file to be converted without any extension.
               The subroutines are declared in the syntax of Perl.   The  func-
@@ -4018,21 +4079,21 @@
        Note  for  advanced  usage: The operating system's environment variable
        TEXINPUTS can be used to specify a search path for finding files by la-
        tex  etc.   Correspondingly,  when  a missing file is reported, latexmk
+       looks in the directories specified in TEXINPUTS as well as in the  cur-
+       rent  directory, to find a source file from which an instance of a cus-
+       tom dependency can be used to make the missing file.
 
 
 
-                               29 September 2020                            61
 
 
+                                 15 April 2021                              62
 
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       looks in the directories specified in TEXINPUTS as well as in the  cur-
-       rent  directory, to find a source file from which an instance of a cus-
-       tom dependency can be used to make the missing file.
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
    Function to implement custom dependency, traditional method:
@@ -4084,10 +4145,15 @@
            }
 
        Note  1: In the command lines given in the system commands in the above
+       examples, double quotes have been inserted around the file  names  (im-
+       plemented  by '\"' in the Perl language).  They immunize the running of
+       the program against special characters in filenames.  Very often  these
+       quotes  are  not  necessary, i.e., they can be omitted.  But it is nor-
+       mally safer to keep them in.  Even though the rules  for  quoting  vary
 
 
 
-                               29 September 2020                            62
+                                 15 April 2021                              63
 
 
 
@@ -4096,11 +4162,6 @@
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       examples, double quotes have been inserted around the file  names  (im-
-       plemented  by '\"' in the Perl language).  They immunize the running of
-       the program against special characters in filenames.  Very often  these
-       quotes  are  not  necessary, i.e., they can be omitted.  But it is nor-
-       mally safer to keep them in.  Even though the rules  for  quoting  vary
        between  operating  systems,  command  shells  and individual pieces of
        software, the quotes in the above examples do not cause problems in the
        cases I have tested.
@@ -4149,11 +4210,16 @@
        file.  This method has been available since very old  versions  of  la-
        texmk, and many examples can be found, e.g., on the web.
 
-       However  in  later  versions  of  latexmk the internal structure of the
+       However  in later versions of latexmk the internal structure of the im-
+       plementation of its "rules" for the steps of processing, including cus-
+       tom dependencies, became much more powerful.  The function implementing
+       a custom dependency is executed within a special context where a number
+       of  extra  variables  and subroutines are defined.  Publicly documented
+       ones, intended to be long-term stable,  are  listed  below,  under  the
 
 
 
-                               29 September 2020                            63
+                                 15 April 2021                              64
 
 
 
@@ -4162,12 +4228,7 @@
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       implementation of its "rules" for the steps  of  processing,  including
-       custom  dependencies,  became  much more powerful.  The function imple-
-       menting a custom dependency is executed within a special context  where
-       a number of extra variables and subroutines are defined.  Publicly doc-
-       umented ones, intended to be long-term stable, are listed below,  under
-       the heading "Variables and subroutines for processing a rule".
+       heading "Variables and subroutines for processing a rule".
 
        Examples  of  their  use is given in the following examples, concerning
        multiple index files and glossaries.
@@ -4216,22 +4277,22 @@
            push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
 
        This  last example uses the command specification in $makeindex, and so
+       any customization you have made for the standard index also applies  to
+       your extra indexes.
 
+       Similar techniques can be applied for glossaries.
 
 
-                               29 September 2020                            64
 
 
+                                 15 April 2021                              65
 
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       any customization you have made for the standard index also applies  to
-       your extra indexes.
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-       Similar techniques can be applied for glossaries.
 
        Those of you with experience with Makefiles, may get concerned that the
        .ndx file is written during a run of *latex and is  always  later  than
@@ -4281,23 +4342,24 @@
 
        See  also the section DEALING WITH ERRORS, PROBLEMS, ETC.  See also the
        examples in the directory example_rcfiles in the latexmk distributions.
-       Even  if  none  of  the  examples apply to your case, they may give you
+       Even if none of the examples apply to your case, they may give you use-
+       ful ideas
 
 
+   Utility subroutines
 
-                               29 September 2020                            65
 
 
 
+                                 15 April 2021                              66
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       useful ideas
 
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-   Utility subroutines
+
        ensure_path( var, values ...)
 
               The first parameter is the name of one of the system's  environ-
@@ -4347,23 +4409,23 @@
               This gives the name of the primary source file.  Note the double
               dollar signs.
 
+       $$Pdest
+              This gives the name of the main output file if  any.   Note  the
+              double dollar signs.
 
 
 
 
-                               29 September 2020                            66
 
+                                 15 April 2021                              67
 
 
 
 
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       $$Pdest
-              This gives the name of the main output file if  any.   Note  the
-              double dollar signs.
-
        rdb_ensure_file( $rule, file )
               This  a subroutine that ensures that the given file is among the
               source files for the specified rule.  It is typically used when,
@@ -4414,21 +4476,21 @@
        pattern,  you  can  use one of the following subroutines, std_tex_cmds,
        alt_tex_cmds, and set_tex_cmds.
 
+       They work as follows
 
+          &std_tex_cmds;
 
 
-                               29 September 2020                            67
 
 
+                                 15 April 2021                              68
 
 
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       They work as follows
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-          &std_tex_cmds;
 
        This results in $latex = 'latex %O %S', and  similarly  for  $pdflatex,
        $lualatex,  and  $xelatex.   Note the ampersand in the invocation; this
@@ -4479,23 +4541,23 @@
        could be quite complicated, for example if some of the source files for
        a LaTeX document are generated by the project's software.
 
-       In  this  section,  I  give  a couple of examples of how latexmk can be
+       In this section, I give a couple of examples of how latexmk can be use-
+       fully invoked from a Makefile.  The examples use specific  features  of
+       current  versions  of  GNU make, which is the default on both linux and
+       OS-X systems.  They may need modifications for other versions of make.
 
 
 
-                               29 September 2020                            68
 
+                                 15 April 2021                              69
 
 
 
 
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       usefully invoked from a Makefile.  The examples use  specific  features
-       of current versions of GNU make, which is the default on both linux and
-       OS-X systems.  They may need modifications for other versions of make.
-
        The simplest method is simply to delegate all the relevant tasks to la-
        texmk, as is suitable for a straightforward LaTeX document.  For this a
        suitable Makefile is like
@@ -4546,22 +4608,22 @@
                    mkdir $@
             %.pdf : %.tex
                    if [ ! -e $(DEPS_DIR) ]; then mkdir $(DEPS_DIR); fi
+                   $(LATEXMK) -pdf -dvi- -ps- -deps-out=$(DEPS_DIR)/$@P $<
+            %.pdf : %.fig
+                   fig2dev -Lpdf $< $@
 
 
 
-                               29 September 2020                            69
 
+                                 15 April 2021                              70
 
 
 
 
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-                   $(LATEXMK) -pdf -dvi- -ps- -deps-out=$(DEPS_DIR)/$@P $<
-            %.pdf : %.fig
-                   fig2dev -Lpdf $< $@
-
        (Again,  the  lines  containing  the  commands  for the rules should be
        started with tabs.)  This example was inspired by how GNU automake han-
        dles automatic dependency tracking of C source files.
@@ -4612,10 +4674,14 @@
        manual  update (reopen); it views postscript and pdf.  Gsview under MS-
        Windows works for both postscript and pdf, but only reads  the  updated
        file  when  its  screen  is refreshed.  Acroread under UNIX/Linux views
+       pdf, but the file needs to be closed and reopened to  view  an  updated
+       version.   Under  MS-Windows,  acroread locks its input file and so the
+       pdf file cannot be updated.  (Remedy: configure latexmk  to  use  suma-
+       trapdf instead.)
 
 
 
-                               29 September 2020                            70
+                                 15 April 2021                              71
 
 
 
@@ -4624,11 +4690,6 @@
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       pdf, but the file needs to be closed and reopened to  view  an  updated
-       version.   Under  MS-Windows,  acroread locks its input file and so the
-       pdf file cannot be updated.  (Remedy: configure latexmk  to  use  suma-
-       trapdf instead.)
-
 THANKS TO
        Authors  of previous versions.  Many users with their feedback, and es-
        pecially David Coppit (username david at node coppit.org) who made many
@@ -4637,7 +4698,7 @@
        dard form to avoid being harvested too easily.)
 
 AUTHOR
-       Current  version,  by John Collins (Version 4.70b).  Report bugs etc to
+       Current  version,  by John Collins (Version 4.72b).  Report bugs etc to
        his e-mail (jcc8 at psu.edu).
 
        Released     version     can      be      obtained      from      CTAN:
@@ -4681,6 +4742,11 @@
 
 
 
-                               29 September 2020                            71
 
 
+
+
+
+                                 15 April 2021                              72
+
+

Modified: trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl	2021-04-16 20:15:03 UTC (rev 58885)
+++ trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl	2021-04-16 20:15:34 UTC (rev 58886)
@@ -1,130 +1,7 @@
 #!/usr/bin/env perl
 
-#!!!!!!!!!!!!!!!!!!!????????? CLEAN UP INITIALIZATION
-#!!! See all FIX items.
 
-# Perhaps add subroutine rdb_change_active( (rules to deactivate), (rules to activate))
-
-# ?? Still need to fix bcf error issue.
-# Don't keep looping after error
-# pvc: Only re-run on USER FILE CHANGE.
-# See # ??????? BCF
-
-
-#!!!!!!!!???  Check @pwd_log
-
-
-# !!!!!!!!!! Don't forget to document $silence_logfile_warnings.!!!
-
-# N.B. !!!!!!!!!!!  See 17 July 2012 comments !!!!!!!!!!!!!!!!!!
-
-# On a UNIX-like system, the above enables latexmk to run independently
-#   of the location of the perl executable.  This line relies on the 
-#   existence of the program /usr/bin/env
-# If there is a problem for any reason, you can replace the first line of 
-#   this file by:
-
-#!/usr/bin/perl -w
-
-# with the path of the perl executable adjusted for your system. 
-
-use warnings;
-
-# Delete #??!! when working
-
-# See ?? <===============================
-
-## ?? Issues with clean-up
-## List of aux files deleted is those read, not those generated.
-## Other files are generated by *latex; should they be deleted?
-## (I have hooks for this).
-
-
-
-#=======================================
-
-#??  Force mode doesn't appear to do force (if error in latex file)
-#??? Get banner back in.
-#??  CORRECT DIAGNOSTICS ON CHANGED FILES IF THEY DIDN'T EXIST BEFORE
-#??  Further corrections to deal with disappeared source files for custom dependencies.
-#       Message repeatedly appears about remake when source file of cusdep doesn't exist.
-#??  logfile w/o fdb file: don't set changed file, perhaps for generated exts.
-#    Reconsider
-#??  Do proper run-stuff for bibtex, makeindex, cus-deps.  OK I think
-#    Parse and correctly find ist files
-
-
-# ATTEMPT TO ALLOW FILENAMES WITH SPACES:
-#    (as of 1 Apr 2006, and then 14 Sep. 2007)
-
-# Problems:
-# A.  Quoting filenames will not always work.  
-#        a.  Under UNIX, quotes are legal in filenames, so when PERL
-#            directly runs a binary, a quoted filename will be treated as
-#            as a filename containing a quote character.  But when it calls
-#            a shell, the quotes are handled by the shell as quotes.
-#        b.  Under MSWin32, quotes are illegal filename characters, and tend
-#            to be handled correctly.
-#        c.  But under cygwin, results are not so clear (there are many 
-#            combinations: native v. cygwin perl, native v cygwin programs
-#            NT v. unix scripts, which shell is called.
-# B.  TeX doesn't always handle filenames with spaces gracefully.
-#        a.  UNIX/LINUX: The version on gluon2 Mar 31, 2006 to Sep. 2007) 
-#            doesn't handle them at all.  (TeX treats space as separator.)
-#        b.  At least some later versions actually do (Brad Miller e-mail, 
-#            Sep. 2007).
-#        c.  fptex [[e-TeXk, Version 3.141592-2.1 (Web2c 7.5.2)] does, on 
-#            my MSWin at home.  In \input the filename must be in quotes.
-#        d.  Bibtex [BibTeX (Web2c 7.5.2) 0.99c on my MSWin system at home,
-#            Sep. 2007] does not allow names of bibfiles to have spaces.
-# C.  =====> Using the shell for command lines is not safe, since special 
-#     characters can cause lots of mayhem.
-#     It will therefore be a good idea to sanitize filenames. 
-#
-# I've sanitized all calls out:
-#     a. system and exec use a single argument, which forces
-#        use of shell, under all circumstances
-#        Thus I can safely use quotes on filenames:  They will be handled by 
-#        the shell under UNIX, and simply passed on to the program under MSWin32.
-#     b. I reorganized Run, Run_Detached to use single command line
-#     c. All calls to Run and Run_Detached have quoted filenames.
-#     d. So if a space-free filename with wildcards is given on latexmk's
-#        command line, and it globs to space-containing filename(s), that
-#        works (fptex on home computer, native NT tex)
-#     e. ====> But globbing fails: the glob function takes space as filename 
-#        separator.   ====================
-
-#================= TO DO ================
-#
-# 1.  See ??  ESPECIALLY $MSWin_fudge_break
-# 2.  Check fudged conditions in looping and make_files 
-# 3.  Should not completely abort after a run that ends in failure from latex
-#     Missing input files (including via custom dependency) should be checked for
-#     a change in status
-#         If sources for missing files from custom dependency 
-#             are available, then do a rerun
-#         If sources of any kind become available rerun (esp. for pvc)
-#             rerun
-#         Must parse log_file after unsuccessful run of latex: it may give
-#             information about missing files. 
-# 4.  Check file of bug reports and requests
-# 5.  Rationalize bibtex warnings and errors.  Two almost identical routines.
-#         Should 1. Use single routine
-#                2. Convert errors to failure only in calling routine
-#                3. Save first warning/error.
-
-# ?? Use of generated_exts arrays and hashes needs rationalization
-
-# To do: 
-#   Rationalize again handling of include files.
-#     Now I use kpsewhich to do searches, if file not found
-#        (How do I avoid getting slowed down too much?)
-#   Document the assumptions at each stage of processing algorithm.
-#   Option to restart previewer automatically, if it dies under -pvc
-#   Test for already running previewer gets wrong answer if another
-#     process has the viewed file in its command line
-
-## Copyright John Collins 1998-2020
+## Copyright John Collins 1998-2021
 ##           (username jcc8 at node psu.edu)
 ##      (and thanks to David Coppit (username david at node coppit.org) 
 ##           for suggestions) 
@@ -149,19 +26,79 @@
 ##
 ##
 ##
-##   NEW FEATURES, since v. 2.0:
-##     1.  Correct algorithm for deciding how many times to run latex:
-##         based on whether source file(s) change between runs
-##     2.  Continuous preview works, and can be of ps file or dvi file
-##     3.  pdf creation by pdflatex possible
-##     4.  Defaults for commands are OS dependent.
-##     5.  Parsing of log file instead of source file is used to
-##         obtain dependencies, by default.
+##   Modification log from 1 Jan 2020 onwards in detail
 ##
-##   Modification log from 9 Dec 2011 onwards in detail
-##
-## 12 Jan 2012 STILL NEED TO DOCUMENT some items below
-##
+## 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
@@ -168,6 +105,7 @@
 ##                               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
@@ -221,81 +159,9 @@
 ##                             xetex source).  This forces xdvipdfmx to always
 ##                             try to embed fonts, ignoring licensing flags, etc.
 ##
-## Current version (4.67, 26 Dec 2019) to CTAN
-## 26 Dec 2019 John Collins  Change place of setting of $view_file
-##                           Make fully consistent set of options for engines:
-##                               -latex, -latex=...,
-##                           preserving backward compatibility, and avoiding suprises. 
-## 11 Dec 2019 John Collins  Change rules for wrapping in log file: This deals
-##                             with xelatex wrapping at > standard number of
-##                             bytes in presence of non-ASCII Unicode characters.
-##  4 Dec 2019 John Collins  If there were missing subdirectories in output/aux
-##                           directories, and these were successfully created,
-##                           then ignore error from *latex, since rerun may
-##                           succeed.
-## 14 Nov 2019 John Collins  Add comment.
-## 12 Nov 2019 John Collins  Use $compiling_cmd, $warning_cmd, $success_cmd
-#                            on normal make, rather than just in -pvc mode.
-##  5 Aug 2019 John Collins  The changing of '\' to '/' in filenames is now
-##                             done for msys as well as MSWin32.
-##  8 Jul 2019 John Collins  Allow addition of hook for processing lists of
-##                             missing source files, used after run of *latex.
-##  2 Jul 2019 John Collins  Silence message about disallowing change of output
-##                            file type.
-##                           V. 4.66
-## 28 Jun 2019 John Collins  Try to deal with log file parsing problems
-##                           V. 4.65
-## 21 May 2019 John Collins  Fix incorrect listings by -rules and by -deps
-## 21 May 2019 John Collins  V. 4.64a.
-## 20,21 May 2019 John Collins Fix problem with not always running dvipdf,
-##                             dvips, xdvpdf because of missing information
-##                             on source files.  Do this by adding a
-##                             source_rule hash to each rule and adding a
-##                             pass-based criterion for out-of-dateness
-## 20 May 2019 John Collins  V. 4.64.
-## 17 Mar 2019 John Collins  V. 4.63c.
-## 18 Mar 2019 John Collins  Update copyright date
-## 17 Mar 2019 John Collins  Further test for problems when linking rules
-## 17 Mar 2019 John Collins  V. 4.63b.
-## 17 Mar 2019 John Collins  Fix problem revealed by bibtopic package
-## 15 Mar 2019 John Collins  Corrections
-## 14 Mar 2019 John Collins  Version to 4.63a
-## 12-14 Mar 2019 John Collins  Jobname has placeholder
-##  8-11 Mar 2019 John Collins  Correct aux-dir bugs 
-##  8 Mar 2019 John Collins  Version to 4.63
-##  1 Jan 2019 John Collins  Correct bug in output switching code
-## 31 Dec 2018 John Collins  Correct bug that with $cleanup_includes_generated
-##                              -c mode deletes final output files (e.g., .dvi, .pdf).
-## 13 Dec 2018 John Collins  Fixes, cleanup
-## 12 Dec 2018 John Collins  Fix rdb_read
-## 11 Dec 2018 John Collins  For output-switch: Reorganize initialization
-##                           Remove possibility of more than one primary.
-##  1 Dec 2018 John Collins  Clean up some code.
-## 30 Nov 2018 John Collins  Allow any characters in directory part of tex
-##                             filename when cd mode on.  (Still standard
-##                             set of disallowed characters applies basename.)
-## 21 Nov 2018 John Collins  Infrastructure finished, I think, for active flag
-##                           Start on output switch
-## 16 Nov 2018 John Collins  Remove in non-diagnostics mode a warning about
-##                             rule not in use in this session that is given
-##                             when reading an fdb_latexmk file.
-##  2 Nov 2018 John Collins  Start implementing active flag for rules.
-##  1 Nov 2018 John Collins  Fix finding of missing files that are relative to aux_dir
-## 29-31 Oct 2018 John Collins  Some cleanup.
-## 27,28 Oct 2018 John Collins  Fix bug that in -pvc mode, after an error in
-##                             certain rules, new rounds of compilation 
-##                             are triggered because of changes in generated
-##                             files, instead of only by later user-generated
-##                             changes.
-##                           Improve linking of rules.
-## 25 Oct 2018 John Collins  V. 4.62
-##                           Clean up can remove (empty) directories
-## 25 Oct 2018 John Collins  Fix definition of clean up substitution for %R
-##                             so that something with intermediate %R works,
-##                             as in 'pythontex-files-%R/*'.
 ##
-## 1998-2018, John Collins.  Many improvements and fixes.
-##   See CHANGE-log.txt for full list, and CHANGES for summary
+## 1998-2019, 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)
 ## Original script (RCS version 2.3) called "go" written by David J. Musliner
@@ -313,8 +179,8 @@
 
 $my_name = 'latexmk';
 $My_name = 'Latexmk';
-$version_num = '4.70b';
-$version_details = "$My_name, John Collins, 29 September 2020";
+$version_num = '4.72b';
+$version_details = "$My_name, John Collins, 15 April 2021";
 
 use Config;
 use File::Basename;
@@ -351,8 +217,9 @@
 use FileHandle;
 use File::Find;
 use List::Util qw( max );
-use Cwd;            # To be able to change cwd
-#use Cwd "chdir";    # Ensure $ENV{PWD}  tracks cwd.  NO NEED, and it messes up -cd -outdir=
+use Cwd;
+use Cwd "abs_path"; 
+use Cwd "chdir";    # Ensure $ENV{PWD}  tracks cwd.
 use Digest::MD5;
 
 #use strict;
@@ -414,6 +281,8 @@
 #        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:
+$normalize_names = 2;  # Strongest kind.
 
 ## Hash mapping file extension (w/o period, e.g., 'eps') to a single regexp,
 #  whose matching by a line in a file with that extension indicates that the 
@@ -539,7 +408,6 @@
     "-mltex                  enable MLTeX extensions such as \charsubdef",
     "-output-comment=STRING  use STRING for DVI file comment instead of date\n".
     "                           (no effect for PDF)",
-    "-output-format=FORMAT   use FORMAT for job output; FORMAT is `dvi\" or `pdf\"",
     "-parse-first-line       enable parsing of first line of input file",
     "-no-parse-first-line    disable parsing of first line of input file",
     "-progname=STRING        set program (and fmt) name to STRING",
@@ -621,6 +489,7 @@
     #-jobname=STRING         set the job name to STRING
     #-aux-directory=dir    Set the directory dir to which auxiliary files are written
     #-output-directory=DIR   use existing DIR as the directory to write files in
+    # "-output-format=FORMAT   use FORMAT for job output; FORMAT is `dvi\" or `pdf\"",
     #-quiet
     #-recorder               enable filename recorder
     #
@@ -659,12 +528,6 @@
 $biber  = 'biber %O %S';
 $bibtex  = 'bibtex %O %S';
 # Switch(es) to make biber & bibtex silent:
-$bibtex_fudge = 0; # Don't use hack to get bibtex working in old versions that
-                   #    don't handle output-directory.  When this version of
-                   #    latexmk is part of a distribution of TeX, the
-                   #    accompanying bibtex should also be recent enough
-                   #    (e.g., TeXLive 2019 or later, current MiKTeX) not to
-                   #    need the  hack/fudge.
 $biber_silent_switch  = '--onlylog';
 $bibtex_silent_switch  = '-terse';
 $bibtex_use = 1;   # Whether to actually run bibtex to update bbl files.
@@ -685,11 +548,23 @@
                    #
                    # In any event bibtex is only run if the log file
                    #   indicates that the document uses bbl files.
+$bibtex_fudge = 1; #  Whether or not to cd to aux dir when running bibtex.
+                   #  If the cd is not done, and bibtex is passed a
+                   #  filename with a path component, then it can easily
+                   #  happen that (a) bibtex refuses to write bbl and blg
+                   #  files to the aux directory, for security reasons,
+                   #  and/or (b) bibtex in pre-2019 versions fails to find
+                   #  some input file(s).  But in some other cases, the cd
+                   #  method fails. 
 
 ## Command to invoke makeindex
 $makeindex  = 'makeindex %O -o %D %S';
 # Switch(es) to make makeinex silent:
 $makeindex_silent_switch  = '-q';
+$makeindex_fudge = 1; # Whether or not to cd to aux dir when running makeindex.
+                      # Set to 1 to avoid security-related prohibition on
+                      # 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';
@@ -1548,13 +1423,14 @@
                     #       for source, %B for base of current rule,
                     #       %R for base of primary tex file, %T for
                     #       texfile name, %O for options,
+                    #       %V=$aux_dir, %W=$out_dir,
                     #       %Y for $aux_dir1, and %Z for $out_dir1
                     #     int_cmd specifies any internal command to be
                     #       used to implement the application of the
                     #       rule.  If this is present, it overrides
-                    #       the external command, and it is the
-                    #       responsibility of the perl subroutine
-                    #       specified in intcmd to execute the
+                    #       **direct** execution of the external command, and
+                    #       it is the responsibility of the perl subroutine
+                    #       specified in intcmd to execute the specified
                     #       external command if this is appropriate.
                     #       This variable intcmd is a reference to an array,  
                     #       $$intcmd[0] = internal routine
@@ -1776,7 +1652,7 @@
 }
 if ( $auto_rc_use ) { 
     # Rc file in current directory:
-    read_first_rc_file_in_list( "./latexmkrc", "./.latexmkrc" );
+    read_first_rc_file_in_list( ".latexmkrc", "latexmkrc" );
 }
 
 ## Process command line args.
@@ -1793,8 +1669,8 @@
   if ( /^-aux-directory=(.*)$/ || /^-auxdir=(.*)$/ ) {
       $aux_dir = $1;
   }
-  elsif (/^-bibfudge$/) { $bibtex_fudge = 1; }
-  elsif (/^-bibfudge-$/) { $bibtex_fudge = 0; }
+  elsif (/^-bib(tex|)fudge$/) { $bibtex_fudge = 1; }
+  elsif (/^-bib(tex|)fudge-$/) { $bibtex_fudge = 0; }
   elsif (/^-bibtex$/) { $bibtex_use = 2; }
   elsif (/^-bibtex-$/) { $bibtex_use = 0; }
   elsif (/^-nobibtex$/) { $bibtex_use = 0; }
@@ -1861,6 +1737,8 @@
      shift; 
   }
   elsif ( /^-MP$/ ) { $dependents_phony = 1; }
+  elsif (/^-(make|)indexfudge$/) { $makeindex_fudge = 1; }
+  elsif (/^-(make|)indexfudge-$/) { $makeindex_fudge = 0; }
   elsif ( /-MSWinBackSlash$/ ) { $MSWin_back_slash = 1; }
   elsif ( /-MSWinBackSlash-$/ ) { $MSWin_back_slash = 0; }
   elsif (/^-new-viewer$/) {
@@ -1873,10 +1751,26 @@
       $auto_rc_use = 0;
       # N.B. This has already been obeyed.
   }
-  elsif (/^-nobibfudge$/) { $bibtex_fudge = 0; }
+  elsif (/^-nobib(tex|)fudge$/) { $bibtex_fudge = 0; }
+  elsif (/^-no(make|)indexfudge$/) { $makeindex_fudge = 0; }
   elsif ( /^-output-directory=(.*)$/ ||/^-outdir=(.*)$/ ) {
       $out_dir = $1;
   }
+  elsif ( /^-output-format=(.*)$/ ) {
+      my $format = $1;
+      if ($format eq 'dvi' ) {
+          $dvi_mode = 1;
+          $pdf_mode = $postscript_mode = 0;
+      }
+      elsif ($format eq 'pdf' ) {
+          $pdf_mode = 1;
+          $dvi_mode = $postscript_mode = 0;
+      }
+      else {
+          warn "$My_name: unknown format in option '$_'\n";
+          $bad_options++;
+      }
+  }
   elsif (/^-p$/)     { $printout_mode = 1; 
                        $preview_continuous_mode = 0; # to avoid conflicts
                        $preview_mode = 0;  
@@ -2045,7 +1939,7 @@
       push @extra_xelatex_options, $original;
   }
   elsif (/^-/) {
-     warn "$My_name: $_ bad option\n"; 
+     warn "$My_name: $_ unknown option\n"; 
      $bad_options++;
   }
   else {
@@ -2083,8 +1977,6 @@
 #          3 log file **not** in aux_dir or out_dir, but in cwd.
 $where_log = -1;  
 
-&set_dirs_etc;
-
 if ($bibtex_use > 1) {
     push @generated_exts, 'bbl';
 }
@@ -2253,19 +2145,6 @@
 #   possible cd to the document directory, since the directories can be
 #   relative to the document.
 
-$q = $quote_filenames ? '"' : '';
-if ( $out_dir ) {
-    add_option( "-output-directory=$q$out_dir$q",
-                \$latex, \$pdflatex, \$lualatex, \$xelatex );
-}
-if ( $aux_dir && ($aux_dir ne $out_dir) ) {
-    # N.B. If $aux_dir and $out_dir are the same, then the -output-directory
-    # option is sufficient, especially because the -aux-directory exists
-    # only in MiKTeX, not in TeXLive.
-    add_option( "-aux-directory=$q$aux_dir$q",
-                \$latex, \$pdflatex, \$lualatex, \$xelatex );
-}
-
 if ( $jobname ne '' ) {
     # Since $jobname may include placeholder(s), put %R placeholder
     # in option, and let %R be substituted by actual jobname at runtime.
@@ -2467,6 +2346,8 @@
 # Deal with illegal and problematic characters in filename:
 test_fix_texnames( @file_list );
 
+$quote = $quote_filenames ? '"' : '';
+
 FILE:
 foreach $filename ( @file_list )
 {
@@ -2479,12 +2360,18 @@
     if ( $do_cd ) {
        ($filename, $path) = fileparse( $filename );
        warn "$My_name: Changing directory to '$path'\n"
-          if !$silent;
+           if !$silent;
        pushd( dirname_no_tail( $path ) );
     }
     else {
         $path = '';
     }
+    local $aux_dir = $aux_dir;
+    local $out_dir = $out_dir;
+    local $latex = $latex;
+    local $lualatex = $lualatex;
+    local $pdflatex = $pdflatex;
+    local $xelatex = $xelatex;
 
     # Ensure the output/auxiliary directories exist, if need be
     if ( $out_dir ) {
@@ -2516,7 +2403,31 @@
         }
     }
 
+    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:
     @default_includes = ($texfile_name, $aux_main);
     # N.B. Do **not** apply local %rule_db here.  It might appear appropriate,
@@ -2710,15 +2621,13 @@
             rdb_for_some( [keys %current_primaries], \&rdb_set_latex_deps );
         }
     }
-    foreach $rule ( &rdb_accessible ) {
-        # For all source files of all accessible rules, 
-        #    if the file data are not already set (e.g., from fdb_latexmk
-        #    file, set them from disk.
-        rdb_one_rule ($rule, undef, 
-                      sub{ if ( $$Ptime == 0) { &rdb_update1; } }
-        );
-    }
-
+    # At this point, we assume that the file database was correctly
+    # initialized from fdb_latexmk database (corresponding to the state at
+    # the end of the previous run of latexmk, if the fdb_latexmk file exists.
+    # PERHAPS if fdb_latexmk doesn't exist we ought to assume there was
+    # a previous run that completed, if the appropriate output files exist,
+    # so a new run of *latex etc isn't needed; then we should set the file
+    # data from the on-disk state.
     if ($go_mode) {
         # Force everything to be remade.
         rdb_recurse( [ &rdb_target_array], sub{$$Pout_of_date=1;}  );
@@ -2937,7 +2846,7 @@
         else {
             $ENV{$var} = $_ . $search_path_separator;
         }
-        if (!$silent) {
+        if ($diagnostics) {
             print "Set environment variable $var='$ENV{$var}'\n";
         }
     }
@@ -2946,18 +2855,27 @@
 #############################################################
 
 sub set_dirs_etc {
-    # Normalize versions terminating in directory/path separator
-    # and versions referring to current directory
-    # These actions in a subroutine so they can be used elsewhere.
+    # 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.
     $out_dir = dirname_no_tail( $out_dir );
     $aux_dir = dirname_no_tail( $aux_dir );
     $out_dir1 = $out_dir;
     $aux_dir1 = $aux_dir;
-    foreach ( $aux_dir1, $out_dir1 ) {
+    $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 ) {
         if ( ($_ ne '')  && ! m([\\/\:]$) ) {
+            # Add a trailing '/' if necessary to give a string that can be
+            # correctly concatenated with a filename:
             $_ .= '/';
         }
-        while ( s[^\.\/][] ) {}
     }
     if ($aux_dir) {
         # Ensure $aux_dir is in BIBINPUTS and TEXINPUTS search paths.
@@ -2970,9 +2888,31 @@
         # there is an error.  So cope with this situation (and any analogous
         # cases by adding the aux_dir to the relevant path search environment
         # variables.  BIBINPUTS seems to be the only one currently affected.
+        # Convert $aux_dir to absolute path to make the search path invariant
+        # under change of directory.
         foreach ( 'BIBINPUTS', 'TEXINPUTS' ) {
-            ensure_path( $_, $aux_dir );
+            ensure_path( $_, $aux_dir_abs );
         }
+        # 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.
+        # 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;
     }
 }
 
@@ -3179,6 +3119,7 @@
 #  over non-main generated files from other rules.
     local %from_rules_old = %from_rules;
     &rdb_cache_generated;
+    
     rdb_for_actives( 
         0,
         sub{ 
@@ -3194,7 +3135,7 @@
         }
         );
     rdb_for_actives( \&rdb_set_source_rules );
-#    &rdb_show;
+#    print "=========In rdb_make_links: rules\n"; &rdb_show;
 } # END rdb_make_links
 
 #************************************************************
@@ -3296,8 +3237,13 @@
 #************************************************************
 
 sub set_trivial_aux_fdb {
-    # 1. Write aux file EXACTLY as would be written if the tex file
-    #    had no cross references, etc. I.e., a minimal .aux file. 
+    # 1. Write aux file as would be written if the tex file had no cross
+    #    cross references, etc. i.e., a minimal .aux file, as would be
+    #    written by latex with a simple document.
+    #    That saves a run of latex on such simple documents.
+    #    Before about 2020, latex only wrote one line, containing '\relax '
+    #    in the aux file.  After that a reference to the last page was
+    #    added.  So now I write what is written for a one page document.
     # 2. Write a corresponding fdb file
     # 3. Provoke a run of *latex (actually of all primaries). 
 
@@ -3305,6 +3251,9 @@
     open( aux_file, '>', $aux_main )
         or die "Cannot write file '$aux_main'\n";
     print aux_file "\\relax \n";
+    # The following is added by recent versions of latex for a
+    # one page document
+    print aux_file "\\gdef \\\@abspage\@last{1}\n";
     close(aux_file);
 
     foreach my $rule (keys %possible_primaries ) { 
@@ -3807,8 +3756,10 @@
         return 1;
     }
     elsif ( open $RCH, "<$rc_file" ) {
-        { local $/; eval <$RCH>; }
+        my $code = '';
+        { local $/; $code = <$RCH>;}
         close $RCH;
+        eval $code;
     }
     else {
         warn "$My_name: I cannot read the rc-file '$rc_file'\n";
@@ -3998,8 +3949,8 @@
   "   -bibtex-cond  - use bibtex when needed, but only if the bib file exists\n",
   "   -bibtex-cond1 - use bibtex when needed, but only if the bib file exists;\n",
   "                   on cleanup delete bbl file only if bib file exists\n",
-  "   -bibfudge     - use change-directory fudge needed for old bibtexs\n",
-  "   -bibfudge-    - don't use change-directory fudge needed for old bibtexs\n",
+  "   -bibfudge or -bibtexfudge - change directory to output directory when running bibtex\n",
+  "   -bibfudge- or -bibtexfudge- - don't change directory when running bibtex\n",
   "   -bm <message> - Print message across the page when converting to postscript\n",
   "   -bi <intensity> - Set contrast or intensity of banner\n",
   "   -bs <scale> - Set scale for banner\n",
@@ -4033,6 +3984,8 @@
   "   -g-    - Turn off -g\n",
   "   -h     - print help\n",
   "   -help - print help\n",
+  "   -indexfudge or -makeindexfudge - change directory to output directory when running makeindex\n",
+  "   -indexfudge- or -makeindexfudge- - don't change directory when running makeindex\n",
   "   -jobname=STRING - set basename of output file(s) to STRING.\n",
   "            (Like --jobname=STRING on command line for many current\n",
   "            implementations of latex/pdflatex.)\n",
@@ -4050,6 +4003,8 @@
   "   -M     - Show list of dependent files after processing\n",
   "   -MF file - Specifies name of file to receives list dependent files\n",
   "   -MP    - List of dependent files includes phony target for each source file.\n",
+  "   -makeindexfudge - change directory to output directory when running makeindex\n",
+  "   -makeindexfudge-- don't change directory to output directory when running makeindex\n",
   "   -MSWinBackSlash  under MSWin use backslash (\\) for directory separators\n",
   "                    for filenames given to called programs\n",
   "   -MSWinBackSlash-  under MSWin use forward slash (/) for directory separators\n",
@@ -4057,11 +4012,16 @@
   "   -new-viewer    - in -pvc mode, always start a new viewer\n",
   "   -new-viewer-   - in -pvc mode, start a new viewer only if needed\n",
   "   -nobibtex      - never use bibtex\n",
-  "   -nobibfudge    - don't use change-directory fudge needed for old bibtexs\n",
+  "   -nobibfudge or -nobibtexfudge - don't change directory when running bibtex\n",
   "   -nodependents  - Do not show list of dependent files after processing\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",
   "                  - set name of directory for output files\n",
+  "   -output-format=FORMAT\n",
+  "                  - if FORMAT is dvi, turn on dvi output, turn off others\n",
+  "                  - if FORMAT is pdf, turn on pdf output, turn off others\n",
+  "                  - otherwise error\n",    
   "   -pdf   - generate pdf by pdflatex\n",
   "   -pdfdvi - generate pdf by dvipdf\n",
   "   -pdflatex=<program> - set program used for pdflatex.\n",
@@ -4337,7 +4297,11 @@
     my $return = 999;
     # Prevent changes we make to environment becoming global:
     local %ENV = %ENV;
+
     my ( $base, $path, $ext ) = fileparseA( $$Psource );
+    # Define source and dest base to include extension, no path.
+    my $source_base = $base.$ext;
+    my $dest_base = basename( $$Pdest );
     if ( $path && $bibtex_fudge ) {
         # Up to TeXLive 2018, the following was true; situation has changed since.
         #   When an output directory is specified and with a bibtex from 2018 or
@@ -4346,6 +4310,9 @@
         #   directory to the directory of the top-level .aux file to run bibtex.
         #   But we have to fix search paths for .bib and .bst, since they may be
         #   specified relative to the document directory.
+        # There is also another problem: Depending on the exact
+        #   specification of the aux dir, bibtex may refuse to write to the
+        #   aux dir, for security reasons.
         my $cwd = good_cwd();
         foreach ( 'BIBINPUTS', 'BSTINPUTS' ) {
             if ( exists $ENV{$_} ) {
@@ -4357,32 +4324,57 @@
         }
         pushd( $path );
         if (!$silent) {
-            print "$My_name: ==========WARNING:=================\n",
-                  "I am taking action to evade a bug/feature in older versions of bibtex\n",
-                  "This may give problems under some situations, symptomized by bibtex not\n",
-                 "finding a .bib file or an aux file.\n",
-                "Provided you have a recent version of bibtex (about 2019 or later) you\n",
-                "can avoid the problems by  putting '\$bibtex_fudge = 0;' in an\n",
-                "initialization file (a latexmrc file for $my_name.\n",
-                  "\n",
-                  "Here my bug-evading action:\n",
-                  "I temporarily changed directory to '$path'\n",
-                  "Set BIBINPUTS='$ENV{BIBINPUTS}'\n",
-                  "Set BSTINPUTS='$ENV{BSTINPUTS}'\n";
+            print "$My_name: Change directory to '$path'.\n",
+                  "To assist finding of files in document\n",
+                  "directory, I set\n",
+                  "  BIBINPUTS='$ENV{BIBINPUTS}'\n",
+                  "  BSTINPUTS='$ENV{BSTINPUTS}'.\n";
         }
-        $return = &Run_subst( undef, undef, '', $base.$ext, '', $base );
+        # Override standard substitutions for source, dest, and base names in
+        # default external command:
+        $return = &Run_subst( undef, undef, '', $source_base, $dest_base, $base );
         popd();
         if (!$silent) {
-            print "$My_name: changed directory back to '", cwd(), "'\n";
+            print "$My_name: Change directory back to '", cwd(), "'\n";
         }
     }
     else {
+        # Use default substitutions etc for rule:
         $return = Run_subst();
     }
     return $return;
-}
+} #END run_bibtex
 
+#**************************************************
 
+sub run_makeindex {
+    my $return = 999;
+    my ( $base, $path, $ext ) = fileparseA( $$Psource );
+
+    # Define source and dest base to include extension, no path.
+    my $source_base = $base.$ext;
+    my $dest_base = basename( $$Pdest );
+    if ( $path && $makeindex_fudge ) {
+        my $cwd = good_cwd();
+        pushd( $path );
+        if (!$silent) {
+            print "$My_name: Change directory to '$path'.\n";
+        }
+        # Override standard substitutions for source, dest, and base names in
+        # default external command:
+        $return = &Run_subst( undef, undef, '', $source_base, $dest_base, $base );
+        popd();
+        if (!$silent) {
+            print "$My_name: Change directory back to '", cwd(), "'\n";
+        }
+    }
+    else {
+        # Use default substitutions etc for rule:
+        $return = Run_subst();
+    }
+    return $return;
+} #END run_makeindex
+
 #**************************************************
 
 sub check_bibtex_log {
@@ -4423,7 +4415,6 @@
     }
     close $blg_file;
     my $missing = $missing_citations + $#missing_aux + 1;
-
     if ( $#missing_aux > -1 ) {
         # Need to make the missing files.
         warn "$My_name: One or more aux files is missing for bibtex. I'll try\n",
@@ -4453,17 +4444,15 @@
 
 sub normalize_force_directory {
     #  Usage, normalize_force_directory( dir, filename )
+    #  Filename is assumed to be relative to dir (terminated with directory separator).
     #  Perform the following operations:
     #    Clean filename
-    #    If filename contains no path component, insert dir in front
+    #    Prefix filename with dir
     #    Normalize filename
     #  Return result
-    my $default_dir = $_[0];
+    my $dir = $_[0];
     my $filename = clean_filename( $_[1] );
-    my ($base_name, $path ) = fileparse( $filename );
-    if ( $base_name eq $filename ) {
-       $filename = "$default_dir$filename";
-    }
+    $filename = "$dir$filename";
     return normalize_filename( $filename );
 } #END normalize force_directory
 
@@ -4595,22 +4584,6 @@
 #    print "==== Cusdep to-exts:"; foreach (keys %cusdep_to) {print " '$_'";} print "\n";
 
 
-    # Filenames given in log file may be preceded by a pathname
-    #   denoting current directory.  In MiKTeX, this is an absolute
-    #   pathname; in TeXLive, it is './'. Either way, we'll want to
-    #   remove this pathname string --- see the comments in sub
-    #   rdb_set_latex_deps.  In order of reliability for use in
-    #   normalizing filenames from the log file, the following forms
-    #   of the cwd are used:
-    # (a) internally deduced pwd from log file from sequence of lines
-    #                  **file
-    #                  (dir/file
-    #     if possible.  NO THAT'S WRONG if kpsearch is done.
-    # (b) from PWD line in fls file (if available), passed as $pwd_latex
-    # (c) system-given cwd as interpreted by sub good_cwd.
-    # We'll put the first two in  @pwd_log
-    my @pwd_log = ();
-    if ($pwd_latex) { push @pwd_log, $pwd_latex; }
 
     # $primary_out is actual output file (dvi or pdf)
     # It is initialized before the call to this routine, to ensure
@@ -4851,6 +4824,8 @@
             # \openout followed by filename followed by line end.
             # pdflatex and xelatex quote it and wrap,
             # lualatex leaves filename as is, and doesn't wrap.
+            # Filename is always relative to aux_dir, given standard security
+            # settings in TeXLive.
             my $cand = $1;
             if ( $cand =~ /\`\"([^\'\"]+)\"\'\.$/ ) {
                 # One form of quoting by pdflatex, xelatex: `"..."'.
@@ -4864,7 +4839,7 @@
                 # Bad quotes: e.g., incomplete wrapped line
                 next LINE;
             }
-            $generated_log{normalize_force_directory( $aux_dir1, $cand )} = 1;
+            $generated_log{ normalize_force_directory($aux_dir1, $cand) } = 1;
             next LINE;
         }
         # Test for conversion produced by package:
@@ -4903,7 +4878,7 @@
             $idx_file =~ s/\s*$//;
                 #  When *latex is run with an -output-directory 
                 #    or an -aux_directory, the file name does not contain
-                #    the output path; fix this, after removing quotes:
+                #    the path. Fix this:
             $idx_file = normalize_force_directory( $aux_dir1, $idx_file );
             my ($idx_base, $idx_path, $idx_ext) = fileparseA( $idx_file );
             $idx_base = $idx_path.$idx_base;
@@ -4928,10 +4903,10 @@
             next LINE;
         }
         elsif ( /^No file (.*?\.bbl)./ ) {
-            my $bbl_file = normalize_force_directory( $aux_dir1, $1);
-            my $aux_file = $bbl_file;
-            $aux_file =~ s/\.bbl$/\.aux/;
-            warn "$My_name: Non-existent bbl file '$bbl_file in line'\n $_\n";
+            # Filename is always relative to aux_dir, given standard security
+            # settings in TeXLive.
+            my $bbl_file = normalize_force_directory( $aux_dir1, $1 );
+            warn "$My_name: Missing bbl file '$bbl_file' in following:\n $_\n";
             $dependents{$bbl_file} = 0;
             push @bbl_files, $bbl_file;
             next LINE;
@@ -4939,11 +4914,11 @@
         foreach my $pattern (@file_not_found) {
             if ( /$pattern/ ) {
                 my $file = clean_filename($1);
-                warn "$My_name: Missing input file: '$file' from line\n  '$_'\n"
+                warn "$My_name: Missing input file: '$file' from following:\n  '$_'\n"
                     unless $silent;
                 $dependents{normalize_filename($file, @pwd_log)} = 0;
                 my $file1 = $file;
-                if ( $aux_dir ) {
+                if ( $aux_dir && ($aux_dir ne '.') ) {
                     # Allow for the possibility that latex generated
                     # a file in $aux_dir, from which the missing file can
                     # be created by a cusdep (or other) rule that puts
@@ -4955,8 +4930,6 @@
                     # relative to the aux_dir, so allow for that as well
                     my $file1 = normalize_force_directory( $aux_dir1, $file );
                     $dependents{$file1} = 0;
-                    $dependents{$aux_dir1.$file} = 0;
-                    
                 }
                 next LINE;
             }
@@ -5147,6 +5120,7 @@
                 next INCLUDE_NAME;
             }
             $include_name = normalize_filename( $include_name, @pwd_log );
+            if ( ! defined $include_name )  { next INCLUDE_NAME; }
             my ($base, $path, $ext) = fileparseB( $include_name );
             if ( ($path eq './') || ($path eq '.\\') ) {
                 $include_name = $base.$ext;
@@ -5434,6 +5408,11 @@
     if ( ! open ($fls_file, "<$fls_name") ) {
         return 1;
     }
+
+    my $pdf_base = basename($pdf_name);
+    my $log_base = basename($log_name);
+    my $out_base = basename($$Pdest);
+
     foreach $_ ( <$fls_file> ) {
         # Remove trailing CR and LF. Thus we get correct behavior when an fls file
         #  is produced by MS-Windows program (e.g., in MiKTeX) with CRLF line ends,
@@ -5441,12 +5420,15 @@
         #  in read-in lines):
         $_ =~ s/[\n\r]*$//;
         if (/^\s*PWD\s+(.*)$/) {
-            $cwd = $1;
-            $$Ppwd_latex = $cwd;
-            if ( $cwd =~ /\"/ ) {
+            my $cwd_fls = $1;
+            $$Ppwd_latex = $cwd_fls;
+            if ( $cwd_fls =~ /\"/ ) {
                 warn "$My_name: The working directory has a '\"' character in its name:\n",
                      "  '$cwd'\n  This can cause me trouble. Beware!\n";
             }
+            if ( normalize_filename($cwd_fls) ne normalize_filename($cwd) ) {
+                print "$My_name: ============== Inequiv cwd_fls cwd '$cwd_fls' '$cwd'\n";
+            }
         }
         elsif (/^\s*INPUT\s+(.*)$/) {
             # Take precautions against aliasing of foo, ./foo and other possibilities for cwd.
@@ -5463,7 +5445,34 @@
             if ( (exists $$Poutputs{$file}) && (! exists $$Pinputs{$file}) ) {
                 $$Pfirst_read_after_write{$file} = 1;
             }
-            $$Pinputs{$file} = 1;
+            # Take precautions against main destination file being listed as INPUT file
+            # This results, e.g., from hyperxmp (2020/10/05 v. 5.6) reading the pdf file
+            # size, and triggers an infinite loop, unless we omit the pdf file from the 
+            # list of input files.  (Hyperxmp v. 5.7 2010/11/01 doesn't give this problem.)
+            # There's a related issue with the log file, when acmart.cls is used with
+            # xelatex.  (I don't work out what causes this, e.g., what package.)
+            # Test on basenames rather than full name to evade in a simple-minded way
+            # alias issues with the directory part.
+            if ( basename($file) eq $pdf_base ) {
+                warn "$My_name: !!!!!!!!!!! Fls file lists main pdf **output** file as an input\n",
+                     "   file for rule '$rule'. I won't treat as a source file, since that leads\n",
+                     "   to an infinite loop.\n",
+                    "    This can be caused by the hyperxmp package in an old version.\n",
+                    "    You should update to hyperxmp in ver. 5.7 or higher\n";
+            } elsif ( basename($file) eq $out_base ) {
+                warn "$My_name: !!!!!!!!!!! Fls file lists main **output** file as an input\n",
+                     "   file for rule '$rule'. I won't treat as a source file, since that leads\n",
+                     "   to an infinite loop.\n",
+                    "    This can be caused by the hyperxmp package in an old version.\n",
+                    "    You should update to hyperxmp in ver. 5.7 or higher\n";
+            } elsif ( basename($file) eq $log_base ) {
+                warn "$My_name: !!!!!!!!!!! Fls file lists log file as an input\n",
+                     "   file for rule '$rule'. I won't treat it as a source file, since\n",
+                    "   there appear to be no good uses for it.\n",
+                    "   This behavior happens at least under acmart.cls with xelatex\n";
+            } else {
+                $$Pinputs{$file} = 1;
+            }
         }
         elsif (/^\s*OUTPUT\s+(.*)$/) {
             # Take precautions against aliasing of foo, ./foo and other possibilities for cwd.
@@ -5481,7 +5490,6 @@
 
 sub dirname_no_tail {
     my $dirname = $_[0];
-#    print "DNT1 = '$dirname'\n";
     foreach ($dirname) {
         # Normalize name to use / to separate directory components:
         #   (Note both / and \ are allowed under MSWin.)
@@ -5497,7 +5505,6 @@
             }
         }
     }
-#    print "DNT2 = '$dirname'\n";
     return $dirname;
 }
 
@@ -5525,28 +5532,44 @@
 sub normalize_filename {
    # Usage: normalize_filename( filename [, extra forms of name of cwd] )
    # Returns filename with removal of various forms for cwd, and
-   # with conversion of directory separator to '/' only
+   # with conversion of directory separator to '/' only.
+   # Works also when filename is name of a directory.
    #
    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, $file,  @dirs) {
+   foreach ($cwd, $cwd1, $file,  @dirs) {
        s(\\)(/)g;
        $_ = dirname_no_tail( $_ );
    }
+   if ($filename eq '.') { $filename = ''; }
    # 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 ) {
+   foreach my $dir ( @dirs, '.', $cwd, $cwd1 ) {
        if ( $dir =~ /^\s*$/ ) {
+           # All spaces, nothing to do.
            next;
        }
+       if ($file eq $dir) {
+           # Filename equals cwd, so it is . relative to cwd:
+           $file = '.';
+           last;
+       }
        if ( $file =~ s(^\Q$dir\E/)() ) {
            last;
      }
    }
+   if ($file eq '.' ) {
+       # This only occurs for a directory that is the cwd.
+       # Our convention is always to replace this by a blank.
+       # Watch out for tests of existence that will go wrong,
+       # and for a form for concatenating this with a filename.
+       $file = '';
+   }
    return $file;
 }
 
@@ -5556,7 +5579,7 @@
    # Usage: normalize_clean_filename( filename [, extra forms of name of cwd] )
    # Same as normalize_filename, but first remove any double quotes, as
    # done by clean_filename, which is appropriate for filenames from log file.
-    my ($file, @dirs) = @_;
+    my ($file, @dirs) = shift;
     return normalize_filename( clean_filename( $file ) , @dirs );
 }
 
@@ -5934,6 +5957,7 @@
                 if ($rule =~ /^makeindex/) { $PA_extra_gen = [ "$base.ilg" ]; }
                 if ($rule =~ /^(bibtex|biber)/) { $PA_extra_gen = [ "$base.blg" ]; }
                 if ($rule =~ /^bibtex/) { $int_cmd = "run_bibtex"; }
+                if ($rule =~ /^makeindex/) { $int_cmd = "run_makeindex"; }
                 warn "$My_name: File-database '$in_name': setting rule '$rule'\n"
                    if $diagnostics;
                 my $cmd_type = 'external';
@@ -5972,7 +5996,6 @@
             my $size = $3;
             my $md5 = $4;
             my $from_rule = $5;
-#??            print "  --- File '$file'\n";
             if ($state != 1) {
                 warn "$My_name: In file-database '$in_name' ",
                      "line $. is outside a section:\n   '$_'\n";
@@ -6425,7 +6448,7 @@
         if ( ! rdb_rule_exists( $from_rule ) ){
             print "!!!===Creating rule '$from_rule': '$ind_file' from '$idx_file'\n"
                   if ($diagnostics);
-            rdb_create_rule( $from_rule, 'external', $makeindex, '', 1, 
+            rdb_create_rule( $from_rule, 'external', $makeindex, 'run_makeindex', 1, 
                              $idx_file, $ind_file, $ind_base, 1, 0, 0, 1, [ "$ind_base.ilg" ] );
             print "  ===Source file '$ind_file' for '$rule'\n"
                   if ($diagnostics);
@@ -6959,10 +6982,9 @@
     if ( (! -e $file) && $use_make_for_missing_files ) {
         # Try to make the missing file
         #Set character to surround filenames in commands:
-        my $q = $quote_filenames ? '"' : '';
         if ( $toext ne '' ) {
              print "$My_name: '$rule': source file '$file' doesn't exist. I'll try making it...\n";
-             &Run_subst( "$make $q$file$q" );
+             &Run_subst( "$make $quote$file$quote" );
              if ( -e $file ) {
                  return;
              }
@@ -6972,7 +6994,7 @@
                    "   I'll try making it with allowed extensions \n";
              foreach my $try_ext ( keys %$Pinput_extensions ) {
                  my $new_dest = "$file.$try_ext";
-                 &Run_subst( "$make $q$new_dest$q" );
+                 &Run_subst( "$make $quote$new_dest$quote" );
                  if ( -e $new_dest ) {
                      print "SUCCESS in making '$new_dest'\n";
                      # Put file in rule, without a from_rule, but
@@ -7763,7 +7785,7 @@
 
 
 sub rdb_run1 {
-    # Assumes contexts for: rule.
+    # Assumes context for: rule.
     # Unconditionally apply the rule
     # Returns return code from applying the rule.
     # Otherwise: 0 on other kind of success, 
@@ -7790,7 +7812,8 @@
         if ( ! defined $_ ) { $_ = 'undef'; }
     }
     if ($int_cmd) {
-        print "For rule '$rule', running '\&$int_cmd( @int_args_for_printing )' ...\n";
+        print "For rule '$rule', use internal command '\&$int_cmd( @int_args_for_printing )' ...\n"
+            if $diagnostics;
         $return = &$int_cmd( @int_args ); 
     }
     elsif ($$Pext_cmd) {
@@ -7976,7 +7999,8 @@
     #    options, source, dest, base: correspond to placeholders.
     # Substitutions:
     #    %S=source, %D=dest, %B=base, %R=root=base for latex, %O=options, 
-    #    %T=texfile, %Y=$aux_dir1, %Z=$out_dir1
+    #    %T=texfile,
+    #    %V=$aux_dir, %W=$out_dir, %Y=$aux_dir1, %Z=$out_dir1
     # This is a globally usable subroutine, and works in a rule context,
     #    and outside.
     # Defaults:
@@ -8001,24 +8025,24 @@
     }
 
     #Set character to surround filenames:
-    my $q = $quote_filenames ? '"' : '';
-
     my %subst = ( 
-       '%A' => $q.$tex_basename.$q,
-       '%B' => $q.$base.$q,
-       '%D' => $q.$dest.$q,
+       '%A' => $quote.$tex_basename.$quote,
+       '%B' => $quote.$base.$quote,
+       '%D' => $quote.$dest.$quote,
        '%O' => $options,
-       '%S' => $q.$source.$q,
-       '%R' => $q.$root_filename.$q,
-       '%S' => $q.$source.$q,
-       '%T' => $q.$texfile_name.$q,
-       '%Y' => $q.$aux_dir1.$q,
-       '%Z' => $q.$out_dir1.$q,
+       '%S' => $quote.$source.$quote,
+       '%R' => $quote.$root_filename.$quote,
+       '%S' => $quote.$source.$quote,
+       '%T' => $quote.$texfile_name.$quote,
+       '%V' => $quote.$aux_dir.$quote,
+       '%W' => $quote.$out_dir.$quote,
+       '%Y' => $quote.$aux_dir1.$quote,
+       '%Z' => $quote.$out_dir1.$quote,
        '%%' => '%'         # To allow literal %B, %R, etc, by %%B.
         );
     if ($pre_tex_code) {
-        $subst{'%U'} = $q.$pre_tex_code.$q;
-        $subst{'%P'} = "$q$pre_tex_code\\input{$source}$q";
+        $subst{'%U'} = $quote.$pre_tex_code.$quote;
+        $subst{'%P'} = "$quote$pre_tex_code\\input{$source}$quote";
     }
     else {
         $subst{'%U'} = '';
@@ -8594,7 +8618,6 @@
 #===== Accesses rule part of database structure =======
 
     local ( $rule, $rule_act1, $file_act, $rule_act2 ) = @_;
-#??    &R1;
     if ( (! $rule) || ! rdb_rule_exists($rule) ) { return; }
 
     local ( $PArule_data, $PHsource, $PHdest, $PHsource_rules ) = @{$rule_db{$rule}};
@@ -8608,7 +8631,6 @@
     &$rule_act1 if $rule_act1;
     &rdb_do_files( $file_act ) if $file_act;
     &$rule_act2 if $rule_act2;
-#??    &R2;
 } #END rdb_one_rule
 
 #************************************************************
@@ -8671,7 +8693,6 @@
     # Assumes $rule context set.
 #===== Accesses file part of database structure =======
     local ($file, $file_act) = @_;
-#??    &F1;
     if ( (!$file) ||(!exists ${$PHsource}{$file}) ) { return; }
     local $PAfile_data = ${$PHsource}{$file};
     local ($Ptime, $Psize, $Pmd5, $Pfrom_rule, $Pcorrect_after_primary ) 
@@ -8680,7 +8701,6 @@
     if ( ! rdb_rule_exists( $$Pfrom_rule ) ) {
         $$Pfrom_rule = '';
     }
-#??    &F2;
 } #END rdb_one_file
 
 #************************************************************
@@ -9354,7 +9374,6 @@
         else { return( $name, 1 );}
     }
     foreach my $dir ( @path ) {
-        #??print "-------------dir='$dir',  ";
         # Make $dir concatenatable, and empty for current dir:
         if ( $dir eq '.' ) { 
             $dir = ''; 
@@ -9366,7 +9385,6 @@
             #Append directory separator only to non-empty dir
             $dir = "$dir/"; 
         }
-        #?? print " newdir='$dir'\n";
         if (-e "$dir$name") {
             return("$dir$name", 0);
         }
@@ -9417,8 +9435,6 @@
     }
   }
   @$ref_output = @return_list;
-#??  show_array( " Output", @$ref_output );
-#??  foreach (@$ref_output) { if ( /\/\// ) {  print " ====== double slash in  '$_'\n"; }  }
   return @not_found;
 } #END find_file_list1
 
@@ -10021,10 +10037,12 @@
 
 sub find_process_id {
 # find_process_id(string) finds id of process containing string and
-# being run by the present user.  Typically the string will be the
-# name of the process or part of its command line.
+# being run by the present user.  In all the uses in latexmk, the string is
+# the name of a file that is expected to be on the command line.
+#
 # On success, this subroutine returns the process ID.
 # On failure, it returns 0.
+#
 # This subroutine only works on UNIX systems at the moment.
 
     if ( $pid_position < 0 ) {
@@ -10079,7 +10097,7 @@
     # that the result can be used for input to MSWin programs as well
     # as cygwin programs.
     # Similarly for msys.
-    my $cwd = cwd();
+    my $cwd = getcwd();
     if ( $^O eq "cygwin" ) {
         my $cmd = "cygpath -w \"$cwd\"";
         my $Win_cwd = `$cmd`;
@@ -10099,6 +10117,10 @@
     elsif ( $^O eq "msys" ) {
         $cwd =~ s[^/([a-z])/][\u$1:/];
     }
+    # Normalized
+    if ($normalize_names) {
+        $cwd = abs_path($cwd);
+    }
     $cache{cwd} = $cwd;
 }  # END cache_good_cwd
 



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