Subject: bug#8111: after adding a(nother) subconfigure, rerunning make fails

From: Ralf Wildenhues <[email-masked]>
Date: Fri, 25 Feb 2011 21:46:57 +0100

[ adding autoconf-patches; this is <http://debbugs.gnu.org/8111> ]

* Jack Kelly wrote on Thu, Feb 24, 2011 at 11:49:44PM CET:
> On Fri, Feb 25, 2011 at 6:36 AM, Ralf Wildenhues wrote:
> > Can we fix this somehow in either Autoconf or Automake?
> 
> Could we save the results of tracing AC_CONFIG_SUBDIRS calls? If
> there's a change, invoke ./config.status --recheck. If not,
> config.status --recheck --no-recursion.

Well, the rule that invokes 'config.status --recheck', let's call it the
config.status rule, does not invoke any autotools, thus no m4.  Any
rule that invokes m4 must be a developer rule, but the config.status
rule is a user rule, which is even in place with maintainer-mode.
So we cannot mix these two concepts.

(Aside, config.status --recheck invokes configure with --no-create and
--no-recursion added, among the other arguments.  Sorry for the
nitpicking.)

But I think we can still have our cake and eat it too: if I remove the
--no-recursion from the list of arguments passed to configure, then the
test starts to pass (once the missing AC_OUTPUT in the lib/configure.ac
is fixed).  Of course, we don't want to do that outright: if there is
already a makefile in the subdir, then we don't want to recurse: the
subdir makefile might want to run other rebuilding rules first.  But if
there isn't, and there is a configure script we can run, then I think we
should do that.  Since 'makefile' might be spelt in various different
ways, we can take presence of 'config.status' in the subdir build tree
as indicator, that should be good enough.

I'm still wondering whether we should rename the option
--new-recursion-only however, that would be more precise.
Other than that, the patch below seems to do what I want.

Comments?

(And of course the test will need to be rewritten for Autoconf's test
suite and amended to ensure we don't recurse when we shouldn't, and
documentation and all that ...)

Thanks,
Ralf

diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 337aba7..ce80dde 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -751,7 +751,7 @@ do
 
   -no-recursion | --no-recursion | --no-recursio | --no-recursi \
   | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
-    no_recursion=yes ;;
+    no_recursion=new-only ;;
 
   -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
   | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index a1a857b..00d5721 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -1181,6 +1181,11 @@ if test "$no_recursion" != yes; then
     # parts of a large source tree are present.
     test -d "$srcdir/$ac_dir" || continue
 
+    # If recursing to new subpackages only, skip those that have makefiles.
+    if test "$no_recursion" = new-only && test -x $ac_dir/config.status; then
+      continue
+    fi
+
     ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)"
     _AS_ECHO_LOG([$ac_msg])
     _AS_ECHO([$ac_msg])