]> git.saurik.com Git - wxWidgets.git/blobdiff - acinclude.m4
creating graphics context with the correct origin
[wxWidgets.git] / acinclude.m4
index 83e577c1f9a616d7fed5351feb5ddb4be4860fb5..e68a873f6a5002674c4aa1aaa2112c0612ef489b 100644 (file)
@@ -35,8 +35,7 @@ AC_DEFUN([WX_PATH_FIND_INCLUDES],
 ac_find_includes=
 for ac_dir in $1 /usr/include;
   do
-    wx_ac_hdr="$ac_dir/$2"
-    if test -f "$wx_ac_hdr" -o -h "$wx_ac_hdr"; then
+    if test -f "$ac_dir/$2"; then
       ac_find_includes=$ac_dir
       break
     fi
@@ -53,8 +52,7 @@ AC_DEFUN([WX_PATH_FIND_LIBRARIES],
   for ac_dir in $1;
   do
     for ac_extension in a so sl dylib dll.a; do
-      wx_ac_lib="$ac_dir/lib$2.$ac_extension"
-      if test -f "$wx_ac_lib" -o -h "$wx_ac_lib"; then
+      if test -f "$ac_dir/lib$2.$ac_extension"; then
         ac_find_libraries=$ac_dir
         break 2
       fi
@@ -229,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 <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 ---------------------------------------------------------------------------
+
+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 ---------------------------------------------------------------------------
@@ -337,10 +401,11 @@ AC_DEFUN([WX_ARG_SYS_WITH],
         ])
 
 dnl this macro checks for a command line argument and caches the result
-dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
+dnl usage: WX_ARG_WITH(option, helpmessage, variable-name, [withstring])
 AC_DEFUN([WX_ARG_WITH],
         [
-          AC_MSG_CHECKING([for --with-$1])
+         withstring=$4
+          AC_MSG_CHECKING([for --${withstring:-with}-$1])
           no_cache=0
           AC_ARG_WITH($1, [$2],
                       [
@@ -416,6 +481,47 @@ AC_DEFUN([WX_ARG_ENABLE],
         ])
 
 
+dnl Like WX_ARG_ENABLE but accepts a parameter.
+dnl
+dnl Usage:
+dnl   WX_ARG_ENABLE_PARAM(option, helpmessage, variable-name, enablestring)
+dnl
+dnl Example:
+dnl   WX_ARG_ENABLE_PARAM(foo, [[  --enable-foo[=bar] use foo]], wxUSE_FOO)
+dnl 
+dnl  --enable-foo       wxUSE_FOO=yes
+dnl  --disable-foo      wxUSE_FOO=no
+dnl  --enable-foo=bar   wxUSE_FOO=bar
+dnl  <not given>        value from configarg.cache or wxUSE_FOO=no
+dnl 
+AC_DEFUN([WX_ARG_ENABLE_PARAM],
+        [
+          enablestring=$4
+          AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
+          no_cache=0
+          AC_ARG_ENABLE($1, [$2],
+                        [
+                          wx_cv_use_$1="$3='$enableval'"
+                        ],
+                        [
+                          LINE=`grep "$3" ${wx_arg_cache_file}`
+                          if test "x$LINE" != x ; then
+                            eval "DEFAULT_$LINE"
+                            wx_cv_use_$1='$3='$DEFAULT_$3
+                          else
+                            no_cache=1
+                            wx_cv_use_$1="$3=no"
+                          fi
+                        ])
+
+          eval "$wx_cv_use_$1"
+          if test "$no_cache" != 1; then
+            echo $wx_cv_use_$1 >> ${wx_arg_cache_file}.tmp
+          fi
+
+          AC_MSG_RESULT([$$3])
+        ])
+
 dnl ===========================================================================
 dnl Linker features test
 dnl ===========================================================================