# Configure template for whois3.
# Process this file with autoconf to produce a configure script.


dnl Autoconf checks if this file exists, otherwise it won't go on
AC_INIT(whois3.c)

PRODUCT=whois3
VERSION=3.1.1v6
VERSION_NO_IPV6=`echo $VERSION|sed 's/v6$//'`
AC_DEFINE_UNQUOTED(PRODUCT, "$PRODUCT")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
AC_SUBST(PRODUCT)
AC_SUBST(VERSION)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_RANLIB

dnl Checks for libraries.

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(limits.h unistd.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_LIBRARY_NET

AC_CHECK_FUNCS(strerror strtol)
AC_FUNC_MALLOC
AC_FUNC_SETVBUF_REVERSED
AC_FUNC_VPRINTF

# IPv6-check fix (taken from OpenSSH portable configure.ac) by wouter@widexs.nl - 03/06/2003
AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
                ac_cv_have_ss_family_in_struct_ss, [
        AC_TRY_COMPILE(
                [
#include <sys/types.h>
#include <sys/socket.h>
                ],
                [ struct sockaddr_storage s; s.ss_family = 1; ],
                [ ac_cv_have_ss_family_in_struct_ss="yes" ],
                [ ac_cv_have_ss_family_in_struct_ss="no" ],
        )
])

AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
                ac_cv_have___ss_family_in_struct_ss, [
        AC_TRY_COMPILE(
                [
#include <sys/types.h>
#include <sys/socket.h>
                ],
                [ struct sockaddr_storage s; s.__ss_family = 1; ],
                [ ac_cv_have___ss_family_in_struct_ss="yes" ],
                [ ac_cv_have___ss_family_in_struct_ss="no" ]
        )
])
if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
        AC_DEFINE(HAVE_SS_FAMILY_IN_SS)
elif test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
        AC_DEFINE(HAVE___SS_FAMILY)
else
	AC_MSG_ERROR([
                     *** No IPv6 Support detected !!! ***
		     Please download ripe-whois-$VERSION_NO_IPV6])
fi

AC_OUTPUT(Makefile)

