dnl configure.in for the SASL library
dnl Rob Siemborski
dnl Rob Earhart
dnl $Id: configure.in,v 1.1 2002/02/27 23:54:19 snsimon Exp $
dnl
dnl Copyright (c) 2001 Carnegie Mellon University.  All rights reserved.
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions
dnl are met:
dnl
dnl 1. Redistributions of source code must retain the above copyright
dnl    notice, this list of conditions and the following disclaimer. 
dnl
dnl 2. Redistributions in binary form must reproduce the above copyright
dnl    notice, this list of conditions and the following disclaimer in
dnl    the documentation and/or other materials provided with the
dnl    distribution.
dnl
dnl 3. The name "Carnegie Mellon University" must not be used to
dnl    endorse or promote products derived from this software without
dnl    prior written permission. For permission or any other legal
dnl    details, please contact  
dnl      Office of Technology Transfer
dnl      Carnegie Mellon University
dnl      5000 Forbes Avenue
dnl      Pittsburgh, PA  15213-3890
dnl      (412) 268-4387, fax: (412) 268-7395
dnl      tech-transfer@andrew.cmu.edu
dnl
dnl 4. Redistributions of any form whatsoever must retain the following
dnl    acknowledgment:
dnl    \"This product includes software developed by Computing Services
dnl     at Carnegie Mellon University (http://www.cmu.edu/computing/).\"
dnl
dnl CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
dnl THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dnl AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
dnl FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
dnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
dnl AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
dnl OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
dnl
AC_INIT(lib/saslint.h)
AC_CONFIG_AUX_DIR(config)
AM_CONFIG_HEADER(config.h)
AC_CANONICAL_HOST

dnl
dnl REMINDER: When changing the version number here, please also update
dnl the values in win32/include/config.h and include/sasl.h as well.
dnl
AM_INIT_AUTOMAKE(cyrus-sasl, 2.1.1)
CMU_INIT_AUTOMAKE

# and include our config dir scripts
ACLOCAL="$ACLOCAL -I \$(top_srcdir)/config"

DIRS=""

AC_ARG_ENABLE(cmulocal, [  --enable-cmulocal       enable local mods for CMU [no]],,enable_cmulocal=no)

AC_ARG_ENABLE(sample, [  --enable-sample         compile sample code [yes]],,enable_sample=yes)

AC_PROG_CC
AC_PROG_CPP
AC_PROG_AWK
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_INSTALL
CMU_C___ATTRIBUTE__

dnl check for -R, etc. switch
CMU_GUESS_RUNPATH_SWITCH
dnl let's just link against local.  otherwise we never find anything useful.
CPPFLAGS="-I/usr/local/include ${CPPFLAGS}"
CMU_ADD_LIBPATH("/usr/local/lib")

AM_DISABLE_STATIC

CMU_PROG_LIBTOOL

if test "$ac_cv_prog_gcc" = yes; then
  CFLAGS="-Wall -W ${CFLAGS}"
fi

AC_ARG_WITH(staticsasl,[  --with-staticsasl       build a static library with all mechs included.                 (Different from enable-static, but probabally the one you want)])
AC_MSG_CHECKING(to build static libsasl2.a)
if test "$with_staticsasl" = yes; then
  AC_MSG_RESULT(yes)
  SASL_STATIC_LIBS="$SASL_STATIC_LIBS libsasl2.a"
else
  AC_MSG_RESULT(no)
fi
AC_SUBST(SASL_STATIC_LIBS)

AC_ARG_WITH(purecov,[  --with-purecov          link with purecov])
if test "$with_purecov" = yes; then
  AC_CHECK_PROGS(PURECOV, purecov)
fi
AC_ARG_WITH(purify,[  --with-purify           link with purify])
if test "$with_purify" = yes; then
  AC_CHECK_PROGS(PURIFY, purify)
fi

AC_ARG_ENABLE(java, [  --enable-java           compile Java support [no]],
	enable_java=yes, enable_java=no)
if test "$enable_java" = yes; then
  AC_PATH_PROG(JAVAC, javac, no)
  AC_PATH_PROGS(JAVAH, javah kaffeh, no)
  AC_CHECK_PROGS(JAVADOC, javadoc, :)	
  if test "$JAVAC" = "no" -o "$JAVAH" = "no"; then
    AC_WARN([Disabling Java support])
    enable_java=no
  fi
else
# Make distcheck work
  JAVAC="true"
  JAVAH="true"
  JAVADOC="true"
fi
AM_CONDITIONAL(JAVA, test "$enable_java" = yes)

if test "$enable_java" = yes; then
  AC_MSG_CHECKING([JNI cpp flags])
  AC_CACHE_VAL(sasl_cv_java_includes,[
  if test `echo $JAVAH | sed 's,.*/,,'` = "kaffeh"; then
    sasl_cv_java_includes=-I`echo $JAVAH | sed -e 's,/bin.*,/include/kaffe,'`
  else
    java_base=`echo $JAVAC | sed 's,/bin.*,'','`

    AC_ARG_WITH(javabase, [  --with-javabase=PATH    set path to find jni.h in [/usr/java/include] ],
        java_base=$withval,)
	

    sasl_cv_java_includes=''
    for dir in `find ${java_base}/include -follow -type d -print | grep -v green_threads`; do
      sasl_cv_java_includes="${sasl_cv_java_includes} -I$dir"
    done
  fi

  sasl_cv_java_includes="${sasl_cv_java_includes} -I$javapath/include"])

  JAVA_INCLUDES=$sasl_cv_java_includes
  AC_SUBST(JAVA_INCLUDES)
  AC_MSG_RESULT(ok)

  JAVAROOT=".."
  AC_SUBST(JAVAROOT)
  JAVAC=`echo "$JAVAC" | sed 's,.*/,,'`
  JAVAH=`echo "$JAVAH" | sed 's,.*/,,'`
fi

AM_CONDITIONAL(SAMPLE, test "$enable_sample" = yes)

dnl we extracted this to config/sasldb.m4
SASL_DB_PATH_CHECK()
SASL_DB_CHECK()

AC_CHECK_LIB(dl, dlopen, SASL_DL_LIB="-ldl", SASL_DL_LIB="")
AC_SUBST(SASL_DL_LIB)

dnl Do we need leading underscores on our symbols?

AC_CHECK_PROGS(NM, nm)

AC_MSG_CHECKING(for underscore before symbols)
AC_CACHE_VAL(sasl_cv_uscore,[
    echo "main(){int i=1;}
    foo(){int i=6;}" > conftest.c
    ${CC} -o a.out conftest.c > /dev/null
    if (${NM} a.out | grep _foo) > /dev/null; then
      sasl_cv_uscore=yes
    else
      sasl_cv_uscore=no
    fi])
AC_MSG_RESULT($sasl_cv_uscore)
rm -f conftest.c a.out

if test $sasl_cv_uscore = yes; then
  if test $ac_cv_lib_dl_dlopen = yes ; then
	AC_MSG_CHECKING(whether dlsym adds the underscore for us)
	AC_CACHE_VAL(sasl_cv_dlsym_adds_uscore,AC_TRY_RUN( [
#include <dlfcn.h>
#include <stdio.h>
foo() { int i=0;}
main() { void *self, *ptr1, *ptr2; self=dlopen(NULL,RTLD_LAZY);
    if(self) { ptr1=dlsym(self,"foo"); ptr2=dlsym(self,"_foo");
    if(ptr1 && !ptr2) exit(0); } exit(1); } 
], [sasl_cv_dlsym_adds_uscore=yes], sasl_cv_dlsym_adds_uscore=no
	AC_DEFINE(DLSYM_NEEDS_UNDERSCORE),
	AC_MSG_WARN(cross-compiler, we'll do our best)))

      AC_MSG_RESULT($sasl_cv_dlsym_adds_uscore)
  fi
fi

dnl See if we can provide a default logging function...
AC_CHECK_FUNCS(syslog)

CMU_SOCKETS

AC_ARG_WITH(pam, [  --with-pam=DIR          use PAM (rooted in DIR) [yes] ],
	with_pam=$withval,
	with_pam=yes)
if test "$with_pam" != no; then
  if test -d $with_pam; then
    CPPFLAGS="$CPPFLAGS -I${with_pam}/include"
    LDFLAGS="$LDFLAGS -L${with_pam}/lib"
  fi
  cmu_save_LIBS="$LIBS"
  AC_CHECK_LIB(pam, pam_start,
	  AC_CHECK_HEADER(security/pam_appl.h,,
			  with_pam=no),
		with_pam=no, $SASL_DL_LIB)
  LIBS="$cmu_save_LIBS"
fi

AC_MSG_CHECKING(for PAM support)
AC_MSG_RESULT($with_pam)
LIB_PAM=""
if test "$with_pam" != no; then
  AC_DEFINE(HAVE_PAM)
  LIB_PAM="-lpam"
fi
AC_SUBST(LIB_PAM)

AC_ARG_WITH(saslauthd, [  --with-saslauthd=DIR    enable use of the saslauth daemon using state dir DIR ],
		with_saslauthd=$withval,
		with_saslauthd=no)
if test "$with_saslauthd" != no; then
  if test "$with_saslauthd" = yes; then
    with_saslauthd="/var/state/saslauthd"
  fi
  AC_DEFINE(HAVE_SASLAUTHD)
  AC_DEFINE_UNQUOTED(PATH_SASLAUTHD_RUNDIR, "$with_saslauthd")
fi
AM_CONDITIONAL(SASLAUTHD, test "$with_saslauthd" != no)
AC_MSG_CHECKING(if I should include saslauthd)
AC_MSG_RESULT($with_saslauthd)

AC_ARG_WITH(pwcheck,
[  --with-pwcheck=DIR      enable depricated pwcheck daemonusing statedir DIR ],
	with_pwcheck=$withval,
	with_pwcheck=no)
if test "$with_pwcheck" != no; then
   if test "$with_pwcheck" = yes; then
     with_pwcheck=/var/pwcheck
   fi
   AC_DEFINE(HAVE_PWCHECK)
   AC_DEFINE_UNQUOTED(PWCHECKDIR, "$with_pwcheck")
   AC_CHECK_FUNC(getspnam,PWCHECKMETH="getspnam",PWCHECKMETH="getpwnam")
   AC_SUBST(PWCHECKMETH)
fi
AM_CONDITIONAL(PWCHECK, test "$with_pwcheck" != no)
AC_MSG_CHECKING(if I should include pwcheck)
AC_MSG_RESULT($with_pwcheck)

AC_ARG_ENABLE(alwaystrue, [  --enable-alwaystrue     enable the alwaystrue password verifier (discouraged)],
		enable_alwaystrue=$enableval,
		enable_alwaystrue=no)
if test "$enable_alwaystrue" = yes; then
  AC_DEFINE(HAVE_ALWAYSTRUE)
fi
AC_MSG_CHECKING(if I should include the alwaystrue verifier)
AC_MSG_RESULT($enable_alwaystrue)

dnl sasl_checkapop support
AC_ARG_ENABLE(checkapop, [  --enable-checkapop      enable use of sasl_checkapop [yes] ],
  checkapop=$enableval,
  checkapop=yes)

AC_MSG_CHECKING(if we should enable sasl_checkapop)
if test "$checkapop" != no; then
  AC_MSG_RESULT(enabled)
  AC_DEFINE(DO_SASL_CHECKAPOP)
else
  AC_MSG_RESULT(disabled)
fi

dnl CRAM-MD5
AC_ARG_ENABLE(cram, [  --enable-cram           enable CRAM-MD5 authentication [yes] ],
  cram=$enableval,
  cram=yes)

AC_MSG_CHECKING(CRAM-MD5)
if test "$cram" != no; then
  AC_MSG_RESULT(enabled)
  SASL_MECHS="$SASL_MECHS libcrammd5.la"
  SASL_STATIC_OBJS="$SASL_STATIC_OBJS ../plugins/cram.o"
  AC_DEFINE(STATIC_CRAMMD5)
else
  AC_MSG_RESULT(disabled)
fi

SASL_DES_CHK

dnl DIGEST-MD5
AC_ARG_ENABLE(digest, [  --enable-digest         enable DIGEST-MD5 authentication [yes] ],
  digest=$enableval,
  digest=yes)

if test "$digest" != no; then
  dnl In order to compile digest, we should look for need libdes.
  if test -d $digest; then
    CPPFLAGS="$CPPFLAGS -I$digest/include"
    LDFLAGS="$LDFLAGS -L$digest/lib"
  fi
  if test "$with_des" = no; then
    AC_WARN(No DES support for DIGEST-MD5)
  fi
fi

AC_MSG_CHECKING(DIGEST-MD5)
if test "$digest" != no; then
  AC_MSG_RESULT(enabled)
  SASL_MECHS="$SASL_MECHS libdigestmd5.la"
  SASL_STATIC_OBJS="$SASL_STATIC_OBJS ../plugins/digestmd5.o"
  AC_DEFINE(STATIC_DIGESTMD5)
else
  AC_MSG_RESULT(disabled)
fi

dnl See if we have OpenSSL (required for OTP)
AC_CHECK_LIB(crypto, EVP_DigestInit, AC_CHECK_HEADER(openssl/evp.h,
						with_openssl=yes,
						with_openssl=no),
				with_openssl=no)

dnl OTP
AC_ARG_ENABLE(otp, [  --enable-otp            enable OTP authentication [no] ],
  otp=$enableval,
  otp=yes)

if test "$with_openssl" = no; then
  AC_WARN([OpenSSL not found -- OTP will be disabled])
  otp=no
fi

AC_MSG_CHECKING(OTP)
if test "$otp" != no; then
  AC_MSG_RESULT(enabled)
  OTP_LIBS="-lcrypto"

  SASL_MECHS="$SASL_MECHS libotp.la"
  SASL_STATIC_OBJS="$SASL_STATIC_OBJS ../plugins/otp.o"
  AC_DEFINE(STATIC_OTP)

  dnl Test for OPIE
  AC_ARG_WITH(with-opie,[  --with-opie=PATH        use OPIE (One Time Passwords in Everything) from PATH],
	with_opie="${withval}")

  case "$with_opie" in
	""|yes) 
		AC_CHECK_LIB(opie, opiechallenge,
			AC_CHECK_HEADER(opie.h, with_opie="yes",
					with_opie="no"),
			with_opie="no")
		;;
	*)
		if test -d $with_opie; then
		  CPPFLAGS="${CPPFLAGS} -I${with_opie}/include"
		  LDFLAGS="${LDFLAGS} -L${with_opie}/lib"
		else
		  with_opie="no"
		fi
		;;
  esac

  AC_MSG_CHECKING(for OPIE)
  AC_MSG_RESULT($with_opie)

  if test "$with_opie" != no; then
    AC_DEFINE(HAVE_OPIE)
    OTP_LIBS="$OTP_LIBS -lopie"
  else
    OTP_LIBS="$OTP_LIBS ../sasldb/libsasldb.la \$(SASL_DB_LIB)"
  fi

  AC_SUBST(OTP_LIBS)

else
  AC_MSG_RESULT(disabled)
fi

SASL_KERBEROS_V4_CHK
SASL_GSSAPI_CHK
SASL_PLAIN_CHK

if test "$gssapi" != "no"; then
  AC_DEFINE(STATIC_GSSAPIV2)
fi

dnl ANONYMOUS
AC_ARG_ENABLE(anon, [  --enable-anon           enable ANONYMOUS authentication [yes] ],
  anon=$enableval,
  anon=yes)

AC_MSG_CHECKING(ANONYMOUS)
if test "$anon" != no; then
  AC_MSG_RESULT(enabled)
  SASL_MECHS="$SASL_MECHS libanonymous.la"
  SASL_STATIC_OBJS="$SASL_STATIC_OBJS ../plugins/anonymous.o"
  AC_DEFINE(STATIC_ANONYMOUS)
else
  AC_MSG_RESULT(disabled)
fi

dnl LOGIN
AC_ARG_ENABLE(login, [  --enable-login          enable unsupported LOGIN authentication [no] ],
  login=$enableval,
  login=no)

AC_MSG_CHECKING(LOGIN)
if test "$login" != no; then
  AC_MSG_RESULT(enabled)
  SASL_MECHS="$SASL_MECHS liblogin.la"
  SASL_STATIC_OBJS="$SASL_STATIC_OBJS ../plugins/login.o"
  AC_DEFINE(STATIC_LOGIN)
else
  AC_MSG_RESULT(disabled)
fi


dnl See if we have OpenSSL (required for SRP)
dnl
dnl We need 0.9.6 (or higher), so check for a 0.9.6 function
AC_CHECK_LIB(crypto, RAND_egd_bytes, AC_CHECK_HEADER(openssl/evp.h,
						with_openssl=yes,
						with_openssl=no),
				with_openssl=no)

dnl SRP
AC_ARG_ENABLE(srp, [  --enable-srp            enable SRP authentication [no] ],
  srp=$enableval,
  srp=no)

if test "$with_openssl" = no; then
  AC_WARN([OpenSSL 0.9.6 (or higher) not found -- SRP will be disabled])
  srp=no
fi

AC_MSG_CHECKING(SRP)
if test "$srp" != no; then
  AC_MSG_RESULT(enabled)
  SRP_LIBS="-lcrypto"

  SASL_MECHS="$SASL_MECHS libsrp.la"
  SASL_STATIC_OBJS="$SASL_STATIC_OBJS ../plugins/srp.o"
  AC_DEFINE(STATIC_SRP)

dnl srp_setpass support
  AC_ARG_ENABLE(srp_setpass, [  --enable-srp-setpass    enable setting SRP secrets with saslpasswd [no]],
      srp_setpass=$enableval,
      srp_setpass=no)

  AC_MSG_CHECKING(if we should enable setting SRP secrets with saslpasswd)
  if test "$srp_setpass" != no; then
    AC_MSG_RESULT(enabled)
    AC_DEFINE(DO_SRP_SETPASS)
    SRP_LIBS="$SRP_LIBS ../sasldb/libsasldb.la \$(SASL_DB_LIB)"
  else
    AC_MSG_RESULT(disabled)
  fi

  AC_SUBST(SRP_LIBS)
else
  AC_MSG_RESULT(disabled)
fi

# and add in the plugin_common file (it's shared)
SASL_STATIC_OBJS="$SASL_STATIC_OBJS ../plugins/plugin_common.o"

AC_SUBST(SASL_MECHS)
AC_SUBST(SASL_STATIC_OBJS)

AC_ARG_WITH(plugindir, [  --with-plugindir=DIR    set the directory where plugins will
                          be found [/usr/lib/sasl2] ],
  plugindir=$withval,
  plugindir=/usr/lib/sasl2)
AC_DEFINE_UNQUOTED(PLUGINDIR, "$plugindir")
AC_SUBST(plugindir)

dnl look for rc4 libraries. we accept the CMU one or one from openSSL
AC_ARG_WITH(rc4, [  --with-rc4              use internal rc4 routines [yes] ],
	with_rc4=$withval,
	with_rc4=yes)

if test "$with_rc4" != no; then
    AC_DEFINE(WITH_RC4)
fi

building_for_macosx=no
case "$host_os" in
        darwin*)
            building_for_macosx=yes
        ;;
esac
AM_CONDITIONAL(MACOSX, test "$building_for_macosx" = yes)

dnl dmalloc tests
AC_MSG_CHECKING(for dmalloc library)
AC_ARG_WITH(dmalloc, [  --with-dmalloc=DIR      with DMALLOC support (for test applications) [no] ],
	with_dmalloc=$withval,
	with_dmalloc=no)

DMALLOC_LIBS=""

if test "$with_dmalloc" != "no"; then
   if test "$with_dmalloc" = "yes"; then
	with_dmalloc="/usr/local"
   fi

   if test -r "$with_dmalloc/libdmalloc.a"; then
	DMALLOC_LIBS="$with_dmalloc/libdmalloc.a"
	AC_DEFINE(WITH_DMALLOC)
	AC_MSG_RESULT(yes)
   elif test -r "$with_dmalloc/lib/libdmalloc.a"; then
	DMALLOC_LIBS="$with_dmalloc/lib/libdmalloc.a"
	AC_DEFINE(WITH_DMALLOC)
	AC_MSG_RESULT(yes)
   else
	AC_MSG_ERROR(cannot find dmalloc library, please check your installation.)
   fi
else
   AC_MSG_RESULT(no)
fi

AC_SUBST(DMALLOC_LIBS)

dnl sfio tests
AC_MSG_CHECKING(for sfio library)
AC_ARG_WITH(sfio, [  --with-sfio=DIR         with SFIO support (for smtptest/libsfsasl) [no] ],
	with_sfio=$withval,
	with_sfio=no)

if test "$with_sfio" != "no"; then
   if test "$with_sfio" = "yes"; then
	with_sfio="/usr/local"
   fi

   AC_DEFUN(SFIO_INC_CHK,
	[if test -r "$with_sfio$1/sfio.h"; then SFIO_DIR=$with_sfio;
					      SFIO_INC_DIR=$with_sfio$1])

   AC_DEFUN(SFIO_LIB_CHK,[
		str="$SFIO_DIR/$1/libsfio.*"
		for i in `echo $str`; do
			if test -r $i; then
				SFIO_LIBDIR=$SFIO_DIR/$1
				break 2
			fi
		done
		])

   SFIO_INC_CHK()
   el[]SFIO_INC_CHK(/include)
   el[]SFIO_INC_CHK(/include/sfio)
   fi

   if test -z "$SFIO_DIR"; then
	AC_MSG_ERROR(Cannot find sfio.h, Please check your SFIO installation.)
   fi

   SFIO_LIB_CHK(lib)
   SFIO_LIB_CHK(lib/sfio)

   if test -z "$SFIO_LIBDIR"; then
	AC_MSG_ERROR(Cannot find sfio library, Please check your SFIO installation.)
   fi

   SFIO_INC_FLAGS="-I$SFIO_INC_DIR"
   SFIO_LIB_FLAGS="-L$SFIO_LIBDIR -lsfio"
   SMTPTEST_PROGRAM="smtptest"
   SASL_UTIL_LIBS_EXTRA=libsfsasl2.la
   SASL_UTIL_HEADERS_EXTRA=sfsasl.h

   AC_MSG_RESULT(yes)
else
   AC_MSG_RESULT(no)
   SFIO_INC_FLAGS=""
   SFIO_LIB_FLAGS=""
   SMTPTEST_PROGRAM=""
   SASL_UTIL_LIBS_EXTRA=""
   SASL_UTIL_HEADERS_EXTRA=""
fi

AC_SUBST(SFIO_INC_FLAGS)
AC_SUBST(SFIO_LIB_FLAGS)
AC_SUBST(SMTPTEST_PROGRAM)
AC_SUBST(SASL_UTIL_LIBS_EXTRA)
AC_SUBST(SASL_UTIL_HEADERS_EXTRA)

dnl check for getsubopt
sasl_cv_getsubopt=no
AC_CHECK_FUNC(getsubopt, [AC_DEFINE(HAVE_GETSUBOPT)], [sasl_cv_getsubopt=yes])
if test $sasl_cv_getsubopt = yes; then
	LIBOBJS="$LIBOBJS getsubopt.o"
	GETSUBOPT="getsubopt.lo"
fi
AC_SUBST(GETSUBOPT)

dnl Check for snprintf
sasl_cv_snprintf=no
SNPRINTFOBJS=""
AC_CHECK_FUNC(snprintf, [AC_DEFINE(HAVE_SNPRINTF)], [sasl_cv_snprintf=yes])
AC_CHECK_FUNC(vsnprintf, [AC_DEFINE(HAVE_VSNPRINTF)], [sasl_cv_snprintf=yes])
if test $sasl_cv_snprintf = yes; then
	LIBOBJS="$LIBOBJS snprintf.o"
        SNPRINTFOBJS="snprintf.o"
        LTSNPRINTFOBJS="snprintf.lo"
fi
AC_SUBST(SNPRINTFOBJS)
AC_SUBST(LTSNPRINTFOBJS)

dnl do we need to link in -lresolv?
AC_CHECK_LIB(resolv, inet_aton)

dnl Check for getaddrinfo
GETADDRINFOOBJS=""
sasl_cv_getaddrinfo=no
IPv6_CHECK_FUNC(getaddrinfo,
		[AC_DEFINE(HAVE_GETADDRINFO)], [sasl_cv_getaddrinfo=yes])
if test $sasl_cv_getaddrinfo = yes; then
    LIBOBJS="$LIBOBJS getaddrinfo.o"
    GETADDRINFOOBJS="getaddrinfo.o"
    LTGETADDRINFOOBJS="getaddrinfo.lo"
fi
AC_SUBST(GETADDRINFOOBJS)
AC_SUBST(LTGETADDRINFOOBJS)

dnl Check for getnameinfo
GETNAMEINFOOBJS=""
sasl_cv_getnameinfo=no
IPv6_CHECK_FUNC(getnameinfo,
		[AC_DEFINE(HAVE_GETNAMEINFO)], [sasl_cv_getnameinfo=yes])
if test $sasl_cv_getnameinfo = yes; then
	LIBOBJS="$LIBOBJS getnameinfo.o"
        GETNAMEINFOOBJS="getnameinfo.o"
        LTGETNAMEINFOOBJS="getnameinfo.lo"
fi
AC_SUBST(GETNAMEINFOOBJS)
AC_SUBST(LTGETNAMEINFOOBJS)

LTLIBOBJS=`echo "$LIBOBJS" | sed 's/\.o/.lo/g'`
AC_SUBST(LIBOBJS)
AC_SUBST(LTLIBOBJS)

AC_C_CONST
AC_C_INLINE
AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_SIGNAL

AC_HEADER_TIME
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h limits.h malloc.h paths.h strings.h sys/file.h sys/time.h syslog.h unistd.h inttypes.h sys/uio.h)

IPv6_CHECK_SS_FAMILY()
IPv6_CHECK_SA_LEN()
IPv6_CHECK_SOCKLEN_T()

#AC_FUNC_MEMCMP
#AC_FUNC_VPRINTF
AC_CHECK_FUNCS(gethostname getdomainname getpwnam getspnam gettimeofday memcpy mkdir select socket strchr strdup strerror strspn strstr strtol jrand48)

if test $enable_cmulocal = yes; then
    AC_WARN([enabling CMU local kludges])
    AC_DEFINE(KRB4_IGNORE_IP_ADDRESS)
    AC_DEFINE_UNQUOTED(PREFER_MECH, "KERBEROS_V4")
fi

AC_EGREP_HEADER(sockaddr_storage, sys/socket.h,
		AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE))

AC_SUBST(DIRS)

AC_CONFIG_SUBDIRS(saslauthd)

AC_OUTPUT(Makefile
include/Makefile
sasldb/Makefile
plugins/Makefile
lib/Makefile
utils/Makefile
doc/Makefile
sample/Makefile
java/Makefile
java/CyrusSasl/Makefile
java/Test/Makefile
java/javax/Makefile
java/javax/security/Makefile
java/javax/security/auth/Makefile
java/javax/security/auth/callback/Makefile
pwcheck/Makefile
man/Makefile)

echo Configuration Complete.  Type \'make\' to build.
