dnl Process this file with autoconf to produce a configure script.
AC_INIT(rwhod++.c)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL

dnl Checks for libraries.
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, gethostbyname)

dnl Checks for header files.
AC_HEADER_STDC

dnl On some platforms, there are no prototypes for setnetgrent() and
dnl getnetgrent() in <netdb.h>.  Check whether we can supply our own
dnl prototype.  If this fails, there must already be one in netdb.h.

AC_MSG_CHECKING(whether supplying netgrent prototypes is permitted)
AC_TRY_COMPILE([#include <netdb.h>],
    [extern void setnetgrent(const char *);],
    [AC_MSG_RESULT(yes)
     AC_DEFINE(SUPPLY_NETGRENT_PROTO)],
    AC_MSG_RESULT(no))

dnl On some platforms the prototype for gettimeofday() is missing.
dnl Check whether we can supply one.  The second argument is never
dnl used; we specify void* to avoid trouble on systems such as Solaris 2.4.

AC_MSG_CHECKING(whether supplying gettimeofday() prototype is permitted)
AC_TRY_COMPILE([#include <sys/time.h>],
    [extern int gettimeofday(struct timeval *, void *);],
    [AC_MSG_RESULT(yes)
     AC_DEFINE(SUPPLY_GETTIMEOFDAY_PROTO)],
    AC_MSG_RESULT(no))

dnl On some platforms, <utmp.h> must be included before <rpcsvc/rusers.h>.
dnl Check whether this is permitted.

AC_MSG_CHECKING(whether including utmp.h before rusers.h is permitted)
AC_TRY_COMPILE([#include <utmp.h>
#include <rpcsvc/rusers.h>],,
    [AC_MSG_RESULT(yes)
     AC_DEFINE(USE_UTMP_H)],
    AC_MSG_RESULT(no))

dnl Checks for typedefs, structures, and compiler characteristics.

dnl Checks for library functions.
AC_CHECK_FUNCS(setsid memmove vsyslog)

if test "$GCC" = yes -a "$ac_cv_header_stdc" = yes; then
    CFLAGS="$CFLAGS -Wall -pedantic"
fi

AC_OUTPUT(Makefile)
