aboutsummaryrefslogtreecommitdiffhomepage
path: root/configure
blob: 0fd5a1193a39ea0d312f6ca67555edf55eecbe74 (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
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
#! /bin/sh
#
# Original version (C) 2000 Pontscho/fresh!mindworkz
#                      pontscho@makacs.poliod.hu
#
# History / Contributors: check the cvs log !
#
# Cleanups all over the place (c) 2001 pl
#
#
# Guidelines:
# If the option is named 'opt':
#   _opt : should have a value in yes/no/auto
#   _def_opt : '#define ... 1' or '#undef ...' that is: some C code
#   _ld_opt : ' -L/path/dir -lopt ' that is: some GCC option
#   _inc_opt : ' -I/path/dir/include '
#
# In this file, a tab is 8 chars and indentation shift is 2 characters
#
# GOTCHAS:
#  - config files are currently:
#    config.h config.mak libvo/config.mak libao2/config.mak Gui/config.mak
#
#############################################################################

# Prefer these macros to full length text !
# These macros only return an error code - NO display is done
cc_check() {
  echo >> "$TMPLOG"
  cat "$TMPC" >> "$TMPLOG"
  echo >> "$TMPLOG"
  echo "$_cc $_inc_extra $_ld_static $_ld_extra $TMPC -o $TMPO $@" >> "$TMPLOG"
  rm -f "$TMPO"
  ( "$_cc" $_inc_extra $_ld_static $_ld_extra "$TMPC" -o "$TMPO" "$@" ) >> "$TMPLOG" 2>&1
  TMP="$?"
  echo >> "$TMPLOG"
  echo "ldd $TMPO" >> "$TMPLOG"
  ( ldd "$TMPO" ) >> "$TMPLOG" 2>&1
  echo >> "$TMPLOG"
  return "$TMP"
}

# Display error message, flushes tempfile, exit
die () {
  echo
  echo "Error: $@" >&2
  echo >&2
  rm -f "$TMPO" "$TMPC" "$TMPS" "$TMPCPP"
  echo "Check "$TMPLOG" if you do not understand why it failed."
  exit 1
}

# OS test booleans functions
issystem() {
  test "`echo $system_name | tr A-Z a-z`" = "`echo $1 | tr A-Z a-z`"
}
linux()   { issystem "Linux"   ; return "$?" ; }
sunos()   { issystem "SunOS"   ; return "$?" ; }
hpux()    { issystem "HP-UX"   ; return "$?" ; }
irix()    { issystem "IRIX"    ; return "$?" ; }
cygwin()  { issystem "CYGWIN"  ; return "$?" ; }
freebsd() { issystem "FreeBSD" ; return "$?" ; }
netbsd()  { issystem "NetBSD"  ; return "$?" ; }
bsdos()   { issystem "BSD/OS"  ; return "$?" ; }
openbsd() { issystem "OpenBSD" ; return "$?" ; }
bsd()     { freebsd || netbsd || bsdos || openbsd ; return "$?" ; }
qnx()     { issystem "QNX"     ; return "$?" ; }
darwin()  { issystem "Darwin"  ; return "$?" ; }

# arch test boolean functions
# x86/x86pc is used by QNX
x86() {
  case "$host_arch" in
    i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686) return 0 ;;
    *) return 1 ;;
  esac
}

ppc() {
  case "$host_arch" in
    ppc) return 0;;
    *) return 1;;
  esac
}

# Use this before starting a check
echocheck() {
  echo "============ Checking for $@ ============" >> "$TMPLOG"
  echo ${_echo_n} "Checking for $@ ... ${_echo_c}"
}

# Use this to echo the results of a check
echores() {
  echo "Result is: $@" >> "$TMPLOG"
  echo "##########################################" >> "$TMPLOG"
  echo "" >> "$TMPLOG"
  echo "$@"
}
#############################################################################

# Check how echo works in this /bin/sh
case `echo -n` in
  -n)	_echo_n=	_echo_c='\c'	;;	# SysV echo
  *)	_echo_n='-n '	_echo_c=	;;	# BSD echo
esac

LANGUAGES=`echo help/help_mp-??.h help/help_mp-??_??.h | sed "s/help_mp-\(..\).h/\1/g" |sed "s/help_mp-\(.....\).h/\1/g"`

for parm in "$@" ; do
  if test "$parm" = "--help" || test "$parm" = "-help" || test "$parm" = "-h" ; then
    cat << EOF

Usage: $0 [OPTIONS]...

Configuration:
  -h, --help             display this help and exit

Installation directories:
  --prefix=DIR           use this prefix for installing mplayer [/usr/local]
  --bindir=DIR           use this prefix for installing mplayer binary
                         [PREFIX/bin]
  --datadir=DIR          use this prefix for installing machine independent
                         data files (fonts, skins) [PREFIX/share/mplayer]
  --mandir=DIR           use this prefix for installing manpages [PREFIX/man]
  --confdir=DIR          use this prefix for installing configuration files
                         [same as datadir]
  --libdir=DIR           use this prefix for object code libraries [PREFIX/lib]

Optional features:
  --disable-mencoder     disable mencoder (a/v encoder) compilation [enable]
  --enable-gui           enable gmplayer compilation (gtk-1.2 GUI) [disable]
  --enable-largefiles    enable support for files > 2 GBytes [disable]
  --enable-linux-devfs   set default devices to devfs ones [disable]
  --enable-termcap       use termcap database for key codes [autodetect]
  --disable-iconv        do not use iconv(3) function [autodetect]
  --disable-setlocale    disable setlocale using in mplayer [autodetect]
  --enable-lirc          enable LIRC (remote control) support [autodetect]
  --enable-joystick      enable joystick support [disable]
  --disable-tv           disable TV Interface (tv/dvb grabbers) [enable]
  --disable-tv-v4l       disable Video4Linux TV Interface support [autodetect]
  --disable-tv-bsdbt848  disable BSD BT848 Interface support [autodetect]
  --disable-rtc          disable RTC (/dev/rtc) on Linux [autodetect]
  --disable-streaming    disable network streaming support
                         (support for: http/mms/rtp) [enable]
  --enable-live          enable LIVE.COM Streaming Media support [disable]
  --disable-dvdnav       Disable dvdnav support [autodetect]
  --disable-dvdread      Disable libdvdread support [autodetect]
  --disable-mpdvdkit     Disable mpdvdkit/mpdvdkit2 support [autodetect]
  --disable-css          Disable old-style libcss DVD support [autodetect]
  --disable-cdparanoia   Disable cdparanoia support [autodetect]
  --enable-freetype      Enable freetype2 font rendering support [disabled]
  --disable-unrarlib     Disable Unique RAR File Library [enabled]

Codecs:
  --enable-gif		 enable gif89a output support [autodetect]
  --enable-png		 enable png input/output support [autodetect]
  --enable-jpeg		 enable jpeg input/output support [autodetect]
  --disable-win32        disable Win32 DLL support [autodetect]
  --disable-dshow        disable Win32/DirectShow support [autodetect]
  --disable-xanim        disable XAnim DLL support [autodetect]
  --disable-real         disable RealPlayer DLL support [autodetect]
  --disable-xvid         disable XviD codec [autodetect]
  --disable-divx4linux   disable DivX4linux/Divx5linux codec [autodetect]
  --enable-opendivx      enable _old_ OpenDivx codec [disable]
  --disable-libavcodec   disable libavcodec [autodetect]
  --enable-libfame       enable libfame realtime encoder [autodetect]
  --enable-vorbis        build with OggVorbis support [autodetect]
  --enable-faad          build with FAAD2 (MP4/AAC) support [autodetect]
  --disable-libdv        disable libdv 0.9.5 en/decoding support [autodetect]
  --disable-mad          disable libmad (mpeg audio) support [autodetect]
  
Video output:
  --disable-vidix        disable VIDIX stuff [enable on x86 *nix]
  --enable-gl            build with OpenGL render support [autodetect]
  --enable-dga[=n]       build with DGA [n in {1, 2} ] support [autodetect]
  --enable-vesa          build with VESA support [autodetect]
  --enable-svga          build with SVGAlib support [autodetect]
  --enable-sdl           build with SDL render support [autodetect]
  --enable-aa            build with AAlib render support [autodetect]
  --enable-ggi           build with GGI render support [autodetect]
  --enable-directx       build with Directx support [autodetect]
  --enable-dxr2          build with DXR2 render support [autodetect]
  --enable-dxr3          build with DXR3/H+ render support [autodetect]
  --enable-dvb           build with support for output via DVB-Card [autodetect]
  --enable-mga           build with mga_vid (for Matrox G200/G4x0/G550) support
                         (check for /dev/mga_vid) [autodetect]
  --enable-xmga          build with mga_vid X Window support
                         (check for X & /dev/mga_vid) [autodetect]
  --enable-xv            build with Xv render support for X 4.x [autodetect]
  --enable-vm            build with XF86VidMode support for X11 [autodetect]
  --enable-xinerama      build with Xinerama support for X11 [autodetect]
  --enable-x11           build with X11 render support [autodetect]
  --enable-fbdev         build with FBDev render support [autodetect]
  --enable-fbdev=nocopy  yuv12 converts directly into framebuffer
  --enable-mlib          build with MLIB support (Solaris only) [autodetect]
  --enable-3dfx          build with obsolete /dev/3dfx support [disable]
  --enable-tdfxfb        build with tdfxfb (Voodoo 3/banshee) support [disable]
  --enable-directfb      build with DirectFB support [autodetect]
  --enable-zr            build with ZR360[56]7/ZR36060 support [autodetect]
  --enable-bl		 build with Blinkenlights support [disable]

Audio output:
  --disable-ossaudio     disable OSS sound support [autodetect]
  --disable-arts         disable aRts sound support [autodetect]
  --disable-alsa         disable alsa sound support [autodetect]
  --disable-sunaudio     disable Sun sound support [autodetect]
  --disable-select       disable using select() on audio device [enable]

Miscellaneous options:
  --enable-runtime-cpudetection    Enable runtime CPU detection [disable]
  --cc=COMPILER          use this C compiler to build MPlayer [gcc]
  --target=PLATFORM      target platform (i386-linux, arm-linux, etc)
  --enable-static        build a statically linked binary. Set further linking
                         options with --enable-static="-lslang -lncurses"
  --language=xx          select a language (for translated messages/gui) [en]
                         (Available: $LANGUAGES)

Advanced options:
  --enable-mmx           build with mmx support [autodetect]
  --enable-mmx2          build with mmx2 support (PIII, Athlon) [autodetect]
  --enable-3dnow         build with 3dnow! support [autodetect]
  --enable-3dnowex       build with 3dnow-dsp! support (K7) [autodetect]
  --enable-sse           build with sse support [autodetect]
  --enable-sse2          build with sse2 support [autodetect]
  --disable-fastmemcpy   disable 3dnow/sse/mmx optimized memcpy() [enable]
  --disable-big-endian   Force byte order to little endian [autodetect]
  --enable-big-endian    Force byte order to big endian [autodetect]
  --enable-debug[=1-3]   compile debugging information into mplayer [disable]
  --enable-profile       compile profiling information into mplayer [disable]
  --disable-sighandler   disable sighandler for crashes [enable]
  --enable-i18n          _experimental_ gnu gettext() support [disable]

Hazardous options a.k.a. "DO NOT REPORT ANY BUGS!"
  --disable-gcc-checking   disable gcc version checking [enable]

Use these options if autodetection fails:
  --with-extraincdir=DIR   extra headers (png, dvb, mad, sdl, css, ...) in DIR
  --with-extralibdir=DIR   extra library files (png, SDL, ...) in DIR
  --with-x11incdir=DIR     X headers in DIR
  --with-x11libdir=DIR     X library files in DIR
  --with-dxr2incdir=DIR    DXR2 headers in DIR
  --with-csslibdir=DIR     libcss in DIR
  --with-madlibdir=DIR     libmad (libmad shared library) in DIR
  --with-mlibdir=DIR       libmlib (MLIB support) in DIR (Solaris only)
  --with-libdvdnav=DIR     libdvdnav in DIR
  --with-win32libdir=DIR   W*ndows DLL files in DIR
  --with-xanimlibdir=DIR   XAnim DLL files in DIR
  --with-reallibdir=DIR    RealPlayer DLL files in DIR
  --with-xvidcore=PATH     path to XviD libcore.a (e.g. /opt/lib/libcore.a)
  --with-sdl-config=PATH   path to sdl*-config (e.g. /opt/bin/sdl-config)
  --with-freetype-config=PATH  path to freetype-config
                           (e.g. /opt/bin/freetype-config)
  --with-gtk-config=PATH   path to gtk*-config (e.g. /opt/bin/gtk-config)
  --with-glib-config=PATH  path to glib*-config (e.g. /opt/bin/glib-config)
  --with-dvdnav-config=PATH  path to dvdnav-config
  --with-livelibdir=DIR    path to LIVE.COM Streaming Media libraries

EOF
    exit 0
  fi
done # for parm in ...


# 1st pass checking for vital options
_cc=gcc
test "$CC" && _cc="$CC"
_as=auto
_runtime_cpudetection=no
for ac_option do
  case "$ac_option" in
  --target=*)
    _target=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --cc=*)
    _cc=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --as=*)
    _as=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --enable-gcc-checking)
    _skip_cc_check=no
    ;;
  --disable-gcc-checking)
    _skip_cc_check=yes
    ;;
  --enable-static)
    _ld_static='-static'
    ;;
  --disable-static)
    _ld_static=''
    ;;
  --enable-static=*)
    _ld_static="-static `echo $ac_option | cut -d '=' -f 2`"
    ;;
  --with-extraincdir=*)
    _inc_extra=-I`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -I,g'`
    ;;
  --with-extralibdir=*)
    _ld_extra=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
#    _ld_extra="${_ld_extra} -Wl,-R"`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -Wl\,-R,g'`" -L"`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
    ;;
  --enable-runtime-cpudetection)
    _runtime_cpudetection=yes
    ;;
  --disable-runtime-cpudetection)
    _runtime_cpudetection=no
    ;;
  esac
done

# Determine our OS name and CPU architecture
if test -z "$_target" ; then
  # OS name
  system_name=`( uname -s ) 2>&1`
  case "$system_name" in
  Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin)
    ;;
  IRIX*)
    system_name=IRIX
    ;;
  HP-UX*)
    system_name=HP-UX
    ;;
  [cC][yY][gG][wW][iI][nN]*)
    system_name=CYGWIN
    ;;
  *)
    system_name="$system_name-UNKNOWN"
    ;;
  esac


  # host's CPU/instruction set
   host_arch=`( uname -p ) 2>&1`
   case "$host_arch" in
   i386|sparc|ppc|alpha|arm|mips)
     ;;
   powerpc) # Darwin returns 'powerpc'
     host_arch=ppc
     ;;
   *) # uname -p on Linux returns 'unknown' for the processor type,
      # OpenBSD returns 'Intel Pentium/MMX ("Genuine Intel" 586-class)'

      # Maybe uname -m (machine hardware name) returns something we
      # recognize.

      # x86/x86pc is used by QNX
      case "`( uname -m ) 2>&1`" in
      i[3-9]86|x86|x86pc|k5|k6|k6_2|k6_3|k6-2|k6-3|pentium*|athlon*|i586_i686|i586-i686) host_arch=i386 ;;
      ia64) host_arch=ia64 ;;
      x86_64) host_arch=x86_64 ;;
      ppc) host_arch=ppc ;;
      alpha) host_arch=alpha ;;
      sparc*) host_arch=sparc ;;
      9000*) host_arch=hppa ;;
      arm*) host_arch=arm ;;
      s390) host_arch=s390 ;;
      s390x) host_arch=s390x ;;
      mips) host_arch=mips ;;
      *) host_arch=UNKNOWN ;;
    esac
    ;;
  esac
else
  system_name=`echo $_target | cut -d '-' -f 2`
  case "`echo $system_name | tr A-Z a-z`" in
    linux) system_name=Linux ;;
    freebsd) system_name=FreeBSD ;;
    netbsd) system_name=NetBSD ;;
    bsd/os) system_name=BSD/OS ;;
    openbsd) system_name=OpenBSD ;;
    sunos) system_name=SunOS ;;
    qnx) system_name=QNX ;;
  esac
  # We need to convert underscores so that values like k6-2 and pentium-mmx can be passed
  host_arch=`echo $_target | cut -d '-' -f 1 | tr '_' '-'`
fi

echo "Detected operating system: $system_name"
echo "Detected host architecture: $host_arch"

# LGB: temporary files
for I in "$TMPDIR" "$TEMPDIR" "/tmp" ; do
  test "$I" && break
done

TMPLOG="configure.log"
rm -f "$TMPLOG"
TMPC="$I/mplayer-conf-$RANDOM-$$.c"
TMPCPP="$I/mplayer-conf-$RANDOM-$$.cpp"
TMPO="$I/mplayer-conf-$RANDOM-$$.o"
TMPS="$I/mplayer-conf-$RANDOM-$$.S"

# config files

# FIXME: A lot of stuff is installed under /usr/local
# NK: But we should never use this stuff implicitly since we call compiler
# from /usr we should be sure that there no effects from other compilers
# (libraries) which might be installed into /usr/local.  Let users use this
# stuff explicitly as command line argument.  In other words: It would be
# resonable to have only /usr/include or only /usr/local/include.

if freebsd ; then
  _ld_extra="$_ld_extra -L/usr/local/lib"
  _inc_extra="$_inc_extra -I/usr/local/include"
fi


# Checking CC version...
if test "$_skip_cc_check" != yes ; then
 for _cc in $_cc gcc-3.1 gcc3 gcc-3.0 cc ; do
  echocheck "$_cc version"
  cc_name=`( $_cc -v ) 2>&1 | tail -1 | cut -d ' ' -f 1`
  cc_version=`( $_cc -dumpversion ) 2>&1`
  if test "$?" -gt 0; then
    cc_version="not found"
  fi
  case $cc_version in
    '')
      cc_version="v. ?.??, bad"
      cc_verc_fail=yes
      ;;
    2.95.[2-9]|2.95.[2-9][-.][0-9]|3.[0-9]|3.[0-9].[0-9])
      cc_version="$cc_version, ok"
      cc_verc_fail=no
      ;;
    'not found')
      cc_verc_fail=yes
      ;;
    *)
      cc_version="$cc_version, bad"
      cc_verc_fail=yes
      ;;
  esac
  echores "$cc_version"
  (test "$cc_verc_fail" = "no") && break
 done 
  if test "$cc_verc_fail" = yes ; then
    cat <<EOF

*** Please downgrade/upgrade C compiler to version gcc-2.95.x or gcc-3.x! ***

You are not using a supported compiler. We do not have the time to make sure
everything works with compilers other than the ones we use.  Use either the
same compiler as we do, or use --disable-gcc-checking but DO *NOT* REPORT BUGS
unless you can reproduce them after recompiling with a 2.95.x or 3.x version!

Note for gcc 2.96 users: Some versions of this compiler are known to miscompile
mplayer and lame (which is used for mencoder).  If you get compile errors,
first upgrade to the latest 2.96 release (minimum 2.96-85) and try again.
If the problem still exists, try with gcc 3.x (or 2.95.x) *BEFORE* reporting
bugs!

        GCC 2.96 IS NOT AND WILL NOT BE SUPPORTED BY US !

     *** For details please read DOCS/users_against_developers.html ***

EOF
    die "Bad gcc version"
  fi
else
cat <<EOF

******************************************************************************

Hmm. You really want to compile MPlayer with an *UNSUPPORTED* C compiler?
Ok. You know. Do it. Did you already read DOCS/users_against_developers.html???

DO NOT SEND BUGREPORTS OR COMPLAIN, it's *YOUR* compiler's fault!
Get ready for mysterious crashes, no-picture bugs, strange noises... REALLY!
Lame which is used by mencoder produces weird errors, too.

If you have any problem, install a GCC 2.95.x or 3.x version and try again.
If the problem _still_ exists, then read DOCS/bugreports.html !

  *** DO NOT SEND BUG REPORTS OR COMPLAIN it's *YOUR* compiler's fault! ***

******************************************************************************

EOF

read _answer

fi
# ---

# now that we know what compiler should be used for compilation, try to find
# out which assembler is used by the $_cc compiler
if test "$_as" = auto ; then
  _as=`$_cc -print-prog-name=as`
  test -z "$_as" && _as=as
fi

# Try to find the available options for the current CPU
if x86 || ppc; then
  if test -r /proc/cpuinfo ; then
    # linux with /proc mounted, extract cpu information from it
    _cpuinfo="cat /proc/cpuinfo"
  elif test -r /compat/linux/proc/cpuinfo ; then
    # FreeBSD with linux emulation /proc mounted,
    # extract cpu information from it
    _cpuinfo="cat /compat/linux/proc/cpuinfo"
  elif x86; then
    # all other OS try to extract cpu information from a small helper
    # program TOOLS/cpuinfo instead
    $_cc -o TOOLS/cpuinfo TOOLS/cpuinfo.c
    _cpuinfo="TOOLS/cpuinfo"
  fi

  pname=`$_cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1`
  pvendor=`$_cpuinfo | grep 'vendor_id' | cut -d ':' -f 2  | cut -d ' ' -f 2 | head -1`
  pfamily=`$_cpuinfo | grep 'cpu family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
  pmodel=`$_cpuinfo | grep -v 'model name' | grep 'model' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
  pstepping=`$_cpuinfo | grep 'stepping' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`

  pparam=`$_cpuinfo | grep 'features' | cut -d ':' -f 2 | head -1`
  if test -z "$pparam" ; then
    pparam=`$_cpuinfo | grep 'flags' | cut -d ':' -f 2 | head -1`
  fi

  _mmx=no
  _3dnow=no
  _3dnowex=no
  _mmx2=no
  _sse=no
  _sse2=no
  _mtrr=no

  for i in $pparam ; do
    case "$i" in
    3dnow)        _3dnow=yes               ;;
    3dnowext)     _3dnow=yes  _3dnowex=yes ;;
    mmx)          _mmx=yes                 ;;
    mmxext)       _mmx2=yes                ;;
    mtrr|k6_mtrr|cyrix_arr)   _mtrr=yes    ;;
    xmm|sse|kni)  _sse=yes    _mmx2=yes    ;;
    sse2)         _sse2=yes                ;;
    esac
  done

  echocheck "CPU vendor"
  echores "$pvendor ($pfamily:$pmodel:$pstepping)"

  echocheck "CPU type"
  echores "$pname"

  if test "$_runtime_cpudetection" = yes ; then
    _mmx=yes
    _3dnow=yes
    _3dnowex=yes
    _mmx2=yes
    _sse=yes
    _sse2=yes
    _mtrr=yes
    _optimizing="Runtime CPU-Detection enabled"
  fi

fi


if [ "$host_arch" = alpha ]; then
  echocheck "CPU type"
cat > $TMPC << EOF
int main() {
    unsigned long ver, mask;
    asm ("implver %0" : "=r" (ver));
    asm ("amask %1, %0" : "=r" (mask) : "r" (-1));
    printf("%ld-%x\n", ver, ~mask);
    return 0;
}
EOF
  $_cc -o "$TMPO" "$TMPC"
  case `"$TMPO"` in
    0-0) proc="ev4" ;;
    1-0) proc="ev5" ;;
    1-1) proc="ev56" ;;
    1-101) proc="pca56" ;;
    2-303) proc="ev6" ;;
    2-307) proc="ev67" ;;
    2-1307) proc="ev68" ;;
  esac
  echores "$proc"
fi


# x86/x86pc is used by QNX
case "$host_arch" in
  i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686)
  _def_arch="#define ARCH_X86 1"
  _target_arch="TARGET_ARCH_X86 = yes"

  case "$pvendor" in
  AuthenticAMD)
    case "$pfamily" in
    3) proc=i386 iproc=386 ;;
    4) proc=i486 iproc=486 ;;
    5) iproc=586       # LGB: models are: K5/SSA5 K5 K5 K5 ? ? K6 K6 K6-2 K6-3
	# TODO: how to determine if model 13 is a k6-2 or a k6-3? Couldn't find anything on amd.com
	if test "$pmodel" -eq 9; then
		proc=k6-3
	elif test "$pmodel" -ge 8; then
		proc=k6-2
	elif test "$pmodel" -ge 6; then
		proc=k6
	else
		proc=i586
		iproc=586
	fi
	;;
    6) iproc=686
	if test "$pmodel" -ge 7; then
		proc=athlon-4
	elif test "$pmodel" -ge 6; then
		# only Athlon XP supports ssem MP, Duron etc not
		# but most of them are cpuid 666, so check if sse detected
		# btw. there is also athlon-mp opt, but we need extended
		# cpuid to detect if cpu is SMP capable -> athlon-mp ::atmos
		if test "$_sse" = yes && test "$pstepping" -ge 2; then
			proc=athlon-xp
		else
			proc=athlon-4
		fi
	elif test "$pmodel" -ge 4; then
		proc=athlon-tbird
	else
		proc=athlon # TODO: should the Duron Spitfire be considered a Thunderbird instead?
	fi
	;;
    
    *) proc=athlon-xp iproc=686 ;;
    esac
    ;;
  GenuineIntel)
    case "$pfamily" in
    3) proc=i386 iproc=386 ;;
    4) proc=i486 iproc=486 ;;
    5) iproc=586
	if test "$pmodel" -eq 4 || test "$pmodel" -eq 8; then
		proc=pentium-mmx # 4 is desktop, 8 is mobile
	else
		proc=i586
	fi
	;;
    6) iproc=686
	if test "$pmodel" -ge 7; then
		proc=pentium3
	elif test "$pmodel" -ge 3; then
		proc=pentium2
	else
		proc=i686
	fi
	;;
    15) proc=pentium4 iproc=686 ;;
    *) proc=pentium4 iproc=686 ;;
    esac
    ;;
  unknown)
    case "$pfamily" in
    3) proc=i386 iproc=386 ;;
    4) proc=i486 iproc=486 ;;
    *) proc=i586 iproc=586 ;;
    esac
    ;;
  *)
    proc=i586 iproc=586 ;;
  esac

    # check that gcc supports our cpu, if not, fallback to earlier ones
    # LGB: check -mcpu and -march swithing step by step with enabling
    # to fall back till 386.

    echocheck "GCC & CPU optimization abilities"
cat > $TMPC << EOF
int main(void) { return 0; }
EOF
  if test "$_runtime_cpudetection" = no ; then
    if test "$proc" = "athlon-xp" || test "$proc" = "athlon-4" || test "$proc" = "athlon-tbird"; then
      cc_check -march=$proc -mcpu=$proc || proc=athlon
    fi
    if test "$proc" = "k6-3" || test "$proc" = "k6-2"; then
      cc_check -march=$proc -mcpu=$proc  || proc=k6
    fi
    if test "$proc" = "k6"; then
      if ! cc_check -march=$proc -mcpu=$proc; then
        if cc_check -march=i586 -mcpu=i686; then
          proc=i586-i686
        else 
          proc=i586
	fi
      fi
    fi
    if test "$proc" = "pentium4" || test "$proc" = "pentium3" || test "$proc" = "pentium2" || test "$proc" = "athlon"; then
      cc_check -march=$proc -mcpu=$proc  || proc=i686
    fi
    if test "$proc" = "i686" || test "$proc" = "pentium-mmx"; then
      cc_check -march=$proc -mcpu=$proc  || proc=i586
    fi
    if test "$proc" = "i586" ; then
      cc_check -march=$proc -mcpu=$proc  || proc=i486
    fi
    if test "$proc" = "i486" ; then
      cc_check -march=$proc -mcpu=$proc  || proc=i386
    fi
    if test "$proc" = "i386" ; then
      cc_check -march=$proc -mcpu=$proc  || proc=error
    fi
    if test "$proc" = "error" ; then
      echores "Your $_cc does not support even \"i386\" for '-march' and '-mcpu'."
      _mcpu=""
      _march=""
      _optimizing=""
    elif test "$proc" = "i586-i686"; then
      _march="-march=i586"
      _mcpu="-mcpu=i686"
      _optimizing="$proc"
    else
      _march="-march=$proc"
      _mcpu="-mcpu=$proc"
      _optimizing="$proc"
    fi
  else
    # i686 is probably the most common cpu - optimize to it
    _mcpu="-mcpu=i686"
    # at least i486 required, for bswap instruction
    _march="-march=i486"
    cc_check $_mcpu || _mcpu=""
    cc_check $_march $_mcpu || _march=""
  fi

    ## Gabucino : --target takes effect here (hopefully...) by overwriting
    ##             autodetected mcpu/march parameters
    if test "$_target" ; then
      # TODO: it may be a good idea to check GCC and fallback in all cases
      if test "$host_arch" = "i586-i686"; then
        _march="-march=i586"
        _mcpu="-mcpu=i686"
      else      
        _march="-march=$host_arch"
        _mcpu="-mcpu=$host_arch"
      fi
    
      proc="$host_arch"

      case "$proc" in
        i386) iproc=386 ;;
        i486) iproc=486 ;;
        i586|k5|k6|k6-2|k6-3|pentium|pentium-mmx) iproc=586 ;;
        i686|athlon*|pentium*) iproc=686 ;;
        *) iproc=586 ;;
      esac
    fi

    echores "$proc"
    ;;

  ia64)
    _def_arch='#define ARCH_IA64 1'
    _target_arch='TARGET_ARCH_IA64 = yes'
    iproc='ia64'
    proc=''
    _march=''
    _mcpu=''
    ;;

  x86_64)
    _def_arch='#define ARCH_X86_64 1'
    _target_arch='TARGET_ARCH_X86_64 = yes'
    iproc='x86_64'
    proc=''
    _march=''
    _mcpu=''
    ;;

  sparc)
    _def_arch='#define ARCH_SPARC 1'
    _target_arch='TARGET_ARCH_SPARC = yes'
    iproc='sparc'
    proc='v8'
    _march=''
    _mcpu="-mcpu=$proc"
    ;;

  arm)
    _def_arch='#define ARCH_ARM 1'
    _target_arch='TARGET_ARCH_ARM = yes'
    iproc=arm
    proc=''
    _march=''
    _mcpu=''
    ;;

  ppc)
    _def_arch='#define ARCH_PPC 1'
    _target_arch='TARGET_ARCH_PPC = yes'
    iproc='ppc'
    proc=''
    _march=''
    _mcpu=''
    cpu750=`$_cpuinfo | grep "cpu.*750"`
    if test -n "$cpu750"; then
	_march='-mcpu=750'
	_mcpu='-mtune=750'
    fi
    ;;

  alpha)
    _def_arch='#define ARCH_ALPHA 1'
    _target_arch='TARGET_ARCH_ALPHA = yes'
    iproc='alpha'
    _march=''
    echocheck "GCC & CPU optimization abilities"
    if test "$proc" = "ev68" ; then
      cc_check -mcpu=$proc || proc=ev67
    fi
    if test "$proc" = "ev67" ; then
      cc_check -mcpu=$proc || proc=ev6
    fi
    _mcpu="-mcpu=$proc"
    echores "$proc"
    ;;

  mips)
    _def_arch='#define ARCH_SGI_MIPS 1'
    _target_arch='TARGET_ARCH_SGI_MIPS = yes'
    iproc='sgi-mips'
    proc=''
    _march=''
    _mcpu=''
    ;;

  hppa)
    _def_arch='#define ARCH_PA_RISC 1'
    _target_arch='TARGET_ARCH_PA_RISC = yes'
    iproc='PA-RISC'
    proc=''
    _march=''
    _mcpu=''
    ;;

  s390)
    _def_arch='#define ARCH_S390 1'
    _target_arch='TARGET_ARCH_S390 = yes'
    iproc='390'
    proc=''
    _march=''
    _mcpu=''
    ;;

  s390x)
    _def_arch='#define ARCH_S390X 1'
    _target_arch='TARGET_ARCH_S390X = yes'
    iproc='390x'
    proc=''
    _march=''
    _mcpu=''
    ;;

  *)
    echo "The architecture of your CPU ($host_arch) is not supported by this configure script"
    echo "It seems nobody has ported MPlayer to your OS or CPU type yet."
    die "unsupported architecture $host_arch"
    ;;
esac


if x86 && test "$_runtime_cpudetection" = no ; then
  extcheck() {
    if test "$1" = yes ; then
      echocheck "kernel support of $2"
      cat > $TMPC <<EOF
#include <signal.h>
void catch() { exit(1); }
int main(void){
  signal(SIGILL, catch);
  __asm__ __volatile__ ("$3":::"memory");return(0);
}
EOF

      if ( cc_check && $TMPO ) > /dev/null 2>&1 ; then
        echores "yes"
	_optimizing="$_optimizing $2"
        return 0
      else
        echores "failed"
        echo "It seems that your kernel does not correctly support $2."
        echo "To use $2 extensions in MPlayer, you have to upgrade/recompile your kernel!"
	return 1
      fi
    fi
    return 0
  }

  extcheck $_mmx "mmx" "emms" || _mmx=no
  extcheck $_mmx2 "mmx2" "sfence" || _mmx2=no
  extcheck $_3dnow "3dnow" "femms" || _3dnow=no
  extcheck $_3dnowex "3dnowex" "pswapd %%mm0, %%mm0" || _3dnowex=no
  extcheck $_sse "sse" "xorps %%xmm0, %%xmm0" || _sse=no _gcc3_ext="$_gcc3_ext -mno-sse"
  extcheck $_sse2 "sse2" "xorpd %%xmm0, %%xmm0" || _sse2=no _gcc3_ext="$_gcc3_ext -mno-sse2"
  echocheck "mtrr support"
  echores "$_mtrr"

  if test "$_mtrr" = yes ; then
    _optimizing="$_optimizing mtrr"
  fi

  if test "$_gcc3_ext" != ""; then
    # if we had to disable sse/sse2 because the active kernel does not
    # support this instruction set extension, we also have to tell
    # gcc3 to not generate sse/sse2 instructions for normal C code
    cat > $TMPC << EOF
int main(void) { return 0; }
EOF
    cc_check $_march $_gcc3_ext && _march="$_march $_gcc3_ext"
  fi

fi


_prefix="/usr/local"

# GOTCHA: the variables below defines the default behavior for autodetection
# and have - unless stated otherwise - at least 2 states : yes no
# If autodetection is available then the third state is: auto
_libavcodec=auto
_libavcodecso=auto 
_fame=auto
_mp1e=no
_mencoder=yes
_x11=auto
_dga=auto	# 1 2 no auto
_xv=auto
_sdl=auto
_directx=auto
_nas=auto
_png=auto
_jpg=auto
_gif=auto
_gl=auto
_ggi=auto
_aa=auto
_svga=auto
_vesa=auto
_fbdev=auto
_fbdev_nocopy=no
_dvb=auto
_dxr2=auto
_dxr3=auto
_iconv=auto
_rtc=auto
_ossaudio=auto
_arts=auto
_mad=auto
_vorbis=auto
_faad=auto
_css=auto
_dvdnav=yes
_dvdread=auto
_dvdkit=auto
_xanim=auto
_real=auto
_live=no
_xinerama=auto
_mga=auto
_xmga=auto
_vm=auto
_mlib=auto
_sgiaudio=auto
_sunaudio=auto
_alsa=auto
_fastmemcpy=yes
_unrarlib=yes
_win32=auto
_dshow=yes
_select=yes
_tv=yes
_tv_v4l=auto
_tv_bsdbt848=auto
_streaming=yes
_vidix=auto
_joystick=no
_xvid=auto
_divx4linux=auto
_opendivx=no
_lirc=auto
_gui=no
_termcap=auto
_termios=auto
_3dfx=no
_tdfxfb=no
_directfb=auto
_zr=auto
_bl=no
_largefiles=no
_language=en
_shm=auto
_linux_devfs=no
_i18n=no
_setlocale=auto
_sighandler=yes
_libdv=auto
_cdparanoia=auto
_big_endian=auto
_freetype=no

for ac_option do
  case "$ac_option" in
  # Skip 1st pass
  --target=*) ;;
  --cc=*) ;;
  --as=*) ;;
  --enable-gcc-checking) ;;
  --disable-gcc-checking) ;;
  --enable-static*) ;;
  --disable-static*) ;;
  --with-extraincdir=*) ;;
  --with-extralibdir=*) ;;
  --enable-runtime-cpudetection) ;;
  --disable-runtime-cpudetection) ;;

  # Real 2nd pass
  --enable-mencoder)	_mencoder=yes	;;
  --disable-mencoder)	_mencoder=no	;;
  --enable-i18n)	_i18n=yes	;;
  --disable-i18n)	_i18n=no	;;
  --enable-setlocale)   _setlocale=yes  ;;
  --disable-setlocale)  _setlocale=no   ;;
  --enable-x11)		_x11=yes	;;
  --disable-x11)	_x11=no		;;
  --enable-xv)		_xv=yes		;;
  --disable-xv)		_xv=no		;;
  --enable-sdl)		_sdl=yes	;;
  --disable-sdl)	_sdl=no		;;
  --enable-directx)     _directx=yes    ;;
  --disable-directx)    _directx=no     ;;
  --enable-nas)		_nas=yes	;;
  --disable-nas)	_nas=no		;;
  --enable-png)		_png=yes	;;
  --disable-png)	_png=no		;;
  --enable-jpeg)	_jpg=yes	;;
  --disable-jpeg)	_jpg=no		;;
  --enable-gif)	_gif=yes	;;
  --disable-gif)	_gif=no		;;
  --enable-gl)		_gl=yes		;;
  --disable-gl)		_gl=no		;;
  --enable-ggi)		_ggi=yes	;;
  --disable-ggi)	_ggi=no		;;
  --enable-aa)		_aa=yes		;;
  --disable-aa)		_aa=no		;;
  --enable-svga)	_svga=yes	;;
  --disable-svga)	_svga=no	;;
  --enable-vesa)	_vesa=yes	;;
  --disable-vesa)	_vesa=no	;;
  --enable-fbdev)	_fbdev=yes	;;
  --enable-fbdev=nocopy) _fbdev=yes; _fbdev_nocopy=yes	;;
  --disable-fbdev)	_fbdev=no	;;
  --enable-dvb)		_dvb=yes	;;
  --disable-dvb)        _dvb=no		;;
  --enable-dxr2)	_dxr2=yes	;;
  --disable-dxr2)	_dxr2=no	;;
  --enable-dxr3)	_dxr3=yes	;;
  --disable-dxr3)	_dxr3=no	;;
  --enable-iconv)	_iconv=yes	;;
  --disable-iconv)	_iconv=no	;;
  --enable-rtc)	        _rtc=yes	;;
  --disable-rtc)	_rtc=no	        ;;
  --enable-mp1e)	_mp1e=yes	;;
  --disable-mp1e)	_mp1e=no	;;
  --enable-libdv)	_libdv=yes	;;
  --disable-libdv)	_libdv=no	;;
  --enable-ossaudio)	_ossaudio=yes	;;
  --disable-ossaudio)	_ossaudio=no	;;
  --enable-arts)	_arts=yes	;;
  --disable-arts)	_arts=no	;;
  --enable-mad)		_mad=yes	;;
  --disable-mad)	_mad=no		;;
  --enable-vorbis)	_vorbis=yes	;;
  --disable-vorbis)	_vorbis=no	;;
  --enable-faad)	_faad=yes	;;
  --disable-faad)	_faad=no	;;
  --enable-css)		_css=yes	;;
  --disable-css)	_css=no		;;
  --enable-dvdread)	_dvdread=yes	;;
  --disable-dvdread)	_dvdread=no	;;
  --enable-mpdvdkit)	_dvdkit=yes	;;
  --disable-mpdvdkit)	_dvdkit=no	;;
  --enable-dvdnav)	_dvdnav=yes	;;
  --disable-dvdnav)	_dvdnav=no	;;
  --enable-xanim)	_xanim=yes	;;
  --disable-xanim)	_xanim=no	;;
  --enable-real)	_real=yes	;;
  --disable-real)	_real=no	;;
  --enable-live)	_live=yes	;;
  --disable-live)	_live=no	;;
  --enable-xinerama)	_xinerama=yes	;;
  --disable-xinerama)	_xinerama=no	;;
  --enable-mga)		_mga=yes	;;
  --disable-mga)	_mga=no		;;
  --enable-xmga)	_xmga=yes	;;
  --disable-xmga)	_xmga=no	;;
  --enable-vm)		_vm=yes		;;
  --disable-vm)		_vm=no		;;
  --enable-mlib)	_mlib=yes	;;
  --disable-mlib)	_mlib=no	;;
  --enable-sunaudio)	_sunaudio=yes	;;
  --disable-sunaudio)	_sunaudio=no	;;
  --enable-sgiaudio)	_sgiaudio=yes	;;
  --disable-sgiaudio)	_sgiaudio=no	;;
  --enable-alsa)	_alsa=yes	;;
  --disable-alsa)	_alsa=no	;;
  --enable-tv)		_tv=yes		;;
  --disable-tv)		_tv=no		;;
  --enable-tv-bsdbt848)	_tv_bsdbt848=yes	;;
  --disable-tv-bsdbt848)	_tv_bsdbt848=no	;;
  --enable-tv-v4l)	_tv_v4l=yes	;;
  --disable-tv-v4l)	_tv_v4l=no	;;
  --enable-fastmemcpy)	_fastmemcpy=yes	;;
  --disable-fastmemcpy)	_fastmemcpy=no	;;
  --enable-streaming)	_streaming=yes	;;
  --disable-streaming)	_streaming=no	;;
  --enable-vidix)	_vidix=yes	;;
  --disable-vidix)	_vidix=no	;;
  --enable-joystick)	_joystick=yes	;;
  --disable-joystick)	_joystick=no	;;
  --enable-xvid)	_xvid=yes	;;
  --disable-xvid)	_xvid=no	;;
  --enable-divx4linux)	_divx4linux=yes	;;
  --disable-divx4linux)	_divx4linux=no	;;
  --enable-opendivx)	_opendivx=yes	;;
  --disable-opendivx)	_opendivx=no	;;
  --enable-libavcodec)	_libavcodec=yes	;;
  --disable-libavcodec)	_libavcodec=no	;;
  --enable-libfame)	_fame=yes	;;
  --disable-libfame)	_fame=no	;;
  --enable-lirc)	_lirc=yes	;;
  --disable-lirc)	_lirc=no	;;
  --enable-gui)		_gui=yes	;;
  --disable-gui)	_gui=no		;;
  --enable-termcap)	_termcap=yes	;;
  --disable-termcap)	_termcap=no	;;
  --enable-termios)	_termios=yes    ;;
  --disable-termios)    _termios=no     ;;
  --enable-3dfx)	_3dfx=yes	;;
  --disable-3dfx)	_3dfx=no	;;
  --enable-tdfxfb)	_tdfxfb=yes	;;
  --disable-tdfxfb)	_tdfxfb=no	;;
  --enable-directfb)	_directfb=yes	;;
  --disable-directfb)	_directfb=no	;;
  --enable-zr)		_zr=yes		;;
  --disable-zr)		_zr=no		;;
  --enable-bl)		_bl=yes		;;
  --disable-bl)		_bl=no		;;
  --enable-mtrr)	_mtrr=yes	;;
  --disable-mtrr)	_mtrr=no	;;
  --enable-largefiles)	_largefiles=yes	;;
  --disable-largefiles)	_largefiles=no	;;
  --enable-shm)		_shm=yes	;;
  --disable-shm)	_shm=no         ;;
  --enable-select)	_select=yes	;;
  --disable-select)	_select=no	;;
  --enable-linux-devfs)	_linux_devfs=yes	;;
  --disable-linux-devfs)	_linux_devfs=no	;;
  --enable-cdparanoia)	_cdparanoia=yes	;;
  --disable-cdparanoia)	_cdparanoia=no	;;
  --enable-big-endian)  _big_endian=yes ;;
  --disable-big-endian) _big_endian=no  ;;
  --enable-freetype)    _freetype=yes   ;;
  --disable-freetype)   _freetype=no    ;;
  --enable-unralib)	_unrarlib=yes	;;
  --disable-unrarlib)	_unrarlib=no	;;

  --enable-dga) _dga=auto ;; # as we don't know if it's 1 or 2
  --enable-dga=*) _dga=`echo $ac_option | cut -d '=' -f 2` ;;
  --disable-dga) _dga=no ;;

  --language=*)
    LINGUAS=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-libdvdnav=*)
    _dvdnavdir=`echo $ac_option | cut -d '=' -f 2`
    _dvdnav=yes
    ;;

  --with-win32libdir=*)
    _win32libdir=`echo $ac_option | cut -d '=' -f 2`
    _win32=yes
    ;;
  --with-xanimlibdir=*)
    _xanimlibdir=`echo $ac_option | cut -d '=' -f 2`
    _xanim=yes
    ;;
  --with-reallibdir=*)
    _reallibdir=`echo $ac_option | cut -d '=' -f 2`
    _real=yes
    ;;
  --with-livelibdir=*)
    _livelibdir=`echo $ac_option | cut -d '=' -f 2`
    _live=yes
    ;;
  --with-csslibdir=*)
    _csslibdir=`echo $ac_option | cut -d '=' -f 2`
    _css=yes
    ;;
  --with-mlibdir=*)
    _mlibdir=`echo $ac_option | cut -d '=' -f 2`
    _mlib=yes
    ;;

  --disable-profile)
    _profile=
    ;;
  --enable-profile)
    _profile='-p'
    ;;
  --enable-debug)
    _debug='-g'
    ;;
  --enable-debug=*)
    _debug=`echo $_echo_n '-g'$_echo_c; echo $ac_option | cut -d '=' -f 2`
    ;;
  --disable-sighandler)
    _sighandler=no
    ;;

  --enable-sse)	_sse=yes ;;
  --disable-sse) _sse=no ;;
  --enable-sse2) _sse2=yes ;;
  --disable-sse2) _sse2=no ;;
  --enable-mmx2) _mmx2=yes ;;
  --disable-mmx2) _mmx2=no ;;
  --enable-3dnow) _3dnow=yes ;;
  --disable-3dnow) _3dnow=no _3dnowex=no ;;
  --enable-3dnowex) _3dnow=yes _3dnowex=yes ;;
  --disable-3dnowex) _3dnowex=no ;;
  --enable-mmx)	_mmx=yes ;;
  --disable-mmx) # without mmx 3Dnow! and stuff is also not possible
        _3dnow=no _3dnowex=no _mmx=no _mmx2=no ;;

  --enable-win32) _win32=yes ;;
  --disable-win32) _win32=no _dshow=no ;;
  --enable-dshow) _win32=yes _dshow=yes ;;
  --disable-dshow) _dshow=no ;;

  --with-x11incdir=*)
    _inc_x11=-I`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -I,g'`
    ;;
  --with-x11libdir=*)
    _ld_x11=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
    ;;
  --with-dxr2incdir=*)
    _inc_dxr2=-I`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -I,g'`
    ;;
  --with-xvidcore=*)
    _xvidcore=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-sdl-config=*)
    _sdlconfig=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-freetype-config=*)
    _freetypeconfig=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-gtk-config=*)
    _gtkconfig=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-glib-config=*)
    _glibconfig=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-dvdnav-config=*)
    _dvdnavconfig=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-madlibdir=*)
    _ld_mad=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
    ;;
  --with-cdparanoiaincdir=*)
    _inc_cdparanoia=-I`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -I,g'`
    ;;
  --with-cdparanoialibdir=*)
    _ld_cdparanoia=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
    ;;

  --prefix=*)
    _prefix=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --bindir=*)
    _bindir=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --datadir=*)
    _datadir=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --mandir=*)
    _mandir=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --confdir=*)
    _confdir=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --libdir=*)
    _libdir=`echo $ac_option | cut -d '=' -f 2`
    ;;

  *)
    echo "Unknown parameter: $ac_option"
    exit
    ;;

  esac
done

# Atmos: moved this here, to be correct, if --prefix is specified
test -z "$_bindir" && _bindir="$_prefix/bin"
test -z "$_datadir" && _datadir="$_prefix/share/mplayer"
test -z "$_mandir" && _mandir="$_prefix/man"
test -z "$_confdir" && _confdir="$_prefix/etc/mplayer"
test -z "$_libdir" && _libdir="$_prefix/lib"
test -z "$_mlibdir" && _mlibdir="$MLIBHOME"

if x86 ; then
  # Checking assembler (_as) compatibility...
  # Added workaround for older as that reads from stdin by default - atmos
  as_version=`echo '' | $_as -version 2>&1 | sed -n 's/^.*assembler \(version \)*\([0-9.]*\).*$/\2/p'`
  echocheck "assembler ($_as $as_version)"

  _pref_as_version='2.9.1'
  echo 'nop' > $TMPS
  if test "$_mmx" = yes ; then
    echo 'emms' >> $TMPS
  fi
  if test "$_3dnow" = yes ; then
    _pref_as_version='2.10.1'
    echo 'femms' >> $TMPS
  fi
  if test "$_3dnowex" = yes ; then
    _pref_as_version='2.10.1'
    echo 'pswapd	%mm0, %mm0' >> $TMPS
  fi
  if test "$_mmx2" = yes ; then
    _pref_as_version='2.10.1'
    echo 'movntq	%mm0, (%eax)' >> $TMPS
  fi
  if test "$_sse" = yes ; then
    _pref_as_version='2.10.1'
    echo 'xorps %xmm0, %xmm0' >> $TMPS
  fi
  #if test "$_sse2" = yes ; then
  #  _pref_as_version='2.11'
  #  echo 'xorpd %xmm0, %xmm0' >> $TMPS
  #fi
  $_as $TMPS -o $TMPO > /dev/null 2>&1 || as_verc_fail=yes

  if test "$as_verc_fail" != yes ; then
    echores "ok"
  else
    echores "failed"
    echo "Upgrade binutils to ${_pref_as_version} ..."
    die "obsolete binutils version"
  fi
fi

_def_mmx='#undef HAVE_MMX'
test "$_mmx" = yes && _def_mmx='#define HAVE_MMX 1'
_def_mmx2='#undef HAVE_MMX2'
test "$_mmx2" = yes && _def_mmx2='#define HAVE_MMX2 1'
_def_3dnow='#undef HAVE_3DNOW'
test "$_3dnow" = yes && _def_3dnow='#define HAVE_3DNOW 1'
_def_3dnowex='#undef HAVE_3DNOWEX'
test "$_3dnowex" = yes && _def_3dnowex='#define HAVE_3DNOWEX 1'
_def_sse='#undef HAVE_SSE'
test "$_sse" = yes && _def_sse='#define HAVE_SSE 1'
_def_sse2='#undef HAVE_SSE2'
test "$_sse2" = yes && _def_sse2='#define HAVE_SSE2 1'


# Checking kernel version...
if x86 && linux ; then
  _k_verc_problem=no
  kernel_version=`uname -r 2>&1`
  echocheck "$system_name kernel version"
  case "$kernel_version" in
    '') kernel_version="?.??"; _k_verc_fail=yes;;
    [0-1].[0-9].[0-9]*|2.[0-3].[0-9]*)
      _k_verc_problem=yes;;
  esac
  if test "$_k_verc_problem" = yes && test "$_sse" = yes ; then
    _k_verc_fail=yes
  fi
  if test "$_k_verc_fail" ; then
    echores "$kernel_version, fail"
    echo "WARNING! If you want to run MPlayer on this system, get prepared for problems!"
    echo "2.2.x has limited SSE support. Upgrade the kernel or use --disable-sse if you"
    echo "experience crashes. MPlayer tries to autodetect if your kernel correctly"
    echo "supports SSE, but you have been warned! If you are using a kernel older than"
    echo "2.2.x you must upgrade it to get SSE support!"
#    die "old kernel for this cpu" # works fine on some 2.2.x so don't die (later check will test)
  else
    echores "$kernel_version, ok"
  fi
fi

if test "$_vidix" = auto ; then
  _vidix=no
  # should check for x86 systems supporting vidix (does qnx have vidix?)
  x86 && _vidix=yes
  cygwin && _vidix=no
  qnx && _vidix=no
fi

# checking for a working awk, I'm using mawk first, because it's fastest - atmos
_awk=
if test "$_vidix" = yes ; then
_awk_verc_fail=yes
echocheck "awk"
for _awk in mawk gawk nawk awk; do
  if ( $_awk 'BEGIN{testme();}function testme(){print"";}' ) >> "$TMPLOG" 2>&1; then
    _awk_verc_fail=no
    break
  fi
done
test "$_awk_verc_fail" = yes && _awk=no
echores "$_awk"
if test "$_awk_verc_fail" = yes; then
echo "VIDIX needs awk, but no working implementation was found!"
echo "Try the GNU version, which can be downloaded from:"
echo "ftp://ftp.gnu.org/gnu/gawk/"
echo "If you don't need VIDIX, you can use configure --disable-vidix instead."
die "no awk"
fi
fi


######################
# MAIN TESTS GO HERE #
######################


echocheck "extra headers"
if test "$_inc_extra" ; then
  echores "$_inc_extra"
else
  echores "none"
fi


echocheck "extra libs"
if test "$_ld_extra" ; then
  echores "$_ld_extra"
else
  echores "none"
fi


# Checking for localization ...
# CSAK EGY MARADHAT - A HEGYLAKO
echocheck "i18n"
if test "$_i18n" = auto ; then
  cat > $TMPC <<EOF
#include <libintl.h>
int main(void) { gettext("test"); return 0; }
EOF
  _i18n=no
  cc_check && _i18n=yes
fi
if test "$_i18n" = yes ; then
  _def_i18n='#define USE_I18N 1'
  LINGUAS='en' # force help_mp-en.h
else
  _def_i18n='#undef USE_I18N'
fi
echores "$_i18n"


# Checking for setlocale() ...
# CSAK EGY MARADHAT - A HEGYLAKO
# Nemnem. a TV Maci !
echocheck "setlocale()"
if test "$_setlocale" = auto ; then
  cat > $TMPC <<EOF
#include <locale.h>
int main(void) { setlocale( LC_ALL,"" ); return 0; }
EOF
  _setlocale=no
  cc_check && _setlocale=yes
fi
if test "$_setlocale" = yes ; then
  _def_setlocale='#define USE_SETLOCALE 1'
else
  _def_setlocale='#undef USE_SETLOCALE'
fi
echores "$_setlocale"


echocheck "language"
test -z "$LINGUAS" && LINGUAS="en"
if test -f "help/help_mp-${LINGUAS}.h" ; then
  echores "using ${LINGUAS}"
else
  echores "${LINGUAS} not found, using en"
  LINGUAS="en"
fi
_mp_help="help/help_mp-${LINGUAS}.h"
test -f $_mp_help || die "$_mp_help not found"

echocheck "enable sighandler"
if test "$_sighandler" = yes ; then
  _def_sighandler='#define ENABLE_SIGHANDLER 1'
else
  _def_sighandler='#undef ENABLE_SIGHANDLER'
fi
echores "$_sighandler"

echocheck "runtime cpudetection"
if test "$_runtime_cpudetection" = yes ; then
  _def_runtime_cpudetection='#define RUNTIME_CPUDETECT 1'
else
  _def_runtime_cpudetection='#undef RUNTIME_CPUDETECT'
fi
echores "$_runtime_cpudetection"

echocheck "restrict keyword"
for restrict_keyword in restrict __restrict __restrict__ ; do
  echo "void foo(char * $restrict_keyword p); int main(){}" > $TMPC
  if cc_check; then
    _def_restrict_keyword=$restrict_keyword
    break;
  fi
done
if [ -n "$_def_restrict_keyword" ]; then
  echores "$_def_restrict_keyword"
else
  echores "none"
fi

echocheck "kstat"
cat > $TMPC << EOF
#include <kstat.h>
int main(void) { (void) kstat_open(); (void) kstat_close(0); return 0; }
EOF
_kstat=no
cc_check -lkstat && _kstat=yes
if test "$_kstat" = yes ; then
  _ld_arch="-lkstat $_ld_arch"
fi
if test "$_kstat" = yes ; then
  _def_kstat="#define HAVE_LIBKSTAT 1"
else
  _def_kstat="#undef HAVE_LIBKSTAT"
fi
echores "$_kstat"


echocheck "posix4"
# required for nanosleep on some systems
cat > $TMPC << EOF
#include <time.h>
int main(void) { (void) nanosleep(0, 0); return 0; }
EOF
_posix4=no
cc_check -lposix4 && _posix4=yes
if test "$_posix4" = yes ; then
  _ld_arch="-lposix4 $_ld_arch"
fi
echores "$_posix4"


echocheck "nanosleep"
# also check for nanosleep
cat > $TMPC << EOF
#include <time.h>
int main(void) { (void) nanosleep(0, 0); return 0; }
EOF
_nanosleep=no
cc_check $_ld_arch && _nanosleep=yes
if test "$_nanosleep" = yes ; then
  _def_nanosleep='#define HAVE_NANOSLEEP 1'
else
  _def_nanosleep='#undef HAVE_NANOSLEEP'
fi
echores "$_nanosleep"


echocheck "socklib"
# for Solaris (socket stuff is in -lsocket, gethostbyname and friends in -lnsl):
cat > $TMPC << EOF
#include <netdb.h>
int main(void) { (void) gethostbyname(0); return 0; }
EOF
cc_check -lsocket && _ld_sock="-lsocket"
cc_check -lnsl && _ld_sock="-lnsl"
cc_check -lsocket -lnsl && _ld_sock="-lsocket -lnsl"
if test "$_ld_sock" ; then
  echores "yes (using $_ld_sock)"
else
  echores "no"
fi


_use_aton=no
echocheck "inet_pton()"
cat > $TMPC << EOF
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
int main(void) { (void) inet_pton(0, 0, 0); return 0; }
EOF
if cc_check $_ld_sock ; then
  # NOTE: Linux has libresolv but does not need it
  :
  echores "yes (using $_ld_sock)"
elif cc_check $_ld_sock -lresolv ; then
  # NOTE: needed for SunOS at least
  _ld_sock="$_ld_sock -lresolv"
  echores "yes (using $_ld_sock)"
else
  echores "no (=> i'll try inet_aton next)"
  
  echocheck "inet_aton()"
  cat > $TMPC << EOF
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
int main(void) { (void) inet_aton(0, 0); return 0; }
EOF
  _use_aton=yes
  if cc_check $_ld_sock ; then
      # NOTE: Linux has libresolv but does not need it
    :
    echores "yes (using $_ld_sock)"
  elif cc_check $_ld_sock -lresolv ; then
    # NOTE: needed for SunOS at least
    _ld_sock="$_ld_sock -lresolv"
    echores "yes (using $_ld_sock)"
  else
    _use_aton=no
    _streaming=no
    echores "no (=> streaming support disabled)"
  fi
fi

_def_use_aton='#undef USE_ATON'
if test "$_use_aton" != no; then
  _def_use_aton='#define USE_ATON 1'
fi

echocheck "inttypes.h (required)"
cat > $TMPC << EOF
#include <inttypes.h>
int main(void) { return 0; }
EOF
_inttypes=no
cc_check && _inttypes=yes
if test "$_inttypes" = yes ; then
  # nothing to do
  :
else
  die "cannot find header inttypes.h (see DOCS/faq.html)"
fi
echores "$_inttypes"

echocheck "word size"
_mp_wordsize="#undef MP_WORDSIZE"
cat > $TMPC << EOF
#include <stdio.h>
#include <sys/types.h>
int main(void) { printf("%d\n", sizeof(size_t)*8); return 0; }
EOF
cc_check && _wordsize=`$TMPO` && _mp_wordsize="#define MP_WORDSIZE $_wordsize"
echores "$_wordsize"

echocheck "stddef.h"
cat > $TMPC << EOF
#include <stddef.h>
int main(void) { return 0; }
EOF
_stddef=no
cc_check && _stddef=yes
if test "$_stddef" = yes ; then
  _def_stddef='#define HAVE_STDDEF_H 1'
else
  _def_stddef='#undef HAVE_STDDEF_H'
fi
echores "$_stddef"


echocheck "malloc.h"
cat > $TMPC << EOF
#include <malloc.h>
int main(void) { (void) malloc(0); return 0; }
EOF
_malloc=no
cc_check && _malloc=yes
if test "$_malloc" = yes ; then
  _def_malloc='#define HAVE_MALLOC_H 1'
else
  _def_malloc='#undef HAVE_MALLOC_H'
fi
# malloc.h emits a warning in FreeBSD and OpenBSD
(freebsd || openbsd) && _def_malloc='#undef HAVE_MALLOC_H'
echores "$_malloc"


echocheck "memalign()"
# XXX restrict to x86 ? extend to other CPUs/cacheline sizes ?
cat > $TMPC << EOF
#include <malloc.h>
int main (void) { (void) memalign(64, sizeof(char)); return 0; }
EOF
_memalign=no
cc_check && _memalign=yes
if test "$_memalign" = yes ; then
 _def_memalign='#define HAVE_MEMALIGN 1'
else
 _def_memalign='#undef HAVE_MEMALIGN'
fi
echores "$_memalign"


echocheck "alloca.h"
cat > $TMPC << EOF
#include <alloca.h>
int main(void) { (void) alloca(0); return 0; }
EOF
_alloca=no
cc_check && _alloca=yes
if cc_check ; then
  _def_alloca='#define HAVE_ALLOCA_H 1'
else
  _def_alloca='#undef HAVE_ALLOCA_H'
fi
echores "$_alloca"


echocheck "mman.h"
cat > $TMPC << EOF
#include <sys/types.h>
#include <sys/mman.h>
int main(void) { (void) mmap(0, 0, 0, 0, 0, 0); return 0; }
EOF
_mman=no
cc_check && _mman=yes
if test "$_mman" = yes ; then
  _def_mman='#define HAVE_SYS_MMAN_H 1'
else
  _def_mman='#undef HAVE_SYS_MMAN_H'
fi
echores "$_mman"


echocheck "dynamic loader"
cat > $TMPC << EOF
#include <dlfcn.h>
int main(void) { dlopen(0, 0); dlclose(0); dlsym(0, 0); return 0; }
EOF
_dl=no
if cc_check ; then
  _dl=yes
elif cc_check -ldl ; then
  _dl=yes
  _ld_dl='-ldl'
fi
if test "$_dl" = yes ; then
 _def_dl='#define HAVE_LIBDL 1'
else
 _def_dl='#undef HAVE_LIBDL'
fi
echores "$_dl"


#echocheck "dynamic linking"
# FIXME !! make this dynamic detection work and modify at the end (search _ld_dl_dynamic)
# also gcc flags are different, but ld flags aren't (-Bdynamic/-Bstatic/-Bsymbolic)
#cat > $TMPC << EOF
#int main(void) { return 0; }
#EOF
#if cc_check -rdynamic ; then
#  _ld_dl_dynamic='-rdynamic'
#elif cc_check -Bdynamic ; then
#  _ld_dl_dynamic='-Bdynamic'
#elif cc_check ; then
#  _ld_dl_dynamic=''
#fi
#echores "using $_ld_dl_dynamic"


echocheck "pthread"
cat > $TMPC << EOF
#include <pthread.h>
void* func(void *arg) { return arg; }
int main(void) { pthread_t tid; return pthread_create (&tid, 0, func, 0) == 0 ? 0 : 1; }
EOF
if ( cc_check && $TMPO ) ; then              # QNX
  _ld_pthread=''
elif ( cc_check -lpthread && $TMPO ) ; then
  _ld_pthread='-lpthread'
elif ( cc_check -pthread && $TMPO ) ; then
  _ld_pthread='-pthread'
else
  if test "$_ld_static" ; then
    # for crosscompilation, we cannot execute the program, be happy if we can link statically
    if ( cc_check -lpthread ) ; then
      _ld_pthread='-lpthread'
    elif ( cc_check -pthread ) ; then
     _ld_pthread='-pthread'
    else
      die "Static lib pthread not found (needed by Windows and networking stufff)."
    fi
  else
    die "Lib pthread not found (needed by Windows and networking stuff)."
  fi
fi
echores "yes (using $_ld_pthread)"


echocheck "sys/soundcard.h"
cat > $TMPC << EOF
#include <sys/soundcard.h>
int main(void) { return 0; }
EOF
_sys_soundcard=no
cc_check && _sys_soundcard=yes
if test "$_sys_soundcard" = yes ; then
  _def_sys_soundcard='#define HAVE_SYS_SOUNDCARD_H 1'
  _inc_soundcard='#include <sys/soundcard.h>'
else
  _def_sys_soundcard='#undef HAVE_SYS_SOUNDCARD_H'
fi
echores "$_sys_soundcard"

if test "$_sys_soundcard" != yes ; then
echocheck "soundcard.h"
cat > $TMPC << EOF
#include <soundcard.h>
int main(void) { return 0; }
EOF
_soundcard=no
cc_check && _soundcard=yes
if test "$_soundcard" = yes ; then
  _def_soundcard='#define HAVE_SOUNDCARD_H 1'
  _inc_soundcard='#include <soundcard.h>'
else
  _def_soundcard='#undef HAVE_SOUNDCARD_H'
fi
echores "$_soundcard"
else
  _def_soundcard='#undef HAVE_SOUNDCARD_H'
fi

echocheck "sys/dvdio.h"
cat > $TMPC << EOF
#include <unistd.h>
#include <sys/dvdio.h>
int main(void) { return 0; }
EOF
_dvdio=no
cc_check && _dvdio=yes
if test "$_dvdio" = yes ; then
  _def_dvdio='#define DVD_STRUCT_IN_SYS_DVDIO_H 1'
else
  _def_dvdio='#undef DVD_STRUCT_IN_SYS_DVDIO_H'
fi
echores "$_dvdio"


echocheck "sys/cdio.h"
cat > $TMPC << EOF
#include <unistd.h>
#include <sys/cdio.h>
int main(void) { return 0; }
EOF
_cdio=no
cc_check && _cdio=yes
if test "$_cdio" = yes ; then
  _def_cdio='#define DVD_STRUCT_IN_SYS_CDIO_H 1'
else
  _def_cdio='#undef DVD_STRUCT_IN_SYS_CDIO_H'
fi
echores "$_cdio"


echocheck "linux/cdrom.h"
cat > $TMPC << EOF
#include <sys/types.h>
#include <linux/cdrom.h>
int main(void) { return 0; }
EOF
_cdrom=no
cc_check && _cdrom=yes
if test "$_cdrom" = yes ; then
  _def_cdrom='#define DVD_STRUCT_IN_LINUX_CDROM_H 1'
else
  _def_cdrom='#undef DVD_STRUCT_IN_LINUX_CDROM_H'
fi
echores "$_cdrom"


echocheck "dvd.h"
cat > $TMPC << EOF
#include <dvd.h>
int main(void) { return 0; }
EOF
_dvd=no
cc_check && _dvd=yes
if test "$_dvd" = yes ; then
  _def_dvd='#define DVD_STRUCT_IN_DVD_H 1'
else
  _def_dvd='#undef DVD_STRUCT_IN_DVD_H'
fi
echores "$_dvd"


echocheck "BSDI dvd.h"
cat > $TMPC << EOF
#include <dvd.h>
int main(void) { return 0; }
EOF
_bsdi_dvd=no
cc_check && _bsdi_dvd=yes
if test "$_bsdi_dvd" = yes ; then
  _def_bsdi_dvd='#define DVD_STRUCT_IN_BSDI_DVDIOCTL_DVD_H 1'
else
  _def_bsdi_dvd='#undef DVD_STRUCT_IN_BSDI_DVDIOCTL_DVD_H'
fi
echores "$_bsdi_dvd"


echocheck "HPUX SCSI header"
cat > $TMPC << EOF
#include <sys/scsi.h>
int main(void) { return 0; }
EOF
_hpux_scsi_h=no
cc_check && _hpux_scsi_h=yes
if test "$_hpux_scsi_h" = yes ; then
  _def_hpux_scsi_h='#define HPUX_SCTL 1'
else
  _def_hpux_scsi_h='#undef HPUX_SCTL'
fi
echores "$_hpux_scsi_h"


echocheck "userspace SCSI headers (Solaris)"
cat > $TMPC << EOF
#   include <unistd.h>
#   include <stropts.h>
#   include <sys/scsi/scsi_types.h>
#   include <sys/scsi/impl/uscsi.h>
int main(void) { return 0; }
EOF
_sol_scsi_h=no
cc_check && _sol_scsi_h=yes
if test "$_sol_scsi_h" = yes ; then
  _def_sol_scsi_h='#define SOLARIS_USCSI 1'
else
  _def_sol_scsi_h='#undef SOLARIS_USCSI'
fi
echores "$_sol_scsi_h"


echocheck "termcap"
if test "$_termcap" = auto ; then
  cat > $TMPC <<EOF
int main(void) { return 0; }
EOF
  _termcap=no
  cc_check -ltermcap && _termcap=yes
fi
if test "$_termcap" = yes ; then
  _def_termcap='#define USE_TERMCAP 1'
  _ld_termcap='-ltermcap'
else
  _def_termcap='#undef USE_TERMCAP'
fi
echores "$_termcap"


echocheck "termios"
if test "$_termios" = auto ; then
  cat > $TMPC <<EOF
#include <sys/termios.h>
int main(void) { return 0; }
EOF
  _termios=no
  cc_check && _termios=yes
  _def_termios_h_name='sys/termios.h'
fi
# second test:
if test "$_termios" = no ; then
  cat > $TMPC <<EOF
#include <termios.h>
int main(void) { return 0; }
EOF
  _termios=no
  cc_check && _termios=yes
  _def_termios_h_name='termios.h'
fi

if test "$_termios" = yes ; then
  _def_termios='#define HAVE_TERMIOS 1'
  _def_termios_h='#undef HAVE_TERMIOS_H'
  _def_termios_sys_h='#undef HAVE_SYS_TERMIOS_H'

  if test "$_def_termios_h_name" = 'sys/termios.h' ; then
    _def_termios_sys_h='#define HAVE_SYS_TERMIOS_H 1'
  elif test "$_def_termios_h_name" = 'termios.h' ; then
    _def_termios_h='#define HAVE_TERMIOS_H 1'
  fi
  echores "yes (using $_def_termios_h_name)"
else
  _def_termios='#undef HAVE_TERMIOS'
  _def_termios_h_name=''
  echores "no"
fi


echocheck "shm"
if test "$_shm" = auto ; then
  cat > $TMPC << EOF
#include <sys/types.h>
#include <sys/shm.h>
int main(void) { shmget(0, 0, 0); shmat(0, 0, 0); shmctl(0, 0, 0); return 0; }
EOF
  _shm=no
  cc_check && _shm=yes
fi
if test "$_shm" = yes ; then
  _def_shm='#define HAVE_SHM 1'
else
  _def_shm='#undef HAVE_SHM'
fi
echores "$_shm"


# XXX: FIXME, add runtime checking
echocheck "linux devfs"
echores "$_linux_devfs"


echocheck "strsep()"
cat > $TMPC << EOF
#include <string.h>
int main (void) { char *s = "Hello, world!"; (void) strsep(&s, ","); return 0; }
EOF
_strsep=no
cc_check && _strsep=yes
if test "$_strsep" = yes ; then
 _def_strsep='#define HAVE_STRSEP 1'
else
 _def_strsep='#undef HAVE_STRSEP'
fi
echores "$_strsep"


echocheck "vsscanf()"
cat > $TMPC << EOF
#include <stdarg.h>
int main(void) { vsscanf(); return 0; }
EOF
_vsscanf=no
cc_check && _vsscanf=yes
if test "$_vsscanf" = yes ; then
  _def_vsscanf='#define HAVE_VSSCANF 1'
else
  _def_vsscanf='#undef HAVE_VSSCANF'
fi
echores "$_vsscanf"

echocheck "sys/sysinfo.h"
cat > $TMPC << EOF
#include <sys/sysinfo.h>
int main(void) {
  struct sysinfo s_info;
  sysinfo(&s_info);
  return 0;
}
EOF
_sys_sysinfo=no
cc_check && _sys_sysinfo=yes
if test "$_sys_sysinfo" = yes ; then
  _def_sys_sysinfo='#define HAVE_SYS_SYSINFO_H 1'
  _inc_sysinfo='#include <sys/sysinfo.h>'
else
  _def_sys_sysinfo='#undef HAVE_SYS_SYSINFO_H'
fi
echores "$_sys_sysinfo"


#########
# VIDEO #
#########


echocheck "3dfx"
if test "$_3dfx" = yes ; then
  _def_3dfx='#define HAVE_3DFX 1'
  _vosrc="$_vosrc vo_3dfx.c"
  _vomodules="3dfx $_vomodules"
else
  _def_3dfx='#undef HAVE_3DFX'
  _novomodules="3dfx $_novomodules"
fi
echores "$_3dfx"


echocheck "tdfxfb"
if test "$_tdfxfb" = yes ; then
  _def_tdfxfb='#define HAVE_TDFXFB 1'
  _vosrc="$_vosrc vo_tdfxfb.c"
  _vomodules="tdfxfb $_vomodules"
else
  _def_tdfxfb='#undef HAVE_TDFXFB'
  _novomodules="tdfxfb $_novomodules"
fi
echores "$_tdfxfb"


echocheck "DirectFB headers presence"
if test -z "$_inc_directfb" ; then
  for I in /usr/include /usr/local/include; do
    if test -d "$I/directfb" && test -f "$I/directfb/directfb.h" ; then
      _inc_directfb="-I$I/directfb"
      echores "yes (using $_inc_directfb)"
      break
    fi
    if test -d "$I" && test -f "$I/directfb.h" ; then
      _inc_directfb="-I$I"
      echores "yes (using $_inc_directfb)"
      break
    fi
  done
  if test -z "$_inc_directfb" ; then
    _directfb=no
    echores "not found"
  fi
else
  echores "yes (using $_inc_directfb)"
fi
if test "$_inc_directfb" = "-I/usr/include" ; then
  _inc_directfb=""
fi

echocheck "DirectFB"
if test "$_directfb" = auto ; then
  _directfb=no
  cat > $TMPC <<EOF
#include <directfb.h>
int main(void) { IDirectFB *foo; return 0; }
EOF
  linux && test -c /dev/fb0 && cc_check $_inc_directfb -ldirectfb && _directfb=yes
fi

if test "$_directfb" = yes; then
cat > $TMPC <<EOF
#include <directfb.h>
int main(void) { 
  printf ("%i",(directfb_major_version*100+directfb_minor_version)*100+directfb_micro_version);
  return 0; 
}
EOF
  if cc_check $_inc_directfb -ldirectfb && "$TMPO" >> "$TMPLOG" ; then
    _directfb_version=`"$TMPO"`
    _def_directfb_version="#define DIRECTFBVERSION $_directfb_version"
    echores "yes ($_directfb_version)"
  else
    _directfb=no
    echores "no (failed to get version)"
  fi
else
  echores "$_directfb"
fi

if test "$_directfb" = yes ; then
  _def_directfb='#define HAVE_DIRECTFB 1'
  if test "$_directfb_version" -ge 913; then
    _vosrc="$_vosrc vo_directfb2.c"
  else
    _vosrc="$_vosrc vo_directfb.c"
  fi
  _vomodules="directfb $_vomodules"
  _ld_directfb='-ldirectfb'
else
  _def_directfb='#undef HAVE_DIRECTFB'
  _novomodules="directfb $_novomodules"
  _inc_directfb=""
fi


echocheck "X11 headers presence"
if test -z "$_inc_x11" ; then
  for I in /usr/include /usr/include/X11R6 /usr/X11R6/include /usr/X11/include /usr/openwin/include ; do
    if test -d "$I/X11" && test -f "$I/X11/Xlib.h" ; then
      _inc_x11="-I$I"
      echores "yes (using $I)"
      break
    fi
  done
  if test -z "$_inc_x11" ; then
    _x11=no
    echores "not found (check if the dev(el) packages are installed)"
  fi
else
  echores "yes (using $_inc_x11)"
fi
if test "$_inc_x11" = "-I/usr/include" ; then
  _inc_x11=""
fi


echocheck "X11 libs presence"
if test -z "$_ld_x11" ; then
  for I in /usr/X11R6/lib /usr/lib/X11R6 /usr/X11/lib /usr/lib32 /usr/openwin/lib /usr/X11R6/lib64 ; do
    if test -d "$I" && ( test -f "$I/libX11.so" || test -f "$I/libX11.a" ) ; then
      _ld_x11="-L$I"
      echores "yes (using $I)"
      break;
    fi
  done
  if test -z "$_ld_x11" ; then
    _x11=no
    echores "not found (check if the dev(el) packages are installed)"
  fi
else
  echores "yes (using $_ld_x11)"
fi
_ld_x11="$_ld_x11 -lX11 -lXext $_ld_sock"


echocheck "X11"
if test "$_x11" != no ; then
  cat > $TMPC <<EOF
#include <X11/Xlib.h>
#include <X11/Xutil.h>
int main(void) { (void) XCreateWindow(0,0,0,0,0,0,0,0,0,0,0,0); return 0; }
EOF
  _x11=no
  cc_check $_inc_x11 $_ld_x11 && _x11=yes
fi
if test "$_x11" = yes ; then
  _def_x11='#define HAVE_X11 1'
  _vosrc="$_vosrc x11_common.c vo_x11.c"
  _vomodules="x11 $_vomodules"
else
  _def_x11='#undef HAVE_X11'
  _inc_x11=''
  _ld_x11=''
  _novomodules="x11 $_novomodules"
fi
echores "$_x11"


echocheck "DPMS"
_xdpms3=no
if test "$_x11" = yes ; then
  cat > $TMPC <<EOF
#include <X11/Xmd.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/dpms.h>
int main(void) {
  (void) DPMSQueryExtension(0, 0, 0);
}
EOF
  cc_check $_inc_x11 $_ld_x11 -lXdpms && _xdpms3=yes
fi
_xdpms4=no
if test "$_x11" = yes ; then
  cat > $TMPC <<EOF
#include <X11/Xlib.h>
#include <X11/extensions/dpms.h>
int main(void) {
  (void) DPMSQueryExtension(0, 0, 0);
}
EOF
  cc_check $_inc_x11 $_ld_x11 && _xdpms4=yes
fi
if test "$_xdpms4" = yes ; then
  _def_xdpms='#define HAVE_XDPMS 1'
  echores "yes (using Xdpms 4)"
elif test "$_xdpms3" = yes ; then
  _def_xdpms='#define HAVE_XDPMS 1'
  _ld_x11="$_ld_x11 -lXdpms"
  echores "yes (using Xdpms 3)"
else
  _def_xdpms='#undef HAVE_XDPMS'
  echores "no"
fi


echocheck "Xv"
if test "$_x11" = yes && test "$_xv" != no ; then
  cat > $TMPC <<EOF
#include <X11/Xlib.h>
#include <X11/extensions/Xvlib.h>
int main(void) { (void) XvGetPortAttribute(0, 0, 0, 0); return 0; }
EOF
  _xv=no
  cc_check $_inc_x11 $_ld_x11 -lXv && _xv=yes
else
  _xv=no
fi
if test "$_xv" = yes ; then
  _def_xv='#define HAVE_XV 1'
  _ld_xv='-lXv'
  _vosrc="$_vosrc vo_xv.c"
  _vomodules="xv $_vomodules"
else
  _def_xv='#undef HAVE_XV'
  _novomodules="xv $_novomodules"
fi
echores "$_xv"


echocheck "Xinerama"
if test "$_x11" = yes && test "$_xinerama" != no ; then
  cat > $TMPC <<EOF
#include <X11/Xlib.h>
#include <X11/extensions/Xinerama.h>
int main(void) { (void) XineramaIsActive(0); return 0; }
EOF
  _xinerama=no
  cc_check $_inc_x11 $_ld_x11 -lXinerama && _xinerama=yes
else
  _xinerama=no
fi
if test "$_xinerama" = yes ; then
  _def_xinerama='#define HAVE_XINERAMA 1'
  _ld_xinerama='-lXinerama'
else
  _def_xinerama='#undef HAVE_XINERAMA'
fi
echores "$_xinerama"


# Note: the -lXxf86vm library is the VideoMode extension and though it's not
# needed for DGA, AFAIK every distribution packages together with DGA stuffs
# named 'X extensions' or something similar.
# This check may be useful for future mplayer versions (to change resolution)
# If you run into problems, remove '-lXxf86vm'.
echocheck "Xxf86vm"
if test "$_x11" = yes && test "$_vm" != no ; then
  cat > $TMPC <<EOF
#include <X11/Xlib.h>
#include <X11/extensions/xf86vmode.h>
int main(void) { (void) XF86VidModeQueryExtension(0, 0, 0); return 0; }
EOF
  _vm=no
  cc_check $_inc_x11 $_ld_x11 -lXxf86vm && _vm=yes
else
  _vm=no
fi
if test "$_vm" = yes ; then
  _def_vm='#define HAVE_XF86VM 1'
  _ld_vm='-lXxf86vm'
else
  _def_vm='#undef HAVE_XF86VM'
fi
echores "$_vm"


echocheck "DGA"
# Version 2 is preferred to version 1 if available
if test "$_dga" = auto ; then
  cat > $TMPC << EOF
#include <X11/Xlib.h>
#include <X11/extensions/xf86dga.h>
int main (void) { (void) XF86DGASetViewPort(0, 0, 0, 0); return 0; }
EOF
  _dga=no
  cc_check $_inc_x11 $_ld_x11 -lXxf86dga -lXxf86vm && _dga=1

  cat > $TMPC << EOF
#include <X11/Xlib.h>
#include <X11/extensions/xf86dga.h>
int main (void) { (void) XDGASetViewport(0, 0, 0, 0, 0); return 0; }
EOF
  cc_check $_inc_x11 $_ld_x11 -lXxf86dga && _dga=2
fi

_def_dga='#undef HAVE_DGA'
_def_dga2='#undef HAVE_DGA2'
if test "$_dga" = 1 ; then
  _def_dga='#define HAVE_DGA 1'
  _ld_dga='-lXxf86dga'
  _vosrc="$_vosrc vo_dga.c"
  _vomodules="dga $_vomodules"
  echores "yes (using DGA 1.0)"
elif test "$_dga" = 2 ; then
  _def_dga='#define HAVE_DGA 1'
  _def_dga2='#define HAVE_DGA2 1'
  _ld_dga='-lXxf86dga'
  _vosrc="$_vosrc vo_dga.c"
  _vomodules="dga $_vomodules"
  echores "yes (using DGA 2.0)"
elif test "$_dga" = no ; then
  echores "no"
  _novomodules="dga $_novomodules"
else
  die "DGA version must be 1 or 2"
fi


echocheck "OpenGL"
#Note: this test is run even with --enable-gl since we autodetect $_ld_gl
if test "$_x11" = yes && test "$_gl" != no ; then
  cat > $TMPC << EOF
#include <GL/gl.h>
int main(void) { return 0; }
EOF
  _gl=no
  if cc_check $_inc_x11 $_ld_x11 -lGL -lm ; then
    _gl=yes
    _ld_gl="-lGL"
  elif cc_check $_inc_x11 $_ld_x11 -lGL -lm $_ld_pthread ; then
    _gl=yes
    _ld_gl="-lGL $_ld_pthread"
  fi
else
  _gl=no
fi
if test "$_gl" = yes ; then
  _def_gl='#define HAVE_GL 1'
  _vosrc="$_vosrc vo_gl.c vo_gl2.c"
  _vomodules="opengl $_vomodules"
else
  _def_gl='#undef HAVE_GL'
  _novomodules="opengl $_novomodules"
fi
echores "$_gl"


echocheck "/dev/mga_vid"
if test "$_mga" = auto ; then
  _mga=no
  test -c /dev/mga_vid && _mga=yes
fi
if test "$_mga" = yes ; then
  _def_mga='#define HAVE_MGA 1'
  _vosrc="$_vosrc vo_mga.c"
  _vomodules="mga $_vomodules"
else
  _def_mga='#undef HAVE_MGA'
  _novomodules="mga $_novomodules"
fi
echores "$_mga"


# echocheck "syncfb"
# _syncfb=no
# test "$_mga" = yes && _syncfb=yes
# if test "$_syncfb" = yes ; then
#   _def_syncfb='#define HAVE_SYNCFB 1'
#   _vosrc="$_vosrc vo_syncfb.c"
# else
#   _def_syncfb='#undef HAVE_SYNCFB'
# fi
# echores "$_syncfb"


echocheck "xmga"
if test "$_xmga" = auto ; then
  _xmga=no
  test "$_x11" = yes && test "$_mga" = yes && _xmga=yes
fi
if test "$_xmga" = yes ; then
  _def_xmga='#define HAVE_XMGA 1'
  _vosrc="$_vosrc vo_xmga.c"
  _vomodules="xmga $_vomodules"
else
  _def_xmga='#undef HAVE_XMGA'
  _novomodules="xmga $_novomodules"
fi
echores "$_xmga"


echocheck "GGI"
if test "$_ggi" = auto ; then
  cat > $TMPC << EOF
#include <ggi/ggi.h>
int main(void) { return 0; }
EOF
  _ggi=no
  cc_check -lggi && _ggi=yes
fi
if test "$_ggi" = yes ; then
  _def_ggi='#define HAVE_GGI 1'
  _ld_ggi='-lggi'
  _vosrc="$_vosrc vo_ggi.c"
  _vomodules="ggi $_vomodules"
else
  _def_ggi='#undef HAVE_GGI'
  _novomodules="ggi $_novomodules"
fi
echores "$_ggi"


echocheck "AA"
if test "$_aa" = auto ; then
  cat > $TMPC << EOF
#include <aalib.h>
int main(void) { (void) aa_init(0, 0, 0); return 0; }
EOF
  _aa=no
  cc_check  -laa && _aa=yes
fi
if test "$_aa" = yes ; then
  _def_aa='#define HAVE_AA 1'
  _ld_aa='-laa'
  _vosrc="$_vosrc vo_aa.c"
  _vomodules="aa $_vomodules"
else
  _def_aa='#undef HAVE_AA'
  _novomodules="aa $_novomodules"
fi
echores "$_aa"


echocheck "SVGAlib"
if test "$_svga" = auto ; then
  cat > $TMPC << EOF
#include <vga.h>
#include <vgagl.h>
int main(void) { return 0; }
EOF
  _svga=no
  cc_check  -lvgagl -lvga && _svga=yes
fi
if test "$_svga" = yes ; then
  _def_svga='#define HAVE_SVGALIB 1'
  _ld_svga='-lvgagl -lvga'
  _vosrc="$_vosrc vo_svga.c"
  _vomodules="svga $_vomodules"
else
  _def_svga='#undef HAVE_SVGALIB'
  _novomodules="svga $_novomodules"
fi
echores "$_svga"


echocheck "FBDev"
if test "$_fbdev" = auto ; then
  _fbdev=no
  linux && test -c /dev/fb0 && _fbdev=yes
fi
if test "$_fbdev" = yes ; then
  _def_fbdev='#define HAVE_FBDEV 1'
  _vosrc="$_vosrc vo_fbdev.c"
  _vomodules="fbdev $_vomodules"

  if test "$_fbdev_nocopy" = yes ; then
    _def_fbdev_nocopy='#define USE_CONVERT2FB 1'
  fi
else
  _def_fbdev='#undef HAVE_FBDEV'
  _def_fbdev_nocopy='#undef USE_CONVERT2FB'
  _novomodules="fbdev $_novomodules"
fi
echores "$_fbdev"



echocheck "DVB"
if test "$_dvb" != no ; then
  _dvb=no
  test -c /dev/ost/video && _dvb=yes
cat >$TMPC << EOF
#include <sys/poll.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>

#include <ost/dmx.h>
#include <ost/frontend.h>
#include <ost/sec.h>
#include <ost/video.h>
#include <ost/audio.h>
int main(void) {return 0;}
EOF
    if cc_check ; then
        _dvb=yes
        echores "yes"
    else
      for I in "-I/usr/src/DVB/ost/include" "$_inc_extra/ost/include" ; do
        if cc_check "$I" ; then
          _dvb=yes
          _inc_dvb="$I"
          echores "yes (using $_inc_dvb)"
          break
        fi
      done
      test "$_dvb" = no && echores "no (specify path to DVB/ost/include with --with-extraincdir=DIR)"
    fi
else
    echores "no"
fi
if test "$_dvb" = yes ; then
  _def_dvb='#define HAVE_DVB 1'
  _aomodules="mpegpes(dvb) $_aomodules"
  _vomodules="mpegpes(dvb) $_vomodules"
else
  _def_dvb='#undef HAVE_DVB'
  _aomodules="mpegpes(file) $_aomodules"
  _vomodules="mpegpes(file) $_vomodules"  
fi


echocheck "PNG support"
if test "$_png" = auto ; then
  _png=no
  if irix ; then
    # Don't check for -lpng on irix since it has its own libpng
    # incompatible with the GNU libpng
    echores "disabled on irix (not GNU libpng)"
  else
cat > $TMPC << EOF
#include <png.h>
#include <string.h>
int main(void) {
  printf("png.h : %s\n", PNG_LIBPNG_VER_STRING);
  printf("libpng: %s\n", png_libpng_ver);
  return (strcmp(PNG_LIBPNG_VER_STRING, png_libpng_ver));
}
EOF
    if cc_check -lpng -lz -lm ; then
      if "$TMPO" >> "$TMPLOG" ; then
        _png=yes
        echores yes
      else
        echores "no (mismatch of library and header versions)"
      fi
    else
      echores no
    fi
  fi
else
  echores "$_png"
fi
if test "$_png" = yes ; then
  _def_png='#define HAVE_PNG 1'
  _ld_png='-lpng -lz'
  _vosrc="$_vosrc vo_png.c"
  _vomodules="png $_vomodules"
  _mkf_png="yes"
else
  _def_png='#undef HAVE_PNG'
  _novomodules="png $_novomodules"
  _mkf_png="no"
fi

echocheck "JPEG support"
if test "$_jpg" = auto ; then
  _jpg=no
cat > $TMPC << EOF
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <string.h>
#include <jpeglib.h>
int main(void) {
  return 0;
}
EOF
    if cc_check -ljpeg -lm ; then
      if "$TMPO" >> "$TMPLOG" ; then
        _jpg=yes
      fi
    fi
fi
echores "$_jpg"

if test "$_jpg" = yes ; then
  _def_jpg='#define HAVE_JPEG 1'
  _vosrc="$_vosrc vo_jpeg.c"
  _vomodules="jpeg $_vomodules"
  _ld_jpg="-ljpeg"
  _mkf_jpg="yes"
else
  _def_jpg='#undef HAVE_JPEG'
  _novomodules="jpeg $_novomodules"
  _mkf_jpg="no"
fi


echocheck "GIF89a support"
if test "$_gif" = auto ; then
  _gif=no
cat > $TMPC << EOF
#include <gif_lib.h>
int main(void) {
  return 0;
}
EOF
  if cc_check -lgif && "$TMPO" >> "$TMPLOG" ; then
    _gif=yes
    _ld_gif="-lgif"
  elif cc_check -lungif && "$TMPO" >> "$TMPLOG" ; then
    _gif=yes
    _ld_gif="-lungif"
  elif cc_check -lgif $_ld_x11 && "$TMPO" >> "$TMPLOG" ; then
    _gif=yes
    _ld_gif="-lgif $_ld_x11"
  elif cc_check -lungif $_ld_x11 && "$TMPO" >> "$TMPLOG" ; then
    _gif=yes
    _ld_gif="-lungif $_ld_x11"
  fi
fi

if test "$_gif" = yes ; then
  _def_gif='#define HAVE_GIF 1'
  _vosrc="$_vosrc vo_gif89a.c"
  _vomodules="gif89a $_vomodules"
  _mkf_gif="yes"
  _gif="yes (old version, some functions disabled)"
  _def_gif_4='#undef HAVE_GIF_4'

  cat > $TMPC << EOF
#include <signal.h>
#include <gif_lib.h>
void catch() { exit(1); }
int main(void) {
  signal(SIGSEGV, catch);  // catch segfault
  printf("EGifPutExtensionFirst is at address %p\n", EGifPutExtensionFirst);
  EGifSetGifVersion("89a");   // this will segfault a buggy gif lib.
  return 0;
}
EOF
  if cc_check "$_ld_gif" && ( "$TMPO" ) >>"$TMPLOG" 2>&1 ; then
    _def_gif_4='#define HAVE_GIF_4 1'
    _gif="yes"
  fi
else
  _def_gif='#undef HAVE_GIF'
  _def_gif_4='#undef HAVE_GIF_4'
  _novomodules="gif89a $_novomodules"
  _mkf_gif="no"
fi
echores "$_gif"


if test "$_vesa" != no ; then
echocheck "VESA support"
if x86 && linux ; then
  _def_vesa='#define HAVE_VESA 1'
  _vosrc="$_vosrc vo_vesa.c vesa_lvo.c"
  _vomodules="vesa $_vomodules"
  echores "yes"
else
  _def_vesa='#undef HAVE_VESA'
  _novomodules="vesa $_novomodules"
  echores "no (not supported on this OS/architecture)"
fi
else
_def_vesa='#undef HAVE_VESA'
fi


#################
# VIDEO + AUDIO #
#################


echocheck "SDL"
if test -z "$_sdlconfig" ; then
  if ( sdl-config --version ) >>"$TMPLOG" 2>&1 ; then
    _sdlconfig="sdl-config"
  elif ( sdl11-config --version ) >>"$TMPLOG" 2>&1 ; then
    _sdlconfig="sdl11-config"
  else
    _sdlconfig=false
  fi
fi
if test "$_sdl" = auto || test "$_sdl" = yes ; then
  cat > $TMPC << EOF
#include <SDL.h>
int main(int argc, char *argv[]) { return 0; }
EOF
  _sdl=no
  if "$_sdlconfig" --version >>"$TMPLOG" 2>&1 ; then
    if cc_check `$_sdlconfig --cflags` `$_sdlconfig --libs` >>"$TMPLOG" 2>&1 ; then
      _sdlversion=`$_sdlconfig --version | sed 's/[^0-9]//g'`
        if test "$_sdlversion" -gt 116 ; then
          if test "$_sdlversion" -lt 121 ; then
            _def_sdlbuggy='#define BUGGY_SDL'
          else
            _def_sdlbuggy='#undef BUGGY_SDL'
          fi
          _sdl=yes
        else
          _sdl=outdated
        fi
     fi
  fi
fi
if test "$_sdl" = yes ; then
  _def_sdl='#define HAVE_SDL 1'
  _ld_sdl=`$_sdlconfig --libs`
  _inc_sdl=`$_sdlconfig --cflags`
  _vosrc="$_vosrc vo_sdl.c"
  _vomodules="sdl $_vomodules"
  _aosrc="$_aosrc ao_sdl.c"
  _aomodules="sdl $_aomodules"
  echores "yes (using $_sdlconfig)"
else
  _def_sdl='#undef HAVE_SDL'
  _novomodules="sdl $_novomodules"
  _noaomodules="sdl $_noaomodules"
  echores "no"
fi

echocheck "Directx"
if test "$_directx" = auto ; then
  cat > $TMPC << EOF
#include <windows.h>
#include <ddraw.h>
int main(void) { return 0; }
EOF
  _directx=no
  cc_check -mwindows && _directx=yes
fi
if test "$_directx" = yes ; then
  _def_directx='#define HAVE_DIRECTX 1'
  _ld_directx='-mcygwin'
  _vosrc="$_vosrc vo_directx.c"
  _vomodules="directx $_vomodules"
else
  _def_directx='#undef HAVE_DIRECTX'
  _novomodules="directx $_novomodules"
fi
echores "$_directx"

echocheck "NAS"
if test "$_nas" = auto || test "$_nas" = yes ; then
  cat > $TMPC << EOF
#include <audio/audiolib.h>
int main(void) { return 0; }
EOF
  _nas=no
  cc_check -laudio $_inc_x11 $_ld_x11 -lXt -lm && _nas=yes
fi
if test "$_nas" = yes ; then
  _def_nas='#define HAVE_NAS 1'
  _ld_nas="-laudio  $_ld_x11 -lXt"
  _aosrc="$_aosrc ao_nas.c"
  _aomodules="nas $_aomodules"
else
  _noaomodules="nas $_noaomodules"
  _def_nas='#undef HAVE_NAS'
fi
echores "$_nas"

echocheck "DXR2"
if test "$_dxr2" = auto; then
  _dxr2=no
  for _inc_dxr2 in "$_inc_dxr2" \
		   "-I /usr/local/include/dxr2" \
		   "-I /usr/include/dxr2"; do
    cat > $TMPC << EOF
#include <dxr2ioctl.h>
int main(void) { return 0; }
EOF
    cc_check $_inc_dxr2 && _dxr2=yes && break
  done
fi
if test "$_dxr2" = yes; then
  _def_dxr2='#define HAVE_DXR2 1'
  _vosrc="$_vosrc vo_dxr2.c"
  _aosrc="$_aosrc ao_dxr2.c"
  _aomodules="dxr2 $_aomodules"
  _vomodules="dxr2 $_vomodules"
  echores "yes (using $_inc_dxr2)"
else
  _def_dxr2='#undef HAVE_DXR2'
  _noaomodules="dxr2 $_noaomodules"
  _novomodules="dxr2 $_novomodules"
  _inc_dxr2=""
  echores "no"
fi

echocheck "DXR3/H+"
if test "$_dxr3" = auto ; then
  cat > $TMPC << EOF
#include <linux/em8300.h>
int main(void) { return 0; }
EOF
  _dxr3=no
  cc_check && _dxr3=yes
fi
if test "$_dxr3" = yes ; then
  _def_dxr3='#define HAVE_DXR3 1'
  _vosrc="$_vosrc vo_dxr3.c"
  _vomodules="dxr3 $_vomodules"
else
  _def_dxr3='#undef HAVE_DXR3'
  _novomodules="dxr3 $_novomodules"
  if test "$_mp1e" = auto ; then
    # we don't need mp1e
    _mp1e=no
  fi
fi
echores "$_dxr3"

echocheck "libmp1e"
if test "$_mmx" = no ; then
  # mp1e REQUIRES mmx!
  _mp1e=no
fi
if test "$_mp1e" != no ; then
  _mp1e=yes
  _def_mp1e='#define USE_MP1E'
  _ld_mp1e='libmp1e/libmp1e.a'
  _dep_mp1e='libmp1e/libmp1e.a'
else
  _mp1e=no
  _def_mp1e='#undef USE_MP1E'
  _ld_mp1e=""
  _dep_mp1e=''
fi
echores "$_mp1e"


echocheck "libfame"
if test "$_fame" = auto ; then
  _fame=no
  test "$_dxr2" = yes && _fame=auto
  test "$_dxr3" = yes && _fame=auto
  test "$_dvb" = yes && _fame=auto
fi
if test "$_fame" = auto ; then
  _fame=no
  if test -d libfame && test -f libfame/fame.h ; then
    # disable fame on cygwin as no sense to port - atmos	  
    cygwin || _fame=yes
    echores $_fame
  else
    echores "no (no fame dir)"
  fi
else
  echores "$_fame"
fi

_def_fame='#undef USE_LIBFAME'
if test "$_fame" = yes ; then
  _def_fame='#define USE_LIBFAME 1'	
  _ld_fame='libfame/libfame.a'
fi


#########
# AUDIO #
#########


echocheck "OSS Audio"
if test "$_ossaudio" = auto ; then
  cat > $TMPC << EOF
#include <sys/ioctl.h>
$_inc_soundcard
int main(void) { int arg = SNDCTL_DSP_SETFRAGMENT; return 0; }
EOF
  _ossaudio=no
  cc_check && _ossaudio=yes
fi
if test "$_ossaudio" = yes ; then
  _def_ossaudio='#define USE_OSS_AUDIO 1'
  _aosrc="$_aosrc ao_oss.c"
  _aomodules="oss $_aomodules"
  if test "$_linux_devfs" = yes; then
    _def_ossaudio_devdsp='#define PATH_DEV_DSP "/dev/sound/dsp"'
    _def_ossaudio_devmixer='#define PATH_DEV_MIXER "/dev/sound/mixer"'
  else
     if netbsd || openbsd ; then
       _def_ossaudio_devdsp='#define PATH_DEV_DSP "/dev/sound"'
       openbsd && _ld_arch="$_ld_arch -lossaudio"
     else
       _def_ossaudio_devdsp='#define PATH_DEV_DSP "/dev/dsp"'
     fi
    _def_ossaudio_devmixer='#define PATH_DEV_MIXER "/dev/mixer"'
  fi  
else
  _def_ossaudio='#undef USE_OSS_AUDIO'
  _def_ossaudio_devdsp='#define PATH_DEV_DSP ""'
  _def_ossaudio_devmixer='#define PATH_DEV_MIXER ""'
  _noaomodules="oss $_noaomodules"
fi
echores "$_ossaudio"


echocheck "aRts"
if test "$_arts" = auto ; then
  _arts=no
  if ( artsc-config --version ) >> "$TMPLOG" 2>&1 ; then

cat > $TMPC << EOF
#include <artsc.h>
int main(void) { return 0; }
EOF
cc_check `artsc-config --libs` `artsc-config --cflags` && ( "$TMPO" >> "$TMPLOG" 2>&1 ) && _arts=yes

  fi
fi

if test "$_arts" = yes ; then
  _def_arts='#define USE_ARTS 1'
  _aosrc="$_aosrc ao_arts.c"
  _aomodules="arts $_aomodules"
  _ld_arts=`artsc-config --libs`
  _inc_arts=`artsc-config --cflags`
else
  _noaomodules="arts $_noaomodules"
fi
echores "$_arts"


echocheck "ALSA audio"
if test "$_alsa" != no ; then
  _alsa=no
  cat > $TMPC << EOF
#include <sys/asoundlib.h>
int main(void) { return (!(SND_LIB_MAJOR==0 && SND_LIB_MINOR==5)); }
EOF
  cc_check -lasound $_ld_dl $_ld_pthread && $TMPO && _alsaver='0.5.x'

  cat > $TMPC << EOF
#include <sys/asoundlib.h>
int main(void) { return (!(SND_LIB_MAJOR==0 && SND_LIB_MINOR==9)); }
EOF
  cc_check -lasound $_ld_dl $_ld_pthread && $TMPO && _alsaver='0.9.x-sys'
  cat > $TMPC << EOF
#include <alsa/asoundlib.h>
int main(void) { return (!(SND_LIB_MAJOR==0 && SND_LIB_MINOR==9)); }
EOF
  cc_check -lasound $_ld_dl $_ld_pthread && $TMPO && _alsaver='0.9.x-alsa'
fi
_def_alsa5='#undef HAVE_ALSA5'
_def_alsa9='#undef HAVE_ALSA9'
_def_sys_asoundlib_h='#undef HAVE_SYS_ASOUNDLIB_H'
_def_alsa_asoundlib_h='#undef HAVE_ALSA_ASOUNDLIB_H'
if test "$_alsaver" ; then
  if test "$_alsaver" = '0.5.x' ; then
    _aosrc="$_aosrc ao_alsa5.c"
    _aomodules="alsa5 $_aomodules"
    _def_alsa5='#define HAVE_ALSA5 1'
    _def_sys_asoundlib_h='#define HAVE_SYS_ASOUNDLIB_H 1'
    echores "yes (using alsa 0.5.x and sys/asoundlib.h)"
  elif test "$_alsaver" = '0.9.x-sys' ; then
    _aosrc="$_aosrc ao_alsa9.c"
    _aomodules="alsa9 $_aomodules"
    _def_alsa9='#define HAVE_ALSA9 1'
    _def_sys_asoundlib_h='#define HAVE_SYS_ASOUNDLIB_H 1'
    echores "yes (using alsa 0.9.x and sys/asoundlib.h)"
  elif test "$_alsaver" = '0.9.x-alsa' ; then
    _aosrc="$_aosrc ao_alsa9.c"
    _aomodules="alsa9 $_aomodules"
    _def_alsa9='#define HAVE_ALSA9 1'
    _def_alsa_asoundlib_h='#define HAVE_ALSA_ASOUNDLIB_H 1'
    echores "yes (using alsa 0.9.x and alsa/asoundlib.h)"
  fi
  _ld_alsa="-lasound $_ld_dl $_ld_pthread"
else
  _noaomodules="alsa $_noaomodules"
  echores "no"
fi


echocheck "Sun audio"
if test "$_sunaudio" = auto ; then
  cat > $TMPC << EOF
#include <sys/types.h>
#include <sys/audioio.h>
int main(void) { audio_info_t info; AUDIO_INITINFO(&info); return 0; }
EOF
  _sunaudio=no
  cc_check && _sunaudio=yes
fi
if test "$_sunaudio" = yes ; then
  _def_sunaudio='#define USE_SUN_AUDIO 1'
  _aosrc="$_aosrc ao_sun.c"
  _aomodules="sun $_aomodules"
else
  _def_sunaudio='#undef USE_SUN_AUDIO'
  _noaomodules="sun $_noaomodules"
fi
echores "$_sunaudio"


echocheck "Sun mediaLib"
if test "$_mlib" = auto ; then
  _mlib=no
  test -z "$_mlibdir" && _mlibdir=/opt/SUNWmlib
  cat > $TMPC << EOF
#include <mlib.h>
int main(void) { mlib_VideoColorYUV2ABGR420(0,0,0,0,0,0,0,0,0); return 0; }
EOF
  cc_check  -I${_mlibdir}/include -L${_mlibdir}/lib -lmlib && _mlib=yes
fi
if test "$_mlib" = yes ; then
  _def_mlib='#define HAVE_MLIB 1'
  _inc_mlib=" -I${_mlibdir}/include "
  _ld_mlib=" -L${_mlibdir}/lib -R${_mlibdir}/lib -lmlib "
else
  _def_mlib='#undef HAVE_MLIB'
fi
echores "$_mlib"


echocheck "SGI audio"
if test "$_sgiaudio" = auto ; then
  # check for SGI audio
  cat > $TMPC << EOF
#include <dmedia/audio.h>
int main(void) { return 0; }
EOF
  _sgiaudio=no
  cc_check && _sgiaudio=yes
fi
if test "$_sgiaudio" = "yes" ; then
  _def_sgiaudio='#define USE_SGI_AUDIO 1'
  _ld_sgiaudio='-laudio'
  _aosrc="$_aosrc ao_sgi.c"
  _aomodules="sgi $_aomodules"
else
  _def_sgiaudio='#undef USE_SGI_AUDIO'
  _noaomodules="sgi $_noaomodules"
fi
echores "$_sgiaudio"


echocheck "VCD support"
if linux || bsdos || freebsd || netbsd || sunos ; then
  _inputmodules="vcd $_inputmodules"
  _def_vcd='#define HAVE_VCD 1'
  echores "ok"
else
  _def_vcd='#undef HAVE_VCD'
  _noinputmodules="vcd $_noinputmodules"
  echores "not supported on this OS"
fi

echocheck "DVD support (libmpdvdkit)"
if test "$_dvdkit" = auto ; then
 _dvdkit=no
 if linux || freebsd || netbsd || darwin || cygwin || openbsd || sunos || hpux; then
  test -f "./libmpdvdkit2/Makefile" && _dvdkit=yes
  test -f "./libmpdvdkit/Makefile" && _dvdkit=yes
 fi
fi
if test "$_dvdkit" = yes ; then
  if test "$_dvd" = yes || test "$_cdrom" = yes || test "$_cdio" = yes || test "$_dvdio" = yes || test "$_bsdi_dvd" = yes || cygwin; then
   if test -f "./libmpdvdkit2/Makefile" ; then
    _inputmodules="mpdvdkit2 $_inputmodules"
    _dvdread=libmpdvdkit2
    _dvdkit2=yes
    _dvdkit=no
   else
    _inputmodules="mpdvdkit $_inputmodules"
    _dvdread=libmpdvdkit
   fi
  else
    _noinputmodules="mpdvdkit $_noinputmodules"
  fi
  _def_dvd_linux='#undef HAVE_LINUX_DVD_STRUCT'
  _def_dvd_bsd='#undef HAVE_BSD_DVD_STRUCT'
  _dev_dvd_openbsd='#undef HAVE_OPENBSD_DVD_STRUCT'
  if linux || netbsd || openbsd || bsdos ; then
    _def_dvd_linux='#define HAVE_LINUX_DVD_STRUCT 1'
    if openbsd ; then
      _dev_dvd_openbsd='#define HAVE_OPENBSD_DVD_STRUCT 1'
    fi
  else
    if freebsd ; then
     _def_dvd_bsd='#define HAVE_BSD_DVD_STRUCT 1'
    fi
  fi
else
  _noinputmodules="mpdvdkit $_noinputmodules"
fi
if test "$_dvdkit" = yes || test "$_dvdkit2" = yes; then
  echores "yes"
else
  echores "no"
fi  

echocheck "DVD support (libcss - old style)"
if test "$_css" = auto ; then
  cat > $TMPC <<EOF
#include <sys/types.h>
#include <css.h>
int main(void) { (void) CSSisEncrypted(0); return 0; }
EOF
  _css=no
  cc_check -lcss $_ld_dl && _css=yes
fi
if test "$_css" = yes ; then
  _def_css='#define HAVE_LIBCSS 1'
  test "$_csslibdir" && _ld_css="-L${_csslibdir} $_ld_css"
  _inputmodules="dvdcss $_inputmodules"
  _largefiles=yes
  echores "yes"
else
  _def_css='#undef HAVE_LIBCSS'
  _noinputmodules="dvdcss $_noinputmodules"
  echores "no"
fi

echocheck "DVD support (libdvdread - new style)"
if test "$_dvdread" = auto ; then
  cat > $TMPC << EOF
#include <dvdread/dvd_reader.h>
#include <dvdread/ifo_types.h>
#include <dvdread/ifo_read.h>
#include <dvdread/nav_read.h>
int main(void) { return 0; }
EOF
  _dvdread=no
  if test "$_dl" = yes; then
   cc_check  \
     -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -ldvdread $_ld_dl && \
     _dvdread=yes
  fi
fi
_def_mpdvdkit="#undef USE_MPDVDKIT"
case "$_dvdread" in
  yes)
	_largefiles=yes
	_def_dvdread='#define USE_DVDREAD 1'
	_ld_css='-ldvdread'
	_inputmodules="dvdread $_inputmodules"
	echores "yes"
	;;
  no)
	_def_dvdread='#undef USE_DVDREAD'
	_noinputmodules="dvdread $_noinputmodules"
	echores "no"
	;;
  libmpdvdkit)
	_largefiles=yes
	_def_dvdread='#define USE_DVDREAD 1'
	_ld_css='-Llibmpdvdkit -lmpdvdkit'
	_noinputmodules="dvdread $_noinputmodules"
	_def_mpdvdkit="#define USE_MPDVDKIT 1"
	echores "disabled by libmpdvdkit"
	;;
  libmpdvdkit2)
	_largefiles=yes
	_def_dvdread='#define USE_DVDREAD 1'
	_ld_css='-Llibmpdvdkit2 -lmpdvdkit'
	_noinputmodules="dvdread $_noinputmodules"
	_def_mpdvdkit="#define USE_MPDVDKIT 2"
	echores "disabled by libmpdvdkit2"
	;;
esac

echocheck "DVD support (libdvdnav)"
if test "$_dvdnav" = yes ; then
  cat > $TMPC <<EOF
#include <dvdnav.h>
int main(void) { dvdnav_t *dvd=0; return 0; }
EOF
  _dvdnav=no
  test -n "$_dvdnavdir" && _legal_dvdnavdir=-L$_dvdnavdir/.libs
  if test -z "$_dvdnavconfig" ; then
    if ( dvdnav-config --version ) >/dev/null 2>&1 ; then
      _dvdnavconfig="dvdnav-config"
    fi
  fi
  test -z "$_dvdnavdir" && test -n "$_dvdnavconfig" && _dvdnavdir=`$_dvdnavconfig --cflags`
  _used_css=
  test "$_dvdkit" = no && test "$_dvdkit2" = no && _used_css=$_ld_css
  cc_check $_inc_extra -I$_dvdnavdir $_legal_dvdnavdir -ldvdnav $_used_css $_ld_dl && _dvdnav=yes
fi
if test "$_dvdnav" = yes ; then
  _largefiles=yes
  _def_dvdnav='#define USE_DVDNAV 1'
  if test -n "$_legal_dvdnavdir" ; then
   _ld_css="$_ld_css $_legal_dvdnavdir -ldvdnav"
  elif test -n "$_dvdnavconfig" ; then
   _ld_css="$_ld_css `$_dvdnavconfig --libs`"
  else
   _ld_css="$_ld_css -ldvdnav"
  fi
  if test -n "$_dvdnavconfig" ; then
   _dvdnav_version=`$_dvdnavconfig --version | sed "s/\.//g"`
   _def_dvdnav_version="#define DVDNAVVERSION $_dvdnav_version"
  fi
  if test -n "$_dvdnavdir" ; then
   _inc_extra="$_inc_extra -I$_dvdnavdir"
  fi
  _inputmodules="dvdnav $_inputmodules"
  echores "yes"
else
  _def_dvdnav='#undef USE_DVDNAV'
  _noinputmodules="dvdnav $_noinputmodules"
  echores "no"
fi

echocheck "cdparanoia"
if test "$_cdparanoia" = auto ; then
    cat > $TMPC <<EOF
#include <cdda_interface.h>
#include <cdda_paranoia.h>
// This need a better test. How ?
int main(void) { return 1; }
EOF
    _cdparanoia=no
    cc_check $_inc_cdparanoia $_ld_cdparanoia -lcdda_interface -lcdda_paranoia -lm && _cdparanoia=yes
fi
if test "$_cdparanoia" = yes ; then
    _def_cdparanoia='#define HAVE_CDDA'
    _inputmodules="cdda $_inputmodules"
    _ld_cdparanoia="$_ld_cdparanoia -lcdda_interface -lcdda_paranoia"
    openbsd && _ld_cdparanoia="$_ld_cdparanoia -lutil"
else
    _def_cdparanoia='#undef HAVE_CDDA'
    _noinputmodules="cdda $_noinputmodules"
fi
echores "$_cdparanoia"

echocheck "freetype >= 2.0.9"
if test "$_freetype" = yes ; then
    test -z "$_freetypeconfig" && _freetypeconfig='freetype-config'
    if ( $_freetypeconfig --version ) >/dev/null 2>&1 ; then
	cat > $TMPC << EOF
#include <stdio.h>
#include <freetype/freetype.h>
#if ((FREETYPE_MAJOR < 2) || ((FREETYPE_MINOR == 0) && (FREETYPE_PATCH < 9)))
#error "Need FreeType 2.0.9 or newer"
#endif
int main()
{
    FT_Library library;
    FT_Int major=-1,minor=-1,patch=-1;
    int err=FT_Init_FreeType(&library);
    if(err){
	printf("Couldn't initialize freetype2 lib, err code: %d\n",err);
	exit(err);
    }
    FT_Library_Version(library,&major,&minor,&patch); // in v2.1.0+ only :(((
    printf("freetype2  header version: %d.%d.%d  library version: %d.%d.%d\n",
	FREETYPE_MAJOR,FREETYPE_MINOR,FREETYPE_PATCH,
	(int)major,(int)minor,(int)patch );
    if(major!=FREETYPE_MAJOR || minor!=FREETYPE_MINOR){
	printf("Library and header version mismatch! Fix it in your distribution!\n");
	exit(1);
    }
    return 0;
}
EOF
	_freetype=no
	cc_check `$_freetypeconfig --cflags` `$_freetypeconfig --libs` && ( $TMPO >> "$TMPLOG" ) && _freetype=yes
    else
	_freetype=no
    fi
fi
if test "$_freetype" = yes ; then
    _def_freetype='#define HAVE_FREETYPE'
    _inc_freetype=`$_freetypeconfig --cflags`
    _ld_freetype=`$_freetypeconfig --libs`
else
    _def_freetype='#undef HAVE_FREETYPE'
fi
echores "$_freetype"

echocheck "zlib"
cat > $TMPC << EOF
#include <zlib.h>
int main(void) { (void) inflate(0, Z_NO_FLUSH); return 0; }
EOF
_zlib=no
cc_check -lz && _zlib=yes
if test "$_zlib" = yes ; then
  _def_zlib='#define HAVE_ZLIB 1'
  _ld_zlib='-lz'
else
  _def_zlib='#undef HAVE_ZLIB'
fi
echores "$_zlib"


echocheck "RTC"
if linux ; then
  if test "$_rtc" = auto ; then
    cat > $TMPC << EOF
#include <sys/ioctl.h>
#include <linux/rtc.h>
int main(void) { return RTC_IRQP_READ; }
EOF
    _rtc=no
    cc_check && _rtc=yes
  fi
  echores "$_rtc"
else
  _rtc=no
  echores "no (Linux specific feature)"
fi
if test "$_rtc" = yes ; then
  _def_rtc='#define HAVE_RTC 1'
else
  _def_rtc='#undef HAVE_RTC'
fi


echocheck "mad support"
if test "$_mad" = auto ; then
  _mad=no
  cat > $TMPC << EOF
#include <mad.h>
int main(void) { return 0; }
EOF
  cc_check $_madlibdir -lmad && _mad=yes
fi
if test "$_mad" = yes ; then
  _def_mad='#define USE_LIBMAD 1'
  _ld_mad='-lmad'
  _codecmodules="libmad $_codecmodules"
else
  _def_mad='#undef USE_LIBMAD'
  _nocodecmodules="libmad $_nocodecmodules"
fi
echores "$_mad"


echocheck "OggVorbis support"
if test "$_vorbis" = auto ; then
  _vorbis=no
  cat > $TMPC << EOF
#include <vorbis/codec.h>
int main(void) { vorbis_packet_blocksize(0,0); return 0; }
EOF
  cc_check -lvorbis -logg -lm && _vorbis=yes
fi
if test "$_vorbis" = yes ; then
  _def_vorbis='#define HAVE_OGGVORBIS 1'
  _ld_vorbis='-lvorbis -logg'
  _codecmodules="libvorbis $_codecmodules"
else
  _def_vorbis='#undef HAVE_OGGVORBIS'
  _nocodecmodules="libvorbis $_nocodecmodules"
fi
echores "$_vorbis"


echocheck "FAAD (AAC) support"
if test "$_faad" = auto ; then
  _faad=no
  cat > $TMPC << EOF
#include <faad.h>
int main(void) { faacDecHandle testhand; faacDecFrameInfo testinfo; testhand = faacDecOpen(); return 0; }
EOF
  cc_check -lfaad -lm && _faad=yes
fi
if test "$_faad" = yes ; then
  _def_faad='#define HAVE_FAAD 1'
  _ld_faad='-lfaad'
else
  _def_faad='#undef HAVE_FAAD'
fi
echores "$_faad"


echocheck "Win32 DLL support"
qnx && _win32=no
if test "$_win32" = auto ; then
  _win32=no
  if x86 ; then
    if test -z "$_win32libdir" ; then
      for I in "$_libdir/win32" /usr/local/lib/win32 /usr/lib/win32 ; do
        if test -d "$I" ; then
          _win32libdir="$I"
          break;
        fi;
      done
    fi
    test "$_win32libdir" && _win32=yes
  fi
fi
if test "$_win32" = yes ; then
  _def_win32='#define USE_WIN32DLL 1'
  _ld_win32='loader/libloader.a'
  _dep_win32='loader/libloader.a'
  _codecmodules="win32 $_codecmodules"
  echores "yes (using $_win32libdir)"
  if openbsd ; then
    x86 && _ld_win32="$_ld_win32 -li386"
  fi
else
  _def_win32='#undef USE_WIN32DLL'
  _nocodecmodules="win32 $_nocodecmodules"
  _dshow=no
  echores "no"
fi


echocheck "DirectShow"
if false ; then

if test "$_dshow" != no ; then
  _dshow=no
  # check if compiler supports C++ and C++-libs are installed correctly
  cat > "$TMPCPP" << EOF
#include <string>
class myclass {
  private: int ret;
  public: int myreturn(void);
};
int myclass::myreturn(void) { ret = 0; return ret ; }
int main(void) { myclass myobject; return myobject.myreturn(); }
EOF
  echo "------------------------------------------------"  >> "$TMPLOG"
  cat "$TMPCPP" >> "$TMPLOG"
  if ( "$_cc" "$TMPCPP" -o "$TMPO" && "$TMPO" ) >> "$TMPLOG" 2>&1 ; then
    _dshow=yes
    echores "yes (C++ is ok)"
  else
    echores "no"
    cat << EOF

Your C++ runtime environment is broken.

Hints: Does $_cc support C++? Do you have you a C++ compiler installed?
       Are the C++ libraries correctly installed?
       Check for libstdc++ and in (/etc/)ld.so.conf.

If you do not need DirectShow support, you can also use:
  ./configure --disable-dshow <your-normal-configure-options>
to disable building the C++ based DirectShow code.

EOF
    die "$_cc's C++ is broken"
  fi
fi

fi

echores "$_dshow"

if test "$_dshow" = yes ; then
  _def_dshow='#define USE_DIRECTSHOW 1'
  _ld_dshow='loader/dshow/libDS_Filter.a'
  _dep_dshow='loader/dshow/libDS_Filter.a'
  _codecmodules="directshow $_codecmodules"
else
  _def_dshow='#undef USE_DIRECTSHOW'
  _nocodecmodules="directshow $_nocodecmodules"
fi


echocheck "XAnim DLL"
if test "$_xanim" = auto ; then
  _xanim=no
  if test "$_dl" = yes ; then
    if test -z "$_xanimlibdir" ; then
	for I in /usr/local/lib/xanim/mods /usr/lib/xanim/mods /usr/lib/xanim $XANIM_MOD_DIR ; do
          if test -d "$I" ; then
            _xanimlibdir="$I"
            break;
          fi;
        done
    fi
    test "$_xanimlibdir" && _xanim=yes
    if test "$_xanim" = yes ; then
      echores "yes (using $_xanimlibdir)"
    else
      echores "no (no suitable directory found - see DOCS/codecs.html)"
    fi
  else
    echores "no (dynamic loader support needed)"
  fi
else
  echores "$_xanim"
fi
if test "$_xanim" = yes ; then
  _def_xanim='#define USE_XANIM 1'
  _def_xanim_path="#define XACODEC_PATH \"$_xanimlibdir\""
  _codecmodules="xanim $_codecmodules"
else
  _def_xanim='#undef USE_XANIM'
  _def_xanim_path='#undef XACODEC_PATH'
  _nocodecmodules="xanim $_nocodecmodules"
fi

echocheck "RealPlayer DLL"
if test "$_real" = auto ; then
  _real=no
  if test "$_dl" = yes ; then
    if linux || freebsd || netbsd || cygwin ; then
      _real=yes
    else
      echores "no (tested only on Linux/FreeBSD/NetBSD/CygWin)"
    fi
    if test "$_real" = yes ; then
      if test -z "$_reallibdir" ; then
	for I in $_libdir/real /usr/lib/real /usr/lib/RealPlayer*/Codecs \
          /usr/local/RealPlayer*/Codecs /usr/local/lib/RealPlayer*/Codecs; do
          if test -d "$I" ; then
            _reallibdir="$I"
            break;
          fi;
        done
      fi
      test "$_reallibdir" || _real=no
      if test "$_real" = yes ; then
        echores "yes (using $_reallibdir)"
      else
        echores "no (no suitable directory found - see DOCS/codecs.html)"
      fi
    fi
  else
    echores "no (dynamic loader support needed)"
  fi
else
  echores "$_real"
fi
if test "$_real" = yes ; then
  _def_real='#define USE_REALCODECS 1'
  _def_real_path="#define REALCODEC_PATH \"$_reallibdir\""
  _codecmodules="real $_codecmodules"
else
  _def_real='#undef USE_REALCODECS'
  _def_real_path="#undef REALCODEC_PATH"
  _nocodecmodules="real $_nocodecmodules"
fi


if test -z "$_livelibdir" ; then
    for I in $_libdir/live /usr/lib/live /usr/local/lib/live; do
      if test -d "$I" ; then
        _livelibdir="$I"
        break;
      fi;
    done
fi

echocheck "LIVE.COM Streaming Media libraries"
if test "$_live" = auto  && test "$_streaming" = yes ; then
  _live=yes
  test "$_livelibdir" || _live=no
  # TODO: deeper, more reliable test of libs, and version!
  # (users may have empty live/ dir or something different there, for
  # example 'live config files', or they may have old, incompatibel version)
fi
if test "$_live" = yes && test "$_streaming" = yes ; then
  echores "yes (using $_livelibdir)"
  _def_live='#define STREAMING_LIVE_DOT_COM 1'
  _live_libs_def="# LIVE.COM Streaming Media libraries:
LIVE_LIB_DIR = $_livelibdir
LIVE_LIBS =  \$(LIVE_LIB_DIR)/liveMedia/libliveMedia.a
LIVE_LIBS += \$(LIVE_LIB_DIR)/groupsock/libgroupsock.a
LIVE_LIBS += \$(LIVE_LIB_DIR)/UsageEnvironment/libUsageEnvironment.a
LIVE_LIBS += \$(LIVE_LIB_DIR)/BasicUsageEnvironment/libBasicUsageEnvironment.a
LIVE_LIBS += -lstdc++"
  _ld_live='$(LIVE_LIBS)'
else
  echores "no"
  _def_live='#undef STREAMING_LIVE_DOT_COM'
fi


echocheck "iconv"
if test "$_iconv" = auto ; then
  _iconv_tmp='#include <iconv.h>'

  cat > $TMPC << EOF
#include <stdio.h>
#include <unistd.h>
$_iconv_tmp
#define INBUFSIZE 1024
#define OUTBUFSIZE 4096

char inbuffer[INBUFSIZE];
char outbuffer[OUTBUFSIZE];

int main(void) {
  ssize_t numread;
  iconv_t icdsc;
  char *tocode="UTF-8";
  char *fromcode="cp1250";
  if ((icdsc = iconv_open (tocode, fromcode)) != (iconv_t)(-1)) {
    while ((numread = read (0, inbuffer, INBUFSIZE))) {
      char *iptr=inbuffer;
      char *optr=outbuffer;
      size_t inleft=numread;
      size_t outleft=OUTBUFSIZE;
      if (iconv(icdsc, (const char **)&iptr, &inleft, &optr, &outleft)
          != (size_t)(-1)) {
        write (1, outbuffer, OUTBUFSIZE - outleft);
      }
    }
    if (iconv_close(icdsc) == -1)
      ;
  }
}
EOF
  _iconv=no
  if cc_check -lm -liconv ; then
    _iconv=yes
    _ld_iconv='-liconv'
  else
    cc_check -lm && _iconv=yes
  fi
fi
if test "$_iconv" = yes ; then
  _def_iconv='#define USE_ICONV 1'
else
  _def_iconv='#undef USE_ICONV'
fi
echores "$_iconv"


echocheck "FFmpeg libavcodec (static)"
if test "$_libavcodec" = auto ; then
  # Note: static linking is preferred to dynamic linking
  _libavcodec=no
  if test -d libavcodec && test -f libavcodec/utils.c ; then
    if grep avcodec_find_encoder_by_name libavcodec/utils.c > /dev/null 2>&1 ; then
      _libavcodec=yes
      echores "yes"
    else
      echores "no (old ffmpeg version, use CVS !)"
    fi
  else
    echores "no (see DOCS/codecs.html)"
  fi
else
  echores "$_libavcodec"
fi

if test "$_libavcodec" != yes ; then
echocheck "FFmpeg libavcodec (dynamic)"
if test "$_libavcodecso" = auto ; then
  _libavcodecso=no
# FIXME : check for avcodec_find_encoder_by_name() for mencoder
  cat > $TMPC << EOF
#define FF_POSTPROCESS 1 
#include <ffmpeg/avcodec.h>
int quant_store[MBR+1][MBC+1];
int main(void) { 
    avcodec_find_encoder_by_name("");
    return 0; 
}
EOF
  if cc_check -lavcodec -lm ; then
    _libavcodecso=yes
    echores "yes (using libavcodec.so)"
  else
    echores "no (libavcodec.so is broken/obsolete)"
  fi
else
  echores "$_libavcodecso"
fi
fi

_def_libavcodec='#undef USE_LIBAVCODEC'
_def_libavcodecso='#undef USE_LIBAVCODEC_SO'
_def_ffpostprocess='#undef FF_POSTPROCESS'
if test "$_libavcodec" = yes ; then
  _def_libavcodec='#define USE_LIBAVCODEC 1'
  _ld_libavcodec='libavcodec/libavcodec.a'
  _dep_libavcodec='libavcodec/libavcodec.a'
  _def_ffpostprocess='#define FF_POSTPROCESS 1'
  _codecmodules="libavcodec $_codecmodules"
elif test "$_libavcodecso" = yes ; then
  _def_libavcodec='#define USE_LIBAVCODEC 1'
  _def_libavcodecso='#define USE_LIBAVCODEC_SO 1'
  _ld_libavcodec='-lavcodec'
  _def_ffpostprocess='#define FF_POSTPROCESS 1'
  _codecmodules="libavcodec.so $_codecmodules"
else
  _nocodecmodules="libavcodec $_nocodecmodules"
fi

echocheck "libdv-0.9.5 (for mencoder)"
if test "$_libdv" = auto ; then
  _libdv=no
  cat > $TMPC <<EOF
#include <libdv/dv.h>
int main(void) { dv_encoder_t* enc=dv_encoder_new(1,1,1); return 0; }
EOF
  cc_check -ldv -lm && _libdv=yes
fi
if test "$_libdv" = yes ; then
  _def_libdv='#define HAVE_LIBDV095 1'
  _ld_libdv="-ldv"
else
  _def_libdv='#undef HAVE_LIBDV095'
fi
echores "$_libdv"

echocheck "zr"
if test "$_zr" = auto ; then
  #36067's seem to identify themselves as 36057PQC's, so the line 
  #below should work for 36067's and 36057's. 
  if grep -e "Multimedia video controller: Zoran Corporation ZR36057" /proc/pci > /dev/null 2>&1; then
    _zr=yes 
  else
    _zr=no
  fi
fi
if test "$_zr" = yes ; then
  if test "$_libavcodec" = yes ; then
    _def_zr='#define HAVE_ZR 1'
    _vosrc="$_vosrc vo_zr.c jpeg_enc.c"
    _vomodules="zr $_vomodules"
    echores "$_zr"
  else
    echores "libavcodec (static) is required by zr, sorry"
    _novomodules="zr $_novomodules"
    _def_zr='#undef HAVE_ZR'
  fi
else
  _def_zr='#undef HAVE_ZR'
  _novomodules="zr $_novomodules"
  echores "$_zr"
fi

echocheck "bl"
if test "$_bl" = yes ; then
  _def_bl='#define HAVE_BL 1'
  _vosrc="$_vosrc vo_bl.c"
  _vomodules="bl $_vomodules"
else
  _def_bl='#undef HAVE_BL'
  _novomodules="bl $_novomodules"
fi
echores "$_bl"

echocheck "XviD"
cat > $TMPC << EOF
#include <xvid.h>
#include <divx4.h>
int main(void) { xvid_init(0, 0, 0, 0); return 0; }
EOF
if test "$_xvid" != no && cc_check -lm "$_xvidcore" ; then
  _xvid=yes
  _ld_xvid="$_xvidcore"
  _def_xvid='#define HAVE_XVID 1'
  _def_divx4_h='#define HAVE_DIVX4_H 1'
  _codecmodules="xvid $_codecmodules"
elif test "$_xvid" != no && cc_check -lm -lxvidcore ; then
  _xvid=yes
  _ld_xvid='-lxvidcore'
  _def_xvid='#define HAVE_XVID 1'
  _def_divx4_h='#define HAVE_DIVX4_H 1'
  _codecmodules="xvid $_codecmodules"
else
  _xvid=no
  _ld_xvid=''
  _def_xvid='#undef HAVE_XVID'
  _def_divx4_h='#undef HAVE_DIVX4_H'
  _nocodecmodules="xvid $_nocodecmodules"
fi
echores "$_xvid"

_xvidcompat=no
if test "$_xvid" = yes ; then
  echocheck "DivX4 compatibility in XviD"
  cat > $TMPC << EOF
#include <divx4.h>
int main(void) { (void) decore(0, 0, 0, 0); return 0; }
EOF
  cc_check -lm "$_ld_xvid" && _xvidcompat=yes
  echores "$_xvidcompat"
fi

if test "$_xvidcompat" != no ; then
  _divx4linux=no
  _opendivx=no
  _ld_decore=''
  _def_decore='#define NEW_DECORE 1'
  _def_divx='#define USE_DIVX 1'
  _def_divx5='#undef DECORE_DIVX5'
  _def_odivx_postprocess='#undef HAVE_ODIVX_POSTPROCESS'
  _nocodecmodules="opendivx divx5linux divx4linux $_nocodecmodules"
else
echocheck "DivX4linux/DivX5linux/OpenDivX decore"
# DivX5: DEC_OPT_MEMORY_REQS - DivX4: DEC_OPT_FRAME_311
cat > $TMPC << EOF
#include <decore.h>
int main(void) { (void) decore(0, 0, 0, 0);  return DEC_OPT_FRAME_311; }
EOF
if test "$_divx4linux" != no && cc_check -lm -ldivxdecore -lm ; then
  _divx4linux=yes
  _opendivx=no
  _ld_decore='-ldivxdecore'
  _def_decore='#define NEW_DECORE 1'
  _def_divx='#define USE_DIVX'
  _def_divx5='#undef DECORE_DIVX5'
  _def_odivx_postprocess='#undef HAVE_ODIVX_POSTPROCESS'
  _codecmodules="divx4linux $_codecmodules"
  echores "DivX4linux (with libdivxdecore.so)"
elif test "$_divx4linux" != no ; then 
# DivX5 check
# OdivxPP disabled because of:
# ld: Warning: type of symbol `dering' changed from 1 to 2 in opendivx/postprocess.o
cat > $TMPC << EOF
#include <decore.h>
int main(void) { (void) decore(0, 0, 0, 0);  return DEC_OPT_MEMORY_REQS; }
EOF
if cc_check -lm -ldivxdecore -lm ; then
  _divx4linux=yes
  _opendivx=no
#  _ld_decore='-ldivxdecore opendivx/postprocess.o'
  _ld_decore='-ldivxdecore'
  _def_decore='#define NEW_DECORE 1'
  _def_divx='#define USE_DIVX'
  _def_divx5='#define DECORE_DIVX5 1'
#  _def_odivx_postprocess='#define HAVE_ODIVX_POSTPROCESS 1'
  _def_odivx_postprocess='#undef HAVE_ODIVX_POSTPROCESS'
  _codecmodules="divx5linux $_codecmodules"
  _nocodecmodules="divx4linux $_nocodecmodules"
  echores "DivX5linux (with libdivxdecore.so)"
elif test "$_opendivx" != no ; then
  _divx4linux=no
  _opendivx=yes
  _ld_decore='opendivx/libdecore.a'
  _def_decore='#undef NEW_DECORE'
  _def_divx='#define USE_DIVX'
  _def_divx5='#undef DECORE_DIVX5'
  _def_odivx_postprocess='#define HAVE_ODIVX_POSTPROCESS 1'
  _codecmodules="opendivx $_codecmodules"
  _nocodecmodules="divx5linux $_nocodecmodules"
  echores "OpenDivX"
else
  _divx4linux=no
  _opendivx=no
  _ld_decore=''
  _def_decore='#undef NEW_DECORE'
  _def_divx='#undef USE_DIVX'
  _def_divx5='#undef DECORE_DIVX5'
  _def_odivx_postprocess='#undef HAVE_ODIVX_POSTPROCESS'
  _nocodecmodules="opendivx $_nocodecmodules"
  echores "no"
fi # DivX5 check
fi

fi # XviD divx4 compatiblity check

# mencoder requires (optional) those libs: libmp3lame and divx4linux encore
if test "$_mencoder" != no ; then

  echocheck "libmp3lame (for mencoder)"
  _mp3lame=no
  cat > $TMPC <<EOF
#include <lame/lame.h>
int main(void) { (void) lame_init(); return 0; }
EOF
  # Note: libmp3lame usually depends on vorbis
  cc_check -lmp3lame $_ld_vorbis -lm && _mp3lame=yes
  if test "$_mp3lame" = yes ; then
    _def_mp3lame='#define HAVE_MP3LAME 1'
    _ld_mp3lame="-lmp3lame $_ld_vorbis"
  else
    _def_mp3lame='#undef HAVE_MP3LAME'
  fi
  echores "$_mp3lame"


  echocheck "XviD/DivX4linux encore (for mencoder)"
  cat > $TMPC << EOF
#include <encore2.h>
int main(void) { (void) encore(0, 0, 0, 0); return 0; }
EOF
  if test "$_xvid" != no && test "$_xvidcore" && cc_check -lm "$_xvidcore" ; then
    _def_encore='#define HAVE_DIVX4ENCORE 1'
    _ld_encore="$_xvidcore"
    echores "XviD (with $_xvidcore)"
  elif test "$_xvid" != no && cc_check -lm -lxvidcore ; then
    _def_encore='#define HAVE_DIVX4ENCORE 1'
    _ld_encore='-lxvidcore'
    echores "XviD (with libxvidcore.so)"
  elif test "$_divx4linux" != no && cc_check -lm -ldivxencore ; then
    _def_encore='#define HAVE_DIVX4ENCORE 1'
    _ld_encore='-ldivxencore'
    echores "DivX4linux (with libdivxencore.so)"
  else
    _def_encore='#undef HAVE_DIVX4ENCORE'
    echores "no"
  fi
fi

echocheck "mencoder"
_mencoder_flag='#undef HAVE_MENCODER'
if test "$_mencoder" = yes ; then
  _mencoder_flag='#define HAVE_MENCODER'
fi
echores "$_mencoder"

echocheck "fastmemcpy"
# fastmemcpy check is done earlier with tests of CPU & binutils features
if test "$_fastmemcpy" = yes ; then
  _def_fastmemcpy='#define USE_FASTMEMCPY 1'
else
  _def_fastmemcpy='#undef USE_FASTMEMCPY'
fi
echores "$_fastmemcpy"

echocheck "UniquE RAR File Library"
if test "$_unrarlib" = yes ; then
    _def_unrarlib='#define USE_UNRARLIB 1'
else
    _def_unrarlib='#undef USE_UNRARLIB'
fi
echores "$_unrarlib"

echocheck "TV interface"
if test "$_tv" = yes ; then
  _def_tv='#define USE_TV 1'
  _inputmodules="tv $_inputmodules"
else
  _noinputmodules="tv $_noinputmodules"
  _def_tv='#undef USE_TV'
fi
echores "$_tv"

echocheck "*BSD BrookTree 848 TV interface"
if test "$_tv_bsdbt848" = auto ; then
 _tv_bsdbt848=no
 if test "$_tv" = yes ; then
    cat > $TMPC <<EOF
#include <sys/types.h>
#if defined(__NetBSD__)
#include <dev/ic/bt8xx.h>
#else
#include <machine/ioctl_bt848.h>
#endif
int main(void) { return 0; }
EOF
    cc_check && _tv_bsdbt848=yes
 fi
fi
if test "$_tv_bsdbt848" = yes ; then
  _def_tv_bsdbt848='#define HAVE_TV_BSDBT848 1'
  _inputmodules="tv-bsdbt848 $_inputmodules"
else
  _def_tv_bsdbt848='#undef HAVE_TV_BSDBT848'
  _noinputmodules="tv-bsdbt848 $_noinputmodules"
fi
echores "$_tv_bsdbt848"

echocheck "Video 4 Linux TV interface"
if test "$_tv_v4l" = auto ; then
 _tv_v4l=no
 if test "$_tv" = yes && linux ; then
  for I in /dev/video /dev/video? ; do
    if test -c $I ; then
      cat > $TMPC <<EOF
#include <stdlib.h>
#include <linux/videodev.h>
int main(void) { return 0; }
EOF
      cc_check && _tv_v4l=yes
      break
    fi
  done
 fi
fi
if test "$_tv_v4l" = yes ; then
  _def_tv_v4l='#define HAVE_TV_V4L 1'
  _inputmodules="tv-v4l $_inputmodules"
else
  _noinputmodules="tv-v4l $_noinputmodules"
  _def_tv_v4l='#undef HAVE_TV_V4L'
fi
echores "$_tv_v4l"


echocheck "audio select()"
if test "$_select" = no ; then
  _def_select='#undef HAVE_AUDIO_SELECT'
elif test  "$_select" = yes ; then
  _def_select='#define HAVE_AUDIO_SELECT 1'
fi
echores "$_select"


echocheck "streaming"
# FIXME streaming check
if test "$_streaming" != no ; then
  _def_streaming='#define STREAMING 1'
  _ld_streaming="$_ld_sock"
  _inputmodules="network $_inputmodules"
else
  _noinputmodules="network $_noinputmodules"
  _def_streaming='#undef STREAMING'
fi
echores "$_streaming"

# endian testing
echocheck "byte order"
if test "$_big_endian" = auto ; then
  cat > $TMPC <<EOF
#include <inttypes.h>
int main(void) { 
    volatile uint32_t i=0x01234567;
    return (*((uint8_t*)(&i))) == 0x67;
}
EOF
  if cc_check ; then 
    if $TMPO ; then 
      _big_endian=yes
    else
      _big_endian=no
    fi
  else
    echo -n "failed to autodetect byte order, defaulting to "
  fi
fi
if test "$_big_endian" = yes ; then
  _byte_order='Big Endian'
  _def_words_endian='#define WORDS_BIGENDIAN 1'
else
  _byte_order='Little Endian'
  _def_words_endian='#undef WORDS_BIGENDIAN'
fi
echores "$_byte_order"

# --------------- GUI specific tests begin -------------------
echocheck "GUI"
echo "$_gui"
if test "$_gui" = yes ; then

  # Required libraries
  test "$_png" != yes && die "PNG support required for GUI compilation, please install libpng or libpng-dev packages."
  test "$_x11" != yes && die "X11 support required for GUI compilation"

  echocheck "XShape extension"
  _xshape=no
  if test "$_x11" = yes ; then
    cat > $TMPC << EOF
#include <X11/Xlib.h>
#include <X11/Xproto.h>
#include <X11/Xutil.h>
#include <X11/extensions/shape.h>
#include <stdlib.h>
int main(void) {
  char *name = ":0.0";
  Display *wsDisplay;
  int exitvar = 0;
  int eventbase, errorbase;
  if (getenv("DISPLAY"))
    name=getenv("DISPLAY");
  wsDisplay=XOpenDisplay(name);
  if (!XShapeQueryExtension(wsDisplay,&eventbase,&errorbase))
    exitvar=1;
  XCloseDisplay(wsDisplay);
  return exitvar;
}
EOF
    cc_check $_inc_x11 $_ld_x11 && _xshape=yes
  fi
  if test "$_xshape" = yes ; then
    _def_xshape='#define HAVE_XSHAPE 1'
  else
    die "the GUI requires the X11 extension XShape (which was not found)"
  fi
  echores "$_xshape"


  # Check for GTK:
  echocheck "gtk version"
  if test -z "$_gtkconfig" ; then
    if ( gtk-config --version ) >/dev/null 2>&1 ; then
      _gtkconfig="gtk-config"
    elif ( gtk12-config --version ) >/dev/null 2>&1 ; then
      _gtkconfig="gtk12-config"
    else
      die "the GUI requires GTK (which was not found)"
    fi
  fi
  _gtk=`$_gtkconfig --version 2>&1`
  _inc_gtk=`$_gtkconfig --cflags 2>&1`
  _ld_gtk=`$_gtkconfig --libs 2>&1`
  echores "$_gtk (using $_gtkconfig)"

  # Check for GLIB
  echocheck "glib version"
  if test -z "$_glibconfig" ; then
    if ( glib-config --version ) >/dev/null 2>&1 ; then
      _glibconfig="glib-config"
    elif ( glib12-config --version ) >/dev/null 2>&1 ; then
      _glibconfig="glib12-config"
    else
      die "the GUI requires GLIB (which was not found)"
    fi
  fi
  _glib=`$_glibconfig --version 2>&1`
  _inc_glib=`$_glibconfig --cflags 2>&1`
  _ld_glib=`$_glibconfig --libs 2>&1`
  echores "$_glib (using $_glibconfig)"

  _def_gui='#define HAVE_NEW_GUI 1'
  _ld_gui='$(GTKLIB) $(GLIBLIB)'

  echo "Creating Gui/config.mak"
  cat > Gui/config.mak << EOF
# -------- Generated by configure -----------

GTKINC = $_inc_gtk
GTKLIBS = $_ld_gtk
GLIBINC = $_inc_glib
GLIBLIBS = $_ld_glib

EOF

else
  _def_gui='#undef HAVE_NEW_GUI'
fi
# --------------- GUI specific tests end -------------------



#############################################################################

# Checking for CFLAGS
_stripbinaries=yes
if test "$_profile" != "" || test "$_debug" != "" ; then
  CFLAGS="-W -Wall -O2 $_march $_mcpu $_debug $_profile"
  _stripbinaries=no
elif test -z "$CFLAGS" ; then
  if test "$host_arch" != "mips" ; then
    CFLAGS="-O4 $_march $_mcpu -pipe -ffast-math -fomit-frame-pointer"
  else
    CFLAGS="-O4 $_march $_mcpu -ffast-math -fomit-frame-pointer"
  fi
  # always compile with '-g' if .developer:
  if test -f ".developer" ; then
    CFLAGS="-g $CFLAGS"
    _stripbinaries=no
  fi
else
  cat <<EOF

MPlayer compilation will use the CFLAGS set by you, but:

    *** ***  DO NOT REPORT BUGS IF IT DOES NOT COMPILE/WORK!  *** ***

It is strongly recommended to let MPlayer choose the correct CFLAGS!
To do so, execute 'CFLAGS= ./configure <options>'

EOF
fi
if darwin ; then
  # use gnu style cpp on Darwin
  CFLAGS="$CFLAGS -no-cpp-precomp -DSYS_DARWIN"
fi
if hpux ; then
  # use flag for HPUX missing setenv()
  CFLAGS="$CFLAGS -DHPUX"
fi
# Thread support
if linux ; then
  CFLAGS="$CFLAGS -D_REENTRANT"
elif bsd ; then
  # FIXME bsd needs this so maybe other OS'es
  CFLAGS="$CFLAGS -D_THREAD_SAFE"
fi
# 64 bit file offsets?
if test "$_largefiles" = yes || freebsd ; then
  CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
  if test "$_dvdread" = yes ; then
    # dvdread support requires this (for off64_t)
    CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
  fi
fi

echocheck "ftello()"
# if we dont have ftello map it to ftell
cat > $TMPC << EOF
#include <stdio.h>
int main (void) { ftello(stdin); return 0; }
EOF
_ftello=no
cc_check && _ftello=yes
if test "$_ftello" = yes ; then
 _def_ftello='#define HAVE_FTELLO 1'
else
 _def_ftello='#undef HAVE_FTELLO'
fi
echores "$_ftello"

# Determine OS dependent libs
if cygwin ; then
  _confcygwin='TARGET_CYGWIN = yes'
  _def_confwin32='#define WIN32'
  #CFLAGS="$CFLAGS -D__CYGWIN__ -D__CYGWIN_USE_BIG_TYPES__"
  # stat.st_size with BIG_TYPES is broken (not set) ::atmos 
  CFLAGS="$CFLAGS -D__CYGWIN__"
else
  _confcygwin="TARGET_CYGWIN = no"
fi

# Dynamic linking flags 
# (FIXME: 'echocheck "dynamic linking"' above and modify here accordingly)
_ld_dl_dynamic=''
bsd && _ld_dl_dynamic='-rdynamic'
test "$_xanim" = yes && _ld_dl_dynamic='-rdynamic'
test "$_real" = yes && _ld_dl_dynamic='-rdynamic'

_ld_arch="$_ld_arch $_ld_pthread $_ld_dl $_ld_dl_dynamic"
bsdos && _ld_arch="$_ld_arch -ldvd"
if netbsd ; then
  _ld_arch="$_ld_arch -lossaudio"
  x86 && _ld_arch="$_ld_arch -li386"
fi

_def_debug='#undef MP_DEBUG'
test "$_debug" != "" && _def_debug='#define MP_DEBUG 1'

_def_linux='#undef TARGET_LINUX'
linux && _def_linux='#define TARGET_LINUX 1'

# TODO cleanup the vidix stuff here
_def_vidix='#define CONFIG_VIDIX 1'
test "$_vidix" = no && _def_vidix='#undef CONFIG_VIDIX'
if test "$_vidix" = yes && test "$_x11" = yes; then
  _vosrc="$_vosrc vo_xvidix.c"
  _vomodules="xvidix $_vomodules"
else
  _novomodules="xvidix $_novomodules"
fi
echo Checking for vidix ... "$_vidix"

_def_joystick='#undef HAVE_JOYSTICK'
if test "$_joystick" = yes ; then
  if linux ; then
    # TODO add some check
    _def_joystick='#define HAVE_JOYSTICK 1'
  else
    _joystick="no (unsupported under $system_name)"
  fi
fi
echo Checking for joystick ... "$_joystick"

echocheck "lirc"
if test "$_lirc" = auto ; then
  _lirc=no
  if test -c /dev/lirc ; then
      cat > $TMPC <<EOF
#include <lirc/lirc_client.h>
int main(void) { return 0; }
EOF
      cc_check -llirc_client && _lirc=yes
  fi
fi
if test "$_lirc" = yes ; then
  _def_lirc='#define HAVE_LIRC 1'
  _ld_lirc='-llirc_client'
else
  _def_lirc='#undef HAVE_LIRC'
fi
echores "$_lirc"


#############################################################################
echo "Creating config.mak"
cat > config.mak << EOF
# -------- Generated by configure -----------

LANG = C
TARGET_OS = $system_name
DESTDIR =
prefix = \$(DESTDIR)$_prefix
BINDIR = \$(DESTDIR)$_bindir
DATADIR = \$(DESTDIR)$_datadir
MANDIR = \$(DESTDIR)$_mandir
CONFDIR = \$(DESTDIR)$_confdir
LIBDIR = \$(DESTDIR)$_libdir
#AR = ar
CC = $_cc
AWK = $_awk
RANLIB = ranlib
# OPTFLAGS = -O4 $_profile $_debug $_march $_mcpu -pipe -fomit-frame-pointer -ffast-math
OPTFLAGS = $CFLAGS
EXTRA_INC = $_inc_extra $_inc_gtk
WIN32_PATH = -DWIN32_PATH=\\"$_win32libdir\\"
STRIPBINARIES = $_stripbinaries

$_live_libs_def

STREAMING = $_streaming
STREAMING_LIVE_DOT_COM = $_live
STREAMING_LIB = $_ld_streaming $_ld_live
VIDIX = $_vidix

OPENDIVX = $_opendivx

UNRARLIB = $_unrarlib

PNG = $_mkf_png
JPEG = $_mkf_jpg
GIF = $_mkf_gif

EXTRA_LIB = $_ld_extra
Z_LIB =  $_ld_static $_ld_zlib
HAVE_MLIB = $_mlib
STATIC_LIB = $_ld_static

X11_INC = $_inc_x11
X11DIR = $_ld_x11

# for libavcodec:
SRC_PATH=.

# video output
X_LIB = $_ld_x11 $_ld_gl $_ld_dga $_ld_xv $_ld_vm $_ld_xinerama $_ld_mad $_ld_sock
GGI_LIB = $_ld_ggi
MLIB_LIB =  $_ld_mlib
MLIB_INC = $_inc_mlib
DXR2_INC = $_inc_dxr2
DVB_INC = $_inc_dvb
PNG_LIB = $_ld_png
JPEG_LIB = $_ld_jpg
GIF_LIB = $_ld_gif
SDL_LIB = $_ld_sdl
DIRECTX_LIB = $_ld_directx
SVGA_LIB = $_ld_svga
AA_LIB = $_ld_aa

# audio output
ALSA_LIB = $_ld_alsa
NAS_LIB = $_ld_nas
MAD_LIB = $_ld_mad
ARTS_LIB = $_ld_arts
ARTS_INC = $_inc_arts
VORBIS_LIB = $_ld_vorbis
FAAD_LIB = $_ld_faad
SGIAUDIO_LIB = $_ld_sgiaudio

# input
TERMCAP_LIB = $_ld_termcap
LIRC_LIB = $_ld_lirc
CSS_USE = $_css
CSS_LIB = $_ld_css
DVDKIT = $_dvdkit
DVDKIT2 = $_dvdkit2
DVDKIT_SHARED = no
SDL_INC = $_inc_sdl
W32_DEP = $_dep_win32
W32_LIB = $_ld_win32
DS_DEP = $_dep_dshow
DS_LIB = $_ld_dshow
AV_DEP = $_dep_libavcodec
AV_LIB = $_ld_libavcodec
FAME = $_fame
FAME_LIB = $_ld_fame
MP1E_DEP = $_dep_mp1e
MP1E_LIB = $_ld_mp1e
ARCH_LIB =  $_ld_arch $_ld_iconv
DIVX4LINUX = $_divx4linux
XVID = $_xvid
XVID_LIB = $_ld_xvid
DECORE_LIB = $_ld_decore $_ld_libdv
MENCODER = $_mencoder
ENCORE_LIB =  $_ld_encore $_ld_mp3lame
DIRECTFB_INC = $_inc_directfb
DIRECTFB_LIB = $_ld_directfb
CDPARANOIA_INC = $_inc_cdparanoia
CDPARANOIA_LIB = $_ld_cdparanoia
FREETYPE_INC = $_inc_freetype
FREETYPE_LIB = $_ld_freetype

# --- Some stuff for autoconfigure ----
$_target_arch
$_confcygwin
TARGET_CPU=$iproc
TARGET_MMX = $_mmx
TARGET_MMX2 = $_mmx2
TARGET_3DNOW = $_3dnow
TARGET_3DNOWEX = $_3dnowex
TARGET_SSE = $_sse

# --- GUI stuff ---
GTKLIB = $_ld_static $_ld_gtk
GLIBLIB = $_ld_static  $_ld_glib
GTK_LIBS =  $_ld_static $_ld_gui
GUI = $_gui
DEBUG = -DDEBUG

EOF

#############################################################################
echo "Creating config.h"
cat > config.h << EOF
/* -------- This file has been automatically generated by configure ---------
   Note: Any changes in it will be lost when you run configure again. */

/* use GNU internationalization */
$_def_i18n

/* use setlocale() function */
$_def_setlocale

/* Runtime CPU detection */
$_def_runtime_cpudetection

/* "restrict" keyword */
#define restrict $_def_restrict_keyword

#define PREFIX "$_prefix"

/* define this to use simple idct with patched libavcodec */
#define SIMPLE_IDCT 1

#define USE_OSD 1
#define USE_SUB 1

/* enable/disable SIGHANDLER */
$_def_sighandler

/* Toggles debugging informations */
$_def_debug

/* Indicates that Ogle's libdvdread is available for DVD playback */
$_def_dvdread

/* Indicates that dvdread is from libmpdvdkit */
$_def_mpdvdkit

/* Additional options for libmpdvdkit*/
$_def_dvd
$_def_cdrom
$_def_cdio
$_def_dvdio
$_def_bsdi_dvd
$_def_dvd_bsd
$_def_dvd_linux
$_dev_dvd_openbsd
$_def_sol_scsi_h
$_def_hpux_scsi_h
$_def_stddef

/* Common data directory (for fonts, etc) */
#define DATADIR "$_datadir"
#define CONFDIR "$_confdir"
#define LIBDIR "$_libdir"

/* Define this to compile stream-caching support, it can be enabled via
   -cache <kilobytes> */
#define USE_STREAM_CACHE 1

/* Define to include support for XviD/Divx4Linux/OpenDivx */
$_def_divx

/* Define to use the new XviD/DivX4Linux library instead of open source OpenDivX */
/* You have to change DECORE_LIBS in config.mak, too! */
$_def_decore

/* Define if you are using DivX5Linux Decore library */
$_def_divx5

/* Define if you are using XviD library */
$_def_xvid

/* Define if you have divx4.h in place of decore.h */
$_def_divx4_h

/* Define to include support for libdv-0.9.5 */
$_def_libdv

/* If build mencoder */
$_mencoder_flag

/* Indicates if XviD/Divx4linux encore is available
   Note: for mencoder */
$_def_encore

/* Indicates if libmp3lame is available
   Note: for mencoder */
$_def_mp3lame

/* Define libmp1e for realtime mpeg encoding (for DXR3 and DVB cards) */
$_def_mp1e

/* Define this to enable avg. byte/sec-based AVI sync method by default:
   (use -bps or -nobps commandline option for run-time method selection)
   -bps gives better sync for vbr mp3 audio, it is now default */
#define AVI_SYNC_BPS 1

/* Undefine this if you do not want to select mono audio (left or right)
   with a stereo MPEG layer 2/3 audio stream. The command line option
   -stereo has three possible values (0 for stereo, 1 for left-only, 2 for
   right-only), with 0 being the default.
   */
#define USE_FAKE_MONO 1

/* Undefine this if your sound card driver has no working select().
   If you have kernel Oops, player hangups, or just no audio, you should
   try to recompile MPlayer with this option disabled! */
$_def_select

/* define this to use iconv(3) function to codepage conversions */
$_def_iconv

/* define this to use RTC (/dev/rtc) for video timers (LINUX only) */
$_def_rtc

/* set up max. outburst. use 65536 for ALSA 0.5, for others 16384 is enough */
#define MAX_OUTBURST 65536

/* set up audio OUTBURST. Do not change this! */
#define OUTBURST 512

/* Define this if your system has the header file for the OSS sound interface */
$_def_sys_soundcard

/* Define this if your system has the header file for the OSS sound interface
 * in /usr/include */
$_def_soundcard

/* Define this if your system has the sysinfo header */
$_def_sys_sysinfo

/* Define this if your system uses ftello() for off_t seeking */

$_def_ftello
#ifndef HAVE_FTELLO
# define ftello(a) ftell(a)
#endif

/* Define this if your system has the "malloc.h" header file */
$_def_malloc

/* memalign is mapped to malloc if unsupported */
$_def_memalign
#ifndef HAVE_MEMALIGN
# define memalign(a,b) malloc(b)
#endif

/* Define this if your system has the "alloca.h" header file */
$_def_alloca

/* Define this if your system has the "sys/mman.h" header file */
$_def_mman

/* Define this if you have the elf dynamic linker -ldl library */
$_def_dl

/* Define this if you have the kstat kernel statistics library */
$_def_kstat

/* Define this if you have zlib */
$_def_zlib

/* Define this if you have shm support */
$_def_shm

/* Define this if your system has strsep */
$_def_strsep

/* Define this if your system has vsscanf */
$_def_vsscanf

/* LIRC (remote control, see www.lirc.org) support: */
$_def_lirc

/* DeCSS support using libcss */
$_def_css

/* DVD navigation support using libdvdnav */
$_def_dvdnav
$_def_dvdnav_version

/* Define this to enable MPEG 1/2 image postprocessing (requires a FAST CPU!) */
#define MPEG12_POSTPROC 1

/* Define this to enable image postprocessing in libavcodec (requires a FAST CPU!) */
$_def_ffpostprocess

/* Define to include support for OpenDivx postprocessing */
$_def_odivx_postprocess

/* Win32 DLL support */
$_def_win32

/* DirectShow support */
$_def_dshow

/* ffmpeg's libavcodec support (requires libavcodec source) */
$_def_libavcodec
$_def_libavcodecso

/* Use libavcodec's decoders */
#define CONFIG_DECODERS 1
/* Use libavcodec's encoders */
#define CONFIG_ENCODERS 1

/* Use libfame encoder filter */
$_def_fame

/* XAnim DLL support */
$_def_xanim
/* Default search path */
$_def_xanim_path

/* RealPlayer DLL support */
$_def_real
/* Default search path */
$_def_real_path

/* LIVE.COM Streaming Media library support */
$_def_live

/* Use 3dnow/mmxext/sse/mmx optimized fast memcpy() [maybe buggy... signal 4]*/
$_def_fastmemcpy

/* Use unrarlib for Vobsubs */
$_def_unrarlib

/* gui support, please do not edit this option */
$_def_gui

/* Audio output drivers */
$_def_ossaudio
$_def_ossaudio_devdsp
$_def_ossaudio_devmixer
$_def_alsa5
$_def_alsa9
$_def_arts
$_def_sys_asoundlib_h
$_def_alsa_asoundlib_h
$_def_sunaudio
$_def_sgiaudio
$_def_nas

/* Enable fast OSD/SUB renderer (looks ugly, but uses less CPU power) */
#undef FAST_OSD
#undef FAST_OSD_TABLE

/* Enable TV Interface support */
$_def_tv

/* Enable Video 4 Linux TV interface support */
$_def_tv_v4l

/* Enable *BSD BrookTree TV interface support */
$_def_tv_bsdbt848

/* Define if your processor stores words with the most significant
   byte first (like Motorola and SPARC, unlike Intel and VAX).  */
$_def_words_endian

$_def_arch

/* Define this for Cygwin build for win32 */
$_def_confwin32

/* Define this to any prefered value from 386 up to infinity with step 100 */
#define __CPU__ $iproc

$_mp_wordsize

$_def_linux

$_def_vcd

#ifdef sun
#define	DEFAULT_CDROM_DEVICE	"/vol/dev/aliases/cdrom0"
#define DEFAULT_DVD_DEVICE	DEFAULT_CDROM_DEVICE
#elif defined(HPUX)
#define DEFAULT_CDROM_DEVICE    "/dev/cdrom"
#define DEFAULT_DVD_DEVICE     "/dev/dvd"
#elif defined(WIN32)
#define DEFAULT_CDROM_DEVICE    "D:"
#define DEFAULT_DVD_DEVICE	"D:"
#else
#define DEFAULT_CDROM_DEVICE    "/dev/cdrom"
#define DEFAULT_DVD_DEVICE	"/dev/dvd"
#endif


/*----------------------------------------------------------------------------
**
** NOTE: Instead of modifying these definitions here, use the
**       --enable/--disable options of the ./configure script!
**       See ./configure --help for details.
**
*---------------------------------------------------------------------------*/

/* nanosleep support */
$_def_nanosleep

/* termcap flag for getch2.c */
$_def_termcap

/* termios flag for getch2.c */
$_def_termios
$_def_termios_h
$_def_termios_sys_h

/* enable PNG support */
$_def_png

/* enable JPEG support */
$_def_jpg

/* enable GIF support */
$_def_gif
$_def_gif_4

/* enable FreeType support */
$_def_freetype

/* libmad support */
$_def_mad

/* enable OggVorbis support */
$_def_vorbis

/* enable FAAD (AAC) support */
$_def_faad

/* enable streaming */
$_def_streaming

/* define this to use inet_aton() instead of inet_pton() */
$_def_use_aton

/* enables / disables cdparanoia support */
$_def_cdparanoia

/* enables / disables vidix usage */
$_def_vidix

/* enables / disables new input joystick support */
$_def_joystick

/* Extension defines */
$_def_3dnow	// only define if you have 3DNOW (AMD k6-2, AMD Athlon, iDT WinChip, etc.)
$_def_3dnowex	// only define if you have 3DNOWEX (AMD Athlon, etc.)
$_def_mmx	// only define if you have MMX (newer x86 chips, not P54C/PPro)
$_def_mmx2	// only define if you have MMX2 (Athlon/PIII/4/CelII)
$_def_sse	// only define if you have SSE (Intel Pentium III/4 or Celeron II)
$_def_sse2	// only define if you have SSE2 (Intel Pentium 4)

#ifdef HAVE_MMX
#define USE_MMX_IDCT 1
#endif

$_def_mlib  // Sun mediaLib, available only on solaris

/* libmpeg2 uses a different feature test macro for mediaLib */
#ifdef HAVE_MLIB
#define LIBMPEG2_MLIB 1
#endif

/* libvo options */
#define SCREEN_SIZE_X 1
#define SCREEN_SIZE_Y 1
$_def_x11
$_def_xv
$_def_vm
$_def_xinerama
$_def_gl
$_def_dga
$_def_dga2
$_def_sdl
/* defined for SDLlib with keyrepeat bugs (before 1.2.1) */
$_def_sdlbuggy
$_def_directx
$_def_ggi
$_def_3dfx
$_def_tdfxfb
$_def_directfb
$_def_directfb_version
$_def_zr
$_def_bl
$_def_mga
$_def_xmga
$_def_syncfb
$_def_fbdev
$_def_fbdev_nocopy
$_def_dxr2
$_def_dxr3
$_def_dvb
$_def_svga
$_def_vesa
$_def_xdpms
$_def_aa

/* used by GUI: */
$_def_xshape

#if defined(HAVE_GL) || defined(HAVE_X11) || defined(HAVE_XV)
#define X11_FULLSCREEN 1
#endif

EOF

#############################################################################

echo "Creating libvo/config.mak"
_voobj=`echo $_vosrc | sed -e 's/\.c/\.o/g'`
cat > libvo/config.mak << EOF
include ../config.mak
OPTIONAL_SRCS = $_vosrc
OPTIONAL_OBJS = $_voobj
EOF

#############################################################################

echo "Creating libao2/config.mak"
_aoobj=`echo $_aosrc | sed -e 's/\.c/\.o/g'`
cat > libao2/config.mak << EOF
include ../config.mak
OPTIONAL_SRCS = $_aosrc
OPTIONAL_OBJS = $_aoobj
EOF

#############################################################################

echo "Creating help_mp.h"
cat > help_mp.h << EOF
//
// WARNING! This is a generated file. Do NOT edit.
// See the help/ subdir for the editable files.
//
#include "$_mp_help"
EOF

if test $_mp_help != "help/help_mp-en.h"; then
  echo "Adding untranslated messages to help_mp.h"
  echo '// untranslated messages from the english master-file:' >> help_mp.h
  help/help_diff.sh $_mp_help <help/help_mp-en.h >> help_mp.h
fi

#############################################################################

cat << EOF

Config files successfully generated by ./configure !

  Install prefix: $_prefix
  Data directory: $_datadir
  Config direct.: $_confdir

  Byte order: $_byte_order
  Optimizing for: $_optimizing
  
  Enabled optional drivers:
    Input: $_inputmodules
    Codecs: $_codecmodules
    Audio output: $_aomodules
    Video output: $_vomodules
  Disabled optional drivers:
    Input: $_noinputmodules
    Codecs: $_nocodecmodules
    Audio output: $_noaomodules
    Video output: $_novomodules

'config.h' and 'config.mak' contain your configuration options.
Note: If you alter theses files (for instance CFLAGS) MPlayer may no longer
      compile *** DO NOT REPORT BUGS if you tweak these files ***

'make' will now compile MPlayer and 'make install' will install it.
Note: On non-Linux systems you might need to use 'gmake' instead of 'make'.

EOF


if test "$_mtrr" = yes ; then
  echo "Please check mtrr settings at /proc/mtrr (see DOCS/video.html#mtrr)"
  echo
fi

if test "$_sdl" = "outdated" ; then
  cat <<EOF
You have an outdated version of libSDL installed (older than v1.1.7) and SDL
support has therefore been disabled.

Please upgrade to a more recent version (version 1.1.8 and above are known to
work). You may get this library from: http://www.libsdl.org

You need to rerun ./configure and recompile after updating SDL.  If you are
only interested in the libSDL audio drivers, then an older version might work.

Use --enable-sdl to force usage of libSDL.

EOF
fi

if x86 ; then
  if test "$_win32" = no ; then
    if test "$_win32libdir" ; then
      cat <<EOF
Failed to find a WIN32 codecs dir at $_win32libdir!
Create it and copy the DLL files there! (You can get them from your windows
directory or download them from:
  ftp://ftp.MPlayerHQ.hu/MPlayer/releases/w32codec.zip

EOF
    fi
  else
    if test "$_win32libdir" ; then
#      echo "Ok, found Win32 codecs directory at $_win32libdir."
      :
    else
      cat <<EOF
Failed to find a WIN32 codecs directory!
Create it and copy the DLL files there! (You can get them from your Windows
directory or download them from:
  ftp://ftp.MPlayerHQ.hu/MPlayer/releases/w32codec.zip

EOF
    fi
  fi
else
  cat <<EOF
NOTE: WIN32 codec DLLs are not supported on your CPU ($host_arch).
You may encounter a few AVI files that cannot be played due to missing
open source video/audio codec support.

EOF
fi


cat <<EOF

Check $TMPLOG if you wonder why an autodetection failed (check whether the
development headers/packages are installed).

If you suspect a bug, please read DOCS/bugreports.html.

EOF

if test "$_vidix" = no ; then
cat <<EOF
You've disabled VIDIX. Although it would be better to PORT it instead.
Have a look at the documentation for supported cards!

EOF
fi

# Last move:
rm -f "$TMPO" "$TMPC" "$TMPS" "$TMPCPP"