-
Notifications
You must be signed in to change notification settings - Fork 3
/
latexmk.pl
executable file
·6625 lines (6013 loc) · 250 KB
/
latexmk.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env perl
# 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 (pdf)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 bst and 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
$my_name = 'latexmk';
$My_name = 'Latexmk';
$version_num = '4.13a';
$version_details = "$My_name, John Collins, 16 January 2010";
use Config;
use File::Copy;
use File::Basename;
use FileHandle;
use File::Find;
use Cwd; # To be able to change cwd
use Cwd "chdir"; # Ensure $ENV{PWD} tracks cwd
use Digest;
#use strict;
# The following variables are assigned once and then used in symbolic
# references, so we need to avoid warnings 'name used only once':
use vars qw( $dvi_update_command $ps_update_command $pdf_update_command );
# Translation of signal names to numbers and vv:
%signo = ();
@signame = ();
if ( defined $Config{sig_name} ) {
$i = 0;
foreach $name (split(' ', $Config{sig_name})) {
$signo{$name} = $i;
$signame[$i] = $name;
$i++;
}
}
else {
warn "Something wrong with the perl configuration: No signals?\n";
}
## Copyright John Collins 1998-2010
## (username collins at node phys.psu.edu)
## (and thanks to David Coppit (username david at node coppit.org)
## for suggestions)
## Copyright Evan McLean
## (modifications up to version 2)
## Copyright 1992 by David J. Musliner and The University of Michigan.
## (original version)
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
##
##
##
## 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 25 Nov 2009 onwards in detail
##
## 16 Jan 2010, John Collins V. 4.13a.
## Correct bug in deleting extra files (I wasn't
## consistent about periods in file extensions)
## Delete unused subroutines
## 13 Jan 2010, John Collins V. 4.13
## 27 Dec 2009, John Collins Correct position of inserting bbl into list
## of generated extensions.
## Correct clean_up. It stopped deleting aux
## file.
## $bibtex_use defaults to 1.
## 15 Dec 2009, John Collins Option not to do bibtex
## (to allow for case that bbl files
## are available, but no bibtex).
## 27 Nov 2009, John Collins Solve problem that changes in \include
## files weren't reflected in changes
## in bibtex source files.
## Remove excess recalculations of md5 in
## startup and when initializing rule
## from fdb_latexmk file.
## Fdb_latexmk now has data for all rules
## need for making target files,
## not just rules accessible from primary
## rules.
## 26 Nov 2009, John Collins In testing for changes, when filetime
## has changed, but file is unchanged,
## update filetime in rule.
## This saves excessive md5 calculations.
## 25 Nov 2009, John Collins Fixed issue with fdb_get and 1-second
## granularity of file timestamps.
## The issue was that if runs of
## latex (etc) occur within the
## 1-second time granularity, file
## contents can change even though
## the file's time and size are
## unchanged, falsifying an
## assumption made by fdb_get, but
## only when the old time is the
## same as the run time of a command
## that uses the file.
## Avoided excess md5 calculations at
## startup.
##
## 1998-2009, John Collins. Many improvements and fixes.
## See CHANGE-log.txt for full list, and CHANGES for summary
##
## Modified by Evan McLean (no longer available for support)
## Original script (RCS version 2.3) called "go" written by David J. Musliner
##
## 2.0 - Final release, no enhancements. LatexMk is no longer supported
## by the author.
## 1.9 - Fixed bug that was introduced in 1.8 with path name fix.
## - Fixed buglet in man page.
## 1.8 - Add not about announcement mailling list above.
## - Added texput.dvi and texput.aux to files deleted with -c and/or
## the -C options.
## - Added landscape mode (-l option and a bunch of RC variables).
## - Added sensing of "\epsfig{file=...}" forms in dependency generation.
## - Fixed path names when specified tex file is not in the current
## directory.
## - Fixed combined use of -pvc and -s options.
## - Fixed a bunch of speling errors in the source. :-)
## - Fixed bugs in xdvi patches in contrib directory.
## 1.7 - Fixed -pvc continuous viewing to reattach to pre-existing
## process correctly.
## - Added $pscmd to allow changing process grepping for different
## systems.
## 1.6 - Fixed buglet in help message
## - Fixed bugs in detection of input and include files.
## 1.5 - Removed test message I accidentally left in version 1.4
## - Made dvips use -o option instead of stdout redirection as some
## people had problems with dvips not going to stdout by default.
## - Fixed bug in input and include file detection
## - Fixed dependency resolution process so it detects new .toc file
## and makeindex files properly.
## - Added dvi and postscript filtering options -dF and -pF.
## - Added -v version commmand.
## 1.4 - Fixed bug in -pvc option.
## - Made "-F" option include non-existant file in the dependency list.
## (RC variable: $force_include_mode)
## - Added .lot and .lof files to clean up list of extensions.
## - Added file "texput.log" to list of files to clean for -c.
## - LatexMk now handles file names in a similar fashion to latex.
## The ".tex" extension is no longer enforced.
## - Added $texfile_search RC variable to look for default files.
## - Fixed \input and \include so they add ".tex" extension if necessary.
## - Allow intermixing of file names and options.
## - Added "-d" and banner options (-bm, -bs, and -bi).
## (RC variables: $banner, $banner_message, $banner_scale,
## $banner_intensity, $tmpdir)
## - Fixed "-r" option to detect an command line syntax errors better.
## 1.3 - Added "-F" option, patch supplied by Patrick van der Smagt.
## 1.2 - Added "-C" option.
## - Added $clean_ext and $clean_full_ext variables for RC files.
## - Added custom dependency generation capabilities.
## - Added command line and variable to specify custom RC file.
## - Added reading of rc file in current directly.
## 1.1 - Fixed bug where Dependency file generation header is printed
## rependatively.
## - Fixed bug where TEXINPUTS path is searched for file that was
## specified with absolute an pathname.
## 1.0 - Ripped from script by David J. Musliner (RCS version 2.3) called "go"
## - Fixed a couple of file naming bugs
## e.g. when calling latex, left the ".tex" extension off the end
## of the file name which could do some interesting things
## with some file names.
## - Redirected output of dvips. My version of dvips was a filter.
## - Cleaned up the rc file mumbo jumbo and created a dependency file
## instead. Include dependencies are always searched for if a
## dependency file doesn't exist. The -i option regenerates the
## dependency file.
## Getting rid of the rc file stuff also gave the advantage of
## not being restricted to one tex file per directory.
## - Can specify multiple files on the command line or no files
## on the command line.
## - Removed lpr options stuff. I would guess that generally,
## you always use the same options in which case they can
## be set up from an rc file with the $lpr variable.
## - Removed the dviselect stuff. If I ever get time (or money :-) )
## I might put it back in if I find myself needing it or people
## express interest in it.
## - Made it possible to view dvi or postscript file automatically
## depending on if -ps option selected.
## - Made specification of dvi file viewer seperate for -pv and -pvc
## options.
##-----------------------------------------------------------------------
## Explicit exit codes:
## 10 = bad command line arguments
## 11 = file specified on command line not found
## or other file not found
## 12 = failure in some part of making files
## 13 = error in initialization file
## 20 = probable bug
## or retcode from called program.
#Line length in log file that indicates wrapping.
# This number EXCLUDES line-end characters, and is one-based
# It is the parameter max_print_line in the TeX program. (tex.web)
$log_wrap = 79;
#########################################################################
## Default parsing and file-handling settings
## Array of reg-exps for patterns in log-file for file-not-found
## Each item is the string in a regexp, without the enclosing slashes.
## First parenthesized part is the filename.
## Note the need to quote slashes and single right quotes to make them
## appear in the regexp.
## Add items by push, e.g.,
## push @file_not_found, '^No data file found `([^\\\']*)\\\'';
## will give match to line starting "No data file found `filename'"
@file_not_found = (
'^No file\\s*(.*)\\.$',
'^\\! LaTeX Error: File `([^\\\']*)\\\' not found\\.',
'.*?:\\d*: LaTeX Error: File `([^\\\']*)\\\' not found\\.',
'^LaTeX Warning: File `([^\\\']*)\\\' not found',
'^Package .* [fF]ile `([^\\\']*)\\\' not found',
'Error: pdflatex \(file ([^\)]*)\): cannot find image file',
);
## 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
# line is to be ignored in the calculation of the hash number (md5 checksum)
# for the file. Typically used for ignoring datestamps in testing whether
# a file has changed.
# Add items e.g., by
# $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: ';
# This makes the hash calculation for an eps file ignore lines starting with
# '%%CreationDate: '
# ?? Note that a file will be considered changed if
# (a) its size changes
# or (b) its hash changes
# So it is useful to ignore lines in the hash calculation only if they
# are of a fixed size (as with a date/time stamp).
%hash_calc_ignore_pattern =();
#########################################################################
## Default document processing programs, and related settings,
## These are mostly the same on all systems.
## Most of these variables represents the external command needed to
## perform a certain action. Some represent switches.
## Commands to invoke latex, pdflatex
$latex = 'latex %O %S';
$pdflatex = 'pdflatex %O %S';
## Switch(es) to make them silent:
$latex_silent_switch = '-interaction=batchmode';
$pdflatex_silent_switch = '-interaction=batchmode';
# %input_extensions maps primary_rule_name to pointer to hash of file extensions
# used for extensionless files specified in the source file by constructs
# like \input{file} \includegraphics{file}
# Could write
#%input_extensions = ( 'latex' => { 'tex' => 1, 'eps' => 1 };,
# 'pdflatex' => { 'tex' => 1, 'pdf' => 1, 'jpg' => 1, 'png' => 1 }; );
# Instead we'll exercise the user-friendly access routines:
add_input_ext( 'latex', 'tex', 'eps' );
add_input_ext( 'pdflatex', 'tex', 'jpg', 'pdf' );
#show_input_ext( 'latex' ); show_input_ext( 'pdflatex' );
## Command to invoke bibtex
$bibtex = 'bibtex %O %B';
# Switch(es) to make bibtex silent:
$bibtex_silent_switch = '-terse';
$bibtex_use = 1; # Whether to actually run bibtex to update bbl files
# 0: Never run bibtex
# 1: Run bibtex only if the bibfiles exists
# according to kpsewhich, and the bbl files
# appear to be out-of-date
# 2: Run bibtex when the bbl files are out-of-date
# In any event bibtex is only run if the log file
# indicates that the document uses bbl files.
## Command to invoke makeindex
$makeindex = 'makeindex %O -o %D %S';
# Switch(es) to make makeinex silent:
$makeindex_silent_switch = '-q';
## Command to convert dvi file to pdf file directly:
$dvipdf = 'dvipdf %O %S %D';
## Command to convert dvi file to ps file:
$dvips = 'dvips %O -o %D %S';
## Command to convert dvi file to ps file in landscape format:
$dvips_landscape = 'dvips -tlandscape %O -o %D %S';
# Switch(es) to get dvips to make ps file suitable for conversion to good pdf:
# (If this is not used, ps file and hence pdf file contains bitmap fonts
# (type 3), which look horrible under acroread. An appropriate switch
# ensures type 1 fonts are generated. You can put this switch in the
# dvips command if you prefer.)
$dvips_pdf_switch = '-P pdf';
# Switch(es) to make dvips silent:
$dvips_silent_switch = '-q';
## Command to convert ps file to pdf file:
$ps2pdf = 'ps2pdf %O %S %D';
## Command to search for tex-related files
$kpsewhich = 'kpsewhich %S';
##Printing:
$print_type = 'ps'; # When printing, print the postscript file.
# Possible values: 'dvi', 'ps', 'pdf', 'none'
## Which treatment of default extensions and filenames with
## multiple extensions is used, for given filename on
## tex/latex's command line? See sub find_basename for the
## possibilities.
## Current tex's treat extensions like UNIX teTeX:
$extension_treatment = 'unix';
$dvi_update_signal = undef;
$ps_update_signal = undef;
$pdf_update_signal = undef;
$dvi_update_command = undef;
$ps_update_command = undef;
$pdf_update_command = undef;
$new_viewer_always = 0; # If 1, always open a new viewer in pvc mode.
# If 0, only open a new viewer if no previous
# viewer for the same file is detected.
$quote_filenames = 1; # Quote filenames in external commands
#########################################################################
################################################################
## Special variables for system-dependent fudges, etc.
$log_file_binary = 0; # Whether to treat log file as binary
# Normally not, since the log file SHOULD be pure text.
# But Miktex 2.7 sometimes puts binary characters
# in it. (Typically in construct \OML ... after
# overfull box with mathmode.)
# Sometimes there is ctrl/Z, which is not only non-text,
# but is end-of-file marker for MS-Win in text mode.
$MSWin_fudge_break = 1; # Give special treatment to ctrl/C and ctrl/break
# in -pvc mode under MSWin
# Under MSWin32 (at least with perl 5.8 and WinXP)
# when latemk is running another program, and the
# user gives ctrl/C or ctrl/break, to stop the
# daughter program, not only does it reach
# the daughter, but also latexmk/perl, so
# latexmk is stopped also. In -pvc mode,
# this is not normally desired. So when the
# $MSWin_fudge_break variable is set,
# latexmk arranges to ignore ctrl/C and
# ctrl/break during processing of files;
# only the daughter programs receive them.
# This fudge is not applied in other
# situations, since then having latexmk also
# stopping because of the ctrl/C or
# ctrl/break signal is desirable.
# The fudge is not needed under UNIX (at least
# with Perl 5.005 on Solaris 8). Only the
# daughter programs receive the signal. In
# fact the inverse would be useful: In
# normal processing, as opposed to -pvc, if
# force mode (-f) is set, a ctrl/C is
# received by a daughter program does not
# also stop latexmk. Under tcsh, we get
# back to a command prompt, while latexmk
# keeps running in the background!
################################################################
# System-dependent overrides:
if ( $^O eq "MSWin32" ) {
# Pure MSWindows configuration
## Configuration parameters:
## Use first existing case for $tmpdir:
$tmpdir = $ENV{TMPDIR} || $ENV{TEMP} || '.';
$log_file_binary = 1; # Protect against ctrl/Z in log file from
# Miktex 2.7.
## List of possibilities for the system-wide initialization file.
## The first one found (if any) is used.
@rc_system_files = ( 'C:/latexmk/LatexMk' );
$search_path_separator = ';'; # Separator of elements in search_path
# For both fptex and miktex, the following makes error messages explicit:
$latex_silent_switch = '-interaction=batchmode -c-style-errors';
$pdflatex_silent_switch = '-interaction=batchmode -c-style-errors';
# For a pdf-file, "start x.pdf" starts the pdf viewer associated with
# pdf files, so no program name is needed:
$pdf_previewer = 'start %O %S';
$ps_previewer = 'start %O %S';
$ps_previewer_landscape = $ps_previewer;
$dvi_previewer = 'start %O %S';
$dvi_previewer_landscape = "$dvi_previewer";
# Viewer update methods:
# 0 => auto update: viewer watches file (e.g., gv)
# 1 => manual update: user must do something: e.g., click on window.
# (e.g., ghostview, MSWIN previewers, acroread under UNIX)
# 2 => send signal. Number of signal in $dvi_update_signal,
# $ps_update_signal, $pdf_update_signal
# 3 => viewer can't update, because it locks the file and the file
# cannot be updated. (acroread under MSWIN)
# 4 => run a command to force the update. The commands are
# specified by the variables $dvi_update_command,
# $ps_update_command, $pdf_update_command
$dvi_update_method = 1;
$ps_update_method = 1;
$pdf_update_method = 3; # acroread locks the pdf file
# Use NONE as flag that I am not implementing some commands:
$lpr =
'NONE $lpr variable is not configured to allow printing of ps files';
$lpr_dvi =
'NONE $lpr_dvi variable is not configured to allow printing of dvi files';
$lpr_pdf =
'NONE $lpr_pdf variable is not configured to allow printing of pdf files';
# The $pscmd below holds a command to list running processes. It
# is used to find the process ID of the viewer looking at the
# current output file. The output of the command must include the
# process number and the command line of the processes, since the
# relevant process is identified by the name of file to be viewed.
# Its use is not essential.
$pscmd =
'NONE $pscmd variable is not configured to detect running processes';
$pid_position = -1; # offset of PID in output of pscmd.
# Negative means I cannot use ps
}
elsif ( $^O eq "cygwin" ) {
# The problem is a mixed MSWin32 and UNIX environment.
# Perl decides the OS is cygwin in two situations:
# 1. When latexmk is run from a cygwin shell under a cygwin
# environment. Perl behaves in a UNIX way. This is OK, since
# the user is presumably expecting UNIXy behavior.
# 2. When CYGWIN exectuables are in the path, but latexmk is run
# from a native NT shell. Presumably the user is expecting NT
# behavior. But perl behaves more UNIXy. This causes some
# clashes.
# The issues to handle are:
# 1. Perl sees both MSWin32 and cygwin filenames. This is
# normally only an advantage.
# 2. Perl uses a UNIX shell in the system command
# This is a nasty problem: under native NT, there is a
# start command that knows about NT file associations, so that
# we can do, e.g., (under native NT) system("start file.pdf");
# But this won't work when perl has decided the OS is cygwin,
# even if it is invoked from a native NT command line. An
# NT command processor must be used to deal with this.
# 3. External executables can be native NT (which only know
# NT-style file names) or cygwin executables (which normally
# know both cygwin UNIX-style file names and NT file names,
# but not always; some do not know about drive names, for
# example).
# Cygwin executables for tex and latex may only know cygwin
# filenames.
# 4. The BIBINPUTS and TEXINPUTS environment variables may be
# UNIX-style or MSWin-style depending on whether native NT or
# cygwin executables are used. They are therefore parsed
# differently. Here is the clash:
# a. If a user is running under an NT shell, is using a
# native NT installation of tex (e.g., fptex or miktex),
# but has the cygwin executables in the path, then perl
# detects the OS as cygwin, but the user needs NT
# behavior from latexmk.
# b. If a user is running under an UNIX shell in a cygwin
# environment, and is using the cygwin installation of
# tex, then perl detects the OS as cygwin, and the user
# needs UNIX behavior from latexmk.
# Latexmk has no way of detecting the difference. The two
# situations may even arise for the same user on the same
# computer simply by changing the order of directories in the
# path environment variable
## Configuration parameters: We'll assume native NT executables.
## The user should override if they are not.
# This may fail: perl converts MSWin temp directory name to cygwin
# format. Names containing this string cannot be handled by native
# NT executables.
$tmpdir = $ENV{TMPDIR} || $ENV{TEMP} || '.';
## List of possibilities for the system-wide initialization file.
## The first one found (if any) is used.
## We can stay with MSWin files here, since perl understands them,
@rc_system_files = ( 'C:/latexmk/LatexMk' );
$search_path_separator = ';'; # Separator of elements in search_path
# This is tricky. The search_path_separator depends on the kind
# of executable: native NT v. cygwin.
# So the user will have to override this.
# For both fptex and miktex, the following makes error messages explicit:
$latex_silent_switch = '-interaction=batchmode -c-style-errors';
$pdflatex_silent_switch = '-interaction=batchmode -c-style-errors';
# We will assume that files can be viewed by native NT programs.
# Then we must fix the start command/directive, so that the
# NT-native start command of a cmd.exe is used.
# For a pdf-file, "start x.pdf" starts the pdf viewer associated with
# pdf files, so no program name is needed:
$start_NT = "cmd /c start \"\"";
$pdf_previewer = "$start_NT %O %S";
$ps_previewer = "$start_NT %O %S";
$ps_previewer_landscape = $ps_previewer;
$dvi_previewer = "$start_NT %O %S";
$dvi_previewer_landscape = $dvi_previewer;
# Viewer update methods:
# 0 => auto update: viewer watches file (e.g., gv)
# 1 => manual update: user must do something: e.g., click on window.
# (e.g., ghostview, MSWIN previewers, acroread under UNIX)
# 2 => send signal. Number of signal in $dvi_update_signal,
# $ps_update_signal, $pdf_update_signal
# 3 => viewer can't update, because it locks the file and the file
# cannot be updated. (acroread under MSWIN)
$dvi_update_method = 1;
$ps_update_method = 1;
$pdf_update_method = 3; # acroread locks the pdf file
# Use NONE as flag that I am not implementing some commands:
$lpr =
'NONE $lpr variable is not configured to allow printing of ps files';
$lpr_dvi =
'NONE $lpr_dvi variable is not configured to allow printing of dvi files';
$lpr_pdf =
'NONE $lpr_pdf variable is not configured to allow printing of pdf files';
# The $pscmd below holds a command to list running processes. It
# is used to find the process ID of the viewer looking at the
# current output file. The output of the command must include the
# process number and the command line of the processes, since the
# relevant process is identified by the name of file to be viewed.
# Its use is not essential.
# When the OS is detected as cygwin, there are two possibilities:
# a. Latexmk was run from an NT prompt, but cygwin is in the
# path. Then the cygwin ps command will not see commands
# started from latexmk. So we cannot use it.
# b. Latexmk was started within a cygwin environment. Then
# the ps command works as we need.
# Only the user, not latemk knows which, so we default to not
# using the ps command. The user can override this in a
# configuration file.
$pscmd =
'NONE $pscmd variable is not configured to detect running processes';
$pid_position = -1; # offset of PID in output of pscmd.
# Negative means I cannot use ps
}
else {
# Assume anything else is UNIX or clone
## Configuration parameters:
## Use first existing case for $tmpdir:
$tmpdir = $ENV{TMPDIR} || '/tmp';
## List of possibilities for the system-wide initialization file.
## The first one found (if any) is used.
## Normally on a UNIX it will be in a subdirectory of /opt/local/share or
## /usr/local/share, depending on the local conventions.
## /usr/local/lib/latexmk/LatexMk is put in the list for
## compatibility with older versions of latexmk.
@rc_system_files =
( '/opt/local/share/latexmk/LatexMk',
'/usr/local/share/latexmk/LatexMk',
'/usr/local/lib/latexmk/LatexMk' );
$search_path_separator = ':'; # Separator of elements in search_path
$dvi_update_signal = $signo{USR1}
if ( defined $signo{USR1} ); # Suitable for xdvi
$ps_update_signal = $signo{HUP}
if ( defined $signo{HUP} ); # Suitable for gv
$pdf_update_signal = $signo{HUP}
if ( defined $signo{HUP} ); # Suitable for gv
## default document processing programs.
# Viewer update methods:
# 0 => auto update: viewer watches file (e.g., gv)
# 1 => manual update: user must do something: e.g., click on window.
# (e.g., ghostview, MSWIN previewers, acroread under UNIX)
# 2 => send signal. Number of signal in $dvi_update_signal,
# $ps_update_signal, $pdf_update_signal
# 3 => viewer can't update, because it locks the file and the file
# cannot be updated. (acroread under MSWIN)
# 4 => Run command to update. Command in $dvi_update_command,
# $ps_update_command, $pdf_update_command.
$dvi_previewer = 'start xdvi %O %S';
$dvi_previewer_landscape = 'start xdvi -paper usr %O %S';
if ( defined $dvi_update_signal ) {
$dvi_update_method = 2; # xdvi responds to signal to update
} else {
$dvi_update_method = 1;
}
# if ( defined $ps_update_signal ) {
# $ps_update_method = 2; # gv responds to signal to update
# $ps_previewer = 'start gv -nowatch';
# $ps_previewer_landscape = 'start gv -swap -nowatch';
# } else {
# $ps_update_method = 0; # gv -watch watches the ps file
# $ps_previewer = 'start gv -watch';
# $ps_previewer_landscape = 'start gv -swap -watch';
# }
# Turn off the fancy options for gv. Regular gv likes -watch etc
# GNU gv likes --watch etc. User must configure
$ps_update_method = 0; # gv -watch watches the ps file
$ps_previewer = 'start gv %O %S';
$ps_previewer_landscape = 'start gv -swap %O %S';
$pdf_previewer = 'start acroread %O %S';
$pdf_update_method = 1; # acroread under unix needs manual update
$lpr = 'lpr %O %S'; # Assume lpr command prints postscript files correctly
$lpr_dvi =
'NONE $lpr_dvi variable is not configured to allow printing of dvi files';
$lpr_pdf =
'NONE $lpr_pdf variable is not configured to allow printing of pdf files';
# The $pscmd below holds a command to list running processes. It
# is used to find the process ID of the viewer looking at the
# current output file. The output of the command must include the
# process number and the command line of the processes, since the
# relevant process is identified by the name of file to be viewed.
# Uses:
# 1. In preview_continuous mode, to save running a previewer
# when one is already running on the relevant file.
# 2. With xdvi in preview_continuous mode, xdvi must be
# signalled to make it read a new dvi file.
#
# The following works on Solaris, LINUX, HP-UX, IRIX
# Use -f to get full listing, including command line arguments.
# Use -u $ENV{CMD} to get all processes started by current user (not just
# those associated with current terminal), but none of other users'
# processes.
$pscmd = "ps -f -u $ENV{USER}";
$pid_position = 1; # offset of PID in output of pscmd; first item is 0.
if ( $^O eq "linux" ) {
# Ps on Redhat (at least v. 7.2) appears to truncate its output
# at 80 cols, so that a long command string is truncated.
# Fix this with the --width option. This option works under
# other versions of linux even if not necessary (at least
# for SUSE 7.2).
# However the option is not available under other UNIX-type
# systems, e.g., Solaris 8.
$pscmd = "ps --width 200 -f -u $ENV{USER}";
}
elsif ( $^O eq "darwin" ) {
# OS-X on Macintosh
$lpr_pdf = 'lpr %O %S';
$pscmd = "ps -ww -u $ENV{USER}";
}
}
## default parameters
$max_repeat = 5; # Maximum times I repeat latex. Normally
# 3 would be sufficient: 1st run generates aux file,
# 2nd run picks up aux file, and maybe toc, lof which
# contain out-of-date information, e.g., wrong page
# references in toc, lof and index, and unresolved
# references in the middle of lines. But the
# formatting is more-or-less correct. On the 3rd
# run, the page refs etc in toc, lof, etc are about
# correct, but some slight formatting changes may
# occur, which mess up page numbers in the toc and lof,
# Hence a 4th run is conceivably necessary.
# At least one document class (JHEP.cls) works
# in such a way that a 4th run is needed.
# We allow an extra run for safety for a
# maximum of 5. Needing further runs is
# usually an indication of a problem; further
# runs may not resolve the problem, and
# instead could cause an infinite loop.
$clean_ext = ""; # space separated extensions of files that are
# to be deleted when doing cleanup, beyond
# standard set
$clean_full_ext = ""; # space separated extensions of files that are
# to be deleted when doing cleanup_full, beyond
# standard set and those in $clean_ext
@cus_dep_list = (); # Custom dependency list
@default_files = ( '*.tex' ); # Array of LaTeX files to process when
# no files are specified on the command line.
# Wildcards allowed
# Best used for project specific files.
@default_excluded_files = ( );
# Array of LaTeX files to exclude when using
# @default_files, i.e., when no files are specified
# on the command line.
# Wildcards allowed
# Best used for project specific files.
$texfile_search = ""; # Specification for extra files to search for
# when no files are specified on the command line
# and the @default_files variable is empty.
# Space separated, and wildcards allowed.
# These files are IN ADDITION to *.tex in current
# directory.
# This variable is obsolete, and only in here for
# backward compatibility.
$fdb_ext = 'fdb_latexmk'; # Extension for the file for latexmk's
# file-database
# Make it long to avoid possible collisions.
$fdb_ver = 2; # Version number for kind of fdb_file.
$jobname = ''; # Jobname: as with current tex, etc indicates
# basename of generated files.
# Defined so that --jobname=STRING on latexmk's
# command line has same effect as with current
# tex, etc. (If $jobname is non-empty, then
# the --jobname=... option is used on tex.)
## default flag settings.
$silent = 0; # silence latex's messages?
$landscape_mode = 0; # default to portrait mode
# The following two arrays contain lists of extensions (without
# period) for files that are read in during a (pdf)LaTeX run but that
# are generated automatically from the previous run, as opposed to
# being user generated files (directly or indirectly from a custom
# dependency). These files get two kinds of special treatment:
# 1. In clean up, where depending on the kind of clean up, some
# or all of these generated files are deleted.
# (Note that special treatment is given to aux files.)
# 2. In analyzing the results of a run of (pdf)LaTeX, to
# determine if another run is needed. With an error free run,
# a rerun should be provoked by a change in any source file,
# whether a user file or a generated file. But with a run
# that ends in an error, only a change in a user file during
# the run (which might correct the error) should provoke a
# rerun, but a change in a generated file should not.
# These arrays can be user-configured.
@generated_exts = ( 'aux', 'idx', 'ind', 'lof', 'lot', 'out', 'toc' );
# N.B. 'out' is generated by hyperref package
# Which kinds of file do I have requests to make?
# If no requests at all are made, then I will make dvi file
# If particular requests are made then other files may also have to be
# made. E.g., ps file requires a dvi file
$dvi_mode = 0; # No dvi file requested
$postscript_mode = 0; # No postscript file requested
$pdf_mode = 0; # No pdf file requested to be made by pdflatex
# Possible values:
# 0 don't create pdf file
# 1 to create pdf file by pdflatex
# 2 to create pdf file by ps2pdf
# 3 to create pdf file by dvipdf
$view = 'default'; # Default preview is of highest of dvi, ps, pdf
$sleep_time = 2; # time to sleep b/w checks for file changes in -pvc mode
$banner = 0; # Non-zero if we have a banner to insert
$banner_scale = 220; # Original default scale
$banner_intensity = 0.95; # Darkness of the banner message
$banner_message = 'DRAFT'; # Original default message
$do_cd = 0; # Do not do cd to directory of source file.
# Thus behave like latex.
$dependents_list = 0; # Whether to display list(s) of dependencies
@dir_stack = (); # Stack of pushed directories.
$cleanup_mode = 0; # No cleanup of nonessential LaTex-related files.
# $cleanup_mode = 0: no cleanup
# $cleanup_mode = 1: full cleanup
# $cleanup_mode = 2: cleanup except for dvi,
# dviF, pdf, ps, & psF
$cleanup_fdb = 0; # No removal of file for latexmk's file-database
$cleanup_only = 0; # When doing cleanup, do not go-on to making files
$cleanup_includes_generated = 0;
# Determines whether cleanup deletes files generated by
# (pdf)latex (found from \openout lines in log file).
$diagnostics = 0;
$dvi_filter = ''; # DVI filter command
$ps_filter = ''; # Postscript filter command
$force_mode = 0; # =1 to force processing past errors
$force_include_mode = 0;# =1 to ignore non-existent files when testing
# for dependency. (I.e., don't treat them as error)
$go_mode = 0; # =1 to force processing regardless of time-stamps
# =2 full clean-up first
$preview_mode = 0;
$preview_continuous_mode = 0;
$printout_mode = 0; # Don't print the file
# Do we make view file in temporary then move to final destination?
# (To avoid premature updating by viewer).
$always_view_file_via_temporary = 0; # Set to 1 if viewed file is always
# made through a temporary.
$pvc_view_file_via_temporary = 1; # Set to 1 if only in -pvc mode is viewed
# file made through a temporary.
# State variables initialized here:
$updated = 0; # Flags when something has been remade
# Used to allow convenient user message in -pvc mode
$waiting = 0; # Flags whether we are in loop waiting for an event
# Used to avoid unnecessary repeated o/p in wait loop
# Used for some results of parsing log file:
$reference_changed = 0;
$bad_reference = 0;
$bad_citation = 0;
# Set search paths for includes.
# Set them early so that they can be overridden
$BIBINPUTS = $ENV{'BIBINPUTS'};
if (!$BIBINPUTS) { $BIBINPUTS = '.'; }
#?? OBSOLETE
$TEXINPUTS = $ENV{'TEXINPUTS'};
if (!$TEXINPUTS) { $TEXINPUTS = '.'; }
# Convert search paths to arrays:
# If any of the paths end in '//' then recursively search the
# directory. After these operations, @BIBINPUTS should
# have all the directories that need to be searched
@BIBINPUTS = find_dirs1 ($BIBINPUTS);
######################################################################
######################################################################
#
# ??? UPDATE THE FOLLOWING!!
#
# We will need to determine whether source files for runs of various
# programs are out of date. In a normal situation, this is done by
# asking whether the times of the source files are later than the
# destination files. But this won't work for us, since a common
# situation is that a file is written on one run of latex, for
# example, and read back in on the next run (e.g., an .aux file).
# Some situations of this kind are standard in latex generally; others
# occur with particular macro packages or with particular
# postprocessors.
#
# The correct criterion for whether a source is out-of-date is
# therefore NOT that its modification time is later than the
# destination file, but whether the contents of the source file have
# changed since the last successful run. This also handles the case
# that the user undoes some changes to a source file by replacing the
# source file by reverting to an earlier version, which may well have
# an older time stamp. Since a direct comparison of old and new files
# would involve storage and access of a large number of backup files,
# we instead use the md5 signature of the files. (Previous versions
# of latexmk used the backup file method, but restricted to the case
# of .aux and .idx files, sufficient for most, but not all,
# situations.)
#
# We will have a database of (time, size, md5) for the relevant
# files. If the time and size of a file haven't changed, then the file
# is assumed not to have changed; this saves us from having to
# determine its md5 signature, which would involve reading the whole
# file, which is naturally time-consuming, especially if network file
# access to a server is needed, and many files are involved, when most
# of them don't change. It is of course possible to change a file
# without changing its size, but then to adjust its timestamp
# to what it was previously; this requires a certain amount of
# perversity. We can safely assume that if the user edits a file or
# changes its contents, then the file's timestamp changes. The
# interesting case is that the timestamp does change, because the file
# has actually been written to, but that the contents do not change;
# it is for this that we use the md5 signature. However, since
# computing the md5 signature involves reading the whole file, which
# may be large, we should avoid computing it more than necessary.
#
# So we get the following structure:
#
# 1. For each relevant run (latex, pdflatex, each instance of a
# custom dependency) we have a database of the state of the
# source files that were last used by the run.
# 2. On an initial startup, the database for a primary tex file
# is read that was created by a previous run of latex or
# pdflatex, if this exists.
# 3. If the file doesn't exist, then the criterion for
# out-of-dateness for an initial run is that it goes by file
# timestamps, as in previous versions of latexmk, with due
# (dis)regard to those files that are known to be generated by
# latex and re-read on the next run.
# 4. Immediately before a run, the database is updated to
# represent the current conditions of the run's source files.
# 5. After the run, it is determined whether any of the source
# files have changed. This covers both files written by the
# run, which are therefore in a dependency loop, and files that
# the user may have updated during the run. (The last often
# happens when latex takes a long time, for a big document,
# and the user makes edits before latex has finished. This is
# particularly prevalent when latexmk is used with