dnl $Cambridge: hermes/src/cyrus-imapd/configure.in,v 1.2 2004/09/02 15:02:11 dpc22 Exp $
dnl Process this file with autoconf to produce a configure script.

dnl
dnl Copyright (c) 1998-2000 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

dnl
dnl configure.in for the Cyrus imapd
dnl $Id: configure.in,v 1.266 2003/06/25 21:12:54 rjs3 Exp $
dnl


AC_INIT(imap/imapd.c)
AC_CONFIG_HEADER(config.h)
AC_CANONICAL_HOST

dnl Useful for maintainer mode stuff
WARNERROR=-W
AC_ARG_ENABLE(warnings-are-errors,[  --enable-warnings-are-errors   add -Werror to most gcc calls], [ if test "$enableval" != "no" ; then WARNERROR=-Werror ; fi ])
AC_SUBST(WARNERROR)

dnl Useful hook for distributions
AC_ARG_WITH(extraident,[  --with-extraident=STRING   use STRING as extra version information],
	[AC_DEFINE_UNQUOTED(EXTRA_IDENT,"$withval", [Extra version information for imap/version.h])])

AC_CHECK_PROG(MAKEDEPEND,makedepend,makedepend,[`cd ${srcdir};pwd`/tools/not-mkdep])
if test "$MAKEDEPEND" != "makedepend"; then
        AC_MSG_WARN([Makedepend is not installed on this system.  You should compile and install the version from the makedepend subdirectory.])
fi

AC_ARG_WITH(login,,AC_ERROR([--with-login is no longer supported.
Configure SASL appropriately instead.]))

AC_ARG_WITH(cyrus-prefix,[  --with-cyrus-prefix=DIR    use DIR as cyrus install directory],
	cyrus_prefix="$withval",cyrus_prefix="/usr/cyrus")
AC_SUBST(cyrus_prefix)
AC_DEFINE_UNQUOTED(CYRUS_PATH,"$cyrus_prefix",[Where will we be installed?])
AC_ARG_WITH(cyrus-user,[  --with-cyrus-user=USERID   use USERID cyrus userid],
	cyrus_user="$withval",cyrus_user="cyrus")
AC_SUBST(cyrus_user)
AC_DEFINE_UNQUOTED(CYRUS_USER, "$cyrus_user",[What user will we run as?])
AC_ARG_WITH(cyrus-group,[  --with-cyrus-group=GROUPID use GROUPID cyrus group],
	cyrus_group="$withval",cyrus_group="mail")
AC_SUBST(cyrus_group)
AC_ARG_WITH(statedir,[  --with-statedir=DIR        use DIR as state directory],
	statedir="$withval",statedir="/var")
AC_DEFINE_UNQUOTED(STATEDIR,"$statedir",[Where should we put our state?])

dnl Hermes compatibility nonsense. --sysconfdir (the obvious choice)
dnl appears to be intended for shell scripts and Makefiles, not C headers.
dnl It defaults to '$prefix/etc', the quotes mean that it isn't expanded.
AC_ARG_WITH(cyrus_sysconfdir,
        [  --with-cyrus-sysconfdir=DIR        read only configuration files],
	cyrus_sysconfdir="$withval", cyrus_sysconfdir="$cyrus_prefix/etc")
AC_DEFINE_UNQUOTED(CYRUS_SYSCONFDIR, "$cyrus_sysconfdir")

AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_AIX
AC_ISC_POSIX
AC_PROG_AWK
AC_C_CONST
dnl fakeroot fails with this and Debian always support
dnl long filenames anyway
dnl AC_SYS_LONG_FILE_NAMES
dnl if test $ac_cv_sys_long_file_names = no; then
dnl 	AC_MSG_ERROR(The Cyrus IMAPD requires support for long file names)
dnl fi

CMU_C___ATTRIBUTE__
CMU_C_FPIC

dnl check for -R, etc. switch
CMU_GUESS_RUNPATH_SWITCH


AC_CHECK_HEADERS(unistd.h sys/select.h sys/param.h stdarg.h)
AC_REPLACE_FUNCS(memmove strcasecmp ftruncate strerror)
AC_CHECK_FUNCS(strlcat strlcpy)
AC_HEADER_DIRENT

dnl do this before Berkeley DB/IPv6 detection
CMU_SOCKETS
LIBS="$LIBS ${LIB_SOCKET}"

dnl check for IPv6 functions (fall back to sasl's if we don't have them)
cyrus_cv_getaddrinfo=yes
IPv6_CHECK_FUNC(getaddrinfo, [IPv6_CHECK_FUNC(gai_strerror,[
	AC_DEFINE(HAVE_GETADDRINFO,[],[Do we have a getaddrinfo?])
	cyrus_cv_getaddrinfo=no])])

cyrus_cv_getnameinfo=yes
IPv6_CHECK_FUNC(getnameinfo,
	AC_DEFINE(HAVE_GETNAMEINFO,[],[Do we have a getnameinfo?]),
	cyrus_cv_getnameinfo=no)


dnl this is to check for time things for sieve
AC_STRUCT_TM
AC_STRUCT_TIMEZONE

AC_SUBST(CPPFLAGS)
AC_SUBST(PRE_SUBDIRS)
AC_SUBST(EXTRA_SUBDIRS)
AC_SUBST(DEPLIBS)
AC_SUBST(LOCALDEFS)
AC_FUNC_VPRINTF

dnl Berkeley DB Detection

dnl support old-style
AC_ARG_WITH(dbdir,
	[  --with-dbdir=DIR        Berkeley DB files are in prefix DIR],
	with_bdb_lib="$withval/lib"; with_bdb_inc="$withval/include",
	with_bdb_lib=none; with_bdb_inc=none)

CYRUS_BERKELEY_DB_CHK()

if test "$dblib" = "no"; then
  AC_ERROR([this version requires Berkeley DB 3.x or later.
(Get it from http://www.sleepycat.com/).  You may need to suppply the
--with-bdb-libdir or --with-bdb-incdir configure options.])
fi

if test "$with_bdb_lib" != "none"; then
  CMU_ADD_LIBPATH($with_bdb_lib)
fi
LIBS="${LIBS} ${BDB_LIBADD}"
CPPFLAGS="${BDB_INCADD} ${CPPFLAGS}"

dnl End Berkeley DB Detection

dnl function for doing each of the database backends
dnl parameters: backend name, variable to set, withval
AC_DEFUN([CYRUS_SET_BACKEND], [
	AC_MSG_CHECKING([$1 database backend])
	if test "$3" != "db3" -a \
		"$3" != "db3_nosync" -a \
	 	"$3" != "flat" -a \
		"$3" != "skiplist"; then
	   AC_ERROR([invalid $1 value])
	fi
	DB_STRING="(&cyrusdb_$3)"
	AC_DEFINE_UNQUOTED($2, $DB_STRING, [Database backend for $1])
	AC_MSG_RESULT($3)
])
AC_DEFUN([CYRUS_SET_BACKEND_BINARY], [
	AC_MSG_CHECKING([$1 database backend])
	if test "$3" = "flat"; then
	   AC_ERROR([this database requires a backend capable of binary data])
	fi
	if test "$3" != "db3" -a \
		"$3" != "db3_nosync" -a \
		"$3" != "skiplist"; then
	   AC_ERROR([invalid $1 value])
	fi
	DB_STRING="(&cyrusdb_$3)"
	AC_DEFINE_UNQUOTED($2, $DB_STRING, [Database backend for $1])
	AC_MSG_RESULT($3)
])

AC_ARG_WITH(duplicate-db,
	[  --with-duplicate-db=DB  use DB (db3, skiplist) as a backend
                          for the duplicate delivery db (Default: db3_nosync) ],
	DB="$withval", DB="db3_nosync")
CYRUS_SET_BACKEND_BINARY("duplicate db", CONFIG_DB_DUPLICATE, $DB)

AC_ARG_WITH(mboxlist-db,
	[  --with-mboxlist-db=DB   use DB (flat, db3, skiplist) as a backend
                          for the mailbox list (Default: db3) ],
	DB="$withval", DB="db3")
CYRUS_SET_BACKEND("mboxlist", CONFIG_DB_MBOX, $DB)

AC_ARG_WITH(seen-db,
	[  --with-seen-db=DB       use DB (flat, db3, skiplist) as a backend
                          for the seen state (Default: flat) ],
	DB="$withval", DB="flat")
CYRUS_SET_BACKEND("seen state", CONFIG_DB_SEEN, $DB)

AC_ARG_WITH(subs-db,
	[  --with-subs-db=DB       use DB (flat, db3, skiplist) as a backend
                          for the subscriptions list (Default: flat) ],
	DB="$withval", DB="flat")
CYRUS_SET_BACKEND("subscription", CONFIG_DB_SUBS, $DB)

AC_ARG_WITH(tls-db,
	[  --with-tls-db=DB        use DB (db3, skiplist) as a backend
                          for the TLS cache (Default: db3_nosync) ],
	DB="$withval", DB="db3_nosync")
CYRUS_SET_BACKEND_BINARY("TLS cache", CONFIG_DB_TLS, $DB)

sievedir="sieve"
AC_ARG_ENABLE(sieve,
        [  --disable-sieve         disable Sieve support],
	if test "$enableval" = no; then
 		sievedir="no"
	fi)

if test "$sievedir" != "no"; then
	SIEVE_LIBS="../${sievedir}/libsieve.a"
	AC_SUBST(SIEVE_LIBS)
	SIEVE_CPPFLAGS="-I\$(srcdir)/../$sievedir"
	AC_SUBST(SIEVE_CPPFLAGS)
	AC_DEFINE(USE_SIEVE,[],[Build in Sieve support?])

	dnl Sieve configure stuff
	AC_PROG_YACC
	AC_PROG_LEX
	AC_CHECK_LIB(fl,main)

 	AC_SEARCH_LIBS(regcomp, rx regex, [
 			AC_DEFINE(ENABLE_REGEX,[],[Do we have a decent regex library?])
		 	AC_CHECK_HEADER(rxposix.h, AC_DEFINE(HAVE_RX,[],[Do we have rxposix.h?]))])
  		

	PRE_SUBDIRS="${PRE_SUBDIRS} $sievedir"
	EXTRA_OUTPUT="${EXTRA_OUTPUT} $sievedir/Makefile"
fi

dnl for et routines
AC_FUNC_CHECK(strerror,AC_DEFINE(HAS_STRERROR,[],[Do we have strerror()?]),
              AC_DEFINE(NEED_SYS_ERRLIST,[],[Do we have a sys_errlist?]))

dnl for master fd limits
AC_CHECK_HEADERS(sys/resource.h)
AC_CHECK_FUNCS(setrlimit)
AC_CHECK_FUNCS(getrlimit)

dnl for detaching terminal
AC_CHECK_FUNCS(daemon setsid)

dnl for turning off sockets
AC_CHECK_FUNCS(shutdown)

AC_EGREP_HEADER(socklen_t, sys/socket.h, AC_DEFINE(HAVE_SOCKLEN_T,[],[Do we have a socklen_t?]))
AC_EGREP_HEADER(sockaddr_storage, sys/socket.h,
		AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE,[],[Do we have a sockaddr_storage?]))
AC_EGREP_HEADER(rlim_t, sys/resource.h, AC_DEFINE(HAVE_RLIM_T,[],[Do we have an rlim_t?]))

dnl Bunch of setproctitle stuff
spt_type=""
AC_CHECK_FUNC(setproctitle,spt_type=SPT_BUILTIN)
if test "$spt_type" = ""; then
	dnl BSD/OS and FreeBSD put it in -lutil
	AC_CHECK_LIB(util,setproctitle,spt_type=SPT_BUILTIN
			LIBS="${LIBS} -lutil")
fi
if test "$spt_type" = ""; then
	AC_CHECK_HEADER(sys/pstat.h,spt_type=SPT_PSTAT)
fi
if test "$spt_type" = ""; then
	AC_CHECK_HEADER(sys/sysnews.h,spt_type=SPT_SYSMIPS)
fi
if test "$spt_type" = ""; then
	AC_MSG_CHECKING(for PS_STRINGS)
	AC_CACHE_VAL(cyrus_cv_sys_psstrings, AC_TRY_CPP([
#include <machine/vmparam.h>
#include <sys/exec.h>
#ifndef PS_STRINGS
#include </nonexistent>
#endif],cyrus_cv_sys_psstrings=yes,cyrus_cv_sys_psstrings=no))
	if test $cyrus_cv_sys_psstrings = yes; then
		spt_type=SPT_PSSTRINGS
	fi
	AC_MSG_RESULT($cyrus_cv_sys_psstrings)
fi
if test "$spt_type" = ""; then
	AC_MSG_CHECKING(for SCO)
	AC_CACHE_VAL(cyrus_cv_sys_sco, AC_TRY_CPP([
#ifndef _SCO_unix_
#include </nonexistent>
#endif],cyrus_cv_sys_sco=yes,cyrus_cv_sys_sco=no))
	if test $cyrus_cv_sys_sco = yes; then
		spt_type=SPT_SCO
	fi
	AC_MSG_RESULT($cyrus_cv_sys_sco)
fi
if test "$spt_type" = ""; then
	AC_MSG_CHECKING(for setproctitle usability)
	AC_CACHE_VAL(cyrus_cv_sys_setproctitle, AC_TRY_CPP([
#if defined(DGUX) || defined(_SEQUENT_) || defined(apollo)
#include </nonexistent>
#endif],cyrus_cv_sys_setproctitle=yes,cyrus_cv_sys_setproctitle=no))
	if test $cyrus_cv_sys_setproctitle = no; then
		spt_type=SPT_NONE
	fi
	AC_MSG_RESULT($cyrus_cv_sys_setproctitle)
fi
if test "$spt_type" != ""; then
	AC_DEFINE_UNQUOTED(SPT_TYPE,$spt_type,[Do we already have setproctitle?])
fi

AC_MSG_CHECKING(nonblocking method)
AC_CACHE_VAL(cyrus_cv_sys_nonblock,AC_TRY_LINK([#include <sys/types.h>
#include <sys/file.h>
#include <fcntl.h>
#ifndef	FNDELAY
#define FNDELAY		O_NDELAY
#endif],[fcntl(0, F_GETFL, 0)&FNDELAY],
cyrus_cv_sys_nonblock=fcntl,cyrus_cv_sys_nonblock=ioctl))
WITH_NONBLOCK=$cyrus_cv_sys_nonblock
AC_SUBST(WITH_NONBLOCK)
AC_MSG_RESULT($WITH_NONBLOCK)

AC_MSG_CHECKING(timezone GMT offset method)
AC_CACHE_VAL(cyrus_cv_struct_sys_gmtoff,AC_TRY_COMPILE([
#include <time.h>],[struct tm tm;
tm.tm_gmtoff = 0;
],cyrus_cv_struct_sys_gmtoff=tm,cyrus_cv_struct_sys_gmtoff=gmtime))
WITH_GMTOFF=$cyrus_cv_struct_sys_gmtoff
AC_SUBST(WITH_GMTOFF)
AC_MSG_RESULT($WITH_GMTOFF)
AC_MSG_CHECKING(for shared mmap)
AC_CACHE_VAL(cyrus_cv_func_mmap_shared,AC_TRY_RUN([
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
main() {
char *base;
int fd = open("conftestmmap", O_RDWR|O_CREAT|O_TRUNC, 0666);
if (fd == -1) exit(1);
if (write(fd, "test", 4) != 4) exit(1);
fsync(fd);
base = mmap((caddr_t)0, 100, PROT_READ, MAP_SHARED
#ifdef MAP_FILE
| MAP_FILE
#endif
#ifdef MAP_VARIABLE
| MAP_VARIABLE
#endif
, fd, 0L);
if (base == (caddr_t)-1) exit(1);
if (strncmp(base, "test", 4) != 0) exit(1);
if (write(fd, "test", 4) != 4) exit(1);
fsync(fd);
if (strncmp(base+4, "test", 4) != 0) exit(1);
exit(0);}
],cyrus_cv_func_mmap_shared=yes,cyrus_cv_func_mmap_shared=no,
cyrus_cv_func_mmap_shared=no))
AC_MSG_RESULT($cyrus_cv_func_mmap_shared)
if test $cyrus_cv_func_mmap_shared = yes; then
	WITH_MAP="shared"
else
AC_MSG_CHECKING(for stupid shared mmap)
AC_CACHE_VAL(cyrus_cv_func_mmap_stupidshared,AC_TRY_RUN([
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
main() {
char *base;
int fd = open("conftestmmap", O_RDWR|O_CREAT|O_TRUNC, 0666);
if (fd == -1) exit(1);
if (write(fd, "test", 4) != 4) exit(1);
fsync(fd);
base = mmap((caddr_t)0, 4, PROT_READ, MAP_SHARED
#ifdef MAP_FILE
| MAP_FILE
#endif
#ifdef MAP_VARIABLE
| MAP_VARIABLE
#endif
, fd, 0L);
if (base == (caddr_t)-1) exit(1);
if (strncmp(base, "test", 4) != 0) exit(1);
lseek(fd, 0L, 0);	
if (write(fd, "xyzz", 4) != 4) exit(1);
fsync(fd);
if (strncmp(base, "xyzz", 4) != 0) exit(1);
exit(0);}
],cyrus_cv_func_mmap_stupidshared=yes,cyrus_cv_func_mmap_stupidshared=no,
cyrus_cv_func_mmap_stupidshared=no))
AC_MSG_RESULT($cyrus_cv_func_mmap_stupidshared)
if test $cyrus_cv_func_mmap_stupidshared = yes; then
	WITH_MAP="stupidshared"
else
	AC_MSG_WARN([*** This system does not have a working mmap()])
	AC_MSG_WARN(*** Expect a considerable performance penalty)
	WITH_MAP=nommap
fi
fi

AC_SUBST(WITH_MAP)
AC_ARG_WITH(lock,
  [  --with-lock=METHOD      force use of METHOD for locking (flock or fcntl)],
  WITH_LOCK="$withval", [
  AC_CHECK_FUNC(fcntl,WITH_LOCK="fcntl",[
		AC_CHECK_FUNC(flock,WITH_LOCK="flock",[
				AC_ERROR(unable to detect locking method)
			      ])
		])
  ])

AC_SUBST(WITH_LOCK)

dnl check for fdatasync (used by cyrusdb_skiplist)
LIB_RT=""
AC_CHECK_FUNC(fdatasync, AC_DEFINE(HAVE_FDATASYNC,[],[Do we have fdatasync()?]), [
  AC_CHECK_LIB(rt, fdatasync, [
	LIB_RT="-lrt"
	AC_DEFINE(HAVE_FDATASYNC,[],[Do we have fdatasync()?])
  ])
])

dnl for makedepend and AFS.
cant_find_sigvec=no
AC_CACHE_VAL(cyrus_sigveclib,[
 dnl bsd classic flavor
 AC_CHECK_FUNC(sigvec, [
	cyrus_sigveclib=""
  ], [
  dnl hp flavor
  AC_CHECK_LIB(BSD, sigvec, cyrus_sigveclib="-lBSD", [
    dnl not hp flavor
    SAVE_LDFLAGS="$LDFLAGS"
    dnl solaris flavor
    LDFLAGS="-L/usr/ucblib -R/usr/ucblib $LDFLAGS"
    AC_CHECK_LIB(ucb, sigvec, [
      dnl more solaris flavor
      cyrus_sigveclib="-lc -L/usr/ucblib -R/usr/ucblib -lucb"],
      [ cant_find_sigvec=yes ])
    LDFLAGS="$SAVE_LDFLAGS"])
  ])
])
AC_SUBST(cyrus_sigveclib)

# ok, we still look for this stuff because of checking groups, but
# all authentication goes through SASL

AC_ARG_WITH(afs,[  --with-afs=PATH         use AFS libraries from PATH],
	[with_afs="${withval}"
	CFLAGS="${CFLAGS} -I${withval}/include"],with_afs="/usr/local")

AC_ARG_WITH(auth,[  --with-auth=METHOD      use authorization module METHOD
                          METHOD is unix or krb],WITH_AUTH="$withval",
	if test -f /etc/krb.conf -o -f /etc/kerberosIV/krb.conf ; then
		WITH_AUTH="krb"
	else
		WITH_AUTH="unix"
	fi)
AC_SUBST(WITH_AUTH)
if test "$WITH_AUTH" = krb_pts; then
	EXTRA_SUBDIRS="${EXTRA_SUBDIRS} ptclient"
	EXTRA_OUTPUT="${EXTRA_OUTPUT} ptclient/Makefile"
	AFS_LIBS="${with_afs}/lib/afs/libkauth.a ${with_afs}/lib/afs/libprot.a  ${with_afs}/lib/afs/libauth.a ${with_afs}/lib/afs/libsys.a ${with_afs}/lib/librxkad.a ${with_afs}/lib/librx.a ${with_afs}/lib/afs/libsys.a ${with_afs}/lib/libubik.a  ${with_afs}/lib/liblwp.a ${with_afs}/lib/afs/util.a"
	if test -f ${with_afs}/lib/afs/libaudit.a; then
		AFS_LIBS="$AFS_LIBS ${with_afs}/lib/afs/libaudit.a"
	fi
	if test -f /usr/ucblib/libucb.a; then
		CMU_ADD_LIBPATH_TO(/usr/ucblib, AFS_LDFLAGS)
		AFS_LIBS="$AFS_LIBS -lc -lucb"
	fi

	AC_CACHE_VAL(cyrus_afs_pr_end,[
		SAVE_LIBS="$LIBS"
		LIBS="$AFS_LIBS"
		AC_MSG_CHECKING(if AFS libraries have pr_End)
		AC_TRY_LINK([pr_End();],
			[pr_End()],
			[
				dnl it linked; have it
				AC_MSG_RESULT(yes)
				cyrus_afs_pr_end="yes"
			], [
				dnl didn't link; use old code
				AC_MSG_RESULT(no)
				cyrus_afs_pr_end="no"
			])
		])
	LIBS="$SAVE_LIBS"
	if test "$cyrus_afs_pr_end" = no; then
		AC_DEFINE(HAVE_PR_END,[],[do we have the AFS symbol pr_End?])
	fi
	AC_CACHE_VAL(cyrus_afs_sigvec,[
		SAVE_LIBS="$LIBS"
		LIBS="${with_afs}/lib/liblwp.a"
		AC_MSG_CHECKING(if AFS libraries need sigvec)
		dnl Does AFS need sigvec?  We have to link against lwp and see
		dnl if IOMGR_Initialize wants it
		AC_TRY_LINK([IOMGR_Initialize();],
			[IOMGR_Initialize()],
			[
				dnl it linked; don't need it
				AC_MSG_RESULT(no)
				cyrus_afs_sigvec="no"
			], [
				dnl didn't link; pick up sigvec
				AC_MSG_RESULT(yes)
				cyrus_afs_sigvec="yes"
			])
		])
	if test "$cyrus_afs_sigvec" = yes; then
	  if test "$cant_find_sigvec" = yes; then
            AC_MSG_WARN([Can't find a sigvec for AFS libraries which seem to])
	    AC_MSG_WARN([need one; ptloader may not build.])
          else
	    AFS_LIBS="${AFS_LIBS} $cyrus_sigveclib"
	  fi
	fi
	LIBS="$SAVE_LIBS"
	AC_SUBST(AFS_LIBS)
	AC_SUBST(AFS_LDFLAGS)
fi

SERVER_SUBDIRS="master imap"
AC_ARG_ENABLE(server,
	[  --disable-server        disable compiling servers],
	if test "$enableval" = no; then
        	SERVER_SUBDIRS=""
	fi)
AC_SUBST(SERVER_SUBDIRS)
# We always output a server makefile (just because we can)

dnl this is the new simple check for kerberos; since the person had to
dnl compile SASL, we might as well use the same checks.
AC_ARG_WITH(krb,[  --with-krb=PATH         use Kerberos from PATH],
	with_krb="$withval", with_krb="yes")

AC_ARG_ENABLE(statickrb,
		[  --enable-statickrb      link Kerberos statically],
	with_statickrb="yes", with_statickrb="no")

if test "$WITH_AUTH" = "krb" -o "$WITH_AUTH" = "krb_pts" ; then
  dnl In order to compile kerberos4, we need libkrb and libdes.

  dnl we might need -lresolv for kerberos
  AC_CHECK_LIB(resolv,res_search)

  if test "$with_statickrb" = "yes" -a ! -d "$with_krb"; then
	AC_MSG_ERROR([--enable-statickrb specified but --with-krb did not specify a valid directory])
  fi 

  AC_CHECK_LIB(des,des_ecb_encrypt,
	if test "$with_statickrb" = "yes"; then
	    KRB_LIBS="$with_krb/lib/libdes.a"
	else
	    KRB_LIBS="-ldes"
	fi,
  AC_MSG_ERROR([The Kerberos DES library is required for Kerberos support.  You might want --with-auth=unix.]))

  dnl if we were ambitious, we'd look more aggressively for the
  dnl krb4 install
  if test -d ${with_krb}; then
     AC_CACHE_CHECK(for Kerberos includes, cyrus_krbinclude, [
       for krbhloc in include/kerberosIV include
       do
         if test -f ${with_krb}/${krbhloc}/krb.h ; then
           cyrus_krbinclude=${with_krb}/${krbhloc}
           break
         fi
       done
       ])

     if test -n "${cyrus_krbinclude}"; then
       CPPFLAGS="$CPPFLAGS -I${cyrus_krbinclude}"
     fi
     CMU_ADD_LIBPATH(${with_krb}/lib)
  fi

  if test "$with_des" != no; then
    AC_CHECK_HEADER(krb.h,
      AC_CHECK_LIB(krb, krb_mk_priv,
	if test "$with_statickrb" = "yes"; then
	    KRB_LIBS="$KRB_LIBS $with_krb/lib/libkrb.a"
	else
	    KRB_LIBS="$KRB_LIBS -lkrb"
	fi,
                   AC_WARN(No Kerberos V4 found); krb4=no,
		   $KRB_LIBS),
      AC_WARN(No Kerberos V4 found); krb4=no)
  else
    AC_WARN(No DES library found for Kerberos V4 support)
    krb4=no
  fi

  if test "${krb4}" != no; then
    AC_DEFINE(HAVE_KRB,[],[Support for Kerberos?])
  else
    AC_ERROR([Kerberos not found for authorization module])
  fi
fi

AC_SUBST(KRB_LIBS)

dnl
dnl Test for OpenSSL
dnl
IMAP_PROGS=""
AC_ARG_WITH(openssl,[  --with-openssl=PATH     use OpenSSL from PATH],
	with_openssl="${withval}")

OPENSSL_INC=
OPENSSL_LIB=
case "$with_openssl" in
	no) with_openssl="no";;
	""|yes) 
	  dnl if openssl has been compiled with the rsaref2 libraries,
	  dnl we need to include the rsaref libraries in the crypto check
                LIB_RSAREF=""
	        AC_CHECK_LIB(rsaref, RSAPublicEncrypt,
		       LIB_RSAREF="-lRSAglue -lrsaref"; cmu_have_rsaref=yes,
		       cmu_have_rsaref=no)

		with_openssl="yes"
		AC_CHECK_LIB(crypto,BIO_accept,
                                    LIBS="-lcrypto $LIB_RSAREF ${LIBS}",
		                    with_openssl="no", $LIB_RSAREF)
		AC_CHECK_LIB(ssl, SSL_CTX_new, LIBS="-lssl ${LIBS}",
		             with_openssl="no", -lcrypto $LIB_RSAREF)
		
		;;
	*)  OPENSSL_INC="-I${with_openssl}/include"
	    OPENSSL_LIBPATH="${with_openssl}/lib"
	    OPENSSL_LIB="-L${OPENSSL_LIBPATH}"
	    CPPFLAGS="${CPPFLAGS} ${OPENSSL_INC}"
	    CMU_ADD_LIBPATH(${OPENSSL_LIBPATH})
	    CMU_ADD_LIBPATH_TO(${OPENSSL_LIBPATH}, OPENSSL_LIB)
	    LIBS="${LIBS} -lssl -lcrypto";;
esac

AC_MSG_CHECKING(for openssl)
AC_MSG_RESULT($with_openssl)

if test "$with_openssl" != "no"; then
	AC_DEFINE(HAVE_SSL,[],[Build with SSL support?])
	IMAP_PROGS="$IMAP_PROGS tls_prune"
fi
AC_SUBST(OPENSSL_INC)
AC_SUBST(OPENSSL_LIB)

dnl
dnl Allow for setting EGD socket file on systems without /dev/*random.
dnl
AC_ARG_WITH(egd-socket,
      [  --with-egd-socket=FILE  Entropy Gathering Daemon socket pathname
                          for systems without /dev/urandom],
              [ EGD_SOCKET="$withval" ]
      )
if test -n "$EGD_SOCKET" ; then
      AC_DEFINE_UNQUOTED(EGD_SOCKET, "$EGD_SOCKET", [Alternative to /dev/urandom?])
fi

dnl
dnl Test for Zephyr
dnl
AC_ARG_WITH(zephyr,[  --with-zephyr[=PATH]    enable Zephyr notification (installed on PATH)],
	with_zephyr="${withval}")
if test -z "$with_zephyr"; then
     if test -f /usr/local/lib/libzephyr.a; then
	with_zephyr="/usr/local"
     elif test -f /usr/lib/libzephyr.a; then
        with_zephyr="/usr"
     fi
fi
ZEPHYR_LIBS=""
ZEPHYR_CPPFLAGS=""
case "$with_zephyr" in
	no) true;;
	""|yes) AC_CHECK_LIB(zephyr,ZInitialize,ZEPHYR_LIBS="-lzephyr",
		with_zephyr="no",);;
       *)  if test -d ${with_zephyr}/include/zephyr; then
               ZEPHYR_CPPFLAGS="-I${with_zephyr}/include/zephyr"
           else
               ZEPHYR_CPPFLAGS="-I${with_zephyr}/include"
           fi
           ZEPHYR_LIBS="-lzephyr";;
esac
AC_SUBST(ZEPHYR_LIBS)
AC_SUBST(ZEPHYR_CPPFLAGS)
if test "$with_zephyr" != "no"; then
	AC_DEFINE(HAVE_ZEPHYR,[],[Build with Zephyr support?])
fi

dnl
dnl Set pidfile location
dnl
AC_ARG_WITH(pidfile,[  --with-pidfile[=PATH]     pidfile in PATH (/var/run/cyrus-master.pid)],
	[MASTERPIDFILE="$withval"],
	[MASTERPIDFILE="/var/run/cyrus-master.pid"])
MASTERPIDFILE="\"$MASTERPIDFILE\""
AC_DEFINE_UNQUOTED(MASTER_PIDFILE, $MASTERPIDFILE,[Name of the pidfile for master])

dnl
dnl Select a method for IMAP IDLE
dnl
AC_ARG_WITH(idle,[  --with-idle=METHOD      use METHOD for IMAP IDLE
                          METHOD is [poll], idled or no],
	WITH_IDLE="${withval}",WITH_IDLE="poll")
AC_SUBST(WITH_IDLE)
if test "$WITH_IDLE" = "idled"; then
  IMAP_PROGS="$IMAP_PROGS idled"
fi

dnl
dnl see if we're compiling the Murder support programs
dnl
AC_ARG_ENABLE(murder,
        [  --enable-murder         enable IMAP Murder support],
        if test "$enableval" != no; then
	  IMAP_PROGS="$IMAP_PROGS proxyd pop3proxyd lmtpproxyd mupdate"
        fi) 

AC_SUBST(IMAP_PROGS)

dnl
dnl Try and find a system version of com_err.
dnl If we see something that looks a little wacky, ignore it (there are many
dnl deficient installs of com_err, unfortunately, which leave out compile_et)
dnl
AC_ARG_WITH(com_err,
[  --with-com_err=PATH     use com_err from path -- includes in PATH/include,
                          libs in PATH/lib, and compile_et in PATH/bin])
if test -z "$with_com_err"; then
	AC_CHECK_HEADER(com_err.h, [
  	  # no value supplied
	  AC_CHECK_LIB(com_err, com_err, [
		# com_err is already in library path
		# guess we're okay
		# can use system com_err
		with_com_err=""
		AC_PATH_PROG(COMPILE_ET, compile_et, [no compile et])
	  ], [
	  if test -f /usr/local/include/com_err.h; then
		with_com_err="/usr/local"
		AC_PATH_PROG(COMPILE_ET, /usr/local/bin/compile_et, [no compile et])
	  else
		# use ours
		with_com_err=yes
	  fi
	  ])], [
	  with_com_err="no"
	])

	if test "${with_com_err}" = "no"; then
	  AC_MSG_WARN([com_err is required; included version will be used.])
	  with_com_err="yes"
	else
	  if test "${COMPILE_ET}" = "no compile et" -o "${COMPILE_ET}" = ""; then
	    AC_MSG_WARN([Parts of com_err distribuion were found, but not compile_et.])
	    AC_MSG_WARN([Will build com_err from included sources.])
	    with_com_err="yes" # build it ourselves
	  fi
	fi
fi

case "$with_com_err" in
  # built-in et
  yes) # use the com_err we're gonna build
	  COM_ERR_LIBS="../et/libcom_err.a"
	  COMPILE_ET="../et/compile_et"
	  COM_ERR_LDFLAGS=""
	  COM_ERR_CPPFLAGS="-I\${srcdir}/../et"
	  PRE_SUBDIRS="et ${PRE_SUBDIRS}"
	  EXTRA_OUTPUT="${EXTRA_OUTPUT} et/Makefile"
	  ;;
  "")   # no problem, we already have it in the paths
	# we do nothing to pick it up
	COM_ERR_LIBS="-lcom_err" # hope it's not shared
	# we already set COMPILE_ET, or we didn't get here
	COM_ERR_LDFLAGS=""
	COM_ERR_CPPFLAGS=""
      ;;
  *) # use whatever they told us, or whatever we found
     COMPILE_ET="${with_com_err}/bin/compile_et"
     COM_ERR_LIBS="${with_com_err}/lib/libcom_err.a"
     COM_ERR_CPPFLAGS="-I${with_com_err}/include"
     # Ever get the feeling people hide this stuff on purpose?
     if test -d "${with_com_err}/include/et" ; then
       COM_ERR_CPPFLAGS="-I${with_com_err}/include/et"
     fi
dnl     CMU_ADD_LIBPATH_TO(${with_com_err}/lib, COM_ERR_LDFLAGS)
     COMPILE_ET="${with_com_err}/bin/compile_et"
esac
AC_SUBST(COMPILE_ET)
AC_SUBST(COM_ERR_LIBS)
AC_SUBST(COM_ERR_LDFLAGS)
AC_SUBST(COM_ERR_CPPFLAGS)

dnl Syslog compile-time options
SYSLOG_FACILITY=LOG_LOCAL6
AC_ARG_WITH(syslogfacility, [  --with-syslogfacility=FACILITY (default LOCAL6)],
		[ if test "$withval" != "yes" -a "$withval" != "no" ; then
			SYSLOG_FACILITY=LOG_$withval
		fi; ])
AC_DEFINE_UNQUOTED(SYSLOG_FACILITY, $SYSLOG_FACILITY, [Syslog facility to use.])

AC_MSG_CHECKING(for modern syslog)
AC_CACHE_VAL(cyrus_cv_lib_syslog, AC_TRY_CPP([#include <syslog.h>
#ifndef LOG_LOCAL6
#include </nonexistent>
#endif],cyrus_cv_lib_syslog=yes,cyrus_cv_lib_syslog=no))
if test $cyrus_cv_lib_syslog = no; then
	PRE_SUBDIRS="${PRE_SUBDIRS} syslog"
	EXTRA_OUTPUT="${EXTRA_OUTPUT} syslog/Makefile"
	DEPLIBS="${DEPLIBS} ../syslog/libsyslog.a"
	CPPFLAGS="$CPPFLAGS -I\$(srcdir)/../syslog"
fi
AC_MSG_RESULT($cyrus_cv_lib_syslog)

dnl Have to check getdtabalesize after adding ossup, as some ossups define it
AC_REPLACE_FUNCS(getdtablesize)
AC_ARG_ENABLE(cmulocal,
	[  --enable-cmulocal       enable CMU-specific local support],
	if test "$enableval" = yes; then
		EXTRA_SUBDIRS="${EXTRA_SUBDIRS} netnews depot"
		EXTRA_OUTPUT="${EXTRA_OUTPUT} depot/Makefile"
	fi)

AC_ARG_ENABLE(fulldirhash,
	[  --enable-fulldirhash    enable improved directory hashing -- hashes full
                          username instead of using just the first letter],
	if test "$enableval" = yes; then
		AC_DEFINE(USE_DIR_FULL,[],[Use full hashing scheme?])
	fi)

AC_MSG_CHECKING(to use old sieve service name)
AC_ARG_ENABLE(oldsievename,
	[  --enable-oldsievename   enable the use of 'imap' as the sieve service name],
	if test "$enableval" = yes; then
		AC_MSG_RESULT(yes)
		AC_DEFINE(OLD_SIEVE_SERVICE_NAME,[],[Use "imap" as sieve service name?])
	else
		AC_MSG_RESULT(no)
	fi,
	AC_MSG_RESULT(no))

AC_ARG_ENABLE(listext,
	[  --enable-listext        enable IMAP List extensions],
	if test "$enableval" = yes; then
		AC_DEFINE(ENABLE_LISTEXT,[],[Enable the LISTEXT extension?])
	fi)

AC_ARG_ENABLE(annotatemore,
	[  --enable-annotatemore   enable IMAP mailbox/server annotations],
	if test "$enableval" = yes; then
		AC_DEFINE(ENABLE_ANNOTATEMORE,[],[Enable the ANNOTATEMORE extension?])
	fi)

AC_ARG_ENABLE(netscapehack,
	[  --enable-netscapehack   enable Netscape hack for the menu option
                          in Communicator to Administrate Mail],
	if test "$enableval" = yes; then
		AC_DEFINE(ENABLE_X_NETSCAPE_HACK,[],[Enable Netscape Menu Option Hack?])
	fi)

AC_CHECK_FUNC(dlopen,,[AC_CHECK_LIB(dl, dlopen)])
CMU_SASL2_CHECKAPOP_REQUIRED

AC_ARG_WITH(perl,       [  --with-perl=PERL        use PERL for perl],
	with_perl="$withval", with_perl="perl")

if test "${with_perl}" = yes; then
    with_perl="perl"
fi
if test "${with_perl}" != no; then
    if test ${using_static_sasl} = "staticonly"; then
	AC_MSG_WARN([Cannot compile perl utilities using static libsasl])
	with_perl="no"
    else 
	AC_CHECK_PROGS(PERL, ${with_perl} perl, with_perl=notfound)
    fi
fi
if test "$with_perl" = "notfound"; then
    AC_MSG_WARN(Perl not found: Administrative tools won't be available)
elif test "${with_perl}" != "no"; then
dnl compile perl stuff
    EXTRA_SUBDIRS="${EXTRA_SUBDIRS} perl"
dnl and compile perl/cyradm
    PERL_SUBDIRS="imap"
    PERL="${with_perl}"
fi

dnl for timsieved
if test "$sievedir" != "no"; then
	EXTRA_SUBDIRS="${EXTRA_SUBDIRS} timsieved notifyd"
	EXTRA_OUTPUT="${EXTRA_OUTPUT} timsieved/Makefile notifyd/Makefile"

	PERL_SUBDIRS="${PERL_SUBDIRS} sieve"
	PERL_DEPSUBDIRS="sieve"
	EXTRA_OUTPUT="${EXTRA_OUTPUT} perl/sieve/Makefile perl/sieve/lib/Makefile"
else
	PERL_DEPSUBDIRS="none"
fi

dnl Check for MD5 functions
AC_FUNC_CHECK(MD5Init,,
       AC_CHECK_LIB(md, MD5Init, LIBS="${LIBS} -lmd",
                    MD5OBJ="md5.o"))
AC_SUBST(MD5OBJ)

dnl snmp
dnl (agentx was depricated, but SNMP_SUBDIRS is conveinent as a placeholder)
SNMP_SUBDIRS=""
AC_SUBST(SNMP_SUBDIRS)

dnl
dnl Test for DRAC
dnl
DRACLIBS=
AC_ARG_WITH(drac, [  --with-drac=DIR         use DRAC library in <DIR> [no] ],
	if test -d "$withval"; then
		LDFLAGS="$LDFLAGS -L${withval}"
		AC_CHECK_LIB(drac, dracauth,
			AC_DEFINE(DRAC_AUTH,[],[Use DRAC library for pop/imap-before-smtp?])
			DRACLIBS="-ldrac")
	fi)
AC_SUBST(DRACLIBS)

CMU_LIBWRAP
CMU_UCDSNMP

sasl_cv_getaddrinfo=no
IPv6_CHECK_FUNC(getaddrinfo,
		[AC_DEFINE(HAVE_GETADDRINFO)], [sasl_cv_getaddrinfo=yes], 
		[Do we have a getaddrinfo?])
if test $sasl_cv_getaddrinfo = yes; then
    AC_LIBOBJ([getaddrinfo])
fi
sasl_cv_getnameinfo=no
IPv6_CHECK_FUNC(getnameinfo,
		[AC_DEFINE(HAVE_GETNAMEINFO)], [sasl_cv_getnameinfo=yes],
		[Do we have a getnameinfo?])
if test $sasl_cv_getnameinfo = yes; then
    AC_LIBOBJ([getnameinfo])
fi

IPv6_CHECK_SS_FAMILY()
IPv6_CHECK_SA_LEN()

# Figure out what directories we're linking against.
# Lots of fun for the whole family.
# This probably chokes on anything with spaces in it.
# All we want is the list of -L directories, and -L may or may not be
# followed by a space.
isdir=no
libpath=""
#echo "debug ldflags: << ${ldflags} >>"
#echo "debug default_ldflags: << ${default_ldflags} >>"
for flag in ${ldflags} ${default_ldflags}; do
  case $flag in
    -L)
      # it's a split -L option, we'll mark the next option as a dir.
      isdir=yes
      ;;

    -L*) 
      # attached -L option: split off the directory
      larg=`echo $flag | sed -e 's:-L\(..*\):\1:'`
      libpath="${libpath} ${larg}"
      ;;

    *)
      if test $isdir = yes ; then
	libpath="${libpath} ${flag}"
	isdir=no
      fi
  esac
done

IMAP_COM_ERR_LIBS="${COM_ERR_LIBS}"
IMAP_LIBS="${LIB_SASL} ${KRB_LIBS} ${LIB_RT} ${LIBS}"

AC_SUBST(IMAP_COM_ERR_LIBS)
AC_SUBST(IMAP_LIBS)

dnl AC_OUTPUT_COMMANDS([
dnl   if test "$with_perl" != "no"; then
dnl     (cd perl/sieve/acap; $perl Makefile.PL PREFIX=$prefix)
dnl     (cd perl/sieve/managesieve; $perl Makefile.PL PREFIX=$prefix)
dnl     (cd perl/imap; $perl Makefile.PL PREFIX=$prefix)
dnl   fi
dnl ], perl=$PERL; with_perl=$with_perl; prefix=$prefix; SASL_LIB="$LIB_SASL"; SASL_INC="$SASLFLAGS"; export SASL_LIB SASL_INC)
AC_SUBST(PERL_SUBDIRS)
AC_SUBST(PERL_DEPSUBDIRS)
AC_SUBST(PERL)

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

#ifndef _CYRUS_IMAPD_CONFIG_H_
#define _CYRUS_IMAPD_CONFIG_H_
])

AH_BOTTOM([
/* time.h */
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
#  include <sys/time.h>
# else
#  include <time.h>
# endif
#endif

/* This allows us to work even when we don't have an fdatasync */
#ifndef HAVE_FDATASYNC
#define fdatasync(fd) fsync(fd)
#endif

/* A similar setup for not having O_DSYNC */
#include <fcntl.h>

#ifndef O_DSYNC
#  ifdef O_SYNC
#    define O_DSYNC     O_SYNC          /* POSIX */
#  else
#    define O_DSYNC     O_FSYNC         /* BSD */
#  endif
#endif

/* where are our binaries? */
#define SERVICE_PATH (CYRUS_PATH "/bin")

#ifndef HAVE___ATTRIBUTE__
/* Can't use attributes... */
#define __attribute__(foo)
#endif

#ifndef HAVE_SOCKLEN_T
typedef unsigned int socklen_t;
#endif

#ifndef HAVE_RLIM_T
typedef int rlim_t;
#endif

/* some potentially memory saving tradeoffs, 
   preconfigured in memory-saving mode */

/* call sasl_client_init() at the start of imapd */
#define DELAY_SASL_CLIENT_INIT

/* save the cmdlines for the ID command */
#undef ID_SAVE_CMDLINE

/* IPv6 things */
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
#define	_SS_MAXSIZE	128	/* Implementation specific max size */
#define	_SS_PADSIZE	(_SS_MAXSIZE - sizeof (struct sockaddr))

struct sockaddr_storage {
	struct	sockaddr ss_sa;
	char		__ss_pad2[_SS_PADSIZE];
};
# define ss_family ss_sa.sa_family
# define HAVE_SS_FAMILY
#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */

#ifndef HAVE_SS_FAMILY
#define ss_family	__ss_family
#endif

#ifndef AF_INET6
/* Define it to something that should never appear */
#define	AF_INET6	AF_MAX
#endif

#ifndef HAVE_GETADDRINFO
#define getaddrinfo     sasl_getaddrinfo
#define freeaddrinfo    sasl_freeaddrinfo
#define gai_strerror    sasl_gai_strerror
#endif

#ifndef HAVE_GETNAMEINFO
#define getnameinfo     sasl_getnameinfo
#endif

#if !defined(HAVE_GETADDRINFO) || !defined(HAVE_GETNAMEINFO)
#include "gai.h"
#endif

#ifndef	NI_WITHSCOPEID
#define	NI_WITHSCOPEID	0
#endif

/* End IPv6 things */

#ifdef OLD_SIEVE_SERVICE_NAME
#define SIEVE_SERVICE_NAME "imap"
#else
#define SIEVE_SERVICE_NAME "sieve"
#endif

#ifndef HAVE_SHUTDOWN
#define shutdown(fd, mode) 0
#endif

/* sendmail configuration parameters */
#define DEFAULT_SENDMAIL ("/usr/sbin/sendmail")
#define DEFAULT_POSTMASTER ("postmaster")

#define SENDMAIL (config_getstring("sendmail", DEFAULT_SENDMAIL))
#define POSTMASTER (config_getstring("postmaster", DEFAULT_POSTMASTER))

/* compile time options; think carefully before modifying */
enum {
    /* should we send an UNAVAILABLE message to master when
     * a service is exiting (master is already going to be 
     * informed of the exit by the SIGCHLD signal anyway) ? */
    MESSAGE_MASTER_ON_EXIT = 0,

    /* should a hierarchical rename stop on error? */
    RENAME_STOP_ON_ERROR = 1,

    /* should we call fsync() to maybe help with softupdates? (it should) */
    APPEND_ULTRA_PARANOID = 1,

    /* should we log extra information at the DEBUG level for DB stuff? 
     * 0 -> nothing; 1 -> some; higher -> even more */
    CONFIG_DB_VERBOSE = 1,

    /* log timing information to LOG_DEBUG */
    CONFIG_TIMING_VERBOSE = 0,

    /* should we be pedantic about namespace or sleezy? */
    SLEEZY_NAMESPACE = 1,

    /* should we do a fast TLS session shutdown? */
    TLS_FAST_SHUTDOWN = 1,

    /* should we use the SQUAT engine to accelerate SEARCH? */
    SQUAT_ENGINE = 1,

    /* should we have long LMTP error messages? */
    LMTP_LONG_ERROR_MSGS = 1,

    /* default time to wait, in seconds, before giving up
     * trying to lock something */
    LOCK_GIVEUP_TIMER_DEFAULT = 100
};

#endif /* _CYRUS_IMAPD_CONFIG_H_ */
])

dnl make sure that Makefile is the last thing output
AC_OUTPUT(man/Makefile master/Makefile lib/Makefile acap/Makefile imap/Makefile imap/feedcyrus imtest/Makefile netnews/Makefile perl/Makefile $EXTRA_OUTPUT Makefile)
