>>>>> "Paul" == Paul Eggert <[EMAIL PROTECTED]> writes:
Paul> Furthermore, autoconf 2.13 AC_CHECK_FUNC is obsolete these days,
Paul> as C99 requires that functions must be declared before used. So
Paul> we need to do something about this anyway, and perhaps we can
Paul> kill two birds with one stone.
Paul> So how about this solution instead? Define a new macro,
Paul> AC_CHECK_FUNCTION say, where the caller specifies not only the
Paul> function name but also the headers that declare it.
Paul> For example, AC_CHECK_FUNCTION(open, (sys/types.h, sys/stat.h,
Paul> fcntl.h)) would first check for the existence of those three
Paul> headers and then attempt to compile and link the following
Paul> program:
What would be the problem with enabling the use of the fourth
parameter of AC_CHECK_FUNCS? AC_CHECK_FUNC(func, yes, no, includes)?
I'm not sure we can enable the default includes right now though.
The test suite succeeds with this patch under GNU/Linux.
Index: acgeneral.m4
===================================================================
RCS file: /cvs/autoconf/acgeneral.m4,v
retrieving revision 1.531
diff -u -r1.531 acgeneral.m4
--- acgeneral.m4 2000/07/24 06:54:53 1.531
+++ acgeneral.m4 2000/07/24 08:53:58
@@ -3471,12 +3471,14 @@
## -------------------------------- ##
-# AC_CHECK_FUNC(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-# -----------------------------------------------------------------
+# AC_CHECK_FUNC(FUNCTION,
+# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+# [INCLUDES])
+# -------------------------------------------------------
AC_DEFUN([AC_CHECK_FUNC],
[AC_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl
AC_CACHE_CHECK([for $1], ac_var,
-[AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
+[AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([AC_INCLUDES_DEFAULT([$4])], [$1])],
[AC_VAR_SET(ac_var, yes)],
[AC_VAR_SET(ac_var, no)])])
AC_SHELL_IFELSE([test AC_VAR_GET(ac_var) = yes],
@@ -3485,10 +3487,10 @@
])# AC_CHECK_FUNC
-# AC_CHECK_FUNCS(FUNCTION..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-# ---------------------------------------------------------------------
-# FIXME: Should we die if there are not enough arguments, or just
-# ignore?
+# AC_CHECK_FUNCS(FUNCTION...,
+# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+# [INCLUDES])
+# --------------------------------------------------------
AC_DEFUN([AC_CHECK_FUNCS],
[AC_FOREACH([AC_Func], [$1],
[AH_TEMPLATE(AC_TR_CPP(HAVE_[]AC_Func),
@@ -3497,7 +3499,8 @@
do
AC_CHECK_FUNC($ac_func,
[AC_DEFINE_UNQUOTED(AC_TR_CPP(HAVE_$ac_func)) $2],
- [$3])dnl
+ [$3],
+ [$4])dnl
done
])
Index: aclang.m4
===================================================================
RCS file: /cvs/autoconf/aclang.m4,v
retrieving revision 1.50
diff -u -r1.50 aclang.m4
--- aclang.m4 2000/07/24 07:58:52 1.50
+++ aclang.m4 2000/07/24 08:53:58
@@ -259,9 +259,15 @@
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
-# AC_LANG_FUNC_LINK_TRY(FUNCTION)
-# -------------------------------
+# AC_LANG_FUNC_LINK_TRY(PROLOGUE, FUNCTION)
+# -----------------------------------------
# Produce a source which links correctly iff the FUNCTION exists.
+#
+# FIXME: It is very unclear why there is both AC_LANG_CALL and
+# AC_LANG_FUNC_LINK_TRY: it might very well be historical and wrong.
+# IMHO, we should have a single one. It's a legacy of the difference
+# of code which was used in 2.13 for AC_CHECK_FUNC on the one hand, and
+# AC_TRY_LINK_FUNC on the other hand.
AC_DEFUN([AC_LANG_FUNC_LINK_TRY],
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
@@ -326,15 +332,15 @@
char $2 ();])], [$2 ();])])
-# AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
-# ----------------------------------
+# AC_LANG_FUNC_LINK_TRY(C)(PROLOGUE, FUNCTION)
+# --------------------------------------------
# Don't include <ctype.h> because on OSF/1 3.0 it includes
# <sys/types.h> which includes <sys/select.h> which contains a
# prototype for select. Similarly for bzero.
define([AC_LANG_FUNC_LINK_TRY(C)],
[AC_LANG_PROGRAM(
[/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $1 (); below. */
+ which can conflict with char $2 (); below. */
#include <assert.h>
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
@@ -342,16 +348,17 @@
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
-char $1 ();
+char $2 ();
char (*f) ();
+$1
],
[/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
-#if defined (__stub_$1) || defined (__stub___$1)
+#if defined (__stub_$2) || defined (__stub___$2)
choke me
#else
-f = $1;
+f = $2;
#endif
])])
@@ -401,8 +408,8 @@
define([AC_LANG_CALL(C++)], defn([AC_LANG_CALL(C)]))
-# AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
-# ------------------------------------
+# AC_LANG_FUNC_LINK_TRY(C++)(PROLOGUE, FUNCTION)
+# ----------------------------------------------
# Same as C.
define([AC_LANG_FUNC_LINK_TRY(C++)], defn([AC_LANG_FUNC_LINK_TRY(C)]))
@@ -1577,6 +1584,7 @@
# The replacement is empty.
AU_DEFUN([AC_F77_NAME_MANGLING], [])
+
# AC_F77_WRAPPERS
# ---------------
# Defines C macros F77_FUNC(name,NAME) and F77_FUNC_(name,NAME) to
@@ -1621,8 +1629,9 @@
esac
])# AC_F77_WRAPPERS
+
# AC_F77_FUNC(NAME, [SHELLVAR = NAME])
-# -------------------
+# ------------------------------------
# For a Fortran subroutine of given NAME, define a shell variable
# $SHELLVAR to the Fortran-77 mangled name. If the SHELLVAR
# argument is not supplied, it defaults to NAME.
@@ -1639,5 +1648,3 @@
])
m4_default([$2],[$1])="$ac_val"
]) # AC_F77_FUNC
-
-