]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
aclocal: just warn if the primary local m4 dir doesn't exist (don't error)
authorPavel Raiskup <praiskup@redhat.com>
Mon, 11 Feb 2013 12:11:51 +0000 (13:11 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 20 Feb 2013 21:08:16 +0000 (22:08 +0100)
Related to automake bug#13514.

Every package which does not need to have the local m4 macro
directory pre-existing in the version control system (because
e.g., it does not have nor need any private m4 macros) would
fail during the "autoreconf -vfi" phase if AC_CONFIG_MACRO_DIRS([m4])
is specified in configure.ac (it could be to instruct tools like
'autopoint' and 'libtoolize' to use 'm4' as the local directory
where to install definitions of their m4 macros, and to instruct
aclocal to look into it).  The failure would go like this:

  autoreconf: Entering directory `.'
  autoreconf: running: aclocal --force
  aclocal: error: couldn't open directory 'm4': No such file or directory
  autoreconf: aclocal failed with exit status: 1

The problem is that when 'aclocal' is run for the first time during
'autoreconf', the directory 'm4' does not exist yet.  It will be
created by e.g., 'libtoolize' or 'autopoint' later on.  During the
second 'aclocal' run, the 'm4' directory exists and aclocal does not
complain.

To work around this issue, we degrade the error to a simple warning.
The warning is still quite useful when aclocal is run by hand - so
we are not removing completely.

See also:
<http://lists.gnu.org/archive/html/bug-automake/2013-01/msg00115.html>
<http://lists.gnu.org/archive/html/automake-patches/2010-02/msg00030.html>
<http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=565663>
<https://bugzilla.redhat.com/show_bug.cgi?id=901333>

* aclocal.in (SCAN_M4_DIRS_SILENT, SCAN_M4_DIRS_WARN)
(SCAN_M4_DIRS_ERROR): New constants.
(scan_m4_dirs): Change the second parameter name to $ERR_LEVEL to
better reflect new semantic. Use new constants.
(scan_m4_files): Adjust to reflect the new 'scan_m4_dirs' semantics.
* t/aclocal-macrodir.tap: Adjust.
* t/aclocal-macrodirs.tap: Likewise.
* THANKS: Update.
* NEWS: Likewise.

Suggested-by: Ben Pfaff <blp@cs.stanford.edu>
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
NEWS
THANKS
aclocal.in
t/aclocal-macrodir.tap
t/aclocal-macrodirs.tap

diff --git a/NEWS b/NEWS
index f629fe2f5c7bb802da43d87e9f24788e31f5ee93..70c45322e3f9f5bfeec52852c1667ab1644c7cf7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -90,6 +90,13 @@ New in 1.13.2:
     Automake 1.13, has turned out to be a similarly very bad idea,
     for exactly the same reason.
 
+  - Aclocal no longer error out if the first local m4 directory (as
+    specified by the '-I' option or the 'AC_CONFIG_MACRO_DIRS' or
+    'AC_CONFIG_MACRO_DIR' macros) doesn't exist; it merely report a
+    warning in the 'unsupported' category.  This is done to support
+    some pre-existing real-world usages; refer to automake bug#13514
+    for more details.
+
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 New in 1.13.1:
diff --git a/THANKS b/THANKS
index 66498d45e6e16e14864959f5586129f89d48abac..5c014bf6b3a2a859d03cddaf6d94931fa7a400be 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -297,6 +297,7 @@ Paul Jarc                       prj@po.cwru.edu
 Paul Lunau                      temp@lunau.me.uk
 Paul Martinolich                martinol@datasync.com
 Paul Thomas                     PTHOMAS@novell.com
+Pavel Raiskup                   praiskup@redhat.com
 Pavel Roskin                    pavel_roskin@geocities.com
 Pavel Sanda                     ps@twin.jikos.cz
 Per Bothner                     bothner@cygnus.com
index b51c09df7755ed424533fe5c654f351ccb7dcad3..e65b0ab2d53b79684aab67bf6ac06d06046ab441 100644 (file)
@@ -165,6 +165,11 @@ my @ac_config_macro_dirs;
 # If set, names a temporary file that must be erased on abnormal exit.
 my $erase_me;
 
+# Constants for the $ERR_LEVEL parameter of the 'scan_m4_dirs' function.
+use constant SCAN_M4_DIRS_SILENT => 0;
+use constant SCAN_M4_DIRS_WARN => 1;
+use constant SCAN_M4_DIRS_ERROR => 2;
+
 ################################################################
 
 # Prototypes for all subroutines.
@@ -355,21 +360,42 @@ sub list_compare (\@\@)
 
 ################################################################
 
-# scan_m4_dirs($TYPE, $ERR_ON_NONEXISTING, @DIRS)
+# scan_m4_dirs($TYPE, $ERR_LEVEL, @DIRS)
 # -----------------------------------------------
 # Scan all M4 files installed in @DIRS for new macro definitions.
 # Register each file as of type $TYPE (one of the FT_* constants).
+# If a directory in @DIRS cannot be read:
+#  - fail hard                if $ERR_LEVEL == SCAN_M4_DIRS_ERROR
+#  - just print a warning     if $ERR_LEVEL == SCAN_M4_DIRS_WA
+#  - continue silently        if $ERR_LEVEL == SCAN_M4_DIRS_SILENT
 sub scan_m4_dirs ($$@)
 {
-  my ($type, $err_on_nonexisting, @dirlist) = @_;
+  my ($type, $err_level, @dirlist) = @_;
 
   foreach my $m4dir (@dirlist)
     {
       if (! opendir (DIR, $m4dir))
        {
          # TODO: maybe avoid complaining only if errno == ENONENT?
-         next unless $err_on_nonexisting;
-         fatal "couldn't open directory '$m4dir': $!";
+          my $message = "couldn't open directory '$m4dir': $!";
+
+          if ($err_level == SCAN_M4_DIRS_ERROR)
+            {
+              fatal $message;
+            }
+          elsif ($err_level == SCAN_M4_DIRS_WARN)
+            {
+              msg ('unsupported', $message);
+              next;
+            }
+          elsif ($err_level == SCAN_M4_DIRS_SILENT)
+            {
+              next; # Silently ignore.
+            }
+          else
+            {
+               prog_error "invalid \$err_level value '$err_level'";
+            }
        }
 
       # We reverse the directory contents so that foo2.m4 gets
@@ -408,11 +434,15 @@ sub scan_m4_files ()
     {
       # Don't complain if the first user directory doesn't exist, in case
       # we need to create it later (can happen if '--install' was given).
-      scan_m4_dirs (FT_USER, !$install, $user_includes[0]);
-      scan_m4_dirs (FT_USER, 1, @user_includes[1..$#user_includes]);
+      scan_m4_dirs (FT_USER,
+                    $install ? SCAN_M4_DIRS_SILENT : SCAN_M4_DIRS_WARN,
+                    $user_includes[0]);
+      scan_m4_dirs (FT_USER,
+                    SCAN_M4_DIRS_ERROR,
+                   @user_includes[1..$#user_includes]);
     }
-  scan_m4_dirs (FT_AUTOMAKE, 1, @automake_includes);
-  scan_m4_dirs (FT_SYSTEM,   1, @system_includes);
+  scan_m4_dirs (FT_AUTOMAKE, SCAN_M4_DIRS_ERROR, @automake_includes);
+  scan_m4_dirs (FT_SYSTEM, SCAN_M4_DIRS_ERROR, @system_includes);
 
   # Construct a new function that does the searching.  We use a
   # function (instead of just evaluating $search in the loop) so that
index 3c66e530cd93c5052722805200da5a11d66000c4..a480c4cd467b22c85f3cec9f2f1d3ad5a528ff34 100755 (executable)
@@ -157,16 +157,24 @@ test_end
 
 #---------------------------------------------------------------------------
 
-test_begin "AC_CONFIG_MACRO_DIR([non-existent]) errors out (1)"
+test_begin "AC_CONFIG_MACRO_DIR([non-existent]) warns with -Wunsupported"
 
 cat > configure.ac << 'END'
 AC_INIT([oops], [1.0])
 AC_CONFIG_MACRO_DIR([non-existent])
+AM_INIT_AUTOMAKE
 END
 
-not $ACLOCAL -Wnone 2>stderr \
+$ACLOCAL -Wno-error 2>stderr \
   && cat stderr >&2 \
   && grep "couldn't open directory 'non-existent'" stderr \
+  && test -f aclocal.m4 \
+  || r='not ok'
+
+rm -rf aclocal.m4 autom4te*.cache
+
+$ACLOCAL -Werror -Wno-unsupported \
+  && test -f aclocal.m4 \
   || r='not ok'
 
 test_end
index 89e424d46bd9fddf9b6045c27b6dcc858d4d1a56..c0bb0aceebc7e6dadc90aa6152d12e33f2cbc4f9 100755 (executable)
@@ -317,23 +317,31 @@ test_end
 
 #---------------------------------------------------------------------------
 
-test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) errors out (1)"
+test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) warns (1)"
 
 cat > configure.ac << 'END'
 AC_INIT([oops], [1.0])
 AC_CONFIG_MACRO_DIRS([non-existent])
+AM_INIT_AUTOMAKE
 END
 
-not $ACLOCAL 2>stderr \
+$ACLOCAL -Wno-error 2>stderr \
   && cat stderr >&2 \
   && grep "couldn't open directory 'non-existent'" stderr \
+  && test -f aclocal.m4 \
+  || r='not ok'
+
+rm -rf aclocal.m4 autom4te*.cache
+
+$ACLOCAL -Werror -Wno-unsupported \
+  && test -f aclocal.m4 \
   || r='not ok'
 
 test_end
 
 #---------------------------------------------------------------------------
 
-test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) errors out (2)"
+test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) warns (2)"
 
 cat > configure.ac << 'END'
 AC_INIT([oops], [1.0])
@@ -346,13 +354,14 @@ not $ACLOCAL 2>stderr \
   && cat stderr >&2 \
   && grep "couldn't open directory 'dir-ko'" stderr \
   && not grep "dir-ok" stderr \
+  && test ! -e aclocal.m4 \
   || r='not ok'
 
 test_end
 
 #---------------------------------------------------------------------------
 
-test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) errors out (tricky setup)"
+test_begin "AC_CONFIG_MACRO_DIRS([existent non-existent]) errors out"
 
 cat > configure.ac << 'END'
 AC_INIT([oops], [1.0])