File: configure.in

package info (click to toggle)
zmailer 2.99.51.52pre3-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 16,596 kB
  • ctags: 7,422
  • sloc: ansic: 90,470; sh: 3,608; makefile: 2,784; perl: 1,585; python: 115; awk: 22
file content (1787 lines) | stat: -rw-r--r-- 55,652 bytes parent folder | download
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
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
dnl Process this file with autoconf to produce a configure script.
#
# This autoconfigure input was modelled after GNU fileutils  configure.in,
# and modified by hand by <matti.aarnio@nic.funet.fi>  for the ZMailer
#

#PACKAGE=ZMailer
#VERSION=2.99.51patch1
#PACKAGE_VERSION="$PACKAGE-$VERSION"
#AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
#AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
#AC_DEFINE_UNQUOTED(PACKAGE_VERSION, "$PACKAGE_VERSION")
#AC_SUBST(PACKAGE)
#AC_SUBST(VERSION)
#AC_SUBST(PACKAGE_VERSION)

#
# This autoconfigure input was taken from  GNU fileutils  configure.in,
# and modified by hand by <matti.aarnio@nic.funet.fi>  for the ZMailer
#
# Parts are also from scotty-2.0.2 configuration
# Parts from other sources long forgotten, and many
# new things invented by myself...
#
# ZMailer is almoast as versatile systems feature tester as
# the best (or worst) other beats, like  SSH ...   About the
# only thing that ZMailer does not need are PTY allocation
# mechanisms ...
#

AC_INIT(router/router.c)
AC_CONFIG_HEADER(config.h)
AC_LANG_C

#----------------------------------------------------------------------------
#       Check if we should use gcc if available on this machine.
#----------------------------------------------------------------------------
use_gcc=0
AC_ARG_WITH(gcc, [  --with-gcc              use gcc for compilation],
	use_gcc=1)
if test "$use_gcc" = 0 ; then
    CC=${CC-cc}
else
    AC_PROG_CC
    if test "$CC" = "gcc" ; then
	CC="gcc -Wall"
    fi
fi
AC_PROG_CPP

AC_AIX
AC_MINIX
AC_ISC_POSIX

AC_SUBST(MKDIR)
MKDIR="mkdir -p"

# AC_PROG_GCC_TRADITIONAL
AC_PROG_MAKE_SET

# things get pretty tought, if the dup2() is not available ...
AC_CHECK_FUNC(dup2,
	AC_DEFINE(HAVE_DUP2),
	AC_MSG_ERROR([Bizzare -- the system does not have dup2()!  Is your C-compiler working ? (See config.log)])
)



defROUTEROPTIONS='-dkn 4'
defSMTPOPTIONS='-a -sve -l ${LOGDIR}/smtpserver'
defSCHEDULEROPTIONS='-l ${LOGDIR}/scheduler.perflog -S -H'
defNNTPSERVER='nntp'
ac_default_zmconfig="${ZCONFIG-/etc/zmailer.conf}"

if test "x$prefix" = "xNONE" ; then
  AC_MSG_RESULT([!!!])
  AC_MSG_RESULT([!!! You did not define  --prefix=DIR  -parameter !!!])
  AC_MSG_RESULT([!!!])
  AC_MSG_RESULT([!!! Define the  --prefix=DIR -parameter to tell the subtree,])
  AC_MSG_RESULT([!!! where the ZMailer system is to be installed.])
  AC_MSG_RESULT([!!!])
  exit 1
fi

AC_MSG_RESULT([***])
AC_MSG_RESULT([*** You can set  ZCONFIG  environment variable to define])
AC_MSG_RESULT([*** the location of the (default) /etc/zmailer.conf -file])
AC_MSG_RESULT([*** (You can use also   --with-zconfig=  -parameter)])
AC_MSG_RESULT([***])
AC_MSG_RESULT([*** Consider also setting following parameters:])
AC_MSG_RESULT([***   --mandir=DIR     -- for man-pages])
AC_MSG_RESULT([***   --libdir=DIR     -- for libzmailer(3)])
AC_MSG_RESULT([***   --includedir=DIR -- for libzmailer(3)])
AC_MSG_RESULT([*** (They can be outside the --prefix=DIR -tree)])
AC_MSG_RESULT([***])
AC_MSG_RESULT([*** You can also set CC, CFLAGS, and CPPFLAGS  environment variables])
AC_MSG_RESULT([*** to choose the C-compiler, and its options, especially at systems])
AC_MSG_RESULT([*** where there are multiple choices to use ...])
AC_MSG_RESULT([*** (Also doing CPPFLAGS="-I/local/include" may be something you need])
AC_MSG_RESULT([***  to find oddly located headers of some utility libraries.)])
AC_MSG_RESULT([***])

sleep 3  # delay a bit, then continue..

AC_SUBST(PROGS)dnl

AC_PATH_PROG(LN, ln, ln)dnl
AC_PATH_PROG(MV, mv, mv)dnl
AC_PATH_PROG(RM, rm, rm)dnl
AC_PATH_PROG(TRUE, true, true)dnl
AC_PATH_PROG(PERL, perl, perl)dnl
AC_SUBST(LIBPROGS)dnl

AC_SUBST(CPPDEP)
CPPDEP=${CPPDEP-"gcc -MM"}

AC_MSG_RESULT([** Using C compiler: $CC])
AC_MSG_RESULT([** Using CFLAGS:     $CFLAGS])
AC_MSG_RESULT([** Using CPPDEP:     $CPPDEP])

dnl AC_DEFINE_UNQUOTED(CONFIGURE_CMD,"$0 $ac_configure_args")
AC_DEFINE_UNQUOTED(CONFIGURE_CMD,
		   "CC='$CC' CFLAGS='$CFLAGS' $0 $ac_configure_args")


AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PATH_PROG(AR, ar, ar)dnl
AC_PATH_PROG(LD, ld, ld)dnl
AC_PATH_PROG(PROCMAIL, procmail, procmail)dnl
AC_PROG_YACC
AC_PROG_LN_S
AC_HEADER_MAJOR

AC_C_BIGENDIAN
AC_C_INLINE
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(double)

AC_SUBST(GENINCL)
AC_ARG_WITH(generic-include, [  --with-generic-include=\"-I/...\"
                            Include option for local overriders],
	use_genincl=1, use_genincl=0)
if test "$use_genincl" = 1; then
  GENINCL="$withval"
  CPPFLAGS="$CPPFLAGS $withval"
fi
AC_SUBST(GENLIB)
AC_ARG_WITH(generic-library, [  --with-generic-library=\"-L/...\"
                            Library directory option for local overriders],
	use_genlib=1, use_genlib=0)
if test "$use_genlib" = 1; then
  GENLIB="$withval"
  LIBS="$LIBS $GENLIB"
fi

AC_SUBST(ZMAILERCFGFILE)
use_zcfg=0
AC_ARG_WITH(zconfig, 
[  --with-zconfig=PATH     define the path and name of the zmailer.conf -file
                          Set ZCONFIG environment, and then use --with-zconfig=no
                          to disable usage of existing zmailer.conf -file to
                          load existing defaults. ],
	use_zcfg=1)
if test "$use_zcfg" = "0" ; then
	ZMAILERCFGFILE="${ZMAILERCFGFILE-$ac_default_zmconfig}"
	use_zcfg=1
else
    if test "$withval" != "no" ; then
	use_zcfg=1
	ZMAILERCFGFILE="$withval"
    else
	use_zcfg=0
	ZMAILERCFGFILE="${ZMAILERCFGFILE-$ac_default_zmconfig}"
    fi
fi
AC_MSG_RESULT([Using ZMailer parametrization file path: $ZMAILERCFGFILE])

if test -r $ZMAILERCFGFILE -a "$use_zcfg" != "0" ; then
  # Source the previous configuration values for various environment parameters
  . $ZMAILERCFGFILE
  AC_MSG_RESULT([   The file exists, we use its values as defaults])
fi

AC_SUBST(MAILBOX)
use_mailbox=0
AC_ARG_WITH(mailbox,      [  --with-mailbox=DIR      define the path of the mailbox directory],
	use_mailbox=1)
if test "$use_mailbox" = 0 ; then
    # No explicite value given, make some guesses as to where it might be..
    for DEFMAILBOX in /var/mail /var/spool/mail /usr/mail /usr/spool/mail
    do
	if test -d $DEFMAILBOX ; then
	    break
	fi
    done
    MAILBOX="${MAILBOX-$DEFMAILBOX}"
else
    MAILBOX="$withval"
fi
AC_MSG_RESULT([Using ZMailer MAILBOX directory path: $MAILBOX])

AC_SUBST(POSTOFFICE)
use_postoffice=0
AC_ARG_WITH(postoffice,   [  --with-postoffice=DIR   define the path of the postoffice directory],
	use_postoffice=1)
if test "$use_postoffice" = 0 ; then
    # No explicite value given, make some guesses as to where it might be..
    # XX: Should see what the MAILBOX value is, and then default between
    # XX: the /usr, and the /var -trees.
    for DEFPOSTOFFICE  in /usr/spool/postoffice /var/spool/postoffice
    do
	if test -d $DEFPOSTOFFICE ; then
	    break
	fi
    done
    POSTOFFICE="${POSTOFFICE-$DEFPOSTOFFICE}"
else
    POSTOFFICE="$withval"
fi
AC_MSG_RESULT([Using ZMailer POSTOFFICE path: $POSTOFFICE])


AC_SUBST(MAILSHARE)
use_mailshare=0
AC_ARG_WITH(mailshare,    [  --with-mailshare=DIR    define the path of the mailshare directory],
	use_mailshare=1)
if test "$use_mailshare" = 0 ; then
    eval MAILSHARE="${MAILSHARE-$prefix}"
else
    MAILSHARE="$withval"
fi
AC_MSG_RESULT([Using ZMailer MAILSHARE directory path: $MAILSHARE])

AC_SUBST(MAILVAR)
use_mailvar=0
AC_ARG_WITH(mailvar,      [  --with-mailvar=DIR      define the path of the mailvar directory],
	use_mailvar=1)
if test "$use_mailvar" = 0 ; then
    eval MAILVAR="${MAILVAR-$prefix}"
else
    MAILVAR="$withval"
fi
AC_MSG_RESULT([Using ZMailer MAILVAR directory path: $MAILVAR])

AC_SUBST(MAILBIN)
use_mailbin=0
AC_ARG_WITH(mailbin,      [  --with-mailbin=DIR      define the path of the mailbin directory],
	use_mailbin=1)
if test "$use_mailbin" = 0 ; then
    eval MAILBIN="${MAILBIN-${MAILSHARE}/bin}"
else
    MAILBIN="$withval"
fi
AC_MSG_RESULT([Using ZMailer MAILBIN directory path: $MAILBIN])

AC_SUBST(LOGDIR)
use_logdir=0
AC_ARG_WITH(logdir,       [  --with-logdir=DIR       define the path of the log directory],
	use_logdir=1)
if test "$use_logdir" = 0; then
    LOGDIR=${LOGDIR-/var/log/mail}
else
    LOGDIR="$withval"
fi
AC_MSG_RESULT([Using ZMailer LOGDIR directory path: $LOGDIR])

AC_SUBST(NNTPSERVER)
use_nntpserver=0
AC_ARG_WITH(nntpserver,   [  --with-nntpserver=HOST  define the domain name of the nntp server],
	use_nntpserver=1)
if test "$use_nntpserver" = 0; then
    NNTPSERVER="${NNTPSERVER-$defNNTPSERVER}"
else
    NNTPSERVER="$withval"
fi
AC_MSG_RESULT([Using ZMailer NNTPSERVER host name: $NNTPSERVER])

if test "x$INEWSBIN" = "x" ; then
  AC_PATH_PROG(INEWS, inews, inews)
else
  AC_SUBST(INEWS)
  INEWS="$INEWSBIN"
fi
AC_MSG_RESULT([Using ZMailer INEWS program path: $INEWS])

AC_SUBST(SCHEDULEROPTIONS)
SCHEDULEROPTIONS="${SCHEDULEROPTIONS-$defSCHEDULEROPTIONS}"
AC_MSG_RESULT([Using ZMailer SCHEDULEROPTIONS='$SCHEDULEROPTIONS'])
AC_SUBST(ROUTEROPTIONS)
ROUTEROPTIONS="${ROUTEROPTIONS-$defROUTEROPTIONS}"
AC_MSG_RESULT([Using ZMailer ROUTEROPTIONS='$ROUTEROPTIONS'])
AC_SUBST(SMTPOPTIONS)
SMTPOPTIONS="${SMTPOPTIONS-$defSMTPOPTIONS}"
AC_MSG_RESULT([Using ZMailer SMTPOPTIONS='$SMTPOPTIONS'])

AC_SUBST(SENDMAILPATH)
use_sendmailpath=0
AC_ARG_WITH(sendmailpath,   [  --with-sendmailpath=PATH The location of the 'sendmail'],
	use_sendmailpath=1)
if test "$use_sendmailpath" = 0 ; then
  # Ok, no value given, make some guesses; /usr/sbin ??
  for SENDMAILDEF in /usr/sbin/sendmail /usr/lib/sendmail ; do
    if test -x $SENDMAILDEF ; then
	break
    fi
  done
  SENDMAILPATH="${SENDMAILPATH-$SENDMAILDEF}"
else
    if test -d "$withval" ; then
        SENDMAILPATH="$withval/sendmail"
    else
        SENDMAILPATH="$withval"
    fi
fi
AC_MSG_RESULT([Using ZMailer SENDMAILPATH: $SENDMAILPATH])

oldRMAILPATH="$RMAILPATH"
AC_SUBST(RMAILPATH)
use_rmailpath=0
AC_ARG_WITH(rmailpath,   [  --with-rmailpath=PATH    The location of 'rmail'],
	use_rmailpath=1)
if test "$use_rmailpath" = 0 ; then
  # Ok, no value given, make some guesses; /usr/bin ?? (last is default)
  for RMAILDEF in /sbin/rmail /usr/sbin/rmail /usr/bin/rmail /bin/rmail; do
    if test -x $RMAILDEF ; then
	break
    fi
  done
  if test "x$oldRMAILPATH" = x ; then
    RMAILPATH="$RMAILDEF"
  else
    RMAILPATH="$oldRMAILPATH"
  fi
else
  RMAILPATH="$withval"
fi
AC_MSG_RESULT([Using ZMailer RMAILPATH: $RMAILPATH])

AC_SUBST(VACATIONPATH)
use_vacationpath=0
AC_ARG_WITH(vacationpath,   [  --with-vacationpath=PATH The location of the 'vacation'],
	use_vacationpath=1)
if test "$use_vacationpath" = 0 ; then
  # Ok, no value given, make some guesses; /usr/sbin ??
  for VACATIONDEF in /bin/vacation /usr/ucb/vacation /usr/bin/vacation ; do
    if test -x $VACATIONDEF ; then
	break
    fi
  done
  VACATIONPATH="${VACATIONPATH-$VACATIONDEF}"
else
    if test -d "$withval" ; then
        VACATIONPATH="$withval/vacation"
    else
        VACATIONPATH="$withval"
    fi
fi
AC_MSG_RESULT([Using ZMailer VACATIONPATH: $VACATIONPATH])


oldSELFADDRESSES="$SELFADDRESSES"
AC_SUBST(SELFADDRESSES)
AC_ARG_WITH(selfaddresses,   [  --with-selfaddresses=NAME,NAME  Comma separated list of names],
	use_selfaddresses=1)
if test "x$use_selfaddresses" != "x" ; then
    SELFADDRESSES="$withval"
else
    SELFADDRESSES="$oldSELFADDRESSES"
fi
AC_MSG_RESULT([Using ZMailer SELFADDRESSES: $SELFADDRESSES])

sleep 2  # Sleep a bit here too

AC_SUBST(LIBMALLOC)
AC_SUBST(MALLOC)
AC_SUBST(MALLOCEXT)
MALLOCEXT=""
AC_ARG_WITH(system-malloc,[  --with-system-malloc    use system malloc instead of our own],
	use_system_malloc=1)
AC_ARG_WITH(libmalloc,
[  --with-libmalloc=LIBNAME define the name of the malloc library
                           possible values: malloc, malloc_d, system (default)],
	use_libmalloc=1)
if test "x$use_system_malloc" = x1 ; then
  LIBMALLOC=""
  MALLOC="system"
else
  if test "x$withval" = xmalloc_d -o "x$withval" = xmalloc ; then
    LIBMALLOC="-l$withval"
    MALLOC="$withval"
    if test "$withval" = "malloc_d" ; then
      MALLOCEXT="_d"
    fi
  else
    if test "x$withval" = xsystem -o "x$use_libmalloc" != x1; then
      LIBMALLOC=""; MALLOCEXT=""
      MALLOC="system"
    else
      eval LIBMALLOC="-l${MALLOC-malloc}"
      if test "x$LIBMALLOC" = "x-lmalloc_d"; then
	MALLOC="malloc_d"; MALLOCEXT="_d"
      else
	if test "x$LIBMALLOC" = "x-lmalloc"; then
	  MALLOC="malloc"
	fi
      fi
    fi
  fi
fi
AC_MSG_RESULT([Using ZMailer malloc library of type: $MALLOC])

#
# Following is rather painfull to do fully automatic, thus I choose
# to do it in dumb way -- explicitely, INCLUDING LINKER STUFF !
#

AC_SUBST(HAVE_YP)
AC_ARG_WITH(yp, [  --with-yp                Have YP/NIS in system, and want to use it],
	AC_DEFINE(HAVE_YP))

AC_SUBST(LIBNIS)
LIBNIS=""
AC_ARG_WITH(yp-lib, [  --with-yp-lib='-L... -lyp'  Linker arguments for the YP/NIS in the router],
	LIBNIS="$withval")

#AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
#if test "$ac_cv_header_rpc_rpc.h" = yes			\
#	-a "$ac_cv_header_rpcsvc_yp_prot_h" = yes	\
#	-a "$ac_cv_header_rpcsvc_ypclnt_h" = yes ; then
#    # Ok, we have the headers, do we have the libs ?
#    # Asch....  Lets just presume that headers match with libs
#    # (and for Solaris the needed  -lnsl  comes with  connect() )
#    AC_DEFINE(HAVE_YP)
#fi

AC_HEADER_SYS_WAIT
AC_FUNC_WAIT3
AC_CHECK_FUNCS(waitpid wait4)
AC_CHECK_FUNCS(getenv putenv setenv unsetenv)

#
#  Study shared library generation
#
AC_SUBST(SHLIB_CFLAGS)
AC_SUBST(SHLIB_LD)
AC_SUBST(SHLIB_SUFFIX)
AC_SUBST(DL_LIBS)
AC_SUBST(LD_FLAGS)


AC_HEADER_DIRENT
AC_FUNC_CLOSEDIR_VOID

AC_TYPE_GETGROUPS
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_CHECK_TYPE(ino_t, unsigned long)

AC_C_CONST
AC_HEADER_STDC

# Timezones are always a pain in... everybody has their own ways :-(
AC_CHECK_HEADERS(sys/time.h)
AC_HEADER_TIME
AC_STRUCT_TIMEZONE
AC_STRUCT_TM
AC_STRUCT_TM_GMTOFF

AC_STRUCT_ST_BLOCKS
AC_STRUCT_ST_BLKSIZE

DEFDBTYPE="$DBTYPE" # From possible entry in  zmailer.conf above...
AC_SUBST(DBTYPE) # Default db-type, unless we figure out something.
AC_SUBST(DBEXT)  # Default db-extension (pag/db) for FILE OPEN
AC_SUBST(DBEXTtest) # Default db-extension (pag/db) for FILE AGE TESTS
AC_CHECK_HEADERS(gdbm.h ndbm.h sdbm.h db.h db_185.h)
LIBGDBM=""
# Sometimes it is in libc, sometimes at separate lib...
# Umm...
dblocation=""
if test "$ac_cv_header_gdbm_h" = yes ; then
  t_found_at="nowhere"
  if test "$ac_cv_lib_c_gdbm_open" = yes ; then
    LIBGDBM=""
    t_found_at="libc"
  else
    if test "$ac_cv_lib_gdbm_gdbm_open" = yes ; then
      LIBGDBM="-lgdbm"
      t_found_at="gdbm library"
      DBTYPE="gdbm"
    else
      AC_TRY_LINK([], [gdbm_open();], ac_cv_lib_c_gdbm_open=yes,
				      ac_cv_lib_c_gdbm_open=no)
      if test "$ac_cv_lib_c_gdbm_open" = no; then
	if test "x$ac_cv_lib_gdbm_gdbm_open" = x; then # not set
	  t_oldLibs="$LIBS"
	  LIBS="$LIBS -lgdbm"
	  AC_TRY_LINK([], [gdbm_open();], ac_cv_lib_gdbm_gdbm_open=yes,
					  ac_cv_lib_gdbm_gdbm_open=no)
	  LIBS="$t_oldLibs"
	  if test "$ac_cv_lib_gdbm_gdbm_open" = yes; then
	    LIBGDBM="-lgdbm"
	    t_found_at="gdbm library"
	    DBTYPE="gdbm"
	  else
	    AC_MSG_RESULT([??? Has <gdbm.h>, but gdbm_open() is not at libc, nor at libgdbm ???])
	    
	  fi
	else
	  if test "$ac_cv_lib_gdbm_gdbm_open" = yes ; then
	    AC_MSG_ERROR([config.cache inconsistency! (gdbm) Delete it, and redo!])
	  fi
	fi
      else # Has it in the libc!
	LIBGDBM=""
	t_found_at="libc"
	DBTYPE="gdbm"
      fi
    fi
  fi
  AC_MSG_RESULT([Located GNU GDBM's  gdbm_open()  routine at $t_found_at])
  if test "$t_found_at" != nowhere; then
    dblocation="$dblocation;$t_found_at"
  fi
fi

LIBNDBM=""
if test "$ac_cv_header_ndbm_h" = yes ; then
  t_found_at="nowhere"
  if test "$ac_cv_lib_c_dbm_open" = yes ; then
    LIBNDBM=""
    t_found_at="libc"
    DBTYPE="ndbm"
  else
    if test "$ac_cv_lib_dbm_dbm_open" = yes ; then
      LIBNDBM="-ldbm"
      t_found_at="dbm library"
      DBTYPE="ndbm"
    else
      if test "$ac_cv_lib_dbm_dbm_open" = no ; then
	if test "$ac_cv_lib_db_dbm_open" = yes ; then
	  LIBNDBM="-ldb"
	  t_found_at="db library"
	  DBTYPE="ndbm"
	fi
      else
	AC_TRY_LINK([], [dbm_open();],	ac_cv_lib_c_dbm_open=yes,
					ac_cv_lib_c_dbm_open=no)
	if test "$ac_cv_lib_c_dbm_open" = no; then
	  if test "x$ac_cv_lib_dbm_dbm_open" = x; then # not set
	    t_oldLibs="$LIBS"
	    LIBS="$LIBS -ldbm"
	    AC_TRY_LINK([], [dbm_open();], ac_cv_lib_dbm_dbm_open=yes,
					   ac_cv_lib_dbm_dbm_open=no)
	    LIBS="$t_oldLibs"
	    if test "$ac_cv_lib_dbm_dbm_open" = yes; then
	      LIBNDBM="-ldbm"
	      t_found_at="dbm library"
	      DBTYPE="ndbm"
	    else
	      LIBS="$t_oldLibs -ldb"
	      AC_TRY_LINK([],[dbm_open();], ac_cv_lib_db_dbm_open=yes,
					    ac_cv_lib_db_dbm_open=no)
	      LIBS="$t_oldLibs"
	      if test "$ac_cv_lib_db_dbm_open" = yes ; then
		  LIBNDBM="-ldb"
		  t_found_at="db library"
		  DBTYPE="ndbm"
	      else
		  AC_MSG_RESULT([??? Has <ndbm.h>, but dbm_open() is not at libc, libndbm, nor at libdb ???])
	      fi
	    fi
	  else
	    if test "$ac_cv_lib_dbm_dbm_open" = yes ; then
	      AC_MSG_ERROR([config.cache inconsistency! (ndbm) Delete it, and redo!])
	    fi
	  fi
	else # Has it in the libc!
	  LIBNDBM=""
	  t_found_at="libc"
	  DBTYPE="ndbm"
	fi
      fi
    fi
  fi
  if test "$t_found_at" != nowhere ; then
    # If we have BSD DB's compability mode in use, it does not have
    # dbm_error() function.  Check at it!
    LIBS="$LIBS $LIBNDBM"
    AC_TRY_LINK([#include <ndbm.h>], [DBM *db;int i = dbm_error(db);], AC_DEFINE(HAVE_DBM_ERROR))
    LIBS="$t_oldLibs"
  fi
  AC_MSG_RESULT([Located NDBM's  dbm_open()  routine at $t_found_at])
  if test "$t_found_at" != nowhere; then
    dblocation="$dblocation;$t_found_at"
  fi
fi


LIBSDBM=""
# Sometimes it is in libc, sometimes at separate lib...
# Umm...
if test "$ac_cv_header_sdbm_h" = yes ; then
  AC_MSG_RESULT([Note:  SDBM  support is not really integrated!])
  AC_MSG_RESULT([Note2: Usually the <sdbm.h> is installed as  <ndbm.h> and the library])
  AC_MSG_RESULT([       is installed as  libdbm.a, and it is indistinguishable])
  AC_MSG_RESULT([       (at source level) from a real NDBM.])
  t_found_at="nowhere"
  if test "$ac_cv_lib_c_dbm_open" = yes ; then
    LIBSDBM=""
    t_found_at="libc"
    DBTYPE="ndbm"
  else
    if test "$ac_cv_lib_sdbm_dbm_open" = yes ; then
      LIBSDBM="-lsdbm"
      t_found_at="sdbm library"
      DBTYPE="ndbm"
    else
      AC_TRY_LINK([], [dbm_open();], ac_cv_lib_c_dbm_open=yes,
				     ac_cv_lib_c_dbm_open=no)
      if test "$ac_cv_lib_c_dbm_open" = no; then
	if test "x$ac_cv_lib_sdbm_dbm_open" = x; then # not set
	  t_oldLibs="$LIBS"
	  LIBS="$LIBS -lsdbm"
	  AC_TRY_LINK([], [dbm_open();], ac_cv_lib_sdbm_dbm_open=yes,
					 ac_cv_lib_sdbm_dbm_open=no)
	  LIBS="$t_oldLibs"
	  if test "$ac_cv_lib_sdbm_dbm_open" = yes; then
	    LIBSDBM="-lsdbm"
	    t_found_at="sdbm library"
	    DBTYPE="ndbm"
	  else
	    AC_MSG_RESULT([??? Has <sdbm.h>, but dbm_open() is not at libc, nor at libsdbm ???])
	  fi
	else
	  if test "$ac_cv_lib_sdbm_dbm_open" = yes ; then
	    AC_MSG_ERROR([config.cache inconsistency! (sdbm) Delete it, and redo!])
	  fi
	fi
      else # Has it in the libc!
	LIBSDBM=""
	t_found_at="libc"
	DBTYPE="ndbm"
      fi
    fi
  fi
  AC_MSG_RESULT([Located SDBM's  dbm_open()  routine at $t_found_at])
  if test "$t_found_at" != nowhere; then
    dblocation="$dblocation;$t_found_at"
  fi
fi

LIBDB=""
# Sometimes it is in libc, sometimes at separate lib...
# Umm...
if test "$ac_cv_header_db_185_h" = yes ; then
  t_found_at="nowhere"
  if test "$ac_cv_lib_c_dbopen1" = yes ; then
    LIBDB=""
    t_found_at="libc(1)"
    DBTYPE="btree"
  else
    if test "$ac_cv_lib_db1_dbopen1" = yes ; then
      LIBDB="-ldb1"
      t_found_at="db1 library"
      DBTYPE="btree"
    else
      if test "x$ac_cv_lib_c_dbopen1" = x ; then # not set
	AC_TRY_LINK([], [dbopen();], ac_cv_lib_c_dbopen1=yes,
				     ac_cv_lib_c_dbopen1=no)
      fi
      if test "$ac_cv_lib_c_dbopen1" = no ; then
	if test "x$ac_cv_lib_db1_dbopen1" = x ; then # not set
	  t_oldLibs="$LIBS"
	  LIBS="$LIBS -ldb1"
	  AC_TRY_LINK([], [dbopen();],	ac_cv_lib_db1_dbopen1=yes,
					ac_cv_lib_db1_dbopen1=no)
	  LIBS="$t_oldLibs"
	  if test "$ac_cv_lib_db1_dbopen1" = yes ; then
	    LIBDB="-ldb1"
	    t_found_at="db1 library"
	    DBTYPE="btree"
	  else
	    AC_MSG_RESULT([??? Has <db_185.h>, but dbopen() is not at libc, nor at libdb ???])
	  fi
	else
	  if test "$ac_cv_lib_db1_dbopen1" = yes ; then
	    AC_MSG_ERROR([config.cache inconsistency! (db1) Delete it, and redo!])
	  fi
	fi
      else # Has it in the libc!
	LIBDB=""
	t_found_at="libc(2)"
	DBTYPE="btree"
      fi
    fi
  fi
  if test "$t_found_at" = nowhere ; then
    AC_MSG_RESULT([Didn't locate BSD DB 1.x  dbopen()  anywhere, although <db_185.h> file exists.])
  else
    AC_MSG_RESULT([Located BSD DB 1.x  dbopen()  routine at $t_found_at])
    if test "x$LIBDB" != "x" -a "x$LIBDB" = "x$LIBNDBM" ; then
	# Well, both at the same library ( -ldb ), which propably
	# means that  <ndbm.h>  is just an emulation mode at BSD DB.
	LIBNDBM=""
      AC_MSG_RESULT([Note: It looks like your NDBM is actually BSD DB compability wrapper at])
      AC_MSG_RESULT([      libdb -library. If so, your NDBM databases are actually BSD DB_HASH ones..])
    fi
    if test "$t_found_at" != nowhere; then
      dblocation="$dblocation;$t_found_at"
    fi
  fi
fi

dnl Possible backwards compability library is detected above, but we believe
dnl that following code can be *still* able to locate  dbopen()  from another
dnl library which contains call API (ABI?) compatible interface, however which
dnl does not necessarily contain binary compatible DATABASE which would use
dnl same binary layout as old BSD DB 1.85 version did...

if test "$ac_cv_header_db_h" = yes ; then
  t_found_at="nowhere"
  if test "$ac_cv_lib_c_dbopen" = yes ; then
    LIBDB=""
    t_found_at="libc(3)"
    DBTYPE="btree"
  else
    if test "$ac_cv_lib_db_dbopen" = yes ; then
      LIBDB="-ldb"
      t_found_at="db library"
      DBTYPE="btree"
    else
      if test "x$ac_cv_lib_c_dbopen" = x ; then # not set
	AC_TRY_LINK([], [dbopen();], ac_cv_lib_c_dbopen=yes,
				     ac_cv_lib_c_dbopen=no)
      fi
      if test "$ac_cv_lib_c_dbopen" = no ; then
	if test "x$ac_cv_lib_db_dbopen" = x ; then # not set
	  t_oldLibs="$LIBS"
	  LIBS="$LIBS -ldb"
	  AC_TRY_LINK([], [dbopen();],	ac_cv_lib_db_dbopen=yes,
					ac_cv_lib_db_dbopen=no)
	  LIBS="$t_oldLibs"
	  if test "$ac_cv_lib_db_dbopen" = yes ; then
	    LIBDB="-ldb"
	    t_found_at="db library"
	    DBTYPE="btree"
	  else
	    AC_MSG_RESULT([??? Has <db.h>, but dbopen() is not at libc, nor at libdb ???])
	  fi
	else
	  if test "$ac_cv_lib_db_dbopen" = yes ; then
	    AC_MSG_ERROR([config.cache inconsistency! (db) Delete it, and redo!])
	  fi
	fi
      else # Has it in the libc!
	LIBDB=""
	t_found_at="libc(4)"
	DBTYPE="btree"
      fi
    fi
  fi
  if test "$t_found_at" = nowhere ; then
    AC_MSG_RESULT([Didn't locate BSD DB  dbopen()  anywhere, although <db.h> file exists.])
  else
    AC_MSG_RESULT([Located BSD DB  dbopen()  routine at $t_found_at])
    if test "x$LIBDB" != "x" -a "x$LIBDB" = "x$LIBNDBM" ; then
	# Well, both at the same library ( -ldb ), which propably
	# means that  <ndbm.h>  is just an emulation mode at BSD DB.
	LIBNDBM=""
      AC_MSG_RESULT([Note: It looks like your NDBM is actually BSD DB compability wrapper at])
      AC_MSG_RESULT([      libdb -library. If so, your NDBM databases are actually BSD DB_HASH ones..])
    fi
    if test "$t_found_at" != nowhere; then
      dblocation="$dblocation;$t_found_at"
    fi
  fi
fi

dnl
dnl Ok, a third case; SleepyCat's BSD DB 2.*;  db_open() et.al.
dnl

if test "$ac_cv_header_db_h" = yes ; then
  t_found_at="nowhere"
  if test "$ac_cv_lib_c_db_open2" = yes ; then
    LIBDB=""
    t_found_at="libc(3)"
    DBTYPE="btree"
    AC_DEFINE(HAVE_DB_OPEN2)
  else
    if test "$ac_cv_lib_db_db_open2" = yes ; then
      LIBDB="-ldb"
      t_found_at="db library"
      DBTYPE="btree"
      AC_DEFINE(HAVE_DB_OPEN2)
    else
      if test "x$ac_cv_lib_c_db_open2" = x ; then # not set
	AC_TRY_LINK([], [db_open();], ac_cv_lib_c_db_open2=yes,
				      ac_cv_lib_c_db_open2=no)
      fi
      if test "$ac_cv_lib_c_db_open2" = no ; then
	if test "x$ac_cv_lib_db_db_open2" = x ; then # not set
	  t_oldLibs="$LIBS"
	  LIBS="$LIBS -ldb"
	  AC_TRY_LINK([], [db_open();],	ac_cv_lib_db_db_open2=yes,
					ac_cv_lib_db_db_open2=no)
	  LIBS="$t_oldLibs"
	  if test "$ac_cv_lib_db_db_open2" = yes ; then
	    LIBDB="-ldb"
	    t_found_at="db library"
	    DBTYPE="btree"
	    AC_DEFINE(HAVE_DB_OPEN2)
	  else
	    if test "$ac_cv_lib_db_dbopen"   != yes -a \
		    "$ac_cv_lib_c_dbopen"    != yes -a \
		    "$ac_cv_lib_db1_dbopen1" != yes -a \
		    "$ac_cv_lib_c_dbopen1"   != yes ; then
	      AC_MSG_RESULT([??? Has <db.h>, but db_open() is not at libc, nor at libdb ???])
	    fi
	  fi
	else
	  if test "$ac_cv_lib_db_db_open2" = yes ; then
	    AC_MSG_ERROR([config.cache inconsistency! (db2) Delete it, and redo!])
	  fi
	fi
      else # Has it in the libc!
	LIBDB=""
	t_found_at="libc(4)"
	DBTYPE="btree"
	AC_DEFINE(HAVE_DB_OPEN2)
      fi
    fi
  fi
  if test "$t_found_at" = nowhere ; then
    AC_MSG_RESULT([Didn't locate BSD DB 2.x  db_open()  anywhere, although <db.h> file exists.])
  else
    AC_MSG_RESULT([Located BSD DB 2.x  db_open()  routine at $t_found_at])
    if test "x$LIBDB" != "x" ; then
	# Does (db->cursor)(...) have 3 or 4 args ?
	if test "x$ac_cv_db_cursor_4" = x ; then # not set
	  AC_TRY_COMPILE([#include <db.h>],[DB *db; DBC *curs;
int err = (db->cursor)(db, NULL, &curs, 0);],
			 ac_cv_db_cursor_4=yes, ac_cv_db_cursor_4=no)
	fi
	if test "x$ac_cv_db_cursor_4" = "xyes"; then
	  AC_MSG_RESULT([  (db->cursor)() method function seems to want 4 args.])
	  AC_DEFINE(HAVE_DB_CURSOR4)
	fi
    fi
  if test "x$LIBDB" != "x" -a "x$LIBDB" = "x$LIBNDBM" ; then
	# Well, both at the same library ( -ldb ), which propably
	# means that  <ndbm.h>  is just an emulation mode at BSD DB.
	LIBNDBM=""
    AC_MSG_RESULT([Note: It looks like your NDBM is actually BSD DB compability wrapper at])
    AC_MSG_RESULT([      libdb -library. If so, your NDBM databases are actually BSD DB_HASH ones..])
    fi
    if test "$t_found_at" != nowhere; then
      dblocation="$dblocation;$t_found_at"
    fi
  fi
fi

AC_SUBST(INCLLDAP)
LIBLDAP=""
INCLLDAP=""
AC_ARG_WITH(ldap-prefix,[  --with-ldap-prefix=/usr  Prefix of UMich/NetScape LDAP includes, and library
                           the directories are  PREFIX/include/ and PREFIX/lib/],
	use_ldap=1)
if test "$use_ldap" = 1 ; then
    AC_DEFINE(HAVE_LDAP)
    LIBLDAP="-lldap -llber"
    if test "$withval" != "/usr" ; then
	LIBLDAP="-L$withval/lib $LIBLDAP"
	INCLLDAP="-I$withval/include"
    fi
fi
use_ldap=0
AC_ARG_WITH(ldap-include-dir,[  --with-ldap-include-dir=/.. Directory of UMich/NetScape LDAP includes],
	use_ldap=1)
if test "$use_ldap" = 1 ; then
    AC_DEFINE(HAVE_LDAP)
    LIBLDAP="-lldap -llber"
    if test "$withval" != "/usr/include" ; then
	INCLLDAP="-I$withval/include"
    fi
fi
use_ldap=0
AC_ARG_WITH(ldap-library-dir,[  --with-ldap-library-dir=/... Directory of UMich/NetScape LDAP libraries],
	use_ldap=1)
if test "$use_ldap" = 1 ; then
    AC_DEFINE(HAVE_LDAP)
    LIBLDAP="-lldap -llber"
    if test "$withval" != "/usr/lib" -a "$withval" != "/lib" ; then
	LIBLDAP="-L$withval/lib $LIBLDAP"
    fi
fi

# Lets build a nice single substitute variable
AC_SUBST(LIBDBMS)
AC_SUBST(LIBLOCALDBMS)
# GDBM must be last as if we have LIBDB at the system instead of real
# LIBNDBM, we still have ndbm routines, but want to use (likely)
# ones from LIBDB instead of LIBGDBM...
sep=""
if test "x$LIBNDBM" != "x" ; then
  LIBDBMS="$LIBDBMS$sep$LIBNDBM"
  LIBLOCALDBMS="$LIBLOCALDBMS$sep$LIBNDBM"
  sep=" "
fi
if test "x$LIBSDBM" != "x" ; then
  LIBDBMS="$LIBDBMS$sep$LIBSDBM"
  LIBLOCALDBMS="$LIBLOCALDBMS$sep$LIBSDBM"
  sep=" "
fi
if test "x$LIBDB" != "x" ; then
  LIBDBMS="$LIBDBMS$sep$LIBDB"
  LIBLOCALDBMS="$LIBLOCALDBMS$sep$LIBDB"
  sep=" "
fi
if test "x$LIBGDBM" != "x" ; then
  LIBDBMS="$LIBDBMS$sep$LIBGDBM"
  LIBLOCALDBMS="$LIBLOCALDBMS$sep$LIBGDBM"
  sep=" "
fi
if test "x$LIBLDAP" != "x" ; then
  LIBDBMS="$LIBDBMS$sep$LIBLDAP"
  sep=" "
fi

if test "$dblocation" = "" ; then
  AC_MSG_RESULT([>>> OOPS!  You don't have any kind of modern DBMs in your])
  AC_MSG_RESULT([>>>        system!  We will not use ancient single-db using])
  AC_MSG_RESULT([>>>        <dbm.h> even if you had it.  Now you have only])
  AC_MSG_RESULT([>>>        relation (external) db types: ordered, unordered])
fi

# ... this is pointless test ...
#if test "$DBTYPE" = "" -a "$DEFDBTYPE" != "" ; then
#  DBTYPE="$DEFDBTYPE" # Use old value as a default..
#fi

case "$DBTYPE" in
 dbm)   DBEXT=""
	DBEXTtest=".pag"
	;;
 ndbm)  DBEXT=""
	DBEXTtest=".pag"
	;;
 sdbm)  DBEXT=""
	DBEXTtest=".pag"
	;;
 gdbm)  DBEXT=".gdbm"
	DBEXTtest=".gdbm"
	;;
 btree) DBEXT=".db"
	DBEXTtest=".db"
	;;
 *)	DBEXT=".dat"
	DBEXTtest=".dat"
	;;
esac

AC_CHECK_HEADERS(string.h fcntl.h limits.h errno.h unistd.h stdlib.h \
    sys/param.h sys/statfs.h sys/fstyp.h mnttab.h mntent.h utime.h \
    sys/statvfs.h sys/vfs.h sys/mount.h sys/filsys.h sys/fs_types.h)
AC_CHECK_HEADERS(sys/utsname.h maillock.h arpa/inet.h)

AC_SUBST(AUTHLIB)
AC_CHECK_HEADERS(security/pam_appl.h shadow.h)
if test "$ac_cv_header_security_pam_appl_h" = "yes"; then
    AUTHLIB="-lpam -ldl"
else
    if test "$ac_cv_header_shadow_h" = "yes"; then
	AC_TRY_LINK([], [getspnam("foo");],
			AUTHLIB="",
			AUTHLIB="-lshadow")
    else
	AUTHLIB=""
    fi
fi

#
# Following set of tests is rather weird... Some people don't agree on
# where to place these IPv6 related headers :-(
# The API specs say: <netinet/in.h>,  but some people disagree...
#

AC_CHECK_HEADERS(netinet/in.h sys/socket.h)
if test "$ac_cv_header_netinet_in_h" = no ; then
    AC_MSG_RESULT([%%% AIEEE!  NO  <netinet/in.h>  HEADER ?!])
fi

AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>],[socklen_t sl = 2;],
	AC_DEFINE(HAVE_SOCKLEN_T))

AC_ARG_WITH(ipv6,[  --with-ipv6              Have IPv6 in system, and want to use it],
	AC_DEFINE(INET6)
	ac_with_ipv6=yes
	)

if test "$ac_with_ipv6" = yes; then
  if test "x$ac_cv_af_inet6" = "x"; then
    AC_TRY_LINK([#include <sys/types.h>
#include <sys/socket.h>],
		[int af = AF_INET6;],
		ac_cv_af_inet6=yes, ac_cv_af_inet6=no)
    if test "$ac_cv_af_inet6" = yes; then
	AC_TRY_LINK([#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>],
		    [/* Has AF_INET6, but does one have all related things ? */
		     struct in6_addr sin6;],
		    ac_cv_struct_in6_addr=yes, ac_cv_struct_in6_addr=no)
	AC_MSG_RESULT([We have <sys/socket.h> defining  AF_INET6, but do we have properly ..])
	AC_MSG_RESULT([.. structured <netinet/in.h> headers with 'struct in6_addr' ? $ac_cv_struct_in6_addr])
	if test "$ac_cv_struct_in6_addr" != yes; then

	    AC_CHECK_HEADERS(netinet/in6.h)
	    if test "$ac_cv_header_netinet_in6_h" != "yes" ; then
		AC_CHECK_HEADERS(netinet6/in6.h)
		if test "$ac_cv_header_netinet6_in6_h" != "yes" ; then

		    AC_CHECK_HEADERS(linux/in6.h)
		    if test "$ac_cv_header_linux_in6_h" != "yes" ; then
			AC_MSG_RESULT([***  You have a SOME system with  <sys/socket.h>  defining AF_INET6, however])
			AC_MSG_RESULT([***  the system does not have all required includes ])
			AC_MSG_RESULT([***  for the compilation to succeed. ])
			AC_MSG_RESULT([***  I know of some releases of Linux 2.0.* systems doing this.])
			AC_MSG_RESULT([***  If you have one, edit the  <linux/socket.h>,  and])
			AC_MSG_RESULT([***  remove the define of   AF_INET6 ])
			AC_MSG_ERROR([AF_INET6 feature error])
		    fi
		fi
	    fi
	fi
    fi
  else
    if test "$ac_cv_af_inet6" = yes; then
	# We were successfull at creating these cached variables above,
	# thus we can (with confidence) do following, and only one is
	# defined as an end result..
	if test "$ac_cv_header_netinet_in6_h" = yes; then
	    AC_DEFINE(HAVE_NETINET_IN6_H)
	fi
	if test "$ac_cv_header_netinet6_in6_h" = yes; then
	    AC_DEFINE(HAVE_NETINET6_IN6_H)
	fi
	if test "$ac_cv_header_linux_in6_h" = yes; then
	    AC_DEFINE(HAVE_LINUX_IN6_H)
	fi
    fi
  fi
fi # End of:  --with-ipv6


AC_CHECK_HEADERS(varargs.h stdarg.h)
AC_CHECK_FUNCS(flock lockf lstat)

without_fsync=0
AC_ARG_WITH(fsync,[  --without-fsync          Do not use fsync() even if you have it],
	without_fsync=1)
if test $without_fsync = 0; then
	AC_CHECK_FUNCS(fsync)
fi

AC_FUNC_SVR4_MAILLOCK

AC_CHECK_FUNCS(mkdir mktime mkstemp rename rmdir strcpy strdup strstr \
		strchr strrchr setvbuf strerror strsignal setreuid \
		setregid sigprocmask sigpending sigsuspend)
# If the system does not have the following (library) calls,
# we use emulations (replacements):
AC_REPLACE_FUNCS(mkdir mktime rename rmdir strcpy strdup strstr \
		 strchr strrchr setvbuf strerror strsignal strtoul)

AC_DECL_SYS_SIGLIST

AC_CACHE_CHECK([existence of char **sys_siglist], ac_cv_arr_sys_siglist, [
AC_TRY_LINK([extern char *sys_siglist[]; static char *s;], [s = sys_siglist[2]; ],
		[AC_DEFINE(HAVE_SYS_SIGLIST)
		 ac_cv_arr_sys_siglist=yes])
])


# Additional tests for the emulations..
AC_CHECK_FUNCS(index rindex)
# more tests..
AC_CHECK_FUNCS(endgrent fchdir ftime getcwd getgroups setgroups \
		getmntinfo gettimeofday isascii memcpy memchr mkfifo   \
		getpgrp setsid seteuid setuid)
AC_CHECK_FUNCS(setrlimit fchown utimes utime sysconf fpathconf)
# Networking stuff is in deep trouble, if sockets are not found..
AC_CHECK_HEADERS(netdb.h syslog.h sys/resource.h \
		protocols/rwhod.h select.h sys/select.h)
AC_CHECK_FUNCS(select syslog getdtablesize setpriority)

#
# Test to see, if we have BSD4.4  sa_len -field in the "struct sockaddr*"
#
AC_STRUCT_SA_LEN

AC_CHECK_FUNC(res_init)  # Can be found without any libs ?  Or needs BIND libresolv ?
AC_CHECK_FUNC(res_mkquery)

AC_SUBST(LIBRESOLV)
AC_SUBST(INCLRESOLV)
AC_SUBST(LIBRESOLVA)
use_resolvopt=0
AC_ARG_WITH(bundled-libresolv,   [  --with-bundled-libresolv Use bundled libresolv source],
	use_resolvopt=1)
if test "$use_resolvopt" = 0 ; then
    if test $ac_cv_func_res_mkquery = yes ; then
	LIBRESOLV="" #  res_mkquery() is at system libc
	AC_MSG_RESULT([Using no -lresolv; res_mkquery() in libc ?])
    else
	LIBRESOLV="-lresolv"
	AC_MSG_RESULT([Using system supplied -lresolv -- hope it works..])
    fi
    AC_DEFINE(HAVE_GETHOSTBYNAME)
    AC_DEFINE(HAVE_RESOLVER)
    INCLRESOLV=""
    LIBRESOLVA=""
else
    # We have bundled BIND 4.9.4 resolver, which can make things
    # so much simpler to ourselves (except at BSD machines..)
    AC_DEFINE(HAVE_GETHOSTBYNAME)
    AC_DEFINE(HAVE_RESOLVER)
    LIBRESOLV="-lresolv"
    INCLRESOLV='-I$(TOPDIR)/libresolv'
    LIBRESOLVA="libresolv.a"
    AC_MSG_RESULT([Using bundled (bind 4.9.4-REL) libresolv])
fi

#
#  We check for various libraries
#  - SysVr4 style of "-lsocket" at first (unless in libc)
#    The hallmark is  connect()  routine (we presume)
#
AC_SUBST(LIBSOCKET)dnl
ac_cv_libsocket_both=1
AC_CHECK_FUNC(connect, ac_cv_libsocket_both=0)
AC_CHECK_FUNC(gethostbyname, ac_cv_libsocket_both=0)
if test "$ac_cv_libsocket_both" = 1 ; then
  # Check cache
  if test "$ac_cv_func_socket_lxnet" = yes ; then
    AC_MSG_RESULT([need -lxnet library (cached)])
    LIBSOCKET="-lxnet"
  else
  if test "$ac_cv_func_socket_lsocket" = yes ; then
    AC_MSG_RESULT([need -lsocket library (cached)])
    LIBSOCKET="-lsocket"
    if test "$ac_cv_func_gethostbyname_lnsl" = yes ; then
	LIBSOCKET="-lsocket -lnsl"
    fi
  else
    # Well, will this work ?  SysVR4, but not Sun Solaris ?
    AC_CHECK_LIB(xnet, connect, [LIBSOCKET="-lxnet"
				 ac_cv_func_socket_lsocket=no
				 ac_cv_func_socket_lxnet=yes],[
      AC_CHECK_LIB(socket, connect, [LIBSOCKET="-lsocket"
				     ac_cv_func_socket_lsocket=yes],
				     ac_cv_func_socket_lsocket=no)
      if test "$ac_cv_func_socket_lsocket" = yes ; then
        t_oldLibs="$LIBS"
        LIBS="$LIBS -lsocket $LIBRESOLV"
        AC_TRY_LINK([],[gethostbyname();], ,[
	  LIBS="$LIBS -lnsl" # Add this Solaris library..
	  AC_TRY_LINK([],[gethostbyname();],[
			LIBSOCKET="-lsocket -lnsl"
			ac_cv_func_gethostbyname_lnsl=yes
		], [
		   AC_MSG_ERROR([Weird, '$LIBS' not enough to find  gethostnyname() ?!])
		])
	  ])
        LIBS="$t_oldLibs"
      fi
    ])
  fi
  fi
fi

if test "x$LIBRESOLV" = "x"; then
  # Ok, No  -lresolv,  is this enough for the  _res  to appear ?
  t_oldLibs="$LIBS"
  LIBS="$LIBS $LIBSOCKET"
  ac_cv_var__res_options=no
  # This following is for IRIX6.4, and I sincerely hope it
  # will not fail on other systems...  It did! It did!
  # Many systems don't have idemponent headers, they need specific
  # includes before latter ones, or the latter ones won't be successful...
  AC_TRY_LINK([#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>],
	      [_res.options = RES_INIT;],
		ac_cv_var__res_options=yes);
  if test "$ac_cv_var__res_options" != "yes"; then
    AC_MSG_RESULT([Can't do without  -lresolv  to link resolver's  _res.options])
    LIBRESOLV="-lresolv"
  fi
  LIBS="$t_oldLibs"
fi

# See about the routines that possibly exist at the libraries..
LIBS="$t_oldLibs $LIBSOCKET"
AC_CHECK_FUNCS(socket socketpair)
LIBS="$t_oldLibs"

if test "$ac_cv_func_socket" = no -a "$LIBSOCKET" != ""; then
  LIBS="$LIBS $LIBSOCKET"
  AC_TRY_LINK([],[socket();], ac_cv_func_socket=yes)
  if test $ac_cv_func_socket = yes; then
    AC_DEFINE(HAVE_SOCKET)
    AC_MSG_RESULT([Has  socket()  when using  $LIBSOCKET])
  fi
  LIBS="$t_oldLibs"
fi
if test "$ac_cv_func_socketpair" = no -a "$LIBSOCKET" != ""; then
  LIBS="$LIBS $LIBSOCKET"
  AC_TRY_LINK([],[socketpair();], ac_cv_func_socketpair=yes)
  if test $ac_cv_func_socketpair = yes; then
    AC_DEFINE(HAVE_SOCKETPAIR)
    AC_MSG_RESULT([Has  socketpair()  when using  $LIBSOCKET])
  fi
  LIBS="$t_oldLibs"
fi

AC_REPLACE_FUNCS(gai_strerror)

ac_with_ipv6_replacement_libc=0
AC_ARG_WITH(ipv6-replacement-libc, [  --with-ipv6-replacement-libc If system has broken  getaddrinfo() and friends],
	ac_with_ipv6_replacement_libc=1)

if test "$ac_with_ipv6_replacement_libc" = 1 ; then
  LIBOBJS="$LIBOBJS inet_ntop.o inet_pton.o getaddrinfo.o getnameinfo.o"
  AC_SUBST(LIBOBJS)
else

  #  Following stuff may exist in our LIBC, or in separate -linet6
  AC_CHECK_FUNCS(inet_ntop inet_pton getaddrinfo getnameinfo)
  #  If not found in LIBC, try to use  -linet6,  if it fails too,
  #  THEN call the AC_REPLACE_FUNCS()
  if test "$ac_cv_func_gai_strerror" = no ; then
    LIBS="$LIBS $LIBSOCKET -linet6"
    AC_TRY_LINK([],[gai_strerror();], ac_cv_func_gai_strerror=yes)
    LIBS="$t_oldLibs"
    if test "$ac_cv_func_gai_strerror" = yes; then
      LIBSOCKET="$LIBSOCKET -linet6"
      AC_MSG_RESULT([Has IPv6 API  gai_strerror()  when using  $LIBSOCKET])
    else
      LIBOBJS="$LIBOBJS inet_ntop.o inet_pton.o getaddrinfo.o getnameinfo.o"
      AC_SUBST(LIBOBJS)
    fi
  fi
fi

AC_ARG_WITH(rfc822-tabs,   [  --without-rfc822-tabs    Turn off the TABs from the rewritten headers ],
	[if test "$withval" = no; then
	   use_rfc822_tabs=0
	 else
	   use_rfc822_tabs=1
	 fi], [use_rfc822_tabs=1])
AC_DEFINE_UNQUOTED(RFC822TABS,$use_rfc822_tabs)
AC_MSG_RESULT([RFC-822 TABs setting: $use_rfc822_tabs])

AC_SUBST(LIBWRAP)
AC_SUBST(INCLWRAP)
use_tcpwrappers=0
AC_ARG_WITH(tcp-wrappers,   [  --with-tcp-wrappers=DIRPATH Where the TCP-WRAPPERS can be found],
	use_tcpwrappers=1)

t_oldLibs="$LIBS"
t_oldCpp="$CPPFLAGS"

if test "$use_tcpwrappers" = 0 ; then
#    if test "$ac_cv_lib_tcpwrap" = yes; then
#	LIBWRAP="-lwrap"
#	INCLWRAP=""
#	AC_MSG_RESULT([Tcp-wrapper available at system default: -lwrap !]);
#    else
#-------------
#	AC_TRY_LINK([#include <tcpd.h>
#		     int deny_severity, allow_severity;],[hosts_access();],
#			 ac_cv_lib_tcpwrap=yes,ac_cv_lib_tcpwrap=no)
#	LIBWRAP=""
#	INCLWRAP=""
#	if test "$ac_cv_lib_tcpwrap" = yes; then
#	    AC_MSG_RESULT([Tcp-wrapper available at $wraploc: -lwrap !]);
#	else
#	    AC_MSG_RESULT([No tcp-wrapper available system at default location ?])
#	fi
#	: # "nop"	
#-------------
	AC_CHECK_HEADERS(tcpd.h)
	if test "$ac_cv_header_tcpd_h" = yes; then
	    LIBWRAP="-lwrap"
	    INCLWRAP=""
	    wraploc="sysdefault"
	else
	    AC_CHECK_HEADERS(/local/include/tcpd.h /usr/local/include/tcpd.h \
			     /opt/include/tcpd.h /opt/local/include/tcpd.h)
	    if test -n "$ac_cv_header__local_include_tcpd_h"; then
		LIBWRAP="-L/local/lib -lwrap"
		INCLWRAP="-I/local/include"
		wraploc="-L/local/lib -I/local/include"
	    elif test -n "$ac_cv_header__usr_local_include_tcpd_h"; then
		LIBWRAP="-L/usr/local/lib -lwrap"
		INCLWRAP="-I/usr/local/include"
		wraploc="-L/usr/local/lib -I/usr/local/include"
	    elif test -n "$ac_cv_header__opt_include_tcpd_h"; then
		LIBWRAP="-L/opt/lib -lwrap"
		INCLWRAP="-I/opt/include"
		wraploc="-L/opt/lib -I/opt/include"
	    elif test -n "$ac_cv_header__opt_local_include_tcpd_h"; then
		LIBWRAP="-L/opt/local/lib -lwrap"
		INCLWRAP="-I/opt/local/include"
		wraploc="-L/opt/local/lib -I/opt/local/include"
	    else
		LIBWRAP=""
		INCLWRAP=""
		wraploc="nowhere?"
	    fi
	fi
	LIBS="$LIBS $LIBSOCKET $LIBWRAP"
	CPPFLAGS="$CPPFLAGS $INCLWRAP"
	AC_CACHE_VAL(ac_cv_lib_tcpwrap,
	  [AC_TRY_LINK([#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <tcpd.h>
struct request_info request;
int deny_severity, allow_severity;],[hosts_access(&request);],
			ac_cv_lib_tcpwrap=yes,ac_cv_lib_tcpwrap=no)
	  ])
	if test "$ac_cv_lib_tcpwrap" = yes; then
	    AC_MSG_RESULT([Tcp-wrapper available at $wraploc: -lwrap !]);
	else
	    AC_MSG_RESULT([No tcp-wrapper available at system default locations ?])
	    LIBWRAP=""
	    INCLWRAP=""
	fi
#    fi
else
    LIBWRAP="-L$withval -lwrap"
    INCLWRAP="-I$withval"
    unset ac_cv_lib_tcpwrap
    AC_DEFINE(HAVE_TCPD_H)
    AC_MSG_RESULT([Using tcp-wrappers at directory: $withval]);
fi


CPPFLAGS="$t_oldCpp"
LIBS="$t_oldLibs"


AC_SUBST(PRIVATEMBOX)
PRIVATEMBOX=""
AC_ARG_WITH(privatembox,   [  --with-privatembox       Use 'private/' in a part of mailbox compilations],
	PRIVATEMBOX="private/")

AC_ARG_WITH(mboxquotacheck,[  --with-mboxquotacheck    Use 'CHECK_MB_SIZE' define in mailbox program.
                           Linking is presumed to use  --with-generic-lib=DIR],
	AC_DEFINE(CHECK_MB_SIZE))

AC_SUBST(PRIVATEAUTH)
PRIVATEAUTH=""
AC_ARG_WITH(privateauth,   [  --with-privateauth       Use 'private/' in a part of smtpserver compilations],
	PRIVATEAUTH="private/")

AC_SUBST(LIBWHOSON)
AC_SUBST(INCLWHOSON)
use_whoson=0
AC_ARG_WITH(whoson,   [  --with-whoson=DIRPATH    Where the WHOSON libs can be found],
	use_whoson=1)

t_oldLibs="$LIBS"
t_oldCpp="$CPPFLAGS"

if test "$use_whoson" = 0 ; then
#    if test "$ac_cv_lib_whoson" = yes; then
#	LIBWHOSON="-lwhoson"
#	INCLWHOSON=""
#	AC_MSG_RESULT([Whoson libs available at system default: -lwhoson !]);
#    else
#-------------
#	AC_TRY_LINK([#include <whoson.h>],[wso_version();],
#			 ac_cv_lib_whoson=yes,ac_cv_lib_whoson=no)
#	LIBWHOSON=""
#	INCLWHOSON=""
#	if test "$ac_cv_lib_whoson" = yes; then
#	    AC_MSG_RESULT([Whoson libs available at $whosonloc: -lwhoson !]);
#	else
#	    AC_MSG_RESULT([No whoson libs available system at default location ?])
#	fi
#	: # "nop"	
#-------------
	AC_CHECK_HEADERS(whoson.h)
	if test "$ac_cv_header_whoson_h" = yes; then
	    LIBWHOSON="-lwhoson"
	    INCLWHOSON=""
	    whosonloc="sysdefault"

	    LIBS="$LIBS $LIBSOCKET $LIBWHOSON"
	    CPPFLAGS="$CPPFLAGS $INCLWHOSON"
	    AC_TRY_LINK([#include <whoson.h>
			int deny_severity, allow_severity;],[wso_version();],
			ac_cv_lib_whoson=yes,ac_cv_lib_whoson=no)
dnl AC_MSG_RESULT([ ... link -lwhoson yields: $ac_cv_lib_whoson])
	    if test "$ac_cv_lib_whoson" = no; then
		LIBS="$t_oldLibs"
		LIBS="$LIBS $LIBSOCKET -L/usr/local/lib $LIBWHOSON"
		AC_TRY_LINK([#include <whoson.h>],[wso_version();],
			ac_cv_lib_whoson=yes,ac_cv_lib_whoson=no)
dnl AC_MSG_RESULT([ ... link -L/usr/local/lib -lwhoson yields: $ac_cv_lib_whoson])
		if test  "$ac_cv_lib_whoson" = yes; then
		    whosonloc="-L/usr/local/lib"
		    LIBWHOSON="-L/usr/local/lib $LIBWHOSON"
		fi
	    fi
	    if test "$ac_cv_lib_whoson" = no; then
		LIBS="$t_oldLibs"
		LIBS="$LIBS $LIBSOCKET -L/local/lib $LIBWHOSON"
		AC_TRY_LINK([#include <whoson.h>],[wso_version();],
			ac_cv_lib_whoson=yes,ac_cv_lib_whoson=no)
dnl AC_MSG_RESULT([ ... link -L/local/lib -lwhoson yields: $ac_cv_lib_whoson])
		if test  "$ac_cv_lib_whoson" = yes; then
		    whosonloc="-L/local/lib"
		    LIBWHOSON="-L/local/lib $LIBWHOSON"
		fi
	    fi
	    if test "$ac_cv_lib_whoson" = no; then
		LIBS="$t_oldLibs"
		LIBS="$LIBS $LIBSOCKET -L/opt/lib $LIBWHOSON"
		AC_TRY_LINK([#include <whoson.h>],[wso_version();],
			ac_cv_lib_whoson=yes,ac_cv_lib_whoson=no)
dnl AC_MSG_RESULT([ ... link -L/opt/lib -lwhoson yields: $ac_cv_lib_whoson])
		if test  "$ac_cv_lib_whoson" = yes; then
		    whosonloc="-L/opt/lib"
		    LIBWHOSON="-L/opt/lib $LIBWHOSON"
		fi
	    fi
	    if test "$ac_cv_lib_whoson" = no; then
		LIBS="$t_oldLibs"
		LIBS="$LIBS $LIBSOCKET -L/opt/local/lib $LIBWHOSON"
		AC_TRY_LINK([#include <whoson.h>],[wso_version();],
			ac_cv_lib_whoson=yes,ac_cv_lib_whoson=no)
		if test  "$ac_cv_lib_whoson" = yes; then
		    whosonloc="-L/opt/local/lib"
		    LIBWHOSON="-L/opt/local/lib $LIBWHOSON"
		fi
	    fi
	    if test "$ac_cv_lib_whoson" = no; then
		unset ac_cv_lib_whoson
	    fi

	    CPPFLAGS="$t_oldCpp"
	    LIBS="$t_oldLibs"

	else
	    AC_CHECK_HEADERS(/local/include/whoson.h /usr/local/include/whoson.h \
			     /opt/include/whoson.h /opt/local/include/whoson.h)
	    if test -n "$ac_cv_header__local_include_whoson_h"; then
		LIBWHOSON="-L/local/lib -lwhoson"
		INCLWHOSON="-I/local/include"
		whosonloc="-L/local/lib -I/local/include"
	    elif test -n "$ac_cv_header__usr_local_include_whoson_h"; then
		LIBWHOSON="-L/usr/local/lib -lwhoson"
		INCLWHOSON="-I/usr/local/include"
		whosonloc="-L/usr/local/lib -I/usr/local/include"
	    elif test -n "$ac_cv_header__opt_include_whoson_h"; then
		LIBWHOSON="-L/opt/lib -lwhoson"
		INCLWHOSON="-I/opt/include"
		whosonloc="-L/opt/lib -I/opt/include"
	    elif test -n "$ac_cv_header__opt_local_include_whoson_h"; then
		LIBWHOSON="-L/opt/local/lib -lwhoson"
		INCLWHOSON="-I/opt/local/include"
		whosonloc="-L/opt/local/lib -I/opt/local/include"
	    else
		LIBWHOSON=""
		INCLWHOSON=""
		whosonloc="nowhere?"
	    fi
	fi
	LIBS="$LIBS $LIBSOCKET $LIBWHOSON"
	CPPFLAGS="$CPPFLAGS $INCLWHOSON"
	AC_CACHE_VAL(ac_cv_lib_whoson,
	  [AC_TRY_LINK([#include <whoson.h>],[wso_version();],
			ac_cv_lib_whoson=yes,ac_cv_lib_whoson=no)
	  ])
	if test "$ac_cv_lib_whoson" = yes; then
	    AC_MSG_RESULT([Whoson libs  available at $whosonloc: -lwhoson !]);
	    AC_DEFINE(HAVE_WHOSON_H)
	else
	    AC_MSG_RESULT([No whoson libs available at system default locations ?])
	    LIBWHOSON=""
	    INCLWHOSON=""
	fi
#    fi
else
    if test -f "$withval"/lib/libwhoson.a ; then
	LIBWHOSON="-L$withval/lib -lwhoson"
	AC_MSG_RESULT([Using whoson libs at directory: $withval/lib]);
    else
	LIBWHOSON="-L$withval -lwhoson"
	AC_MSG_RESULT([Using whoson libs at directory: $withval]);
    fi
    if test -f "$withval"/include/whoson.h ; then
	INCLWHOSON="-I$withval/include"
	AC_MSG_RESULT([Using whoson includes at directory: $withval]);
    else
	INCLWHOSON="-I$withval"
	AC_MSG_RESULT([Using whoson includes at directory: $withval]);
    fi
    unset ac_cv_lib_whoson
    AC_DEFINE(HAVE_WHOSON_H)
fi

CPPFLAGS="$t_oldCpp"
LIBS="$t_oldLibs"


dnl #
dnl #  At some systems the load-average can be gotten with these routines..
dnl #
dnl AC_SUBST(LIBLOADAVER)dnl
dnl AC_CHECK_HEADERS(kvm.h)
dnl #if test "$ac_cv_header_kvm_h" = yes; then
dnl #  AC_DEFINE(SVR4_kvm)
dnl #  LIBLOADAVER="-lkvm"
dnl #  AC_MSG_RESULT([Presuming the need of -lkvm for load-average library])
dnl #fi
dnl 
dnl AC_CHECK_HEADERS(elf.h, [
dnl elf_LIBS="$LIBS"
dnl have_nlist=0
dnl AC_TRY_LINK([
dnl #ifdef HAVE_NLIST_H
dnl #include <nlist.h>
dnl #endif
dnl ],
dnl 	    [nlist((char*)0,(char*)0);],
dnl 	    have_nlist=1);
dnl if test "$have_nlist" = 1 ; then
dnl 	AC_DEFINE(SVR4_elf)
dnl 	AC_MSG_RESULT([Have  nlist()  without  -lelf])
dnl else
dnl     LIBS="$LIBS -lelf"
dnl     AC_TRY_LINK([
dnl #ifdef HAVE_NLIST_H
dnl #include <nlist.h>
dnl #endif
dnl ],
dnl 		[nlist((char*)0,(char*)0);],
dnl 		have_nlist=1);
dnl     if test "$have_nlist" = 1 ; then
dnl 	AC_DEFINE(SVR4_elf)
dnl 	LIBLOADAVER="$LIBLOADAVER -lelf"
dnl 	AC_MSG_RESULT([Seems to need  -lelf  to link nlist()])
dnl     else
dnl 	AC_MSG_RESULT([Don't know how to extract system load-average -- but don't really need it])
dnl     fi
dnl fi
dnl LIBS="$elf_LIBS"
dnl ])
dnl 

AC_FUNC_STRFTIME
AC_FUNC_SPRINTF
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(vsprintf vsnprintf snprintf)
AC_FUNC_ALLOCA
AC_FUNC_GETPGRP
AC_FUNC_MMAP
dnl AC_FUNC_UTIME_NULL

AC_ARG_WITH(ta-mmap,   [  --with-ta-mmap           TA's to use MMAP for reading the message bodies],
	use_ta_mmap=1, use_ta_mmap=0)
if test "$use_ta_mmap" = "1"; then
  AC_DEFINE(TA_USE_MMAP)
fi

AC_SUBST(GETPWLIB)
AC_ARG_WITH(getpwnam-library, [  --with-getpwnam-library=\"-L.. -l..\"
                            Linking options for non-std getpwnam() libraries],
	use_getpwnam_lib=1, use_getpwnam_lib=0)
if test "$use_getpwnam_lib" = 1; then
  GETPWLIB="$withval"
fi

AC_SUBST(OPENSSLPREFIX)
AC_SUBST(OPENSSLINCL)
AC_SUBST(OPENSSLLIB)

AC_ARG_WITH(openssl-prefix, [  --with-openssl-prefix=/dir/path (defines both include and lib)],
	OPENSSLPREFIX="$withval")
AC_ARG_WITH(openssl-include, [  --with-openssl-include=/dir/incl/path],
	OPENSSLINCL="-I$withval")
AC_ARG_WITH(openssl-lib, [  --with-openssl-lib=/dir/lib/path],
	[if test -f "$withval/libssl.so" ; then
	  OPENSSLLIB="$withval/libssl.so $withval/libcrypto.so"
	else
	  OPENSSLLIB="$withval/libssl.a $withval/libcrypto.a"
	fi
#	if test "$withval" != "/usr" -a "$withval" != "/usr/lib"; then
#	  # Operating system dependent runtime path definition :-/
#	  OPENSSLLIB="-R$withval $OPENSSLLIB"
#	fi
])
if test -n "$OPENSSLPREFIX" -a -z "$OPENSSLINCL" ; then
  if test -f "$OPENSSLPREFIX/include/openssl/ssl.h" ; then
    OPENSSLINCL="-I$OPENSSLPREFIX/include/"
  else
    AC_MSG_RESULT([!!! You defined  --with-openssl-prefix=$OPENSSLPREFIX,  BUT])
    AC_MSG_RESULT([!!! there does not exist file  $OPENSSLPREFIX/include/openssl/ssl.h !])
  fi
fi
if test -n "$OPENSSLPREFIX" -a -z "$OPENSSLLIB" ; then
  if test -n "$OPENSSLPREFIX" -a -f "$OPENSSLPREFIX/lib/libssl.so" ; then
    OPENSSLLIB="$OPENSSLPREFIX/lib/libssl.so $OPENSSLPREFIX/lib/libcrypto.so"
#   if test "$withval" != "/usr" -a "$withval" != "/usr/lib"; then
#	# Operating system dependent runtime path definition :-/
#	OPENSSLLIB="-R$withval $OPENSSLLIB"
#   fi
  elif test -n "$OPENSSLPREFIX" -a -f "$OPENSSLPREFIX/lib/libssl.a" ; then
    OPENSSLLIB="$OPENSSLPREFIX/lib/libssl.a $OPENSSLPREFIX/lib/libcrypto.a"
  else
    AC_MSG_RESULT([!!! You defined  --with-openssl-prefix=$OPENSSLPREFIX,  BUT])
    AC_MSG_RESULT([!!! there does not exist file  $OPENSSLPREFIX/lib/libssl.a !])
  fi
fi
if test -n "$OPENSSLINCL" -a -n "$OPENSSLLIB" ; then
  AC_DEFINE(HAVE_OPENSSL)
fi

if test -z "$OPENSSLINCL" ; then
  # No Explicite setup, lets do some auto-tests
  if test -f /usr/local/ssl/include/openssl/ssl.h ; then
    # Gee, OpenSSL 0.9.3a at default prefix!
    AC_DEFINE(HAVE_OPENSSL)
    OPENSSLPREFIX="/usr/local/ssl"
    OPENSSLINCL="-I$OPENSSLPREFIX/include"
    if test -f "$OPENSSLPREFIX/lib/libssl.so" ; then
      OPENSSLLIB="$OPENSSLPREFIX/lib/libssl.so $OPENSSLPREFIX/lib/libcrypto.so"
    else
      OPENSSLLIB="$OPENSSLPREFIX/lib/libssl.a $OPENSSLPREFIX/lib/libcrypto.a"
    fi
    AC_MSG_RESULT([You have OpenSSL version 0.9.3a (or newer) at default location])
  fi
  if test -f /usr/include/openssl/ssl.h ; then
    # Gee, OpenSSL 0.9.3a at  "--prefix=/usr" !!!
    AC_DEFINE(HAVE_OPENSSL)
    OPENSSLPREFIX="/usr"
    OPENSSLINCL=""
    if test -f "$OPENSSLPREFIX/lib/libssl.so" ; then
      OPENSSLLIB="$OPENSSLPREFIX/lib/libssl.so $OPENSSLPREFIX/lib/libcrypto.so"
    else
      OPENSSLLIB="$OPENSSLPREFIX/lib/libssl.a $OPENSSLPREFIX/lib/libcrypto.a"
    fi
    AC_MSG_RESULT([You have OpenSSL version 0.9.3a (or newer) at system root!])
  fi
fi


AC_CHECK_FUNCS(crypt)

if test "$ac_cv_func_crypt" != yes ; then
    # Now why ???  Must have "-lcrypt" like Linuxes ???
    t_oldLibs="$LIBS"
    LIBS="$LIBS -lcrypt"
    AC_TRY_LINK([], [char *s1, *s2, *s3; s3 = crypt(s1,s2);],
		ac_cv_lib_crypt_lib=yes,ac_cv_lib_crypt_lib=no)
    if test "$ac_cv_lib_crypt_lib" = yes; then
	# Success with this flag..
	GETPWLIB="$GETPWLIB -lcrypt"
	AC_MSG_RESULT([crypt() was found by using -lcrypt  library!])
    fi
    LIBS="$t_oldLibs"
fi



AC_STRUCT_DIRENT_D_INO

# Determine how to get the list of mounted filesystems.

AC_FUNC_GETMNTENT
AC_FUNC_GETMNTENT_MORE

# Test how to find out the filesystem space usage:
AC_FUNC_STATVFS

#if test -n "$list_mounted_fs" && test $space != no; then
#  PROGS="$PROGS df" LIBOBJS="$LIBOBJS"
#fi

AC_CHECK_FUNCS(ftruncate, , [ftruncate_missing=yes])

if test "$ftruncate_missing" = yes; then
  AC_MSG_CHECKING([fcntl emulation of ftruncate])
  AC_CACHE_VAL(fu_cv_sys_ftruncate_emulation,
  [AC_TRY_LINK([
#include <sys/types.h>
#include <fcntl.h>], [
#if !defined(F_CHSIZE) && !defined(F_FREESP)
chsize();
#endif
],
    fu_cv_sys_ftruncate_emulation=yes,
    fu_cv_sys_ftruncate_emulation=no)])
  AC_MSG_RESULT($fu_cv_sys_ftruncate_emulation)
  if test $fu_cv_sys_ftruncate_emulation = yes; then
    LIBOBJS="$LIBOBJS ftruncate.o"
  fi
fi

# If we don't yet have getgroups, see if it's in -lbsd.
# This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
AC_CHECK_FUNC(getgroups, , AC_CHECK_LIB(bsd, getgroups))

AC_CHECK_HEADERS(sys/ipc.h sys/msg.h)
AC_CHECK_FUNCS(msgsnd msgrcv msgctl)

# Check for libypsec.a on Dolphin M88K machines.
AC_CHECK_LIB(ypsec, main)

# m88k running dgux 5.4 needs this
AC_CHECK_LIB(ldgc, main)

AC_CHECKING(for AFS)
test -d /afs && AC_DEFINE(AFS)

AC_SUBST(MANDIR)
eval MANDIR=${mandir}

if test "$ac_cv_c_const" = no ; then
  CFLAGS="$CFLAGS -Dconst=''"
fi

AC_OUTPUT(Makefile
	router/Makefile			router/libdb/Makefile		\
	scheduler/Makefile		smtpserver/Makefile		\
	transports/Makefile		transports/smtp/Makefile	\
	transports/mailbox/Makefile	transports/hold/Makefile	\
	transports/libta/Makefile	transports/sm/Makefile		\
	transports/errormail/Makefile	transports/fuzzyalias/Makefile	\
	transports/expirer/Makefile	transports/expirer/manual-expirer \
	compat/Makefile			compat/rmail/Makefile		\
	compat/sendmail/Makefile					\
	lib/Makefile			libc/Makefile			\
	libident/Makefile		libs/Makefile			\
	libsh/Makefile			libmalloc/Makefile		\
	libmalloc/splay/Makefile	libresolv/Makefile		\
	ssl/Makefile							\
	doc/Makefile			doc/design/Makefile		\
	include/mail.h			man/Makefile			\
	utils/policy-builder.sh		utils/Makefile			\
	utils/zmailer.init.sh		utils/autoanswer.pl		\
	utils/vacation/Makefile		man/vacation.1			\
	utils/vacation/vacation.sh	utils/makedb/Makefile		\
	utils/rotate-logs.sh						\
	proto/Makefile			proto/zmailer.sh		\
	proto/newaliases		proto/newfqdnaliases		\
	proto/newdb			proto/scheduler.conf		\
	proto/mailrm.sh			proto/db/Makefile		\
	proto/smtpserver.conf		proto/cf/TELE-FI.cf		\
	proto/cf/SMTP+UUCP.cf		proto/cf/UTdefault.cf		\
	proto/cf/SMTP.cf						\
	proto/db/aliases		proto/sm.conf			\
	bin/mkdep			bin/mklibdep			\
	proto/post-install.sh						\
	packaging/Makefile		\
	packaging/solaris/Makefile	\
	SiteConfig	,
[chmod 755 bin/*
 echo > stamp-h])dnl
AC_MSG_RESULT([Remember to check  SiteConfig  for possible option changes])