Codebase list cyrus-imapd / upstream/2.4.17+caldav_beta7 configure.in
upstream/2.4.17+caldav_beta7

Tree @upstream/2.4.17+caldav_beta7 (Download .tar.gz)

configure.in @upstream/2.4.17+caldav_beta7raw · history · blame

   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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
dnl Process this file with autoconf to produce a configure script.

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


AC_INIT(imap/imapd.c)
AC_PREREQ([2.54])
AC_CONFIG_HEADER(config.h)
AC_CANONICAL_SYSTEM

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

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

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

AC_ARG_WITH(cyrus-prefix,[  --with-cyrus-prefix=DIR    use DIR as cyrus server install directory],
	cyrus_prefix="$withval",cyrus_prefix="/usr/cyrus")
AC_SUBST(cyrus_prefix)
AC_DEFINE_UNQUOTED(CYRUS_PATH,"$cyrus_prefix",[Where will we be installed?])
AC_ARG_WITH(service-path,[  --with-service-path=DIR    use DIR as service install directory],
	service_path="$withval",service_path="$cyrus_prefix/bin")
AC_SUBST(service_path)
AC_DEFINE_UNQUOTED(SERVICE_PATH,"$service_path",[Directory to use for service binaries])
AC_ARG_WITH(cyrus-user,[  --with-cyrus-user=USERID   use USERID cyrus userid],
	cyrus_user="$withval",cyrus_user="cyrus")
AC_SUBST(cyrus_user)
AC_DEFINE_UNQUOTED(CYRUS_USER, "$cyrus_user",[What user will we run as?])
AC_ARG_WITH(cyrus-group,[  --with-cyrus-group=GROUPID use GROUPID cyrus group],
	cyrus_group="$withval",cyrus_group="mail")
AC_SUBST(cyrus_group)

dnl allow users to override $sysconfdir, but retain old default (/etc)
dnl if not specified
if test $sysconfdir = '${prefix}/etc'; then
  sysconfdir="/etc"
fi
AC_DEFINE_UNQUOTED(SYSCONFDIR,"$sysconfdir",[Config File Location])

AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_AIX
AC_ISC_POSIX
AC_PROG_AWK
AC_C_CONST
AC_SYS_LONG_FILE_NAMES
if test $ac_cv_sys_long_file_names = no; then
	AC_MSG_ERROR(The Cyrus IMAPD requires support for long file names)
fi
AC_C_INLINE

dnl Check the size of various types
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(off_t)

dnl Check if `long long int' is available
AC_CHECK_SIZEOF(long long int)
AC_CHECK_SIZEOF(unsigned long long int)
if test "$ac_cv_sizeof_long_long_int" -eq 8 -a \
        "$ac_cv_sizeof_unsigned_long_long_int" -eq 8; then
  AC_DEFINE(HAVE_LONG_LONG_INT,[],[Does the compiler support long long int?])
  AC_C_BIGENDIAN
fi

CMU_C___ATTRIBUTE__
CMU_C_FPIC

dnl check for -R, etc. switch
CMU_GUESS_RUNPATH_SWITCH

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

dnl check whether to use getpassphrase or getpass
AC_CHECK_HEADERS(stdlib.h)
AC_CHECK_FUNCS(getpassphrase)

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

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

if test $cyrus_cv_getaddrinfo = no; then
	IPV6_OBJS="getaddrinfo.o"
fi

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

if test $cyrus_cv_getnameinfo = no; then
	IPV6_OBJS="$IPV6_OBJS getnameinfo.o"
fi

IPv6_CHECK_SS_FAMILY()
IPv6_CHECK_SA_LEN()

AC_SUBST(IPV6_OBJS)

dnl this is to check for time things
AC_CHECK_HEADERS(sys/time.h)
AC_HEADER_TIME
AC_STRUCT_TM
AC_STRUCT_TIMEZONE

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

dnl function for doing each of the database backends
dnl parameters: backend name, variable to set, withval

CYRUSDB_OBJS="cyrusdb_flat.o cyrusdb_skiplist.o cyrusdb_quotalegacy.o"

dnl Berkeley DB Detection

AC_ARG_WITH(bdb, [  --with-bdb=DIR          use Berkeley DB (in DIR) [[yes]] ],
	with_bdb=$withval, with_bdb="yes")

dnl support old-style
AC_ARG_WITH(dbdir,, with_bdb=$withval)

case "$with_bdb" in
  no)
	use_berkeley="no"
	;;
  yes)
	use_berkeley="yes"
	with_bdb_lib=none
	with_bdb_inc=none
	;;
  
  *)
	use_berkeley="yes"
	with_bdb_lib="$with_bdb/lib"
	with_bdb_inc="$with_bdb/include"
	;;
esac

if test "$use_berkeley" != "no"; then
  CYRUS_BERKELEY_DB_CHK()

  if test "$dblib" = "no"; then
    AC_ERROR([Berkeley DB 3.x or later was not found.  You may need to 
    supply the --with-bdb-libdir or --with-bdb-incdir configure options.])
  fi

  if test "$with_bdb_lib" != "none"; then
    CMU_ADD_LIBPATH($with_bdb_lib)
  fi

  BDB_INC=${BDB_INCADD}
  BDB_LIB=${BDB_LIBADD}
  AC_SUBST(BDB_INC)
  AC_SUBST(BDB_LIB)

  LIBS="${LIBS} ${BDB_LIBADD}"
  CPPFLAGS="${BDB_INCADD} ${CPPFLAGS}"

  CYRUSDB_OBJS="$CYRUSDB_OBJS cyrusdb_berkeley.o"
  AC_DEFINE(HAVE_BDB,[],[Build in Berkeley DB support?])
fi

dnl End Berkeley DB Detection


dnl SQL DB Detection

HAVE_SQL=0

dnl MySQL Detection
AC_ARG_WITH(mysql,  [  --with-mysql=DIR          use MySQL (in DIR) [[no]] ],
  with_mysql=$withval, with_mysql="no")

case "$with_mysql" in
  no)
	use_mysql="no"
	;;
  yes)
	use_mysql="yes"
	with_mysql_lib=none
	with_mysql_inc=none
	;;
  
  *)
	use_mysql="yes"
	with_mysql_lib="$with_mysql/lib"
	with_mysql_inc="$with_mysql/include"
	;;
esac

if test "$use_mysql" != "no"; then
  CYRUS_MYSQL_CHK()

  if test "$mysqllib" = "no"; then
    AC_ERROR([MySQL was not found.  You may need to supply the
    --with-mysql-libdir or --with-mysql-incdir configure options.])
  else
    HAVE_SQL=1
  fi

  if test "$with_mysql_lib" != "none"; then
    CMU_ADD_LIBPATH($with_mysql_lib)
  fi

  LIBS="${LIBS} ${MYSQL_LIBADD}"
  CPPFLAGS="${MYSQL_INCADD} ${CPPFLAGS}"

  AC_DEFINE(HAVE_MYSQL,[],[Build in MySQL support?])
fi

dnl End MySQL Detection


dnl PgSQL Detection
AC_ARG_WITH(pgsql,  [  --with-pgsql=DIR          use PostgreSQL (in DIR) [[no]] ],
  with_pgsql=$withval, with_pgsql="no")

case "$with_pgsql" in
  no)
	use_pgsql="no"
	;;
  yes)
	use_pgsql="yes"
	with_pgsql_lib=none
	with_pgsql_inc=none
	;;
  
  *)
	use_pgsql="yes"
	with_pgsql_lib="$with_pgsql/lib"
	with_pgsql_inc="$with_pgsql/include"
	;;
esac

if test "$use_pgsql" != "no"; then
  CYRUS_PGSQL_CHK()

  if test "$pgsqllib" = "no"; then
    AC_ERROR([PgSQL was not found.  You may need to supply the
    --with-pgsql-libdir or --with-pgsql-incdir configure options.])
  else
    HAVE_SQL=1
  fi

  if test "$with_pgsql_lib" != "none"; then
    CMU_ADD_LIBPATH($with_pgsql_lib)
  fi

  LIBS="${LIBS} ${PGSQL_LIBADD}"
  CPPFLAGS="${PGSQL_INCADD} ${CPPFLAGS}"

  AC_DEFINE(HAVE_PGSQL,[],[Build in PgSQL support?])
fi

dnl End PgSQL Detection


dnl SQLite Detection
AC_ARG_WITH(sqlite,  [  --with-sqlite=DIR          use SQLite (in DIR) [[no]] ],
  with_sqlite=$withval, with_sqlite=no)

case "$with_sqlite" in
  no)
	use_sqlite="no"
	;;
  yes)
	use_sqlite="yes"
	with_sqlite_lib=none
	with_sqlite_inc=none
	;;
  
  *)
	use_sqlite="yes"
	with_sqlite_lib="$with_sqlite/lib"
	with_sqlite_inc="$with_sqlite/include"
	;;
esac

if test "$use_sqlite" != "no"; then
  CYRUS_SQLITE_CHK()

  if test "$sqlitelib" = "no"; then
    AC_ERROR([Sqlite was not found.  You may need to supply the
    --with-sqlite-libdir or --with-sqlite-incdir configure options.])
  else
    HAVE_SQL=1
  fi

  if test "$with_sqlite_lib" != "none"; then
    CMU_ADD_LIBPATH($with_sqlite_lib)
  fi

  LIBS="${LIBS} ${SQLITE_LIBADD}"
  CPPFLAGS="${SQLITE_INCADD} ${CPPFLAGS}"

  AC_DEFINE(HAVE_SQLITE,[],[Build in SQLite support?])
fi

dnl End SQLite Detection


if test $HAVE_SQL = 1; then
  CYRUSDB_OBJS="${CYRUSDB_OBJS} cyrusdb_sql.o"
fi

dnl End SQL DB Detection

AC_SUBST(CYRUSDB_OBJS)

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

testpcre="yes"
AC_ARG_ENABLE(pcre,
		[  --disable-pcre      disable PCRE library],
	if test "$enableval" = no; then
		testpcre="no"
	fi)

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

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

	if test "$testpcre" != "no"; then
	    AC_CHECK_HEADER(pcreposix.h)
	    if test "$ac_cv_header_pcreposix_h" = "yes"; then
		    AC_MSG_CHECKING(for utf8 enabled pcre)
		    AC_CACHE_VAL(cyrus_cv_pcre_utf8, AC_TRY_CPP([#include <pcreposix.h>
#ifndef REG_UTF8
#include </nonexistent>
#endif],cyrus_cv_pcre_utf8=yes,cyrus_cv_pcre_utf8=no))
		    AC_MSG_RESULT($cyrus_cv_pcre_utf8)
	    else
		    cyrus_cv_pcre_utf8="no"
	    fi
	fi

	if test "$cyrus_cv_pcre_utf8" = "yes"; then
		LIBS="$LIBS -lpcre -lpcreposix";
		AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
		AC_DEFINE(HAVE_PCREPOSIX_H, [], [Do we have usable pcre library?])
	else 
		AC_CHECK_HEADERS(rxposix.h)
		if test "$ac_cv_header_rxposix_h" = "yes"; then
			LIBS="$LIBS -lrx"
			AC_DEFINE(ENABLE_REGEX, [],
				  [Do we have a regex library?])
		else
			AC_SEARCH_LIBS(regcomp, regex,
					AC_DEFINE(ENABLE_REGEX, [],
					[Do we have a regex library?]), [])
		fi
	fi

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

AC_SUBST(SIEVE_SUBDIRS)

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

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

dnl for detaching terminal
AC_CHECK_FUNCS(daemon setsid)

dnl for turning off sockets
AC_CHECK_FUNCS(shutdown)

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

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

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

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

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

AC_SUBST(WITH_LOCK)

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

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

# ok, we still look for this stuff because of checking groups, but
# all authentication goes through SASL
AC_ARG_ENABLE([afs],[  --enable-afs            Enable AFS with ptloader])

AC_ARG_WITH(afs-libdir,[  --with-afs-libdir=PATH  use AFS libraries from PATH [[/usr/lib]]],
	    afs_libdir="${withval}", afs_libdir="/usr/lib")
 
AC_ARG_WITH(afs-incdir,[  --with-afs-incdir=PATH  use AFS headers from PATH [[/usr/include]]],
            afs_incdir="${withval}", afs_incdir="/usr/include")

AC_ARG_WITH(ldap, [  --with-ldap=DIR         use LDAP (in DIR) (experimental) [/usr/local] ],
	    with_ldap="${withval}", with_ldap="no")
  
dnl select mode of afspts
AC_ARG_ENABLE(krb5afspts,[  --enable-krb5afspts     compile afskrb PTS module with krb5 support])

if test "x$enable_afs" = "xyes"; then
# krb5afspts is only valid if AFS is enabled, so check inside here.
    AS_IF([test "x$enable_krb5afspts" = "xyes"], [SASL_SET_GSSAPI_LIBS
      AC_DEFINE(AFSPTS_USE_KRB5,[],[Should the AFS PTS plugin use krb5?])    
    ])

    CFLAGS="${CFLAGS} -I${with_afs_incdir}/include"
    AFS_LIBS="${with_afs_libdir}/afs/libkauth.a ${with_afs_libdir}/afs/libprot.a  ${with_afs_libdir}/afs/libauth.a ${with_afs_libdir}/afs/libsys.a ${with_afs_libdir}/librxkad.a ${with_afs_libdir}/librx.a ${with_afs_libdir}/afs/libsys.a ${with_afs_libdir}/libubik.a  ${with_afs_libdir}/liblwp.a ${with_afs_libdir}/afs/util.a"
    if test -f ${with_afs_libdir}/afs/libafscom_err.a; then
      AFS_LIBS="$AFS_LIBS ${with_afs_libdir}/afs/libafscom_err.a"
    else
      AFS_LIBS="$AFS_LIBS ${with_afs_libdir}/afs/libcom_err.a"
    fi
    if test -f ${with_afs_libdir}/afs/libaudit.a; then
      AFS_LIBS="$AFS_LIBS ${with_afs_libdir}/afs/libaudit.a"
    fi
    if test -f /usr/ucblib/libucb.a; then
      CMU_ADD_LIBPATH_TO(/usr/ucblib, AFS_LDFLAGS)
      AFS_LIBS="$AFS_LIBS -lc -lucb"
    fi
    if test -f ${with_afs_libdir}/afs/libdes.a; then
      AFS_LIBS="$AFS_LIBS ${with_afs_libdir}/afs/libdes.a"
    else
      AFS_LIBS="$AFS_LIBS -ldes"
    fi

    AC_CACHE_VAL(cyrus_cv_afs_sigvec,[
        SAVE_LIBS="$LIBS"
        LIBS="${with_afs_libdir}/liblwp.a"
        AC_MSG_CHECKING(if AFS libraries need sigvec)
        dnl Does AFS need sigvec?  We have to link against lwp and see
        dnl if IOMGR_Initialize wants it
        AC_TRY_LINK([IOMGR_Initialize();],
                [IOMGR_Initialize()],
                [
                        dnl it linked; don't need it
                        AC_MSG_RESULT(no)
                        cyrus_cv_afs_sigvec="no"
                ], [
                        dnl didn't link; pick up sigvec
                        AC_MSG_RESULT(yes)
                        cyrus_cv_afs_sigvec="yes"
                ])
        ])
    if test "$cyrus_cv_afs_sigvec" = yes; then
      if test "$cant_find_sigvec" = yes; then
        AC_MSG_WARN([Can't find a sigvec for AFS libraries which seem to need one.])
      else
        AFS_LIBS="${AFS_LIBS} $cyrus_cv_sigveclib"
        AC_SUBST(AFS_LIBS)
        AC_SUBST(AFS_LDFLAGS)
        AC_DEFINE(HAVE_AFSKRB,[],[Should we build afskrb pts module?])
      fi
    else
      AFS_LIBS="${AFS_LIBS}"
      AC_SUBST(AFS_LIBS)
      AC_SUBST(AFS_LDFLAGS)
      AC_DEFINE(HAVE_AFSKRB,[],[Should we build afskrb pts module?])
    fi
    LIBS="$SAVE_LIBS"
fi

LDAP_CPPFLAGS=""
LDAP_LDFLAGS=""
LDAP_LIBS=""

if test "x$with_ldap" != "xno"; then
    if test ! -d $with_ldap; then
        with_ldap=/usr/local
    fi

    LDAP_CPPFLAGS="$CPPFLAGS -I${with_ldap}/include"
    LDAP_LDFLAGS="$LDFLAGS -L${with_ldap}/lib"
    LDAP_LIBS=""

    save_CPPFLAGS=$CPPFLAGS
    save_LDFLAGS=$LDFLAGS
    CPPFLAGS=$LDAP_CPPFLAGS
    LDFLAGS=$LDAP_LDFLAGS

    AC_CHECK_LIB(ldap, ldap_initialize, 
        [ AC_DEFINE(HAVE_LDAP,[],[Should we build ldap pts module?])
          AC_SUBST(LDAP_CPPFLAGS)
          AC_SUBST(LDAP_LDFLAGS)
          AC_SUBST(LDAP_LIBS) 
          LDAP_LIBS="-lldap -llber" ],,-llber)

    CPPFLAGS=$save_CPPFLAGS
    LDFLAGS=$LDAP_LDFLAGS

    AC_CHECK_LIB(ldap, ldap_initialize, 
        [ AC_DEFINE(HAVE_LDAP,[],[Should we build ldap pts module?])
          AC_SUBST(LDAP_CPPFLAGS)
          AC_SUBST(LDAP_LDFLAGS)
          AC_SUBST(LDAP_LIBS) 
          LDAP_LIBS="-lldap -llber" ],,-llber)

    CPPFLAGS=$save_CPPFLAGS
    LDFLAGS=$save_LDFLAGS
fi
 
if test "x$enable_afs" = "xyes" -o "x$with_ldap" != "xno"; then
        EXTRA_SUBDIRS="${EXTRA_SUBDIRS} ptclient"
        EXTRA_OUTPUT="${EXTRA_OUTPUT} ptclient/Makefile"

	AC_DEFINE(WITH_PTS,[],[Build in PTS support?])
fi



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

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

AC_ARG_WITH(krbimpl,[  --with-krbimpl=\[kth|mit\]         assume Kerberos 4 from KTH or MIT],
	with_krbimpl="$withval", with_krbimpl="kth")

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

dnl In order to compile kerberos4, we need libkrb and libdes.

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

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

if test "$with_krb" != "no"; then
dnl Do we need DES for kerberos?
AC_ARG_WITH(krbdes,[  --with-krbdes           use Kerberos DES implementation [[yes]]],
      with_krbdes="$withval", with_krbdes="yes")
if test "$with_krbdes" = "yes"; then
  AC_CHECK_LIB(des,des_ecb_encrypt,
      if test "$with_statickrb" = "yes"; then
          KRB_LIBS="$with_krb/lib/libdes.a"
      else
          KRB_LIBS="-ldes"
      fi,
  AC_MSG_ERROR([The Kerberos DES library is required for Kerberos support.  You might want --with-auth=unix.]))
fi
fi

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

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

if test "$with_krbimpl" != "kth"; then
  KRBLIB="krb4"
else
  KRBLIB="krb"
fi

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

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

LIBS="$KRB_LIBS $LIBS"

SASL_SET_GSSAPI_LIBS

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

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

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

AC_MSG_CHECKING(for openssl)
AC_MSG_RESULT($with_openssl)

if test "$with_openssl" != "no"; then
	AC_DEFINE(HAVE_SSL,[],[Build with SSL support?])
	IMAP_PROGS="$IMAP_PROGS tls_prune"
        if test "${krb4}" != no; then
           AC_DEFINE(OPENSSL_ENABLE_OLD_DES_SUPPORT,[],[Configure OpenSSL to provide legacy des apis])
           AC_DEFINE(OPENSSL_DES_LIBDES_COMPATIBILITY,[],[Configure OpenSSL to provide krb4-compatible legacy des apis])
        fi
fi
AC_SUBST(OPENSSL_INC)
AC_SUBST(OPENSSL_LIB)

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

dnl
dnl Test for zlib
dnl
CMU_HAVE_ZLIB
AC_MSG_CHECKING(for zlib)
AC_MSG_RESULT($with_zlib)
AC_SUBST(ZLIB)

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

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

dnl
dnl see if we're compiling with IMAP idled support
dnl
AC_ARG_ENABLE(idled,
        [  --enable-idled          enable IMAP idled support],
        if test "$enable_val" != no; then
	  IMAP_PROGS="$IMAP_PROGS idled"
        fi) 

dnl
dnl see if we're compiling with NNTP support
dnl
ENABLE_NNTP=no
AC_ARG_ENABLE(nntp,
        [  --enable-nntp           enable NNTP support],
	ENABLE_NNTP=$enableval
        if test "$ENABLE_NNTP" != no; then
	  IMAP_PROGS="$IMAP_PROGS nntpd fetchnews"
        fi) 

dnl
dnl see if we're compiling with HTTP support
dnl
ENABLE_HTTP=no
AC_ARG_ENABLE(http,
        [  --enable-http           enable HTTP support],
	ENABLE_HTTP=$enableval)

if test "$ENABLE_HTTP" != no; then
dnl
dnl see which HTTP modules we can compile
dnl
	ENABLE_RSS=yes
	ENABLE_DAV=yes
	PKG_CHECK_MODULES([XML2], [libxml-2.0],
		[ PKG_CHECK_MODULES([ICAL], [libical],
		  	[ PKG_CHECK_MODULES([SQLITE3], [sqlite3],,
			  	ENABLE_DAV=no) ],
			ENABLE_DAV=no ) ],
		[ ENABLE_RSS=no
		  ENABLE_DAV=no ])
fi

HTTP_OBJS=""
if test "$ENABLE_RSS" != no -o "$ENABLE_DAV" != no; then
   IMAP_PROGS="$IMAP_PROGS httpd"
   AC_SUBST(XML2_CFLAGS)
   AC_SUBST(XML2_LIBS)

   if test "$ENABLE_RSS" != no; then
      AC_DEFINE(WITH_RSS,[],[Build RSS support into httpd?])
      HTTP_OBJS="$HTTP_OBJS \$(RSS_OBJS)"
   fi

   if test "$ENABLE_DAV" != no; then
      AC_DEFINE(WITH_DAV,[],[Build DAV support into httpd?])

      IMAP_PROGS="$IMAP_PROGS dav_reconstruct"
      HTTP_OBJS="$HTTP_OBJS \$(DAV_OBJS) \$(CALDAV_OBJS) \$(CARDDAV_OBJS) \$(ISCHED_OBJS)"
      AC_SUBST(ICAL_CFLAGS)
      AC_SUBST(ICAL_LIBS)
      AC_SUBST(SQLITE3_CFLAGS)
      AC_SUBST(SQLITE3_LIBS)

      CYRUS_OPENDKIM_CHK()
      if test "$opendkimlib" = "yes"; then
      	 AC_SUBST(DKIM_CFLAGS)
	 AC_SUBST(DKIM_LIBS)
	 AC_DEFINE(WITH_DKIM,[],[Build DKIM support into iSchedule?]) 
      fi
   fi
fi
AC_SUBST(HTTP_OBJS)

dnl
dnl see if we're compiling the Murder support programs
dnl
ENABLE_MURDER=no
AC_ARG_ENABLE(murder,
        [  --enable-murder         enable IMAP Murder support],
	ENABLE_MURDER=$enableval)

if test "$ENABLE_MURDER" != no; then
	IMAP_PROGS="$IMAP_PROGS mupdate"
	# for master/slave auto-selection
	AC_CHECK_HEADERS(sys/sockio.h)
fi

dnl
dnl see if we're compiling replication support programs
dnl
ENABLE_REPLICATION=no
AC_ARG_ENABLE(replication,
        [  --enable-replication    enable replication support (experimental)],
	ENABLE_REPLICATION=$enableval
        if test "$ENABLE_REPLICATION" != no; then
	  IMAP_PROGS="$IMAP_PROGS sync_client sync_server sync_reset"
        fi) 

AC_SUBST(IMAP_PROGS)

dnl
dnl Try and find a system version of com_err.
dnl If we see something that looks a little wacky, ignore it (there are many
dnl deficient installs of com_err, unfortunately, which leave out compile_et)
dnl There is also a broken re-implementation of compile_et, apparently derived
dnl from the Kerberos project, being shipped in /usr/bin on MacOS X, see Bug #3711.
dnl
AC_ARG_WITH(com_err,
[  --with-com_err=PATH     use com_err from path -- includes in PATH/include,
                          libs in PATH/lib, and compile_et in PATH/bin])
if test -z "$with_com_err"; then
	# no value supplied
	AC_CHECK_LIB(com_err, com_err, [
		# com_err is already in library path
		# guess we're okay
		# can use system com_err
		with_com_err=""
		AC_CHECK_HEADER(et/com_err.h,
		  [AC_DEFINE(HAVE_ET_COM_ERR_H,[],[We need et/com_err.h])],
		  [AC_CHECK_HEADER(com_err.h,[],[AC_ERROR([cannot locate com_err.h])])])
		AC_PATH_PROG(COMPILE_ET, compile_et, [no compile et])
	], [
	if test -f /usr/local/include/com_err.h -o -f /usr/local/include/et/com_err.h; then
		with_com_err="/usr/local"
		AC_PATH_PROG(COMPILE_ET, /usr/local/bin/compile_et, [no compile et])
	elif test -f /usr/include/com_err.h -o -f /usr/include/et/com_err.h; then
		with_com_err="/usr"
		AC_PATH_PROG(COMPILE_ET, /usr/bin/compile_et, [no compile et])
	else
		# use ours
		with_com_err=yes
	fi
	])

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

dnl Set up $COMPILE_ET first, we need to test it
case "$with_com_err" in
  # built-in et
  yes) # use the com_err we're gonna build
	  COMPILE_ET="../com_err/et/compile_et"
	  ;;
  "")   # no problem, we already have it in the paths
	# we do nothing to pick it up
      ;;
  *) # use whatever they told us, or whatever we found
     COMPILE_ET="${with_com_err}/bin/compile_et"
esac

if test "$with_com_err" != yes ; then
    dnl Test that the specified compile_et produces correct output
    dnl See bug #3711 for why this is necessary
    TEST1=".cyrus-configure-test-$$"
    /bin/rm -f $TEST1.et $TEST1.h $TEST1.c
    echo "error_table imap" >> $TEST1.et
    echo "ec IMAP_TESTING," >> $TEST1.et
    echo "   \"Testing\"" >> $TEST1.et
    echo "end" >> $TEST1.et
    "${COMPILE_ET}" $TEST1.et > /dev/null
    compile_et_ok=no
    if test -f $TEST1.h ; then
	if test `awk '/IMAP_TESTING/{print $3}' $TEST1.h 2>/dev/null` = "(-1904809472L)" ; then
	    compile_et_ok=yes
	fi
	dnl Broken compile_et produces (2390157824L)
    fi
    /bin/rm -f $TEST1.et $TEST1.h $TEST1.c
    if test "$compile_et_ok" = no ; then
	AC_MSG_WARN([It seems $COMPILE_ET is buggy, building our own])
	COMPILE_ET="../com_err/et/compile_et" # build it ourselves
    fi
fi

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

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

AC_MSG_CHECKING(which syslog facility to use)
SYSLOG_FACILITY=LOG_LOCAL6
AC_ARG_WITH(syslogfacility,[  --with-syslogfacility=FACILITY set the syslog facility to use (default LOCAL6)],
               [ if test "$withval" != "yes" -a "$withval" != "no" ; then
                       SYSLOG_FACILITY=LOG_$withval
               fi; ])
AC_DEFINE_UNQUOTED(SYSLOG_FACILITY, $SYSLOG_FACILITY, [Syslog facility to use.])
AC_MSG_RESULT($SYSLOG_FACILITY)

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

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

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

AC_CHECK_FUNC(dlopen,,[AC_CHECK_LIB(dl, dlopen)])
CMU_SASL2_REQUIRE_VER(2,1,7)
CMU_SASL2_CHECKAPOP_REQUIRED

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

if test "${with_perl}" = yes; then
    with_perl="perl"
fi
if test "${with_perl}" != no; then
    if test ${using_static_sasl} = "staticonly"; then
	AC_MSG_WARN([Cannot compile perl utilities using static libsasl])
	with_perl="no"
    else 
	AC_CHECK_PROGS(PERL, ${with_perl} perl, with_perl=notfound)
    fi
fi
if test "$with_perl" = "notfound"; then
    AC_MSG_WARN(Perl not found: Administrative tools won't be available)
elif test "${with_perl}" != "no"; then
dnl compile perl stuff
    EXTRA_SUBDIRS="${EXTRA_SUBDIRS} perl"
dnl and compile perl/cyradm
    PERL_SUBDIRS="imap"
    PERL="${with_perl}"
dnl add perl cccdlflags when building libraries -- this ensures that the
dnl libraries will be compiled as PIC if perl requires PIC objects
dnl -- this is needed on NetBSD and Linux, but seems to cause problems on atleast Solaris --
    case "${target_os}" in
        linux*|netbsd*|freebsd*|dragonfly*)
            AC_MSG_CHECKING(for perl cccdlflags needed on "${target_os}")
            eval `${PERL} -V:cccdlflags`
            PERL_CCCDLFLAGS="$cccdlflags"
            AC_SUBST(PERL_CCCDLFLAGS)
            AC_MSG_RESULT($PERL_CCCDLFLAGS)
            ;;
        *)
            AC_MSG_WARN(skipping check for perl cccdlflags on "${target_os}")
    esac
fi

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

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

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

CMU_LIBWRAP
CMU_UCDSNMP

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

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

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

IMAP_COM_ERR_LIBS="${COM_ERR_LIBS}"
IMAP_LIBS="${LIB_SASL} ${LIBS} ${SQL_LIBS}"

AC_SUBST(LIB_RT)
AC_SUBST(IMAP_COM_ERR_LIBS)
AC_SUBST(IMAP_LIBS)

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

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

#ifndef _CYRUS_IMAPD_CONFIG_H_
#define _CYRUS_IMAPD_CONFIG_H_
])

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

/* com_err.h, as needed */
#ifndef IN_COM_ERR
#ifdef HAVE_ET_COM_ERR_H
#include <et/com_err.h>
#else
#include <com_err.h>
#endif /* HAVE_ET_COM_ERR_H */
#endif /* IN_COM_ERR */

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

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

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

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

#ifndef HAVE_SOCKLEN_T
typedef unsigned int socklen_t;
#endif

#ifndef HAVE_RLIM_T
typedef int rlim_t;
#endif

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

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

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

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

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

#ifndef HAVE_SS_FAMILY
#define ss_family	__ss_family
#endif

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

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

/* End IPv6 things */

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

/* filenames */
#define FNAME_DBDIR "/db"
#define FNAME_USERDIR "/user/"
#define FNAME_DOMAINDIR "/domain/"
#define FNAME_LOGDIR "/log/"
#define FNAME_PTSDB "/ptclient/ptscache.db"
#define CONFIG_FILENAME (SYSCONFDIR "/imapd.conf")
#define DEFAULT_MASTER_CONFIG_FILENAME (SYSCONFDIR "/cyrus.conf")

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

/* *printf() macros */
#if (SIZEOF_SIZE_T == SIZEOF_INT)
#define SIZE_T_FMT "%u"
#elif (SIZEOF_SIZE_T == SIZEOF_LONG)
#define SIZE_T_FMT "%lu"
#elif (SIZEOF_SIZE_T == SIZEOF_LONG_LONG_INT)
#define SIZE_T_FMT "%llu"
#else
#error dont know what to use for SIZE_T_FMT
#endif

#if (SIZEOF_OFF_T == SIZEOF_LONG)
#define OFF_T_FMT "%ld"
#define strtoofft(nptr, endptr, base) strtol(nptr, endptr, base)
#elif (SIZEOF_OFF_T == SIZEOF_LONG_LONG_INT)
#define OFF_T_FMT "%lld"
#define strtoofft(nptr, endptr, base) strtoll(nptr, endptr, base)
#else
#error dont know what to use for OFF_T_FMT
#endif

#ifndef HAVE_STRSEP
extern char *strsep(char **, const char *);
#endif

#ifndef HAVE_MEMMEM
extern void *memmem(const void *, size_t, const void *, size_t);
#endif

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

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

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

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

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

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

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

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

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

#endif /* _CYRUS_IMAPD_CONFIG_H_ */
])

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