r11375: Update to the latest config.guess and config.sub files.
[kai/samba.git] / source3 / aclocal.m4
index 96f265daf26368d670d8d6abaa44648403e632ae..af93aa236851e4c358678b9851921370cec18769 100644 (file)
@@ -102,16 +102,22 @@ AC_DEFUN(AC_HAVE_DECL,
 ])
 
 
-dnl check for a function in a library, but don't
+dnl Check for a function in a library, but don't
 dnl keep adding the same library to the LIBS variable.
+dnl Check whether the function is available in the current
+dnl LIBS before adding the library. This prevents us spuriously
+dnl finding symbols that are in libc.
 dnl AC_LIBTESTFUNC(lib,func)
 AC_DEFUN(AC_LIBTESTFUNC,
-[case "$LIBS" in
-  *-l$1*) AC_CHECK_FUNCS($2) ;;
-  *) AC_CHECK_LIB($1, $2) 
-     AC_CHECK_FUNCS($2)
-  ;;
-  esac
+[
+  AC_CHECK_FUNCS($2, [],
+      [ case "$LIBS" in
+          *-l$1*) AC_CHECK_FUNCS($2) ;;
+          *) AC_CHECK_LIB($1, $2) 
+             AC_CHECK_FUNCS($2)
+          ;;
+        esac
+      ])
 ])
 
 # AC_CHECK_LIB_EXT(LIBRARY, [EXT_LIBS], [FUNCTION],
@@ -484,6 +490,51 @@ AC_ARG_WITH(mysql-exec-prefix,[  --with-mysql-exec-prefix=PFX Exec prefix where
   AC_SUBST(MYSQL_LIBS)
 ])
 
+# =========================================================================
+# AM_PATH_PGSQL : pgSQL library
+
+dnl AM_PATH_PGSQL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
+dnl Test for PGSQL, and define PGSQL_CFLAGS and PGSQL_LIBS
+dnl
+AC_DEFUN(AM_PATH_PGSQL,
+[dnl
+dnl Get the cflags and libraries from the pg_config script
+dnl
+AC_ARG_WITH(pgsql-prefix,[  --with-pgsql-prefix=PFX   Prefix where PostgreSQL is installed (optional)],
+            pgsql_prefix="$withval", pgsql_prefix="")
+AC_ARG_WITH(pgsql-exec-prefix,[  --with-pgsql-exec-prefix=PFX Exec prefix where PostgreSQL is installed (optional)],
+            pgsql_exec_prefix="$withval", pgsql_exec_prefix="")
+
+  if test x$pgsql_exec_prefix != x ; then
+     if test x${PGSQL_CONFIG+set} != xset ; then
+        PGSQL_CONFIG=$pgsql_exec_prefix/bin/pg_config
+     fi
+  fi
+  if test x$pgsql_prefix != x ; then
+     if test x${PGSQL_CONFIG+set} != xset ; then
+        PGSQL_CONFIG=$pgsql_prefix/bin/pg_config
+     fi
+  fi
+
+  AC_REQUIRE([AC_CANONICAL_TARGET])
+  AC_PATH_PROG(PGSQL_CONFIG, pg_config, no, [$PATH:/usr/lib/postgresql/bin])
+  AC_MSG_CHECKING(for PGSQL)
+  no_pgsql=""
+  if test "$PGSQL_CONFIG" = "no" ; then
+    PGSQL_CFLAGS=""
+    PGSQL_LIBS=""
+    AC_MSG_RESULT(no)
+     ifelse([$2], , :, [$2])
+  else
+    PGSQL_CFLAGS=-I`$PGSQL_CONFIG --includedir`
+    PGSQL_LIBS="-lpq -L`$PGSQL_CONFIG --libdir`"
+    AC_MSG_RESULT(yes)
+    ifelse([$1], , :, [$1])
+  fi
+  AC_SUBST(PGSQL_CFLAGS)
+  AC_SUBST(PGSQL_LIBS)
+])
+
 dnl Removes -I/usr/include/? from given variable
 AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[
   ac_new_flags=""
@@ -519,17 +570,6 @@ AC_DEFUN(jm_ICONV,
     jm_cv_lib_iconv=""
     jm_cv_giconv=no
     jm_save_LIBS="$LIBS"
-    LIBS="$LIBS -lbiconv"
-    AC_TRY_LINK([#include <stdlib.h>
-#include <biconv.h>],
-        [iconv_t cd = iconv_open("","");
-         iconv(cd,NULL,NULL,NULL,NULL);
-         iconv_close(cd);],
-      jm_cv_func_iconv=yes
-      jm_cv_biconv=yes
-      jm_cv_include="biconv.h"
-      jm_cv_lib_iconv="biconv")
-      LIBS="$jm_save_LIBS"
 
     dnl Check for include in funny place but no lib needed
     if test "$jm_cv_func_iconv" != yes; then