From: Aki Tuomi Date: Tue, 19 Apr 2016 11:51:15 +0000 (+0300) Subject: configure: Move checks to separate m4 files X-Git-Tag: 2.3.0.rc1~3977 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cca227d2929386ee11e4aa23464681ef35eb9679;p=thirdparty%2Fdovecot%2Fcore.git configure: Move checks to separate m4 files --- diff --git a/Makefile.am b/Makefile.am index a7be896d2f..418ea70cdf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,7 +23,7 @@ nodist_pkginclude_HEADERS = config.h ChangeLog: git log --name-status --pretty="format:%ai %aN <%aE> (%h)%n%n%w(80,4,4)%s%n%n%b" 5d5c4f2bfb812c767084c0338dae692db476da10^.. > ChangeLog || rm -f ChangeLog -aclocal_DATA = dovecot.m4 +aclocal_DATA = m4/dovecot.m4 dovecot-version.h: noop $(SHELL) $(top_srcdir)/update-version.sh $(top_srcdir) $(top_builddir) diff --git a/autogen.sh b/autogen.sh index c933cbf1c3..930ec52616 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,13 +1,10 @@ #!/bin/sh # If you've non-standard directories, set these -#ACLOCAL_DIR= +ACLOCAL_DIR=m4 #GETTEXT_DIR= -ACLOCAL="aclocal -I ." -if test "$ACLOCAL_DIR" != ""; then - ACLOCAL="$ACLOCAL -I $ACLOCAL_DIR" -fi +ACLOCAL="aclocal -I$ACLOCAL_DIR" export ACLOCAL for dir in $GETTEXT_DIR /usr/share/gettext /usr/local/share/gettext; do diff --git a/configure.ac b/configure.ac index 8d274e7a8a..301118c638 100644 --- a/configure.ac +++ b/configure.ac @@ -12,28 +12,9 @@ AM_INIT_AUTOMAKE([foreign]) AM_MAINTAINER_MODE PKG_PROG_PKG_CONFIG -ACLOCAL_AMFLAGS='-I $(top_srcdir)' +ACLOCAL_AMFLAGS='-I $(top_srcdir)/m4' AC_SUBST(ACLOCAL_AMFLAGS) -dnl TEST_WITH(name, value, [plugin]) -AC_DEFUN([TEST_WITH], [ - want=want_`echo $1|sed s/-/_/g` - if test $2 = yes || test $2 = no || test $2 = auto; then - eval $want=$2 - elif test $2 = plugin; then - if test "$3" = plugin; then - eval $want=plugin - else - AC_ERROR([--with-$1=plugin not supported]) - fi - elif `echo $2|grep '^/' >/dev/null`; then - AC_ERROR([--with-$1=path not supported. You may want to use instead: -CPPFLAGS=-I$2/include LDFLAGS=-L$2/lib ./configure --with-$1]) - else - AC_ERROR([--with-$1: Unknown value: $2]) - fi -]) - AC_ARG_ENABLE(devel-checks, AS_HELP_STRING([--enable-devel-checks], [Enable some extra expensive checks for developers]), if test x$enableval = xyes; then @@ -333,119 +314,14 @@ AC_CHECK_HEADERS(strings.h stdint.h unistd.h dirent.h malloc.h inttypes.h \ xfs/xqm.h execinfo.h ucontext.h malloc_np.h sys/utsname.h sys/vmount.h \ sys/utsname.h glob.h linux/falloc.h ucred.h sys/ucred.h) -dnl * clang check -have_clang=no -if $CC -dM -E -x c /dev/null | grep __clang__ > /dev/null 2>&1; then - have_clang=yes -fi - -dnl * gcc specific options -if test "x$ac_cv_c_compiler_gnu" = "xyes"; then - # -Wcast-qual -Wcast-align -Wconversion -Wunreachable-code # too many warnings - # -Wstrict-prototypes -Wredundant-decls # may give warnings in some systems - # -Wmissing-format-attribute -Wmissing-noreturn -Wwrite-strings # a couple of warnings - CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast" - - if test "$have_clang" = "yes"; then - AC_TRY_COMPILE([ - #if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 3) - # error new clang - #endif - ],,,[ - # clang 3.3+ unfortunately this gives warnings with hash.h - CFLAGS="$CFLAGS -Wno-duplicate-decl-specifier" - ]) - else - # This is simply to avoid warning when building strftime() wrappers.. - CFLAGS="$CFLAGS -fno-builtin-strftime" - fi - - AC_TRY_COMPILE([ - #if __GNUC__ < 4 - # error old gcc - #endif - ],,[ - # gcc4 - CFLAGS="$CFLAGS -Wstrict-aliasing=2" - ]) +CC_CLANG - # Use std=gnu99 if we have new enough gcc - old_cflags=$CFLAGS - CFLAGS="-std=gnu99" - AC_TRY_COMPILE([ - ],, [ - CFLAGS="$CFLAGS $old_cflags" - ], [ - CFLAGS="$old_cflags" - ]) -fi -if test "$have_clang" = "yes"; then - # clang specific options - if test "$want_devel_checks" = "yes"; then - # FIXME: enable once md[45], sha[12] can be compiled without - #CFLAGS="$CFLAGS -fsanitize=integer,undefined -ftrapv" - : - fi -fi - -dnl ** -dnl ** just some generic stuff... -dnl ** - -AC_SEARCH_LIBS(socket, socket) -AC_SEARCH_LIBS(inet_addr, nsl) -AC_SEARCH_LIBS(fdatasync, rt, [ - AC_DEFINE(HAVE_FDATASYNC,, [Define if you have fdatasync()]) -]) - -if test $want_libcap != no; then - AC_CHECK_LIB(cap, cap_init, [ - AC_DEFINE(HAVE_LIBCAP,, [libcap is installed for cap_init()]) - LIBCAP="-lcap" - AC_SUBST(LIBCAP) - ], [ - if test "$want_libcap" = "yes"; then - AC_ERROR([Can't build with libcap support: libcap not found]) - fi - ]) -fi +DOVECOT_CFLAGS -have_libwrap=no -if test $want_libwrap != no; then - AC_CHECK_HEADER(tcpd.h, [ - old_LIBS=$LIBS - - AC_CACHE_CHECK([whether we have libwrap],i_cv_have_libwrap,[ - AC_TRY_COMPILE([ - #include - int allow_severity = 0; - int deny_severity = 0; - ], [ - request_init((void *)0); - ], [ - i_cv_have_libwrap=yes - ], [ - i_cv_have_libwrap=no - ]) - ]) - if test $i_cv_have_libwrap = yes; then - AC_DEFINE(HAVE_LIBWRAP,, [Define if you have libwrap]) - LIBWRAP_LIBS=-lwrap - AC_SUBST(LIBWRAP_LIBS) - have_libwrap=yes - else - if test "$want_libwrap" = "yes"; then - AC_ERROR([Can't build with libwrap support: libwrap not found]) - fi - fi - LIBS=$old_LIBS - ], [ - if test "$want_libwrap" = "yes"; then - AC_ERROR([Can't build with libwrap support: tcpd.h not found]) - fi - ]) -fi -AM_CONDITIONAL(TCPWRAPPERS, test "$have_libwrap" = "yes") +DOVECOT_NSL +DOVECOT_FDATASYNC +DOVECOT_LIBCAP +DOVECOT_LIBWRAP AC_DEFINE(PACKAGE_WEBPAGE, "http://www.dovecot.org/", [Support URL]) @@ -458,170 +334,14 @@ AC_CHECK_FUNCS(fcntl flock lockf inet_aton sigaction getpagesize madvise \ malloc_usable_size glob fallocate posix_fadvise \ getpeereid getpeerucred inotify_init timegm) -AC_CHECK_TYPES([struct sockpeercred],,,[ -#include -#include -]) +DOVECOT_SOCKPEERCRED +DOVECOT_CLOCK_GETTIME -AC_SEARCH_LIBS(clock_gettime, rt, [ - AC_DEFINE(HAVE_CLOCK_GETTIME,, [Define if you have the clock_gettime function]) -]) +DOVECOT_TYPEOF +DOVECOT_IOLOOP +DOVECOT_NOTIFY -AC_CACHE_CHECK([for typeof],i_cv_have_typeof,[ - AC_TRY_COMPILE([ - ], [ - int foo; - typeof(foo) bar; - ], [ - i_cv_have_typeof=yes - ], [ - i_cv_have_typeof=no - ]) -]) -if test $i_cv_have_typeof = yes; then - AC_DEFINE(HAVE_TYPEOF,, [Define if you have typeof()]) -fi - -dnl * I/O loop function -have_ioloop=no - -if test "$ioloop" = "best" || test "$ioloop" = "epoll"; then - AC_CACHE_CHECK([whether we can use epoll],i_cv_epoll_works,[ - AC_TRY_RUN([ - #include - - int main() - { - return epoll_create(5) < 1; - } - ], [ - i_cv_epoll_works=yes - ], [ - i_cv_epoll_works=no - ]) - ]) - if test $i_cv_epoll_works = yes; then - AC_DEFINE(IOLOOP_EPOLL,, [Implement I/O loop with Linux 2.6 epoll()]) - have_ioloop=yes - ioloop=epoll - else - if test "$ioloop" = "epoll" ; then - AC_MSG_ERROR([epoll ioloop requested but epoll_create() is not available]) - fi - fi -fi - -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()]) - ioloop=kqueue - have_ioloop=yes - elif test "$ioloop" = "kqueue"; then - AC_MSG_ERROR([kqueue ioloop requested but kqueue() is not available]) - fi -fi - -if test "$ioloop" = "best" || test "$ioloop" = "poll"; then - AC_CHECK_FUNC(poll, [ - AC_DEFINE(IOLOOP_POLL,, [Implement I/O loop with poll()]) - ioloop=poll - have_ioloop=yes - ]) -fi - -if test "$have_ioloop" = "no"; then - AC_DEFINE(IOLOOP_SELECT,, [Implement I/O loop with select()]) - ioloop="select" -fi - -have_notify=none - -if test "$notify" = "" || test "$notify" = "inotify" ; then - dnl * inotify? - AC_MSG_CHECKING([whether we can use inotify]) - if test "$ac_cv_func_inotify_init" = yes; then - have_notify=inotify - notify=inotify - AC_MSG_RESULT("yes") - AC_DEFINE(IOLOOP_NOTIFY_INOTIFY,, [Use Linux inotify]) - else - AC_MSG_RESULT("no") - if test "$notify" = "inotify"; then - AC_MSG_ERROR([inotify requested but not available]) - notify="" - fi - fi -fi - -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 - have_notify=kqueue - notify=kqueue - AC_MSG_RESULT("yes") - AC_DEFINE(IOLOOP_NOTIFY_KQUEUE,, [Use BSD kqueue directory changes notificaton]) - else - AC_MSG_RESULT("no") - if test "$notify" = "kqueue" ; then - AC_MSG_ERROR([kqueue notify requested but kqueue() is not available]) - notify="" - fi - fi -fi - -if test "$have_notify" = "none"; then - AC_DEFINE(IOLOOP_NOTIFY_NONE,, [No special notify support]) -fi - -AC_CACHE_CHECK([whether we have glibc],i_cv_have_glibc,[ - AC_TRY_COMPILE([ - #include - #ifdef __GLIBC__ - we have glibc - #endif - ],, [ - i_cv_have_glibc=no - ], [ - i_cv_have_glibc=yes - ]) -]) -if test "$i_cv_have_glibc" = "yes"; then - AC_DEFINE(PREAD_WRAPPERS,, [Define if pread/pwrite needs _XOPEN_SOURCE 500]) -fi - -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,[ - AC_TRY_RUN([ - #define _XOPEN_SOURCE 600 - #include - #include - #include - #include - #if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 7) - possibly broken posix_fallocate - #endif - int main() { - int fd = creat("conftest.temp", 0600); - int ret; - if (fd == -1) { - perror("creat()"); - return 2; - } - ret = posix_fallocate(fd, 1024, 1024) < 0 ? 1 : 0; - unlink("conftest.temp"); - return ret; - } - ], [ - 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()]) -fi +DOVECOT_GLIBC dnl * OS specific options DC_PLUGIN_DEPS @@ -645,127 +365,6 @@ AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(void *) AC_CHECK_SIZEOF(long long) -AC_DEFUN([AC_TYPEOF], [ - dnl * first check if we can get the size with redefining typedefs - - order="$2" - if test "$2" = ""; then - order="int long long-long" - fi - - result="" - visible="unknown" - 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 - old_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Werror" - - for type in $order; do - case "$type" in - int) - fmt="%d" - ;; - unsigned-int) - fmt="%u" - ;; - long) - fmt="%ld" - ;; - unsigned-long) - fmt="%lu" - ;; - long-long) - fmt="%lld" - ;; - unsigned-long-long) - fmt="%llu" - ;; - *) - fmt="" - ;; - esac - - if test "$fmt" != ""; then - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - #include - ]], [[ - printf("$fmt", ($1)0); - ]])],[ - if test "$result" != ""; then - dnl * warning check isn't working - result="" - visible="unknown" - break - fi - result="`echo $type|sed 's/-/ /g'`" - visible="$result" - ],[]) - fi - done - CFLAGS="$old_CFLAGS" - fi - - if test "$result" = ""; then - for type in $order; do - type="`echo $type|sed 's/-/ /g'`" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - typedef $type $1; - ]], [[]])],[ - if test "$result" != ""; then - dnl * compiler allows redefining to anything - result="" - visible="unknown" - break - fi - result="$type" - visible="$type" - ],[]) - done - fi - - if test "$result" = ""; then - dnl * check with sizes - - dnl * older autoconfs don't include sys/types.h, so do it manually - AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include - #include - int main() { - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof($1)); - exit(0); - } - ]])],[ - size=`cat conftestval` - rm -f conftestval - - for type in $order; do - 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)" - break - fi - done - if test "$result" = ""; then - result=unknown - visible="`expr $size \* 8`bit (unknown type)" - fi - ],[],[]) - fi - i_cv_typeof_$1=$result/$visible - ]) - - typeof_$1=`echo $i_cv_typeof_$1 | sed s,/.*$,,` - visible=`echo $i_cv_typeof_$1 | sed s,^.*/,,` - AC_MSG_RESULT($visible) -]) - AC_SYS_LARGEFILE AC_CHECK_TYPES(_Bool) @@ -807,94 +406,16 @@ case "$typeof_off_t" in ;; esac -dnl * Do we have struct dirent->d_type -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include -]], [[ - struct dirent d; - d.d_type = DT_DIR; -]])],[ - 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([[ - #include - #include -]], [[ - off_t i = OFF_T_MAX; -]])],[ - : -],[ - AC_DEFINE_UNQUOTED(OFF_T_MAX, $offt_max, [Maximum value of off_t]) -]) +DOVECOT_DIRENT_DTYPE +DOVECOT_OFF_T_MAX 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([[ - #include - int main() { - /* return 0 if we're signed */ - exit((size_t)(int)-1 <= 0 ? 0 : 1); - } - ]])],[ - i_cv_signed_size_t=yes - - echo - 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 - AC_MSG_ERROR([aborting]) - fi - echo "..ignoring as requested.." - ],[ - i_cv_signed_size_t=no - ],[]) -]) -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) -case "$typeof_size_t" in - "unsigned long") - ssizet_max=LONG_MAX - sizet_fmt="lu" - ;; - "unsigned long long") - ssizet_max=LLONG_MAX - sizet_fmt="llu" - ;; - *) - dnl older systems didn't have ssize_t, default to int - ssizet_max=INT_MAX - sizet_fmt="u" - - 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]) - fi - ;; -esac +DOVECOT_SIZE_T_SIGNED 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([[ - #include - $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 dnl defined elsewhere AC_CHECK_HEADER(stdint.h, [ @@ -936,805 +457,57 @@ if test "$have_random_source" != "yes"; then ]) fi -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([[ -#include ]], -[[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]) -fi -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([[ - #include - #include - int main() { - FILE *f; - int bits; - - for (bits = 1; bits < sizeof(time_t)*8; bits++) { - time_t t = ((time_t)1 << bits) - 1; - if (gmtime(&t) == NULL) { - bits--; - break; - } - } - if (bits > 40) { - /* 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. */ - bits = 40; - } - - f = fopen("conftest.temp", "w"); - if (f == NULL) { - perror("fopen()"); - return 1; - } - fprintf(f, "%d", bits); - fclose(f); - return 0; - } - ]])],[ - i_cv_gmtime_max_time_t=`cat conftest.temp` - rm -f conftest.temp - ], [ - 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([[ - #include - int main() { - /* return 0 if we're signed */ - exit((time_t)(int)-1 <= 0 ? 0 : 1); - } - ]])],[ - i_cv_signed_time_t=yes - ], [ - i_cv_signed_time_t=no - ]) -]) -if test $i_cv_signed_time_t = yes; then - AC_DEFINE(TIME_T_SIGNED,, [Define if your time_t is signed]) -fi - -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,[ - AC_TRY_COMPILE([ - struct foo { - int x; - char y[]; - }; - ], [ - struct foo foo; - ], [ - i_cv_c99_flex_arrays=yes - ], [ - i_cv_c99_flex_arrays=no - ]) -]) - -if test $i_cv_c99_flex_arrays = yes; then - flexible_value= -else - flexible_value=1 -fi -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([[ -#include -#include -#include ]], -[[struct iovec *iovec;]])], -[i_cv_struct_iovec=yes], -[i_cv_struct_iovec=no])]) - -if test $i_cv_struct_iovec = yes; then - AC_DEFINE(HAVE_STRUCT_IOVEC,, [Define if you have struct iovec]) -fi -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([[ - #include - struct test { dev_t a; }; - static struct test t = { 0 }; - ]], - [[ ]])], [ - i_cv_dev_t_struct=no - ],[ - i_cv_dev_t_struct=yes - ]) -]) -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]) -fi - -dnl * Do we have RLIMIT_AS? -AC_CACHE_CHECK([whether RLIMIT_AS exists],i_cv_have_rlimit_as,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - #include - #include - ]], [[ - struct rlimit r; - getrlimit(RLIMIT_AS, &r); - ]])],[ - i_cv_have_rlimit_as=yes - ], [ - i_cv_have_rlimit_as=no - ]) -]) - -if test $i_cv_have_rlimit_as = yes; then - AC_DEFINE(HAVE_RLIMIT_AS,, [Define if you have RLIMIT_AS for setrlimit()]) -fi - -dnl * Do we have RLIMIT_NPROC? -AC_CACHE_CHECK([whether RLIMIT_NPROC exists],i_cv_have_rlimit_nproc,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - #include - #include - ]], [[ - struct rlimit r; - 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()]) -fi - -dnl * Do we have RLIMIT_CORE? -AC_CACHE_CHECK([whether RLIMIT_CORE exists],i_cv_have_rlimit_core,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - #include - #include - ]], [[ - struct rlimit r; - getrlimit(RLIMIT_CORE, &r); - ]])],[ - i_cv_have_rlimit_core=yes - ],[ - i_cv_have_rlimit_core=no - ]) -]) - -if test $i_cv_have_rlimit_core = yes; then - AC_DEFINE(HAVE_RLIMIT_CORE,, [Define if you have RLIMIT_CORE for getrlimit()]) -fi - -AC_CACHE_CHECK([whether PR_SET_DUMPABLE exists],i_cv_have_pr_set_dumpable,[ - AC_TRY_LINK([ - #include - ], [ - 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)]) -fi - -dnl * Linux compatible mremap() -AC_CACHE_CHECK([Linux compatible mremap()],i_cv_have_linux_mremap,[ - AC_TRY_LINK([ - #include - #define __USE_GNU - #include - ], [ - 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()]) -fi - -dnl * If mmap() plays nicely with write() -AC_CACHE_CHECK([whether shared mmaps get updated by write()s],i_cv_mmap_plays_with_write,[ - AC_TRY_RUN([ - #include - #include - #include - #include - #include - #include - int main() { - /* return 0 if we're signed */ - int f = open("conftest.mmap", O_RDWR|O_CREAT|O_TRUNC, 0600); - void *mem; - if (f == -1) { - perror("open()"); - return 1; - } - unlink("conftest.mmap"); - - write(f, "1", 2); - mem = mmap(NULL, 2, PROT_READ|PROT_WRITE, MAP_SHARED, f, 0); - if (mem == MAP_FAILED) { - perror("mmap()"); - return 1; - } - strcpy(mem, "2"); - msync(mem, 2, MS_SYNC); - lseek(f, 0, SEEK_SET); - write(f, "3", 2); - - 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]) -fi - -dnl * see if fd passing works -AC_CACHE_CHECK([whether fd passing works],i_cv_fd_passing,[ - for i in 1 2; do - old_cflags="$CFLAGS" - CFLAGS="$CFLAGS -I$srcdir/src/lib $srcdir/src/lib/fdpass.c" - if test $i = 2; then - CFLAGS="$CFLAGS -DBUGGY_CMSG_MACROS" - fi - - AC_TRY_RUN([ - #include - #include - #include - #include - #include - #include - #include "fdpass.h" - - int nopen(void) - { - int i, n; - struct stat sb; - for (i = n = 0; i < 256; i++) - if (fstat(i, &sb) == 0) n++; - return n; - } - int main(void) - { - int fd[2], send_fd, recv_fd, status, n1, n2; - struct stat st, st2; - char data; - - send_fd = creat("conftest.fdpass", 0600); - if (send_fd == -1) return 2; - unlink("conftest.fdpass"); - if (fstat(send_fd, &st) < 0) return 2; - if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) return 2; - n1 = nopen(); - - switch (fork()) { - case -1: - return 2; - case 0: - alarm(1); - if (fd_send(fd[0], send_fd, &data, 1) != 1) return 2; - return 0; - default: - alarm(2); - if (wait(&status) == -1) - return 2; - if (status != 0) - return status; - 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 - was received */ - n2 = nopen(); - return st.st_ino == st2.st_ino && n2 == n1 + 1 ? 0 : 1; - } - } - ], [ - CFLAGS=$old_cflags - if test $i = 2; then - i_cv_fd_passing=buggy_cmsg_macros - else - i_cv_fd_passing=yes - fi - break - ], [ - dnl no, try with BUGGY_CMSG_MACROS - CFLAGS=$old_cflags - i_cv_fd_passing=no - ]) - done -]); - -case "$host_os" in -darwin[[1-9]].*) - if test "$i_cv_fd_passing" = "yes"; then - i_cv_fd_passing=buggy_cmsg_macros - fi - ;; -esac +DOVECOT_TM_GMTOFF +DOVECOT_GMTIME_MAX +DOVECOT_TIME_T_SIGNED -if test $i_cv_fd_passing = buggy_cmsg_macros; then - AC_DEFINE(BUGGY_CMSG_MACROS,, [Define if you have buggy CMSG macros]) -fi -if test $i_cv_fd_passing = no; then - AC_ERROR([fd passing is required for Dovecot to work]) -fi +DOVECOT_C_FLEXIBLE_ARRAY_MEMBER -dnl * Solaris compatible sendfile() -AC_CHECK_LIB(sendfile, sendfile, [ - LIBS="$LIBS -lsendfile" - 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,[ - AC_TRY_LINK([ - #undef _FILE_OFFSET_BITS - #include - #include - #include - ], [ - 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()]) - fi +DOVECOT_IOVEC - dnl * FreeBSD compatible sendfile() - AC_CACHE_CHECK([FreeBSD compatible sendfile()],i_cv_have_freebsd_sendfile,[ - AC_TRY_LINK([ - #include - #include - #include - ], [ - struct sf_hdtr hdtr; - 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()]) - fi -]) +DOVECOT_TYPEOF_DEV_T -AC_CACHE_CHECK([if unsetenv returns int],i_cv_unsetenv_ret_int,[ - AC_TRY_COMPILE([ - #include - ], [ - if (unsetenv("env") < 0) ; - ], [ - i_cv_unsetenv_ret_int=yes - ], [ - i_cv_unsetenv_ret_int=no - ]) -]) -if test $i_cv_unsetenv_ret_int = yes; then - AC_DEFINE(UNSETENV_RET_INT,, [Define if unsetenv() returns int]) -fi +DOVECOT_RLIMIT_AS +DOVECOT_RLIMIT_NPROC +DOVECOT_RLIMIT_CORE -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,[ - AC_TRY_COMPILE([ - #define _XOPEN_SOURCE 4 - #define _XOPEN_SOURCE_EXTENDED 1 - #define _XOPEN_VERSION 4 - #define _XPG4_2 - #define _XPG6 - #include - ], [ - crypt("a", "b"); - ], [ - i_cv_use_xpg6_crypt=yes - ], [ - i_cv_use_xpg6_crypt=no - ]) -]) -if test $i_cv_use_xpg6_crypt = yes; then - AC_DEFINE(CRYPT_USE_XPG6,, [Define if _XPG6 macro is needed for crypt()]) -fi +DOVECOT_PR_SET_DUMPABLE -AC_CACHE_CHECK([if struct stat has st_?tim timespec fields],i_cv_have_st_tim_timespec,[ - AC_TRY_COMPILE([ - #include - #include - #include - ], [ - struct stat st; - unsigned long x = st.st_mtim.tv_nsec; - - return 0; - ], [ - 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]) -fi +DOVECOT_LINUX_MREMAP -AC_CACHE_CHECK([if struct stat has st_?timespec fields],i_cv_have_st_timespec,[ - AC_TRY_COMPILE([ - #include - #include - #include - ], [ - struct stat st; - unsigned long x = st.st_mtimespec.tv_nsec; - - return 0; - ], [ - i_cv_have_st_timespec=yes - ], [ - i_cv_have_st_timespec=no - ]) -]) -if test $i_cv_have_st_timespec = yes; then - AC_DEFINE(HAVE_STAT_XTIMESPEC,, [Define if you have st_?timespec fields in struct stat]) -fi +DOVECOT_MMAP_WRITE -dnl * Check if statvfs() can be used to find out block device for files -AC_CACHE_CHECK([if statvfs.f_mntfromname exists],i_cv_have_statvfs_f_mntfromname,[ - AC_TRY_COMPILE([ - #include - #include - ], [ - struct statvfs buf; - char *p = buf.f_mntfromname; - - statvfs(".", &buf); - ], [ - i_cv_have_statvfs_f_mntfromname=yes - ], [ - i_cv_have_statvfs_f_mntfromname=no - ]) -]) -if test $i_cv_have_statvfs_f_mntfromname = yes; then - AC_DEFINE(HAVE_STATVFS_MNTFROMNAME,, [Define if you have statvfs.f_mntfromname]) -fi - -dnl * Check if statfs() can be used to find out block device for files -AC_CACHE_CHECK([if statfs.f_mntfromname exists],i_cv_have_statfs_f_mntfromname,[ - AC_TRY_COMPILE([ - #include - #include - ], [ - struct statfs buf; - char *p = buf.f_mntfromname; - - statfs(".", &buf); - ], [ - i_cv_have_statfs_f_mntfromname=yes - ], [ - i_cv_have_statfs_f_mntfromname=no - ]) -]) -if test $i_cv_have_statfs_f_mntfromname = yes; then - AC_DEFINE(HAVE_STATFS_MNTFROMNAME,, [Define if you have statfs.f_mntfromname]) -fi - -dnl * Check if we have struct dqblk.dqb_curblocks -AC_CACHE_CHECK([if struct dqblk.dqb_curblocks exists],i_cv_have_dqblk_dqb_curblocks,[ - AC_TRY_COMPILE([ - #include - #include "$srcdir/src/plugins/quota/quota-fs.h" - ], [ - struct dqblk dqblk; - unsigned int x = dqblk.dqb_curblocks; - ], [ - i_cv_have_dqblk_dqb_curblocks=yes - ], [ - i_cv_have_dqblk_dqb_curblocks=no - ]) -]) -if test $i_cv_have_dqblk_dqb_curblocks = yes; then - AC_DEFINE(HAVE_STRUCT_DQBLK_CURBLOCKS,, [Define if struct sqblk.dqb_curblocks exists]) -fi - -dnl * Check if we have struct dqblk.dqb_curspace -AC_CACHE_CHECK([if struct dqblk.dqb_curspace exists],i_cv_have_dqblk_dqb_curspace,[ - AC_TRY_COMPILE([ - #include - #include "$srcdir/src/plugins/quota/quota-fs.h" - ], [ - struct dqblk dqblk; - unsigned int x = dqblk.dqb_curspace; - ], [ - i_cv_have_dqblk_dqb_curspace=yes - ], [ - i_cv_have_dqblk_dqb_curspace=no - ]) -]) -if test $i_cv_have_dqblk_dqb_curspace = yes; then - AC_DEFINE(HAVE_STRUCT_DQBLK_CURSPACE,, [Define if struct sqblk.dqb_curspace exists]) -fi +DOVECOT_FD_PASSING -dnl * Check if we have Q_QUOTACTL ioctl (Solaris) -AC_CACHE_CHECK([if Q_QUOTACTL ioctl exists],i_cv_have_ioctl_q_quotactl,[ - AC_TRY_COMPILE([ - #include - #include - ], [ - struct quotctl ctl; - ioctl(0, Q_QUOTACTL, &ctl); - ], [ - i_cv_have_ioctl_q_quotactl=yes - ], [ - i_cv_have_ioctl_q_quotactl=no - ]) -]) +DOVECOT_SENDFILE -if test $i_cv_have_ioctl_q_quotactl = yes; then - AC_DEFINE(HAVE_Q_QUOTACTL,, [Define if Q_QUOTACTL exists]) -fi - -dnl *** -dnl *** C99 vsnprintf()? -dnl *** - -AC_CACHE_CHECK([for C99 vsnprintf()],i_cv_c99_vsnprintf,[ - AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include - #include - static int f(const char *fmt, ...) { - va_list args; - char buf[13]; - int ret; - - va_start(args, fmt); - ret = vsnprintf(buf, 11, fmt, args) != 12 || buf[11-1] != '\0'; - va_end(args); - return ret; - } - int main() { - return f("hello %s%d", "world", 1); - }]])], - [i_cv_c99_vsnprintf=yes], - [i_cv_c99_vsnprintf=no]) -]) -if test $i_cv_c99_vsnprintf = no; then - AC_DEFINE(HAVE_OLD_VSNPRINTF,, [Define if you don't have C99 compatible vsnprintf() call]) -fi - -dnl *** -dnl *** va_copy checks (from GLIB) -dnl *** - -AC_CACHE_CHECK([for an implementation of va_copy()],lib_cv_va_copy,[ - AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include - void f (int i, ...) { - va_list args1, args2; - va_start (args1, i); - va_copy (args2, args1); - if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) - exit (1); - va_end (args1); va_end (args2); - } - int main() { - f (0, 42); - return 0; - }]])], - [lib_cv_va_copy=yes], - [lib_cv_va_copy=no],[]) -]) -AC_CACHE_CHECK([for an implementation of __va_copy()],lib_cv___va_copy,[ - AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include - void f (int i, ...) { - va_list args1, args2; - va_start (args1, i); - __va_copy (args2, args1); - if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) - exit (1); - va_end (args1); va_end (args2); - } - int main() { - f (0, 42); - return 0; - }]])], - [lib_cv___va_copy=yes], - [lib_cv___va_copy=no],[]) -]) +DOVECOT_UNSETENV_RET_INT -if test "x$lib_cv_va_copy" = "xyes"; then - va_copy_func=va_copy -else if test "x$lib_cv___va_copy" = "xyes"; then - va_copy_func=__va_copy -fi -fi +DOVECOT_CRYPT_XPG6 +DOVECOT_CRYPT -if test -n "$va_copy_func"; then - AC_DEFINE_UNQUOTED(VA_COPY,$va_copy_func,[A 'va_copy' style function]) -fi +DOVECOT_ST_TIM_TIMESPEC -AC_CACHE_CHECK([whether va_lists can be copied by value],lib_cv_va_val_copy,[ - AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include - void f (int i, ...) { - va_list args1, args2; - va_start (args1, i); - args2 = args1; - if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) - exit (1); - va_end (args1); va_end (args2); - } - int main() { - f (0, 42); - return 0; - }]])], - [lib_cv_va_val_copy=yes], - [lib_cv_va_val_copy=no],[]) -]) +DOVECOT_FILE_BLOCKDEV -if test "x$lib_cv_va_val_copy" = "xno"; then - AC_DEFINE(VA_COPY_AS_ARRAY,1, ['va_lists' cannot be copies as values]) -fi +DOVECOT_DQBLK_CURBLOCKS +DOVECOT_DQBLK_CURSPACE -dnl * dynamic modules? -have_modules=no -AC_CHECK_FUNC(dlopen, [ - have_modules=yes - MODULE_LIBS="-export-dynamic" -], [ - AC_CHECK_LIB(dl, dlopen, [ - have_modules=yes - MODULE_LIBS="-export-dynamic -ldl" - DLLIB=-ldl - ]) -]) +DOVECOT_Q_QUOTACTL -dnl ** -dnl ** AIX mntctl -dnl ** +DOVECOT_C99_VSNPRINTF -if test $ac_cv_header_sys_vmount_h = yes; then - AC_MSG_CHECKING([for reasonable mntctl buffer size]) - AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include - #include - #include - int main() { - int size,count; char *m; - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - 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 */ - exit(0); - } - ]])],[ - size=`cat conftestval` - rm -f conftestval - AC_DEFINE_UNQUOTED(STATIC_MTAB_SIZE,$size, [reasonable mntctl buffer size]) - AC_MSG_RESULT($size) - ],[ - AC_MSG_RESULT(default) - ]) -fi +DOVECOT_VA_COPY +DOVECOT_VA_COPY_BYVAL +DOVECOT_MODULES -dnl ** -dnl ** SSL -dnl ** +DOVECOT_MNTCTL -have_ssl=no - -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" - have_openssl=yes - else - # openssl 0.9.8 wants -ldl and it's required if there's only .a lib - AC_CHECK_LIB(ssl, SSL_read, [ - AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h, [ - SSL_LIBS="-lssl -lcrypto $DLLIB" - AC_SUBST(SSL_LIBS) - have_openssl=yes - ], [ - if test $want_openssl = yes; then - AC_ERROR([Can't build with OpenSSL: openssl/ssl.h or openssl/err.h not found]) - fi - ]) - ], [ - if test $want_openssl = yes; then - AC_ERROR([Can't build with OpenSSL: libssl not found]) - fi - ], -lcrypto $DLLIB) - fi - if test "$have_openssl" = "yes"; then - AC_DEFINE(HAVE_OPENSSL,, [Build with OpenSSL support]) - have_ssl="yes (OpenSSL)" - - AC_CHECK_LIB(ssl, SSL_get_current_compression, [ - AC_DEFINE(HAVE_SSL_COMPRESSION,, [Build with OpenSSL compression]) - ],, $SSL_LIBS) - AC_CHECK_LIB(ssl, SSL_get_servername, [ - AC_DEFINE(HAVE_SSL_GET_SERVERNAME,, [Build with TLS hostname support]) - ],, $SSL_LIBS) - fi -fi -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_CHECK_HEADER(gnutls/gnutls.h, [ - AC_DEFINE(HAVE_GNUTLS,, [Build with GNUTLS support]) - SSL_LIBS="-lgnutls -lgcrypt" - AC_SUBST(SSL_LIBS) - have_ssl="yes (GNUTLS)" - have_gnutls=yes - ], [ - if test $want_gnutls = yes; then - AC_ERROR([Can't build with GNUTLS: gnutls/gnutls.h not found]) - fi - ]) - ], [ - if test $want_gnutls = yes; then - AC_ERROR([Can't build with GNUTLS: libgnutls not found]) - fi - ], -lgcrypt) -fi +DOVECOT_SSL -if test "$have_ssl" != "no"; then - AC_DEFINE(HAVE_SSL,, [Build with SSL/TLS support]) -fi +DOVECOT_GC -dnl ** -dnl ** Garbage Collector -dnl ** - -if test $want_gc != no; then - AC_CHECK_LIB(gc, GC_malloc, [ - AC_CHECK_HEADERS(gc/gc.h gc.h) - AC_DEFINE(USE_GC,, [Define if you want to use Boehm GC]) - LIBS="$LIBS -lgc" - ], [ - if test $want_gc = yes; then - AC_ERROR([Can't build with GC: libgc not found]) - fi - ]) -fi dnl ** dnl ** userdb and passdb checks @@ -1747,605 +520,26 @@ not_passdb="" passdb="$passdb static" userdb="$userdb static" - -if test $want_prefetch_userdb != no; then - AC_DEFINE(USERDB_PREFETCH,, [Build with prefetch userdb support]) - userdb="$userdb prefetch" -else - not_userdb="$not_userdb prefetch" -fi - -if test $want_passwd != no; then - AC_DEFINE(USERDB_PASSWD,, [Build with passwd support]) - AC_DEFINE(PASSDB_PASSWD,, [Build with passwd support]) - userdb="$userdb passwd" - passdb="$passdb passwd" -else - not_passdb="$not_passdb passwd" - not_userdb="$not_userdb passwd" -fi - -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" -else - not_passdb="$not_passdb passwd-file" - not_userdb="$not_userdb passwd-file" -fi - -have_shadow=no -if test $want_shadow != no; then - AC_CHECK_FUNC(getspnam, [ - AC_CHECK_HEADER(shadow.h, [ - AC_DEFINE(PASSDB_SHADOW,, [Build with shadow support]) - have_shadow=yes - ], [ - if test $want_shadow = yes; then - AC_ERROR([Can't build with shadow support: shadow.h not found]) - fi - ]) - ], [ - if test $want_shadow = yes; then - AC_ERROR([Can't build with shadow support: getspnam() not found]) - fi - ]) -fi -if test $have_shadow = no; then - not_passdb="$not_passdb shadow" -else - passdb="$passdb shadow" -fi - -if test $want_pam != no; then - AC_CHECK_LIB(pam, pam_start, [ - have_pam=no - AC_CHECK_HEADER(security/pam_appl.h, [ - AC_DEFINE(HAVE_SECURITY_PAM_APPL_H,, - [Define if you have security/pam_appl.h]) - have_pam=yes - ]) - - AC_CHECK_HEADER(pam/pam_appl.h, [ - AC_DEFINE(HAVE_PAM_PAM_APPL_H,, - [Define if you have pam/pam_appl.h]) - have_pam=yes - ]) - ], [ - if test $want_pam = yes; then - AC_ERROR([Can't build with PAM support: libpam not found]) - fi - ]) -fi - -if test "$have_pam" = "yes"; then - AUTH_LIBS="$AUTH_LIBS -lpam" - AC_DEFINE(PASSDB_PAM,, [Build with PAM support]) - passdb="$passdb pam" - - 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]) -else - not_passdb="$not_passdb pam" -fi - -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" -else - not_passdb="$not_passdb checkpassword" - not_userdb="$not_userdb checkpassword" -fi - -have_bsdauth=no -if test $want_bsdauth != no; then - AC_CHECK_FUNC(auth_userokay, [ - AC_DEFINE(PASSDB_BSDAUTH,, [Build with BSD authentication support]) - have_bsdauth=yes - ], [ - if test $want_bsdauth = yes; then - AC_ERROR([Can't build with BSD authentication support: auth_userokay() not found]) - fi - ]) -fi -if test $have_bsdauth = no; then - not_passdb="$not_passdb bsdauth" -else - passdb="$passdb bsdauth" -fi - -have_gssapi=no -if test $want_gssapi != no; then - AC_CHECK_PROG(KRB5CONFIG, krb5-config, krb5-config, NO) - if test $KRB5CONFIG != NO; then - if ! $KRB5CONFIG --version gssapi 2>/dev/null > /dev/null; then - # krb5-config doesn't support gssapi. - KRB5_LIBS="`$KRB5CONFIG --libs`" - KRB5_CFLAGS=`$KRB5CONFIG --cflags` - AC_CHECK_LIB(gss, gss_acquire_cred, [ - # Solaris - KRB5_LIBS="$KRB5_LIBS -lgss" - ], [ - # failed - KRB5_LIBS= - ], $KRB5_LIBS) - else - KRB5_LIBS=`$KRB5CONFIG --libs gssapi` - KRB5_CFLAGS=`$KRB5CONFIG --cflags gssapi` - fi - if test "$KRB5_LIBS" != ""; then - AC_SUBST(KRB5_LIBS) - AC_SUBST(KRB5_CFLAGS) - - # Although krb5-config exists, all systems still don't - # have gssapi.h - old_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $KRB5_CFLAGS" - AC_CHECK_HEADER([gssapi/gssapi.h], [ - AC_DEFINE(HAVE_GSSAPI_GSSAPI_H,, [GSSAPI headers in gssapi/gssapi.h]) - have_gssapi=yes - ]) - AC_CHECK_HEADER([gssapi.h], [ - AC_DEFINE(HAVE_GSSAPI_H,, [GSSAPI headers in gssapi.h]) - have_gssapi=yes - ]) - if test $have_gssapi != no; then - if test $want_gssapi = plugin; then - have_gssapi=plugin - fi - AC_DEFINE(HAVE_GSSAPI,, [Build with GSSAPI support]) - AC_CHECK_HEADERS(gssapi/gssapi_ext.h gssapi_krb5.h gssapi/gssapi_krb5.h) - AC_CHECK_LIB(gss, __gss_userok, [ - AC_DEFINE(HAVE___GSS_USEROK,, - [Define if you have __gss_userok()]) - KRB5_LIBS="$KRB5_LIBS -lgss" - ],, $KRB5_LIBS) - - # MIT has a #define for Heimdal acceptor_identity, but it's way too - # difficult to test for it.. - old_LIBS=$LIBS - LIBS="$LIBS $KRB5_LIBS" - 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,[ - AC_TRY_RUN([ - #ifdef HAVE_GSSAPI_H - # include - #else - # include - #endif - #include - #include - int main(void) { - OM_uint32 minor_status; - gss_OID_set mech_set; - unsigned char spnego_oid[] = { 0x2b, 0x06, 0x01, 0x05, 0x05, 0x02 }; - unsigned int i; - - 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, - spnego_oid, 6) == 0) - return 0; - } - return 1; - } - ], [ - i_cv_gssapi_spnego=yes - ], [ - i_cv_gssapi_spnego=no - ]) - ]) - if test "$i_cv_gssapi_spnego" = "yes"; then - AC_DEFINE(HAVE_GSSAPI_SPNEGO,, [GSSAPI supports SPNEGO]) - fi - LIBS=$old_LIBS - - 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]) - else - have_gssapi_plugin=yes - fi - else - if test $want_gssapi != auto; then - AC_ERROR([Can't build with GSSAPI support: gssapi.h not found]) - fi - fi - CFLAGS=$old_CFLAGS - fi - else - if test $want_gssapi != auto; then - AC_ERROR([Can't build with GSSAPI support: krb5-config not found]) - fi - fi -fi -AM_CONDITIONAL(GSSAPI_PLUGIN, test "$have_gssapi_plugin" = "yes") - -have_sia=no -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" - have_sia=yes - ], [ - if test $want_sia = yes; then - AC_ERROR([Can't build with SIA support: sia_validate_user() not found]) - fi - ]) -fi - -if test $have_sia = no; then - not_passdb="$not_passdb sia" -else - passdb="$passdb sia" -fi - -have_ldap=no -if test $want_ldap != no; then - AC_CHECK_LIB(ldap, ldap_init, [ - AC_CHECK_HEADER(ldap.h, [ - 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]) - ]) - LDAP_LIBS="-lldap" - 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" - ]) - ]) - AC_SUBST(LDAP_LIBS) - if test $want_ldap != plugin; then - AUTH_LIBS="$AUTH_LIBS $LDAP_LIBS" - AC_DEFINE(BUILTIN_LDAP,, [LDAP support is built in]) - fi - - AC_DEFINE(USERDB_LDAP,, [Build with LDAP support]) - AC_DEFINE(PASSDB_LDAP,, [Build with LDAP support]) - AC_CHECK_HEADERS(sasl.h sasl/sasl.h) - have_ldap=yes - ], [ - if test $want_ldap != auto; then - AC_ERROR([Can't build with LDAP support: ldap.h not found]) - fi - ]) - ], [ - if test $want_ldap != auto; then - AC_ERROR([Can't build with LDAP support: libldap not found]) - fi - ]) -fi - -if test $have_ldap = no; then - not_passdb="$not_passdb ldap" - not_userdb="$not_userdb ldap" -else - userdb="$userdb ldap" - passdb="$passdb ldap" - if test $want_ldap = plugin; then - have_ldap_plugin=yes - userdb="$userdb (plugin)" - passdb="$passdb (plugin)" - fi -fi -AM_CONDITIONAL(LDAP_PLUGIN, test "$have_ldap_plugin" = "yes") -AM_CONDITIONAL(HAVE_LDAP, test "$want_ldap" = "yes") -dict_drivers= - -if test $want_db != no; then - AC_CACHE_CHECK([db_env_create in -ldb],i_cv_have_db_env_create,[ - old_LIBS=$LIBS - LIBS="$LIBS -ldb" - AC_TRY_LINK([ - #include - ], [ - db_env_create(0, 0); - ], [ - i_cv_have_db_env_create=yes - ], [ - i_cv_have_db_env_create=no - ]) - LIBS=$old_LIBS - ]) - if test $i_cv_have_db_env_create = yes; then - AC_CHECK_HEADER(db.h, [ - 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]) - fi - ]) - else - if test $want_db = yes; then - AC_ERROR([Can't build with db support: libdb not found]) - fi - fi -fi - -if test $want_cdb != no; then - AC_CHECK_LIB(cdb, cdb_init, [ - AC_CHECK_HEADER(cdb.h, [ - DICT_LIBS="$DICT_LIBS -lcdb" - dict_drivers="$dict_drivers cdb" - 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]) - fi - ]) - ], [ - if test $want_cdb = yes; then - AC_ERROR([Can't build with CDB support: libcdb not found]) - fi - ]) -fi - -if test $want_pgsql != no; then - AC_CHECK_PROG(PG_CONFIG, pg_config, pg_config, NO) - if test $PG_CONFIG = NO; then - # based on code from PHP - for i in /usr /usr/local /usr/local/pgsql; do - for j in include include/pgsql include/postgres include/postgresql ""; do - if test -r "$i/$j/libpq-fe.h"; then - PGSQL_INCLUDE=$i/$j - fi - done - for lib in lib lib64; do - for j in $lib $lib/pgsql $lib/postgres $lib/postgresql ""; do - if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then - PGSQL_LIBDIR=$i/$j - fi - done - done - done - else - PGSQL_INCLUDE="`$PG_CONFIG --includedir`" - PGSQL_LIBDIR="`$PG_CONFIG --libdir`" - fi - - old_LIBS=$LIBS - if test "$PGSQL_LIBDIR" != ""; then - LIBS="$LIBS -L$PGSQL_LIBDIR" - fi - - AC_CHECK_LIB(pq, PQconnectdb, [ - AC_CHECK_LIB(pq, PQescapeStringConn, [ - AC_DEFINE(HAVE_PQESCAPE_STRING_CONN,, [Define if libpq has PQescapeStringConn function]) - ]) - old_CPPFLAGS=$CPPFLAGS - if test "$PGSQL_INCLUDE" != ""; then - CPPFLAGS="$CPPFLAGS -I$PGSQL_INCLUDE" - fi - AC_CHECK_HEADER(libpq-fe.h, [ - if test "$PGSQL_INCLUDE" != ""; then - PGSQL_CFLAGS="$PGSQL_CFLAGS -I$PGSQL_INCLUDE" - fi - if test "$PGSQL_LIBDIR" != ""; then - PGSQL_LIBS="$PGSQL_LIBS -L$PGSQL_LIBDIR" - fi - 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]) - fi - ]) - CPPFLAGS=$old_CPPFLAGS - ], [ - if test $want_pgsql = yes; then - AC_ERROR([Can't build with PostgreSQL support: libpq not found]) - fi - ]) - LIBS=$old_LIBS -fi - -have_mysql=no -if test $want_mysql != no; then - AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, mysql_config, NO) - if test $MYSQL_CONFIG = NO; then - # based on code from PHP - MYSQL_LIBS="-lmysqlclient -lz -lm" - for i in /usr /usr/local /usr/local/mysql; do - for j in include include/mysql ""; do - if test -r "$i/$j/mysql.h"; then - MYSQL_INCLUDE="-I$i/$j" - fi - done - for j in lib lib/mysql lib64 lib64/mysql ""; do - if test -f "$i/$j/libmysqlclient.so" || test -f "$i/$j/libmysqlclient.a"; then - MYSQL_LIBS="-L$i/$j -lmysqlclient -lz -lm" - fi - done - done - else - MYSQL_INCLUDE="`$MYSQL_CONFIG --include`" - MYSQL_LIBS="`$MYSQL_CONFIG --libs`" - fi - - old_LIBS=$LIBS - if test "$MYSQL_LIBS" != ""; then - LIBS="$LIBS $MYSQL_LIBS" - fi - - mysql_lib="" - LIBS="$LIBS -lz -lm" - AC_CHECK_LIB(mysqlclient, mysql_init, [ - old_CPPFLAGS=$CPPFLAGS - if test "$MYSQL_INCLUDE" != ""; then - CPPFLAGS="$CPPFLAGS $MYSQL_INCLUDE" - fi - AC_CHECK_HEADER(mysql.h, [ - if test "$MYSQL_INCLUDE" != ""; then - MYSQL_CFLAGS="$MYSQL_CFLAGS $MYSQL_INCLUDE" - fi - - 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" - else - ssl_define="" - fi - AC_TRY_COMPILE([ - $ssl_define - #include - ], [ - mysql_set_ssl(0, 0, 0, 0, 0, 0); - ], [ - AC_DEFINE(HAVE_MYSQL_SSL_CIPHER,, [Define if your MySQL library supports setting cipher]) - - AC_TRY_COMPILE([ - $ssl_define - #include - ], [ - int i = MYSQL_OPT_SSL_VERIFY_SERVER_CERT; - ], [ - AC_DEFINE(HAVE_MYSQL_SSL_VERIFY_SERVER_CERT,, [Define if your MySQL library supports verifying the name in the SSL certificate]) - ]) - ]) - ]) - - have_mysql=yes - 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]) - fi - ]) - CPPFLAGS=$old_CPPFLAGS - ], [ - if test $want_mysql = yes; then - AC_ERROR([Can't build with MySQL support: libmysqlclient not found]) - fi - ]) - - if test $have_mysql != yes; then - MYSQL_LIBS= - MYSQL_CFLAGS= - fi - LIBS=$old_LIBS -fi - -if test $want_sqlite != no; then - AC_CHECK_LIB(sqlite3, sqlite3_open, [ - AC_CHECK_HEADER(sqlite3.h, [ - SQLITE_LIBS="$SQLITE_LIBS -lsqlite3" - - 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]) - fi - ]) - ], [ - if test $want_sqlite = yes; then - AC_ERROR([Can't build with SQLite support: libsqlite3 not found]) - fi - ]) -fi - -if test $want_cassandra != no; then - AC_CHECK_LIB(cassandra, cass_session_new, [ - AC_CHECK_HEADER(cassandra.h, [ - CASSANDRA_LIBS="$CASSANDRA_LIBS -lcassandra" - - AC_DEFINE(HAVE_CASSANDRA,, [Build with Cassandra support]) - found_sql_drivers="$found_sql_drivers cassandra" - ], [ - if test $want_cassandra = yes; then - AC_ERROR([Can't build with Cassandra support: cassandra.h not found]) - fi - ]) - ], [ - if test $want_cassandra = yes; then - AC_ERROR([Can't build with Cassandra support: libcassandra not found]) - fi - ]) -fi - -SQL_CFLAGS="$MYSQL_CFLAGS $PGSQL_CFLAGS $SQLITE_CFLAGS $CASSANDRA_CFLAGS" -if test "$want_sql" != "plugin"; then - SQL_LIBS="$MYSQL_LIBS $PGSQL_LIBS $SQLITE_LIBS $CASSANDRA_LIBS" -else - AC_DEFINE(SQL_DRIVER_PLUGINS,, [Build SQL drivers as plugins]) -fi -sql_drivers= -not_sql_drivers= - -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" - passdb="$passdb sql" - userdb="$userdb sql" -else - not_passdb="$not_passdb sql" - not_userdb="$not_userdb sql" -fi - -have_vpopmail=no -if test $want_vpopmail != no; then - vpop_etc="$vpopmail_home/etc" - AC_MSG_CHECKING([for vpopmail configuration at $vpop_etc/lib_deps]) - if ! test -f $vpop_etc/lib_deps; then - AC_MSG_RESULT(not found) - vpop_etc="$vpopmail_home" - AC_MSG_CHECKING([for vpopmail configuration at $vpop_etc/lib_deps]) - fi - if test -f $vpop_etc/lib_deps; then - AUTH_CFLAGS="$AUTH_CFLAGS `cat $vpop_etc/inc_deps` $CFLAGS" - AUTH_LIBS="$AUTH_LIBS `cat $vpop_etc/lib_deps`" - AC_DEFINE(USERDB_VPOPMAIL,, [Build with vpopmail support]) - AC_DEFINE(PASSDB_VPOPMAIL,, [Build with vpopmail support]) - AC_MSG_RESULT(found) - have_vpopmail=yes - else - AC_MSG_RESULT(not found) - if test $want_vpopmail = yes; then - AC_ERROR([Can't build with vpopmail support: $vpop_etc/lib_deps not found]) - fi - fi -fi - -if test $have_vpopmail = no; then - not_passdb="$not_passdb vpopmail" - not_userdb="$not_userdb vpopmail" -else - userdb="$userdb vpopmail" - passdb="$passdb vpopmail" -fi - -AC_CHECK_FUNC(crypt,, [ - AC_CHECK_LIB(crypt, crypt, [ - AUTH_LIBS="-lcrypt $AUTH_LIBS" - CRYPT_LIBS="-lcrypt" - ], [ - AC_MSG_ERROR([crypt() wasn't found]) - ]) -]) -AC_SUBST(CRYPT_LIBS) +dict_drivers="" + +dnl *** auth/userdb/dict things +DOVECOT_WANT_PREFETCH +DOVECOT_WANT_PASSWD +DOVECOT_WANT_SHADOW +DOVECOT_WANT_PAM +DOVECOT_WANT_CHECKPASSWORD +DOVECOT_WANT_BSDAUTH +DOVECOT_WANT_GSSAPI +DOVECOT_WANT_SIA +DOVECOT_WANT_LDAP +DOVECOT_WANT_DB +DOVECOT_WANT_CDB +DOVECOT_WANT_PGSQL +DOVECOT_WANT_MYSQL +DOVECOT_WANT_SQLITE +DOVECOT_WANT_CASSANDRA + +DOVECOT_SQL if test $have_modules = yes; then AC_DEFINE(HAVE_MODULES,, [Define if you have dynamic module support]) @@ -2361,41 +555,6 @@ if test $have_modules = yes; then AC_SUBST(MODULE_SUFFIX) fi -have_nss=no -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]) - fi - else - AC_CACHE_CHECK([for NSS support],i_cv_have_nss,[ - AC_TRY_COMPILE([ - #include - ], [ - enum nss_status status = NSS_STATUS_TRYAGAIN; - ], [ - i_cv_have_nss=yes - ], [ - i_cv_have_nss=no - ]) - ]) - if test $i_cv_have_nss = yes; then - AC_DEFINE(USERDB_NSS,, [Build with NSS module support]) - have_nss=yes - else - if test $want_nss = yes; then - AC_ERROR([Can't build with NSS support: nss.h not found or not usable]) - fi - fi - fi -fi - -if test $have_nss = no; then - not_userdb="$not_userdb nss" -else - userdb="$userdb nss" -fi - AC_SUBST(AUTH_CFLAGS) AC_SUBST(AUTH_LIBS) AC_SUBST(SQL_CFLAGS) @@ -2413,49 +572,9 @@ AC_SUBST(DICT_LIBS) AC_SUBST(CDB_LIBS) AC_SUBST(dict_drivers) -dnl ** -dnl ** Endianess -dnl ** - -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__,[ - AC_TRY_COMPILE([ - #if !(__BIG_ENDIAN__ || __LITTLE_ENDIAN__) - #error nope - #endif - ], [ - ], [ - 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]) -else - AC_C_BIGENDIAN -fi - -dnl ** -dnl ** IPv6 support -dnl ** +DOVECOT_ENDIAN -AC_MSG_CHECKING([for IPv6]) -AC_CACHE_VAL(i_cv_type_in6_addr, -[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include -#include -#include ]], -[[struct in6_addr i;]])], -[i_cv_type_in6_addr=yes], -[i_cv_type_in6_addr=no])]) -AC_MSG_RESULT($i_cv_type_in6_addr) -if test $i_cv_type_in6_addr = no; then - AC_ERROR([Can't build without IPv6 support.]) -fi +DOVECOT_IPV6 dnl ** dnl ** storage classes @@ -2598,99 +717,18 @@ dnl ** Plugins dnl ** COMPRESS_LIBS= -if test "$want_zlib" != "no"; then - AC_CHECK_HEADER(zlib.h, [ - have_zlib=yes - have_compress_lib=yes - 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]) - fi - ]) -fi -if test "$want_bzlib" != "no"; then - AC_CHECK_HEADER(bzlib.h, [ - AC_CHECK_LIB(bz2, BZ2_bzdopen, [ - have_bzlib=yes - have_compress_lib=yes - 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]) - fi - ]) - ], [ - if test "$want_bzlib" = "yes"; then - AC_ERROR([Can't build with bzlib support: bzlib.h not found]) - fi - ]) -fi +DOVECOT_WANT_ZLIB +DOVECOT_WANT_BZLIB +DOVECOT_WANT_LZMA +DOVECOT_WANT_LZ4 -if test "$want_lzma" != "no"; then - AC_CHECK_HEADER(lzma.h, [ - AC_CHECK_LIB(lzma, lzma_stream_decoder, [ - have_lzma=yes - have_compress_lib=yes - AC_DEFINE(HAVE_LZMA,, [Define if you have lzma library]) - COMPRESS_LIBS="$COMPRESS_LIBS -llzma" - ], [ - if test "$want_lzma" = "yes"; then - AC_ERROR([Can't build with lzma support: liblzma not found]) - fi - ]) - ], [ - if test "$want_lzma" = "yes"; then - AC_ERROR([Can't build with lzma support: lzma.h not found]) - fi - ]) -fi -AC_SUBST(COMPRESS_LIBS) - -if test "$want_lz4" != "no"; then - AC_CHECK_HEADER(lz4.h, [ - AC_CHECK_LIB(lz4, LZ4_compress, [ - have_lz4=yes - have_compress_lib=yes - AC_DEFINE(HAVE_LZ4,, [Define if you have lz4 library]) - COMPRESS_LIBS="$COMPRESS_LIBS -llz4" - ], [ - if test "$want_lz4" = "yes"; then - AC_ERROR([Can't build with lz4 support: liblz4 not found]) - fi - ]) - ], [ - if test "$want_lz4" = "yes"; then - AC_ERROR([Can't build with lz4 support: lz4.h not found]) - fi - ]) -fi AC_SUBST(COMPRESS_LIBS) AM_CONDITIONAL(BUILD_ZLIB_PLUGIN, test "$have_compress_lib" = "yes") -RPCGEN=${RPCGEN-rpcgen} -if ! $RPCGEN -c /dev/null > /dev/null; then - RPCGEN= -fi -AC_SUBST(RPCGEN) - -have_rquota=no -if test -f /usr/include/rpcsvc/rquota.x && test -n "$RPCGEN"; then - AC_DEFINE(HAVE_RQUOTA,, [Define if you wish to retrieve quota of NFS mounted mailboxes]) - have_rquota=yes -fi -AM_CONDITIONAL(HAVE_RQUOTA, test "$have_rquota" = "yes") - -QUOTA_LIBS="" -AC_SEARCH_LIBS(quota_open, quota, [ - AC_DEFINE(HAVE_QUOTA_OPEN,, [Define if you have quota_open()]) - QUOTA_LIBS="-lquota" -]) -AC_SUBST(QUOTA_LIBS) +DOVECOT_RPCGEN +DOVECOT_QUOTA dnl dnl ** Full text search @@ -2699,94 +737,12 @@ dnl fts=" squat" not_fts="" -have_solr=no -if test "$want_solr" != "no"; then - dnl need libexpat - AC_CHECK_LIB(expat, XML_Parse, [ - AC_CHECK_HEADER(expat.h, [ - have_solr=yes - fts="$fts solr" - ], [ - if test $want_solr = yes; then - AC_ERROR([Can't build with Solr support: expat.h not found]) - fi - ]) - ], [ - if test $want_solr = yes; then - AC_ERROR([Can't build with Solr support: libexpat not found]) - fi - ]) -fi -AM_CONDITIONAL(BUILD_SOLR, test "$have_solr" = "yes") - -have_lucene=no -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" - ]) - have_lucene=yes - fts="$fts lucene" -fi +DOVECOT_WANT_SOLR +DOVECOT_WANT_CLUCENE +DOVECOT_WANT_STEMMER +DOVECOT_WANT_TEXTCAT -if test $want_stemmer != no; then - AC_CHECK_LIB(stemmer, sb_stemmer_new, [ - have_fts_stemmer=yes - AC_DEFINE(HAVE_FTS_STEMMER,, [Define if you want stemming support for FTS]) - ], [ - if test $want_stemmer = yes; then - AC_ERROR([Can't build with stemmer support: libstemmer not found]) - fi - ]) -fi -AM_CONDITIONAL(BUILD_FTS_STEMMER, test "$have_fts_stemmer" = "yes") - -if test $want_textcat != no; then - if test "$PKG_CONFIG" != "" && $PKG_CONFIG --exists libexttextcat 2>/dev/null; then - PKG_CHECK_MODULES(LIBEXTTEXTCAT, libexttextcat) - TEXTCAT_DATADIR=`$PKG_CONFIG --variable=pkgdatadir libexttextcat` - AC_DEFINE(HAVE_FTS_EXTTEXTCAT,, [Define if you want exttextcat support for FTS]) - have_fts_exttextcat=yes - # Debian Wheezy workaround - LIBEXTTEXTCAT_CFLAGS include path is wrong: - AC_CHECK_HEADERS(libexttextcat/textcat.h) - else - AC_CHECK_LIB(exttextcat, special_textcat_Init, [ - have_fts_exttextcat=yes - AC_CHECK_HEADERS(libexttextcat/textcat.h) - LIBEXTTEXTCAT_LIBS=-lexttextcat - AC_DEFINE(HAVE_FTS_EXTTEXTCAT,, [Define if you want exttextcat support for FTS]) - TEXTCAT_DATADIR="/usr/share/libexttextcat" - AC_SUBST(LIBEXTTEXTCAT_LIBS) - ], [ - AC_CHECK_LIB(textcat, special_textcat_Init, [ - have_fts_textcat=yes - TEXTCAT_DATADIR="/usr/share/libtextcat" - AC_CHECK_HEADERS(libtextcat/textcat.h) - ]) - ]) - if test $want_textcat = yes && test "$have_fts_exttextcat" != yes && test "$have_fts_textcat" != yes; then - AC_ERROR([Can't build with textcat support: libtextcat or libexttextcat not found]) - fi - fi - if test "$have_fts_exttextcat" = yes || test "$have_fts_textcat" = yes; then - AC_DEFINE(HAVE_FTS_TEXTCAT,, [Define if you want textcat support for FTS]) - AC_DEFINE_UNQUOTED(TEXTCAT_DATADIR, "$TEXTCAT_DATADIR", [Points to textcat pkgdatadir containing the language files]) - fi -fi -AM_CONDITIONAL(BUILD_FTS_TEXTCAT, test "$have_fts_textcat" = "yes") -AM_CONDITIONAL(BUILD_FTS_EXTTEXTCAT, test "$have_fts_exttextcat" = "yes") - -if test "$want_icu" != "no"; then - if test "$PKG_CONFIG" != "" && $PKG_CONFIG --exists icu-i18n 2>/dev/null; then - PKG_CHECK_MODULES(LIBICU, icu-i18n) - have_icu=yes - AC_DEFINE(HAVE_LIBICU,, [Define if you want ICU normalization support for FTS]) - elif test "$want_icu" = "yes"; then - AC_ERROR([Can't build with libicu support: libicu-i18n not found]) - fi -fi -AM_CONDITIONAL(BUILD_LIBICU, test "$have_icu" = "yes") +DOVECOT_WANT_ICU if test $have_lucene = no; then not_fts="$not_fts lucene" diff --git a/m4/ac_checktype2.m4 b/m4/ac_checktype2.m4 new file mode 100644 index 0000000000..397c99d089 --- /dev/null +++ b/m4/ac_checktype2.m4 @@ -0,0 +1,8 @@ +AC_DEFUN([AC_CHECKTYPE2], [ + AC_MSG_CHECKING([for $1]) + AC_CACHE_VAL(i_cv_type_$1, + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + $2]], [[$1 t;]])],[i_cv_type_$1=yes],[i_cv_type_$1=no])]) + AC_MSG_RESULT($i_cv_type_$1) +]) diff --git a/m4/ac_typeof.m4 b/m4/ac_typeof.m4 new file mode 100644 index 0000000000..0a2a7e0d42 --- /dev/null +++ b/m4/ac_typeof.m4 @@ -0,0 +1,121 @@ +AC_DEFUN([AC_TYPEOF], [ + dnl * first check if we can get the size with redefining typedefs + + order="$2" + if test "$2" = ""; then + order="int long long-long" + fi + + result="" + visible="unknown" + 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 + old_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + + for type in $order; do + case "$type" in + int) + fmt="%d" + ;; + unsigned-int) + fmt="%u" + ;; + long) + fmt="%ld" + ;; + unsigned-long) + fmt="%lu" + ;; + long-long) + fmt="%lld" + ;; + unsigned-long-long) + fmt="%llu" + ;; + *) + fmt="" + ;; + esac + + if test "$fmt" != ""; then + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + ]], [[ + printf("$fmt", ($1)0); + ]])],[ + if test "$result" != ""; then + dnl * warning check isn't working + result="" + visible="unknown" + break + fi + result="`echo $type|sed 's/-/ /g'`" + visible="$result" + ],[]) + fi + done + CFLAGS="$old_CFLAGS" + fi + + if test "$result" = ""; then + for type in $order; do + type="`echo $type|sed 's/-/ /g'`" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + typedef $type $1; + ]], [[]])],[ + if test "$result" != ""; then + dnl * compiler allows redefining to anything + result="" + visible="unknown" + break + fi + result="$type" + visible="$type" + ],[]) + done + fi + + if test "$result" = ""; then + dnl * check with sizes + + dnl * older autoconfs don't include sys/types.h, so do it manually + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + #include + int main() { + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof($1)); + exit(0); + } + ]])],[ + size=`cat conftestval` + rm -f conftestval + + for type in $order; do + 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)" + break + fi + done + if test "$result" = ""; then + result=unknown + visible="`expr $size \* 8`bit (unknown type)" + fi + ],[],[]) + fi + i_cv_typeof_$1=$result/$visible + ]) + + typeof_$1=`echo $i_cv_typeof_$1 | sed s,/.*$,,` + visible=`echo $i_cv_typeof_$1 | sed s,^.*/,,` + AC_MSG_RESULT($visible) +]) + diff --git a/m4/blockdev.m4 b/m4/blockdev.m4 new file mode 100644 index 0000000000..e44589e49e --- /dev/null +++ b/m4/blockdev.m4 @@ -0,0 +1,41 @@ +dnl * Check if statvfs() can be used to find out block device for files +AC_DEFUN([DOVECOT_FILE_BLOCKDEV], [ + AC_CACHE_CHECK([if statvfs.f_mntfromname exists],i_cv_have_statvfs_f_mntfromname,[ + AC_TRY_COMPILE([ + #include + #include + ], [ + struct statvfs buf; + char *p = buf.f_mntfromname; + + statvfs(".", &buf); + ], [ + i_cv_have_statvfs_f_mntfromname=yes + ], [ + i_cv_have_statvfs_f_mntfromname=no + ]) + ]) + if test $i_cv_have_statvfs_f_mntfromname = yes; then + AC_DEFINE(HAVE_STATVFS_MNTFROMNAME,, [Define if you have statvfs.f_mntfromname]) + fi + + dnl * Check if statfs() can be used to find out block device for files + AC_CACHE_CHECK([if statfs.f_mntfromname exists],i_cv_have_statfs_f_mntfromname,[ + AC_TRY_COMPILE([ + #include + #include + ], [ + struct statfs buf; + char *p = buf.f_mntfromname; + + statfs(".", &buf); + ], [ + i_cv_have_statfs_f_mntfromname=yes + ], [ + i_cv_have_statfs_f_mntfromname=no + ]) + ]) + if test $i_cv_have_statfs_f_mntfromname = yes; then + AC_DEFINE(HAVE_STATFS_MNTFROMNAME,, [Define if you have statfs.f_mntfromname]) + fi +]) diff --git a/m4/c99_vsnprintf.m4 b/m4/c99_vsnprintf.m4 new file mode 100644 index 0000000000..e64208393f --- /dev/null +++ b/m4/c99_vsnprintf.m4 @@ -0,0 +1,29 @@ +dnl *** +dnl *** C99 vsnprintf()? +dnl *** + +AC_DEFUN([DOVECOT_C99_VSNPRINTF], [ + AC_CACHE_CHECK([for C99 vsnprintf()],i_cv_c99_vsnprintf,[ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + #include + static int f(const char *fmt, ...) { + va_list args; + char buf[13]; + int ret; + + va_start(args, fmt); + ret = vsnprintf(buf, 11, fmt, args) != 12 || buf[11-1] != '\0'; + va_end(args); + return ret; + } + int main() { + return f("hello %s%d", "world", 1); + }]])], + [i_cv_c99_vsnprintf=yes], + [i_cv_c99_vsnprintf=no]) + ]) + if test $i_cv_c99_vsnprintf = no; then + AC_DEFINE(HAVE_OLD_VSNPRINTF,, [Define if you don't have C99 compatible vsnprintf() call]) + fi +]) diff --git a/m4/cc_clang.m4 b/m4/cc_clang.m4 new file mode 100644 index 0000000000..f1198d768e --- /dev/null +++ b/m4/cc_clang.m4 @@ -0,0 +1,7 @@ +dnl * clang check +AC_DEFUN([CC_CLANG],[ +have_clang=no +if $CC -dM -E -x c /dev/null | grep __clang__ > /dev/null 2>&1; then + have_clang=yes +fi +]) diff --git a/m4/cflags.m4 b/m4/cflags.m4 new file mode 100644 index 0000000000..cd1ecbf301 --- /dev/null +++ b/m4/cflags.m4 @@ -0,0 +1,51 @@ +dnl * gcc specific options +AC_DEFUN([DOVECOT_CFLAGS],[ + if test "x$ac_cv_c_compiler_gnu" = "xyes"; then + # -Wcast-qual -Wcast-align -Wconversion -Wunreachable-code # too many warnings + # -Wstrict-prototypes -Wredundant-decls # may give warnings in some systems + # -Wmissing-format-attribute -Wmissing-noreturn -Wwrite-strings # a couple of warnings + CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast" + + if test "$have_clang" = "yes"; then + AC_TRY_COMPILE([ + #if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 3) + # error new clang + #endif + ],,,[ + # clang 3.3+ unfortunately this gives warnings with hash.h + CFLAGS="$CFLAGS -Wno-duplicate-decl-specifier" + ]) + else + # This is simply to avoid warning when building strftime() wrappers.. + CFLAGS="$CFLAGS -fno-builtin-strftime" + fi + + AC_TRY_COMPILE([ + #if __GNUC__ < 4 + # error old gcc + #endif + ],,[ + # gcc4 + CFLAGS="$CFLAGS -Wstrict-aliasing=2" + ]) + + # Use std=gnu99 if we have new enough gcc + old_cflags=$CFLAGS + CFLAGS="-std=gnu99" + AC_TRY_COMPILE([ + ],, [ + CFLAGS="$CFLAGS $old_cflags" + ], [ + CFLAGS="$old_cflags" + ]) + + fi + if test "$have_clang" = "yes"; then + # clang specific options + if test "$want_devel_checks" = "yes"; then + # FIXME: enable once md[45], sha[12] can be compiled without + #CFLAGS="$CFLAGS -fsanitize=integer,undefined -ftrapv" + : + fi + fi +]) diff --git a/m4/clock_gettime.m4 b/m4/clock_gettime.m4 new file mode 100644 index 0000000000..d93b680cae --- /dev/null +++ b/m4/clock_gettime.m4 @@ -0,0 +1,5 @@ +AC_DEFUN([DOVECOT_CLOCK_GETTIME], [ + AC_SEARCH_LIBS(clock_gettime, rt, [ + AC_DEFINE(HAVE_CLOCK_GETTIME,, [Define if you have the clock_gettime function]) + ]) +]) diff --git a/m4/crypt.m4 b/m4/crypt.m4 new file mode 100644 index 0000000000..5aa1e14832 --- /dev/null +++ b/m4/crypt.m4 @@ -0,0 +1,11 @@ +AC_DEFUN([DOVECOT_CRYPT], [ + AC_CHECK_FUNC(crypt,, [ + AC_CHECK_LIB(crypt, crypt, [ + AUTH_LIBS="-lcrypt $AUTH_LIBS" + CRYPT_LIBS="-lcrypt" + ], [ + AC_MSG_ERROR([crypt() wasn't found]) + ]) + ]) + AC_SUBST(CRYPT_LIBS) +]) diff --git a/m4/crypt_xpg6.m4 b/m4/crypt_xpg6.m4 new file mode 100644 index 0000000000..9a86f46e55 --- /dev/null +++ b/m4/crypt_xpg6.m4 @@ -0,0 +1,23 @@ +dnl * Check for crypt() if unistd.h compiles with _XOPEN_SOURCE + _XPG6 +dnl * Add other macros there too "just in case". +AC_DEFUN([DOVECOT_CRYPT_XPG6], [ + AC_CACHE_CHECK([if we should use _XPG6 macro for crypt()],i_cv_use_xpg6_crypt,[ + AC_TRY_COMPILE([ + #define _XOPEN_SOURCE 4 + #define _XOPEN_SOURCE_EXTENDED 1 + #define _XOPEN_VERSION 4 + #define _XPG4_2 + #define _XPG6 + #include + ], [ + crypt("a", "b"); + ], [ + i_cv_use_xpg6_crypt=yes + ], [ + i_cv_use_xpg6_crypt=no + ]) + ]) + if test $i_cv_use_xpg6_crypt = yes; then + AC_DEFINE(CRYPT_USE_XPG6,, [Define if _XPG6 macro is needed for crypt()]) + fi +]) diff --git a/m4/dbqlk.m4 b/m4/dbqlk.m4 new file mode 100644 index 0000000000..d030f8fa14 --- /dev/null +++ b/m4/dbqlk.m4 @@ -0,0 +1,39 @@ +dnl * Check if we have struct dqblk.dqb_curblocks +AC_DEFUN([DOVECOT_DQBLK_CURBLOCKS], [ + AC_CACHE_CHECK([if struct dqblk.dqb_curblocks exists],i_cv_have_dqblk_dqb_curblocks,[ + AC_TRY_COMPILE([ + #include + #include "$srcdir/src/plugins/quota/quota-fs.h" + ], [ + struct dqblk dqblk; + unsigned int x = dqblk.dqb_curblocks; + ], [ + i_cv_have_dqblk_dqb_curblocks=yes + ], [ + i_cv_have_dqblk_dqb_curblocks=no + ]) + ]) + if test $i_cv_have_dqblk_dqb_curblocks = yes; then + AC_DEFINE(HAVE_STRUCT_DQBLK_CURBLOCKS,, [Define if struct sqblk.dqb_curblocks exists]) + fi +]) + +dnl * Check if we have struct dqblk.dqb_curspace +AC_DEFUN([DOVECOT_DQBLK_CURSPACE], [ + AC_CACHE_CHECK([if struct dqblk.dqb_curspace exists],i_cv_have_dqblk_dqb_curspace,[ + AC_TRY_COMPILE([ + #include + #include "$srcdir/src/plugins/quota/quota-fs.h" + ], [ + struct dqblk dqblk; + unsigned int x = dqblk.dqb_curspace; + ], [ + i_cv_have_dqblk_dqb_curspace=yes + ], [ + i_cv_have_dqblk_dqb_curspace=no + ]) + ]) + if test $i_cv_have_dqblk_dqb_curspace = yes; then + AC_DEFINE(HAVE_STRUCT_DQBLK_CURSPACE,, [Define if struct sqblk.dqb_curspace exists]) + fi +]) diff --git a/m4/dirent_dtype.m4 b/m4/dirent_dtype.m4 new file mode 100644 index 0000000000..a5740404fb --- /dev/null +++ b/m4/dirent_dtype.m4 @@ -0,0 +1,11 @@ +AC_DEFUN([DOVECOT_DIRENT_DTYPE], [ + dnl * Do we have struct dirent->d_type + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + ]], [[ + struct dirent d; + d.d_type = DT_DIR; + ]])],[ + AC_DEFINE(HAVE_DIRENT_D_TYPE,, [Define if you have struct dirent->d_type]) + ],[]) +]) diff --git a/dovecot.m4 b/m4/dovecot.m4 similarity index 100% rename from dovecot.m4 rename to m4/dovecot.m4 diff --git a/m4/endian.m4 b/m4/endian.m4 new file mode 100644 index 0000000000..a1766ff5f4 --- /dev/null +++ b/m4/endian.m4 @@ -0,0 +1,25 @@ +dnl ** +dnl ** Endianess +dnl ** + +dnl At least Apple's gcc supports __BIG_ENDIAN__ and __LITTLE_ENDIAN__ +dnl defines. Use them if possible to allow cross-compiling. +AC_DEFUN([DOVECOT_ENDIAN], [ + AC_CACHE_CHECK([if __BIG_ENDIAN__ or __LITTLE_ENDIAN__ is defined],i_cv_have___big_endian__,[ + AC_TRY_COMPILE([ + #if !(__BIG_ENDIAN__ || __LITTLE_ENDIAN__) + #error nope + #endif + ], [ + ], [ + 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]) + else + AC_C_BIGENDIAN + fi +]) diff --git a/m4/fd_passing.m4 b/m4/fd_passing.m4 new file mode 100644 index 0000000000..79a44143c7 --- /dev/null +++ b/m4/fd_passing.m4 @@ -0,0 +1,92 @@ +dnl * see if fd passing works +AC_DEFUN([DOVECOT_FD_PASSING], [ + AC_CACHE_CHECK([whether fd passing works],i_cv_fd_passing,[ + for i in 1 2; do + old_cflags="$CFLAGS" + CFLAGS="$CFLAGS -I$srcdir/src/lib $srcdir/src/lib/fdpass.c" + if test $i = 2; then + CFLAGS="$CFLAGS -DBUGGY_CMSG_MACROS" + fi + + AC_TRY_RUN([ + #include + #include + #include + #include + #include + #include + #include "fdpass.h" + + int nopen(void) + { + int i, n; + struct stat sb; + for (i = n = 0; i < 256; i++) + if (fstat(i, &sb) == 0) n++; + return n; + } + int main(void) + { + int fd[2], send_fd, recv_fd, status, n1, n2; + struct stat st, st2; + char data; + + send_fd = creat("conftest.fdpass", 0600); + if (send_fd == -1) return 2; + unlink("conftest.fdpass"); + if (fstat(send_fd, &st) < 0) return 2; + if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) return 2; + n1 = nopen(); + + switch (fork()) { + case -1: + return 2; + case 0: + alarm(1); + if (fd_send(fd[0], send_fd, &data, 1) != 1) return 2; + return 0; + default: + alarm(2); + if (wait(&status) == -1) + return 2; + if (status != 0) + return status; + 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 + was received */ + n2 = nopen(); + return st.st_ino == st2.st_ino && n2 == n1 + 1 ? 0 : 1; + } + } + ], [ + CFLAGS=$old_cflags + if test $i = 2; then + i_cv_fd_passing=buggy_cmsg_macros + else + i_cv_fd_passing=yes + fi + break + ], [ + dnl no, try with BUGGY_CMSG_MACROS + CFLAGS=$old_cflags + i_cv_fd_passing=no + ]) + done + ]); + + case "$host_os" in + darwin[[1-9]].*) + if test "$i_cv_fd_passing" = "yes"; then + i_cv_fd_passing=buggy_cmsg_macros + fi + ;; + esac + + if test $i_cv_fd_passing = buggy_cmsg_macros; then + AC_DEFINE(BUGGY_CMSG_MACROS,, [Define if you have buggy CMSG macros]) + fi + if test $i_cv_fd_passing = no; then + AC_ERROR([fd passing is required for Dovecot to work]) + fi +]) diff --git a/m4/fdatasync.m4 b/m4/fdatasync.m4 new file mode 100644 index 0000000000..bb17e94e75 --- /dev/null +++ b/m4/fdatasync.m4 @@ -0,0 +1,5 @@ +AC_DEFUN([DOVECOT_FDATASYNC], [ + AC_SEARCH_LIBS(fdatasync, rt, [ + AC_DEFINE(HAVE_FDATASYNC,, [Define if you have fdatasync()]) + ]) +]) diff --git a/m4/flexible_array_member.m4 b/m4/flexible_array_member.m4 new file mode 100644 index 0000000000..10fea3b433 --- /dev/null +++ b/m4/flexible_array_member.m4 @@ -0,0 +1,25 @@ +dnl Our implementation of AC_C_FLEXIBLE_ARRAY_MEMBER. +dnl Use it until autoconf 2.61+ becomes more widely used +AC_DEFUN([DOVECOT_C_FLEXIBLE_ARRAY_MEMBER], [ + AC_CACHE_CHECK([if we can use C99-like flexible array members],i_cv_c99_flex_arrays,[ + AC_TRY_COMPILE([ + struct foo { + int x; + char y[]; + }; + ], [ + struct foo foo; + ], [ + i_cv_c99_flex_arrays=yes + ], [ + i_cv_c99_flex_arrays=no + ]) + ]) + + if test $i_cv_c99_flex_arrays = yes; then + flexible_value= + else + flexible_value=1 + fi + AC_DEFINE_UNQUOTED(FLEXIBLE_ARRAY_MEMBER, $flexible_value, [How to define flexible array members in structs]) +]) diff --git a/m4/gc.m4 b/m4/gc.m4 new file mode 100644 index 0000000000..473993ced4 --- /dev/null +++ b/m4/gc.m4 @@ -0,0 +1,17 @@ +dnl ** +dnl ** Garbage Collector +dnl ** + +AC_DEFUN([DOVECOT_GC], [ + if test $want_gc != no; then + AC_CHECK_LIB(gc, GC_malloc, [ + AC_CHECK_HEADERS(gc/gc.h gc.h) + AC_DEFINE(USE_GC,, [Define if you want to use Boehm GC]) + LIBS="$LIBS -lgc" + ], [ + if test $want_gc = yes; then + AC_ERROR([Can't build with GC: libgc not found]) + fi + ]) + fi +]) diff --git a/m4/glibc.m4 b/m4/glibc.m4 new file mode 100644 index 0000000000..5d722aab5b --- /dev/null +++ b/m4/glibc.m4 @@ -0,0 +1,49 @@ +AC_DEFUN([DOVECOT_GLIBC], [ + AC_CACHE_CHECK([whether we have glibc],i_cv_have_glibc,[ + AC_TRY_COMPILE([ + #include + #ifdef __GLIBC__ + we have glibc + #endif + ],, [ + i_cv_have_glibc=no + ], [ + i_cv_have_glibc=yes + ]) + ]) + if test "$i_cv_have_glibc" = "yes"; then + AC_DEFINE(PREAD_WRAPPERS,, [Define if pread/pwrite needs _XOPEN_SOURCE 500]) + fi + 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,[ + AC_TRY_RUN([ + #define _XOPEN_SOURCE 600 + #include + #include + #include + #include + #if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 7) + possibly broken posix_fallocate + #endif + int main() { + int fd = creat("conftest.temp", 0600); + int ret; + if (fd == -1) { + perror("creat()"); + return 2; + } + ret = posix_fallocate(fd, 1024, 1024) < 0 ? 1 : 0; + unlink("conftest.temp"); + return ret; + } + ], [ + 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()]) + fi +]) diff --git a/m4/gmtime_max.m4 b/m4/gmtime_max.m4 new file mode 100644 index 0000000000..1613cb25c2 --- /dev/null +++ b/m4/gmtime_max.m4 @@ -0,0 +1,42 @@ +dnl * how large time_t values does gmtime() accept? +AC_DEFUN([DOVECOT_GMTIME_MAX], [ + AC_CACHE_CHECK([how large time_t values gmtime() accepts],i_cv_gmtime_max_time_t,[ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + #include + int main() { + FILE *f; + int bits; + + for (bits = 1; bits < sizeof(time_t)*8; bits++) { + time_t t = ((time_t)1 << bits) - 1; + if (gmtime(&t) == NULL) { + bits--; + break; + } + } + if (bits > 40) { + /* 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. */ + bits = 40; + } + + f = fopen("conftest.temp", "w"); + if (f == NULL) { + perror("fopen()"); + return 1; + } + fprintf(f, "%d", bits); + fclose(f); + return 0; + } + ]])],[ + i_cv_gmtime_max_time_t=`cat conftest.temp` + rm -f conftest.temp + ], [ + 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]) +]) diff --git a/m4/gmtime_tm_gmtoff.m4 b/m4/gmtime_tm_gmtoff.m4 new file mode 100644 index 0000000000..57df6aeb1e --- /dev/null +++ b/m4/gmtime_tm_gmtoff.m4 @@ -0,0 +1,14 @@ +dnl * do we have tm_gmtoff +AC_DEFUN([DOVECOT_TM_GMTOFF], [ + AC_MSG_CHECKING([for tm_gmtoff]) + AC_CACHE_VAL(i_cv_field_tm_gmtoff, + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include ]], + [[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]) + fi + AC_MSG_RESULT($i_cv_field_tm_gmtoff) +]) diff --git a/m4/ioloop.m4 b/m4/ioloop.m4 new file mode 100644 index 0000000000..0f7dde05e6 --- /dev/null +++ b/m4/ioloop.m4 @@ -0,0 +1,53 @@ +dnl * I/O loop function +AC_DEFUN([DOVECOT_IOLOOP], [ + have_ioloop=no + + if test "$ioloop" = "best" || test "$ioloop" = "epoll"; then + AC_CACHE_CHECK([whether we can use epoll],i_cv_epoll_works,[ + AC_TRY_RUN([ + #include + + int main() + { + return epoll_create(5) < 1; + } + ], [ + i_cv_epoll_works=yes + ], [ + i_cv_epoll_works=no + ]) + ]) + if test $i_cv_epoll_works = yes; then + AC_DEFINE(IOLOOP_EPOLL,, [Implement I/O loop with Linux 2.6 epoll()]) + have_ioloop=yes + ioloop=epoll + else + if test "$ioloop" = "epoll" ; then + AC_MSG_ERROR([epoll ioloop requested but epoll_create() is not available]) + fi + fi + fi + + 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()]) + ioloop=kqueue + have_ioloop=yes + elif test "$ioloop" = "kqueue"; then + AC_MSG_ERROR([kqueue ioloop requested but kqueue() is not available]) + fi + fi + + if test "$ioloop" = "best" || test "$ioloop" = "poll"; then + AC_CHECK_FUNC(poll, [ + AC_DEFINE(IOLOOP_POLL,, [Implement I/O loop with poll()]) + ioloop=poll + have_ioloop=yes + ]) + fi + + if test "$have_ioloop" = "no"; then + AC_DEFINE(IOLOOP_SELECT,, [Implement I/O loop with select()]) + ioloop="select" + fi +]) diff --git a/m4/iovec.m4 b/m4/iovec.m4 new file mode 100644 index 0000000000..a1f3b48558 --- /dev/null +++ b/m4/iovec.m4 @@ -0,0 +1,17 @@ +dnl * do we have struct iovec +AC_DEFUN([DOVECOT_IOVEC], [ + AC_MSG_CHECKING([for struct iovec]) + AC_CACHE_VAL(i_cv_struct_iovec, + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + #include ]], + [[struct iovec *iovec;]])], + [i_cv_struct_iovec=yes], + [i_cv_struct_iovec=no])]) + + if test $i_cv_struct_iovec = yes; then + AC_DEFINE(HAVE_STRUCT_IOVEC,, [Define if you have struct iovec]) + fi + AC_MSG_RESULT($i_cv_struct_iovec) +]) diff --git a/m4/ipv6.m4 b/m4/ipv6.m4 new file mode 100644 index 0000000000..4e6ab46d01 --- /dev/null +++ b/m4/ipv6.m4 @@ -0,0 +1,25 @@ +dnl ** +dnl ** IPv6 support +dnl ** + +AC_DEFUN([DOVECOT_IPV6], [ + have_ipv6=no + AC_MSG_CHECKING([for IPv6]) + AC_CACHE_VAL(i_cv_type_in6_addr, + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + #include + #include + #include ]], + [[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]) + have_ipv6=yes + else + AC_ERROR([Can't build without IPv6 support.]) + fi + AC_MSG_RESULT($i_cv_type_in6_addr) +]) diff --git a/m4/libcap.m4 b/m4/libcap.m4 new file mode 100644 index 0000000000..b4ab9cc133 --- /dev/null +++ b/m4/libcap.m4 @@ -0,0 +1,13 @@ +AC_DEFUN([DOVECOT_LIBCAP],[ + if test $want_libcap != no; then + AC_CHECK_LIB(cap, cap_init, [ + AC_DEFINE(HAVE_LIBCAP,, [libcap is installed for cap_init()]) + LIBCAP="-lcap" + AC_SUBST(LIBCAP) + ], [ + if test "$want_libcap" = "yes"; then + AC_ERROR([Can't build with libcap support: libcap not found]) + fi + ]) + fi +]) diff --git a/m4/libwrap.m4 b/m4/libwrap.m4 new file mode 100644 index 0000000000..895c067b64 --- /dev/null +++ b/m4/libwrap.m4 @@ -0,0 +1,38 @@ +AC_DEFUN([DOVECOT_LIBWRAP], [ + have_libwrap=no + if test $want_libwrap != no; then + AC_CHECK_HEADER(tcpd.h, [ + old_LIBS=$LIBS + + AC_CACHE_CHECK([whether we have libwrap],i_cv_have_libwrap,[ + AC_TRY_COMPILE([ + #include + int allow_severity = 0; + int deny_severity = 0; + ], [ + request_init((void *)0); + ], [ + i_cv_have_libwrap=yes + ], [ + i_cv_have_libwrap=no + ]) + ]) + if test $i_cv_have_libwrap = yes; then + AC_DEFINE(HAVE_LIBWRAP,, [Define if you have libwrap]) + LIBWRAP_LIBS=-lwrap + AC_SUBST(LIBWRAP_LIBS) + have_libwrap=yes + else + if test "$want_libwrap" = "yes"; then + AC_ERROR([Can't build with libwrap support: libwrap not found]) + fi + fi + LIBS=$old_LIBS + ], [ + if test "$want_libwrap" = "yes"; then + AC_ERROR([Can't build with libwrap support: tcpd.h not found]) + fi + ]) + fi + AM_CONDITIONAL(TCPWRAPPERS, test "$have_libwrap" = "yes") +]) diff --git a/m4/linux_mremap.m4 b/m4/linux_mremap.m4 new file mode 100644 index 0000000000..7eb0cce41c --- /dev/null +++ b/m4/linux_mremap.m4 @@ -0,0 +1,19 @@ +dnl * Linux compatible mremap() +AC_DEFUN([DOVECOT_LINUX_MREMAP], [ + AC_CACHE_CHECK([Linux compatible mremap()],i_cv_have_linux_mremap,[ + AC_TRY_LINK([ + #include + #define __USE_GNU + #include + ], [ + 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()]) + fi +]) diff --git a/m4/mmap_write.m4 b/m4/mmap_write.m4 new file mode 100644 index 0000000000..7679d91f40 --- /dev/null +++ b/m4/mmap_write.m4 @@ -0,0 +1,43 @@ +dnl * If mmap() plays nicely with write() +AC_DEFUN([DOVECOT_MMAP_WRITE], [ + AC_CACHE_CHECK([whether shared mmaps get updated by write()s],i_cv_mmap_plays_with_write,[ + AC_TRY_RUN([ + #include + #include + #include + #include + #include + #include + int main() { + /* return 0 if we're signed */ + int f = open("conftest.mmap", O_RDWR|O_CREAT|O_TRUNC, 0600); + void *mem; + if (f == -1) { + perror("open()"); + return 1; + } + unlink("conftest.mmap"); + + write(f, "1", 2); + mem = mmap(NULL, 2, PROT_READ|PROT_WRITE, MAP_SHARED, f, 0); + if (mem == MAP_FAILED) { + perror("mmap()"); + return 1; + } + strcpy(mem, "2"); + msync(mem, 2, MS_SYNC); + lseek(f, 0, SEEK_SET); + write(f, "3", 2); + + 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]) + fi +]) diff --git a/m4/mntctl.m4 b/m4/mntctl.m4 new file mode 100644 index 0000000000..9d0dde1d13 --- /dev/null +++ b/m4/mntctl.m4 @@ -0,0 +1,30 @@ +dnl ** +dnl ** AIX mntctl +dnl ** + +AC_DEFUN([DOVECOT_MNTCTL], [ + if test $ac_cv_header_sys_vmount_h = yes; then + AC_MSG_CHECKING([for reasonable mntctl buffer size]) + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + #include + #include + int main() { + int size,count; char *m; + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + 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 */ + exit(0); + } + ]])],[ + size=`cat conftestval` + rm -f conftestval + AC_DEFINE_UNQUOTED(STATIC_MTAB_SIZE,$size, [reasonable mntctl buffer size]) + AC_MSG_RESULT($size) + ],[ + AC_MSG_RESULT(default) + ]) + fi +]) diff --git a/m4/modules.m4 b/m4/modules.m4 new file mode 100644 index 0000000000..9bb04b9bcd --- /dev/null +++ b/m4/modules.m4 @@ -0,0 +1,14 @@ +dnl * dynamic modules? +AC_DEFUN([DOVECOT_MODULES], [ + have_modules=no + AC_CHECK_FUNC(dlopen, [ + have_modules=yes + MODULE_LIBS="-export-dynamic" + ], [ + AC_CHECK_LIB(dl, dlopen, [ + have_modules=yes + MODULE_LIBS="-export-dynamic -ldl" + DLLIB=-ldl + ]) + ]) +]) diff --git a/m4/notify.m4 b/m4/notify.m4 new file mode 100644 index 0000000000..600612b6ec --- /dev/null +++ b/m4/notify.m4 @@ -0,0 +1,41 @@ +AC_DEFUN([DOVECOT_NOTIFY], [ + have_notify=none + + if test "$notify" = "" || test "$notify" = "inotify" ; then + dnl * inotify? + AC_MSG_CHECKING([whether we can use inotify]) + if test "$ac_cv_func_inotify_init" = yes; then + have_notify=inotify + notify=inotify + AC_MSG_RESULT("yes") + AC_DEFINE(IOLOOP_NOTIFY_INOTIFY,, [Use Linux inotify]) + else + AC_MSG_RESULT("no") + if test "$notify" = "inotify"; then + AC_MSG_ERROR([inotify requested but not available]) + notify="" + fi + fi + fi + + 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 + have_notify=kqueue + notify=kqueue + AC_MSG_RESULT("yes") + AC_DEFINE(IOLOOP_NOTIFY_KQUEUE,, [Use BSD kqueue directory changes notificaton]) + else + AC_MSG_RESULT("no") + if test "$notify" = "kqueue" ; then + AC_MSG_ERROR([kqueue notify requested but kqueue() is not available]) + notify="" + fi + fi + fi + + if test "$have_notify" = "none"; then + AC_DEFINE(IOLOOP_NOTIFY_NONE,, [No special notify support]) + fi +]) diff --git a/m4/nsl.m4 b/m4/nsl.m4 new file mode 100644 index 0000000000..f0b9bf97b2 --- /dev/null +++ b/m4/nsl.m4 @@ -0,0 +1,6 @@ +AC_DEFUN([DOVECOT_NSL], [ + AC_SEARCH_LIBS([inet_aton], [resolv]) + AC_SEARCH_LIBS([gethostbyname], [nsl]) + AC_SEARCH_LIBS([socket], [socket]) + AC_SEARCH_LIBS([gethostent], [nsl]) +]) diff --git a/m4/off_t_max.m4 b/m4/off_t_max.m4 new file mode 100644 index 0000000000..4ec6d08b4e --- /dev/null +++ b/m4/off_t_max.m4 @@ -0,0 +1,13 @@ +AC_DEFUN([DOVECOT_OFF_T_MAX], [ + dnl * Do we have OFF_T_MAX? + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + ]], [[ + off_t i = OFF_T_MAX; + ]])],[ + : + ],[ + AC_DEFINE_UNQUOTED(OFF_T_MAX, $offt_max, [Maximum value of off_t]) + ]) +]) diff --git a/m4/pr_set_dumpable.m4 b/m4/pr_set_dumpable.m4 new file mode 100644 index 0000000000..a5f94f79b6 --- /dev/null +++ b/m4/pr_set_dumpable.m4 @@ -0,0 +1,16 @@ +AC_DEFUN([DOVECOT_PR_SET_DUMPABLE], [ + AC_CACHE_CHECK([whether PR_SET_DUMPABLE exists],i_cv_have_pr_set_dumpable,[ + AC_TRY_LINK([ + #include + ], [ + 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)]) + fi +]) diff --git a/m4/q_quotactl.m4 b/m4/q_quotactl.m4 new file mode 100644 index 0000000000..36099ab439 --- /dev/null +++ b/m4/q_quotactl.m4 @@ -0,0 +1,20 @@ +dnl * Check if we have Q_QUOTACTL ioctl (Solaris) +AC_DEFUN([DOVECOT_Q_QUOTACTL], [ + AC_CACHE_CHECK([if Q_QUOTACTL ioctl exists],i_cv_have_ioctl_q_quotactl,[ + AC_TRY_COMPILE([ + #include + #include + ], [ + struct quotctl ctl; + 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]) + fi +]) diff --git a/m4/quota.m4 b/m4/quota.m4 new file mode 100644 index 0000000000..5840e3af89 --- /dev/null +++ b/m4/quota.m4 @@ -0,0 +1,22 @@ +AC_DEFUN([DOVECOT_RPCGEN], [ + RPCGEN=${RPCGEN-rpcgen} + if ! $RPCGEN -c /dev/null > /dev/null; then + RPCGEN= + fi + AC_SUBST(RPCGEN) + + have_rquota=no + if test -f /usr/include/rpcsvc/rquota.x && test -n "$RPCGEN"; then + AC_DEFINE(HAVE_RQUOTA,, [Define if you wish to retrieve quota of NFS mounted mailboxes]) + have_rquota=yes + fi + AM_CONDITIONAL(HAVE_RQUOTA, test "$have_rquota" = "yes") +]) + +AC_DEFUN([DOVECOT_QUOTA], [ + AC_SEARCH_LIBS(quota_open, quota, [ + AC_DEFINE(HAVE_QUOTA_OPEN,, [Define if you have quota_open()]) + QUOTA_LIBS="-lquota" + ]) + AC_SUBST(QUOTA_LIBS) +]) diff --git a/m4/rlimit.m4 b/m4/rlimit.m4 new file mode 100644 index 0000000000..9e652a4924 --- /dev/null +++ b/m4/rlimit.m4 @@ -0,0 +1,65 @@ +dnl * Do we have RLIMIT_AS? +AC_DEFUN([DOVECOT_RLIMIT_AS], [ + AC_CACHE_CHECK([whether RLIMIT_AS exists],i_cv_have_rlimit_as,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + #include + ]], [[ + struct rlimit r; + getrlimit(RLIMIT_AS, &r); + ]])],[ + i_cv_have_rlimit_as=yes + ], [ + i_cv_have_rlimit_as=no + ]) + ]) + + if test $i_cv_have_rlimit_as = yes; then + AC_DEFINE(HAVE_RLIMIT_AS,, [Define if you have RLIMIT_AS for setrlimit()]) + fi +]) + +dnl * Do we have RLIMIT_NPROC? +AC_DEFUN([DOVECOT_RLIMIT_NPROC], [ + AC_CACHE_CHECK([whether RLIMIT_NPROC exists],i_cv_have_rlimit_nproc,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + #include + ]], [[ + struct rlimit r; + 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()]) + fi +]) + +dnl * Do we have RLIMIT_CORE? +AC_DEFUN([DOVECOT_RLIMIT_CORE], [ + AC_CACHE_CHECK([whether RLIMIT_CORE exists],i_cv_have_rlimit_core,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + #include + ]], [[ + struct rlimit r; + getrlimit(RLIMIT_CORE, &r); + ]])],[ + i_cv_have_rlimit_core=yes + ],[ + i_cv_have_rlimit_core=no + ]) + ]) + + if test $i_cv_have_rlimit_core = yes; then + AC_DEFINE(HAVE_RLIMIT_CORE,, [Define if you have RLIMIT_CORE for getrlimit()]) + fi +]) diff --git a/m4/sendfile.m4 b/m4/sendfile.m4 new file mode 100644 index 0000000000..33ec88b4f5 --- /dev/null +++ b/m4/sendfile.m4 @@ -0,0 +1,46 @@ +dnl * Compatible sendfile() +AC_DEFUN([DOVECOT_SENDFILE], [ + AC_CHECK_LIB(sendfile, sendfile, [ + LIBS="$LIBS -lsendfile" + 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,[ + AC_TRY_LINK([ + #undef _FILE_OFFSET_BITS + #include + #include + #include + ], [ + 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()]) + fi + + dnl * FreeBSD compatible sendfile() + AC_CACHE_CHECK([FreeBSD compatible sendfile()],i_cv_have_freebsd_sendfile,[ + AC_TRY_LINK([ + #include + #include + #include + ], [ + struct sf_hdtr hdtr; + 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()]) + fi + ]) +]) diff --git a/m4/size_t_signed.m4 b/m4/size_t_signed.m4 new file mode 100644 index 0000000000..4f54f391de --- /dev/null +++ b/m4/size_t_signed.m4 @@ -0,0 +1,53 @@ +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_DEFUN([DOVECOT_SIZE_T_SIGNED], [ + AC_CACHE_CHECK([whether size_t is signed],i_cv_signed_size_t,[ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + int main() { + /* return 0 if we're signed */ + exit((size_t)(int)-1 <= 0 ? 0 : 1); + } + ]])],[ + i_cv_signed_size_t=yes + + echo + 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 + AC_MSG_ERROR([aborting]) + fi + echo "..ignoring as requested.." + ],[ + i_cv_signed_size_t=no + ],[]) + ]) + 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) + case "$typeof_size_t" in + "unsigned long") + ssizet_max=LONG_MAX + sizet_fmt="lu" + ;; + "unsigned long long") + ssizet_max=LLONG_MAX + sizet_fmt="llu" + ;; + *) + dnl older systems didn't have ssize_t, default to int + ssizet_max=INT_MAX + sizet_fmt="u" + + 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]) + fi + ;; + esac +]) diff --git a/m4/sockpeercred.m4 b/m4/sockpeercred.m4 new file mode 100644 index 0000000000..96b4822c51 --- /dev/null +++ b/m4/sockpeercred.m4 @@ -0,0 +1,6 @@ +AC_DEFUN([DOVECOT_SOCKPEERCRED], [ + AC_CHECK_TYPES([struct sockpeercred],,,[ + #include + #include + ]) +]) diff --git a/m4/sql.m4 b/m4/sql.m4 new file mode 100644 index 0000000000..3a8b67ec6e --- /dev/null +++ b/m4/sql.m4 @@ -0,0 +1,23 @@ +AC_DEFUN([DOVECOT_SQL], [ + SQL_CFLAGS="$MYSQL_CFLAGS $PGSQL_CFLAGS $SQLITE_CFLAGS $CASSANDRA_CFLAGS" + if test "$want_sql" != "plugin"; then + SQL_LIBS="$MYSQL_LIBS $PGSQL_LIBS $SQLITE_LIBS $CASSANDRA_LIBS" + else + AC_DEFINE(SQL_DRIVER_PLUGINS,, [Build SQL drivers as plugins]) + fi + sql_drivers= + not_sql_drivers= + + 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" + passdb="$passdb sql" + userdb="$userdb sql" + else + not_passdb="$not_passdb sql" + not_userdb="$not_userdb sql" + fi +]) diff --git a/m4/ssl.m4 b/m4/ssl.m4 new file mode 100644 index 0000000000..dbf0bbb07c --- /dev/null +++ b/m4/ssl.m4 @@ -0,0 +1,64 @@ +AC_DEFUN([DOVECOT_SSL], [ + have_ssl=no + + 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" + have_openssl=yes + else + # openssl 0.9.8 wants -ldl and it's required if there's only .a lib + AC_CHECK_LIB(ssl, SSL_read, [ + AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h, [ + SSL_LIBS="-lssl -lcrypto $DLLIB" + AC_SUBST(SSL_LIBS) + have_openssl=yes + ], [ + if test $want_openssl = yes; then + AC_ERROR([Can't build with OpenSSL: openssl/ssl.h or openssl/err.h not found]) + fi + ]) + ], [ + if test $want_openssl = yes; then + AC_ERROR([Can't build with OpenSSL: libssl not found]) + fi + ], -lcrypto $DLLIB) + fi + if test "$have_openssl" = "yes"; then + AC_DEFINE(HAVE_OPENSSL,, [Build with OpenSSL support]) + have_ssl="yes (OpenSSL)" + + AC_CHECK_LIB(ssl, SSL_get_current_compression, [ + AC_DEFINE(HAVE_SSL_COMPRESSION,, [Build with OpenSSL compression]) + ],, $SSL_LIBS) + AC_CHECK_LIB(ssl, SSL_get_servername, [ + AC_DEFINE(HAVE_SSL_GET_SERVERNAME,, [Build with TLS hostname support]) + ],, $SSL_LIBS) + fi + fi + 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_CHECK_HEADER(gnutls/gnutls.h, [ + AC_DEFINE(HAVE_GNUTLS,, [Build with GNUTLS support]) + SSL_LIBS="-lgnutls -lgcrypt" + AC_SUBST(SSL_LIBS) + have_ssl="yes (GNUTLS)" + have_gnutls=yes + ], [ + if test $want_gnutls = yes; then + AC_ERROR([Can't build with GNUTLS: gnutls/gnutls.h not found]) + fi + ]) + ], [ + if test $want_gnutls = yes; then + AC_ERROR([Can't build with GNUTLS: libgnutls not found]) + fi + ], -lgcrypt) + fi + + if test "$have_ssl" != "no"; then + AC_DEFINE(HAVE_SSL,, [Build with SSL/TLS support]) + fi +]) diff --git a/m4/st_tim.m4 b/m4/st_tim.m4 new file mode 100644 index 0000000000..aa790b63e7 --- /dev/null +++ b/m4/st_tim.m4 @@ -0,0 +1,41 @@ +AC_DEFUN([DOVECOT_ST_TIM_TIMESPEC], [ + AC_CACHE_CHECK([if struct stat has st_?tim timespec fields],i_cv_have_st_tim_timespec,[ + AC_TRY_COMPILE([ + #include + #include + #include + ], [ + struct stat st; + unsigned long x = st.st_mtim.tv_nsec; + + return 0; + ], [ + 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]) + fi + + AC_CACHE_CHECK([if struct stat has st_?timespec fields],i_cv_have_st_timespec,[ + AC_TRY_COMPILE([ + #include + #include + #include + ], [ + struct stat st; + unsigned long x = st.st_mtimespec.tv_nsec; + + return 0; + ], [ + i_cv_have_st_timespec=yes + ], [ + i_cv_have_st_timespec=no + ]) + ]) + if test $i_cv_have_st_timespec = yes; then + AC_DEFINE(HAVE_STAT_XTIMESPEC,, [Define if you have st_?timespec fields in struct stat]) + fi +]) diff --git a/m4/test_with.m4 b/m4/test_with.m4 new file mode 100644 index 0000000000..85a99c1d0d --- /dev/null +++ b/m4/test_with.m4 @@ -0,0 +1,18 @@ +dnl TEST_WITH(name, value, [plugin]) +AC_DEFUN([TEST_WITH], [ + want=want_`echo $1|sed s/-/_/g` + if test $2 = yes || test $2 = no || test $2 = auto; then + eval $want=$2 + elif test $2 = plugin; then + if test "$3" = plugin; then + eval $want=plugin + else + AC_ERROR([--with-$1=plugin not supported]) + fi + elif `echo $2|grep '^/' >/dev/null`; then + AC_ERROR([--with-$1=path not supported. You may want to use instead: +CPPFLAGS=-I$2/include LDFLAGS=-L$2/lib ./configure --with-$1]) + else + AC_ERROR([--with-$1: Unknown value: $2]) + fi +]) diff --git a/m4/time_t_signed.m4 b/m4/time_t_signed.m4 new file mode 100644 index 0000000000..d5789fd5bc --- /dev/null +++ b/m4/time_t_signed.m4 @@ -0,0 +1,18 @@ +AC_DEFUN([DOVECOT_TIME_T_SIGNED], [ + AC_CACHE_CHECK([whether time_t is signed],i_cv_signed_time_t,[ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + int main() { + /* return 0 if we're signed */ + exit((time_t)(int)-1 <= 0 ? 0 : 1); + } + ]])],[ + i_cv_signed_time_t=yes + ], [ + i_cv_signed_time_t=no + ]) + ]) + if test $i_cv_signed_time_t = yes; then + AC_DEFINE(TIME_T_SIGNED,, [Define if your time_t is signed]) + fi +]) diff --git a/m4/typeof.m4 b/m4/typeof.m4 new file mode 100644 index 0000000000..b98cda7dbb --- /dev/null +++ b/m4/typeof.m4 @@ -0,0 +1,16 @@ +AC_DEFUN([DOVECOT_TYPEOF],[ + AC_CACHE_CHECK([for typeof],i_cv_have_typeof,[ + AC_TRY_COMPILE([ + ], [ + int foo; + typeof(foo) bar; + ], [ + i_cv_have_typeof=yes + ], [ + i_cv_have_typeof=no + ]) + ]) + if test $i_cv_have_typeof = yes; then + AC_DEFINE(HAVE_TYPEOF,, [Define if you have typeof()]) + fi +]) diff --git a/m4/typeof_dev_t.m4 b/m4/typeof_dev_t.m4 new file mode 100644 index 0000000000..bec20ab982 --- /dev/null +++ b/m4/typeof_dev_t.m4 @@ -0,0 +1,18 @@ +dnl * is dev_t an integer or something else? +AC_DEFUN([DOVECOT_TYPEOF_DEV_T], [ + AC_CACHE_CHECK([whether dev_t is struct],i_cv_dev_t_struct,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + struct test { dev_t a; }; + static struct test t = { 0 }; + ]], + [[ ]])], [ + i_cv_dev_t_struct=no + ],[ + i_cv_dev_t_struct=yes + ]) + ]) + 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]) + fi +]) diff --git a/m4/unsetenv.m4 b/m4/unsetenv.m4 new file mode 100644 index 0000000000..0c469e8809 --- /dev/null +++ b/m4/unsetenv.m4 @@ -0,0 +1,16 @@ +AC_DEFUN([DOVECOT_UNSETENV_RET_INT], [ + AC_CACHE_CHECK([if unsetenv returns int],i_cv_unsetenv_ret_int,[ + AC_TRY_COMPILE([ + #include + ], [ + if (unsetenv("env") < 0) ; + ], [ + i_cv_unsetenv_ret_int=yes + ], [ + i_cv_unsetenv_ret_int=no + ]) + ]) + if test $i_cv_unsetenv_ret_int = yes; then + AC_DEFINE(UNSETENV_RET_INT,, [Define if unsetenv() returns int]) + fi +]) diff --git a/m4/vararg.m4 b/m4/vararg.m4 new file mode 100644 index 0000000000..fdd641c1b7 --- /dev/null +++ b/m4/vararg.m4 @@ -0,0 +1,74 @@ +AC_DEFUN([DOVECOT_VA_COPY], [ + AC_CACHE_CHECK([for an implementation of va_copy()],lib_cv_va_copy,[ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + void f (int i, ...) { + va_list args1, args2; + va_start (args1, i); + va_copy (args2, args1); + if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) + exit (1); + va_end (args1); va_end (args2); + } + int main() { + f (0, 42); + return 0; + }]])], + [lib_cv_va_copy=yes], + [lib_cv_va_copy=no],[]) + ]) + AC_CACHE_CHECK([for an implementation of __va_copy()],lib_cv___va_copy,[ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + void f (int i, ...) { + va_list args1, args2; + va_start (args1, i); + __va_copy (args2, args1); + if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) + exit (1); + va_end (args1); va_end (args2); + } + int main() { + f (0, 42); + return 0; + }]])], + [lib_cv___va_copy=yes], + [lib_cv___va_copy=no],[]) + ]) + + if test "x$lib_cv_va_copy" = "xyes"; then + va_copy_func=va_copy + else if test "x$lib_cv___va_copy" = "xyes"; then + va_copy_func=__va_copy + fi + fi + + if test -n "$va_copy_func"; then + AC_DEFINE_UNQUOTED(VA_COPY,$va_copy_func,[A 'va_copy' style function]) + fi +]) + +AC_DEFUN([DOVECOT_VA_COPY_BYVAL], [ + AC_CACHE_CHECK([whether va_lists can be copied by value],lib_cv_va_val_copy,[ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + void f (int i, ...) { + va_list args1, args2; + va_start (args1, i); + args2 = args1; + if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) + exit (1); + va_end (args1); va_end (args2); + } + int main() { + f (0, 42); + return 0; + }]])], + [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]) + fi +]) diff --git a/m4/want_bsdauth.m4 b/m4/want_bsdauth.m4 new file mode 100644 index 0000000000..cd64c8de08 --- /dev/null +++ b/m4/want_bsdauth.m4 @@ -0,0 +1,18 @@ +AC_DEFUN([DOVECOT_WANT_BSDAUTH], [ + have_bsdauth=no + if test $want_bsdauth != no; then + AC_CHECK_FUNC(auth_userokay, [ + AC_DEFINE(PASSDB_BSDAUTH,, [Build with BSD authentication support]) + have_bsdauth=yes + ], [ + if test $want_bsdauth = yes; then + AC_ERROR([Can't build with BSD authentication support: auth_userokay() not found]) + fi + ]) + fi + if test $have_bsdauth = no; then + not_passdb="$not_passdb bsdauth" + else + passdb="$passdb bsdauth" + fi +]) diff --git a/m4/want_bzlib.m4 b/m4/want_bzlib.m4 new file mode 100644 index 0000000000..224da98e9f --- /dev/null +++ b/m4/want_bzlib.m4 @@ -0,0 +1,20 @@ +AC_DEFUN([DOVECOT_WANT_BZLIB], [ + if test "$want_bzlib" != "no"; then + AC_CHECK_HEADER(bzlib.h, [ + AC_CHECK_LIB(bz2, BZ2_bzdopen, [ + have_bzlib=yes + have_compress_lib=yes + 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]) + fi + ]) + ], [ + if test "$want_bzlib" = "yes"; then + AC_ERROR([Can't build with bzlib support: bzlib.h not found]) + fi + ]) + fi +]) diff --git a/m4/want_cassandra.m4 b/m4/want_cassandra.m4 new file mode 100644 index 0000000000..22159e9fc7 --- /dev/null +++ b/m4/want_cassandra.m4 @@ -0,0 +1,20 @@ +AC_DEFUN([DOVECOT_WANT_CASSANDRA], [ + if test $want_cassandra != no; then + AC_CHECK_LIB(cassandra, cass_session_new, [ + AC_CHECK_HEADER(cassandra.h, [ + CASSANDRA_LIBS="$CASSANDRA_LIBS -lcassandra" + + AC_DEFINE(HAVE_CASSANDRA,, [Build with Cassandra support]) + found_sql_drivers="$found_sql_drivers cassandra" + ], [ + if test $want_cassandra = yes; then + AC_ERROR([Can't build with Cassandra support: cassandra.h not found]) + fi + ]) + ], [ + if test $want_cassandra = yes; then + AC_ERROR([Can't build with Cassandra support: libcassandra not found]) + fi + ]) + fi +]) diff --git a/m4/want_cdb.m4 b/m4/want_cdb.m4 new file mode 100644 index 0000000000..b18ff490c6 --- /dev/null +++ b/m4/want_cdb.m4 @@ -0,0 +1,19 @@ +AC_DEFUN([DOVECOT_WANT_CDB], [ + if test $want_cdb != no; then + AC_CHECK_LIB(cdb, cdb_init, [ + AC_CHECK_HEADER(cdb.h, [ + DICT_LIBS="$DICT_LIBS -lcdb" + dict_drivers="$dict_drivers cdb" + 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]) + fi + ]) + ], [ + if test $want_cdb = yes; then + AC_ERROR([Can't build with CDB support: libcdb not found]) + fi + ]) + fi +]) diff --git a/m4/want_checkpassword.m4 b/m4/want_checkpassword.m4 new file mode 100644 index 0000000000..696adb47ec --- /dev/null +++ b/m4/want_checkpassword.m4 @@ -0,0 +1,11 @@ +AC_DEFUN([DOVECOT_WANT_CHECKPASSWORD], [ + 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" + else + not_passdb="$not_passdb checkpassword" + not_userdb="$not_userdb checkpassword" + fi +]) diff --git a/m4/want_clucene.m4 b/m4/want_clucene.m4 new file mode 100644 index 0000000000..748ab5a85d --- /dev/null +++ b/m4/want_clucene.m4 @@ -0,0 +1,12 @@ +AC_DEFUN([DOVECOT_WANT_CLUCENE], [ + have_lucene=no + 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" + ]) + have_lucene=yes + fts="$fts lucene" + fi +]) diff --git a/m4/want_db.m4 b/m4/want_db.m4 new file mode 100644 index 0000000000..469dedb190 --- /dev/null +++ b/m4/want_db.m4 @@ -0,0 +1,33 @@ +AC_DEFUN([DOVECOT_WANT_DB], [ + if test $want_db != no; then + AC_CACHE_CHECK([db_env_create in -ldb],i_cv_have_db_env_create,[ + old_LIBS=$LIBS + LIBS="$LIBS -ldb" + AC_TRY_LINK([ + #include + ], [ + db_env_create(0, 0); + ], [ + i_cv_have_db_env_create=yes + ], [ + i_cv_have_db_env_create=no + ]) + LIBS=$old_LIBS + ]) + if test $i_cv_have_db_env_create = yes; then + AC_CHECK_HEADER(db.h, [ + 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]) + fi + ]) + else + if test $want_db = yes; then + AC_ERROR([Can't build with db support: libdb not found]) + fi + fi + fi +]) diff --git a/m4/want_gssapi.m4 b/m4/want_gssapi.m4 new file mode 100644 index 0000000000..745763079b --- /dev/null +++ b/m4/want_gssapi.m4 @@ -0,0 +1,112 @@ +AC_DEFUN([DOVECOT_WANT_GSSAPI], [ + have_gssapi=no + if test $want_gssapi != no; then + AC_CHECK_PROG(KRB5CONFIG, krb5-config, krb5-config, NO) + if test $KRB5CONFIG != NO; then + if ! $KRB5CONFIG --version gssapi 2>/dev/null > /dev/null; then + # krb5-config doesn't support gssapi. + KRB5_LIBS="`$KRB5CONFIG --libs`" + KRB5_CFLAGS=`$KRB5CONFIG --cflags` + AC_CHECK_LIB(gss, gss_acquire_cred, [ + # Solaris + KRB5_LIBS="$KRB5_LIBS -lgss" + ], [ + # failed + KRB5_LIBS= + ], $KRB5_LIBS) + else + KRB5_LIBS=`$KRB5CONFIG --libs gssapi` + KRB5_CFLAGS=`$KRB5CONFIG --cflags gssapi` + fi + if test "$KRB5_LIBS" != ""; then + AC_SUBST(KRB5_LIBS) + AC_SUBST(KRB5_CFLAGS) + + # Although krb5-config exists, all systems still don't + # have gssapi.h + old_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $KRB5_CFLAGS" + AC_CHECK_HEADER([gssapi/gssapi.h], [ + AC_DEFINE(HAVE_GSSAPI_GSSAPI_H,, [GSSAPI headers in gssapi/gssapi.h]) + have_gssapi=yes + ]) + AC_CHECK_HEADER([gssapi.h], [ + AC_DEFINE(HAVE_GSSAPI_H,, [GSSAPI headers in gssapi.h]) + have_gssapi=yes + ]) + if test $have_gssapi != no; then + if test $want_gssapi = plugin; then + have_gssapi=plugin + fi + AC_DEFINE(HAVE_GSSAPI,, [Build with GSSAPI support]) + AC_CHECK_HEADERS(gssapi/gssapi_ext.h gssapi_krb5.h gssapi/gssapi_krb5.h) + AC_CHECK_LIB(gss, __gss_userok, [ + AC_DEFINE(HAVE___GSS_USEROK,, + [Define if you have __gss_userok()]) + KRB5_LIBS="$KRB5_LIBS -lgss" + ],, $KRB5_LIBS) + + # MIT has a #define for Heimdal acceptor_identity, but it's way too + # difficult to test for it.. + old_LIBS=$LIBS + LIBS="$LIBS $KRB5_LIBS" + 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,[ + AC_TRY_RUN([ + #ifdef HAVE_GSSAPI_H + # include + #else + # include + #endif + #include + #include + int main(void) { + OM_uint32 minor_status; + gss_OID_set mech_set; + unsigned char spnego_oid[] = { 0x2b, 0x06, 0x01, 0x05, 0x05, 0x02 }; + unsigned int i; + + 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, + spnego_oid, 6) == 0) + return 0; + } + return 1; + } + ], [ + i_cv_gssapi_spnego=yes + ], [ + i_cv_gssapi_spnego=no + ]) + ]) + if test "$i_cv_gssapi_spnego" = "yes"; then + AC_DEFINE(HAVE_GSSAPI_SPNEGO,, [GSSAPI supports SPNEGO]) + fi + LIBS=$old_LIBS + + 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]) + else + have_gssapi_plugin=yes + fi + else + if test $want_gssapi != auto; then + AC_ERROR([Can't build with GSSAPI support: gssapi.h not found]) + fi + fi + CFLAGS=$old_CFLAGS + fi + else + if test $want_gssapi != auto; then + AC_ERROR([Can't build with GSSAPI support: krb5-config not found]) + fi + fi + fi + AM_CONDITIONAL(GSSAPI_PLUGIN, test "$have_gssapi_plugin" = "yes") +]) diff --git a/m4/want_icu.m4 b/m4/want_icu.m4 new file mode 100644 index 0000000000..9127ebccb6 --- /dev/null +++ b/m4/want_icu.m4 @@ -0,0 +1,12 @@ +AC_DEFUN([DOVECOT_WANT_ICU], [ + if test "$want_icu" != "no"; then + if test "$PKG_CONFIG" != "" && $PKG_CONFIG --exists icu-i18n 2>/dev/null; then + PKG_CHECK_MODULES(LIBICU, icu-i18n) + have_icu=yes + AC_DEFINE(HAVE_LIBICU,, [Define if you want ICU normalization support for FTS]) + elif test "$want_icu" = "yes"; then + AC_ERROR([Can't build with libicu support: libicu-i18n not found]) + fi + fi + AM_CONDITIONAL(BUILD_LIBICU, test "$have_icu" = "yes") +]) diff --git a/m4/want_ldap.m4 b/m4/want_ldap.m4 new file mode 100644 index 0000000000..f1ab2e0e67 --- /dev/null +++ b/m4/want_ldap.m4 @@ -0,0 +1,57 @@ +AC_DEFUN([DOVECOT_WANT_LDAP], [ + have_ldap=no + if test $want_ldap != no; then + AC_CHECK_LIB(ldap, ldap_init, [ + AC_CHECK_HEADER(ldap.h, [ + 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]) + ]) + LDAP_LIBS="-lldap" + 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" + ]) + ]) + AC_SUBST(LDAP_LIBS) + if test $want_ldap != plugin; then + AUTH_LIBS="$AUTH_LIBS $LDAP_LIBS" + AC_DEFINE(BUILTIN_LDAP,, [LDAP support is built in]) + fi + + AC_DEFINE(USERDB_LDAP,, [Build with LDAP support]) + AC_DEFINE(PASSDB_LDAP,, [Build with LDAP support]) + AC_CHECK_HEADERS(sasl.h sasl/sasl.h) + have_ldap=yes + ], [ + if test $want_ldap != auto; then + AC_ERROR([Can't build with LDAP support: ldap.h not found]) + fi + ]) + ], [ + if test $want_ldap != auto; then + AC_ERROR([Can't build with LDAP support: libldap not found]) + fi + ]) + fi + + if test $have_ldap = no; then + not_passdb="$not_passdb ldap" + not_userdb="$not_userdb ldap" + else + userdb="$userdb ldap" + passdb="$passdb ldap" + if test $want_ldap = plugin; then + have_ldap_plugin=yes + userdb="$userdb (plugin)" + passdb="$passdb (plugin)" + fi + fi + AM_CONDITIONAL(LDAP_PLUGIN, test "$have_ldap_plugin" = "yes") + AM_CONDITIONAL(HAVE_LDAP, test "$want_ldap" = "yes") +]) diff --git a/m4/want_lz4.m4 b/m4/want_lz4.m4 new file mode 100644 index 0000000000..00fae5a95b --- /dev/null +++ b/m4/want_lz4.m4 @@ -0,0 +1,20 @@ +AC_DEFUN([DOVECOT_WANT_LZ4], [ + if test "$want_lz4" != "no"; then + AC_CHECK_HEADER(lz4.h, [ + AC_CHECK_LIB(lz4, LZ4_compress, [ + have_lz4=yes + have_compress_lib=yes + AC_DEFINE(HAVE_LZ4,, [Define if you have lz4 library]) + COMPRESS_LIBS="$COMPRESS_LIBS -llz4" + ], [ + if test "$want_lz4" = "yes"; then + AC_ERROR([Can't build with lz4 support: liblz4 not found]) + fi + ]) + ], [ + if test "$want_lz4" = "yes"; then + AC_ERROR([Can't build with lz4 support: lz4.h not found]) + fi + ]) + fi +]) diff --git a/m4/want_lzma.m4 b/m4/want_lzma.m4 new file mode 100644 index 0000000000..7863e835d0 --- /dev/null +++ b/m4/want_lzma.m4 @@ -0,0 +1,20 @@ +AC_DEFUN([DOVECOT_WANT_LZMA], [ + if test "$want_lzma" != "no"; then + AC_CHECK_HEADER(lzma.h, [ + AC_CHECK_LIB(lzma, lzma_stream_decoder, [ + have_lzma=yes + have_compress_lib=yes + AC_DEFINE(HAVE_LZMA,, [Define if you have lzma library]) + COMPRESS_LIBS="$COMPRESS_LIBS -llzma" + ], [ + if test "$want_lzma" = "yes"; then + AC_ERROR([Can't build with lzma support: liblzma not found]) + fi + ]) + ], [ + if test "$want_lzma" = "yes"; then + AC_ERROR([Can't build with lzma support: lzma.h not found]) + fi + ]) + fi +]) diff --git a/m4/want_mysql.m4 b/m4/want_mysql.m4 new file mode 100644 index 0000000000..15cac6283f --- /dev/null +++ b/m4/want_mysql.m4 @@ -0,0 +1,89 @@ +AC_DEFUN([DOVECOT_WANT_MYSQL], [ + have_mysql=no + if test $want_mysql != no; then + AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, mysql_config, NO) + if test $MYSQL_CONFIG = NO; then + # based on code from PHP + MYSQL_LIBS="-lmysqlclient -lz -lm" + for i in /usr /usr/local /usr/local/mysql; do + for j in include include/mysql ""; do + if test -r "$i/$j/mysql.h"; then + MYSQL_INCLUDE="-I$i/$j" + fi + done + for j in lib lib/mysql lib64 lib64/mysql ""; do + if test -f "$i/$j/libmysqlclient.so" || test -f "$i/$j/libmysqlclient.a"; then + MYSQL_LIBS="-L$i/$j -lmysqlclient -lz -lm" + fi + done + done + else + MYSQL_INCLUDE="`$MYSQL_CONFIG --include`" + MYSQL_LIBS="`$MYSQL_CONFIG --libs`" + fi + + old_LIBS=$LIBS + if test "$MYSQL_LIBS" != ""; then + LIBS="$LIBS $MYSQL_LIBS" + fi + + mysql_lib="" + LIBS="$LIBS -lz -lm" + AC_CHECK_LIB(mysqlclient, mysql_init, [ + old_CPPFLAGS=$CPPFLAGS + if test "$MYSQL_INCLUDE" != ""; then + CPPFLAGS="$CPPFLAGS $MYSQL_INCLUDE" + fi + AC_CHECK_HEADER(mysql.h, [ + if test "$MYSQL_INCLUDE" != ""; then + MYSQL_CFLAGS="$MYSQL_CFLAGS $MYSQL_INCLUDE" + fi + + 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" + else + ssl_define="" + fi + AC_TRY_COMPILE([ + $ssl_define + #include + ], [ + mysql_set_ssl(0, 0, 0, 0, 0, 0); + ], [ + AC_DEFINE(HAVE_MYSQL_SSL_CIPHER,, [Define if your MySQL library supports setting cipher]) + + AC_TRY_COMPILE([ + $ssl_define + #include + ], [ + int i = MYSQL_OPT_SSL_VERIFY_SERVER_CERT; + ], [ + AC_DEFINE(HAVE_MYSQL_SSL_VERIFY_SERVER_CERT,, [Defineif your MySQL library supports verifying the name in the SSL certificate]) + ]) + ]) + ]) + + have_mysql=yes + 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]) + fi + ]) + CPPFLAGS=$old_CPPFLAGS + ], [ + if test $want_mysql = yes; then + AC_ERROR([Can't build with MySQL support: libmysqlclient not found]) + fi + ]) + + if test $have_mysql != yes; then + MYSQL_LIBS= + MYSQL_CFLAGS= + fi + LIBS=$old_LIBS + fi +]) diff --git a/m4/want_nss.m4 b/m4/want_nss.m4 new file mode 100644 index 0000000000..1c87963bc0 --- /dev/null +++ b/m4/want_nss.m4 @@ -0,0 +1,36 @@ +AC_DEFUN([DOVECOT_WANT_NSS], [ + have_nss=no + 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]) + fi + else + AC_CACHE_CHECK([for NSS support],i_cv_have_nss,[ + AC_TRY_COMPILE([ + #include + ], [ + enum nss_status status = NSS_STATUS_TRYAGAIN; + ], [ + i_cv_have_nss=yes + ], [ + i_cv_have_nss=no + ]) + ]) + if test $i_cv_have_nss = yes; then + AC_DEFINE(USERDB_NSS,, [Build with NSS module support]) + have_nss=yes + else + if test $want_nss = yes; then + AC_ERROR([Can't build with NSS support: nss.h not found or not usable]) + fi + fi + fi + fi + + if test $have_nss = no; then + not_userdb="$not_userdb nss" + else + userdb="$userdb nss" + fi +]) diff --git a/m4/want_pam.m4 b/m4/want_pam.m4 new file mode 100644 index 0000000000..7d4474e72a --- /dev/null +++ b/m4/want_pam.m4 @@ -0,0 +1,36 @@ +AC_DEFUN([DOVECOT_WANT_PAM], [ + if test $want_pam != no; then + AC_CHECK_LIB(pam, pam_start, [ + have_pam=no + AC_CHECK_HEADER(security/pam_appl.h, [ + AC_DEFINE(HAVE_SECURITY_PAM_APPL_H,, + [Define if you have security/pam_appl.h]) + have_pam=yes + ]) + + AC_CHECK_HEADER(pam/pam_appl.h, [ + AC_DEFINE(HAVE_PAM_PAM_APPL_H,, + [Define if you have pam/pam_appl.h]) + have_pam=yes + ]) + ], [ + if test $want_pam = yes; then + AC_ERROR([Can't build with PAM support: libpam not found]) + fi + ]) + fi + + if test "$have_pam" = "yes"; then + AUTH_LIBS="$AUTH_LIBS -lpam" + AC_DEFINE(PASSDB_PAM,, [Build with PAM support]) + passdb="$passdb pam" + + 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]) + else + not_passdb="$not_passdb pam" + fi +]) diff --git a/m4/want_passwd.m4 b/m4/want_passwd.m4 new file mode 100644 index 0000000000..11b5763ffa --- /dev/null +++ b/m4/want_passwd.m4 @@ -0,0 +1,21 @@ +AC_DEFUN([DOVECOT_WANT_PASSWD], [ + if test $want_passwd != no; then + AC_DEFINE(USERDB_PASSWD,, [Build with passwd support]) + AC_DEFINE(PASSDB_PASSWD,, [Build with passwd support]) + userdb="$userdb passwd" + passdb="$passdb passwd" + else + not_passdb="$not_passdb passwd" + not_userdb="$not_userdb passwd" + fi + + 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" + else + not_passdb="$not_passdb passwd-file" + not_userdb="$not_userdb passwd-file" + fi +]) diff --git a/m4/want_pgsql.m4 b/m4/want_pgsql.m4 new file mode 100644 index 0000000000..b81d556e60 --- /dev/null +++ b/m4/want_pgsql.m4 @@ -0,0 +1,61 @@ +AC_DEFUN([DOVECOT_WANT_PGSQL], [ + if test $want_pgsql != no; then + AC_CHECK_PROG(PG_CONFIG, pg_config, pg_config, NO) + if test $PG_CONFIG = NO; then + # based on code from PHP + for i in /usr /usr/local /usr/local/pgsql; do + for j in include include/pgsql include/postgres include/postgresql ""; do + if test -r "$i/$j/libpq-fe.h"; then + PGSQL_INCLUDE=$i/$j + fi + done + for lib in lib lib64; do + for j in $lib $lib/pgsql $lib/postgres $lib/postgresql ""; do + if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then + PGSQL_LIBDIR=$i/$j + fi + done + done + done + else + PGSQL_INCLUDE="`$PG_CONFIG --includedir`" + PGSQL_LIBDIR="`$PG_CONFIG --libdir`" + fi + + old_LIBS=$LIBS + if test "$PGSQL_LIBDIR" != ""; then + LIBS="$LIBS -L$PGSQL_LIBDIR" + fi + + AC_CHECK_LIB(pq, PQconnectdb, [ + AC_CHECK_LIB(pq, PQescapeStringConn, [ + AC_DEFINE(HAVE_PQESCAPE_STRING_CONN,, [Define if libpq has PQescapeStringConn function]) + ]) + old_CPPFLAGS=$CPPFLAGS + if test "$PGSQL_INCLUDE" != ""; then + CPPFLAGS="$CPPFLAGS -I$PGSQL_INCLUDE" + fi + AC_CHECK_HEADER(libpq-fe.h, [ + if test "$PGSQL_INCLUDE" != ""; then + PGSQL_CFLAGS="$PGSQL_CFLAGS -I$PGSQL_INCLUDE" + fi + if test "$PGSQL_LIBDIR" != ""; then + PGSQL_LIBS="$PGSQL_LIBS -L$PGSQL_LIBDIR" + fi + 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]) + fi + ]) + CPPFLAGS=$old_CPPFLAGS + ], [ + if test $want_pgsql = yes; then + AC_ERROR([Can't build with PostgreSQL support: libpq not found]) + fi + ]) + LIBS=$old_LIBS + fi +]) diff --git a/m4/want_prefetch.m4 b/m4/want_prefetch.m4 new file mode 100644 index 0000000000..49d2f65b06 --- /dev/null +++ b/m4/want_prefetch.m4 @@ -0,0 +1,8 @@ +AC_DEFUN([DOVECOT_WANT_PREFETCH], [ + if test $want_prefetch_userdb != no; then + AC_DEFINE(USERDB_PREFETCH,, [Build with prefetch userdb support]) + userdb="$userdb prefetch" + else + not_userdb="$not_userdb prefetch" + fi +]) diff --git a/m4/want_shadow.m4 b/m4/want_shadow.m4 new file mode 100644 index 0000000000..64409ebda2 --- /dev/null +++ b/m4/want_shadow.m4 @@ -0,0 +1,24 @@ +AC_DEFUN([DOVECOT_WANT_SHADOW], [ + have_shadow=no + if test $want_shadow != no; then + AC_CHECK_FUNC(getspnam, [ + AC_CHECK_HEADER(shadow.h, [ + AC_DEFINE(PASSDB_SHADOW,, [Build with shadow support]) + have_shadow=yes + ], [ + if test $want_shadow = yes; then + AC_ERROR([Can't build with shadow support: shadow.h not found]) + fi + ]) + ], [ + if test $want_shadow = yes; then + AC_ERROR([Can't build with shadow support: getspnam() not found]) + fi + ]) + fi + if test $have_shadow = no; then + not_passdb="$not_passdb shadow" + else + passdb="$passdb shadow" + fi +]) diff --git a/m4/want_sia.m4 b/m4/want_sia.m4 new file mode 100644 index 0000000000..2edaeb9e3c --- /dev/null +++ b/m4/want_sia.m4 @@ -0,0 +1,20 @@ +AC_DEFUN([DOVECOT_WANT_SIA], [ + have_sia=no + 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" + have_sia=yes + ], [ + if test $want_sia = yes; then + AC_ERROR([Can't build with SIA support: sia_validate_user() not found]) + fi + ]) + fi + + if test $have_sia = no; then + not_passdb="$not_passdb sia" + else + passdb="$passdb sia" + fi +]) diff --git a/m4/want_solr.m4 b/m4/want_solr.m4 new file mode 100644 index 0000000000..a7dee18d5a --- /dev/null +++ b/m4/want_solr.m4 @@ -0,0 +1,21 @@ +AC_DEFUN([DOVECOT_WANT_SOLR], [ + have_solr=no + if test "$want_solr" != "no"; then + dnl need libexpat + AC_CHECK_LIB(expat, XML_Parse, [ + AC_CHECK_HEADER(expat.h, [ + have_solr=yes + fts="$fts solr" + ], [ + if test $want_solr = yes; then + AC_ERROR([Can't build with Solr support: expat.h not found]) + fi + ]) + ], [ + if test $want_solr = yes; then + AC_ERROR([Can't build with Solr support: libexpat not found]) + fi + ]) + fi + AM_CONDITIONAL(BUILD_SOLR, test "$have_solr" = "yes") +]) diff --git a/m4/want_sqlite.m4 b/m4/want_sqlite.m4 new file mode 100644 index 0000000000..0af632f846 --- /dev/null +++ b/m4/want_sqlite.m4 @@ -0,0 +1,20 @@ +AC_DEFUN([DOVECOT_WANT_SQLITE], [ + if test $want_sqlite != no; then + AC_CHECK_LIB(sqlite3, sqlite3_open, [ + AC_CHECK_HEADER(sqlite3.h, [ + SQLITE_LIBS="$SQLITE_LIBS -lsqlite3" + + 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]) + fi + ]) + ], [ + if test $want_sqlite = yes; then + AC_ERROR([Can't build with SQLite support: libsqlite3 not found]) + fi + ]) + fi +]) diff --git a/m4/want_stemmer.m4 b/m4/want_stemmer.m4 new file mode 100644 index 0000000000..f3b93d373b --- /dev/null +++ b/m4/want_stemmer.m4 @@ -0,0 +1,14 @@ +AC_DEFUN([DOVECOT_WANT_STEMMER], [ + if test $want_stemmer != no; then + AC_CHECK_LIB(stemmer, sb_stemmer_new, [ + have_fts_stemmer=yes + AC_DEFINE(HAVE_FTS_STEMMER,, [Define if you want stemming support for FTS]) + ], [ + if test $want_stemmer = yes; then + AC_ERROR([Can't build with stemmer support: libstemmer not found]) + fi + ]) + fi + + AM_CONDITIONAL([BUILD_FTS_STEMMER], [test "$have_fts_stemmer" = "yes"]) +]) diff --git a/m4/want_textcat.m4 b/m4/want_textcat.m4 new file mode 100644 index 0000000000..8bf7774814 --- /dev/null +++ b/m4/want_textcat.m4 @@ -0,0 +1,36 @@ +AC_DEFUN([DOVECOT_WANT_TEXTCAT], [ + if test $want_textcat != no; then + if test "$PKG_CONFIG" != "" && $PKG_CONFIG --exists libexttextcat 2>/dev/null; then + PKG_CHECK_MODULES(LIBEXTTEXTCAT, libexttextcat) + TEXTCAT_DATADIR=`$PKG_CONFIG --variable=pkgdatadir libexttextcat` + AC_DEFINE(HAVE_FTS_EXTTEXTCAT,, [Define if you want exttextcat support for FTS]) + have_fts_exttextcat=yes + # Debian Wheezy workaround - LIBEXTTEXTCAT_CFLAGS include path is wrong: + AC_CHECK_HEADERS(libexttextcat/textcat.h) + else + AC_CHECK_LIB(exttextcat, special_textcat_Init, [ + have_fts_exttextcat=yes + AC_CHECK_HEADERS(libexttextcat/textcat.h) + LIBEXTTEXTCAT_LIBS=-lexttextcat + AC_DEFINE(HAVE_FTS_EXTTEXTCAT,, [Define if you want exttextcat support for FTS]) + TEXTCAT_DATADIR="/usr/share/libexttextcat" + AC_SUBST(LIBEXTTEXTCAT_LIBS) + ], [ + AC_CHECK_LIB(textcat, special_textcat_Init, [ + have_fts_textcat=yes + TEXTCAT_DATADIR="/usr/share/libtextcat" + AC_CHECK_HEADERS(libtextcat/textcat.h) + ]) + ]) + if test $want_textcat = yes && test "$have_fts_exttextcat" != yes && test "$have_fts_textcat" != yes; then + AC_ERROR([Can't build with textcat support: libtextcat or libexttextcat not found]) + fi + fi + if test "$have_fts_exttextcat" = yes || test "$have_fts_textcat" = yes; then + AC_DEFINE(HAVE_FTS_TEXTCAT,, [Define if you want textcat support for FTS]) + AC_DEFINE_UNQUOTED(TEXTCAT_DATADIR, "$TEXTCAT_DATADIR", [Points to textcat pkgdatadir containing the language files]) + fi + fi + AM_CONDITIONAL(BUILD_FTS_TEXTCAT, test "$have_fts_textcat" = "yes") + AM_CONDITIONAL(BUILD_FTS_EXTTEXTCAT, test "$have_fts_exttextcat" = "yes") +]) diff --git a/m4/want_vpopmail.m4 b/m4/want_vpopmail.m4 new file mode 100644 index 0000000000..fd8ff6adec --- /dev/null +++ b/m4/want_vpopmail.m4 @@ -0,0 +1,33 @@ +AC_DEFUN([DOVECOT_WANT_VPOPMAIL], [ + have_vpopmail=no + if test $want_vpopmail != no; then + vpop_etc="$vpopmail_home/etc" + AC_MSG_CHECKING([for vpopmail configuration at $vpop_etc/lib_deps]) + if ! test -f $vpop_etc/lib_deps; then + AC_MSG_RESULT(not found) + vpop_etc="$vpopmail_home" + AC_MSG_CHECKING([for vpopmail configuration at $vpop_etc/lib_deps]) + fi + if test -f $vpop_etc/lib_deps; then + AUTH_CFLAGS="$AUTH_CFLAGS `cat $vpop_etc/inc_deps` $CFLAGS" + AUTH_LIBS="$AUTH_LIBS `cat $vpop_etc/lib_deps`" + AC_DEFINE(USERDB_VPOPMAIL,, [Build with vpopmail support]) + AC_DEFINE(PASSDB_VPOPMAIL,, [Build with vpopmail support]) + AC_MSG_RESULT(found) + have_vpopmail=yes + else + AC_MSG_RESULT(not found) + if test $want_vpopmail = yes; then + AC_ERROR([Can't build with vpopmail support: $vpop_etc/lib_deps not found]) + fi + fi + fi + + if test $have_vpopmail = no; then + not_passdb="$not_passdb vpopmail" + not_userdb="$not_userdb vpopmail" + else + userdb="$userdb vpopmail" + passdb="$passdb vpopmail" + fi +]) diff --git a/m4/want_zlib.m4 b/m4/want_zlib.m4 new file mode 100644 index 0000000000..397b8db51b --- /dev/null +++ b/m4/want_zlib.m4 @@ -0,0 +1,14 @@ +AC_DEFUN([DOVECOT_WANT_ZLIB], [ + if test "$want_zlib" != "no"; then + AC_CHECK_HEADER(zlib.h, [ + have_zlib=yes + have_compress_lib=yes + 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]) + fi + ]) + fi +]) diff --git a/m4/warnings.m4 b/m4/warnings.m4 new file mode 100644 index 0000000000..5ae01def13 --- /dev/null +++ b/m4/warnings.m4 @@ -0,0 +1,79 @@ +# warnings.m4 serial 11 +dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Simon Josefsson + +# gl_AS_VAR_APPEND(VAR, VALUE) +# ---------------------------- +# Provide the functionality of AS_VAR_APPEND if Autoconf does not have it. +m4_ifdef([AS_VAR_APPEND], +[m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])], +[m4_define([gl_AS_VAR_APPEND], +[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])]) + + +# gl_COMPILER_OPTION_IF(OPTION, [IF-SUPPORTED], [IF-NOT-SUPPORTED], +# [PROGRAM = AC_LANG_PROGRAM()]) +# ----------------------------------------------------------------- +# Check if the compiler supports OPTION when compiling PROGRAM. +# +# FIXME: gl_Warn must be used unquoted until we can assume Autoconf +# 2.64 or newer. +AC_DEFUN([gl_COMPILER_OPTION_IF], +[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl +AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl +AS_LITERAL_IF([$1], + [m4_pushdef([gl_Positive], m4_bpatsubst([$1], [^-Wno-], [-W]))], + [gl_positive="$1" +case $gl_positive in + -Wno-*) gl_positive=-W`expr "X$gl_positive" : 'X-Wno-\(.*\)'` ;; +esac +m4_pushdef([gl_Positive], [$gl_positive])])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [ + gl_save_compiler_FLAGS="$gl_Flags" + gl_AS_VAR_APPEND(m4_defn([gl_Flags]), + [" $gl_unknown_warnings_are_errors ]m4_defn([gl_Positive])["]) + AC_LINK_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([])])], + [AS_VAR_SET(gl_Warn, [yes])], + [AS_VAR_SET(gl_Warn, [no])]) + gl_Flags="$gl_save_compiler_FLAGS" +]) +AS_VAR_IF(gl_Warn, [yes], [$2], [$3]) +m4_popdef([gl_Positive])dnl +AS_VAR_POPDEF([gl_Flags])dnl +AS_VAR_POPDEF([gl_Warn])dnl +]) + +# gl_UNKNOWN_WARNINGS_ARE_ERRORS +# ------------------------------ +# Clang doesn't complain about unknown warning options unless one also +# specifies -Wunknown-warning-option -Werror. Detect this. +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS], +[gl_COMPILER_OPTION_IF([-Werror -Wunknown-warning-option], + [gl_unknown_warnings_are_errors='-Wunknown-warning-option -Werror'], + [gl_unknown_warnings_are_errors=])]) + +# gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS], +# [PROGRAM = AC_LANG_PROGRAM()]) +# --------------------------------------------- +# Adds parameter to WARN_CFLAGS if the compiler supports it when +# compiling PROGRAM. For example, gl_WARN_ADD([-Wparentheses]). +# +# If VARIABLE is a variable name, AC_SUBST it. +AC_DEFUN([gl_WARN_ADD], +[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) +gl_COMPILER_OPTION_IF([$1], + [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])], + [], + [$3]) +m4_ifval([$2], + [AS_LITERAL_IF([$2], [AC_SUBST([$2])])], + [AC_SUBST([WARN_CFLAGS])])dnl +]) + +# Local Variables: +# mode: autoconf +# End: