summaryrefslogtreecommitdiff
path: root/configure.in
blob: ca3307eb3cc612ad0d630ed944cb74ab5a3b8670 (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
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
dnl Process this file with autoconf to produce a configure script.
AC_INIT(README.txt)
AC_CONFIG_HEADER(include/SDL_config.h)
AC_CONFIG_AUX_DIR(build-scripts)
AC_CONFIG_MACRO_DIR([acinclude])

dnl Save the CFLAGS to see whether they were passed in or generated
orig_CFLAGS="$CFLAGS"

dnl Set various version strings - taken gratefully from the GTk sources
#
# Making releases:
# Edit include/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=2
SDL_MINOR_VERSION=0
SDL_MICRO_VERSION=6
SDL_INTERFACE_AGE=0
SDL_BINARY_AGE=6
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
dnl AC_CANONICAL_HOST

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 Make sure that srcdir is a full pathname
case "$host" in
    *-*-mingw32*)
        # Except on msys, where make can't handle full pathnames (bug 1972)
        ;;
    *)
        srcdir=`cd $srcdir && pwd`
        ;;
esac

dnl Set up the compiler and linker flags
INCLUDE="-I$srcdir/include"
if test x$srcdir != x.; then
    INCLUDE="-Iinclude $INCLUDE"
elif test -d .hg; then
    AC_MSG_ERROR([
*** When building from Mercurial you should configure and build in a
    separate directory so you don't clobber SDL_config.h, SDL_revision.h
])
fi
BASE_CFLAGS=""
BASE_LDFLAGS=""
case "$host" in
    *-*-cygwin*)
        # We build SDL on cygwin without the UNIX emulation layer
        save_CFLAGS="$CFLAGS"
        have_no_cygwin=no
        AC_MSG_CHECKING(for GCC -mno-cygwin option)
        CFLAGS="$save_CFLAGS -mno-cygwin"

        AC_TRY_COMPILE([
        ],[
        ],[
        have_no_cygwin=yes
        ])
        AC_MSG_RESULT($have_no_cygwin)
        CFLAGS="$save_CFLAGS"

        if test x$have_no_cygwin = xyes; then
            BASE_CFLAGS="-mno-cygwin"
            BASE_LDFLAGS="-mno-cygwin"
        fi
        BASE_CFLAGS="$BASE_CFLAGS -I/usr/include/mingw"
        ;;
esac
# Uncomment the following line if you want to force SDL and applications
# built with it to be compiled for a particular architecture.
#AX_GCC_ARCHFLAG([no], [BASE_CFLAGS="$BASE_CFLAGS $ax_cv_gcc_archflag]")
BUILD_CFLAGS="$CFLAGS $CPPFLAGS -DUSING_GENERATED_CONFIG_H"
# The default optimization for SDL is -O3 (Bug #31)
if test "x$orig_CFLAGS" = x; then
    BUILD_CFLAGS=`echo $BUILD_CFLAGS | sed 's/-O2/-O3/'`
fi
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="-lSDL2 $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 $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
        lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`]
        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 want assertions for debugging/sanity checking SDL itself.
AC_ARG_ENABLE(assertions,
AC_HELP_STRING([--enable-assertions],
               [Enable internal sanity checks (auto/disabled/release/enabled/paranoid) [[default=auto]]]),
              , enable_assertions=auto)
case "$enable_assertions" in
    auto) # Use optimization settings to determine assertion level
        ;;
    disabled)
        AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 0, [ ])
        ;;
    release)
        AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 1, [ ])
        ;;
    enabled)
        AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 2, [ ])
        ;;
    paranoid)
        AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 3, [ ])
        ;;
    *)
        AC_MSG_ERROR([*** unknown assertion level. stop.])
        ;;
esac

dnl See whether we can use gcc style dependency tracking
AC_ARG_ENABLE(dependency-tracking,
AC_HELP_STRING([--enable-dependency-tracking],
               [Use gcc -MMD -MT dependency tracking [[default=yes]]]),
              , enable_dependency_tracking=yes)
if test x$enable_dependency_tracking = xyes; then
    have_gcc_mmd_mt=no
    AC_MSG_CHECKING(for GCC -MMD -MT option)
    AC_TRY_COMPILE([
    #if !defined(__GNUC__) || __GNUC__ < 3
    #error Dependency tracking requires GCC 3.0 or newer
    #endif
    ],[
    ],[
    have_gcc_mmd_mt=yes
    ])
    AC_MSG_RESULT($have_gcc_mmd_mt)

    if test x$have_gcc_mmd_mt = xyes; then
        DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@"
    fi
fi

AC_MSG_CHECKING(for linker option --no-undefined)
have_no_undefined=no
case "$host" in
    dnl Skip this on platforms where it is just simply busted.
    *-*-openbsd*)
        ;;

    *)
        save_LDFLAGS="$LDFLAGS"
        LDFLAGS="$LDFLAGS -Wl,--no-undefined"
        AC_TRY_LINK([
        ],[
        ],[
        have_no_undefined=yes
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--no-undefined"
        ])
        LDFLAGS="$save_LDFLAGS"
        ;;
esac
AC_MSG_RESULT($have_no_undefined)

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, 1, [ ])

    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 wchar.h inttypes.h stdint.h ctype.h math.h iconv.h signal.h)

    dnl Check for typedefs, structures, etc.
    AC_TYPE_SIZE_T

    dnl Check for defines
    AC_CHECK_DEFINE(M_PI, math.h)

    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, 1, [ ])
    fi
    AC_FUNC_STRTOD
    if test x$ac_cv_func_strtod = xyes; then
        AC_DEFINE(HAVE_STRTOD, 1, [ ])
    fi
    AC_CHECK_FUNC(mprotect,
        AC_TRY_COMPILE([
          #include <sys/types.h>
          #include <sys/mman.h>
        ],[
        ],[
        AC_DEFINE(HAVE_MPROTECT, 1, [ ])
        ]),
    )
    AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcscmp 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 vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll)

    AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
    AC_CHECK_FUNCS(atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf)

    AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
    AC_CHECK_FUNCS(iconv)

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

dnl AC_CHECK_SIZEOF(void*)

dnl See whether we can use gcc atomic operations on this architecture
AC_ARG_ENABLE(gcc-atomics,
AC_HELP_STRING([--enable-gcc-atomics],
               [Use gcc builtin atomics [[default=yes]]]),
              , enable_gcc_atomics=yes)
if test x$enable_gcc_atomics = xyes; then
    have_gcc_atomics=no
    AC_MSG_CHECKING(for GCC builtin atomic operations)
    AC_TRY_LINK([
    ],[
    int a;
    void *x, *y, *z;
    __sync_lock_test_and_set(&a, 4);
    __sync_lock_test_and_set(&x, y);
    __sync_fetch_and_add(&a, 1);
    __sync_bool_compare_and_swap(&a, 5, 10);
    __sync_bool_compare_and_swap(&x, y, z);
    ],[
    have_gcc_atomics=yes
    ])
    AC_MSG_RESULT($have_gcc_atomics)

    if test x$have_gcc_atomics = xyes; then
        AC_DEFINE(HAVE_GCC_ATOMICS, 1, [ ])
    else
        # See if we have the minimum operation needed for GCC atomics
        AC_TRY_LINK([
        ],[
        int a;
        __sync_lock_test_and_set(&a, 1);
        __sync_lock_release(&a);
        ],[
        have_gcc_sync_lock_test_and_set=yes
        ])
        if test x$have_gcc_sync_lock_test_and_set = xyes; then
            AC_DEFINE(HAVE_GCC_SYNC_LOCK_TEST_AND_SET, 1, [ ])
        fi
    fi
fi

# Standard C sources
SOURCES="$SOURCES $srcdir/src/*.c"
SOURCES="$SOURCES $srcdir/src/atomic/*.c"
SOURCES="$SOURCES $srcdir/src/audio/*.c"
SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
SOURCES="$SOURCES $srcdir/src/dynapi/*.c"
SOURCES="$SOURCES $srcdir/src/events/*.c"
SOURCES="$SOURCES $srcdir/src/file/*.c"
SOURCES="$SOURCES $srcdir/src/haptic/*.c"
SOURCES="$SOURCES $srcdir/src/joystick/*.c"
SOURCES="$SOURCES $srcdir/src/libm/*.c"
SOURCES="$SOURCES $srcdir/src/power/*.c"
#SOURCES="$SOURCES $srcdir/src/filesystem/*.c"
SOURCES="$SOURCES $srcdir/src/render/*.c"
SOURCES="$SOURCES $srcdir/src/render/*/*.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(atomic,
AC_HELP_STRING([--enable-atomic], [Enable the atomic operations subsystem [[default=yes]]]),
              , enable_atomic=yes)
if test x$enable_atomic != xyes; then
    AC_DEFINE(SDL_ATOMIC_DISABLED, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} atomic"
fi
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, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} audio"
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, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} video"
fi
AC_ARG_ENABLE(render,
AC_HELP_STRING([--enable-render], [Enable the render subsystem [[default=yes]]]),
              , enable_render=yes)
if test x$enable_render != xyes; then
    AC_DEFINE(SDL_RENDER_DISABLED, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} render"
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, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} events"
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, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} joystick"
fi
AC_ARG_ENABLE(haptic,
AC_HELP_STRING([--enable-haptic], [Enable the haptic (force feedback) subsystem [[default=yes]]]),
              , enable_haptic=yes)
if test x$enable_haptic != xyes; then
    AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} haptic"
fi
AC_ARG_ENABLE(power,
AC_HELP_STRING([--enable-power], [Enable the power subsystem [[default=yes]]]),
              , enable_power=yes)
if test x$enable_power != xyes; then
    AC_DEFINE(SDL_POWER_DISABLED, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} power"
fi
AC_ARG_ENABLE(filesystem,
AC_HELP_STRING([--enable-filesystem], [Enable the filesystem subsystem [[default=yes]]]),
              , enable_filesystem=yes)
if test x$enable_filesystem != xyes; then
    AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} filesystem"
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, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} threads"
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, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} timers"
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, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} file"
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, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} loadso"
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, 1, [ ])
else
    SUMMARY_modules="${SUMMARY_modules} cpuinfo"
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
    SUMMARY_modules="${SUMMARY_modules} assembly"

    AC_DEFINE(SDL_ASSEMBLY_ROUTINES, 1, [ ])

    # Make sure that we don't generate floating point code that would
    # cause illegal instruction exceptions on older processors
    case "$host" in
        *-*-darwin*)
            # Don't need to worry about Apple hardware, it's all SSE capable
            default_ssemath=yes
            ;;
        *64-*-*)
            # x86 64-bit architectures all have SSE instructions
            default_ssemath=yes
            ;;
        *)
            default_ssemath=no
            ;;
    esac
    AC_ARG_ENABLE(ssemath,
AC_HELP_STRING([--enable-ssemath], [Allow GCC to use SSE floating point math [[default=maybe]]]),
                  , enable_ssemath=$default_ssemath)
    if test x$enable_ssemath = xno; then
        if test x$have_gcc_sse = xyes -o x$have_gcc_sse2 = xyes -o x$have_gcc_sse3 = xyes; then
            EXTRA_CFLAGS="$EXTRA_CFLAGS -mfpmath=387"
        fi
    fi

    dnl Check for various instruction support
    AC_ARG_ENABLE(mmx,
AC_HELP_STRING([--enable-mmx], [use MMX assembly routines [[default=yes]]]),
                  , enable_mmx=yes)
    if test x$enable_mmx = xyes; then
        save_CFLAGS="$CFLAGS"
        have_gcc_mmx=no
        AC_MSG_CHECKING(for GCC -mmmx option)
        mmx_CFLAGS="-mmmx"
        CFLAGS="$save_CFLAGS $mmx_CFLAGS"

        AC_TRY_COMPILE([
        #ifdef __MINGW32__
        #include <_mingw.h>
        #ifdef __MINGW64_VERSION_MAJOR
        #include <intrin.h>
        #else
        #include <mmintrin.h>
        #endif
        #else
        #include <mmintrin.h>
        #endif
        #ifndef __MMX__
        #error Assembler CPP flag not enabled
        #endif
        ],[
        ],[
        have_gcc_mmx=yes
        ])
        AC_MSG_RESULT($have_gcc_mmx)
        CFLAGS="$save_CFLAGS"

        if test x$have_gcc_mmx = xyes; then
            EXTRA_CFLAGS="$EXTRA_CFLAGS $mmx_CFLAGS"
            SUMMARY_math="${SUMMARY_math} mmx"
        fi
    fi

    AC_ARG_ENABLE(3dnow,
AC_HELP_STRING([--enable-3dnow], [use 3DNow! assembly routines [[default=yes]]]),
                  , enable_3dnow=yes)
    if test x$enable_3dnow = xyes; then
        save_CFLAGS="$CFLAGS"
        have_gcc_3dnow=no
        AC_MSG_CHECKING(for GCC -m3dnow option)
        amd3dnow_CFLAGS="-m3dnow"
        CFLAGS="$save_CFLAGS $amd3dnow_CFLAGS"

        AC_TRY_LINK([
        #include <mm3dnow.h>
        #ifndef __3dNOW__
        #error Assembler CPP flag not enabled
        #endif
        ],[
        void *p = 0;
        _m_prefetch(p);
        ],[
        have_gcc_3dnow=yes
        ])
        AC_MSG_RESULT($have_gcc_3dnow)
        CFLAGS="$save_CFLAGS"

        if test x$have_gcc_3dnow = xyes; then
            EXTRA_CFLAGS="$EXTRA_CFLAGS $amd3dnow_CFLAGS"
            SUMMARY_math="${SUMMARY_math} 3dnow"
        fi
    fi

    AC_ARG_ENABLE(sse,
AC_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=yes]]]),
                  , enable_sse=yes)
    if test x$enable_sse = xyes; then
        save_CFLAGS="$CFLAGS"
        have_gcc_sse=no
        AC_MSG_CHECKING(for GCC -msse option)
        sse_CFLAGS="-msse"
        CFLAGS="$save_CFLAGS $sse_CFLAGS"

        AC_TRY_COMPILE([
        #ifdef __MINGW32__
        #include <_mingw.h>
        #ifdef __MINGW64_VERSION_MAJOR
        #include <intrin.h>
        #else
        #include <xmmintrin.h>
        #endif
        #else
        #include <xmmintrin.h>
        #endif
        #ifndef __SSE__
        #error Assembler CPP flag not enabled
        #endif
        ],[
        ],[
        have_gcc_sse=yes
        ])
        AC_MSG_RESULT($have_gcc_sse)
        CFLAGS="$save_CFLAGS"

        if test x$have_gcc_sse = xyes; then
            EXTRA_CFLAGS="$EXTRA_CFLAGS $sse_CFLAGS"
            SUMMARY_math="${SUMMARY_math} sse"
        fi
    fi

    AC_ARG_ENABLE(sse2,
AC_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=maybe]]]),
                  , enable_sse2=$default_ssemath)
    if test x$enable_sse2 = xyes; then
        save_CFLAGS="$CFLAGS"
        have_gcc_sse2=no
        AC_MSG_CHECKING(for GCC -msse2 option)
        sse2_CFLAGS="-msse2"
        CFLAGS="$save_CFLAGS $sse2_CFLAGS"

        AC_TRY_COMPILE([
        #ifdef __MINGW32__
        #include <_mingw.h>
        #ifdef __MINGW64_VERSION_MAJOR
        #include <intrin.h>
        #else
        #include <emmintrin.h>
        #endif
        #else
        #include <emmintrin.h>
        #endif
        #ifndef __SSE2__
        #error Assembler CPP flag not enabled
        #endif
        ],[
        ],[
        have_gcc_sse2=yes
        ])
        AC_MSG_RESULT($have_gcc_sse2)
        CFLAGS="$save_CFLAGS"

        if test x$have_gcc_sse2 = xyes; then
            EXTRA_CFLAGS="$EXTRA_CFLAGS $sse2_CFLAGS"
            SUMMARY_math="${SUMMARY_math} sse2"
        fi
    fi

    AC_ARG_ENABLE(sse3,
AC_HELP_STRING([--enable-sse3], [use SSE3 assembly routines [[default=maybe]]]),
                  , enable_sse3=$default_ssemath)
    if test x$enable_sse3 = xyes; then
        save_CFLAGS="$CFLAGS"
        have_gcc_sse3=no
        AC_MSG_CHECKING(for GCC -msse3 option)
        sse3_CFLAGS="-msse3"
        CFLAGS="$save_CFLAGS $sse3_CFLAGS"

        AC_TRY_COMPILE([
        #ifdef __MINGW32__
        #include <_mingw.h>
        #ifdef __MINGW64_VERSION_MAJOR
        #include <intrin.h>
        #else
        #include <pmmintrin.h>
        #endif
        #else
        #include <pmmintrin.h>
        #endif
        #ifndef __SSE2__
        #error Assembler CPP flag not enabled
        #endif
        ],[
        ],[
        have_gcc_sse3=yes
        ])
        AC_MSG_RESULT($have_gcc_sse3)
        CFLAGS="$save_CFLAGS"

        if test x$have_gcc_sse3 = xyes; then
            EXTRA_CFLAGS="$EXTRA_CFLAGS $sse3_CFLAGS"
            SUMMARY_math="${SUMMARY_math} sse3"
        fi
    fi

    AC_ARG_ENABLE(altivec,
AC_HELP_STRING([--enable-altivec], [use Altivec assembly routines [[default=yes]]]),
                  , enable_altivec=yes)
    if test 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, 1, [ ])
            if test x$have_altivec_h_hdr = xyes; then
              AC_DEFINE(HAVE_ALTIVEC_H, 1, [ ])
            fi
            EXTRA_CFLAGS="$EXTRA_CFLAGS $altivec_CFLAGS"
            SUMMARY_math="${SUMMARY_math} altivec"
        fi
    fi
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=maybe]]]),
                  , enable_oss=maybe)

    # OpenBSD "has" OSS, but it's not really for app use. They want you to
    #  use sndio instead. So on there, we default to disabled. You can force
    #  it on if you really want, though.
    if test x$enable_oss = xmaybe; then
        enable_oss=yes
        case "$host" in
            *-*-openbsd*)
                enable_oss=no;;
        esac
    fi

    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, 1, [ ])
            ])
        fi
        AC_MSG_RESULT($have_oss)
        if test x$have_oss = xyes; then
            SUMMARY_audio="${SUMMARY_audio} oss"
            AC_DEFINE(SDL_AUDIO_DRIVER_OSS, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/audio/dsp/*.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(1.0.11, 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, 1, [ ])
            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", [ ])
                SUMMARY_audio="${SUMMARY_audio} alsa(dynamic)"
            else
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ALSA_LIBS"
                SUMMARY_audio="${SUMMARY_audio} alsa"
            fi
            have_audio=yes
        fi
    fi
}

dnl Find JACK Audio
CheckJACK()
{
    AC_ARG_ENABLE(jack,
AC_HELP_STRING([--enable-jack], [use JACK audio [[default=yes]]]),
                  , enable_jack=yes)
    if test x$enable_audio = xyes -a x$enable_jack = xyes; then
        audio_jack=no

        JACK_REQUIRED_VERSION=0.125

        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
        AC_MSG_CHECKING(for JACK $JACK_REQUIRED_VERSION support)
        if test x$PKG_CONFIG != xno; then
        if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $JACK_REQUIRED_VERSION jack; then
                JACK_CFLAGS=`$PKG_CONFIG --cflags jack`
                JACK_LIBS=`$PKG_CONFIG --libs jack`
                audio_jack=yes
            fi
        fi
        AC_MSG_RESULT($audio_jack)

        if test x$audio_jack = xyes; then
            AC_ARG_ENABLE(jack-shared,
AC_HELP_STRING([--enable-jack-shared], [dynamically load JACK audio support [[default=yes]]]),
                          , enable_jack_shared=yes)
            jack_lib=[`find_lib "libjack.so.*" "$JACK_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]

            AC_DEFINE(SDL_AUDIO_DRIVER_JACK, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/audio/jack/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $JACK_CFLAGS"
            if test x$have_loadso != xyes && \
               test x$enable_jack_shared = xyes; then
                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic JACK audio loading])
            fi
            if test x$have_loadso = xyes && \
               test x$enable_jack_shared = xyes && test x$jack_lib != x; then
                echo "-- dynamic libjack -> $jack_lib"
                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_JACK_DYNAMIC, "$jack_lib", [ ])
                SUMMARY_audio="${SUMMARY_audio} jack(dynamic)"

                case "$host" in
                    # On Solaris, jack must be linked deferred explicitly
                    # to prevent undefined symbol failures.
                    *-*-solaris*)
                        JACK_LIBS=`echo $JACK_LIBS | sed 's/\-l/-Wl,-l/g'`
                        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-zdeferred $JACK_LIBS -Wl,-znodeferred"
                esac
            else
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $JACK_LIBS"
                SUMMARY_audio="${SUMMARY_audio} jack"
            fi
            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, 1, [ ])
            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", [ ])
                SUMMARY_audio="${SUMMARY_audio} esd(dynamic)"
            else
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ESD_LIBS"
                SUMMARY_audio="${SUMMARY_audio} esd"
            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_pulseaudio=no

        PULSEAUDIO_REQUIRED_VERSION=0.9

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

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

            AC_DEFINE(SDL_AUDIO_DRIVER_PULSEAUDIO, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/audio/pulseaudio/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $PULSEAUDIO_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$pulseaudio_lib != x; then
                echo "-- dynamic libpulse-simple -> $pulseaudio_lib"
                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC, "$pulseaudio_lib", [ ])
                SUMMARY_audio="${SUMMARY_audio} pulse(dynamic)"

                case "$host" in
                    # On Solaris, pulseaudio must be linked deferred explicitly
                    # to prevent undefined symbol failures.
                    *-*-solaris*)
                        PULSEAUDIO_LIBS=`echo $PULSEAUDIO_LIBS | sed 's/\-l/-Wl,-l/g'`
                        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-zdeferred $PULSEAUDIO_LIBS -Wl,-znodeferred"
                esac
            else
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PULSEAUDIO_LIBS"
                SUMMARY_audio="${SUMMARY_audio} pulse"
            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, 1, [ ])
                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", [ ])
                    SUMMARY_audio="${SUMMARY_audio} arts(dynamic)"
                else
                    EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ARTS_LIBS"
                    SUMMARY_audio="${SUMMARY_audio} arts"
                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"

        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", [ ])
                SUMMARY_audio="${SUMMARY_audio} nas(dynamic)"
            else
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $NAS_LIBS"
                SUMMARY_audio="${SUMMARY_audio} nas"
            fi

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

dnl See if the sndio audio interface is supported
CheckSNDIO()
{
    AC_ARG_ENABLE(sndio,
AC_HELP_STRING([--enable-sndio], [support the sndio audio API [[default=yes]]]),
                  , enable_sndio=yes)
    if test x$enable_audio = xyes -a x$enable_sndio = xyes; then
        AC_CHECK_HEADER(sndio.h, have_sndio_hdr=yes)
        AC_CHECK_LIB(sndio, sio_open, have_sndio_lib=yes)

        AC_MSG_CHECKING(for sndio audio support)
        have_sndio=no

        if test x$have_sndio_hdr = xyes -a x$have_sndio_lib = xyes; then
            have_sndio=yes
            SNDIO_LIBS="-lsndio"
        fi

        AC_MSG_RESULT($have_sndio)

        if test x$have_sndio = xyes; then
            AC_ARG_ENABLE(sndio-shared,
AC_HELP_STRING([--enable-sndio-shared], [dynamically load sndio audio support [[default=yes]]]),
                          , enable_sndio_shared=yes)
            sndio_lib=[`find_lib "libsndio.so.*" "$SNDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]

            if test x$have_loadso != xyes && \
               test x$enable_sndio_shared = xyes; then
                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic sndio loading])
            fi
            if test x$have_loadso = xyes && \
               test x$enable_sndio_shared = xyes && test x$sndio_lib != x; then
                echo "-- dynamic libsndio -> $sndio_lib"
                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC, "$sndio_lib", [ ])
                SUMMARY_audio="${SUMMARY_audio} sndio(dynamic)"
            else
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SNDIO_LIBS"
                SUMMARY_audio="${SUMMARY_audio} sndio"
            fi

            AC_DEFINE(SDL_AUDIO_DRIVER_SNDIO, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/audio/sndio/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $SNDIO_CFLAGS"
            have_audio=yes
        fi
    fi
}

dnl Find FusionSound
CheckFusionSound()
{
    AC_ARG_ENABLE(fusionsound,
AC_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]),
                  , enable_fusionsound=no)
    if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
        fusionsound=no

        FUSIONSOUND_REQUIRED_VERSION=1.1.1

        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
        AC_MSG_CHECKING(for FusionSound $FUSIONSOUND_REQUIRED_VERSION support)
        if test x$PKG_CONFIG != xno; then
            if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
                FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
                FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
                fusionsound=yes
            fi
        fi
        AC_MSG_RESULT($fusionsound)

        if test x$fusionsound = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_FUSIONSOUND, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
            
            AC_ARG_ENABLE(fusionsound-shared,
AC_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]),
                          , enable_fusionsound_shared=yes)
            fusionsound_shared=no
            AC_MSG_CHECKING(for FusionSound dynamic loading support)
            if test x$have_loadso != xyes && \
               test x$enable_fusionsound_shared = xyes; then
                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic fusionsound loading])
            fi
            if test x$have_loadso = xyes && \
               test x$enable_fusionsound_shared = xyes; then
                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC, "libfusionsound.so", [ ])
                fusionsound_shared=yes
                SUMMARY_audio="${SUMMARY_audio} fusionsound(dynamic)"
            else
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
                SUMMARY_audio="${SUMMARY_audio} fusionsound"
            fi
            AC_MSG_RESULT($fusionsound_shared)
            
            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, 1, [ ])
        SOURCES="$SOURCES $srcdir/src/audio/disk/*.c"
        SUMMARY_audio="${SUMMARY_audio} disk"
    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, 1, [ ])
        SOURCES="$SOURCES $srcdir/src/audio/dummy/*.c"
        SUMMARY_audio="${SUMMARY_audio} dummy"
    fi
}

dnl See if libsamplerate is available
CheckLibSampleRate()
{
    AC_ARG_ENABLE(libsamplerate,
AC_HELP_STRING([--enable-libsamplerate], [use libsamplerate for audio rate conversion [[default=yes]]]),
                  , enable_libsamplerate=yes)
    if test x$enable_libsamplerate = xyes; then
        AC_CHECK_HEADER(samplerate.h,
                        have_samplerate_h_hdr=yes,
                        have_samplerate_h_hdr=no)
        if test x$have_samplerate_h_hdr = xyes; then
            AC_DEFINE(HAVE_LIBSAMPLERATE_H, 1, [ ])

            AC_ARG_ENABLE(libsamplerate-shared,
AC_HELP_STRING([--enable-libsamplerate-shared], [dynamically load libsamplerate [[default=yes]]]),
                          , enable_libsamplerate_shared=yes)

            samplerate_lib=[`find_lib "libsamplerate.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`]

            if test x$have_loadso != xyes && \
               test x$enable_libsamplerate_shared = xyes; then
                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic libsamplerate loading])
            fi
            if test x$have_loadso = xyes && \
               test x$enable_libsamplerate_shared = xyes && test x$samplerate_lib != x; then
                echo "-- dynamic libsamplerate -> $samplerate_lib"
                AC_DEFINE_UNQUOTED(SDL_LIBSAMPLERATE_DYNAMIC, "$samplerate_lib", [ ])
            else
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lsamplerate"
            fi
        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 -mpreferred-stack-boundary is supported.
dnl  Reference: http://bugzilla.libsdl.org/show_bug.cgi?id=1296
CheckStackBoundary()
{
    AC_MSG_CHECKING(for GCC -mpreferred-stack-boundary option)
    have_gcc_preferred_stack_boundary=no

    save_CFLAGS="$CFLAGS"
    CFLAGS="$save_CFLAGS -mpreferred-stack-boundary=2"
    AC_TRY_COMPILE([
    int x = 0;
    ],[
    ],[
    have_gcc_preferred_stack_boundary=yes
    ])
    AC_MSG_RESULT($have_gcc_preferred_stack_boundary)
    CFLAGS="$save_CFLAGS"

    if test x$have_gcc_preferred_stack_boundary = xyes; then
        EXTRA_CFLAGS="$EXTRA_CFLAGS -mpreferred-stack-boundary=2"
    fi
}

dnl See if GCC's -Wdeclaration-after-statement is supported.
dnl  This lets us catch things that would fail on a C89 compiler when using
dnl  a modern GCC.
CheckDeclarationAfterStatement()
{
    AC_MSG_CHECKING(for GCC -Wdeclaration-after-statement option)
    have_gcc_declaration_after_statement=no

    save_CFLAGS="$CFLAGS"
    CFLAGS="$save_CFLAGS -Wdeclaration-after-statement -Werror=declaration-after-statement"
    AC_TRY_COMPILE([
    int x = 0;
    ],[
    ],[
    have_gcc_declaration_after_statement=yes
    ])
    AC_MSG_RESULT($have_gcc_declaration_after_statement)
    CFLAGS="$save_CFLAGS"

    if test x$have_gcc_declaration_after_statement = xyes; then
        EXTRA_CFLAGS="$EXTRA_CFLAGS -Wdeclaration-after-statement -Werror=declaration-after-statement"
    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
            *-*-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 Check for Wayland
CheckWayland()
{
    AC_ARG_ENABLE(video-wayland,
AC_HELP_STRING([--enable-video-wayland], [use Wayland video driver [[default=yes]]]),
                  ,enable_video_wayland=yes)

    AC_ARG_ENABLE(video-wayland-qt-touch,
AC_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for Wayland video driver [[default=yes]]]),
                  ,enable_video_wayland_qt_touch=yes)

    if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then
        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
        AC_MSG_CHECKING(for Wayland support)
        video_wayland=no
        if  test x$PKG_CONFIG != xno && \
            test x$video_opengl_egl = xyes && \
            test x$video_opengles_v2 = xyes; then
            if $PKG_CONFIG --exists wayland-client wayland-scanner wayland-protocols wayland-egl wayland-cursor egl xkbcommon ; then
                WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon`
                WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon`
                WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
                WAYLAND_CORE_PROTOCOL_DIR=`$PKG_CONFIG --variable=pkgdatadir wayland-client`
                WAYLAND_PROTOCOLS_DIR=`$PKG_CONFIG --variable=pkgdatadir wayland-protocols`
                video_wayland=yes
            fi
        fi
        AC_MSG_RESULT($video_wayland)

        if test x$video_wayland = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND, 1, [ ])
            if test x$enable_video_wayland_qt_touch = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH, 1, [ ])
            fi

            WAYLAND_PROTOCOLS_UNSTABLE="relative-pointer-unstable-v1 pointer-constraints-unstable-v1"

            SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS -I\$(gen)"
            AC_ARG_ENABLE(wayland-shared,
AC_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[default=maybe]]]),
                          , enable_wayland_shared=maybe)

            dnl FIXME: Do BSD and OS X need special cases?
            case "$host" in
                *)
                    wayland_client_lib=[`find_lib "libwayland-client.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
                    wayland_egl_lib=[`find_lib "libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
                    if test x$wayland_egl_lib = x; then
                        dnl This works in Ubuntu 13.10, maybe others
                        wayland_egl_lib=[`find_lib "mesa-egl/libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
                    fi
                    wayland_cursor_lib=[`find_lib "libwayland-cursor.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
                    xkbcommon_lib=[`find_lib "libxkbcommon.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
                    ;;
            esac

            if test x$enable_wayland_shared = xmaybe; then
                enable_wayland_shared=yes
            fi
            if test x$have_loadso != xyes && \
               test x$enable_wayland_shared = xyes; then
                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic Wayland loading])
                enable_wayland_shared=no
            fi
            if test x$have_loadso = xyes && \
               test x$enable_wayland_shared = xyes && \
               test x$wayland_client_lib != x && \
               test x$wayland_egl_lib != x && \
               test x$wayland_cursor_lib != x && \
               test x$xkbcommon_lib != x; then
                echo "-- dynamic libwayland-client -> $wayland_client_lib"
                echo "-- dynamic libwayland-egl -> $wayland_egl_lib"
                echo "-- dynamic libwayland-cursor -> $wayland_cursor_lib"
                echo "-- dynamic libxkbcommon -> $xkbcommon_lib"
                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC, "$wayland_client_lib", [ ])
                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL, "$wayland_egl_lib", [ ])
                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR, "$wayland_cursor_lib", [ ])
                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON, "$xkbcommon_lib", [ ])
                SUMMARY_video="${SUMMARY_video} wayland(dynamic)"
            else
                enable_wayland_shared=no
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
                SUMMARY_video="${SUMMARY_video} wayland"
            fi
            have_video=yes
        fi
    fi
}

dnl Check for Mir
CheckMir()
{
    AC_ARG_ENABLE(video-mir,
AC_HELP_STRING([--enable-video-mir], [use Mir video driver [[default=yes]]]),
                  ,enable_video_mir=yes)

    if test x$enable_video = xyes -a x$enable_video_mir = xyes; then
        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
        AC_MSG_CHECKING(for Mir support)
        video_mir=no
        if test x$PKG_CONFIG != xno; then
            if $PKG_CONFIG --exists mirclient egl xkbcommon ; then
                MIR_CFLAGS=`$PKG_CONFIG --cflags mirclient egl xkbcommon`
                MIR_LIBS=`$PKG_CONFIG --libs mirclient egl xkbcommon`
                save_CFLAGS="$CFLAGS"
                CFLAGS="$save_CFLAGS $MIR_CFLAGS"

                dnl This will disable Mir if >= v0.26 is not available
                AC_TRY_COMPILE([
                #include <mir_toolkit/mir_client_library.h>
                ],[
                    MirWindowAttrib attrib = mir_window_attrib_state
                ],[
                video_mir=yes
                ])
                CFLAGS="$save_CFLAGS"
            fi
        fi
        AC_MSG_RESULT($video_mir)

        if test x$video_mir = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_MIR, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/video/mir/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $MIR_CFLAGS"
            AC_ARG_ENABLE(mir-shared,
AC_HELP_STRING([--enable-mir-shared], [dynamically load Mir support [[default=maybe]]]),
                          , enable_mir_shared=maybe)

            dnl FIXME: Do BSD and OS X need special cases?
            case "$host" in
                *)
                    mirclient_lib=[`find_lib "libmirclient.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
                    xkbcommon_lib=[`find_lib "libxkbcommon.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
                    ;;
            esac

            if test x$enable_mir_shared = xmaybe; then
                enable_mir_shared=yes
            fi
            if test x$have_loadso != xyes && \
               test x$enable_mir_shared = xyes; then
                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic Mir loading])
                enable_mir_shared=no
            fi
            if test x$have_loadso = xyes && \
               test x$enable_mir_shared = xyes && \
               test x$mirclient_lib != x && \
               test x$xkbcommon_lib != x; then
                echo "-- dynamic libmirclient -> $mirclient_lib"
                echo "-- dynamic libxkbcommon -> $xkbcommon_lib"
                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_MIR_DYNAMIC, "$mirclient_lib", [ ])
                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON, "$xkbcommon_lib", [ ])
                SUMMARY_video="${SUMMARY_video} mir(dynamic)"
            else
                enable_mir_shared=no
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MIR_LIBS"
                SUMMARY_video="${SUMMARY_video} mir"
            fi
            have_video=yes
        fi
    fi
}

dnl Check for Native Client stuff
CheckNativeClient()
{
        AC_TRY_COMPILE([
          #if !defined(__native_client__)
          #error "NO NACL"
          #endif
        ],[
        ],[
        AC_DEFINE(SDL_VIDEO_DRIVER_NACL, 1, [ ])
        AC_DEFINE(SDL_AUDIO_DRIVER_NACL, 1, [ ])
        AC_DEFINE(HAVE_POW, 1, [ ])
        AC_DEFINE(HAVE_OPENGLES2, 1, [ ])
        AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
        AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])

        SDL_LIBS="-lppapi_simple -lppapi_gles2 $SDL_LIBS"

        SDLMAIN_SOURCES="$srcdir/src/main/nacl/*.c"
        SOURCES="$SOURCES $srcdir/src/audio/nacl/*.c"
        SUMMARY_audio="${SUMMARY_audio} nacl"
        SOURCES="$SOURCES $srcdir/src/video/nacl/*.c"
        SUMMARY_video="${SUMMARY_video} nacl opengles2"
        ])
}


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 && \
                   test -d /usr/X11R6/include && \
                   test -d /usr/X11R6/lib; 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
            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*)
                    x11_lib='/usr/X11R6/lib/libX11.6.dylib'
                    x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
                    xcursor_lib='/usr/X11R6/lib/libXcursor.1.dylib'
                    xinerama_lib='/usr/X11R6/lib/libXinerama.1.dylib'
                    xinput_lib='/usr/X11R6/lib/libXi.6.dylib'
                    xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
                    xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
                    xss_lib='/usr/X11R6/lib/libXss.1.dylib'
                    xvidmode_lib='/usr/X11R6/lib/libXxf86vm.1.dylib'
                    ;;
                *-*-openbsd*)
                    x11_lib='libX11.so'
                    x11ext_lib='libXext.so'
                    xcursor_lib='libXcursor.so'
                    xinerama_lib='libXinerama.so'
                    xinput_lib='libXi.so'
                    xrandr_lib='libXrandr.so'
                    xrender_lib='libXrender.so'
                    xss_lib='libXss.so'
                    xvidmode_lib='libXxf86vm.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'`]
                    xcursor_lib=[`find_lib "libXcursor.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
                    xinerama_lib=[`find_lib "libXinerama.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
                    xinput_lib=[`find_lib "libXi.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'`]
                    xrender_lib=[`find_lib "libXrender.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
                    xss_lib=[`find_lib "libXss.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
                    xvidmode_lib=[`find_lib "libXxf86vm.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
                    ;;
            esac

            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_CHECK_HEADER(X11/extensions/Xext.h,
                            have_xext_h_hdr=yes,
                            have_xext_h_hdr=no,
                            [#include <X11/Xlib.h>
                             #include <X11/Xproto.h>
                            ])
            if test x$have_xext_h_hdr != xyes; then
               AC_MSG_ERROR([
*** Missing Xext.h, maybe you need to install the libxext-dev package?
               ])
            fi

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

            # Needed so SDL applications can include SDL_syswm.h
            SDL_CFLAGS="$SDL_CFLAGS $X_CFLAGS"

            if test x$enable_x11_shared = xmaybe; then
                enable_x11_shared=yes
            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$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", [ ])
                SUMMARY_video="${SUMMARY_video} x11(dynamic)"
            else
                enable_x11_shared=no
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
                SUMMARY_video="${SUMMARY_video} x11"
            fi
            have_video=yes

            AC_MSG_CHECKING(for const parameter to XextAddDisplay)
            have_const_param_XextAddDisplay=no
            AC_TRY_COMPILE([
              #include <X11/Xlib.h>
              #include <X11/Xproto.h>
              #include <X11/extensions/Xext.h>
              #include <X11/extensions/extutil.h>
              extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
            ],[
            ],[
            have_const_param_XextAddDisplay=yes
            AC_DEFINE([SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY], 1, [ ])
            ])
            AC_MSG_RESULT($have_const_param_XextAddDisplay)

            dnl AC_CHECK_LIB(X11, XGetEventData, AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS, 1, [Have XGenericEvent]))
            AC_MSG_CHECKING([for XGenericEvent])
            have_XGenericEvent=no
            AC_TRY_COMPILE([
              	#include <X11/Xlib.h>
            ],[
Display *display;
XEvent event;
XGenericEventCookie *cookie = &event.xcookie;
XNextEvent(display, &event);
XGetEventData(display, cookie);
XFreeEventData(display, cookie);
            ],[
                have_XGenericEvent=yes
                AC_DEFINE([SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS], 1, [ ])
            ])
            AC_MSG_RESULT($have_XGenericEvent)

            AC_CHECK_LIB(X11, XkbKeycodeToKeysym, AC_DEFINE(SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM, 1, [Have XkbKeycodeToKeysym]))

            AC_ARG_ENABLE(video-x11-xcursor,
AC_HELP_STRING([--enable-video-x11-xcursor], [enable X11 Xcursor support [[default=yes]]]),
                            , enable_video_x11_xcursor=yes)
            if test x$enable_video_x11_xcursor = xyes; then
                definitely_enable_video_x11_xcursor=no
                AC_CHECK_HEADER(X11/Xcursor/Xcursor.h,
                                have_xcursor_h_hdr=yes,
                                have_xcursor_h_hdr=no,
                                [#include <X11/Xlib.h>
                                ])
                if test x$have_xcursor_h_hdr = xyes; then
                    if test x$enable_x11_shared = xyes && test x$xcursor_lib != x ; then
                        echo "-- dynamic libXcursor -> $xcursor_lib"
                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR, "$xcursor_lib", [ ])
                        definitely_enable_video_x11_xcursor=yes
                    else
                        AC_CHECK_LIB(Xcursor, XcursorImageCreate, have_xcursor_lib=yes)
                        if test x$have_xcursor_lib = xyes ; then
                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXcursor"
                            definitely_enable_video_x11_xcursor=yes
                        fi
                    fi
                fi
            fi
            if test x$definitely_enable_video_x11_xcursor = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XCURSOR, 1, [ ])
                SUMMARY_video_x11="${SUMMARY_video_x11} xcursor"
            fi
            AC_ARG_ENABLE(video-x11-xdbe,
AC_HELP_STRING([--enable-video-x11-xdbe], [enable X11 Xdbe support [[default=yes]]]),
                            , enable_video_x11_xdbe=yes)
            if test x$enable_video_x11_xdbe = xyes; then
                AC_CHECK_HEADER(X11/extensions/Xdbe.h,
                                have_dbe_h_hdr=yes,
                                have_dbe_h_hdr=no,
                                [#include <X11/Xlib.h>
                                ])
                if test x$have_dbe_h_hdr = xyes; then
                    AC_DEFINE(SDL_VIDEO_DRIVER_X11_XDBE, 1, [ ])
                    SUMMARY_video_x11="${SUMMARY_video_x11} xdbe"
                fi
            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
                definitely_enable_video_x11_xinerama=no
                AC_CHECK_HEADER(X11/extensions/Xinerama.h,
                                have_xinerama_h_hdr=yes,
                                have_xinerama_h_hdr=no,
                                [#include <X11/Xlib.h>
                                ])
                if test x$have_xinerama_h_hdr = xyes; then
                    if test x$enable_x11_shared = xyes && test x$xinerama_lib != x ; then
                        echo "-- dynamic libXinerama -> $xinerama_lib"
                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA, "$xinerama_lib", [ ])
                        definitely_enable_video_x11_xinerama=yes
                    else
                        AC_CHECK_LIB(Xinerama, XineramaQueryExtension, have_xinerama_lib=yes)
                        if test x$have_xinerama_lib = xyes ; then
                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXinerama"
                            definitely_enable_video_x11_xinerama=yes
                        fi
                    fi
                fi
            fi
            if test x$definitely_enable_video_x11_xinerama = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA, 1, [ ])
                SUMMARY_video_x11="${SUMMARY_video_x11} xinerama"
            fi
            AC_ARG_ENABLE(video-x11-xinput,
AC_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for manymouse, tablets, etc [[default=yes]]]),
                            , enable_video_x11_xinput=yes)
            if test x$enable_video_x11_xinput = xyes; then
                definitely_enable_video_x11_xinput=no
                AC_CHECK_HEADER(X11/extensions/XInput2.h,
                                have_xinput_h_hdr=yes,
                                have_xinput_h_hdr=no,
                                [#include <X11/Xlib.h>
                                ])
                if test x$have_xinput_h_hdr = xyes; then
                    if test x$enable_x11_shared = xyes && test x$xinput_lib != x ; then
                        echo "-- dynamic libXi -> $xinput_lib"
                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2, "$xinput_lib", [ ])
                        definitely_enable_video_x11_xinput=yes
                    else
                        AC_CHECK_LIB(Xi, XOpenDevice, have_xinput_lib=yes)
                        if test x$have_xinput_lib = xyes ; then
                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXi"
                            definitely_enable_video_x11_xinput=yes
                        fi
                    fi
                fi
            fi
            if test x$definitely_enable_video_x11_xinput = xyes; then
                SUMMARY_video_x11="${SUMMARY_video_x11} xinput2"
                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2, 1, [ ])
                AC_MSG_CHECKING(for xinput2 multitouch)
            	have_xinput2_multitouch=no
            	AC_TRY_COMPILE([
              		#include <X11/Xlib.h>
             		#include <X11/Xproto.h>
			#include <X11/extensions/XInput2.h>
            	],[
int event_type = XI_TouchBegin;
XITouchClassInfo *t;
            	],[
            	have_xinput2_multitouch=yes
            	AC_DEFINE([SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH], 1, [])
                SUMMARY_video_x11="${SUMMARY_video_x11} xinput2_multitouch"
            	])
            	AC_MSG_RESULT($have_xinput2_multitouch)
            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
                dnl XRRScreenResources is only present in Xrandr >= 1.2, we use that as a test.
                definitely_enable_video_x11_xrandr=no
                have_xrandr_h_hdr=no
                AC_TRY_COMPILE([
                #include <X11/Xlib.h>
                #include <X11/extensions/Xrandr.h>
                ],[
                XRRScreenResources *res = NULL;
                ],[
                have_xrandr_h_hdr=yes
                ])
                if test x$have_xrandr_h_hdr = xyes; then
                    if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
                        echo "-- dynamic libXrandr -> $xrandr_lib"
                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib", [ ])
                        definitely_enable_video_x11_xrandr=yes
                    else
                        AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
                        if test x$have_xrandr_lib = xyes ; then
                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr"
                            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, 1, [ ])
                SUMMARY_video_x11="${SUMMARY_video_x11} xrandr"
            fi
            AC_ARG_ENABLE(video-x11-scrnsaver,
AC_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension [[default=yes]]]),
                            , enable_video_x11_scrnsaver=yes)
            if test x$enable_video_x11_scrnsaver = xyes; then
                AC_CHECK_HEADER(X11/extensions/scrnsaver.h,
                                have_scrnsaver_h_hdr=yes,
                                have_scrnsaver_h_hdr=no,
                                [#include <X11/Xlib.h>
                                ])
                if test x$have_scrnsaver_h_hdr = xyes; then
                    if test x$enable_x11_shared = xyes && test x$xss_lib != x ; then
                        echo "-- dynamic libXss -> $xss_lib"
                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS, "$xss_lib", [ ])
                        definitely_enable_video_x11_scrnsaver=yes
                    else
                        AC_CHECK_LIB(Xss, XScreenSaverSuspend, have_xss_lib=yes)
                        if test x$have_xss_lib = xyes ; then
                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXss"
                            definitely_enable_video_x11_scrnsaver=yes
                        fi
                    fi
                fi
            fi
            if test x$definitely_enable_video_x11_scrnsaver = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSCRNSAVER, 1, [ ])
                SUMMARY_video_x11="${SUMMARY_video_x11} xscrnsaver"
            fi
            AC_ARG_ENABLE(video-x11-xshape,
AC_HELP_STRING([--enable-video-x11-xshape], [enable X11 XShape support [[default=yes]]]),
                            , enable_video_x11_xshape=yes)
            if test x$enable_video_x11_xshape = xyes; then
                AC_CHECK_HEADER(X11/extensions/shape.h,
                                have_shape_h_hdr=yes,
                                have_shape_h_hdr=no,
                                [#include <X11/Xlib.h>
                                ])
                if test x$have_shape_h_hdr = xyes; then
                    AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSHAPE, 1, [ ])
                    SUMMARY_video_x11="${SUMMARY_video_x11} xshape"
                fi
            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
                definitely_enable_video_x11_vm=no
                AC_CHECK_HEADER(X11/extensions/xf86vmode.h,
                                have_vm_h_hdr=yes,
                                have_vm_h_hdr=no,
                                [#include <X11/Xlib.h>
                                ])
                if test x$have_vm_h_hdr = xyes; then
                    if test x$enable_x11_shared = xyes && test x$xvidmode_lib != x ; then
                        echo "-- dynamic libXxf86vm -> $xvidmode_lib"
                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE, "$xvidmode_lib", [ ])
                        definitely_enable_video_x11_vm=yes
                    else
                        AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryVersion, have_vm_lib=yes)
                        if test x$have_vm_lib = xyes ; then
                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXxf86vm"
                            definitely_enable_video_x11_vm=yes
                        fi
                    fi
                fi
            fi
            if test x$definitely_enable_video_x11_vm = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XVIDMODE, 1, [ ])
                SUMMARY_video_x11="${SUMMARY_video_x11} xvidmode"
            fi
        fi
    fi
}

dnl Set up the Vivante video driver if enabled
CheckVivanteVideo()
{
    AC_ARG_ENABLE(video-vivante,
AC_HELP_STRING([--enable-video-vivante], [use Vivante EGL video driver [[default=yes]]]),
                  , enable_video_vivante=yes)
    if test x$enable_video = xyes -a x$enable_video_vivante = xyes; then
        AC_MSG_CHECKING(for Vivante VDK API)
        have_vivante_vdk=no
        AC_TRY_COMPILE([
          #define LINUX
          #define EGL_API_FB
          #include <gc_vdk.h>
        ],[
        ],[
        have_vivante_vdk=yes
        ])
        AC_MSG_RESULT($have_vivante_vdk)

        AC_MSG_CHECKING(for Vivante FB API)
        have_vivante_egl=no
        AC_TRY_COMPILE([
          #define LINUX
          #define EGL_API_FB
          #include <EGL/eglvivante.h>
        ],[
        ],[
        have_vivante_egl=yes
        ])
        AC_MSG_RESULT($have_vivante_egl)

        if test x$have_vivante_vdk = xyes -o x$have_vivante_egl = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE, 1, [ ])
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DLINUX -DEGL_API_FB"
            if test x$have_vivante_vdk = xyes; then
                AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE_VDK, 1, [ ])
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lVDK"
            fi
            SOURCES="$SOURCES $srcdir/src/video/vivante/*.c"
            SUMMARY_video="${SUMMARY_video} vivante"
            have_video=yes
        fi
    fi
}

dnl Set up the Haiku video driver if enabled
CheckHaikuVideo()
{
    if test x$enable_video = xyes; then
        AC_DEFINE(SDL_VIDEO_DRIVER_HAIKU, 1, [ ])
        SOURCES="$SOURCES $srcdir/src/video/haiku/*.cc"
        have_video=yes
        SUMMARY_video="${SUMMARY_video} haiku"
    fi
}

dnl Set up the Cocoa video driver for Mac OS X (but not Darwin)
CheckCOCOA()
{
    AC_ARG_ENABLE(video-cocoa,
AC_HELP_STRING([--enable-video-cocoa], [use Cocoa 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_COCOA, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/video/cocoa/*.m"
            SUMMARY_video="${SUMMARY_video} cocoa"
            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=no]]]),
                  , enable_video_directfb=no)
    if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
        video_directfb=no

        DIRECTFB_REQUIRED_VERSION=1.0.0
        AC_PATH_PROGS(DIRECTFBCONFIG, directfb-config, no, [$prefix/bin:$PATH])
        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`
                    DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb`
                    video_directfb=yes
                fi
            fi
        else
            set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
            NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
            set -- `$DIRECTFBCONFIG --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`
                DIRECTFB_PREFIX=`$DIRECTFBCONFIG --prefix`
                video_directfb=yes
            fi
        fi
        if test x$video_directfb = xyes; then
            # SuSE 11.1 installs directfb-config without directfb-devel
            save_CPPFLAGS="$CPPFLAGS"
            CPPFLAGS="$CPPFLAGS $DIRECTFB_CFLAGS"
            AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
            CPPFLAGS="$save_CPPFLAGS"
            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_ARG_ENABLE(directfb-shared,
AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]),
                              , enable_directfb_shared=yes)

            AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB, 1, [ ])
            AC_DEFINE(SDL_VIDEO_RENDER_DIRECTFB, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
            EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"

            AC_MSG_CHECKING(for directfb dynamic loading support)
            directfb_shared=no
            directfb_lib=[`find_lib "libdirectfb*.so.*" "$DIRECTFB_LIBS"`]
            # | sed 's/.*\/\(.*\)/\1/; q'`]
AC_MSG_WARN("directfb $directfb_lib")
            if test x$have_loadso != xyes && \
               test x$enable_directfb_shared = xyes; then
                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
            fi
            if test x$have_loadso = xyes && \
               test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then
                directfb_shared=yes
                echo "-- $directfb_lib_spec -> $directfb_lib"
                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib", [ ])
                SUMMARY_video="${SUMMARY_video} directfb(dynamic)"
            else
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
                SUMMARY_video="${SUMMARY_video} directfb"
            fi
            AC_MSG_RESULT($directfb_shared)
            SDL_CFLAGS="$SDL_CFLAGS $DIRECTFB_CFLAGS"
            have_video=yes
        fi
    fi
}

dnl Find KMSDRM
CheckKMSDRM()
{
    AC_ARG_ENABLE(video-kmsdrm,
AC_HELP_STRING([--enable-video-kmsdrm], [use KMSDRM video driver [[default=no]]]),
                  , enable_video_kmsdrm=no)

    if test x$enable_video = xyes -a x$enable_video_kmsdrm = xyes; then
        video_kmsdrm=no
        libdrm_avail=no
        libgbm_avail=no

        LIBDRM_REQUIRED_VERSION=2.4.46
        LIBGBM_REQUIRED_VERSION=9.0.0

        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
        if test x$PKG_CONFIG != xno; then
            if $PKG_CONFIG --atleast-pkgconfig-version 0.7; then
                if $PKG_CONFIG --atleast-version $LIBDRM_REQUIRED_VERSION libdrm; then
                    LIBDRM_CFLAGS=`$PKG_CONFIG --cflags libdrm`
                    LIBDRM_LIBS=`$PKG_CONFIG --libs libdrm`
                    LIBDRM_PREFIX=`$PKG_CONFIG --variable=prefix libdrm`
                    libdrm_avail=yes
                fi
                if $PKG_CONFIG --atleast-version $LIBGBM_REQUIRED_VERSION gbm; then
                    LIBGBM_CFLAGS=`$PKG_CONFIG --cflags gbm`
                    LIBGBM_LIBS=`$PKG_CONFIG --libs gbm`
                    LIBGBM_PREFIX=`$PKG_CONFIG --variable=prefix gbm`
                    libgbm_avail=yes
                fi
                if test x$libdrm_avail = xyes -a x$libgbm_avail = xyes; then
                    video_kmsdrm=yes
                fi
 
                AC_MSG_CHECKING(for libdrm $LIBDRM_REQUIRED_VERSION library for kmsdrm support)
                AC_MSG_RESULT($libdrm_avail)
                AC_MSG_CHECKING(for libgbm $LIBGBM_REQUIRED_VERSION library for kmsdrm support)
                AC_MSG_RESULT($libgbm_avail)

                if test x$video_kmsdrm = xyes; then
                    AC_ARG_ENABLE(kmsdrm-shared,
AC_HELP_STRING([--enable-kmsdrm-shared], [dynamically load kmsdrm support [[default=yes]]]),
                              , enable_kmsdrm_shared=yes)

                    AC_DEFINE(SDL_VIDEO_DRIVER_KMSDRM, 1, [ ])
                    SOURCES="$SOURCES $srcdir/src/video/kmsdrm/*.c"
                    EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBDRM_CFLAGS $LIBGBM_CFLAGS"

                    AC_MSG_CHECKING(for kmsdrm dynamic loading support)
                    kmsdrm_shared=no
                    drm_lib=[`find_lib "libdrm.so.*" "$DRM_LIBS"`]
                    gbm_lib=[`find_lib "libgbm.so.*" "$DRM_LIBS"`]
                    if test x$have_loadso != xyes && \
                       test x$enable_kmsdrm_shared = xyes; then
                        AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic kmsdrm loading])
                    fi
                    if test x$have_loadso = xyes && \
                       test x$enable_kmsdrm_shared = xyes && test x$drm_lib != x && test x$gbm_lib != x; then
                        kmsdrm_shared=yes
                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC, "$drm_lib", [ ])
                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM, "$gbm_lib", [ ])
                        AC_DEFINE_UNQUOTED(HAVE_KMSDRM_SHARED, "TRUE", [ ])
                        SUMMARY_video="${SUMMARY_video} kmsdrm(dynamic)"
                    else
                        EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBDRM_LIBS $LIBGBM_LIBS"
                        SUMMARY_video="${SUMMARY_video} kmsdrm"
                    fi
                    AC_MSG_RESULT($kmsdrm_shared)
                    have_video=yes
                fi
            fi
        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, 1, [ ])
        SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
        have_video=yes
        SUMMARY_video="${SUMMARY_video} dummy"
    fi
}

dnl Set up the QNX video driver if enabled
CheckQNXVideo()
{
    if test x$enable_video = xyes; then
        AC_DEFINE(SDL_VIDEO_DRIVER_QNX, 1, [ ])
        SOURCES="$SOURCES $srcdir/src/video/qnx/*.c"
        have_video=yes
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lscreen -lEGL -lGLESv2"
        SUMMARY_video="${SUMMARY_video} qnx"
    fi
}

dnl Set up the QNX audio driver if enabled
CheckQNXAudio()
{
    if test x$enable_audio = xyes; then
        AC_DEFINE(SDL_AUDIO_DRIVER_QSA, 1, [ ])
        SOURCES="$SOURCES $srcdir/src/audio/qsa/*.c"
        have_audio=yes
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lasound"
        SUMMARY_audio="${SUMMARY_audio} qsa"
    fi
}

dnl Check to see if OpenGL support is desired
AC_ARG_ENABLE(video-opengl,
AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[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>
        ],[
        ],[
        video_opengl=yes
        ])
        AC_MSG_RESULT($video_opengl)
        if test x$video_opengl = xyes; then
            AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
            AC_DEFINE(SDL_VIDEO_OPENGL_GLX, 1, [ ])
            AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
            SUMMARY_video="${SUMMARY_video} opengl"
        fi
    fi
}

dnl Check to see if OpenGL ES support is desired
AC_ARG_ENABLE(video-opengles,
AC_HELP_STRING([--enable-video-opengles], [include OpenGL ES support [[default=yes]]]),
              , enable_video_opengles=yes)
AC_ARG_ENABLE(video-opengles1,
AC_HELP_STRING([--enable-video-opengles1], [include OpenGL ES 1.1 support [[default=yes]]]),
              , enable_video_opengles1=yes)
AC_ARG_ENABLE(video-opengles2,
AC_HELP_STRING([--enable-video-opengles2], [include OpenGL ES 2.0 support [[default=yes]]]),
              , enable_video_opengles2=yes)

dnl Find OpenGL ES
CheckOpenGLESX11()
{
    if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
        AC_MSG_CHECKING(for EGL support)
        video_opengl_egl=no
        AC_TRY_COMPILE([
          #define LINUX
          #define EGL_API_FB
          #include <EGL/egl.h>
          #include <EGL/eglext.h>
        ],[
        ],[
        video_opengl_egl=yes
        ])
        AC_MSG_RESULT($video_opengl_egl)
        if test x$video_opengl_egl = xyes; then
            AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
        fi
            
        if test x$enable_video_opengles1 = xyes; then
            AC_MSG_CHECKING(for OpenGL ES v1 headers)
            video_opengles_v1=no
            AC_TRY_COMPILE([
             #include <GLES/gl.h>
             #include <GLES/glext.h>
            ],[
            ],[
            video_opengles_v1=yes
            ])
            AC_MSG_RESULT($video_opengles_v1)
            if test x$video_opengles_v1 = xyes; then
                AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
                AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
                SUMMARY_video="${SUMMARY_video} opengl_es1"
            fi
        fi
        
        if test x$enable_video_opengles2 = xyes; then
            AC_MSG_CHECKING(for OpenGL ES v2 headers)
            video_opengles_v2=no
            AC_TRY_COMPILE([
             #include <GLES2/gl2.h>
             #include <GLES2/gl2ext.h>
            ],[
            ],[
            video_opengles_v2=yes
            ])
            AC_MSG_RESULT($video_opengles_v2)
            if test x$video_opengles_v2 = xyes; then
                AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
                AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
                SUMMARY_video="${SUMMARY_video} opengl_es2"
            fi
        fi
    fi
}

dnl Check for Windows OpenGL
CheckWINDOWSGL()
{
    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
        AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
        AC_DEFINE(SDL_VIDEO_OPENGL_WGL, 1, [ ])
        AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
        SUMMARY_video="${SUMMARY_video} opengl"
    fi
}

dnl Check for Windows OpenGL
CheckWINDOWSGLES()
{
    if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then

        AC_MSG_CHECKING(for EGL support)
        video_opengl_egl=no
        AC_TRY_COMPILE([
         #include <EGL/egl.h>
        ],[
        ],[
        video_opengl_egl=yes
        ])
        AC_MSG_RESULT($video_opengl_egl)
        if test x$video_opengl_egl = xyes; then
            AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
            AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
            SUMMARY_video="${SUMMARY_video} opengl_es1"
        fi
       
        AC_MSG_CHECKING(for OpenGL ES v2 headers)
        video_opengles_v2=no
        AC_TRY_COMPILE([
         #include <GLES2/gl2.h>
         #include <GLES2/gl2ext.h>
        ],[
        ],[
        video_opengles_v2=yes
        ])
        AC_MSG_RESULT($video_opengles_v2)
        if test x$video_opengles_v2 = xyes; then
            AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
            AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
            AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
            SUMMARY_video="${SUMMARY_video} opengl_es2"
        fi
    fi
}

dnl Check for Haiku OpenGL
CheckHaikuGL()
{
    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
        AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
        AC_DEFINE(SDL_VIDEO_OPENGL_HAIKU, 1, [ ])
        AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
        SUMMARY_video="${SUMMARY_video} opengl"
    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, 1, [ ])
        AC_DEFINE(SDL_VIDEO_OPENGL_CGL, 1, [ ])
        AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
        SUMMARY_video="${SUMMARY_video} opengl"
    fi
}

CheckEmscriptenGLES()
{
    if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
        AC_MSG_CHECKING(for EGL support)
        video_opengl_egl=no
        AC_TRY_COMPILE([
         #include <EGL/egl.h>
        ],[
        ],[
        video_opengl_egl=yes
        ])
        AC_MSG_RESULT($video_opengl_egl)
        if test x$video_opengl_egl = xyes; then
            AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
        fi

        AC_MSG_CHECKING(for OpenGL ES v2 headers)
        video_opengles_v2=no
        AC_TRY_COMPILE([
         #include <GLES2/gl2.h>
         #include <GLES2/gl2ext.h>
        ],[
        ],[
        video_opengles_v2=yes
        ])
        AC_MSG_RESULT($video_opengles_v2)
        if test x$video_opengles_v2 = xyes; then
            AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
            AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
            SUMMARY_video="${SUMMARY_video} opengl_es2"
        fi
    fi
}

dnl Check to see if Vulkan surface support is desired
AC_ARG_ENABLE(video-vulkan,
AC_HELP_STRING([--enable-video-vulkan], [include Vulkan support [[default=yes]]]),
              , enable_video_vulkan=yes)

dnl Find Vulkan Header
CheckVulkan()
{
    if test x$enable_video = xyes -a x$enable_video_vulkan = xyes; then
        case "$host" in
            *-*-androideabi*)
                AC_TRY_COMPILE([
                  #if defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__)
                  #error Vulkan doesn't work on this configuration
                  #endif
                  int main()
                  {
                     return 0;
                  }
                ],[
                    enable_video_vulkan=no
                ],[
                ])
                ;;
            *)
                ;;
        esac
        if test x$enable_video_vulkan = xno; then
            # For reasons I am totally unable to see, I get an undefined macro error if
            # I put this in the AC_TRY_COMPILE.
            AC_MSG_WARN([Sorry, Vulkan does not work on this configuration.])
        fi
    fi
    if test x$enable_video_vulkan = xyes; then
        AC_DEFINE(SDL_VIDEO_VULKAN, 1, [ ])
        SUMMARY_video="${SUMMARY_video} vulkan"
    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_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, 1, [ ])
            SUMMARY_input="${SUMMARY_input} linuxev"
        fi
}

dnl See if we can use the kernel kd.h header
CheckInputKD()
{

    AC_MSG_CHECKING(for Linux kd.h)
    use_input_kd=no
    AC_TRY_COMPILE([
      #include <linux/kd.h>
      #include <linux/keyboard.h>
    ],[
        struct kbentry kbe;
        kbe.kb_table = KG_CTRL;
        ioctl(0, KDGKBENT, &kbe);
    ],[
    use_input_kd=yes
    ])
    AC_MSG_RESULT($use_input_kd)
    if test x$use_input_kd = xyes; then
        AC_DEFINE(SDL_INPUT_LINUXKD, 1, [ ])
        SUMMARY_input="${SUMMARY_input} linuxkd"
    fi
}

dnl See if the platform offers libudev for device enumeration and hotplugging.
CheckLibUDev()
{
    AC_ARG_ENABLE(libudev,
AC_HELP_STRING([--enable-libudev], [enable libudev support [[default=yes]]]),
                        , enable_libudev=yes)
    if test x$enable_libudev = xyes; then
        AC_CHECK_HEADER(libudev.h,
                        have_libudev_h_hdr=yes,
                        have_libudev_h_hdr=no)
        if test x$have_libudev_h_hdr = xyes; then
            AC_DEFINE(HAVE_LIBUDEV_H, 1, [ ])

            udev_lib=[`find_lib "libudev.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`]
            if test x$udev_lib != x; then
                echo "-- dynamic udev -> $udev_lib"
                AC_DEFINE_UNQUOTED(SDL_UDEV_DYNAMIC, "$udev_lib", [ ])
            fi
        fi
    fi
}

dnl See if the platform offers libdbus for various IPC techniques.
CheckDBus()
{
    AC_ARG_ENABLE(dbus,
AC_HELP_STRING([--enable-dbus], [enable D-Bus support [[default=yes]]]),
                        , enable_dbus=yes)
    if test x$enable_dbus = xyes; then
        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
        if test x$PKG_CONFIG != xno; then
            DBUS_CFLAGS=`$PKG_CONFIG --cflags dbus-1`
            save_CFLAGS="$CFLAGS"
            CFLAGS="$save_CFLAGS $DBUS_CFLAGS"
            AC_CHECK_HEADER(dbus/dbus.h,
                            have_dbus_dbus_h_hdr=yes,
                            have_dbus_dbus_h_hdr=no)
            CFLAGS="$save_CFLAGS"
            if test x$have_dbus_dbus_h_hdr = xyes; then
                AC_DEFINE(HAVE_DBUS_DBUS_H, 1, [ ])
                EXTRA_CFLAGS="$EXTRA_CFLAGS $DBUS_CFLAGS"
                SOURCES="$SOURCES $srcdir/src/core/linux/SDL_dbus.c"
            fi
        fi
    fi
}

dnl See if the platform wanna IME support.
CheckIME()
{
    AC_ARG_ENABLE(ime,
AC_HELP_STRING([--enable-ime], [enable IME support [[default=yes]]]),
                  , enable_ime=yes)
    if test x$enable_ime = xyes; then
        AC_DEFINE(SDL_USE_IME, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/core/linux/SDL_ime.c"
    fi
}

dnl See if the platform has libibus IME support.
CheckIBus()
{
    AC_ARG_ENABLE(ibus,
AC_HELP_STRING([--enable-ibus], [enable IBus support [[default=yes]]]),
                  , enable_ibus=yes)
    if test x$enable_ibus = xyes; then
        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
        if test x$PKG_CONFIG != xno; then
            IBUS_CFLAGS=`$PKG_CONFIG --cflags ibus-1.0`
            save_CFLAGS="$CFLAGS"
            CFLAGS="$save_CFLAGS $IBUS_CFLAGS"
            AC_CHECK_HEADER(ibus-1.0/ibus.h,
                            have_ibus_ibus_h_hdr=yes,
                            have_ibus_ibus_h_hdr=no)
            AC_CHECK_HEADER(sys/inotify.h,
                            have_inotify_inotify_h_hdr=yes,
                            have_inotify_inotify_h_hdr=no)
            CFLAGS="$save_CFLAGS"
            if test x$have_ibus_ibus_h_hdr = xyes; then
                if test x$enable_ime != xyes; then
                    AC_MSG_WARN([IME support is required for IBus.])
                    have_ibus_ibus_h_hdr=no
                elif test x$enable_dbus != xyes; then
                    AC_MSG_WARN([DBus support is required for IBus.])
                    have_ibus_ibus_h_hdr=no
                elif test x$have_inotify_inotify_h_hdr != xyes; then
                    AC_MSG_WARN([INotify support is required for IBus.])
                    have_ibus_ibus_h_hdr=no
                else
                    AC_DEFINE(HAVE_IBUS_IBUS_H, 1, [ ])
                    EXTRA_CFLAGS="$EXTRA_CFLAGS $IBUS_CFLAGS"
                    SOURCES="$SOURCES $srcdir/src/core/linux/SDL_ibus.c"
               fi
            fi
        fi
    fi
}

dnl See if the platform has fcitx IME support.
CheckFcitx()
{
    AC_ARG_ENABLE(fcitx,
AC_HELP_STRING([--enable-fcitx], [enable fcitx support [[default=yes]]]),
                  , enable_fcitx=yes)
    if test x$enable_fcitx = xyes; then
        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
        if test x$PKG_CONFIG != xno; then
            FCITX_CFLAGS=`$PKG_CONFIG --cflags fcitx`
            CFLAGS="$CFLAGS $FCITX_CFLAGS"
            AC_CHECK_HEADER(fcitx/frontend.h,
                            have_fcitx_frontend_h_hdr=yes,
                            have_fcitx_frontend_h_hdr=no)
            CFLAGS="$save_CFLAGS"
            if test x$have_fcitx_frontend_h_hdr = xyes; then
                if test x$enable_ime != xyes; then
                    AC_MSG_WARN([IME support is required for fcitx.])
                    have_fcitx_frontend_h_hdr=no
                elif test x$enable_dbus != xyes; then
                    AC_MSG_WARN([DBus support is required for fcitx.])
                    have_fcitx_frontend_h_hdr=no
                else
                    AC_DEFINE(HAVE_FCITX_FRONTEND_H, 1, [ ])
                    EXTRA_CFLAGS="$EXTRA_CFLAGS $FCITX_CFLAGS"
                    SOURCES="$SOURCES $srcdir/src/core/linux/SDL_fcitx.c"
               fi
            fi
        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, 1, [ ])
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
            SUMMARY_input="${SUMMARY_input} ts"
        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
         *-*-androideabi*)
            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
            pthread_lib=""
            ;;
        *-*-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"
            ;;
        *-*-solaris2.9)
            # From Solaris 9+, posix4's preferred name is rt.
            pthread_cflags="-D_REENTRANT"
            pthread_lib="-lpthread -lrt"
            ;;
        *-*-solaris2.10)
            # Solaris 10+ merged pthread into libc.
            pthread_cflags="-D_REENTRANT"
            pthread_lib="-lrt"
            ;;
        *-*-solaris*)
            # Solaris 11+ merged rt into libc.
            pthread_cflags="-D_REENTRANT"
            pthread_lib=""
            ;;
        *-*-sysv5*)
            pthread_cflags="-D_REENTRANT -Kthread"
            pthread_lib=""
            ;;
        *-*-aix*)
            pthread_cflags="-D_REENTRANT -mthreads"
            pthread_lib="-lpthread"
            ;;
        *-*-hpux11*)
            pthread_cflags="-D_REENTRANT"
            pthread_lib="-L/usr/lib -lpthread"
            ;;
        *-*-haiku*)
            pthread_cflags="-D_REENTRANT"
            pthread_lib=""
            ;;
        *-*-nto*)
            pthread_cflags="-D_REENTRANT"
            pthread_lib=""
            ;;
        *)
            pthread_cflags="-D_REENTRANT"
            pthread_lib="-lpthread"
            ;;
    esac
    if test x$enable_threads = xyes -a x$enable_pthreads = 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, 1, [ ])
            EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
            SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"

            # 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_LINK([
                  #define _GNU_SOURCE 1
                  #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, 1, [ ])
                ])
            fi
            if test x$has_recursive_mutexes = xno; then
                AC_TRY_LINK([
                  #define _GNU_SOURCE 1
                  #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, 1, [ ])
                ])
            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], 1, [ ])
                ])
                AC_MSG_RESULT($have_sem_timedwait)
            fi

            AC_CHECK_HEADER(pthread_np.h, have_pthread_np_h=yes, have_pthread_np_h=no, [ #include <pthread.h> ])
            if test x$have_pthread_np_h = xyes; then
                AC_DEFINE(HAVE_PTHREAD_NP_H, 1, [ ])
            fi

            # Check to see if pthread naming is available
            AC_MSG_CHECKING(for pthread_setname_np)
            AC_TRY_LINK_FUNC(pthread_setname_np, [
              has_pthread_setname_np=yes
              AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [ ])
            ],[
              has_pthread_setname_np=no
            ])
            AC_MSG_RESULT($has_pthread_setname_np)

            AC_MSG_CHECKING(for pthread_set_name_np)
            AC_TRY_LINK_FUNC(pthread_set_name_np, [
              has_pthread_set_name_np=yes
              AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [ ])
            ],[
              has_pthread_set_name_np=no
            ])
            AC_MSG_RESULT($has_pthread_set_name_np)

            # 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"

            # Thread local storage
            SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systls.c"

            have_threads=yes
        fi
    fi
}

dnl Determine whether the compiler can produce Windows executables
CheckWINDOWS()
{
    AC_MSG_CHECKING(Windows 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 Windows executables!
       ])
    fi

    AC_MSG_CHECKING(Windows CE)
    have_wince=no
    AC_TRY_COMPILE([
#if !defined(_WIN32_WCE) && !defined(__MINGW32CE__)
#error This is not Windows CE
#endif
    ],[
    ],[
    have_wince=yes
       AC_MSG_ERROR([
*** Sorry, Windows CE is no longer supported.
       ])
    ])
    AC_MSG_RESULT($have_wince)

    # This fixes Windows stack alignment with newer GCC
    CheckStackBoundary
}

dnl Find the DirectX includes and libraries
CheckDIRECTX()
{
    AC_ARG_ENABLE(directx,
AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]),
                  , enable_directx=yes)
    if test x$enable_directx = xyes; then
        AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
        AC_CHECK_HEADER(d3d11_1.h, have_d3d11=yes)
        AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
        AC_CHECK_HEADER(dsound.h, have_dsound=yes)
        AC_CHECK_HEADER(dinput.h, have_dinput=yes)
        AC_CHECK_HEADER(dxgi.h, have_dxgi=yes)
        AC_CHECK_HEADER(xaudio2.h, have_xaudio2=yes)
        AC_CHECK_HEADER(xinput.h, have_xinput=yes)
        AC_CHECK_HEADER(mmdeviceapi.h, have_wasapi=yes)
        AC_CHECK_HEADER(audioclient.h,,have_wasapi=no)
        AC_TRY_COMPILE([
#include <windows.h>
#include <xinput.h>
XINPUT_GAMEPAD_EX x1;
        ],[],[have_xinput_gamepadex=yes])
        AC_TRY_COMPILE([
#include <windows.h>
#include <xinput.h>
XINPUT_STATE_EX s1;
        ],[],[have_xinput_stateex=yes])

        if test x$have_ddraw = xyes; then
            AC_DEFINE(HAVE_DDRAW_H, 1, [ ])
        fi
        if test x$have_dinput = xyes; then
            AC_DEFINE(HAVE_DINPUT_H, 1, [ ])
        fi
        if test x$have_dsound = xyes; then
            AC_DEFINE(HAVE_DSOUND_H, 1, [ ])
        fi
        if test x$have_dxgi = xyes; then
            AC_DEFINE(HAVE_DXGI_H, 1, [ ])
        fi
        if test x$have_xinput = xyes; then
            AC_DEFINE(HAVE_XINPUT_H, 1, [ ])
        fi
        if test x$have_xinput_gamepadex = xyes; then
            AC_DEFINE(HAVE_XINPUT_GAMEPAD_EX, 1, [ ])
        fi
        if test x$have_xinput_stateex = xyes; then
            AC_DEFINE(HAVE_XINPUT_STATE_EX, 1, [ ])
        fi

        SUMMARY_video="${SUMMARY_video} directx"
        SUMMARY_audio="${SUMMARY_audio} directx"

        # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers.
        # FIXME:  ...so force it off for now.
        case "$host" in
            *-*-cygwin*)
            have_dinput=false
            ;;
        esac
    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>
        ],[
         void *handle = dlopen("", RTLD_NOW);
         const char *loaderror = (char *) dlerror();
        ],[
        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, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
            have_loadso=yes
        fi
    fi
}

dnl Check for the usbhid(3) library on *BSD
CheckUSBHID()
{
    case "$host" in
        *-*-*bsd*)
            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, 1, [ ])
                    fi
                    AC_MSG_RESULT($have_machine_joystick)

                    AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ])
                    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
        ;;
    esac
}

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=yes]]]),
                  , enable_clock_gettime=yes)
    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, 1, [ ])
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
        else
            AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
            if test x$have_clock_gettime = xyes; then
               AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
               EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
            fi
        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 Do this on all platforms, before everything else (other things might want to override it).
CheckWarnAll

dnl Set up the configuration based on the host platform!
case "$host" in
    *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*|*-*-nto*)
        case "$host" in
            *-raspberry-linux*)
                # Raspberry Pi
                ARCH=linux
                RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
                CFLAGS="$CFLAGS $RPI_CFLAGS"
                SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
                EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L/opt/vc/lib -lbcm_host -ldl"

                if test x$enable_video = xyes; then
                    SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
                    # FIXME: confdefs? Not AC_DEFINE?
                    $as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h
                    SUMMARY_video="${SUMMARY_video} rpi"
                fi
                ;;
            *-*-androideabi*)
                # Android
                ARCH=android
                ANDROID_CFLAGS="-DGL_GLEXT_PROTOTYPES"
                CFLAGS="$CFLAGS $ANDROID_CFLAGS"
                SDL_CFLAGS="$SDL_CFLAGS $ANDROID_CFLAGS"
                SDL_LIBS="$SDL_LIBS -lSDL2main -Wl,-u,SDL_main_dummy"
                EXTRA_CFLAGS="$EXTRA_CFLAGS $ANDROID_CFLAGS"
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl -lGLESv1_CM -lGLESv2 -llog -landroid"
                SDLMAIN_SOURCES="$srcdir/src/main/android/*.c"

                if test x$enable_video = xyes; then
                    SOURCES="$SOURCES $srcdir/src/core/android/*.c $srcdir/src/video/android/*.c"
                    # FIXME: confdefs? Not AC_DEFINE?
                    $as_echo "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h
                    SUMMARY_video="${SUMMARY_video} android"
                fi
                ;;
            *-*-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 ;;
            *-raspberry-netbsd*)
                # Raspberry Pi
                ARCH=netbsd
                RPI_CFLAGS="-I/usr/pkg/include -I/usr/pkg/include/interface/vcos/pthreads -I/usr/pkg/include/interface/vmcs_host/linux"
                CFLAGS="$CFLAGS $RPI_CFLAGS"
                SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
                EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host -ldl"

                if test x$enable_video = xyes; then
                    SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
                    $as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h
                    SUMMARY_video="${SUMMARY_video} raspberry"
                fi
                ;;
            *-*-netbsd*)        ARCH=netbsd ;;
            *-*-openbsd*)       ARCH=openbsd ;;
            *-*-sysv5*)         ARCH=sysv5 ;;
            *-*-solaris*)       ARCH=solaris ;;
            *-*-hpux*)          ARCH=hpux ;;
            *-*-aix*)           ARCH=aix ;;
            *-*-minix*)         ARCH=minix ;;
            *-*-nto*)           ARCH=nto
                CheckQNXVideo
                ;;
        esac
        CheckVisibilityHidden
        CheckDeclarationAfterStatement
        CheckDummyVideo
        CheckDiskAudio
        CheckDummyAudio
        CheckDLOPEN
        CheckOSS
        CheckALSA
        CheckPulseAudio
        CheckJACK
        CheckARTSC
        CheckESD
        CheckNAS
        CheckSNDIO
        CheckFusionSound
        CheckLibSampleRate
        CheckX11
        CheckDirectFB
        CheckKMSDRM
        CheckOpenGLX11
        CheckOpenGLESX11
        CheckVulkan
        CheckMir
        CheckWayland
        CheckLibUDev
        CheckDBus
        CheckIME
        CheckIBus
        CheckFcitx
        case $ARCH in
          linux)
              CheckInputEvents
              CheckInputKD
          ;;
        esac
        CheckTslib
        CheckUSBHID
        CheckPTHREAD
        CheckClockGettime
        CheckLinuxVersion
        CheckRPATH
        CheckVivanteVideo

        # 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, 1, [ ])
                SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
                SUMMARY_audio="${SUMMARY_audio} sun"
                have_audio=yes
            ;;
            netbsd)  # Don't use this on OpenBSD, it's busted.
                AC_DEFINE(SDL_AUDIO_DRIVER_NETBSD, 1, [ ])
                SOURCES="$SOURCES $srcdir/src/audio/netbsd/*.c"
                SUMMARY_audio="${SUMMARY_audio} netbsd"
                have_audio=yes
            ;;
            aix)
                AC_DEFINE(SDL_AUDIO_DRIVER_PAUDIO, 1, [ ])
                SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
                SUMMARY_audio="${SUMMARY_audio} paudio"
                have_audio=yes
            ;;
            android)
                AC_DEFINE(SDL_AUDIO_DRIVER_ANDROID, 1, [ ])
                SOURCES="$SOURCES $srcdir/src/audio/android/*.c"
                SUMMARY_audio="${SUMMARY_audio} android"
                have_audio=yes
            ;;
            nto)
                CheckQNXAudio
            ;;
          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, 1, [ ])
                SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
                have_joystick=yes
            ;;
            android)
                AC_DEFINE(SDL_JOYSTICK_ANDROID, 1, [ ])
                SOURCES="$SOURCES $srcdir/src/joystick/android/*.c"
                have_joystick=yes
            ;;
          esac
        fi
        # Set up files for the haptic library
        if test x$enable_haptic = xyes; then
           if test x$use_input_events = xyes; then
             case $ARCH in
               linux)
                   AC_DEFINE(SDL_HAPTIC_LINUX, 1, [ ])
                   SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c"
                   have_haptic=yes
               ;;
             esac
           fi
        fi
        # Set up files for the power library
        if test x$enable_power = xyes; then
             case $ARCH in
               linux)
                   AC_DEFINE(SDL_POWER_LINUX, 1, [ ])
                   SOURCES="$SOURCES $srcdir/src/power/linux/*.c"
                   have_power=yes
               ;;
               android)
                   AC_DEFINE(SDL_POWER_ANDROID, 1, [ ])
                   SOURCES="$SOURCES $srcdir/src/power/android/*.c"
                   have_power=yes
               ;;
             esac
        fi
        # Set up files for the filesystem library
        if test x$enable_filesystem = xyes; then
             case $ARCH in
               android)
                   AC_DEFINE(SDL_FILESYSTEM_ANDROID, 1, [ ])
                   SOURCES="$SOURCES $srcdir/src/filesystem/android/*.c"
                   have_filesystem=yes
               ;;
               *)
                   AC_DEFINE(SDL_FILESYSTEM_UNIX, 1, [ ])
                   SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c"
                   have_filesystem=yes
               ;;
             esac
        fi
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
            have_timers=yes
        fi
        # Set up files for udev hotplugging support
        if test x$enable_libudev = xyes && test x$have_libudev_h_hdr = xyes; then
            SOURCES="$SOURCES $srcdir/src/core/linux/SDL_udev.c"               
        fi
        # Set up files for evdev input
        if test x$use_input_events = xyes; then
            SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev*.c"
        fi       
        # Set up other core UNIX files
        SOURCES="$SOURCES $srcdir/src/core/unix/*.c"
        ;;
    *-*-cygwin* | *-*-mingw32*)
        ARCH=win32
        if test "$build" != "$host"; then # cross-compiling
            # Default cross-compile location
            ac_default_prefix=/usr/local/cross-tools/$host
        else
            # Look for the location of the tools and install there
            if test "$BUILD_PREFIX" != ""; then
                ac_default_prefix=$BUILD_PREFIX
            fi
        fi
        CheckDeclarationAfterStatement
        CheckDummyVideo
        CheckDiskAudio
        CheckDummyAudio
        CheckWINDOWS
        CheckWINDOWSGL
        CheckWINDOWSGLES
        CheckVulkan
        CheckDIRECTX

        # Set up the core platform files
        SOURCES="$SOURCES $srcdir/src/core/windows/*.c"

        # Set up files for the video library
        if test x$enable_video = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
            have_video=yes
            AC_ARG_ENABLE(render-d3d,
AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
                                , enable_render_d3d=yes)
            if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
                AC_DEFINE(SDL_VIDEO_RENDER_D3D, 1, [ ])
            fi
            if test x$enable_render_d3d = xyes -a x$have_d3d11 = xyes; then
                AC_DEFINE(SDL_VIDEO_RENDER_D3D11, 1, [ ])
            fi
        fi
        # Set up files for the audio library
        if test x$enable_audio = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_WINMM, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/audio/winmm/*.c"
            if test x$have_dsound = xyes; then
                AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND, 1, [ ])
                SOURCES="$SOURCES $srcdir/src/audio/directsound/*.c"
            fi
            if test x$have_xaudio2 = xyes; then
                AC_DEFINE(SDL_AUDIO_DRIVER_XAUDIO2, 1, [ ])
                SOURCES="$SOURCES $srcdir/src/audio/xaudio2/*.c"
            fi
            if test x$have_wasapi = xyes; then
                AC_DEFINE(SDL_AUDIO_DRIVER_WASAPI, 1, [ ])
                SOURCES="$SOURCES $srcdir/src/audio/wasapi/*.c"
            fi
            have_audio=yes
        fi
        # Set up files for the joystick library
        if test x$enable_joystick = xyes; then
            if test x$have_dinput = xyes -o x$have_xinput = xyes; then
                if test x$have_xinput = xyes; then
                    AC_DEFINE(SDL_JOYSTICK_XINPUT, 1, [ ])
                fi
                if test x$have_dinput = xyes; then
                    AC_DEFINE(SDL_JOYSTICK_DINPUT, 1, [ ])
                    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8"
                fi
            else
                AC_DEFINE(SDL_JOYSTICK_WINMM, 1, [ ])
            fi
            SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
            have_joystick=yes
        fi
        if test x$enable_haptic = xyes; then
            if test x$have_dinput = xyes -o x$have_xinput = xyes; then
                if test x$have_xinput = xyes; then
                    AC_DEFINE(SDL_HAPTIC_XINPUT, 1, [ ])
                fi
                if test x$have_dinput = xyes; then
                    AC_DEFINE(SDL_HAPTIC_DINPUT, 1, [ ])
                fi
                SOURCES="$SOURCES $srcdir/src/haptic/windows/*.c"
                have_haptic=yes
            fi
        fi
        if test x$enable_power = xyes; then
            AC_DEFINE(SDL_POWER_WINDOWS, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
            have_power=yes
        fi
        if test x$enable_filesystem = xyes; then
            AC_DEFINE(SDL_FILESYSTEM_WINDOWS, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/filesystem/windows/SDL_sysfilesystem.c"
            have_filesystem=yes
        fi
        # Set up files for the thread library
        if test x$enable_threads = xyes; then
            AC_DEFINE(SDL_THREAD_WINDOWS, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/thread/windows/*.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_WINDOWS, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/timer/windows/*.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_WINDOWS, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
            have_loadso=yes
        fi
        # Set up the system libraries we need
        if test -f /lib/w32api/libuuid.a; then
            LIBUUID=/lib/w32api/libuuid.a
        else
            LIBUUID=-luuid
        fi
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion $LIBUUID -static-libgcc"
        # The Windows platform requires special setup
        VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
        SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
        SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
        SDL_LIBS="-lSDL2main $SDL_LIBS -mwindows"

        # Check to see if this is a mingw or cygwin build
        have_mingw32=
        AC_CHECK_LIB(mingw32, main, [have_mingw32=yes])
        if test x$have_mingw32 = xyes; then
            SDL_LIBS="-lmingw32 $SDL_LIBS"
        else
            SDL_LIBS="-lcygwin $SDL_LIBS"
        fi
        ;;

    dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
    *-*-beos*)
        AC_MSG_ERROR([
*** BeOS support has been removed as of SDL 2.0.2.
        ])
        ;;

    *-*-haiku*)
        ARCH=haiku
        ac_default_prefix=/boot/system
        CheckDummyVideo
        CheckDiskAudio
        CheckDummyAudio
        CheckDLOPEN
        CheckHaikuVideo
        CheckHaikuGL
        CheckPTHREAD

        # Set up files for the audio library
        if test x$enable_audio = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_HAIKU, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/audio/haiku/*.cc"
            SUMMARY_audio="${SUMMARY_audio} haiku"
            have_audio=yes
        fi
        # Set up files for the joystick library
        if test x$enable_joystick = xyes; then
            AC_DEFINE(SDL_JOYSTICK_HAIKU, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/joystick/haiku/*.cc"
            have_joystick=yes
        fi
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_HAIKU, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/timer/haiku/*.c"
            have_timers=yes
        fi
        # Set up files for the system power library
        if test x$enable_power = xyes; then
            AC_DEFINE(SDL_POWER_HAIKU, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/power/haiku/*.c"
            have_power=yes
        fi
        # Set up files for the system filesystem library
        if test x$enable_filesystem = xyes; then
            AC_DEFINE(SDL_FILESYSTEM_HAIKU, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/filesystem/haiku/*.cc"
            have_filesystem=yes
        fi
        # The Haiku platform requires special setup.
        SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
        # Haiku's x86 spins use libstdc++.r4.so (for binary compat?), but
        #  other spins, like x86-64, use a more standard "libstdc++.so.*"
        AC_CHECK_FILE("/boot/system/lib/libstdc++.r4.so", EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lstdc++.r4", EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lstdc++")
        ;;
    arm*-apple-darwin*|*-ios-*)
        ARCH=ios

        CheckVisibilityHidden
        CheckDeclarationAfterStatement
        CheckDummyVideo
        CheckDiskAudio
        CheckDummyAudio
        CheckDLOPEN
        CheckPTHREAD
        CheckVulkan

        # Set up files for the audio library
        if test x$enable_audio = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m"
            SUMMARY_audio="${SUMMARY_audio} coreaudio"
            have_audio=yes
        fi
        # Set up files for the joystick library
        if test x$enable_joystick = xyes; then
            AC_DEFINE(SDL_JOYSTICK_MFI, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m"
            have_joystick=yes
        fi
        # Set up files for the haptic library
        #if test x$enable_haptic = xyes; then
        #    SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
        #    have_haptic=yes
        #    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
        #fi
        # Set up files for the power library
        if test x$enable_power = xyes; then
            AC_DEFINE(SDL_POWER_UIKIT, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
            have_power=yes
        fi
        # Set up files for the filesystem library
        if test x$enable_filesystem = xyes; then
            SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
            have_filesystem=yes
        fi
        # Set up additional files for the file library
        if test x$enable_file = xyes; then
            AC_DEFINE(SDL_FILESYSTEM_COCOA, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
        fi
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
            have_timers=yes
        fi
        # Set up other core UNIX files
        SOURCES="$SOURCES $srcdir/src/core/unix/*.c"
        # The iOS platform requires special setup.
        AC_DEFINE(SDL_VIDEO_DRIVER_UIKIT, 1, [ ])
        AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
        AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
        AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
        AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
        SOURCES="$SOURCES $srcdir/src/video/uikit/*.m"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -liconv -lobjc"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AVFoundation"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreMotion"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,GameController"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
        if test x$enable_video_vulkan = xyes; then
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
        fi
        ;;
    *-*-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"

        CheckVisibilityHidden
        CheckDeclarationAfterStatement
        CheckDummyVideo
        CheckDiskAudio
        CheckDummyAudio
        CheckDLOPEN
        CheckCOCOA
        CheckX11
        CheckMacGL
        CheckOpenGLX11
        CheckVulkan
        CheckPTHREAD

        # Set up files for the audio library
        if test x$enable_audio = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox"
            SUMMARY_audio="${SUMMARY_audio} coreaudio"
            have_audio=yes
        fi
        # Set up files for the joystick library
        if test x$enable_joystick = xyes; then
            AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
            have_joystick=yes
        fi
        # Set up files for the haptic library
        if test x$enable_haptic = xyes; then
            AC_DEFINE(SDL_HAPTIC_IOKIT, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
            have_haptic=yes
        fi
        # Set up files for the power library
        if test x$enable_power = xyes; then
            AC_DEFINE(SDL_POWER_MACOSX, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
            have_power=yes
        fi
        # Set up files for the filesystem library
        if test x$enable_filesystem = xyes; then
            AC_DEFINE(SDL_FILESYSTEM_COCOA, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
            have_filesystem=yes
        fi
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
            have_timers=yes
        fi
        # Set up additional files for the file library
        if test x$enable_file = xyes; then
            SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
        fi
        # Set up other core UNIX files
        SOURCES="$SOURCES $srcdir/src/core/unix/*.c"
        # The Mac OS X platform requires special setup.
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreVideo"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
        if test x$enable_video_vulkan = xyes; then
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
        fi
        ;;
    *-nacl|*-pnacl)
        ARCH=nacl
        CheckNativeClient
        CheckDummyAudio
        CheckDummyVideo
        CheckInputEvents
        CheckPTHREAD
        
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
            have_timers=yes
        fi
        
        if test x$enable_filesystem = xyes; then
            AC_DEFINE(SDL_FILESYSTEM_NACL, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/filesystem/nacl/*.c"
            have_filesystem=yes
        fi
        ;;
    *-*-emscripten* )
        if test x$enable_video = xyes; then
            AC_DEFINE(SDL_VIDEO_DRIVER_EMSCRIPTEN, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/video/emscripten/*.c"
            have_video=yes
            SUMMARY_video="${SUMMARY_video} emscripten"
        fi

        if test x$enable_audio = xyes; then
            AC_DEFINE(SDL_AUDIO_DRIVER_EMSCRIPTEN, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/audio/emscripten/*.c"
            have_audio=yes
            SUMMARY_audio="${SUMMARY_audio} emscripten"
        fi

        CheckVisibilityHidden
        CheckDeclarationAfterStatement
        CheckDummyVideo
        CheckDiskAudio
        CheckDummyAudio
        CheckDLOPEN
        CheckClockGettime
        CheckEmscriptenGLES

         # Set up files for the power library
        if test x$enable_power = xyes; then
            AC_DEFINE(SDL_POWER_EMSCRIPTEN, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/power/emscripten/*.c"
            have_power=yes
        fi
        
        # Set up files for the power library
        if test x$enable_joystick = xyes; then
            AC_DEFINE(SDL_JOYSTICK_EMSCRIPTEN, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/joystick/emscripten/*.c"
            have_joystick=yes
        fi

        # Set up files for the filesystem library
        if test x$enable_filesystem = xyes; then
            AC_DEFINE(SDL_FILESYSTEM_EMSCRIPTEN, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/filesystem/emscripten/*.c"
            have_filesystem=yes
        fi
        # Set up files for the timer library
        if test x$enable_timers = xyes; then
            AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
            have_timers=yes
        fi
        ;;
    *)
        AC_MSG_ERROR([
*** Unsupported host:  Please add to configure.in
        ])
        ;;
esac

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

if test x$have_joystick != xyes; then
    if test x$enable_joystick = xyes; then
        AC_DEFINE(SDL_JOYSTICK_DISABLED, 1, [ ])
    fi
    SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
fi
if test x$have_haptic != xyes; then
    if test x$enable_haptic = xyes; then
        AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ])
    fi
    SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
fi
if test x$have_threads != xyes; then
    if test x$enable_threads = xyes; then
        AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ])
    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, 1, [ ])
    fi
    SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
fi
if test x$have_filesystem != xyes; then
    if test x$enable_filesystem = xyes; then
        AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ])
    fi
    SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c"
fi
if test x$have_loadso != xyes; then
    if test x$enable_loadso = xyes; then
        AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ])
    fi
    SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
fi
if test x$SDLMAIN_SOURCES = x; then
    SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
fi
SDLTEST_SOURCES="$srcdir/src/test/*.c"

if test x$video_wayland = xyes; then
    WAYLAND_CORE_PROTOCOL_SOURCE='$(gen)/wayland-protocol.c'
    WAYLAND_CORE_PROTOCOL_HEADER='$(gen)/wayland-client-protocol.h'
    WAYLAND_PROTOCOLS_UNSTABLE_SOURCES=`echo $WAYLAND_PROTOCOLS_UNSTABLE |\
        sed 's,[[^ ]]\+,\\$(gen)/&-protocol.c,g'`
    WAYLAND_PROTOCOLS_UNSTABLE_HEADERS=`echo $WAYLAND_PROTOCOLS_UNSTABLE |\
        sed 's,[[^ ]]\+,\\$(gen)/&-client-protocol.h,g'`
    GEN_SOURCES="$GEN_SOURCES $WAYLAND_CORE_PROTOCOL_SOURCE $WAYLAND_PROTOCOLS_UNSTABLE_SOURCES"
    GEN_HEADERS="$GEN_HEADERS $WAYLAND_CORE_PROTOCOL_HEADER $WAYLAND_PROTOCOLS_UNSTABLE_HEADERS"

    WAYLAND_CORE_PROTOCOL_SOURCE_DEPENDS="
$WAYLAND_CORE_PROTOCOL_SOURCE: $WAYLAND_CORE_PROTOCOL_DIR/wayland.xml
	\$(SHELL) \$(auxdir)/mkinstalldirs \$(gen)
	\$(RUN_CMD_GEN)\$(WAYLAND_SCANNER) code \$< \$@"

    WAYLAND_CORE_PROTOCOL_HEADER_DEPENDS="
$WAYLAND_CORE_PROTOCOL_HEADER: $WAYLAND_CORE_PROTOCOL_DIR/wayland.xml
	\$(SHELL) \$(auxdir)/mkinstalldirs \$(gen)
	\$(RUN_CMD_GEN)\$(WAYLAND_SCANNER) client-header \$< \$@"

    WAYLAND_CORE_PROTOCOL_OBJECT="
\$(objects)/`echo $WAYLAND_CORE_PROTOCOL_SOURCE | sed 's/\$(gen)\/\(.*\).c$/\1.lo/'`: $WAYLAND_CORE_PROTOCOL_SOURCE
	\$(RUN_CMD_CC)\$(LIBTOOL) --tag=CC --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \$< -o \$@"

    WAYLAND_PROTOCOLS_CLIENT_HEADER_UNSTABLE_DEPENDS=`for p in $WAYLAND_PROTOCOLS_UNSTABLE;\
        do echo ; echo \$p | sed\
        "s,^\\([[a-z\\-]]\\+\\)-unstable-\\(v[[0-9]]\+\\)\$,\\$(gen)/&-client-protocol.h: $WAYLAND_PROTOCOLS_DIR/unstable/\1/&.xml\\\\
	\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)\\\\
	\\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) client-header \\$< \\$@," ; done`

    WAYLAND_PROTOCOLS_CODE_UNSTABLE_DEPENDS=`for p in $WAYLAND_PROTOCOLS_UNSTABLE;\
        do echo ; echo \$p | sed\
        "s,^\\([[a-z\\-]]\\+\\)-unstable-\\(v[[0-9]]\+\\)\$,\\$(gen)/&-protocol.c: $WAYLAND_PROTOCOLS_DIR/unstable/\1/&.xml\\\\
	\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)\\\\
	\\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) code \\$< \\$@," ; done`

    WAYLAND_PROTOCOLS_OBJECTS_UNSTABLE=`for p in $WAYLAND_PROTOCOLS_UNSTABLE;\
        do echo ; echo \$p | sed\
        "s,^\\([[a-z\\-]]\\+\\)-unstable-\\(v[[0-9]]\+\\)\$,\\\$(objects)/&-protocol.lo: \\$(gen)/&-protocol.c \\$(gen)/&-client-protocol.h\\\\
	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@," ; done`

    WAYLAND_PROTOCOLS_DEPENDS="
$WAYLAND_CORE_PROTOCOL_SOURCE_DEPENDS
$WAYLAND_CORE_PROTOCOL_HEADER_DEPENDS
$WAYLAND_CORE_PROTOCOL_OBJECT
$WAYLAND_PROTOCOLS_CLIENT_HEADER_UNSTABLE_DEPENDS
$WAYLAND_PROTOCOLS_CODE_UNSTABLE_DEPENDS
$WAYLAND_PROTOCOLS_OBJECTS_UNSTABLE
"
fi

OBJECTS=`echo $SOURCES`
DEPENDS=`echo $SOURCES | tr ' ' '\n'`
for EXT in asm cc m c S; do
    OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
    DEPENDS=`echo "$DEPENDS" | sed "s,^\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT\\$,\\\\
\\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
done

GEN_OBJECTS=`echo "$GEN_SOURCES" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`

VERSION_OBJECTS=`echo $VERSION_SOURCES`
VERSION_DEPENDS=`echo $VERSION_SOURCES`
VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\
\\$(objects)/\\2.o: \\1/\\2.rc\\\\
	\\$(WINDRES) \\$< \\$@,g"`

SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
\\$(objects)/\\2.lo: \\1/\\2.c\\\\
	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`

SDLTEST_OBJECTS=`echo $SDLTEST_SOURCES`
SDLTEST_DEPENDS=`echo $SDLTEST_SOURCES`
SDLTEST_OBJECTS=`echo "$SDLTEST_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
SDLTEST_DEPENDS=`echo "$SDLTEST_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
\\$(objects)/\\2.lo: \\1/\\2.c\\\\
	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`

# Set runtime shared library paths as needed

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

    AC_MSG_CHECKING(for linker option --enable-new-dtags)
    have_enable_new_dtags=no
    save_LDFLAGS="$LDFLAGS"
    LDFLAGS="$LDFLAGS -Wl,--enable-new-dtags"
    AC_TRY_LINK([
    ],[
    ],[
    have_enable_new_dtags=yes
    SDL_RLD_FLAGS="$SDL_RLD_FLAGS -Wl,--enable-new-dtags"
    ])
    LDFLAGS="$save_LDFLAGS"
    AC_MSG_RESULT($have_enable_new_dtags)
  fi
  if test $ARCH = solaris; then
    SDL_RLD_FLAGS="-R\${libdir}"
  fi
else
  SDL_RLD_FLAGS=""
fi

SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"

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(OBJECTS)
AC_SUBST(GEN_HEADERS)
AC_SUBST(GEN_OBJECTS)
AC_SUBST(VERSION_OBJECTS)
AC_SUBST(SDLMAIN_OBJECTS)
AC_SUBST(SDLTEST_OBJECTS)
AC_SUBST(BUILD_CFLAGS)
AC_SUBST(EXTRA_CFLAGS)
AC_SUBST(BUILD_LDFLAGS)
AC_SUBST(EXTRA_LDFLAGS)
AC_SUBST(WINDRES)
AC_SUBST(WAYLAND_SCANNER)

cat >Makefile.rules <<__EOF__

# Build rules for objects
-include \$(OBJECTS:.lo=.d)

# Special dependency for SDL.c, since it depends on SDL_revision.h
$srcdir/src/SDL.c: update-revision
$DEPENDS
$VERSION_DEPENDS
$SDLMAIN_DEPENDS
$SDLTEST_DEPENDS
$WAYLAND_PROTOCOLS_DEPENDS
__EOF__

AC_CONFIG_FILES([
    Makefile:Makefile.in:Makefile.rules sdl2-config sdl2-config.cmake SDL2.spec sdl2.pc
])
AC_CONFIG_COMMANDS([sdl2_config],[chmod a+x sdl2-config])

SUMMARY="SDL2 Configure Summary:\n"
if test x$enable_shared = xyes; then
    SUMMARY="${SUMMARY}Building Shared Libraries\n"
fi
if test x$enable_static = xyes; then
    SUMMARY="${SUMMARY}Building Static Libraries\n"
fi
SUMMARY="${SUMMARY}Enabled modules :${SUMMARY_modules}\n"
SUMMARY="${SUMMARY}Assembly Math   :${SUMMARY_math}\n" 
SUMMARY="${SUMMARY}Audio drivers   :${SUMMARY_audio}\n"
SUMMARY="${SUMMARY}Video drivers   :${SUMMARY_video}\n"
if test x$have_x = xyes; then
    SUMMARY="${SUMMARY}X11 libraries   :${SUMMARY_video_x11}\n"
fi
SUMMARY="${SUMMARY}Input drivers   :${SUMMARY_input}\n"
if test x$have_samplerate_h_hdr = xyes; then
    SUMMARY="${SUMMARY}Using libsamplerate : YES\n"
else
    SUMMARY="${SUMMARY}Using libsamplerate : NO\n"
fi
if test x$have_libudev_h_hdr = xyes; then
    SUMMARY="${SUMMARY}Using libudev       : YES\n"
else
    SUMMARY="${SUMMARY}Using libudev       : NO\n"
fi
if test x$have_dbus_dbus_h_hdr = xyes; then
    SUMMARY="${SUMMARY}Using dbus          : YES\n"
else
    SUMMARY="${SUMMARY}Using dbus          : NO\n"
fi
if test x$enable_ime = xyes; then
    SUMMARY="${SUMMARY}Using ime           : YES\n"
else
    SUMMARY="${SUMMARY}Using ime           : NO\n"
fi
if test x$have_ibus_ibus_h_hdr = xyes; then
    SUMMARY="${SUMMARY}Using ibus          : YES\n"
else
    SUMMARY="${SUMMARY}Using ibus          : NO\n"
fi
if test x$have_fcitx_frontend_h_hdr = xyes; then
    SUMMARY="${SUMMARY}Using fcitx         : YES\n"
else
    SUMMARY="${SUMMARY}Using fcitx         : NO\n"
fi
AC_CONFIG_COMMANDS([summary], [echo -en "$SUMMARY"], [SUMMARY="$SUMMARY"])

AC_OUTPUT