dnl Process this file with autoconf to produce a configure script.

AC_INIT(configure.in)
AM_INIT_AUTOMAKE(srpftp, 1.1.1)
AC_PROG_MAKE_SET

test "$prefix" = "NONE" && prefix="/usr"
test "$prefix" = "/usr" && exec_prefix=""
test "$CFLAGS" = "" && CFLAGS="-O2"

dnl Checks for programs.

AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_YACC
AC_ARG_PROGRAM

dnl Checks for libraries.

AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(crypt,crypt)

dnl Checks for header files.

AC_CHECK_HEADERS(sys/select.h)
AC_HEADER_CHECK(termios.h,AC_FUNC_CHECK(cfsetispeed,AC_DEFINE(POSIX_TERMIOS)))
AC_CHECK_HEADERS(stdlib.h)
AC_CHECK_HEADERS(unistd.h stdlib.h string.h)

dnl Checks for typedefs, structures, and compiler characteristics.

AC_C_CONST
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)

dnl Checks for library functions.

AC_FUNC_VFORK
AC_HAVE_FUNCS(getcwd getdtablesize)
AC_REPLACE_FUNCS(getdtablesize)
AC_HAVE_FUNCS(getcwd getusershell seteuid setreuid setresuid)

dnl Other stuff from Kerberos

DECLARE_SYS_ERRLIST
TYPE_SIGNAL
CHECK_SIGNALS
CHECK_SIGPROCMASK
CHECK_WAIT_TYPE
CHECK_UTMP
AC_HEADER_STDARG

AC_MSG_CHECKING([setenv])
AC_CACHE_VAL(krb5_cv_setenv,
[AC_TRY_LINK(
[],[setenv("PATH","/bin",0);],
krb5_cv_setenv=yes,krb5_cv_setenv=no)])
AC_MSG_RESULT($krb5_cv_setenv)
if test $krb5_cv_setenv = no; then
AC_REPLACE_FUNCS(setenv)
fi
AC_MSG_CHECKING([shadow password support])
AC_CACHE_VAL(krb5_cv_shadow_pwd,
[AC_TRY_LINK(
[#include <sys/types.h>
#include <pwd.h>
#include <shadow.h>],
[struct spwd *sp = getspnam("root")],
krb5_cv_shadow_pwd=yes, krb5_cv_shadow_pwd=no)])
AC_MSG_RESULT($krb5_cv_shadow_pwd)
if test $krb5_cv_shadow_pwd = yes; then
AC_DEFINE(HAVE_SHADOW)
fi

dnl User options.

AC_ARG_ENABLE(noencryption, [  --enable-noencryption	disable encryption], AC_DEFINE(NOENCRYPTION))


AC_ARG_WITH(cryptolib, [  --with-cryptolib	  use cryptolib for bignums ])

AC_SUBST(LIBMATH)
if test "$with_cryptolib" = "yes"
then
	LIBS="$LIBS ../../lib/libcrypt.a"
else
	LIBS="$LIBS -L../../lib -lgmp"
fi

AC_ARG_WITH(krb4, [  --with-krb4		compile with kerberos4 support])
if test "$with_krb4" = "yes"
then
	AC_CHECK_LIB(krb, krb_mk_safe, AC_DEFINE(KERBEROS) LIBS="-lkrb -ldes $LIBS")
else
	:
fi

AC_DEFINE(FTP_BUFSIZ,10240)
AC_DEFINE(SRP)
AC_DEFINE(NO_PASSIVE_MODE)
AC_DEFINE(FTPAUTH)
AC_DEFINE(FTPAUTH_PATH, "/etc/ftpauth")

AC_OUTPUT(Makefile arpa/Makefile ftp/Makefile ftpd/Makefile)
