Hi Stefano,

> >> [ ... ]
> > 
> > Ping.  Are you considering my opinions OK?
> >
> Basically yes; and a patch would obviously be welcome, if you want
> to speed up the fixing of this bug ;-)

First proposal attached :) (0001-*).

> > Quickly again (let's say that AC_CONFIG_MACRO_DIR([m4]) is specified):
> >   a) Warn because 'aclocal -I m4'
> >
> It should be just 'aclocal' here.  The point of the new code is that,
> if you specify a directory as argument to AC_CONFIG_MACRO_DIR, you
> don't need to repeat it again on the aclocal command line nor in
> ACLOCAL_AMFLAGS anymore.

This may cause problems when user wants to use gettext && specify target
directory on a different place than 'm4'.  For these I'm attaching the
0003-* patch.

> >      wants to search 'm4' dir which does not
> >      exist.  Ignoring this completely is imo idea;
> >
> s/idea/bad idea/ here, I guess.  Right?  IF yes, I mostly agree.

Yes - typo, sorry.

> To summarize: for what concerns automake, I think degrading the fatal
> error in aclocal to a warning is the best and safest approach for now.
> Improvements or re-tightening can be done later, if needed.

Done.

The purpose of patch 0002-* should be obvious from its description.
Patches are generated against 1.13.2 branch.

Pavel


>From ac4e636a2c726437659c57634fb29b38932b412d Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <prais...@redhat.com>
Date: Fri, 8 Feb 2013 12:49:30 +0100
Subject: [PATCH 1/3] maint:  Warn only if primary -Idir directory does not
 exist

Every bootstrapping process which does not need to have the "target" macro
directory existing in version control system (because it does not have any
user-defined macros) would fail during autoreconf -vfi phase if the
AC_CONFIG_MACRO_DIRS([m4]) is specified (to force tools to use 'm4' as
target directory and to instruct aclocal to look into this directory):

    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 the aclocal is run for the first time during
autoreconf, the directory 'm4' does not exist yet.  It will be created by
e.g. by 'libtoolize' later on.  During the second run (after libtoolize),
the 'm4' directory exists and aclocal does not complain anything.

For that reason, we degrade the error to warning only (when the --install
option is not passed).  The warning is quite useful for running aclocal by
hand - so not removing completely.

See:
<http://lists.gnu.org/archive/html/bug-automake/2013-01/msg00115.html>
<http://lists.gnu.org/archive/html/automake-patches/2010-02/msg00030.html>

* aclocal.in (scan_m4_dirs): Change the $err_on_nonexisting semantic so
that 2 means error now, 1 is warning.  Fail or warn only when expected.
(scan_m4_files): Switch passed values 1 ~> 2 to reflect ^^^.

Suggested-by: Ben Pfaff <b...@cs.stanford.edu>
---
 aclocal.in | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/aclocal.in b/aclocal.in
index b51c09d..6fa8eeb 100644
--- a/aclocal.in
+++ b/aclocal.in
@@ -359,6 +359,9 @@ sub list_compare (\@\@)
 # -----------------------------------------------
 # Scan all M4 files installed in @DIRS for new macro definitions.
 # Register each file as of type $TYPE (one of the FT_* constants).
+# Warn on non-existing include directory when $ERR_ON_NONEXISTING
+# equals to 1, fail without discussion if it equals to 2 and don't
+# complain anyting when it equals to zero.
 sub scan_m4_dirs ($$@)
 {
   my ($type, $err_on_nonexisting, @dirlist) = @_;
@@ -368,8 +371,14 @@ sub scan_m4_dirs ($$@)
       if (! opendir (DIR, $m4dir))
 	{
 	  # TODO: maybe avoid complaining only if errno == ENONENT?
+	  my $message = "couldn't open directory '$m4dir': $!";
 	  next unless $err_on_nonexisting;
-	  fatal "couldn't open directory '$m4dir': $!";
+
+	  # fail without discussion for non-"primary" macro directory
+	  fatal $message if $err_on_nonexisting == 2;
+	  # just a warning for the "primary" directory
+	  msg ('unsupported', $message);
+	  next
 	}
 
       # We reverse the directory contents so that foo2.m4 gets
@@ -409,10 +418,10 @@ 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, 2, @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, 2, @automake_includes);
+  scan_m4_dirs (FT_SYSTEM,   2, @system_includes);
 
   # Construct a new function that does the searching.  We use a
   # function (instead of just evaluating $search in the loop) so that
-- 
1.7.11.7

>From f852616715d0de12eb32a19386b274c5060be58d Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <prais...@redhat.com>
Date: Fri, 8 Feb 2013 13:27:08 +0100
Subject: [PATCH 2/3] maint:  Fix for more-than-once specified directories

Do not explore these directories multiple times in 'aclocal'.  This causes
problems on older packages having specified:

    configure.ac:  AC_CONFIG_MACRO_DIRS([m4])
    Makefile.am:   ACLOCAL_AMFLAGS = -I m4

When the m4 directory does not exist.

See:
<http://lists.gnu.org/archive/html/bug-automake/2013-01/msg00115.html>

* aclocal.in (scan_m4_files): Unique multiply specified directories.
---
 aclocal.in | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/aclocal.in b/aclocal.in
index 6fa8eeb..2a9e83b 100644
--- a/aclocal.in
+++ b/aclocal.in
@@ -415,6 +415,16 @@ sub scan_m4_files ()
 
   if (@user_includes)
     {
+      # Don't explore the same directory multiple times.  This is here not
+      # only for speedup purposes.  We need this when user has e.g.
+      # specified 'ACLOCAL_AMFLAGS = -I m4' and user has also set
+      # AC_CONFIG_MACRO_DIR[S]([m4]) in configure.ac.  This forces the 'm4'
+      # directory occur twice here and fail on the second call to
+      # scan_m4_dirs([m4]) when non existent.
+      # TODO: Should'nt there be rather check in scan_m4_dirs for
+      #       @user_includes[0]?
+      @user_includes = uniq @user_includes;
+
       # 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]);
-- 
1.7.11.7

>From fddbb05c9c8722cfb1b8b3d8356d43ff9ca4e4bf Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <prais...@redhat.com>
Date: Fri, 8 Feb 2013 13:42:38 +0100
Subject: [PATCH 3/3] docs: Mention consequences with AC_CONFIG_MACRO_DIRS

* doc/automake.texi: Document possible problems if user wants to specify
AC_CONFIG_MACRO_DIRS to point somewhere else then to the directory 'm4'.

See:
<http://lists.gnu.org/archive/html/bug-automake/2013-01/msg00115.html>
---
 doc/automake.texi | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/doc/automake.texi b/doc/automake.texi
index e700ab9..944fd9d 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -3614,6 +3614,23 @@ AC_CONFIG_MACRO_DIRS([m4])
 @command{aclocal} will then take care of automatically adding @file{m4/}
 to its search path for m4 files.
 
+There is strictly encouraged not to change the 'm4' directory name to
+some different name at the moment.  There still exist several
+incompatibilities among tools which may be run during @code{autoreconf} and
+how they deal with its custom macros.  Note that (e.g.)
+@command{gettextize} installs its macros into first @code{-I DIR} directory
+set by @code{ACLOCAL_AMFLAGS} macro (which is not supported now), otherwise
+defaults to store it into @file{m4} dir.  You also need to specify
+@file{m4} in @code{AC_CONFIG_MACRO_DIRS} at the first place if the
+@file{m4} directory does not exist in distribution by default (to be
+created by @code{aclocal} or other tool).  The least problematic way seems
+to be now:
+
+@example
+configure.ac: AC_CONFIG_MACRO_DIRS([m4])
+Makefile.am:  # **NO** ACLOCAL_AMFLAGS
+@end example
+
 When @samp{aclocal} is run, it will build an @file{aclocal.m4}
 that @code{m4_include}s any file from @file{m4/} that defines a
 required macro.  Macros not found locally will still be searched in
-- 
1.7.11.7

Reply via email to