Subject: bug#7864: odd configure bug with dependency checking and conditional C++ support

From: Ralf Wildenhues <[email-masked]>
Date: Wed, 19 Jan 2011 19:13:31 +0100

[ adding automake-patches, dropping bug-gnulib ]

Hi Eric,

thanks for the report!

* Eric Blake wrote on Wed, Jan 19, 2011 at 05:52:08AM CET:
> checking dependency style of :... mkdir: cannot create directory
> `conftest.dir': File or Directory already exists
> cp: accessing `conftest.dir': Bad data
> ./configure: line 28036: cd: conftest.dir: Not a directory
> ./configure: line 28047: ./depcomp: No such file or directory
> none

> First - should autoconf's m4/depend.m4 be changed to use mkdir -p
> instead of mkdir, when creating conftest.dir?

No, that won't help if it is a file, not a directory.

> Should it be taught that
> if CXX is :, that the dependency check should be skipped?

Maybe, but that is irrelevant for the actual bug AFAICS.

> Also, should
> it be made more robust to cd failure, so that it does not leave the rest
> of the configure running in an unknown temporary sub-directory?

This is all that should be needed in Automake.  I'll be pushing this to
maint in a little bit.

Cheers,
Ralf

    Allow _AM_DEPENDENCIES to be used later in configure.
    
    * m4/depend.m4 (_AM_DEPENDENCIES): Remove a previously existing
    conftest.dir before recreating it.
    Fixes bug#7864.
    Report by Eric Blake, from report by Scott McCreary against M4.

diff --git a/m4/depend.m4 b/m4/depend.m4
index 714bc9c..a5726c6 100644
--- a/m4/depend.m4
+++ b/m4/depend.m4
@@ -1,12 +1,12 @@
 ##                                                          -*- Autoconf -*-
 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009,
-# 2010  Free Software Foundation, Inc.
+# 2010, 2011 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 12
+# serial 13
 
 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
@@ -46,6 +46,7 @@ AC_CACHE_CHECK([dependency style of $depcc],
   # instance it was reported that on HP-UX the gcc test will end up
   # making a dummy file named `D' -- because `-MD' means `put the output
   # in D'.
+  rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
   # using a relative directory.