File: configure.ac

package info (click to toggle)
hercules 3.07-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 14,572 kB
  • ctags: 18,225
  • sloc: ansic: 162,921; sh: 8,522; makefile: 781; perl: 202; sed: 16
file content (1868 lines) | stat: -rw-r--r-- 67,364 bytes parent folder | download | duplicates (3)
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
###############################################################################
# CONFIGURE.AC: Process this file with AutoConf to produce a configure script.
###############################################################################

# $Id: configure.ac 5657 2010-03-07 12:22:25Z jmaynard $

#    AC is AutoConfigure, AM is AutoMake, and AH is AutoHeader. The
#    'HC_XXXX..' macros are custom Hercules autoconf macros defined
#    in the 'hercules.m4' file in the 'autoconf' subdirectory.

AC_INIT(hercules.h)                     # (package, version, bugreport email, etc)
AC_REVISION($Revision: 5657 $)          # (the version of this configure.ac)
AC_CONFIG_AUX_DIR(autoconf)             # (directory containing auxillary build tools)
AM_INIT_AUTOMAKE(hercules,3.07)         # (the version of our software package)
AM_CONFIG_HEADER(config.h)              # (the file the resulting configure script will produce)
AM_MAINTAINER_MODE()
AC_CANONICAL_HOST()                     # (sets $host_cpu, $host_vendor, and $host_os)

###############################################################################
#   Programs section...
###############################################################################

#HC_PROG_CC()                           #    ((( DEPRECATED )))
#
# CFLAGS *MUST* BE SET 1ST - BEFORE CALL AC_PROG_CC OTHERWISE AUTOCONF TRIES TO IMPOSE
#        ITS OWN CHOICES...
# FIXME :
#        Unfortunatelly, these are gcc flags.. so going to have
#        to find something better...
#
CFLAGS="$CFLAGS -W -Wall"

AC_PROG_CC()                            # (back to using this again)

# -----------------------------------------------------------------------------
#  PROGRAMMING NOTE: The below 'AC_SUBST' macro causes AC_OUTPUT to replace
#  all instances of "@xxxxxx@" in input files with the value that the shell
#  variable "xxxxxx" has when AC_OUTPUT is called. Thus, the variable name
#  used ("modexecdir" in our case) *is* significant and cannot be changed
#  unless you change the "@modexecdir@" strings in all of the input files.
# -----------------------------------------------------------------------------

modexecdir=${libdir}/${PACKAGE}
AC_SUBST(modexecdir)


LT_INIT([dlopen win32-dll disable-static])
LTDL_INIT([])
AC_SUBST([LIBTOOL_DEPS])                # (see PROGRAMMING NOTE above)


# -----------------------------------------------------------------------------
# (See comments in the 'AC_CHECK_LIB' Libraries section further below)
# -----------------------------------------------------------------------------
AC_MSG_NOTICE( [(use of lt_dlopen forced by Hercules Dynamic Loader requirement)] )
hc_cv_have_lt_dlopen=yes



AM_GNU_GETTEXT([external])              #
AM_ICONV

HC_LD_DISALLOWDUPS()                    # (add duplicate symbols option to LDFLAGS)

# -----------------------------------------------------------------------------
#  The following is a "global error" flag used to defer aborting configure
#  until after ALL errors have been detected/reported.
# -----------------------------------------------------------------------------

hc_error=no

###############################################################################
#   Autoheader templates
###############################################################################

#  All AC_DEFINE() macros used within autoconf (to define pre-processor vars
#  used during the actual build process) must have corresponding AH_TEMPLATE
#  statements coded somewhere. We place them all here simply for convenience.

AH_TEMPLATE( [CUSTOM_BUILD_STRING],     [Define to provide additional information about this build] )
AH_TEMPLATE( [MAX_CPU_ENGINES],         [Defines the maximum number of emulated CPU engines] )
AH_TEMPLATE( [PKGDATADIR],              [Directory where the HTTP server will find documents] )
AH_TEMPLATE( [HERC_LOCALEDIR],          [Directory where to find NLS data] )
AH_TEMPLATE( [MODULESDIR],              [Directory where HERCULES modules are installed] )
AH_TEMPLATE( [DEBUG],                   [Define to enable extra debugging code (TRACE/VERIFY/ASSERT macros)] )

AH_TEMPLATE( [C99_FLEXIBLE_ARRAYS],     [Define if your gcc properly supports C99 flexible arrays] )

AH_TEMPLATE( [HAVE_ATTR_REGPARM],       [Define if your gcc properly supports __attribute__((regparm(n)))] )
AH_TEMPLATE( [NO_ASM_BYTESWAP],         [Define to disable assembler routines for byte swapping] )
AH_TEMPLATE( [NO_IEEE_SUPPORT],         [Define to disable IEEE floating point support] )
AH_TEMPLATE( [NO_SETUID],               [Define to disable setuid operation] )
AH_TEMPLATE( [NO_SIGABEND_HANDLER],     [Define to disable sigabend_handler (please describe this better)] )
AH_TEMPLATE( [NON_UNIQUE_GETTIMEOFDAY], [Define if 'gettimeofday' returns non-unique values] )

AH_TEMPLATE( [NEED_GETOPT_WRAPPER],     [Define to indicate a wrapper for getopt is needed] )
AH_TEMPLATE( [NEED_GETOPT_OPTRESET],    [Define to indicate optreset exists] )

AH_TEMPLATE( [HAVE_INTTYPES_H],         [Define if inttypes.h header file is present on your system] )
AH_TEMPLATE( [HAVE_U_INT],              [Define if your system uses u_int8_t, etc, instead of uint8_t] )

AH_TEMPLATE( [OPTION_CONFIG_SYMBOLS],   [Define to enable symbolic substitutions in configuration file] )
AH_TEMPLATE( [OPTION_ENHANCED_CONFIG_SYMBOLS], [Define to enable enhanced-mode symbolic substitutions in configuration file] )
AH_TEMPLATE( [OPTION_ENHANCED_CONFIG_INCLUDE], [Define to enable enhanced-mode 'include' file support in configuration file] )
AH_TEMPLATE( [OPTION_HAO],              [Define to enable Hercules Automatic Operator feature] )
AH_TEMPLATE( [OPTION_DYNAMIC_LOAD],     [Define to enable Hercules Dynamic Loader feature] )
AH_TEMPLATE( [HDL_BUILD_SHARED],        [Define to indicate shared libraries are being used] )
AH_TEMPLATE( [HDL_USE_LIBTOOL],         [Define to cause dynamic loader to use libtool instead of dlopen] )

AH_TEMPLATE( [BUILD_HERCIFC],           [Define if hercifc program is to be built] )

AH_TEMPLATE( [WIN32],                   [Define when building under Win32 (MinGW or Cygwin)] )
AH_TEMPLATE( [EXTERNALGUI],             [Define to build interface to external Windows GUI] )
AH_TEMPLATE( [OPTION_FTHREADS],         [Define to use included threads implementation (fthreads)] )
AH_TEMPLATE( [FISH_HANG],               [Define to debug correct fthreads LOCK handling (requires fthreads)] )

AH_TEMPLATE( [TIMESPEC_IN_TIME_H],      [Define if 'struct timespec' defined in <time.h>] )
AH_TEMPLATE( [TIMESPEC_IN_SYS_TYPES_H], [Define if 'struct timespec' defined in <sys/types.h>] )

AH_TEMPLATE( [_BSD_SOCKLEN_T_],         [Define missing macro on apple darwin (osx) platform] )
AH_TEMPLATE( [_INTL_REDIRECT_MACROS],   [Define to 1 if non-Intel architecture (gettext)] )

AH_TEMPLATE( [CCKD_BZIP2],              [Define to enable bzip2 compression in emulated DASDs] )
AH_TEMPLATE( [HET_BZIP2],               [Define to enable bzip2 compression in emulated tapes] )
AH_TEMPLATE( [OPTION_CAPABILITIES],     [Define to enable posix draft 1003.1e capabilities] )

###############################################################################
#   OS-specific settings that we can't figure out any other way (yet)
###############################################################################

#
#  Determine what type of host we're building on...
#

case "$host_os" in

    linux*)

        hc_cv_is_nix=yes
        hc_cv_is_windows=no
        hc_cv_is_mingw32=no
        hc_cv_is_apple=no
        ;;

    mingw*)

        hc_cv_is_nix=no
        hc_cv_is_windows=yes
        hc_cv_is_mingw32=yes
        hc_cv_is_apple=no
        ;;

    cygwin*)

        hc_cv_is_nix=no
        hc_cv_is_windows=yes
        hc_cv_is_mingw32=no
        hc_cv_is_apple=no
        ;;

    darwin*)

        if test $host_vendor = apple; then

            hc_cv_is_nix=no
            hc_cv_is_windows=no
            hc_cv_is_mingw32=no
            hc_cv_is_apple=yes

        else

            hc_cv_is_nix=no
            hc_cv_is_windows=no
            hc_cv_is_mingw32=no
            hc_cv_is_apple=no

        fi
        ;;

    *bsd*)
        hc_cv_is_nix=yes
        hc_cv_is_windows=no
        hc_cv_is_mingw32=no
        hc_cv_is_apple=no
        ;;

    *)
        hc_cv_is_nix=no
        hc_cv_is_windows=no
        hc_cv_is_mingw32=no
        hc_cv_is_apple=no
        ;;
esac

#------------------------------------------------------#
#  Hard-coded host-operating-system-specific settings  #
#  that we have no other/easy way to figure out...     #
#------------------------------------------------------#

if test "$hc_cv_is_nix"        = "yes"; then

    hc_cv_build_hercifc=yes
    hc_cv_non_unique_gettimeofday=no

elif test "$hc_cv_is_windows"  = "yes"; then

    hc_cv_build_hercifc=no
    hc_cv_non_unique_gettimeofday=yes

elif test "$hc_cv_is_apple"    = "yes"; then

    hc_cv_build_hercifc=yes
    hc_cv_non_unique_gettimeofday=no

else
    hc_cv_build_hercifc=no
    hc_cv_non_unique_gettimeofday=no
fi

###############################################################################
#   Checks for REQUIRED (non-optional) header files...
###############################################################################

#  PROGRAMMING NOTE: We use 'AC_CHECK_HEADER' here (singular) since we don't
#  care whether 'HAVE_XXX' gets #defined or not since, because these are re-
#  quired headers, if any of them are not found, we abort and thus we don't
#  need to have any 'HAVE_XXX' pre-processor #defined entered into config.h
#  (because we can't build Herc at all if any of them don't happen to exist)

AC_CHECK_HEADER( ctype.h,      [], [ AC_MSG_RESULT( [ERROR: Required header 'ctype.h' not found]      ); hc_error=yes ] )
AC_CHECK_HEADER( errno.h,      [], [ AC_MSG_RESULT( [ERROR: Required header 'errno.h' not found]      ); hc_error=yes ] )
AC_CHECK_HEADER( fcntl.h,      [], [ AC_MSG_RESULT( [ERROR: Required header 'fcntl.h' not found]      ); hc_error=yes ] )
AC_CHECK_HEADER( limits.h,     [], [ AC_MSG_RESULT( [ERROR: Required header 'limits.h' not found]     ); hc_error=yes ] )
AC_CHECK_HEADER( setjmp.h,     [], [ AC_MSG_RESULT( [ERROR: Required header 'setjmp.h' not found]     ); hc_error=yes ] )
AC_CHECK_HEADER( stdarg.h,     [], [ AC_MSG_RESULT( [ERROR: Required header 'stdarg.h' not found]     ); hc_error=yes ] )
AC_CHECK_HEADER( stdio.h,      [], [ AC_MSG_RESULT( [ERROR: Required header 'stdio.h' not found]      ); hc_error=yes ] )
AC_CHECK_HEADER( stdlib.h,     [], [ AC_MSG_RESULT( [ERROR: Required header 'stdlib.h' not found]     ); hc_error=yes ] )
AC_CHECK_HEADER( string.h,     [], [ AC_MSG_RESULT( [ERROR: Required header 'string.h' not found]     ); hc_error=yes ] )
AC_CHECK_HEADER( time.h,       [], [ AC_MSG_RESULT( [ERROR: Required header 'time.h' not found]       ); hc_error=yes ] )
AC_CHECK_HEADER( unistd.h,     [], [ AC_MSG_RESULT( [ERROR: Required header 'unistd.h' not found]     ); hc_error=yes ] )
AC_CHECK_HEADER( sys/stat.h,   [], [ AC_MSG_RESULT( [ERROR: Required header 'sys/stat.h' not found]   ); hc_error=yes ] )
AC_CHECK_HEADER( sys/time.h,   [], [ AC_MSG_RESULT( [ERROR: Required header 'sys/time.h' not found]   ); hc_error=yes ] )
AC_CHECK_HEADER( sys/types.h,  [], [ AC_MSG_RESULT( [ERROR: Required header 'sys/types.h' not found]  ); hc_error=yes ] )

#  PROGRAMMING NOTE: the pthread.h header only required if this is not
#  an fthreads build. Thus we delay aborting until later once we know
#  (if this is a windows build; otherwise we abort right away)

AC_CHECK_HEADER( pthread.h, [hc_cv_have_pthread_h=yes],
    [
        if test "$hc_cv_is_windows" = "yes"; then

            hc_cv_alt_pthread_location=/usr/Pthreads

            AC_MSG_NOTICE( [looking for pthread.h in ${hc_cv_alt_pthread_location}] )

            hc_temp=$CFLAGS
            CFLAGS="$CFLAGS -I${hc_cv_alt_pthread_location}"

            AC_CHECK_HEADER( pthread.h,
                [hc_cv_have_pthread_h=yes],
                [hc_cv_have_pthread_h=no]
            )

            CFLAGS=$hc_temp

        else
            AC_MSG_RESULT( [ERROR: Required header 'pthread.h' not found] )
            hc_error=yes
        fi
    ]
)

AC_CACHE_SAVE()

###############################################################################
#   Checks for optional (non-required) header files...
###############################################################################

#  PROGRAMMING NOTE: We use 'AC_CHECK_HEADERS' here (plural) to cause autoconf
#  to automatically add a #define/#undef 'HAVE_XXX' statement into config.h to
#  let us know whether the header exists on this system or not (since, because
#  these are optional headers, we are still able to successfully build Herc if
#  they don't happen to exist). The 'hc_cv_have_xxx' variables are only defined
#  in case other parts of configure.ac need to  know whether the header exists
#  or not without having to do their own AC_CHECK_HEADERS (since we've already
#  done it).

#------------------------------------------------------------------------------
#  PROGRAMMING NOTE: on Darwin sys/socket.h must be included before
#  net/if.h, net/route.h, or netinet/in.h can be #included, and on OS X 10.3
#  (but not 10.4) sys/types.h must be #included before sys/socket.h. Thus
#  the below four header checks are treated specially. If we ever drop support
#  for OS X 10.3, a lot of this cruft can be removed, not just here but
#  anywhere we find ourselves manually including sys/types.h.

#  PROGRAMMING NOTE: on *BSD sys/socket.h must be included before net/if.h,
#  net/route.h, or netinet/in.h can be #included.

AC_CHECK_HEADERS( sys/socket.h,   [hc_cv_have_sys_socket_h=yes],   [hc_cv_have_sys_socket_h=no],
[
    #include <sys/types.h>
]   )
AC_CHECK_HEADERS( net/if.h,       [hc_cv_have_net_if_h=yes],       [hc_cv_have_net_if_h=no],
[
    #include <sys/types.h>
    #if HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
] )
AC_CHECK_HEADERS( netinet/in.h,   [hc_cv_have_netinet_in_h=yes],   [hc_cv_have_netinet_in_h=no],
[
    #include <sys/types.h>
    #if HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
] )
AC_CHECK_HEADERS( netinet/tcp.h,  [hc_cv_have_netinet_tcp_h=yes],  [hc_cv_have_netinet_tcp_h=no],
[
    #include <sys/types.h>
    #if HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
] )
AC_CHECK_HEADERS( net/route.h,    [hc_cv_have_net_route_h=yes],    [hc_cv_have_net_route_h=no],
[
    #include <sys/types.h>
    #if HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
] )
#------------------------------------------------------------------------------

AC_CHECK_HEADERS( arpa/inet.h,    [hc_cv_have_arpa_inet_h=yes],    [hc_cv_have_arpa_inet_h=no]    )
AC_CHECK_HEADERS( linux/if_tun.h, [hc_cv_have_linux_if_tun_h=yes], [hc_cv_have_linux_if_tun_h=no] )
AC_CHECK_HEADERS( sys/ioctl.h,    [hc_cv_have_sys_ioctl_h=yes],    [hc_cv_have_sys_ioctl_h=no]    )
AC_CHECK_HEADERS( sys/mman.h,     [hc_cv_have_sys_mman_h=yes],     [hc_cv_have_sys_mman_h=no]     )

#------------------------------------------------------------------------------
#  PROGRAMMING NOTE: on *BSD systems sys/param.h must be #included before 
#  sys/mount.h as it contains the #define of NGROUPS.

AC_CHECK_HEADERS( sys/param.h,    [hc_cv_have_sys_param_h=yes],    [hc_cv_have_sys_param_h=no]    )
AC_CHECK_HEADERS( sys/mount.h,    [hc_cv_have_sys_mount_h=yes],    [hc_cv_have_sys_mount_h=no],
[
    #if HAVE_SYS_PARAM_H
    #include <sys/param.h>
    #endif
] )
#------------------------------------------------------------------------------

AC_CHECK_HEADERS( sys/mtio.h,     [hc_cv_have_sys_mtio_h=yes],     [hc_cv_have_sys_mtio_h=no]     )
AC_CHECK_HEADERS( sys/resource.h, [hc_cv_have_sys_resource_h=yes], [hc_cv_have_sys_resource_h=no] )
AC_CHECK_HEADERS( sys/uio.h,      [hc_cv_have_sys_uio_h=yes],      [hc_cv_have_sys_uio_h=no]      )
AC_CHECK_HEADERS( sys/utsname.h,  [hc_cv_have_sys_utsname_h=yes],  [hc_cv_have_sys_utsname_h=no]  )
AC_CHECK_HEADERS( sys/wait.h,     [hc_cv_have_sys_wait_h=yes],     [hc_cv_have_sys_wait_h=no]     )
AC_CHECK_HEADERS( sys/un.h,       [hc_cv_have_sys_un_h=yes],       [hc_cv_have_sys_un_h=no]       )
AC_CHECK_HEADERS( byteswap.h,     [hc_cv_have_byteswap_h=yes],     [hc_cv_have_byteswap_h=no]     )
AC_CHECK_HEADERS( bzlib.h,        [hc_cv_have_bzlib_h=yes],        [hc_cv_have_bzlib_h=no]        )
AC_CHECK_HEADERS( dlfcn.h,        [hc_cv_have_dlfcn_h=yes],        [hc_cv_have_dlfcn_h=no]        )
AC_CHECK_HEADERS( fenv.h,         [hc_cv_have_fenv_h=yes],         [hc_cv_have_fenv_h=no]         )
AC_CHECK_HEADERS( inttypes.h,     [hc_cv_have_inttypes_h=yes],     [hc_cv_have_inttypes_h=no]     )
AC_CHECK_HEADERS( iconv.h,        [hc_cv_have_iconv_h=yes],        [hc_cv_have_iconv_h=no]        )
AC_CHECK_HEADERS( libintl.h,      [hc_cv_have_libintl_h=yes],      [hc_cv_have_libintl_h=no]      )
AC_CHECK_HEADERS( locale.h,       [hc_cv_have_locale_h=yes],       [hc_cv_have_locale_h=no]       )
AC_CHECK_HEADERS( ltdl.h,         [hc_cv_have_ltdl_h=yes],         [hc_cv_have_ltdl_h=no]         )
AC_CHECK_HEADERS( malloc.h,       [hc_cv_have_malloc_h=yes],       [hc_cv_have_malloc_h=no]       )
AC_CHECK_HEADERS( math.h,         [hc_cv_have_math_h=yes],         [hc_cv_have_math_h=no]         )
AC_CHECK_HEADERS( netdb.h,        [hc_cv_have_netdb_h=yes],        [hc_cv_have_netdb_h=no]        )
AC_CHECK_HEADERS( pwd.h,          [hc_cv_have_pwd_h=yes],          [hc_cv_have_pwd_h=no]          )
AC_CHECK_HEADERS( regex.h,        [hc_cv_have_regex_h=yes],        [hc_cv_have_regex_h=no]        )
AC_CHECK_HEADERS( sched.h,        [hc_cv_have_sched_h=yes],        [hc_cv_have_sched_h=no]        )
AC_CHECK_HEADERS( signal.h,       [hc_cv_have_signal_h=yes],       [hc_cv_have_signal_h=no]       )
AC_CHECK_HEADERS( termios.h,      [hc_cv_have_termios_h=yes],      [hc_cv_have_termios_h=no]      )
AC_CHECK_HEADERS( time.h,         [hc_cv_have_time_h=yes],         [hc_cv_have_time_h=no]         )
AC_CHECK_HEADERS( zlib.h,         [hc_cv_have_zlib_h=yes],         [hc_cv_have_zlib_h=no]         )
AC_CHECK_HEADERS( sys/capability.h, [hc_cv_have_sys_capa_h=yes],   [hc_cv_have_sys_capa_h=no]     )
AC_CHECK_HEADERS( sys/prctl.h,    [hc_cv_have_sys_prctl_h=yes],    [hc_cv_have_sys_prctl_h=no]    )

AC_CACHE_SAVE()

###############################################################################
#   Checks for declarations...
###############################################################################

#  PROGRAMMING NOTE: For declaration checks, you need to be careful to use the
#  following test in your program:
#
#      #if defined(HAVE_DECL_XXXX) && !HAVE_DECL_XXXXX
#      ...code to handle not declared case...
#      #endif
#
#  This is because UNLIKE other 'AC_CHECK' macros, when a SYMBOL isn't DECLared,
#  "HAVE_DECL_XXXX" is #defined to '0' instead of leaving "HAVE_DECL_XXXX" #undefined.
#  (e.g. #defined to 1 if you have the declaration and #defined to 0 if you don't)

AC_CHECK_DECLS( SIGUSR1,              [hc_cv_have_sigusr1=yes],             [hc_cv_have_sigusr1=no],             [#include <signal.h>] )
AC_CHECK_DECLS( SIGUSR2,              [hc_cv_have_sigusr2=yes],             [hc_cv_have_sigusr2=no],             [#include <signal.h>] )
AC_CHECK_DECLS( SIGPIPE,              [hc_cv_have_sigpipe=yes],             [hc_cv_have_sigpipe=no],             [#include <signal.h>] )
AC_CHECK_DECLS( SIGBUS,               [hc_cv_have_sigbus=yes],              [hc_cv_have_sigbus=no],              [#include <signal.h>] )
AC_CHECK_DECLS( IFNAMSIZ,             [hc_cv_have_ifnamsiz=yes],            [hc_cv_have_ifnamsiz=no],
[
    #include <sys/types.h>
    #if HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
] )
AC_CHECK_DECLS( LOGIN_NAME_MAX,       [hc_cv_have_login_name_max=yes],      [hc_cv_have_login_name_max=no],      [#include <limits.h>] )
AC_CHECK_DECLS( _SC_NPROCESSORS_CONF, [hc_cv_have_sc_nprocessors_conf=yes], [hc_cv_have_sc_nprocessors_conf=no], [#include <unistd.h>] )
AC_CHECK_DECLS( _SC_NPROCESSORS_ONLN, [hc_cv_have_sc_nprocessors_onln=yes], [hc_cv_have_sc_nprocessors_onln=no], [#include <unistd.h>] )

AC_CHECK_DECLS( SIOCSIFNETMASK,       [hc_cv_have_siocsifnetmask=yes],      [hc_cv_have_siocsifnetmask=no],      [#include <linux/sockios.h>] )
AC_CHECK_DECLS( SIOCSIFHWADDR,        [hc_cv_have_siocsifhwaddr=yes],       [hc_cv_have_siocsifhwaddr=no],       [#include <linux/sockios.h>] )
AC_CHECK_DECLS( SIOCADDRT,            [hc_cv_have_siocaddrt=yes],           [hc_cv_have_siocaddrt=no],           [#include <linux/sockios.h>] )
AC_CHECK_DECLS( SIOCDELRT,            [hc_cv_have_siocdelrt=yes],           [hc_cv_have_siocdelrt=no],           [#include <linux/sockios.h>] )
AC_CHECK_DECLS( SIOCDIFADDR,          [hc_cv_have_siocdifaddr=yes],         [hc_cv_have_siocdifaddr=no],         [#include <linux/sockios.h>] )

if test "$hc_cv_have_sys_mtio_h" == "yes"; then
    AC_CHECK_DECLS( MTEWARN,          [hc_cv_have_mtewarn=yes],             [hc_cv_have_mtewarn=no],             [#include <sys/mtio.h>] )
else
    hc_cv_have_mtewarn=no
fi

AC_CACHE_SAVE()

###############################################################################
#   Checks for types...
###############################################################################

AC_CHECK_TYPES( u_int8_t,   [hc_cv_have_u_int8_t=yes],   [hc_cv_have_u_int8_t=no]                              )
AC_CHECK_TYPES( useconds_t, [hc_cv_have_useconds_t=yes], [hc_cv_have_useconds_t=no]                            )
AC_CHECK_TYPES( id_t,       [hc_cv_have_id_t=yes],       [hc_cv_have_id_t=no]                                  )
AC_CHECK_TYPES( u_char,     [hc_cv_have_u_char=yes],     [hc_cv_have_u_char=no],
[
    #include <sys/types.h>
    #if HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
] )
AC_CHECK_TYPES( u_short,    [hc_cv_have_u_short=yes],    [hc_cv_have_u_short=no],
[
    #include <sys/types.h>
    #if HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
] )
AC_CHECK_TYPES( u_int,      [hc_cv_have_u_int=yes],      [hc_cv_have_u_int=no],
[
    #include <sys/types.h>
    #if HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
] )
AC_CHECK_TYPES( u_long,     [hc_cv_have_u_long=yes],     [hc_cv_have_u_long=no],
[
    #include <sys/types.h>
    #if HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
] )
AC_CHECK_TYPES( in_addr_t,  [hc_cv_have_in_addr_t=yes],  [hc_cv_have_in_addr_t=no],
[
    #include <sys/types.h>
    #if HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
    #if HAVE_NETINET_IN_H
    #include <netinet/in.h>
    #endif
] )
AC_CHECK_TYPES( socklen_t,  [hc_cv_have_socklen_t=yes],  [hc_cv_have_socklen_t=no],
[
    #include <sys/types.h>
    #if HAVE_SYS_SOCKET_H
    #include <sys/socket.h>
    #endif
] )

AC_CACHE_SAVE()

###############################################################################
#   Checks for libraries...
###############################################################################

#  PROGRAMMING NOTE: we require libtool (or, optionally, dlltool (a less power-
#  ful (flexible) libtool-like tool for Windows platforms) in order to support
#  OPTION_DYNAMIC_LOAD. This is a relatively safe requirement since we provide
#  a version of libtool with Hercules (and build it as part of the preliminary
#  autoconf processing; see the 'Programs' section above). However, we need to
#  keep the below check for 'dlopen' anyway since we prefer that libtool use it
#  instead of its own equivalent (lt_dlopen) if it's available.

AC_CHECK_LIB( msvcrt, _pipe          )
AC_CHECK_LIB( dl,     dlopen         )
AC_CHECK_LIB( m,      sqrt           )
AC_CHECK_LIB( socket, connect        )
AC_CHECK_LIB( nsl,    gethostbyname  )
AC_CHECK_LIB( resolv, inet_aton      )
AC_CHECK_LIB( z,      uncompress     )
AC_CHECK_LIB( bz2,    BZ2_bzBuffToBuffDecompress,
            [ hc_cv_have_libbz2=yes ],
            [ hc_cv_have_libbz2=no  ] )
AC_CHECK_LIB( iconv,  iconv          )
# jbs 10/15/2003 Solaris requires -lrt for sched_yield() and fdatasync()
AC_CHECK_LIB( rt,     sched_yield    )
# rbowler 2008/03/10 rev 1.196 Solaris 2.9 requires -lpthread
AC_CHECK_LIB( pthread,pthread_create )

AC_CACHE_SAVE()

###############################################################################
#   Checks for library functions...
###############################################################################
#   PROGRAMMING NOTE: AC_CHECK_LIB should be called first for the below
#   library function checks to ensure the library where the function is
#   defined gets added to the LIBS library search variable...
###############################################################################

AC_CHECK_FUNCS( iconv )
AC_CHECK_FUNCS( memrchr )
AC_CHECK_FUNCS( getopt_long )
AC_CHECK_FUNCS( sqrtl ldexpl fabsl fmodl frexpl )
AC_CHECK_FUNCS( ldexpf frexpf fabsf rint )
AC_CHECK_FUNCS( strlcpy strlcat )
AC_CHECK_FUNCS( strerror_r )
AC_CHECK_FUNCS( strsignal, [hc_cv_have_strsignal=yes], [hc_cv_have_strsignal=no] )
AC_CHECK_FUNCS( sys_siglist )
AC_CHECK_FUNCS( InitializeCriticalSectionAndSpinCount )
AC_CHECK_FUNCS( sleep usleep nanosleep )
AC_CHECK_FUNCS( sched_yield )
AC_CHECK_FUNCS( strtok_r )
AC_CHECK_FUNCS( pipe )
AC_CHECK_FUNCS( gettimeofday )
AC_CHECK_FUNCS( getpgrp )
AC_CHECK_FUNCS( scandir alphasort )
AC_CHECK_FUNCS( getlogin getlogin_r )
AC_CHECK_FUNCS( realpath )
AC_CHECK_FUNCS( fdatasync fsync ftruncate )
AC_CHECK_FUNCS( inet_aton )
AC_CHECK_FUNCS( fork socketpair )
AC_CHECK_FUNCS( sysconf )

AC_CHECK_FUNCS( vsscanf,
               [hc_cv_have_vsscanf=yes],
               [hc_cv_have_vsscanf=no]
)

AC_CHECK_FUNCS( setresuid getresuid,
               [hc_cv_have_getset_uid=yes],
               [hc_cv_have_getset_uid=no; break]
)

if test "$hc_cv_have_getset_uid" != "yes"; then
    AC_CHECK_FUNCS( setreuid geteuid getuid,
                    [hc_cv_have_getset_uid=yes],
                    [hc_cv_have_getset_uid=no; break]
    )
fi


#  FIXME: Disabled because some builtin ffs seem to be causing a problem.
#         (gcc 3.4 barfs on certain 'march=' settings?)
#AC_CHECK_FUNCS( ffs )


# For OS X 10.6 autoconf defines HAVE_FDATASYNC even though there is
# no function prototype declared for fdatasync() and unistd.h contains
# define _POSIX_SYNCHRONIZED_IO (-1) which indicates that fdatasync is
# not supported. So to decide whether fdatasync really can be used, we
# create a new symbol HAVE_FDATASYNC_SUPPORTED which is defined only if
# HAVE_FDATASYNC is defined and _POSIX_SYNCHRONIZED_IO is not negative.

AC_CACHE_CHECK([whether fdatasync is supported],[ac_cv_func_fdatasync_supported],[
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <unistd.h>
    ]],[[
#if !defined(HAVE_FDATASYNC)
#error fdatasync is not defined on this platform
#endif
#if defined(_POSIX_SYNCHRONIZED_IO) && (_POSIX_SYNCHRONIZED_IO+0 < 0)
#error fdatasync is not supported on this platform
#endif
    ]])],
    [ac_cv_func_fdatasync_supported=yes],
    [ac_cv_func_fdatasync_supported=no])
])
AS_IF([test "x${ac_cv_func_fdatasync_supported}" = "xyes"],
    [AC_DEFINE([HAVE_FDATASYNC_SUPPORTED],[1],[Define to 1 if the fdatasync function is supported.])])


AC_CACHE_SAVE()

###############################################################################
#   Checks for structures and structure members...
###############################################################################

AC_CHECK_MEMBERS( [struct sockaddr_in.sin_len],
                  [hc_cv_have_sockaddr_in_sin_len=yes ],
                  [hc_cv_have_sockaddr_in_sin_len=no  ],
[
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
] )

AC_CHECK_MEMBERS( [struct in_addr.s_addr],
                  [hc_cv_have_in_addr_s_addr=yes  ],
                  [hc_cv_have_in_addr_s_addr=no   ],
[
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
] )

AC_CHECK_MEMBERS( [struct sigaction.sa_sigaction],
                  [hc_cv_have_sa_sigaction=yes  ],
                  [hc_cv_have_sa_sigaction=no   ],
                  [#include <signal.h>          ] )

AC_CHECK_MEMBERS( [struct timespec.tv_nsec],
    [
        hc_cv_timespec_in_sys_types_h=yes
        hc_cv_timespec_in_time_h=no
    ],
    [
        AC_CHECK_MEMBERS( [struct timespec.tv_nsec],
            [
                hc_cv_timespec_in_sys_types_h=no
                hc_cv_timespec_in_time_h=yes
            ],
            [
                hc_cv_timespec_in_sys_types_h=no
                hc_cv_timespec_in_time_h=no
            ],
            [#include <time.h>]
        )
    ],
    [#include <sys/types.h>]
)

AC_CACHE_SAVE()

###############################################################################
#   Checks for compiler characteristics...
###############################################################################

AC_C_BIGENDIAN()

#  PROGRAMMING NOTE: Okay, this is stupid. If there are any trailing spaces
#  following the type we're checking the size of, then they're converted to
#  underscores in the 'SIZEOF_XXXX' that gets #defined! For example, doing a
#  AC_CHECK_SIZEOF( int    ) yields: #define SIZEOF_INT____ 4  !!!!!!!!!!!!!
#  So... the below AC_CHECK_SIZEOF macros must NOT have any spaces in them!!

AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(int *)
AC_CHECK_SIZEOF(off_t)

#----------------------------------#
#  Structure alignment/size test   #
#----------------------------------#

AC_MSG_NOTICE( [begin check: whether byte structs are aligned/rounded by default...] )

cat > conftest.h << __EOF
#include <stdio.h>
struct bytestruct
{
    unsigned char a;
};
__EOF

AC_CHECK_SIZEOF( struct bytestruct, [], [#include "conftest.h"] )

if test "$ac_cv_sizeof_struct_bytestruct" = "1"; then

    hc_cv_byte_structs_aligned_and_rounded_by_default=no
    hc_cv_byte_structs_always_aligned_and_rounded=no

else

    #  The sizeof our test structure is not '1'.
    #  The compiler is rounding the size of the
    #  structure upward to some predefined value.

    hc_cv_byte_structs_aligned_and_rounded_by_default=yes

    #  If there's no way to request the compiler
    #  to not do that, then we can't build Herc.

    case "$host_cpu-$GCC" in

        arm*-yes|xscale*-yes|sh*-yes|pxa*-yes)

            hc_cv_byte_structs_always_aligned_and_rounded=no
            ;;

        *)
            hc_cv_byte_structs_always_aligned_and_rounded=yes
            ;;
    esac
fi

AC_MSG_NOTICE( [results: byte structs are aligned/rounded by default... ${hc_cv_byte_structs_aligned_and_rounded_by_default}] )

if test "$hc_cv_byte_structs_always_aligned_and_rounded" = "yes"; then

    AC_MSG_RESULT( [ERROR: Size of structures are aligned/rounded and we don't know how to tell the compiler otherwise] )
    hc_error=yes
fi

#------------------------------#
#  Check if this is GCC 2.96   #
#------------------------------#

AC_CACHE_CHECK( [if this is the broken 2.96 version of GCC],

    [hc_cv_is_gcc_2_96],
    [
        if test "$GCC" = "yes"; then

            AC_COMPILE_IFELSE(
                [
                    #if __GNUC__ == 2 && __GNUC_MINOR__ == 96
                      yes;
                    #else
                      int no;
                    #endif
                ],
                [hc_cv_is_gcc_2_96=no],
                [hc_cv_is_gcc_2_96=yes]
            )

        else
            hc_cv_is_gcc_2_96=no
        fi
    ]
)

#----------------------------------------------#
#  Check C99 if flexible arrays are supported  #
#----------------------------------------------#
#  The logic to test whether C99 flexible      #
#  arrays are supported is defined in the      #
#  'HC_C99_FLEXIBLE_ARRAYS' macro in the       #
#  'hercules.m4' file in the 'autoconf' sub-   #
#   directory, and issues the AC_DEFINE for    #
#  'C99_FLEXIBLE_ARRAYS' if it's supported     #
#  and also sets '$hc_cv_c99_flexible_array'.  #
#----------------------------------------------#

HC_C99_FLEXIBLE_ARRAYS()

#--------------------------------------------------------#
#  Check if GCC supports '__attribute__ ((regparm(n)))'  #
#--------------------------------------------------------#

#  Note: even though at the moment GCC only supports regparm
#  on i386 or greater machines, that could change at any time
#  in the future so we don't bother checking for it.

if test "$GCC" = "yes"; then

    AC_CACHE_CHECK( [whether '__attribute__ ((regparm(n)))' is supported],

        [hc_cv_regparm_attr_supported],
        [
            hc_temp="$CFLAGS"
            CFLAGS="-Wall -Werror"

            AC_COMPILE_IFELSE(
                [
                    void conftest() __attribute__ ((regparm(1)));
                ],
                [hc_cv_regparm_attr_supported=yes],
                [hc_cv_regparm_attr_supported=no]
            )

            CFLAGS="$hc_temp"
        ]
    )
else
    hc_cv_regparm_attr_supported=no
fi

#---------------------------------------------------#
#  Test for GCC '__attribute__ ((regparm(3)))' bug  #
#---------------------------------------------------#

if test "$GCC"                          = "yes"  &&
   test "$hc_cv_regparm_attr_supported" = "yes"; then

    AC_CACHE_CHECK( [whether '__attribute__ ((regparm(3)))' is broken],

        [hc_cv_regparm_attr_broke],
        [
            hc_temp="$CFLAGS"
            CFLAGS="-O3 -fomit-frame-pointer"

            AC_TRY_RUN(
                [
                    /*
                        Fish: Test for reparms bug caused by alloca bug# 8750
                        Ref: <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8750>
                    */
                    struct REGS
                    {
                        int a, b, c, d;
                        char e[50000];
                    };
                    typedef struct REGS REGS;

                    #define ATTR_REGPARM __attribute__ (( regparm(3) ))

                    int func1 ( int a, int b, int c, REGS *regs ) ATTR_REGPARM;
                    int func2 ( int a, int b, int c, REGS *regs ) ATTR_REGPARM;

                    REGS global_regs;

                    int main()
                    {
                        return func1( 1, 2, 3, &global_regs );
                    }

                    int ATTR_REGPARM func1 ( int a, int b, int c, REGS *regs )
                    {
                        REGS stack_regs;
                        regs=regs; /* (quiet compiler warning) */
                        if ( func2( a, b, c, &stack_regs ) == 0 ) return 0; /* pass */
                        return 1; /* fail */
                    }

                    int ATTR_REGPARM func2 ( int a, int b, int c, REGS *regs )
                    {
                        regs=regs; /* (quiet compiler warning) */
                        if ( 1==a && 2==b && 3==c ) return 0; /* pass */
                        return 1; /* fail */
                    }
                ],
                [hc_cv_regparm_attr_broke=no],
                [hc_cv_regparm_attr_broke=yes],
                [hc_cv_regparm_attr_broke=yes]
            )

            CFLAGS="$hc_temp"
        ]
    )
else
    hc_cv_regparm_attr_broke=no
fi

#------------------------------------------------------#
#  Test for GCC builtin alloca bug# 8750               #
#  <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8750>  #
#------------------------------------------------------#

if test "$GCC" = "yes"; then

    AC_CACHE_CHECK( [whether '__builtin_alloca' is broken],

        [hc_cv_builtin_alloca_broke],
        [
            hc_temp=$CFLAGS
            CFLAGS="-g -O2 -fomit-frame-pointer"

            AC_TRY_RUN(
                [
                    /*
                        Fish: Test for gcc builtin alloca bug# 8750
                        <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8750>

                        Required(?!) (not sure) compiler options:

                            -g -O2 -fomit-frame-pointer
                    */

                    int foo ()
                    {
                        char a[50000+16];
                        memset(a,0xCD,50000);
                        a[50000]=0;
                        return strlen(a);
                    }

                    int main()
                    {
                        return ( foo() != 50000 );
                    }
                ],
                [hc_cv_builtin_alloca_broke=no],
                [hc_cv_builtin_alloca_broke=yes],
                [hc_cv_builtin_alloca_broke=yes]
            )

            CFLAGS=$hc_temp
        ]
    )
else
    hc_cv_builtin_alloca_broke=no
fi

#------------------------------------------------------------#
#  Check for OS X gcc preprocessor macro argument count bug  #
#------------------------------------------------------------#

if test "$GCC" = "yes"; then

    AC_CACHE_CHECK( [whether preprocessor macro argument counting broken],

        [hc_cv_pp_macro_arg_counting_broke],
        [
            hc_temp="$CFLAGS"
            CFLAGS="-Wall -Werror"

            AC_COMPILE_IFELSE(
                [
                    #include <stdio.h>
                    #define MACRO(_x,_args...) printf(_x, ## _args)
                    int  main( int argc, char **argv, char **arge )
                    {
                        MACRO( "bare printf\n" );
                        return 0;
                    }
                ],
                [hc_cv_pp_macro_arg_counting_broke=no],
                [hc_cv_pp_macro_arg_counting_broke=yes]
            )

            CFLAGS="$hc_temp"
        ]
    )
else
    hc_cv_pp_macro_arg_counting_broke=no
fi

#------------------------------------------------------------#
#  Check if traditional preprocessor is the K&R C type...    #
#------------------------------------------------------------#
#
# Apple's latest GCC documentation reveals:
#
#     ... the -traditional-cpp option has changed.
#    In Apple GCC 3.1 and earlier Apple GCC compilers,
#    -traditional-cpp was used to toggle between the
#    standard GNU GCC preprocessor and Apple's own 
#    preprocessor, "cpp-precomp". The GNU GCC compiler
#    interpreted -traditional-cpp differently on all
#    other platforms. Since cpp-precomp has been removed
#    for Apple's GCC 3.3 compiler, the standard GNU
#    meaning of -traditional-cpp has been restored. By
#    default, the GCC 3.3 preprocessor conforms to the
#    ISO C standard. Using the -tradtional-cpp option
#    means the C preprocessor should instead try to
#    emulate the old "K&R C".
#
#------------------------------------------------------------#

if test "$GCC" = "yes"; then

    AC_CACHE_CHECK( [whether '-traditional-cpp' is K&R C preprocessor],

        [hc_cv_traditional_cpp_is_K_AND_R_C_type],
        [
            hc_temp="$CFLAGS"
            CFLAGS="-Wall -Werror -traditional-cpp"

# Note: The test program MUST start in column 1! Otherwise, the compilation
# will fail when it's not supposed to.
            AC_COMPILE_IFELSE(
                [
/* If the following gets an error, then the
   "traditional" preprocessor is K&R C type.
   Otherwise if it compiles WITHOUT error
   the the "traditional" preprocessor is NOT
   the K&R C type.
*/
#if 1
  #include <stdio.h>  // comment/etc...
#endif
int main( int, char**, char** )
{
  return 0;
}
                ],
                [hc_cv_traditional_cpp_is_K_AND_R_C_type=no],
                [hc_cv_traditional_cpp_is_K_AND_R_C_type=yes]
            )

            CFLAGS="$hc_temp"
        ]
    )
else
    hc_cv_traditional_cpp_is_K_AND_R_C_type=no
fi

#-----------------------------------------------------------#
#  Check whether byte-swapping can be done using assembler  #
#-----------------------------------------------------------#

AC_MSG_CHECKING( [whether byte-swapping can be done using assembler] )

# (use our own byteswap assembler routines are i486+ only)
# use system's byteswap routines if present...

case "$host_cpu" in

    i486|i586|i686|i786|x86_64)

        hc_cv_asm_byteswap=yes
        ;;
    *)
        hc_cv_asm_byteswap=$hc_cv_have_byteswap_h
        ;;
esac

AC_MSG_RESULT( [$hc_cv_asm_byteswap] )

#----------------------------------------------#
#  Check whether -pthread needed for pthreads  #
#----------------------------------------------#

AC_MSG_CHECKING( [whether ${CC-cc} accepts -pthread] )

echo 'void f(){}' >conftest.c
if test -z "`${CC-cc} -pthread -c conftest.c 2>&1`"; then
    hc_cv_dash_pthread_needed=yes
else
    hc_cv_dash_pthread_needed=no
fi

AC_MSG_RESULT( [$hc_cv_dash_pthread_needed] )

#------------------------------------------------------------------
#  The logic to test whether optreset is needed for getopt use is
#  defined in the 'HC_CHECK_NEED_GETOPT_OPTRESET' macro in the
#  'hercules.m4' file in the autoconf directory, and issues the
#  AC_DEFINE for 'NEED_GETOPT_OPTRESET' if it's needed (and also
#  sets the '$hc_cv_need_getopt_optreset' variable appropriately).
#------------------------------------------------------------------

HC_CHECK_NEED_GETOPT_OPTRESET()

AC_CACHE_SAVE()

###############################################################################
#   Checks for system services...
###############################################################################

AC_SYS_LARGEFILE()
AC_TYPE_OFF_T()
AC_FUNC_FSEEKO()

AC_CACHE_SAVE()

###############################################################################
#   AC_CONFIG_FILES( [file...] )...
###############################################################################

AC_CACHE_SAVE()

###############################################################################
#   Set flags according to user-specified --enable-xxxxx build options
###############################################################################

#  PROGRAMMING NOTE: some of these values default to previously determined
#  values (e.g. cckd-bzip2 for example defaults to whether libbz2 exists),
#  so this section MUST [unfortunately] come AFTER the above sections. This
#  does have the unfortunate side effect of not detecting invalid options
#  right away like one would normally expect/want. The only way around that
#  would be to perform two checks (one at the beginning and then one again
#  later on), but that approach was rejected since it would tend to make our
#  configure.ac script less clean (simple and straightforward).

AC_ARG_ENABLE( dynamic-load,

    AC_HELP_STRING([--disable-dynamic-load],

        [disable dynamic loader option]
    ),
    [
        case "${enableval}" in
        yes) hc_cv_opt_dynamic_load=yes                      ;;
        no)  hc_cv_opt_dynamic_load=no                       ;;
        *)   AC_MSG_RESULT( [ERROR: invalid 'dynamic-load' option] )
             hc_error=yes
             ;;
        esac
    ],
    [hc_cv_opt_dynamic_load=yes]
)

AC_ARG_ENABLE( cckd-bzip2,

    AC_HELP_STRING( [--enable-cckd-bzip2],

        [enable bzip2 compression for emulated dasd]
    ),
    [
        case "${enableval}" in
        yes) hc_cv_opt_cckd_bzip2=yes                      ;;
        no)  hc_cv_opt_cckd_bzip2=no                       ;;
        *)   AC_MSG_RESULT( [ERROR: invalid 'cckd-bzip2' option] )
             hc_error=yes
             ;;
        esac
    ],
    [hc_cv_opt_cckd_bzip2=$hc_cv_have_libbz2]
)

AC_ARG_ENABLE( het-bzip2,

    AC_HELP_STRING( [--enable-het-bzip2],

        [enable bzip2 compression for emulated tapes]
    ),
    [
        case "${enableval}" in
        yes) hc_cv_opt_het_bzip2=yes                      ;;
        no)  hc_cv_opt_het_bzip2=no                       ;;
        *)   AC_MSG_RESULT( [ERROR: invalid 'het-bzip2' option] )
             hc_error=yes
             ;;
        esac
    ],
    [hc_cv_opt_het_bzip2=$hc_cv_have_libbz2]
)

AC_ARG_ENABLE( debug,

    AC_HELP_STRING( [--enable-debug],

        [enable debugging (TRACE/VERIFY/ASSERT macros)]
    ),
    [
        case "${enableval}" in
        yes) hc_cv_opt_debug=yes                      ;;
        no)  hc_cv_opt_debug=no                       ;;
        *)   AC_MSG_RESULT( [ERROR: invalid 'debug' option] )
             hc_error=yes
             ;;
        esac
    ],
    [hc_cv_opt_debug=no]
)

AC_ARG_ENABLE( optimization,

    AC_HELP_STRING( [--enable-optimization=yes|no|FLAGS],

        [enable automatic optimization, or specify flags]
    ),
    [
        hc_cv_opt_optimization=${enableval}
    ],
    [hc_cv_opt_optimization=yes]
)

AC_ARG_ENABLE( configsymbols,

    AC_HELP_STRING( [--disable-configsymbols],

        [disable symbolic substitutions in configuration file]
    ),
    [
        case "${enableval}" in
        yes) hc_cv_opt_configsymbols=yes                      ;;
        no)  hc_cv_opt_configsymbols=no                       ;;
        *)   AC_MSG_RESULT( [ERROR: invalid 'configsymbols' option] )
             hc_error=yes
             ;;
        esac
    ],
    [hc_cv_opt_configsymbols=yes]
)

AC_ARG_ENABLE( enhanced-configsymbols,

    AC_HELP_STRING( [--disable-enhanced-configsymbols],

        [disable enhanced-mode symbolic substitutions in configuration file]
    ),
    [
        case "${enableval}" in
        yes) hc_cv_opt_enhanced_configsymbols=yes                      ;;
        no)  hc_cv_opt_enhanced_configsymbols=no                       ;;
        *)   AC_MSG_RESULT( [ERROR: invalid 'enhanced-configsymbols' option] )
             hc_error=yes
             ;;
        esac
    ],
    [hc_cv_opt_enhanced_configsymbols=yes]
)

AC_ARG_ENABLE( enhanced-configincludes,

    AC_HELP_STRING( [--disable-enhanced-configincludes],

        [disable enhanced-mode 'include' file support in configuration file]
    ),
    [
        case "${enableval}" in
        yes) hc_cv_opt_enhanced_configincludes=yes                      ;;
        no)  hc_cv_opt_enhanced_configincludes=no                       ;;
        *)   AC_MSG_RESULT( [ERROR: invalid 'enhanced-configincludes' option] )
             hc_error=yes
             ;;
        esac
    ],
    [hc_cv_opt_enhanced_configincludes=yes]
)

AC_ARG_ENABLE( automatic-operator,

    AC_HELP_STRING( [--disable-automatic-operator],

        [disable Hercules Automatic Operator feature]
    ),
    [
        case "${enableval}" in
        yes) hc_cv_opt_auto_oper=yes                      ;;
        no)  hc_cv_opt_auto_oper=no                       ;;
        *)   AC_MSG_RESULT( [ERROR: invalid 'automatic-operator' option] )
             hc_error=yes
             ;;
        esac
    ],
    [hc_cv_opt_auto_oper=$hc_cv_have_regex_h]
)

AC_ARG_ENABLE( external-gui,

    AC_HELP_STRING( [--disable-external-gui],

        [disable external Windows GUI interface]
    ),
    [
        case "${enableval}" in
        yes) hc_cv_opt_external_gui=yes                      ;;
        no)  hc_cv_opt_external_gui=no                       ;;
        *)   AC_MSG_RESULT( [ERROR: invalid 'external-gui' option] )
             hc_error=yes
             ;;
        esac
    ],
    [hc_cv_opt_external_gui=$hc_cv_is_windows]
)

AC_ARG_ENABLE( fthreads,

    AC_HELP_STRING( [--disable-fthreads],

        [disable use of fish threads instead of posix threads]
    ),
    [
        case "${enableval}" in
        yes) hc_cv_opt_fthreads=yes                      ;;
        no)  hc_cv_opt_fthreads=no                       ;;
        *)   AC_MSG_RESULT( [ERROR: invalid 'fthreads' option] )
             hc_error=yes
             ;;
        esac
    ],
    [hc_cv_opt_fthreads=$hc_cv_is_windows]
)

AC_ARG_ENABLE( fishhang,

    AC_HELP_STRING( [--enable-fishhang],

        [debug correct lock handling (fthreads only)]
    ),
    [
        case "${enableval}" in
        yes) hc_cv_opt_fishhang=yes                      ;;
        no)  hc_cv_opt_fishhang=no                       ;;
        *)   AC_MSG_RESULT( [ERROR: invalid 'fishhang' option] )
             hc_error=yes
             ;;
        esac
    ],
    [hc_cv_opt_fishhang=no]
)

AC_ARG_ENABLE( multi-cpu,

    AC_HELP_STRING( [--enable-multi-cpu=yes|no|NUMBER],

        [enable/disable multi-cpu support (1-64, default 8)]
    ),
    [
        case "${enableval}" in
        yes)             hc_cv_opt_num_cpu_engines=8                  ;;
        no)              hc_cv_opt_num_cpu_engines=1                  ;;
        *)
            if test 0 -lt "${enableval}" -a 64 -ge "${enableval}"
            then
                hc_cv_opt_num_cpu_engines=${enableval}
            else
                AC_MSG_RESULT( [ERROR: invalid 'multi-cpu' option] )
                hc_error=yes
            fi
            ;;
        esac
    ],
    [hc_cv_opt_num_cpu_engines=8]
)

AC_ARG_ENABLE( capabilities,

    AC_HELP_STRING([--disable-capabilities],

        [disable fine grained privileges]
    ),
    [
        case "${enableval}" in
        yes) hc_cv_opt_capabilities=yes                      ;;
        no)  hc_cv_opt_capabilities=no                       ;;
        *)   AC_MSG_RESULT( [ERROR: invalid 'capabilities' option] )
             hc_error=yes
             ;;
        esac
    ],
    [hc_cv_opt_capabilities=hc_cv_have_sys_capability]
)

# only include libcap if needed
if test "$hc_cv_opt_capabilities" = "yes"; then
    AC_CHECK_LIB(cap,cap_set_proc)
fi
# Force disable capabilities support if library is missing
if test "$ac_cv_lib_cap_cap_set_proc" = "no"; then
  hc_cv_opt_capabilities="no"
fi
# Force disable capabilities support if sys/capability.h header is missing
if test "$hc_cv_have_sys_capa_h" = "no"; then
  hc_cv_opt_capabilities="no"
fi
# Force disable capabilities support if sys/prctl.h header is missing
if test "$hc_cv_have_sys_prctl_h" = "no"; then
  hc_cv_opt_capabilities="no"
fi

AC_ARG_ENABLE( custom,

    AC_HELP_STRING( [--enable-custom=STRING],

        [provide a custom description for this build]
    ),
    [
        hc_cv_opt_custom_build_str=${enableval}
    ]
)

if test "$hc_cv_build_hercifc" = "yes"; then

    AC_ARG_ENABLE( setuid-hercifc,

        AC_HELP_STRING( [--enable-setuid-hercifc=yes|no|GROUPNAME],

            [install hercifc as setuid root, and allow execution by users in group GROUPNAME]
        ),
        [
            case "${enableval}" in
            yes) hc_cv_opt_setuid_hercifc=yes                      ;;
            no)  hc_cv_opt_setuid_hercifc=no                       ;;
            *)   hc_cv_opt_setuid_hercifc=yes
                 hc_cv_hercifc_groupname=${enableval}
                 ;;
            esac
        ],
        [hc_cv_opt_setuid_hercifc=no]
    )

    hc_cv_setuid_hercifc=$hc_cv_opt_setuid_hercifc

else
    hc_cv_setuid_hercifc=no
fi

#-----------------------------------------------------------------
#  The handling of AC_ARG_ENABLE for "--enable-getoptwrapper"
#  is defined within the 'HC_ARG_ENABLE_GETOPTWRAPPER' macro
#  coded in the 'hercules.m4' file in the autoconf directory
#  and issues the AC_DEFINE for NEED_GETOPT_WRAPPER if needed
#  (and sets the '$hc_cv_need_getopt_wrapper' variable too).
#-----------------------------------------------------------------

HC_ARG_ENABLE_GETOPTWRAPPER()

#----------------------------------------------------------------
#  Note: '$enable_shared' is automatically set by LIBTOOL,
#        unless the user overrides it via --disable-shared.
#----------------------------------------------------------------
hc_cv_hdl_build_shared=$enable_shared

AC_CACHE_SAVE()

###############################################################################
#   Final default settings, final sanity / error checks...
###############################################################################

if test "$hc_cv_build_hercifc" = "yes"; then

   if test "$hc_cv_have_linux_if_tun_h" != "yes"; then

      if test "$hc_cv_have_net_if_h" != "yes"; then
      
         AC_MSG_RESULT( [ERROR: Required headers 'linux/if_tun.h' or 'net/if.h' not found] )
         hc_error=yes
      fi
   fi

   if test "$hc_cv_have_net_route_h" != "yes"; then

      AC_MSG_RESULT( [ERROR: Required header 'net/route_h' not found] )
      hc_error=yes
   fi
fi

#------------------------------------------------------------------------------
#  signal.h is only required if strsignal function isn't available since if
#  the strsignal function isn't available, we use our builtin which needs it.
#  The presumption that if the strsignal function is found, then the signal.h
#  header will also be found seems to be a fairly safe assumption to make IMO.

if test "$hc_cv_have_strsignal" != "yes"  &&
   test "$hc_cv_have_signal_h"  != "yes"; then

   AC_MSG_RESULT( [ERROR: Required header 'signal.h' not found] )
   hc_error=yes
fi

#------------------------------------------------------------------------------

if test "$hc_cv_have_vsscanf" != "yes"; then

    AC_MSG_RESULT( [ERROR: Required function 'vsscanf' not found] )
    hc_error=yes
fi

#------------------------------------------------------------------------------

if test "$hc_cv_have_inttypes_h" != "yes"  &&
   test "$hc_cv_have_u_int8_t"   != "yes"; then

   AC_MSG_RESULT( [ERROR: unable to find fixed-size data types] )
   hc_error=yes
fi

#------------------------------------------------------------------------------

if test "$hc_cv_opt_cckd_bzip2" = "yes"  ||
   test "$hc_cv_opt_het_bzip2"  = "yes"; then

   if test "$hc_cv_have_libbz2" != "yes"; then

      AC_MSG_RESULT( [ERROR: bzip2 compression requested but libbz2 library not found] )
      hc_error=yes
   fi

   if test "$hc_cv_have_bzlib_h" != "yes"; then

      AC_MSG_RESULT( [ERROR: bzip2 compression requested but 'bzlib.h' header not found] )
      hc_error=yes
   fi
fi

#------------------------------------------------------------------------------

if test "$hc_cv_opt_dynamic_load" = "yes"; then

   if test "$hc_cv_have_lt_dlopen" != "yes"  &&
      test "$hc_cv_have_dlopen"    != "yes"; then

      AC_MSG_RESULT( [ERROR: dynamic-load requires libtool or dlltool] )
      hc_error=yes
   fi
fi

#------------------------------------------------------------------------------

if test "$hc_cv_opt_auto_oper" = "yes"  &&
   test "$hc_cv_have_regex_h" != "yes"; then

   AC_MSG_RESULT( [ERROR: automatic-operator requested but 'regex.h' header not found] )
   hc_error=yes
fi

#------------------------------------------------------------------------------

if test "$hc_cv_opt_external_gui"  = "yes"  &&
   test "$hc_cv_opt_dynamic_load" != "yes"; then

   AC_MSG_RESULT( [ERROR: external-gui requires dynamic-load] )
   hc_error=yes
fi

#------------------------------------------------------------------------------

if test "$hc_cv_opt_fthreads" = "yes"  &&
   test "$hc_cv_is_windows"  != "yes"; then

   AC_MSG_RESULT( [ERROR: fthreads is only for Windows platforms] )
   hc_error=yes
fi

if test "$hc_cv_have_pthread_h" != "yes"  &&
   test "$hc_cv_opt_fthreads"   != "yes"; then

   AC_MSG_RESULT( [ERROR: unable to find pthread.h] )
   hc_error=yes
fi

#------------------------------------------------------------------------------

if test "$hc_cv_opt_fishhang"  = "yes"  &&
   test "$hc_cv_opt_fthreads" != "yes"; then

   AC_MSG_RESULT( [ERROR: fishhang requires fthreads] )
   hc_error=yes
fi

#------------------------------------------------------------------------------

if test "$hc_cv_is_apple"                          = "yes"  &&
   test "$hc_cv_pp_macro_arg_counting_broke"       = "yes"  &&
   test "$hc_cv_traditional_cpp_is_K_AND_R_C_type" = "yes"; then

    AC_MSG_RESULT( [ERROR: macro argument counting broken and cannot use -traditional-cpp option to work around it] )
    hc_error=yes
fi

#------------------------------------------------------------------------------
# If any errors have been detected, then abort the configure at this time
#------------------------------------------------------------------------------

if test "$hc_error" != "no"; then
    AC_MSG_ERROR( [Please correct the above error(s) and try again] )
fi

AC_CACHE_SAVE()

###############################################################################
#   Act on the results of all of the above...
###############################################################################

#        AUTOMATIC DETERMINATION OF OPTIMIZATION FLAGS
#
#  If they specified 'no' then don't optimize.
#  If they specified 'yes' then determine what flags we should use.
#  If they didn't specify, then optimize only if this is NOT a debug build.
#  Otherwise use whatever flags they specified as-is.

AC_MSG_CHECKING( [for what optimization flags to use] )

case "$hc_cv_opt_optimization" in

    no)

        hc_cv_auto_optimize=no
        ;;

    yes)

        hc_cv_auto_optimize=yes
        ;;

    *)
        if test "x$hc_cv_opt_optimization" = "x"; then

            if test "$hc_cv_opt_debug" = "yes"; then

                hc_cv_auto_optimize=no
            else
                hc_cv_auto_optimize=yes
            fi

        else

            hc_cv_auto_optimize=no
            hc_cv_optimization_flags="$hc_cv_opt_optimization"
        fi
        ;;
esac

if test "$hc_cv_auto_optimize" = "yes"; then

    if test "$hc_cv_builtin_alloca_broke" != "yes"  &&
       test "$hc_cv_opt_debug"            != "yes"; then

        hc_cv_optimization_flags="-O3"
    fi

    hc_cv_is_intel_x86_arch=no

    case "$host_cpu-$GCC" in

        x86_64-yes)

            hc_cv_is_intel_x86_arch=yes
            hc_cv_intel_cpu_type=k8
            ;;

        i386-yes|i486-yes|i586-yes|i686-yes|i786-yes)

            hc_cv_is_intel_x86_arch=yes

            if test $host_cpu = i786; then

                hc_cv_intel_cpu_type=pentium4
            else
                if test $host_cpu           = i686   &&
                   test "hc_cv_is_gcc_2_96" = "yes"; then

                    hc_cv_intel_cpu_type=i586
                else
                    hc_cv_intel_cpu_type=$host_cpu
                fi
            fi
            ;;

        arm-yes)

            hc_cv_is_intel_x86_arch=no
            hc_cv_optimization_flags="$hc_cv_optimization_flags -frename-registers"
            ;;

        xscale-yes|arm*-yes)

            hc_cv_is_intel_x86_arch=no
            hc_cv_optimization_flags="$hc_cv_optimization_flags -mcpu=$host_cpu -mtune=$host_cpu -frename-registers"
            ;;
    esac
    if test "$hc_cv_is_intel_x86_arch" = "yes"; then

        hc_cv_optimization_flags="$hc_cv_optimization_flags -march=$hc_cv_intel_cpu_type"

        if test "$hc_cv_builtin_alloca_broke" != "yes"  &&
           test "$hc_cv_opt_debug"            != "yes"; then

            hc_cv_optimization_flags="$hc_cv_optimization_flags -fomit-frame-pointer"
        else
            hc_cv_optimization_flags="$hc_cv_optimization_flags -fno-omit-frame-pointer"
        fi
    fi
fi

if test "x$hc_cv_optimization_flags" = "x"; then
    AC_MSG_RESULT( [(none)] )
else
    AC_MSG_RESULT( [$hc_cv_optimization_flags] )
fi

AC_CACHE_SAVE()

###############################################################################
#   DONE! -- Define our OUTPUT values and then exit...
###############################################################################

#  This is ugly...  Someone PLEASE fix this (if possible)...
#
#  The object is to get the value of PKGDATADIR into config.h,
#  but this is the only way I've found to do so. All of this
#  rigamarole is needed because ${datadir} doesn't expand to the
#  desired data directory. If there's a better way to get there,
#  PLEASE replace this. -- JRM
#
#  If DESTPREFIX is set, we're doing an RPM build, and we want to
#  use that value. If it's not set, and prefix is set and not equal
#  to NONE, then we'll use that. If prefix is NONE, then default to
#  /usr/local. Note: This prefix has /share/locale, /share/$PACKAGE,
#  or /lib/$PACKAGE appended in the next step, so it must NOT have
#  those components included in $DESTPREFIX itself.

if test "x${DESTPREFIX}" = "x"; then
    if test "x$prefix" = "xNONE"; then
        DESTPREFIX="/usr/local"
    else
        DESTPREFIX="${prefix}"
    fi
fi

case "x${libdir}" in
    *lib64*) DESTLIBS="lib64" ;;
    *)       DESTLIBS="lib" ;;
esac

MODULESDIR="${DESTPREFIX}/${DESTLIBS}/${PACKAGE}"
PKGDATADIR="${DESTPREFIX}/share/${PACKAGE}"
HERC_LOCALEDIR="${DESTPREFIX}/share/locale"

#--------------------------------------------------------------#
# (place only AC_DEFINE_UNQUOTED here; place AC_DEFINE below)  #
#--------------------------------------------------------------#

if test "x$hc_cv_opt_custom_build_str" != "x"; then
    AC_DEFINE_UNQUOTED( [CUSTOM_BUILD_STRING], "${hc_cv_opt_custom_build_str}" )
fi

AC_DEFINE_UNQUOTED( [MODULESDIR],        "${MODULESDIR}"                )
AC_DEFINE_UNQUOTED( [PKGDATADIR],        "${PKGDATADIR}"                )
AC_DEFINE_UNQUOTED( [HERC_LOCALEDIR],    "${HERC_LOCALEDIR}"            )
AC_DEFINE_UNQUOTED( [MAX_CPU_ENGINES],    ${hc_cv_opt_num_cpu_engines}  )

AC_CACHE_SAVE()

AC_MSG_NOTICE( [                                         ] )
AC_MSG_NOTICE( [ Package destination directory prefixes: ] )
AC_MSG_NOTICE( [                                         ] )
AC_MSG_NOTICE( [    Libraries:  ${MODULESDIR}            ] )
AC_MSG_NOTICE( [    Data:       ${PKGDATADIR}            ] )
AC_MSG_NOTICE( [    Locale:     ${HERC_LOCALEDIR}        ] )
AC_MSG_NOTICE( [                                         ] )

#---------------------------------------------------------------#
#  (place only AC_DEFINE here; place AC_DEFINE_UNQUOTED above)  #
#---------------------------------------------------------------#

test "$hc_cv_opt_debug"                   = "yes"  &&  AC_DEFINE(DEBUG)
test "$hc_cv_have_inttypes_h"             = "yes"  &&  AC_DEFINE(HAVE_INTTYPES_H)
test "$hc_cv_have_u_int8_t"               = "yes"  &&  AC_DEFINE(HAVE_U_INT)
test "$hc_cv_opt_configsymbols"           = "yes"  &&  AC_DEFINE(OPTION_CONFIG_SYMBOLS)
test "$hc_cv_opt_enhanced_configsymbols"  = "yes"  &&  AC_DEFINE(OPTION_ENHANCED_CONFIG_SYMBOLS)
test "$hc_cv_opt_enhanced_configincludes" = "yes"  &&  AC_DEFINE(OPTION_ENHANCED_CONFIG_INCLUDE)
test "$hc_cv_opt_auto_oper"               = "yes"  &&  AC_DEFINE(OPTION_HAO)
test "$hc_cv_opt_dynamic_load"            = "yes"  &&  AC_DEFINE(OPTION_DYNAMIC_LOAD)
test "$hc_cv_opt_fthreads"                = "yes"  &&  AC_DEFINE(OPTION_FTHREADS)
test "$hc_cv_opt_fishhang"                = "yes"  &&  AC_DEFINE(FISH_HANG)
test "$hc_cv_hdl_build_shared"            = "yes"  &&  AC_DEFINE(HDL_BUILD_SHARED)
test "$hc_cv_have_lt_dlopen"              = "yes"  &&  AC_DEFINE(HDL_USE_LIBTOOL)
test "$hc_cv_is_windows"                  = "yes"  &&  AC_DEFINE(WIN32)
test "$hc_cv_opt_external_gui"            = "yes"  &&  AC_DEFINE(EXTERNALGUI)
test "$hc_cv_opt_cckd_bzip2"              = "yes"  &&  AC_DEFINE(CCKD_BZIP2)
test "$hc_cv_opt_het_bzip2"               = "yes"  &&  AC_DEFINE(HET_BZIP2)
test "$hc_cv_timespec_in_sys_types_h"     = "yes"  &&  AC_DEFINE(TIMESPEC_IN_SYS_TYPES_H)
test "$hc_cv_timespec_in_time_h"          = "yes"  &&  AC_DEFINE(TIMESPEC_IN_TIME_H)
test "$hc_cv_have_getset_uid"            != "yes"  &&  AC_DEFINE(NO_SETUID)
test "$hc_cv_asm_byteswap"               != "yes"  &&  AC_DEFINE(NO_ASM_BYTESWAP)
test "$hc_cv_non_unique_gettimeofday"     = "yes"  &&  AC_DEFINE(NON_UNIQUE_GETTIMEOFDAY)
test "$hc_cv_build_hercifc"               = "yes"  &&  AC_DEFINE(BUILD_HERCIFC)
test "$hc_cv_opt_capabilities"            = "yes"  &&  AC_DEFINE(OPTION_CAPABILITIES)

if test $hc_cv_have_sa_sigaction != yes ||
   test $hc_cv_have_sigusr1      != yes ||
   test $hc_cv_have_sigusr2      != yes ||
   test $hc_cv_have_sigpipe      != yes ||
   test $hc_cv_have_sigbus       != yes; then

    AC_DEFINE(NO_SIGABEND_HANDLER)

fi

if test "$hc_cv_regparm_attr_supported" = "yes"  &&
   test "$hc_cv_regparm_attr_broke"    != "yes"; then

    AC_DEFINE(HAVE_ATTR_REGPARM)
fi

if test "$hc_cv_is_windows"  != "yes"  &&
   test "$hc_cv_have_fenv_h" != "yes"; then

    AC_DEFINE(NO_IEEE_SUPPORT)
fi

if test "$hc_cv_is_apple" = "yes"; then

    AC_DEFINE(_INTL_REDIRECT_MACROS)

    #
    #  TODO??
    #
    #  Do whatever is necessary to get the following symbol defined
    #  so the included libltdl will be built and used...
    #

##  AC_PROVIDE_AC_LIBTOOL_DLOPEN()

fi

#--------------------------------------------------#
#  CPPFLAGS  (pre-processor flags)                 #
#--------------------------------------------------#

if test "$hc_cv_is_apple"                    = "yes"  &&
   test "$hc_cv_pp_macro_arg_counting_broke" = "yes"; then

    CPPFLAGS="${CPPFLAGS} -traditional-cpp -Wno-endif-labels"
fi

#--------------------------------------------------#
#  CFLAGS  (compiler flags)                        #
#--------------------------------------------------#


if test "$hc_cv_is_windows"             = "yes"; then

    if test "$hc_cv_have_pthread_h"         = "yes" &&
       test "x$hc_cv_alt_pthread_location" != "x";  then

        CFLAGS="$CFLAGS -I${hc_cv_alt_pthread_location}"
    fi

    CFLAGS="$CFLAGS -Wno-format"
fi

if test "$hc_cv_byte_structs_aligned_and_rounded_by_default" = "yes"; then

    #===============================================================
    # the following requests 8-bit (byte) struct boundary alignment
    #===============================================================

    CFLAGS="$CFLAGS -mstructure-size-boundary=8"
fi

test "x$hc_cv_optimization_flags" !=  "x" &&  CFLAGS="$CFLAGS $hc_cv_optimization_flags"

#--------------------------------------------------#
#  LIBS  (linker flags)                            #
#--------------------------------------------------#

test  "$hc_cv_dash_pthread_needed" =  "yes"  &&  LIBS="$LIBS -pthread"
test  "$hc_cv_have_libbz2"         =  "yes"  &&  LIBS="$LIBS -lbz2"

#      ---------------------- MINGW32 ----------------------

test  "$hc_cv_is_mingw32" =  "yes"  &&  LIBS="$LIBS -lmsvcrt"
test  "$hc_cv_is_mingw32" =  "yes"  &&  LIBS="$LIBS -lws2_32"

AC_CACHE_SAVE()

#--------------------------------------------------------------------------------#
#  Pass certain values/settings as makefile variables to automake (makefile.am)  #
#--------------------------------------------------------------------------------#

AM_CONDITIONAL( OPTION_DYNAMIC_LOAD, [ test "$hc_cv_opt_dynamic_load" = "yes" ] )
AM_CONDITIONAL( BUILD_FTHREADS,      [ test "$hc_cv_opt_fthreads"     = "yes" ] )
AM_CONDITIONAL( BUILD_FISHHANG,      [ test "$hc_cv_opt_fishhang"     = "yes" ] )
AM_CONDITIONAL( BUILD_HERCIFC,       [ test "$hc_cv_build_hercifc"    = "yes" ] )
AM_CONDITIONAL( SETUID_HERCIFC,      [ test "$hc_cv_setuid_hercifc"   = "yes" ] )
AM_CONDITIONAL( HERCIFC_GROUPSET,    [ test "x$hc_cv_hercifc_groupname" != "x"] )

if test "x$hc_cv_hercifc_groupname" != "x"; then
    HERCIFC_GROUPNAME=${hc_cv_hercifc_groupname}
    AC_SUBST(HERCIFC_GROUPNAME)
fi

#  Building of shared libraries is forced, and we force use of libtool too.

AM_CONDITIONAL( BUILD_SHARED,        [ test "$hc_cv_hdl_build_shared" = "yes" ] )
AM_CONDITIONAL( USE_DLLTOOL,         [ test "$hc_cv_is_windows"       = "yes" ] )

AC_CACHE_SAVE()

AC_OUTPUT( [ Makefile util/Makefile html/Makefile crypto/Makefile po/Makefile.in po/Makefile man/Makefile m4/Makefile decNumber/Makefile] )

###############################################################################
#   (end-of-file)
###############################################################################