http://lists.gnu.org/archive/html/bug-m4/2010-12/msg00001.html reported that on Haiku, builds of m4 fail with a strange error:
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 I traced it to the following: M4 is using gnulib's ansi-c++-opt module to enable support for optional C++ compilation support, and has this line in configure.ac to disable C++ by default: AC_DEFUN([gl_CXX_CHOICE_DEFAULT_NO]) Then, when gnulib finally gets around to invoking gl_PROG_ANSI_CXX, $CXX is : (the default for not using C++), and the macro does this (rather than directly calling AC_PROG_CXX which unconditionally requires a working C++ compiler: dnl This macro invocation resolves an automake error: dnl /usr/local/share/automake-1.11/am/depend2.am: am__fastdepCXX does not appear in AM_CONDITIONAL dnl /usr/local/share/automake-1.11/am/depend2.am: The usual way to define `am__fastdepCXX' is to add `AC_PROG_CXX' dnl /usr/local/share/automake-1.11/am/depend2.am: to `configure.ac' and run `aclocal' and `autoconf' again. _AM_DEPENDENCIES([CXX]) Yes, Bruno is exploiting undocumented automake internals. Normally, _AM_DEPENDENCIES is called so early in the build process that conftest.dir does not exist, but in m4's case, there is a leftover conftest.dir from a prior test because the C++ compiler isn't checked until about halfway through configure. Also, _AM_DEPENDENCIES normally assumes that $CXX is a valid compiler (since AC_PROG_CXX aborts configure if the required compiler is not available), but obviously, with Bruno's attempt to conditionalize things, CXX of : will flat out fail the dependency check. The end result is that halfway through configure, automake's attempt to check for C++ dependency mode even though C++ compilation was not requested ends up changing the working directory, so that the remainder of the configure script falls flat because all sorts of assumptions about running directly in $builddir have been violated. First - should autoconf's m4/depend.m4 be changed to use mkdir -p instead of mkdir, when creating conftest.dir? Should it be taught that if CXX is :, that the dependency check should be skipped? 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? Second - when gnulib is avoiding the C++ compiler, why is it still trying to determine the dependency mode? I'm applying this patch to gnulib to avoid the issue in the first place when CXX=: (but it still doesn't solve the automake issue of dependency checking not being robust to a pre-existing conftest.dir when C++ compilation is requested via ./configure --enable-cxx). From 8a5019c9db43ed95ad763683761a0023bf536efb Mon Sep 17 00:00:00 2001 From: Eric Blake <ebl...@redhat.com> Date: Tue, 18 Jan 2011 21:49:45 -0700 Subject: [PATCH] ansi-c++-opt: skip C++ dependency style if C++ is unused * m4/ansi-c++.m4 (gl_PROG_ANSI_CXX): Avoid full-blown dependency tests when we know C++ compilation is not desired. Reported by Scott McCreary. Signed-off-by: Eric Blake <ebl...@redhat.com> --- ChangeLog | 7 +++++++ m4/ansi-c++.m4 | 16 ++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00f9ebe..263f1a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-18 Eric Blake <ebl...@redhat.com> + + ansi-c++-opt: skip C++ dependency style if C++ is unused + * m4/ansi-c++.m4 (gl_PROG_ANSI_CXX): Avoid full-blown dependency + tests when we know C++ compilation is not desired. + Reported by Scott McCreary. + 2011-01-18 Bruno Haible <br...@clisp.org> *printf-posix: Avoid test failures. Make tests work on MacOS X, Cygwin. diff --git a/m4/ansi-c++.m4 b/m4/ansi-c++.m4 index b25cf56..d6352ee 100644 --- a/m4/ansi-c++.m4 +++ b/m4/ansi-c++.m4 @@ -1,4 +1,4 @@ -# ansi-c++.m4 serial 6 +# ansi-c++.m4 serial 7 dnl Copyright (C) 2002-2003, 2005, 2010-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -116,9 +116,13 @@ EOF AM_CONDITIONAL([$2], [test "$$1" != ":"]) - dnl This macro invocation resolves an automake error: - dnl /usr/local/share/automake-1.11/am/depend2.am: am__fastdepCXX does not appear in AM_CONDITIONAL - dnl /usr/local/share/automake-1.11/am/depend2.am: The usual way to define `am__fastdepCXX' is to add `AC_PROG_CXX' - dnl /usr/local/share/automake-1.11/am/depend2.am: to `configure.ac' and run `aclocal' and `autoconf' again. - _AM_DEPENDENCIES([CXX]) + if test "$$1" != ":"; then + dnl This macro invocation resolves an automake error: + dnl /usr/local/share/automake-1.11/am/depend2.am: am__fastdepCXX does not appear in AM_CONDITIONAL + dnl /usr/local/share/automake-1.11/am/depend2.am: The usual way to define `am__fastdepCXX' is to add `AC_PROG_CXX' + dnl /usr/local/share/automake-1.11/am/depend2.am: to `configure.ac' and run `aclocal' and `autoconf' again. + _AM_DEPENDENCIES([CXX]) + else + AM_CONDITIONAL([am__fastdepCXX], [false]) + fi ]) -- 1.7.3.4 -- Eric Blake ebl...@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature