From: Akim Demaille Date: Wed, 24 May 2000 14:22:39 +0000 (+0000) Subject: * acgeneral.m4 (AC_LANG_FUNC_LINK_TRY, AC_LANG_FUNC_LINK_TRY(C), X-Git-Tag: autoconf-2.50~873 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5800da26cdb8c244ee4f0d751c88482548060da5;p=thirdparty%2Fautoconf.git * 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. --- diff --git a/ChangeLog b/ChangeLog index 3c3be8d62..363d816fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-05-24 Akim Demaille + + * 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 * acspecific.m4 (AC_FUNC_VFORK): Quote properly. diff --git a/acgeneral.m4 b/acgeneral.m4 index 5069ee716..96ac36b14 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -3095,31 +3095,9 @@ $3], 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 because on OSF/1 3.0 it includes -dnl which includes 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 -/* 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 diff --git a/aclang.m4 b/aclang.m4 index 905aed125..8e3fa5624 100644 --- a/aclang.m4 +++ b/aclang.m4 @@ -256,6 +256,13 @@ AC_DEFUN([AC_LANG_CALL], [_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. # @@ -301,6 +308,35 @@ extern "C" char $2 ();])], [$2 ();])]) +# AC_LANG_FUNC_LINK_TRY(C)(FUNCTION) +# ---------------------------------- +# Don't include because on OSF/1 3.0 it includes +# which includes 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 +/* 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. # @@ -329,6 +365,12 @@ define([AC_LANG_PROGRAM(C++)], defn([AC_LANG_PROGRAM(C)])) 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. # diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index 905aed125..8e3fa5624 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -256,6 +256,13 @@ AC_DEFUN([AC_LANG_CALL], [_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. # @@ -301,6 +308,35 @@ extern "C" char $2 ();])], [$2 ();])]) +# AC_LANG_FUNC_LINK_TRY(C)(FUNCTION) +# ---------------------------------- +# Don't include because on OSF/1 3.0 it includes +# which includes 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 +/* 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. # @@ -329,6 +365,12 @@ define([AC_LANG_PROGRAM(C++)], defn([AC_LANG_PROGRAM(C)])) 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. # diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4 index 905aed125..8e3fa5624 100644 --- a/lib/autoconf/fortran.m4 +++ b/lib/autoconf/fortran.m4 @@ -256,6 +256,13 @@ AC_DEFUN([AC_LANG_CALL], [_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. # @@ -301,6 +308,35 @@ extern "C" char $2 ();])], [$2 ();])]) +# AC_LANG_FUNC_LINK_TRY(C)(FUNCTION) +# ---------------------------------- +# Don't include because on OSF/1 3.0 it includes +# which includes 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 +/* 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. # @@ -329,6 +365,12 @@ define([AC_LANG_PROGRAM(C++)], defn([AC_LANG_PROGRAM(C)])) 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. # diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 5069ee716..96ac36b14 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -3095,31 +3095,9 @@ $3], 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 because on OSF/1 3.0 it includes -dnl which includes 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 -/* 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 diff --git a/lib/autoconf/lang.m4 b/lib/autoconf/lang.m4 index 905aed125..8e3fa5624 100644 --- a/lib/autoconf/lang.m4 +++ b/lib/autoconf/lang.m4 @@ -256,6 +256,13 @@ AC_DEFUN([AC_LANG_CALL], [_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. # @@ -301,6 +308,35 @@ extern "C" char $2 ();])], [$2 ();])]) +# AC_LANG_FUNC_LINK_TRY(C)(FUNCTION) +# ---------------------------------- +# Don't include because on OSF/1 3.0 it includes +# which includes 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 +/* 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. # @@ -329,6 +365,12 @@ define([AC_LANG_PROGRAM(C++)], defn([AC_LANG_PROGRAM(C)])) 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. #