From: Alexandre Duret-Lutz Date: Wed, 17 Nov 2004 22:36:54 +0000 (+0000) Subject: * aclocal.in (%file_type, FT_USER, FT_AUTOMAKE_SYSTEM): New variables. X-Git-Tag: Release-1-9b~256 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fbf1ceb8211df3cc7cfdaa6ea7595b13f3af7f7f;p=thirdparty%2Fautomake.git * aclocal.in (%file_type, FT_USER, FT_AUTOMAKE_SYSTEM): New variables. (scan_m4_dirs): New function, extracted from ... (scan_m4_files): ... here. Call scan_m4_files three times, for each FT_ constant. (scan_file): Take a file type argument to update %file_type. (write_aclocal): Do not m4_include files that are not of type FT_USER. * tests/dirlist.test: Make sure m4_include is not used for --acdir files. --- diff --git a/ChangeLog b/ChangeLog index f44036831..15c56dbd1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2004-11-17 Alexandre Duret-Lutz + * aclocal.in (%file_type, FT_USER, FT_AUTOMAKE_SYSTEM): New variables. + (scan_m4_dirs): New function, extracted from ... + (scan_m4_files): ... here. Call scan_m4_files three times, for each + FT_ constant. + (scan_file): Take a file type argument to update %file_type. + (write_aclocal): Do not m4_include files that are not of type FT_USER. + * tests/dirlist.test: Make sure m4_include is not used for --acdir + files. + * tests/defs.in (testaclocaldir): New variable. * tests/aclocal.test: Use it to fix the test. Report from Patrick Welche. diff --git a/aclocal.in b/aclocal.in index 336eaac21..af5e286c5 100644 --- a/aclocal.in +++ b/aclocal.in @@ -92,6 +92,12 @@ my %map_traced_defs = (); # Map file names to file contents. my %file_contents = (); +# Map file names to file types. +my %file_type = (); +use constant FT_USER => 1; +use constant FT_AUTOMAKE => 2; +use constant FT_SYSTEM => 3; + # Map file names to included files (transitively closed). my %file_includes = (); @@ -128,22 +134,14 @@ sub check_acinclude () ################################################################ -# Scan all the installed m4 files and construct a map. -sub scan_m4_files (@) +# scan_m4_dirs($TYPE, @DIRS) +# -------------------------- +# Scan all M4 files installed in @DIRS for new macro definitions. +# Register each file as of type $TYPE (one of the FT_* constants). +sub scan_m4_dirs ($@) { - my @dirlist = @_; - - # First, scan configure.ac. It may contain macro definitions, - # or may include other files that define macros. - &scan_file ($configure_ac, 'aclocal'); + my ($type, @dirlist) = @_; - # Then, scan acinclude.m4 if it exists. - if (-f 'acinclude.m4') - { - &scan_file ('acinclude.m4', 'aclocal'); - } - - # Finally, scan all files in our search path. foreach my $m4dir (@dirlist) { if (! opendir (DIR, $m4dir)) @@ -162,10 +160,29 @@ sub scan_m4_files (@) next if $file eq 'aclocal.m4'; my $fullfile = File::Spec->canonpath ("$m4dir/$file"); - &scan_file ($fullfile, 'aclocal'); + &scan_file ($type, $fullfile, 'aclocal'); } closedir (DIR); } +} + +# Scan all the installed m4 files and construct a map. +sub scan_m4_files () +{ + # First, scan configure.ac. It may contain macro definitions, + # or may include other files that define macros. + &scan_file (FT_USER, $configure_ac, 'aclocal'); + + # Then, scan acinclude.m4 if it exists. + if (-f 'acinclude.m4') + { + &scan_file (FT_USER, 'acinclude.m4', 'aclocal'); + } + + # Finally, scan all files in our search paths. + scan_m4_dirs (FT_USER, @user_includes); + scan_m4_dirs (FT_AUTOMAKE, @automake_includes); + scan_m4_dirs (FT_SYSTEM, @system_includes); # Construct a new function that does the searching. We use a # function (instead of just evaluating $search in the loop) so that @@ -273,15 +290,17 @@ sub add_file ($) # Point to the documentation for underquoted AC_DEFUN only once. my $underquoted_manual_once = 0; -# scan_file ($FILE, $WHERE) +# scan_file ($TYPE, $FILE, $WHERE) # ------------------------- # Scan a single M4 file ($FILE), and all files it includes. # Return the list of included files. +# $TYPE is one of FT_USER, FT_AUTOMAKE, or FT_SYSTEM, depending +# on where the file comes from. # $WHERE is the location to use in the diagnostic if the file # does not exist. -sub scan_file ($$) +sub scan_file ($$$) { - my ($file, $where) = @_; + my ($type, $file, $where) = @_; my $base = dirname $file; # Do not scan the same file twice. @@ -291,6 +310,8 @@ sub scan_file ($$) unshift @file_order, $file; + $file_type{$file} = $type; + fatal "$where: file `$file' does not exist" if ! -e $file; my $fh = new Automake::XFile $file; @@ -356,7 +377,8 @@ sub scan_file ($$) # With Perl 5.8.2 it undefines @inc_files. my @copy = @inc_files; my @all_inc_files = (@inc_files, - map { scan_file ($_, "$file:$inc_lines{$_}") } @copy); + map { scan_file ($type, $_, + "$file:$inc_lines{$_}") } @copy); $file_includes{$file} = \@all_inc_files; return @all_inc_files; } @@ -464,13 +486,16 @@ sub write_aclocal ($@) if (exists $map_traced_defs{$m} && $map{$m} eq $map_traced_defs{$m}); } + # Always include acinclude.m4, even if it does not appear to be used. $files{'acinclude.m4'} = 1 if -f 'acinclude.m4'; + # Do not explicitly include a file that is already indirectly included. %files = strip_redundant_includes %files; + # Never include configure.ac :) delete $files{$configure_ac}; for my $file (grep { exists $files{$_} } @file_order) { - # Check the time stamp of this file, and all files it includes. + # Check the time stamp of this file, and of all files it includes. for my $ifile ($file, @{$file_includes{$file}}) { my $mtime = mtime $ifile; @@ -480,7 +505,8 @@ sub write_aclocal ($@) # If the file to add looks like outside the project, copy it # to the output. The regex catches filenames starting with # things like `/', `\', or `c:\'. - if ($file =~ m,^(?:\w:)?[\\/],) + if ($file_type{$file} != FT_USER + || $file =~ m,^(?:\w:)?[\\/],) { $output .= $file_contents{$file} . "\n"; } @@ -681,7 +707,7 @@ sub parse_arguments () parse_WARNINGS; # Parse the WARNINGS environment variable. parse_arguments; $configure_ac = require_configure_ac; -scan_m4_files (@user_includes, @automake_includes, @system_includes); +scan_m4_files; scan_configure; if (! $exit_code) { diff --git a/tests/dirlist.test b/tests/dirlist.test index 0b6e45a54..1fb122a15 100755 --- a/tests/dirlist.test +++ b/tests/dirlist.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -47,11 +47,17 @@ EOF $ACLOCAL $AUTOCONF + +# there should be no m4_include in aclocal.m4, even tho m4/dirlist contains +# `./dirlist-test' as a relative directory. Only -I directories are subject +# to file inclusion. +grep m4_include aclocal.m4 && exit 1 + grep 'GUILE-VERSION' configure # This bug can occur only when we do a VPATH build of Automake -# (because of the `-I' passed to aclocal in tests/defs) but it's -# OK because this is what `make distcheck' does. +# (because of the `-I' passed to aclocal in tests/defs/aclocal.in) but +# it's OK because VPATH builds are done by `make distcheck'. grep 'I should not be included' configure && exit 1 :