AC_LANG_FUNC_LINK_TRY(C++)): New macros.
(AC_CHECK_FUNC): Use it, together with AC_LINK_ELSE.
+2000-05-24 Akim Demaille <akim@epita.fr>
+
+ * acgeneral.m4 (AC_LANG_FUNC_LINK_TRY, AC_LANG_FUNC_LINK_TRY(C),
+ AC_LANG_FUNC_LINK_TRY(C++)): New macros.
+ (AC_CHECK_FUNC): Use it, together with AC_LINK_ELSE.
+
2000-05-24 Akim Demaille <akim@epita.fr>
* acspecific.m4 (AC_FUNC_VFORK): Quote properly.
AC_DEFUN([AC_CHECK_FUNC],
[AC_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl
AC_CACHE_CHECK([for $1], ac_var,
-[AC_TRY_LINK(
-dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
-dnl which includes <sys/select.h> which contains a prototype for
-dnl select. Similarly for bzero.
-[/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $1(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#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 (*f)();
-], [
-/* 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)
-choke me
-#else
-f = $1;
-#endif
-], AC_VAR_SET(ac_var, yes), AC_VAR_SET(ac_var, no))])
+[AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
+ [AC_VAR_SET(ac_var, yes)],
+ [AC_VAR_SET(ac_var, no)])])
AC_SHELL_IFELSE([test AC_VAR_GET(ac_var) = yes],
[$2], [$3])dnl
AC_VAR_POPDEF([ac_var])dnl
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+# AC_LANG_FUNC_LINK_TRY(FUNCTION)
+# -------------------------------
+# Produce a source which links correctly iff the FUNCTION exists.
+AC_DEFUN([AC_LANG_FUNC_LINK_TRY],
+[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+
+
# --------------- #
# 2b. C sources. #
char $2 ();])], [$2 ();])])
+# AC_LANG_FUNC_LINK_TRY(C)(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. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#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 (*f) ();
+],
+[/* 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)
+choke me
+#else
+f = $1;
+#endif
+])])
+
# ----------------- #
# 2c. C++ sources. #
define([AC_LANG_CALL(C++)], defn([AC_LANG_CALL(C)]))
+# AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
+# ------------------------------------
+# Same as C.
+define([AC_LANG_FUNC_LINK_TRY(C++)], defn([AC_LANG_FUNC_LINK_TRY(C)]))
+
+
# ------------------------ #
# 1d. Fortran 77 sources. #
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+# AC_LANG_FUNC_LINK_TRY(FUNCTION)
+# -------------------------------
+# Produce a source which links correctly iff the FUNCTION exists.
+AC_DEFUN([AC_LANG_FUNC_LINK_TRY],
+[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+
+
# --------------- #
# 2b. C sources. #
char $2 ();])], [$2 ();])])
+# AC_LANG_FUNC_LINK_TRY(C)(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. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#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 (*f) ();
+],
+[/* 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)
+choke me
+#else
+f = $1;
+#endif
+])])
+
# ----------------- #
# 2c. C++ sources. #
define([AC_LANG_CALL(C++)], defn([AC_LANG_CALL(C)]))
+# AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
+# ------------------------------------
+# Same as C.
+define([AC_LANG_FUNC_LINK_TRY(C++)], defn([AC_LANG_FUNC_LINK_TRY(C)]))
+
+
# ------------------------ #
# 1d. Fortran 77 sources. #
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+# AC_LANG_FUNC_LINK_TRY(FUNCTION)
+# -------------------------------
+# Produce a source which links correctly iff the FUNCTION exists.
+AC_DEFUN([AC_LANG_FUNC_LINK_TRY],
+[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+
+
# --------------- #
# 2b. C sources. #
char $2 ();])], [$2 ();])])
+# AC_LANG_FUNC_LINK_TRY(C)(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. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#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 (*f) ();
+],
+[/* 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)
+choke me
+#else
+f = $1;
+#endif
+])])
+
# ----------------- #
# 2c. C++ sources. #
define([AC_LANG_CALL(C++)], defn([AC_LANG_CALL(C)]))
+# AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
+# ------------------------------------
+# Same as C.
+define([AC_LANG_FUNC_LINK_TRY(C++)], defn([AC_LANG_FUNC_LINK_TRY(C)]))
+
+
# ------------------------ #
# 1d. Fortran 77 sources. #
AC_DEFUN([AC_CHECK_FUNC],
[AC_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl
AC_CACHE_CHECK([for $1], ac_var,
-[AC_TRY_LINK(
-dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
-dnl which includes <sys/select.h> which contains a prototype for
-dnl select. Similarly for bzero.
-[/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $1(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#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 (*f)();
-], [
-/* 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)
-choke me
-#else
-f = $1;
-#endif
-], AC_VAR_SET(ac_var, yes), AC_VAR_SET(ac_var, no))])
+[AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
+ [AC_VAR_SET(ac_var, yes)],
+ [AC_VAR_SET(ac_var, no)])])
AC_SHELL_IFELSE([test AC_VAR_GET(ac_var) = yes],
[$2], [$3])dnl
AC_VAR_POPDEF([ac_var])dnl
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+# AC_LANG_FUNC_LINK_TRY(FUNCTION)
+# -------------------------------
+# Produce a source which links correctly iff the FUNCTION exists.
+AC_DEFUN([AC_LANG_FUNC_LINK_TRY],
+[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+
+
# --------------- #
# 2b. C sources. #
char $2 ();])], [$2 ();])])
+# AC_LANG_FUNC_LINK_TRY(C)(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. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#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 (*f) ();
+],
+[/* 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)
+choke me
+#else
+f = $1;
+#endif
+])])
+
# ----------------- #
# 2c. C++ sources. #
define([AC_LANG_CALL(C++)], defn([AC_LANG_CALL(C)]))
+# AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
+# ------------------------------------
+# Same as C.
+define([AC_LANG_FUNC_LINK_TRY(C++)], defn([AC_LANG_FUNC_LINK_TRY(C)]))
+
+
# ------------------------ #
# 1d. Fortran 77 sources. #