~ubuntu-branches/ubuntu/wily/dovecot/wily

« back to all changes in this revision

Viewing changes to configure.ac

  • Committer: Package Import Robot
  • Author(s): Jaldhar H. Vyas
  • Date: 2013-09-09 00:57:32 UTC
  • mfrom: (1.13.11)
  • mto: (4.8.5 experimental) (1.16.1)
  • mto: This revision was merged to the branch mainline in revision 97.
  • Revision ID: package-import@ubuntu.com-20130909005732-dn1eell8srqbhh0e
Tags: upstream-2.2.5
ImportĀ upstreamĀ versionĀ 2.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
AC_PREREQ([2.59])
 
2
 
 
3
# Be sure to update ABI version also if anything changes that might require
 
4
# recompiling plugins. Most importantly that means if any structs are changed.
 
5
AC_INIT([Dovecot],[2.2.5],[dovecot@dovecot.org])
 
6
AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv5($PACKAGE_VERSION)", [Dovecot ABI version])
 
7
 
 
8
AC_CONFIG_SRCDIR([src])
 
9
 
 
10
AM_INIT_AUTOMAKE([foreign])
 
11
 
 
12
AM_MAINTAINER_MODE
 
13
PKG_PROG_PKG_CONFIG
 
14
 
 
15
ACLOCAL_AMFLAGS='-I $(top_srcdir)'
 
16
AC_SUBST(ACLOCAL_AMFLAGS)
 
17
 
 
18
dnl TEST_WITH(name, value, [plugin])
 
19
AC_DEFUN([TEST_WITH], [
 
20
  want=want_`echo $1|sed s/-/_/g`
 
21
  if test $2 = yes || test $2 = no || test $2 = auto; then
 
22
    eval $want=$2
 
23
  elif test $2 = plugin; then
 
24
    if test "$3" = plugin; then
 
25
      eval $want=plugin
 
26
    else
 
27
      AC_ERROR([--with-$1=plugin not supported])
 
28
    fi
 
29
  elif `echo $2|grep '^/' >/dev/null`; then
 
30
    AC_ERROR([--with-$1=path not supported. You may want to use instead:
 
31
CPPFLAGS=-I$2/include LDFLAGS=-L$2/lib ./configure --with-$1])
 
32
  else
 
33
    AC_ERROR([--with-$1: Unknown value: $2])
 
34
  fi
 
35
])
 
36
 
 
37
AC_ARG_ENABLE(devel-checks,
 
38
AS_HELP_STRING([--enable-devel-checks], [Enable some extra expensive checks for developers]),
 
39
        if test x$enableval = xyes; then
 
40
                AC_DEFINE(DEBUG,, Build with extra debugging checks)
 
41
                want_devel_checks=yes
 
42
        fi)
 
43
 
 
44
AC_ARG_ENABLE(asserts,
 
45
AS_HELP_STRING([--enable-asserts], [Enable asserts (default)]),
 
46
        if test x$enableval = xno; then
 
47
                AC_DEFINE(DISABLE_ASSERTS,, Disable asserts)
 
48
        fi)
 
49
 
 
50
AC_ARG_WITH(shared-libs,
 
51
AS_HELP_STRING([--with-shared-libs], [Link binaries using shared Dovecot libraries (default)]),
 
52
        want_shared_libs=$withval,
 
53
        want_shared_libs=yes)
 
54
AM_CONDITIONAL(BUILD_SHARED_LIBS, test "$want_shared_libs" = "yes")
 
55
 
 
56
AC_ARG_WITH(mem-align,
 
57
AS_HELP_STRING([--with-mem-align=BYTES], [Set the memory alignment (default: 8)]),
 
58
        mem_align=$withval,
 
59
        mem_align=8)
 
60
 
 
61
AC_ARG_WITH(ioloop,
 
62
AS_HELP_STRING([--with-ioloop=IOLOOP], [Specify the I/O loop method to use (epoll, kqueue, poll; best for the fastest available; default is best)]),
 
63
        ioloop=$withval,
 
64
        ioloop=best)
 
65
 
 
66
AC_ARG_WITH(notify,
 
67
AS_HELP_STRING([--with-notify=NOTIFY], [Specify the file system notification method to use (inotify, kqueue, dnotify, none; default is detected in the above order)]),
 
68
        notify=$withval,
 
69
        notify=)
 
70
 
 
71
AC_ARG_WITH(nss,
 
72
AS_HELP_STRING([--with-nss], [Build with NSS module support (auto)]),
 
73
  TEST_WITH(nss, $withval),
 
74
  want_nss=auto)
 
75
 
 
76
AC_ARG_WITH(shadow,
 
77
AS_HELP_STRING([--with-shadow], [Build with shadow password support (auto)]),
 
78
  TEST_WITH(shadow, $withval),
 
79
  want_shadow=auto)
 
80
 
 
81
AC_ARG_WITH(pam,
 
82
AS_HELP_STRING([--with-pam], [Build with PAM support (auto)]),
 
83
  TEST_WITH(pam, $withval),
 
84
  want_pam=auto)
 
85
 
 
86
AC_ARG_WITH(bsdauth,
 
87
AS_HELP_STRING([--with-bsdauth], [Build with BSD authentication support (auto)]),
 
88
  TEST_WITH(bsdauth, $withval),
 
89
  want_bsdauth=auto)
 
90
 
 
91
AC_ARG_WITH(gssapi,
 
92
AS_HELP_STRING([--with-gssapi=yes|plugin Build with GSSAPI authentication support]),
 
93
  TEST_WITH(gssapi, $withval, plugin),
 
94
  want_gssapi=no)
 
95
 
 
96
AC_ARG_WITH(sia,
 
97
AS_HELP_STRING([--with-sia], [Build with Tru64 SIA support]),
 
98
  TEST_WITH(sia, $withval),
 
99
  want_sia=no)
 
100
 
 
101
AC_ARG_WITH(ldap,
 
102
AS_HELP_STRING([--with-ldap=yes|plugin], [Build with LDAP support]),
 
103
  TEST_WITH(ldap, $withval, plugin),
 
104
  want_ldap=no)
 
105
 
 
106
AC_ARG_WITH(vpopmail,
 
107
AS_HELP_STRING([--with-vpopmail], [Build with vpopmail support (auto)]),
 
108
        if test x$withval = xno; then
 
109
                want_vpopmail=no
 
110
        else
 
111
                if test x$withval = xyes || test x$withval = xauto; then
 
112
                        vpopmail_home="`echo ~vpopmail`"
 
113
                        want_vpopmail=$withval
 
114
                else
 
115
                        vpopmail_home="$withval"
 
116
                        want_vpopmail=yes
 
117
                fi
 
118
        fi, [
 
119
                want_vpopmail=no
 
120
        ])
 
121
 
 
122
# Berkeley DB support is more or less broken. Disabled for now.
 
123
#AC_ARG_WITH(db,
 
124
#AS_HELP_STRING([--with-db], [Build with Berkeley DB support]),
 
125
#  TEST_WITH(db, $withval),
 
126
#  want_db=no)
 
127
want_db=no
 
128
 
 
129
AC_ARG_WITH(cdb,
 
130
AS_HELP_STRING([--with-cdb], [Build with CDB support]),
 
131
  TEST_WITH(cdb, $withval),
 
132
  want_cdb=no)
 
133
 
 
134
dnl The --with-sql is useful only if Dovecot is being built with all the SQL
 
135
dnl drivers as modules. If any SQL driver is built-in, this option is ignored.
 
136
AC_ARG_WITH(sql,
 
137
AS_HELP_STRING([--with-sql=yes|plugin], [Build with generic SQL support]),
 
138
  TEST_WITH(sql, $withval, plugin),
 
139
  want_sql=no)
 
140
 
 
141
AC_ARG_WITH(pgsql,
 
142
AS_HELP_STRING([--with-pgsql], [Build with PostgreSQL driver support]),
 
143
  TEST_WITH(pgsql, $withval),
 
144
  want_pgsql=no)
 
145
 
 
146
AC_ARG_WITH(mysql,
 
147
AS_HELP_STRING([--with-mysql], [Build with MySQL driver support]),
 
148
  TEST_WITH(mysql, $withval),
 
149
  want_mysql=no)
 
150
 
 
151
AC_ARG_WITH(sqlite,
 
152
AS_HELP_STRING([--with-sqlite], [Build with SQLite3 driver support]),
 
153
  TEST_WITH(sqlite, $withval),
 
154
  want_sqlite=no)
 
155
 
 
156
AC_ARG_WITH(lucene,
 
157
AS_HELP_STRING([--with-lucene], [Build with CLucene full text search support]),
 
158
  TEST_WITH(lucene, $withval),
 
159
  want_lucene=no)
 
160
AM_CONDITIONAL(BUILD_LUCENE, test "$want_lucene" = "yes")
 
161
 
 
162
AC_ARG_WITH(stemmer,
 
163
AS_HELP_STRING([--with-stemmer], [Build with libstemmer support (for CLucene)]),
 
164
  TEST_WITH(stemmer, $withval),
 
165
  want_stemmer=auto)
 
166
 
 
167
AC_ARG_WITH(solr,
 
168
AS_HELP_STRING([--with-solr], [Build with Solr full text search support]),
 
169
  TEST_WITH(solr, $withval),
 
170
  want_solr=no)
 
171
 
 
172
AC_ARG_WITH(zlib,
 
173
AS_HELP_STRING([--with-zlib], [Build with zlib compression support]),
 
174
  TEST_WITH(zlib, $withval),
 
175
  want_zlib=auto)
 
176
 
 
177
AC_ARG_WITH(bzlib,
 
178
AS_HELP_STRING([--with-bzlib], [Build with bzlib compression support]),
 
179
  TEST_WITH(bzlib, $withval),
 
180
  want_bzlib=auto)
 
181
 
 
182
AC_ARG_WITH(libcap,
 
183
AS_HELP_STRING([--with-libcap], [Build with libcap support (Dropping capabilities).]),
 
184
  TEST_WITH(libcap, $withval),
 
185
  want_libcap=auto)
 
186
 
 
187
AC_ARG_WITH(libwrap,
 
188
AS_HELP_STRING([--with-libwrap], [Build with libwrap, ie. TCP-wrappers]),
 
189
  TEST_WITH(libwrap, $withval),
 
190
  want_libwrap=no)
 
191
 
 
192
AC_ARG_WITH(ssl,
 
193
AS_HELP_STRING([--with-ssl=gnutls|openssl], [Build with GNUTLS or OpenSSL (default)]),
 
194
        if test x$withval = xno; then
 
195
                want_gnutls=no
 
196
                want_openssl=no
 
197
        elif test x$withval = xgnutls; then
 
198
                AC_ERROR([GNUTLS support is broken currently])
 
199
                want_gnutls=yes
 
200
                want_openssl=no
 
201
        elif test x$withval = xopenssl; then
 
202
                want_gnutls=no
 
203
                want_openssl=yes
 
204
        elif test x$withval = xyes; then
 
205
                want_gnutls=no
 
206
                want_openssl=yes
 
207
        else
 
208
                AC_ERROR([--with-ssl: Invalid value: $withval])
 
209
        fi, [
 
210
                want_gnutls=no
 
211
                want_openssl=auto
 
212
        ])
 
213
 
 
214
AC_ARG_WITH(ssldir,
 
215
AS_HELP_STRING([--with-ssldir=DIR], [SSL base directory for certificates (/etc/ssl)]),
 
216
        ssldir="$withval",
 
217
        ssldir=/etc/ssl
 
218
)
 
219
AC_SUBST(ssldir)
 
220
 
 
221
AC_ARG_WITH(rundir,
 
222
AS_HELP_STRING([--with-rundir=DIR], [Runtime data directory (LOCALSTATEDIR/run/dovecot)]),
 
223
        rundir="$withval",
 
224
        rundir=$localstatedir/run/$PACKAGE
 
225
)
 
226
AC_SUBST(rundir)
 
227
 
 
228
AC_ARG_WITH(statedir,
 
229
AS_HELP_STRING([--with-statedir=DIR], [Permanent data directory (LOCALSTATEDIR/lib/dovecot)]),
 
230
        statedir="$withval",
 
231
        statedir=$localstatedir/lib/$PACKAGE
 
232
)
 
233
AC_SUBST(statedir)
 
234
 
 
235
AC_ARG_WITH([systemdsystemunitdir],
 
236
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files (auto=detect)]), [
 
237
        if test "$withval" = "auto"; then
 
238
                systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd`
 
239
        elif test "$withval" != "no"; then
 
240
                systemdsystemunitdir=$withval
 
241
        fi
 
242
], [])
 
243
if test "$systemdsystemunitdir" != ""; then
 
244
        AC_SUBST(systemdsystemunitdir)
 
245
        AC_DEFINE(HAVE_SYSTEMD,, Define if you want to use systemd socket activation)
 
246
fi
 
247
AM_CONDITIONAL(HAVE_SYSTEMD, test "$systemdsystemunitdir" != "")
 
248
 
 
249
AC_ARG_WITH(gc,
 
250
AS_HELP_STRING([--with-gc], [Use Boehm garbage collector]),
 
251
  TEST_WITH(gc, $withval),
 
252
  want_gc=no)
 
253
 
 
254
AC_ARG_WITH(storages,
 
255
AS_HELP_STRING([--with-storages], [Build with specified mail storage formats (mdbox sdbox maildir mbox cydir imapc pop3c)]), [
 
256
        if test "$withval" = "yes" || test "$withval" = "no"; then
 
257
                AC_MSG_ERROR([--with-storages needs storage list as parameter])
 
258
        fi
 
259
        mail_storages="shared `echo "$withval"|sed 's/,/ /g'`" ],
 
260
        mail_storages="shared mdbox sdbox maildir mbox cydir imapc pop3c")
 
261
AC_SUBST(mail_storages)
 
262
mail_storages="$mail_storages raw fail"
 
263
# drop duplicates
 
264
duplicates=`(for i in $mail_storages; do echo $i; done)|sort|uniq -d|xargs echo`
 
265
if test "$duplicates" != ""; then
 
266
  AC_ERROR([Duplicate --with-storages: $duplicates])
 
267
fi
 
268
 
 
269
DC_DOVECOT_MODULEDIR
 
270
 
 
271
AC_ARG_WITH(docs,
 
272
AS_HELP_STRING([--with-docs], [Install documentation (default)]),
 
273
        if test x$withval = xno; then
 
274
                want_docs=no
 
275
        else
 
276
                want_docs=yes
 
277
        fi,
 
278
        want_docs=yes)
 
279
AM_CONDITIONAL(BUILD_DOCS, test "$want_docs" = "yes")
 
280
 
 
281
dnl always enable all of the passbs and userdbs that don't require extra libs
 
282
want_passwd=yes
 
283
want_passwd_file=yes
 
284
want_checkpassword=yes
 
285
want_prefetch_userdb=yes
 
286
 
 
287
AC_ISC_POSIX
 
288
AC_PROG_CC
 
289
AC_PROG_CPP
 
290
AC_PROG_CXX # lucene plugin needs this
 
291
AC_HEADER_STDC
 
292
AC_C_INLINE
 
293
AC_PROG_LIBTOOL
 
294
AM_ICONV
 
295
 
 
296
AC_DEFINE_UNQUOTED(DOVECOT_NAME, "$PACKAGE_NAME", Dovecot name)
 
297
AC_DEFINE_UNQUOTED(DOVECOT_STRING, "$PACKAGE_STRING", Dovecot string)
 
298
AC_DEFINE_UNQUOTED(DOVECOT_VERSION, "$PACKAGE_VERSION", Dovecot version)
 
299
 
 
300
AC_DEFINE([DOVECOT_VERSION_MAJOR], regexp(AC_PACKAGE_VERSION, [^\([0-9]+\)\.\([0-9]+\)], [\1]), [Dovecot major version])
 
301
AC_DEFINE([DOVECOT_VERSION_MINOR], regexp(AC_PACKAGE_VERSION, [^\([0-9]+\)\.\([0-9]+\)], [\2]), [Dovecot minor version])
 
302
 
 
303
AC_CHECK_HEADERS(strings.h stdint.h unistd.h dirent.h malloc.h inttypes.h \
 
304
  sys/uio.h sys/sysmacros.h sys/resource.h sys/select.h libgen.h \
 
305
  sys/quota.h sys/fs/ufs_quota.h ufs/ufs/quota.h jfs/quota.h \
 
306
  quota.h sys/fs/quota_common.h \
 
307
  mntent.h sys/mnttab.h sys/event.h sys/time.h sys/mkdev.h linux/dqblk_xfs.h \
 
308
  xfs/xqm.h execinfo.h ucontext.h malloc_np.h sys/utsname.h sys/vmount.h \
 
309
  sys/utsname.h glob.h linux/falloc.h ucred.h sys/ucred.h)
 
310
 
 
311
dnl * clang check
 
312
have_clang=no
 
313
if $CC -dM -E -x c /dev/null | grep __clang__ > /dev/null 2>&1; then
 
314
  have_clang=yes
 
315
fi
 
316
 
 
317
dnl * gcc specific options
 
318
if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
 
319
        # -Wcast-qual -Wcast-align -Wconversion -Wunreachable-code # too many warnings
 
320
        # -Wstrict-prototypes -Wredundant-decls # may give warnings in some systems
 
321
        # -Wmissing-format-attribute -Wmissing-noreturn -Wwrite-strings # a couple of warnings
 
322
        CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast"
 
323
 
 
324
        if test "$have_clang" = "yes"; then
 
325
          AC_TRY_COMPILE([
 
326
          #if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 3)
 
327
          #  error new clang
 
328
          #endif
 
329
          ],,,[
 
330
            # clang 3.3+ unfortunately this gives warnings with hash.h
 
331
            CFLAGS="$CFLAGS -Wno-duplicate-decl-specifier"
 
332
          ])
 
333
        else
 
334
          # This is simply to avoid warning when building strftime() wrappers..
 
335
          CFLAGS="$CFLAGS -fno-builtin-strftime"
 
336
        fi
 
337
 
 
338
        AC_TRY_COMPILE([
 
339
        #if __GNUC__ < 4
 
340
        #  error old gcc
 
341
        #endif
 
342
        ],,[
 
343
          # gcc4
 
344
          CFLAGS="$CFLAGS -Wstrict-aliasing=2"
 
345
        ])
 
346
 
 
347
        # Use std=gnu99 if we have new enough gcc
 
348
        old_cflags=$CFLAGS
 
349
        CFLAGS="-std=gnu99"
 
350
        AC_TRY_COMPILE([
 
351
        ],, [
 
352
          CFLAGS="$CFLAGS $old_cflags"
 
353
        ], [
 
354
          CFLAGS="$old_cflags"
 
355
        ])
 
356
fi
 
357
if test "$have_clang" = "yes"; then
 
358
  # clang specific options
 
359
  if test "$want_devel_checks" = "yes"; then
 
360
    # FIXME: enable once md[45], sha[12] can be compiled without
 
361
    #CFLAGS="$CFLAGS -fsanitize=integer,undefined -ftrapv"
 
362
    :
 
363
  fi
 
364
fi
 
365
 
 
366
dnl **
 
367
dnl ** just some generic stuff...
 
368
dnl **
 
369
 
 
370
AC_SEARCH_LIBS(socket, socket)
 
371
AC_SEARCH_LIBS(inet_addr, nsl)
 
372
AC_SEARCH_LIBS(fdatasync, rt, [
 
373
  AC_DEFINE(HAVE_FDATASYNC,, Define if you have fdatasync())
 
374
])
 
375
 
 
376
if test $want_libcap != no; then
 
377
  AC_CHECK_LIB(cap, cap_init, [
 
378
    AC_DEFINE(HAVE_LIBCAP,, libcap is installed for cap_init())
 
379
    LIBCAP="-lcap"
 
380
    AC_SUBST(LIBCAP)
 
381
  ], [
 
382
    if test "$want_libcap" = "yes"; then
 
383
      AC_ERROR([Can't build with libcap support: libcap not found])
 
384
    fi
 
385
  ])
 
386
fi
 
387
 
 
388
have_libwrap=no
 
389
if test $want_libwrap != no; then
 
390
  AC_CHECK_HEADER(tcpd.h, [
 
391
    old_LIBS=$LIBS
 
392
 
 
393
    AC_CACHE_CHECK([whether we have libwrap],i_cv_have_libwrap,[
 
394
      AC_TRY_COMPILE([
 
395
        #include <tcpd.h>
 
396
        int allow_severity = 0;
 
397
        int deny_severity = 0;
 
398
      ], [
 
399
        request_init((void *)0);
 
400
      ], [
 
401
        i_cv_have_libwrap=yes
 
402
      ], [
 
403
        i_cv_have_libwrap=no
 
404
      ])
 
405
    ])
 
406
    if test $i_cv_have_libwrap = yes; then
 
407
      AC_DEFINE(HAVE_LIBWRAP,, Define if you have libwrap)
 
408
      LIBWRAP_LIBS=-lwrap
 
409
      AC_SUBST(LIBWRAP_LIBS)
 
410
      have_libwrap=yes
 
411
    else
 
412
      if test "$want_libwrap" = "yes"; then
 
413
        AC_ERROR([Can't build with libwrap support: libwrap not found])
 
414
      fi
 
415
    fi
 
416
    LIBS=$old_LIBS
 
417
  ], [
 
418
    if test "$want_libwrap" = "yes"; then
 
419
      AC_ERROR([Can't build with libwrap support: tcpd.h not found])
 
420
    fi
 
421
  ])
 
422
fi
 
423
AM_CONDITIONAL(TCPWRAPPERS, test "$have_libwrap" = "yes")
 
424
 
 
425
AC_DEFINE(PACKAGE_WEBPAGE, "http://www.dovecot.org/", Support URL)
 
426
 
 
427
dnl * after -lsocket and -lnsl tests, inet_aton() may be in them
 
428
AC_CHECK_FUNCS(fcntl flock lockf inet_aton sigaction getpagesize madvise \
 
429
               strcasecmp stricmp vsyslog writev pread uname unsetenv \
 
430
               setrlimit setproctitle seteuid setreuid setegid setresgid \
 
431
               strtoull strtoll strtouq strtoq getmntinfo \
 
432
               setpriority quotactl getmntent kqueue kevent backtrace_symbols \
 
433
               walkcontext dirfd clearenv malloc_usable_size glob fallocate \
 
434
               posix_fadvise getpeereid getpeerucred)
 
435
 
 
436
AC_CHECK_TYPES([struct sockpeercred],,,[
 
437
#include <sys/types.h>
 
438
#include <sys/socket.h>
 
439
])
 
440
 
 
441
AC_SEARCH_LIBS(clock_gettime, rt, [
 
442
  AC_DEFINE(HAVE_CLOCK_GETTIME,, Define if you have the clock_gettime function)
 
443
])
 
444
 
 
445
AC_CACHE_CHECK([for typeof],i_cv_have_typeof,[
 
446
  AC_TRY_COMPILE([
 
447
  ], [
 
448
    int foo;
 
449
    typeof(foo) bar;
 
450
  ], [
 
451
    i_cv_have_typeof=yes
 
452
  ], [
 
453
    i_cv_have_typeof=no
 
454
  ])
 
455
])
 
456
if test $i_cv_have_typeof = yes; then
 
457
  AC_DEFINE(HAVE_TYPEOF,, Define if you have typeof())
 
458
fi
 
459
 
 
460
dnl strtoimax and strtoumax are macros in HP-UX, so inttypes.h must be included
 
461
dnl Link instead of just compiling since there's something wrong with Tru64
 
462
AC_CACHE_CHECK([for strtoimax],i_cv_have_strtoimax,[
 
463
  AC_TRY_LINK([
 
464
    #include <inttypes.h>
 
465
  ], [
 
466
    strtoimax(0, 0, 0);
 
467
  ], [
 
468
    i_cv_have_strtoimax=yes
 
469
  ], [
 
470
    i_cv_have_strtoimax=no
 
471
  ])
 
472
])
 
473
if test $i_cv_have_strtoimax = yes; then
 
474
  AC_DEFINE(HAVE_STRTOIMAX,, Define if you have strtoimax function)
 
475
fi
 
476
 
 
477
AC_CACHE_CHECK([for strtoumax],i_cv_have_strtoumax,[
 
478
  AC_TRY_LINK([
 
479
    #include <inttypes.h>
 
480
  ], [
 
481
    strtoumax(0, 0, 0);
 
482
  ], [
 
483
    i_cv_have_strtoumax=yes
 
484
  ], [
 
485
    i_cv_have_strtoumax=no
 
486
  ])
 
487
])
 
488
if test $i_cv_have_strtoumax = yes; then
 
489
  AC_DEFINE(HAVE_STRTOUMAX,, Define if you have strtoumax function)
 
490
fi
 
491
 
 
492
dnl * I/O loop function
 
493
have_ioloop=no
 
494
 
 
495
if test "$ioloop" = "best" || test "$ioloop" = "epoll"; then
 
496
  AC_CACHE_CHECK([whether we can use epoll],i_cv_epoll_works,[
 
497
    AC_TRY_RUN([
 
498
      #include <sys/epoll.h>
 
499
  
 
500
      int main()
 
501
      {
 
502
        return epoll_create(5) < 1;
 
503
      }
 
504
    ], [
 
505
      i_cv_epoll_works=yes
 
506
    ], [
 
507
      i_cv_epoll_works=no
 
508
    ])
 
509
  ])
 
510
  if test $i_cv_epoll_works = yes; then
 
511
    AC_DEFINE(IOLOOP_EPOLL,, Implement I/O loop with Linux 2.6 epoll())
 
512
    have_ioloop=yes
 
513
    ioloop=epoll
 
514
  else
 
515
    if test "$ioloop" = "epoll" ; then
 
516
      AC_MSG_ERROR([epoll ioloop requested but epoll_create() is not available])
 
517
    fi
 
518
  fi
 
519
fi
 
520
 
 
521
if test "$ioloop" = "best" || test "$ioloop" = "kqueue"; then
 
522
    if test "$ac_cv_func_kqueue" = yes && test "$ac_cv_func_kevent" = yes; then
 
523
      AC_DEFINE(IOLOOP_KQUEUE,, [Implement I/O loop with BSD kqueue()])
 
524
      ioloop=kqueue
 
525
      have_ioloop=yes
 
526
    elif test "$ioloop" = "kqueue"; then
 
527
      AC_MSG_ERROR([kqueue ioloop requested but kqueue() is not available])
 
528
    fi
 
529
fi
 
530
 
 
531
if test "$ioloop" = "best" || test "$ioloop" = "poll"; then
 
532
  AC_CHECK_FUNC(poll, [
 
533
    AC_DEFINE(IOLOOP_POLL,, Implement I/O loop with poll())
 
534
    ioloop=poll
 
535
    have_ioloop=yes
 
536
  ])
 
537
fi
 
538
 
 
539
if test "$have_ioloop" = "no"; then
 
540
  AC_DEFINE(IOLOOP_SELECT,, Implement I/O loop with select())
 
541
  ioloop="select"
 
542
fi
 
543
 
 
544
have_notify=none
 
545
 
 
546
if test "$notify" = "" || test "$notify" = "inotify" ; then
 
547
  dnl * inotify?
 
548
  AC_CACHE_CHECK([whether we can use inotify],i_cv_inotify_works,[
 
549
    AC_TRY_RUN([
 
550
      #define _GNU_SOURCE
 
551
      #include <sys/ioctl.h>
 
552
      #include <fcntl.h>
 
553
      #include <sys/inotify.h>
 
554
      #include <stdio.h>
 
555
    
 
556
      int main()
 
557
      {
 
558
        int wd, fd;
 
559
        char * fn = "/tmp";
 
560
      
 
561
        fd = inotify_init ();
 
562
        if (fd < 0)
 
563
          {
 
564
            perror ("inotify_init");
 
565
            return 1;
 
566
          }
 
567
  
 
568
        wd = inotify_add_watch (fd, fn, IN_ALL_EVENTS);
 
569
  
 
570
        if (wd < 0)
 
571
          {
 
572
            perror ("inotify_add_watch");
 
573
            return 2;
 
574
          }
 
575
  
 
576
        inotify_rm_watch (fd, wd);
 
577
  
 
578
        close (fd);
 
579
        return 0;
 
580
      }
 
581
    ], [
 
582
      i_cv_inotify_works=yes
 
583
    ], [
 
584
      i_cv_inotify_works=no
 
585
    ])
 
586
  ])
 
587
  if test $i_cv_inotify_works = yes; then
 
588
    have_notify=inotify
 
589
    notify=inotify
 
590
    AC_DEFINE(IOLOOP_NOTIFY_INOTIFY,, Use Linux inotify)
 
591
  else
 
592
    if test "$notify" = "inotify"; then
 
593
      AC_MSG_ERROR([inotify requested but not available])
 
594
      notify=""
 
595
    fi
 
596
  fi
 
597
fi
 
598
 
 
599
if (test "$notify" = "" && test "$ioloop" = kqueue) || test "$notify" = "kqueue"; then
 
600
  dnl * BSD kqueue() notify
 
601
  AC_MSG_CHECKING([whether we can use BSD kqueue() notify])
 
602
  if test "$ac_cv_func_kqueue" = yes && test "$ac_cv_func_kevent" = yes ; then
 
603
    have_notify=kqueue
 
604
    notify=kqueue
 
605
    AC_MSG_RESULT("yes")
 
606
    AC_DEFINE(IOLOOP_NOTIFY_KQUEUE,,
 
607
      Use BSD kqueue directory changes notificaton)
 
608
  else 
 
609
    AC_MSG_RESULT("no")
 
610
    if test "$notify" = "kqueue" ; then
 
611
      AC_MSG_ERROR([kqueue notify requested but kqueue() is not available])
 
612
      notify=""
 
613
    fi
 
614
  fi
 
615
fi
 
616
 
 
617
if test "$notify" = "" || test "$notify" = "dnotify"; then
 
618
  dnl * dnotify?
 
619
  AC_CACHE_CHECK([whether we can use dnotify],i_cv_have_dnotify,[
 
620
    AC_TRY_COMPILE([
 
621
      #define _GNU_SOURCE
 
622
      #include <fcntl.h>
 
623
      #include <signal.h>
 
624
      #include <unistd.h>
 
625
    ], [
 
626
      fcntl(0, F_SETSIG, SIGRTMIN);
 
627
      fcntl(0, F_NOTIFY, DN_CREATE | DN_DELETE | DN_RENAME | DN_MULTISHOT);
 
628
    ], [
 
629
      i_cv_have_dnotify=yes
 
630
    ], [
 
631
      i_cv_have_dnotify=no
 
632
    ])
 
633
  ])
 
634
  if test $i_cv_have_dnotify = yes; then
 
635
    AC_DEFINE(IOLOOP_NOTIFY_DNOTIFY,, Use Linux dnotify)
 
636
    have_notify=dnotify
 
637
    notify=dnotify
 
638
  else
 
639
    if test "$notify" = "dnotify"; then
 
640
      AC_MSG_ERROR([dnotify requested but not available])
 
641
    fi
 
642
  fi
 
643
fi
 
644
 
 
645
if test "$have_notify" = "none"; then
 
646
  AC_DEFINE(IOLOOP_NOTIFY_NONE,, No special notify support)
 
647
fi
 
648
 
 
649
AC_CACHE_CHECK([whether we have glibc],i_cv_have_glibc,[
 
650
  AC_TRY_COMPILE([
 
651
    #include <stdlib.h>
 
652
    #ifdef __GLIBC__
 
653
      we have glibc
 
654
    #endif
 
655
  ],, [
 
656
    i_cv_have_glibc=no
 
657
  ], [
 
658
    i_cv_have_glibc=yes
 
659
  ])
 
660
])
 
661
if test "$i_cv_have_glibc" = "yes"; then
 
662
  AC_DEFINE(PREAD_WRAPPERS,, Define if pread/pwrite needs _XOPEN_SOURCE 500)
 
663
fi
 
664
 
 
665
dnl * Old glibcs have broken posix_fallocate(). Make sure not to use it.
 
666
dnl * It may also be broken in AIX.
 
667
AC_CACHE_CHECK([whether posix_fallocate() works],i_cv_posix_fallocate_works,[
 
668
  AC_TRY_RUN([
 
669
    #define _XOPEN_SOURCE 600
 
670
    #include <stdio.h>
 
671
    #include <stdlib.h>
 
672
    #include <fcntl.h>
 
673
    #include <unistd.h>
 
674
    #if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 7)
 
675
      possibly broken posix_fallocate
 
676
    #endif
 
677
    int main() {
 
678
      int fd = creat("conftest.temp", 0600);
 
679
      int ret;
 
680
      if (fd == -1) {
 
681
        perror("creat()");
 
682
        return 2;
 
683
      }
 
684
      ret = posix_fallocate(fd, 1024, 1024) < 0 ? 1 : 0;
 
685
      unlink("conftest.temp");
 
686
      return ret;
 
687
    }
 
688
  ], [
 
689
    i_cv_posix_fallocate_works=yes
 
690
  ], [
 
691
    i_cv_posix_fallocate_works=no
 
692
  ])
 
693
])
 
694
if test $i_cv_posix_fallocate_works = yes; then
 
695
  AC_DEFINE(HAVE_POSIX_FALLOCATE,, Define if you have a working posix_fallocate())
 
696
fi
 
697
 
 
698
dnl * OS specific options
 
699
DC_PLUGIN_DEPS
 
700
case "$host_os" in
 
701
        hpux*)
 
702
                CFLAGS="$CFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED"
 
703
                # for getting fd_send/fd_recv working:
 
704
                LDFLAGS="$LDFLAGS -Wl,+b,:"
 
705
                LIBS="-lxnet $LIBS"
 
706
                AC_DEFINE(PREAD_BROKEN,, Defint if pread/pwrite implementation is broken)
 
707
                ;;
 
708
        linux*|darwin*)
 
709
                AC_DEFINE(PROCTITLE_HACK,, Define if process title can be changed by modifying argv)
 
710
                ;;
 
711
        *)
 
712
                ;;
 
713
esac
 
714
 
 
715
AC_CHECK_SIZEOF(int)
 
716
AC_CHECK_SIZEOF(long)
 
717
AC_CHECK_SIZEOF(void *)
 
718
AC_CHECK_SIZEOF(long long)
 
719
 
 
720
AC_DEFUN([AC_TYPEOF], [
 
721
  dnl * first check if we can get the size with redefining typedefs
 
722
 
 
723
  order="$2"
 
724
  if test "$2" = ""; then
 
725
    order="int long long-long"
 
726
  fi
 
727
 
 
728
  result=""
 
729
  visible="unknown"
 
730
  AC_MSG_CHECKING([type of $1])
 
731
  AC_CACHE_VAL(i_cv_typeof_$1,[
 
732
  if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
 
733
    dnl * try with printf() + -Werror
 
734
    old_CFLAGS="$CFLAGS"
 
735
    CFLAGS="$CFLAGS -Werror"
 
736
 
 
737
    for type in $order; do
 
738
      case "$type" in
 
739
        int)
 
740
          fmt="%d"
 
741
          ;;
 
742
        unsigned-int)
 
743
          fmt="%u"
 
744
          ;;
 
745
        long)
 
746
          fmt="%ld"
 
747
          ;;
 
748
        unsigned-long)
 
749
          fmt="%lu"
 
750
          ;;
 
751
        long-long)
 
752
          fmt="%lld"
 
753
          ;;
 
754
        unsigned-long-long)
 
755
          fmt="%llu"
 
756
          ;;
 
757
        *)
 
758
          fmt=""
 
759
          ;;
 
760
      esac
 
761
 
 
762
      if test "$fmt" != ""; then
 
763
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
764
          #include <sys/types.h>
 
765
          #include <stdio.h>
 
766
        ]], [[
 
767
          printf("$fmt", ($1)0);
 
768
        ]])],[
 
769
          if test "$result" != ""; then
 
770
            dnl * warning check isn't working
 
771
            result=""
 
772
            visible="unknown"
 
773
            break
 
774
          fi
 
775
          result="`echo $type|sed 's/-/ /g'`"
 
776
          visible="$result"
 
777
        ],[])
 
778
      fi
 
779
    done
 
780
    CFLAGS="$old_CFLAGS"
 
781
  fi
 
782
 
 
783
  if test "$result" = ""; then
 
784
    for type in $order; do
 
785
      type="`echo $type|sed 's/-/ /g'`"
 
786
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
787
        #include <sys/types.h>
 
788
        typedef $type $1;
 
789
      ]], [[]])],[
 
790
        if test "$result" != ""; then
 
791
          dnl * compiler allows redefining to anything
 
792
          result=""
 
793
          visible="unknown"
 
794
          break
 
795
        fi
 
796
        result="$type"
 
797
        visible="$type"
 
798
      ],[])
 
799
    done
 
800
  fi
 
801
 
 
802
  if test "$result" = ""; then
 
803
    dnl * check with sizes
 
804
 
 
805
    dnl * older autoconfs don't include sys/types.h, so do it manually
 
806
    AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
807
      #include <stdio.h>
 
808
      #include <sys/types.h>
 
809
      int main() {
 
810
        FILE *f=fopen("conftestval", "w");
 
811
        if (!f) exit(1);
 
812
        fprintf(f, "%d\n", sizeof($1));
 
813
        exit(0);
 
814
      }
 
815
    ]])],[
 
816
      size=`cat conftestval`
 
817
      rm -f conftestval
 
818
 
 
819
      for type in $order; do
 
820
        actype="ac_cv_sizeof_`echo $type|sed 's/-/_/g'`"
 
821
        if test "$size" = "`eval echo \\$$actype`"; then
 
822
          result="`echo $type|sed 's/-/ /g'`"
 
823
          visible="`expr $size \* 8`bit (using $result)"
 
824
          break
 
825
        fi
 
826
      done
 
827
      if test "$result" = ""; then
 
828
        result=unknown
 
829
        visible="`expr $size \* 8`bit (unknown type)"
 
830
      fi
 
831
    ],[],[])
 
832
  fi
 
833
  i_cv_typeof_$1=$result/$visible
 
834
  ])
 
835
 
 
836
  typeof_$1=`echo $i_cv_typeof_$1 | sed s,/.*$,,`
 
837
  visible=`echo $i_cv_typeof_$1 | sed s,^.*/,,`
 
838
  AC_MSG_RESULT($visible)
 
839
])
 
840
 
 
841
AC_SYS_LARGEFILE
 
842
AC_CHECK_TYPES(_Bool)
 
843
 
 
844
AC_CHECK_TYPE(uoff_t, [
 
845
  have_uoff_t=yes
 
846
  AC_DEFINE(HAVE_UOFF_T,, Define if you have a native uoff_t type)
 
847
], [
 
848
  have_uoff_t=no
 
849
])
 
850
 
 
851
AC_TYPEOF(off_t, long int long-long)
 
852
case "$typeof_off_t" in
 
853
  int)
 
854
    offt_max=INT_MAX
 
855
    uofft_fmt="u"
 
856
    if test "$have_uoff_t" != "yes"; then
 
857
      AC_DEFINE(UOFF_T_INT,, Define if off_t is int)
 
858
    fi
 
859
    offt_bits=`expr 8 \* $ac_cv_sizeof_int`
 
860
    ;;
 
861
  long)
 
862
    offt_max=LONG_MAX
 
863
    uofft_fmt="lu"
 
864
    if test "$have_uoff_t" != "yes"; then
 
865
      AC_DEFINE(UOFF_T_LONG,, Define if off_t is long)
 
866
    fi
 
867
    offt_bits=`expr 8 \* $ac_cv_sizeof_long`
 
868
    ;;
 
869
  "long long")
 
870
    offt_max=LLONG_MAX
 
871
    uofft_fmt="llu"
 
872
    if test "$have_uoff_t" != "yes"; then
 
873
      AC_DEFINE(UOFF_T_LONG_LONG,, Define if off_t is long long)
 
874
    fi
 
875
    offt_bits=`expr 8 \* $ac_cv_sizeof_long_long`
 
876
    ;;
 
877
  *)
 
878
    AC_MSG_ERROR([Unsupported off_t type])
 
879
    ;;
 
880
esac
 
881
 
 
882
dnl * Do we have struct dirent->d_type
 
883
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
884
  #include <dirent.h>
 
885
]], [[
 
886
  struct dirent d;
 
887
  d.d_type = DT_DIR;
 
888
]])],[
 
889
  AC_DEFINE(HAVE_DIRENT_D_TYPE,, Define if you have struct dirent->d_type)
 
890
],[])
 
891
 
 
892
dnl * Do we have OFF_T_MAX?
 
893
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
894
  #include <limits.h>
 
895
  #include <sys/types.h>
 
896
]], [[
 
897
  off_t i = OFF_T_MAX;
 
898
]])],[
 
899
  :
 
900
],[
 
901
  AC_DEFINE_UNQUOTED(OFF_T_MAX, $offt_max, Maximum value of off_t)
 
902
])
 
903
 
 
904
AC_DEFINE_UNQUOTED(PRIuUOFF_T, "$uofft_fmt", printf() format for uoff_t)
 
905
 
 
906
dnl * make sure size_t isn't signed. we'd probably work fine with it, but
 
907
dnl * it's more likely vulnerable to buffer overflows. Anyway, C99 specifies
 
908
dnl * that it's unsigned and only some old systems define it as signed.
 
909
AC_CACHE_CHECK([whether size_t is signed],i_cv_signed_size_t,[
 
910
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
911
    #include <sys/types.h>
 
912
    int main() {
 
913
      /* return 0 if we're signed */
 
914
      exit((size_t)(int)-1 <= 0 ? 0 : 1);
 
915
    }
 
916
  ]])],[
 
917
    i_cv_signed_size_t=yes
 
918
 
 
919
    echo
 
920
    echo "Your system's size_t is a signed integer, Dovecot isn't designed to"
 
921
    echo "support it. It probably works just fine, but it's less resistant to"
 
922
    echo "buffer overflows. If you're not worried about this and still want to"
 
923
    echo "compile Dovecot, set ignore_signed_size=1 environment."
 
924
  
 
925
    if test "$ignore_signed_size" = ""; then
 
926
      AC_MSG_ERROR([aborting])
 
927
    fi
 
928
    echo "..ignoring as requested.."
 
929
  ],[
 
930
    i_cv_signed_size_t=no
 
931
  ],[])
 
932
])
 
933
dnl Note: we check size_t rather than ssize_t here, because on OSX 10.2
 
934
dnl ssize_t = int and size_t = unsigned long. We're mostly concerned about
 
935
dnl printf format here, so check the size_t one.
 
936
AC_TYPEOF(size_t, unsigned-int unsigned-long unsigned-long-long)
 
937
case "$typeof_size_t" in
 
938
  "unsigned long")
 
939
    ssizet_max=LONG_MAX
 
940
    sizet_fmt="lu"
 
941
    ;;
 
942
  "unsigned long long")
 
943
    ssizet_max=LLONG_MAX
 
944
    sizet_fmt="llu"
 
945
    ;;
 
946
  *)
 
947
    dnl older systems didn't have ssize_t, default to int
 
948
    ssizet_max=INT_MAX
 
949
    sizet_fmt="u"
 
950
 
 
951
    if test "$typeof_size_t" = ""; then
 
952
      AC_DEFINE(size_t, unsigned int, Define to 'unsigned int' if you don't have it)
 
953
      AC_DEFINE(ssize_t, int, Define to 'int' if you don't have it)
 
954
    fi
 
955
    ;;
 
956
esac
 
957
 
 
958
AC_DEFINE_UNQUOTED(SSIZE_T_MAX, $ssizet_max, Maximum value of ssize_t)
 
959
AC_DEFINE_UNQUOTED(PRIuSIZE_T, "$sizet_fmt", printf() format for size_t)
 
960
 
 
961
AC_DEFUN([AC_CHECKTYPE2], [
 
962
  AC_MSG_CHECKING([for $1])
 
963
  AC_CACHE_VAL(i_cv_type_$1,
 
964
  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
965
  #include <sys/types.h>
 
966
  $2]], [[$1 t;]])],[i_cv_type_$1=yes],[i_cv_type_$1=no])])
 
967
  AC_MSG_RESULT($i_cv_type_$1)
 
968
])
 
969
 
 
970
dnl some systems don't have stdint.h, but still have some of the types
 
971
dnl defined elsewhere
 
972
AC_CHECK_HEADER(stdint.h, [
 
973
  stdint_include="#include <stdint.h>"
 
974
])
 
975
 
 
976
AC_CHECKTYPE2(uintmax_t, [$stdint_include])
 
977
if test $i_cv_type_uintmax_t = yes; then
 
978
  AC_DEFINE(HAVE_UINTMAX_T,, Define if you have uintmax_t (C99 type))
 
979
fi
 
980
 
 
981
dnl use separate check, eg. Solaris 8 has uintmax_t but not uint_fast32_t
 
982
AC_CHECKTYPE2(uint_fast32_t, [$stdint_include])
 
983
if test $i_cv_type_uint_fast32_t = yes; then
 
984
  AC_DEFINE(HAVE_UINT_FAST32_T,, Define if you have uint_fast32_t (C99 type))
 
985
fi
 
986
 
 
987
AC_CHECKTYPE2(socklen_t, [#include <sys/socket.h>])
 
988
if test $i_cv_type_socklen_t = yes; then
 
989
  AC_DEFINE(HAVE_SOCKLEN_T,, Define to 'int' if you don't have socklen_t)
 
990
fi
 
991
 
 
992
AC_DEFINE_UNQUOTED(MEM_ALIGN_SIZE, $mem_align, Required memory alignment)
 
993
 
 
994
dnl * find random source
 
995
AC_MSG_CHECKING([for /dev/urandom])
 
996
if test -c /dev/urandom || test -s /dev/urandom; then
 
997
  AC_MSG_RESULT(yes)
 
998
  AC_DEFINE(DEV_URANDOM_PATH, "/dev/urandom", Path to /dev/urandom)
 
999
  have_random_source=yes
 
1000
else
 
1001
  AC_MSG_RESULT(no)
 
1002
fi
 
1003
 
 
1004
if test "$have_random_source" != "yes"; then
 
1005
  AC_CHECK_HEADER(openssl/rand.h, [
 
1006
    AC_DEFINE(HAVE_OPENSSL_RAND_H,, Define if you have openssl/rand.h)
 
1007
    LIBS="$LIBS -lcrypto"
 
1008
  ])
 
1009
fi
 
1010
 
 
1011
dnl * do we have tm_gmtoff
 
1012
AC_MSG_CHECKING([for tm_gmtoff])
 
1013
AC_CACHE_VAL(i_cv_field_tm_gmtoff,
 
1014
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
1015
#include <time.h>]],
 
1016
[[struct tm *tm; return tm->tm_gmtoff;]])],
 
1017
[i_cv_field_tm_gmtoff=yes],
 
1018
[i_cv_field_tm_gmtoff=no])])
 
1019
if test $i_cv_field_tm_gmtoff = yes; then
 
1020
        AC_DEFINE(HAVE_TM_GMTOFF,, Define if you have struct tm->tm_gmtoff)
 
1021
fi
 
1022
AC_MSG_RESULT($i_cv_field_tm_gmtoff)
 
1023
 
 
1024
dnl * how large time_t values does gmtime() accept?
 
1025
AC_CACHE_CHECK([how large time_t values gmtime() accepts],i_cv_gmtime_max_time_t,[
 
1026
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1027
    #include <stdio.h>
 
1028
    #include <time.h>
 
1029
    int main() {
 
1030
      FILE *f;
 
1031
      int bits;
 
1032
  
 
1033
      for (bits = 1; bits < sizeof(time_t)*8; bits++) {
 
1034
        time_t t = ((time_t)1 << bits) - 1;
 
1035
        if (gmtime(&t) == NULL) {
 
1036
          bits--;
 
1037
          break;
 
1038
        }
 
1039
      }
 
1040
      if (bits > 40) {
 
1041
        /* Solaris 9 breaks after 55 bits. Perhaps other systems break earlier.
 
1042
           Let's just do the same as Cyrus folks and limit it to 40 bits. */
 
1043
        bits = 40;
 
1044
      }
 
1045
  
 
1046
      f = fopen("conftest.temp", "w");
 
1047
      if (f == NULL) {
 
1048
        perror("fopen()");
 
1049
        return 1;
 
1050
      }
 
1051
      fprintf(f, "%d", bits);
 
1052
      fclose(f);
 
1053
      return 0;
 
1054
    }
 
1055
  ]])],[
 
1056
    i_cv_gmtime_max_time_t=`cat conftest.temp`
 
1057
    rm -f conftest.temp
 
1058
  ], [
 
1059
    printf "check failed, assuming "
 
1060
    i_cv_gmtime_max_time_t=31
 
1061
  ],[])
 
1062
])
 
1063
AC_DEFINE_UNQUOTED(TIME_T_MAX_BITS, $i_cv_gmtime_max_time_t, max. time_t bits gmtime() can handle)
 
1064
 
 
1065
AC_CACHE_CHECK([whether time_t is signed],i_cv_signed_time_t,[
 
1066
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1067
    #include <sys/types.h>
 
1068
    int main() {
 
1069
      /* return 0 if we're signed */
 
1070
      exit((time_t)(int)-1 <= 0 ? 0 : 1);
 
1071
    }
 
1072
  ]])],[
 
1073
    i_cv_signed_time_t=yes
 
1074
  ], [
 
1075
    i_cv_signed_time_t=no
 
1076
  ])
 
1077
])
 
1078
if test $i_cv_signed_time_t = yes; then
 
1079
  AC_DEFINE(TIME_T_SIGNED,, Define if your time_t is signed)
 
1080
fi
 
1081
 
 
1082
dnl Our implementation of AC_C_FLEXIBLE_ARRAY_MEMBER.
 
1083
dnl Use it until autoconf 2.61+ becomes more widely used
 
1084
AC_CACHE_CHECK([if we can use C99-like flexible array members],i_cv_c99_flex_arrays,[
 
1085
  AC_TRY_COMPILE([
 
1086
    struct foo {
 
1087
      int x;
 
1088
      char y[];
 
1089
    };
 
1090
  ], [
 
1091
    struct foo foo;
 
1092
  ], [
 
1093
    i_cv_c99_flex_arrays=yes
 
1094
  ], [
 
1095
    i_cv_c99_flex_arrays=no
 
1096
  ])
 
1097
])
 
1098
 
 
1099
if test $i_cv_c99_flex_arrays = yes; then
 
1100
  flexible_value=
 
1101
else
 
1102
  flexible_value=1
 
1103
fi
 
1104
AC_DEFINE_UNQUOTED(FLEXIBLE_ARRAY_MEMBER, $flexible_value, How to define flexible array members in structs)
 
1105
 
 
1106
dnl * do we have struct iovec
 
1107
AC_MSG_CHECKING([for struct iovec])
 
1108
AC_CACHE_VAL(i_cv_struct_iovec,
 
1109
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
1110
#include <sys/types.h>
 
1111
#include <sys/uio.h>
 
1112
#include <unistd.h>]],
 
1113
[[struct iovec *iovec;]])],
 
1114
[i_cv_struct_iovec=yes],
 
1115
[i_cv_struct_iovec=no])])
 
1116
 
 
1117
if test $i_cv_struct_iovec = yes; then
 
1118
        AC_DEFINE(HAVE_STRUCT_IOVEC,, Define if you have struct iovec)
 
1119
fi
 
1120
AC_MSG_RESULT($i_cv_struct_iovec)
 
1121
 
 
1122
dnl * is dev_t an integer or something else?
 
1123
AC_CACHE_CHECK([whether dev_t is struct],i_cv_dev_t_struct,[
 
1124
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
1125
    #include <sys/types.h>
 
1126
    struct test { dev_t a; };
 
1127
    static struct test t = { 0 };
 
1128
  ]],
 
1129
  [[ ]])], [
 
1130
    i_cv_dev_t_struct=no
 
1131
  ],[
 
1132
    i_cv_dev_t_struct=yes
 
1133
  ])
 
1134
])
 
1135
if test $i_cv_dev_t_struct = yes; then
 
1136
  AC_DEFINE(DEV_T_STRUCT,, Define if your dev_t is a structure instead of integer type)
 
1137
fi
 
1138
 
 
1139
dnl * Do we have RLIMIT_AS?
 
1140
AC_CACHE_CHECK([whether RLIMIT_AS exists],i_cv_have_rlimit_as,[
 
1141
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
1142
    #include <sys/types.h>
 
1143
    #include <sys/time.h>
 
1144
    #include <sys/resource.h>
 
1145
  ]], [[
 
1146
    struct rlimit r;
 
1147
    getrlimit(RLIMIT_AS, &r);
 
1148
  ]])],[
 
1149
    i_cv_have_rlimit_as=yes
 
1150
  ], [
 
1151
    i_cv_have_rlimit_as=no
 
1152
  ])
 
1153
])
 
1154
 
 
1155
if test $i_cv_have_rlimit_as = yes; then
 
1156
  AC_DEFINE(HAVE_RLIMIT_AS,, Define if you have RLIMIT_AS for setrlimit())
 
1157
fi
 
1158
 
 
1159
dnl * Do we have RLIMIT_NPROC?
 
1160
AC_CACHE_CHECK([whether RLIMIT_NPROC exists],i_cv_have_rlimit_nproc,[
 
1161
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
1162
    #include <sys/types.h>
 
1163
    #include <sys/time.h>
 
1164
    #include <sys/resource.h>
 
1165
  ]], [[
 
1166
    struct rlimit r;
 
1167
    getrlimit(RLIMIT_NPROC, &r);
 
1168
  ]])],[
 
1169
    i_cv_have_rlimit_nproc=yes
 
1170
  ],[
 
1171
    i_cv_have_rlimit_nproc=no
 
1172
  ])
 
1173
])
 
1174
 
 
1175
if test $i_cv_have_rlimit_nproc = yes; then
 
1176
  AC_DEFINE(HAVE_RLIMIT_NPROC,, Define if you have RLIMIT_NPROC for setrlimit())
 
1177
fi
 
1178
 
 
1179
dnl * Do we have RLIMIT_CORE?
 
1180
AC_CACHE_CHECK([whether RLIMIT_CORE exists],i_cv_have_rlimit_core,[
 
1181
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
1182
    #include <sys/types.h>
 
1183
    #include <sys/time.h>
 
1184
    #include <sys/resource.h>
 
1185
  ]], [[
 
1186
    struct rlimit r;
 
1187
    getrlimit(RLIMIT_CORE, &r);
 
1188
  ]])],[
 
1189
    i_cv_have_rlimit_core=yes
 
1190
  ],[
 
1191
    i_cv_have_rlimit_core=no
 
1192
  ])
 
1193
])
 
1194
 
 
1195
if test $i_cv_have_rlimit_core = yes; then
 
1196
  AC_DEFINE(HAVE_RLIMIT_CORE,, Define if you have RLIMIT_CORE for getrlimit())
 
1197
fi
 
1198
 
 
1199
AC_CACHE_CHECK([whether PR_SET_DUMPABLE exists],i_cv_have_pr_set_dumpable,[
 
1200
  AC_TRY_LINK([
 
1201
    #include <sys/prctl.h>
 
1202
  ], [
 
1203
    prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
 
1204
  ], [
 
1205
    i_cv_have_pr_set_dumpable=yes
 
1206
  ], [
 
1207
    i_cv_have_pr_set_dumpable=no
 
1208
  ])
 
1209
])
 
1210
if test $i_cv_have_pr_set_dumpable = yes; then
 
1211
  AC_DEFINE(HAVE_PR_SET_DUMPABLE,, Define if you have prctl(PR_SET_DUMPABLE))
 
1212
fi
 
1213
 
 
1214
dnl * Linux compatible mremap()
 
1215
AC_CACHE_CHECK([Linux compatible mremap()],i_cv_have_linux_mremap,[
 
1216
  AC_TRY_LINK([
 
1217
    #include <unistd.h>
 
1218
    #define __USE_GNU
 
1219
    #include <sys/mman.h>
 
1220
  ], [
 
1221
    mremap(0, 0, 0, MREMAP_MAYMOVE);
 
1222
  ], [
 
1223
    i_cv_have_linux_mremap=yes
 
1224
  ], [
 
1225
    i_cv_have_linux_mremap=no
 
1226
  ])
 
1227
])
 
1228
if test $i_cv_have_linux_mremap = yes; then
 
1229
  AC_DEFINE(HAVE_LINUX_MREMAP,, Define if you have Linux-compatible mremap())
 
1230
fi
 
1231
 
 
1232
dnl * If mmap() plays nicely with write()
 
1233
AC_CACHE_CHECK([whether shared mmaps get updated by write()s],i_cv_mmap_plays_with_write,[
 
1234
  AC_TRY_RUN([
 
1235
    #include <stdio.h>
 
1236
    #include <sys/types.h>
 
1237
    #include <sys/stat.h>
 
1238
    #include <unistd.h>
 
1239
    #include <fcntl.h>
 
1240
    #include <sys/mman.h>
 
1241
    int main() {
 
1242
      /* return 0 if we're signed */
 
1243
      int f = open("conftest.mmap", O_RDWR|O_CREAT|O_TRUNC, 0600);
 
1244
      void *mem;
 
1245
      if (f == -1) {
 
1246
        perror("open()");
 
1247
        return 1;
 
1248
      }
 
1249
      unlink("conftest.mmap");
 
1250
  
 
1251
      write(f, "1", 2);
 
1252
      mem = mmap(NULL, 2, PROT_READ|PROT_WRITE, MAP_SHARED, f, 0);
 
1253
      if (mem == MAP_FAILED) {
 
1254
        perror("mmap()");
 
1255
        return 1;
 
1256
      }
 
1257
      strcpy(mem, "2");
 
1258
      msync(mem, 2, MS_SYNC);
 
1259
      lseek(f, 0, SEEK_SET);
 
1260
      write(f, "3", 2);
 
1261
    
 
1262
      return strcmp(mem, "3") == 0 ? 0 : 1;
 
1263
    }
 
1264
  ], [
 
1265
    i_cv_mmap_plays_with_write=yes
 
1266
  ], [
 
1267
    i_cv_mmap_plays_with_write=no
 
1268
  ])
 
1269
])
 
1270
if test $i_cv_mmap_plays_with_write = no; then
 
1271
  AC_DEFINE(MMAP_CONFLICTS_WRITE,, [Define if shared mmaps don't get updated by write()s])
 
1272
fi
 
1273
 
 
1274
dnl * see if fd passing works
 
1275
AC_CACHE_CHECK([whether fd passing works],i_cv_fd_passing,[
 
1276
  for i in 1 2; do
 
1277
    old_cflags="$CFLAGS"
 
1278
    CFLAGS="$CFLAGS -I$srcdir/src/lib $srcdir/src/lib/fdpass.c"
 
1279
    if test $i = 2; then
 
1280
      CFLAGS="$CFLAGS -DBUGGY_CMSG_MACROS"
 
1281
    fi
 
1282
  
 
1283
    AC_TRY_RUN([
 
1284
      #include <sys/types.h>
 
1285
      #include <sys/socket.h>
 
1286
      #include <sys/wait.h>
 
1287
      #include <sys/stat.h>
 
1288
      #include <unistd.h>
 
1289
      #include <fcntl.h>
 
1290
      #include "fdpass.h"
 
1291
      
 
1292
      int nopen(void)
 
1293
      {
 
1294
              int i, n;
 
1295
              struct stat sb;
 
1296
              for (i = n = 0; i < 256; i++)
 
1297
                  if (fstat(i, &sb) == 0) n++;
 
1298
              return n;
 
1299
      }
 
1300
      int main(void)
 
1301
      {
 
1302
              int fd[2], send_fd, recv_fd, status, n1, n2;
 
1303
              struct stat st, st2;
 
1304
              char data;
 
1305
      
 
1306
              send_fd = creat("conftest.fdpass", 0600);
 
1307
              if (send_fd == -1) return 2;
 
1308
              unlink("conftest.fdpass");
 
1309
              if (fstat(send_fd, &st) < 0) return 2;
 
1310
              if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) return 2;
 
1311
              n1 = nopen();
 
1312
      
 
1313
              switch (fork()) {
 
1314
              case -1:
 
1315
                      return 2;
 
1316
              case 0:
 
1317
                      alarm(1);
 
1318
                      if (fd_send(fd[0], send_fd, &data, 1) != 1) return 2;
 
1319
                      return 0;
 
1320
              default:
 
1321
                      alarm(2);
 
1322
                      if (wait(&status) == -1)
 
1323
                        return 2;
 
1324
                      if (status != 0)
 
1325
                        return status;
 
1326
                      if (fd_read(fd[1], &data, 1, &recv_fd) != 1) return 1;
 
1327
                      if (fstat(recv_fd, &st2) < 0) return 2;
 
1328
                      /* nopen check is for making sure that only a single fd
 
1329
                         was received */
 
1330
                      n2 = nopen();
 
1331
                      return st.st_ino == st2.st_ino && n2 == n1 + 1 ? 0 : 1;
 
1332
              }
 
1333
      }
 
1334
    ], [
 
1335
      CFLAGS=$old_cflags
 
1336
      if test $i = 2; then
 
1337
        i_cv_fd_passing=buggy_cmsg_macros
 
1338
      else
 
1339
        i_cv_fd_passing=yes
 
1340
      fi
 
1341
      break
 
1342
    ], [
 
1343
      dnl no, try with BUGGY_CMSG_MACROS
 
1344
      CFLAGS=$old_cflags
 
1345
      i_cv_fd_passing=no
 
1346
    ])
 
1347
  done
 
1348
]);
 
1349
 
 
1350
case "$host_os" in
 
1351
darwin[[1-9]].*)
 
1352
        if test "$i_cv_fd_passing" = "yes"; then
 
1353
                i_cv_fd_passing=buggy_cmsg_macros
 
1354
        fi
 
1355
        ;;
 
1356
esac
 
1357
 
 
1358
if test $i_cv_fd_passing = buggy_cmsg_macros; then
 
1359
  AC_DEFINE(BUGGY_CMSG_MACROS,, Define if you have buggy CMSG macros)
 
1360
fi
 
1361
if test $i_cv_fd_passing = no; then
 
1362
  AC_ERROR([fd passing is required for Dovecot to work])
 
1363
fi
 
1364
 
 
1365
dnl * Solaris compatible sendfile()
 
1366
AC_CHECK_LIB(sendfile, sendfile, [
 
1367
  LIBS="$LIBS -lsendfile"
 
1368
  AC_DEFINE(HAVE_SOLARIS_SENDFILE,, Define if you have Solaris-compatible sendfile())
 
1369
], [
 
1370
  dnl * Linux compatible sendfile() - don't check if Solaris one was found.
 
1371
  dnl * This seems to pass with Solaris for some reason..
 
1372
  AC_CACHE_CHECK([Linux compatible sendfile()],i_cv_have_linux_sendfile,[
 
1373
    AC_TRY_LINK([
 
1374
      #undef _FILE_OFFSET_BITS
 
1375
      #include <sys/types.h>
 
1376
      #include <sys/socket.h>
 
1377
      #include <sys/sendfile.h>
 
1378
    ], [
 
1379
      sendfile(0, 0, (void *) 0, 0);
 
1380
    ], [
 
1381
      i_cv_have_linux_sendfile=yes
 
1382
    ], [
 
1383
      i_cv_have_linux_sendfile=no
 
1384
    ])
 
1385
  ])
 
1386
  if test $i_cv_have_linux_sendfile = yes; then
 
1387
    AC_DEFINE(HAVE_LINUX_SENDFILE,, Define if you have Linux-compatible sendfile())
 
1388
  fi
 
1389
 
 
1390
  dnl * FreeBSD compatible sendfile()
 
1391
  AC_CACHE_CHECK([FreeBSD compatible sendfile()],i_cv_have_freebsd_sendfile,[
 
1392
    AC_TRY_LINK([
 
1393
      #include <sys/types.h>
 
1394
      #include <sys/socket.h>
 
1395
      #include <sys/uio.h>
 
1396
    ], [
 
1397
      struct sf_hdtr hdtr;
 
1398
      sendfile(0, 0, 0, 0, &hdtr, (void *) 0, 0);
 
1399
    ], [
 
1400
      i_cv_have_freebsd_sendfile=yes
 
1401
    ], [
 
1402
      i_cv_have_freebsd_sendfile=no
 
1403
    ])
 
1404
  ])
 
1405
  if test $i_cv_have_freebsd_sendfile = yes; then
 
1406
    AC_DEFINE(HAVE_FREEBSD_SENDFILE,, Define if you have FreeBSD-compatible sendfile())
 
1407
  fi
 
1408
])
 
1409
 
 
1410
AC_CACHE_CHECK([if unsetenv returns int],i_cv_unsetenv_ret_int,[
 
1411
  AC_TRY_COMPILE([
 
1412
    #include <stdlib.h>
 
1413
  ], [
 
1414
    if (unsetenv("env") < 0) ;
 
1415
  ], [
 
1416
    i_cv_unsetenv_ret_int=yes
 
1417
  ], [
 
1418
    i_cv_unsetenv_ret_int=no
 
1419
  ])
 
1420
])
 
1421
if test $i_cv_unsetenv_ret_int = yes; then
 
1422
  AC_DEFINE(UNSETENV_RET_INT,, Define if unsetenv() returns int)
 
1423
fi
 
1424
 
 
1425
dnl * Check for crypt() if unistd.h compiles with _XOPEN_SOURCE + _XPG6
 
1426
dnl * Add other macros there too "just in case".
 
1427
AC_CACHE_CHECK([if we should use _XPG6 macro for crypt()],i_cv_use_xpg6_crypt,[
 
1428
  AC_TRY_COMPILE([
 
1429
    #define _XOPEN_SOURCE 4
 
1430
    #define _XOPEN_SOURCE_EXTENDED 1
 
1431
    #define _XOPEN_VERSION 4
 
1432
    #define _XPG4_2
 
1433
    #define _XPG6
 
1434
    #include <unistd.h>
 
1435
  ], [
 
1436
    crypt("a", "b");
 
1437
  ], [
 
1438
    i_cv_use_xpg6_crypt=yes
 
1439
  ], [
 
1440
    i_cv_use_xpg6_crypt=no
 
1441
  ])
 
1442
])
 
1443
if test $i_cv_use_xpg6_crypt = yes; then
 
1444
  AC_DEFINE(CRYPT_USE_XPG6,, Define if _XPG6 macro is needed for crypt())
 
1445
fi
 
1446
 
 
1447
AC_CACHE_CHECK([if struct stat has st_?tim timespec fields],i_cv_have_st_tim_timespec,[
 
1448
  AC_TRY_COMPILE([
 
1449
    #include <sys/types.h>
 
1450
    #include <sys/stat.h>
 
1451
    #include <unistd.h>
 
1452
  ], [
 
1453
    struct stat st;
 
1454
    unsigned long x = st.st_mtim.tv_nsec;
 
1455
  
 
1456
    return 0;
 
1457
  ], [
 
1458
    i_cv_have_st_tim_timespec=yes
 
1459
  ], [
 
1460
    i_cv_have_st_tim_timespec=no
 
1461
  ])
 
1462
])
 
1463
if test $i_cv_have_st_tim_timespec = yes; then
 
1464
  AC_DEFINE(HAVE_STAT_XTIM,, Define if you have st_?tim timespec fields in struct stat)
 
1465
fi
 
1466
 
 
1467
AC_CACHE_CHECK([if struct stat has st_?timespec fields],i_cv_have_st_timespec,[
 
1468
  AC_TRY_COMPILE([
 
1469
    #include <sys/types.h>
 
1470
    #include <sys/stat.h>
 
1471
    #include <unistd.h>
 
1472
  ], [
 
1473
    struct stat st;
 
1474
    unsigned long x = st.st_mtimespec.tv_nsec;
 
1475
  
 
1476
    return 0;
 
1477
  ], [
 
1478
    i_cv_have_st_timespec=yes
 
1479
  ], [
 
1480
    i_cv_have_st_timespec=no
 
1481
  ])
 
1482
])
 
1483
if test $i_cv_have_st_timespec = yes; then
 
1484
  AC_DEFINE(HAVE_STAT_XTIMESPEC,, Define if you have st_?timespec fields in struct stat)
 
1485
fi
 
1486
 
 
1487
dnl * Check if statvfs() can be used to find out block device for files
 
1488
AC_CACHE_CHECK([if statvfs.f_mntfromname exists],i_cv_have_statvfs_f_mntfromname,[
 
1489
  AC_TRY_COMPILE([
 
1490
    #include <sys/types.h>
 
1491
    #include <sys/statvfs.h>
 
1492
  ], [
 
1493
    struct statvfs buf;
 
1494
    char *p = buf.f_mntfromname;
 
1495
  
 
1496
    statvfs(".", &buf);
 
1497
  ], [
 
1498
    i_cv_have_statvfs_f_mntfromname=yes
 
1499
  ], [
 
1500
    i_cv_have_statvfs_f_mntfromname=no
 
1501
  ])
 
1502
])
 
1503
if test $i_cv_have_statvfs_f_mntfromname = yes; then
 
1504
  AC_DEFINE(HAVE_STATVFS_MNTFROMNAME,, Define if you have statvfs.f_mntfromname)
 
1505
fi
 
1506
 
 
1507
dnl * Check if statfs() can be used to find out block device for files
 
1508
AC_CACHE_CHECK([if statfs.f_mntfromname exists],i_cv_have_statfs_f_mntfromname,[
 
1509
  AC_TRY_COMPILE([
 
1510
    #include <sys/param.h>
 
1511
    #include <sys/mount.h>
 
1512
  ], [
 
1513
    struct statfs buf;
 
1514
    char *p = buf.f_mntfromname;
 
1515
  
 
1516
    statfs(".", &buf);
 
1517
  ], [
 
1518
    i_cv_have_statfs_f_mntfromname=yes
 
1519
  ], [
 
1520
    i_cv_have_statfs_f_mntfromname=no
 
1521
  ])
 
1522
])
 
1523
if test $i_cv_have_statfs_f_mntfromname = yes; then
 
1524
  AC_DEFINE(HAVE_STATFS_MNTFROMNAME,, Define if you have statfs.f_mntfromname)
 
1525
fi
 
1526
 
 
1527
dnl * Check if we have struct dqblk.dqb_curblocks
 
1528
AC_CACHE_CHECK([if struct dqblk.dqb_curblocks exists],i_cv_have_dqblk_dqb_curblocks,[
 
1529
  AC_TRY_COMPILE([
 
1530
    #include <sys/types.h>
 
1531
    #include "$srcdir/src/plugins/quota/quota-fs.h"
 
1532
  ], [
 
1533
    struct dqblk dqblk;
 
1534
    unsigned int x = dqblk.dqb_curblocks;
 
1535
  ], [
 
1536
    i_cv_have_dqblk_dqb_curblocks=yes
 
1537
  ], [
 
1538
    i_cv_have_dqblk_dqb_curblocks=no
 
1539
  ])
 
1540
])
 
1541
if test $i_cv_have_dqblk_dqb_curblocks = yes; then
 
1542
  AC_DEFINE(HAVE_STRUCT_DQBLK_CURBLOCKS,, Define if struct sqblk.dqb_curblocks exists)
 
1543
fi
 
1544
 
 
1545
dnl * Check if we have struct dqblk.dqb_curspace
 
1546
AC_CACHE_CHECK([if struct dqblk.dqb_curspace exists],i_cv_have_dqblk_dqb_curspace,[
 
1547
  AC_TRY_COMPILE([
 
1548
    #include <sys/types.h>
 
1549
    #include "$srcdir/src/plugins/quota/quota-fs.h"
 
1550
  ], [
 
1551
    struct dqblk dqblk;
 
1552
    unsigned int x = dqblk.dqb_curspace;
 
1553
  ], [
 
1554
    i_cv_have_dqblk_dqb_curspace=yes
 
1555
  ], [
 
1556
    i_cv_have_dqblk_dqb_curspace=no
 
1557
  ])
 
1558
])
 
1559
if test $i_cv_have_dqblk_dqb_curspace = yes; then
 
1560
  AC_DEFINE(HAVE_STRUCT_DQBLK_CURSPACE,, Define if struct sqblk.dqb_curspace exists)
 
1561
fi
 
1562
 
 
1563
dnl * Check if we have Q_QUOTACTL ioctl (Solaris)
 
1564
AC_CACHE_CHECK([if Q_QUOTACTL ioctl exists],i_cv_have_ioctl_q_quotactl,[
 
1565
  AC_TRY_COMPILE([
 
1566
    #include <sys/types.h>
 
1567
    #include <sys/fs/ufs_quota.h>
 
1568
  ], [
 
1569
    struct quotctl ctl;
 
1570
    ioctl(0, Q_QUOTACTL, &ctl);
 
1571
  ], [
 
1572
    i_cv_have_ioctl_q_quotactl=yes
 
1573
  ], [
 
1574
    i_cv_have_ioctl_q_quotactl=no
 
1575
  ])
 
1576
])
 
1577
 
 
1578
if test $i_cv_have_ioctl_q_quotactl = yes; then
 
1579
  AC_DEFINE(HAVE_Q_QUOTACTL,, Define if Q_QUOTACTL exists)
 
1580
fi
 
1581
 
 
1582
dnl ***
 
1583
dnl *** C99 vsnprintf()?
 
1584
dnl ***
 
1585
 
 
1586
AC_CACHE_CHECK([for C99 vsnprintf()],i_cv_c99_vsnprintf,[
 
1587
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1588
  #include <stdio.h>
 
1589
  #include <stdarg.h>
 
1590
  static int f(const char *fmt, ...) {
 
1591
    va_list args;
 
1592
    char buf[13];
 
1593
    int ret;
 
1594
 
 
1595
    va_start(args, fmt);
 
1596
    ret = vsnprintf(buf, 11, fmt, args) != 12 || buf[11-1] != '\0';
 
1597
    va_end(args);
 
1598
    return ret;
 
1599
  }
 
1600
  int main() {
 
1601
    return f("hello %s%d", "world", 1);
 
1602
  }]])],
 
1603
  [i_cv_c99_vsnprintf=yes],
 
1604
  [i_cv_c99_vsnprintf=no])
 
1605
])
 
1606
if test $i_cv_c99_vsnprintf = no; then
 
1607
  AC_DEFINE(HAVE_OLD_VSNPRINTF,, Define if you don't have C99 compatible vsnprintf() call)
 
1608
fi
 
1609
 
 
1610
dnl ***
 
1611
dnl *** va_copy checks (from GLIB)
 
1612
dnl ***
 
1613
 
 
1614
AC_CACHE_CHECK([for an implementation of va_copy()],lib_cv_va_copy,[
 
1615
        AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1616
        #include <stdarg.h>
 
1617
        void f (int i, ...) {
 
1618
        va_list args1, args2;
 
1619
        va_start (args1, i);
 
1620
        va_copy (args2, args1);
 
1621
        if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
 
1622
          exit (1);
 
1623
        va_end (args1); va_end (args2);
 
1624
        }
 
1625
        int main() {
 
1626
          f (0, 42);
 
1627
          return 0;
 
1628
        }]])],
 
1629
        [lib_cv_va_copy=yes],
 
1630
        [lib_cv_va_copy=no],[])
 
1631
])
 
1632
AC_CACHE_CHECK([for an implementation of __va_copy()],lib_cv___va_copy,[
 
1633
        AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1634
        #include <stdarg.h>
 
1635
        void f (int i, ...) {
 
1636
        va_list args1, args2;
 
1637
        va_start (args1, i);
 
1638
        __va_copy (args2, args1);
 
1639
        if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
 
1640
          exit (1);
 
1641
        va_end (args1); va_end (args2);
 
1642
        }
 
1643
        int main() {
 
1644
          f (0, 42);
 
1645
          return 0;
 
1646
        }]])],
 
1647
        [lib_cv___va_copy=yes],
 
1648
        [lib_cv___va_copy=no],[])
 
1649
])
 
1650
 
 
1651
if test "x$lib_cv_va_copy" = "xyes"; then
 
1652
  va_copy_func=va_copy
 
1653
else if test "x$lib_cv___va_copy" = "xyes"; then
 
1654
  va_copy_func=__va_copy
 
1655
fi
 
1656
fi
 
1657
 
 
1658
if test -n "$va_copy_func"; then
 
1659
  AC_DEFINE_UNQUOTED(VA_COPY,$va_copy_func,[A 'va_copy' style function])
 
1660
fi
 
1661
 
 
1662
AC_CACHE_CHECK([whether va_lists can be copied by value],lib_cv_va_val_copy,[
 
1663
        AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1664
        #include <stdarg.h>
 
1665
        void f (int i, ...) {
 
1666
        va_list args1, args2;
 
1667
        va_start (args1, i);
 
1668
        args2 = args1;
 
1669
        if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
 
1670
          exit (1);
 
1671
        va_end (args1); va_end (args2);
 
1672
        }
 
1673
        int main() {
 
1674
          f (0, 42);
 
1675
          return 0;
 
1676
        }]])],
 
1677
        [lib_cv_va_val_copy=yes],
 
1678
        [lib_cv_va_val_copy=no],[])
 
1679
])
 
1680
 
 
1681
if test "x$lib_cv_va_val_copy" = "xno"; then
 
1682
  AC_DEFINE(VA_COPY_AS_ARRAY,1, ['va_lists' cannot be copies as values])
 
1683
fi
 
1684
 
 
1685
dnl * dynamic modules?
 
1686
have_modules=no
 
1687
AC_CHECK_FUNC(dlopen, [
 
1688
  have_modules=yes
 
1689
  MODULE_LIBS="-export-dynamic"
 
1690
], [
 
1691
  AC_CHECK_LIB(dl, dlopen, [
 
1692
    have_modules=yes
 
1693
    MODULE_LIBS="-export-dynamic -ldl"
 
1694
    DLLIB=-ldl
 
1695
  ])
 
1696
])
 
1697
 
 
1698
dnl **
 
1699
dnl ** AIX mntctl
 
1700
dnl **
 
1701
 
 
1702
if test $ac_cv_header_sys_vmount_h = yes; then
 
1703
  AC_MSG_CHECKING([for reasonable mntctl buffer size])
 
1704
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1705
    #include <stdio.h>
 
1706
    #include <stdlib.h>
 
1707
    #include <sys/vmount.h>
 
1708
    int main() {
 
1709
      int size,count; char *m;
 
1710
      FILE *f=fopen("conftestval", "w");
 
1711
      if (!f) exit(1);
 
1712
      if ((count=mntctl(MCTL_QUERY,sizeof(size),&size))!=0 || !(m=malloc(size)) ||
 
1713
          (count=mntctl(MCTL_QUERY,size,m))<=0) exit(1);
 
1714
        fprintf(f, "%d\n",(size * (count + 5))/count & ~1); /* 5 mounts more */
 
1715
        exit(0);
 
1716
    }
 
1717
  ]])],[
 
1718
    size=`cat conftestval`
 
1719
    rm -f conftestval
 
1720
    AC_DEFINE_UNQUOTED(STATIC_MTAB_SIZE,$size, reasonable mntctl buffer size)
 
1721
    AC_MSG_RESULT($size)
 
1722
  ],[
 
1723
    AC_MSG_RESULT(default)
 
1724
  ])
 
1725
fi
 
1726
 
 
1727
 
 
1728
dnl **
 
1729
dnl ** SSL
 
1730
dnl **
 
1731
 
 
1732
have_ssl=no
 
1733
 
 
1734
if test $want_openssl != no && test $have_ssl = no; then
 
1735
  if test "$PKG_CONFIG" != "" && $PKG_CONFIG --exists openssl 2>/dev/null; then
 
1736
    PKG_CHECK_MODULES(SSL, openssl)
 
1737
    CFLAGS="$CFLAGS $SSL_CFLAGS"
 
1738
    have_openssl=yes
 
1739
  else
 
1740
    # openssl 0.9.8 wants -ldl and it's required if there's only .a lib
 
1741
    AC_CHECK_LIB(ssl, SSL_read, [
 
1742
      AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h, [
 
1743
        SSL_LIBS="-lssl -lcrypto $DLLIB"
 
1744
        AC_SUBST(SSL_LIBS)
 
1745
        have_openssl=yes
 
1746
      ], [
 
1747
        if test $want_openssl = yes; then
 
1748
          AC_ERROR([Can't build with OpenSSL: openssl/ssl.h or openssl/err.h not found])
 
1749
        fi
 
1750
      ])
 
1751
    ], [
 
1752
      if test $want_openssl = yes; then
 
1753
        AC_ERROR([Can't build with OpenSSL: libssl not found])
 
1754
      fi
 
1755
    ], -lcrypto $DLLIB)
 
1756
  fi
 
1757
  if test "$have_openssl" = "yes"; then
 
1758
    AC_DEFINE(HAVE_OPENSSL,, Build with OpenSSL support)
 
1759
    have_ssl="yes (OpenSSL)"
 
1760
 
 
1761
    AC_CHECK_LIB(ssl, SSL_get_current_compression, [
 
1762
      AC_DEFINE(HAVE_SSL_COMPRESSION,, Build with OpenSSL compression)
 
1763
    ],, $SSL_LIBS)
 
1764
    AC_CHECK_LIB(ssl, SSL_get_servername, [
 
1765
      AC_DEFINE(HAVE_SSL_GET_SERVERNAME,, Build with TLS hostname support)
 
1766
    ],, $SSL_LIBS)
 
1767
  fi
 
1768
fi
 
1769
AM_CONDITIONAL(BUILD_OPENSSL, test "$have_openssl" = "yes")
 
1770
 
 
1771
if test $want_gnutls != no && test $have_ssl = no; then
 
1772
  AC_CHECK_LIB(gnutls, gnutls_global_init, [
 
1773
    AC_CHECK_HEADER(gnutls/gnutls.h, [
 
1774
      AC_DEFINE(HAVE_GNUTLS,, Build with GNUTLS support)
 
1775
      SSL_LIBS="-lgnutls -lgcrypt"
 
1776
      AC_SUBST(SSL_LIBS)
 
1777
      have_ssl="yes (GNUTLS)"
 
1778
      have_gnutls=yes
 
1779
    ], [
 
1780
      if test $want_gnutls = yes; then
 
1781
        AC_ERROR([Can't build with GNUTLS: gnutls/gnutls.h not found])
 
1782
      fi
 
1783
    ])
 
1784
  ], [
 
1785
    if test $want_gnutls = yes; then
 
1786
      AC_ERROR([Can't build with GNUTLS: libgnutls not found])
 
1787
    fi
 
1788
  ], -lgcrypt)
 
1789
fi
 
1790
 
 
1791
if test "$have_ssl" != "no"; then
 
1792
        AC_DEFINE(HAVE_SSL,, Build with SSL/TLS support)
 
1793
fi
 
1794
 
 
1795
dnl **
 
1796
dnl ** Garbage Collector
 
1797
dnl ** 
 
1798
 
 
1799
if test $want_gc != no; then
 
1800
  AC_CHECK_LIB(gc, GC_malloc, [
 
1801
    AC_CHECK_HEADERS(gc/gc.h gc.h)
 
1802
    AC_DEFINE(USE_GC,, Define if you want to use Boehm GC)
 
1803
    LIBS="$LIBS -lgc"
 
1804
  ], [
 
1805
    if test $want_gc = yes; then
 
1806
      AC_ERROR([Can't build with GC: libgc not found])
 
1807
    fi
 
1808
  ])
 
1809
fi
 
1810
 
 
1811
dnl **
 
1812
dnl ** userdb and passdb checks
 
1813
dnl **
 
1814
 
 
1815
userdb=""
 
1816
passdb=""
 
1817
not_userdb=""
 
1818
not_passdb=""
 
1819
 
 
1820
passdb="$passdb static"
 
1821
userdb="$userdb static"
 
1822
 
 
1823
if test $want_prefetch_userdb != no; then
 
1824
        AC_DEFINE(USERDB_PREFETCH,, Build with prefetch userdb support)
 
1825
        userdb="$userdb prefetch"
 
1826
else
 
1827
        not_userdb="$not_userdb prefetch"
 
1828
fi
 
1829
 
 
1830
if test $want_passwd != no; then
 
1831
        AC_DEFINE(USERDB_PASSWD,, Build with passwd support)
 
1832
        AC_DEFINE(PASSDB_PASSWD,, Build with passwd support)
 
1833
        userdb="$userdb passwd"
 
1834
        passdb="$passdb passwd"
 
1835
else
 
1836
        not_passdb="$not_passdb passwd"
 
1837
        not_userdb="$not_userdb passwd"
 
1838
fi
 
1839
 
 
1840
if test $want_passwd_file != no; then
 
1841
        AC_DEFINE(USERDB_PASSWD_FILE,, Build with passwd-file support)
 
1842
        AC_DEFINE(PASSDB_PASSWD_FILE,, Build with passwd-file support)
 
1843
        userdb="$userdb passwd-file"
 
1844
        passdb="$passdb passwd-file"
 
1845
else
 
1846
        not_passdb="$not_passdb passwd-file"
 
1847
        not_userdb="$not_userdb passwd-file"
 
1848
fi
 
1849
 
 
1850
have_shadow=no
 
1851
if test $want_shadow != no; then
 
1852
  AC_CHECK_FUNC(getspnam, [
 
1853
    AC_CHECK_HEADER(shadow.h, [
 
1854
      AC_DEFINE(PASSDB_SHADOW,, Build with shadow support)
 
1855
      have_shadow=yes
 
1856
    ], [
 
1857
      if test $want_shadow = yes; then
 
1858
        AC_ERROR([Can't build with shadow support: shadow.h not found])
 
1859
      fi
 
1860
    ])
 
1861
  ], [
 
1862
    if test $want_shadow = yes; then
 
1863
      AC_ERROR([Can't build with shadow support: getspnam() not found])
 
1864
    fi
 
1865
  ])
 
1866
fi
 
1867
if test $have_shadow = no; then
 
1868
  not_passdb="$not_passdb shadow"
 
1869
else
 
1870
  passdb="$passdb shadow"
 
1871
fi
 
1872
 
 
1873
if test $want_pam != no; then
 
1874
        AC_CHECK_LIB(pam, pam_start, [
 
1875
                have_pam=no
 
1876
                AC_CHECK_HEADER(security/pam_appl.h, [
 
1877
                        AC_DEFINE(HAVE_SECURITY_PAM_APPL_H,,
 
1878
                                  Define if you have security/pam_appl.h)
 
1879
                        have_pam=yes
 
1880
                ])
 
1881
 
 
1882
                AC_CHECK_HEADER(pam/pam_appl.h, [
 
1883
                        AC_DEFINE(HAVE_PAM_PAM_APPL_H,,
 
1884
                                  Define if you have pam/pam_appl.h)
 
1885
                        have_pam=yes
 
1886
                ])
 
1887
        ], [
 
1888
          if test $want_pam = yes; then
 
1889
            AC_ERROR([Can't build with PAM support: libpam not found])
 
1890
          fi
 
1891
        ])
 
1892
fi
 
1893
 
 
1894
if test "$have_pam" = "yes"; then
 
1895
  AUTH_LIBS="$AUTH_LIBS -lpam"
 
1896
  AC_DEFINE(PASSDB_PAM,, Build with PAM support)
 
1897
  passdb="$passdb pam"
 
1898
 
 
1899
  AC_CHECK_LIB(pam, pam_setcred, [
 
1900
    AC_DEFINE(HAVE_PAM_SETCRED,, Define if you have pam_setcred())
 
1901
  ])
 
1902
elif test $want_pam = yes; then
 
1903
  AC_ERROR([Can't build with PAM support: pam_appl.h not found])
 
1904
else
 
1905
  not_passdb="$not_passdb pam"
 
1906
fi
 
1907
 
 
1908
if test $want_checkpassword != no; then
 
1909
        AC_DEFINE(PASSDB_CHECKPASSWORD,, Build with checkpassword passdb support)
 
1910
        AC_DEFINE(USERDB_CHECKPASSWORD,, Build with checkpassword userdb support)
 
1911
        passdb="$passdb checkpassword"
 
1912
        userdb="$userdb checkpassword"
 
1913
else
 
1914
        not_passdb="$not_passdb checkpassword"
 
1915
        not_userdb="$not_userdb checkpassword"
 
1916
fi
 
1917
 
 
1918
have_bsdauth=no
 
1919
if test $want_bsdauth != no; then
 
1920
        AC_CHECK_FUNC(auth_userokay, [
 
1921
                AC_DEFINE(PASSDB_BSDAUTH,, Build with BSD authentication support)
 
1922
                have_bsdauth=yes
 
1923
        ], [
 
1924
          if test $want_bsdauth = yes; then
 
1925
            AC_ERROR([Can't build with BSD authentication support: auth_userokay() not found])
 
1926
          fi
 
1927
        ])
 
1928
fi
 
1929
if test $have_bsdauth = no; then
 
1930
  not_passdb="$not_passdb bsdauth"
 
1931
else
 
1932
  passdb="$passdb bsdauth"
 
1933
fi
 
1934
 
 
1935
have_gssapi=no
 
1936
if test $want_gssapi != no; then
 
1937
        AC_CHECK_PROG(KRB5CONFIG, krb5-config, krb5-config, NO)
 
1938
        if test $KRB5CONFIG != NO; then
 
1939
                if ! $KRB5CONFIG --version gssapi 2>/dev/null > /dev/null; then
 
1940
                  # krb5-config doesn't support gssapi.
 
1941
                  KRB5_LIBS="`$KRB5CONFIG --libs`"
 
1942
                  KRB5_CFLAGS=`$KRB5CONFIG --cflags`
 
1943
                  AC_CHECK_LIB(gss, gss_acquire_cred, [
 
1944
                    # Solaris
 
1945
                    KRB5_LIBS="$KRB5_LIBS -lgss"
 
1946
                  ], [
 
1947
                    # failed
 
1948
                    KRB5_LIBS=
 
1949
                  ], $KRB5_LIBS)
 
1950
                else
 
1951
                  KRB5_LIBS=`$KRB5CONFIG --libs gssapi`
 
1952
                  KRB5_CFLAGS=`$KRB5CONFIG --cflags gssapi`
 
1953
                fi
 
1954
                if test "$KRB5_LIBS" != ""; then
 
1955
                        AC_SUBST(KRB5_LIBS)
 
1956
                        AC_SUBST(KRB5_CFLAGS)
 
1957
                        
 
1958
                        # Although krb5-config exists, all systems still don't
 
1959
                        # have gssapi.h
 
1960
                        old_CFLAGS=$CFLAGS
 
1961
                        CFLAGS="$CFLAGS $KRB5_CFLAGS"
 
1962
                        AC_CHECK_HEADER([gssapi/gssapi.h], [
 
1963
                                AC_DEFINE(HAVE_GSSAPI_GSSAPI_H,, GSSAPI headers in gssapi/gssapi.h)
 
1964
                                have_gssapi=yes
 
1965
                        ])
 
1966
                        AC_CHECK_HEADER([gssapi.h], [
 
1967
                                AC_DEFINE(HAVE_GSSAPI_H,, GSSAPI headers in gssapi.h)
 
1968
                                have_gssapi=yes
 
1969
                        ])
 
1970
                        if test $have_gssapi != no; then
 
1971
                                if test $want_gssapi = plugin; then
 
1972
                                        have_gssapi=plugin
 
1973
                                fi
 
1974
                                AC_DEFINE(HAVE_GSSAPI,, Build with GSSAPI support)
 
1975
                                AC_CHECK_HEADERS(gssapi/gssapi_ext.h gssapi_krb5.h gssapi/gssapi_krb5.h)
 
1976
                                AC_CHECK_LIB(gss, __gss_userok, [
 
1977
                                        AC_DEFINE(HAVE___GSS_USEROK,,
 
1978
                                                Define if you have __gss_userok())
 
1979
                                        KRB5_LIBS="$KRB5_LIBS -lgss"
 
1980
                                ],, $KRB5_LIBS)
 
1981
 
 
1982
                                # MIT has a #define for Heimdal acceptor_identity, but it's way too
 
1983
                                # difficult to test for it..
 
1984
                                old_LIBS=$LIBS
 
1985
                                LIBS="$LIBS $KRB5_LIBS"
 
1986
                                AC_CHECK_FUNCS(gsskrb5_register_acceptor_identity krb5_gss_register_acceptor_identity)
 
1987
 
 
1988
                                # does the kerberos library support SPNEGO?
 
1989
                                AC_CACHE_CHECK([whether GSSAPI supports SPNEGO],i_cv_gssapi_spnego,[
 
1990
                                  AC_TRY_RUN([
 
1991
                                    #ifdef HAVE_GSSAPI_H
 
1992
                                    #  include <gssapi.h>
 
1993
                                    #else
 
1994
                                    #  include <gssapi/gssapi.h>
 
1995
                                    #endif
 
1996
                                    #include <krb5.h>
 
1997
                                    #include <string.h>
 
1998
                                    int main(void) {
 
1999
                                      OM_uint32 minor_status;
 
2000
                                      gss_OID_set mech_set;
 
2001
                                      unsigned char spnego_oid[] = { 0x2b, 0x06, 0x01, 0x05, 0x05, 0x02 };
 
2002
                                      unsigned int i;
 
2003
    
 
2004
                                      gss_indicate_mechs(&minor_status, &mech_set);
 
2005
                                      for (i = 0; i < mech_set->count; i++) {
 
2006
                                        if (mech_set->elements[i].length == 6 &&
 
2007
                                            memcmp(mech_set->elements[i].elements,
 
2008
                                                   spnego_oid, 6) == 0)
 
2009
                                              return 0;
 
2010
                                      }
 
2011
                                      return 1;
 
2012
                                    }
 
2013
                                  ], [
 
2014
                                    i_cv_gssapi_spnego=yes
 
2015
                                  ], [
 
2016
                                    i_cv_gssapi_spnego=no
 
2017
                                  ])
 
2018
                                ])
 
2019
                                if test "$i_cv_gssapi_spnego" = "yes"; then
 
2020
                                  AC_DEFINE(HAVE_GSSAPI_SPNEGO,, GSSAPI supports SPNEGO)
 
2021
                                fi
 
2022
                                LIBS=$old_LIBS
 
2023
 
 
2024
                                if test $want_gssapi != plugin; then
 
2025
                                  AUTH_LIBS="$AUTH_LIBS $KRB5_LIBS"
 
2026
                                  AUTH_CFLAGS="$AUTH_CFLAGS $KRB5_CFLAGS"
 
2027
                                  AC_DEFINE(BUILTIN_GSSAPI,, GSSAPI support is built in)
 
2028
                                else
 
2029
                                  have_gssapi_plugin=yes
 
2030
                                fi
 
2031
                        else
 
2032
                          if test $want_gssapi != auto; then
 
2033
                            AC_ERROR([Can't build with GSSAPI support: gssapi.h not found])
 
2034
                          fi
 
2035
                        fi
 
2036
                        CFLAGS=$old_CFLAGS
 
2037
                fi
 
2038
        else
 
2039
          if test $want_gssapi != auto; then
 
2040
            AC_ERROR([Can't build with GSSAPI support: krb5-config not found])
 
2041
          fi
 
2042
        fi
 
2043
fi
 
2044
AM_CONDITIONAL(GSSAPI_PLUGIN, test "$have_gssapi_plugin" = "yes")
 
2045
 
 
2046
have_sia=no
 
2047
if test $want_sia != no; then
 
2048
        AC_CHECK_FUNC(sia_validate_user, [
 
2049
                AC_DEFINE(PASSDB_SIA,, Build with Tru64 SIA support)
 
2050
                AUTH_LIBS="$AUTH_LIBS -depth_ring_search"
 
2051
                have_sia=yes
 
2052
        ], [
 
2053
          if test $want_sia = yes; then
 
2054
            AC_ERROR([Can't build with SIA support: sia_validate_user() not found])
 
2055
          fi
 
2056
        ])
 
2057
fi
 
2058
 
 
2059
if test $have_sia = no; then
 
2060
  not_passdb="$not_passdb sia"
 
2061
else
 
2062
  passdb="$passdb sia"
 
2063
fi
 
2064
 
 
2065
have_ldap=no
 
2066
if test $want_ldap != no; then
 
2067
        AC_CHECK_LIB(ldap, ldap_init, [
 
2068
                AC_CHECK_HEADER(ldap.h, [
 
2069
                        AC_CHECK_LIB(ldap, ldap_initialize, [
 
2070
                                AC_DEFINE(LDAP_HAVE_INITIALIZE,, Define if you have ldap_initialize)
 
2071
                        ])
 
2072
                        AC_CHECK_LIB(ldap, ldap_start_tls_s, [
 
2073
                                AC_DEFINE(LDAP_HAVE_START_TLS_S,, Define if you have ldap_start_tls_s)
 
2074
                        ])
 
2075
                        LDAP_LIBS="-lldap"
 
2076
                        AC_CHECK_LIB(ldap, ber_free, [
 
2077
                          # do nothing, default is to add -lldap to LIBS
 
2078
                          :
 
2079
                        ], [
 
2080
                          AC_CHECK_LIB(lber, ber_free, [
 
2081
                            LDAP_LIBS="$LDAP_LIBS -llber"
 
2082
                          ])
 
2083
                        ])
 
2084
                        AC_SUBST(LDAP_LIBS)
 
2085
                        if test $want_ldap != plugin; then
 
2086
                                AUTH_LIBS="$AUTH_LIBS $LDAP_LIBS"
 
2087
                                AC_DEFINE(BUILTIN_LDAP,, LDAP support is built in)
 
2088
                        fi
 
2089
 
 
2090
                        AC_DEFINE(USERDB_LDAP,, Build with LDAP support)
 
2091
                        AC_DEFINE(PASSDB_LDAP,, Build with LDAP support)
 
2092
                        AC_CHECK_HEADERS(sasl.h sasl/sasl.h)
 
2093
                        have_ldap=yes
 
2094
                ], [
 
2095
                  if test $want_ldap != auto; then
 
2096
                    AC_ERROR([Can't build with LDAP support: ldap.h not found])
 
2097
                  fi
 
2098
                ])
 
2099
        ], [
 
2100
          if test $want_ldap != auto; then
 
2101
            AC_ERROR([Can't build with LDAP support: libldap not found])
 
2102
          fi
 
2103
        ])
 
2104
fi
 
2105
 
 
2106
if test $have_ldap = no; then
 
2107
  not_passdb="$not_passdb ldap"
 
2108
  not_userdb="$not_userdb ldap"
 
2109
else
 
2110
  userdb="$userdb ldap"
 
2111
  passdb="$passdb ldap"
 
2112
  if test $want_ldap = plugin; then
 
2113
    have_ldap_plugin=yes
 
2114
    userdb="$userdb (plugin)"
 
2115
    passdb="$passdb (plugin)"
 
2116
  fi
 
2117
fi
 
2118
AM_CONDITIONAL(LDAP_PLUGIN, test "$have_ldap_plugin" = "yes")
 
2119
 
 
2120
dict_drivers=
 
2121
 
 
2122
if test $want_db != no; then
 
2123
  AC_CACHE_CHECK([db_env_create in -ldb],i_cv_have_db_env_create,[
 
2124
    old_LIBS=$LIBS
 
2125
    LIBS="$LIBS -ldb"
 
2126
    AC_TRY_LINK([
 
2127
      #include <db.h>
 
2128
    ], [
 
2129
      db_env_create(0, 0);
 
2130
    ], [
 
2131
      i_cv_have_db_env_create=yes
 
2132
    ], [
 
2133
      i_cv_have_db_env_create=no
 
2134
    ])
 
2135
    LIBS=$old_LIBS
 
2136
  ])
 
2137
  if test $i_cv_have_db_env_create = yes; then
 
2138
    AC_CHECK_HEADER(db.h, [
 
2139
      DICT_LIBS="$DICT_LIBS -ldb"
 
2140
      dict_drivers="$dict_drivers db"
 
2141
      AC_DEFINE(BUILD_DB,, Build with Berkeley DB support)
 
2142
    ], [
 
2143
      if test $want_db = yes; then
 
2144
        AC_ERROR([Can't build with db support: db.h not found])
 
2145
      fi
 
2146
    ])
 
2147
  else
 
2148
    if test $want_db = yes; then
 
2149
      AC_ERROR([Can't build with db support: libdb not found])
 
2150
    fi
 
2151
  fi
 
2152
fi
 
2153
 
 
2154
if test $want_cdb != no; then
 
2155
  AC_CHECK_LIB(cdb, cdb_init, [
 
2156
    AC_CHECK_HEADER(cdb.h, [
 
2157
      DICT_LIBS="$DICT_LIBS -lcdb"
 
2158
      AC_DEFINE(BUILD_CDB,, Build with CDB support)
 
2159
    ], [
 
2160
      if test $want_cdb = yes; then
 
2161
        AC_ERROR([Can't build with CDB support: cdb.h not found])
 
2162
      fi
 
2163
    ])
 
2164
  ], [
 
2165
    if test $want_cdb = yes; then
 
2166
      AC_ERROR([Can't build with CDB support: libcdb not found])
 
2167
    fi
 
2168
  ])
 
2169
fi
 
2170
 
 
2171
if test $want_pgsql != no; then
 
2172
  AC_CHECK_PROG(PG_CONFIG, pg_config, pg_config, NO)
 
2173
  if test $PG_CONFIG = NO; then
 
2174
    # based on code from PHP
 
2175
    for i in /usr /usr/local /usr/local/pgsql; do
 
2176
      for j in include include/pgsql include/postgres include/postgresql ""; do
 
2177
        if test -r "$i/$j/libpq-fe.h"; then
 
2178
          PGSQL_INCLUDE=$i/$j
 
2179
        fi
 
2180
      done
 
2181
      for lib in lib lib64; do
 
2182
        for j in $lib $lib/pgsql $lib/postgres $lib/postgresql ""; do
 
2183
          if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then
 
2184
            PGSQL_LIBDIR=$i/$j
 
2185
          fi
 
2186
        done
 
2187
      done
 
2188
    done
 
2189
  else
 
2190
    PGSQL_INCLUDE="`$PG_CONFIG --includedir`"
 
2191
    PGSQL_LIBDIR="`$PG_CONFIG --libdir`"  
 
2192
  fi
 
2193
 
 
2194
  old_LIBS=$LIBS
 
2195
  if test "$PGSQL_LIBDIR" != ""; then
 
2196
    LIBS="$LIBS -L$PGSQL_LIBDIR"
 
2197
  fi
 
2198
 
 
2199
  AC_CHECK_LIB(pq, PQconnectdb, [
 
2200
          AC_CHECK_LIB(pq, PQescapeStringConn, [
 
2201
                  AC_DEFINE(HAVE_PQESCAPE_STRING_CONN,, Define if libpq has PQescapeStringConn function)
 
2202
          ])
 
2203
          old_CPPFLAGS=$CPPFLAGS
 
2204
          if test "$PGSQL_INCLUDE" != ""; then
 
2205
                  CPPFLAGS="$CPPFLAGS -I$PGSQL_INCLUDE"
 
2206
          fi
 
2207
          AC_CHECK_HEADER(libpq-fe.h, [
 
2208
                  if test "$PGSQL_INCLUDE" != ""; then
 
2209
                          PGSQL_CFLAGS="$PGSQL_CFLAGS -I$PGSQL_INCLUDE"
 
2210
                  fi
 
2211
                  if test "$PGSQL_LIBDIR" != ""; then
 
2212
                          PGSQL_LIBS="$PGSQL_LIBS -L$PGSQL_LIBDIR"
 
2213
                  fi
 
2214
                  PGSQL_LIBS="$PGSQL_LIBS -lpq"
 
2215
                  AC_DEFINE(HAVE_PGSQL,, Build with PostgreSQL support)
 
2216
                  found_sql_drivers="$found_sql_drivers pgsql"
 
2217
          ], [
 
2218
            if test $want_pgsql = yes; then
 
2219
              AC_ERROR([Can't build with PostgreSQL support: libpq-fe.h not found])
 
2220
            fi
 
2221
          ])
 
2222
          CPPFLAGS=$old_CPPFLAGS
 
2223
  ], [
 
2224
    if test $want_pgsql = yes; then
 
2225
      AC_ERROR([Can't build with PostgreSQL support: libpq not found])
 
2226
    fi
 
2227
  ])
 
2228
  LIBS=$old_LIBS
 
2229
fi
 
2230
 
 
2231
have_mysql=no
 
2232
if test $want_mysql != no; then
 
2233
  AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, mysql_config, NO)
 
2234
  if test $MYSQL_CONFIG = NO; then
 
2235
        # based on code from PHP
 
2236
        MYSQL_LIBS="-lmysqlclient -lz -lm"
 
2237
        for i in /usr /usr/local /usr/local/mysql; do
 
2238
                for j in include include/mysql ""; do
 
2239
                        if test -r "$i/$j/mysql.h"; then
 
2240
                                MYSQL_INCLUDE="-I$i/$j"
 
2241
                        fi
 
2242
                done
 
2243
                for j in lib lib/mysql lib64 lib64/mysql ""; do
 
2244
                        if test -f "$i/$j/libmysqlclient.so" || test -f "$i/$j/libmysqlclient.a"; then
 
2245
                                MYSQL_LIBS="-L$i/$j -lmysqlclient -lz -lm"
 
2246
                        fi
 
2247
                done
 
2248
        done
 
2249
  else
 
2250
    MYSQL_INCLUDE="`$MYSQL_CONFIG --include`"
 
2251
    MYSQL_LIBS="`$MYSQL_CONFIG --libs`"
 
2252
  fi
 
2253
 
 
2254
  old_LIBS=$LIBS
 
2255
  if test "$MYSQL_LIBS" != ""; then
 
2256
    LIBS="$LIBS $MYSQL_LIBS"
 
2257
  fi
 
2258
 
 
2259
  mysql_lib=""
 
2260
  LIBS="$LIBS -lz -lm"
 
2261
  AC_CHECK_LIB(mysqlclient, mysql_init, [
 
2262
                old_CPPFLAGS=$CPPFLAGS
 
2263
                if test "$MYSQL_INCLUDE" != ""; then
 
2264
                        CPPFLAGS="$CPPFLAGS $MYSQL_INCLUDE"
 
2265
                fi
 
2266
                AC_CHECK_HEADER(mysql.h, [
 
2267
                        if test "$MYSQL_INCLUDE" != ""; then
 
2268
                                MYSQL_CFLAGS="$MYSQL_CFLAGS $MYSQL_INCLUDE"
 
2269
                        fi
 
2270
 
 
2271
                        AC_CHECK_LIB(mysqlclient, mysql_ssl_set, [
 
2272
                                AC_DEFINE(HAVE_MYSQL_SSL,, Define if your MySQL library has SSL functions)
 
2273
                                if test "x$have_openssl" = "yes"; then
 
2274
                                  ssl_define="#define HAVE_OPENSSL"
 
2275
                                else
 
2276
                                  ssl_define=""
 
2277
                                fi
 
2278
                                AC_TRY_COMPILE([
 
2279
                                  $ssl_define
 
2280
                                  #include <mysql.h>
 
2281
                                ], [
 
2282
                                  mysql_set_ssl(0, 0, 0, 0, 0, 0);
 
2283
                                ], [
 
2284
                                        AC_DEFINE(HAVE_MYSQL_SSL_CIPHER,, Define if your MySQL library supports setting cipher)
 
2285
                                ])
 
2286
                        ])
 
2287
                        
 
2288
                        have_mysql=yes
 
2289
                        AC_DEFINE(HAVE_MYSQL,, Build with MySQL support)
 
2290
                        found_sql_drivers="$found_sql_drivers mysql"
 
2291
                ], [
 
2292
                  if test $want_mysql = yes; then
 
2293
                    AC_ERROR([Can't build with MySQL support: mysql.h not found])
 
2294
                  fi
 
2295
                ])
 
2296
                CPPFLAGS=$old_CPPFLAGS
 
2297
  ], [
 
2298
    if test $want_mysql = yes; then
 
2299
      AC_ERROR([Can't build with MySQL support: libmysqlclient not found])
 
2300
    fi
 
2301
  ])
 
2302
 
 
2303
  if test $have_mysql != yes; then
 
2304
    MYSQL_LIBS=
 
2305
    MYSQL_CFLAGS=
 
2306
  fi
 
2307
  LIBS=$old_LIBS
 
2308
fi
 
2309
 
 
2310
if test $want_sqlite != no; then
 
2311
        AC_CHECK_LIB(sqlite3, sqlite3_open, [
 
2312
                AC_CHECK_HEADER(sqlite3.h, [
 
2313
                        SQLITE_LIBS="$SQLITE_LIBS -lsqlite3 -lz"
 
2314
 
 
2315
                        AC_DEFINE(HAVE_SQLITE,, Build with SQLite3 support)
 
2316
                        found_sql_drivers="$found_sql_drivers sqlite"
 
2317
                ], [
 
2318
                  if test $want_sqlite = yes; then
 
2319
                    AC_ERROR([Can't build with SQLite support: sqlite3.h not found])
 
2320
                  fi
 
2321
                ])
 
2322
        ], [
 
2323
          if test $want_sqlite = yes; then
 
2324
            AC_ERROR([Can't build with SQLite support: libsqlite3 not found])
 
2325
          fi
 
2326
        ])
 
2327
fi
 
2328
        
 
2329
SQL_CFLAGS="$MYSQL_CFLAGS $PGSQL_CFLAGS $SQLITE_CFLAGS"
 
2330
if test "$want_sql" != "plugin"; then
 
2331
        SQL_LIBS="$MYSQL_LIBS $PGSQL_LIBS $SQLITE_LIBS"
 
2332
else
 
2333
        AC_DEFINE(SQL_DRIVER_PLUGINS,, Build SQL drivers as plugins)
 
2334
fi
 
2335
 
 
2336
sql_drivers=
 
2337
not_sql_drivers=
 
2338
 
 
2339
if test "$found_sql_drivers" != "" || test "$want_sql" != "no"; then
 
2340
        sql_drivers="$found_sql_drivers"
 
2341
 
 
2342
        AC_DEFINE(PASSDB_SQL,, Build with SQL support)
 
2343
        AC_DEFINE(USERDB_SQL,, Build with SQL support)
 
2344
        AUTH_LIBS="$AUTH_LIBS $SQL_LIBS"
 
2345
        passdb="$passdb sql"
 
2346
        userdb="$userdb sql"
 
2347
else
 
2348
        not_passdb="$not_passdb sql"
 
2349
        not_userdb="$not_userdb sql"
 
2350
fi
 
2351
 
 
2352
have_vpopmail=no
 
2353
if test $want_vpopmail != no; then
 
2354
        vpop_etc="$vpopmail_home/etc"
 
2355
        AC_MSG_CHECKING([for vpopmail configuration at $vpop_etc/lib_deps])
 
2356
        if ! test -f $vpop_etc/lib_deps; then
 
2357
                AC_MSG_RESULT(not found)
 
2358
                vpop_etc="$vpopmail_home"
 
2359
                AC_MSG_CHECKING([for vpopmail configuration at $vpop_etc/lib_deps])
 
2360
        fi
 
2361
        if test -f $vpop_etc/lib_deps; then
 
2362
                AUTH_CFLAGS="$AUTH_CFLAGS `cat $vpop_etc/inc_deps` $CFLAGS"
 
2363
                AUTH_LIBS="$AUTH_LIBS `cat $vpop_etc/lib_deps`"
 
2364
                AC_DEFINE(USERDB_VPOPMAIL,, Build with vpopmail support)
 
2365
                AC_DEFINE(PASSDB_VPOPMAIL,, Build with vpopmail support)
 
2366
                AC_MSG_RESULT(found)
 
2367
                have_vpopmail=yes
 
2368
        else
 
2369
                AC_MSG_RESULT(not found)
 
2370
                if test $want_vpopmail = yes; then
 
2371
                  AC_ERROR([Can't build with vpopmail support: $vpop_etc/lib_deps not found])
 
2372
                fi
 
2373
        fi
 
2374
fi
 
2375
 
 
2376
if test $have_vpopmail = no; then
 
2377
  not_passdb="$not_passdb vpopmail"
 
2378
  not_userdb="$not_userdb vpopmail"
 
2379
else
 
2380
  userdb="$userdb vpopmail"
 
2381
  passdb="$passdb vpopmail"
 
2382
fi
 
2383
 
 
2384
AC_CHECK_FUNC(crypt,, [
 
2385
  AC_CHECK_LIB(crypt, crypt, [
 
2386
    AUTH_LIBS="-lcrypt $AUTH_LIBS"
 
2387
    CRYPT_LIBS="-lcrypt"
 
2388
  ], [
 
2389
    AC_MSG_ERROR([crypt() wasn't found])
 
2390
  ])
 
2391
])
 
2392
AC_SUBST(CRYPT_LIBS)
 
2393
 
 
2394
if test $have_modules = yes; then
 
2395
  AC_DEFINE(HAVE_MODULES,, Define if you have dynamic module support)
 
2396
  AC_SUBST(MODULE_LIBS)
 
2397
 
 
2398
  # shrext_cmds comes from libtool.m4
 
2399
  module=yes eval MODULE_SUFFIX=$shrext_cmds
 
2400
  if test "$MODULE_SUFFIX" = ""; then
 
2401
    # too old libtool?
 
2402
    MODULE_SUFFIX=.so
 
2403
  fi
 
2404
  AC_DEFINE_UNQUOTED(MODULE_SUFFIX,"$MODULE_SUFFIX",Dynamic module suffix)
 
2405
  AC_SUBST(MODULE_SUFFIX)
 
2406
fi
 
2407
 
 
2408
have_nss=no
 
2409
if test $want_nss != no; then
 
2410
  if test $have_modules != yes; then
 
2411
    if test $want_nss = yes; then
 
2412
      AC_ERROR([Can't build with NSS support: Dynamic modules not supported])
 
2413
    fi
 
2414
  else
 
2415
    AC_CACHE_CHECK([for NSS support],i_cv_have_nss,[
 
2416
      AC_TRY_COMPILE([
 
2417
        #include <nss.h>
 
2418
      ], [
 
2419
        enum nss_status status = NSS_STATUS_TRYAGAIN;
 
2420
      ], [
 
2421
        i_cv_have_nss=yes
 
2422
      ], [
 
2423
        i_cv_have_nss=no
 
2424
      ])
 
2425
    ])
 
2426
    if test $i_cv_have_nss = yes; then
 
2427
      AC_DEFINE(USERDB_NSS,, Build with NSS module support)
 
2428
      have_nss=yes
 
2429
    else
 
2430
      if test $want_nss = yes; then
 
2431
        AC_ERROR([Can't build with NSS support: nss.h not found or not usable])
 
2432
      fi
 
2433
    fi
 
2434
  fi
 
2435
fi
 
2436
 
 
2437
if test $have_nss = no; then
 
2438
  not_userdb="$not_userdb nss"
 
2439
else
 
2440
  userdb="$userdb nss"
 
2441
fi
 
2442
 
 
2443
AC_SUBST(AUTH_CFLAGS)
 
2444
AC_SUBST(AUTH_LIBS)
 
2445
AC_SUBST(SQL_CFLAGS)
 
2446
AC_SUBST(SQL_LIBS)
 
2447
AC_SUBST(MYSQL_CFLAGS)
 
2448
AC_SUBST(MYSQL_LIBS)
 
2449
AC_SUBST(PGSQL_CFLAGS)
 
2450
AC_SUBST(PGSQL_LIBS)
 
2451
AC_SUBST(SQLITE_CFLAGS)
 
2452
AC_SUBST(SQLITE_LIBS)
 
2453
 
 
2454
AC_SUBST(DICT_LIBS)
 
2455
AC_SUBST(CDB_LIBS)
 
2456
AC_SUBST(dict_drivers)
 
2457
 
 
2458
dnl **
 
2459
dnl ** Endianess
 
2460
dnl **
 
2461
 
 
2462
dnl At least Apple's gcc supports __BIG_ENDIAN__ and __LITTLE_ENDIAN__
 
2463
dnl defines. Use them if possible to allow cross-compiling.
 
2464
AC_CACHE_CHECK([if __BIG_ENDIAN__ or __LITTLE_ENDIAN__ is defined],i_cv_have___big_endian__,[
 
2465
  AC_TRY_COMPILE([
 
2466
    #if !(__BIG_ENDIAN__ || __LITTLE_ENDIAN__)
 
2467
    #error nope
 
2468
    #endif
 
2469
  ], [
 
2470
  ], [
 
2471
    i_cv_have___big_endian__=yes
 
2472
  ], [
 
2473
    i_cv_have___big_endian__=no
 
2474
  ])
 
2475
])
 
2476
if test $i_cv_have___big_endian__ = yes; then
 
2477
  AC_DEFINE(WORDS_BIGENDIAN, __BIG_ENDIAN__, Define if your CPU is big endian)
 
2478
else
 
2479
  AC_C_BIGENDIAN
 
2480
fi
 
2481
 
 
2482
dnl **
 
2483
dnl ** IPv6 support
 
2484
dnl **
 
2485
 
 
2486
have_ipv6=no
 
2487
AC_MSG_CHECKING([for IPv6])
 
2488
AC_CACHE_VAL(i_cv_type_in6_addr,
 
2489
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
2490
#include <sys/types.h>
 
2491
#include <sys/socket.h>
 
2492
#include <netinet/in.h>
 
2493
#include <netdb.h>
 
2494
#include <arpa/inet.h>]],
 
2495
[[struct in6_addr i;]])],
 
2496
[i_cv_type_in6_addr=yes],
 
2497
[i_cv_type_in6_addr=no])])
 
2498
if test $i_cv_type_in6_addr = yes; then
 
2499
        AC_DEFINE(HAVE_IPV6,, Build with IPv6 support)
 
2500
        have_ipv6=yes
 
2501
fi
 
2502
AC_MSG_RESULT($i_cv_type_in6_addr)
 
2503
 
 
2504
dnl **
 
2505
dnl ** storage classes
 
2506
dnl **
 
2507
 
 
2508
maildir_libs='$(top_builddir)/src/lib-storage/index/maildir/libstorage_maildir.la'
 
2509
mbox_libs='$(top_builddir)/src/lib-storage/index/mbox/libstorage_mbox.la'
 
2510
dbox_common_libs='$(top_builddir)/src/lib-storage/index/dbox-common/libstorage_dbox_common.la'
 
2511
sdbox_libs='$(top_builddir)/src/lib-storage/index/dbox-single/libstorage_dbox_single.la'
 
2512
mdbox_libs='$(top_builddir)/src/lib-storage/index/dbox-multi/libstorage_dbox_multi.la'
 
2513
cydir_libs='$(top_builddir)/src/lib-storage/index/cydir/libstorage_cydir.la'
 
2514
imapc_libs='$(top_builddir)/src/lib-storage/index/imapc/libstorage_imapc.la $(top_builddir)/src/lib-imap-client/libimap_client.la'
 
2515
pop3c_libs='$(top_builddir)/src/lib-storage/index/pop3c/libstorage_pop3c.la'
 
2516
raw_libs='$(top_builddir)/src/lib-storage/index/raw/libstorage_raw.la'
 
2517
shared_libs='$(top_builddir)/src/lib-storage/index/shared/libstorage_shared.la'
 
2518
 
 
2519
CORE_LIBS='$(top_builddir)/src/lib-dovecot/libdovecot.la'
 
2520
STORAGE_LIB='$(top_builddir)/src/lib-storage/libdovecot-storage.la'
 
2521
 
 
2522
LINKED_STORAGE_LIBS=
 
2523
 
 
2524
mailbox_list_drivers="maildir imapdir fs index none shared"
 
2525
have_sdbox=no
 
2526
for storage in $mail_storages; do
 
2527
  LINKED_STORAGE_LIBS="$LINKED_STORAGE_LIBS `eval echo \\$${storage}_libs`"
 
2528
  if test $storage = sdbox; then
 
2529
    have_sdbox=yes
 
2530
  fi
 
2531
  if test $storage = sdbox || test $storage = mdbox; then
 
2532
    LINKED_STORAGE_LIBS="$LINKED_STORAGE_LIBS $dbox_common_libs"
 
2533
    dbox_common_libs=""
 
2534
  fi
 
2535
  if test $storage = imapc; then
 
2536
    mailbox_list_drivers="$mailbox_list_drivers imapc"
 
2537
  fi
 
2538
done
 
2539
LINKED_STORAGE_LDADD=
 
2540
AC_SUBST(LINKED_STORAGE_LIBS)
 
2541
AC_SUBST(LINKED_STORAGE_LDADD)
 
2542
AC_SUBST(mailbox_list_drivers)
 
2543
AC_DEFINE_UNQUOTED(MAIL_STORAGES, "$mail_storages", List of compiled in mail storages)
 
2544
 
 
2545
if test $have_sdbox = yes; then
 
2546
  # create alias for sdbox
 
2547
  mail_storages="$mail_storages dbox"
 
2548
fi
 
2549
 
 
2550
dnl **
 
2551
dnl ** Shared libraries usage
 
2552
dnl **
 
2553
 
 
2554
if test "$want_shared_libs" = "yes"; then
 
2555
  LIBDOVECOT_DEPS='$(top_builddir)/src/lib-dovecot/libdovecot.la'
 
2556
  LIBDOVECOT="$LIBDOVECOT_DEPS \$(MODULE_LIBS)"
 
2557
  LIBDOVECOT_STORAGE_DEPS='$(top_builddir)/src/lib-storage/libdovecot-storage.la $(top_builddir)/src/lib-imap-storage/libimap-storage.la'
 
2558
  LIBDOVECOT_LOGIN='$(top_builddir)/src/login-common/libdovecot-login.la'
 
2559
  LIBDOVECOT_COMPRESS='$(top_builddir)/src/lib-compression/libcompression.la'
 
2560
  LIBDOVECOT_LDA='$(top_builddir)/src/lib-lda/libdovecot-lda.la'
 
2561
else
 
2562
  LIBDOVECOT_DEPS='$(top_builddir)/src/lib-master/libmaster.la $(top_builddir)/src/lib-settings/libsettings.la $(top_builddir)/src/lib-http/libhttp.la $(top_builddir)/src/lib-dict/libdict.la $(top_builddir)/src/lib-dns/libdns.la $(top_builddir)/src/lib-fs/libfs.la $(top_builddir)/src/lib-imap/libimap.la $(top_builddir)/src/lib-mail/libmail.la $(top_builddir)/src/lib-sasl/libsasl.la $(top_builddir)/src/lib-auth/libauth.la $(top_builddir)/src/lib-charset/libcharset.la $(top_builddir)/src/lib-ssl-iostream/libssl_iostream.la $(top_builddir)/src/lib-test/libtest.la $(top_builddir)/src/lib/liblib.la'
 
2563
  LIBDOVECOT="$LIBDOVECOT_DEPS \$(LIBICONV) \$(MODULE_LIBS)"
 
2564
  LIBDOVECOT_STORAGE_LAST='$(top_builddir)/src/lib-storage/list/libstorage_list.la $(top_builddir)/src/lib-storage/index/libstorage_index.la $(top_builddir)/src/lib-storage/libstorage.la $(top_builddir)/src/lib-index/libindex.la $(top_builddir)/src/lib-imap-storage/libimap-storage.la'
 
2565
  LIBDOVECOT_STORAGE_FIRST='$(top_builddir)/src/lib-storage/libstorage_service.la $(top_builddir)/src/lib-storage/register/libstorage_register.la'
 
2566
  LIBDOVECOT_STORAGE_DEPS="$LIBDOVECOT_STORAGE_FIRST $LINKED_STORAGE_LIBS $LIBDOVECOT_STORAGE_LAST"
 
2567
  LIBDOVECOT_LOGIN='$(top_builddir)/src/login-common/liblogin.la'
 
2568
  LIBDOVECOT_COMPRESS='$(top_builddir)/src/lib-compression/libcompression.la'
 
2569
  LIBDOVECOT_LDA='$(top_builddir)/src/lib-lda/liblda.la'
 
2570
fi
 
2571
LIBDOVECOT_STORAGE="$LIBDOVECOT_STORAGE_DEPS $LINKED_STORAGE_LDADD"
 
2572
LIBDOVECOT_SQL='$(top_builddir)/src/lib-sql/libsql.la'
 
2573
AC_SUBST(LIBDOVECOT)
 
2574
AC_SUBST(LIBDOVECOT_DEPS)
 
2575
AC_SUBST(LIBDOVECOT_STORAGE)
 
2576
AC_SUBST(LIBDOVECOT_STORAGE_DEPS)
 
2577
AC_SUBST(LIBDOVECOT_LOGIN)
 
2578
AC_SUBST(LIBDOVECOT_SQL)
 
2579
AC_SUBST(LIBDOVECOT_COMPRESS)
 
2580
AC_SUBST(LIBDOVECOT_LDA)
 
2581
 
 
2582
dnl **
 
2583
dnl ** SQL drivers
 
2584
dnl **
 
2585
 
 
2586
build_pgsql=no
 
2587
build_mysql=no
 
2588
build_sqlite=no
 
2589
for driver in $sql_drivers; do
 
2590
  if test "$driver" = "pgsql"; then
 
2591
    AC_DEFINE(BUILD_PGSQL,, Built-in PostgreSQL support)
 
2592
    build_pgsql=yes
 
2593
  elif test "$driver" = "mysql"; then
 
2594
    AC_DEFINE(BUILD_MYSQL,, Built-in MySQL support)
 
2595
    build_mysql=yes
 
2596
  elif test "$driver" = "sqlite"; then
 
2597
    AC_DEFINE(BUILD_SQLITE,, Built-in SQLite support)
 
2598
    build_sqlite=yes
 
2599
  fi
 
2600
done
 
2601
if test $build_pgsql = no; then
 
2602
  not_sql_drivers="$not_sql_drivers pgsql"
 
2603
fi
 
2604
if test $build_mysql = no; then
 
2605
  not_sql_drivers="$not_sql_drivers mysql"
 
2606
fi
 
2607
if test $build_sqlite = no; then
 
2608
  not_sql_drivers="$not_sql_drivers sqlite"
 
2609
fi
 
2610
 
 
2611
AC_SUBST(sql_drivers)
 
2612
AM_CONDITIONAL(BUILD_PGSQL, test "$build_pgsql" = "yes")
 
2613
AM_CONDITIONAL(BUILD_MYSQL, test "$build_mysql" = "yes")
 
2614
AM_CONDITIONAL(BUILD_SQLITE, test "$build_sqlite" = "yes")
 
2615
AM_CONDITIONAL(SQL_PLUGINS, test "$want_sql" = "plugin")
 
2616
 
 
2617
dnl **
 
2618
dnl ** Plugins
 
2619
dnl **
 
2620
 
 
2621
COMPRESS_LIBS=
 
2622
if test "$want_zlib" != "no"; then
 
2623
  AC_CHECK_HEADER(zlib.h, [
 
2624
    have_zlib=yes
 
2625
    have_compress_lib=yes
 
2626
    AC_DEFINE(HAVE_ZLIB,, Define if you have zlib library)
 
2627
    COMPRESS_LIBS="$COMPRESS_LIBS -lz"
 
2628
  ], [
 
2629
    if test "$want_zlib" = "yes"; then
 
2630
      AC_ERROR([Can't build with zlib support: zlib.h not found])
 
2631
    fi
 
2632
  ])
 
2633
fi
 
2634
 
 
2635
if test "$want_bzlib" != "no"; then
 
2636
  AC_CHECK_HEADER(bzlib.h, [
 
2637
    AC_CHECK_LIB(bz2, BZ2_bzdopen, [
 
2638
      have_bzlib=yes
 
2639
      have_compress_lib=yes
 
2640
      AC_DEFINE(HAVE_BZLIB,, Define if you have bzlib library)
 
2641
      COMPRESS_LIBS="$COMPRESS_LIBS -lbz2"
 
2642
    ], [
 
2643
      if test "$want_bzlib" = "yes"; then
 
2644
        AC_ERROR([Can't build with bzlib support: libbz2 not found])
 
2645
      fi
 
2646
    ])
 
2647
  ], [
 
2648
    if test "$want_bzlib" = "yes"; then
 
2649
      AC_ERROR([Can't build with bzlib support: bzlib.h not found])
 
2650
    fi
 
2651
  ])
 
2652
fi
 
2653
AC_SUBST(COMPRESS_LIBS)
 
2654
AM_CONDITIONAL(BUILD_ZLIB_PLUGIN, test "$have_compress_lib" = "yes")
 
2655
 
 
2656
RPCGEN=${RPCGEN-rpcgen}
 
2657
if ! $RPCGEN -c /dev/null > /dev/null; then
 
2658
  RPCGEN=
 
2659
fi
 
2660
AC_SUBST(RPCGEN)
 
2661
 
 
2662
have_rquota=no
 
2663
if test -f /usr/include/rpcsvc/rquota.x && test -n "$RPCGEN"; then
 
2664
  AC_DEFINE(HAVE_RQUOTA,, Define if you wish to retrieve quota of NFS mounted mailboxes)
 
2665
  have_rquota=yes
 
2666
fi
 
2667
AM_CONDITIONAL(HAVE_RQUOTA, test "$have_rquota" = "yes")
 
2668
 
 
2669
QUOTA_LIBS=""
 
2670
AC_SEARCH_LIBS(quota_open, quota, [
 
2671
  AC_DEFINE(HAVE_QUOTA_OPEN,, Define if you have quota_open())
 
2672
  QUOTA_LIBS="-lquota"
 
2673
])
 
2674
AC_SUBST(QUOTA_LIBS)
 
2675
 
 
2676
dnl
 
2677
dnl ** Full text search
 
2678
dnl
 
2679
 
 
2680
fts=" squat"
 
2681
not_fts=""
 
2682
 
 
2683
have_solr=no
 
2684
if test "$want_solr" != "no"; then
 
2685
  dnl need libexpat
 
2686
  AC_CHECK_LIB(expat, XML_Parse, [
 
2687
    AC_CHECK_HEADER(expat.h, [
 
2688
      have_solr=yes
 
2689
      fts="$fts solr"
 
2690
    ], [
 
2691
      if test $want_solr = yes; then
 
2692
        AC_ERROR([Can't build with Solr support: expat.h not found])
 
2693
      fi
 
2694
    ])
 
2695
  ], [
 
2696
    if test $want_solr = yes; then
 
2697
      AC_ERROR([Can't build with Solr support: libexpat not found])
 
2698
    fi
 
2699
  ])
 
2700
fi
 
2701
AM_CONDITIONAL(BUILD_SOLR, test "$have_solr" = "yes")
 
2702
 
 
2703
have_lucene=no
 
2704
if test "$want_lucene" = "yes"; then
 
2705
  PKG_CHECK_MODULES(CLUCENE, libclucene-core,, [
 
2706
    # no pkg-config file for clucene. fallback to defaults.
 
2707
    # FIXME: we should verify here that this actually works..
 
2708
    CLUCENE_LIBS="-lclucene-shared -lclucene-core"
 
2709
  ])
 
2710
  if test $want_stemmer != no; then
 
2711
    AC_CHECK_LIB(stemmer, sb_stemmer_new, [
 
2712
      have_lucene_stemmer=yes
 
2713
      AC_DEFINE(HAVE_LUCENE_STEMMER,, Define if you want stemming support for CLucene)
 
2714
      AC_CHECK_LIB(textcat, special_textcat_Init, [
 
2715
        have_lucene_textcat=yes
 
2716
        AC_DEFINE(HAVE_LUCENE_TEXTCAT,, Define if you want textcat support for CLucene)
 
2717
      ], [
 
2718
        AC_CHECK_LIB(exttextcat, special_textcat_Init, [
 
2719
          have_lucene_exttextcat=yes
 
2720
          AC_DEFINE(HAVE_LUCENE_EXTTEXTCAT,, Define if you want textcat (Debian version) support for CLucene)
 
2721
        ])
 
2722
      ])
 
2723
    ], [
 
2724
      if test $want_stemmer = yes; then
 
2725
        AC_ERROR([Can't build with stemmer support: libstemmer not found])
 
2726
      fi
 
2727
    ])
 
2728
  fi
 
2729
  have_lucene=yes
 
2730
  fts="$fts lucene"
 
2731
fi
 
2732
AM_CONDITIONAL(BUILD_LUCENE_STEMMER, test "$have_lucene_stemmer" = "yes")
 
2733
AM_CONDITIONAL(BUILD_LUCENE_TEXTCAT, test "$have_lucene_textcat" = "yes")
 
2734
AM_CONDITIONAL(BUILD_LUCENE_EXTTEXTCAT, test "$have_lucene_exttextcat" = "yes")
 
2735
 
 
2736
if test $have_lucene = no; then
 
2737
  not_fts="$not_fts lucene"
 
2738
fi
 
2739
if test $have_solr = no; then
 
2740
  not_fts="$not_fts solr"
 
2741
fi
 
2742
 
 
2743
dnl **
 
2744
dnl ** Settings
 
2745
dnl **
 
2746
 
 
2747
dnl get a list of setting .[ch] files, but list .h files first
 
2748
FILES1=`find $srcdir/src -name '*settings.[[ch]]'|grep "$srcdir/src/lib-" | sed 's/^\(.*\)\(.\)$/\2 \1\2/' | grep -v 'lib-master.*c$' | sort -r | sed s/^..//`
 
2749
FILES2=`find $srcdir/src -name '*settings.[[ch]]'|grep -v "$srcdir/src/lib-" | sed 's/^\(.*\)\(.\)$/\2 \1\2/' | grep -v all-settings | sort -r | sed s/^..//`
 
2750
SETTING_FILES=`echo $FILES1 $FILES2 | sed -e s,$srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g'`
 
2751
AC_SUBST(SETTING_FILES)
 
2752
 
 
2753
dnl **
 
2754
dnl ** capabilities
 
2755
dnl **
 
2756
 
 
2757
dnl IDLE doesn't really belong to banner. It's there just to make Blackberries
 
2758
dnl happy, because otherwise BIS server disables push email.
 
2759
capability_banner="IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE"
 
2760
capability="$capability_banner SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE BINARY MOVE"
 
2761
AC_DEFINE_UNQUOTED(CAPABILITY_STRING, "$capability", IMAP capabilities)
 
2762
AC_DEFINE_UNQUOTED(CAPABILITY_BANNER_STRING, "$capability_banner", IMAP capabilities advertised in banner) 
 
2763
 
 
2764
CFLAGS="$CFLAGS $EXTRA_CFLAGS"
 
2765
NOPLUGIN_LDFLAGS="-no-undefined"
 
2766
if test "$with_gnu_ld" = yes; then
 
2767
  NOPLUGIN_LDFLAGS="$NOPLUGIN_LDFLAGS -Wl,--as-needed"
 
2768
fi
 
2769
LDFLAGS="\$(NOPLUGIN_LDFLAGS) $LDFLAGS"
 
2770
AC_SUBST(NOPLUGIN_LDFLAGS)
 
2771
 
 
2772
if test "$with_gnu_ld" = yes -a "$want_shared_libs" = "no"; then
 
2773
  # libtool can't handle using whole-archive flags, so we need to do this
 
2774
  # with a CC wrapper.. shouldn't be much of a problem, since most people
 
2775
  # are building with shared libs.
 
2776
  sed "s/@CC@/$CC/" < $srcdir/cc-wrapper.sh.in > cc-wrapper.sh
 
2777
  chmod +x cc-wrapper.sh
 
2778
  CC=`pwd`/cc-wrapper.sh
 
2779
fi
 
2780
 
 
2781
if test "$docdir" = ""; then
 
2782
  dnl docdir supported only by autoconf v2.59c and later
 
2783
  docdir='${datadir}/doc/${PACKAGE_TARNAME}'
 
2784
fi
 
2785
AC_SUBST(docdir)
 
2786
 
 
2787
AC_CHECK_PROG(VALGRIND, valgrind, yes, no)
 
2788
if test $VALGRIND = yes; then
 
2789
  RUN_TEST='$(SHELL) $(top_srcdir)/run-test.sh'
 
2790
else
 
2791
  RUN_TEST=''
 
2792
fi
 
2793
AC_SUBST(RUN_TEST)
 
2794
AC_SUBST(abs_top_builddir)
 
2795
 
 
2796
AC_CONFIG_HEADERS([config.h])
 
2797
AC_CONFIG_FILES([
 
2798
Makefile
 
2799
doc/Makefile
 
2800
doc/man/Makefile
 
2801
doc/wiki/Makefile
 
2802
doc/example-config/Makefile
 
2803
doc/example-config/conf.d/Makefile
 
2804
src/Makefile
 
2805
src/lib/Makefile
 
2806
src/lib-sql/Makefile
 
2807
src/lib-auth/Makefile
 
2808
src/lib-charset/Makefile
 
2809
src/lib-compression/Makefile
 
2810
src/lib-dict/Makefile
 
2811
src/lib-dns/Makefile
 
2812
src/lib-fs/Makefile
 
2813
src/lib-http/Makefile
 
2814
src/lib-imap/Makefile
 
2815
src/lib-imap-storage/Makefile
 
2816
src/lib-imap-client/Makefile
 
2817
src/lib-imap-urlauth/Makefile
 
2818
src/lib-index/Makefile
 
2819
src/lib-lda/Makefile
 
2820
src/lib-mail/Makefile
 
2821
src/lib-master/Makefile
 
2822
src/lib-ntlm/Makefile
 
2823
src/lib-otp/Makefile
 
2824
src/lib-dovecot/Makefile
 
2825
src/lib-sasl/Makefile
 
2826
src/lib-settings/Makefile
 
2827
src/lib-ssl-iostream/Makefile
 
2828
src/lib-test/Makefile
 
2829
src/lib-storage/Makefile
 
2830
src/lib-storage/list/Makefile
 
2831
src/lib-storage/index/Makefile
 
2832
src/lib-storage/index/imapc/Makefile
 
2833
src/lib-storage/index/pop3c/Makefile
 
2834
src/lib-storage/index/maildir/Makefile
 
2835
src/lib-storage/index/mbox/Makefile
 
2836
src/lib-storage/index/dbox-common/Makefile
 
2837
src/lib-storage/index/dbox-multi/Makefile
 
2838
src/lib-storage/index/dbox-single/Makefile
 
2839
src/lib-storage/index/cydir/Makefile
 
2840
src/lib-storage/index/raw/Makefile
 
2841
src/lib-storage/index/shared/Makefile
 
2842
src/lib-storage/register/Makefile
 
2843
src/anvil/Makefile
 
2844
src/auth/Makefile
 
2845
src/config/Makefile
 
2846
src/doveadm/Makefile
 
2847
src/doveadm/dsync/Makefile
 
2848
src/lda/Makefile
 
2849
src/log/Makefile
 
2850
src/lmtp/Makefile
 
2851
src/dict/Makefile
 
2852
src/director/Makefile
 
2853
src/dns/Makefile
 
2854
src/indexer/Makefile
 
2855
src/ipc/Makefile
 
2856
src/imap/Makefile
 
2857
src/imap-login/Makefile
 
2858
src/imap-urlauth/Makefile
 
2859
src/login-common/Makefile
 
2860
src/master/Makefile
 
2861
src/pop3/Makefile
 
2862
src/pop3-login/Makefile
 
2863
src/replication/Makefile
 
2864
src/replication/aggregator/Makefile
 
2865
src/replication/replicator/Makefile
 
2866
src/ssl-params/Makefile
 
2867
src/stats/Makefile
 
2868
src/util/Makefile
 
2869
src/plugins/Makefile
 
2870
src/plugins/acl/Makefile
 
2871
src/plugins/imap-acl/Makefile
 
2872
src/plugins/autocreate/Makefile
 
2873
src/plugins/expire/Makefile
 
2874
src/plugins/fts/Makefile
 
2875
src/plugins/fts-lucene/Makefile
 
2876
src/plugins/fts-solr/Makefile
 
2877
src/plugins/fts-squat/Makefile
 
2878
src/plugins/lazy-expunge/Makefile
 
2879
src/plugins/listescape/Makefile
 
2880
src/plugins/mail-log/Makefile
 
2881
src/plugins/mailbox-alias/Makefile
 
2882
src/plugins/notify/Makefile
 
2883
src/plugins/pop3-migration/Makefile
 
2884
src/plugins/quota/Makefile
 
2885
src/plugins/imap-quota/Makefile
 
2886
src/plugins/replication/Makefile
 
2887
src/plugins/snarf/Makefile
 
2888
src/plugins/stats/Makefile
 
2889
src/plugins/imap-stats/Makefile
 
2890
src/plugins/trash/Makefile
 
2891
src/plugins/virtual/Makefile
 
2892
src/plugins/zlib/Makefile
 
2893
src/plugins/imap-zlib/Makefile
 
2894
stamp.h
 
2895
dovecot-config.in])
 
2896
 
 
2897
AC_OUTPUT
 
2898
 
 
2899
if test "$want_sql" = "plugin"; then
 
2900
  sql_drivers="$sql_drivers (plugins)"
 
2901
fi
 
2902
 
 
2903
not_passdb=`echo "$not_passdb"|sed 's/ / -/g'`
 
2904
not_userdb=`echo "$not_userdb"|sed 's/ / -/g'`
 
2905
not_sql_drivers=`echo "$not_sql_drivers"|sed 's/ / -/g'`
 
2906
not_fts=`echo "$not_fts"|sed 's/ / -/g'`
 
2907
 
 
2908
echo
 
2909
echo "Install prefix . : $prefix"
 
2910
echo "File offsets ... : ${offt_bits}bit"
 
2911
echo "I/O polling .... : $ioloop"
 
2912
echo "I/O notifys .... : $have_notify"
 
2913
echo "SSL ............ : $have_ssl"
 
2914
echo "GSSAPI ......... : $have_gssapi"
 
2915
echo "passdbs ........ :$passdb"
 
2916
if test "$not_passdb" != ""; then
 
2917
  echo "                 :$not_passdb"
 
2918
fi
 
2919
echo "userdbs ........ :$userdb"
 
2920
if test "$not_userdb" != ""; then
 
2921
  echo "                 :$not_userdb"
 
2922
fi
 
2923
echo "SQL drivers .... :$sql_drivers"
 
2924
if test "$not_sql_drivers" != ""; then
 
2925
  echo "                 :$not_sql_drivers"
 
2926
fi
 
2927
echo "Full text search :$fts"
 
2928
if test "$not_fts" != ""; then
 
2929
  echo "                 :$not_fts"
 
2930
fi