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-29 Alexandre Duret-Lutz <adl@gnu.org>
+
+ * 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 <adl@gnu.org>
For Debian Bug #206299:
# 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 = ();
close (DEFAULT_DIRLIST);
}
-
return @dirlist;
}
}
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$/;
# 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 ($)
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));
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;
aclocal6.test \
aclocal7.test \
aclocal8.test \
+aclocal9.test \
+acloca10.test \
+acloca11.test \
+acloca12.test \
acoutnoq.test \
acoutpt.test \
acoutpt2.test \
aclocal6.test \
aclocal7.test \
aclocal8.test \
+aclocal9.test \
+acloca10.test \
+acloca11.test \
+acloca12.test \
acoutnoq.test \
acoutpt.test \
acoutpt2.test \
--- /dev/null
+#! /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 <<EOF
+AC_DEFUN([MACRO1], [echo macro11 >> foo])
+AC_DEFUN([MACRO2], [echo macro21 > foo])
+EOF
+
+cat >m4_2/somedefs.m4 <<EOF
+AC_DEFUN([MACRO1], [echo macro12 >> 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
--- /dev/null
+#! /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 <<EOF
+AC_DEFUN([MACRO1], [echo macro11 >> foo])
+AC_DEFUN([MACRO2], [echo macro21 > foo])
+EOF
+
+cat >m4/version2.m4 <<EOF
+AC_DEFUN([MACRO1], [echo macro12 >> foo])
+EOF
+
+$ACLOCAL -I m4
+$AUTOCONF
+./configure
+grep macro12 foo
+grep macro21 foo
--- /dev/null
+#! /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 <<EOF
+AC_DEFUN([MACRO1], [echo macro11 >> foo])
+AC_DEFUN([MACRO2], [echo macro21 > foo])
+EOF
+
+cat >m4/version2.m4 <<EOF
+AC_DEFUN([MACRO1], [echo macro12 >> foo])
+EOF
+
+$ACLOCAL --verbose -I m4
+$AUTOCONF
+./configure
+grep macro11 foo && exit 1
+grep macro21 foo && exit 1
+grep macro12 foo