aboutsummaryrefslogtreecommitdiffstats
path: root/distrib/sdl-1.2.15/configure.in
blob: 08c8e1e97c678763462d088dfe1447ed84f05645 (plain)
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
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
dnl Process this file with autoconf to produce a configure script.
AC_INIT(README)
AC_CONFIG_HEADER(include/SDL_config.h)
AC_GNU_SOURCE
AC_CONFIG_AUX_DIRS($srcdir/build-scripts)

dnl Set various version strings - taken gratefully from the GTk sources
#
# Making releases:
# Edit include/SDL/SDL_version.h and change the version, then:
#   SDL_MICRO_VERSION += 1;
#   SDL_INTERFACE_AGE += 1;
#   SDL_BINARY_AGE += 1;
# if any functions have been added, set SDL_INTERFACE_AGE to 0.
# if backwards compatibility has been broken,
# set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
#
SDL_MAJOR_VERSION=1
SDL_MINOR_VERSION=2
SDL_MICRO_VERSION=15
SDL_INTERFACE_AGE=4
SDL_BINARY_AGE=15
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION

AC_SUBST(SDL_MAJOR_VERSION)
AC_SUBST(SDL_MINOR_VERSION)
AC_SUBST(SDL_MICRO_VERSION)
AC_SUBST(SDL_INTERFACE_AGE)
AC_SUBST(SDL_BINARY_AGE)
AC_SUBST(SDL_VERSION)

# libtool versioning
LT_INIT([win32-dll])

LT_RELEASE=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION
LT_CURRENT=`expr $SDL_MICRO_VERSION - $SDL_INTERFACE_AGE`
LT_REVISION=$SDL_INTERFACE_AGE
LT_AGE=`expr $SDL_BINARY_AGE - $SDL_INTERFACE_AGE`
m4_pattern_allow([^LT_])

AC_SUBST(LT_RELEASE)
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)

dnl Detect the canonical build and host environments
AC_CONFIG_AUX_DIR([build-scripts])
dnl AC_CANONICAL_HOST
AC_C_BIGENDIAN
if test x$ac_cv_c_bigendian = xyes; then
    AC_DEFINE(SDL_BYTEORDER, 4321)
else
    AC_DEFINE(SDL_BYTEORDER, 1234)
fi

dnl Check for tools
AC_PROG_LIBTOOL
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_CHECK_TOOL(WINDRES, [windres], [:])

dnl Set up the compiler and linker flags
INCLUDE="-I$srcdir/include"
if test x$srcdir != x.; then
    # Remove SDL_config.h from the source directory, since it's the
    # default one, and we want to include the one that we generate.
    if test -f $srcdir/include/SDL_config.h; then
        rm $srcdir/include/SDL_config.h
    fi
    INCLUDE="-Iinclude $INCLUDE"
fi
case "$host" in
    *-*-cygwin*)
        # We build SDL on cygwin without the UNIX emulation layer
        BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
        BASE_LDFLAGS="-mno-cygwin"
        ;;
    *)
        BASE_CFLAGS="-D_GNU_SOURCE=1"
        BASE_LDFLAGS=""
        ;;
esac
BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
BUILD_LDFLAGS="$LDFLAGS"
EXTRA_LDFLAGS="$BASE_LDFLAGS"
## These are common directories to find software packages
#for path in /usr/freeware /usr/pkg /usr/X11R6 /usr/local; do
#    if test -d $path/include; then
#        EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
#    fi
#    if test -d $path/lib; then
#        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
#    fi
#done
SDL_CFLAGS="$BASE_CFLAGS"
SDL_LIBS="-lSDL $BASE_LDFLAGS"
CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
CFLAGS="$CFLAGS $EXTRA_CFLAGS"
LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"

dnl set this to use on systems that use lib64 instead of lib
base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`

dnl Function to find a library in the compiler search path
find_lib()
{
    gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
    gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
    env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
    if test "$cross_compiling" = yes; then
        host_lib_path=""
    else
        host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
    fi
    for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
        lib=[`ls -- $path/$1 2>/dev/null | sort | sed 's/.*\/\(.*\)/\1/; q'`]
        if test x$lib != x; then
            echo $lib
            return
        fi
    done
}

dnl Check for compiler characteristics
AC_C_CONST
AC_C_INLINE
AC_C_VOLATILE

dnl See whether we are allowed to use the system C library
AC_ARG_ENABLE(libc,
AC_HELP_STRING([--enable-libc], [Use the system C library [[default=yes]]]),
              , enable_libc=yes)
if test x$enable_libc = xyes; then
    AC_DEFINE(HAVE_LIBC)

    dnl Check for C library headers
    AC_HEADER_STDC
    AC_CHECK_HEADERS(sys/types.h stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h strings.h inttypes.h stdint.h ctype.h math.h iconv.h signal.h)

    dnl Check for typedefs, structures, etc.
    AC_TYPE_SIZE_T
    if test x$ac_cv_header_inttypes_h = xyes -o x$ac_cv_header_stdint_h = xyes; then
        AC_CHECK_TYPE(int64_t)
        if test x$ac_cv_type_int64_t = xyes; then
            AC_DEFINE(SDL_HAS_64BIT_TYPE)
        fi
        have_inttypes=yes
    fi

    dnl Checks for library functions.
    case "$host" in
    *-*-cygwin* | *-*-mingw32*)
        ;;
    *)
        AC_FUNC_ALLOCA
        ;;
    esac

    AC_FUNC_MEMCMP
    if test x$ac_cv_func_memcmp_working = xyes; then
        AC_DEFINE(HAVE_MEMCMP)
    fi
    AC_FUNC_STRTOD
    if test x$ac_cv_func_strtod = xyes; then
        AC_DEFINE(HAVE_STRTOD)
    fi
    AC_CHECK_FUNC(mprotect,
        AC_TRY_COMPILE([
          #include <sys/types.h>
          #include <sys/mman.h>
        ],[
        ],[
        AC_DEFINE(HAVE_MPROTECT)
        ]),
    )
    AC_CHECK_FUNCS(malloc calloc realloc free getenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp sscanf snprintf vsnprintf iconv sigaction setjmp nanosleep)

    AC_CHECK_LIB(iconv, libiconv_open, [EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
    AC_CHECK_LIB(m, pow, [EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])

    AC_CHECK_MEMBER(struct sigaction.sa_sigaction,[AC_DEFINE(HAVE_SA_SIGACTION)], ,[#include <signal.h>])
fi

if test x$have_inttypes != xyes; then
    AC_CHECK_SIZEOF(char, 1)
    AC_CHECK_SIZEOF(short, 2)
    AC_CHECK_SIZEOF(int, 4)
    AC_CHECK_SIZEOF(long, 4)
    AC_CHECK_SIZEOF(long long, 8)
    if test x$ac_cv_sizeof_char = x1; then
        AC_DEFINE(int8_t, signed char)
        AC_DEFINE(uint8_t, unsigned char)
    fi
    if test x$ac_cv_sizeof_short = x2; then
        AC_DEFINE(int16_t, signed short)
        AC_DEFINE(uint16_t, unsigned short)
    else
        if test x$ac_cv_sizeof_int = x2; then
            AC_DEFINE(int16_t, signed int)
            AC_DEFINE(uint16_t, unsigned int)
        fi
    fi
    if test x$ac_cv_sizeof_int = x4; then
        AC_DEFINE(int32_t, signed int)
        AC_DEFINE(uint32_t, unsigned int)
    else
        if test x$ac_cv_sizeof_long = x4; then
            AC_DEFINE(int32_t, signed long)
            AC_DEFINE(uint32_t, unsigned long)
        fi
    fi
    if test x$ac_cv_sizeof_long = x8; then
        AC_DEFINE(int64_t, signed long)
        AC_DEFINE(uint64_t, unsigned long)
        AC_DEFINE(SDL_HAS_64BIT_TYPE)
    else
        if test x$ac_cv_sizeof_long_long = x8; then
            AC_DEFINE(int64_t, signed long long)
            AC_DEFINE(uint64_t, unsigned long long)
            AC_DEFINE(SDL_HAS_64BIT_TYPE)
        fi
    fi
    AC_DEFINE(size_t, unsigned int)
    AC_DEFINE(uintptr_t, unsigned long)
fi

# Standard C sources
SOURCES="$SOURCES $srcdir/src/*.c"
SOURCES="$SOURCES $srcdir/src/audio/*.c"
SOURCES="$SOURCES $srcdir/src/cdrom/*.c"
SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
SOURCES="$SOURCES $srcdir/src/events/*.c"
SOURCES="$SOURCES $srcdir/src/file/*.c"
SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
SOURCES="$SOURCES $srcdir/src/thread/*.c"
SOURCES="$SOURCES $srcdir/src/timer/*.c"
SOURCES="$SOURCES $srcdir/src/video/*.c"

dnl Enable/disable various subsystems of the SDL library

AC_ARG_ENABLE(audio,
AC_HELP_STRING([--enable-audio], [Enable the audio subsystem [[default=yes]]]),
              , enable_audio=yes)
if test x$enable_audio != xyes; then
    AC_DEFINE(SDL_AUDIO_DISABLED)
fi
AC_ARG_ENABLE(video,
AC_HELP_STRING([--enable-video], [Enable the video subsystem [[default=yes]]]),
              , enable_video=yes)
if test x$enable_video != xyes; then
    AC_DEFINE(SDL_VIDEO_DISABLED)
fi
AC_ARG_ENABLE(events,
AC_HELP_STRING([--enable-events], [Enable the events subsystem [[default=yes]]]),
              , enable_events=yes)
if test x$enable_events != xyes; then
    AC_DEFINE(SDL_EVENTS_DISABLED)
fi
AC_ARG_ENABLE(joystick,
AC_HELP_STRING([--enable-joystick], [Enable the joystick subsystem [[default=yes]]]),
              , enable_joystick=yes)
if test x$enable_joystick != xyes; then
    AC_DEFINE(SDL_JOYSTICK_DISABLED)
else
    SOURCES="$SOURCES $srcdir/src/joystick/*.c"
fi
AC_ARG_ENABLE(cdrom,
AC_HELP_STRING([--enable-cdrom], [Enable the cdrom subsystem [[default=yes]]]),
              , enable_cdrom=yes)
if test x$enable_cdrom != xyes; then
    AC_DEFINE(SDL_CDROM_DISABLED)
fi
AC_ARG_ENABLE(threads,
AC_HELP_STRING([--enable-threads], [Enable the threading subsystem [[default=yes]]]),
              , enable_threads=yes)
if test x$enable_threads != xyes; then
    AC_DEFINE(SDL_THREADS_DISABLED)
fi
AC_ARG_ENABLE(timers,
AC_HELP_STRING([--enable-timers], [Enable the timer subsystem [[default=yes]]]),
              , enable_timers=yes)
if test x$enable_timers != xyes; then
    AC_DEFINE(SDL_TIMERS_DISABLED)
fi
AC_ARG_ENABLE(file,
AC_HELP_STRING([--enable-file], [Enable the file subsystem [[default=yes]]]),
              , enable_file=yes)
if test x$enable_file != xyes; then
    AC_DEFINE(SDL_FILE_DISABLED)
fi
AC_ARG_ENABLE(loadso,
AC_HELP_STRING([--enable-loadso], [Enable the shared object loading subsystem [[default=yes]]]),
              , enable_loadso=yes)
if test x$enable_loadso != xyes; then
    AC_DEFINE(SDL_LOADSO_DISABLED)
fi
AC_ARG_ENABLE(cpuinfo,
AC_HELP_STRING([--enable-cpuinfo], [Enable the cpuinfo subsystem [[default=yes]]]),
              , enable_cpuinfo=yes)
if test x$enable_cpuinfo != xyes; then
    AC_DEFINE(SDL_CPUINFO_DISABLED)
fi
AC_ARG_ENABLE(assembly,
AC_HELP_STRING([--enable-assembly], [Enable assembly routines [[default=yes]]]),
              , enable_assembly=yes)
if test x$enable_assembly = xyes; then
    AC_DEFINE(SDL_ASSEMBLY_ROUTINES)
fi

dnl See if the OSS audio interface is supported
CheckOSS()
{
    AC_ARG_ENABLE(oss,
AC_HELP_STRING([--enable-oss], [support the OSS audio API [[default=yes]]]),
                  , enable_oss=yes)
    if test x$enable_audio = xyes -a x$enable_oss = xyes; then
        AC_MSG_CHECKING(for OSS audio support)
        have_oss=no
        if test x$have_oss != xyes; then
            AC_TRY_COMPILE([
              #include <sys/soundcard.h>
            ],[
              int arg = SNDCTL_DSP_SETFRAGMENT;
            ],[
            have_oss=yes
            ])
        fi
        if test x$have_oss != xyes; then
            AC_TRY_COMPILE([
              #include <soundcard.h>
            ],[
              int arg = SNDCTL_DSP_SETFRAGMENT;
            ],[
            have_oss=yes
            AC_DEFINE(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H)
            ])
        fi
        AC_MSG_RESULT($have_oss)
        if test x$have_oss = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_OSS)
            SOURCES="$SOURCES $srcdir/src/audio/dsp/*.c"
            SOURCES="$SOURCES $srcdir/src/audio/dma/*.c"
            have_audio=yes

            # We may need to link with ossaudio emulation library
            case "$host" in
                *-*-openbsd*|*-*-netbsd*)
                    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lossaudio";;
            esac
        fi
    fi
}

dnl See if the ALSA audio interface is supported
CheckALSA()
{
    AC_ARG_ENABLE(alsa,
AC_HELP_STRING([--enable-alsa], [support the ALSA audio API [[default=yes]]]),
                  , enable_alsa=yes)
    if test x$enable_audio = xyes -a x$enable_alsa = xyes; then
        AM_PATH_ALSA(0.9.0, have_alsa=yes, have_alsa=no)
        # Restore all flags from before the ALSA detection runs
        CFLAGS="$alsa_save_CFLAGS"
        LDFLAGS="$alsa_save_LDFLAGS"
        LIBS="$alsa_save_LIBS"
        if test x$have_alsa = xyes; then
            AC_ARG_ENABLE(alsa-shared,
AC_HELP_STRING([--enable-alsa-shared], [dynamically load ALSA audio support [[default=yes]]]),
                          , enable_alsa_shared=yes)
            alsa_lib=[`find_lib "libasound.so.*" "$ALSA_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]

            AC_DEFINE(SDL_AUDIO_DRIVER_ALSA)
            SOURCES="$SOURCES $srcdir/src/audio/alsa/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $ALSA_CFLAGS"
            if test x$have_loadso != xyes && \
               test x$enable_alsa_shared = xyes; then
                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ALSA loading])
            fi
            if test x$have_loadso = xyes && \
               test x$enable_alsa_shared = xyes && test x$alsa_lib != x; then
                echo "-- dynamic libasound -> $alsa_lib"
                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ALSA_DYNAMIC, "$alsa_lib")
            else
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ALSA_LIBS"
            fi
            have_audio=yes
        fi
    fi
}

dnl Check whether we want to use IRIX 6.5+ native audio or not
CheckDMEDIA()
{
    if test x$enable_audio = xyes; then
        AC_MSG_CHECKING(for dmedia audio support)
        have_dmedia=no
        AC_TRY_COMPILE([
          #include <dmedia/audio.h>
        ],[
          ALport audio_port;
        ],[
        have_dmedia=yes
        ])
        AC_MSG_RESULT($have_dmedia)
        # Set up files for the audio library
        if test x$have_dmedia = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_DMEDIA)
            SOURCES="$SOURCES $srcdir/src/audio/dmedia/*.c"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -laudio"
            have_audio=yes
        fi
    fi
}

dnl Check whether we want to use Tru64 UNIX native audio or not
CheckMME()
{
    dnl Make sure we are running on an Tru64 UNIX
    case $ARCH in
        osf)
            ;;
        *)
            return
            ;;
    esac
    if test x$enable_audio = xyes; then
        AC_MSG_CHECKING(for MME audio support)
        MME_CFLAGS="-I/usr/include/mme"
        MME_LIBS="-lmme"
        have_mme=no
        save_CFLAGS="$CFLAGS"
        CFLAGS="$CFLAGS $MME_CFLAGS"
        AC_TRY_COMPILE([
          #include <mme_api.h>
        ],[
          HWAVEOUT sound;
        ],[
        have_mme=yes
        ])
        CFLAGS="$save_CFLAGS"
        AC_MSG_RESULT($have_mme)
        # Set up files for the audio library
        if test x$have_mme = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_MMEAUDIO)
            SOURCES="$SOURCES $srcdir/src/audio/mme/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $MME_CFLAGS"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MME_LIBS"
            have_audio=yes
        fi
    fi
}

dnl Find the ESD includes and libraries
CheckESD()
{
    AC_ARG_ENABLE(esd,
AC_HELP_STRING([--enable-esd], [support the Enlightened Sound Daemon [[default=yes]]]),
                  , enable_esd=yes)
    if test x$enable_audio = xyes -a x$enable_esd = xyes; then
        AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
        if test x$have_esd = xyes; then
            AC_ARG_ENABLE(esd-shared,
AC_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [[default=yes]]]),
                          , enable_esd_shared=yes)
            esd_lib=[`find_lib "libesd.so.*" "$ESD_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]

            AC_DEFINE(SDL_AUDIO_DRIVER_ESD)
            SOURCES="$SOURCES $srcdir/src/audio/esd/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $ESD_CFLAGS"
            if test x$have_loadso != xyes && \
               test x$enable_esd_shared = xyes; then
                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ESD loading])
            fi
            if test x$have_loadso = xyes && \
               test x$enable_esd_shared = xyes && test x$esd_lib != x; then
                echo "-- dynamic libesd -> $esd_lib"
                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ESD_DYNAMIC, "$esd_lib")
            else
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ESD_LIBS"
            fi
            have_audio=yes
        fi
    fi
}

dnl Find PulseAudio
CheckPulseAudio()
{
    AC_ARG_ENABLE(pulseaudio,
AC_HELP_STRING([--enable-pulseaudio], [use PulseAudio [[default=yes]]]),
                  , enable_pulseaudio=yes)
    if test x$enable_audio = xyes -a x$enable_pulseaudio = xyes; then
        audio_pulse=no

        PULSE_REQUIRED_VERSION=0.9

        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
        AC_MSG_CHECKING(for PulseAudio $PULSE_REQUIRED_VERSION support)
        if test x$PKG_CONFIG != xno; then
            if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $PULSE_REQUIRED_VERSION libpulse-simple; then
                PULSE_CFLAGS=`$PKG_CONFIG --cflags libpulse-simple`
                PULSE_LIBS=`$PKG_CONFIG --libs libpulse-simple`
                audio_pulse=yes
            fi
        fi
        AC_MSG_RESULT($audio_pulse)

        if test x$audio_pulse = xyes; then
            AC_ARG_ENABLE(pulseaudio-shared,
AC_HELP_STRING([--enable-pulseaudio-shared], [dynamically load PulseAudio support [[default=yes]]]),
                          , enable_pulseaudio_shared=yes)
            pulse_lib=[`find_lib "libpulse-simple.so.*" "$PULSE_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]

            AC_DEFINE(SDL_AUDIO_DRIVER_PULSE)
            SOURCES="$SOURCES $srcdir/src/audio/pulse/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $PULSE_CFLAGS"
            if test x$have_loadso != xyes && \
               test x$enable_pulseaudio_shared = xyes; then
                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic PulseAudio loading])
            fi
            if test x$have_loadso = xyes && \
               test x$enable_pulseaudio_shared = xyes && test x$pulse_lib != x; then
                echo "-- dynamic libpulse-simple -> $pulse_lib"
                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_PULSE_DYNAMIC, "$pulse_lib")
            else
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PULSE_LIBS"
            fi
            have_audio=yes
        fi
    fi
}

CheckARTSC()
{
    AC_ARG_ENABLE(arts,
AC_HELP_STRING([--enable-arts], [support the Analog Real Time Synthesizer [[default=yes]]]),
                  , enable_arts=yes)
    if test x$enable_audio = xyes -a x$enable_arts = xyes; then
        AC_PATH_PROG(ARTSCONFIG, artsc-config)
        if test x$ARTSCONFIG = x -o x$ARTSCONFIG = x'"$ARTSCONFIG"'; then
            : # arts isn't installed
        else
            ARTS_CFLAGS=`$ARTSCONFIG --cflags`
            ARTS_LIBS=`$ARTSCONFIG --libs`
            AC_MSG_CHECKING(for aRts development environment)
            audio_arts=no
            save_CFLAGS="$CFLAGS"
            CFLAGS="$CFLAGS $ARTS_CFLAGS"
            AC_TRY_COMPILE([
             #include <artsc.h>
            ],[
             arts_stream_t stream;
            ],[
            audio_arts=yes
            ])
            CFLAGS="$save_CFLAGS"
            AC_MSG_RESULT($audio_arts)
            if test x$audio_arts = xyes; then
                AC_ARG_ENABLE(arts-shared,
AC_HELP_STRING([--enable-arts-shared], [dynamically load aRts audio support [[default=yes]]]),
                              , enable_arts_shared=yes)
                arts_lib=[`find_lib "libartsc.so.*" "$ARTS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]

                AC_DEFINE(SDL_AUDIO_DRIVER_ARTS)
                SOURCES="$SOURCES $srcdir/src/audio/arts/*.c"
                EXTRA_CFLAGS="$EXTRA_CFLAGS $ARTS_CFLAGS"
                if test x$have_loadso != xyes && \
                   test x$enable_arts_shared = xyes; then
                    AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ARTS loading])
                fi
                if test x$have_loadso = xyes && \
                   test x$enable_arts_shared = xyes && test x$arts_lib != x; then
                    echo "-- dynamic libartsc -> $arts_lib"
                    AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ARTS_DYNAMIC, "$arts_lib")
                else
                    EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ARTS_LIBS"
                fi
                have_audio=yes
            fi
        fi
    fi
}

dnl See if the NAS audio interface is supported
CheckNAS()
{
    AC_ARG_ENABLE(nas,
AC_HELP_STRING([--enable-nas], [support the NAS audio API [[default=yes]]]),
                  , enable_nas=yes)
    if test x$enable_audio = xyes -a x$enable_nas = xyes; then
        AC_CHECK_HEADER(audio/audiolib.h, have_nas_hdr=yes)
        AC_CHECK_LIB(audio, AuOpenServer, have_nas_lib=yes)

        AC_MSG_CHECKING(for NAS audio support)
        have_nas=no

        if test x$have_nas_hdr = xyes -a x$have_nas_lib = xyes; then
            have_nas=yes
            NAS_LIBS="-laudio"

        elif test -r /usr/X11R6/include/audio/audiolib.h; then
            have_nas=yes
            NAS_CFLAGS="-I/usr/X11R6/include/"
            NAS_LIBS="-L/usr/X11R6/lib -laudio -lXt"

        dnl On IRIX, the NAS includes are in a different directory,
        dnl and libnas must be explicitly linked in

        elif test -r /usr/freeware/include/nas/audiolib.h; then
            have_nas=yes
            NAS_LIBS="-lnas -lXt"
        fi

        AC_MSG_RESULT($have_nas)

        if test x$have_nas = xyes; then
            AC_ARG_ENABLE(nas-shared,
AC_HELP_STRING([--enable-nas-shared], [dynamically load NAS audio support [[default=yes]]]),
                          , enable_nas_shared=yes)
            nas_lib=[`find_lib "libaudio.so.*" "$NAS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]

            if test x$have_loadso != xyes && \
               test x$enable_nas_shared = xyes; then
                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic NAS loading])
            fi
            if test x$have_loadso = xyes && \
               test x$enable_nas_shared = xyes && test x$nas_lib != x; then
                echo "-- dynamic libaudio -> $nas_lib"
                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_NAS_DYNAMIC, "$nas_lib")
            else
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $NAS_LIBS"
            fi

            AC_DEFINE(SDL_AUDIO_DRIVER_NAS)
            SOURCES="$SOURCES $srcdir/src/audio/nas/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $NAS_CFLAGS"
            have_audio=yes
        fi
    fi
}

dnl rcg07142001 See if the user wants the disk writer audio driver...
CheckDiskAudio()
{
    AC_ARG_ENABLE(diskaudio,
AC_HELP_STRING([--enable-diskaudio], [support the disk writer audio driver [[default=yes]]]),
                  , enable_diskaudio=yes)
    if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then
        AC_DEFINE(SDL_AUDIO_DRIVER_DISK)
        SOURCES="$SOURCES $srcdir/src/audio/disk/*.c"
    fi
}

dnl rcg03142006 See if the user wants the dummy audio driver...
CheckDummyAudio()
{
    AC_ARG_ENABLE(dummyaudio,
AC_HELP_STRING([--enable-dummyaudio], [support the dummy audio driver [[default=yes]]]),
                  , enable_dummyaudio=yes)
    if test x$enable_audio = xyes -a x$enable_dummyaudio = xyes; then
        AC_DEFINE(SDL_AUDIO_DRIVER_DUMMY)
        SOURCES="$SOURCES $srcdir/src/audio/dummy/*.c"
    fi
}

dnl Set up the Atari Audio driver
CheckAtariAudio()
{
    AC_ARG_ENABLE(mintaudio,
AC_HELP_STRING([--enable-mintaudio], [support Atari audio driver [[default=yes]]]),
                  , enable_mintaudio=yes)
    if test x$enable_audio = xyes -a x$enable_mintaudio = xyes; then
        mintaudio=no
        AC_CHECK_HEADER(mint/falcon.h, have_mint_falcon_hdr=yes)
        if test x$have_mint_falcon_hdr = xyes; then
            mintaudio=yes
            AC_DEFINE(SDL_AUDIO_DRIVER_MINT)
            SOURCES="$SOURCES $srcdir/src/audio/mint/*.c"
            SOURCES="$SOURCES $srcdir/src/audio/mint/*.S"
            have_audio=yes
        fi
    fi
}

dnl See if we can use x86 assembly blitters
# NASM is available from: http://nasm.sourceforge.net
CheckNASM()
{
    dnl Make sure we are running on an x86 platform
    case $host in
        i?86*)
            ;;
        *)
        # Nope, bail early.
            return
            ;;
    esac

    dnl Mac OS X might report itself as "i386" but generate x86_64 code.
    dnl  So see what size we think a pointer is, and bail if not 32-bit.
    AC_CHECK_SIZEOF([void *], 4)
    if test x$ac_cv_sizeof_void_p != x4; then
        return
    fi

    dnl Check for NASM (for assembly blit routines)
    AC_ARG_ENABLE(nasm,
AC_HELP_STRING([--enable-nasm], [use nasm assembly blitters on x86 [[default=yes]]]),
                  , enable_nasm=yes)
    if test x$enable_video = xyes -a x$enable_assembly = xyes -a x$enable_nasm = xyes; then
        CompileNASM()
        {
            # Usage: CompileNASM <filename>
            AC_MSG_CHECKING(to see if $NASM supports $1)
            if $NASM $NASMFLAGS $1 -o $1.o >&AS_MESSAGE_LOG_FD 2>&1; then
                CompileNASM_ret="yes"
            else
                CompileNASM_ret="no"
            fi
            rm -f $1 $1.o
            AC_MSG_RESULT($CompileNASM_ret)
            test "$CompileNASM_ret" = "yes"
        }

        if test x"$NASMFLAGS" = x; then
            case $ARCH in
              win32)
                  NASMFLAGS="-f win32"
                  ;;
              macosx)
                  NASMFLAGS="-f macho"
                  ;;
              *)
                  NASMFLAGS="-f elf32"
                  ;;
            esac
        fi

        AC_PATH_PROG(NASM, nasm)
        echo "%ifidn __OUTPUT_FORMAT__,elf32" > unquoted-sections
        echo "section .note.GNU-stack noalloc noexec nowrite progbits" >> unquoted-sections
        echo "%endif" >> unquoted-sections
        CompileNASM unquoted-sections || NASM=""

        if test "x$NASM" != x -a "x$NASM" != x'"$NASM"'; then
            AC_DEFINE(SDL_HERMES_BLITTERS)
            SOURCES="$SOURCES $srcdir/src/hermes/*.asm"
            NASMFLAGS="$NASMFLAGS -I $srcdir/src/hermes/"

            dnl See if hidden visibility is supported
            echo "GLOBAL _bar:function hidden" > symbol-visibility
            echo "_bar:" >> symbol-visibility
            CompileNASM symbol-visibility && NASMFLAGS="$NASMFLAGS -DHIDDEN_VISIBILITY"

            AC_SUBST(NASM)
            AC_SUBST(NASMFLAGS)

            case "$host" in
                # this line is needed for QNX, because it's not defined the __ELF__
                *-*-qnx*)
                     EXTRA_CFLAGS="$EXTRA_CFLAGS -D__ELF__";;
                *-*-solaris*)
                     EXTRA_CFLAGS="$EXTRA_CFLAGS -D__ELF__";;
            esac
        fi
    fi
}

dnl Check for altivec instruction support using gas syntax
CheckAltivec()
{
    AC_ARG_ENABLE(altivec,
AC_HELP_STRING([--enable-altivec], [use altivec assembly blitters on PPC [[default=yes]]]),
                  , enable_altivec=yes)
    if test x$enable_video = xyes -a x$enable_assembly = xyes -a x$enable_altivec = xyes; then
        save_CFLAGS="$CFLAGS"
        have_gcc_altivec=no
        have_altivec_h_hdr=no
        altivec_CFLAGS="-maltivec"
        CFLAGS="$save_CFLAGS $altivec_CFLAGS"

        AC_MSG_CHECKING(for Altivec with GCC altivec.h and -maltivec option)
        AC_TRY_COMPILE([
        #include <altivec.h>
        vector unsigned int vzero() {
            return vec_splat_u32(0);
        }
        ],[
        ],[
        have_gcc_altivec=yes
        have_altivec_h_hdr=yes
        ])
        AC_MSG_RESULT($have_gcc_altivec)

        if test x$have_gcc_altivec = xno; then
            AC_MSG_CHECKING(for Altivec with GCC -maltivec option)
            AC_TRY_COMPILE([
            vector unsigned int vzero() {
                return vec_splat_u32(0);
            }
            ],[
            ],[
            have_gcc_altivec=yes
            ])
            AC_MSG_RESULT($have_gcc_altivec)
        fi

        if test x$have_gcc_altivec = xno; then
            AC_MSG_CHECKING(for Altivec with GCC altivec.h and -faltivec option)
            altivec_CFLAGS="-faltivec"
            CFLAGS="$save_CFLAGS $altivec_CFLAGS"
            AC_TRY_COMPILE([
            #include <altivec.h>
            vector unsigned int vzero() {
                return vec_splat_u32(0);
            }
            ],[
            ],[
            have_gcc_altivec=yes
            have_altivec_h_hdr=yes
            ])
            AC_MSG_RESULT($have_gcc_altivec)
	fi

        if test x$have_gcc_altivec = xno; then
            AC_MSG_CHECKING(for Altivec with GCC -faltivec option)
            AC_TRY_COMPILE([
            vector unsigned int vzero() {
                return vec_splat_u32(0);
            }
            ],[
            ],[
            have_gcc_altivec=yes
            ])
            AC_MSG_RESULT($have_gcc_altivec)
        fi
        CFLAGS="$save_CFLAGS"

        if test x$have_gcc_altivec = xyes; then
            AC_DEFINE(SDL_ALTIVEC_BLITTERS)
            if test x$have_altivec_h_hdr = xyes; then
              AC_DEFINE(HAVE_ALTIVEC_H)
            fi
            EXTRA_CFLAGS="$EXTRA_CFLAGS $altivec_CFLAGS"
        fi
    fi
}

dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
dnl  Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
CheckVisibilityHidden()
{
    AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
    have_gcc_fvisibility=no

    visibility_CFLAGS="-fvisibility=hidden"
    save_CFLAGS="$CFLAGS"
    CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
    AC_TRY_COMPILE([
    #if !defined(__GNUC__) || __GNUC__ < 4
    #error SDL only uses visibility attributes in GCC 4 or newer
    #endif
    ],[
    ],[
    have_gcc_fvisibility=yes
    ])
    AC_MSG_RESULT($have_gcc_fvisibility)
    CFLAGS="$save_CFLAGS"

    if test x$have_gcc_fvisibility = xyes; then
        EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
    fi
}

dnl See if GCC's -Wall is supported.
CheckWarnAll()
{
    AC_MSG_CHECKING(for GCC -Wall option)
    have_gcc_Wall=no

    save_CFLAGS="$CFLAGS"
    CFLAGS="$save_CFLAGS -Wall"
    AC_TRY_COMPILE([
    int x = 0;
    ],[
    ],[
    have_gcc_Wall=yes
    ])
    AC_MSG_RESULT($have_gcc_Wall)
    CFLAGS="$save_CFLAGS"

    if test x$have_gcc_Wall = xyes; then
        EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"

        dnl Haiku headers use multicharacter constants all over the place. Ignore these warnings when using -Wall.
        AC_MSG_CHECKING(for necessary GCC -Wno-multichar option)
        need_gcc_Wno_multichar=no
        case "$host" in
            *-*-beos* | *-*-haiku*)
                need_gcc_Wno_multichar=yes
                ;;
        esac
        AC_MSG_RESULT($need_gcc_Wno_multichar)
        if test x$need_gcc_Wno_multichar = xyes; then
            EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-multichar"
        fi
    fi
}


dnl Do the iPod thing
CheckIPod()
{
    AC_ARG_ENABLE(ipod,
AC_HELP_STRING([--enable-ipod], [configure SDL to work with iPodLinux [[default=no]]]),
        , enable_ipod=no)

    if test x$enable_ipod = xyes; then
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DIPOD"
        AC_DEFINE(SDL_VIDEO_DRIVER_IPOD)
        SOURCES="$SOURCES $srcdir/src/video/ipod/*.c"
    fi
}

dnl Find the nanox include and library directories
CheckNANOX()
{
    AC_ARG_ENABLE(video-nanox,
        AC_HELP_STRING([--enable-video-nanox], [use nanox video driver [[default=no]]]),
        , enable_video_nanox=no)

    if test x$enable_video = xyes -a x$enable_video_nanox = xyes; then
        AC_ARG_ENABLE(nanox-debug,  
            AC_HELP_STRING([--enable-nanox-debug], [print debug messages [[default=no]]]),
            , enable_nanox_debug=no)
        if test x$enable_nanox_debug = xyes; then
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DENABLE_NANOX_DEBUG"
        fi

        AC_ARG_ENABLE(nanox-share-memory,  
            AC_HELP_STRING([--enable-nanox-share-memory], [use share memory [[default=no]]]),
            , enable_nanox_share_memory=no)
        if test x$enable_nanox_share_memory = xyes; then
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DNANOX_SHARE_MEMORY"
        fi

        AC_ARG_ENABLE(nanox_direct_fb, 
            AC_HELP_STRING([--enable-nanox-direct-fb], [use direct framebuffer access [[default=no]]]),
            , enable_nanox_direct_fb=no)
        if test x$enable_nanox_direct_fb = xyes; then
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DENABLE_NANOX_DIRECT_FB"
        fi

        AC_DEFINE(SDL_VIDEO_DRIVER_NANOX)
        SOURCES="$SOURCES $srcdir/src/video/nanox/*.c"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lnano-X"
        have_video=yes
    fi
}

dnl Find the X11 include and library directories
CheckX11()
{
    AC_ARG_ENABLE(video-x11,
AC_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
                  , enable_video_x11=yes)
    if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
        case "$host" in
            *-*-darwin*)
                # This isn't necessary for X11, but fixes GLX detection
                if test "x$x_includes" = xNONE && test "x$x_libraries" = xNONE; then
                    x_includes="/usr/X11R6/include"
                    x_libraries="/usr/X11R6/lib"
                fi
                ;;
        esac
        AC_PATH_X
        AC_PATH_XTRA
        if test x$have_x = xyes; then
            # Only allow dynamically loaded X11 if the X11 function pointers
            # will not end up in the global namespace, which causes problems
            # with other libraries calling X11 functions.
            x11_symbols_private=$have_gcc_fvisibility

            AC_ARG_ENABLE(x11-shared,
AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=maybe]]]),
                          , enable_x11_shared=maybe)

            case "$host" in
                *-*-darwin*) # Latest Mac OS X actually ships with Xrandr/Xrender libs...
                    x11_symbols_private=yes
                    x11_lib='/usr/X11R6/lib/libX11.6.dylib'
                    x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
                    xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
                    xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
                    ;;
                *-*-osf*)
                    x11_lib='libX11.so'
                    x11ext_lib='libXext.so'
                    ;;
                *-*-irix*) # IRIX 6.5 requires that we use /usr/lib32
                    x11_lib='libX11.so'
                    x11ext_lib='libXext.so'
                    ;;
                *)
                    x11_lib=[`find_lib "libX11.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
                    x11ext_lib=[`find_lib "libXext.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
                    xrender_lib=[`find_lib "libXrender.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
                    xrandr_lib=[`find_lib "libXrandr.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
                    ;;
            esac

            X_CFLAGS="$X_CFLAGS -DXTHREADS"
            if test x$ac_cv_func_shmat != xyes; then
                X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
            fi
            CFLAGS="$CFLAGS $X_CFLAGS"
            LDFLAGS="$LDFLAGS $X_LIBS"

            AC_DEFINE(SDL_VIDEO_DRIVER_X11)
            SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"

            if test x$enable_x11_shared = xmaybe; then
                enable_x11_shared=$x11_symbols_private
            fi
            if test x$have_loadso != xyes && \
               test x$enable_x11_shared = xyes; then
                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
                enable_x11_shared=no
            fi
            if test x$x11_symbols_private != xyes && \
               test x$enable_x11_shared = xyes; then
                AC_MSG_WARN([You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading])
                enable_x11_shared=no
            fi

            if test x$have_loadso = xyes && \
               test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
                echo "-- dynamic libX11 -> $x11_lib"
                echo "-- dynamic libX11ext -> $x11ext_lib"
                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib")
                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib")
            else
                enable_x11_shared=no
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
            fi
            have_video=yes

            AC_ARG_ENABLE(dga,
AC_HELP_STRING([--enable-dga], [allow use of X11 DGA code [[default=yes]]]),
                          , enable_dga=yes)
            if test x$enable_dga = xyes; then
                SOURCES="$SOURCES $srcdir/src/video/Xext/Xxf86dga/*.c"
            fi
            AC_ARG_ENABLE(video-dga,
AC_HELP_STRING([--enable-video-dga], [use DGA 2.0 video driver [[default=yes]]]),
                  , enable_video_dga=yes)
            if test x$enable_dga = xyes -a x$enable_video_dga = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_DGA)
                SOURCES="$SOURCES $srcdir/src/video/dga/*.c"
            fi
            AC_ARG_ENABLE(video-x11-dgamouse,
AC_HELP_STRING([--enable-video-x11-dgamouse], [use X11 DGA for mouse events [[default=yes]]]),
                          , enable_video_x11_dgamouse=yes)
            if test x$enable_dga = xyes -a x$enable_video_x11_dgamouse = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_X11_DGAMOUSE)
            fi
            AC_ARG_ENABLE(video-x11-vm,
AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
                          , enable_video_x11_vm=yes)
            if test x$enable_video_x11_vm = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_X11_VIDMODE)
                SOURCES="$SOURCES $srcdir/src/video/Xext/Xxf86vm/*.c"
            fi
            AC_ARG_ENABLE(video-x11-xv,
AC_HELP_STRING([--enable-video-x11-xv], [use X11 XvImage extension for video [[default=yes]]]),
                          , enable_video_x11_xv=yes)
            if test x$enable_video_x11_xv = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XV)
                SOURCES="$SOURCES $srcdir/src/video/Xext/Xv/*.c"
            fi
            AC_ARG_ENABLE(video-x11-xinerama,
AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
                            , enable_video_x11_xinerama=yes)
            if test x$enable_video_x11_xinerama = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA)
                SOURCES="$SOURCES $srcdir/src/video/Xext/Xinerama/*.c"
            fi
            AC_ARG_ENABLE(video-x11-xme,
AC_HELP_STRING([--enable-video-x11-xme], [enable Xi Graphics XME for fullscreen [[default=yes]]]),
                            , enable_video_x11_xme=yes)
            if test x$enable_video_x11_xme = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XME)
                SOURCES="$SOURCES $srcdir/src/video/Xext/XME/*.c"
            fi
            AC_ARG_ENABLE(video-x11-xrandr,
AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
                            , enable_video_x11_xrandr=yes)
            if test x$enable_video_x11_xrandr = xyes; then
                definitely_enable_video_x11_xrandr=no
                AC_CHECK_HEADER(X11/extensions/Xrandr.h,
                                have_xrandr_h_hdr=yes,
                                have_xrandr_h_hdr=no,
                                [#include <X11/Xlib.h>
                                ])
                if test x$have_xrandr_h_hdr = xyes; then
                    if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
                        echo "-- dynamic libXrender -> $xrender_lib"
                        echo "-- dynamic libXrandr -> $xrandr_lib"
                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER, "$xrender_lib")
                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib")
                        definitely_enable_video_x11_xrandr=yes
                    else
                        AC_CHECK_LIB(Xrender, XRenderQueryExtension, have_xrender_lib=yes)
                        AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
                        if test x$have_xrender_lib = xyes && test x$have_xrandr_lib = xyes ; then
                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr -lXrender"
                            definitely_enable_video_x11_xrandr=yes
                        fi
                    fi
                fi
            fi
            if test x$definitely_enable_video_x11_xrandr = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR)
            fi
        fi
    fi
}

dnl Check for QNX photon video driver
CheckPHOTON()
{
    AC_ARG_ENABLE(video-photon,
AC_HELP_STRING([--enable-video-photon], [use QNX Photon video driver [[default=yes]]]),
                  , enable_video_photon=yes)
    if test x$enable_video = xyes -a x$enable_video_photon = xyes; then
        AC_MSG_CHECKING(for QNX Photon support)
        video_photon=no
        AC_TRY_COMPILE([
          #include <Ph.h>
          #include <Pt.h>
          #include <photon/Pg.h>
          #include <photon/PdDirect.h>
        ],[
         PgDisplaySettings_t *visual;
        ],[
        video_photon=yes
        ])
        AC_MSG_RESULT($video_photon)
        if test x$video_photon = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_PHOTON)
            SOURCES="$SOURCES $srcdir/src/video/photon/*.c"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lph"
            have_video=yes

            CheckOpenGLQNX
        fi
    fi
}

dnl Set up the BWindow video driver if enabled
CheckBWINDOW()
{
    if test x$enable_video = xyes; then
        AC_DEFINE(SDL_VIDEO_DRIVER_BWINDOW)
        SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
        have_video=yes
    fi
}

dnl Set up the Carbon/QuickDraw video driver for Mac OS X (but not Darwin)
CheckCARBON()
{
    AC_ARG_ENABLE(video-carbon,
AC_HELP_STRING([--enable-video-carbon], [use Carbon/QuickDraw video driver [[default=no]]]),
                  , enable_video_carbon=no)
    if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
        AC_MSG_CHECKING(for Carbon framework)
        have_carbon=no
        AC_TRY_COMPILE([
          #include <Carbon/Carbon.h>
        ],[
        ],[
        have_carbon=yes
        ])
        AC_MSG_RESULT($have_carbon)
        if test x$have_carbon = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_TOOLBOX)
            SOURCES="$SOURCES $srcdir/src/video/maccommon/*.c"
            SOURCES="$SOURCES $srcdir/src/video/macrom/*.c"
            have_video=yes
        fi
    fi
}

dnl Set up the Cocoa/Quartz video driver for Mac OS X (but not Darwin)
CheckCOCOA()
{
    AC_ARG_ENABLE(video-cocoa,
AC_HELP_STRING([--enable-video-cocoa], [use Cocoa/Quartz video driver [[default=yes]]]),
                  , enable_video_cocoa=yes)
    if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
        save_CFLAGS="$CFLAGS"
        dnl work around that we don't have Objective-C support in autoconf
        CFLAGS="$CFLAGS -x objective-c"
        AC_MSG_CHECKING(for Cocoa framework)
        have_cocoa=no
        AC_TRY_COMPILE([
          #import <Cocoa/Cocoa.h>
        ],[
        ],[
        have_cocoa=yes
        ])
        AC_MSG_RESULT($have_cocoa)
        CFLAGS="$save_CFLAGS"
        if test x$have_cocoa = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_QUARTZ)
            SOURCES="$SOURCES $srcdir/src/video/quartz/*.m"
            have_video=yes
        fi
    fi
}

dnl Find the framebuffer console includes
CheckFBCON()
{
    AC_ARG_ENABLE(video-fbcon,
AC_HELP_STRING([--enable-video-fbcon], [use framebuffer console video driver [[default=yes]]]),
                  , enable_video_fbcon=yes)
    if test x$enable_video = xyes -a x$enable_video_fbcon = xyes; then
        AC_MSG_CHECKING(for framebuffer console support)
        video_fbcon=no
        AC_TRY_COMPILE([
         #include <linux/fb.h>
         #include <linux/kd.h>
         #include <linux/keyboard.h>
        ],[
        ],[
        video_fbcon=yes
        ])
        AC_MSG_RESULT($video_fbcon)
        if test x$video_fbcon = xyes; then
            AC_CHECK_FUNCS(getpagesize)
            AC_DEFINE(SDL_VIDEO_DRIVER_FBCON)
            SOURCES="$SOURCES $srcdir/src/video/fbcon/*.c"
            have_video=yes
        fi
    fi
}

dnl Find DirectFB
CheckDirectFB()
{
    AC_ARG_ENABLE(video-directfb,
AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=yes]]]),
                  , enable_video_directfb=yes)
    if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
        video_directfb=no

        DIRECTFB_REQUIRED_VERSION=0.9.15

        AC_PATH_PROG(DIRECTFBCONFIG, directfb-config, no)
        if test x$DIRECTFBCONFIG = xno; then
            AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
            if test x$PKG_CONFIG != xno; then
                if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
                    DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
                    DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
                    video_directfb=yes
                fi
            fi
        else
            set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
            NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
            set -- `directfb-config --version | sed 's/\./ /g'`
            HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
            if test $HAVE_VERSION -ge $NEED_VERSION; then
                DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
                DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
                video_directfb=yes
            fi
        fi
        if test x$video_directfb = xyes; then
            # SuSE 11.1 installs directfb-config without directfb-devel
            save_CFLAGS="$CFLAGS"
            CFLAGS="$CFLAGS $DIRECTFB_CFLAGS"
            AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
            CFLAGS="$save_CFLAGS"
            video_directfb=$have_directfb_hdr
        fi
        AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
        AC_MSG_RESULT($video_directfb)

        if test x$video_directfb = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB)
            SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
            have_video=yes
        fi
    fi
}

dnl See if we're running on PlayStation 2 hardware
CheckPS2GS()
{
    AC_ARG_ENABLE(video-ps2gs,
AC_HELP_STRING([--enable-video-ps2gs], [use PlayStation 2 GS video driver [[default=yes]]]),
                  , enable_video_ps2gs=yes)
    if test x$enable_video = xyes -a x$enable_video_ps2gs = xyes; then
        AC_MSG_CHECKING(for PlayStation 2 GS support)
        video_ps2gs=no
        AC_TRY_COMPILE([
         #include <linux/ps2/dev.h>
         #include <linux/ps2/gs.h>
        ],[
        ],[
        video_ps2gs=yes
        ])
        AC_MSG_RESULT($video_ps2gs)
        if test x$video_ps2gs = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_PS2GS)
            SOURCES="$SOURCES $srcdir/src/video/ps2gs/*.c"
            have_video=yes
        fi
    fi
}

dnl See if we're running on PlayStation 3 Cell hardware
CheckPS3()
{
  AC_ARG_ENABLE(video-ps3,
                AC_HELP_STRING([--enable-video-ps3], [use PlayStation 3 Cell driver [[default=yes]]]),
                , enable_video_ps3=yes)
  if test x$enable_video = xyes -a x$enable_video_ps3 = xyes; then
    AC_MSG_CHECKING(for PlayStation 3 Cell support)
    video_ps3=no
    AC_TRY_COMPILE([
      #include <linux/fb.h>
      #include <asm/ps3fb.h>
      #include <libspe2.h>
    ],[
    ],[
      video_ps3=yes
    ])
    AC_MSG_RESULT($video_ps3)
    if test x$video_ps3 = xyes; then
      AC_DEFINE(SDL_VIDEO_DRIVER_PS3)
      SOURCES="$SOURCES $srcdir/src/video/ps3/*.c"
      EXTRA_CFLAGS="$EXTRA_CFLAGS -I/opt/cell/sdk/usr/include"
      EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lbilin_scaler_spu -lfb_writer_spu -lyuv2rgb_spu -L/opt/cell/sdk/usr/lib -lspe2"
      have_video=yes
    fi
  fi
}

dnl Find the GGI includes
CheckGGI()
{
    AC_ARG_ENABLE(video-ggi,
AC_HELP_STRING([--enable-video-ggi], [use GGI video driver [[default=no]]]),
                  , enable_video_ggi=no)
    if test x$enable_video = xyes -a x$enable_video_ggi = xyes; then
        AC_MSG_CHECKING(for GGI support)
        video_ggi=no
        AC_TRY_COMPILE([
         #include <ggi/ggi.h>
         #include <ggi/gii.h>
        ],[
        ],[
        video_ggi=yes
        ])
        AC_MSG_RESULT($video_ggi)
        if test x$video_ggi = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_GGI)
            SOURCES="$SOURCES $srcdir/src/video/ggi/*.c"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lggi -lgii -lgg"
            have_video=yes
        fi
    fi
}

dnl Find the SVGAlib includes and libraries
CheckSVGA()
{
    AC_ARG_ENABLE(video-svga,
AC_HELP_STRING([--enable-video-svga], [use SVGAlib video driver [[default=yes]]]),
                  , enable_video_svga=yes)
    if test x$enable_video = xyes -a x$enable_video_svga = xyes; then
        AC_MSG_CHECKING(for SVGAlib (1.4.0+) support)
        video_svga=no
        AC_TRY_COMPILE([
         #include <vga.h>
         #include <vgamouse.h>
         #include <vgakeyboard.h>
        ],[
         if ( SCANCODE_RIGHTWIN && SCANCODE_LEFTWIN ) {
             exit(0);
         }
        ],[
        video_svga=yes
        ])
        AC_MSG_RESULT($video_svga)
        if test x$video_svga = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_SVGALIB)
            SOURCES="$SOURCES $srcdir/src/video/svga/*.c"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvga"
            have_video=yes
        fi
    fi
}

dnl Find the VGL includes and libraries
CheckVGL()
{
    AC_ARG_ENABLE(video-vgl,
AC_HELP_STRING([--enable-video-vgl], [use VGL video driver [[default=yes]]]),
                  , enable_video_vgl=yes)
    if test x$enable_video = xyes -a x$enable_video_vgl = xyes; then
        AC_MSG_CHECKING(for libVGL support)
        video_vgl=no
        AC_TRY_COMPILE([
         #include <sys/fbio.h>
         #include <sys/consio.h>
         #include <sys/kbio.h>
         #include <vgl.h>
        ],[
         VGLBitmap bitmap;
         bitmap.Type = VIDBUF32;
         bitmap.PixelBytes = 4;
         exit(bitmap.Bitmap);
        ],[
        video_vgl=yes
        ])
        AC_MSG_RESULT($video_vgl)
        if test x$video_vgl = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_VGL)
            SOURCES="$SOURCES $srcdir/src/video/vgl/*.c"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvgl"
            have_video=yes
        fi
    fi
}

dnl Set up the wscons video driver if enabled
CheckWscons()
{
    AC_ARG_ENABLE(video-wscons,
AC_HELP_STRING([--enable-video-wscons], [use wscons video driver [[default=yes]]]),
                  , enable_video_wscons=yes)
    if test x$enable_video = xyes -a x$enable_video_wscons = xyes; then
        AC_MSG_CHECKING(for wscons support)
        video_wscons=no
        AC_TRY_COMPILE([
         #include <sys/time.h>
         #include <dev/wscons/wsconsio.h>
         #include <dev/wscons/wsdisplay_usl_io.h>
        ],[
         int wsmode = WSDISPLAYIO_MODE_DUMBFB;
        ],[
        video_wscons=yes
        ])
        AC_MSG_RESULT($video_wscons)
        if test x$video_wscons = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_WSCONS)
            SOURCES="$SOURCES $srcdir/src/video/wscons/*.c"
            have_video=yes
        fi
    fi
}


dnl Find the AAlib includes
CheckAAlib()
{
    AC_ARG_ENABLE(video-aalib,
AC_HELP_STRING([--enable-video-aalib], [use AAlib video driver [[default=no]]]),
                  , enable_video_aalib=no)
    if test x$enable_video = xyes -a x$enable_video_aalib = xyes; then
        AC_MSG_CHECKING(for AAlib support)
        video_aalib=no
        AC_TRY_COMPILE([
         #include <aalib.h>
        ],[
        ],[
        video_aalib=yes
        ])
        AC_MSG_RESULT($video_aalib)
        if test x$video_aalib = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_AALIB)
            SOURCES="$SOURCES $srcdir/src/video/aalib/*.c"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -laa"
            have_video=yes
        fi
    fi
}

dnl Find the libcaca includes
CheckCaca()
{
    AC_ARG_ENABLE(video-caca,
AC_HELP_STRING([--enable-video-caca], [use libcaca video driver [[default=no]]]),
                  , enable_video_caca=no)
    if test x$enable_video = xyes -a x$enable_video_caca = xyes; then
        video_caca=no
        AC_PATH_PROG(CACACONFIG, caca-config, no)
        if test x$CACACONFIG != xno; then
            AC_MSG_CHECKING(for libcaca support)
            CACA_CFLAGS=`$CACACONFIG --cflags`
            CACA_LDFLAGS=`$CACACONFIG --libs`
            save_CFLAGS="$CFLAGS"
            AC_TRY_COMPILE([
             #include <caca.h>
            ],[
            ],[
             video_caca=yes
            ])
            CFLAGS="$save_CFLAGS"
            AC_MSG_RESULT($video_caca)
            if test x$video_caca = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_CACA)
                EXTRA_CFLAGS="$EXTRA_CFLAGS $CACA_CFLAGS"
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $CACA_LDFLAGS"
                SOURCES="$SOURCES $srcdir/src/video/caca/*.c"
            fi
        fi
    fi
}

dnl Set up the QTopia video driver if enabled
CheckQtopia()
{
    AC_ARG_ENABLE(video-qtopia,
AC_HELP_STRING([--enable-video-qtopia], [use Qtopia video driver [[default=no]]]),
                  , enable_video_qtopia=no)
    if test x$enable_video = xyes -a x$enable_video_qtopia = xyes; then
        AC_MSG_CHECKING(for Qtopia support)
        video_qtopia=no
        QTOPIA_FLAGS="-DQT_QWS_EBX -DQT_QWS_CUSTOM -DQWS -I${QPEDIR}/include -I${QTDIR}/include/ -DNO_DEBUG -fno-rtti -fno-exceptions"
        AC_LANG_CPLUSPLUS
        OLD_CXX="$CXXFLAGS"
        CXXFLAGS="$QTOPIA_FLAGS"
        AC_TRY_COMPILE([
         #include <qpe/qpeapplication.h>
        ],[
        ],[
        video_qtopia=yes
        ])
        CXXFLAGS="$OLD_CXX"
        AC_MSG_RESULT($video_qtopia)
        if test x$video_qtopia = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_QTOPIA)
            SOURCES="$SOURCES $srcdir/src/video/qtopia/*.cc"
            SDLMAIN_SOURCES="$srcdir/src/main/qtopia/*.cc"
            SDLMAIN_LDFLAGS="-static"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $QTOPIA_FLAGS"
            SDL_CFLAGS="$SDL_CFLAGS -DQWS -Dmain=SDL_main"
            SDL_LIBS="-lSDLmain $SDL_LIBS -L${QPEDIR}/lib -L${QTDIR}/lib/ -lqpe -lqte"
            have_video=yes
        fi
        AC_LANG_C
    fi
}

dnl Set up the PicoGUI video driver if enabled
CheckPicoGUI()
{
    AC_ARG_ENABLE(video-picogui,
AC_HELP_STRING([--enable-video-picogui], [use PicoGUI video driver [[default=no]]]),
                  , enable_video_picogui=no)
    if test x$enable_video = xyes -a x$enable_video_picogui = xyes; then
        AC_MSG_CHECKING(for PicoGUI support)
        video_picogui=no
        AC_TRY_COMPILE([
         #include <picogui.h>
        ],[
        ],[
        video_picogui=yes
        ])
        AC_MSG_RESULT($video_picogui)
        if test x$video_picogui = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_PICOGUI)
            SOURCES="$SOURCES $srcdir/src/video/picogui/*.c"
            SDL_LIBS="$SDL_LIBS -lpgui"
            have_video=yes
        fi
    fi
}

dnl Set up the Atari Bios keyboard driver
CheckAtariBiosEvent()
{
    SOURCES="$SOURCES $srcdir/src/video/ataricommon/*.c"
    SOURCES="$SOURCES $srcdir/src/video/ataricommon/*.S"
}

dnl Set up the Atari Xbios driver
CheckAtariXbiosVideo()
{
    AC_ARG_ENABLE(xbios,
AC_HELP_STRING([--enable-video-xbios], [use Atari Xbios video driver [[default=yes]]]),
                  , enable_video_xbios=yes)
    video_xbios=no
    if test x$enable_video = xyes -a x$enable_video_xbios = xyes; then
        video_xbios=yes
        AC_DEFINE(SDL_VIDEO_DRIVER_XBIOS)
        SOURCES="$SOURCES $srcdir/src/video/xbios/*.c"
        have_video=yes
    fi
}

dnl Set up the Atari Gem driver
CheckAtariGemVideo()
{
    AC_ARG_ENABLE(gem,
AC_HELP_STRING([--enable-video-gem], [use Atari Gem video driver [[default=yes]]]),
                  , enable_video_gem=yes)
    if test x$enable_video = xyes -a x$enable_video_gem = xyes; then
        video_gem=no
        AC_CHECK_HEADER(gem.h, have_gem_hdr=yes)
        AC_CHECK_LIB(gem, appl_init, have_gem_lib=yes)
        if test x$have_gem_hdr = xyes -a x$have_gem_lib = xyes; then
            video_gem=yes
            AC_DEFINE(SDL_VIDEO_DRIVER_GEM)
            SOURCES="$SOURCES $srcdir/src/video/gem/*.c"
            SDL_LIBS="$SDL_LIBS -lgem"
            have_video=yes
        fi
    fi
}

dnl rcg04172001 Set up the Null video driver.
CheckDummyVideo()
{
    AC_ARG_ENABLE(video-dummy,
AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
                  , enable_video_dummy=yes)
    if test x$enable_video_dummy = xyes; then
        AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY)
        SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
        have_video=yes
    fi
}

dnl Check to see if OpenGL support is desired
AC_ARG_ENABLE(video-opengl,
AC_HELP_STRING([--enable-video-opengl], [include OpenGL context creation [[default=yes]]]),
              , enable_video_opengl=yes)

dnl Find OpenGL
CheckOpenGLX11()
{
    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
        AC_MSG_CHECKING(for OpenGL (GLX) support)
        video_opengl=no
        AC_TRY_COMPILE([
         #include <GL/gl.h>
         #include <GL/glx.h>
         #include <GL/glu.h>
        ],[
        ],[
        video_opengl=yes
        ])
        AC_MSG_RESULT($video_opengl)
        if test x$video_opengl = xyes; then
            AC_DEFINE(SDL_VIDEO_OPENGL)
            AC_DEFINE(SDL_VIDEO_OPENGL_GLX)
        fi
    fi
}

dnl Find QNX RtP OpenGL
CheckOpenGLQNX()
{
    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
        AC_MSG_CHECKING(for OpenGL (Photon) support)
        video_opengl=no
        AC_TRY_COMPILE([
         #include <GL/gl.h>
        ],[
        ],[
        video_opengl=yes
        ])
        AC_MSG_RESULT($video_opengl)
        if test x$video_opengl = xyes; then
            AC_DEFINE(SDL_VIDEO_OPENGL)
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
        fi
    fi
}

dnl Check for Win32 OpenGL
CheckWIN32GL()
{
    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
        AC_DEFINE(SDL_VIDEO_OPENGL)
        AC_DEFINE(SDL_VIDEO_OPENGL_WGL)
    fi
}

dnl Check for BeOS OpenGL
CheckBeGL()
{
    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
        AC_DEFINE(SDL_VIDEO_OPENGL)
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
    fi
}

dnl Check for MacOS OpenGL
CheckMacGL()
{
    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
        AC_DEFINE(SDL_VIDEO_OPENGL)
        case "$host" in
            *-*-darwin*)
                if test x$enable_video_cocoa = xyes; then
                    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGL"
                fi
                if test x$enable_video_carbon = xyes; then
                    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AGL"
                fi
        esac
    fi
}

dnl Check for Mesa offscreen rendering
CheckAtariOSMesa()
{
    if test "x$enable_video" = "xyes" -a "x$enable_video_opengl" = "xyes"; then
        AC_CHECK_HEADER(GL/osmesa.h, have_osmesa_hdr=yes)
        AC_CHECK_LIB(OSMesa, OSMesaCreateContext, have_osmesa_lib=yes, have_osmesa_lib=no, -lm)

        # Static linking to -lOSMesa
        AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
        if test "x$OSMESA_CONFIG" = "xno" -o "x$enable_atari_ldg" = "xno"; then
            # -lOSMesa is really the static library
            if test "x$have_osmesa_hdr" = "xyes" -a "x$have_osmesa_lib" = "xyes"; then
                OSMESA_LIBS="-lOSMesa"
            fi
        else
            # -lOSMesa is a loader for OSMesa.ldg
            OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
            OSMESA_LIBS=`$OSMESA_CONFIG --libs`
        fi
        AC_DEFINE(SDL_VIDEO_OPENGL)
        AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA)
        SDL_CFLAGS="$SDL_CFLAGS $OSMESA_CFLAGS"
        SDL_LIBS="$SDL_LIBS $OSMESA_LIBS"

        AC_ARG_ENABLE(osmesa-shared,
AC_HELP_STRING([--enable-osmesa-shared], [dynamically load OSMesa OpenGL support [[default=yes]]]),
                              , enable_osmesa_shared=yes)
        if test "x$enable_osmesa_shared" = "xyes" -a "x$enable_atari_ldg" = "xyes"; then
            # Dynamic linking
            if test "x$have_osmesa_hdr" = "xyes"; then
                AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA_DYNAMIC)
            fi
        fi
    fi
}

AC_ARG_ENABLE(screensaver,
AC_HELP_STRING([--enable-screensaver], [enable screensaver by default while any SDL application is running [[default=no]]]),
              , enable_screensaver=no)
if test x$enable_screensaver = xno; then
    AC_DEFINE(SDL_VIDEO_DISABLE_SCREENSAVER)
fi

dnl See if we can use the new unified event interface in Linux 2.4
CheckInputEvents()
{
    dnl Check for Linux 2.4 unified input event interface support
    AC_ARG_ENABLE(input-events,
AC_HELP_STRING([--enable-input-events], [use Linux 2.4 unified input interface [[default=yes]]]),
                  , enable_input_events=yes)
    if test x$enable_input_events = xyes; then
        AC_MSG_CHECKING(for Linux 2.4 unified input interface)
        use_input_events=no
        AC_TRY_COMPILE([
          #include <linux/input.h>
        ],[
          #ifndef EVIOCGNAME
          #error EVIOCGNAME() ioctl not available
          #endif
        ],[
        use_input_events=yes
        ])
        AC_MSG_RESULT($use_input_events)
        if test x$use_input_events = xyes; then
            AC_DEFINE(SDL_INPUT_LINUXEV)
        fi
    fi
}

dnl See if we can use the Touchscreen input library
CheckTslib()
{
    AC_ARG_ENABLE(input-tslib,
AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
                  , enable_input_tslib=yes)
    if test x$enable_input_tslib = xyes; then
        AC_MSG_CHECKING(for Touchscreen library support)
        enable_input_tslib=no
        AC_TRY_COMPILE([
          #include "tslib.h"
        ],[
        ],[
        enable_input_tslib=yes
        ])
        AC_MSG_RESULT($enable_input_tslib)
        if test x$enable_input_tslib = xyes; then
            AC_DEFINE(SDL_INPUT_TSLIB)
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
        fi
    fi
}

dnl See if we can use GNU pth library for threads
CheckPTH()
{
    dnl Check for pth support
    AC_ARG_ENABLE(pth,
AC_HELP_STRING([--enable-pth], [use GNU pth library for multi-threading [[default=yes]]]),
                  , enable_pth=yes)
    if test x$enable_threads = xyes -a x$enable_pth = xyes; then
        AC_PATH_PROG(PTH_CONFIG, pth-config, no)
        if test "$PTH_CONFIG" = "no"; then
            use_pth=no
        else
            use_pth=yes
        fi
        AC_MSG_CHECKING(pth)
        AC_MSG_RESULT($use_pth)
        if test "x$use_pth" = xyes; then
            AC_DEFINE(SDL_THREAD_PTH)
            SOURCES="$SOURCES $srcdir/src/thread/pth/*.c"
            SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
            SDL_CFLAGS="$SDL_CFLAGS `$PTH_CONFIG --cflags`"
            SDL_LIBS="$SDL_LIBS `$PTH_CONFIG --libs --all`"
            have_threads=yes
        fi
    fi
}

dnl See what type of thread model to use on Linux and Solaris
CheckPTHREAD()
{
    dnl Check for pthread support
    AC_ARG_ENABLE(pthreads,
AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
                  , enable_pthreads=yes)
    dnl This is used on Linux for glibc binary compatibility (Doh!)
    AC_ARG_ENABLE(pthread-sem,
AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
                  , enable_pthread_sem=yes)
    case "$host" in
        *-*-linux*|*-*-uclinux*)
            pthread_cflags="-D_REENTRANT"
            pthread_lib="-lpthread"
            ;;
        *-*-bsdi*)
            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
            pthread_lib=""
            ;;
        *-*-darwin*)
            pthread_cflags="-D_THREAD_SAFE"
# causes Carbon.p complaints?
#            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
            ;;
        *-*-freebsd*|*-*-dragonfly*)
            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
            pthread_lib="-pthread"
            ;;
        *-*-netbsd*)
            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
            pthread_lib="-lpthread"
            ;;
        *-*-openbsd*)
            pthread_cflags="-D_REENTRANT"
            pthread_lib="-pthread"
            ;;
        *-*-solaris*)
            pthread_cflags="-D_REENTRANT"
            pthread_lib="-lpthread -lposix4"
            ;;
        *-*-sysv5*)
            pthread_cflags="-D_REENTRANT -Kthread"
            pthread_lib=""
            ;;
        *-*-irix*)
            pthread_cflags="-D_SGI_MP_SOURCE"
            pthread_lib="-lpthread"
            ;;
        *-*-aix*)
            pthread_cflags="-D_REENTRANT -mthreads"
            pthread_lib="-lpthread"
            ;;
        *-*-hpux11*)
            pthread_cflags="-D_REENTRANT"
            pthread_lib="-L/usr/lib -lpthread"
            ;;
        *-*-qnx*)
            pthread_cflags=""
            pthread_lib=""
            ;;
        *-*-osf*)
            pthread_cflags="-D_REENTRANT"
            if test x$ac_cv_prog_gcc = xyes; then
                pthread_lib="-lpthread -lrt"
            else
                pthread_lib="-lpthread -lexc -lrt"
            fi
            ;;
        *)
            pthread_cflags="-D_REENTRANT"
            pthread_lib="-lpthread"
            ;;
    esac
    if test x$enable_threads = xyes -a x$enable_pthreads = xyes -a x$enable_ipod != xyes; then
        # Save the original compiler flags and libraries
        ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
        # Add the pthread compiler flags and libraries
        CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
        # Check to see if we have pthread support on this system
        AC_MSG_CHECKING(for pthreads)
        use_pthreads=no
        AC_TRY_LINK([
         #include <pthread.h>
        ],[
         pthread_attr_t type;
         pthread_attr_init(&type);
        ],[
        use_pthreads=yes
        ])
        AC_MSG_RESULT($use_pthreads)
        # Restore the compiler flags and libraries
        CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"

        # Do futher testing if we have pthread support...
        if test x$use_pthreads = xyes; then
            AC_DEFINE(SDL_THREAD_PTHREAD)
            EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
            SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
            SDL_LIBS="$SDL_LIBS $pthread_lib"

            # Save the original compiler flags and libraries
            ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
            # Add the pthread compiler flags and libraries
            CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"

            # Check to see if recursive mutexes are available
            AC_MSG_CHECKING(for recursive mutexes)
            has_recursive_mutexes=no
            if test x$has_recursive_mutexes = xno; then
                AC_TRY_COMPILE([
                  #include <pthread.h>
                ],[
                  pthread_mutexattr_t attr;
                  pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
                ],[
                has_recursive_mutexes=yes
                AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX)
                ])
            fi
            if test x$has_recursive_mutexes = xno; then
                AC_TRY_COMPILE([
                  #include <pthread.h>
                ],[
                  pthread_mutexattr_t attr;
                  pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
                ],[
                has_recursive_mutexes=yes
                AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP)
                ])
            fi
            AC_MSG_RESULT($has_recursive_mutexes)

            # Check to see if pthread semaphore support is missing
            if test x$enable_pthread_sem = xyes; then
                AC_MSG_CHECKING(for pthread semaphores)
                have_pthread_sem=no
                AC_TRY_COMPILE([
                  #include <pthread.h>
                  #include <semaphore.h>
                ],[
                ],[
                have_pthread_sem=yes
                ])
                AC_MSG_RESULT($have_pthread_sem)
            fi
            if test x$have_pthread_sem = xyes; then
                AC_MSG_CHECKING(for sem_timedwait)
                have_sem_timedwait=no
                AC_TRY_LINK([
                  #include <pthread.h>
                  #include <semaphore.h>
                ],[
                  sem_timedwait(NULL, NULL);
                ],[
                have_sem_timedwait=yes
                AC_DEFINE(HAVE_SEM_TIMEDWAIT)
                ])
                AC_MSG_RESULT($have_sem_timedwait)
            fi

            # Restore the compiler flags and libraries
            CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"

            # Basic thread creation functions
            SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"

            # Semaphores
            # We can fake these with mutexes and condition variables if necessary
            if test x$have_pthread_sem = xyes; then
                SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
            else
                SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
            fi

            # Mutexes
            # We can fake these with semaphores if necessary
            SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"

            # Condition variables
            # We can fake these with semaphores and mutexes if necessary
            SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"

            have_threads=yes
        else
            CheckPTH
        fi
    fi
}

dnl Determine whether the compiler can produce Win32 executables
CheckWIN32()
{
    AC_MSG_CHECKING(Win32 compiler)
    have_win32_gcc=no
    AC_TRY_COMPILE([
     #include <windows.h>
    ],[
    ],[
    have_win32_gcc=yes
    ])
    AC_MSG_RESULT($have_win32_gcc)
    if test x$have_win32_gcc != xyes; then
       AC_MSG_ERROR([
*** Your compiler ($CC) does not produce Win32 executables!
       ])
    fi

    dnl See if the user wants to redirect standard output to files
    AC_ARG_ENABLE(stdio-redirect,
AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Win32 [[default=yes]]]),
                  , enable_stdio_redirect=yes)
    if test x$enable_stdio_redirect != xyes; then
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DNO_STDIO_REDIRECT"
    fi

    if test x$enable_video = xyes; then
        AC_DEFINE(SDL_VIDEO_DRIVER_WINDIB)
        SOURCES="$SOURCES $srcdir/src/video/wincommon/*.c"
        SOURCES="$SOURCES $srcdir/src/video/windib/*.c"
        have_video=yes
    fi
}

dnl Find the DirectX includes and libraries
CheckDIRECTX()
{
    AC_ARG_ENABLE(directx,
AC_HELP_STRING([--enable-directx], [use DirectX for Win32 audio/video [[default=yes]]]),
                  , enable_directx=yes)
    if test x$enable_directx = xyes; then
        have_directx=no
        AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
        AC_CHECK_HEADER(dsound.h, have_dsound=yes)
        AC_CHECK_HEADER(dinput.h, use_dinput=yes)
        if test x$have_ddraw = xyes -a x$have_dsound = xyes -a x$use_dinput = xyes; then
            have_directx=yes
        fi
        if test x$enable_video = xyes -a x$have_directx = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_DDRAW)
            SOURCES="$SOURCES $srcdir/src/video/windx5/*.c"
            have_video=yes
        fi
    fi
}

dnl Check for the dlfcn.h interface for dynamically loading objects
CheckDLOPEN()
{
    AC_ARG_ENABLE(sdl-dlopen,
AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
                  , enable_sdl_dlopen=yes)
    if test x$enable_sdl_dlopen = xyes; then
        AC_MSG_CHECKING(for dlopen)
        have_dlopen=no
        AC_TRY_COMPILE([
         #include <dlfcn.h>
        ],[
         #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
         #error Use dlcompat for Mac OS X 10.2 compatibility
         #endif
        ],[
        have_dlopen=yes
        ])
        AC_MSG_RESULT($have_dlopen)

        if test x$have_dlopen = xyes; then
            AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
               AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
                  AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
            AC_DEFINE(SDL_LOADSO_DLOPEN)
            SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
            have_loadso=yes
        fi
    fi
}

dnl Set up the Atari LDG (shared object loader)
CheckAtariLdg()
{
    AC_ARG_ENABLE(atari-ldg,
AC_HELP_STRING([--enable-atari-ldg], [use Atari LDG for shared object loading [[default=yes]]]),
                  , enable_atari_ldg=yes)
    if test x$video_gem = xyes -a x$enable_atari_ldg = xyes; then
        AC_CHECK_HEADER(ldg.h, have_ldg_hdr=yes)
        AC_CHECK_LIB(ldg, ldg_open, have_ldg_lib=yes, have_ldg_lib=no, -lgem)
        if test x$have_ldg_hdr = xyes -a x$have_ldg_lib = xyes; then
            AC_DEFINE(SDL_LOADSO_LDG)
            SOURCES="$SOURCES $srcdir/src/loadso/mint/*.c"
            SDL_LIBS="$SDL_LIBS -lldg -lgem"
            have_loadso=yes
        fi
    fi
}

dnl Check for the usbhid(3) library on *BSD
CheckUSBHID()
{
    if test x$enable_joystick = xyes; then
        AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
        if test x$have_libusbhid = xyes; then
            AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
            AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
            USB_LIBS="$USB_LIBS -lusbhid"
        else
            AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
            AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
            AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
        fi
            
        save_CFLAGS="$CFLAGS"
        CFLAGS="$CFLAGS $USB_CFLAGS"

        AC_MSG_CHECKING(for usbhid)
        have_usbhid=no
        AC_TRY_COMPILE([
          #include <sys/types.h>
          #if defined(HAVE_USB_H)
          #include <usb.h>
          #endif
          #ifdef __DragonFly__
          # include <bus/usb/usb.h>
          # include <bus/usb/usbhid.h>
          #else
          # include <dev/usb/usb.h>
          # include <dev/usb/usbhid.h>
          #endif
          #if defined(HAVE_USBHID_H)
          #include <usbhid.h>
          #elif defined(HAVE_LIBUSB_H)
          #include <libusb.h>
          #elif defined(HAVE_LIBUSBHID_H)
          #include <libusbhid.h>
          #endif
        ],[
          struct report_desc *repdesc;
          struct usb_ctl_report *repbuf;
          hid_kind_t hidkind;
        ],[
        have_usbhid=yes
        ])
        AC_MSG_RESULT($have_usbhid)

        if test x$have_usbhid = xyes; then
            AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
            have_usbhid_ucr_data=no
            AC_TRY_COMPILE([
              #include <sys/types.h>
              #if defined(HAVE_USB_H)
              #include <usb.h>
              #endif
              #ifdef __DragonFly__
              # include <bus/usb/usb.h>
              # include <bus/usb/usbhid.h>
              #else
              # include <dev/usb/usb.h>
              # include <dev/usb/usbhid.h>
              #endif
              #if defined(HAVE_USBHID_H)
              #include <usbhid.h>
              #elif defined(HAVE_LIBUSB_H)
              #include <libusb.h>
              #elif defined(HAVE_LIBUSBHID_H)
              #include <libusbhid.h>
              #endif
            ],[
              struct usb_ctl_report buf;
              if (buf.ucr_data) { }
            ],[
            have_usbhid_ucr_data=yes
            ])
            if test x$have_usbhid_ucr_data = xyes; then
                USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
            fi
            AC_MSG_RESULT($have_usbhid_ucr_data)
            
            AC_MSG_CHECKING(for new usbhid API)
            have_usbhid_new=no
            AC_TRY_COMPILE([
              #include <sys/types.h>
              #if defined(HAVE_USB_H)
              #include <usb.h>
              #endif
              #ifdef __DragonFly__
              #include <bus/usb/usb.h>
              #include <bus/usb/usbhid.h>
              #else
              #include <dev/usb/usb.h>
              #include <dev/usb/usbhid.h>
              #endif
              #if defined(HAVE_USBHID_H)
              #include <usbhid.h>
              #elif defined(HAVE_LIBUSB_H)
              #include <libusb.h>
              #elif defined(HAVE_LIBUSBHID_H)
              #include <libusbhid.h>
              #endif
            ],[
              report_desc_t d;
              hid_start_parse(d, 1, 1);
            ],[
            have_usbhid_new=yes
            ])
            if test x$have_usbhid_new = xyes; then
                USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
            fi
            AC_MSG_RESULT($have_usbhid_new)

            AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
            have_machine_joystick=no
            AC_TRY_COMPILE([
              #include <machine/joystick.h>
            ],[
              struct joystick t;
            ],[
            have_machine_joystick=yes
            ])
            if test x$have_machine_joystick = xyes; then
                AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H)
            fi
            AC_MSG_RESULT($have_machine_joystick)

            AC_DEFINE(SDL_JOYSTICK_USBHID)
            SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
            have_joystick=yes
        fi
        CFLAGS="$save_CFLAGS"
    fi
}

dnl Check for clock_gettime()
CheckClockGettime()
{
    AC_ARG_ENABLE(clock_gettime,
AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=no]]]),
                  , enable_clock_gettime=no)
    if test x$enable_clock_gettime = xyes; then
        AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
        if test x$have_clock_gettime = xyes; then
            AC_DEFINE(HAVE_CLOCK_GETTIME)
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
        fi
    fi
}

dnl Check for a valid linux/version.h
CheckLinuxVersion()
{
    AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
    if test x$have_linux_version_h = xyes; then
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
    fi
}

dnl Check if we want to use RPATH
CheckRPATH()
{
    AC_ARG_ENABLE(rpath,
AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
                  , enable_rpath=yes)
}

dnl Set up the configuration based on the host platform!
case "$host" in
    arm-*-elf*) # FIXME: Can we get more specific for iPodLinux?
        ARCH=linux
        CheckDummyVideo
        CheckIPod
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_UNIX)
            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
            have_timers=yes
        fi
        ;;
    *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*)
        case "$host" in
            *-*-linux*)         ARCH=linux ;;
            *-*-uclinux*)       ARCH=linux ;;
            *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
            *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
            *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
            *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
            *-*-bsdi*)          ARCH=bsdi ;;
            *-*-freebsd*)       ARCH=freebsd ;;
            *-*-dragonfly*)     ARCH=freebsd ;;
            *-*-netbsd*)        ARCH=netbsd ;;
            *-*-openbsd*)       ARCH=openbsd ;;
            *-*-sysv5*)         ARCH=sysv5 ;;
            *-*-solaris*)       ARCH=solaris ;;
            *-*-hpux*)          ARCH=hpux ;;
            *-*-irix*)          ARCH=irix ;;
            *-*-aix*)           ARCH=aix ;;
            *-*-osf*)           ARCH=osf ;;
        esac
        CheckVisibilityHidden
        CheckDummyVideo
        CheckDiskAudio
        CheckDummyAudio
        CheckDLOPEN
        CheckNASM
        CheckAltivec
        CheckOSS
        CheckDMEDIA
        CheckMME
        CheckALSA
        CheckARTSC
        CheckESD
        CheckPulseAudio
        CheckNAS
        CheckX11
        CheckNANOX
        CheckFBCON
        CheckDirectFB
        CheckPS2GS
        CheckPS3
        CheckGGI
        CheckSVGA
        CheckVGL
        CheckWscons
        CheckAAlib
        CheckCaca
        CheckQtopia
        CheckPicoGUI
        CheckOpenGLX11
        CheckInputEvents
        CheckTslib
        CheckUSBHID
        CheckPTHREAD
        CheckClockGettime
        CheckLinuxVersion
        CheckRPATH
        # Set up files for the audio library
        if test x$enable_audio = xyes; then
          case $ARCH in
            sysv5|solaris|hpux)
                AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
                SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
                have_audio=yes
            ;;
            netbsd|openbsd)
                AC_DEFINE(SDL_AUDIO_DRIVER_BSD)
                SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
                have_audio=yes
            ;;
            aix)
                AC_DEFINE(SDL_AUDIO_DRIVER_PAUD)
                SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
                have_audio=yes
            ;;
          esac
        fi
        # Set up files for the joystick library
        if test x$enable_joystick = xyes; then
          case $ARCH in
            linux)
                AC_DEFINE(SDL_JOYSTICK_LINUX)
                SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
                have_joystick=yes
            ;;
          esac
        fi
        # Set up files for the cdrom library
        if test x$enable_cdrom = xyes; then
          case $ARCH in
            linux|solaris)
                AC_DEFINE(SDL_CDROM_LINUX)
                SOURCES="$SOURCES $srcdir/src/cdrom/linux/*.c"
                have_cdrom=yes
            ;;
            *freebsd*)
                AC_DEFINE(SDL_CDROM_FREEBSD)
                SOURCES="$SOURCES $srcdir/src/cdrom/freebsd/*.c"
                have_cdrom=yes
            ;;
            *openbsd*|*netbsd*)
                AC_DEFINE(SDL_CDROM_OPENBSD)
                SOURCES="$SOURCES $srcdir/src/cdrom/openbsd/*.c"
                have_cdrom=yes
            ;;
            bsdi)
                AC_DEFINE(SDL_CDROM_BSDI)
                SOURCES="$SOURCES $srcdir/src/cdrom/bsdi/*.c"
                have_cdrom=yes
            ;;
            aix)
                AC_DEFINE(SDL_CDROM_AIX)
                SOURCES="$SOURCES $srcdir/src/cdrom/aix/*.c"
                have_cdrom=yes
            ;;
            osf)
                AC_DEFINE(SDL_CDROM_OSF)
                SOURCES="$SOURCES $srcdir/src/cdrom/osf/*.c"
                have_cdrom=yes
            ;;
          esac
        fi
        # Set up files for the thread library
        if test x$enable_threads = xyes -a x$use_pthreads != xyes -a x$use_pth != xyes -a x$ARCH = xirix; then
            AC_DEFINE(SDL_THREAD_SPROC)
            SOURCES="$SOURCES $srcdir/src/thread/irix/*.c"
            SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
            SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
            have_threads=yes
        fi
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_UNIX)
            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
            have_timers=yes
        fi
        ;;
    *-*-qnx*)
        ARCH=qnx
        CheckDummyVideo
        CheckDiskAudio
        CheckDummyAudio
        # CheckNASM
        CheckDLOPEN
        CheckNAS
        CheckPHOTON
        CheckX11
        CheckOpenGLX11
        CheckPTHREAD
        # Set up files for the audio library
        if test x$enable_audio = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_QNXNTO)
            SOURCES="$SOURCES $srcdir/src/audio/nto/*.c"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lasound"
            have_audio=yes
        fi
        # Set up files for the cdrom library
        if test x$enable_cdrom = xyes; then
            AC_DEFINE(SDL_CDROM_QNX)
            SOURCES="$SOURCES $srcdir/src/cdrom/qnx/*.c"
            have_cdrom=yes
        fi
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_UNIX)
            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
            have_timers=yes
        fi
        ;;
    *-*-cygwin* | *-*-mingw32*)
        ARCH=win32
        if test "$build" != "$host"; then # cross-compiling
            # Default cross-compile location
            ac_default_prefix=/usr/local/cross-tools/i386-mingw32
        else
            # Look for the location of the tools and install there
            if test "$BUILD_PREFIX" != ""; then
                ac_default_prefix=$BUILD_PREFIX
            fi
        fi
        CheckDummyVideo
        CheckDiskAudio
        CheckDummyAudio
        CheckWIN32
        CheckWIN32GL
        CheckDIRECTX
        CheckNASM
        # Set up files for the audio library
        if test x$enable_audio = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_WAVEOUT)
            SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
            if test x$have_directx = xyes; then
                AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
                SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
            fi
            have_audio=yes
        fi
        # Set up files for the joystick library
        if test x$enable_joystick = xyes; then
            AC_DEFINE(SDL_JOYSTICK_WINMM)
            SOURCES="$SOURCES $srcdir/src/joystick/win32/*.c"
            have_joystick=yes
        fi
        # Set up files for the cdrom library
        if test x$enable_cdrom = xyes; then
            AC_DEFINE(SDL_CDROM_WIN32)
            SOURCES="$SOURCES $srcdir/src/cdrom/win32/*.c"
            have_cdrom=yes
        fi
        # Set up files for the thread library
        if test x$enable_threads = xyes; then
            AC_DEFINE(SDL_THREAD_WIN32)
            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
            SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
            have_threads=yes
        fi
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_WIN32)
            SOURCES="$SOURCES $srcdir/src/timer/win32/*.c"
            have_timers=yes
        fi
        # Set up files for the shared object loading library
        if test x$enable_loadso = xyes; then
            AC_DEFINE(SDL_LOADSO_WIN32)
            SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
            have_loadso=yes
        fi
        # Set up the system libraries we need
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm"
        if test x$have_directx = xyes; then
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldxguid"
        fi
        # The Win32 platform requires special setup
        SOURCES="$SOURCES $srcdir/src/main/win32/*.rc"
        SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
        SDLMAIN_LDFLAGS="-static"
        SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
        SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
        ;;
    *-wince*)
        ARCH=win32
        CheckDummyVideo
        CheckDiskAudio
        CheckDummyAudio
        CheckWIN32
        CheckNASM
        SOURCES="$SOURCES $srcdir/src/video/gapi/*.c"
        EXTRA_CFLAGS="$EXTRA_CFLAGS -D_WIN32_WCE=0x420"
        if test x$enable_audio = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_WAVEOUT)
            SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
            have_audio=yes
        fi
        # Set up files for the thread library
        if test x$enable_threads = xyes; then
            AC_DEFINE(SDL_THREAD_WIN32)
            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
            SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
            have_threads=yes
        fi
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_WINCE)
            SOURCES="$SOURCES $srcdir/src/timer/wince/*.c"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lmmtimer"
            have_timers=yes
        fi
        # Set up files for the shared object loading library
        if test x$enable_loadso = xyes; then
            AC_DEFINE(SDL_LOADSO_WIN32)
            SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
            have_loadso=yes
        fi
        # Set up the system libraries we need
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl"
        # The Win32 platform requires special setup
        SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
        SDLMAIN_LDFLAGS="-static"
        SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
        SDL_LIBS="-lSDLmain $SDL_LIBS"
        ;;
    *-*-beos* | *-*-haiku*)
        ARCH=beos
        ac_default_prefix=/boot/develop/tools/gnupro
        CheckDummyVideo
        CheckDiskAudio
        CheckDummyAudio
        CheckNASM
        CheckBWINDOW
        CheckBeGL
        # Set up files for the audio library
        if test x$enable_audio = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_BAUDIO)
            SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
            have_audio=yes
        fi
        # Set up files for the joystick library
        if test x$enable_joystick = xyes; then
            AC_DEFINE(SDL_JOYSTICK_BEOS)
            SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
            have_joystick=yes
        fi
        # Set up files for the cdrom library
        if test x$enable_cdrom = xyes; then
            AC_DEFINE(SDL_CDROM_BEOS)
            SOURCES="$SOURCES $srcdir/src/cdrom/beos/*.cc"
            have_cdrom=yes
        fi
        # Set up files for the thread library
        if test x$enable_threads = xyes; then
            AC_DEFINE(SDL_THREAD_BEOS)
            SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
            SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
            SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
            have_threads=yes
        fi
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_BEOS)
            SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
            have_timers=yes
        fi
        # Set up files for the shared object loading library
        if test x$enable_loadso = xyes; then
            case "$host" in
                *-*-beos*)
                    AC_DEFINE(SDL_LOADSO_BEOS)
                    SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
                ;;
                *-*-haiku*)
                    AC_DEFINE(SDL_LOADSO_DLOPEN)
                    SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
                ;;
            esac    
            have_loadso=yes
        fi
        # The BeOS platform requires special setup.
        SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
        ;;
    *-*-darwin* )
        # This could be either full "Mac OS X", or plain "Darwin" which is
        # just the OS X kernel sans upper layers like Carbon and Cocoa.
        # Next line is broken, and a few files below require Mac OS X (full)
        ARCH=macosx

        # Mac OS X builds with both the Carbon and OSX APIs at the moment
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"

        # HACK: Reset EXTRA_LDFLAGS; the only thing it contains at this point
        # is -lm which is not needed under Mac OS X. But for some reasons it
        # also tends to contain spurious -L switches, which we don't want to
        # use here or in sdl-config. Hence we reset it.
        EXTRA_LDFLAGS=""

        CheckVisibilityHidden
        CheckDummyVideo
        CheckDiskAudio
        CheckDummyAudio
        CheckDLOPEN
        CheckNASM

        # Set up files for the shared object loading library
        # (this needs to be done before the dynamic X11 check)
        if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
            AC_DEFINE(SDL_LOADSO_DLCOMPAT)
            SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
            have_loadso=yes
        fi

        CheckCOCOA
        CheckCARBON
        CheckX11
        CheckMacGL
        CheckOpenGLX11
        CheckPTHREAD
        CheckAltivec

        # Need this or things might misbuild on a G3.
        EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL"

        # Set up files for the audio library
        if test x$enable_audio = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO)
            SOURCES="$SOURCES $srcdir/src/audio/macosx/*.c"
            have_audio=yes
        fi
        # Set up files for the joystick library
        if test x$enable_joystick = xyes; then
            AC_DEFINE(SDL_JOYSTICK_IOKIT)
            SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
            have_joystick=yes
            need_iokit_framework=yes
        fi
        # Set up files for the cdrom library
        if test x$enable_cdrom = xyes; then
            AC_DEFINE(SDL_CDROM_MACOSX)
            SOURCES="$SOURCES $srcdir/src/cdrom/macosx/*.c"
            have_cdrom=yes
        fi
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_UNIX)
            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
            have_timers=yes
        fi
        # The Mac OS X platform requires special setup.
        SDLMAIN_SOURCES="$srcdir/src/main/macosx/*.m"
        SDLMAIN_LDFLAGS="-static"
        EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
        SDL_LIBS="-lSDLmain $SDL_LIBS"
        if test x$enable_video_cocoa = xyes; then
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
            need_iokit_framework=yes
        fi
        if test x$enable_video_carbon = xyes -o x$enable_video_cocoa = xyes; then
            # The Cocoa backend still needs Carbon
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ApplicationServices"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
        fi
        # If either the audio or CD driver is used, add the AudioUnit framework
        if test x$enable_audio = xyes -o x$enable_cdrom = xyes; then
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
        fi
        # Some subsystems reference IOKit...
        if test x$need_iokit_framework = xyes; then
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
        fi
        ;;
    *-*-mint*)
        ARCH=mint
        CheckDummyVideo
        CheckDiskAudio
        CheckDummyAudio
        CheckAtariBiosEvent
        CheckAtariXbiosVideo
        CheckAtariGemVideo
        CheckAtariAudio
        CheckAtariLdg
        CheckAtariOSMesa
        CheckPTH
        # Set up files for the audio library
        if test x$enable_threads = xyes -a x$enable_pth = xyes; then
            if test x$enable_audio = xyes; then
                AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
                SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
                have_audio=yes
            fi
        fi
        # Set up files for the joystick library
        if test x$enable_joystick = xyes; then
            AC_DEFINE(SDL_JOYSTICK_MINT)
            SOURCES="$SOURCES $srcdir/src/joystick/mint/*.c"
            have_joystick=yes
        fi
        # Set up files for the cdrom library
        if test x$enable_cdrom = xyes; then
            AC_DEFINE(SDL_CDROM_MINT)
            SOURCES="$SOURCES $srcdir/src/cdrom/mint/*.c"
            have_cdrom=yes
        fi
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            if test x$enable_threads = xyes -a x$enable_pth = xyes; then
                AC_DEFINE(SDL_TIMER_UNIX)
                SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
            else
                AC_DEFINE(SDL_TIMER_MINT)
                SOURCES="$SOURCES $srcdir/src/timer/mint/*.c"
                SOURCES="$SOURCES $srcdir/src/timer/mint/*.S"
            fi
            have_timers=yes
        fi
        ;;
    *-riscos)
        ARCH=riscos
        CheckOSS
        CheckPTHREAD
        # Set up files for the video library
        if test x$enable_video = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_RISCOS)
            SOURCES="$SOURCES $srcdir/src/video/riscos/*.c"
            SOURCES="$SOURCES $srcdir/src/video/riscos/*.S"
            have_video=yes
        fi
        # Set up files for the joystick library
        if test x$enable_joystick = xyes; then
            AC_DEFINE(SDL_JOYSTICK_RISCOS)
            SOURCES="$SOURCES $srcdir/src/joystick/riscos/*.c"
            have_joystick=yes
        fi
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_RISCOS)
            SOURCES="$SOURCES $srcdir/src/timer/riscos/*.c"
            have_timers=yes
        fi
        # The RISC OS platform requires special setup.
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ljpeg -ltiff -lpng -lz"
        ;;
    *)
        AC_MSG_ERROR([
*** Unsupported host:  Please add to configure.in
        ])
        ;;
esac

dnl Do this on all platforms, after everything else.
CheckWarnAll

# Verify that we have all the platform specific files we need

if test x$enable_joystick = xyes; then
  if test x$have_joystick != xyes; then
    # Wants joystick subsystem, but doesn't have a platform-specific backend...
    AC_DEFINE(SDL_JOYSTICK_DUMMY)
    SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  fi
fi
if test x$have_cdrom != xyes; then
    if test x$enable_cdrom = xyes; then
        AC_DEFINE(SDL_CDROM_DISABLED)
    fi
    SOURCES="$SOURCES $srcdir/src/cdrom/dummy/*.c"
fi
if test x$have_threads != xyes; then
    if test x$enable_threads = xyes; then
        AC_DEFINE(SDL_THREADS_DISABLED)
    fi
    SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
fi
if test x$have_timers != xyes; then
    if test x$enable_timers = xyes; then
        AC_DEFINE(SDL_TIMERS_DISABLED)
    fi
    SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
fi
if test x$have_loadso != xyes; then
    if test x$enable_loadso = xyes; then
        AC_DEFINE(SDL_LOADSO_DISABLED)
    fi
    SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
fi
if test x$SDLMAIN_SOURCES = x; then
    SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
    SDLMAIN_LDFLAGS="-static"
fi

OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.asm,$(objects)/\1.lo,g'`
OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.S,$(objects)/\1.lo,g'`
OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.lo,g'`

SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`

# Set runtime shared library paths as needed

if test "x$enable_rpath" = "xyes"; then
  if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = irix -o $ARCH = linux -o $ARCH = netbsd; then
    SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
  fi
  if test $ARCH = solaris; then
    SDL_RLD_FLAGS="-R\${libdir}"
  fi
else
  SDL_RLD_FLAGS=""
fi

case "$ARCH" in
  macosx)
    if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
      SDL_LIBS="$SDL_LIBS -Wl,-framework,Cocoa"
    fi
    if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
      SDL_LIBS="$SDL_LIBS -Wl,-framework,Carbon"
    fi
    # Evil hack to allow static linking on Mac OS X
    SDL_STATIC_LIBS="\${libdir}/libSDLmain.a \${libdir}/libSDL.a $EXTRA_LDFLAGS"
    ;;
  *)
    SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
    ;;
esac

dnl Expand the cflags and libraries needed by apps using SDL
AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_LIBS)
AC_SUBST(SDL_STATIC_LIBS)
AC_SUBST(SDL_RLD_FLAGS)
if test x$enable_shared = xyes; then
    ENABLE_SHARED_TRUE=
    ENABLE_SHARED_FALSE="#"
else
    ENABLE_SHARED_TRUE="#"
    ENABLE_SHARED_FALSE=
fi
if test x$enable_static = xyes; then
    ENABLE_STATIC_TRUE=
    ENABLE_STATIC_FALSE="#"
else
    ENABLE_STATIC_TRUE="#"
    ENABLE_STATIC_FALSE=
fi
AC_SUBST(ENABLE_SHARED_TRUE)
AC_SUBST(ENABLE_SHARED_FALSE)
AC_SUBST(ENABLE_STATIC_TRUE)
AC_SUBST(ENABLE_STATIC_FALSE)

dnl Expand the sources and objects needed to build the library
AC_SUBST(ac_aux_dir)
AC_SUBST(INCLUDE)
AC_SUBST(SOURCES)
AC_SUBST(OBJECTS)
AC_SUBST(SDLMAIN_SOURCES)
AC_SUBST(SDLMAIN_OBJECTS)
AC_SUBST(SDLMAIN_LDFLAGS)
AC_SUBST(BUILD_CFLAGS)
AC_SUBST(EXTRA_CFLAGS)
AC_SUBST(BUILD_LDFLAGS)
AC_SUBST(EXTRA_LDFLAGS)
AC_SUBST(WINDRES)

AC_OUTPUT([
    Makefile sdl-config SDL.spec SDL.qpg sdl.pc
], [
    : >build-deps
    if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
])