(scan_m4_files): Normalize filenames.
(trace_used_macros): Trace for AC_DEFUN and AU_DEFUN, also
ask for the filename and the first argument. Populate
%map_traced_defs.
(write_aclocal): Use $map_traced_defs to filter out unused
definitions.
* tests/acloca15.test: New file.
* tests/Makefile.am (TESTS): Add acloca15.test.
+2004-04-15 Alexandre Duret-Lutz <adl@gnu.org>
+
+ * aclocal.in (%map_traced_defs): New variable.
+ (scan_m4_files): Normalize filenames.
+ (trace_used_macros): Trace for AC_DEFUN and AU_DEFUN, also
+ ask for the filename and the first argument. Populate
+ %map_traced_defs.
+ (write_aclocal): Use $map_traced_defs to filter out unused
+ definitions.
+ * tests/acloca15.test: New file.
+ * tests/Makefile.am (TESTS): Add acloca15.test.
+
2004-04-12 Alexandre Duret-Lutz <adl@gnu.org>
* automake.in ($automake_needs_to_reprocess_all_files): Remove.
endif
liba_la_SOURCES = ...
+* aclocal now ensures that AC_DEFUNs and AU_DEFUNs it discovers are
+ really evaluated, before it decides to include them in aclocal.m4.
+ This solves nasty problems with conditional redefinitions of
+ Autoconf macros in /usr/share/aclocal/*.m4 files causing extraneous
+ *.m4 files to be included in any project using these macros.
+ (Calls to AC_PROG_EGREP causing libtool.m4 to be included is the
+ most famous instance of this bug.)
+
\f
New in 1.8:
# Map macro names to file names.
%map = ();
+# Ditto, but records the last definition of each macro as returned by --trace.
+%map_traced_defs = ();
+
# Map file names to file contents.
%file_contents = ();
# Skip some files when running out of srcdir.
next if $file eq 'aclocal.m4';
- $fullfile = $m4dir . '/' . $file;
+ $fullfile = File::Spec->canonpath ("$m4dir/$file");
&scan_file ($fullfile);
}
closedir (DIR);
# All candidate files.
$traces .= join (' ', grep { exists $files{$_} } @file_order) . " ";
# All candidate macros.
- $traces .= join (' ', map { "--trace='$_:\$n'" } (keys %macro_seen));
+ $traces .= join (' ', map { "--trace='$_:\$f:\$n:\$1'" } ('AC_DEFUN',
+ 'AU_DEFUN',
+ keys %macro_seen));
print STDERR "aclocal: running $traces $configure_ac\n" if $verbose;
while ($_ = $tracefh->getline)
{
chomp;
- $traced{$_} = 1 if $macro_seen{$_};
+ my ($file, $macro, $arg1) = split (/:/);
+
+ $traced{$macro} = 1 if $macro_seen{$macro};
+
+ $map_traced_defs{$arg1} = $file
+ if $macro eq 'AC_DEFUN' || $macro eq 'AU_DEFUN';
}
$tracefh->close;
my ($output_file, @macros) = @_;
my $output = '';
- my %files = map { $map{$_} => 1 } @macros;
+ my %files = ();
+ # Get the list of files containing definitions for the macros used.
+ # (Filter out unused macro definitions with $map_traced_defs. This
+ # can happen when an Autoconf macro is conditionally defined:
+ # aclocal sees the potential definition, but this definition is
+ # actually never processed and the Autoconf implementation is used
+ # instead.)
+ for my $m (@macros)
+ {
+ $files{$map{$m}} = 1 if $map{$m} eq $map_traced_defs{$m};
+ }
$files{'acinclude.m4'} = 1 if -f 'acinclude.m4';
%files = strip_redundant_includes %files;
delete $files{$configure_ac};
acloca13.test \
acloca14.test \
acloca15.test \
+acloca16.test \
acoutnoq.test \
acoutpt.test \
acoutpt2.test \
acloca13.test \
acloca14.test \
acloca15.test \
+acloca16.test \
acoutnoq.test \
acoutpt.test \
acoutpt2.test \
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2004 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 does not include definitions that are not actually
+# evaluated.
+
+. ./defs || exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_SUBST([POM])
+END
+
+mkdir m4
+cat >m4/some.m4 <<'EOF'
+AC_DEFUN([AM_SOME_MACRO],
+[AC_DEFUN([AC_SUBST], [GREPME])])
+EOF
+
+$ACLOCAL -I m4
+grep m4/some.m4 aclocal.m4 && exit 1
+: