dnl configure.in for cvs
AC_INIT(src/cvs.h)
AC_CONFIG_HEADER(config.h)
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_YACC
AC_MINIX
AC_CONST
AC_STDC_HEADERS
AC_HAVE_HEADERS(errno.h unistd.h string.h memory.h utime.h fcntl.h ndbm.h sys/select.h sys/timeb.h sys/wait.h)
AC_RETSIGTYPE
AC_DIR_HEADER
AC_UID_T
AC_MODE_T
AC_SIZE_T
AC_CHAR_UNSIGNED
AC_STRUCT_TM
AC_REPLACE_FUNCS(fnmatch getwd mkdir rename strdup dup2 strerror valloc waitpid memmove)
AC_HAVE_FUNCS(fchmod fsync ftime mkfifo putenv setvbuf vfork vprintf ftruncate timezone getpagesize)
AC_FUNC_CHECK(re_exec, :, LIBOBJS="$LIBOBJS regex.o")
AC_FUNC_CHECK(gethostname, :, LIBOBJS="$LIBOBJS hostname.o")
AC_UTIME_NULL
AC_ALLOCA
AC_RSH
AC_LONG_FILE_NAMES
dnl
dnl set $(KRB4) from --with-krb4=value -- WITH_KRB4
dnl
define(WITH_KRB4,[
AC_WITH([krb4],
KRB4=$withval,
KRB4=/usr/kerberos
)dnl
echo "default place for krb4 is $KRB4"
AC_SUBST(KRB4)])dnl
WITH_KRB4

AC_SIZEOF_TYPE(long)
AC_SIZEOF_TYPE(int)

AC_REQUIRE([AC_CROSS_CHECK])
krb_h=
AC_COMPILE_CHECK(krb.h,[#include <krb.h>],[int i;],
  [krb_h=yes krb_incdir=],
  [if test -z "$cross_compiling" && test -r $KRB4/include/krb.h; then
     hold_cflags=$CFLAGS
     CFLAGS="$CFLAGS -I$KRB4/include"
     AC_COMPILE_CHECK(krb.h in $KRB4/include,
       [#include <krb.h>],[int i;],
       [krb_h=yes krb_incdir=$KRB4/include])
     CFLAGS=$hold_cflags
   fi])
if test -n "$krb_h"; then
  krb_lib=
  AC_HAVE_LIBRARY(-lkrb,[krb_lib=yes krb_libdir=],
    [if test -z "$cross_compiling" && test -r $KRB4/lib/libkrb.a; then
       krb_lib=yes krb_libdir=$KRB4/lib
     fi])
  if test -n "$krb_lib"; then
    AC_DEFINE(HAVE_KERBEROS)
    test -n "${krb_libdir}" && LIBS="${LIBS} -L${krb_libdir}"
    LIBS="${LIBS} -lkrb"
    AC_HAVE_LIBRARY(-ldes,[LIBS="${LIBS} -ldes"])
    if test -n "$krb_incdir"; then
      includeopt="${includeopt} -I$krb_incdir"
      AC_SUBST(includeopt)
    fi
  fi
fi
AC_HAVE_FUNCS(krb_get_err_text)
# If we can't find connect, try looking in -lsocket and -lnsl.  The
# Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
# libsocket.so which has a bad implementation of gethostbyname (it
# only looks in /etc/hosts), so we only look for -lsocket if we need
# it.
AC_FUNC_CHECK(connect, :, [AC_HAVE_LIBRARY(-lsocket) AC_HAVE_LIBRARY(-lnsl)])

AC_OUTPUT(Makefile lib/Makefile src/Makefile doc/Makefile man/Makefile contrib/Makefile examples/Makefile)
