]> git.saurik.com Git - wxWidgets.git/blobdiff - acinclude.m4
miniframe default style
[wxWidgets.git] / acinclude.m4
index d6c0566e8ff8b482cc250a9d52dd6526dd53af2f..e68a873f6a5002674c4aa1aaa2112c0612ef489b 100644 (file)
@@ -228,39 +228,67 @@ AC_DEFUN([WX_CPP_EXPLICIT],
 ])
 
 dnl ---------------------------------------------------------------------------
 ])
 
 dnl ---------------------------------------------------------------------------
-dnl WX_CHECK_DECLS(TARGET...,
-dnl                HEADER,
+dnl WX_CHECK_FUNCS(FUNCTIONS...,
 dnl                [ACTION-IF-FOUND],
 dnl                [ACTION-IF-FOUND],
-dnl                [ACTION-IF-NOT-FOUND])
+dnl                [ACTION-IF-NOT-FOUND],
+dnl                [EXTRA-DEFINES-AND-INCLUDES],
+dnl                [EXTRA-TEST-CODE])
 dnl
 dnl
-dnl Checks that the functions, macros or variables listed in TARGET are
-dnl declared when HEADER is included.
+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 <wchar.h>])
+dnl   # checking the signature with extra test code
+dnl   WX_CHECK_FUNCS(gettimeofday, [], [], [#include <sys/time.h>]
+dnl     [struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz)])
 dnl ---------------------------------------------------------------------------
 
 dnl ---------------------------------------------------------------------------
 
-AC_DEFUN([WX_CHECK_DECLS],
+AC_DEFUN([WX_CHECK_FUNCS],
 [
 [
-  for target in $1
+  for wx_func in $1
   do
   do
-    AC_CACHE_CHECK([for $target in $2],
-                   [wx_cv_decl_$target],
-                   [
-                    AC_TRY_COMPILE([#include <$2>],
-                                   [
-                                    #ifndef $target
-                                      &$target;
-                                    #endif
-                                   ],
-                                   [eval wx_cv_decl_$target=yes],
-                                   [eval wx_cv_decl_$target=no])
-                   ])
-
-    if eval test \$wx_cv_decl_$target = yes
+    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
     then
-      AC_DEFINE_UNQUOTED([HAVE_`echo $target | tr 'a-z' 'A-Z'`])
-      $3
+      AC_DEFINE_UNQUOTED([HAVE_`echo $wx_func | tr 'a-z' 'A-Z'`])
+      $2
     else
       :
     else
       :
-      $4
+      $3
     fi
   done
 ])
     fi
   done
 ])