File: configure.ac

package info (click to toggle)
alpine 2.20%2Bdfsg1-7
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 35,680 kB
  • sloc: ansic: 319,334; tcl: 26,277; sh: 12,178; makefile: 1,904; perl: 189; xml: 93; exp: 69; csh: 48; sed: 16
file content (1985 lines) | stat: -rw-r--r-- 57,363 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
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
dnl Process this file with autoconf to produce a configure script.

dnl /* ========================================================================
dnl  * Copyright 2013-2015 Eduardo Chappa
dnl  * Copyright 2006-2008 University of Washington
dnl  *
dnl  * Licensed under the Apache License, Version 2.0 (the "License");
dnl  * you may not use this file except in compliance with the License.
dnl  * You may obtain a copy of the License at
dnl  *
dnl  *     http://www.apache.org/licenses/LICENSE-2.0
dnl  *
dnl  * ========================================================================
dnl  */

AC_PREREQ([2.69])

AC_REVISION([Rev:15 by chappa@washington.edu])

dnl Alpine Version Number is in $srcdir/VERSION
AC_INIT([alpine],[m4_normalize(m4_include(VERSION))],[chappa@washington.edu])

AC_CONFIG_SRCDIR([include/system.h])
AC_CONFIG_HEADERS([include/config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign nostdinc])

AM_MAINTAINER_MODE

AC_CANONICAL_HOST

AC_LANG(C)

AC_MSG_NOTICE([Configuring for $PACKAGE_STRING ($host))])

# start out with intent to build Web Alpine
WEB_BUILD=web/src/alpined.d

dnl CHECK PROGRAMS

AC_PROG_CC
AC_PROG_CC_STDC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_LN_S
AC_PROG_AWK
AC_PROG_RANLIB
LT_INIT
AC_SUBST([LIBTOOL_DEPS])

AC_PATH_PROG(AR, ar, ar)
AC_PATH_PROG(RM, rm, rm)
AC_PATH_PROG(CP, cp, cp)
AC_PATH_PROG(LN, ln, ln)
AC_PATH_PROG(LS, ls, ls)
AC_PATH_PROG(SED, sed, sed)
AC_PATH_PROG(MAKE, make)

dnl COMPILE-TIME OPTIONS

AM_GNU_GETTEXT_VERSION([0.16.1])
AM_GNU_GETTEXT([external])

dnl enable dmalloc per http://dmalloc.com
dnl NOTE: does not check c-client
AC_MSG_CHECKING([option: dmalloc enabled])
AC_ARG_ENABLE(dmalloc, AS_HELP_STRING([--enable-dmalloc],[Enable dmalloc debugging]))
if test x$enable_dmalloc = "xyes" ; then
  AC_MSG_RESULT([yes])
else
  AC_MSG_RESULT([no])
fi

AC_ARG_WITH(dmalloc-dir,
  AS_HELP_STRING([--with-dmalloc-dir=DIR],[Root of dmalloc lib/include path]),
  [
    if test "x$withval" != "xno" ; then
      enable_dmalloc = "yes"
      CPPFLAGS="$CPPFLAGS -I${withval}"
      LDFLAGS="$LDFLAGS -L${withval}"
    fi
  ])

if test x$enable_dmalloc = "xyes" ; then
  AC_DEFINE(ENABLE_DMALLOC, 1, [Define enable dmalloc debugging])
fi

dnl set ps command, this test is fragile, but it should mostly work
ALPINE_psefcmd="/bin/ps auxww"
ALPINE_psfailed="0"
ALPINE_PSTEST="-"
AC_ARG_WITH(ps-cmd,
  AS_HELP_STRING([--with-ps-cmd="CMD"],[Use this command to check running commands. Default: /bin/ps auxww]),
  [
    if test "x$withval" = "xno" -o "x$withval" = "xyes" -o "x$withval" = "x" ; then
	withval=$ALPINE_psefcmd
    fi
    ALPINE_PSTEST=`$withval | $EGREP "$withval" | $EGREP -v $EGREP`
    if test -n "$ALPINE_PSTEST" ; then
       ALPINE_psefcmd="$withval"
    else
       ALPINE_psfailed="1"
       if test "x$ALPINE_psefcmd" != "x$withval" ; then
          AC_MSG_WARN(failed command $withval. Trying $ALPINE_psefcmd)
       fi
    fi
  ])
if test "$ALPINE_psfailed" = "1" -o "$ALPINE_PSTEST" = "-" ; then
   withval="$ALPINE_psefcmd"
   ALPINE_PSTEST=`$withval | $EGREP "$withval" | $EGREP -v $EGREP`
   if test -z "$ALPINE_PSTEST" ; then
      ALPINE_psfailed="1"
   else
      ALPINE_psfailed="0"
   fi
fi
if test "$ALPINE_psfailed" = "0" ; then
  AC_DEFINE_UNQUOTED([PSEFCMD], "$ALPINE_psefcmd", [ps command which outputs list of running commands])
fi

dnl Set default locale dir.
case $host in
    *apple-darwin*)
      if test -d /opt/local ; then
	localedir="/opt/local/share/locale"
      else
	localedir="\${datadir}/locale"
      fi
      ;;
    *-*-cygwin)
	localedir="/usr/share"
      ;;
    *)  
      localedir="\${datadir}/locale"
      ;;
esac
AC_ARG_WITH(localedir,
  AS_HELP_STRING([--with-localedir=DIR],[Name of gettext locale directory]),
  [
    case $withval in
      yes)
        ;;
      no)
        ;;
      *)
        localedir=$withval
        ;;
    esac
  ])
AC_SUBST(localedir, "[$localedir]")

# Setup OS-Specific features
case "$host" in
  *darwin*)
    dnl OS X Universal Binary Support
    AC_ARG_ENABLE(osx-universal-binaries,
      AS_HELP_STRING([--enable-osx-universal-binaries],[Produce universal binaries under OS X [[default=no]]]))
    if test "x$enable_osx_universal_binaries" = "xyes" ; then
      if test "x$enable_dependency_tracking" != xno ; then
	AC_MSG_ERROR([--enable-osx-universal-binary requires --disable-dependency-tracking.
Please re-run configure with these options:
    --disable-dependency-tracking --enable-osx-universal-binary])
      fi
      if [test -d /Developer/SDKs/MacOSX10.5.sdk] ; then
        alpine_sysroot=/Developer/SDKs/MacOSX10.5.sdk
      elif [test -d /Developer/SDKs/MacOSX10.4u.sdk] ; then
        alpine_sysroot=/Developer/SDKs/MacOSX10.4u.sdk
      else
	AC_MSG_ERROR([No suitable MacOSX SDK found.  Make sure Xcode tools are installed])
      fi
      ub_cflags="-isysroot $alpine_sysroot -arch ppc -arch i386"
      ub_ldflags="-Wl,-syslibroot,$alpine_sysroot -arch ppc -arch i386"
      AM_CFLAGS="$AM_CFLAGS $ub_cflags"
      AM_LDFLAGS="$AM_LDFLAGS $ub_ldflags"
      alpine_c_client_cflags="$alpine_c_client_cflags $ub_cflags"
      alpine_c_client_ldflags="$alpine_c_client_ldflags $ub_ldflags"
    fi
    ;;
esac

AC_ARG_WITH(include-path,
  AS_HELP_STRING([--with-include-path=PATHS],[Colon-separated list of directories used for include file search]),
  [
    case $withval in
      no)
        ;;
      yes)
        ;;
      *)
	new_cppflags="-I`echo ${withval} | ${SED} 's/:/ -I/g'`"
	CPPFLAGS="$CPPFLAGS ${new_cppflags}"
	alpine_c_client_cflags="$alpine_c_client_cflags ${new_cppflags}"
	;;
    esac
  ])

AC_ARG_WITH(lib-path,
  AS_HELP_STRING([--with-lib-path=PATHS],[Colon-separated list of directories used for library search]),
  [
    case $withval in
      no)
        ;;
      yes)
        ;;
      *)
      	new_ldflags="-L`echo ${withval} | ${SED} 's/:/ -L/g'`"
      	LDFLAGS="$LDFLAGS $new_ldflags"
        alpine_c_client_ldflags="$alpine_c_client_ldflags ${new_ldflags}"
	;;
    esac
  ])

AC_ARG_WITH(pubcookie,
  AS_HELP_STRING([--with-pubcookie],[Include support for UW-Pubcookie Web Authentication]),
  [
    if test "x$withval" != "xno" ; then
      WEB_PUBCOOKIE_BUILD=web/src/pubcookie
    fi
  ])


AC_ARG_WITH(web-bin,
  AS_HELP_STRING([--with-web-bin=PATH],[Directory to hold Web Alpine component binary files]),
  [
    case "$withval" in
      no)
	;;
      yes)
	;;
      *)
	WEB_BINDIR=$withval
	;;
    esac
  ])

dnl disable debug, turned on by default
AC_MSG_CHECKING([option: debugging is enabled])
AC_ARG_ENABLE(debug, AS_HELP_STRING([--disable-debug],[Exclude debug messages from source]))
if test x$enable_debug != "xno" ; then
  AM_CFLAGS="$AM_CFLAGS -g"
  AC_DEFINE([DEBUG], [1], [Compile in debugging])
  AC_DEFINE([DEBUGJOURNAL], [1], [Display debug messages in journal])
  AC_MSG_RESULT([yes])
else
dnl ??? set AM_CFLAGS to optimize ???
  AC_MSG_RESULT([no])
fi

dnl disable optimization, on by default
AC_MSG_CHECKING([option: optimization is enabled])
AC_ARG_ENABLE(optimization, AS_HELP_STRING([--disable-optimization],[Exclude optimizing compiler flags]))
if test x$enable_optimization != "xno" ; then
  AC_MSG_RESULT([yes])
else
  CFLAGS="`echo $AM_CFLAGS | ${SED} 's/-O2//'`"
  alpine_c_client_gccoptlevel="-O0"
  AC_MSG_RESULT([no])
fi

dnl disable mouse support
AC_MSG_CHECKING([option: mouse support enabled])
AC_ARG_ENABLE(mouse, AS_HELP_STRING([--disable-mouse],[Disable mouse support]))
if test x$enable_mouse != "xno" ; then
  AC_DEFINE([MOUSE], [], [Compile in mouse support])
  AC_MSG_RESULT([yes])
else
   AC_MSG_RESULT([no])
fi

dnl enable quotas
AC_MSG_CHECKING([option: quotas enabled])
AC_ARG_ENABLE(quotas, AS_HELP_STRING([--enable-quotas],[Enable disk quota checking on startup]))
if test x$enable_quotas = "xyes" ; then
  AC_DEFINE([USE_QUOTAS], [], [Compile in quota check on startup])
  AC_MSG_RESULT([yes])
else
   AC_MSG_RESULT([no])
fi

AC_MSG_CHECKING([option: From changing enabled])
AC_ARG_ENABLE(from_changing, AS_HELP_STRING([--disable-from-changing],[Disallow users changing From addresss]))
if test x$enable_from_changing != "xno" ; then
  AC_MSG_RESULT([yes])
else
  AC_DEFINE([NEVER_ALLOW_CHANGING_FROM], [], [Disallow users changing their From address])
  AC_MSG_RESULT([no])
fi

dnl enable background posting support
AC_MSG_CHECKING([option: background post enabled])
AC_ARG_ENABLE(background-post, AS_HELP_STRING([--disable-background-post],[Disable background posting]))
if test x$enable_background_post != "xno" ; then
  AC_DEFINE([BACKGROUND_POST], [], [Enable background posting support])
  AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi

dnl enable keyboard locking support
AC_MSG_CHECKING([option: keyboard lock enabled])
AC_ARG_ENABLE(keyboard-lock, AS_HELP_STRING([--disable-keyboard-lock],[Disable keyboard locking]))
if test x$enable_keyboard_lock != "xno" ; then
  AC_DEFINE([KEYBOARD_LOCK], [], [Enable keyboard lock support])
  AC_MSG_RESULT([yes])
else
  AC_MSG_RESULT([no])
fi

dnl enable from encoding support
AC_MSG_CHECKING([option: from encoding enabled])
AC_ARG_ENABLE(from-encoding, AS_HELP_STRING([--enable-from-encoding],[Enable From encoding in sent messages]))
if test x$enable_from_encoding = "xyes" ; then
  AC_DEFINE([ENCODE_FROMS], [], [Enable From address encoding in sent messages])
  AC_MSG_RESULT([yes])
else
  AC_MSG_RESULT([no])
fi

dnl OPTION: name of local submission agent
dnl         Might not be sendmail, but it MUST speak SMTP on stdin/stdout
AC_ARG_WITH(smtp-msa,
  AS_HELP_STRING([--with-smtp-msa=PATH],[Local Mail Submission Agent (sendmail)]),
    [
      case "$withval" in
	no)
	  ;;
	yes)
	  AC_PATH_PROG(SENDMAIL, sendmail, "", $PATH:/usr/sbin:/usr/lib)
	  ;;
	*)
	  SENDMAIL=$withval
	  ;;
      esac
    ],
    [
	  AC_PATH_PROG(SENDMAIL, sendmail, "", $PATH:/usr/sbin:/usr/lib)
    ])
if test -n "$SENDMAIL" ; then
    AC_DEFINE_UNQUOTED([SENDMAIL], "$SENDMAIL", [Local mail submission agent])
fi

dnl OPTION: local msa arguments
smtp_msa_flags="-bs -odb -oem"
AC_ARG_WITH(smtp-msa-flags,
  AS_HELP_STRING([--with-smtp-msa-flags=FLAGS],[MSA flags for SMTP on stdin/stdout (-bs -odb -oem)]),
  [
    if test "x$withval" != "xno" ; then
      smtp_msa_flags=$withval
    fi
  ])
AC_DEFINE_UNQUOTED([SENDMAILFLAGS], "$smtp_msa_flags", [Local MSA flags for SMTP on stdin/stdout])

dnl OPTION: name of local news posting agent and flags
npa="inews"
AC_ARG_WITH(npa,
  AS_HELP_STRING([--with-npa=PATH],[Posting agent when no nntp-servers defined (inews)]),
    [
      case "$withval" in
	no)
	  ;;
	yes)
	  AC_PATH_PROG(NPA_PROG, inews, "", $PATH:/usr/sbin:/usr/lib)
	  ;;
	*)
	  NPA_PROG=$withval
	  ;;
      esac
    ],
    [
	  AC_PATH_PROG(NPA_PROG, inews, "", $PATH:/usr/sbin:/usr/lib)
    ])

npa_flags="-h"
AC_ARG_WITH(npa-flags,
  AS_HELP_STRING([--with-npa-flags=FLAGS],[Flags to allow posting via local agent (-h)]),
  [
    if test "x$withval" != "xno" ; then
      npa_flags=$withval
    fi
  ])
if test -n "$NPA_PROG" ; then
  AC_DEFINE_UNQUOTED([SENDNEWS], "$NPA_PROG $npa_flags", [Posting agent to use when no nntp-servers defined])
fi

dnl OPTION: password changing program
AC_ARG_WITH(password-prog,
  AS_HELP_STRING([--with-password-prog=PATH],[Password change program (/bin/passwd)]),
    [
      case "$withval" in
	no)
	  ;;
	yes)
	  AC_PATH_PROG(PWPROG, passwd, "", $PATH:/usr/sbin:/usr/lib)
	  ;;
	*)
	  AC_PATH_PROG(PWPROG, $withval, "", $PATH:/usr/sbin:/usr/lib)
	  ;;
      esac
    ],
    [
	  AC_PATH_PROG(PWPROG, passwd, "", $PATH:/usr/sbin:/usr/lib)
    ])
if test -n "$PWPROG" ; then
    AC_DEFINE_UNQUOTED([PASSWD_PROG], "$PWPROG", [Program users use to change their password])
fi

dnl OPTION: basic spell checking program
AC_ARG_WITH(simple-spellcheck,
  AS_HELP_STRING([--with-simple-spellcheck=PROG],[Spellcheck program reads stdin, emits misspellings on stdout]),
    [
      if test "x$withval" != "xno" ; then
        SPELLPROG=$withval
      fi
    ],
    [
      AC_CHECK_PROG([SPELLPROG], [hunspell], [hunspell], [])
      if test -z "$SPELLPROG" ; then
        AC_CHECK_PROG([SPELLPROG], [aspell], [aspell], [])
        if test -z "$SPELLPROG" ; then
          AC_CHECK_PROG([SPELLPROG], [ispell], [ispell], [])
          if test -z "$SPELLPROG" ; then
           SPELLPROG="spell"
          fi
        fi
      fi
    ])

if test "x$SPELLPROG" != "xno" ; then
  AC_PATH_PROG(alpine_simple_spellcheck, $SPELLPROG)
  if test -n "$alpine_simple_spellcheck" ; then
    case "$SPELLPROG" in
      hunspell)
        alpine_simple_spellcheck="$alpine_simple_spellcheck -l"
        ;;
      aspell)
        alpine_simple_spellcheck="$alpine_simple_spellcheck --dont-backup --mode=email list"
        ;;
      ispell)
        alpine_simple_spellcheck="$alpine_simple_spellcheck -l"
        ;;
      *)
        ;;
    esac
  fi
fi

dnl OPTION: interactive spell checking program
AC_ARG_WITH(interactive-spellcheck,
  AS_HELP_STRING([--with-interactive-spellcheck=PROG],[Interactive, filewise spell checker]),
    [
      if test "x$withval" != "xno" ; then
        ISPELLPROG=$withval
      fi
    ],
    [
      AC_CHECK_PROG([ISPELLPROG], [hunspell], [hunspell], [])
      if test -z "$ISPELLPROG" ; then
        AC_CHECK_PROG([ISPELLPROG], [aspell], [aspell], [])
        if test -z "$SPELLPROG" ; then
          ISPELLPROG="ispell"
        fi
      fi
    ])

if test "x$ISPELLPROG" != "xno" ; then
  AC_PATH_PROG(alpine_interactive_spellcheck, $ISPELLPROG)
  if test -n "$alpine_interactive_spellcheck" ; then
    case "$ISPELLPROG" in
      aspell)
        alpine_interactive_spellcheck="$alpine_interactive_spellcheck --dont-backup --mode=email check"
        ;;
      *)
        ;;
    esac
  fi
fi

if test -n "$alpine_interactive_spellcheck" ; then
    AC_DEFINE_UNQUOTED([DF_VAR_SPELLER], "$alpine_interactive_spellcheck", [Interactive, filewise spell checker])
fi

if test -z "$alpine_simple_spellcheck" -a -n "$alpine_interactive_spellcheck" ; then
  alpine_simple_spellcheck=test
fi
AC_DEFINE_UNQUOTED([SPELLER], "$alpine_simple_spellcheck", [Simple spell checker: reads stdin, emits misspellings on stdout])

dnl OPTION: system-pinerc
dnl NOTE: historically we used /lib for the config dir.
dnl       don't ask, it was a long time ago. but, we can't
dnl       change it now without breaking compatibility
case "$prefix" in
  NONE) dpv=/usr/local/lib/pine.conf ;;
  *) dpv=${prefix}/lib/pine.conf ;;
esac
AC_ARG_WITH(system-pinerc,
  AS_HELP_STRING([--with-system-pinerc=VALUE],[System pinerc (/usr/local/lib/pine.conf)]),
    [
      case "$withval" in
	no)
	  ;;
	yes)
	  ;;
	*)
	  dpv=$withval
	  ;;
      esac
    ])
AC_DEFINE_UNQUOTED(SYSTEM_PINERC, "$dpv", [System pinerc])

dnl OPTION: system-fixed-pinerc
dnl NOTE: historically we used /lib for the config dir.
dnl       don't ask, it was a long time ago. but, we can't
dnl       change it now without breaking compatibility
case "$prefix" in
  NONE) dpv=/usr/local/lib/pine.conf.fixed ;;
  *) dpv=${prefix}/lib/pine.conf.fixed ;;
esac
AC_ARG_WITH(system-fixed-pinerc,
  AS_HELP_STRING([--with-system-fixed-pinerc=VALUE],[System fixed pinerc (/usr/local/lib/pine.conf.fixed)]),
    [
      case "$withval" in
	no)
	  ;;
	yes)
	  ;;
	*)
	  dpv=$withval
	  ;;
      esac
    ])
AC_DEFINE_UNQUOTED(SYSTEM_PINERC_FIXED, "$dpv", [System fixed pinerc])

dnl OPTION: local support information, file that contains information on
dnl 	    how to contact local support for Alpine.
dnl NOTE: historically we used /lib for the config dir.
dnl       don't ask, it was a long time ago. but, we can't
dnl       change it now without breaking compatibility
case "$prefix" in
  NONE) dpv=/usr/local/lib/pine.info ;;
  *) dpv=${prefix}/lib/pine.info ;;
esac
AC_ARG_WITH(local-support-info,
  AS_HELP_STRING([--with-local-support-info=VALUE],[Local Support Info File (/usr/local/lib/pine.info)]),
    [
      case "$withval" in
	no)
	  ;;
	yes)
	  ;;
	*)
	  dpv=$withval
	  ;;
      esac
    ])
AC_DEFINE_UNQUOTED(SYSTEM_PINE_INFO_PATH, "$dpv", [Local Support Info File])

dnl Function to simplify setting alpine/pico defaults
dnl usage: PINEVAR(configure-name, definition-name, definition-value, help)
AC_DEFUN([PINEVAR],
  [
    dpv=$3
    AC_ARG_WITH($1,
      AS_HELP_STRING([--with-$1=VALUE],[$4 ($3)]),
      [
	if test "x$withval" != "xno" ; then
	  dpv=$withval
	fi
      ])
    AC_DEFINE_UNQUOTED($2, "$dpv", [Default configuration value])
  ])

dnl Function to simplify setting pine/pico defaults
dnl usage: PINEVAR_UNQUOTED(configure-name, definition-name, definition-value, help)
AC_DEFUN([PINEVAR_UNQUOTED],
  [
    dpv=$3
    AC_ARG_WITH($1,
      AS_HELP_STRING([--with-$1=VALUE],[$4 ($3)]),
      [
	if test "x$withval" != "xno" ; then
	  dpv=$withval
	fi
      ])
    AC_DEFINE_UNQUOTED($2, $dpv, [Default configuration value])
  ])

PINEVAR(mailcheck-interval, DF_MAILCHECK, 150, [Specify default mail-check-interval])
PINEVAR_UNQUOTED(checkpoint-interval, CHECK_POINT_TIME, 420, [Specify default checkpoint-interval])
PINEVAR_UNQUOTED(checkpoint-frequency, CHECK_POINT_FREQ, 12, [State change count before checkpoint])
PINEVAR_UNQUOTED(display-rows, DEFAULT_LINES_ON_TERMINAL, 24, [Initial rows on display])
PINEVAR_UNQUOTED(display-columns, DEFAULT_COLUMNS_ON_TERMINAL, 80, [Initial columns on display])
PINEVAR_UNQUOTED(max-display-rows, MAX_SCREEN_ROWS, 200, [Maximum display rows])
PINEVAR_UNQUOTED(max-display-columns, MAX_SCREEN_COLS, 500, [Maximum display columns])
PINEVAR(fill-column, DF_FILLCOL, 74, [Default fill column])
PINEVAR_UNQUOTED(max_fill-column, MAX_FILLCOL, 80, [Maximum fill column])
PINEVAR_UNQUOTED(debug-level, DEFAULT_DEBUG, 2, [Specify default debug verbosity level])
PINEVAR_UNQUOTED(debug-files, NUMDEBUGFILES, 4, [Specify number of debug files])
PINEVAR(debug-file, DEBUGFILE, [.pine-debug], [Specify debug file name])
PINEVAR(forwarded-keyword, FORWARDED_FLAG, ["\$Forwarded"], [IMAP (c-client) keyword to store forwarded status])
PINEVAR(display-overlap, DF_OVERLAP, [2], [Lines preserved while paging])
PINEVAR(display-margin, DF_MARGIN, [0], [Lines visible while scrolling])
PINEVAR(default-fcc, DF_DEFAULT_FCC, [sent-mail], [Default sent mail folder])
PINEVAR(default-save-folder, DEFAULT_SAVE, [saved-messages], [Default save folder])
PINEVAR(default-legacy-postponed-folder, POSTPONED_MAIL, [postponed-mail], [Pre Pine 3.90 postponed folder])
PINEVAR(default-postponed-folder, POSTPONED_MSGS, [postponed-msgs], [Default postponed folder])
PINEVAR(default-trash-folder, TRASH_FOLDER, [Trash], [Default Trash folder for Web Alpine])
PINEVAR(default-interrupted-mail, INTERRUPTED_MAIL, [.pine-interrupted-mail], [Default folder for interrupted mail])
PINEVAR(default-dead-letter-folder, DEADLETTER, [dead.letter], [Default dead letter folder])
PINEVAR(default-mail-directory, DF_MAIL_DIRECTORY, [mail], [Default mail directory])
PINEVAR(default-inbox-name, INBOX_NAME, [INBOX], [Default inbox name])
PINEVAR(default-signature-file, DF_SIGNATURE_FILE, [.signature], [Default signature file])
PINEVAR(default-elm-style-save, DF_ELM_STYLE_SAVE, [no], [Default to Elm style save])
PINEVAR(default-header-in-reply, DF_HEADER_IN_REPLY, [no], [Include header in reply])
PINEVAR(default-old-style-reply, DF_OLD_STYLE_REPLY, [no], [Default to old style reply])
PINEVAR(default-use-only-domain-name, DF_USE_ONLY_DOMAIN_NAME, [no], [Default to using only the domain name])
PINEVAR(default-save-by-sender, DF_SAVE_BY_SENDER, [no], [Default to save by sender])
PINEVAR(default-sort-key, DF_SORT_KEY, [arrival], [Default sort key])
PINEVAR(default-addressbook-sort-rule, DF_AB_SORT_RULE, [fullname-with-lists-last], [Default addressbook sort rule])
PINEVAR(default-folder-sort-rule, DF_FLD_SORT_RULE, [alphabetical], [Default folder sort rule])
PINEVAR(default-saved-message-name-rule, DF_SAVED_MSG_NAME_RULE, [default-folder], [Default saved message name rule])
PINEVAR(default-fcc-rule, DF_FCC_RULE, [default-fcc], [Default fcc rule])
PINEVAR(default-standard-printer, DF_STANDARD_PRINTER, [lpr], [Default standard printern])
PINEVAR(default-ansi-printer, ANSI_PRINTER, [attached-to-ansi], [ANSI printer definition])
PINEVAR(default-addressbook, DF_ADDRESSBOOK, [.addressbook], [Default addressbook name])
PINEVAR(default-local-fullname, DF_LOCAL_FULLNAME, ["Local Support"], [Default local support fullname])
PINEVAR(default-local-address, DF_LOCAL_ADDRESS, [postmaster], [Default local support address])
PINEVAR(default-keyboard-lock-count, DF_KBLOCK_PASSWD_COUNT, [1], [Default keyboard lock count])
PINEVAR(default-remote-addressbook-history, DF_REMOTE_ABOOK_HISTORY, [3], [Default address book history count])
PINEVAR(smime-public-cert-directory, DF_PUBLICCERT_DIR, [.alpine-smime/public], [Default Public Cert Directory])
PINEVAR(smime-private-key-directory, DF_PRIVATEKEY_DIR, [.alpine-smime/private], [Default Private Key Directory])
PINEVAR(smime-cacert-directory, DF_CACERT_DIR, [.alpine-smime/ca], [Default Cert Authority Directory])
PINEVAR_UNQUOTED(default-printer, DF_DEFAULT_PRINTER, [ANSI_PRINTER], [Default printer])

AC_DEFINE_UNQUOTED([DF_PUBLIC_CONTAINER], "PublicContainer", [Name of default public container])
AC_DEFINE_UNQUOTED([DF_PRIVATE_CONTAINER], "PrivateContainer", [Name of default private container])
AC_DEFINE_UNQUOTED([DF_CA_CONTAINER], "CAContainer", [Name of default certificate authority container])

dnl set PASSFILE?
AC_ARG_WITH(passfile,
  AS_HELP_STRING([--with-passfile=FILENAME],[Password cache file (recommended when S/MIME is enabled and configured)]),
    [
      case "$withval" in
	no)
	  ;;
	yes)
	  ;;
	*)
	  alpine_PASSFILE=$withval
	  ;;
      esac
    ])


dnl os-specific credential cache?
AC_ARG_WITH(local-password-cache,
 AS_HELP_STRING([--without-local-password-cache],[Disable OS-specific password cache, if supported]),
   [
     alpine_os_credential_cache=$withval
   ])

dnl Particular os-specific credential cache?
AC_ARG_WITH(local-password-cache-method,
 AS_HELP_STRING([--with-local-password-cache-method],[OS-specific credential cache (OSX=APPLEKEYCHAIN, Windows=WINCRED)]),
   [
     alpine_os_credential_cache_method=$withval
   ])

if test -n "$alpine_PASSFILE" ; then
  case $alpine_os_credential_cache in
    no)
      ;;
    *)
      alpine_os_credential_cache="no"
      AC_MSG_NOTICE([--with-passfile definition overrides OS-Specific password caching])
      ;;
  esac
  AC_DEFINE_UNQUOTED([PASSFILE], "$alpine_PASSFILE", [Password cache file (recommended if S/MIME is enabled and configured)])
fi

dnl set DF_SSHPATH?
AC_ARG_WITH(default-sshpath,
  AS_HELP_STRING([--with-default-sshpath=FILENAME],[set default value of ssh command path (defining should cause ssh to be preferred to rsh)]),
    [
      case "$withval" in
	no)
	  ;;
	yes)
	  ;;
	*)
	  AC_DEFINE_UNQUOTED([DF_SSHPATH], "$withval", [set default value of ssh command path (defining should cause ssh to be preferred to rsh)])
	  ;;
      esac
    ])

dnl set DF_SSHCMD?
AC_ARG_WITH(default-sshcmd,
  AS_HELP_STRING([--with-default-sshcmd=PERCENT_S_STRING],[set default value of ssh command string (usually "%s %s -l %s exec /etc/r%sd")]),
    [
      case "$withval" in
	no)
	  ;;
	yes)
	  ;;
	*)
	  AC_DEFINE_UNQUOTED([DF_SSHCMD], "$withval", [set default value of ssh command string (usually "%s %s -l %s exec /etc/r%sd")])
	  ;;
      esac
    ])

dnl Include SSL?
dnl Set SSLDIR for c-client make
AC_ARG_WITH(ssl,
  AS_HELP_STRING([--without-ssl],[Disable SSL support (OpenSSL)]),
  [ with_ssl=$withval ])

if test "x$with_ssl" = "xno" ; then
  alpine_SSLTYPE="none"
elif test -d /usr/local/ssl ; then
dnl When the system has openssl installed in its default location
dnl instead of the one used by the distribution assume that this
dnl is the one intended to be used.
  alpine_SSLDIR="/usr/local/ssl"
else
  dnl preload c-client default locations/options
  case $host in
    *-linux-gnu*|*-k*bsd*-gnu*|*-gnu*)
      if test -f /etc/fedora-release -o -f /etc/redhat-release -o -f /etc/redhat_version ; then  
        alpine_SSLTYPE="nopwd"
	if test -d /etc/pki/tls ; then  
	  alpine_SSLDIR="/etc/pki/tls"
	else
	  alpine_SSLDIR="/usr/share/ssl"
	fi
	alpine_SSLCERTS="$alpine_SSLDIR/certs"
	alpine_SSLKEYS="$alpine_SSLDIR/private"
	alpine_SSLINCLUDE="/usr/include/openssl" 
	alpine_SSLLIB="/usr/lib"
      elif test -f /etc/mandrake-release ; then
	alpine_SSLDIR="/usr/lib/ssl"
	alpine_SSLCERTS="$alpine_SSLDIR/certs" 
	alpine_SSLKEYS="$alpine_SSLDIR/private"
	alpine_SSLINCLUDE="/usr/include/openssl" 
	alpine_SSLLIB="/usr/lib"
      elif test -f /etc/SuSE-release ; then
        alpine_SSLTYPE="nopwd"
        alpine_SSLDIR="/etc/ssl"
        alpine_SSLCERTS="$alpine_SSLDIR/certs"
	alpine_SSLKEYS="$alpine_SSLDIR/private"
	alpine_SSLINCLUDE="/usr/include/openssl" 
	alpine_SSLLIB="/usr/lib"
      elif test -d /etc/osso-af-init ; then
        alpine_SSLTYPE="nopwd"
        alpine_SSLDIR="/usr"
        alpine_SSLCERTS="/usr/share/certs"
	alpine_SSLINCLUDE="/usr/include/openssl"
	alpine_SSLLIB="/usr/lib"
      elif test -f /etc/debian_release -o -f /etc/debian_version ; then
        if test ! -d /etc/osso-af-init ; then
	   alpine_SSLDIR="/etc/ssl"
	   alpine_SSLCERTS="$alpine_SSLDIR/certs"
	   alpine_SSLKEYS="$alpine_SSLDIR/private"
	   alpine_SSLINCLUDE="/usr/include/openssl" 
	   alpine_SSLLIB="/usr/lib"
        fi
      else
        alpine_SSLTYPE="nopwd"
        alpine_SSLDIR="/usr"
        alpine_SSLCERTS="/etc/ssl/certs"
      fi
      ;;
    *-apple-darwin*)
      alpine_SSLTYPE="nopwd"
dnl Originally this is where certs are, and they might still be there, even
dnl after installing Homebrew, MacPorts or Fink. We will use it if we cannot
dnl find it anywhere else.
      alpine_SSLCERTS_ORIG="/System/Library/OpenSSL/certs"
      if test -d /usr/local/opt/openssl ; then
	alpine_SSLDIR="/usr/local/opt/openssl"
	alpine_SSLINCLUDE="$alpine_SSLDIR/include"
	alpine_SSLLIB="$alpine_SSLDIR/lib"
	alpine_SSLCERTS="/usr/local/etc/openssl"
	alpine_SSLKEYS="$alpine_SSLDIR/private"
      elif test -d /opt/local/etc/openssl ; then
	alpine_SSLDIR="/opt/local"
	alpine_SSLINCLUDE="$alpine_SSLDIR/include"
	alpine_SSLLIB="$alpine_SSLDIR/lib"
	alpine_SSLCERTS="/opt/local/etc/openssl/certs"
	alpine_SSLKEYS="/opt/local/etc/openssl/private"
      elif test -d /sw/etc/ssl ; then
	alpine_SSLDIR="/sw/etc/ssl"
	alpine_SSLINCLUDE="/sw/include"
	alpine_SSLLIB="/sw/lib"
	alpine_SSLCERTS="/sw/etc/ssl/certs"
	alpine_SSLKEYS="/sw/etc/ssl/private"
      elif test -d /usr/local/ssl ; then
	alpine_SSLDIR="/usr/local/ssl"
      elif test -d /System/Library/OpenSSL ; then
	alpine_SSLDIR="/System/Library/OpenSSL"
        alpine_SSLCERTS="$alpine_SSLDIR/certs"
	alpine_SSLKEYS="$alpine_SSLDIR/private"
	alpine_SSLLIB="/usr/lib"
	alpine_SSLINCLUDE="/usr/include/openssl"
      fi
      ;;
    *-*-netbsd*)
	alpine_SSLDIR="/etc/openssl"
	alpine_SSLCERTS="$alpine_SSLDIR/certs"
	alpine_SSLKEYS="$alpine_SSLDIR/private"
	alpine_SSLINCLUDE="/usr/include/openssl"
	alpine_SSLLIB="/usr/lib"
      ;;
    *-*-dragonfly*)
	alpine_SSLDIR="/etc/openssl"
	alpine_SSLCERTS="$alpine_SSLDIR/certs"
	alpine_SSLKEYS="$alpine_SSLDIR/private"
	alpine_SSLINCLUDE="/usr/include/openssl"
	alpine_SSLLIB="/usr/lib"
      ;;
    *-openbsd*)
	alpine_SSLTYPE="nopwd"
	alpine_SSLDIR="/usr"
	alpine_SSLCERTS="/etc/ssl/certs"
      ;;
    *-*-freebsd*)
	alpine_SSLDIR="/etc/ssl"
	alpine_SSLCERTS="$alpine_SSLDIR/certs"
	alpine_SSLKEYS="$alpine_SSLDIR/private"
	if test -d /usr/local/include/openssl ; then
	  alpine_SSLINCLUDE="/usr/local/include/openssl" 
	  alpine_SSLLIB="/usr/local/lib"
	else
	  alpine_SSLINCLUDE="/usr/include/openssl" 
	  alpine_SSLLIB="/usr/lib"
	fi
      ;;
    *-*-openbsd*)
	alpine_SSLDIR="/etc/ssl"
	alpine_SSLINCLUDE="/usr/include/openssl"
	alpine_SSLLIB="/usr/lib"
	alpine_SSLCERTS="/etc/ssl" 
	alpine_SSLKEYS="/etc/ssl/private"
      ;;
    *-*-cygwin)
	alpine_SSLDIR="/usr/ssl"
	alpine_SSLCERTS="$alpine_SSLDIR/certs" 
	alpine_SSLKEYS="$alpine_SSLDIR/certs"
	alpine_SSLINCLUDE="/usr/include/openssl" 
	alpine_SSLLIB="/usr/lib"
      ;;
    *-sco-sysv* | *-sysv*UnixWare | *-sysv*OpenUNIX)
	alpine_SSLTYPE="sco.nopwd"
	alpine_SSLDIR="/usr/local/ssl"
      ;;
    *-*-solaris*)
      if test -d /usr/sfw/include/openssl ; then
        alpine_SSLDIR="/usr/sfw"
      elif test -d /opt/csw/include/openssl ; then
        alpine_SSLDIR="/opt/csw"
	if test -d /opt/csw/ssl/certs ; then
	  alpine_SSLCERTS="/opt/csw/ssl/certs"
	fi
      fi
      if test -z "$alpine_SSLCERTS" -a -d /etc/certs ; then
        alpine_SSLCERTS="/etc/certs"
      fi
      ;;
    *)
      alpine_SSLTYPE="nopwd"
      alpine_SSLDIR="/usr/local/ssl"
      ;;
  esac

  AC_ARG_WITH(ssl-dir,
    AS_HELP_STRING([--with-ssl-dir=DIR],[Root of SSL lib/include path]),
    [
      if test "x$withval" != "xno" ; then
	alpine_SSLDIR=$withval
	alpine_SSLINCLUDE=$alpine_SSLDIR/include
	alpine_SSLLIB=$alpine_SSLDIR/lib
      fi
    ])

  AC_ARG_WITH(ssl-certs-dir,
    AS_HELP_STRING([--with-ssl-certs-dir=DIR],[Path to SSL certificate directory]),
    [
      if test "x$withval" != "xno" ; then
	alpine_SSLCERTS=$withval
      fi
    ])

  AC_ARG_WITH(ssl-include-dir,
    AS_HELP_STRING([--with-ssl-include-dir=DIR],[SSL include file path]),
    [
      if test "x$withval" != "xno" ; then
	alpine_SSLINCLUDE=$withval
      fi
    ])

  AC_ARG_WITH(ssl-lib-dir,
    AS_HELP_STRING([--with-ssl-lib-dir=DIR],[SSL library path]),
    [
      if test "x$withval" != "xno" ; then
	alpine_SSLLIB=$withval
      fi
    ])
fi

if test "x$alpine_SSLTYPE" != "xnone" ; then
  dnl setup globals so tests below work
  if test -n "$alpine_SSLINCLUDE" ; then
    CPPFLAGS="-I$alpine_SSLINCLUDE $CPPFLAGS"
  elif test -n "$alpine_SSLDIR" ; then
    CPPFLAGS="-I${alpine_SSLDIR}/include $CPPFLAGS"
  fi
  if test -n "$alpine_SSLLIB" ; then
    LDFLAGS="-L$alpine_SSLLIB $LDFLAGS"
  elif test -n "$alpine_SSLDIR" ; then
    LDFLAGS="-L${alpine_SSLDIR}/lib $LDFLAGS"
  fi
fi


dnl Include Kerberos?
dnl Set GSSDIR for c-client make
AC_ARG_WITH(krb5,
  AS_HELP_STRING([--without-krb5],[Disable Kerberos support]),
  [ with_krb5=$withval ])

if test "x$with_krb5" = "xno" ; then
  alpine_GSSTYPE="none"
else
  alpine_GSSTYPE=

  AC_ARG_WITH(krb5-dir,
    AS_HELP_STRING([--with-krb5-dir=DIR],[Root of Kerberos lib/include path]),
    [
      if test "x$withval" != "xno" ; then
	CPPFLAGS="$CPPFLAGS -I${withval}/include"
	LDFLAGS="$LDFLAGS -L${withval}/lib"
      fi
    ])

  AC_ARG_WITH(krb5-include-dir,
    AS_HELP_STRING([--with-krb5-include-dir=DIR],[Kerberos include file path]),
    [
      if test "x$withval" != "xno" ; then
	CPPFLAGS="$CPPFLAGS -I$withval"
      fi
    ])

  AC_ARG_WITH(krb5-lib-dir,
    AS_HELP_STRING([--with-krb5-lib-dir=DIR],[Kerberos library path]),
    [
      if test "x$withval" != "xno" ; then
	LDFLAGS="$LDFLAGS -L$withval"
      fi
    ])
fi

dnl Include LDAP?
AC_ARG_WITH(ldap,
  AS_HELP_STRING([--without-ldap],[Disable LDAP query support]),
  [ with_ldap=$withval ])

if test "x$with_ldap" = "xno" ; then
  alpine_with_ldap=
  AC_MSG_NOTICE([Excluding LDAP Support])
else
  dnl Do stuff to figure out where OpenLDAP is

  alpine_with_ldap=yes
  AC_ARG_WITH(ldap-dir,
    AS_HELP_STRING([--with-ldap-dir=DIR],[Root of LDAP lib/include path]),
    [
      if test "x$withval" != "xno" ; then 
	CPPFLAGS="$CPPFLAGS -I${withval}/include"
	LDFLAGS="$LDFLAGS -L${withval}/lib"
      fi
    ])

  AC_ARG_WITH(ldap-include-dir,
    AS_HELP_STRING([--with-ldap-include-dir=DIR],[Directory containing LDAP include files]),
    [
      if test "x$withval" != "xno" ; then
	CPPFLAGS="$CPPFLAGS -I$withval"
      fi
    ])

  AC_ARG_WITH(ldap-lib-dir,
    AS_HELP_STRING([--with-ldap-lib-dir=DIR],[LDAP library path]),
    [
      if test "x$withval" != "xno" ; then
	LDFLAGS="$LDFLAGS -L$withval"
      fi
    ])
fi

dnl Include SMIME?
AC_ARG_WITH(smime,
  AS_HELP_STRING([--without-smime],[Disable S/MIME]),
  [ with_smime=$withval ])

dnl Include TCL?
AC_ARG_WITH(tcl,
  AS_HELP_STRING([--without-tcl],[Disable TCL, thus Web Alpine support]),
  [ with_tcl=$withval ])

if test "x$with_tcl" = "xno" ; then
  WEB_BUILD=
  AC_MSG_NOTICE([Excluding TCL Support, and thus Web Alpine Support])
else
  AC_ARG_WITH(tcl-lib,
    AS_HELP_STRING([--with-tcl-lib=LIBRARY],[Specific TCL Library, like \"tcl8.6\"]),
    [
      if test "x$withval" != "xno" ; then 
	alpine_TCLLIB=$withval
      fi
    ])
  AC_ARG_WITH(tcl-include,
    AS_HELP_STRING([--with-tcl-include=DIR],[Directory containing TCL include files]),
    [
      if test "x$withval" != "xno" ; then
        CPPFLAGS="$CPPFLAGS -I$withval"
	alpine_TCLINC=$withval
      fi
    ])
fi

AC_ARG_WITH(supplied-regex,
  AS_HELP_STRING([--with-supplied-regex],[Use regex library supplied with alpine]),
  [ alpine_REGEX=$withval ])

AC_ARG_WITH(pthread,
  AS_HELP_STRING([--without-pthread],[Do NOT test for nor build with POSIX thread support]),
  [ with_pthread=$withval ])

AC_ARG_WITH(system-mail-directory,
  AS_HELP_STRING([--with-system-mail-directory=DIR],[Directory where local mail is delivered]),
  [
    if test "x$withval" != "xno" ; then
      alpine_with_local_maildir="$withval"
    fi
  ])

AC_ARG_WITH(c-client-target,
  AS_HELP_STRING([--with-c-client-target=TARGET],[IMAP build target (see imap/Makefile)]),
  [
    if test "x$withval" != "xno" ;then
      alpine_with_c_client_target="$withval"
    fi
  ])


dnl Assume PAM is *not* required and only set the systems that need it.
alpine_PAM="none"

dnl HOST-OS SPECIFIC DEFINITIONS
dnl Tests and assignments below are mostly to coax the appropriate
dnl build from c-client.  Most of this will go away when c-client
dnl adopts configure
case "$host" in
  *-linux-gnu*|*-k*bsd*-gnu*|*-gnu*)
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    if test -f /etc/fedora-release ; then  
      systype="LFD"
      alpine_PAM="yes"
      if test -d /etc/pki/tls ; then  
	alpine_c_client_target="lfd"
      else
	alpine_c_client_target="lrh"
      fi
    elif test -f /etc/mandrake-release ; then
      systype="LMD"
      alpine_c_client_target="lmd"
      alpine_PAM="yes"
    elif test -f /etc/redhat-release -o -f /etc/redhat_version ; then
      systype="LRH"
      alpine_PAM="yes"
      if test -d /etc/pki/tls ; then  
	alpine_c_client_target="lr5"
      else
	alpine_c_client_target="lrh"
      fi
    elif test -f /etc/debian_release -o -f /etc/debian_version ; then
      if test -d /etc/osso-af-init ; then
        systype="LN8"
        alpine_c_client_target="ln8"
      else
        systype="DEB"
        alpine_c_client_target="ldb"
	alpine_PAM="yes"
      fi
    elif test -f /etc/SuSE-release ; then
      systype="LSU"
      alpine_c_client_target="lsu"
      alpine_PAM="yes"
    else
      systype="LNX"
      AC_CHECK_LIB(pam, pam_start,
        [
          alpine_c_client_target="lnp"
	  alpine_PAM="yes"
        ],
        [
	  if test -f /etc/shadow ; then
	    alpine_c_client_target="slx"
	  else
	    alpine_c_client_target="lnx"
	  fi
        ])
    fi
    ;;
  *-apple-darwin*)
    systype="OSX"
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    LIBS="$LIBS -framework Carbon -framework ApplicationServices -framework Security"
    AM_CFLAGS="$AM_CFLAGS -Dbsd"
    dnl SEE include/system.h
    AC_DEFINE([OSX_TARGET],[1],[OSX TARGET])
    case "$alpine_os_credential_cache" in
      no)
	;;
      *)
	AC_DEFINE([APPLEKEYCHAIN], [1], [Use Apple OS X key chain for credential caching])
	;;
    esac
    AC_CHECK_LIB(pam, pam_start,
      [
	AC_CHECK_HEADER([security/pam_appl.h],
	[
	  alpine_PAM="yes"
	  alpine_c_client_target="oxs"
	],
	[	AC_CHECK_HEADER([pam/pam_appl.h],
		[
		   alpine_PAM="yes"
		   alpine_c_client_target="oxp" 
		],
		[
		  alpine_PAM="none"
		  alpine_pam_none_reason="header files not found"
		])
	])
      ],
      [
        alpine_c_client_target="osx"
      ])
    ;;
  *-*-solaris*)
    if test x$GCC = "xyes" ; then
      systype="GSO"
      alpine_c_client_target="gso"
    else
      systype="SOC"
      alpine_c_client_target="soc"
      AC_DEFINE([__EXTENSIONS__], [1], [Enable extended pthread features on Solaris])
    fi
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    dnl possible other OS's need this.
    dnl Use autoconf 2.61's AC_USE_SYSTEM_EXTENSIONS at some point
    ;;
  *-*-sunos4*)
    systype="SUN"
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    alpine_c_client_target="s40"
    ;;
  *-*-sco3.2v5*)
    if test x$GCC = "xyes" ; then
      systype="GO5"
      alpine_c_client_target="go5"
    else
      systype="SC5"
      alpine_c_client_target="sc5"
    fi
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    dnl possible other OS's need this.
    dnl Use autoconf 2.61's AC_USE_SYSTEM_EXTENSIONS at some point
    ;;
  *-next-*)
    systype="NXT"
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    alpine_c_client_target="nx3"
    ;;
  *-*-netbsd*)
    systype="NEB"
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    alpine_c_client_target="neb"
    ;;
  *-*-dragonfly*)
    systype="DFB"
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    alpine_c_client_target="neb"
    ;;
  *-*-bsdi*)
    systype="BSI"
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    alpine_c_client_target="bsi"
    ;;
  *-*-freebsd*)
    systype="BSF"
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    alpine_c_client_target="bsf"
    LIBS="$LIBS $LIBINTL"
    ;;
  *-*-openbsd*)
    systype="BSO"
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    alpine_c_client_target="bso"
    LIBS="$LIBS $LIBINTL"
    ;;
  *-*-aix5*)
    systype="A52"
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    alpine_c_client_target="a52"
    ;;
  *-*-aix4*)
    systype="A41"
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    alpine_c_client_target="a41"
    ;;
  *-*-aix3*)
    systype="A32"
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    alpine_c_client_target="a32"
    ;;
  *-*UNIX_SV | *-*-sysv5UnixWare7* | *-*OpenUNIX*)
    systype="UW2"
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    alpine_c_client_target="uw2"
    ;;
  *-*-osf5*)
    systype="OSF"
    alpine_path_delim="/"
    alpine_mode_readonly="(0600)"
    alpine_c_client_target="osf"
    ;;
  *-*-cygwin)
    systype="CYG"
    alpine_path_delim="/"
    alpine_mode_readonly="(S_IREAD | S_IWRITE)"
    alpine_c_client_target="cyg"
    LIBS="$LIBS $LIBINTL"
    ;;
  windows* | *-*-pw32*)
    systype="WNT"
    alpine_path_delim="\\"
    alpine_mode_readonly="(S_IREAD | S_IWRITE)"
    alpine_c_client_target="wnt"
    AC_DEFINE([_WINDOWS], [1], [Windows is just too different])
    ;;
  *)
    AC_MSG_ERROR(Unrecognized system: $host)
    ;;
esac

dnl Without IPv6?
AC_ARG_WITH(ipv6,
  AS_HELP_STRING([--without-ipv6],[Disable IPv6, primarily to work around resolver problems]),
  [ with_ipv6=$withval ])

if test "x$with_ipv6" = "xno" ; then
  AC_MSG_NOTICE([Excluding IPv6 Support])
  c_client_specials="${c_client_specials}IP6=4 "
  c_client_ip6="true"
else
  c_client_ip6="touch imap/ip6"
fi


dnl CHECK LIBRARIES

if test x$enable_dmalloc = "xyes" ; then
  if test "x$with_pthread" = "xyes" ; then
    dmalloc_lib=dmallocth
  else
    dmalloc_lib=dmalloc
  fi

  AC_CHECK_LIB($dmalloc_lib,dmalloc_shutdown,,
    [
      AC_MSG_ERROR($dmalloc_lib requested, but -ldmalloc not found)
    ])
fi

dnl which terminal cabability database
AC_CHECK_LIB(tinfo, setupterm,
  [
    alpine_termdata=info
    LIBS="$LIBS -ltinfo"
  ],
  [
    AC_CHECK_LIB(ncurses, setupterm,
      [
        alpine_termdata=info
        LIBS="$LIBS -lncurses"
      ],
      [
        AC_CHECK_LIB(curses, setupterm,
          [
            alpine_termdata=info
            LIBS="$LIBS -lcurses"
          ],
          [
            AC_CHECK_LIB(termlib, tgetent,
              [
                alpine_termdata=cap
                LIBS="$LIBS -ltermlib"
              ],
              [
                AC_CHECK_LIB(termcap, tgetent,
                  [
                    alpine_termdata=cap
                    LIBS="$LIBS -ltermcap"
                  ],
                  [
                    AC_MSG_ERROR(Terminfo/termcap not found)
                  ])
              ])
          ])
      ])
  ])
case $alpine_termdata in
  info)
    AC_DEFINE(HAS_TERMINFO, [1], [Define if systems uses terminfo terminal database])
    ;;
  cap)
    AC_DEFINE(HAS_TERMCAP, [1], [Define if systems uses termcap terminal database])
    ;;
esac

dnl is -ldl present? if so, add it
AC_SEARCH_LIBS([dlopen], [dl dld],, [ alpine_DL="none" ])
if test "x$alpine_DL" = "xnone" ; then
    AC_MSG_ERROR([No library containing dlopen found])
    exit 1	
fi

dnl Check Openssl/LibreSSL version first
if test "x$alpine_SSLTYPE" != "xnone" ; then
  AC_MSG_CHECKING([Openssl library version >= 1.0.1c])
  AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdlib.h>
#if HAVE_STDINT_H
#include <stdint.h>
#endif /* HAVE_STDINT_H */
#include <openssl/ssl.h>
int main(void) {

	if (OPENSSL_VERSION_NUMBER >= 0x1000003f)
		exit(0);

	exit(2);
}
	]])],
	[ AC_MSG_RESULT(yes) ],
	[ alpine_SSLTYPE="none" ])

    if test "x$alpine_SSLTYPE" = "xnone" ; then
	AC_MSG_ERROR(Install openssl version >= 1.0.1c)
	exit 1
    fi
    AC_SEARCH_LIBS(TLSv1_2_client_method,ssl,
	[ alpine_c_client_cflags="$alpine_c_client_cflags -DTLSV1_2"
	  AC_DEFINE([SSL_SUPPORTS_TLSV1_2], [1], [SSL Supports TLSV1.2])
	])
fi

dnl Crypto support is needed 
if test "x$alpine_SSLTYPE" != "xnone" ; then
  AC_SEARCH_LIBS(SSLeay,crypto,, [ alpine_CRYPTO="none" ])
  if test "x$alpine_CRYPTO" = "xnone" ; then
     AC_MSG_ERROR(crypto library NOT found)
     exit 1
  fi
fi

dnl provide SSL support?
if test "x$alpine_SSLTYPE" != "xnone" ; then
   AC_SEARCH_LIBS(SSL_library_init,ssl,,[ alpine_SSLTYPE="none" ])

  if test "x$alpine_SSLTYPE" = "xnone" ; then
     AC_MSG_ERROR(No library containing SSL_library_init found in your path)
     exit 1
  fi

fi

dnl provide LDAP support?
if test "$alpine_with_ldap" = "yes" ; then
  alpine_has_ldap=
  AC_CHECK_LIB(lber, ber_alloc,
    [
      LIBS="$LIBS -llber"
    ])
  AC_SEARCH_LIBS(ldap_init,ldap,
    [
      alpine_has_ldap=yes
    ],
    [
      AC_SEARCH_LIBS(ldap_open,ldap,
	[
	  alpine_has_ldap=yes
	])
    ])

  if test "$alpine_has_ldap" = "yes" ; then
    AC_MSG_NOTICE([* * * Including LDAP Support])
    AC_DEFINE([ENABLE_LDAP], [], [Enable LDAP query support])

    dnl we use deprecated functions (ldap_get_values)
    dnl OpenLDAP 2.3.x doesn't define LDAP_DEPRECATED by default like 2.2.x
    AC_MSG_CHECKING([if we should define LDAP_DEPRECATED])
    AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdlib.h>
#include <ldap.h>
int main(void) {

	if (LDAP_VENDOR_VERSION >= 20300)
		exit(0);

	exit(2);
}
	]])],
	[
		AC_MSG_RESULT(yes)
		AC_DEFINE(LDAP_DEPRECATED, 1,
		[Define if you use OpenLDAP 2.3.x deprecated functions])

	],
	[
		AC_MSG_RESULT(no)
	],
	[
		AC_MSG_WARN([cross compiling: not checking])
	]
    )

  else
    AC_MSG_NOTICE([Cannot find LDAP functions!  Excluding LDAP support.])
  fi
fi

dnl PAM support is needed to build c-client in some linux, and hence Alpine.
if test "x$alpine_PAM" != "xnone" ; then
  AC_SEARCH_LIBS(pam_start,pam,
      [
	LIBS="$LIBS -lpam"
	AC_CHECK_HEADER([security/pam_appl.h],
	[
	  alpine_PAM="yes"
	],
	dnl Only mac is incompatible, do not spread bad habits.
	[ AC_CHECK_HEADER([pam/pam_appl.h],
	  [
		alpine_PAM="yes"
		if test "x$alpine_c_client_target" != "xoxp" ; then
		   alpine_PAM="none"
		   alpine_pam_none_reason="header files not in security/ directory"
		fi
	  ],
	  [
		alpine_PAM="none"
		alpine_pam_none_reason="header files not found"
	  ])
	])
      ],
      [
	alpine_PAM="none"
	alpine_pam_none_reason="library files not found"
      ])
    if test -n "$alpine_pam_none_reason" ; then
      AC_MSG_ERROR(No PAM support: $alpine_pam_none_reason)
  fi
fi


dnl provide KRB5 support?
if test "x$alpine_GSSTYPE" != "xnone" ; then
  AC_SEARCH_LIBS(gss_init_sec_context,gss gssapi gssapi_krb5,
    [
      dnl MIT-based?
      LIBS="$LIBS -lkrb5"
      AC_CHECK_HEADER([gssapi/gssapi_generic.h],,
	[
	  if test ! -d /usr/kerberos/include ; then
	    alpine_GSSTYPE="none"
	    alpine_gss_none_reason="header files not found"
	  fi
	])
    ],
    [
      alpine_GSSTYPE="none"
      alpine_gss_none_reason="libraries not found"
    ])
  if test -n "$alpine_gss_none_reason" ; then
    AC_MSG_NOTICE([NOT including Kerberos Support: $alpine_gss_none_reason])
  fi
fi

dnl check for tcl libraries for Web Alpine (HACKY)
if test -n "$WEB_BUILD" ; then
TCL_VERSIONS_DOT="tcl8.6 tcl8.5 tcl8.4 tcl8.3"
TCL_VERSIONS_NODOT="`echo ${TCL_VERSIONS_DOT} | ${SED} 's/\.//g'`"
TCL_VERSIONS="${TCL_VERSIONS_DOT} ${TCL_VERSIONS_NODOT} tcl"
  AC_SEARCH_LIBS([Tcl_Eval],[$alpine_TCLLIB ${TCL_VERSIONS}],,
    [
      WEB_BUILD=
    ])

  dnl look for header file
  if test -n "$alpine_TCLINC" ; then
    AC_CHECK_HEADER($alpine_TCLINC/tcl.h,,
      [
	WEB_BUILD=
      ])
    if test -z "$WEB_BUILD" ; then
      AC_MSG_NOTICE([Tcl Include file NOT found])
    fi
  else
    AC_CHECK_HEADER(tcl.h,,
      [
	for base in /usr /usr/local ; do
	 for dir in ${TCL_VERSIONS} ; do
	  AC_CHECK_FILE([$base/include/$dir/tcl.h],
	    [
	      found=yes
	    ])
	  if test "$found" = "yes" ; then
	    CPPFLAGS="$CPPFLAGS -I$base/include/$dir"
	    break
	  fi
	 done
	 if test "$found" = "yes" ; then
	    break
	 fi
	done
	if test "$found" != "yes" ; then
	    WEB_BUILD=
	    AC_MSG_NOTICE([header file tcl.h NOT found: Web Alpine will not be built])
	fi
      ])
  fi
fi

dnl Local or supplied regex?
if test "x$alpine_REGEX" != "xyes" ; then
  AC_SEARCH_LIBS([regcomp],posix regexp regex re,,
    [
      if test x$alpine_REGEX = "xno" ; then
        AC_MSG_ERROR(Unable to find system regex library)
      else
	alpine_REGEX=yes
      fi
    ])
fi
if test "x$alpine_REGEX" != "xyes" ; then
  AC_CHECK_HEADER([regex.h],,
    [
      if test x$alpine_REGEX = "xno" ; then
	AC_MSG_ERROR(Unable to find system regex include file)
      else
	alpine_REGEX=yes
      fi
    ])
fi
AC_DEFINE(HAVE_REGEX_H,1,[Regular expression header file exists])
if test "x$alpine_REGEX" = "xyes" ; then
  CPPFLAGS="$CPPFLAGS -I${top_builddir}/regex"
  LDFLAGS="$LDFLAGS -L${top_builddir}/regex"
  REGEX_BUILD=regex
  REGEX_MAKEFILE="$REGEX_BUILD/Makefile"
fi

if test "x$with_pthread" != "xno" ; then
  AC_MSG_CHECKING([for pthread support])
  ACX_PTHREAD(
    [
      AC_MSG_RESULT([yes])
      case "$target" in
	  *openbsd*)
	    AC_MSG_NOTICE([WARNING: pthread support on OpenBSD is unstable!])
	    AM_CFLAGS="$AM_CFLAGS -pthread"
	    ;;
      esac
      LIBS="$PTHREAD_LIBS $LIBS"
      AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
      CC="$PTHREAD_CC"
      AC_DEFINE([HAVE_PTHREAD], [1], [System has pthread support])
    ],
    [
      AC_MSG_RESULT([no])
    ])

  AC_SEARCH_LIBS([nanosleep], [rt posix4],
    [
      AC_DEFINE([HAVE_NANOSLEEP], [1], [Define if system supports subsecond, non-alarm sleep])
    ])
fi



dnl CHECK HEADERS

AC_HEADER_STDC
AC_HEADER_DIRENT
AC_HEADER_STAT
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
AC_HEADER_TIOCGWINSZ

AC_CHECK_HEADERS([unistd.h])

AC_CHECK_HEADERS([errno.h \
		  ctype.h \
		  fcntl.h \
		  signal.h \
		  setjmp.h \
		  memory.h \
		  sys/param.h \
		  sys/socket.h \
		  sys/uio.h \
		  sys/un.h \
		  limits.h \
		  wchar.h \
		  sys/poll.h \
		  stropts.h \
		  netdb.h \
		  syslog.h \
		  sys/syslog.h \
		  locale.h \
		  langinfo.h \
		  utime.h \
		  sys/utime.h \
		  pthread.h \
		  pwd.h \
		  assert.h])

dnl terminal line discipline?
AC_CHECK_HEADER([termios.h],
  AC_DEFINE(HAS_TERMIOS, [1], [Define if systems uses termios terminal control]),
  [
    AC_CHECK_HEADER([termio.h],
      AC_DEFINE(HAS_TERMIO, [1], [Define if systems uses termio terminal control]),
      [
        AC_CHECK_HEADER([sgtty.h],
	  AC_DEFINE(HAS_SGTTY, [1], [Define if systems uses old BSD-style terminal control]),
	[
	  AC_MSG_ERROR(Unable to figure out terminal control method)
	])
      ])
  ])


dnl CHECK TYPEDEFS

AC_DIAGNOSE([obsolete],[your code may safely assume C89 semantics that RETSIGTYPE is void.
Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])dnl
AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([#include <sys/types.h>
#include <signal.h>
],
		 [return *(signal (0, 0)) (0) == 1;])],
		   [ac_cv_type_signal=int],
		   [ac_cv_type_signal=void])])
AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type of signal handlers
		    (`int' or `void').])

AC_TYPE_SIZE_T
AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_UID_T
AC_STRUCT_TM

AC_CHECK_TYPES([union wait])

AC_CHECK_HEADERS([stdint.h], [uint16=uint16_t], [
  AC_CHECK_HEADERS([inttypes.h], [uint16=uint16_t], [
    AC_CHECK_HEADERS([sys/types.h], [uint16=u_int16_t], [
      AC_CHECK_SIZEOF(unsigned short)
      if test $ac_cv_sizeof_unsigned_short -eq 2 ; then
	uint16="unsigned short"
      else
	AC_CHECK_SIZEOF(unsigned int)
	if $ac_cv_sizeof_unsigned_int -eq 2 ; then
	  uint16="unsigned int"
	else
	  AC_MSG_ERROR(Unable to determine 16 bit integer type)
        fi
      fi
    ])
  ])
])
AC_DEFINE_UNQUOTED([UINT16], $uint16, [System defined unsigned 16 bit integer])

AC_CHECK_HEADERS([stdint.h], [uint32=uint32_t], [
  AC_CHECK_HEADERS([inttypes.h], [uint32=uint32_t], [
    AC_CHECK_HEADERS([sys/types.h], [uint32=u_int32_t], [
      AC_CHECK_SIZEOF(unsigned int)
      if test $ac_cv_sizeof_unsigned_int -eq 4 ; then
	uint32="unsigned int"
      else
	AC_CHECK_SIZEOF(unsigned long)
	if $ac_cv_sizeof_unsigned_long -eq 4 ; then
	  uint32="unsigned long"
	else
	  AC_MSG_ERROR(Unable to determine 32 bit integer type)
        fi
      fi
    ])
  ])
])
AC_DEFINE_UNQUOTED([UINT32], $uint32, [System defined unsigned 32 bit integer])

AC_CACHE_CHECK(argument pointer type of qsort compare function and base,
ac_cv_func_qsort_argtype,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if	HAVE_STDLIB_H
#include "stdlib.h"
#endif

extern void *base;
extern sortf(const void *, const void *);
int sortf(a, b)
  const void *a;
  const void *b; { return 0; }
]], [[
qsort(base, 2, sizeof(char *), sortf);
]])],[ac_cv_func_qsort_argtype=void],[ac_cv_func_qsort_argtype=char])
])
AC_DEFINE_UNQUOTED([qsort_t], $ac_cv_func_qsort_argtype, [qsort compare function argument type])

dnl check for "struct passwd" ?

AC_FUNC_SELECT_ARGTYPES

AC_FUNC_STRCOLL

dnl CHECK FOR LIBRARY FUNCTIONS

AC_FUNC_FORK
AC_CHECK_FUNCS([strchr \
		memcpy \
		strtol \
		strtoul \
		select \
		poll \
		qsort \
	 	getuid \
		getpwuid \
		getpwnam \
	        gettimeofday \
		tmpfile \
		uname \
		rename \
		read \
		signal \
		setjmp \
		chown \
		wait4 \
		waitpid \
		wait \
		srandom \
		popen \
		pclose \
		fsync \
		truncate \
		listen \
		wcwidth \
		mbstowcs \
		wcrtomb \
		putenv \
		setenv])

AC_SEARCH_LIBS([gethostname],[nsl])

AC_SEARCH_LIBS([socket],[socket],,
  [
    WEB_BUILD=
  ])

AC_SEARCH_LIBS([bind],[bind],,
  [
    WEB_BUILD=
  ])

dnl check for POSIX signal interface
AC_CHECK_FUNCS([sigaction sigemptyset sigaddset sigprocmask],
  [
    AC_DEFINE([POSIX_SIGNALS], [], [Define if system supports POSIX signal interface])
  ],
  [
    AC_CHECK_FUNCS([sigset sigrelse],
      [
	AC_DEFINE([SYSV_SIGNALS], [], [Define if system supports SYSV signal interface])
      ])
  ])

AC_SEARCH_LIBS([syslog], [bsd socket inet],
  [
    AC_DEFINE([HAVE_SYSLOG], [1], [Define if system supplies syslog() logging])
  ])


dnl set pico newmail check directory
if test -n "$alpine_with_local_maildir" ; then
    alpine_local_maildir=$alpine_with_local_maildir
elif test -d /var/spool/mail ; then
    alpine_local_maildir="/var/spool/mail"
elif test -d /var/mail ; then
    alpine_local_maildir="/var/mail"
else
    alpine_local_maildir="/usr/spool/mail"
fi

dnl set c-client make target
if test -n "$alpine_with_c_client_target" ; then
    alpine_c_client_target=$alpine_with_c_client_target
fi

AC_DEFINE_UNQUOTED([SYSTYPE], "$systype", [Pine-Centric Host Specifier])
AC_DEFINE_UNQUOTED([C_FILESEP],'$alpine_path_delim',[File name separator as character constant])
AC_DEFINE_UNQUOTED([S_FILESEP],"$alpine_path_delim",[File name separator as string constant])
AC_DEFINE_UNQUOTED([MAILDIR],"$alpine_local_maildir",[Path to local inboxes for pico newmail check])
AC_DEFINE_UNQUOTED([MODE_READONLY], $alpine_mode_readonly, [File mode used to set readonly access])

dnl c-client make particulars
AC_SUBST([C_CLIENT_TARGET], $alpine_c_client_target)
AC_SUBST([C_CLIENT_WITH_IPV6], $c_client_ip6)
if test "x$alpine_SSLTYPE" = "xnone" ; then 
  AC_MSG_NOTICE([* * *  NOT Including SSL Support])
  c_client_specials="${c_client_specials}SSLTYPE=none "
else
  dnl issue any warnings for common OpenSSL issues

  if test -n "$alpine_SSLCERTS" -a -d "$alpine_SSLCERTS" ; then
    certdir="$alpine_SSLCERTS"
  elif test -n "$alpine_SSLDIR" -a -d "${alpine_SSLDIR}/certs" ; then
    certdir="${alpine_SSLDIR}/certs"
  elif test -n "$alpine_SSLDIR" -a -d "${alpine_SSLDIR}/ssl/certs" ; then
    certdir="${alpine_SSLDIR}/ssl/certs"
  elif test -n "$alpine_SSLCERTS_ORIG" -a -d "$alpine_SSLCERTS_ORIG" ; then
    certdir="$alpine_SSLCERTS_ORIG"
  else
    AC_MSG_NOTICE([SSL Problem: certificate directory not found])
  fi

  if test "x$with_smime" != "xno" ; then
    if test -n "$certdir" ; then
      AC_MSG_NOTICE([* * * S/MIME support enabled])
      AC_DEFINE([SMIME], [], [Enable S/MIME code])
      AC_DEFINE_UNQUOTED([SMIME_SSLCERTS],"$certdir",[Directory where S/MIME CACerts are located])
    fi
  fi

  if test ! -f ${certdir}/factory.pem ; then
    AC_MSG_NOTICE([* * * SSL file "${certdir}/factory.pem" is missing.])
    AC_MSG_NOTICE([* * *   This might indicate that CA certs did not get properly])
    AC_MSG_NOTICE([* * *   installed.  If you get certificate validation failures])
    AC_MSG_NOTICE([* * *   in Alpine, this might be the reason for them.])
  fi

  if test -z "`ls ${certdir} | $EGREP '^@<:@0-9A-Fa-f@:>@{8}\.@<:@0-9@:>@'`" ; then
    AC_MSG_NOTICE([* * * No 8-hexdigit symlinks in certificate directory "${certdir}".])
    AC_MSG_NOTICE([* * *   This might indicate that CA certs did not get properly])
    AC_MSG_NOTICE([* * *   installed.  If you get certificate validation failures])
    AC_MSG_NOTICE([* * *   in Alpine, this might be the reason for them.])
  fi

  if test -n "$alpine_SSLINCLUDE" ; then
    c_client_specials="${c_client_specials}SSLINCLUDE=$alpine_SSLINCLUDE "
  fi

  if test -n "$alpine_SSLLIB" ; then
    c_client_specials="${c_client_specials}SSLLIB=$alpine_SSLLIB "
  fi

  if test -n "$alpine_SSLDIR" ; then
    c_client_specials="${c_client_specials}SSLDIR=$alpine_SSLDIR "
  fi

  if test -n "$certdir" ; then
    c_client_specials="${c_client_specials}SSLCERTS=$certdir "
  fi

  if test -n "$alpine_SSLKEYS" ; then
      c_client_specials="${c_client_specials}SSLKEYS=$alpine_SSLKEYS "
  fi
fi

if test "x$alpine_GSSTYPE" != "xnone" ; then
  c_client_specials="${c_client_specials}EXTRAAUTHENTICATORS=gss "
  AC_MSG_NOTICE([* * * Including Kerberos5 functionality])
fi

if test -n "$CPPFLAGS" ; then
  alpine_c_client_cflags="$alpine_c_client_cflags ${CPPFLAGS}"
fi
if test -n "$CFLAGS" ; then
  alpine_c_client_cflags="$alpine_c_client_cflags ${CFLAGS}"
fi

if test -n "$alpine_c_client_cflags" ; then
  AC_SUBST(C_CLIENT_CFLAGS, EXTRACFLAGS=\"$alpine_c_client_cflags\")
fi

if test -n "$LDFLAGS" ; then
  alpine_c_client_ldflags="$alpine_c_client_ldflags ${LDFLAGS}"
fi
if test -n "$LIBS" ; then
  alpine_c_client_ldflags="$alpine_c_client_ldflags ${LIBS}"
fi

if test -n "$alpine_c_client_ldflags" ; then
  AC_SUBST(C_CLIENT_LDFLAGS, EXTRALDFLAGS=\"$alpine_c_client_ldflags\")
fi

if test -n "$alpine_c_client_gccoptlevel" ; then
  AC_SUBST(C_CLIENT_GCCOPTLEVEL, GCCOPTLEVEL=\"$alpine_c_client_gccoptlevel\")
fi

AC_SUBST([C_CLIENT_SPECIALS], $c_client_specials)

dnl Deal with Web Alpine
if test -z "$WEB_BUILD" ; then
  WEB_PUBCOOKIE_BUILD=
  AC_MSG_NOTICE([* * * TCL libraries could not be found.])
  AC_MSG_NOTICE([* * * WEB ALPINE COMPONENT WILL NOT BE BUILT.])
else
  if test -n "$WEB_PUBCOOKIE_BUILD" ; then
    if test "x$alpine_GSSTYPE" = "xnone" ; then
      WEB_PUBCOOKIE_BUILD=
      AC_MSG_NOTICE([* * * Kerberos5 support not found.])
      AC_MSG_NOTICE([* * * WEB ALPINE PUBCOOKIE COMPONENT WILL NOT BE BUILT.])
    elif test -z "$WEB_BINDIR" ; then
      WEB_PUBCOOKIE_BUILD=
      AC_MSG_NOTICE([* * * Web Alpine binary directory not provided.])
	AC_MSG_ERROR([* * * --with-pubcookie requires --with-web-bin=PATH.
        Please re-run configure with these options:
        --with-pubcookie --with-web-bin=/usr/local/libexec/alpine/bin])
    else
      AC_DEFINE([PUBCOOKIE],[1],[Include support for UW Pubcookie Web Authentication])
      WEB_PUBCOOKIE_LIB=../pubcookie/libauthgssproxy.a
      WEB_PUBCOOKIE_LINK=gssapi_proxy.l
    fi
  fi
fi

AC_SUBST([REGEX_BUILD])

AC_SUBST([WEB_BUILD])
AC_SUBST([WEB_BINDIR])
AC_SUBST([WEB_PUBCOOKIE_BUILD])
AC_SUBST([WEB_PUBCOOKIE_LIB])
AC_SUBST([WEB_PUBCOOKIE_LINK])

AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_LDFLAGS])

AC_CONFIG_FILES([m4/Makefile po/Makefile.in $REGEX_MAKEFILE \
	  pith/osdep/Makefile pith/charconv/Makefile pith/Makefile \
	  pico/osdep/Makefile pico/Makefile \
	  alpine/osdep/Makefile alpine/Makefile \
	  web/src/Makefile web/src/pubcookie/Makefile \
	  web/src/alpined.d/Makefile \
	  Makefile])
AC_OUTPUT