+dnl ------ iconv
+AC_ARG_WITH(iconv, [ --with-iconv[=PREFIX] iconv library in PREFIX])
+if test "$with_iconv" != "no"; then
+ AC_MSG_CHECKING(for iconv)
+ oldLIBS="$LIBS"
+ oldCPPFLAGS="${CPPFLAGS}"
+ if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
+ LIBS="$LIBS -L${with_iconv}/lib"
+ CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
+ fi
+ AC_TRY_LINK([
+ #include <iconv.h>
+ ],[
+ iconv_t t = iconv_open("", "");
+ ],[
+ AC_DEFINE(HAVE_ICONV_H)
+ AC_MSG_RESULT(yes)
+ ],[
+ LIBS="$LIBS -liconv"
+ AC_TRY_LINK([
+ #include <iconv.h>
+ ],[
+ iconv_t t = iconv_open("", "");
+ ],[
+ AC_DEFINE(HAVE_ICONV_H)
+ AC_MSG_RESULT(yes)
+ ],[
+ LIBS="$oldLIBS"
+ CPPFLAGS="$oldCPPFLAGS"
+ AC_MSG_RESULT(no)
+ ])
+ ])
+fi
+dnl ------ various functions
+AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64)
+case $host in
+*-*-darwin*)
+ trypoll="no";
+ ;;
+*)
+ trypoll="yes";
+ ;;
+esac
+
+if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
+ AC_CHECK_HEADERS(sys/poll.h)
+fi
+dnl ------ socklen_t
+dnl We check for socklen_t by making prototypes with the
+dnl various types. First socklen_t, then size_t, finally int.
+dnl If the prototype succeeds, we're probably safe.
+dnl That works if accept is not preprocessor defined (such sa AIX)
+AC_MSG_CHECKING([for socklen_t])
+AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
+ AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/socket.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+#define try 1
+#ifdef AIX
+#if AIX >= 51
+#define try 0
+#endif
+#endif
+#if try
+extern int accept(int, struct sockaddr *, socklen_t *);
+#endif
+#ifdef __cplusplus
+}
+#endif
+ ],,[ac_cv_check_socklen_t=socklen_t],[
+ AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/socket.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+#define try 1
+#ifdef AIX
+#if AIX >= 42
+#define try 0
+#endif
+#endif
+#if try
+extern int accept(int, struct sockaddr *, size_t t *);
+#endif
+#ifdef __cplusplus
+}
+#endif
+ ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
+ ])
+])
+AC_MSG_RESULT($ac_cv_check_socklen_t)
+AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
+AC_DEFINE(YAZ_USE_NEW_LOG)