File: configure.in

package info (click to toggle)
kolab-cyrus-imapd 2.2.13-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 14,028 kB
  • ctags: 8,058
  • sloc: ansic: 83,921; sh: 36,867; perl: 3,994; makefile: 1,416; yacc: 949; awk: 302; lex: 249; asm: 214
file content (1212 lines) | stat: -rw-r--r-- 37,198 bytes parent folder | download | duplicates (8)
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
dnl Process this file with autoconf to produce a configure script.

dnl
dnl Copyright (c) 1998-2005 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 other legal
dnl    details, please contact  
dnl      Office of Technology Transfer
dnl      Carnegie Mellon University
dnl      5000 Forbes Avenue
dnl      Pittsburgh, PA  15213-3890
dnl      (412) 268-4387, fax: (412) 268-7395
dnl      tech-transfer@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
dnl configure.in for the Cyrus imapd
dnl $Id: configure.in,v 1.296 2005/10/13 19:56:14 jeaton Exp $
dnl


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

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",[Directiory 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

CMU_C___ATTRIBUTE__
CMU_C_FPIC

AC_CHECK_SIZEOF(long)

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)
AC_CHECK_FUNCS(strlcat strlcpy)
AC_HEADER_DIRENT

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

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)

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)

 	AC_SEARCH_LIBS(regcomp, rx regex, [
 			AC_DEFINE(ENABLE_REGEX,[],[Do we have a decent regex library?])
		 	AC_CHECK_HEADER(rxposix.h, AC_DEFINE(HAVE_RX,[],[Do we have rxposix.h?]))])
  		

	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_sigveclib,[
 dnl bsd classic flavor
 AC_CHECK_FUNC(sigvec, [
	cyrus_sigveclib=""
  ], [
  dnl hp flavor
  AC_CHECK_LIB(BSD, sigvec, cyrus_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_sigveclib="-lc -L/usr/ucblib -R/usr/ucblib -lucb"],
      [ cant_find_sigvec=yes ])
    LDFLAGS="$SAVE_LDFLAGS"])
  ])
])
AC_SUBST(cyrus_sigveclib)

# ok, we still look for this stuff because of checking groups, but
# all authentication goes through SASL

AC_ARG_WITH(afs,[  --with-afs=PATH         use AFS libraries from PATH],
	with_afs="${withval}", with_afs="no")

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],
	[SASL_SET_GSSAPI_LIBS
         AC_DEFINE(AFSPTS_USE_KRB5,[],[Should the AFS PTS plugin use krb5?])])

if test "x$with_afs" != "xno"; then
    if test ! -d $with_afs; then
        $with_afs=/usr/local
    fi
    CFLAGS="${CFLAGS} -I${with_afs}/include"
    AFS_LIBS="${with_afs}/lib/afs/libkauth.a ${with_afs}/lib/afs/libprot.a  ${with_afs}/lib/afs/libauth.a ${with_afs}/lib/afs/libsys.a ${with_afs}/lib/librxkad.a ${with_afs}/lib/librx.a ${with_afs}/lib/afs/libsys.a ${with_afs}/lib/libubik.a  ${with_afs}/lib/liblwp.a ${with_afs}/lib/afs/util.a"
    if test -f ${with_afs}/lib/afs/libaudit.a; then
    AFS_LIBS="$AFS_LIBS ${with_afs}/lib/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

    AC_CACHE_VAL(cyrus_afs_sigvec,[
        SAVE_LIBS="$LIBS"
        LIBS="${with_afs}/lib/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_afs_sigvec="no"
                ], [
                        dnl didn't link; pick up sigvec
                        AC_MSG_RESULT(yes)
                        cyrus_afs_sigvec="yes"
                ])
        ])
    if test "$cyrus_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_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=$save_LDFLAGS
fi

if test "x$with_afs" != "xno" -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_krbinclude, [
     for krbhloc in include/kerberosIV include
     do
       if test -f ${with_krb}/${krbhloc}/krb.h ; then
         cyrus_krbinclude=${with_krb}/${krbhloc}
         break
       fi
     done
     ])

   if test -n "${cyrus_krbinclude}"; then
     CPPFLAGS="$CPPFLAGS -I${cyrus_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 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=""
ZEPHYR_CPPFLAGS=""
case "$with_zephyr" in
	no) true;;
	""|yes) AC_CHECK_LIB(zephyr,ZInitialize,ZEPHYR_LIBS="-lzephyr",
		with_zephyr="no",);;
       *)  if test -d ${with_zephyr}/include/zephyr; then
               ZEPHYR_CPPFLAGS="-I${with_zephyr}/include/zephyr"
           else
               ZEPHYR_CPPFLAGS="-I${with_zephyr}/include"
           fi
           ZEPHYR_LIBS="-lzephyr";;
esac
AC_SUBST(ZEPHYR_LIBS)
AC_SUBST(ZEPHYR_CPPFLAGS)
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 Select a method for IMAP IDLE
dnl
AC_ARG_WITH(idle,[  --with-idle=METHOD      use METHOD for IMAP IDLE
                          METHOD is [poll], idled or no],
	WITH_IDLE="${withval}",WITH_IDLE="poll")
AC_SUBST(WITH_IDLE)
if test "$WITH_IDLE" = "idled"; 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 (experimental)],
	ENABLE_NNTP=$enableval
        if test "$ENABLE_NNTP" != no; then
	  IMAP_PROGS="$IMAP_PROGS nntpd fetchnews"
        fi) 

dnl
dnl see if we're compiling the Murder support programs
dnl
AC_ARG_ENABLE(murder,
        [  --enable-murder         enable IMAP Murder support],
        if test "$enableval" != no; then
	  IMAP_PROGS="$IMAP_PROGS proxyd lmtpproxyd mupdate"
        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
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

case "$with_com_err" in
  # built-in et
  yes) # use the com_err we're gonna build
	  COM_ERR_LIBS="../et/libcom_err.a"
	  COMPILE_ET="../et/compile_et"
	  COM_ERR_LDFLAGS=""
	  COM_ERR_CPPFLAGS="-I\${top_srcdir}/et"
	  PRE_SUBDIRS="et ${PRE_SUBDIRS}"
	  EXTRA_OUTPUT="${EXTRA_OUTPUT} 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
     COMPILE_ET="${with_com_err}/bin/compile_et"
     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)
     COMPILE_ET="${with_com_err}/bin/compile_et"
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(listext,
	[  --enable-listext        enable IMAP List extensions],
	if test "$enableval" = yes; then
		AC_DEFINE(ENABLE_LISTEXT,[],[Enable the LISTEXT extension?])
	fi)

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, but seems to cause problems on atleast Solaris --
dnl    eval `${PERL} -V:cccdlflags`
    PERL_CCCDLFLAGS="$cccdlflags"
    AC_SUBST(PERL_CCCDLFLAGS)
fi

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

	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 Check for MD5 functions
AC_FUNC_CHECK(MD5Init,,
       AC_CHECK_LIB(md, MD5Init, LIBS="${LIBS} -lmd",
                    MD5OBJ="md5.o"))
AC_SUBST(MD5OBJ)

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}"

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([
/* $Id: configure.in,v 1.296 2005/10/13 19:56:14 jeaton Exp $ */
/* 
 * Copyright (c) 1998-2003 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 other legal
 *    details, please contact  
 *      Office of Technology Transfer
 *      Carnegie Mellon University
 *      5000 Forbes Avenue
 *      Pittsburgh, PA  15213-3890
 *      (412) 268-4387, fax: (412) 268-7395
 *      tech-transfer@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.
 */

#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

/* 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)