dnl $Id: configure.in,v 1.6 2001/09/18 02:18:37 james Rel james $
dnl Process this file with autoconf to produce a configure script.
AC_INIT(tcpxd.c)
AM_INIT_AUTOMAKE(tcpxd, 1.4)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL

dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h)

dnl Checks for library functions.
AC_CHECK_LIB(socket, main)
AC_CHECK_LIB(resolv, main)
AC_CHECK_LIB(nsl, main)
AC_CHECK_FUNCS(select socket strdup strerror gethostbyname herror inet_aton)

# Check whether user wants TCP wrappers support
TCPW_MSG="no"
AC_ARG_WITH(libwrap,
  [  --with-libwrap[[=DIR]]    enable TCP wrappers support],
  [
    if test "x$withval" != "xno" ; then
      saved_CPPFLAGS="$CPPFLAGS"
      saved_LDFLAGS="$LDFLAGS"
      saved_LIBS="$LIBS"
      if test -n "${withval}" && \
          test "x${withval}" != "xyes"; then
        if test -d "${withval}/lib"; then
          LDFLAGS="-L${withval}/lib ${LDFLAGS}"
        else
          LDFLAGS="-L${withval} ${LDFLAGS}"
        fi
        if test -d "${withval}/include"; then
          CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
        else
          CPPFLAGS="-I${withval} ${CPPFLAGS}"
        fi
      fi
      LIBS="-lwrap $LIBS"
      AC_MSG_CHECKING(for libwrap)
      AC_TRY_LINK(
        [
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <tcpd.h>
          int deny_severity = 0;
          int allow_severity = 0;
        ],
        [hosts_access(0);],
        [
          AC_MSG_RESULT(yes)
          AC_DEFINE(HAVE_LIBWRAP)
        ],
        [
          AC_MSG_RESULT(no)
          CPPFLAGS="$saved_CPPFLAGS"
          LDFLAGS="$saved_LDFLAGS"
          LIBS="$saved_LIBS"
        ]
      )
    fi
  ]
)

AC_OUTPUT(Makefile)
