+dnl Next line needed to find the gethost*_r functions on Solaris
+AC_CHECK_LIB(nsl, gethostbyname)
+
+AC_CHECK_FUNC(gethostbyaddr_r, [
+ AC_MSG_CHECKING([signature of gethostbyaddr_r])
+ AC_TRY_COMPILE([
+# include <netdb.h>
+ ], [
+ struct hostent *h, *hp;
+ char *a, *b;
+ int l, bl, t, e;
+ (void) gethostbyaddr_r(a, l, t, h, b, bl, &hp, &e)
+ ], [
+ AC_DEFINE(HAVE_GETHOSTBYADDR_R_8_ARGS)
+ AC_MSG_RESULT([8 args])
+ ], [
+ AC_TRY_COMPILE([
+# include <netdb.h>
+ ], [
+ struct hostent *h;
+ char *a, *b;
+ int l, bl, t, e;
+ (void) gethostbyaddr_r(a, l, t, h, b, bl, &e)
+ ], [
+ AC_DEFINE(HAVE_GETHOSTBYADDR_R_7_ARGS)
+ AC_MSG_RESULT([7 args])
+ ], [
+ AC_TRY_COMPILE([
+# include <netdb.h>
+ ], [
+ struct hostent_data *d;
+ struct hostent *h;
+ char a,
+ int l, t;
+ (void) gethostbyaddr_r(a, l, t, h, d)
+ ], [
+ AC_DEFINE(HAVE_GETHOSTBYADDR_R_5_ARGS)
+ AC_MSG_RESULT([5 args])
+ ], [
+ AC_MSG_RESULT(unrecognised)
+ ])
+ ])
+ ])
+], [
+ AC_MSG_RESULT(no)
+])
+
+AC_CHECK_FUNC(gethostbyname_r, [
+ AC_MSG_CHECKING([signature of gethostbyname_r])
+ AC_TRY_COMPILE([
+# include <netdb.h>
+ ], [
+ struct hostent *h, *r;
+ char *n, *b;
+ int bl, e;
+ (void) gethostbyname_r(n, h, b, bl, &r, &e)
+ ], [
+ AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARGS)
+ AC_MSG_RESULT([6 args])
+ ], [
+ AC_TRY_COMPILE([
+# include <netdb.h>
+ ], [
+ struct hostent *h;
+ char *n, *b;
+ int bl, e;
+ (void) gethostbyname_r(n, h, b, bl, &e)
+ ], [
+ AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARGS)
+ AC_MSG_RESULT([5 args])
+ ], [
+ AC_TRY_COMPILE([
+# include <netdb.h>
+ ], [
+ struct hostent_data *d;
+ struct hostent *h;
+ char *n,
+ (void) gethostbyname_r(n, h, d)
+ ], [
+ AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARGS)
+ AC_MSG_RESULT([3 args])
+ ], [
+ AC_MSG_RESULT(unrecognised)
+ ])
+ ])
+ ])
+], [
+ AC_MSG_RESULT(no)
+])
+
+AC_CHECK_FUNC(gmtime_r, [
+ AC_MSG_CHECKING([signature of gmtime_r])
+ AC_TRY_COMPILE([
+# include <time.h>
+ ], [
+ struct time *t;
+ struct tm *tm;
+ (void) gmtime_r(t, tm)
+ ], [
+ AC_MSG_RESULT(ok)
+ AC_DEFINE(HAVE_GMTIME_R)
+ ], [
+ AC_MSG_RESULT(unrecognised)
+ ])
+], [
+ AC_MSG_RESULT(no)
+])
+
+AC_CHECK_FUNC(localtime_r, [
+ AC_MSG_CHECKING([signature of localtime_r])
+ AC_TRY_COMPILE([
+# include <time.h>
+ ], [
+ struct time *t;
+ struct tm *tm;
+ (void) localtime_r(t, tm)
+ ], [
+ AC_MSG_RESULT(ok)
+ AC_DEFINE(HAVE_LOCALTIME_R)
+ ], [
+ AC_MSG_RESULT(unrecognised)
+ ])
+], [
+ AC_MSG_RESULT(no)
+])
+
+dnl =================================================================
+dnl Solaris specific
+dnl FIXME: Not tested on Solaris yet...
+dnl ISFIXED: Have tested it on Solaris, but there are other ways to
+dnl make these checks generic, e.g.:
+dnl AC_CHECK_FUNC(getsockopt, , AC_CHECK_LIB(socket, getsockopt))
+dnl (Moritz Barsnick <moritz@barsnick.net>)
+dnl =================================================================
+
+
+SOCKET_LIB=
+
+case "$host" in
+*-solaris*) SOCKET_LIB="-lsocket -lnsl"
+ AC_DEFINE(__EXTENSIONS__)
+ if test "$GCC" = "yes"; then
+ # Set a GCC specific switch:
+ # This compiler switch makes Solaris thread-safe
+ PTHREAD_LIB=
+ SPECIAL_CFLAGS="-pthreads"
+ else
+ # What do we do without GCC? Guess this:
+ SPECIAL_CFLAGS="-D_REENTRANT"
+ fi
+;;
+esac
+
+AC_SUBST(SOCKET_LIB)
+
+dnl =================================================================
+dnl Solaris problem, and others perhaps (socklen_t is undefined)
+dnl =================================================================
+
+if test $target_type != mingw; then
+# i686-w64-mingw32-gcc gets socklen_t define from ws2tcpip.h
+
+AC_MSG_CHECKING([for socklen_t])
+AC_EGREP_HEADER(socklen_t, sys/socket.h, AC_MSG_RESULT([yes]),
+ AC_MSG_RESULT([no])
+ AC_DEFINE(socklen_t,int,
+ [ Define to 'int' if <sys/socket.h> doesn't have it. ]))
+
+fi
+
+dnl =================================================================
+dnl OS/2 specific
+dnl =================================================================
+
+case "$host" in
+*-os2-emx*) SOCKET_LIB=-lsocket
+;;
+esac
+
+AC_SUBST(SOCKET_LIB)
+
+dnl =================================================================
+dnl Mac OSX specific
+dnl =================================================================
+
+case "$host" in
+*-apple-darwin*) SPECIAL_CFLAGS="-Dunix"
+;;
+esac
+
+dnl =================================================================
+dnl OpenBSD specific
+dnl =================================================================
+
+case "$host" in
+*-openbsd*) SPECIAL_CFLAGS="$SPECIAL_CFLAGS -Dunix"
+;;
+esac
+
+dnl =================================================================
+dnl Haiku specific
+dnl =================================================================
+
+if test "$host_os" = haiku; then
+ # Omit the "-pthread" flag to gcc, even when building with gcc 2.95
+ SPECIAL_CFLAGS=
+
+ # Haiku's pthreads implementation exists in its system library,
+ # libroot, not in a separate pthreads library
+ PTHREAD_LIB=
+
+ # Networking code exists in libnetwork
+ SOCKET_LIB=-lnetwork
+
+ # Search Haiku's common-library folder to find its pcre and
+ # pcreposix libraries
+ LIBS="-L/boot/common/lib $LIBS"
+fi
+
+dnl =================================================================
+dnl Check for standard compiler stuff
+dnl =================================================================
+
+AC_EXEEXT
+AC_OBJEXT
+AC_HEADER_STDC
+AC_HEADER_DIRENT
+AC_C_CONST
+AC_TYPE_SIZE_T
+AC_TYPE_PID_T
+AC_HEADER_TIME
+AC_STRUCT_TM
+AC_CHECK_SIZEOF(int, 4)
+AC_CHECK_SIZEOF(char *, 4)
+AC_CHECK_SIZEOF(long, 4)
+AC_CHECK_SIZEOF(long long, 8)
+AC_CHECK_SIZEOF(size_t, 4)
+AC_CHECK_SIZEOF(time_t, 8)
+
+dnl Checks for header files.
+AC_CHECK_HEADERS([ \
+ OS.h \
+ arpa/inet.h \
+ errno.h \
+ fcntl.h \
+ limits.h \
+ locale.h \
+ netdb.h \
+ netinet/in.h \
+ stddef.h \
+ stdlib.h \
+ string.h \
+ sys/ioctl.h \
+ sys/socket.h \
+ sys/time.h \
+ sys/timeb.h \
+ sys/wait.h \
+ unistd.h \
+])
+
+dnl Checks for library functions.
+dnl bcopy is for PCRE
+AC_CHECK_FUNCS([bcopy])
+AC_PROG_GCC_TRADITIONAL
+AC_TYPE_SIGNAL
+AC_CHECK_FUNCS([ \
+ access \
+ arc4random \
+ atexit \
+ calloc \
+ getcwd \
+ gethostbyaddr \
+ gethostbyaddr_r \
+ gethostbyname \
+ gethostbyname_r \
+ gettimeofday \
+ inet_ntoa \
+ memchr \
+ memmove \
+ memset \
+ nanosleep \
+ poll \
+ putenv \
+ random \
+ regcomp \
+ select \
+ setlocale \
+ shutdown \
+ snprintf \
+ socket \
+ strchr \
+ strdup \
+ strerror \
+ strftime \
+ strlcat \
+ strlcpy \
+ strptime \
+ strtoul \
+ timegm \
+ tzset \
+])
+
+dnl Checks for RFC 2553 resolver and socket functions
+AC_ARG_ENABLE(ipv6-support,
+[ --disable-ipv6-support Disable IPv6 support and other RFC-2554-related improvements],