-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfigure.ac
2997 lines (2722 loc) · 80.2 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
AC_PREREQ([2.59])
# Be sure to update ABI version also if anything changes that might require
# recompiling plugins. Most importantly that means if any structs are changed.
AC_INIT([Dovecot],[2.2.12],[[email protected]])
AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv11($PACKAGE_VERSION)", [Dovecot ABI version])
AC_CONFIG_SRCDIR([src])
AM_INIT_AUTOMAKE([foreign])
AM_MAINTAINER_MODE
PKG_PROG_PKG_CONFIG
ACLOCAL_AMFLAGS='-I $(top_srcdir)'
AC_SUBST(ACLOCAL_AMFLAGS)
dnl TEST_WITH(name, value, [plugin])
AC_DEFUN([TEST_WITH], [
want=want_`echo $1|sed s/-/_/g`
if test $2 = yes || test $2 = no || test $2 = auto; then
eval $want=$2
elif test $2 = plugin; then
if test "$3" = plugin; then
eval $want=plugin
else
AC_ERROR([--with-$1=plugin not supported])
fi
elif `echo $2|grep '^/' >/dev/null`; then
AC_ERROR([--with-$1=path not supported. You may want to use instead:
CPPFLAGS=-I$2/include LDFLAGS=-L$2/lib ./configure --with-$1])
else
AC_ERROR([--with-$1: Unknown value: $2])
fi
])
AC_ARG_ENABLE(devel-checks,
AS_HELP_STRING([--enable-devel-checks], [Enable some extra expensive checks for developers]),
if test x$enableval = xyes; then
AC_DEFINE(DEBUG,, Build with extra debugging checks)
want_devel_checks=yes
fi)
AC_ARG_ENABLE(asserts,
AS_HELP_STRING([--enable-asserts], [Enable asserts (default)]),
if test x$enableval = xno; then
AC_DEFINE(DISABLE_ASSERTS,, Disable asserts)
fi)
AC_ARG_WITH(shared-libs,
AS_HELP_STRING([--with-shared-libs], [Link binaries using shared Dovecot libraries (default)]),
want_shared_libs=$withval,
want_shared_libs=yes)
AM_CONDITIONAL(BUILD_SHARED_LIBS, test "$want_shared_libs" = "yes")
AC_ARG_WITH(mem-align,
AS_HELP_STRING([--with-mem-align=BYTES], [Set the memory alignment (default: 8)]),
mem_align=$withval,
mem_align=8)
AC_ARG_WITH(ioloop,
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)]),
ioloop=$withval,
ioloop=best)
AC_ARG_WITH(notify,
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)]),
notify=$withval,
notify=)
AC_ARG_WITH(nss,
AS_HELP_STRING([--with-nss], [Build with NSS module support (auto)]),
TEST_WITH(nss, $withval),
want_nss=auto)
AC_ARG_WITH(shadow,
AS_HELP_STRING([--with-shadow], [Build with shadow password support (auto)]),
TEST_WITH(shadow, $withval),
want_shadow=auto)
AC_ARG_WITH(pam,
AS_HELP_STRING([--with-pam], [Build with PAM support (auto)]),
TEST_WITH(pam, $withval),
want_pam=auto)
AC_ARG_WITH(bsdauth,
AS_HELP_STRING([--with-bsdauth], [Build with BSD authentication support (auto)]),
TEST_WITH(bsdauth, $withval),
want_bsdauth=auto)
AC_ARG_WITH(gssapi,
AS_HELP_STRING([--with-gssapi=yes|plugin Build with GSSAPI authentication support]),
TEST_WITH(gssapi, $withval, plugin),
want_gssapi=no)
AC_ARG_WITH(sia,
AS_HELP_STRING([--with-sia], [Build with Tru64 SIA support]),
TEST_WITH(sia, $withval),
want_sia=no)
AC_ARG_WITH(ldap,
AS_HELP_STRING([--with-ldap=yes|plugin], [Build with LDAP support]),
TEST_WITH(ldap, $withval, plugin),
want_ldap=no)
AC_ARG_WITH(vpopmail,
AS_HELP_STRING([--with-vpopmail], [Build with vpopmail support (auto)]),
if test x$withval = xno; then
want_vpopmail=no
else
if test x$withval = xyes || test x$withval = xauto; then
vpopmail_home="`echo ~vpopmail`"
want_vpopmail=$withval
else
vpopmail_home="$withval"
want_vpopmail=yes
fi
fi, [
want_vpopmail=no
])
# Berkeley DB support is more or less broken. Disabled for now.
#AC_ARG_WITH(db,
#AS_HELP_STRING([--with-db], [Build with Berkeley DB support]),
# TEST_WITH(db, $withval),
# want_db=no)
want_db=no
AC_ARG_WITH(cdb,
AS_HELP_STRING([--with-cdb], [Build with CDB support]),
TEST_WITH(cdb, $withval),
want_cdb=no)
dnl The --with-sql is useful only if Dovecot is being built with all the SQL
dnl drivers as modules. If any SQL driver is built-in, this option is ignored.
AC_ARG_WITH(sql,
AS_HELP_STRING([--with-sql=yes|plugin], [Build with generic SQL support]),
TEST_WITH(sql, $withval, plugin),
want_sql=no)
AC_ARG_WITH(pgsql,
AS_HELP_STRING([--with-pgsql], [Build with PostgreSQL driver support]),
TEST_WITH(pgsql, $withval),
want_pgsql=no)
AC_ARG_WITH(mysql,
AS_HELP_STRING([--with-mysql], [Build with MySQL driver support]),
TEST_WITH(mysql, $withval),
want_mysql=no)
AC_ARG_WITH(sqlite,
AS_HELP_STRING([--with-sqlite], [Build with SQLite3 driver support]),
TEST_WITH(sqlite, $withval),
want_sqlite=no)
AC_ARG_WITH(lucene,
AS_HELP_STRING([--with-lucene], [Build with CLucene full text search support]),
TEST_WITH(lucene, $withval),
want_lucene=no)
AM_CONDITIONAL(BUILD_LUCENE, test "$want_lucene" = "yes")
AC_ARG_WITH(stemmer,
AS_HELP_STRING([--with-stemmer], [Build with libstemmer support (for CLucene)]),
TEST_WITH(stemmer, $withval),
want_stemmer=auto)
AC_ARG_WITH(solr,
AS_HELP_STRING([--with-solr], [Build with Solr full text search support]),
TEST_WITH(solr, $withval),
want_solr=no)
AC_ARG_WITH(zlib,
AS_HELP_STRING([--with-zlib], [Build with zlib compression support]),
TEST_WITH(zlib, $withval),
want_zlib=auto)
AC_ARG_WITH(bzlib,
AS_HELP_STRING([--with-bzlib], [Build with bzlib compression support]),
TEST_WITH(bzlib, $withval),
want_bzlib=auto)
AC_ARG_WITH(lzma,
AS_HELP_STRING([--with-lzma], [Build with LZMA compression support]),
TEST_WITH(lzma, $withval),
want_lzma=auto)
AC_ARG_WITH(lz4,
AS_HELP_STRING([--with-lz4], [Build with LZ4 compression support]),
TEST_WITH(lz4, $withval),
want_lz4=auto)
AC_ARG_WITH(libcap,
AS_HELP_STRING([--with-libcap], [Build with libcap support (Dropping capabilities).]),
TEST_WITH(libcap, $withval),
want_libcap=auto)
AC_ARG_WITH(libwrap,
AS_HELP_STRING([--with-libwrap], [Build with libwrap, ie. TCP-wrappers]),
TEST_WITH(libwrap, $withval),
want_libwrap=no)
AC_ARG_WITH(ssl,
AS_HELP_STRING([--with-ssl=gnutls|openssl], [Build with GNUTLS or OpenSSL (default)]),
if test x$withval = xno; then
want_gnutls=no
want_openssl=no
elif test x$withval = xgnutls; then
AC_ERROR([GNUTLS support is broken currently])
want_gnutls=yes
want_openssl=no
elif test x$withval = xopenssl; then
want_gnutls=no
want_openssl=yes
elif test x$withval = xyes; then
want_gnutls=no
want_openssl=yes
else
AC_ERROR([--with-ssl: Invalid value: $withval])
fi, [
want_gnutls=no
want_openssl=auto
])
AC_ARG_WITH(ssldir,
AS_HELP_STRING([--with-ssldir=DIR], [SSL base directory for certificates (/etc/ssl)]),
ssldir="$withval",
ssldir=/etc/ssl
)
AC_SUBST(ssldir)
AC_ARG_WITH(rundir,
AS_HELP_STRING([--with-rundir=DIR], [Runtime data directory (LOCALSTATEDIR/run/dovecot)]),
rundir="$withval",
rundir=$localstatedir/run/$PACKAGE
)
AC_SUBST(rundir)
AC_ARG_WITH(statedir,
AS_HELP_STRING([--with-statedir=DIR], [Permanent data directory (LOCALSTATEDIR/lib/dovecot)]),
statedir="$withval",
statedir=$localstatedir/lib/$PACKAGE
)
AC_SUBST(statedir)
AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files (auto=detect)]), [
if test "$withval" = "auto"; then
systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd`
elif test "$withval" != "no"; then
systemdsystemunitdir=$withval
fi
], [])
if test "$systemdsystemunitdir" != ""; then
AC_SUBST(systemdsystemunitdir)
AC_DEFINE(HAVE_SYSTEMD,, Define if you want to use systemd socket activation)
fi
AM_CONDITIONAL(HAVE_SYSTEMD, test "$systemdsystemunitdir" != "")
AC_ARG_WITH(gc,
AS_HELP_STRING([--with-gc], [Use Boehm garbage collector]),
TEST_WITH(gc, $withval),
want_gc=no)
AC_ARG_WITH(storages,
AS_HELP_STRING([--with-storages], [Build with specified mail storage formats (mdbox sdbox maildir mbox cydir imapc pop3c)]), [
if test "$withval" = "yes" || test "$withval" = "no"; then
AC_MSG_ERROR([--with-storages needs storage list as parameter])
fi
mail_storages="shared `echo "$withval"|sed 's/,/ /g'`" ],
mail_storages="shared mdbox sdbox maildir mbox cydir imapc pop3c")
AC_SUBST(mail_storages)
mail_storages="$mail_storages raw fail"
# drop duplicates
duplicates=`(for i in $mail_storages; do echo $i; done)|sort|uniq -d|xargs echo`
if test "$duplicates" != ""; then
AC_ERROR([Duplicate --with-storages: $duplicates])
fi
DC_DOVECOT_MODULEDIR
AC_ARG_WITH(docs,
AS_HELP_STRING([--with-docs], [Install documentation (default)]),
if test x$withval = xno; then
want_docs=no
else
want_docs=yes
fi,
want_docs=yes)
AM_CONDITIONAL(BUILD_DOCS, test "$want_docs" = "yes")
dnl always enable all of the passbs and userdbs that don't require extra libs
want_passwd=yes
want_passwd_file=yes
want_checkpassword=yes
want_prefetch_userdb=yes
AC_ISC_POSIX
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX # lucene plugin needs this
AC_HEADER_STDC
AC_C_INLINE
AC_PROG_LIBTOOL
AM_ICONV
AC_DEFINE_UNQUOTED(DOVECOT_NAME, "$PACKAGE_NAME", Dovecot name)
AC_DEFINE_UNQUOTED(DOVECOT_STRING, "$PACKAGE_STRING", Dovecot string)
AC_DEFINE_UNQUOTED(DOVECOT_VERSION, "$PACKAGE_VERSION", Dovecot version)
AC_DEFINE([DOVECOT_VERSION_MAJOR], regexp(AC_PACKAGE_VERSION, [^\([0-9]+\)\.\([0-9]+\)], [\1]), [Dovecot major version])
AC_DEFINE([DOVECOT_VERSION_MINOR], regexp(AC_PACKAGE_VERSION, [^\([0-9]+\)\.\([0-9]+\)], [\2]), [Dovecot minor version])
AC_CHECK_HEADERS(strings.h stdint.h unistd.h dirent.h malloc.h inttypes.h \
sys/uio.h sys/sysmacros.h sys/resource.h sys/select.h libgen.h \
sys/quota.h sys/fs/ufs_quota.h ufs/ufs/quota.h jfs/quota.h \
quota.h sys/fs/quota_common.h \
mntent.h sys/mnttab.h sys/event.h sys/time.h sys/mkdev.h linux/dqblk_xfs.h \
xfs/xqm.h execinfo.h ucontext.h malloc_np.h sys/utsname.h sys/vmount.h \
sys/utsname.h glob.h linux/falloc.h ucred.h sys/ucred.h)
dnl * clang check
have_clang=no
if $CC -dM -E -x c /dev/null | grep __clang__ > /dev/null 2>&1; then
have_clang=yes
fi
dnl * gcc specific options
if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
# -Wcast-qual -Wcast-align -Wconversion -Wunreachable-code # too many warnings
# -Wstrict-prototypes -Wredundant-decls # may give warnings in some systems
# -Wmissing-format-attribute -Wmissing-noreturn -Wwrite-strings # a couple of warnings
CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast"
if test "$have_clang" = "yes"; then
AC_TRY_COMPILE([
#if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 3)
# error new clang
#endif
],,,[
# clang 3.3+ unfortunately this gives warnings with hash.h
CFLAGS="$CFLAGS -Wno-duplicate-decl-specifier"
])
else
# This is simply to avoid warning when building strftime() wrappers..
CFLAGS="$CFLAGS -fno-builtin-strftime"
fi
AC_TRY_COMPILE([
#if __GNUC__ < 4
# error old gcc
#endif
],,[
# gcc4
CFLAGS="$CFLAGS -Wstrict-aliasing=2"
])
# Use std=gnu99 if we have new enough gcc
old_cflags=$CFLAGS
CFLAGS="-std=gnu99"
AC_TRY_COMPILE([
],, [
CFLAGS="$CFLAGS $old_cflags"
], [
CFLAGS="$old_cflags"
])
fi
if test "$have_clang" = "yes"; then
# clang specific options
if test "$want_devel_checks" = "yes"; then
# FIXME: enable once md[45], sha[12] can be compiled without
#CFLAGS="$CFLAGS -fsanitize=integer,undefined -ftrapv"
:
fi
fi
dnl **
dnl ** just some generic stuff...
dnl **
AC_SEARCH_LIBS(socket, socket)
AC_SEARCH_LIBS(inet_addr, nsl)
AC_SEARCH_LIBS(fdatasync, rt, [
AC_DEFINE(HAVE_FDATASYNC,, Define if you have fdatasync())
])
if test $want_libcap != no; then
AC_CHECK_LIB(cap, cap_init, [
AC_DEFINE(HAVE_LIBCAP,, libcap is installed for cap_init())
LIBCAP="-lcap"
AC_SUBST(LIBCAP)
], [
if test "$want_libcap" = "yes"; then
AC_ERROR([Can't build with libcap support: libcap not found])
fi
])
fi
have_libwrap=no
if test $want_libwrap != no; then
AC_CHECK_HEADER(tcpd.h, [
old_LIBS=$LIBS
AC_CACHE_CHECK([whether we have libwrap],i_cv_have_libwrap,[
AC_TRY_COMPILE([
#include <tcpd.h>
int allow_severity = 0;
int deny_severity = 0;
], [
request_init((void *)0);
], [
i_cv_have_libwrap=yes
], [
i_cv_have_libwrap=no
])
])
if test $i_cv_have_libwrap = yes; then
AC_DEFINE(HAVE_LIBWRAP,, Define if you have libwrap)
LIBWRAP_LIBS=-lwrap
AC_SUBST(LIBWRAP_LIBS)
have_libwrap=yes
else
if test "$want_libwrap" = "yes"; then
AC_ERROR([Can't build with libwrap support: libwrap not found])
fi
fi
LIBS=$old_LIBS
], [
if test "$want_libwrap" = "yes"; then
AC_ERROR([Can't build with libwrap support: tcpd.h not found])
fi
])
fi
AM_CONDITIONAL(TCPWRAPPERS, test "$have_libwrap" = "yes")
AC_DEFINE(PACKAGE_WEBPAGE, "http://www.dovecot.org/", Support URL)
dnl * after -lsocket and -lnsl tests, inet_aton() may be in them
AC_CHECK_FUNCS(fcntl flock lockf inet_aton sigaction getpagesize madvise \
strcasecmp stricmp vsyslog writev pread uname unsetenv \
setrlimit setproctitle seteuid setreuid setegid setresgid \
strtoull strtoll strtouq strtoq getmntinfo \
setpriority quotactl getmntent kqueue kevent backtrace_symbols \
walkcontext dirfd clearenv malloc_usable_size glob fallocate \
posix_fadvise getpeereid getpeerucred)
AC_CHECK_TYPES([struct sockpeercred],,,[
#include <sys/types.h>
#include <sys/socket.h>
])
AC_SEARCH_LIBS(clock_gettime, rt, [
AC_DEFINE(HAVE_CLOCK_GETTIME,, Define if you have the clock_gettime function)
])
AC_CACHE_CHECK([for typeof],i_cv_have_typeof,[
AC_TRY_COMPILE([
], [
int foo;
typeof(foo) bar;
], [
i_cv_have_typeof=yes
], [
i_cv_have_typeof=no
])
])
if test $i_cv_have_typeof = yes; then
AC_DEFINE(HAVE_TYPEOF,, Define if you have typeof())
fi
dnl strtoimax and strtoumax are macros in HP-UX, so inttypes.h must be included
dnl Link instead of just compiling since there's something wrong with Tru64
AC_CACHE_CHECK([for strtoimax],i_cv_have_strtoimax,[
AC_TRY_LINK([
#include <inttypes.h>
], [
strtoimax(0, 0, 0);
], [
i_cv_have_strtoimax=yes
], [
i_cv_have_strtoimax=no
])
])
if test $i_cv_have_strtoimax = yes; then
AC_DEFINE(HAVE_STRTOIMAX,, Define if you have strtoimax function)
fi
AC_CACHE_CHECK([for strtoumax],i_cv_have_strtoumax,[
AC_TRY_LINK([
#include <inttypes.h>
], [
strtoumax(0, 0, 0);
], [
i_cv_have_strtoumax=yes
], [
i_cv_have_strtoumax=no
])
])
if test $i_cv_have_strtoumax = yes; then
AC_DEFINE(HAVE_STRTOUMAX,, Define if you have strtoumax function)
fi
dnl * I/O loop function
have_ioloop=no
if test "$ioloop" = "best" || test "$ioloop" = "epoll"; then
AC_CACHE_CHECK([whether we can use epoll],i_cv_epoll_works,[
AC_TRY_RUN([
#include <sys/epoll.h>
int main()
{
return epoll_create(5) < 1;
}
], [
i_cv_epoll_works=yes
], [
i_cv_epoll_works=no
])
])
if test $i_cv_epoll_works = yes; then
AC_DEFINE(IOLOOP_EPOLL,, Implement I/O loop with Linux 2.6 epoll())
have_ioloop=yes
ioloop=epoll
else
if test "$ioloop" = "epoll" ; then
AC_MSG_ERROR([epoll ioloop requested but epoll_create() is not available])
fi
fi
fi
if test "$ioloop" = "best" || test "$ioloop" = "kqueue"; then
if test "$ac_cv_func_kqueue" = yes && test "$ac_cv_func_kevent" = yes; then
AC_DEFINE(IOLOOP_KQUEUE,, [Implement I/O loop with BSD kqueue()])
ioloop=kqueue
have_ioloop=yes
elif test "$ioloop" = "kqueue"; then
AC_MSG_ERROR([kqueue ioloop requested but kqueue() is not available])
fi
fi
if test "$ioloop" = "best" || test "$ioloop" = "poll"; then
AC_CHECK_FUNC(poll, [
AC_DEFINE(IOLOOP_POLL,, Implement I/O loop with poll())
ioloop=poll
have_ioloop=yes
])
fi
if test "$have_ioloop" = "no"; then
AC_DEFINE(IOLOOP_SELECT,, Implement I/O loop with select())
ioloop="select"
fi
have_notify=none
if test "$notify" = "" || test "$notify" = "inotify" ; then
dnl * inotify?
AC_CACHE_CHECK([whether we can use inotify],i_cv_inotify_works,[
AC_TRY_RUN([
#define _GNU_SOURCE
#include <sys/ioctl.h>
#include <fcntl.h>
#include <sys/inotify.h>
#include <stdio.h>
int main()
{
int wd, fd;
char * fn = "/tmp";
fd = inotify_init ();
if (fd < 0)
{
perror ("inotify_init");
return 1;
}
wd = inotify_add_watch (fd, fn, IN_ALL_EVENTS);
if (wd < 0)
{
perror ("inotify_add_watch");
return 2;
}
inotify_rm_watch (fd, wd);
close (fd);
return 0;
}
], [
i_cv_inotify_works=yes
], [
i_cv_inotify_works=no
])
])
if test $i_cv_inotify_works = yes; then
have_notify=inotify
notify=inotify
AC_DEFINE(IOLOOP_NOTIFY_INOTIFY,, Use Linux inotify)
else
if test "$notify" = "inotify"; then
AC_MSG_ERROR([inotify requested but not available])
notify=""
fi
fi
fi
if (test "$notify" = "" && test "$ioloop" = kqueue) || test "$notify" = "kqueue"; then
dnl * BSD kqueue() notify
AC_MSG_CHECKING([whether we can use BSD kqueue() notify])
if test "$ac_cv_func_kqueue" = yes && test "$ac_cv_func_kevent" = yes ; then
have_notify=kqueue
notify=kqueue
AC_MSG_RESULT("yes")
AC_DEFINE(IOLOOP_NOTIFY_KQUEUE,,
Use BSD kqueue directory changes notificaton)
else
AC_MSG_RESULT("no")
if test "$notify" = "kqueue" ; then
AC_MSG_ERROR([kqueue notify requested but kqueue() is not available])
notify=""
fi
fi
fi
if test "$notify" = "" || test "$notify" = "dnotify"; then
dnl * dnotify?
AC_CACHE_CHECK([whether we can use dnotify],i_cv_have_dnotify,[
AC_TRY_COMPILE([
#define _GNU_SOURCE
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
], [
fcntl(0, F_SETSIG, SIGRTMIN);
fcntl(0, F_NOTIFY, DN_CREATE | DN_DELETE | DN_RENAME | DN_MULTISHOT);
], [
i_cv_have_dnotify=yes
], [
i_cv_have_dnotify=no
])
])
if test $i_cv_have_dnotify = yes; then
AC_DEFINE(IOLOOP_NOTIFY_DNOTIFY,, Use Linux dnotify)
have_notify=dnotify
notify=dnotify
else
if test "$notify" = "dnotify"; then
AC_MSG_ERROR([dnotify requested but not available])
fi
fi
fi
if test "$have_notify" = "none"; then
AC_DEFINE(IOLOOP_NOTIFY_NONE,, No special notify support)
fi
AC_CACHE_CHECK([whether we have glibc],i_cv_have_glibc,[
AC_TRY_COMPILE([
#include <stdlib.h>
#ifdef __GLIBC__
we have glibc
#endif
],, [
i_cv_have_glibc=no
], [
i_cv_have_glibc=yes
])
])
if test "$i_cv_have_glibc" = "yes"; then
AC_DEFINE(PREAD_WRAPPERS,, Define if pread/pwrite needs _XOPEN_SOURCE 500)
fi
dnl * Old glibcs have broken posix_fallocate(). Make sure not to use it.
dnl * It may also be broken in AIX.
AC_CACHE_CHECK([whether posix_fallocate() works],i_cv_posix_fallocate_works,[
AC_TRY_RUN([
#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 7)
possibly broken posix_fallocate
#endif
int main() {
int fd = creat("conftest.temp", 0600);
int ret;
if (fd == -1) {
perror("creat()");
return 2;
}
ret = posix_fallocate(fd, 1024, 1024) < 0 ? 1 : 0;
unlink("conftest.temp");
return ret;
}
], [
i_cv_posix_fallocate_works=yes
], [
i_cv_posix_fallocate_works=no
])
])
if test $i_cv_posix_fallocate_works = yes; then
AC_DEFINE(HAVE_POSIX_FALLOCATE,, Define if you have a working posix_fallocate())
fi
dnl * OS specific options
DC_PLUGIN_DEPS
case "$host_os" in
hpux*)
CFLAGS="$CFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED"
# for getting fd_send/fd_recv working:
LDFLAGS="$LDFLAGS -Wl,+b,:"
LIBS="-lxnet $LIBS"
AC_DEFINE(PREAD_BROKEN,, Defint if pread/pwrite implementation is broken)
;;
linux*|darwin*)
AC_DEFINE(PROCTITLE_HACK,, Define if process title can be changed by modifying argv)
;;
*)
;;
esac
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long long)
AC_DEFUN([AC_TYPEOF], [
dnl * first check if we can get the size with redefining typedefs
order="$2"
if test "$2" = ""; then
order="int long long-long"
fi
result=""
visible="unknown"
AC_MSG_CHECKING([type of $1])
AC_CACHE_VAL(i_cv_typeof_$1,[
if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
dnl * try with printf() + -Werror
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
for type in $order; do
case "$type" in
int)
fmt="%d"
;;
unsigned-int)
fmt="%u"
;;
long)
fmt="%ld"
;;
unsigned-long)
fmt="%lu"
;;
long-long)
fmt="%lld"
;;
unsigned-long-long)
fmt="%llu"
;;
*)
fmt=""
;;
esac
if test "$fmt" != ""; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <stdio.h>
]], [[
printf("$fmt", ($1)0);
]])],[
if test "$result" != ""; then
dnl * warning check isn't working
result=""
visible="unknown"
break
fi
result="`echo $type|sed 's/-/ /g'`"
visible="$result"
],[])
fi
done
CFLAGS="$old_CFLAGS"
fi
if test "$result" = ""; then
for type in $order; do
type="`echo $type|sed 's/-/ /g'`"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
typedef $type $1;
]], [[]])],[
if test "$result" != ""; then
dnl * compiler allows redefining to anything
result=""
visible="unknown"
break
fi
result="$type"
visible="$type"
],[])
done
fi
if test "$result" = ""; then
dnl * check with sizes
dnl * older autoconfs don't include sys/types.h, so do it manually
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
#include <sys/types.h>
int main() {
FILE *f=fopen("conftestval", "w");
if (!f) exit(1);
fprintf(f, "%d\n", sizeof($1));
exit(0);
}
]])],[
size=`cat conftestval`
rm -f conftestval
for type in $order; do
actype="ac_cv_sizeof_`echo $type|sed 's/-/_/g'`"
if test "$size" = "`eval echo \\$$actype`"; then
result="`echo $type|sed 's/-/ /g'`"
visible="`expr $size \* 8`bit (using $result)"
break
fi
done
if test "$result" = ""; then
result=unknown
visible="`expr $size \* 8`bit (unknown type)"
fi
],[],[])
fi
i_cv_typeof_$1=$result/$visible
])
typeof_$1=`echo $i_cv_typeof_$1 | sed s,/.*$,,`
visible=`echo $i_cv_typeof_$1 | sed s,^.*/,,`
AC_MSG_RESULT($visible)
])
AC_SYS_LARGEFILE
AC_CHECK_TYPES(_Bool)
AC_CHECK_TYPE(uoff_t, [
have_uoff_t=yes
AC_DEFINE(HAVE_UOFF_T,, Define if you have a native uoff_t type)
], [
have_uoff_t=no
])
AC_TYPEOF(off_t, long int long-long)
case "$typeof_off_t" in
int)
offt_max=INT_MAX
uofft_fmt="u"
if test "$have_uoff_t" != "yes"; then
AC_DEFINE(UOFF_T_INT,, Define if off_t is int)
fi
offt_bits=`expr 8 \* $ac_cv_sizeof_int`
;;
long)
offt_max=LONG_MAX
uofft_fmt="lu"
if test "$have_uoff_t" != "yes"; then
AC_DEFINE(UOFF_T_LONG,, Define if off_t is long)
fi
offt_bits=`expr 8 \* $ac_cv_sizeof_long`
;;
"long long")
offt_max=LLONG_MAX
uofft_fmt="llu"
if test "$have_uoff_t" != "yes"; then
AC_DEFINE(UOFF_T_LONG_LONG,, Define if off_t is long long)
fi
offt_bits=`expr 8 \* $ac_cv_sizeof_long_long`
;;
*)
AC_MSG_ERROR([Unsupported off_t type])
;;
esac
dnl * Do we have struct dirent->d_type
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <dirent.h>
]], [[
struct dirent d;
d.d_type = DT_DIR;
]])],[
AC_DEFINE(HAVE_DIRENT_D_TYPE,, Define if you have struct dirent->d_type)
],[])
dnl * Do we have OFF_T_MAX?
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <limits.h>
#include <sys/types.h>
]], [[
off_t i = OFF_T_MAX;
]])],[
:
],[
AC_DEFINE_UNQUOTED(OFF_T_MAX, $offt_max, Maximum value of off_t)
])
AC_DEFINE_UNQUOTED(PRIuUOFF_T, "$uofft_fmt", printf() format for uoff_t)
dnl * make sure size_t isn't signed. we'd probably work fine with it, but
dnl * it's more likely vulnerable to buffer overflows. Anyway, C99 specifies
dnl * that it's unsigned and only some old systems define it as signed.
AC_CACHE_CHECK([whether size_t is signed],i_cv_signed_size_t,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <sys/types.h>
int main() {
/* return 0 if we're signed */
exit((size_t)(int)-1 <= 0 ? 0 : 1);
}
]])],[
i_cv_signed_size_t=yes
echo
echo "Your system's size_t is a signed integer, Dovecot isn't designed to"
echo "support it. It probably works just fine, but it's less resistant to"
echo "buffer overflows. If you're not worried about this and still want to"
echo "compile Dovecot, set ignore_signed_size=1 environment."
if test "$ignore_signed_size" = ""; then
AC_MSG_ERROR([aborting])
fi
echo "..ignoring as requested.."
],[
i_cv_signed_size_t=no
],[])
])
dnl Note: we check size_t rather than ssize_t here, because on OSX 10.2
dnl ssize_t = int and size_t = unsigned long. We're mostly concerned about
dnl printf format here, so check the size_t one.
AC_TYPEOF(size_t, unsigned-int unsigned-long unsigned-long-long)
case "$typeof_size_t" in
"unsigned long")
ssizet_max=LONG_MAX
sizet_fmt="lu"
;;
"unsigned long long")
ssizet_max=LLONG_MAX
sizet_fmt="llu"
;;
*)
dnl older systems didn't have ssize_t, default to int
ssizet_max=INT_MAX
sizet_fmt="u"
if test "$typeof_size_t" = ""; then
AC_DEFINE(size_t, unsigned int, Define to 'unsigned int' if you don't have it)
AC_DEFINE(ssize_t, int, Define to 'int' if you don't have it)
fi
;;
esac
AC_DEFINE_UNQUOTED(SSIZE_T_MAX, $ssizet_max, Maximum value of ssize_t)
AC_DEFINE_UNQUOTED(PRIuSIZE_T, "$sizet_fmt", printf() format for size_t)
AC_DEFUN([AC_CHECKTYPE2], [
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(i_cv_type_$1,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
$2]], [[$1 t;]])],[i_cv_type_$1=yes],[i_cv_type_$1=no])])
AC_MSG_RESULT($i_cv_type_$1)
])
dnl some systems don't have stdint.h, but still have some of the types
dnl defined elsewhere
AC_CHECK_HEADER(stdint.h, [
stdint_include="#include <stdint.h>"
])
AC_CHECKTYPE2(uintmax_t, [$stdint_include])
if test $i_cv_type_uintmax_t = yes; then
AC_DEFINE(HAVE_UINTMAX_T,, Define if you have uintmax_t (C99 type))
fi
dnl use separate check, eg. Solaris 8 has uintmax_t but not uint_fast32_t
AC_CHECKTYPE2(uint_fast32_t, [$stdint_include])
if test $i_cv_type_uint_fast32_t = yes; then
AC_DEFINE(HAVE_UINT_FAST32_T,, Define if you have uint_fast32_t (C99 type))
fi
AC_CHECKTYPE2(socklen_t, [#include <sys/socket.h>])
if test $i_cv_type_socklen_t = yes; then
AC_DEFINE(HAVE_SOCKLEN_T,, Define to 'int' if you don't have socklen_t)
fi