From: Alexandre Duret-Lutz Date: Thu, 28 Aug 2003 22:49:58 +0000 (+0000) Subject: * aclocal.in (@file_order): New variable, to make sure X-Git-Tag: Release-1-7b~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4cf7056d1667b4c1261920a69b1c78392f50469;p=thirdparty%2Fautomake.git * aclocal.in (@file_order): New variable, to make sure files are output in the opposite order of the -I arguments. (scan_file): Fill it. (trace_used_macros, write_aclocal): Use it. (scan_m4_files): Reverse the directory contents, so that macros from the lexicographically greatest files are preferred. * tests/aclocal9.test, tests/acloca10.test, tests/acloca11.test: New files. * tests/Makefile.am (TESTS): Add them. --- diff --git a/ChangeLog b/ChangeLog index 277e0510b..a025756fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2003-08-29 Alexandre Duret-Lutz + + * aclocal.in (@file_order): New variable, to make sure + files are output in the opposite order of the -I arguments. + (scan_file): Fill it. + (trace_used_macros, write_aclocal): Use it. + (scan_m4_files): Reverse the directory contents, so that + macros from the lexicographically greatest files are preferred. + * tests/aclocal9.test, tests/acloca10.test, tests/acloca11.test: + New files. + * tests/Makefile.am (TESTS): Add them. + 2003-08-24 Alexandre Duret-Lutz For Debian Bug #206299: diff --git a/aclocal.in b/aclocal.in index 53c0374cf..b134cab25 100644 --- a/aclocal.in +++ b/aclocal.in @@ -73,6 +73,10 @@ $force_output = 0; # Which files have been seen. %file_seen = (); +# Remember the order into which we scanned the files. +# It's important to output the contents of aclocal.m4 in the opposite order. +@file_order = (); + # Map macro names to file names. %map = (); @@ -228,7 +232,6 @@ sub parse_arguments (@) close (DEFAULT_DIRLIST); } - return @dirlist; } @@ -313,7 +316,9 @@ sub scan_m4_files (@) } local ($file, $fullfile); - foreach $file (sort grep (! /^\./, readdir (DIR))) + # We reverse the directory contents so that foo2.m4 gets + # used in preference to foo1.m4. + foreach $file (reverse sort grep (! /^\./, readdir (DIR))) { # Only examine .m4 files. next unless $file =~ /\.m4$/; @@ -424,35 +429,41 @@ sub add_file ($) # Scan a single M4 file. Return contents. sub scan_file ($) { - local ($file) = @_; + local ($file) = @_; + + unshift @file_order, $file; - my $fh = new Automake::XFile $file; - my $contents = ''; - while ($_ = $fh->getline) + my $fh = new Automake::XFile $file; + my $contents = ''; + while ($_ = $fh->getline) { - # Ignore `##' lines. - next if /^##/; + # Ignore `##' lines. + next if /^##/; - $contents .= $_; + $contents .= $_; - if (/$ac_defun_rx/) + if (/$ac_defun_rx/) { - if (! defined $map{$1 || $2}) + if (! defined $map{$1 || $2}) { - $map{$1 || $2} = $file; + print STDERR "aclocal: found macro $1 in $file: $.\n" + if $verbose; + $map{$1 || $2} = $file; + } + else + { + # Note: we used to give an error here if we saw a + # duplicated macro. However, this turns out to be + # extremely unpopular. It causes actual problems which + # are hard to work around, especially when you must + # mix-and-match tool versions. + print STDERR "aclocal: ignoring macro $1 in $file: $.\n" + if $verbose; } - - # Note: we used to give an error here if we saw a - # duplicated macro. However, this turns out to be - # extremely unpopular. It causes actual problems which - # are hard to work around, especially when you must - # mix-and-match tool versions. - - print STDERR "aclocal: found macro $1 in $file: $.\n" if $verbose; } } - return $contents; + return $contents; } sub trace_used_macros ($) @@ -464,7 +475,7 @@ sub trace_used_macros ($) my $traces = ($ENV{AUTOM4TE} || 'autom4te'); $traces .= " --language Autoconf-without-aclocal-m4 $filename "; # All candidate files. - $traces .= join (' ', sort keys %files) . " "; + $traces .= join (' ', grep { exists $files{$_} } @file_order) . " "; # All candidate macros. $traces .= join (' ', map { "--trace='$_:\$n'" } (keys %macro_seen)); @@ -493,7 +504,7 @@ sub write_aclocal ($@) my %files = map { $map{$_} => 1 } @macros; $files{'acinclude.m4'} = 1 if -f 'acinclude.m4'; - for $file (sort keys %files) + for $file (grep { exists $files{$_} } @file_order) { my $mtime = mtime $file; $greatest_mtime = $mtime if $greatest_mtime < $mtime; diff --git a/tests/Makefile.am b/tests/Makefile.am index a3213957d..b70ad8be2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,6 +11,10 @@ aclocal5.test \ aclocal6.test \ aclocal7.test \ aclocal8.test \ +aclocal9.test \ +acloca10.test \ +acloca11.test \ +acloca12.test \ acoutnoq.test \ acoutpt.test \ acoutpt2.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 91c256aab..155727b8f 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -120,6 +120,10 @@ aclocal5.test \ aclocal6.test \ aclocal7.test \ aclocal8.test \ +aclocal9.test \ +acloca10.test \ +acloca11.test \ +acloca12.test \ acoutnoq.test \ acoutpt.test \ acoutpt2.test \ diff --git a/tests/acloca10.test b/tests/acloca10.test new file mode 100755 index 000000000..b41b2910f --- /dev/null +++ b/tests/acloca10.test @@ -0,0 +1,55 @@ +#! /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 aclocal define macros in the same order as -I's. +# This is the same as aclocal9.test, with the macro calls reversed. +# (It did make a difference.) + +. ./defs || exit 1 + +set -e + +cat >> configure.in << 'END' +MACRO2 +MACRO1 +END + +mkdir m4_1 m4_2 + +cat >m4_1/somedefs.m4 <> foo]) +AC_DEFUN([MACRO2], [echo macro21 > foo]) +EOF + +cat >m4_2/somedefs.m4 <> foo]) +EOF + +$ACLOCAL -I m4_1 -I m4_2 +$AUTOCONF +./configure +grep macro11 foo +grep macro21 foo + +$ACLOCAL -I m4_2 -I m4_1 +$AUTOCONF +./configure +grep macro12 foo +grep macro21 foo diff --git a/tests/acloca11.test b/tests/acloca11.test new file mode 100755 index 000000000..5c6167215 --- /dev/null +++ b/tests/acloca11.test @@ -0,0 +1,48 @@ +#! /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 that when two files define the same macro in the same +# directory, the macro from the lexically greatest file is used. + +. ./defs || exit 1 + +set -e + +cat >> configure.in << 'END' +MACRO2 +MACRO1 +END + +mkdir m4 + +cat >m4/version1.m4 <> foo]) +AC_DEFUN([MACRO2], [echo macro21 > foo]) +EOF + +cat >m4/version2.m4 <> foo]) +EOF + +$ACLOCAL -I m4 +$AUTOCONF +./configure +grep macro12 foo +grep macro21 foo diff --git a/tests/acloca12.test b/tests/acloca12.test new file mode 100755 index 000000000..3db8104e5 --- /dev/null +++ b/tests/acloca12.test @@ -0,0 +1,49 @@ +#! /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 that when two files define the same macro in the same +# directory, the macro from the lexically greatest file is used. +# Same as acloca11.test, but without calling MACRO2. + +. ./defs || exit 1 + +set -e + +cat >> configure.in << 'END' +MACRO1 +END + +mkdir m4 + +cat >m4/version1.m4 <> foo]) +AC_DEFUN([MACRO2], [echo macro21 > foo]) +EOF + +cat >m4/version2.m4 <> foo]) +EOF + +$ACLOCAL --verbose -I m4 +$AUTOCONF +./configure +grep macro11 foo && exit 1 +grep macro21 foo && exit 1 +grep macro12 foo