dnl Process this file with autoconf to product a configure script.
AC_INIT(client/discuss.c)
AC_CONFIG_HEADER(include/config.h)
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
AC_PROGRAM_CHECK(LEX, flex, flex, lex)
AC_PROGRAM_CHECK(LEXLIB, flex, -lfl, -ll)
AC_SUBST(LEXLIB)
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_YACC
AC_ISC_POSIX
AC_STDC_HEADERS
AC_HEADER_DIRENT
AC_TYPE_SIGNAL
AC_HAVE_HEADERS(string.h memory.h unistd.h fcntl.h sysexits.h /usr/ucbinclude/sysexits.h sys/select.h termios.h netinet/in.h)
AC_CHECK_FUNCS(strcasecmp)
AC_HEADER_EGREP(w_status, sys/wait.h, AC_DEFINE(HAVE_UNION_WAIT))
AC_VPRINTF
KDOBJS=
LDEPS=
KLIBS=
KINCLUDES=
ZLIBS=
use_krb=yes
use_zephyr=yes
dnl -lsocket is broken on SGI's is broken.  Sigh.
AC_FUNC_CHECK(connect, :, [AC_CHECK_LIB(socket,socket) AC_CHECK_LIB(nsl,main)])
AC_SUBST(KLIBS)
AC_SUBST(ZLIBS)
AC_SUBST(KINCLUDES)
AC_SUBST(LDEPS)
AC_SUBST(KDOBJS)
AC_ARG_WITH(krb, [  --with-krb	          use Kerberos for authentication],
use_krb=$withval)
AC_ARG_WITH(krb-lib, [  --with-krb-lib=DIR      Kerberos library files are in DIR],
AC_MSG_RESULT(krb-lib is $withval)
use_krb=yes KLIBS="-L$withval -lkrb -ldes",
use_std_krblib=no
if test $use_krb = yes; then
  def_krblib=/usr/athena/lib
  if test -r /usr/kerberos/lib/libkrb.a; then
    def_krblib=/usr/kerberos/lib
  else
    AC_CHECK_LIB(krb,krb_mk_req,
use_std_krblib=yes
KLIBS="-lkrb"
)
    AC_CHECK_LIB(des,des_set_key,
KLIBS="$KLIBS -ldes"
)
    AC_CHECK_LIB(krb4,krb_mk_req,
   	KLIBS="-lkrb4 -lkrb5 -lkrb5util -ldes425 -lcrypto -L/usr/athena/lib",
	,
	-lkrb5 -lkrb5util -ldes425 -lcrypto -L$def_krblib -lcom_err
)
  fi
  if test $use_std_krblib = yes; then
    AC_MSG_RESULT(Using standard path for krb-lib)
  else
    AC_MSG_RESULT(krb-lib defaults to $def_krblib)
    KLIBS="-L$def_krblib -lkrb -ldes"
  fi
fi
)
AC_ARG_WITH(krb-include, [  --with-krb-include=DIR  Kerberos include files are in DIR],
AC_MSG_RESULT(krb-include is $withval)
use_krb=yes KINCLUDES="-I$withval",
if test $use_krb = yes; then
  def_krbinc=/usr/athena/include
  if test -r /usr/kerberos/include/krb.h; then
    def_krbinc=/usr/kerberos/include
  fi
  AC_MSG_RESULT(krb-include defaults to $def_krbinc)
  KINCLUDES="-I$def_krbinc"
fi)
if test $use_krb = yes; then
  AC_DEFINE(KERBEROS)
  KDOBJS="auth_krb.o krb_et.o"
else
  KDOBJS="auth_weak.o"
fi

AC_ARG_WITH(zephyr,     [  --with-zephyr           use Zephyr to send out notifications when new
                          transactions are entered],
use_zephyr=$withval)
AC_ARG_WITH(zephyr-lib, [  --with-zephyr-lib=DIR   Zephyr library files are in DIR],
AC_MSG_RESULT(zephyr-lib is $withval)
AC_DEFINE(ZEPHYR)
ZLIBS="-L$ZLIBS -lzephyr",
if test $use_zephyr = yes; then
  AC_MSG_RESULT(zephyr-lib defaults to /usr/athena/lib)
  ZLIBS="-L/usr/athena/lib -lzephyr"
fi)
if test $use_zephyr = yes ; then
  AC_DEFINE(ZEPHYR)
fi

AC_DEFINE_UNQUOTED(SERVER,"$prefix/sbin/disserve")
dnl AC_DEFINE(SERVER_LOCAL,"disserve-fs") ???
AC_DEFINE_UNQUOTED(INFO_DIR,"$prefix/lib/discuss/info") dnl *not* gnu-info stuff
AC_DEFINE(SERVER_NAME,"disserve")
AC_DEFINE(REALM,"No.Such.Realm")
AC_DEFINE(SERVICE_NAME,"discuss")
AC_DEFINE(SERVICE_PORT,2100)
AC_DEFINE_UNQUOTED(DSPIPE,"$prefix/sbin/dspipe")
AC_DEFINE_UNQUOTED(DSC_SETUP,"$prefix/sbin/dsc_setup")

AC_SIZEOF_TYPE(short)
AC_SIZEOF_TYPE(int)
AC_SIZEOF_TYPE(long)

test -d utils || mkdir utils
AC_OUTPUT(Makefile client/Makefile dsgrep/Makefile dsgrep/regexp/Makefile edsc/Makefile ets/Makefile include/Makefile include/discuss/Makefile libds/Makefile mclient/Makefile server/Makefile usp/Makefile utils/et/Makefile utils/ss/Makefile)
