From: Alexandre Duret-Lutz Date: Sun, 7 Sep 2003 13:26:44 +0000 (+0000) Subject: Changes to m4_included files should also cause aclocal.m4 to change. X-Git-Tag: Release-1-7b~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7d7581b3a22ede67c2836e7b1788d7820a9add1;p=thirdparty%2Fautomake.git Changes to m4_included files should also cause aclocal.m4 to change. * aclocal.in (m4_include_rx): New variable. (scan_configure_dep): New function. (scan_configure, add_file): Simplify using scan_configure_dep. * tests/Makefile.am (TESTS): Add acloca13.test. * tests/aclocal13.test: New file. --- diff --git a/ChangeLog b/ChangeLog index 671c06cbc..378c30ca5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2003-09-07 Alexandre Duret-Lutz + Changes to m4_included files should also cause aclocal.m4 to change. + * aclocal.in (m4_include_rx): New variable. + (scan_configure_dep): New function. + (scan_configure, add_file): Simplify using scan_configure_dep. + * tests/Makefile.am (TESTS): Add acloca13.test. + * tests/aclocal13.test: New file. + * tests/instsh.test: Do not reset $ACLOCAL and $AUTOMAKE now that we have fake version in the $PATH. diff --git a/aclocal.in b/aclocal.in index 96e19685c..8a1e612ee 100644 --- a/aclocal.in +++ b/aclocal.in @@ -39,6 +39,7 @@ use Automake::Configure_ac; use Automake::Channels; use Automake::XFile; use Automake::FileUtils; +use File::Basename; use File::stat; # Note that this isn't pkgdatadir, but a separate directory. @@ -96,6 +97,9 @@ $ac_defun_rx = "A[CU]_DEFUN\\((?:\\[([^]]+)\\]|([^],)\n]+))"; # Matches an AC_REQUIRE line. $ac_require_rx = "AC_REQUIRE\\((?:\\[([^]]+)\\]|([^],)\n]+))\\)"; +# Matches an m4_include line +$m4_include_rx = "(?:m4_)?s?include\\((?:\\[([^]]+)\\]|([^],)\n]+))\\)"; + local (@dirlist) = &parse_arguments (@ARGV); @@ -238,40 +242,13 @@ sub parse_arguments (@) sub scan_configure () { - if (! open (CONFIGURE, $configure_ac)) - { - print STDERR "aclocal: couldn't open `$configure_ac': $!\n"; - exit 1; - } - - my $mtime = mtime $configure_ac; - $greatest_mtime = $mtime if $greatest_mtime < $mtime; - # Make sure we include acinclude.m4 if it exists. if (-f 'acinclude.m4') { &add_file ('acinclude.m4'); } - while () - { - # Remove comments from current line. - s/\bdnl\b.*$//; - s/\#.*$//; - - # Search for things we know about. The "search" sub is - # constructed dynamically by scan_m4_files. The last - # parenthetical match makes sure we don't match things that - # look like macro assignments or AC_SUBSTs. - if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/) - { - # Macro not found, but AM_ prefix found. - warn "aclocal: $configure_ac: $.: macro `$2' not found in library\n"; - $exit_code = 1; - } - } - - close (CONFIGURE); + &scan_configure_dep ($configure_ac); } ################################################################ @@ -369,26 +346,39 @@ sub add_macro ($) &add_file ($map{$macro}); } -# Add a file to output. -sub add_file ($) +# scan_contents ($file) +# -------------------------------- +my %scanned_configure_dep = (); +sub scan_configure_dep ($) { - local ($file) = @_; - - # Only add a file once. - return if ($file_seen{$file}); - $file_seen{$file} = 1; + my ($file) = @_; + # Do not scan a file twice. + return () + if exists $scanned_configure_dep{$file}; + $scanned_configure_dep = 1; my $mtime = mtime $file; $greatest_mtime = $mtime if $greatest_mtime < $mtime; - my (@rlist); - foreach (split ("\n", $file_contents{$file})) + my $contents = exists $file_contents{$file} ? + $file_contents{$file} : contents $file; + + my $line = 0; + my @rlist = (); + my @ilist = (); + foreach (split ("\n", $contents)) { + ++$line; # Remove comments from current line. s/\bdnl\b.*$//; s/\#.*$//; - if (/$ac_require_rx/g) + while (/$m4_include_rx/g) + { + push (@ilist, $1 || $2); + } + + while (/$ac_require_rx/g) { push (@rlist, $1 || $2); } @@ -400,16 +390,27 @@ sub add_file ($) if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/) { # Macro not found, but AM_ prefix found. - warn "aclocal: $configure_ac: $.: macro `$2' not found in library\n"; + warn "aclocal: $file: $line: macro `$2' not found in library\n"; $exit_code = 1; } } - local ($macro); - foreach $macro (@rlist) - { - &add_macro ($macro); - } + + &add_macro ($_) foreach (@rlist); + my $dirname = dirname $file; + scan_configure_dep (File::Spec->rel2abs ($_, $dirname)) foreach (@ilist); +} + +# Add a file to output. +sub add_file ($) +{ + local ($file) = @_; + + # Only add a file once. + return if ($file_seen{$file}); + $file_seen{$file} = 1; + + scan_configure_dep $file; } # Point to the documentation for underquoted AC_DEFUN only once. diff --git a/tests/Makefile.am b/tests/Makefile.am index ae6ed2686..5b0a28f1d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -15,6 +15,7 @@ aclocal9.test \ acloca10.test \ acloca11.test \ acloca12.test \ +acloca13.test \ acoutnoq.test \ acoutpt.test \ acoutpt2.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index dff977e75..a0e255a9a 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -125,6 +125,7 @@ aclocal9.test \ acloca10.test \ acloca11.test \ acloca12.test \ +acloca13.test \ acoutnoq.test \ acoutpt.test \ acoutpt2.test \ diff --git a/tests/acloca13.test b/tests/acloca13.test new file mode 100755 index 000000000..8386f2096 --- /dev/null +++ b/tests/acloca13.test @@ -0,0 +1,62 @@ +#! /bin/sh +# Copyright (C) 2003 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake 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, or (at your option) +# any later version. +# +# GNU Automake 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 Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Make sure changes to m4_included files also cause aclocal.m4 to change. + +. ./defs || exit 1 + +set -e + +cat >> configure.in << 'END' +m4_include([somefile.m4]) +END + +mkdir m4 + +echo MACRO1 >somefile.m4 +echo HELLO >m4/otherfile.m4 + +cat >m4/version1.m4 <m4/version2.m4 <somefile.m4 + +$ACLOCAL -I m4 +grep version2 aclocal.m4 && exit 1 +grep version1 aclocal.m4 + +$sleep +# aclocal.m4 should change if we touch otherfile.m4 +touch m4/otherfile.m4 +$sleep +$ACLOCAL -I m4 +test `ls -1t aclocal.m4 m4/otherfile.m4 | sed 1q` = aclocal.m4