184
192
## Modification log from 9 Dec 2011 onwards in detail
186
194
## 12 Jan 2012 STILL NEED TO DOCUMENT some items below
196
## 1 Jan 2015 John Collins V. 4.41
197
## 18 Dec 2014 John Collins -c also deletes $deps_file if it is used.
198
## 16 Dec 2014 John Collins Finish change of e-mail
199
## 5 Dec 2014 John Collins Quote jobname when needed.
200
## 5 Sep 2014 John Collins Change my e-mail
201
## 30 Aug 2014 John Collins Change my e-mail
202
## 13 Aug 2014 John Collins Try to correct error handling to avoid
203
## repeated runs of latex after an error.
204
## Revert to some code from v. 4-32.
205
## Do I need $retry_msg?
206
## 8 Aug 2014 John Collins Fix up for the making of -eps-converted-to.pdf
207
## 4 Aug 2014 John Collins Sort and remove redundant xxx-undefined
208
## warning lines from log file.
209
## 23 Jul 2014 John Collins Fix failure when using both -cd and -output-directory
210
## 22 Jul 2014 John Collins If $HOME not set, then don't read ~/.latexmkrc
211
## Introduce $silence_logfile_warnings
212
## 21 Jul 2014 John Collins In setting $pscmd, allow for non-existent
214
## 29 May 2014 John Collins Correct sub Run for internal cmd w/o arguments
215
## 21 Mar 2014 John Collins Experimental: Add analysis hook for aux file.
216
## But I need to change rdb_create_rule in someway to
217
## allow correct handling of: (a) rule creation if
218
## rule doesn't exist, (b) either no change, or rule
219
## update, if the rule exists. No change is a bad
220
## idea, because conditions may change. Such a
221
## change, to effectively rdb_ensure_rule, would also
222
## help other dependencies, e.g., if a custom
223
## dependency has been created on one run of latexmk,
224
## and then on another run the definition is changed.
225
## With the old method, the old cus-dep is used unless
226
## the dependency cache fdb_latexmk is cleared; but
227
## with the new method the custom dependency will be
228
## changed correctly.
229
## 5 Mar 2014 John Collins System initialization files: allow them
230
## to be named latexmkrc as well as LatexMk,
231
## for more consistency with user directory
232
## names. Keep both cases, to preserve
233
## backward compatibility.
234
## 30 Jan 2014 John Collins Change sign-on message. Bug report info with help. V. 4.40a
235
## 15 Jan 2014 John Collins Fix failure to clean up correctly when
236
## root filename contains [, which is
237
## a glob metacharacter.
187
239
## 10 Nov 2013 John Collins Change split / /, ... to split /\s*/, ...
188
240
## so as to be immune from extra white space.
189
241
## Clean up $clean_ext and $clean_full_ext by removing
776
849
## List of possibilities for the system-wide initialization file.
777
850
## The first one found (if any) is used.
778
851
## We could stay with MSWin files here, since cygwin perl understands them
779
## @rc_system_files = ( 'C:/latexmk/LatexMk' );
852
## @rc_system_files = ( 'C:/latexmk/LatexMk', 'C:/latexmk/latexmkrc' );
780
853
## But they are deprecated in v. 1.7. So use the UNIX version, prefixed
781
854
## with a cygwin equivalent of the MSWin location
783
( '/cygdrive/c/latexmk/LatexMk',
784
'/opt/local/share/latexmk/LatexMk',
785
'/usr/local/share/latexmk/LatexMk',
786
'/usr/local/lib/latexmk/LatexMk' );
855
## In addition, we need to add the same set of possible locations as with
856
## unix, so that the user use a unix-style setup.
857
@rc_system_files = ();
858
foreach ( 'LatexMk', 'latexmkrc' ) {
859
push @rc_system_files,
860
( "/cygdrive/c/latexmk/$_",
861
"/opt/local/share/latexmk/$_",
862
"/usr/local/share/latexmk/$_",
863
"/usr/local/lib/latexmk/$_" );
788
865
$search_path_separator = ';'; # Separator of elements in search_path
789
866
# This is tricky. The search_path_separator depends on the kind
790
867
# of executable: native NT v. cygwin.
1291
1383
# cmd_type is 'primary', 'external', or 'cusdep'
1292
1384
# ext_cmd is string for associated external command
1293
1385
# with substitutions (%D for destination, %S
1294
# for source, %B for base of current rule,
1295
# %R for base of primary tex file, %T for
1296
# texfile name, %O for options,
1386
# for source, %B for base of current rule,
1387
# %R for base of primary tex file, %T for
1388
# texfile name, %O for options,
1297
1389
# %Y for $aux_dir1, and %Z for $out_dir1
1298
1390
# int_cmd specifies any internal command to be
1299
# used to implement the application of the
1300
# rule. If this is present, it overrides
1301
# the external command, and it is the
1302
# responsibility of the perl subroutine
1303
# specified in intcmd to execute the
1304
# external command if this is appropriate.
1305
# This variable intcmd is a reference to an array,
1391
# used to implement the application of the
1392
# rule. If this is present, it overrides
1393
# the external command, and it is the
1394
# responsibility of the perl subroutine
1395
# specified in intcmd to execute the
1396
# external command if this is appropriate.
1397
# This variable intcmd is a reference to an array,
1306
1398
# $$intcmd[0] = internal routine
1307
1399
# $$intcmd[1...] = its arguments (if any)
1308
1400
# test_kind specifies method of determining
1309
1401
# whether a file is out-of-date:
1311
1403
# 1 for usual: whether there is a source
1313
1405
# 2 for dest earlier than source
1314
1406
# 3 for method 2 at first run, 1 thereafter
1315
1407
# (used when don't have file data from
1317
1409
# source = name of primary source file, if any
1318
1410
# dest = name of primary destination file,
1320
1412
# base = base name, if any, of files for
1322
1414
# out_of_date = 1 if it has been detected that
1323
# this rule needs to be run
1324
# (typically because a source
1325
# file has changed).
1415
# this rule needs to be run
1416
# (typically because a source
1417
# file has changed).
1327
1419
# out_of_date_user is like out_of_date, except
1328
1420
# that the detection of out-of-dateness
1329
1421
# has been made from a change of a
1330
# putative user file, i.e., one that is
1331
# not a generated file (e.g., aux). This
1332
# kind of out-of-dateness should provoke a
1333
# rerun whether or not there was an error
1334
# during a run of (pdf)LaTeX. Normally,
1335
# if there is an error, one should wait
1336
# for the user to correct the error. But
1337
# it is possible the error condition is
1338
# already corrected during the run, e.g.,
1339
# by the user changing a source file in
1340
# response to an error message.
1422
# putative user file, i.e., one that is
1423
# not a generated file (e.g., aux). This
1424
# kind of out-of-dateness should provoke a
1425
# rerun whether or not there was an error
1426
# during a run of (pdf)LaTeX. Normally,
1427
# if there is an error, one should wait
1428
# for the user to correct the error. But
1429
# it is possible the error condition is
1430
# already corrected during the run, e.g.,
1431
# by the user changing a source file in
1432
# response to an error message.
1341
1433
# time_of_last_run = time that this rule was
1342
# last applied. (In standard units
1343
# from perl, to be directly compared
1344
# with file modification times.)
1434
# last applied. (In standard units
1435
# from perl, to be directly compared
1436
# with file modification times.)
1345
1437
# time_of_last_file_check = last time that a check
1346
1438
# was made for changes in source files.
1347
1439
# changed flags whether special changes have been made
2513
2634
foreach my $Prule_list (@_) {
2514
foreach my $rule ( keys %$Prule_list) {
2515
my ( $cmd_type, $ext_cmd, $int_cmd, $source, $dest, $base, $test_kind, $PA_extra_gen ) = @{$$Prule_list{$rule}};
2635
foreach my $rule ( keys %$Prule_list) {
2636
my ( $cmd_type, $ext_cmd, $int_cmd, $source, $dest, $base, $test_kind, $PA_extra_gen ) = @{$$Prule_list{$rule}};
2516
2637
if ( ! $PA_extra_gen ) { $PA_extra_gen = []; }
2517
my $needs_making = 0;
2518
# Substitute in the filename variables, since we will use
2519
# those for determining filenames. But delay expanding $cmd
2520
# until run time, in case of changes.
2521
foreach ($base, $source, $dest, @$PA_extra_gen ) {
2522
s/%R/$root_filename/;
2526
foreach ($source, $dest ) {
2528
s/%T/$texfile_name/;
2638
my $needs_making = 0;
2639
# Substitute in the filename variables, since we will use
2640
# those for determining filenames. But delay expanding $cmd
2641
# until run time, in case of changes.
2642
foreach ($base, $source, $dest, @$PA_extra_gen ) {
2643
s/%R/$root_filename/;
2647
foreach ($source, $dest ) {
2649
s/%T/$texfile_name/;
2530
2651
# print "$rule: $cmd_type, EC='$ext_cmd', IC='$int_cmd', $test_kind,\n",
2531
2652
# " S='$source', D='$dest', B='$base' $needs_making\n";
2532
rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $test_kind,
2533
$source, $dest, $base,
2534
$needs_making, undef, undef, 1, $PA_extra_gen );
2653
rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $test_kind,
2654
$source, $dest, $base,
2655
$needs_making, undef, undef, 1, $PA_extra_gen );
2535
2656
# !! ?? Last line was
2536
# $needs_making, undef, ($test_kind==1) );
2657
# $needs_making, undef, ($test_kind==1) );
2538
2659
} # End arguments of subroutine
2539
2660
&rdb_make_links;
2540
2661
} # END rdb_set_rules
3811
3942
if ( ($block_type eq 'conversion')
3812
3943
&& /^\($current_pkg\)\s+Output file: <([^>]+)>/ )
3814
$delegated_output = normalize_clean_filename($1);
3945
$delegated_output = normalize_clean_filename($1);
3818
3949
# Block has ended.
3819
3950
if ($block_type eq 'conversion') {
3951
print "=== $delegated_source -> $delegated_output\n";
3820
3952
$new_conversions{$delegated_source} = $delegated_output;
3822
3954
$current_pkg = $block_type
3823
3955
= $delegated_source = $delegated_output = "";
3824
3956
# Then process current line
3826
3959
# Check for changed references, bad references and bad citations:
3827
3960
if (/Rerun to get/) {
3828
warn "$My_name: References changed.\n" if ! $silent;
3961
warn "$My_name: References changed.\n" if ! $log_silent;
3829
3962
$reference_changed = 1;
3831
if (/LaTeX Warning: (Reference[^\001]*undefined)./) {
3832
warn "$My_name: $1 \n" unless $silent;
3835
if (/LaTeX Warning: (Citation[^\001]*undefined)./) {
3836
warn "$My_name: $1 \n" unless $silent;
3839
if (/Package natbib Warning: (Citation[^\001]*undefined)./) {
3840
warn "$My_name: $1 \n" unless $silent;
3843
if ( /^Document Class: / ) {
3844
# Class sign-on line
3847
if ( /^\(Font\)/ ) {
3851
if (/^No pages of output\./) {
3964
if (/^LaTeX Warning: (Reference[^\001]*undefined on input line .*)\./) {
3965
push @warning_list, $1;
3968
elsif (/^LaTeX Warning: (Label [^\001]* multiply defined.*)\./) {
3969
push @warning_list, $1;
3972
elsif (/^LaTeX Warning: (Citation[^\001]*undefined on input line .*)\./) {
3973
push @warning_list, $1;
3976
elsif (/^Package natbib Warning: (Citation[^\001]*undefined on input line .*)\./) {
3977
push @warning_list, $1;
3980
elsif ( /^Document Class: / ) {
3981
# Class sign-on line
3984
elsif ( /^\(Font\)/ ) {
3988
elsif (/^No pages of output\./) {
3852
3989
$primary_out = '';
3853
warn "$My_name: Log file says no output from latex\n";
3856
if ( /^Output written on\s+(.*)\s+\(\d+\s+page/ ) {
3990
warn "$My_name: Log file says no output from latex\n";
3993
elsif ( /^Output written on\s+(.*)\s+\(\d+\s+page/ ) {
3857
3994
$primary_out = normalize_clean_filename($1);
3858
warn "$My_name: Log file says output to '$primary_out'\n"
3995
warn "$My_name: Log file says output to '$primary_out'\n"
3999
elsif ( /^Overfull /
3864
4001
|| /^or enter new name\. \(Default extension: .*\)/
3865
4002
|| /^\*\*\* \(cannot \\read from terminal in nonstop modes\)/
3867
# Latex error/warning, etc.
3870
if ( /^\\openout\d+\s*=\s*\`([^\']+)\'\.$/ ) {
4004
# Latex error/warning, etc.
4007
elsif ( /^\\openout\d+\s*=\s*\`([^\']+)\'\.$/ ) {
3871
4008
# When (pdf)latex is run with an -output-directory
3872
4009
# or an -aux_directory, the file name does not contain
3873
4010
# the output path; fix this, after removing quotes:
3874
4011
$generated_log{normalize_force_directory( $aux_dir1, $1 )} = 1;
3877
4014
# Test for conversion produced by package:
3878
if ( /^Package (\S+) Info: Source file: <([^>]+)>/ ) {
3879
# Info. produced by epstopdf (and possibly others)
4015
elsif ( /^Package (\S+) Info: Source file: <([^>]+)>/ ) {
4016
# Info. produced by epstopdf (and possibly others)
3880
4017
# about file conversion
3881
4018
$current_pkg = normalize_clean_filename($1);
3882
4019
$delegated_source = normalize_clean_filename($2);
3883
4020
$block_type = 'conversion';
3886
4023
# Test for writing of index file. The precise format of the message
3887
4024
# depends on which package (makeidx.sty , multind.sty or index.sty) and
3888
4025
# which version writes the message.
3889
if ( /Writing index file (.*)$/ ) {
4026
elsif ( /Writing index file (.*)$/ ) {
3890
4027
my $idx_file = '';
3891
if ( /^Writing index file (.*)$/ ) {
4028
if ( /^Writing index file (.*)$/ ) {
3892
4029
# From makeidx.sty or multind.sty
3893
4030
$idx_file = $1;
3895
4032
elsif ( /^index\.sty> Writing index file (.*)$/ ) {
3896
4033
# From old versions of index.sty
3897
4034
$idx_file = $1;
3899
4036
elsif ( /^Package \S* Info: Writing index file (.*) on input line/ ) {
3900
4037
# From new versions of index.sty
3901
4038
$idx_file = $1;
3904
warn "$My_name: Message indicates index file was written\n",
3905
" ==> but I do not know how to understand it: <==\n",
4041
warn "$My_name: Message indicates index file was written\n",
4042
" ==> but I do not know how to understand it: <==\n",
3909
# Typically, there is trailing space, not part of filename:
3910
$idx_file =~ s/\s*$//;
4046
# Typically, there is trailing space, not part of filename:
4047
$idx_file =~ s/\s*$//;
3911
4048
# When (pdf)latex is run with an -output-directory
3912
4049
# or an -aux_directory, the file name does not contain
3913
4050
# the output path; fix this, after removing quotes:
3914
$idx_file = normalize_force_directory( $aux_dir1, $idx_file );
3915
my ($idx_base, $idx_path, $idx_ext) = fileparseA( $idx_file );
3916
$idx_base = $idx_path.$idx_base;
4051
$idx_file = normalize_force_directory( $aux_dir1, $idx_file );
4052
my ($idx_base, $idx_path, $idx_ext) = fileparseA( $idx_file );
4053
$idx_base = $idx_path.$idx_base;
3917
4054
$idx_file = $idx_base.$idx_ext;
3918
if ( $idx_ext eq '.idx' ) {
3919
warn "$My_name: Index file '$idx_file' was written\n"
3921
$idx_files{$idx_file} = [ "$idx_base.ind", $idx_base ];
3923
elsif ( exists $cusdep_from{$idx_ext} ) {
4055
if ( $idx_ext eq '.idx' ) {
4056
warn "$My_name: Index file '$idx_file' was written\n"
4058
$idx_files{$idx_file} = [ "$idx_base.ind", $idx_base ];
4060
elsif ( exists $cusdep_from{$idx_ext} ) {
3924
4061
if ( !$silent ) {
3925
warn "$My_name: Index file '$idx_file' was written\n";
4062
warn "$My_name: Index file '$idx_file' was written\n";
3926
4063
warn " Cusdep '$cusdep_from{$idx_ext}' should be used\n";
3928
4065
# No action needed here
3931
warn "$My_name: Index file '$idx_file' written\n",
3932
" ==> but it has an extension I do not know how to handle <==\n";
4068
warn "$My_name: Index file '$idx_file' written\n",
4069
" ==> but it has an extension I do not know how to handle <==\n";
3937
if ( /^No file (.*?\.bbl)./ ) {
4074
elsif ( /^No file (.*?\.bbl)./ ) {
3938
4075
# When (pdf)latex is run with an -output-directory
3939
4076
# or an -aux_directory, the file name does not contain
3940
4077
# the output path; fix this, after removing quotes:
3941
my $bbl_file = normalize_force_directory( $aux_dir1, $1 );
3942
warn "$My_name: Non-existent bbl file '$bbl_file'\n $_\n";
3943
$dependents{$bbl_file} = 0;
3944
push @bbl_files, $bbl_file;
3947
foreach my $pattern (@file_not_found) {
4078
my $bbl_file = normalize_force_directory( $aux_dir1, $1 );
4079
warn "$My_name: Non-existent bbl file '$bbl_file'\n $_\n";
4080
$dependents{$bbl_file} = 0;
4081
push @bbl_files, $bbl_file;
4084
foreach my $pattern (@file_not_found) {
3949
4086
my $file = clean_filename($1);
3950
warn "$My_name: Missing input file: '$file' from line\n '$_'\n"
3952
$dependents{normalize_filename($file)} = 0;
4087
warn "$My_name: Missing input file: '$file' from line\n '$_'\n"
4089
$dependents{normalize_filename($file)} = 0;
3954
4091
if ( $aux_dir ) {
3955
4092
# Allow for the possibility that latex generated
3956
4093
# a file in $aux_dir, from which the missing file can
4029
4166
# Solution: use ' [', but not '[' as first try at delimiter.
4030
# Then if candidate filename is of form 'name1[name2]', then
4031
# try splitting it. If 'name1' and/or 'name2' exists, put
4032
# it/them in list, else just put 'name1[name2]' in list.
4033
# So form of filename is now:
4035
# then any number of characters that are NOT ')', '(', or '{'
4036
# (these form the filename);
4037
# then ' [', or ' (', or ')', or end-of-string.
4038
# That fails for pdflatex
4040
# '(' => start of reading of file, followed by filename
4041
# ')' => end of reading of file
4042
# '[' => start of page (normally preceeded by space)
4044
# filename (on VAX/VMS) may include '[' and ']' (directory
4046
# filenames (on MS-Win) commonly include space.
4167
# Then if candidate filename is of form 'name1[name2]', then
4168
# try splitting it. If 'name1' and/or 'name2' exists, put
4169
# it/them in list, else just put 'name1[name2]' in list.
4170
# So form of filename is now:
4172
# then any number of characters that are NOT ')', '(', or '{'
4173
# (these form the filename);
4174
# then ' [', or ' (', or ')', or end-of-string.
4175
# That fails for pdflatex
4177
# '(' => start of reading of file, followed by filename
4178
# ')' => end of reading of file
4179
# '[' => start of page (normally preceeded by space)
4181
# filename (on VAX/VMS) may include '[' and ']' (directory
4183
# filenames (on MS-Win) commonly include space.
4047
4184
# filenames on UNIX can included space.
4048
4185
# Miktex quotes filenames
4049
4186
# But web2c doesn't. Then
4106
4243
# If the first component exists, we probably have the
4107
4244
# pdflatex form
4108
4245
push @new_includes, $1, $2;
4111
4248
# We have something else.
4112
4249
# So leave the original candidate in the list
4116
4253
foreach my $include_name (@new_includes) {
4117
4254
$include_name = normalize_filename( $include_name );
4118
my ($base, $path, $ext) = fileparseB( $include_name );
4255
my ($base, $path, $ext) = fileparseB( $include_name );
4119
4256
if ( ($path eq './') || ($path eq '.\\') ) {
4120
4257
$include_name = $base.$ext;
4122
4259
if ( $include_name !~ m'[/|\\]' ) {
4123
4260
# Filename does not include a path character
4124
4261
# High potential for misparsed line
4125
$dependents{$include_name} = 2;
4127
$dependents{$include_name} = 3;
4129
if ( $ext eq '.bbl' ) {
4130
warn "$My_name: Found input bbl file '$include_name'\n"
4132
push @bbl_files, $include_name;
4262
$dependents{$include_name} = 2;
4264
$dependents{$include_name} = 3;
4266
if ( $ext eq '.bbl' ) {
4267
warn "$My_name: Found input bbl file '$include_name'\n"
4269
push @bbl_files, $include_name;
4135
4272
} # INCLUDE_CANDIDATE
4235
4372
my @kpse_result = kpsewhich( $candidate,);
4236
4373
if ($#kpse_result > -1) {
4237
4374
$candidate = $kpse_result[0];
4241
4378
if ( ( (-e $delegated_source) || ($delegated_source eq '') )
4242
4379
&& (-e $delegated_output) )
4244
$conversions{$delegated_output} = $delegated_source;
4245
$dependents{$delegated_output} = 7;
4381
$conversions{$delegated_output} = $delegated_source;
4382
$dependents{$delegated_output} = 7;
4246
4383
if ($delegated_source) {
4247
4384
$dependents{$delegated_source} = 4;
4251
4388
print "Logfile claimed conversion from '$delegated_source' ",
4252
"to '$delegated_output'. But:\n";
4389
"to '$delegated_output'. But:\n";
4253
4390
if (! -e $delegated_output) {
4254
print " Output file does not exist\n";
4391
print " Output file does not exist\n";
4256
4393
if ( ($delegated_source ne '') && (! -e $delegated_source) ) {
4257
print " Input file does not exist\n";
4394
print " Input file does not exist\n";
4399
if ( ($#warning_list >= 0) && !$log_silent ) {
4400
@warning_list = uniqs( @warning_list );
4401
show_array( "$My_name: List of undefined refs and citations:",
4263
4405
if ( $diagnostics ) {
4264
4406
@misparse = uniqs( @misparse );
4736
4883
$base = $path.$base;
4737
4884
if ($rule_generic eq 'makeindex') {
4738
4885
$dest = "$base.ind";
4740
4887
elsif ($rule_generic eq 'bibtex') {
4741
4888
$dest = "$base.bbl";
4742
4889
$source = "$base.aux";
4744
4891
elsif ($rule_generic eq 'biber') {
4745
4892
$dest = "$base.bbl";
4746
4893
$source = "$base.bcf";
4749
4896
if ($rule =~ /^makeindex/) { $PA_extra_gen = [ "$base.ilg" ]; }
4750
4897
if ($rule =~ /^(bibtex|biber)/) { $PA_extra_gen = [ "$base.blg" ]; }
4751
4898
if ($rule =~ /^bibtex/) { $int_cmd = "run_bibtex"; }
4752
warn "$My_name: File-database '$in_name': setting rule '$rule'\n"
4899
warn "$My_name: File-database '$in_name': setting rule '$rule'\n"
4753
4900
if $diagnostics;
4754
4901
my $cmd_type = 'external';
4755
4902
my $ext_cmd = ${$rule_generic};
4756
warn " Rule kind = '$rule_generic'; ext_cmd = '$ext_cmd';\n",
4903
warn " Rule kind = '$rule_generic'; ext_cmd = '$ext_cmd';\n",
4757
4904
" int_cmd = '$int_cmd';\n",
4758
" source = '$source'; dest = '$dest'; base = '$base';\n"
4905
" source = '$source'; dest = '$dest'; base = '$base';\n"
4759
4906
if $diagnostics;
4760
4907
# Set source file as non-existent.
4761
4908
# If it existed on last run, it will be in later
4762
4909
# lines of the fdb file
4763
4910
rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, 1,
4764
4911
$source, $dest, $base, 0, $run_time, $check_time, 1, $PA_extra_gen );
4767
warn "$My_name: In file-database '$in_name' rule '$rule'\n",
4914
warn "$My_name: In file-database '$in_name' rule '$rule'\n",
4768
4915
" is not in use in this session\n"
4769
4916
if $diagnostics;
4770
$new_source = undef;
4917
$new_source = undef;
4774
4921
$new_source = $new_sources{$rule} = {};
4775
$state = 1; #Reading a section, source part
4922
$state = 1; #Reading a section, source part
4777
4924
elsif ( ($state <=0) || ($state >= 3) ) {
4780
4927
elsif ( /^\(source\)/ ) { $state = 1; next LINE; }
4781
4928
elsif ( /^\(generated\)/ ) { $state = 2; next LINE; }
4782
elsif ( ($state == 1) && /^\"([^\"]*)\"\s+(\S+)\s+(\S+)\s+(\S+)\s+\"([^\"]*)\"/ ) {
4929
elsif ( ($state == 1) && /^\"([^\"]*)\"\s+(\S+)\s+(\S+)\s+(\S+)\s+\"([^\"]*)\"/ ) {
4783
4930
# Source file line
4788
4935
my $from_rule = $5;
4789
4936
#?? print " --- File '$file'\n";
4790
4937
if ($state != 1) {
4791
4938
warn "$My_name: In file-database '$in_name' ",
4792
"line $. is outside a section:\n '$_'\n";
4939
"line $. is outside a section:\n '$_'\n";
4796
4943
# Set file in database. But ensure we don't do an unnecessary
4797
4944
# fdb_get, which can trigger a new MD5 calculation, which is
4798
4945
# lengthy for a big file. Ininitially flagging the file
4799
4946
# as non-existent solves the problem:
4800
rdb_ensure_file( $rule, $file, undef, 1 );
4947
rdb_ensure_file( $rule, $file, undef, 1 );
4801
4948
rdb_set_file1( $rule, $file, $time, $size, $md5 );
4802
4949
fdb_set( $file, $time, $size, $md5 );
4803
4950
# Save the rest of the data, especially the from_fule until we know all
4804
4951
# the rules, otherwise the from_rule may not exist.
4805
4952
# Also we'll have a better chance of looping through files.
4806
${$new_source}{$file} = [ $time, $size, $md5, $from_rule ];
4808
elsif ( ($state == 2) && /^\"([^\"]*)\"/ ) {
4953
${$new_source}{$file} = [ $time, $size, $md5, $from_rule ];
4955
elsif ( ($state == 2) && /^\"([^\"]*)\"/ ) {
4810
4957
rdb_one_rule( $rule, sub{ rdb_add_generated($file); } );
4813
warn "$My_name: In file-database '$in_name' ",
4960
warn "$My_name: In file-database '$in_name' ",
4814
4961
"line $. is of wrong format:\n '$_'\n";
4819
4966
undef $in_handle;
4820
4967
# Set cus dependencies.
5105
5293
# database, then the previous version of the file should be
5106
5294
# treated as non-existent, to ensure another run is forced.
5107
5295
rdb_ensure_file( $rule, $new_source, undef, 1 );
5109
elsif ( $dependents{$new_source} == 7 ) {
5297
elsif ( $dependents{$new_source} == 7 ) {
5110
5298
# File was result of conversion by (pdf)latex.
5111
5299
my $cnv_source = $conversions{$new_source};
5112
5300
rdb_ensure_file( $rule, $new_source );
5114
5302
# Conversion from $cnv_source to $new_source
5115
5303
# implies that effectively $cnv_source is a source
5116
5304
# of the (pdf)latex run.
5117
5305
rdb_ensure_file( $rule, $cnv_source );
5119
5307
# Flag that changes of the generated file during a run
5120
5308
# do not require a rerun:
5121
5309
rdb_one_file( $new_source, sub{ $$Pcorrect_after_primary = 1; } );
5124
5312
# But we don't need special precautions for ordinary user files
5125
5313
# (or for files that are generated outside of latex/pdflatex).
5126
5314
rdb_ensure_file( $rule, $new_source );
5128
if ( ($dependents{$new_source} == 6)
5316
if ( ($dependents{$new_source} == 6)
5129
5317
|| ($dependents{$new_source} == 7)
5131
rdb_add_generated($new_source);
5319
rdb_add_generated($new_source);
5135
5323
my @more_sources = &rdb_set_dependents( $rule );
5136
5324
my $num_new = $#more_sources + 1;
5137
5325
foreach (@more_sources) {
5138
$dependents{$_} = 4;
5326
$dependents{$_} = 4;
5139
5327
if ( ! -e $_ ) {
5140
5328
# Failure was non-existence of makable file
5141
5329
# Leave failure issue to other rules.
5330
5518
my ($fromext,$proptoext,$must,$func_name) = split('\s+',$dep);
5331
5519
if ( $toext eq $proptoext ) {
5332
5520
my $source = "$base_name.$fromext";
5333
# Found match of rule
5521
# Found match of rule
5334
5522
if ($diagnostics) {
5335
5523
print "Found cusdep: $source to make $rule:$new_dest ====\n";
5338
$$Pfrom_rule = "cusdep $fromext $toext $base_name";
5339
#?? print "?? Ensuring rule for '$$Pfrom_rule'\n";
5526
$$Pfrom_rule = "cusdep $fromext $toext $base_name";
5527
#?? print "?? Ensuring rule for '$$Pfrom_rule'\n";
5340
5528
local @PAnew_cmd = ( 'do_cusdep', $func_name );
5341
5529
if ( !-e $new_dest ) {
5342
push @new_sources, $new_dest;
5530
push @new_sources, $new_dest;
5344
5532
if (! rdb_rule_exists( $$Pfrom_rule ) ) {
5345
5533
print "=== Creating rule for '$$Pfrom_rule'\n";
5346
5534
rdb_create_rule( $$Pfrom_rule, 'cusdep', '', \@PAnew_cmd, 3,
5347
5535
$source, $new_dest, $base_name, 0 );
5352
5540
sub{ @$PAint_cmd = @PAnew_cmd; $$Pdest = $new_dest;}
5358
5546
# Source file does not exist
5359
5547
if ( !$force_mode && ( $must != 0 ) ) {
5384
5572
my $source = "$base_name.$fromext";
5385
5573
if ( -e $source ) {
5386
5574
$new_dest = "$base_name.$proptoext";
5387
my $from_rule = "cusdep $fromext $proptoext $base_name";
5575
my $from_rule = "cusdep $fromext $proptoext $base_name";
5388
5576
push @new_sources, $new_dest;
5389
print "Ensuring rule for '$from_rule', to make '$new_dest'\n"
5390
if $diagnostics > -1;
5577
print "Ensuring rule for '$from_rule', to make '$new_dest'\n"
5578
if $diagnostics > -1;
5391
5579
local @PAnew_cmd = ( 'do_cusdep', $func_name );
5392
5580
if (! rdb_rule_exists( $from_rule ) ) {
5393
5581
rdb_create_rule( $from_rule, 'cusdep', '', \@PAnew_cmd, 3,
5394
5582
$source, $new_dest, $base_name, 0 );
5399
5587
sub{ @$PAint_cmd = @PAnew_cmd; $$Pdest = $new_dest;}
5402
5590
rdb_ensure_file( $rule, $new_dest, $from_rule );
5403
5591
# We've now got a spurious file in our rule. But don't mess
5404
5592
# with deleting an item we are in the middle of!
5405
5593
push @deletions, [$rule, $file];
5408
5596
} # End of Rule found
5410
5598
if ( (! -e $file) && $use_make_for_missing_files ) {
5746
5934
# limit. In the second case $too_many_runs is set.
5747
5935
rdb_for_some( [@pre_primary, $primary], \&rdb_make1 );
5748
5936
if ( ($runs > 0) && ! $too_many_passes ) {
5938
if ( $force_mode || (! $failure) ) {
5941
# Get here on failure, without being in force_mode
5942
if ( $newrule_nofile ) {
5944
print "$My_name: Error on run, but found possibility to ",
5945
"make new source files\n";
5751
5950
if ($runs == 0) {
5752
5951
# $failure not set on this pass, so use value from previous pass:
5753
5952
$failure = $previous_failure;
5954
print "But in fact no new files made\n";
5754
5956
if ($failure && !$force_mode ) { last PASS; }
5756
5958
if ( $missing_dvi_pdf ) {
5757
5959
# No output from primary, after completing circular dependence
5758
5960
warn "Failure to make '$missing_dvi_pdf'\n";
5763
print "Make: doing post_primary...\n";
5965
print "Make: doing post_primary...\n";
5765
5967
rdb_for_some( [@post_primary], \&rdb_make1 );
5766
5968
if ( ($runs == 0) || $too_many_passes ) {
5767
5969
# If $too_many_passes is set, it should also be that
5768
5970
# $runs == 0; but for safety, I also checked
5769
5971
# $too_many_passes.
5774
5976
# Re-evaluate rule classification and accessibility,
5775
5977
# but do not change primaries.
5776
5978
# Problem is that %current_primaries gets altered
5805
6007
local @errors = ();
5806
6008
local @warnings = ();
5809
if ($$Plast_message ne '') {
6011
if ($$Plast_message ne '') {
5810
6012
if ($$Plast_result == 200) {
5811
push @warnings, "$rule: $$Plast_message";
5814
push @errors, "$rule: $$Plast_message";
5817
elsif ($$Plast_result == 1) {
5818
push @errors, "$rule: failed to create output file";
5820
elsif ($$Plast_result == 2) {
5821
push @errors, "$rule: gave an error";
5823
elsif ($$Prun_time == 0) {
6013
push @warnings, "$rule: $$Plast_message";
6016
push @errors, "$rule: $$Plast_message";
6019
elsif ($$Plast_result == 1) {
6020
push @errors, "$rule: failed to create output file";
6022
elsif ($$Plast_result == 2) {
6023
push @errors, "$rule: gave an error";
6025
elsif ($$Prun_time == 0) {
5824
6026
# This can have innocuous causes. So don't report
5828
6030
if ($#warnings > -1) {
5829
warn "Collected warning summary (may duplicate other messages):\n";
5830
foreach (@warnings){
6031
warn "Collected warning summary (may duplicate other messages):\n";
6032
foreach (@warnings){
5834
6036
if ($#errors > -1) {
5835
warn "Collected error summary (may duplicate other messages):\n";
6037
warn "Collected error summary (may duplicate other messages):\n";
5840
6042
return $#errors+1;
5888
6090
if ( $$Pdest && (! -e $$Pdest) ) {
5889
# With a non-existent destination, if we haven't made any passes
6091
# With a non-existent destination, if we haven't made any passes
5890
6092
# through a rule, rerunning the rule is good, because the file
5891
6093
# may fail to exist because of being deleted by the user (for ex.)
5892
6094
# rather than because of a failure on a previous run.
5893
6095
# (We could do better with a flag in fdb file.)
5894
# But after the first pass, the situation is different.
5895
# For a primary rule (pdf)latex, the lack of a destination file
5896
# could result from there being zero content due to a missing
5897
# essential input file. The input file could be generated
5898
# by a program to be run later (e.g., a cusdep or bibtex),
5899
# so we should wait until all passes are completed before
6096
# But after the first pass, the situation is different.
6097
# For a primary rule (pdf)latex, the lack of a destination file
6098
# could result from there being zero content due to a missing
6099
# essential input file. The input file could be generated
6100
# by a program to be run later (e.g., a cusdep or bibtex),
6101
# so we should wait until all passes are completed before
5900
6102
# deciding a non-existent destination file is an error.
5901
# For a custom dependency, the rule may be obsolete, and
5902
# if the source file does not exist also, we should simply
5903
# not run the rule, but not set an error condition.
5904
# Any error will arise at the (pdf)latex level due to a
5905
# missing source file at that level.
5906
if ( $$Psource && (! -e $$Psource)
6103
# For a custom dependency, the rule may be obsolete, and
6104
# if the source file does not exist also, we should simply
6105
# not run the rule, but not set an error condition.
6106
# Any error will arise at the (pdf)latex level due to a
6107
# missing source file at that level.
6108
if ( $$Psource && (! -e $$Psource)
5907
6109
# OLD && ( ( $$Pcmd_type eq 'cusdep') )
5909
6111
&& ( ( $$Pcmd_type ne 'primary') )
5911
6113
# Main source file doesn't exist, and rule is NOT primary.
5912
# No action, since a run is pointless. Primary is different:
6114
# No action, since a run is pointless. Primary is different:
5913
6115
# file might be found elsewhere (by kpsearch from (pdf)latex),
5914
6116
# while non-existence of main source file is a clear error.
5916
elsif ( $$Pcmd_type eq 'delegated' ) {
5917
# Delegate to destination rule
5919
elsif ( $pass{$rule}==0) {
5920
push @no_dest, $$Pdest;
5923
if ( $$Pcmd_type eq 'primary' ) {
5924
$missing_dvi_pdf = $$Pdest;
6118
elsif ( $$Pcmd_type eq 'delegated' ) {
6119
# Delegate to destination rule
6121
elsif ( $pass{$rule}==0) {
6122
push @no_dest, $$Pdest;
6125
if ( $$Pcmd_type eq 'primary' ) {
6126
$missing_dvi_pdf = $$Pdest;
5929
6131
&rdb_flag_changes_here(0);
5931
6133
if (!$$Pout_of_date) {
5932
#?? if ( ($$Pcmd_type eq 'primary') && (! $silent) ) {
6134
#?? if ( ($$Pcmd_type eq 'primary') && (! $silent) ) {
5933
6135
# print "Rule '$rule' up to date\n";
5937
6139
if ($diagnostics) { print " remake\n"; }
5938
6140
if (!$silent) {
6082
6284
@post_primary = reverse @post_primary;
6084
6286
if ($diagnostics) {
6085
print "Rule classification: \n";
6086
if ($#requested_targets < 0) {
6087
print " No requested rules\n";
6090
print " Requested rules:\n";
6091
foreach ( @requested_targets ) { print " $_\n"; }
6093
if ($#pre_primary < 0) {
6094
print " No pre-primaries\n";
6097
print " Pre-primaries:\n";
6098
foreach (@pre_primary) { print " $_\n"; }
6100
print " Primaries:\n";
6101
foreach (keys %current_primaries) { print " $_\n"; }
6102
if ($#post_primary < 0) {
6103
print " No post-primaries\n";
6106
print " Post-primaries:\n";
6107
foreach (@post_primary) { print " $_\n"; }
6109
if ($#unusual_one_time < 0) {
6110
print " No inner-level one_time rules, as expected\n";
6113
print " Inner-level one_time rules:\n";
6114
foreach ( @unusual_one_time ) { print " $_\n"; }
6287
print "Rule classification: \n";
6288
if ($#requested_targets < 0) {
6289
print " No requested rules\n";
6292
print " Requested rules:\n";
6293
foreach ( @requested_targets ) { print " $_\n"; }
6295
if ($#pre_primary < 0) {
6296
print " No pre-primaries\n";
6299
print " Pre-primaries:\n";
6300
foreach (@pre_primary) { print " $_\n"; }
6302
print " Primaries:\n";
6303
foreach (keys %current_primaries) { print " $_\n"; }
6304
if ($#post_primary < 0) {
6305
print " No post-primaries\n";
6308
print " Post-primaries:\n";
6309
foreach (@post_primary) { print " $_\n"; }
6311
if ($#unusual_one_time < 0) {
6312
print " No inner-level one_time rules, as expected\n";
6315
print " Inner-level one_time rules:\n";
6316
foreach ( @unusual_one_time ) { print " $_\n"; }
6116
6318
my @normal_one_time = keys %one_time;
6117
if ($#normal_one_time < 0) {
6118
print " No outer-level one_time rules\n";
6121
print " Outer-level one_time rules:\n";
6122
foreach ( @normal_one_time ) { print " $_\n"; }
6319
if ($#normal_one_time < 0) {
6320
print " No outer-level one_time rules\n";
6323
print " Outer-level one_time rules:\n";
6324
foreach ( @normal_one_time ) { print " $_\n"; }
6124
6326
} #end diagnostics
6126
6328
} #END rdb_classify_rules