From: Michael Wetherell Date: Mon, 28 Aug 2006 07:48:26 +0000 (+0000) Subject: Add WX_CHECK_FUNCS (instead of WX_CHECK_DECLS). It checks for functions in X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/040b34976ecef760b0c18db7fb408664f32319dd?hp=12125a1effd3e9ce9dd980bb7403b1e95686d699 Add WX_CHECK_FUNCS (instead of WX_CHECK_DECLS). It checks for functions in both headers and libs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40888 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/acinclude.m4 b/acinclude.m4 index dcd3a5ecf7..e68a873f6a 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -227,6 +227,72 @@ AC_DEFUN([WX_CPP_EXPLICIT], fi ]) +dnl --------------------------------------------------------------------------- +dnl WX_CHECK_FUNCS(FUNCTIONS..., +dnl [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND], +dnl [EXTRA-DEFINES-AND-INCLUDES], +dnl [EXTRA-TEST-CODE]) +dnl +dnl Checks that the functions listed in FUNCTIONS exist in the headers and the +dnl libs. For each function, if it is found then defines 'HAVE_FUNCTION' and +dnl executes ACTION-IF-FOUND, otherwise executes ACTION-IF-NOT-FOUND. +dnl +dnl The code from EXTRA-DEFINES-AND-INCLUDES is inserted into the test before +dnl the default headers are included, and EXTRA-TEST-CODE is inserted into +dnl the main() function after the default test for existence. +dnl +dnl Examples: +dnl # the simple case +dnl WX_CHECK_FUNCS(stat) +dnl # use break to finish the loop early +dnl WX_CHECK_FUNCS(mkstemp mktemp, break) +dnl # extra defines +dnl WX_CHECK_FUNCS(strtok_r, [], [], [#define _RREENTRANT]) +dnl # extra includes +dnl WX_CHECK_FUNCS(swprintf, [], [], [#include ]) +dnl # checking the signature with extra test code +dnl WX_CHECK_FUNCS(gettimeofday, [], [], [#include ] +dnl [struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz)]) +dnl --------------------------------------------------------------------------- + +AC_DEFUN([WX_CHECK_FUNCS], +[ + for wx_func in $1 + do + AC_CACHE_CHECK( + [for $wx_func], + [wx_cv_func_$wx_func], + [ + AC_LINK_IFELSE( + [ + AC_LANG_PROGRAM( + [ + $4 + AC_INCLUDES_DEFAULT + ], + [ + #ifndef $wx_func + &$wx_func; + #endif + $5 + ]) + ], + [eval wx_cv_func_$wx_func=yes], + [eval wx_cv_func_$wx_func=no]) + ]) + + if eval test \$wx_cv_func_$wx_func = yes + then + AC_DEFINE_UNQUOTED([HAVE_`echo $wx_func | tr 'a-z' 'A-Z'`]) + $2 + else + : + $3 + fi + done +]) + dnl --------------------------------------------------------------------------- dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling dnl ---------------------------------------------------------------------------