~ubuntu-branches/ubuntu/raring/vice/raring

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
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
dnl
dnl This file is part of VICE, the Versatile Commodore Emulator.
dnl See README for copyright notice.
dnl
dnl Process this file with GNU autoconf to produce a configure script.
dnl

AC_INIT(src/maincpu.c)

VICE_VERSION_MAJOR=2
VICE_VERSION_MINOR=1
VICE_VERSION_BUILD=0

AC_SUBST(VICE_VERSION_MAJOR)
AC_SUBST(VICE_VERSION_MINOR)
AC_SUBST(VICE_VERSION_BUILD)

if test x"$VICE_VERSION_BUILD" = "x" -o x"$VICE_VERSION_BUILD" = "x0" ; then
  VICE_VERSION=$VICE_VERSION_MAJOR"."$VICE_VERSION_MINOR
else
  VICE_VERSION=$VICE_VERSION_MAJOR"."$VICE_VERSION_MINOR"."$VICE_VERSION_BUILD
  AC_DEFINE(UNSTABLE,,[Define if this version is unstable.])
fi
AC_SUBST(VICE_VERSION)

AM_INIT_AUTOMAKE(vice, $VICE_VERSION)
AM_CONFIG_HEADER(src/config.h)

if test x"$VICE_VERSION_BUILD" = "x" -o x"$VICE_VERSION_BUILD" = "x0" ; then
  VERSION_RC=$VICE_VERSION_MAJOR","$VICE_VERSION_MINOR",0,0"
else
  VERSION_RC=$VICE_VERSION_MAJOR","$VICE_VERSION_MINOR","$VICE_VERSION_BUILD",0"
fi
AC_SUBST(VERSION_RC)

AC_DEFINE(VERSION_RC,"$VERSION_RC",[Win32 Version string.])

is_unix=no
is_unix_gp2x=no
is_unix_x11=no
is_unix_macosx=no
is_dos=no
is_win32=no
is_win32_x11=no
is_riscos=no
is_os2=no
is_beos=no
is_amiga=no

dnl Try to find out which system we are on...
AC_CANONICAL_HOST

dnl Command-line options

AC_ARG_ENABLE(textfield,[  --disable-textfield     disable enhanced text field widget])
AC_ARG_ENABLE(zlibtest,[  --disable-zlibtest      disable zlib test])
AC_ARG_WITH(xaw3d, [  --with-xaw3d            use Xaw3d library instead of plain Xaw])
AC_ARG_WITH(readline, [  --without-readline      do not try to use the system's readline library])
AC_ARG_WITH(midas, [  --with-midas            use MIDAS sound system instead of Allegro for audio])
AC_ARG_WITH(arts, [  --with-arts             use aRts sound system])
AC_ARG_WITH(esd, [  --without-esd           do not use the Enlightened Sound Daemon system])
AC_ARG_WITH(alsa, [  --without-alsa          do not use the ALSA sound system])
AC_ARG_WITH(oss, [  --without-oss           do not use the OSS sound system])
AC_ARG_ENABLE(sdl, [  --with-sdl              use sdl sound system])
AC_ARG_WITH(resid, [  --without-resid         do not use the reSID engine])
AC_ARG_WITH(png, [  --without-png           do not use the PNG screenshot system])
AC_ARG_WITH(zlib, [  --without-zlib          do not use the ZLIB support])
AC_ARG_ENABLE(fullscreen, [  --enable-fullscreen     enable XFree86 fullscreen detection], [ echo checking for XFree86 fullscreen requested...], [enable_fullscreen="no"; echo no explicit checking for XFree86 fullscreen requested, disabling fullscreen...])
AC_ARG_ENABLE(gnomeui,[  --enable-gnomeui        enables gnome ui support])
AC_ARG_ENABLE(nls,[  --disable-nls           disables national language support])
AC_ARG_ENABLE(realdevice,[  --disable-realdevice    disables access to real peripheral devices (CBM4Linux/OpenCBM)])
AC_ARG_ENABLE(ffmpeg,[  --enable-ffmpeg         enables ffmpeg library support])
AC_ARG_ENABLE(ethernet,[  --enable-ethernet       enables Tfe Final Ethernet emulation])
AC_ARG_ENABLE(ipv6,[  --disable-ipv6          disables the checking for ipv6 compatibility])
AC_ARG_ENABLE(parsid,[  --enable-parsid         enables ParSID support])
AC_ARG_WITH(picasso96, [  --with-picasso96        use Amiga P96 grafix system instead of cgx])
AC_ARG_ENABLE(bundle, [  --disable-bundle        do not use application bundles on Macs])
AC_ARG_WITH(cocoa, [  --with-cocoa            enables native Cocoa UI on Macs])
AC_ARG_ENABLE(memmap, [  --enable-memmap         enable the mem map feature])

if test x"$enable_memmap" = "xyes"; then
  AC_DEFINE(FEATURE_CPUMEMHISTORY,,[Use the memmap feature.])
fi

if test x"$enable_gnomeui" = "xyes" ; then
  AC_DEFINE(USE_GNOMEUI,,[Use GNOME UI.])
fi

AM_CONDITIONAL(GNOMEUI, test x"$enable_gnomeui" = "xyes")

if test x"$with_cocoa" = "xyes" ; then
  AC_DEFINE(MACOSX_COCOA,,[Use Cocoa on Macs.])
fi

AM_CONDITIONAL(MACOSX_COCOA, test x"$with_cocoa" = "xyes")

if test x"$enable_textfield" != "xno"; then
  AC_DEFINE(ENABLE_TEXTFIELD,,[Enable support for the TextField widget.])
  echo "using TextField widget."
else
  echo "using ugly Athena text widget."
fi

user_cflags=$CFLAGS
AC_PROG_CC

dnl --- setup Objective-C ---
OBJC="${CC}"
if test -z "x${OBJCFLAGS}"; then
  OBJCFLAGS="${CFLAGS}"
fi
OBJCDEPMODE="depmode=${CC}"
AC_SUBST(OBJC)
AC_SUBST(OBJCFLAGS)
dnl AC_SUBST(OBJCDEPMODE)
_AM_DEPENDENCIES([OBJC])

if test x"$host_os" = "xminixvmd"; then
  AR="\$(top_srcdir)/src/arch/unix/minix/minix-ar.sh"
  AC_DEFINE(MINIXVMD,,[are we compiling under Minix-Vmd])
  CFLAGS="$CFLAGS -I/usr/include/bsdcompat"
fi

if test x"$host_os" = "xminix"; then
  AC_DEFINE(MINIX_SUPPORT,,[do we need minix support])
  CFLAGS="$CFLAGS -D_MINIX -D_POSIX_SOURCE"
  MINIX_RELEASE=`uname -r`
  MINIX_VERSION=`uname -v`
  if test x"$MINIX_RELEASE" != "x3"; then
    AC_MSG_ERROR([VICE works only on minix 3 and up])
  fi
  case "$MINIX_VERSION" in
    1.3*)
      AC_DEFINE(MINIX_HAS_RECV_SEND,,[Define if this version of minix has the recv and send prototypes])
      ;;
  esac  
  AM_CONDITIONAL(MINIX_SUPPORT, true)
else
  AM_CONDITIONAL(MINIX_SUPPORT, false)
fi

if test x"$host_os" = "xcygwin32" -o x"$host_os" = "xcygwin"; then
  if test x"$with_x" = "xyes"; then
    host_os=cygwin-x11
    is_win32_x11=yes
  fi
fi

dnl Setup crosscompiling.
if test x"$host_vendor" = "xgo32" -o x"$host_vendor" = "xmsdos" -o x"$host_os" = "xmsdosdjgpp"; then

  dnl Some GCC cross-compilers are installed with a different name
  dnl instead of using the GCC architecture targeting features.
  dnl Check for the most common ones.

  if test "x$CC" = "xgcc" -a "x$host_vendor" != "xmsdos" -a "x`uname -s`" != "xMS-DOS"; then
    CFLAGS="$CFLAGS -b i386-go32"
    LDFLAGS="$CFLAGS -b i386-go32"
  fi

  dnl This is used by subsequent tests.
  ac_cv_prog_gcc=yes
  GCC=yes

  is_dos=yes

  if test x"$with_midas" = "xyes" ; then
      AC_DEFINE(USE_MIDAS_SOUND,,
                [Use MIDAS Sound System instead of the Allegro library.])
      LIBMIDAS="-lmidas"
      echo "configuring support for MIDAS Sound System"
  else
      LIBMIDAS=""
      echo "using Allegro sound driver"
  fi

  AM_CONDITIONAL(HAVE_RS232, false)
  AM_CONDITIONAL(HAVE_RAWDRIVE, false)

  dnl We always have a joystick and mouse on MSDOS.
  AC_DEFINE(HAS_JOYSTICK,,[Enable joystick emulation.])
  AC_DEFINE(HAVE_MOUSE,,[Enable 1351 mouse support])
  AC_DEFINE(HAS_SINGLE_CANVAS,,[Is only one canvas supported?])

  if test x"$enable_parsid" = "xyes"; then
    AC_DEFINE(HAVE_PARSID,,[Support for ParSID.])
  fi

elif test x"$host_os" = "xamigaos" -o x"$host_os" = "xamigaos4" -o x"$host_os" = "xamithlon" -o x"$host_os" = "xaros" -o x"$host_os" = "xmorphos" -o x"$host_os" = "xwarpos" -o x"$host_os" = "xpowerup"; then
  AM_CONDITIONAL(HAVE_RS232, true)
  AM_CONDITIONAL(HAVE_RAWDRIVE, true)

  AC_DEFINE(HAVE_RS232,,[Enable RS232 emulation.])
  AC_DEFINE(HAVE_RAWDRIVE,,[Support for block device disk image access.])
  AC_DEFINE(HAS_JOYSTICK,,[Enable joystick emulation.])
  AC_DEFINE(HAVE_MOUSE,,[Enable 1351 mouse support])
  AC_DEFINE(HAVE_HARDSID,,[Support for HardSID.])
  AC_DEFINE(AMIGA_SUPPORT,,[Should we enable Amigaos support.])

  is_amigaos4=yes
  is_amigaos3=no
  is_amiga_aros=no

  if test x"$host_os" = "xmorphos"; then
    AC_DEFINE(AMIGA_MORPHOS,,[Should we enable Amiga Morphos support.])
    CFLAGS="$CFLAGS -noixemul"
    AC_DEFINE(HAVE_HTONL,,[Define to 1 if you have the htonl function.])
    AC_DEFINE(HAVE_HTONS,,[Define to 1 if you have the htons function.])
    AC_DEFINE(HAVE_NETWORK,,[Enable netplay support])
    AC_DEFINE(HAVE_XVIDEO,,[Enable XVideo (overlay) support.])
    is_amigaos4=no
  fi

  if test x"$host_os" = "xamithlon" -o x"$host_cpu" = "xi686be"; then
    AC_DEFINE(AMIGA_AMITHLON,,[Should we enable Amiga Amithlon support.])
    is_amigaos4=no
  fi

  if test x"$host_os" = "xaros"; then
    AC_DEFINE(AMIGA_AROS,,[Should we enable AROS support.])
    AC_DEFINE(HAVE_HTONL,,[Define to 1 if you have the htonl function.])
    AC_DEFINE(HAVE_HTONS,,[Define to 1 if you have the htons function.])
    if test x"$host_cpu" != "xpowerpc" -a x"$host_cpu" != "xppc" -a x"$host_cpu" != "xx86_64" -a x"$host_cpu" != "xamd64"; then
      AC_DEFINE(HAVE_NETWORK,,[Enable netplay support])
    fi
    is_amigaos4=no
    is_amiga_aros=yes
  fi

  if test x"$host_os" = "xamigaos" -a x"$host_cpu" = "xm68k"; then
    CFLAGS="$CFLAGS -mc68020 -noixemul"
    AC_DEFINE(AMIGA_M68K,,[Should we enable M68K AmigaOS support.])
    AC_DEFINE(HAVE_HTONL,,[Define to 1 if you have the htonl function.])
    AC_DEFINE(HAVE_HTONS,,[Define to 1 if you have the htons function.])
    AC_DEFINE(HAVE_NETWORK,,[Enable netplay support])
    with_png=no
    with_zlib=no
    is_amigaos4=no
    is_amigaos3=yes
  fi

  if test x"$host_os" = "xwarpos"; then
    AC_DEFINE(AMIGA_WARPOS,,[Should we enable PPC Amiga WarpOS support.])
    is_amigaos4=no
  fi

  if test x"$host_os" = "xpowerup"; then
    AC_DEFINE(AMIGA_POWERUP,,[Should we enable PPC Amiga PowerUP support.])
    is_amigaos4=no
  fi

  if test x"$is_amigaos4" = "xyes"; then
    AC_DEFINE(AMIGA_OS4,,[Should we enable AmigaOS4 support.])
    AC_DEFINE(HAVE_CATWEASELMKIII,,[Support for Catweasel MKIII.])  
    with_picasso96=yes
  fi

  is_amiga=yes

  CFLAGS="$CFLAGS -finline-functions"
  
elif test x"$host_os" = "xcygwin32" -o x"$host_os" = "xcygwin" -o x"$host_os" = "xmingw32"; then

  dnl This is used by subsequent tests.
  ac_cv_prog_gcc=yes
  GCC=yes

  is_win32=yes

  dnl AC_CHECK_HEADERS(commctrl.h shlobj.h winioctl.h)

  AC_DEFINE(HAS_JOYSTICK,,[Enable joystick emulation.])
  AC_DEFINE(HAVE_MOUSE,,[Enable 1351 mouse support])
  AC_DEFINE(HAVE_RS232,,[Enable RS232 emulation.])
  AM_CONDITIONAL(HAVE_RS232, true)
  AM_CONDITIONAL(HAVE_RAWDRIVE, false)
  AC_DEFINE(HAVE_CATWEASELMKIII,,[Support for Catweasel MKIII.])
  AC_DEFINE(HAVE_HARDSID,,[Support for HardSID.])
  AC_DEFINE(HAVE_TFE,,[Support for The final Ethernet.])
  AC_DEFINE(HAVE_HTONL,,[Define to 1 if you have the htonl function.])
  AC_DEFINE(HAVE_HTONS,,[Define to 1 if you have the htons function.])
  AC_DEFINE(HAVE_NETWORK,,[Enable netplay support])
  AC_DEFINE(HAVE_MIDI,,[Enable support for midi.])
  if test x"$enable_parsid" = "xyes"; then
    AC_DEFINE(HAVE_PARSID,,[Support for ParSID.])
  fi

  AC_TRY_LINK([#include <windows.h>],
              [LARGE_INTEGER li; return (int) li.QuadPart],
              AC_DEFINE(HAS_LONGLONG_INTEGER,,
                [Support 64bit integer for Win32 performance counter]),)
  AC_TRY_LINK([#include <windows.h>],
              [HGLOBAL hGlobal; UnlockResource(hGlobal); return 0],
              AC_DEFINE(HAS_UNLOCKRESOURCE,,[Do we have UnlockResource()?]),)

elif test x"$host_os" = "xbeos"; then

  dnl This is used by subsequent tests.
  ac_cv_prog_gcc=yes
  GCC=yes

  is_beos=yes

  AC_DEFINE(HAS_JOYSTICK,,[Enable joystick emulation.])
  AC_DEFINE(HAVE_MOUSE,,[Enable 1351 mouse support])
  AM_CONDITIONAL(HAVE_RS232, false)
  AM_CONDITIONAL(HAVE_RAWDRIVE, false)

elif test x"$host_os" = "xriscos"; then

  dnl This is used by subsequent tests.
  ac_cv_prog_gcc=yes
  GCC=yes
  READLINE=""
    
  is_riscos=yes

  AC_DEFINE(HAS_JOYSTICK,,[Enable joystick emulation.])
  AM_CONDITIONAL(HAVE_RS232, false)
  AM_CONDITIONAL(HAVE_RAWDRIVE, false)

elif test x"$host_os" = "xgp2x" -o x"$host_os" = "xlinux-gp2x" -o x"$host_vendor" = "xgp2x"; then

  dnl This is used by subsequent tests.
  ac_cv_prog_gcc=yes
  GCC=yes

  is_unix=yes
  is_unix_gp2x=yes

  CFLAGS="$CFLAGS -fomit-frame-pointer -mcpu=arm920t -msoft-float"

  AC_DEFINE(HAVE_MOUSE,,[Enable 1351 mouse support])
  AC_DEFINE(DEBUG_ZFILE,,[Use debugging of the zfile])
  AC_DEFINE(GP2X,,[Enable GP2X compilation])
  AM_CONDITIONAL(HAVE_RS232, false)
  AM_CONDITIONAL(HAVE_RAWDRIVE, false)

else

dnl Check for host os with version attached. Typically on UN*X like systems.
case "$host_os" in

dnl Mac OS X Host
darwin*)

  is_unix=yes
  is_unix_macosx=yes

  if test x"$with_cocoa" = "xyes" ; then
    is_unix_x11=no
  else
    is_unix_x11=yes
  fi

  if test -z "$user_cflags" ; then
    if test x"$GCC" = "xyes" ; then
      warnings_cxx="-Wall -Winline"
      warnings_c="-Wstrict-prototypes $warnings_cxx"
      optimization_c="-O2 -finline-functions"
      optimization_cxx="-fno-exceptions $optimization_c"
      if test x"$ac_cv_prog_cc_g" = "xyes" ; then
        CFLAGS="-g $optimization_c $warnings_c"
        CXXFLAGS="-g $optimization_cxx $warnings_cxx"
      else
        CFLAGS="$optimization_c $warnings_c"
        CXXFLAGS="$optimization_cxx $warnings_cxx"
      fi 
    fi
  fi

  AM_CONDITIONAL(HAVE_RS232, true)
  AM_CONDITIONAL(HAVE_RAWDRIVE, true)

  AC_DEFINE(HAVE_RS232,,[Enable RS232 emulation.])
  AC_DEFINE(HAVE_RAWDRIVE,,[Support for block device disk image access.])
  AC_DEFINE(HAVE_MOUSE,,[Enable 1351 mouse support])

  AC_DEFINE(MACOSX_SUPPORT,,[Enable Mac OS X specific code.])
  if test "x$enable_bundle" != "xno" ; then
    echo "enabled Mac application bundles"
    AC_DEFINE(MACOSX_BUNDLE,,[Enable Mac OS X application bundles.])
  else
    echo "disabled Mac application bundles"
  fi
  ;;

dnl All other UN*X systems
*)

  dnl special handling of sco unixware 7.x
  case "$host_os" in
    sco3.2v7*)
      LIBS="-lxti -lsocket -lnsl $LIBS"
      ;;
  esac

  is_unix=yes
  is_unix_x11=yes

  if test -z "$user_cflags" ; then

    dnl Check for the type of compiler first.
    if test x"$GCC" = "xyes" ; then

      warnings_cxx="-Wall -Winline"
      if test x"$enable_gnomeui" != "xyes" ; then
          warnings_c="-Wstrict-prototypes $warnings_cxx"
      else
	  dnl "-Wstrict-prototypes" gives zillions of warnings in gtk headers
	  dnl warnings_gnome="-DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGNOME_DISABLE_DEPRECATED -DG_DISABLE_DEPRECATED"
	  warnings_c="$warnings_gnome $warnings_cxx"
      fi

      dnl Set appropriate optimization options (better than the default -g -O)
      dnl if using GCC.
      dnl `-pipe' is broken on some Alpha systems, and also `-funroll-loops'
      dnl gives troubles on both Alpha and SPARC.  That's why we use the fancy
      dnl options on x86 only.
      dnl If the user has specified her own `CFLAGS', we do not override them.

      if test "x$host_cpu" = "xi586" -o x"$host_cpu" = "xi486" -o x"$host_cpu" = "xi686" -o x"$host_cpu" = "xi386"; then

        echo using x86-specific optimizing options

        dnl `-DNO_REGPARM' should theoretically make it slower, but
        dnl regparms are so broken on the current GCC/EGCS that it's
        dnl better not to rely on them by default.
        CFLAGS="-g -O2 -DNO_REGPARM $warnings_c"
        CXXFLAGS="-g -fno-exceptions -O2 -DNO_REGPARM $warnings_cxx"

      else

        optimization_c="-O2 -finline-functions"
        optimization_cxx="-fno-exceptions $optimization_c"
        dnl Use -g if available.
        if test x"$ac_cv_prog_cc_g" = "xyes" ; then
           CFLAGS="-g $optimization_c $warnings_c"
           CXXFLAGS="-g $optimization_cxx $warnings_cxx"
        else
           CFLAGS="$optimization_c $warnings_c"
           CXXFLAGS="$optimization_cxx $warnings_cxx"
        fi

      fi

      dnl Check whether the options are OK.
      AC_PROG_CC

    fi

    dnl (If not on GCC, just keep the defaults, which are very conservative).

  fi

  AM_CONDITIONAL(HAVE_RS232, true)
  AM_CONDITIONAL(HAVE_RAWDRIVE, true)

  AC_DEFINE(HAVE_RS232,,[Enable RS232 emulation.])
  AC_DEFINE(HAVE_RAWDRIVE,,[Support for block device disk image access.])
  AC_DEFINE(HAVE_MOUSE,,[Enable 1351 mouse support])
  AC_DEFINE(HAVE_MIDI,,[Enable support for midi.])

  AC_CHECK_HEADER(linux/hardsid.h,
      [ AC_DEFINE(HAVE_HARDSID,,[Support for HardSID.]) ],)

  ;;
esac
fi

AM_CONDITIONAL(USE_MIDAS_SOUND, test x"$with_midas" = "xyes")

dnl Check for needed external programs.
AC_PROG_CPP
AC_CHECK_PROG(AR, ar, ar, ar)
AC_CHECK_TOOL(RANLIB, ranlib, :)
AC_CHECK_TOOL(STRIP, strip, :)
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_YACC
AM_PROG_LEX

dnl Extension for executable files in this system
AC_EXEEXT

dnl NLS stuff
dnl Its has been rejected to use the full GNU gettext package 
dnl delivered within the source. This is a minimum replacement implementing
dnl a simple check to find `libintl.h' and `gettext'.
dnl

dnl Add new languages here
ALL_LINGUAS="de fr it sv pl nl hu"

dnl These rules are solely for the distribution goal.  While doing this
dnl we only have to keep exactly one list of the available catalogs
dnl in configure.in.
for lang in $ALL_LINGUAS; do
  GMOFILES="$GMOFILES $lang.gmo"
  POFILES="$POFILES $lang.po"
done
AC_SUBST(GMOFILES)
AC_SUBST(POFILES)

if test x"$enable_nls" != "xno" -a x"$is_unix" = "xyes"; then
  AC_CHECK_HEADER(libintl.h,
    [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
      [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
  	 gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])

     AC_CACHE_CHECK([for gettext in libintl], gt_cv_func_gettext_libintl,
      [save_libs="$LIBS"
       LIBS="-lintl $LIBS"
       AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
  	 INTLLIBS=-lintl gt_cv_func_gettext_libintl=yes, gt_cv_func_gettext_libintl=no)
       LIBS="$save_libs"])

     if test "$gt_cv_func_gettext_libc" = "yes" \
  	|| test "$gt_cv_func_gettext_libintl" = "yes"; then
  	AC_DEFINE(HAVE_GETTEXT,,[Define if gettext if available.])
  	AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
  	  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
  	if test "$MSGFMT" != "no"; then
  	  AC_CHECK_FUNCS(dcgettext)
  	  AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
  	  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
  	    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
  	  AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
  			 return _nl_msg_cat_cntr],
  	    [CATOBJEXT=.gmo
  	     DATADIRNAME=share],
  	    [CATOBJEXT=.mo
  	     DATADIRNAME=lib])
  	  INSTOBJEXT=.mo
  	fi
        USE_NLS=yes
	AC_DEFINE(ENABLE_NLS,,[Define if NLS support is enabled.])
	AC_DEFINE(HAVE_LIBINTL_H,,[use libintl for NLS.])
	AC_DEFINE_UNQUOTED(DATADIRNAME, "$DATADIRNAME",[NLS datadirname.])
	dnl this is prefixed with PREFIX
	AC_DEFINE(NLS_LOCALEDIR, PREFIX"/"DATADIRNAME"/locale",[NLS local directory.])
      else
        AC_MSG_WARN([libintl.h not found, disabling NLS])
        USE_NLS=no
      fi
  ])
  dnl Test whether we really found GNU xgettext.
  if test "$XGETTEXT" != ":"; then
    dnl If it is no GNU xgettext we define it as : so that the
    dnl Makefiles still can work.
    if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
      : ;
    else
      AC_MSG_RESULT(
    	[found xgettext program is not GNU xgettext; ignore it])
      XGETTEXT=":"
    fi
  fi

  dnl Test wether GMSGFMT is there. Should fix `make dist'.
  if test "$GMSGFMT" = "" ; then
    GMSGFMT=":"
  fi

  # We need to process the po/ directory.
  POSUB=po
  
  AC_OUTPUT_COMMANDS(
    [case "$CONFIG_FILES" in *po/Makefile.in*)
      sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
    esac])
  
  dnl Make all variables we use known to autoconf.
  AC_SUBST(USE_INCLUDED_LIBINTL)
  AC_SUBST(CATALOGS)
  AC_SUBST(DATADIRNAME)
  AC_SUBST(INSTOBJEXT)
  AC_SUBST(INTLDEPS)
  AC_SUBST(INTLLIBS)
  AC_SUBST(INTLOBJS)
  AC_SUBST(POSUB)
  AC_SUBST(GENCAT)

  dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
  dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
  dnl Try to locate is.
  MKINSTALLDIRS=
  if test -n "$ac_aux_dir"; then
    MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
  fi
  if test -z "$MKINSTALLDIRS"; then
    MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
  fi
  AC_SUBST(MKINSTALLDIRS)

  dnl currently no catgets support, can't check it.
  GENCAT=
  AC_SUBST(GENCAT)
else
  if test x"$is_unix" = "xyes"; then
    AC_MSG_WARN([disabling NLS on user request])
  fi
  USE_NLS=no
fi

if test x"$USE_NLS" = "x" ; then
  USE_NLS=no
fi
if test "$MSGFMT" = "no" ; then
  dnl Fallback to shipped .gmo 
  dnl Those should work on x86 linux systems.
  AC_MSG_WARN([msgfmt not found, falling back to default catalogs (x86/Linux)])
  CATOBJEXT=".gmo"
fi
AC_SUBST(CATOBJEXT)
AC_SUBST(USE_NLS)
AC_SUBST(NLS_LOCALEDIR)

dnl Check for a perl interpreter.
AC_PATH_PROG(PERL, perl)
AC_SUBST(PERL)
 
if test x"$POSUB" = "xpo"; then
  AM_CONDITIONAL(PO_SUBDIR_USED, true)
else
  AM_CONDITIONAL(PO_SUBDIR_USED, false)
fi

dnl Check if --param inline-unit-growth=60 can be used.
old_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS --param inline-unit-growth=60"
AC_MSG_CHECKING([if the compiler accepts --param inline-unit-growth=60])
AC_TRY_COMPILE([],
               [int test;],
               [ AC_MSG_RESULT(yes)
                 INLINE_UNIT_GROWTH="--param inline-unit-growth=60"
                ],
               [ AC_MSG_RESULT(no)
                INLINE_UNIT_GROWTH=""
                ])
CFLAGS=$old_CFLAGS
AC_SUBST(INLINE_UNIT_GROWTH)

dnl Check if --param max-inline-insns-single=600 can be used.
old_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS --param max-inline-insns-single=600"
AC_MSG_CHECKING([if the compiler accepts --param max-inline-insns-single=600])
AC_TRY_COMPILE([],
               [int test;],
               [ AC_MSG_RESULT(yes)
                 MAX_INLINE_INSN_SINGLE="--param max-inline-insns-single=600"
                ],
               [ AC_MSG_RESULT(no)
                MAX_INLINE_INSN_SINGLE=""
                ])
CFLAGS=$old_CFLAGS
AC_SUBST(MAX_INLINE_INSN_SINGLE)

dnl Check and setup aRts compilation.
if test x"$with_arts" = "xyes"; then
	AC_CHECK_PROGS(artsc_config, artsc-config, no)
	if test x"$artsc_config" = "xno"; then
		AC_MSG_WARN([artsc-config not found. aRts will not be configured])
                with_arts=no
        fi
else
	with_arts=no
fi

dnl Check and setup SDL compilation.
if test x"$with_sdl" = "xyes"; then
	AC_CHECK_PROGS(sdl_config, sdl-config, no)
	if test x"$sdl_config" = "xno"; then
		AC_MSG_WARN([sdl-config not found. SDL will not be configured])
                with_sdl=no
        fi
else
	with_sdl=no
fi

dnl Setup reSID compilation.  We need a C++ compiler for this.
if test x"$with_resid" != "xno" -a -z "$CXX"; then
  AC_CHECK_PROGS(cxx, $CCC c++ g++ gcc CC cxx cc++, no)
  if test x"$cxx" = "xno"; then
    AC_MSG_WARN([C++ compiler missing, reSID will not be configured])
    with_resid=no
  fi
fi

RESID_DIR=
RESID_LIBS=
RESID_INCLUDES=
RESID_DEP=

RESID_FP_DIR=
RESID_FP_LIBS=
RESID_FP_INCLUDES=
RESID_FP_DEP=


LINKCC='$(CC)'

if test x"$with_resid" = "xno"; then
  dnl Do not attempt to configure reSID.
  dnl NOTE: no_recursion is set because directories specified with
  dnl AC_CONFIG_SUBDIRS are always recursed into regardless of where the
  dnl macro is used.
  dnl Another workaround must be found if other self-contained packages go
  dnl into VICE.
  no_recursion=yes
  dnl A workaround for an autoconf bug when not using/checking the C++
  dnl compiler, we'll define am__fastdepCXX_TRUE as #
  am__fastdepCXX_TRUE=#
  am__fastdepCXX_FALSE=
else
  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_PROG_CXX

  dnl Set CXXFLAGS. Use -fno-exceptions for G++ if supported.
  if test "$ac_test_CXXFLAGS" != set; then
    if test "$GXX" = yes; then
      CXXFLAGS="$CFLAGS -fno-exceptions"
      AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works])
      AC_TRY_COMPILE([],
                     [ int test; ],
                     [ AC_MSG_RESULT(yes) ],
                     [ AC_MSG_RESULT(no)
                       CXXFLAGS="$CFLAGS"
                       ])
    else
      CXXFLAGS="$CFLAGS"
    fi
  fi

  AC_PROG_CXXCPP
  if test x"$CXX" != "x" ; then
    LINKCC='$(CXX)'
  fi
  if test x"$with_resid" = "xyes" -o x"$with_resid" = "x"; then
    AC_DEFINE(HAVE_RESID,,[This version provides ReSID support.])
    AC_CONFIG_SUBDIRS(src/resid)
    RESID_DIR=resid
    RESID_LIBS="\$(top_builddir)/src/resid/libresid.a"
    RESID_INCLUDES="-I\$(top_builddir)/src/resid"
    RESID_DEP=libresid

    disable_resid_fp=no

    dnl disable reSID-FP for certain platforms
    if test x"$host_os" = "xamigaos" -a x"$host_cpu" = "xm68k"; then
        disable_resid_fp=yes
    fi
    if test x"$host_os" = "xgp2x" -o x"$host_os" = "xlinux-gp2x" -o x"$host_vendor" = "xgp2x"; then
        disable_resid_fp=yes
    fi

    if test x"$host_os" = "xbeos" -a x"$host_cpu" = "xpowerpc"; then
        disable_resid_fp=yes
    fi

    if test x"$disable_resid_fp" != "xyes"; then
      AC_DEFINE(HAVE_RESID_FP,,[This version provides ReSID_FP support.])
      AC_CONFIG_SUBDIRS(src/resid-fp)
      RESID_FP_DIR=resid-fp
      RESID_FP_LIBS="\$(top_builddir)/src/resid-fp/libresidfp.a"
      RESID_FP_INCLUDES="-I\$(top_builddir)/src/resid-fp"
      RESID_FP_DEP=libresidfp
    fi
  else
    dnl reSID is installed elsewhere, no need to configure.
    no_recursion=yes

    LDFLAGS="$LDFLAGS -L$with_resid/lib"
    CPPFLAGS="$CPPFLAGS -I$with_resid/include"

    dnl Test for libresid.a and resid/sid.h
    AC_CHECK_LIB(resid, resid_version_string,
                 [],
                 AC_MSG_ERROR([reSID library not found]))
    AC_CHECK_HEADER(resid/sid.h,
                    [],
                    AC_MSG_ERROR([reSID header file not found]))

    AC_DEFINE(HAVE_RESID,,[This version provides ReSID support.])
    RESID_DIR=
    RESID_LIBS="$with_resid/lib/libresid.a"
    RESID_INCLUDES="-I$with_resid/include"
  fi

  AC_LANG_RESTORE
fi

AC_SUBST(LINKCC)

AM_CONDITIONAL(HAVE_RESID, test x"$with_resid" != "xno")

AC_SUBST(RESID_DIR)
AC_SUBST(RESID_LIBS)
AC_SUBST(RESID_INCLUDES)
AC_SUBST(RESID_DEP)

if test x"$disable_resid_fp" = "xyes"; then
  AM_CONDITIONAL(HAVE_RESID_FP, false)
else
  AM_CONDITIONAL(HAVE_RESID_FP, test x"$with_resid" != "xno")
fi

AC_SUBST(RESID_FP_DIR)
AC_SUBST(RESID_FP_LIBS)
AC_SUBST(RESID_FP_INCLUDES)
AC_SUBST(RESID_FP_DEP)

dnl Check for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADERS(sys/types.h)

AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T

dnl Check whether inline functions are available.
AC_C_INLINE
if test x"$ac_cv_c_inline" = "xno" ; then
  CFLAGS="$CFLAGS -DNO_INLINE"
fi

dnl Define the type sizes.
if [[ x"$ac_cv_prog_cc_cross" != "xyes" ]]; then
  AC_C_BIGENDIAN
else
  dnl if cross-compiling, we have to do this by hand
  echo "warning: assuming sizeof(unsigned short) == 2,"
  echo "                  sizeof(unsigned int) == 4,"
  echo "                  sizeof(unsigned long) == 4"
fi

if test x"$cross_compiling" = "xyes"; then
  AM_CONDITIONAL(CROSS, true)
  CROSS=true
else
  AM_CONDITIONAL(CROSS, false)
  CROSS=false
fi
AC_SUBST(CROSS)

AC_CHECK_SIZEOF(unsigned short, 2)
AC_CHECK_SIZEOF(unsigned int, 4)
AC_CHECK_SIZEOF(unsigned long, 4)


dnl Check whether gcc needs -traditional.
AC_PROG_GCC_TRADITIONAL


dnl Check for header files.
AC_HEADER_DIRENT
AC_CHECK_HEADERS(direct.h errno.h fcntl.h limits.h regex.h unistd.h strings.h \
sys/dirent.h sys/ioctl.h sys/stat.h inttypes.h libgen.h \
dir.h io.h process.h signal.h commctrl.h shlobj.h winioctl.h)

AC_CHECK_HEADER(regexp.h,,,[#define	INIT		register char *sp = instring;
#define	GETC()		(*sp++)
#define	PEEKC()		(*sp)
#define	UNGETC(c)	-- sp
#define	RETURN(ptr)	return NULL;
#define	ERROR(val)	_RegExpError(val)
])
AC_DECL_SYS_SIGLIST


dnl ----- Joystick support -----
JOY_LIBS=
if test x"$is_unix_x11" = "xyes" ; then
  AC_CHECK_HEADER(linux/joystick.h,
                  [ AC_DEFINE(HAS_JOYSTICK,,[Enable joystick emulation.])
                    AC_DEFINE(LINUX_JOYSTICK,,
                              [Enable support for Linux style joysticks.])],)
  if test x"$ac_cv_header_linux_joystick_h" = "xyes" ; then
    AC_MSG_CHECKING(whether linux/joystick.h supports digital joysticks)
    AC_TRY_COMPILE([ #include <linux/joystick.h> ],
                   [ struct DJS_DATA_TYPE djs; ],
                   [ AC_DEFINE(HAS_DIGITAL_JOYSTICK,,
                               [Enable emulation for digital joysticks.])
                     AC_MSG_RESULT(yes) ], AC_MSG_RESULT(no))
  fi

  AC_CHECK_HEADER(machine/joystick.h,
                  [ AC_DEFINE(HAS_JOYSTICK,,[Enable joystick emulation.])
                    AC_DEFINE(HAVE_MACHINE_JOYSTICK_H,,
                              [Define to 1 if you have the <machine/joystick.h> header file.])
                    AC_DEFINE(BSD_JOYSTICK,,
                              [Enable support for BSD style joysticks.])],)

  if test x"$ac_cv_header_machine_joystick_h" != "xyes"; then
    AC_CHECK_HEADER(sys/joystick.h,
                    [ AC_DEFINE(HAS_JOYSTICK,,[Enable joystick emulation.])
                      AC_DEFINE(HAVE_SYS_JOYSTICK_H,,
                                [Define to 1 if you have the <sys/joystick.h> header file.])
                      AC_DEFINE(BSD_JOYSTICK,,
                                [Enable support for BSD style joysticks.])],)
  fi

  dnl NetBSD/FreeBSD USB joystick support
  usbhid_header=no
  usbhid_lib=no
  usb_lib=no
  AC_CHECK_LIB(usbhid, hid_get_report_desc, usbhid_lib=yes)
  if test x"$usbhid_lib" = "xyes" ; then
    AC_CHECK_HEADER(usbhid.h,
                    [AC_DEFINE(HAVE_USBHID_H,1,
                      [Define to 1 if you have the <usbhid.h> header file.])
                    usb_header=yes])
    AC_CHECK_HEADER(libusbhid.h,
                    [AC_DEFINE(HAVE_LIBUSBHID_H,1,
                      [Define to 1 if you have the <libusbhid.h> header file.])
                    usb_header=yes])
 
    if test x"$usb_header" = "xyes" ; then
      AC_DEFINE(HAS_USB_JOYSTICK,,[Enable emulation for USB joysticks.])
      JOY_LIBS="-lusbhid"
    fi
  else
    AC_CHECK_LIB(usb, hid_get_report_desc, usb_lib=yes)
    if test x"$usb_lib" = "xyes"; then
      AC_CHECK_HEADER(usb.h,
                      [AC_DEFINE(HAVE_USB_H,1,
                        [Define to 1 if you have the <usb.h> header file.])
                      usb_header=yes])
      AC_CHECK_HEADER(libusb.h,
                      [AC_DEFINE(HAVE_LIBUSB_H,1,
                        [Define to 1 if you have the <libusb.h> header file.])
                      usb_header=yes])
      if test x"$usb_header" = "xyes" ; then
        AC_DEFINE(HAS_USB_JOYSTICK,,[Enable emulation for USB joysticks.])
        JOY_LIBS="-lusb"
      fi
    fi
  fi
fi

if test x"$is_unix_macosx" = "xyes" ; then
  dnl --- Mac joystick support ---
  dnl check for HID utility library
  AC_CHECK_HEADER(HID_Utilities_External.h,,)
  if test x"$ac_cv_header_HID_Utilities_External_h" = "xyes" ; then
    AC_MSG_CHECKING(whether we can link the (mac) HIDUtilities library)
    old_LIBS="${LIBS}"
    LIBS="$LIBS -lHIDUtilities -framework IOKit -framework CoreServices"
    AC_TRY_LINK([#include <HID_Utilities_External.h>],
                [HIDCountDevices()],
                [AC_MSG_RESULT(yes);
                 JOY_LIBS="-lHIDUtilities -framework IOKit -framework CoreServices";
                 AC_DEFINE(HAS_JOYSTICK,,[Enable Joystick emulation.])
                 AC_DEFINE(MAC_JOYSTICK,,[Enable Mac Joystick support.])],
                [AC_MSG_RESULT(no);
                 LIBS=${old_LIBS}])
    LIBS="${old_LIBS}"
  fi
fi
AC_SUBST(JOY_LIBS)

dnl Check for math library
AC_CHECK_HEADERS(math.h)
AC_CHECK_LIB(m, sqrt,,,$LIBS)


dnl ----- ZLib -----
VICE_ZLIB=
VICE_ZLIB_DIR=
VICE_ZLIB_DEP=
VICE_ZLIB_INCLUDES=
ZLIB_LIBS=

if test x"$with_zlib" != "xno" ; then
  AC_CHECK_HEADER(zlib.h,,)
  if test x"$ac_cv_header_zlib_h" = "xyes" ; then
    ac_cv_lib_z_zlibVersion=yes
    if test x"$enable_zlibtest" != "xno" ; then
      AC_CHECK_LIB(z, zlibVersion,
                 [ ZLIB_LIBS="-lz";
                   AC_DEFINE(HAVE_ZLIB,,
                             [Can we use the ZLIB compression library?]) ],,)
    fi
  fi
  if test x"$ac_cv_lib_z_zlibVersion" != "xyes"; then
    AC_DEFINE(HAVE_ZLIB,, [Can we use the ZLIB compression library?])
    VICE_ZLIB="\$(top_builddir)/src/lib/zlib/libz.a"
    VICE_ZLIB_DEP=libz
    VICE_ZLIB_INCLUDES="-I\$(top_srcdir)/src/lib/zlib"
    VICE_ZLIB_DIR=lib/zlib
  fi
fi

AC_SUBST(VICE_ZLIB)
AC_SUBST(VICE_ZLIB_DIR)
AC_SUBST(VICE_ZLIB_DEP)
AC_SUBST(VICE_ZLIB_INCLUDES)
AC_SUBST(ZLIB_LIBS)


dnl ----- Netplay Support -----
NETPLAY_LIBS=
old_LIBS="$LIBS"
if test x"$is_unix_x11" = "xyes" -o x"$is_dos" = "xyes" -o x"$is_unix_macosx" = "xyes"; then

  if test x"$host_os" != "xqnx"; then
    dnl Check for needed network headers
    UNIX_NETWORK_HEADERS_PRESENT=yes
    AC_CHECK_HEADERS(sys/types.h unistd.h sys/socket.h sys/time.h sys/select.h netinet/in.h arpa/inet.h netdb.h,,
                     [UNIX_NETWORK_HEADERS_PRESENT=no],)
  else
    LIBS="-lsocket -lunix $LIBS"
  fi

  if test x"$UNIX_NETWORK_HEADERS_PRESENT" = "xyes"; then

    dnl Check for possible extra needed network libraries
    AC_CHECK_LIB(nsl, gethostbyname,[ NETPLAY_LIBS="-lnsl $NETPLAY_LIBS";
                                      LIBS="-lnsl $LIBS"],,)
    AC_CHECK_LIB(socket, gethostbyname,[ NETPLAY_LIBS="-lsocket $NETPLAY_LIBS";
                                         LIBS="-lsocket $LIBS"],,)
    AC_CHECK_LIB(bsd, gethostbyname,[ NETPLAY_LIBS="-lbsd $NETPLAY_LIBS";
                                      LIBS="-lbsd $LIBS"],,)
    AC_CHECK_LIB(net, gethostbyname,[ NETPLAY_LIBS="-lnet $NETPLAY_LIBS";
                                      LIBS="-lnet $LIBS"],,)
    AC_CHECK_LIB(inet, gethostbyname,[ NETPLAY_LIBS="-linet $NETPLAY_LIBS";
                                       LIBS="-linet $LIBS"],,)
    AC_CHECK_LIB(watt, gethostbyname,[ NETPLAY_LIBS="-lwatt $NETPLAY_LIBS";
                                       LIBS="-lwatt $LIBS"],,)

    dnl Check for needed functions
    UNIX_NETWORK_FUNCS_PRESENT=yes

    AC_CHECK_FUNCS(socket send bind listen gethostbyname connect recv accept,,
                   [UNIX_NETWORK_FUNCS_PRESENT=no],)

    if test x"$UNIX_NETWORK_FUNCS_PRESENT" = "xyes"; then
      AC_DEFINE(HAVE_NETWORK,,[Enable netplay support])
      AC_CHECK_FUNCS(htons htonl)
      AC_CHECK_FUNCS(getdtablesize getrlimit)
    fi
  fi
elif test x"$is_beos" = "xyes"; then

  dnl Check for needed network headers
  BEOS_NETWORK_HEADERS_PRESENT=yes
  AC_CHECK_HEADERS(socket.h netdb.h byteorder.h,,
                   [BEOS_NETWORK_HEADERS_PRESENT=no],)

  if test x"$BEOS_NETWORK_HEADERS_PRESENT" = "xyes"; then

    dnl Check for possible extra needed network libraries
    AC_CHECK_LIB(net, gethostbyname,[ NETPLAY_LIBS="-lnet -lnetapi $NETPLAY_LIBS";
                                      LIBS="-lnet -lnetapi $LIBS"],,)

    dnl Check for needed functions

    BEOS_NETWORK_FUNCS_PRESENT=yes

    AC_CHECK_FUNCS(socket send bind listen gethostbyname connect recv accept,,
                   [BEOS_NETWORK_FUNCS_PRESENT=no],)

    if test x"$BEOS_NETWORK_FUNCS_PRESENT" = "xyes"; then
      AC_DEFINE(HAVE_NETWORK,,[Enable netplay support])
      AC_CHECK_FUNCS(getdtablesize getrlimit)
    fi
  fi
fi

dnl Check for availability of IPV6
if test x"$is_unix_x11" = "xyes" -o x"$is_dos" = "xyes" -o x"$is_unix_macosx" = "xyes" ; then
  if test x"$UNIX_NETWORK_FUNCS_PRESENT" = "xyes"; then
    AC_MSG_CHECKING([if IPV6 should be enabled])
    if test x"$enable_ipv6" != "xno"; then
      have_ipv6=no
      AC_TRY_COMPILE([
        #include <sys/socket.h>
        #include <sys/types.h>], [
        struct sockaddr_storage ss;
        socket(AF_INET6, SOCK_STREAM, 0)
        ],
        have_ipv6=yes,
        have_ipv6=no
      )
      AC_MSG_RESULT($have_ipv6)

      if test $have_ipv6 = yes; then
        have_broken_ss_family=no

        dnl on some platforms, the structure sockaddr doesn't have a
        dnl ss_family, but __ss_family. If we find no ss_family then we
        dnl check for __ss_family, and if found define NEED_PREFIXED_SS_FAMILY.
        AC_MSG_CHECKING([struct sockaddr::ss_family])
        AC_TRY_COMPILE([
          #include <sys/socket.h>
          #include <sys/types.h>], [
          struct sockaddr_storage ss ;
          ss.ss_family = 0 ;
          ],
          have_ss_family=yes,
          have_ss_family=no
        )
        AC_MSG_RESULT($have_ss_family)
        if test x"$have_ss_family" = "xno" ; then
          AC_MSG_CHECKING([broken struct sockaddr::ss_family])
          AC_TRY_COMPILE([
            #include <sys/socket.h>
            #include <sys/types.h>], [
            struct sockaddr_storage ss ;
            ss.__ss_family = 0 ;
            ],
            have_broken_ss_family=yes,
            have_broken_ss_family=no
          )
          AC_MSG_RESULT($have_broken_ss_family)
          if test x$have_broken_ss_family = xyes ; then
            AC_DEFINE(NEED_PREFIXED_SS_FAMILY, [],
            [Whether struct sockaddr::__ss_family exists]) 
            AC_DEFINE(ss_family, __ss_family,
            [ss_family is not defined here, use __ss_family instead])
          else
            AC_MSG_WARN(ss_family and __ss_family not found)
          fi
        fi

        have_gethostbyname2=no
        AC_CHECK_FUNC(gethostbyname2, have_gethostbyname2=yes)
        if test $have_gethostbyname2 = yes; then
          AC_DEFINE([HAVE_GETHOSTBYNAME2], [], [Define if gethostbyname2 can be used])
          AC_DEFINE([HAVE_IPV6], [], [Define if ipv6 can be used])
        else
          have_getipnodebyname=no
          AC_CHECK_FUNC(getipnodebyname, have_getipnodebyname=yes)
          if test $have_getipnodebyname = yes; then
            AC_DEFINE([HAVE_GETIPNODEBYNAME], [], [Define if getipnodebyname can be used])
            AC_DEFINE([HAVE_IPV6], [], [Define if ipv6 can be used])
          fi
        fi
      fi
    else
      AC_MSG_RESULT("no")
    fi
  fi
fi
LIBS="$old_LIBS"
AC_SUBST(NETPLAY_LIBS)


dnl Configure output drivers
SOUND_DRIVERS=""
GFXOUTPUT_DRIVERS=""

dnl ----- FFMPEG -----
FFMPEG_INCLUDES=
FFMPEG_LIBS=
if test x"$enable_ffmpeg" = "xyes" -o x"$is_win32" = "xyes"; then
  SOUND_DRIVERS="$SOUND_DRIVERS soundffmpegaudio.o"
  GFXOUTPUT_DRIVERS="$GFXOUTPUT_DRIVERS ffmpegdrv.o"
  AC_CHECK_HEADERS( ffmpeg/avformat.h )
  if test x"$ac_cv_header_ffmpeg_avformat_h" = "xno" ; then
    FFMPEG_INCLUDES="-I\$(top_srcdir)/src/lib/libffmpeg"
  fi
  if test x"$is_unix" = "xyes" ; then
    old_LIBS="$LIBS"
    AC_CHECK_LIB(mp3lame, lame_encode_frame,[
      LIBS="-lmp3lame $LIBS";
      FFMPEG_LIBS="-lmp3lame"
    ],,$LIBS)
    AC_CHECK_LIB(avutil, av_free,[
      LIBS="-lavutil $LIBS";
      AC_CHECK_LIB(avcodec, avcodec_init,[
        LIBS="-lavcodec $LIBS";
        AC_CHECK_LIB(avformat, av_register_all,[
          LIBS="-lavformat $LIBS";
          FFMPEG_LIBS="-lavformat -lavcodec -lavutil $FFMPEG_LIBS";
          AC_DEFINE(HAVE_FFMPEG,,[Enable FFMPEG library support])
        ],,$LIBS)
      ],,$LIBS)
    ],,$LIBS)
    LIBS="$old_LIBS"
  else
    dnl win always uses FFMPEG
    AC_DEFINE(HAVE_FFMPEG,,[Enable FFMPEG library support])
  fi
fi
AC_SUBST(FFMPEG_INCLUDES)
AC_SUBST(FFMPEG_LIBS)

dnl ----- Ethernet -----
TFE_LIBS=
if test x"$is_dos" = "xyes" ; then
  if test x"$enable_ethernet" = "xyes"; then
    AC_CHECK_LIB(watt, gethostbyname,
                 [ AC_DEFINE(DOS_TCP,,
                             [Can we use the dos WATTCP library?]) ],,)
    AC_CHECK_LIB(pcap, pcap_open_live,
                 [ AC_DEFINE(DOS_TFE,,
                             [Can we use the dos PCAP library?])
                   AC_DEFINE(HAVE_TFE,,
                             [Support for The Final Ethernet]) ],,)
    AC_CHECK_LIB(net, libnet_write_link_layer,
                 [ TFE_LIBS="-lnet";
                   AC_DEFINE(HAVE_DOS_LIBNET,,
                             [Can we use the dos NET library?]) ],,)
    DOS_TFE_PCAP_LIB="libpcap_nodma.a"
  fi
else
  if test x"$enable_ethernet" = "xyes"; then
  dnl /usr/lib/libpcap.a
  dnl /usr/lib/libnet.a
    AC_CHECK_LIB(pcap, pcap_open_live,[
      AC_CHECK_LIB(net, libnet_init,[
        AC_DEFINE(HAVE_TFE,,[Support for The Final Ethernet])
        AC_DEFINE(VICE_USE_LIBNET_1_1,,[Support for The Final Ethernet])
        TFE_LIBS="-lpcap `libnet-config --libs`"
        CFLAGS="$CFLAGS `libnet-config --defines`"
    ],,$LIBS)],,$LIBS)
  dnl /usr/lib/libpcap.a
  dnl /usr/lib/libnet.a
    AC_CHECK_LIB(pcap, pcap_open_live,[
      AC_CHECK_LIB(net, libnet_write_link_layer,[
        AC_DEFINE(HAVE_TFE,,[Support for The Final Ethernet])
        TFE_LIBS="-lpcap `libnet-config --libs`"
        CFLAGS="$CFLAGS `libnet-config --defines`"
    ],,$LIBS)],,$LIBS)
  fi
fi
AC_SUBST(DOS_TFE_PCAP_LIB)
AC_SUBST(TFE_LIBS)

dnl ----- Sound Drivers -----
if test x"$is_unix" = "xyes"; then
  AC_CHECK_HEADERS(cwsid.h, AC_DEFINE(HAVE_CATWEASELMKIII,,
                   [Support for Catweasel MKIII.]), )

  if test x"$with_arts" = "xyes"; then
    old_cflags=$CFLAGS
    old_libs=$LIBS
    CFLAGS="$CFLAGS `artsc-config --cflags`"
    LIBS="$LIBS `artsc-config --libs`"
    AC_CHECK_HEADERS(artsc.h,[AC_CHECK_LIB(artsc, arts_init,
                     [SOUND_DRIVERS="$SOUND_DRIVERS soundarts.o"; break],
                     [CFLAGS=$old_cflags; LIBS=$old_libs; with_arts=no; break],$SOUND_LIBS)],
                     [CFLAGS=$old_cflags; LIBS=$old_libs; with_arts=no; break])
  fi

  if test x"$with_arts" = "xyes"; then
    AC_DEFINE(USE_ARTS,,[Enable aRts support.])
  fi

  if test x"$with_alsa" != "xno" -a x"$is_unix_gp2x" != "xyes"; then
    AC_CHECK_HEADERS(alsa/asoundlib.h,[AC_CHECK_LIB(asound, snd_pcm_open,
                     [SOUND_DRIVERS="$SOUND_DRIVERS soundalsa.o";
                      SOUND_LIBS="$SOUND_LIBS -lasound";
                      AC_DEFINE(USE_ALSA,,[Enable alsa support.])],,$SOUND_LIBS)])
  fi

  if test x"$with_oss" != "xno"; then
    AC_CHECK_HEADERS(linux/soundcard.h machine/soundcard.h sys/soundcard.h soundcard.h,
                     [SOUND_DRIVERS="$SOUND_DRIVERS sounduss.o";
                      AC_DEFINE(USE_OSS,,[Enable oss support.])])
    AC_CHECK_LIB(ossaudio, _oss_ioctl,,,$SOUND_LIBS)
  fi

  AC_CHECK_HEADERS(dmedia/audio.h, [AC_CHECK_LIB(audio, ALseterrorhandler,
                   [SOUND_DRIVERS="$SOUND_DRIVERS soundsgi.o";
                    SOUND_LIBS="$SOUND_LIBS -laudio";
                    AC_DEFINE(USE_DMEDIA,,[Enable sgi sound support.])],,$SOUND_LIBS)])

  AC_CHECK_HEADERS(sys/audioio.h,
                   [SOUND_DRIVERS="$SOUND_DRIVERS soundsun.o"; break])

  if test x"$with_esd" != "xno"; then
    AC_CHECK_HEADERS(esd.h,[AC_CHECK_LIB(esd, esd_open_sound,
                     [SOUND_DRIVERS="$SOUND_DRIVERS soundesd.o";
                      SOUND_LIBS="$SOUND_LIBS -lesd";
                      AC_DEFINE(USE_ESD,,[Enable esd sound support.])],,$SOUND_LIBS)])
  fi

  if test x"$with_sdl" = "xyes"; then
    old_cflags=$CFLAGS
    old_libs=$LIBS
    CFLAGS="$CFLAGS `sdl-config --cflags`"
    LIBS="$LIBS `sdl-config --libs`"
    AC_CHECK_HEADERS(SDL/SDL_audio.h,[AC_CHECK_LIB(SDL, SDL_OpenAudio,
                     [SOUND_DRIVERS="$SOUND_DRIVERS soundsdl.o";
                      AC_DEFINE(USE_SDL_AUDIO,,[Enable sdl sound support.])],
                     [CFLAGS=$old_cflags; LIBS=$old_libs; break],$SOUND_LIBS)],
                     [CFLAGS=$old_cflags; LIBS=$old_libs; break])
  fi

  case "$host_os" in
    hpux*)
      AC_CHECK_HEADERS(sys/audio.h,
                       [SOUND_DRIVERS="$SOUND_DRIVERS soundhpux.o"; break])
      ;;
    *)
      ;;
  esac

  AC_CHECK_HEADERS(UMS/UMSAudioDevice.h,[AC_CHECK_HEADERS(UMS/UMSBAUDDevice.h,
                   [AC_CHECK_LIB(UMSobj, UMSAudioDevice_initialize,
                    [SOUND_DRIVERS="$SOUND_DRIVERS soundaix.o";
                     SOUND_LIBS="$SOUND_LIBS -lUMSobj";
                     AC_DEFINE(USE_AIX_AUDIO,,[Enable aix sound support.])],,$SOUND_LIBS)])])
fi

if test x"$is_amiga" = "xyes"; then
  AC_CHECK_HEADERS(devices/ahi.h,
                   [SOUND_DRIVERS="$SOUND_DRIVERS soundahi.o"; break])
fi

AC_CHECK_HEADERS(lame/lame.h,[AC_CHECK_LIB(mp3lame, lame_encode_buffer,
                 [SOUND_DRIVERS="$SOUND_DRIVERS soundmp3.o";
                 SOUND_LIBS="$SOUND_LIBS -lmp3lame";
                 AC_DEFINE(USE_LAMEMP3,,[Enable lamemp3 support.])],,$SOUND_LIBS)])

if test "$ac_cv_lib_mp3lame_lame_encode_buffer" = "no"; then
  unset ac_cv_lib_mp3lame_lame_encode_buffer
  AC_CHECK_LIB(mp3lame, lame_encode_buffer,
               [SOUND_DRIVERS="$SOUND_DRIVERS soundmp3.o";
               SOUND_LIBS="$SOUND_LIBS -lmp3lame -lmpgdecoder";
               AC_DEFINE(USE_LAMEMP3,,[Enable lamemp3 support.])],,$SOUND_LIBS -lmpgdecoder)
fi

AC_PATH_PROGS(FCCACHE, fc-cache, false)
if test x"$FCCACHE" = "xfalse"; then
  AM_CONDITIONAL(HAVE_FC_CACHE, false)
else
  AM_CONDITIONAL(HAVE_FC_CACHE, true)
fi

if test x"$is_amigaos4" = "xyes"; then
  AC_MSG_CHECKING(whether devices/timer.h defines TimeVal)
  AC_TRY_COMPILE([ #include <devices/timer.h> ],
                 [ struct TimeVal djs; ],
                 [ AC_DEFINE(AMIGA_OS4_ALT,,
                             [Enable alternate OS4 includes.])
                   AC_MSG_RESULT(yes) ], AC_MSG_RESULT(no))

  dnl for AmigaOS4 native resid needs to be configured without dependency tracking
  if test x"$cross_compiling" != "xyes"; then
    ac_configure_args="$ac_configure_args --disable-dependency-tracking"
  fi
fi

if test x"$is_dos" = "xyes"; then
    if test x"$with_midas" = "xyes"; then
        AC_CHECK_HEADERS(midasdll.h,
                         [SOUND_DRIVERS="$SOUND_DRIVERS soundmidas.o"; break])
    else
        AC_CHECK_HEADERS(allegro.h,
                         [SOUND_DRIVERS="$SOUND_DRIVERS soundallegro.o"; break])
    fi
fi

if test x"$is_win32" = "xyes"; then
    SOUND_DRIVERS="$SOUND_DRIVERS sounddx.o soundwmm.o"
    AC_PATH_PROGS(WINDRES, windres, windres)
    AC_PATH_PROGS(WRC, wrc , windres)
    if test x"$WRC" != "xwindres"; then
        WRC_VERSION=`($WRC --version) 2>/dev/null`
        case "$WRC_VERSION" in
            Wine*)
                winerc=yes
                ;;
            *)
                winerc=no
                AC_MSG_WARN([WRC found, but is not the Wine Resource Compiler])
                WRC="$WINDRES"
                ;;
        esac
    else
        AC_MSG_WARN([WRC not found, WRC is required for propper internationalization support])
        WRC="$WINDRES"
    fi
fi

if [[ x"$is_beos" = "xyes" ]] ; then
    SOUND_DRIVERS="$SOUND_DRIVERS soundbeos.o"
fi

if [[ x"$is_riscos" = "xyes" ]]; then
    SOUND_DRIVERS="$SOUND_DRIVERS soundacorn.o"
fi

if [[ x"$is_unix_macosx" = "xyes" ]]; then

dnl --- check for CoreAudio ---
AC_CHECK_HEADER(CoreAudio/CoreAudio.h,,)
if test x"$ac_cv_header_CoreAudio_CoreAudio_h" = "xyes" ; then
  AC_CHECK_HEADER(AudioToolbox/AudioToolbox.h,,)
  if test x"$ac_cv_header_AudioToolbox_AudioToolbox_h" = "xyes" ; then
    AC_MSG_CHECKING(whether we can link the CoreAudio framework)
    old_LIBS="${LIBS}"
    LIBS="${LIBS} -framework CoreAudio -framework AudioToolbox"
    AC_TRY_LINK([#include <CoreAudio/CoreAudio.h>],
                [AudioDeviceStart(0,0);],
                [AC_MSG_RESULT(yes);
                 SOUND_DRIVERS="$SOUND_DRIVERS soundcoreaudio.o";
                 SOUND_LIBS="$SOUND_LIBS -framework CoreAudio -framework AudioToolbox";
                 AC_DEFINE(USE_COREAUDIO,,[Enable CoreAudio support.])],
                [AC_MSG_RESULT(no)])
    LIBS=${old_LIBS}
  fi
fi

dnl --- check for CoreMIDI ---
AC_MSG_CHECKING(whether we can link the CoreMIDI framework)
old_LIBS="${LIBS}"
LIBS="$LIBS -framework CoreMidi -framework CoreServices"
AC_TRY_LINK([#include <CoreMIDI/MIDIServices.h>],
            [MIDIGetNumberOfDevices()],
            [AC_MSG_RESULT(yes);
             AC_DEFINE(HAVE_MIDI,,[Enable MIDI emulation.])],
            [AC_MSG_RESULT(no);
             LIBS=${old_LIBS}])

fi

AC_SUBST(SOUND_DRIVERS)
AC_SUBST(SOUND_LIBS)

dnl Check for ParSID support
if test x"$is_unix" = "xyes" -a x"is_unix_gp2x" != "xyes"; then

  if test x"$enable_parsid" = "xyes"; then
    dnl Check for needed parallel port io headers

    LIBIEEE1284_HEADERS_PRESENT=yes
    QNX_MMAN_HEADERS_PRESENT=yes
    BSD_SET_IOPERM_HEADERS_PRESENT=yes
    PARSID_SUPPORT=no

    AC_CHECK_HEADERS(ieee1284.h,,[LIBIEEE1284_HEADERS_PRESENT=no],)
    AC_CHECK_HEADERS(sys/mman.h hw/inout.h,,[QNX_MMAN_HEADERS_PRESENT=no],)
    AC_CHECK_HEADERS(machine/sysarch.h,,[BSD_SET_IOPERM_HEADERS_PRESENT=no],)
    AC_CHECK_HEADERS(unistd.h sys/io.h machine/pio.h machine/cpufunc.h)

    if test x"$LIBIEEE1284_HEADERS_PRESENT" = "xyes"; then
      AC_CHECK_LIB(ieee1284, ieee1284_find_ports,[LIBS="-lieee1284 $LIBS"; PARSID_SUPPORT=yes],,)
      if test x"$PARSID_SUPPORT" = "xyes"; then
        AC_DEFINE(HAVE_LIBIEEE1284,,[Define to 1 if you have the `ieee1284' library (-lieee1284).])
      fi
    fi

    if test x"$PARSID_SUPPORT" = "xno"; then
      if test x"$QNX_MMAN_HEADERS_PRESENT" = "xyes"; then
        QNX_MMAN_FUNCS_PRESENT=yes
        AC_CHECK_FUNCS(mmap_device_io in8 out8,,[QNX_MMAN_FUNCS_PRESENT=no])
        if test x"$QNX_MMAN_FUNCS_PRESENT" = "xyes"; then
          PARSID_SUPPORT=yes
        fi
      fi
    fi

    if test x"$PARSID_SUPPORT" = "xno"; then
      if test x"$BSD_SET_IOPERM_HEADERS_PRESENT" = "xyes"; then
        AC_CHECK_LIB(amd64, amd64_set_ioperm,[LIBS="-lamd64 $LIBS"; PARSID_SUPPORT=yes],,)
        if test x"$PARSID_SUPPORT" = "xyes"; then
          AC_DEFINE(HAVE_LIBAMD64,,[Define to 1 if you have the `amd64' library (-lamd64).])
        fi
      fi
    fi

    if test x"$PARSID_SUPPORT" = "xno"; then
      if test x"$BSD_SET_IOPERM_HEADERS_PRESENT" = "xyes"; then
        AC_CHECK_LIB(i386, i386_get_ioperm,[LIBS="-li386 $LIBS"],,)
        AC_CHECK_FUNCS(i386_set_ioperm,[PARSID_SUPPORT=yes],)
      fi
    fi

    if test x"$PARSID_SUPPORT" = "xno"; then
      AC_CHECK_FUNCS(ioperm,[PARSID_SUPPORT=yes],)
    fi

    if test x"$PARSID_SUPPORT" = "xyes"; then
      AC_DEFINE(HAVE_PARSID,,[Support for ParSID.])
    fi
  fi
fi

dnl Check for library functions
if test x"$is_dos" = "xno" -a x"$is_win32" = "xno" -a x"$is_riscos" = "xno"; then
  AC_FUNC_MEMCMP
fi
AC_TYPE_SIGNAL
AC_FUNC_VFORK
AC_CHECK_TYPES(u_short)
dnl some platforms have some of the functions in libbsd,
dnl so we check it out first.
AC_CHECK_LIB(bsd,gettimeofday,,,$LIBS)
AC_CHECK_FUNCS(gettimeofday memmove atexit strerror strcasecmp strncasecmp telldir seekdir rewinddir dirname mkstemp swab getcwd)

AC_SUBST(LIBS)

dnl if usleep is not defined, compile our own version for it (usleep.o)
if test x"$is_win32" = "xno" -a x"$is_amiga_aros" = "xno" -a x"$is_riscos" = "xno"; then
  AC_REPLACE_FUNCS(usleep)
fi

dnl Check time.h.

dnl AC_HEADER_TIME
dnl AC_STRUCT_TM

dnl ----- Readline -----
dnl Check whether we have GNU readline.  If not, use our replacement.
dnl The user can force us to use the replacement with `--without-readline'.
READLINE_LIBS=
if test x"$is_unix_x11" = "xyes"; then
  if test x"$with_readline" != "xno" ; then
    READLINE=""
    unset ac_cv_lib_readline_readline
    old_LIBS="$LIBS"
    AC_CHECK_LIB(readline, readline,
               [ READLINE="" READLINE_LIBS="-lreadline"],
               [],,)
    if test "$ac_cv_lib_readline_readline" = "no"; then
      unset ac_cv_lib_readline_readline
      AC_CHECK_LIB(readline, readline,
               [ READLINE="" READLINE_LIBS="-lreadline -lncurses"],
               [], "-lncurses",)
      if test "$ac_cv_lib_readline_readline" = "no"; then
        unset ac_cv_lib_readline_readline
        AC_CHECK_LIB(readline, readline,
               [ READLINE="" READLINE_LIBS="-lreadline -lcurses"],
               [ READLINE="\$(top_builddir)/src/arch/unix/readline/libreadline.a" ],
                "-lcurses",)
      else
        AC_CHECK_LIB(readline, rl_readline_name,
          [ AC_DEFINE(HAVE_RLNAME,,
            [Does the `readline' library support `rl_readline_name'?]) ],,)
      fi
    else
      AC_CHECK_LIB(readline, rl_readline_name,
        [ AC_DEFINE(HAVE_RLNAME,,
          [Does the `readline' library support `rl_readline_name'?]) ],,)
    fi
    LIBS="${old_LIBS}"
  else
    READLINE="\$(top_builddir)/src/arch/unix/readline/libreadline.a"
  fi
else
  READLINE=""
fi
AM_CONDITIONAL(NEED_READLINE, test x"$READLINE" != "x")
AC_SUBST(READLINE)
AC_SUBST(READLINE_LIBS)

dnl check Amiga graphics support
if test x"$is_amiga" = "xyes"; then
  cgx_present=no
  p96_present=no
  if test x"$with_picasso96" != "xyes"; then
    AC_CHECK_HEADERS(proto/cybergraphics.h,[cgx_present=yes],,)
  fi

  if test x"$cgx_present" = "xno"; then
    AC_CHECK_HEADERS(proto/Picasso96.h,[p96_present=yes],,)
    if test x"$p96_present" = "xno"; then
      AC_CHECK_HEADERS(proto/Picasso96API.h,[p96_present=yes],,)
      if test x"$p96_present" = "xno"; then
        AC_MSG_ERROR([No CGX or P96 headers found])
      fi
    fi
  fi
fi


dnl Configure graphics output drivers
VICE_LIBPNG=
VICE_LIBPNG_DIR=
VICE_LIBPNG_DEP=
VICE_LIBPNG_INCLUDES=

old_LIBS="$LIBS"
GFXOUTPUT_LIBS=

if test x"$is_beos" != "xyes"; then
  if test x"$with_png" != "xno" ; then
    dnl Check for the PNG library.
    AC_CHECK_HEADER(png.h,,)
    if test x"$ac_cv_header_png_h" = "xyes" ; then
      unset ac_cv_lib_png_png_check_sig
      AC_CHECK_LIB(png, png_check_sig,
                   [ GFXOUTPUT_LIBS="-lpng $GFXOUTPUT_LIBS";
                     GFXOUTPUT_DRIVERS="$GFXOUTPUT_DRIVERS pngdrv.o";
                     AC_DEFINE(HAVE_PNG,,[Can we use the PNG library?]) ],,)
      if test "$ac_cv_lib_png_png_check_sig" = "no"; then
        unset ac_cv_lib_png_png_check_sig
        AC_CHECK_LIB(png, png_check_sig,
                     [ GFXOUTPUT_LIBS="-lpng -lz $GFXOUTPUT_LIBS";
                       GFXOUTPUT_DRIVERS="$GFXOUTPUT_DRIVERS pngdrv.o";
                       AC_DEFINE(HAVE_PNG,,
                                 [Can we use the PNG library?]) ],,"-lz")
      fi
    fi
    if test x"$ac_cv_lib_png_png_check_sig" != "xyes"; then
      if test x"$with_zlib" != "xno" ; then
        AC_DEFINE(HAVE_PNG,,[Can we use the PNG library?])
        VICE_LIBPNG="\$(top_builddir)/src/lib/lpng/libpng.a"
        VICE_LIBPNG_DEP=libpng
        GFXOUTPUT_DRIVERS="$GFXOUTPUT_DRIVERS pngdrv.o"
        VICE_LIBPNG_INCLUDES="-I\$(top_srcdir)/src/lib/lpng"
        VICE_LIBPNG_DIR=lib/lpng
      fi
    fi
  fi
fi

dnl Check for the GIF or UNGIF library.
AC_CHECK_HEADER(gif_lib.h,,)
if test x"$ac_cv_header_gif_lib_h" = "xyes" ; then
  AC_CHECK_LIB(ungif, EGifPutLine, [ 
               GFXOUTPUT_LIBS="-lungif $GFXOUTPUT_LIBS";
               GFXOUTPUT_DRIVERS="$GFXOUTPUT_DRIVERS gifdrv.o";
               AC_DEFINE(HAVE_GIF,,[Can we use the GIF or UNGIF library?]) ],,)
  if test "$ac_cv_lib_ungif_EGifPutLine" = "no"; then
    AC_CHECK_LIB(gif, EGifPutLine, [ 
                 GFXOUTPUT_LIBS="-lgif $GFXOUTPUT_LIBS";
                 GFXOUTPUT_DRIVERS="$GFXOUTPUT_DRIVERS gifdrv.o";
                 AC_DEFINE(HAVE_GIF,,[Can we use the GIF or UNGIF library?]) ],,)
  fi
fi

dnl Check for the JPEG library.
AC_CHECK_HEADER(jpeglib.h,,)
if test x"$ac_cv_header_jpeglib_h" = "xyes" ; then
  AC_CHECK_LIB(jpeg, jpeg_CreateCompress, [ 
               GFXOUTPUT_LIBS="-ljpeg $GFXOUTPUT_LIBS";
               GFXOUTPUT_DRIVERS="$GFXOUTPUT_DRIVERS jpegdrv.o";
               AC_DEFINE(HAVE_JPEG,,[Can we use the JPEG library?]) ],,)
fi

LIBS="$old_LIBS"
AC_SUBST(VICE_LIBPNG)
AC_SUBST(VICE_LIBPNG_DIR)
AC_SUBST(VICE_LIBPNG_DEP)
AC_SUBST(GFXOUTPUT_DRIVERS)
AC_SUBST(GFXOUTPUT_LIBS)
AC_SUBST(VICE_LIBPNG_INCLUDES)


dnl Check for libraries and header files
if test x"$is_unix_x11" = "xyes"; then
  X_LIBS=""
  AC_PATH_XTRA

  PATH_X_LIBS=$X_LIBS
  LINK_X_LIBS=""

  have_xvideo_header="no"
  have_xvideo_lib="no"

  if [[ x"${enable_gnomeui}" = "xyes" ]] ; then

    PKG_CHECK_MODULES(GTK, [gtk+-2.0])
    PKG_CHECK_MODULES(GTKGL, [gtkglext-1.0],
        AC_DEFINE(HAVE_HWSCALE,,[Enable arbitrary window scaling]),
        AC_MSG_RESULT(no)
      )
    X_LIBS="$GTK_LIBS $GTKGL_LIBS $X_LIBS"
    LINK_X_LIBS="$GTK_LIBS $GTKGL_LIBS $LINK_X_LIBS"
  else
    AC_DEFINE(USE_COLOR_MANAGEMENT,,[Enable new color management code.])
    dnl instead of assuming that libsocket needs libnsl, we
    dnl will check the existance of libnsl first.

    AC_CHECK_LIB(nsl, gethostbyname,[ X_LIBS="-lnsl $X_LIBS";
                 LINK_X_LIBS="-lnsl $LINK_X_LIBS"],,$X_LIBS)
    AC_CHECK_LIB(socket, gethostbyname,[ X_LIBS="-lsocket $X_LIBS";
                 LINK_X_LIBS="-lsocket $LINK_X_LIBS"],,$X_LIBS)
    AC_CHECK_LIB(bsd, gethostbyname,[ X_LIBS="-lbsd $X_LIBS";
                 LINK_X_LIBS="-lbsd $LINK_X_LIBS"],,$X_LIBS)
    if test x"$ac_cv_lib_ICE_IceConnectionNumber" != "xyes"; then
      unset ac_cv_lib_ICE_IceConnectionNumber
    fi
    AC_CHECK_LIB(ICE, IceConnectionNumber,[ X_LIBS="-lICE $X_LIBS";
                 LINK_X_LIBS="-lICE $LINK_X_LIBS"],,$X_LIBS)
    AC_CHECK_LIB(SM, SmFreeProperty,[ X_LIBS="-lSM $X_LIBS";
                 LINK_X_LIBS="-lSM $LINK_X_LIBS"],,$X_LIBS)

    dnl This is necessary because CPP tests use `CPPFLAGS' instead.
    dnl FIXME: Are we sure `AC_PATH_XTRA' will always put only X11
    dnl include paths in?  Let's hope so.
    CPPFLAGS="$CPPFLAGS $X_CFLAGS"

    MISSING_X_LIBS=""

    AC_CHECK_LIB(X11, XCreateWindow,
                 [ X_LIBS="-lX11 $X_LIBS";
                   LINK_X_LIBS="-lX11 $LINK_X_LIBS"],
                 [ MISSING_X_LIBS="$MISSING_X_LIBS X11" ],$X_LIBS)

    AC_CHECK_LIB(Xext, XQueryExtension,
                 [ X_LIBS="-lXext $X_LIBS";
                   LINK_X_LIBS="-lXext $LINK_X_LIBS"],,$X_LIBS)

    AC_MSG_CHECKING(for X11/extensions/Xvlib.h)
    AC_TRY_LINK([#include <X11/Xlib.h>
                 #include <X11/extensions/Xvlib.h>],
                [return 0;],
                [AC_MSG_RESULT(yes); have_xvideo_header="yes"],
                [AC_MSG_RESULT(no); have_xvideo_header="no"])

    AC_CHECK_LIB(Xv, XvQueryExtension,
                 [ X_LIBS="-lXv $X_LIBS";
                   LINK_X_LIBS="-lXv $LINK_X_LIBS";
                  have_xvideo_lib="yes" ],,$X_LIBS)

    if test x"$have_xvideo_header" != "xno" -a x"$have_xvideo_lib" != "xno"; then
       AC_DEFINE(HAVE_XVIDEO,,[Enable XVideo support.])
       AC_DEFINE(HAVE_HWSCALE,,[Enable arbitrary window scaling])
    fi

    AC_CHECK_LIB(Xt, XtToolkitInitialize,
                 [ X_LIBS="-lXt $X_LIBS";
                   LINK_X_LIBS="-lXt $LINK_X_LIBS"],
                 [ MISSING_X_LIBS="$MISSING_X_LIBS Xt" ],$X_LIBS)

    AC_CHECK_LIB(Xmu, XInternAtom,
                 [ X_LIBS="-lXmu $X_LIBS";
                   LINK_X_LIBS="-lXmu $LINK_X_LIBS"],
                 [ MISSING_X_LIBS="$MISSING_X_LIBS Xmu" ],$X_LIBS)

    dnl check for Xpm, on some systems Xpm is required for correct Xaw usage.
    AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData,
                 [ X_LIBS="-lXpm $X_LIBS";
                   LINK_X_LIBS="-lXpm $LINK_X_LIBS";
                   AC_DEFINE(HAVE_LIBXPM,,[Is libXpm available?]) ],,$X_LIBS)

    dnl Check for Xaw.  Use Xaw3d if requested.
    if test x"$with_xaw3d" != "xyes" ; then
      AC_CHECK_LIB(Xaw, XawFormDoLayout,
                   [ X_LIBS="-lXaw $X_LIBS";
                     LINK_X_LIBS="-lXaw $LINK_X_LIBS"],
                   [ MISSING_X_LIBS="$MISSING_X_LIBS Xaw" ],
                   $X_LIBS $X_PRE_LIBS)
    else
      AC_CHECK_LIB(Xaw3d, XawFormDoLayout,
                   [ X_LIBS="-lXaw3d $X_LIBS";
                     LINK_X_LIBS="-lXaw3d $LINK_X_LIBS"],
                   [ MISSING_X_LIBS="$MISSING_X_LIBS Xaw3d" ],
                   $X_LIBS $X_PRE_LIBS)
    fi

    AC_CHECK_HEADER(X11/extensions/XShm.h,,,[#include <X11/Xlib.h>])
    if test x"$ac_cv_header_X11_extensions_XShm_h" = "xyes" ; then
      AC_CHECK_LIB(Xext, XShmAttach,
                   [ AC_DEFINE(USE_MITSHM,,
                   [Enable MITSHM extensions.]) ],,$X_LIBS)
    fi

    if test x"$MISSING_X_LIBS" != "x"; then
      echo
      echo "+++ Warning: the following important X11 libraries were not found: $MISSING_X_LIBS"
      echo "+++ You might have to edit the Makefile by hand to compile properly"
      echo
    fi

    AC_CHECK_HEADERS(X11/Sunkeysym.h X11/xpm.h xpm.h)
  fi

  AC_CHECK_HEADER(GL/glx.h,,,[#include <GL/gl.h>])
  if test x"$ac_cv_header_GL_glx_h" = "xyes" ; then
    AC_CHECK_LIB(GL, glXWaitVideoSyncSGI,
                 [ X_LIBS="-lGL $X_LIBS";
                   LINK_X_LIBS="-lGL $LINK_X_LIBS";
		   VICE_SYNC="openGL_sync.o $VICE_SYNC";
                   AC_DEFINE(USE_XF86_EXTENSIONS,,[Enable XF86 extensions.])
		   AC_DEFINE(HAVE_OPENGL_SYNC,,
		   [Enable openGL synchronization])],,$X_LIBS)
  fi
  AC_SUBST(VICE_SYNC)

  dnl Check for XFree86 header and library extensions.
  FULLSCREEN_DRIVERS=""
  if test x"$enable_fullscreen" != "xno"; then
    AC_CHECK_HEADER(X11/extensions/xf86vmode.h,,,[#include <X11/Xlib.h>])
    if test x"$ac_cv_header_X11_extensions_xf86vmode_h" = "xyes" ; then
      AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryVersion,
                   [ X_LIBS="-lXxf86vm $X_LIBS";
                     LINK_X_LIBS="-lXxf86vm $LINK_X_LIBS";
                     FULLSCREEN_DRIVERS="$FULLSCREEN_DRIVERS vidmode.o";
                     AC_DEFINE(USE_XF86_VIDMODE_EXT,,
                               [Enable XF86 VidMode extensions.])
                     AC_DEFINE(HAVE_FULLSCREEN,,[Enable Fullscreen support.])
                     AC_DEFINE(USE_XF86_EXTENSIONS,,
                               [Enable XF86 extensions.])],,$X_LIBS)
    fi
    AC_CHECK_HEADER(X11/extensions/Xrandr.h,,,[#include <X11/Xlib.h>])
    if test x"$ac_cv_header_X11_extensions_Xrandr_h" = "xyes" ; then
      AC_CHECK_LIB(Xrandr, XRRGetScreenInfo,
                   [ X_LIBS="-lXrandr $X_LIBS";
                     LINK_X_LIBS="-lXrandr $LINK_X_LIBS";
                     FULLSCREEN_DRIVERS="$FULLSCREEN_DRIVERS xrandr.o";
                     AC_DEFINE(USE_XF86_EXTENSIONS,,[Enable XF86 extensions.])
                     AC_DEFINE(HAVE_FULLSCREEN,,[Enable Fullscreen support.])
                     AC_DEFINE(HAVE_XRANDR,,
                     [Enable XRandR extension.])],,$X_LIBS)
    fi
  fi

  X_LIBS="$PATH_X_LIBS $LINK_X_LIBS"
  AC_SUBST(FULLSCREEN_DRIVERS)

elif test x"$is_dos" = "xyes"; then

  dnl On MS-DOS, we already know what we want.

  LIBS="$LIBS -lalleg $LIBMIDAS"
  AC_SUBST(LDFLAGS)

elif test x"$is_amiga" = "xyes"; then

  dnl On Amiga, we already know what we want.
  if test x"$is_amiga_aros" != "xyes"; then
    if test x"$host_os" != "xmorphos" -a x"$host_os" != "xwarpos" -a x"$host_os" != "xpowerup"; then
      LIBS="$LIBS -lauto"
    fi
  else
    LIBS="$LIBS -lmui"
  fi
  AC_SUBST(LDFLAGS)

  AC_DEFINE(HAS_TRANSLATION,,[Enable internationalization support])

elif test x"$is_beos" = "xyes"; then

  dnl On BEOS, we already know what we want.

  LIBS="$LIBS -lbe -ltracker -ldevice -lgame"
  AC_SUBST(LDFLAGS)

elif test x"$is_unix_gp2x" = "xyes"; then

  dnl on GP2X we need static libs.

  LDFLAGS="$LDFLAGS -static"
  AC_SUBST(LDFLAGS)

elif test x"$is_win32" = "xyes"; then

  dnl On Windows, we already know what we want.

  LIBS="$LIBS -lkernel32 -luser32 -lgdi32 -lwinmm -lcomdlg32 -lcomctl32 -lddraw -ldsound -ldinput -lth32 -lwsock32 -lversion"

  AC_CHECK_LIB(dxguid, GUID_SysMouse,[LIBS="$LIBS -ldxguid";
               AC_DEFINE(HAVE_GUIDLIB,,
                         [Is the GUID lib of DX SDK present?])],,$LIBS)

  AC_MSG_CHECKING([whether DWORD is defined as unsigned long or unsigned int in the Mingw32 headers])
  AC_TRY_COMPILE([#include <windows.h>
extern DWORD test;
unsigned long test; ],
                 ,
                 [ AC_DEFINE(DWORD_IS_LONG,,
                   [Is DWORD defined as long or int in the Windows header files?])
                   AC_MSG_RESULT(unsigned long) ], AC_MSG_RESULT(unsigned int))

  x64_LDFLAGS="-mwindows"
  x128_LDFLAGS="-mwindows"
  xvic_LDFLAGS="-mwindows"
  xpet_LDFLAGS="-mwindows"
  xplus4_LDFLAGS="-mwindows"
  xcbm2_LDFLAGS="-mwindows"

  X64_WINRES="\$(top_builddir)/src/arch/win32/resc64.o"
  X64DTV_WINRES="\$(top_builddir)/src/arch/win32/resc64dtv.o"
  X128_WINRES="\$(top_builddir)/src/arch/win32/resc128.o"
  XVIC_WINRES="\$(top_builddir)/src/arch/win32/resvic20.o"
  XPET_WINRES="\$(top_builddir)/src/arch/win32/respet.o"
  XPLUS4_WINRES="\$(top_builddir)/src/arch/win32/resplus4.o"
  XCBM2_WINRES="\$(top_builddir)/src/arch/win32/rescbm2.o"

  AC_SUBST(LDFLAGS)

  if test -z "$WINDRES" ; then
    WINDRES="windres"
  fi

  AC_SUBST(WINDRES)

  AC_DEFINE(HAS_TRANSLATION,,[Enable internationalization support])
fi

dnl CBM4Linux/OpenCBM
if test x"$enable_realdevice" != "xno"; then
  if test x"$host_os" = "xcygwin32" -o x"$host_os" = "xcygwin" -o x"$host_os" = "xmingw32"; then
    AC_DEFINE(HAVE_OPENCBM,,[Support for OpenCBM (former CBM4Linux).])
    AM_CONDITIONAL(HAVE_REALDEVICE, true)
  else
    AC_CHECK_HEADER(opencbm.h,,)
    if test x"$ac_cv_header_opencbm_h" = "xyes" ; then
      AC_DEFINE(HAVE_OPENCBM_H,,[OpenCBM header file is available.])
      AC_CHECK_LIB(opencbm, cbm_get_eoi,
                   [ LIBS="$LIBS -lopencbm";
                     AC_DEFINE(HAVE_OPENCBM,,
                               [Support for OpenCBM (former CBM4Linux).]) ],,)  
      AM_CONDITIONAL(HAVE_REALDEVICE,
                     test x"$ac_cv_lib_opencbm_cbm_get_eoi" = "xyes")
    else
      AM_CONDITIONAL(HAVE_REALDEVICE, false)
    fi
  fi
else
  AM_CONDITIONAL(HAVE_REALDEVICE, false)
fi

AC_SUBST(x64_LDFLAGS)
AC_SUBST(x128_LDFLAGS)
AC_SUBST(xvic_LDFLAGS)
AC_SUBST(xpet_LDFLAGS)
AC_SUBST(xplus4_LDFLAGS)
AC_SUBST(xcbm2_LDFLAGS)

AC_SUBST(X64_WINRES)
AC_SUBST(X64DTV_WINRES)
AC_SUBST(X128_WINRES)
AC_SUBST(XVIC_WINRES)
AC_SUBST(XPET_WINRES)
AC_SUBST(XPLUS4_WINRES)
AC_SUBST(XCBM2_WINRES)


if test x"$is_unix_gp2x" = "xyes" ; then
  AM_CONDITIONAL(SUPPORT_X64DTV, false)
else
  if test x"$is_riscos" = "xyes"; then
    AM_CONDITIONAL(SUPPORT_X64DTV, false)
  else
    AM_CONDITIONAL(SUPPORT_X64DTV, true)
  fi
fi

dnl Setup the system-specific object files.
if test x"$is_unix" = "xyes"; then
  ARCH_DIR="\$(top_builddir)/src/arch/unix"
  ARCH_SRC_DIR="\$(top_srcdir)/src/arch/unix"
  ARCH_EXTRA_SUBDIR="gui x11"

  if test x"$is_unix_x11" = "xyes" ; then
    if test x"$enable_gnomeui" != "xyes" ; then
      ARCH_LIBS="$ARCH_DIR/libarch.a $ARCH_DIR/gui/libarchgui.a $ARCH_DIR/x11/libx11ui.a $ARCH_DIR/x11/xaw/libxawui.a $ARCH_DIR/x11/xaw/widgets/libwidgets.a $ARCH_DIR/libarch.a $ARCH_DIR/gui/libarchgui.a $ARCH_DIR/x11/libx11ui.a"
      ARCH_INCLUDES="-I$ARCH_SRC_DIR"
    else
      ARCH_LIBS="$ARCH_DIR/libarch.a $ARCH_DIR/gui/libarchgui.a $ARCH_DIR/x11/gnome/libgnomeui.a $ARCH_DIR/x11/libx11ui.a"
      ARCH_INCLUDES="-I$ARCH_SRC_DIR $GTK_CFLAGS $GTKGL_CFLAGS"
    fi
    
    AC_DEFINE(HAVE_READLINE,,[Are we using the readline library replacement?])
    if test x"$READLINE" != x ; then
      ARCH_EXTRA_SUBDIR="$ARCH_EXTRA_SUBDIR readline"
    fi

  fi

  if test x"$is_unix_gp2x" = "xyes" ; then
    ARCH_LIBS="$ARCH_DIR/libarch.a $ARCH_DIR/gp2x/libarchgp2x.a"
    ARCH_INCLUDES="-I$ARCH_SRC_DIR"
    ARCH_EXTRA_SUBDIR="gp2x"
  fi

  if test x"$is_unix_macosx" = "xyes" ; then
    if test x"$with_cocoa" = "xyes" ; then
      ARCH_LIBS="$ARCH_DIR/macosx/cocoa/menu/libarchmacosxcocoamenu.a $ARCH_DIR/macosx/cocoa/dialog/libarchmacosxcocoadialog.a $ARCH_DIR/macosx/cocoa/libarchmacosxcocoa.a $ARCH_DIR/macosx/cocoa/view/libarchmacosxcocoaview.a $ARCH_DIR/macosx/libarchmacosx.a $ARCH_DIR/libarch.a $ARCH_LIBS"
      ARCH_INCLUDES="-I$ARCH_SRC_DIR/macosx/cocoa/menu -I$ARCH_SRC_DIR/macosx/cocoa/dialog -I$ARCH_SRC_DIR/macosx/cocoa/view -I$ARCH_SRC_DIR/macosx/cocoa -I$ARCH_SRC_DIR/macosx -I$ARCH_SRC_DIR $ARCH_INCLUDES"
      ARCH_EXTRA_SUBDIR="macosx macosx/cocoa macosx/cocoa/view macosx/cocoa/menu macosx/cocoa/dialog"
      UI_LIBS="-framework Cocoa -framework OpenGL -framework Carbon"
      UNIX_MACOSX_UITYPE=cocoa
    else
      ARCH_LIBS="$ARCH_DIR/macosx/libarchmacosx.a $ARCH_LIBS"
      ARCH_INCLUDES="-I$ARCH_SRC_DIR/macosx $ARCH_INCLUDES"
      ARCH_EXTRA_SUBDIR="$ARCH_EXTRA_SUBDIR macosx"
      if test x"$enable_gnomeui" != "xyes" ; then
        UNIX_MACOSX_UITYPE=x11
      else
        UNIX_MACOSX_UITYPE=gtk
      fi
    fi
  fi
  AC_SUBST(UNIX_MACOSX_UITYPE)

  AM_CONDITIONAL(UNIX_COMPILE, true)
  AM_CONDITIONAL(WIN32_COMPILE, false)
  AM_CONDITIONAL(MSDOS_COMPILE, false)
  AM_CONDITIONAL(RISCOS_COMPILE, false)
  AM_CONDITIONAL(OS2_COMPILE, false)
  AM_CONDITIONAL(BEOS_COMPILE, false)
  AM_CONDITIONAL(AMIGA_COMPILE, false)
  AM_CONDITIONAL(HAVE_TRANSLATION, false)
  openserver5compile=no
  openserver6compile=no
  unixwarecompile=no
  qnx4compile=no
  qnx6compile=no
  solariscompile=no
  hpuxcompile=no
  skyoscompile=no
  case "$host_os" in
    skyos*)
      skyoscompile=yes
      AM_CONDITIONAL(UNIX_SKYOS_COMPILE, true)
      ;;
    qnx*)
      qnx4compile=yes
      AM_CONDITIONAL(UNIX_QNX4_COMPILE, true)
      ;;
    nto*)
      qnx6compile=yes
      AM_CONDITIONAL(UNIX_QNX6_COMPILE, true)
      ;;
    solaris*)
      solariscompile=yes
      AM_CONDITIONAL(UNIX_SOLARIS_COMPILE, true)
      sol_version=`uname -r`
      if test x"$sol_version" = "x5.7"; then
        ac_configure_args="$ac_configure_args --disable-sse"
      fi
      ;;
    sco3.2v5*)
      openserver5compile=yes
      AM_CONDITIONAL(UNIX_OPENSERVER5_COMPILE, true)
      AC_DEFINE(OPENSERVER5_COMPILE,,[Enable SCO Openserver 5.x support])
      ;;
    sco3.2v6*)
      openserver6compile=yes
      AM_CONDITIONAL(UNIX_OPENSERVER6_COMPILE, true)
      AC_DEFINE(OPENSERVER6_COMPILE,,[Enable SCO Openserver 6.x support])
      ;;
    sco3.2v7*)
      unixwarecompile=yes
      AM_CONDITIONAL(UNIX_UNIXWARE_COMPILE, true)
      AC_DEFINE(UNIXWARE_COMPILE,,[Enable SCO Unixware 7.x support])
      ;;
    hpux*)
      hpuxcompile=yes
      AM_CONDITIONAL(UNIX_HPUX_COMPILE, true)
      ;;
    *)
      ;;  
  esac

  if test x"$skyoscompile" = "xno"; then
    AM_CONDITIONAL(UNIX_SKYOS_COMPILE, false)
  fi

  if test x"$qnx4compile" = "xno"; then
    AM_CONDITIONAL(UNIX_QNX4_COMPILE, false)
  fi

  if test x"$qnx6compile" = "xno"; then
    AM_CONDITIONAL(UNIX_QNX6_COMPILE, false)
  fi

  if test x"$solariscompile" = "xno"; then
    AM_CONDITIONAL(UNIX_SOLARIS_COMPILE, false)
  fi

  if test x"$openserver5compile" = "xno"; then
    AM_CONDITIONAL(UNIX_OPENSERVER5_COMPILE, false)
  fi

  if test x"$openserver6compile" = "xno"; then
    AM_CONDITIONAL(UNIX_OPENSERVER6_COMPILE, false)
  fi

  if test x"$unixwarecompile" = "xno"; then
    AM_CONDITIONAL(UNIX_UNIXWARE_COMPILE, false)
  fi

  if test x"$hpuxcompile" = "xno"; then
    AM_CONDITIONAL(UNIX_HPUX_COMPILE, false)
  fi

  if test x"$is_unix_gp2x" = "xyes" ; then
    AM_CONDITIONAL(UNIX_GP2X_COMPILE, true)
    AM_CONDITIONAL(MAKE_BINDIST, true)
  else
    AM_CONDITIONAL(UNIX_GP2X_COMPILE, false)
  fi

  if test x"$is_unix_macosx" = "xyes" ; then
    AM_CONDITIONAL(UNIX_MACOSX_COMPILE, true)
    if test x"$enable_bundle" != "xno" ; then
      AM_CONDITIONAL(MAKE_BINDIST, true)
    else
      AM_CONDITIONAL(MAKE_BINDIST, false)
    fi
  else
    AM_CONDITIONAL(UNIX_MACOSX_COMPILE, false)
  fi

  if test x"$is_unix_gp2x" != "xyes" -a x"$is_unix_macosx" != "xyes"; then
    AM_CONDITIONAL(MAKE_BINDIST, false)
  fi

elif test x"$is_win32" = "xyes"; then
  ARCH_DIR="\$(top_builddir)/src/arch/win32"
  ARCH_SRC_DIR="\$(top_srcdir)/src/arch/win32"
  ARCH_LIBS="$ARCH_DIR/libarch.a"
  ARCH_INCLUDES="-I\$(top_srcdir)/src/arch/win32"
  AM_CONDITIONAL(UNIX_COMPILE, false)
  AM_CONDITIONAL(UNIX_GP2X_COMPILE, false)
  AM_CONDITIONAL(UNIX_SKYOS_COMPILE, false)
  AM_CONDITIONAL(UNIX_QNX4_COMPILE, false)
  AM_CONDITIONAL(UNIX_QNX6_COMPILE, false)
  AM_CONDITIONAL(UNIX_SOLARIS_COMPILE, false)
  AM_CONDITIONAL(UNIX_OPENSERVER5_COMPILE, false)
  AM_CONDITIONAL(UNIX_OPENSERVER6_COMPILE, false)
  AM_CONDITIONAL(UNIX_UNIXWARE_COMPILE, false)
  AM_CONDITIONAL(UNIX_HPUX_COMPILE, false)
  AM_CONDITIONAL(WIN32_COMPILE, true)
  AM_CONDITIONAL(MSDOS_COMPILE, false)
  AM_CONDITIONAL(RISCOS_COMPILE, false)
  AM_CONDITIONAL(OS2_COMPILE, false)
  AM_CONDITIONAL(BEOS_COMPILE, false)
  AM_CONDITIONAL(AMIGA_COMPILE, false)
  AM_CONDITIONAL(UNIX_MACOSX_COMPILE, false)
  AM_CONDITIONAL(HAVE_TRANSLATION, true)
  AM_CONDITIONAL(MAKE_BINDIST, true)
elif test x"$is_amiga" = "xyes"; then
  ARCH_DIR="\$(top_builddir)/src/arch/amigaos"
  ARCH_SRC_DIR="\$(top_srcdir)/src/arch/amigaos"
  ARCH_LIBS="$ARCH_DIR/libarch.a"
  ARCH_INCLUDES="-I\$(top_srcdir)/src/arch/amigaos"
  AM_CONDITIONAL(UNIX_COMPILE, false)
  AM_CONDITIONAL(UNIX_GP2X_COMPILE, false)
  AM_CONDITIONAL(UNIX_SKYOS_COMPILE, false)
  AM_CONDITIONAL(UNIX_QNX4_COMPILE, false)
  AM_CONDITIONAL(UNIX_QNX6_COMPILE, false)
  AM_CONDITIONAL(UNIX_SOLARIS_COMPILE, false)
  AM_CONDITIONAL(UNIX_OPENSERVER5_COMPILE, false)
  AM_CONDITIONAL(UNIX_OPENSERVER6_COMPILE, false)
  AM_CONDITIONAL(UNIX_UNIXWARE_COMPILE, false)
  AM_CONDITIONAL(UNIX_HPUX_COMPILE, false)
  AM_CONDITIONAL(WIN32_COMPILE, false)
  AM_CONDITIONAL(MSDOS_COMPILE, false)
  AM_CONDITIONAL(RISCOS_COMPILE, false)
  AM_CONDITIONAL(OS2_COMPILE, false)
  AM_CONDITIONAL(BEOS_COMPILE, false)
  AM_CONDITIONAL(AMIGA_COMPILE, true)
  AM_CONDITIONAL(UNIX_MACOSX_COMPILE, false)
  AM_CONDITIONAL(HAVE_TRANSLATION, true)
  AM_CONDITIONAL(MAKE_BINDIST, true)
elif test x"$is_dos" = "xyes"; then
  ARCH_INCLUDES="-I\$(top_srcdir)/src/arch/msdos"
  ARCH_DIR="\$(top_builddir)/src/arch/msdos"
  ARCH_SRC_DIR="\$(top_srcdir)/src/arch/msdos"
  if test $ac_cv_lib_pcap_pcap_open_live = yes; then
  ARCH_LIBS="$ARCH_DIR/libarch.a $ARCH_DIR/libpcap_nodma.a"
  else
  ARCH_LIBS="$ARCH_DIR/libarch.a"
  fi
  AM_CONDITIONAL(UNIX_COMPILE, false)
  AM_CONDITIONAL(UNIX_GP2X_COMPILE, false)
  AM_CONDITIONAL(UNIX_SKYOS_COMPILE, false)
  AM_CONDITIONAL(UNIX_QNX4_COMPILE, false)
  AM_CONDITIONAL(UNIX_QNX6_COMPILE, false)
  AM_CONDITIONAL(UNIX_SOLARIS_COMPILE, false)
  AM_CONDITIONAL(UNIX_OPENSERVER5_COMPILE, false)
  AM_CONDITIONAL(UNIX_OPENSERVER6_COMPILE, false)
  AM_CONDITIONAL(UNIX_UNIXWARE_COMPILE, false)
  AM_CONDITIONAL(UNIX_HPUX_COMPILE, false)
  AM_CONDITIONAL(WIN32_COMPILE, false)
  AM_CONDITIONAL(MSDOS_COMPILE, true)
  AM_CONDITIONAL(RISCOS_COMPILE, false)
  AM_CONDITIONAL(OS2_COMPILE, false)
  AM_CONDITIONAL(BEOS_COMPILE, false)
  AM_CONDITIONAL(AMIGA_COMPILE, false)
  AM_CONDITIONAL(UNIX_MACOSX_COMPILE, false)
  AM_CONDITIONAL(HAVE_TRANSLATION, false)
  AM_CONDITIONAL(MAKE_BINDIST, true)
elif test x"$is_os2" = "xyes"; then
  ARCH_INCLUDES="-I\$(top_srcdir)/src/arch/os2"
  ARCH_DIR="\$(top_builddir)/src/arch/os2"
  ARCH_SRC_DIR="\$(top_srcdir)/src/arch/os2"
  ARCH_LIBS="$ARCH_DIR/libarch.a"
  AM_CONDITIONAL(UNIX_COMPILE, false)
  AM_CONDITIONAL(UNIX_GP2X_COMPILE, false)
  AM_CONDITIONAL(UNIX_SKYOS_COMPILE, false)
  AM_CONDITIONAL(UNIX_QNX4_COMPILE, false)
  AM_CONDITIONAL(UNIX_QNX6_COMPILE, false)
  AM_CONDITIONAL(UNIX_SOLARIS_COMPILE, false)
  AM_CONDITIONAL(UNIX_OPENSERVER5_COMPILE, false)
  AM_CONDITIONAL(UNIX_OPENSERVER6_COMPILE, false)
  AM_CONDITIONAL(UNIX_UNIXWARE_COMPILE, false)
  AM_CONDITIONAL(UNIX_HPUX_COMPILE, false)
  AM_CONDITIONAL(WIN32_COMPILE, false)
  AM_CONDITIONAL(MSDOS_COMPILE, false)
  AM_CONDITIONAL(RISCOS_COMPILE, false)
  AM_CONDITIONAL(OS2_COMPILE, true)
  AM_CONDITIONAL(BEOS_COMPILE, false)
  AM_CONDITIONAL(AMIGA_COMPILE, false)
  AM_CONDITIONAL(UNIX_MACOSX_COMPILE, false)
  AM_CONDITIONAL(HAVE_TRANSLATION, false)
  AM_CONDITIONAL(MAKE_BINDIST, true)
elif test x"$is_beos" = "xyes"; then
  ARCH_INCLUDES="-I\$(top_srcdir)/src/arch/beos"
  ARCH_DIR="\$(top_builddir)/src/arch/beos"
  ARCH_SRC_DIR="\$(top_srcdir)/src/arch/beos"
  ARCH_LIBS="$ARCH_DIR/libarch.a"
  AM_CONDITIONAL(UNIX_COMPILE, false)
  AM_CONDITIONAL(UNIX_GP2X_COMPILE, false)
  AM_CONDITIONAL(UNIX_SKYOS_COMPILE, false)
  AM_CONDITIONAL(UNIX_QNX4_COMPILE, false)
  AM_CONDITIONAL(UNIX_QNX6_COMPILE, false)
  AM_CONDITIONAL(UNIX_SOLARIS_COMPILE, false)
  AM_CONDITIONAL(UNIX_OPENSERVER5_COMPILE, false)
  AM_CONDITIONAL(UNIX_OPENSERVER6_COMPILE, false)  
  AM_CONDITIONAL(UNIX_UNIXWARE_COMPILE, false)  
  AM_CONDITIONAL(UNIX_HPUX_COMPILE, false)
  AM_CONDITIONAL(WIN32_COMPILE, false)
  AM_CONDITIONAL(MSDOS_COMPILE, false)
  AM_CONDITIONAL(RISCOS_COMPILE, false)
  AM_CONDITIONAL(OS2_COMPILE, false)
  AM_CONDITIONAL(BEOS_COMPILE, true)
  AM_CONDITIONAL(AMIGA_COMPILE, false)
  AM_CONDITIONAL(UNIX_MACOSX_COMPILE, false)
  AM_CONDITIONAL(HAVE_TRANSLATION, false)
  AM_CONDITIONAL(MAKE_BINDIST, true)
elif test x"$is_riscos" = "xyes"; then
  ARCH_INCLUDES="-I\$(top_srcdir)/src/arch/riscos"
  ARCH_DIR="\$(top_builddir)/src/arch/riscos"
  ARCH_SRC_DIR="\$(top_srcdir)/src/arch/riscos"
  ARCH_LIBS="$ARCH_DIR/libarch.a"
  AM_CONDITIONAL(UNIX_COMPILE, false)
  AM_CONDITIONAL(UNIX_GP2X_COMPILE, false)
  AM_CONDITIONAL(UNIX_SKYOS_COMPILE, false)
  AM_CONDITIONAL(UNIX_QNX4_COMPILE, false)
  AM_CONDITIONAL(UNIX_QNX6_COMPILE, false)
  AM_CONDITIONAL(UNIX_SOLARIS_COMPILE, false)
  AM_CONDITIONAL(UNIX_OPENSERVER5_COMPILE, false)
  AM_CONDITIONAL(UNIX_OPENSERVER6_COMPILE, false)
  AM_CONDITIONAL(UNIX_UNIXWARE_COMPILE, false)
  AM_CONDITIONAL(UNIX_HPUX_COMPILE, false)
  AM_CONDITIONAL(WIN32_COMPILE, false)
  AM_CONDITIONAL(MSDOS_COMPILE, false)
  AM_CONDITIONAL(RISCOS_COMPILE, true)
  AM_CONDITIONAL(OS2_COMPILE, false)
  AM_CONDITIONAL(BEOS_COMPILE, false)
  AM_CONDITIONAL(AMIGA_COMPILE, false)
  AM_CONDITIONAL(UNIX_MACOSX_COMPILE, false)
  AM_CONDITIONAL(HAVE_TRANSLATION, false)
  AM_CONDITIONAL(MAKE_BINDIST, true)
else
  AC_MSG_WARN([No architecture defined!])
fi

dnl Check wether we have gcc and solaris /usr/openwin stuff.
dnl The headers there give zillions of warnings because of implicit int 
dnl declarations. gcc's >= 2.6.3 know the `-Wno-implicit-int' option so I 
dnl don't care about checking it out. MP

if test x"$GCC" = "xyes" ; then
  case "$host_os" in
    solaris*)
      if echo ${CFLAGS} ${ARCH_INCLUDES} | grep "I/usr/openwin/include" > /dev/null 2>&1 ; then
  	CFLAGS="${CFLAGS} -Wno-implicit-int"
      fi
      ;;
    *)
      ;;  
  esac
fi

AC_SUBST(HAVE_READLINE)
AC_SUBST(ARCH_INCLUDES)
AC_SUBST(ARCH_LIBS)
AC_SUBST(ARCH_DIR)
AC_SUBST(ARCH_SRC_DIR)
AC_SUBST(ARCH_EXTRA_SUBDIR)
AC_SUBST(UI_LIBS)
AC_SUBST(SOUND_USS_OBJ)
AC_SUBST(SOUND_SGI_OBJ)
AC_SUBST(SOUND_HPUX_OBJ)
AC_SUBST(SOUND_AIX_OBJ)
AC_SUBST(SOUND_MIDAS_OBJ)
AC_SUBST(SOUND_SDL_OBJ)

if test "$prefix" = NONE && test "$exec_prefix" = NONE; then
  PREFIX="$ac_default_prefix"
elif test "$prefix" = NONE; then
  PREFIX="$exec_prefix"
else
  PREFIX="$prefix"
fi

AC_DEFINE_UNQUOTED(PREFIX, "$PREFIX",
		   [Where do we want to install the executable?])

dnl Path for keymaps, ROMs etc.
case "$host_os" in
  netbsd*)
    VICEDIR="$PREFIX/share/vice";
    AM_CONDITIONAL(ALTERNATE_DOCDIR, true)
    ;;
  freebsd*)
    VICEDIR="$PREFIX/lib/vice";
    AM_CONDITIONAL(ALTERNATE_DOCDIR, true)
    ;;
  *)
    VICEDIR="$PREFIX/lib/vice";
    AM_CONDITIONAL(ALTERNATE_DOCDIR, false)
    ;;  
esac
AC_SUBST(VICEDIR)

if false ; then
    dnl Now produce the directories & Makefiles.

    mkdir -p arch/amigaos
    mkdir -p arch/beos
    mkdir -p arch/msdos
    mkdir -p arch/os2
    mkdir -p arch/os2/dialogs
    mkdir -p arch/os2/icons
    mkdir -p arch/os2/kbd
    mkdir -p arch/os2/snippets
    mkdir -p arch/os2/vac++
    mkdir -p arch/riscos
    mkdir -p arch/unix
    mkdir -p arch/unix/gp2x
    mkdir -p arch/unix/gui
    mkdir -p arch/unix/readline
    mkdir -p arch/unix/x11
    mkdir -p arch/unix/x11/gnome
    mkdir -p arch/unix/x11/xaw
    mkdir -p arch/unix/x11/xaw/widgets
    mkdir -p arch/unix/macosx
    mkdir -p arch/unix/macosx/cocoa
    mkdir -p arch/unix/macosx/cocoa/view
    mkdir -p arch/unix/macosx/cocoa/menu
    mkdir -p arch/unix/macosx/cocoa/dialog
    mkdir -p arch/win32
    mkdir -p arch/win32/utils
    mkdir -p c128
    mkdir -p c64
    mkdir -p c64/cart
    mkdir -p cbm2
    mkdir -p core
    mkdir -p crtc
    mkdir -p diskimage
    mkdir -p drive
    mkdir -p drive/iec
    mkdir -p drive/iec/c64exp
    mkdir -p drive/iec/plus4exp
    mkdir -p drive/iec128dcr
    mkdir -p drive/iecieee
    mkdir -p drive/ieee
    mkdir -p drive/tcbm
    mkdir -p fileio
    mkdir -p fsdevice
    mkdir -p gfxoutputdrv
    mkdir -p iecbus
    mkdir -p imagecontents
    mkdir -p lib
    mkdir -p lib/lpng
    mkdir -p lib/zlib
    mkdir -p monitor
    mkdir -p parallel
    mkdir -p pet
    mkdir -p plus4
    mkdir -p printerdrv
    mkdir -p raster
    mkdir -p resid
    mkdir -p resid-fp
    mkdir -p rs232drv
    mkdir -p serial
    mkdir -p sid
    mkdir -p sounddrv
    mkdir -p tape
    mkdir -p vdc
    mkdir -p vdrive
    mkdir -p vic20
    mkdir -p vicii
    mkdir -p video 

    if test x"$srcdir" != "x." ; then
        BINDIR="./bin"
        mkdir -p "$BINDIR"
        rm -f "$BINDIR/C64" "$BINDIR/PET" "$BINDIR/VIC20"
        $LN_S "../$srcdir/../bin/C64" "$BINDIR/C64"
        $LN_S "../$srcdir/../bin/PET" "$BINDIR/PET"
        $LN_S "../$srcdir/../bin/VIC20" "$BINDIR/VIC20"
    else
        BINDIR="../bin"
    fi

    AC_SUBST(BINDIR)
fi

AC_OUTPUT([Makefile
           build/Makefile
           data/Makefile
           data/C128/Makefile
           data/C64/Makefile
           data/C64DTV/Makefile
           data/CBM-II/Makefile
           data/DRIVES/Makefile
           data/PET/Makefile
           data/PLUS4/Makefile
           data/PRINTER/Makefile
           data/VIC20/Makefile
           data/fonts/Makefile
           doc/Makefile
           doc/html/Makefile
           man/Makefile
           src/Makefile
           src/arch/Makefile
           src/arch/amigaos/Makefile
           src/arch/beos/Makefile
           src/arch/msdos/Makefile
           src/arch/os2/Makefile
           src/arch/os2/dialogs/Makefile
           src/arch/os2/kbd/Makefile
           src/arch/os2/snippets/Makefile
           src/arch/os2/vac++/Makefile
           src/arch/riscos/Makefile
           src/arch/unix/Makefile
           src/arch/unix/gp2x/Makefile
           src/arch/unix/gui/Makefile
           src/arch/unix/readline/Makefile
           src/arch/unix/x11/Makefile
           src/arch/unix/x11/gnome/Makefile
           src/arch/unix/x11/xaw/Makefile
           src/arch/unix/x11/xaw/widgets/Makefile
           src/arch/unix/macosx/Makefile
           src/arch/unix/macosx/cocoa/Makefile
           src/arch/unix/macosx/cocoa/view/Makefile
           src/arch/unix/macosx/cocoa/menu/Makefile
           src/arch/unix/macosx/cocoa/dialog/Makefile
           src/arch/unix/macosx/Resources/Makefile
           src/arch/unix/macosx/Resources/English.lproj/Makefile
           src/arch/win32/Makefile
           src/arch/win32/utils/Makefile
           src/c128/Makefile
           src/c64/Makefile
           src/c64/cart/Makefile
           src/c64dtv/Makefile
           src/cbm2/Makefile
           src/core/Makefile
           src/crtc/Makefile
           src/diskimage/Makefile
           src/drive/Makefile
           src/drive/iec/Makefile
           src/drive/iec/c64exp/Makefile
           src/drive/iec/plus4exp/Makefile
           src/drive/iec128dcr/Makefile
           src/drive/iecieee/Makefile
           src/drive/ieee/Makefile
           src/drive/tcbm/Makefile
           src/fileio/Makefile
           src/fsdevice/Makefile
           src/gfxoutputdrv/Makefile
           src/iecbus/Makefile
           src/imagecontents/Makefile
           src/lib/Makefile
           src/lib/lpng/Makefile
           src/lib/zlib/Makefile
           src/monitor/Makefile
           src/parallel/Makefile
           src/pet/Makefile
           src/plus4/Makefile
           src/printerdrv/Makefile
           src/raster/Makefile
           src/rs232drv/Makefile
           src/serial/Makefile
           src/sid/Makefile
           src/sounddrv/Makefile
           src/tape/Makefile
           src/vdc/Makefile
           src/vdrive/Makefile
           src/vic20/Makefile
           src/vicii/Makefile
           src/video/Makefile
           src/version.h
           po/Makefile.in
           ])

dnl Local Variables:
dnl mode: autoconf
dnl compile-command: "autoconf"
dnl End: