0N/A# Be sure to update ABI version also if anything changes that might require
0N/A# recompiling plugins. Most importantly that means if any structs are changed.
661N/AAC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "
2.2.ABIv0($PACKAGE_VERSION)", [Dovecot ABI version])
0N/AAC_CONFIG_SRCDIR([src])
0N/AAM_INIT_AUTOMAKE([foreign])
0N/AACLOCAL_AMFLAGS='-I $(top_srcdir)'
0N/AAC_SUBST(ACLOCAL_AMFLAGS)
0N/Adnl TEST_WITH(name, value, [plugin])
0N/AAC_DEFUN([TEST_WITH], [
0N/A want=want_`echo $1|sed s/-/_/g`
0N/A if test $2 = yes || test $2 = no || test $2 = auto; then
0N/A elif test $2 = plugin; then
0N/A if test "$3" = plugin; then
0N/A AC_ERROR([--with-$1=plugin not supported])
0N/A AC_ERROR([--with-$1=path not supported. You may want to use instead:
0N/ACPPFLAGS=-I$2/include LDFLAGS=-L$2/lib ./configure --with-$1])
0N/A AC_ERROR([--with-$1: Unknown value: $2])
0N/AAC_ARG_ENABLE(devel-checks,
0N/AAS_HELP_STRING([--enable-devel-checks], [Enable some extra expensive checks for developers]),
0N/A if test x$enableval = xyes; then
0N/A AC_DEFINE(DEBUG,, Build with extra debugging checks)
0N/AAC_ARG_ENABLE(asserts,
661N/AAS_HELP_STRING([--enable-asserts], [Enable asserts (default)]),
0N/A if test x$enableval = xno; then
661N/A AC_DEFINE(DISABLE_ASSERTS,, Disable asserts)
661N/AAC_ARG_WITH(shared-libs,
661N/AAS_HELP_STRING([--with-shared-libs], [Link binaries using shared Dovecot libraries (default)]),
661N/A want_shared_libs=$withval,
661N/AAM_CONDITIONAL(BUILD_SHARED_LIBS, test "$want_shared_libs" = "yes")
661N/AAS_HELP_STRING([--with-mem-align=BYTES], [Set the memory alignment (default: 8)]),
661N/AAS_HELP_STRING([--with-ioloop=IOLOOP], [Specify the I/O loop method to use (epoll, kqueue, poll; best for the fastest available; default is best)]),
661N/AAS_HELP_STRING([--with-notify=NOTIFY], [Specify the file system notification method to use (inotify, kqueue, dnotify, none; default is detected in the above order)]),
661N/AAS_HELP_STRING([--with-nss], [Build with NSS module support (auto)]),
661N/A TEST_WITH(nss, $withval),
661N/AAS_HELP_STRING([--with-shadow], [Build with shadow password support (auto)]),
661N/A TEST_WITH(shadow, $withval),
661N/AAS_HELP_STRING([--with-pam], [Build with PAM support (auto)]),
661N/A TEST_WITH(pam, $withval),
661N/AAS_HELP_STRING([--with-bsdauth], [Build with BSD authentication support (auto)]),
661N/A TEST_WITH(bsdauth, $withval),
661N/AAS_HELP_STRING([--with-gssapi=yes|plugin Build with GSSAPI authentication support]),
661N/A TEST_WITH(gssapi, $withval, plugin),
661N/AAS_HELP_STRING([--with-sia], [Build with Tru64 SIA support]),
661N/A TEST_WITH(sia, $withval),
661N/AAS_HELP_STRING([--with-ldap=yes|plugin], [Build with LDAP support]),
661N/A TEST_WITH(ldap, $withval, plugin),
661N/AAS_HELP_STRING([--with-vpopmail], [Build with vpopmail support (auto)]),
661N/A if test x$withval = xno; then
661N/A if test x$withval = xyes || test x$withval = xauto; then
661N/A vpopmail_home="`echo ~vpopmail`"
661N/A vpopmail_home="$withval"
661N/A# Berkeley DB support is more or less broken. Disabled for now.
661N/A#AS_HELP_STRING([--with-db], [Build with Berkeley DB support]),
661N/A# TEST_WITH(db, $withval),
661N/AAS_HELP_STRING([--with-cdb], [Build with CDB support]),
661N/A TEST_WITH(cdb, $withval),
661N/Adnl The --with-sql is useful only if Dovecot is being built with all the SQL
661N/Adnl drivers as modules. If any SQL driver is built-in, this option is ignored.
661N/AAS_HELP_STRING([--with-sql=yes|plugin], [Build with generic SQL support]),
661N/A TEST_WITH(sql, $withval, plugin),
661N/AAS_HELP_STRING([--with-pgsql], [Build with PostgreSQL driver support]),
661N/A TEST_WITH(pgsql, $withval),
661N/AAS_HELP_STRING([--with-mysql], [Build with MySQL driver support]),
661N/A TEST_WITH(mysql, $withval),
661N/AAS_HELP_STRING([--with-sqlite], [Build with SQLite3 driver support]),
661N/A TEST_WITH(sqlite, $withval),
661N/AAS_HELP_STRING([--with-lucene], [Build with CLucene full text search support]),
661N/A TEST_WITH(lucene, $withval),
661N/AAM_CONDITIONAL(BUILD_LUCENE, test "$want_lucene" = "yes")
661N/AAS_HELP_STRING([--with-stemmer], [Build with libstemmer support (for CLucene)]),
661N/A TEST_WITH(stemmer, $withval),
661N/AAS_HELP_STRING([--with-solr], [Build with Solr full text search support]),
661N/A TEST_WITH(solr, $withval),
661N/AAS_HELP_STRING([--with-zlib], [Build with zlib compression support]),
661N/A TEST_WITH(zlib, $withval),
661N/AAS_HELP_STRING([--with-bzlib], [Build with bzlib compression support]),
661N/A TEST_WITH(bzlib, $withval),
661N/AAS_HELP_STRING([--with-libcap], [Build with libcap support (Dropping capabilities).]),
661N/A TEST_WITH(libcap, $withval),
661N/AAS_HELP_STRING([--with-libwrap], [Build with libwrap, ie. TCP-wrappers]),
661N/A TEST_WITH(libwrap, $withval),
661N/AAS_HELP_STRING([--with-ssl=gnutls|openssl], [Build with GNUTLS or OpenSSL (default)]),
661N/A if test x$withval = xno; then
661N/A elif test x$withval = xgnutls; then
661N/A AC_ERROR([GNUTLS support is broken currently])
661N/A elif test x$withval = xopenssl; then
661N/A elif test x$withval = xyes; then
661N/A AC_ERROR([--with-ssl: Invalid value: $withval])
661N/AAS_HELP_STRING([--with-ssldir=DIR], [SSL base directory for certificates (
/etc/ssl)]),
661N/AAC_ARG_WITH([systemdsystemunitdir],
661N/AAS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files (auto=detect)]), [
661N/A if test "$withval" = "auto"; then
661N/A systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd`
661N/A elif test "$withval" != "no"; then
661N/A systemdsystemunitdir=$withval
661N/Aif test "$systemdsystemunitdir" != ""; then
661N/A AC_SUBST(systemdsystemunitdir)
661N/A AC_DEFINE(HAVE_SYSTEMD,, Define if you want to use systemd socket activation)
661N/AAM_CONDITIONAL(HAVE_SYSTEMD, test "$systemdsystemunitdir" != "")
661N/AAS_HELP_STRING([--with-gc], [Use Boehm garbage collector]),
661N/A TEST_WITH(gc, $withval),
661N/AAS_HELP_STRING([--with-storages], [Build with specified mail storage formats (mdbox sdbox maildir mbox cydir imapc pop3c)]), [
661N/A if test "$withval" = "yes" || test "$withval" = "no"; then
661N/A AC_MSG_ERROR([--with-storages needs storage list as parameter])
661N/A mail_storages="shared `echo "$withval"|sed 's/,/ /g'`" ],
661N/A mail_storages="shared mdbox sdbox maildir mbox cydir imapc pop3c")
661N/Amail_storages="$mail_storages raw fail"
0N/Aduplicates=`(for i in $mail_storages; do echo $i; done)|sort|uniq -d|xargs echo`
661N/Aif test "$duplicates" != ""; then
661N/A AC_ERROR([Duplicate --with-storages: $duplicates])
0N/AAS_HELP_STRING([--with-docs], [Install documentation (default)]),
661N/A if test x$withval = xno; then
661N/AAM_CONDITIONAL(BUILD_DOCS, test "$want_docs" = "yes")
0N/Adnl always enable all of the passbs and userdbs that don't require extra libs
661N/Awant_prefetch_userdb=yes
661N/AAC_PROG_CXX # lucene plugin needs this
661N/AAC_DEFINE_UNQUOTED(DOVECOT_NAME, "$PACKAGE_NAME", Dovecot name)
661N/AAC_DEFINE_UNQUOTED(DOVECOT_STRING, "$PACKAGE_STRING", Dovecot string)
661N/AAC_DEFINE_UNQUOTED(DOVECOT_VERSION, "$PACKAGE_VERSION", Dovecot version)
661N/Adnl * gcc specific options
661N/Aif test "x$ac_cv_c_compiler_gnu" = "xyes"; then
661N/A # -Wcast-qual -Wcast-align -Wconversion -Wunreachable-code # too many warnings
661N/A # -Wstrict-prototypes -Wredundant-decls # may give warnings in some systems
0N/A # -Wmissing-format-attribute -Wmissing-noreturn -Wwrite-strings # a couple of warnings
661N/A CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast"
661N/A if test "$have_clang" = "yes"; then
661N/A #if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 3)
0N/A # clang 3.3+ unfortunately this gives warnings with
hash.h 661N/A CFLAGS="$CFLAGS -Wno-duplicate-decl-specifier"
661N/A # This is simply to avoid warning when building strftime() wrappers..
661N/A CFLAGS="$CFLAGS -fno-builtin-strftime"
0N/A CFLAGS="$CFLAGS -Wstrict-aliasing=2"
661N/A # Use std=gnu99 if we have new enough gcc
661N/A CFLAGS="$CFLAGS $old_cflags"
661N/Aif test "$have_clang" = "yes"; then
661N/A # clang specific options
0N/A if test "$want_devel_checks" = "yes"; then
661N/A # FIXME: enable once md[45], sha[12] can be compiled without
661N/A #CFLAGS="$CFLAGS -fsanitize=integer,undefined -ftrapv"
0N/Adnl ** just some generic stuff...
661N/AAC_SEARCH_LIBS(socket, socket)
661N/AAC_SEARCH_LIBS(inet_addr, nsl)
661N/AAC_SEARCH_LIBS(fdatasync, rt, [
661N/A AC_DEFINE(HAVE_FDATASYNC,, Define if you have fdatasync())
0N/Aif test $want_libcap != no; then
661N/A AC_CHECK_LIB(cap, cap_init, [
661N/A AC_DEFINE(HAVE_LIBCAP,, libcap is installed for cap_init())
0N/A if test "$want_libcap" = "yes"; then
AC_ERROR([Can't build with libcap support: libcap not found])
if test $want_libwrap != no; then
AC_CACHE_CHECK([whether we have libwrap],i_cv_have_libwrap,[
if test $i_cv_have_libwrap = yes; then
AC_DEFINE(HAVE_LIBWRAP,, Define if you have libwrap)
if test "$want_libwrap" = "yes"; then
AC_ERROR([Can't build with libwrap support: libwrap not found])
if test "$want_libwrap" = "yes"; then
AC_ERROR([Can't build with libwrap support:
tcpd.h not found])
AM_CONDITIONAL(TCPWRAPPERS, test "$have_libwrap" = "yes")
dnl * after -lsocket and -lnsl tests, inet_aton() may be in them
AC_CHECK_FUNCS(fcntl flock lockf inet_aton sigaction getpagesize madvise \
strcasecmp stricmp vsyslog writev pread uname unsetenv \
setrlimit setproctitle seteuid setreuid setegid setresgid \
strtoull strtoll strtouq strtoq getmntinfo \
setpriority quotactl getmntent kqueue kevent backtrace_symbols \
walkcontext dirfd clearenv malloc_usable_size glob fallocate \
posix_fadvise getpeereid getpeerucred)
AC_CHECK_TYPES([struct sockpeercred])
AC_SEARCH_LIBS(clock_gettime, rt, [
AC_DEFINE(HAVE_CLOCK_GETTIME,, Define if you have the clock_gettime function)
AC_CACHE_CHECK([for typeof],i_cv_have_typeof,[
if test $i_cv_have_typeof = yes; then
AC_DEFINE(HAVE_TYPEOF,, Define if you have typeof())
dnl strtoimax and strtoumax are macros in HP-UX, so
inttypes.h must be included
dnl Link instead of just compiling since there's something wrong with Tru64
AC_CACHE_CHECK([for strtoimax],i_cv_have_strtoimax,[
if test $i_cv_have_strtoimax = yes; then
AC_DEFINE(HAVE_STRTOIMAX,, Define if you have strtoimax function)
AC_CACHE_CHECK([for strtoumax],i_cv_have_strtoumax,[
if test $i_cv_have_strtoumax = yes; then
AC_DEFINE(HAVE_STRTOUMAX,, Define if you have strtoumax function)
if test "$ioloop" = "best" || test "$ioloop" = "epoll"; then
AC_CACHE_CHECK([whether we can use epoll],i_cv_epoll_works,[
return epoll_create(5) < 1;
if test $i_cv_epoll_works = yes; then
AC_DEFINE(IOLOOP_EPOLL,, Implement I/O loop with Linux 2.6 epoll())
if test "$ioloop" = "epoll" ; then
AC_MSG_ERROR([epoll ioloop requested but epoll_create() is not available])
if test "$ioloop" = "best" || test "$ioloop" = "kqueue"; then
if test "$ac_cv_func_kqueue" = yes && test "$ac_cv_func_kevent" = yes; then
AC_DEFINE(IOLOOP_KQUEUE,, [Implement I/O loop with BSD kqueue()])
elif test "$ioloop" = "kqueue"; then
AC_MSG_ERROR([kqueue ioloop requested but kqueue() is not available])
if test "$ioloop" = "best" || test "$ioloop" = "poll"; then
AC_DEFINE(IOLOOP_POLL,, Implement I/O loop with poll())
if test "$have_ioloop" = "no"; then
AC_DEFINE(IOLOOP_SELECT,, Implement I/O loop with select())
if test "$notify" = "" || test "$notify" = "inotify" ; then
AC_CACHE_CHECK([whether we can use inotify],i_cv_inotify_works,[
wd = inotify_add_watch (fd, fn, IN_ALL_EVENTS);
perror ("inotify_add_watch");
inotify_rm_watch (fd, wd);
if test $i_cv_inotify_works = yes; then
AC_DEFINE(IOLOOP_NOTIFY_INOTIFY,, Use Linux inotify)
if test "$notify" = "inotify"; then
AC_MSG_ERROR([inotify requested but not available])
if (test "$notify" = "" && test "$ioloop" = kqueue) || test "$notify" = "kqueue"; then
dnl * BSD kqueue() notify
AC_MSG_CHECKING([whether we can use BSD kqueue() notify])
if test "$ac_cv_func_kqueue" = yes && test "$ac_cv_func_kevent" = yes ; then
AC_DEFINE(IOLOOP_NOTIFY_KQUEUE,,
Use BSD kqueue directory changes notificaton)
if test "$notify" = "kqueue" ; then
AC_MSG_ERROR([kqueue notify requested but kqueue() is not available])
if test "$notify" = "" || test "$notify" = "dnotify"; then
AC_CACHE_CHECK([whether we can use dnotify],i_cv_have_dnotify,[
fcntl(0, F_SETSIG, SIGRTMIN);
fcntl(0, F_NOTIFY, DN_CREATE | DN_DELETE | DN_RENAME | DN_MULTISHOT);
if test $i_cv_have_dnotify = yes; then
AC_DEFINE(IOLOOP_NOTIFY_DNOTIFY,, Use Linux dnotify)
if test "$notify" = "dnotify"; then
AC_MSG_ERROR([dnotify requested but not available])
if test "$have_notify" = "none"; then
AC_DEFINE(IOLOOP_NOTIFY_NONE,, No special notify support)
AC_CACHE_CHECK([whether we have glibc],i_cv_have_glibc,[
if test "$i_cv_have_glibc" = "yes"; then
AC_DEFINE(PREAD_WRAPPERS,, Define if
pread/pwrite needs _XOPEN_SOURCE 500)
dnl * Old glibcs have broken posix_fallocate(). Make sure not to use it.
dnl * It may also be broken in AIX.
AC_CACHE_CHECK([whether posix_fallocate() works],i_cv_posix_fallocate_works,[
#define _XOPEN_SOURCE 600
#if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 7)
possibly broken posix_fallocate
ret = posix_fallocate(fd, 1024, 1024) < 0 ? 1 : 0;
i_cv_posix_fallocate_works=yes
i_cv_posix_fallocate_works=no
if test $i_cv_posix_fallocate_works = yes; then
AC_DEFINE(HAVE_POSIX_FALLOCATE,, Define if you have a working posix_fallocate())
dnl * OS specific options
CFLAGS="$CFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED"
LDFLAGS="$LDFLAGS -Wl,+b,:"
AC_DEFINE(PREAD_BROKEN,, Defint if
pread/pwrite implementation is broken)
AC_DEFINE(PROCTITLE_HACK,, Define if process title can be changed by modifying argv)
AC_CHECK_SIZEOF(long long)
dnl * first check if we can get the size with redefining typedefs
order="int long long-long"
AC_MSG_CHECKING([type of $1])
AC_CACHE_VAL(i_cv_typeof_$1,[
if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
dnl * try with printf() + -Werror
if test "$fmt" != ""; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
if test "$result" != ""; then
dnl * warning check isn't working
result="`echo $type|sed 's/-/ /g'`"
if test "$result" = ""; then
type="`echo $type|sed 's/-/ /g'`"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
if test "$result" != ""; then
dnl * compiler allows redefining to anything
if test "$result" = ""; then
dnl * older autoconfs don't include
sys/types.h, so do it manually
AC_RUN_IFELSE([AC_LANG_SOURCE([[
FILE *f=fopen("conftestval", "w");
fprintf(f, "%d\n", sizeof($1));
actype="ac_cv_sizeof_`echo $type|sed 's/-/_/g'`"
if test "$size" = "`eval echo \\$$actype`"; then
result="`echo $type|sed 's/-/ /g'`"
visible="`expr $size \* 8`bit (using $result)"
if test "$result" = ""; then
visible="`expr $size \* 8`bit (unknown type)"
i_cv_typeof_$1=$result/$visible
typeof_$1=`echo $i_cv_typeof_$1 | sed s,/.*$,,`
visible=`echo $i_cv_typeof_$1 | sed s,^.*/,,`
AC_DEFINE(HAVE_UOFF_T,, Define if you have a native uoff_t type)
AC_TYPEOF(off_t, long int long-long)
if test "$have_uoff_t" != "yes"; then
AC_DEFINE(UOFF_T_INT,, Define if off_t is int)
offt_bits=`expr 8 \* $ac_cv_sizeof_int`
if test "$have_uoff_t" != "yes"; then
AC_DEFINE(UOFF_T_LONG,, Define if off_t is long)
offt_bits=`expr 8 \* $ac_cv_sizeof_long`
if test "$have_uoff_t" != "yes"; then
AC_DEFINE(UOFF_T_LONG_LONG,, Define if off_t is long long)
offt_bits=`expr 8 \* $ac_cv_sizeof_long_long`
AC_MSG_ERROR([Unsupported off_t type])
dnl * Do we have struct dirent->d_type
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
AC_DEFINE(HAVE_DIRENT_D_TYPE,, Define if you have struct dirent->d_type)
dnl * Do we have OFF_T_MAX?
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
AC_DEFINE_UNQUOTED(OFF_T_MAX, $offt_max, Maximum value of off_t)
AC_DEFINE_UNQUOTED(PRIuUOFF_T, "$uofft_fmt", printf() format for uoff_t)
dnl * make sure size_t isn't signed. we'd probably work fine with it, but
dnl * it's more likely vulnerable to buffer overflows. Anyway, C99 specifies
dnl * that it's unsigned and only some old systems define it as signed.
AC_CACHE_CHECK([whether size_t is signed],i_cv_signed_size_t,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
/* return 0 if we're signed */
exit((size_t)(int)-1 <= 0 ? 0 : 1);
echo "Your system's size_t is a signed integer, Dovecot isn't designed to"
echo "support it. It probably works just fine, but it's less resistant to"
echo "buffer overflows. If you're not worried about this and still want to"
echo "compile Dovecot, set ignore_signed_size=1 environment."
if test "$ignore_signed_size" = ""; then
dnl Note: we check size_t rather than ssize_t here, because on OSX 10.2
dnl ssize_t = int and size_t = unsigned long. We're mostly concerned about
dnl printf format here, so check the size_t one.
AC_TYPEOF(size_t, unsigned-int unsigned-long unsigned-long-long)
dnl older systems didn't have ssize_t, default to int
if test "$typeof_size_t" = ""; then
AC_DEFINE(size_t, unsigned int, Define to 'unsigned int' if you don't have it)
AC_DEFINE(ssize_t, int, Define to 'int' if you don't have it)
AC_DEFINE_UNQUOTED(SSIZE_T_MAX, $ssizet_max, Maximum value of ssize_t)
AC_DEFINE_UNQUOTED(PRIuSIZE_T, "$sizet_fmt", printf() format for size_t)
AC_DEFUN([AC_CHECKTYPE2], [
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(i_cv_type_$1,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
$2]], [[$1 t;]])],[i_cv_type_$1=yes],[i_cv_type_$1=no])])
AC_MSG_RESULT($i_cv_type_$1)
dnl some systems don't have
stdint.h, but still have some of the types
AC_CHECKTYPE2(uintmax_t, [$stdint_include])
if test $i_cv_type_uintmax_t = yes; then
AC_DEFINE(HAVE_UINTMAX_T,, Define if you have uintmax_t (C99 type))
dnl use separate check, eg. Solaris 8 has uintmax_t but not uint_fast32_t
AC_CHECKTYPE2(uint_fast32_t, [$stdint_include])
if test $i_cv_type_uint_fast32_t = yes; then
AC_DEFINE(HAVE_UINT_FAST32_T,, Define if you have uint_fast32_t (C99 type))
if test $i_cv_type_socklen_t = yes; then
AC_DEFINE(HAVE_SOCKLEN_T,, Define to 'int' if you don't have socklen_t)
AC_DEFINE_UNQUOTED(MEM_ALIGN_SIZE, $mem_align, Required memory alignment)
if test "$have_random_source" != "yes"; then
dnl * do we have tm_gmtoff
AC_MSG_CHECKING([for tm_gmtoff])
AC_CACHE_VAL(i_cv_field_tm_gmtoff,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
[[struct tm *tm; return tm->tm_gmtoff;]])],
[i_cv_field_tm_gmtoff=yes],
[i_cv_field_tm_gmtoff=no])])
if test $i_cv_field_tm_gmtoff = yes; then
AC_DEFINE(HAVE_TM_GMTOFF,, Define if you have struct tm->tm_gmtoff)
AC_MSG_RESULT($i_cv_field_tm_gmtoff)
dnl * how large time_t values does gmtime() accept?
AC_CACHE_CHECK([how large time_t values gmtime() accepts],i_cv_gmtime_max_time_t,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
for (bits = 1; bits < sizeof(time_t)*8; bits++) {
time_t t = ((time_t)1 << bits) - 1;
if (gmtime(&t) == NULL) {
/* Solaris 9 breaks after 55 bits. Perhaps other systems break earlier.
Let's just do the same as Cyrus folks and limit it to 40 bits. */
printf "check failed, assuming "
i_cv_gmtime_max_time_t=31
AC_DEFINE_UNQUOTED(TIME_T_MAX_BITS, $i_cv_gmtime_max_time_t, max. time_t bits gmtime() can handle)
AC_CACHE_CHECK([whether time_t is signed],i_cv_signed_time_t,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
/* return 0 if we're signed */
exit((time_t)(int)-1 <= 0 ? 0 : 1);
if test $i_cv_signed_time_t = yes; then
AC_DEFINE(TIME_T_SIGNED,, Define if your time_t is signed)
dnl Our implementation of AC_C_FLEXIBLE_ARRAY_MEMBER.
dnl Use it until autoconf 2.61+ becomes more widely used
AC_CACHE_CHECK([if we can use C99-like flexible array members],i_cv_c99_flex_arrays,[
if test $i_cv_c99_flex_arrays = yes; then
AC_DEFINE_UNQUOTED(FLEXIBLE_ARRAY_MEMBER, $flexible_value, How to define flexible array members in structs)
dnl * do we have struct iovec
AC_MSG_CHECKING([for struct iovec])
AC_CACHE_VAL(i_cv_struct_iovec,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
[[struct iovec *iovec;]])],
[i_cv_struct_iovec=no])])
if test $i_cv_struct_iovec = yes; then
AC_DEFINE(HAVE_STRUCT_IOVEC,, Define if you have struct iovec)
AC_MSG_RESULT($i_cv_struct_iovec)
dnl * is dev_t an integer or something else?
AC_CACHE_CHECK([whether dev_t is struct],i_cv_dev_t_struct,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
struct test { dev_t a; };
static struct test t = { 0 };
if test $i_cv_dev_t_struct = yes; then
AC_DEFINE(DEV_T_STRUCT,, Define if your dev_t is a structure instead of integer type)
dnl * Do we have RLIMIT_AS?
AC_CACHE_CHECK([whether RLIMIT_AS exists],i_cv_have_rlimit_as,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
getrlimit(RLIMIT_AS, &r);
if test $i_cv_have_rlimit_as = yes; then
AC_DEFINE(HAVE_RLIMIT_AS,, Define if you have RLIMIT_AS for setrlimit())
dnl * Do we have RLIMIT_NPROC?
AC_CACHE_CHECK([whether RLIMIT_NPROC exists],i_cv_have_rlimit_nproc,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
getrlimit(RLIMIT_NPROC, &r);
i_cv_have_rlimit_nproc=yes
i_cv_have_rlimit_nproc=no
if test $i_cv_have_rlimit_nproc = yes; then
AC_DEFINE(HAVE_RLIMIT_NPROC,, Define if you have RLIMIT_NPROC for setrlimit())
dnl * Do we have RLIMIT_CORE?
AC_CACHE_CHECK([whether RLIMIT_CORE exists],i_cv_have_rlimit_core,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
getrlimit(RLIMIT_CORE, &r);
i_cv_have_rlimit_core=yes
if test $i_cv_have_rlimit_core = yes; then
AC_DEFINE(HAVE_RLIMIT_CORE,, Define if you have RLIMIT_CORE for getrlimit())
AC_CACHE_CHECK([whether PR_SET_DUMPABLE exists],i_cv_have_pr_set_dumpable,[
prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
i_cv_have_pr_set_dumpable=yes
i_cv_have_pr_set_dumpable=no
if test $i_cv_have_pr_set_dumpable = yes; then
AC_DEFINE(HAVE_PR_SET_DUMPABLE,, Define if you have prctl(PR_SET_DUMPABLE))
dnl * Linux compatible mremap()
AC_CACHE_CHECK([Linux compatible mremap()],i_cv_have_linux_mremap,[
mremap(0, 0, 0, MREMAP_MAYMOVE);
i_cv_have_linux_mremap=yes
i_cv_have_linux_mremap=no
if test $i_cv_have_linux_mremap = yes; then
AC_DEFINE(HAVE_LINUX_MREMAP,, Define if you have Linux-compatible mremap())
dnl * If mmap() plays nicely with write()
AC_CACHE_CHECK([whether shared mmaps get updated by write()s],i_cv_mmap_plays_with_write,[
/* return 0 if we're signed */
mem = mmap(NULL, 2, PROT_READ|PROT_WRITE, MAP_SHARED, f, 0);
return strcmp(mem, "3") == 0 ? 0 : 1;
i_cv_mmap_plays_with_write=yes
i_cv_mmap_plays_with_write=no
if test $i_cv_mmap_plays_with_write = no; then
AC_DEFINE(MMAP_CONFLICTS_WRITE,, [Define if shared mmaps don't get updated by write()s])
dnl * see if fd passing works
AC_CACHE_CHECK([whether fd passing works],i_cv_fd_passing,[
CFLAGS="$CFLAGS -DBUGGY_CMSG_MACROS"
for (i = n = 0; i < 256; i++)
if (fstat(i, &sb) == 0) n++;
int fd[2], send_fd, recv_fd, status, n1, n2;
if (send_fd == -1) return 2;
if (fstat(send_fd, &st) < 0) return 2;
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) return 2;
if (fd_send(fd[0], send_fd, &data, 1) != 1) return 2;
if (fd_read(fd[1], &data, 1, &recv_fd) != 1) return 1;
if (fstat(recv_fd, &st2) < 0) return 2;
/* nopen check is for making sure that only a single fd
i_cv_fd_passing=buggy_cmsg_macros
dnl no, try with BUGGY_CMSG_MACROS
if test "$i_cv_fd_passing" = "yes"; then
i_cv_fd_passing=buggy_cmsg_macros
if test $i_cv_fd_passing = buggy_cmsg_macros; then
AC_DEFINE(BUGGY_CMSG_MACROS,, Define if you have buggy CMSG macros)
if test $i_cv_fd_passing = no; then
AC_ERROR([fd passing is required for Dovecot to work])
dnl * Solaris compatible sendfile()
AC_CHECK_LIB(sendfile, sendfile, [
AC_DEFINE(HAVE_SOLARIS_SENDFILE,, Define if you have Solaris-compatible sendfile())
dnl * Linux compatible sendfile() - don't check if Solaris one was found.
dnl * This seems to pass with Solaris for some reason..
AC_CACHE_CHECK([Linux compatible sendfile()],i_cv_have_linux_sendfile,[
sendfile(0, 0, (void *) 0, 0);
i_cv_have_linux_sendfile=yes
i_cv_have_linux_sendfile=no
if test $i_cv_have_linux_sendfile = yes; then
AC_DEFINE(HAVE_LINUX_SENDFILE,, Define if you have Linux-compatible sendfile())
dnl * FreeBSD compatible sendfile()
AC_CACHE_CHECK([FreeBSD compatible sendfile()],i_cv_have_freebsd_sendfile,[
sendfile(0, 0, 0, 0, &hdtr, (void *) 0, 0);
i_cv_have_freebsd_sendfile=yes
i_cv_have_freebsd_sendfile=no
if test $i_cv_have_freebsd_sendfile = yes; then
AC_DEFINE(HAVE_FREEBSD_SENDFILE,, Define if you have FreeBSD-compatible sendfile())
AC_CACHE_CHECK([if unsetenv returns int],i_cv_unsetenv_ret_int,[
if (unsetenv("env") < 0) ;
i_cv_unsetenv_ret_int=yes
if test $i_cv_unsetenv_ret_int = yes; then
AC_DEFINE(UNSETENV_RET_INT,, Define if unsetenv() returns int)
dnl * Check for crypt() if
unistd.h compiles with _XOPEN_SOURCE + _XPG6
dnl * Add other macros there too "just in case".
AC_CACHE_CHECK([if we should use _XPG6 macro for crypt()],i_cv_use_xpg6_crypt,[
#define _XOPEN_SOURCE_EXTENDED 1
if test $i_cv_use_xpg6_crypt = yes; then
AC_DEFINE(CRYPT_USE_XPG6,, Define if _XPG6 macro is needed for crypt())
AC_CACHE_CHECK([if struct stat has st_?tim timespec fields],i_cv_have_st_tim_timespec,[
i_cv_have_st_tim_timespec=yes
i_cv_have_st_tim_timespec=no
if test $i_cv_have_st_tim_timespec = yes; then
AC_DEFINE(HAVE_STAT_XTIM,, Define if you have st_?tim timespec fields in struct stat)
AC_CACHE_CHECK([if struct stat has st_?timespec fields],i_cv_have_st_timespec,[
i_cv_have_st_timespec=yes
if test $i_cv_have_st_timespec = yes; then
AC_DEFINE(HAVE_STAT_XTIMESPEC,, Define if you have st_?timespec fields in struct stat)
dnl * Check if statvfs() can be used to find out block device for files
i_cv_have_statvfs_f_mntfromname=yes
i_cv_have_statvfs_f_mntfromname=no
if test $i_cv_have_statvfs_f_mntfromname = yes; then
dnl * Check if statfs() can be used to find out block device for files
i_cv_have_statfs_f_mntfromname=yes
i_cv_have_statfs_f_mntfromname=no
if test $i_cv_have_statfs_f_mntfromname = yes; then
i_cv_have_dqblk_dqb_curblocks=yes
i_cv_have_dqblk_dqb_curblocks=no
if test $i_cv_have_dqblk_dqb_curblocks = yes; then
i_cv_have_dqblk_dqb_curspace=yes
i_cv_have_dqblk_dqb_curspace=no
if test $i_cv_have_dqblk_dqb_curspace = yes; then
dnl * Check if we have Q_QUOTACTL ioctl (Solaris)
AC_CACHE_CHECK([if Q_QUOTACTL ioctl exists],i_cv_have_ioctl_q_quotactl,[
ioctl(0, Q_QUOTACTL, &ctl);
i_cv_have_ioctl_q_quotactl=yes
i_cv_have_ioctl_q_quotactl=no
if test $i_cv_have_ioctl_q_quotactl = yes; then
AC_DEFINE(HAVE_Q_QUOTACTL,, Define if Q_QUOTACTL exists)
AC_CACHE_CHECK([for C99 vsnprintf()],i_cv_c99_vsnprintf,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
static int f(const char *fmt, ...) {
ret = vsnprintf(buf, 11, fmt, args) != 12 || buf[11-1] != '\0';
return f("hello %s%d", "world", 1);
[i_cv_c99_vsnprintf=yes],
if test $i_cv_c99_vsnprintf = no; then
AC_DEFINE(HAVE_OLD_VSNPRINTF,, Define if you don't have C99 compatible vsnprintf() call)
dnl *** va_copy checks (from GLIB)
AC_CACHE_CHECK([for an implementation of va_copy()],lib_cv_va_copy,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
va_end (args1); va_end (args2);
AC_CACHE_CHECK([for an implementation of __va_copy()],lib_cv___va_copy,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
__va_copy (args2, args1);
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
va_end (args1); va_end (args2);
[lib_cv___va_copy=no],[])
if test "x$lib_cv_va_copy" = "xyes"; then
else if test "x$lib_cv___va_copy" = "xyes"; then
if test -n "$va_copy_func"; then
AC_DEFINE_UNQUOTED(VA_COPY,$va_copy_func,[A 'va_copy' style function])
AC_CACHE_CHECK([whether va_lists can be copied by value],lib_cv_va_val_copy,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
va_end (args1); va_end (args2);
[lib_cv_va_val_copy=yes],
[lib_cv_va_val_copy=no],[])
if test "x$lib_cv_va_val_copy" = "xno"; then
AC_DEFINE(VA_COPY_AS_ARRAY,1, ['va_lists' cannot be copies as values])
MODULE_LIBS="-export-dynamic"
AC_CHECK_LIB(dl, dlopen, [
MODULE_LIBS="-export-dynamic -ldl"
if test $ac_cv_header_sys_vmount_h = yes; then
AC_MSG_CHECKING([for reasonable mntctl buffer size])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
FILE *f=fopen("conftestval", "w");
if ((count=mntctl(MCTL_QUERY,sizeof(size),&size))!=0 || !(m=malloc(size)) ||
(count=mntctl(MCTL_QUERY,size,m))<=0) exit(1);
fprintf(f, "%d\n",(size * (count + 5))/count & ~1); /* 5 mounts more */
AC_DEFINE_UNQUOTED(STATIC_MTAB_SIZE,$size, reasonable mntctl buffer size)
if test $want_openssl != no && test $have_ssl = no; then
if test "$PKG_CONFIG" != "" && $PKG_CONFIG --exists openssl 2>
/dev/null; then
PKG_CHECK_MODULES(SSL, openssl)
CFLAGS="$CFLAGS $SSL_CFLAGS"
# openssl 0.9.8 wants -ldl and it's required if there's only .a lib
AC_CHECK_LIB(ssl, SSL_read, [
SSL_LIBS="-lssl -lcrypto $DLLIB"
if test $want_openssl = yes; then
if test $want_openssl = yes; then
AC_ERROR([Can't build with OpenSSL: libssl not found])
if test "$have_openssl" = "yes"; then
AC_DEFINE(HAVE_OPENSSL,, Build with OpenSSL support)
AC_CHECK_LIB(ssl, SSL_get_current_compression, [
AC_DEFINE(HAVE_SSL_COMPRESSION,, Build with OpenSSL compression)
AC_CHECK_LIB(ssl, SSL_get_servername, [
AC_DEFINE(HAVE_SSL_GET_SERVERNAME,, Build with TLS hostname support)
AM_CONDITIONAL(BUILD_OPENSSL, test "$have_openssl" = "yes")
if test $want_gnutls != no && test $have_ssl = no; then
AC_CHECK_LIB(gnutls, gnutls_global_init, [
AC_DEFINE(HAVE_GNUTLS,, Build with GNUTLS support)
SSL_LIBS="-lgnutls -lgcrypt"
if test $want_gnutls = yes; then
if test $want_gnutls = yes; then
AC_ERROR([Can't build with GNUTLS: libgnutls not found])
if test "$have_ssl" != "no"; then
AC_DEFINE(HAVE_SSL,, Build with
SSL/TLS support)
if test $want_gc != no; then
AC_CHECK_LIB(gc, GC_malloc, [
AC_DEFINE(USE_GC,, Define if you want to use Boehm GC)
if test $want_gc = yes; then
AC_ERROR([Can't build with GC: libgc not found])
dnl ** userdb and passdb checks
if test $want_prefetch_userdb != no; then
AC_DEFINE(USERDB_PREFETCH,, Build with prefetch userdb support)
userdb="$userdb prefetch"
not_userdb="$not_userdb prefetch"
if test $want_passwd != no; then
AC_DEFINE(USERDB_PASSWD,, Build with passwd support)
AC_DEFINE(PASSDB_PASSWD,, Build with passwd support)
not_passdb="$not_passdb passwd"
not_userdb="$not_userdb passwd"
if test $want_passwd_file != no; then
AC_DEFINE(USERDB_PASSWD_FILE,, Build with passwd-file support)
AC_DEFINE(PASSDB_PASSWD_FILE,, Build with passwd-file support)
userdb="$userdb passwd-file"
passdb="$passdb passwd-file"
not_passdb="$not_passdb passwd-file"
not_userdb="$not_userdb passwd-file"
if test $want_shadow != no; then
AC_CHECK_FUNC(getspnam, [
AC_DEFINE(PASSDB_SHADOW,, Build with shadow support)
if test $want_shadow = yes; then
AC_ERROR([Can't build with shadow support:
shadow.h not found])
if test $want_shadow = yes; then
AC_ERROR([Can't build with shadow support: getspnam() not found])
if test $have_shadow = no; then
not_passdb="$not_passdb shadow"
if test $want_pam != no; then
AC_CHECK_LIB(pam, pam_start, [
AC_DEFINE(HAVE_SECURITY_PAM_APPL_H,,
AC_DEFINE(HAVE_PAM_PAM_APPL_H,,
if test $want_pam = yes; then
AC_ERROR([Can't build with PAM support: libpam not found])
if test "$have_pam" = "yes"; then
AUTH_LIBS="$AUTH_LIBS -lpam"
AC_DEFINE(PASSDB_PAM,, Build with PAM support)
AC_CHECK_LIB(pam, pam_setcred, [
AC_DEFINE(HAVE_PAM_SETCRED,, Define if you have pam_setcred())
elif test $want_pam = yes; then
AC_ERROR([Can't build with PAM support:
pam_appl.h not found])
not_passdb="$not_passdb pam"
if test $want_checkpassword != no; then
AC_DEFINE(PASSDB_CHECKPASSWORD,, Build with checkpassword passdb support)
AC_DEFINE(USERDB_CHECKPASSWORD,, Build with checkpassword userdb support)
passdb="$passdb checkpassword"
userdb="$userdb checkpassword"
not_passdb="$not_passdb checkpassword"
not_userdb="$not_userdb checkpassword"
if test $want_bsdauth != no; then
AC_CHECK_FUNC(auth_userokay, [
AC_DEFINE(PASSDB_BSDAUTH,, Build with BSD authentication support)
if test $want_bsdauth = yes; then
AC_ERROR([Can't build with BSD authentication support: auth_userokay() not found])
if test $have_bsdauth = no; then
not_passdb="$not_passdb bsdauth"
if test $want_gssapi != no; then
AC_CHECK_PROG(KRB5CONFIG, krb5-config, krb5-config, NO)
if test $KRB5CONFIG != NO; then
# krb5-config doesn't support gssapi.
KRB5_LIBS="`$KRB5CONFIG --libs`"
KRB5_CFLAGS=`$KRB5CONFIG --cflags`
AC_CHECK_LIB(gss, gss_acquire_cred, [
KRB5_LIBS="$KRB5_LIBS -lgss"
KRB5_LIBS=`$KRB5CONFIG --libs gssapi`
KRB5_CFLAGS=`$KRB5CONFIG --cflags gssapi`
if test "$KRB5_LIBS" != ""; then
# Although krb5-config exists, all systems still don't
CFLAGS="$CFLAGS $KRB5_CFLAGS"
AC_DEFINE(HAVE_GSSAPI_H,, GSSAPI headers in
gssapi.h)
if test $have_gssapi != no; then
if test $want_gssapi = plugin; then
AC_DEFINE(HAVE_GSSAPI,, Build with GSSAPI support)
AC_CHECK_LIB(gss, __gss_userok, [
AC_DEFINE(HAVE___GSS_USEROK,,
Define if you have __gss_userok())
KRB5_LIBS="$KRB5_LIBS -lgss"
# MIT has a #define for Heimdal acceptor_identity, but it's way too
# difficult to test for it..
AC_CHECK_FUNCS(gsskrb5_register_acceptor_identity krb5_gss_register_acceptor_identity)
# does the kerberos library support SPNEGO?
AC_CACHE_CHECK([whether GSSAPI supports SPNEGO],i_cv_gssapi_spnego,[
unsigned char spnego_oid[] = { 0x2b, 0x06, 0x01, 0x05, 0x05, 0x02 };
gss_indicate_mechs(&minor_status, &mech_set);
for (i = 0; i < mech_set->count; i++) {
if (mech_set->elements[i].length == 6 &&
memcmp(mech_set->elements[i].elements,
if test "$i_cv_gssapi_spnego" = "yes"; then
AC_DEFINE(HAVE_GSSAPI_SPNEGO,, GSSAPI supports SPNEGO)
if test $want_gssapi != plugin; then
AUTH_LIBS="$AUTH_LIBS $KRB5_LIBS"
AUTH_CFLAGS="$AUTH_CFLAGS $KRB5_CFLAGS"
AC_DEFINE(BUILTIN_GSSAPI,, GSSAPI support is built in)
if test $want_gssapi != auto; then
AC_ERROR([Can't build with GSSAPI support:
gssapi.h not found])
if test $want_gssapi != auto; then
AC_ERROR([Can't build with GSSAPI support: krb5-config not found])
AM_CONDITIONAL(GSSAPI_PLUGIN, test "$have_gssapi_plugin" = "yes")
if test $want_sia != no; then
AC_CHECK_FUNC(sia_validate_user, [
AC_DEFINE(PASSDB_SIA,, Build with Tru64 SIA support)
AUTH_LIBS="$AUTH_LIBS -depth_ring_search"
if test $want_sia = yes; then
AC_ERROR([Can't build with SIA support: sia_validate_user() not found])
if test $have_sia = no; then
not_passdb="$not_passdb sia"
if test $want_ldap != no; then
AC_CHECK_LIB(ldap, ldap_init, [
AC_CHECK_LIB(ldap, ldap_initialize, [
AC_DEFINE(LDAP_HAVE_INITIALIZE,, Define if you have ldap_initialize)
AC_CHECK_LIB(ldap, ldap_start_tls_s, [
AC_DEFINE(LDAP_HAVE_START_TLS_S,, Define if you have ldap_start_tls_s)
AC_CHECK_LIB(ldap, ber_free, [
# do nothing, default is to add -lldap to LIBS
AC_CHECK_LIB(lber, ber_free, [
LDAP_LIBS="$LDAP_LIBS -llber"
if test $want_ldap != plugin; then
AUTH_LIBS="$AUTH_LIBS $LDAP_LIBS"
AC_DEFINE(BUILTIN_LDAP,, LDAP support is built in)
AC_DEFINE(USERDB_LDAP,, Build with LDAP support)
AC_DEFINE(PASSDB_LDAP,, Build with LDAP support)
if test $want_ldap != auto; then
AC_ERROR([Can't build with LDAP support:
ldap.h not found])
if test $want_ldap != auto; then
AC_ERROR([Can't build with LDAP support: libldap not found])
if test $have_ldap = no; then
not_passdb="$not_passdb ldap"
not_userdb="$not_userdb ldap"
if test $want_ldap = plugin; then
userdb="$userdb (plugin)"
passdb="$passdb (plugin)"
AM_CONDITIONAL(LDAP_PLUGIN, test "$have_ldap_plugin" = "yes")
if test $want_db != no; then
AC_CACHE_CHECK([db_env_create in -ldb],i_cv_have_db_env_create,[
i_cv_have_db_env_create=yes
i_cv_have_db_env_create=no
if test $i_cv_have_db_env_create = yes; then
DICT_LIBS="$DICT_LIBS -ldb"
dict_drivers="$dict_drivers db"
AC_DEFINE(BUILD_DB,, Build with Berkeley DB support)
if test $want_db = yes; then
AC_ERROR([Can't build with db support:
db.h not found])
if test $want_db = yes; then
AC_ERROR([Can't build with db support: libdb not found])
if test $want_cdb != no; then
AC_CHECK_LIB(cdb, cdb_init, [
DICT_LIBS="$DICT_LIBS -lcdb"
AC_DEFINE(BUILD_CDB,, Build with CDB support)
if test $want_cdb = yes; then
AC_ERROR([Can't build with CDB support:
cdb.h not found])
if test $want_cdb = yes; then
AC_ERROR([Can't build with CDB support: libcdb not found])
if test $want_pgsql != no; then
AC_CHECK_PROG(PG_CONFIG, pg_config, pg_config, NO)
if test $PG_CONFIG = NO; then
PGSQL_INCLUDE="`$PG_CONFIG --includedir`"
PGSQL_LIBDIR="`$PG_CONFIG --libdir`"
if test "$PGSQL_LIBDIR" != ""; then
LIBS="$LIBS -L$PGSQL_LIBDIR"
AC_CHECK_LIB(pq, PQconnectdb, [
AC_CHECK_LIB(pq, PQescapeStringConn, [
AC_DEFINE(HAVE_PQESCAPE_STRING_CONN,, Define if libpq has PQescapeStringConn function)
if test "$PGSQL_INCLUDE" != ""; then
CPPFLAGS="$CPPFLAGS -I$PGSQL_INCLUDE"
if test "$PGSQL_INCLUDE" != ""; then
PGSQL_CFLAGS="$PGSQL_CFLAGS -I$PGSQL_INCLUDE"
if test "$PGSQL_LIBDIR" != ""; then
PGSQL_LIBS="$PGSQL_LIBS -L$PGSQL_LIBDIR"
PGSQL_LIBS="$PGSQL_LIBS -lpq"
AC_DEFINE(HAVE_PGSQL,, Build with PostgreSQL support)
found_sql_drivers="$found_sql_drivers pgsql"
if test $want_pgsql = yes; then
AC_ERROR([Can't build with PostgreSQL support:
libpq-fe.h not found])
if test $want_pgsql = yes; then
AC_ERROR([Can't build with PostgreSQL support: libpq not found])
if test $want_mysql != no; then
AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, mysql_config, NO)
if test $MYSQL_CONFIG = NO; then
MYSQL_LIBS="-lmysqlclient -lz -lm"
MYSQL_LIBS="-L$i/$j -lmysqlclient -lz -lm"
MYSQL_INCLUDE="`$MYSQL_CONFIG --include`"
MYSQL_LIBS="`$MYSQL_CONFIG --libs`"
if test "$MYSQL_LIBS" != ""; then
AC_CHECK_LIB(mysqlclient, mysql_init, [
if test "$MYSQL_INCLUDE" != ""; then
CPPFLAGS="$CPPFLAGS $MYSQL_INCLUDE"
if test "$MYSQL_INCLUDE" != ""; then
MYSQL_CFLAGS="$MYSQL_CFLAGS $MYSQL_INCLUDE"
AC_CHECK_LIB(mysqlclient, mysql_ssl_set, [
AC_DEFINE(HAVE_MYSQL_SSL,, Define if your MySQL library has SSL functions)
if test "x$have_openssl" = "yes"; then
ssl_define="#define HAVE_OPENSSL"
mysql_set_ssl(0, 0, 0, 0, 0, 0);
AC_DEFINE(HAVE_MYSQL_SSL_CIPHER,, Define if your MySQL library supports setting cipher)
AC_DEFINE(HAVE_MYSQL,, Build with MySQL support)
found_sql_drivers="$found_sql_drivers mysql"
if test $want_mysql = yes; then
AC_ERROR([Can't build with MySQL support:
mysql.h not found])
if test $want_mysql = yes; then
AC_ERROR([Can't build with MySQL support: libmysqlclient not found])
if test $have_mysql != yes; then
if test $want_sqlite != no; then
AC_CHECK_LIB(sqlite3, sqlite3_open, [
SQLITE_LIBS="$SQLITE_LIBS -lsqlite3 -lz"
AC_DEFINE(HAVE_SQLITE,, Build with SQLite3 support)
found_sql_drivers="$found_sql_drivers sqlite"
if test $want_sqlite = yes; then
AC_ERROR([Can't build with SQLite support:
sqlite3.h not found])
if test $want_sqlite = yes; then
AC_ERROR([Can't build with SQLite support: libsqlite3 not found])
SQL_CFLAGS="$MYSQL_CFLAGS $PGSQL_CFLAGS $SQLITE_CFLAGS"
if test "$want_sql" != "plugin"; then
SQL_LIBS="$MYSQL_LIBS $PGSQL_LIBS $SQLITE_LIBS"
AC_DEFINE(SQL_DRIVER_PLUGINS,, Build SQL drivers as plugins)
if test "$found_sql_drivers" != "" || test "$want_sql" != "no"; then
sql_drivers="$found_sql_drivers"
AC_DEFINE(PASSDB_SQL,, Build with SQL support)
AC_DEFINE(USERDB_SQL,, Build with SQL support)
AUTH_LIBS="$AUTH_LIBS $SQL_LIBS"
not_passdb="$not_passdb sql"
not_userdb="$not_userdb sql"
if test $want_vpopmail != no; then
vpop_etc="$vpopmail_home"
AC_DEFINE(USERDB_VPOPMAIL,, Build with vpopmail support)
AC_DEFINE(PASSDB_VPOPMAIL,, Build with vpopmail support)
if test $want_vpopmail = yes; then
if test $have_vpopmail = no; then
not_passdb="$not_passdb vpopmail"
not_userdb="$not_userdb vpopmail"
userdb="$userdb vpopmail"
passdb="$passdb vpopmail"
AC_CHECK_LIB(crypt, crypt, [
AUTH_LIBS="-lcrypt $AUTH_LIBS"
AC_MSG_ERROR([crypt() wasn't found])
if test $have_modules = yes; then
AC_DEFINE(HAVE_MODULES,, Define if you have dynamic module support)
module=yes eval MODULE_SUFFIX=$shrext_cmds
if test "$MODULE_SUFFIX" = ""; then
AC_DEFINE_UNQUOTED(MODULE_SUFFIX,"$MODULE_SUFFIX",Dynamic module suffix)
if test $want_nss != no; then
if test $have_modules != yes; then
if test $want_nss = yes; then
AC_ERROR([Can't build with NSS support: Dynamic modules not supported])
AC_CACHE_CHECK([for NSS support],i_cv_have_nss,[
enum nss_status status = NSS_STATUS_TRYAGAIN;
if test $i_cv_have_nss = yes; then
AC_DEFINE(USERDB_NSS,, Build with NSS module support)
if test $want_nss = yes; then
AC_ERROR([Can't build with NSS support:
nss.h not found or not usable])
if test $have_nss = no; then
not_userdb="$not_userdb nss"
dnl At least Apple's gcc supports __BIG_ENDIAN__ and __LITTLE_ENDIAN__
dnl defines. Use them if possible to allow cross-compiling.
AC_CACHE_CHECK([if __BIG_ENDIAN__ or __LITTLE_ENDIAN__ is defined],i_cv_have___big_endian__,[
#if !(__BIG_ENDIAN__ || __LITTLE_ENDIAN__)
i_cv_have___big_endian__=yes
i_cv_have___big_endian__=no
if test $i_cv_have___big_endian__ = yes; then
AC_DEFINE(WORDS_BIGENDIAN, __BIG_ENDIAN__, Define if your CPU is big endian)
AC_MSG_CHECKING([for IPv6])
AC_CACHE_VAL(i_cv_type_in6_addr,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
[[struct in6_addr i;]])],
[i_cv_type_in6_addr=yes],
[i_cv_type_in6_addr=no])])
if test $i_cv_type_in6_addr = yes; then
AC_DEFINE(HAVE_IPV6,, Build with IPv6 support)
AC_MSG_RESULT($i_cv_type_in6_addr)
mailbox_list_drivers="maildir imapdir fs index none shared"
for storage in $mail_storages; do
LINKED_STORAGE_LIBS="$LINKED_STORAGE_LIBS `eval echo \\$${storage}_libs`"
if test $storage = sdbox; then
if test $storage = sdbox || test $storage = mdbox; then
LINKED_STORAGE_LIBS="$LINKED_STORAGE_LIBS $dbox_common_libs"
if test $storage = imapc; then
mailbox_list_drivers="$mailbox_list_drivers imapc"
AC_SUBST(LINKED_STORAGE_LIBS)
AC_SUBST(LINKED_STORAGE_LDADD)
AC_SUBST(mailbox_list_drivers)
AC_DEFINE_UNQUOTED(MAIL_STORAGES, "$mail_storages", List of compiled in mail storages)
if test $have_sdbox = yes; then
mail_storages="$mail_storages dbox"
dnl ** Shared libraries usage
if test "$want_shared_libs" = "yes"; then
LIBDOVECOT="$LIBDOVECOT_DEPS \$(MODULE_LIBS)"
LIBDOVECOT="$LIBDOVECOT_DEPS \$(LIBICONV) \$(MODULE_LIBS)"
LIBDOVECOT_STORAGE_DEPS="$LIBDOVECOT_STORAGE_FIRST $LINKED_STORAGE_LIBS $LIBDOVECOT_STORAGE_LAST"
LIBDOVECOT_STORAGE="$LIBDOVECOT_STORAGE_DEPS $LINKED_STORAGE_LDADD"
AC_SUBST(LIBDOVECOT_DEPS)
AC_SUBST(LIBDOVECOT_STORAGE)
AC_SUBST(LIBDOVECOT_STORAGE_DEPS)
AC_SUBST(LIBDOVECOT_LOGIN)
AC_SUBST(LIBDOVECOT_COMPRESS)
for driver in $sql_drivers; do
if test "$driver" = "pgsql"; then
AC_DEFINE(BUILD_PGSQL,, Built-in PostgreSQL support)
elif test "$driver" = "mysql"; then
AC_DEFINE(BUILD_MYSQL,, Built-in MySQL support)
elif test "$driver" = "sqlite"; then
AC_DEFINE(BUILD_SQLITE,, Built-in SQLite support)
if test $build_pgsql = no; then
not_sql_drivers="$not_sql_drivers pgsql"
if test $build_mysql = no; then
not_sql_drivers="$not_sql_drivers mysql"
if test $build_sqlite = no; then
not_sql_drivers="$not_sql_drivers sqlite"
AM_CONDITIONAL(BUILD_PGSQL, test "$build_pgsql" = "yes")
AM_CONDITIONAL(BUILD_MYSQL, test "$build_mysql" = "yes")
AM_CONDITIONAL(BUILD_SQLITE, test "$build_sqlite" = "yes")
AM_CONDITIONAL(SQL_PLUGINS, test "$want_sql" = "plugin")
if test "$want_zlib" != "no"; then
AC_DEFINE(HAVE_ZLIB,, Define if you have zlib library)
COMPRESS_LIBS="$COMPRESS_LIBS -lz"
if test "$want_zlib" = "yes"; then
AC_ERROR([Can't build with zlib support:
zlib.h not found])
if test "$want_bzlib" != "no"; then
AC_CHECK_LIB(bz2, BZ2_bzdopen, [
AC_DEFINE(HAVE_BZLIB,, Define if you have bzlib library)
COMPRESS_LIBS="$COMPRESS_LIBS -lbz2"
if test "$want_bzlib" = "yes"; then
AC_ERROR([Can't build with bzlib support: libbz2 not found])
if test "$want_bzlib" = "yes"; then
AC_ERROR([Can't build with bzlib support:
bzlib.h not found])
AM_CONDITIONAL(BUILD_ZLIB_PLUGIN, test "$have_compress_lib" = "yes")
AC_DEFINE(HAVE_RQUOTA,, Define if you wish to retrieve quota of NFS mounted mailboxes)
AM_CONDITIONAL(HAVE_RQUOTA, test "$have_rquota" = "yes")
AC_SEARCH_LIBS(quota_open, quota, [
AC_DEFINE(HAVE_QUOTA_OPEN,, Define if you have quota_open())
if test "$want_solr" != "no"; then
AC_CHECK_LIB(expat, XML_Parse, [
if test $want_solr = yes; then
AC_ERROR([Can't build with Solr support:
expat.h not found])
if test $want_solr = yes; then
AC_ERROR([Can't build with Solr support: libexpat not found])
AM_CONDITIONAL(BUILD_SOLR, test "$have_solr" = "yes")
if test "$want_lucene" = "yes"; then
PKG_CHECK_MODULES(CLUCENE, libclucene-core,, [
# no pkg-config file for clucene. fallback to defaults.
# FIXME: we should verify here that this actually works..
CLUCENE_LIBS="-lclucene-shared -lclucene-core"
if test $want_stemmer != no; then
AC_CHECK_LIB(stemmer, sb_stemmer_new, [
AC_DEFINE(HAVE_LUCENE_STEMMER,, Define if you want stemming support for CLucene)
AC_CHECK_LIB(textcat, special_textcat_Init, [
AC_DEFINE(HAVE_LUCENE_TEXTCAT,, Define if you want textcat support for CLucene)
AC_CHECK_LIB(exttextcat, special_textcat_Init, [
have_lucene_exttextcat=yes
AC_DEFINE(HAVE_LUCENE_EXTTEXTCAT,, Define if you want textcat (Debian version) support for CLucene)
if test $want_stemmer = yes; then
AC_ERROR([Can't build with stemmer support: libstemmer not found])
AM_CONDITIONAL(BUILD_LUCENE_STEMMER, test "$have_lucene_stemmer" = "yes")
AM_CONDITIONAL(BUILD_LUCENE_TEXTCAT, test "$have_lucene_textcat" = "yes")
AM_CONDITIONAL(BUILD_LUCENE_EXTTEXTCAT, test "$have_lucene_exttextcat" = "yes")
if test $have_lucene = no; then
not_fts="$not_fts lucene"
if test $have_solr = no; then
dnl get a list of setting .[ch] files, but list .h files first
FILES1=`find $
srcdir/src -name '*settings.[[ch]]'|grep "$
srcdir/src/lib-" | sed 's/^\(.*\)\(.\)$/\2 \1\2/' | grep -v 'lib-master.*c$' | sort -r | sed s/^..//`
FILES2=`find $
srcdir/src -name '*settings.[[ch]]'|grep -v "$
srcdir/src/lib-" | sed 's/^\(.*\)\(.\)$/\2 \1\2/' | grep -v all-settings | sort -r | sed s/^..//`
SETTING_FILES=`echo $FILES1 $FILES2 | sed -e s,$
srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g'`
dnl IDLE doesn't really belong to banner. It's there just to make Blackberries
dnl happy, because otherwise BIS server disables push email.
capability_banner="IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE"
capability="$capability_banner SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE BINARY MOVE"
AC_DEFINE_UNQUOTED(CAPABILITY_STRING, "$capability", IMAP capabilities)
AC_DEFINE_UNQUOTED(CAPABILITY_BANNER_STRING, "$capability_banner", IMAP capabilities advertised in banner)
CFLAGS="$CFLAGS $EXTRA_CFLAGS"
NOPLUGIN_LDFLAGS="-no-undefined"
if test "$with_gnu_ld" = yes; then
NOPLUGIN_LDFLAGS="$NOPLUGIN_LDFLAGS -Wl,--as-needed"
LDFLAGS="\$(NOPLUGIN_LDFLAGS) $LDFLAGS"
AC_SUBST(NOPLUGIN_LDFLAGS)
if test "$with_gnu_ld" = yes -a "$want_shared_libs" = "no"; then
# libtool can't handle using whole-archive flags, so we need to do this
# with a CC wrapper.. shouldn't be much of a problem, since most people
# are building with shared libs.
if test "$docdir" = ""; then
dnl docdir supported only by autoconf v2.59c and later
docdir='${datadir}/doc/${PACKAGE_TARNAME}'
AC_CHECK_PROG(VALGRIND, valgrind, yes, no)
if test $VALGRIND = yes; then
AC_SUBST(abs_top_builddir)
if test "$want_sql" = "plugin"; then
sql_drivers="$sql_drivers (plugins)"
not_passdb=`echo "$not_passdb"|sed 's/ / -/g'`
not_userdb=`echo "$not_userdb"|sed 's/ / -/g'`
not_sql_drivers=`echo "$not_sql_drivers"|sed 's/ / -/g'`
not_fts=`echo "$not_fts"|sed 's/ / -/g'`
echo "Install prefix . : $prefix"
echo "File offsets ... : ${offt_bits}bit"
echo "I/O polling .... : $ioloop"
echo "I/O notifys .... : $have_notify"
echo "SSL ............ : $have_ssl"
echo "GSSAPI ......... : $have_gssapi"
echo "passdbs ........ :$passdb"
if test "$not_passdb" != ""; then
echo "userdbs ........ :$userdb"
if test "$not_userdb" != ""; then
echo "SQL drivers .... :$sql_drivers"
if test "$not_sql_drivers" != ""; then
echo " :$not_sql_drivers"
echo "Full text search :$fts"
if test "$not_fts" != ""; then