Here is my first proposal.
Index: aclang.m4
===================================================================
RCS file: /cvs/autoconf/aclang.m4,v
retrieving revision 1.57
diff -u -r1.57 aclang.m4
--- aclang.m4 2000/08/07 12:33:18 1.57
+++ aclang.m4 2000/08/09 08:05:23
@@ -481,8 +481,8 @@
[AC_REQUIRE([AC_PROG_CXXCPP])])])
-# AC_LANG_COMPILER_WORKS
-# ----------------------
+# _AC_LANG_COMPILER_WORKS
+# -----------------------
define([_AC_LANG_COMPILER_WORKS],
[AC_MSG_CHECKING([whether the _AC_LANG compiler works])
AC_LINK_IFELSE([AC_LANG_PROGRAM()],
@@ -505,7 +505,44 @@
AC_MSG_ERROR([_AC_LANG compiler cannot create executables], 77)])[]dnl
AC_MSG_CHECKING([whether we are cross compiling])
AC_MSG_RESULT($cross_compiling)
-])# AC_LANG_COMPILER_WORKS
+])# _AC_LANG_COMPILER_WORKS
+
+
+# AC_GCC_GROSS_HACK
+# -----------------
+# FIXME: The GCC team has specific needs which the current Autoconf
+# framework cannot solve elegantly. This macro implements a dirty
+# hack until Autoconf is abble to provide the services its users
+# needs.
+#
+# Several of the support libraries that are often built with GCC can't
+# assume the tool-chain is already capable of linking a program: the
+# compiler often expects to be able to link with some of such
+# libraries.
+#
+# In several of these libraries, work-arounds have been introduced to
+# avoid the AC_PROG_CC_WORKS test, that would just abort their
+# configuration. The introduction of AC_EXEEXT, enabled either by
+# libtool or by CVS autoconf, have just made matters worse.
+AC_DEFUN_ONCE([AC_GCC_GROSS_HACK],
+[AC_DIVERT_PUSH([KILL])
+
+AC_BEFORE([$0], [_AC_LANG_COMPILER_WORKS])
+AC_BEFORE([$0], [_AC_EXEEXT])
+AC_BEFORE([$0], [_AC_LINK_IFELSE])
+
+define([_AC_LANG_COMPILER_WORKS], [cross_compiling=maybe])
+
+define([_AC_EXEEXT], [EXEEXT=])
+
+define([_AC_LINK_IFELSE_ORIGINAL], defn([AC_LINK_IFELSE]))
+define([AC_LINK_IFELSE(C)], defn([AC_LINK_IFELSE]))
+define([AC_LINK_IFELSE(C++)], defn([AC_LINK_IFELSE]))
+AC_DEFUN([AC_LINK_IFELSE],
+[_AC_LANG_DISPATCH([AC_LINK_IFELSE], _AC_LANG, $][@)])
+
+AC_DIVERT_POP()dnl
+])
# -------------------- #
/tmp % cat configure.in nostromo 10:03
AC_INIT
AC_GCC_GROSS_HACK
define([AC_LINK_IFELSE(C)], [echo "No you don't"])
AC_PROG_CXX
AC_PROG_CC
AC_CHECK_FUNCS(bar foo)
AC_LANG(C++)
AC_CHECK_FUNCS(bar foo)
/tmp % ace nostromo 10:04
/tmp % ./configure nostromo 10:04
checking for g++... g++
checking whether we are using GNU C++... yes
checking whether g++ accepts -g... yes
checking for object suffix... o
checking for gcc... gcc
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking for bar... No you don't
./configure: test: =: unary operator expected
checking for foo... No you don't
./configure: test: =: unary operator expected
checking for bar... no
checking for foo... no
The test stuff is due to the fact that the cache variable is not set,
which normally impossible. Can be fixed if you want to.
Akim