From 1177b44e1d5a4e8db8579ec39219a2437f7ecf95 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Thu, 10 Jun 2004 21:12:10 +0000 Subject: [PATCH] For Debian Bug #251820: * aclocal.in (scan_file): Keep track of the location where each file is included, and display it when reporting a missing file. Pass this location to scan_file as a second argument. (scan_m4_files): Adjust calls to scan_file. * tests/acloca14.test: Add a test for this diagnostic. --- ChangeLog | 9 +++++++++ aclocal.in | 29 +++++++++++++++++++++-------- tests/acloca14.test | 5 +++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66aa647f8..2a010ea1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-06-10 Alexandre Duret-Lutz + + For Debian Bug #251820: + * aclocal.in (scan_file): Keep track of the location where each + file is included, and display it when reporting a missing file. + Pass this location to scan_file as a second argument. + (scan_m4_files): Adjust calls to scan_file. + * tests/acloca14.test: Add a test for this diagnostic. + 2004-06-07 Alexandre Duret-Lutz * m4/tar.m4 (_AM_PROG_TAR): Split the definition of $_am_tools diff --git a/aclocal.in b/aclocal.in index 3423841cd..3a3f45e15 100644 --- a/aclocal.in +++ b/aclocal.in @@ -133,12 +133,12 @@ sub scan_m4_files (@) # First, scan configure.ac. It may contain macro definitions, # or may include other files that define macros. - &scan_file ($configure_ac); + &scan_file ($configure_ac, 'aclocal'); # Then, scan acinclude.m4 if it exists. if (-f 'acinclude.m4') { - &scan_file ('acinclude.m4'); + &scan_file ('acinclude.m4', 'aclocal'); } # Finally, scan all files in our search path. @@ -163,7 +163,7 @@ sub scan_m4_files (@) next if $file eq 'aclocal.m4'; $fullfile = File::Spec->canonpath ("$m4dir/$file"); - &scan_file ($fullfile); + &scan_file ($fullfile, 'aclocal'); } closedir (DIR); } @@ -293,11 +293,15 @@ sub add_file ($) # Point to the documentation for underquoted AC_DEFUN only once. my $underquoted_manual_once = 0; -# Scan a single M4 file, and all files it includes. +# scan_file ($FILE, $WHERE) +# ------------------------- +# Scan a single M4 file ($FILE), and all files it includes. # Return the list of included files. -sub scan_file ($) +# $WHERE is the location to use in the diagnostic if the file +# does not exist. +sub scan_file ($$) { - my ($file) = @_; + my ($file, $where) = @_; my $base = dirname $file; # Do not scan the same file twice. @@ -307,9 +311,16 @@ sub scan_file ($) unshift @file_order, $file; + if (! -e $file) + { + print STDERR "$where: file `$file' does not exist\n"; + exit 1; + } + my $fh = new Automake::XFile $file; my $contents = ''; my @inc_files = (); + my %inc_lines = (); while ($_ = $fh->getline) { # Ignore `##' lines. @@ -360,15 +371,17 @@ sub scan_file ($) $ifile = "$base/$ifile" unless $base eq '.' || File::Spec->file_name_is_absolute ($ifile); push (@inc_files, $ifile); + $inc_lines{$ifile} = $.; } } $file_contents{$file} = $contents; # For some reason I don't understand, it does not work - # to do `map { scan_file ($_) } @inc_files' below. + # to do `map { scan_file ($_, ...) } @inc_files' below. # With Perl 5.8.2 it undefines @inc_files. my @copy = @inc_files; - my @all_inc_files = (@inc_files, map { scan_file ($_) } @copy); + my @all_inc_files = (@inc_files, + map { scan_file ($_, "$file:$inc_lines{$_}") } @copy); $file_includes{$file} = \@all_inc_files; return @all_inc_files; } diff --git a/tests/acloca14.test b/tests/acloca14.test index 5ad6d16e8..ad48479c0 100755 --- a/tests/acloca14.test +++ b/tests/acloca14.test @@ -109,3 +109,8 @@ $sleep $MAKE grep 'defs/f.m4' aclocal.m4 $MAKE testdist2 + +# Make sure aclocal diagnose missing included files with correct `file:line:'. +rm -f b.m4 +$ACLOCAL 2>stderr && exit 1 +grep 'a.m4:1:.*b.m4.*does not exist' stderr -- 2.47.2