* aclocal.in (add_macro): Do not error out on undefined required
authorAlexandre Duret-Lutz <adl@gnu.org>
Sat, 15 May 2004 18:19:57 +0000 (18:19 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Sat, 15 May 2004 18:19:57 +0000 (18:19 +0000)
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.

ChangeLog
NEWS
aclocal.in
tests/Makefile.am
tests/Makefile.in
tests/acloca17.test [moved from tests/error.test with 60% similarity]
tests/aclocal3.test
tests/aclocal8.test
tests/ammissing.test

index 7857479..db6ac5f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2004-05-15  Alexandre Duret-Lutz  <adl@gnu.org>
 
+       * 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.
+
        * lib/am/texibuild.am (?!GENERIC_INFO?%DEST_INFO_PREFIX%%DEST_SUFFIX%):
        Fold a few lines to reduce the output by 5 lines.
        Suggested by Karl Berry.
diff --git a/NEWS b/NEWS
index eb804a0..93c030d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -34,13 +34,26 @@ New in 1.8a:
     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 0a07dc6..3423841 100644 (file)
@@ -189,17 +189,11 @@ sub add_macro ($)
 {
     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 @@ sub scan_configure_dep ($)
       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 760bca1..507aae1 100644 (file)
@@ -19,6 +19,7 @@ acloca13.test \
 acloca14.test \
 acloca15.test \
 acloca16.test \
+acloca17.test \
 acoutnoq.test \
 acoutpt.test \
 acoutpt2.test \
@@ -200,7 +201,6 @@ empty.test \
 empty2.test \
 empty3.test \
 empty4.test \
-error.test \
 exdir.test \
 exdir2.test \
 exeext.test \
index bb3a32c..561e602 100644 (file)
@@ -136,6 +136,7 @@ acloca13.test \
 acloca14.test \
 acloca15.test \
 acloca16.test \
+acloca17.test \
 acoutnoq.test \
 acoutpt.test \
 acoutpt2.test \
@@ -317,7 +318,6 @@ empty.test \
 empty2.test \
 empty3.test \
 empty4.test \
-error.test \
 exdir.test \
 exdir2.test \
 exeext.test \
similarity index 60%
rename from tests/error.test
rename to tests/acloca17.test
index 176fb32..882b615 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 1996, 2002  Free Software Foundation, Inc.
+# Copyright (C) 2004  Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
 # 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.
+# Make sure aclocal report unused required macros.
 
 . ./defs || exit 1
 
-cat > configure.in << 'END'
-AM_ONE_MACRO
-END
+set -e
 
-# 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])])
+cat >> configure.in << 'END'
+SOME_DEFS
 END
 
-$ACLOCAL && exit 1
-exit 0
+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 d39e86d..4c43c3b 100755 (executable)
@@ -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 @@ AC_DEFUN([GNOME_X_CHECKS], [
 ])
 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 df68b80..c4675d3 100755 (executable)
@@ -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 @@ AC_DEFUN([SOME_DEFS], [
 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 54996cf..63311bb 100755 (executable)
@@ -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