[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: .m4 dependencies: automake is smarter than aclocal
From: |
Alexandre Duret-Lutz |
Subject: |
Re: .m4 dependencies: automake is smarter than aclocal |
Date: |
Sat, 15 May 2004 20:18:08 +0200 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) |
Hi Jim and Bruno,
Thanks for the report.
Actually automake is not really smarter than aclocal since it
simply distributes the files the latter listed in aclocal.m4.
All the work is really done by aclocal itself.
>>> "Jim" == Jim Meyering <address@hidden> writes:
[...]
Jim> aclocal: m4/gettext.m4: 430: macro `AM_LC_MESSAGES' not found in library
Jim> aclocal: macro `gt_TYPE_INTMAX_T' required but not defined
Jim> aclocal: macro `gt_PRINTF_POSIX' required but not defined
Jim> aclocal: macro `gt_INTDIV0' required but not defined
Jim> aclocal: macro `gl_XSIZE' required but not defined
I'm installing the following patch on HEAD. This should
suppress the latter 4 errors (since aclocal now calls autom4te
which will report missing required macros that are actually
used, there is no need to diagnose these in aclocal itself), and
turn the first error into a warning.
Bruno, you can get rid of this first warning by either moving
the macro out of the Automake namespace, or calling it in a way
that does not match /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/.
For instance I think `[]AM_LC_MESSAGES' would do it.
Technically there would be ways to diagnose missing AM_ macros
more accurately (e.g., creating dummy definitions on-the-fly the
tracing whether they are used), but aclocal is already
complicated enough and it does not seem worth to make it worse
just for the sake of the Automake namespace.
2004-05-15 Alexandre Duret-Lutz <address@hidden>
* aclocal.in (add_macro): Do not error out on undefined required
macros. We are not sure they are really used, and Autoconf
already diagnoses them.
(scan_configure_dep): Diagnose missing AM_ macros as warnings rather
than errors.
* tests/aclocal3.test, tests/ammissing.test: Adjust to expect a
warning instead of an error.
* tests/aclocal8.test: AC_REQUIRE an undefined macro in an unused
macro, and ensure aclocal works anyway.
* tests/acloca17.test: New file.
* tests/error.test: Delete, superseded by tests/acloca17.test.
* tests/Makefile.am (TESTS): Add acloca17.test and remove error.test.
Report from Jim Meyering.
Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.271
diff -u -r1.271 NEWS
--- NEWS 13 May 2004 22:02:41 -0000 1.271
+++ NEWS 15 May 2004 18:10:05 -0000
@@ -34,13 +34,26 @@
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.)
+* Changes to aclocal:
+
+ - 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.)
+
+ - Do not complain about missing conditionally AC_REQUIREd macros
+ that are not actually used. In 1.8.x aclocal would correctly
+ determine which of these macros were really needed (and include
+ only these in the package); unfortunately it would also require
+ all of them to be present in order to run. This created
+ situations were aclocal would not work on a tarball distributing
+ all the macros it uses. For instance running aclocal on a project
+ containing only the subset of the Gettext macros in use by the
+ project did not work, because gettext conditionally requires other
+ macros.
* Diagnose AC_CONFIG_AUX_DIR calls following AM_INIT_AUTOMAKE. (PR/49)
Index: aclocal.in
===================================================================
RCS file: /cvs/automake/automake/aclocal.in,v
retrieving revision 1.102
diff -u -r1.102 aclocal.in
--- aclocal.in 15 Apr 2004 07:51:46 -0000 1.102
+++ aclocal.in 15 May 2004 18:10:05 -0000
@@ -189,17 +189,11 @@
{
local ($macro) = @_;
- # We want to ignore AC_ macros. However, if an AC_ macro is
- # defined in (eg) acinclude.m4, then we want to make sure we mark
- # it as seen.
- return if $macro =~ /^AC_/ && ! defined $map{$macro};
-
- if (! defined $map{$macro})
- {
- warn "aclocal: macro `$macro' required but not defined\n";
- $exit_code = 1;
- return;
- }
+ # Ignore unknown required macros. Either they are not really
+ # needed (e.g., a conditional AC_REQUIRE), in which case aclocal
+ # should be quiet, or they are needed and Autoconf itself will
+ # complain when we trace for macro usage later.
+ return unless defined $map{$macro};
print STDERR "aclocal: saw macro $macro\n" if $verbose;
$macro_seen{$macro} = 1;
@@ -272,8 +266,10 @@
if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
{
# Macro not found, but AM_ prefix found.
- warn "aclocal: $file: $line: macro `$2' not found in library\n";
- $exit_code = 1;
+ # Make this just a warning, because we do not know whether
+ # the macro is actually used (it could be called conditionally).
+ warn ("aclocal:$file:$line: warning: "
+ . "macro `$2' not found in library\n");
}
}
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.561
diff -u -r1.561 Makefile.am
--- tests/Makefile.am 14 May 2004 20:13:53 -0000 1.561
+++ tests/Makefile.am 15 May 2004 18:10:13 -0000
@@ -19,6 +19,7 @@
acloca14.test \
acloca15.test \
acloca16.test \
+acloca17.test \
acoutnoq.test \
acoutpt.test \
acoutpt2.test \
@@ -200,7 +201,6 @@
empty2.test \
empty3.test \
empty4.test \
-error.test \
exdir.test \
exdir2.test \
exeext.test \
Index: tests/acloca17.test
===================================================================
RCS file: tests/acloca17.test
diff -N tests/acloca17.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/acloca17.test 15 May 2004 18:10:13 -0000
@@ -0,0 +1,43 @@
+#! /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 report unused required macros.
+
+. ./defs || exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+SOME_DEFS
+END
+
+mkdir m4
+cat >m4/somedefs.m4 <<EOF
+AC_DEFUN([SOME_DEFS], [
+ AC_REQUIRE([UNDEFINED_MACRO])
+])
+EOF
+
+# FIXME: We want autom4te's 'undefined required macro' warning to be fatal,
+# but have no means to say so to aclocal. We use WARNINGS=error instead.
+
+WARNINGS=error $ACLOCAL -I m4 2>stderr && exit 1
+cat stderr
+grep 'configure.in:4:.*UNDEFINED_MACRO' stderr
Index: tests/aclocal3.test
===================================================================
RCS file: /cvs/automake/automake/tests/aclocal3.test,v
retrieving revision 1.2
diff -u -r1.2 aclocal3.test
--- tests/aclocal3.test 14 Nov 2003 21:25:58 -0000 1.2
+++ tests/aclocal3.test 15 May 2004 18:10:13 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 1998, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1998, 2002, 2004 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -31,5 +31,6 @@
])
END
-$ACLOCAL -I macros && exit 1
-exit 0
+$ACLOCAL -I macros 2>stderr
+cat stderr
+grep 'macros/gnome.m4:2:.*AM_PATH_GTK.*not found' stderr
Index: tests/aclocal8.test
===================================================================
RCS file: /cvs/automake/automake/tests/aclocal8.test,v
retrieving revision 1.1
diff -u -r1.1 aclocal8.test
--- tests/aclocal8.test 24 Aug 2003 02:00:58 -0000 1.1
+++ tests/aclocal8.test 15 May 2004 18:10:13 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2003 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -36,9 +36,11 @@
EOF
echo 'AC_DEFUN([MACRO1],)' >m4/macro1.m4
-echo 'AC_DEFUN([MACRO2],)' >m4/macro2.m4
+echo 'AC_DEFUN([MACRO2], [AC_REQUIRE([AM_UNUSED_MACRO])])' >m4/macro2.m4
-$ACLOCAL -I m4
+$ACLOCAL -I m4 >output 2>&1
+cat output
+test 0 = `wc -l <output`
grep macro1.m4 aclocal.m4
grep macro2.m4 aclocal.m4 && exit 1
:
Index: tests/ammissing.test
===================================================================
RCS file: /cvs/automake/automake/tests/ammissing.test,v
retrieving revision 1.3
diff -u -r1.3 ammissing.test
--- tests/ammissing.test 14 Nov 2003 21:25:58 -0000 1.3
+++ tests/ammissing.test 15 May 2004 18:10:13 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 1997, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1997, 2002, 2004 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -24,5 +24,6 @@
echo AM_ZARDOZ >> configure.in
-$ACLOCAL && exit 1
-exit 0
+$ACLOCAL 2>stderr
+cat stderr
+grep 'configure.in:.*AM_ZARDOZ.*not found' stderr
Index: tests/error.test
===================================================================
RCS file: tests/error.test
diff -N tests/error.test
--- tests/error.test 14 Nov 2003 21:25:58 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-#! /bin/sh
-# Copyright (C) 1996, 2002 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.
-
-# Test to make sure error handling in add_file works.
-
-. ./defs || exit 1
-
-cat > configure.in << 'END'
-AM_ONE_MACRO
-END
-
-# Set up a strange environment, where AM_ONE_MACRO exists but its
-# dependency does not.
-cat > AM_ONE_MACRO.m4 << 'END'
-AC_DEFUN([AM_ONE_MACRO],
-[AC_REQUIRE([AM_NONEXISTENT_MACRO])])
-END
-
-$ACLOCAL && exit 1
-exit 0
--
Alexandre Duret-Lutz