~ubuntu-dev/mplayer/ubuntu-feisty

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
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
#! /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
#
#
# This configure script is *not* autoconf-based and has different semantics.
# It attempts to autodetect all settings and options where possible. It is
# possible to override autodetection with the --enable-option/--disable-option
# command line parameters.  --enable-option forces the option on skipping
# autodetection. Yes, this means that compilation may fail and yes, this is not
# how autoconf-based configure scripts behave.
#
# configure generates a series of configuration files:
#  - config.h contains #defines that are used in the C code.
#  - config.mak is included from the Makefiles.
#
# If you want to add a new check for $feature, here is a simple skeleton:
#
# echocheck "$feature"
# if "$_feature" = auto; then
# cat > $TMPC << EOF
# #include <feature.h>
# int main(void) { return 0; }
# EOF
# _feature=no
# cc_check && _feature=yes
# if test "$_feature" = yes ; then
#   _def_feature='#define HAVE_FEATURE 1'
# else
#   _def_feature='#undef HAVE_FEATURE'
# fi
# echores "$_feature"
#
# Furthermore you need to add the variable _feature to the list of default
# settings and set it to one of yes/no/auto. Also add appropriate
# --enable-feature/--disable-feature command line options.
# The results of the check should be written to config.h and config.mak
# at the end of this script. The variable names used for this should be
# uniform, i.e. if the option is named 'feature':
#
# _feature     : should have a value of yes/no/auto
# _def_feature : '#define ... 1' or '#undef ...' for conditional compilation
# _ld_feature  : '-L/path/dir -lfeature' GCC options
#
#############################################################################

# Prevent locale nonsense from breaking basic text processing utils
LC_ALL=C
export LC_ALL

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

cc_check() {
  compile_check $TMPC $@
}

cxx_check() {
  compile_check $TMPCPP $@ -lstdc++
}

tmp_run() {
  "$TMPO" >> "$TMPLOG" 2>&1
}

# 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 "$?" ; }
aix()     { issystem "AIX"     ; 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 "$?" ; }
gnu()     { issystem "GNU"     ; return "$?" ; }
mingw32() { issystem "MINGW32" ; return "$?" ; }
morphos() { issystem "MorphOS" ; return "$?" ; }
win32()   { cygwin || mingw32  ; return "$?" ; }
beos()    { issystem "BEOS"    ; 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
}

x86_64() {
  case "$host_arch" in
    x86_64|amd64) return 0 ;;
    *) return 1 ;;
  esac
}

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

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

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

# not boolean test: implement the posix shell "!" operator for a
# non-posix /bin/sh.
#   usage:  not {command}
# returns exit status "success" when the execution of "command"
# fails.
not() {
  eval "$@"
  test $? -ne 0
}

# 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() {
  if test "$_res_comment" ; then
    _res_comment="($_res_comment)"
  fi
  echo "Result is: $@ $_res_comment" >> "$TMPLOG"
  echo "##########################################" >> "$TMPLOG"
  echo "" >> "$TMPLOG"
  echo "$@ $_res_comment"
  _res_comment=""
}
#############################################################################

# 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/help_mp-\(..\).h:\1:g" | sed "s:help/help_mp-\(.....\).h:\1:g"`

show_help(){
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
                         [PREFIX/etc/mplayer]
  --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+ GUI) [disable]
  --enable-gtk1          force using GTK 1.2 for 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]
  --enable-termios       use termios database for key codes [autodetect]
  --disable-iconv        do not use iconv(3) function [autodetect]
  --disable-langinfo     do not use langinfo [autodetect]
  --enable-lirc          enable LIRC (remote control) support [autodetect]
  --enable-lircc         enable LIRCCD (LIRC client daemon) input [autodetect]
  --enable-joystick      enable joystick support [disable]
  --disable-vm           disable support X video mode extensions [autodetect]
  --disable-xf86keysym   disable support for 'multimedia' keys [autodetect]
  --enable-radio         enable Radio Interface [disable]
  --enable-radio-capture enable Capture for Radio Interface (through pci/line-in) [disable]
  --disable-radio-v4l2   disable Video4Linux2 Radio Interface support [autodetect]
  --disable-tv           disable TV Interface (tv/dvb grabbers) [enable]
  --disable-tv-v4l1      disable Video4Linux TV Interface support [autodetect]
  --disable-tv-v4l2      disable Video4Linux2 TV Interface support [autodetect]
  --disable-tv-bsdbt848  disable BSD BT848 Interface support [autodetect]
  --disable-pvr          disable Video4Linux2 MPEG PVR support [autodetect]
  --disable-rtc          disable RTC (/dev/rtc) on Linux [autodetect]
  --disable-network      disable network support (for: http/mms/rtp) [enable]
  --enable-winsock2      enable winsock2 usage [autodetect]
  --enable-smb           enable Samba (SMB) input support [autodetect]
  --enable-live          enable LIVE555 Streaming Media support [autodetect]
  --disable-dvdnav       disable libdvdnav support [autodetect]
  --disable-dvdread      Disable libdvdread support [autodetect]
  --disable-mpdvdkit     Disable mpdvdkit2 support [autodetect]
  --disable-cdparanoia   Disable cdparanoia support [autodetect]
  --disable-bitmap-font  Disable bitmap font support [enable]
  --disable-freetype     Disable freetype2 font rendering support [autodetect]
  --disable-fontconfig   Disable fontconfig font lookup support [autodetect]
  --disable-unrarlib     Disable Unique RAR File Library [enabled]
  --enable-menu          Enable OSD menu support (NOT DVD MENU) [disabled]
  --disable-sortsub      Disable subtitles sorting [enabled]
  --enable-fribidi       Enable using the FriBiDi libs [autodetect]
  --disable-enca         Disable using ENCA charset oracle library [autodetect]
  --disable-macosx       Disable Mac OS X specific features [autodetect]
  --disable-maemo        Disable maemo specific features [autodetect]
  --enable-macosx-finder-support  Enable Mac OS X Finder invocation parameter parsing [disabled]
  --enable-macosx-bundle Enable Mac OS X bundle file locations [autodetect]
  --disable-inet6        Disable IPv6 support [autodetect]
  --disable-gethostbyname2  gethostbyname() function is not provided by the C
                            library [autodetect]
  --disable-ftp          Disable ftp support [enabled]
  --disable-vstream      Disable tivo vstream client support [autodetect]
  --disable-pthreads     Disable Posix threads support [autodetect]
  --disable-ass          Disable internal SSA/ASS subtitles support [autodetect]
  --enable-rpath         Enable runtime linker path for extra libs [disabled]

Codecs:
  --enable-gif		 enable gif support [autodetect]
  --enable-png		 enable png input/output support [autodetect]
  --enable-jpeg		 enable jpeg input/output support [autodetect]
  --enable-libcdio	 enable external libcdio support [autodetect]
  --enable-liblzo	 enable external liblzo support [autodetect]
  --disable-win32        disable Win32 DLL support [autodetect]
  --disable-qtx          disable Quicktime codecs [autodetect]
  --disable-xanim        disable XAnim DLL support [autodetect]
  --disable-real         disable RealPlayer DLL support [autodetect]
  --disable-xvid         disable XviD codec [autodetect]
  --disable-x264         disable H.264 encoder [autodetect]
  --disable-nut          disable libnut demuxer [autodetect]
  --disable-libavutil    disable libavutil [autodetect]
  --disable-libavcodec   disable libavcodec [autodetect]
  --disable-libavformat  disable libavformat [autodetect]
  --disable-libpostproc  disable libpostproc [autodetect]
  --disable-libavutil_so   disable shared libavutil [autodetect]
  --disable-libavcodec_so  disable shared libavcodec [autodetect]
  --disable-libavformat_so disable shared libavformat [autodetect]
  --disable-libpostproc_so disable shared libpostproc [autodetect]
  --disable-libavcodec_mpegaudio_hp disable high precision audio decoding
                                    in libavcodec [enabled]
  --enable-libfame       enable libfame realtime encoder [autodetect]
  --disable-tremor-internal do not build internal Tremor support [enabled]
  --enable-tremor-low    build with lower accuracy internal Tremor [disabled]
  --enable-tremor-external build with external Tremor [autodetect]
  --disable-libvorbis    disable libvorbis support [autodetect]
  --disable-speex        disable Speex support [autodetect]
  --enable-theora        build with OggTheora support [autodetect]
  --enable-faad-external build with external FAAD2 (AAC) support [autodetect]
  --disable-faad-internal disable internal FAAD2 (AAC) support [autodetect]
  --enable-faad-fixed    enable fixed-point mode in internal FAAD2 [disabled]
  --disable-faac         disable support for FAAC (AAC encoder) [autodetect]
  --disable-ladspa       disable LADSPA plugin support [autodetect]
  --disable-libdv        disable libdv 0.9.5 en/decoding support [autodetect]
  --disable-mad          disable libmad (MPEG audio) support [autodetect]
  --disable-toolame      disable Toolame (MPEG layer 2 audio) support in mencoder [autodetect]
  --disable-twolame      disable Twolame (MPEG layer 2 audio) support in mencoder [autodetect]
  --enable-xmms          build with XMMS inputplugin support [disabled]
  --disable-mp3lib       disable builtin mp3lib [enabled]
  --disable-liba52       disable builtin liba52 [enabled]
  --enable-libdts        enable libdts support [autodetect]
  --disable-libmpeg2     disable builtin libmpeg2 [enabled]
  --disable-musepack     disable musepack support [autodetect]
  --disable-amr_nb       disable amr narrowband, floating point [autodetect]
  --disable-amr_nb-fixed disable amr narrowband, fixed point [autodetect]
  --disable-amr_wb       disable amr wideband, floating point [autodetect]
  --disable-decoder=DECODER disable specified FFmpeg decoder
  --enable-decoder=DECODER  enable specified FFmpeg decoder
  --disable-encoder=ENCODER disable specified FFmpeg encoder
  --enable-encoder=ENCODER  enable specified FFmpeg encoder
  --disable-parser=PARSER   disable specified FFmpeg parser
  --enable-parser=PARSER    enable specified FFmpeg parser
  --disable-demuxer=DEMUXER disable specified FFmpeg demuxer
  --enable-demuxer=DEMUXER  enable specified FFmpeg demuxer
  --disable-muxer=MUXER     disable specified FFmpeg muxer
  --enable-muxer=MUXER      enable specified FFmpeg muxer
  
Video output:
  --disable-vidix-internal disable internal VIDIX [for x86 *nix]
  --disable-vidix-external disable external VIDIX [for 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-caca          build with CACA render support [autodetect]
  --enable-ggi           build with GGI render support [autodetect]
  --enable-ggiwmh        build with GGI libggiwmh extension [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-ivtv          build with IVTV TV-Out render support [autodetect]
  --enable-dvb           build with support for output via DVB-Card [autodetect]
  --enable-dvbhead       build with DVB support (HEAD version) [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-xvmc          build with XvMC acceleration for X 4.x [disable]
  --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-xshape        build with XShape support [autodetect]
  --enable-fbdev         build with FBDev render support [autodetect]
  --enable-mlib          build with mediaLib support (Solaris only) [disable]
  --enable-3dfx          build with obsolete /dev/3dfx support [disable]
  --enable-tdfxfb        build with tdfxfb (Voodoo 3/banshee) support [disable]
  --enable-s3fb          build with s3fb (S3 ViRGE) 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]
  --enable-tdfxvid       build with tdfx_vid support [disable]
  --disable-tga          disable targa output support [enable]
  --disable-pnm		 disable pnm output support [enable]
  --disable-md5sum	 disable md5sum output support [enable]
  
Audio output:
  --disable-alsa         disable ALSA sound support [autodetect]
  --disable-ossaudio     disable OSS sound support [autodetect]
  --disable-arts         disable aRts sound support [autodetect]
  --disable-esd          disable esd sound support [autodetect]
  --disable-pulse        disable PulseAudio sound support [autodetect]
  --disable-jack         disable JACK sound support [autodetect]
  --disable-openal       disable OpenAL sound support [autodetect]
  --disable-nas          disable NAS sound support [autodetect]
  --disable-sgiaudio     disable SGI sound support [autodetect]
  --disable-sunaudio     disable Sun sound support [autodetect]
  --disable-win32waveout disable Windows waveout sound support [autodetect]
  --disable-select       disable using select() on audio device [enable]

Miscellaneous options:
  --enable-runtime-cpudetection    Enable runtime CPU detection [disable]
  --enable-cross-compile Enable cross-compilation [autodetect]
  --cc=COMPILER          use this C compiler to build MPlayer [gcc]
  --host-cc=COMPILER     use this C compiler to build apps needed for the build process [gcc]
  --as=ASSEMBLER         use this assembler to build MPlayer [as]
  --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"
  --charset              convert the help messages to this charset
  --language=list        a white space or comma separated list of languages
                         for translated man pages, the first language is the
                         primary and therefore used for translated messages
                         and GUI (also the environment variable \$LINGUAS is
                         honored) [en]
                         (Available: $LANGUAGES all)
  --with-install=PATH    use a custom install program (useful if your OS uses 
                         a GNU-incompatible install utility by default and 
                         you want to use GNU version)
  --install-path=PATH    the path to a custom install program 
                         this option is obsolete and will be removed soon,
                         use --with-install instead.

Advanced options:
  --enable-mmx           build with MMX support [autodetect]
  --enable-mmxext        build with MMX2 support (PIII, Athlon) [autodetect]
  --enable-3dnow         build with 3DNow! support [autodetect]
  --enable-3dnowext      build with extended 3DNow! support [autodetect]
  --enable-sse           build with SSE support [autodetect]
  --enable-sse2          build with SSE2 support [autodetect]
  --enable-shm           build with shm support [autodetect]
  --enable-altivec       build with Altivec support (PowerPC) [autodetect]
  --enable-armv5te       build with DSP extensions support (ARM) [autodetect]
  --enable-iwmmxt        build with iWMMXt support (ARM) [autodetect]
  --disable-fastmemcpy   disable 3DNow!/SSE/MMX optimized memcpy() [enable]
  --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-crash-debug   enable automatic gdb attach on crash [disable]
  --enable-dynamic-plugins  Enable support for dynamic a/v plugins [disable]

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

Use these options if autodetection fails (Options marked with (*) accept
multiple paths separated by ':'):
  --with-extraincdir=DIR   extra headers (png, mad, sdl, ...) in DIR (*)
  --with-extralibdir=DIR   extra linker search paths in DIR (*)
  --extra-libs=FLAGS       extra linker flags
  --with-x11libdir=DIR     X library files in DIR (*)
  --with-mliblibdir=DIR    libmlib (mediaLib support) in DIR (Solaris only)
  --with-codecsdir=DIR     Binary codec files 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-xvidlibdir=DIR    libxvidcore (XviD) in DIR  (*)
  --with-x264libdir=DIR    libx264 in DIR
  --with-libdtslibdir=DIR  libdts library in DIR  (*)
  --with-livelibdir=DIR    LIVE555 Streaming Media libraries in DIR
  --with-toolamelibdir=DIR Toolame library in DIR
  --with-xmmsplugindir=DIR XMMS plugins in DIR
  --with-xmmslibdir=DIR    libxmms.so.1 in DIR
  --with-cdparanoialibdir=DIR  cdparanoia libraries (libcdda_*) in DIR (*)
  --with-xvmclib=NAME      name of adapter-specific library (e.g. XvMCNVIDIA)

  --with-freetype-config=PATH path to freetype-config
                              (e.g. /opt/bin/freetype-config)
  --with-fribidi-config=PATH  path to fribidi-config
                              (e.g. /opt/bin/fribidi-config)
  --with-glib-config=PATH  path to glib*-config (e.g. /opt/bin/glib-config)
  --with-gtk-config=PATH   path to gtk*-config (e.g. /opt/bin/gtk-config)
  --with-sdl-config=PATH   path to sdl*-config (e.g. /opt/bin/sdl-config)
  --with-dvdnav-config=PATH path to dvdnav-config (e.g. /opt/bin/dvdnav-config)

This configure script is NOT autoconf-based, even though its output is similar.
It will try to autodetect all configuration options. If you --enable an option
it will be forcefully turned on, skipping autodetection. This can break
compilation, so you need to know what you are doing.
EOF
exit 0
} #show_help()

for parm in "$@" ; do
  case $parm in
    --help|-help|-h)
      show_help
  esac
done

# 1st pass checking for vital options
_mmx=auto
_3dnow=auto
_3dnowext=auto
_mmxext=auto
_sse=auto
_sse2=auto
_armv5te=auto
_iwmmxt=auto
_mtrr=auto
_install=install
_ranlib=ranlib
_cc=cc
test "$CC" && _cc="$CC"
_gcc_check=yes
_as=auto
_runtime_cpudetection=no
_cross_compile=auto
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`
    ;;
  --host-cc=*)
    _host_cc=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --as=*)
    _as=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --enable-gcc-check)
    _gcc_check=yes
    ;;
  --disable-gcc-check)
    _gcc_check=no
    ;;
  --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'`
    ;;
  --extra-libs=*)
    _extra_libs=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --enable-runtime-cpudetection)
    _runtime_cpudetection=yes
    ;;
  --disable-runtime-cpudetection)
    _runtime_cpudetection=no
    ;;
  --enable-cross-compile)
    _cross_compile=yes
    ;;
  --disable-cross-compile)
    _cross_compile=no
    ;;
  --install-path=*)
    _install=`echo $ac_option | cut -d '=' -f 2 | sed 's/\/$//'`"/install"
    ;;
  --with-install=*)
    _install=`echo $ac_option | cut -d '=' -f 2 `
    ;;
  --enable-profile)
    _profile='-p'
    ;;
  --disable-profile)
    _profile=
    ;;
  --enable-debug)
    _debug='-g'
    ;;
  --enable-debug=*)
    _debug=`echo $_echo_n '-g'$_echo_c; echo $ac_option | cut -d '=' -f 2`
    ;;
  --disable-debug)
    _debug=
    ;;
  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|GNU|BeOS|MorphOS|AIX)
    ;;
  IRIX*)
    system_name=IRIX
    ;;
  HP-UX*)
    system_name=HP-UX
    ;;
  [cC][yY][gG][wW][iI][nN]*)
    system_name=CYGWIN
    ;;
  MINGW32*)
    system_name=MINGW32
    ;;
  *)
    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|vax)
     ;;
   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|BePC) host_arch=i386 ;;
      ia64) host_arch=ia64 ;;
      x86_64|amd64)
        if [ -n "`$_cc -dumpmachine | sed -n '/^x86_64-/p;/^amd64-/p'`" -a \
             -z "`echo $CFLAGS | grep -- -m32`"  ]; then
          host_arch=x86_64
        else
          host_arch=i386
        fi
      ;;
      macppc|ppc|ppc64) host_arch=ppc ;;
      alpha) host_arch=alpha ;;
      sparc) host_arch=sparc ;;
      sparc64) host_arch=sparc64 ;;
      parisc*|hppa*|9000*) host_arch=hppa ;;
      arm*|zaurus|cats) host_arch=arm ;;
      s390) host_arch=s390 ;;
      s390x) host_arch=s390x ;;
      mips*) host_arch=mips ;;
      vax) host_arch=vax ;;
      *) host_arch=UNKNOWN ;;
    esac
    ;;
  esac
else # if test -z "$_target"
  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 ;;
    morphos) system_name=MorphOS ;;
    mingw32msvc) system_name=MINGW32 ;;
  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

_ldd=ldd
if darwin; then
  _ldd="otool -L"
fi

if aix ; then
  _ld_libC="-lC"
else
  _ld_libC=""
fi

# Check how to call 'head' and 'tail'. Newer versions spit out warnings
# if used as 'head -1' instead of 'head -n 1', but older versions don't
# know about '-n'.
if test "`(echo line1 ; echo line2) | head -1 2>/dev/null`" = "line1" ; then
  _head() { head -$1 2>/dev/null ; }
else
  _head() { head -n $1 2>/dev/null ; }
fi
if test "`(echo line1 ; echo line2) | tail -1 2>/dev/null`" = "line2" ; then
  _tail() { tail -$1 2>/dev/null ; }
else
  _tail() { tail -n $1 2>/dev/null ; }
fi

# Checking CC version...
if test "$_gcc_check" = yes ; then
 # Intel C++ Compilers (no autoselect, use CC=/some/binary ./configure)
 if test "`basename $_cc`" = "icc" || test "`basename $_cc`" = "ecc"; then
  echocheck "$_cc version"
  cc_vendor=intel
  cc_name=`$_cc -V 2>&1 | _head 1 | cut -d ',' -f 1`
  cc_version=`$_cc -V 2>&1 | _head 1 | cut -d ',' -f 2 | cut -d ' ' -f 3`
  _cc_major=`echo $cc_version | cut -d '.' -f 1`
  _cc_minor=`echo $cc_version | cut -d '.' -f 2`
  # TODO verify older icc/ecc compatibility
  case $cc_version in
    '')
      cc_version="v. ?.??, bad"
      cc_verc_fail=yes
      ;;
    8.0)
      cc_version="$cc_version, ok"
      cc_verc_fail=no
      ;;
    *)
      cc_version="$cc_version, bad"
      cc_verc_fail=yes
      ;;
  esac
  echores "$cc_version"
 else
 for _cc in "$_cc" gcc gcc-3.4 gcc-3.3 gcc-3.2 gcc-3.1 gcc3 gcc-3.0 cc ; do
  echocheck "$_cc version"
  cc_vendor=gnu
  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][-.]*|[3-4].*)
      _cc_major=`echo $cc_version | cut -d '.' -f 1`
      _cc_minor=`echo $cc_version | cut -d '.' -f 2`
      _cc_mini=`echo $cc_version | cut -d '.' -f 3`
      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 
 fi # icc
  if test "$cc_verc_fail" = yes ; then
    cat <<EOF

*** Please downgrade/upgrade C compiler to version gcc-2.95, 3.x or 4.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-check but DO *NOT* REPORT BUGS
unless you can reproduce them after recompiling with a 2.95.x or 3/4.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/HTML/en/users-vs-dev.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 read DOCS/HTML/en/users-vs-dev.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/HTML/en/bugreports.html !

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

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

EOF

read _answer

fi
echocheck "host cc"
test "$_host_cc" || _host_cc=$_cc
echores $_host_cc 

echocheck "cross compilation"
if test $_cross_compile = auto ; then
  cat > $TMPC << EOF
int main() { return 0; }
EOF
  _cross_compile=yes
  cc_check && "$TMPO" && _cross_compile=no
fi
echores $_cross_compile

if test $_cross_compile = yes; then
  tmp_run() {
    return 0
  }
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

# XXX: this should be ok..
_cpuinfo="echo"
# Cygwin has /proc/cpuinfo, but only supports Intel CPUs
# FIXME: Remove the cygwin check once AMD CPUs are supported
if test -r /proc/cpuinfo && not cygwin; then
  # Linux with /proc mounted, extract CPU information from it
  _cpuinfo="cat /proc/cpuinfo"
elif test -r /compat/linux/proc/cpuinfo && not x86 ; then
  # FreeBSD with Linux emulation /proc mounted,
  # extract CPU information from it
  _cpuinfo="cat /compat/linux/proc/cpuinfo"
elif darwin && not x86 ; then
  # use hostinfo on Darwin
  _cpuinfo="hostinfo"
elif aix; then
  # use 'lsattr' on AIX
  _cpuinfo="lsattr -E -l proc0 -a type"
elif x86 || x86_64; then
  # all other OSes try to extract CPU information from a small helper
  # program TOOLS/cpuinfo instead
  $_cc -o TOOLS/cpuinfo TOOLS/cpuinfo.c
  _cpuinfo="TOOLS/cpuinfo"
fi

if x86 || x86_64 ; then
  # gather more CPU information
  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`

  exts=`$_cpuinfo | egrep 'features|flags' | cut -d ':' -f 2 | _head 1`

  pparam=`echo $exts | sed -e s/k6_mtrr/mtrr/ -e s/cyrix_arr/mtrr/ -e s/centaur_mcr/mtrr/ \
                           -e s/xmm/sse/ -e s/kni/sse/`

  for ext in $pparam ; do
    eval _$ext=auto && eval _$ext=yes
  done

  # SSE implies MMX2, but not all SSE processors report the mmxext CPU flag.
  test $_sse = yes && _mmxext=yes

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

  echocheck "CPU type"
  echores "$pname"
fi

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
	# K6 model 13 are the K6-2+ and K6-III+, only differing in cache size.
	if test "$pmodel" -eq 9 -o "$pmodel" -eq 13; then
		proc=k6-3
	elif test "$pmodel" -ge 8; then
		proc=k6-2
	elif test "$pmodel" -ge 6; then
		proc=k6
	else
		proc=i586
	fi
	;;
    6) iproc=686
	# It's a bit difficult to determine the correct type of Family 6
	# AMD CPUs just from their signature. Instead, we check directly
	# whether it supports SSE.
	if test "$_sse" = yes; then
		# gcc treats athlon-xp, athlon-4 and athlon-mp similarly.
		proc=athlon-xp
	else
		# Again, gcc treats athlon and athlon-tbird similarly.
		proc=athlon
	fi
	;;
    15) iproc=686
    	# k8 cpu-type only supported in gcc >= 3.4.0, but that will be
    	# caught and remedied in the optimization tests below.
    	proc=k8
    	;;

    *) proc=k8 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" -eq 9 -o "$pmodel" -ge 13; then
		proc=pentium-m
	elif test "$pmodel" -ge 7; then
		proc=pentium3
	elif test "$pmodel" -ge 3; then
		proc=pentium2
	else
		proc=i686
	fi
	;;
    15) iproc=686
	# A nocona in 32-bit mode has no more capabilities than a prescott.
	if test "$pmodel" -ge 3; then
		proc=prescott
	else
		proc=pentium4
	fi
	;;
    *) proc=prescott iproc=686 ;;
    esac
    ;;
  CentaurHauls)
    case "$pfamily" in
    5) iproc=586
	if test "$pmodel" -ge 8; then
		proc=winchip2
	elif test "$pmodel" -ge 4; then
		proc=winchip-c6
	else
		proc=i586
	fi
	;;
    6) iproc=686
	if test "$pmodel" -ge 9; then
		proc=c3-2
	else
		proc=c3
		iproc=586
	fi
	;;
    *) proc=i686 iproc=i686 ;;
    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, fall back to earlier ones
    # LGB: check -mcpu and -march swithing step by step with enabling
    # to fall back till 386.

    # gcc >= 3.4.0  doesn't support -mcpu, we have to use -mtune instead

    if [ "$cc_vendor" = "gnu" ] && ([ "$_cc_major" -gt 3 ] || ( [ "$_cc_major" = 3 ] && [ "$_cc_minor" -ge 4 ])) ; then
	cpuopt=-mtune
    else
	cpuopt=-mcpu
    fi

    echocheck "GCC & CPU optimization abilities"
cat > $TMPC << EOF
int main(void) { return 0; }
EOF
  if test "$_runtime_cpudetection" = no ; then
    if test "$proc" = "k8"; then
      cc_check -march=$proc $cpuopt=$proc || proc=athlon-xp
    fi
    if test "$proc" = "athlon-xp"; then
      cc_check -march=$proc $cpuopt=$proc || proc=athlon
    fi
    if test "$proc" = "k6-3" || test "$proc" = "k6-2"; then
      cc_check -march=$proc $cpuopt=$proc  || proc=k6
    fi
    if test "$proc" = "k6" || test "$proc" = "c3"; then
      if not cc_check -march=$proc $cpuopt=$proc; then
        if cc_check -march=i586 $cpuopt=i686; then
          proc=i586-i686
        else 
          proc=i586
	fi
      fi
    fi
    if test "$proc" = "prescott" ; then
      cc_check -march=$proc $cpuopt=$proc || proc=pentium4
    fi
    if test "$proc" = "pentium4" || test "$proc" = "pentium-m" || test "$proc" = "pentium3" || test "$proc" = "pentium2" || test "$proc" = "athlon" || test "$proc" = "c3-2"; then
      cc_check -march=$proc $cpuopt=$proc  || proc=i686
    fi
    if test "$proc" = "i686" || test "$proc" = "pentium-mmx" || test "$proc" = "winchip-c6" || test "$proc" = "winchip2"; then
      cc_check -march=$proc $cpuopt=$proc  || proc=i586
    fi
    if test "$proc" = "i586"; then
      cc_check -march=$proc $cpuopt=$proc  || proc=i486
    fi
    if test "$proc" = "i486" ; then
      cc_check -march=$proc $cpuopt=$proc  || proc=i386
    fi
    if test "$proc" = "i386" ; then
      cc_check -march=$proc $cpuopt=$proc  || proc=error
    fi
    if test "$proc" = "error" ; then
        echores "CPU optimization disabled. CPU not recognized or your compiler is too old."
      _mcpu=""
      _march=""
      _optimizing=""
    elif test "$proc" = "i586-i686"; then
      _march="-march=i586"
      _mcpu="$cpuopt=i686"
      _optimizing="$proc"
    else
      _march="-march=$proc"
      _mcpu="$cpuopt=$proc"
      _optimizing="$proc"
    fi
  else # if test "$_runtime_cpudetection" = no
    # i686 is probably the most common CPU - optimize for it
    _mcpu="$cpuopt=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 fall back in all cases
      if test "$host_arch" = "i586-i686"; then
        _march="-march=i586"
        _mcpu="$cpuopt=i686"
      else      
        _march="-march=$host_arch"
        _mcpu="$cpuopt=$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=''
    _optimizing=''
    ;;

  x86_64|amd64)
    _def_arch='#define ARCH_X86_64 1'
    _target_arch='TARGET_ARCH_X86_64 = yes'
    iproc='x86_64'

    # gcc >= 3.4.0  doesn't support -mcpu, we have to use -mtune instead
    if test "$cc_vendor" = "gnu" && test "$_cc_major" -gt 3 -o "$_cc_major" -eq 3 -a "$_cc_minor" -ge 4 ; then
	cpuopt=-mtune
    else
	cpuopt=-mcpu
    fi
    case "$pvendor" in
    AuthenticAMD)
      proc=k8;;
    GenuineIntel)
      # 64-bit prescotts exist, but as far as GCC is concerned they have the
      # same capabilities as a nocona.
      proc=nocona;;
    *)
      proc=error;;
    esac

    echocheck "GCC & CPU optimization abilities"
cat > $TMPC << EOF
int main(void) { return 0; }
EOF
    # This is a stripped-down version of the i386 fallback.
    if test "$_runtime_cpudetection" = no ; then
      # --- AMD processors ---
      if test "$proc" = "k8"; then
        cc_check -march=$proc $cpuopt=$proc || proc=athlon-xp
      fi
      # This will fail if gcc version < 3.3, which is ok because earlier
      # versions don't really support 64-bit on amd64.
      # Is this a valid assumption? -Corey
      if test "$proc" = "athlon-xp"; then
        cc_check -march=$proc $cpuopt=$proc || proc=error
      fi
      # --- Intel processors ---
      if test "$proc" = "nocona"; then
        cc_check -march=$proc $cpuopt=$proc || proc=pentium4
      fi
      if test "$proc" = "pentium4"; then
        cc_check -march=$proc $cpuopt=$proc || proc=error
      fi

      _march="-march=$proc"
      _mcpu="$cpuopt=$proc"
      if test "$proc" = "error" ; then
        echores "CPU optimization disabled. CPU not recognized or your compiler is too old."
        _mcpu=""
        _march=""
      fi
    else # if test "$_runtime_cpudetection" = no
      # x86-64 is an undocumented option, an intersection of k8 and nocona.
      _march="-march=x86-64"
      _mcpu="$cpuopt=x86-64"
      cc_check $_mcpu || _mcpu=""
      cc_check $_march $_mcpu || _march=""
    fi
    
    _optimizing=""

    echores "$proc"
    ;;

  sparc)
    _def_arch='#define ARCH_SPARC 1'
    _target_arch='TARGET_ARCH_SPARC = yes'
    iproc='sparc'
    if sunos ; then
	echocheck "CPU type"
	karch=`uname -m`
	case "`echo $karch`" in
	    sun4) proc=v7 ;;
	    sun4c) proc=v7 ;; 
	    sun4d) proc=v8 ;;
	    sun4m) proc=v8 ;;
	    sun4u) proc=v9 _vis='yes' _def_vis='#define HAVE_VIS = yes' ;;
	    sun4v) proc=v9 ;;
	    *) proc=v8 ;;
	esac
	echores "$proc"
    else
	proc=v8
    fi
    _march=''
    _mcpu="-mcpu=$proc"
    _optimizing="$proc"
    ;;

  sparc64)
    _def_arch='#define ARCH_SPARC 1'
    _target_arch='TARGET_ARCH_SPARC = yes'
    _vis='yes'
    _def_vis='#define HAVE_VIS = yes'
    iproc='sparc'
    proc='v9'
    _march=''
    _mcpu="-mcpu=$proc"
    _optimizing="$proc"
    ;;

  arm|armv4l|armv5tel)
    _def_arch='#define ARCH_ARMV4L 1'
    _target_arch='TARGET_ARCH_ARMV4L = yes'
    iproc='arm'
    proc=''
    _march=''
    _mcpu=''
    _optimizing=''
    ;;

  ppc)
    _def_arch='#define ARCH_POWERPC 1'
    _def_dcbzl='#define NO_DCBZL 1'
    _target_arch='TARGET_ARCH_POWERPC = yes'
    iproc='ppc'
    proc=''
    _march=''
    _mcpu=''
    _optimizing=''
    _altivec=no

    echocheck "CPU type"
    case $system_name in
      Linux)
	proc=`$_cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ',' -f 1 | cut -b 2- | _head 1`
	if test -n "`$_cpuinfo | grep altivec`"; then
	    _altivec=yes
	fi
        ;;
      Darwin)
	proc=`$_cpuinfo | grep "Processor type" | cut -f 3 -d ' ' | sed 's/ppc//'`
	if [ `sysctl -n hw.vectorunit` -eq 1 -o \
	    "`sysctl -n hw.optional.altivec 2> /dev/null`" = "1" ]; then
	    _altivec=yes
	fi
        ;;
      NetBSD)
        # only gcc 3.4 works reliably with AltiVec code under NetBSD
	case $cc_version in
	    2*|3.0*|3.1*|3.2*|3.3*)
		;;
	    *)
		if [ `sysctl -n machdep.altivec` -eq 1 ]; then
		    _altivec=yes
		fi
		;;
	esac
        ;;
      AIX)
	proc=`$_cpuinfo | grep 'type' | cut -f 2 -d ' ' | sed 's/PowerPC_//'`
	;;
    esac
    if test "$_altivec" = yes; then
        echores "$proc altivec"
    else
        echores "$proc"
    fi

    echocheck "GCC & CPU optimization abilities"

    if test -n "$proc"; then
        case "$proc" in
	    601) _march='-mcpu=601' _mcpu='-mtune=601' ;;
	    603) _march='-mcpu=603' _mcpu='-mtune=603' ;;
	    603e|603ev) _march='-mcpu=603e' _mcpu='-mtune=603e' ;;
	    604|604e|604r|604ev) _march='-mcpu=604' _mcpu='-mtune=604' ;;
	    740|740/750|745/755) _march='-mcpu=740' _mcpu='-mtune=740' ;;
	    750|750CX) _march='-mcpu=750' _mcpu='-mtune=750' ;;
	    POWER)  _march='-mcpu=power'  _mcpu='-mtune=power'  ;;
	    POWER2) _march='-mcpu=power2' _mcpu='-mtune=power2' ;;
	    POWER3) _march='-mcpu=power3' _mcpu='-mtune=power3' ;;
    	    *) ;;
        esac
	# gcc 3.1(.1) and up supports 7400 and 7450
	if test "$_cc_major" -ge "3" && test "$_cc_minor" -ge "1" || test "$_cc_major" -ge "4"; then
	    case "$proc" in
		7400*|7410*) _march='-mcpu=7400' _mcpu='-mtune=7400' ;;
		7447*|7450*|7455*) _march='-mcpu=7450' _mcpu='-mtune=7450' ;;
    		*) ;;
    	    esac
	fi
	# gcc 3.2 and up supports 970
	if test "$_cc_major" -ge "3" && test "$_cc_minor" -ge "3" || test "$_cc_major" -ge "4"; then
	    case "$proc" in
		970*|PPC970*) _march='-mcpu=970' _mcpu='-mtune=970'
                      _def_dcbzl='#undef NO_DCBZL' ;;
    		*) ;;
    	    esac
	fi
	# gcc 3.3 and up supports POWER4
	if test "$_cc_major" -ge "3" && test "$_cc_minor" -ge "3" || test "$_cc_major" -ge "4"; then
	    case "$proc" in
		POWER4) _march='-mcpu=power4' _mcpu='-mtune=power4' ;;
		*) ;;
	    esac
	fi
	# gcc 4.0 and up supports POWER5
	if test "$_cc_major" -ge "4"; then
	    case "$proc" in
		POWER5*) _march='-mcpu=power5' _mcpu='-mtune=power5' ;;
		*) ;;
	    esac
	fi
    fi

    if test -n "$_mcpu"; then
        _optimizing=`echo $_mcpu | cut -c 8-`
        echores "$_optimizing"
    else
        echores "none"
    fi

    ;;

  alpha)
    _def_arch='#define ARCH_ALPHA 1'
    _target_arch='TARGET_ARCH_ALPHA = yes'
    iproc='alpha'
    _march=''
    
    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";   cpu_understands_mvi="0";;
        1-0)    proc="ev5";   cpu_understands_mvi="0";;
        1-1)    proc="ev56";  cpu_understands_mvi="0";; 
        1-101)  proc="pca56"; cpu_understands_mvi="1";;
        2-303)  proc="ev6";   cpu_understands_mvi="1";;
        2-307)  proc="ev67";  cpu_understands_mvi="1";;
        2-1307) proc="ev68";  cpu_understands_mvi="1";;
    esac
    echores "$proc"
    
    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"
    
    _optimizing="$proc"

    echocheck "MVI instruction support in GCC"
    if test "$_cc_major" -ge "3" && test "$cpu_understands_mvi" = "1" ; then
        _def_gcc_mvi_support="#define CAN_COMPILE_ALPHA_MVI 1"
	echores "yes"
    else
	_def_gcc_mvi_support="#undef CAN_COMPILE_ALPHA_MVI"
	echores "no, GCC = `$_cc -dumpversion 2>&1` (must be >= 3), CPU = $proc (must be pca56 or later)"
    fi
    ;;

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

    if irix ; then
	echocheck "CPU type"
	proc=`hinv -c processor | grep CPU | cut -d " " -f3`
	case "`echo $proc`" in
	    R3000) _march='-mips1' _mcpu='-mtune=r2000' ;;
	    R4000) _march='-mips3' _mcpu='-mtune=r4000' ;;
	    R4400) _march='-mips3' _mcpu='-mtune=r4400' ;;
	    R4600) _march='-mips3' _mcpu='-mtune=r4600' ;;
	    R5000) _march='-mips4' _mcpu='-mtune=r5000' ;;
	    R8000|R10000|R12000|R14000|R16000) _march='-mips4' _mcpu='-mtune=r8000' ;;
	esac
	# gcc < 3.x does not support -mtune.
	if test "$cc_vendor" = "gnu" && test "$_cc_major" -lt 3 ; then
	    _mcpu=''
	fi
        echores "$proc"
    fi

    ;;

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

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

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

  vax)
    _def_arch='#define ARCH_VAX 1'
    _target_arch='TARGET_ARCH_VAX = yes'
    iproc='vax'
    proc=''
    _march=''
    _mcpu=''
    _optimizing=''
    ;;

  *)
    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 # case "$host_arch" in

if test "$_runtime_cpudetection" = yes ; then
  if x86; then
    _mmx=yes
    _3dnow=yes
    _3dnowext=yes
    _mmxext=yes
    _sse=yes
    _sse2=yes
    _mtrr=yes
  fi
  if ppc; then
    _altivec=yes
  fi
fi

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 && tmp_run ; 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 $_mmxext "mmxext" "sfence" || _mmxext=no
  extcheck $_3dnow "3dnow" "femms" || _3dnow=no
  extcheck $_3dnowext "3dnowext" "pswapd %%mm0, %%mm0" || _3dnowext=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


echocheck "assembler support of -pipe option"
cat > $TMPC << EOF
int main(void) { return 0; }
EOF
cc_check -pipe && _pipe="-pipe" && echores "yes" || echores "no"


echocheck "compiler support of named assembler arguments"
_named_asm_args=yes
_def_named_asm_args="#define NAMED_ASM_ARGS 1"
if test "$cc_vendor" = "gnu" && test "$_cc_major" -lt 3 \
     -o "$_cc_major" -eq 3 -a "$_cc_minor" = 0 ; then
  _named_asm_args=no
  _def_named_asm_args="#undef NAMED_ASM_ARGS"
fi
echores $_named_asm_args


# Checking for CFLAGS
_stripbinaries=yes
if test "$_profile" != "" || test "$_debug" != "" ; then
  CFLAGS="-W -Wall -O2 $_march $_mcpu $_debug $_profile"
  if test "$_cc_major" -ge "3" ; then
    CFLAGS=`echo "$CFLAGS" | sed -e 's/\(-Wall\)/\1 -Wno-unused-parameter/'`
  fi
  _stripbinaries=no
elif test -z "$CFLAGS" ; then
    CFLAGS="-O4 $_march $_mcpu $_pipe -ffast-math -fomit-frame-pointer"
else
  _warn_CFLAGS=yes
fi
if test -n "$LDFLAGS" ; then
  _ld_extra="$_ld_extra $LDFLAGS"
  _warn_CFLAGS=yes
fi
if test -n "$CPPFLAGS" ; then
  _inc_extra="$_inc_extra $CPPFLAGS"
  _warn_CFLAGS=yes
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
_libavutil=auto
_libavutil_so=auto
_libavcodec=auto
_amr_nb=auto
_amr_nb_fixed=auto
_amr_wb=auto
_libavdecoders=`grep 'register_avcodec(&[a-z0-9_]*_decoder)' libavcodec/allcodecs.c  | sed 's/.*&\(.*\)).*/\1/'`
_libavencoders=`grep 'register_avcodec(&[a-z0-9_]*_encoder)' libavcodec/allcodecs.c  | sed 's/.*&\(.*\)).*/\1/'`
_libavparsers=`grep 'av_register_codec_parser(&[a-z]' libavcodec/allcodecs.c  | sed 's/.*&\(.*\)).*/\1/'`
_libavdemuxers=`grep 'av_register_input_format(&[a-z]' libavformat/allformats.c  | sed 's/.*&\(.*\)).*/\1/'`
_libavmuxers=`grep 'av_register_output_format(&[a-z]' libavformat/allformats.c  | sed 's/.*&\(.*\)).*/\1/'`
_libavcodec_so=auto
_libavformat=auto
_libavformat_so=auto
_libpostproc=auto
_libpostproc_so=auto
_libavcodec_mpegaudio_hp=yes
_libfame=auto
_mencoder=yes
_x11=auto
_xshape=auto
_dga=auto	# 1 2 no auto
_xv=auto
_xvmc=no  #auto when complete
_sdl=auto
_directx=auto
_win32waveout=auto
_nas=auto
_png=auto
_jpeg=auto
_pnm=yes
_md5sum=yes
_gif=auto
_gl=auto
_ggi=auto
_ggiwmh=auto
_aa=auto
_caca=auto
_svga=auto
_vesa=auto
_fbdev=auto
_dvb=auto
_dvbhead=auto
_dxr2=auto
_dxr3=auto
_ivtv=auto
_iconv=auto
_langinfo=auto
_rtc=auto
_ossaudio=auto
_arts=auto
_esd=auto
_pulse=auto
_jack=auto
_openal=auto
_libcdio=auto
_liblzo=auto
_mad=auto
_toolame=auto
_twolame=auto
_tremor_internal=yes
_tremor_low=no
_tremor_external=auto
_libvorbis=auto
_speex=auto
_theora=auto
_mp3lib=yes
_liba52=yes
_libdts=auto
_libmpeg2=yes
_faad_internal=auto
_faad_external=auto
_faad_fixed=no
_faac=auto
_ladspa=auto
_xmms=no
_have_dvd=no
_dvdnav=auto
# theres's some known linking issues with darwin and dvdnav, so disable autodetection
if darwin; then
  _dvdnav=no
fi
_dvdnavconfig=dvdnav-config
_dvdread=auto
_mpdvdkit=auto
_xanim=auto
_real=auto
_live=auto
_xinerama=auto
_mga=auto
_xmga=auto
_vm=auto
_xf86keysym=auto
_mlib=no #broken, thus disabled
_sgiaudio=auto
_sunaudio=auto
_alsa=auto
_fastmemcpy=yes
_unrarlib=yes
_win32=auto
_select=yes
_radio=no
_radio_capture=no
_radio_v4l=auto
_radio_v4l2=auto
_tv=yes
_tv_v4l1=auto
_tv_v4l2=auto
_tv_bsdbt848=auto
_pvr=auto
_network=yes
_winsock2=auto
_smbsupport=auto
_vidix_internal=auto
_vidix_external=auto
_joystick=no
_xvid=auto
_x264=auto
_nut=auto
_lirc=auto
_lircc=auto
_gui=no
_gtk1=no
_termcap=auto
_termios=auto
_3dfx=no
_s3fb=no
_tdfxfb=no
_tdfxvid=no
_tga=yes
_directfb=auto
_zr=auto
_bl=no
_largefiles=no
#_language=en
_shm=auto
_linux_devfs=no
#_charset=utf8
_dynamic_plugins=no
_crash_debug=no
_sighandler=yes
_libdv=auto
_cdparanoia=auto
_big_endian=auto
_bitmap_font=yes
_freetype=auto
_fontconfig=auto
_menu=no
_qtx=auto
_macosx=auto
_maemo=auto
_macosx_finder_support=no
_macosx_bundle=auto
_sortsub=yes
_freetypeconfig='freetype-config'
_fribidi=auto
_fribidiconfig='fribidi-config'
_enca=auto
_inet6=auto
_gethostbyname2=auto
_ftp=yes
_musepack=auto
_vstream=auto
_pthreads=auto
_ass=auto
_rpath=no
_asmalign_pot=auto
for ac_option do
  case "$ac_option" in
  # Skip 1st pass
  --target=*) ;;
  --cc=*) ;;
  --host-cc=*) ;;
  --as=*) ;;
  --enable-gcc-check) ;;
  --disable-gcc-check) ;;
  --enable-static*) ;;
  --disable-static*) ;;
  --with-extraincdir=*) ;;
  --with-extralibdir=*) ;;
  --extra-libs=*) ;;
  --enable-runtime-cpudetection) ;;
  --disable-runtime-cpudetection) ;;
  --enable-cross-compile) ;;
  --disable-cross-compile) ;;
  --install-path=*) ;;
  --with-install=*) ;;
  --enable-profile) ;;
  --disable-profile) ;;
  --enable-debug) ;;
  --enable-debug=*) ;;
  --disable-debug) ;;

  # Real 2nd pass
  --enable-mencoder)	_mencoder=yes	;;
  --disable-mencoder)	_mencoder=no	;;
  --enable-dynamic-plugins) _dynamic_plugins=yes ;;
  --disable-dynamic-plugins) _dynamic_plugins=no ;;
  --enable-x11)		_x11=yes	;;
  --disable-x11)	_x11=no		;;
  --enable-xshape)	_xshape=yes	;;
  --disable-xshape)	_xshape=no	;;
  --enable-xv)		_xv=yes		;;
  --disable-xv)		_xv=no		;;
  --enable-xvmc)        _xvmc=yes       ;;
  --disable-xvmc)       _xvmc=no        ;;
  --enable-sdl)		_sdl=yes	;;
  --disable-sdl)	_sdl=no		;;
  --enable-directx)     _directx=yes    ;;
  --disable-directx)    _directx=no     ;;
  --enable-win32waveout)  _win32waveout=yes ;;
  --disable-win32waveout) _win32waveout=no  ;;
  --enable-nas)		_nas=yes	;;
  --disable-nas)	_nas=no		;;
  --enable-png)		_png=yes	;;
  --disable-png)	_png=no		;;
  --enable-jpeg)	_jpeg=yes	;;
  --disable-jpeg)	_jpeg=no		;;
  --enable-pnm)		_pnm=yes	;;
  --disable-pnm)	_pnm=no		;;
  --enable-md5sum)	_md5sum=yes	;;
  --disable-md5sum)	_md5sum=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-ggiwmh)	_ggiwmh=yes	;;
  --disable-ggiwmh)	_ggiwmh=no	;;
  --enable-aa)		_aa=yes		;;
  --disable-aa)		_aa=no		;;
  --enable-caca)	_caca=yes	;;
  --disable-caca)	_caca=no	;;
  --enable-svga)	_svga=yes	;;
  --disable-svga)	_svga=no	;;
  --enable-vesa)	_vesa=yes	;;
  --disable-vesa)	_vesa=no	;;
  --enable-fbdev)	_fbdev=yes	;;
  --disable-fbdev)	_fbdev=no	;;
  --enable-dvb)		_dvb=yes	;;
  --disable-dvb)        _dvb=no		;;
  --enable-dvbhead)	_dvbhead=yes	;;
  --disable-dvbhead)    _dvbhead=no	;;
  --enable-dxr2)	_dxr2=yes	;;
  --disable-dxr2)	_dxr2=no	;;
  --enable-dxr3)	_dxr3=yes	;;
  --disable-dxr3)	_dxr3=no	;;
  --enable-ivtv)        _ivtv=yes       ;;
  --disable-ivtv)       _ivtv=no        ;;
  --enable-iconv)	_iconv=yes	;;
  --disable-iconv)	_iconv=no	;;
  --enable-langinfo)	_langinfo=yes	;;
  --disable-langinfo)	_langinfo=no	;;
  --enable-rtc)	        _rtc=yes	;;
  --disable-rtc)	_rtc=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-esd)		_esd=yes	;;
  --disable-esd)	_esd=no		;;
  --enable-pulse)	_pulse=yes	;;
  --disable-pulse)	_pulse=no		;;
  --enable-jack)	_jack=yes	;;
  --disable-jack)	_jack=no	;;
  --enable-openal)	_openal=yes	;;
  --disable-openal)	_openal=no	;;
  --enable-mad)		_mad=yes	;;
  --disable-mad)	_mad=no		;;
  --enable-toolame)	_toolame=yes	;;
  --disable-toolame)	_toolame=no	;;
  --enable-twolame)	_twolame=yes	;;
  --disable-twolame)	_twolame=no	;;
  --enable-libcdio)	_libcdio=yes	;;
  --disable-libcdio)	_libcdio=no	;;
  --enable-liblzo)	_liblzo=yes	;;
  --disable-liblzo)	_liblzo=no		;;
  --enable-libvorbis)	_libvorbis=yes	;;
  --disable-libvorbis)	_libvorbis=no	;;
  --enable-speex)	_speex=yes	;;
  --disable-speex)	_speex=no	;;
  --enable-tremor-internal)	_tremor_internal=yes	;;
  --disable-tremor-internal)	_tremor_internal=no	;;
  --enable-tremor-low)	_tremor_low=yes	;;
  --disable-tremor-low)	_tremor_low=no	;;
  --enable-tremor-external)	_tremor_external=yes	;;
  --disable-tremor-external)	_tremor_external=no	;;
  --enable-theora)	_theora=yes	;;
  --disable-theora)	_theora=no	;;
  --enable-mp3lib)	_mp3lib=yes	;;
  --disable-mp3lib)	_mp3lib=no	;;
  --enable-liba52)	_liba52=yes	;;
  --disable-liba52)	_liba52=no	;;
  --enable-libdts)	_libdts=yes     ;;
  --disable-libdts)	_libdts=no      ;;
  --enable-libmpeg2)	_libmpeg2=yes	;;
  --disable-libmpeg2)	_libmpeg2=no	;;
  --enable-musepack)	_musepack=yes	;;
  --disable-musepack)	_musepack=no	;;
  --enable-faad-internal)	_faad_internal=yes	;;
  --disable-faad-internal)	_faad_internal=no	;;
  --enable-faad-external)	_faad_external=yes	;;
  --disable-faad-external)	_faad_external=no	;;
  --enable-faad-fixed)	_faad_fixed=yes	;;
  --disable-faad-fixed)	_faad_fixed=no	;;
  --enable-faac)	_faac=yes	;;
  --disable-faac)	_faac=no	;;
  --enable-ladspa)	_ladspa=yes	;;
  --disable-ladspa)	_ladspa=no		;;
  --enable-xmms)	_xmms=yes	;;
  --disable-xmms)	_xmms=no	;;
  --enable-dvdread)	_dvdread=yes	;;
  --disable-dvdread)	_dvdread=no	;;
  --enable-mpdvdkit)	_mpdvdkit=yes	;;
  --disable-mpdvdkit)	_mpdvdkit=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-xf86keysym)	_xf86keysym=yes	;;
  --disable-xf86keysym)	_xf86keysym=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-v4l1)	_tv_v4l1=yes	;;
  --disable-tv-v4l1)	_tv_v4l1=no	;;
  --enable-tv-v4l2)	_tv_v4l2=yes	;;
  --disable-tv-v4l2)	_tv_v4l2=no	;;
  --enable-radio)       _radio=yes	;;
  --enable-radio-capture)       _radio_capture=yes	;;
  --disable-radio-capture)       _radio_capture=no	;;
  --disable-radio)	_radio=no	;;
  --enable-radio-v4l)	_radio_v4l=yes	;;
  --disable-radio-v4l)	_radio_v4l=no	;;
  --enable-radio-v4l2)	_radio_v4l2=yes	;;
  --disable-radio-v4l2)	_radio_v4l2=no	;;
  --enable-pvr)  	_pvr=yes	;;
  --disable-pvr)	_pvr=no 	;;
  --enable-fastmemcpy)	_fastmemcpy=yes	;;
  --disable-fastmemcpy)	_fastmemcpy=no	;;
  --enable-network)	_network=yes	;;
  --disable-network)	_network=no	;;
  --enable-winsock2)	_winsock2=yes	;;
  --disable-winsock2)	_winsock2=no	;;
  --enable-smb)		_smbsupport=yes	;;
  --disable-smb)	_smbsupport=no	;;
  --enable-vidix-internal)	_vidix_internal=yes	;;
  --disable-vidix-internal)	_vidix_internal=no	;;
  --enable-vidix-external)	_vidix_external=yes	;;
  --disable-vidix-external)	_vidix_external=no	;;
  --enable-joystick)	_joystick=yes	;;
  --disable-joystick)	_joystick=no	;;
  --enable-xvid)	_xvid=yes	;;
  --disable-xvid)	_xvid=no	;;
  --enable-x264)        _x264=yes       ;;
  --disable-x264)       _x264=no        ;;
  --enable-nut)		_nut=yes	;;
  --disable-nut)	_nut=no		;;
  --enable-libavutil)	_libavutil=yes	;;
  --disable-libavutil)	_libavutil=no	;;
  --enable-libavutil_so)	_libavutil_so=yes	;;
  --disable-libavutil_so)	_libavutil_so=no	;;
  --enable-libavcodec)	_libavcodec=yes	;;
  --disable-libavcodec)	_libavcodec=no	;;
  --enable-libavcodec_so)	_libavcodec_so=yes	;;
  --disable-libavcodec_so)	_libavcodec_so=no	;;
  --enable-amr_nb)	_amr_nb=yes	;;
  --disable-amr_nb)	_amr_nb=no	;;
  --enable-amr_nb-fixed)	_amr_nb_fixed=yes ;;
  --disable-amr_nb-fixed)	_amr_nb_fixed=no ;;
  --enable-amr_wb)	_amr_wb=yes	;;
  --disable-amr_wb)	_amr_wb=no	;;
  --enable-decoder=*)	_libavdecoders="$_libavdecoders `echo $ac_option | cut -d '=' -f 2`" ;;
  --disable-decoder=*)	_libavdecoders=`echo $_libavdecoders | sed "s/\`echo $ac_option | cut -d '=' -f 2\`//g"` ;;
  --enable-encoder=*)	_libavencoders="$_libavencoders `echo $ac_option | cut -d '=' -f 2`" ;;
  --disable-encoder=*)	_libavencoders=`echo $_libavencoders | sed "s/\`echo $ac_option | cut -d '=' -f 2\`//g"` ;;
  --enable-parser=*)	_libavparsers="$_libavparsers `echo $ac_option | cut -d '=' -f 2`" ;;
  --disable-parser=*)	_libavparsers=`echo $_libavparsers | sed "s/\`echo $ac_option | cut -d '=' -f 2\`//g"` ;;
  --enable-demuxer=*)	_libavdemuxers="$_libavdemuxers `echo $ac_option | cut -d '=' -f 2`" ;;
  --disable-demuxer=*)	_libavdemuxers=`echo $_libavdemuxers | sed "s/\`echo $ac_option | cut -d '=' -f 2\`//g"` ;;
  --enable-muxer=*)	_libavmuxers="$_libavmuxers `echo $ac_option | cut -d '=' -f 2`" ;;
  --disable-muxer=*)	_libavmuxers=`echo $_libavmuxers | sed "s/\`echo $ac_option | cut -d '=' -f 2\`//g"` ;;
  --enable-libavformat)	_libavformat=yes;;
  --disable-libavformat)	_libavformat=no	;;
  --enable-libavformat_so)	_libavformat_so=yes	;;
  --disable-libavformat_so)	_libavformat_so=no	;;
  --enable-libpostproc)		_libpostproc=yes	;;
  --disable-libpostproc)	_libpostproc=no		;;
  --enable-libpostproc_so)	_libpostproc_so=yes	;;
  --disable-libpostproc_so)	_libpostproc_so=no	;;
  --enable-libavcodec_mpegaudio_hp)	_libavcodec_mpegaudio_hp=yes	;;
  --disable-libavcodec_mpegaudio_hp)	_libavcodec_mpegaudio_hp=no	;;

  --enable-libfame)	_libfame=yes	;;
  --disable-libfame)	_libfame=no	;;
  --enable-lirc)	_lirc=yes	;;
  --disable-lirc)	_lirc=no	;;
  --enable-lircc)	_lircc=yes	;;
  --disable-lircc)	_lircc=no	;;
  --enable-gui)		_gui=yes	;;
  --disable-gui)	_gui=no		;;
  --enable-gtk1)	_gtk1=yes	;;
  --disable-gtk1)	_gtk1=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-s3fb)	_s3fb=yes	;;
  --disable-s3fb)	_s3fb=no	;;
  --enable-tdfxfb)	_tdfxfb=yes	;;
  --disable-tdfxvid)	_tdfxvid=no	;;
  --enable-tdfxvid)	_tdfxvid=yes	;;
  --disable-tga)	_tga=no	  	;;
  --enable-tga)		_tga=yes	;;
  --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-bitmap-font)    _bitmap_font=yes   ;;
  --disable-bitmap-font)   _bitmap_font=no    ;;
  --enable-freetype)    _freetype=yes   ;;
  --disable-freetype)   _freetype=no    ;;
  --enable-fontconfig)  _fontconfig=yes ;;
  --disable-fontconfig) _fontconfig=no  ;;
  --enable-unrarlib)	_unrarlib=yes	;;
  --disable-unrarlib)	_unrarlib=no	;;
  --enable-ftp)         _ftp=yes        ;;
  --disable-ftp)        _ftp=no         ;;
  --enable-vstream)     _vstream=yes    ;;
  --disable-vstream)    _vstream=no     ;;
  --enable-pthreads)    _pthreads=yes   ;;
  --disable-pthreads)   _pthreads=no    ;;
  --enable-ass)         _ass=yes        ;;
  --disable-ass)        _ass=no         ;;
  --enable-rpath)       _rpath=yes      ;;
  --disable-rpath)      _rpath=no       ;;

  --enable-fribidi)     _fribidi=yes    ;;
  --disable-fribidi)    _fribidi=no     ;;

  --enable-enca)        _enca=yes    ;;
  --disable-enca)       _enca=no     ;;

  --enable-inet6)	_inet6=yes	;;
  --disable-inet6)	_inet6=no	;;

  --enable-gethostbyname2)	_gethostbyname2=yes	;;
  --disable-gethostbyname2)	_gethostbyname2=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 ;;

  --enable-menu) _menu=yes ;;
  --disable-menu) _menu=no ;;

  --enable-qtx) _qtx=yes ;;
  --disable-qtx) _qtx=no ;;

  --enable-macosx) _macosx=yes ;;
  --disable-macosx) _macosx=no ;;
  --enable-macosx-finder-support) _macosx_finder_support=yes ;;
  --disable-macosx-finder-support) _macosx_finder_support=no ;;
  --enable-macosx-bundle) _macosx_bundle=yes;;
  --disable-macosx-bundle) _macosx_bundle=no;;  

  --enable-maemo) _maemo=yes ;;
  --disable-maemo) _maemo=no ;;

  --enable-sortsub) _sortsub=yes ;;
  --disable-sortsub) _sortsub=no ;;

  --charset=*)
    _charset=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --language=*)
    _language=`echo $ac_option | cut -d '=' -f 2`
    ;;

  --with-codecsdir=*)
    _win32libdir=`echo $ac_option | cut -d '=' -f 2`
    _xanimlibdir=`echo $ac_option | cut -d '=' -f 2`
    _reallibdir=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-win32libdir=*)
    _win32libdir=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-xanimlibdir=*)
    _xanimlibdir=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-reallibdir=*)
    _reallibdir=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-livelibdir=*)
    _livelibdir=`echo $ac_option | cut -d '=' -f 2`
    ;;

  --with-xmmslibdir=*)
    _xmmslibdir=`echo $ac_option | cut -d '=' -f 2`
    ;;
    
  --with-xmmsplugindir=*)
    _xmmsplugindir=`echo $ac_option | cut -d '=' -f 2`
    ;;

  --enable-crash-debug)
    _crash_debug=yes
    ;;
  --disable-crash-debug)
    _crash_debug=no
    ;;
  --enable-sighandler)
    _sighandler=yes
    ;;
  --disable-sighandler)
    _sighandler=no
    ;;

  --enable-sse)	_sse=yes ;;
  --disable-sse) _sse=no ;;
  --enable-sse2) _sse2=yes ;;
  --disable-sse2) _sse2=no ;;
  --enable-mmxext) _mmxext=yes ;;
  --disable-mmxext) _mmxext=no ;;
  --enable-3dnow) _3dnow=yes ;;
  --disable-3dnow) _3dnow=no _3dnowext=no ;;
  --enable-3dnowext) _3dnow=yes _3dnowext=yes ;;
  --disable-3dnowext) _3dnowext=no ;;
  --enable-altivec) _altivec=yes ;;
  --disable-altivec) _altivec=no ;;
  --enable-armv5te) _armv5te=yes ;;
  --disable-armv5te) _armv5te=no ;;
  --enable-iwmmxt) _iwmmxt=yes ;;
  --disable-iwmmxt) _iwmmxt=no ;;
  --enable-mmx)	_mmx=yes ;;
  --disable-mmx) # 3Dnow! and MMX2 require MMX
        _3dnow=no _3dnowext=no _mmx=no _mmxext=no ;;

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

  --with-x11libdir=*)
    _ld_x11=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
    ;;
  --with-xvmclib=*)
    _xvmclib=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-xvidlibdir=*)
    _ld_xvid=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
    ;;
  --with-libdtslibdir=*)
    _ld_libdts=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
    ;;
  --with-x264libdir=*)
    _ld_x264=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
    ;;
  --with-mliblibdir=*)
    _ld_mlib=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
    ;;
  --with-sdl-config=*)
    _sdlconfig=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-freetype-config=*)
    _freetypeconfig=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-fribidi-config=*)
    _fribidiconfig=`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-cdparanoialibdir=*)
    _ld_cdparanoia=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
    ;;
  --with-toolamelibdir=*)
    _ld_toolame=-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 1
    ;;

  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"

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 "$_3dnowext" = yes ; then
    _pref_as_version='2.10.1'
    echo 'pswapd	%mm0, %mm0' >> $TMPS
  fi
  if test "$_mmxext" = 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
    _res_comment="Upgrade binutils to ${_pref_as_version} ..."
    echores "failed"
    die "obsolete binutils version"
  fi

fi #if x86

echocheck ".align is a power of two"
if test "$_asmalign_pot" = auto ; then
_asmalign_pot=no
cat > $TMPC << EOF
main() { asm (".align 3"); }
EOF
cc_check && _asmalign_pot=yes
fi
if test "$_asmalign_pot" = "yes" ; then
  _def_asmalign_pot='#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\n\t"'
else
  _def_asmalign_pot='#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\n\t"'
fi
echores $_asmalign_pot


#FIXME: This should happen before the check for CFLAGS..
if ppc ; then
    
    # check if altivec is supported by the compiler, and how to enable it

    _altivec_gcc_flags=''

    if test "$_altivec" = yes -o "$_runtime_cpudetection" = yes ; then
        echocheck "GCC altivec support"
        
        p=''
        cat > $TMPC << EOF
int main() {
    return 0;
}
EOF
        FSF_flags='-maltivec -mabi=altivec'
        Darwin_flags='-faltivec -D__APPLE_ALTIVEC__'

        # check for Darwin-style flags first, since
        # gcc-3.3 (August Update from Apple) on MacOS 10.2.8
        # accepts but ignores FSF-style flags...

        if test -z "$p"; then
            cc_check $Darwin_flags && p='Darwin'
        fi
        if test -z "$p"; then
            cc_check $FSF_flags && p='FSF'
        fi

        case $p in
            FSF) _altivec_gcc_flags="$FSF_flags" _altivec=yes ;;
            Darwin) _altivec_gcc_flags="$Darwin_flags" _altivec=yes ;;
            *) _altivec=no ;;
        esac

        if test -z "$p"; then
            p=none
        else
            p="$p-style ($_altivec_gcc_flags)"
        fi

        echores "$p"
    fi

    # check if <altivec.h> should be included

    _def_altivec_h='#undef HAVE_ALTIVEC_H'

    if test "$_altivec" = yes ; then
        echocheck "altivec.h"
        cat > $TMPC << EOF
#include <altivec.h>
int main(void) { return 0; }
EOF
        _have_altivec_h=no
         cc_check $_altivec_gcc_flags && _have_altivec_h=yes
         if test "$_have_altivec_h" = yes ; then
             _def_altivec_h='#define HAVE_ALTIVEC_H 1'
         fi
         echores "$_have_altivec_h"
    fi

    # disable runtime cpudetection if 
    # - we cannot generate altivec code
    # - altivec is disabled by the user

    if test "$_runtime_cpudetection" = yes -a "$_altivec" = no ; then
        _runtime_cpudetection=no
    fi

    # show that we are optimizing for altivec (if enabled and supported)

    if test "$_runtime_cpudetection" = no -a "$_altivec" = yes ; then
	_optimizing="$_optimizing altivec"
    fi

    # if altivec is enabled, make sure the correct flags turn up in CFLAGS

    if test "$_altivec" = yes ; then
        #FIXME: _mcpu is used for CFLAGS, this needs to be set earlier
        #_mcpu="$_mcpu $_altivec_gcc_flags"
        CFLAGS="$CFLAGS $_altivec_gcc_flags"
    fi

    # setup _def_altivec correctly

    if test "$_altivec" = yes ; then
	_def_altivec='#define HAVE_ALTIVEC 1'
    else
	_def_altivec='#undef HAVE_ALTIVEC'
    fi
fi

if arm ; then
  echocheck "ARMv5TE (Enhanced DSP Extensions)"
  if test $_armv5te = "auto" ; then
    cat > $TMPC << EOF
int main(void) {
    __asm__ __volatile__ ("qadd r0, r0, r0");
}
EOF
    _armv5te=no
    cc_check && _armv5te=yes
  fi
  echores "$_armv5te"

  echocheck "iWMMXt (Intel XScale SIMD instructions)"
  if test $_iwmmxt = "auto" ; then
    cat > $TMPC << EOF
int main(void) {
    __asm__ __volatile__ ("wunpckelub wr6, wr4");
}
EOF
    _iwmmxt=no
    cc_check && _iwmmxt=yes
  fi
  echores "$_iwmmxt"
fi

_def_mmx='#undef HAVE_MMX'
test "$_mmx" = yes && _def_mmx='#define HAVE_MMX 1'
_def_mmxext='#undef HAVE_MMX2'
test "$_mmxext" = yes && _def_mmxext='#define HAVE_MMX2 1'
_def_3dnow='#undef HAVE_3DNOW'
test "$_3dnow" = yes && _def_3dnow='#define HAVE_3DNOW 1'
_def_3dnowext='#undef HAVE_3DNOWEX'
test "$_3dnowext" = yes && _def_3dnowext='#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'
_def_armv5te='#undef HAVE_ARMV5TE'
test "$_armv5te" = yes && _def_armv5te='#define HAVE_ARMV5TE 1'
_def_iwmmxt='#undef HAVE_IWMMXT'
test "$_iwmmxt" = yes && _def_iwmmxt='#define HAVE_IWMMXT 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 "Your kernel is too old 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_internal" = auto ; then
  _vidix_internal=no
  # should check for x86 systems supporting VIDIX (does QNX have VIDIX?)
  x86 && _vidix_internal=yes
  x86_64 && _vidix_internal=yes
  ppc && linux && _vidix_internal=yes
  alpha && linux && _vidix_internal=yes
  qnx && _vidix_internal=no
  sunos && _vidix_internal=no
  beos && _vidix_internal=no
  darwin && _vidix_internal=no
fi

echocheck "MPlayer binary name"
if win32 ; then
  _prg="mplayer.exe"
  _prg_mencoder="mencoder.exe"
else
  _prg="mplayer"
  _prg_mencoder="mencoder"
fi
echores $_prg


# On QNX we must link to libph - Gabucino
if qnx ; then
  _ld_arch="$_ld_arch -lph"
fi

# checking for a working awk, I'm using mawk first, because it's fastest - atmos
_awk=
if test "$_vidix_internal" = 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

# If IRIX we must use ar instead of ranlib (not present on IRIX systems)
if irix ; then
  _ranlib='ar -r'
elif linux ; then
  _ranlib='true'
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

echocheck "-lposix"
cat > $TMPC <<EOF
int main(void) { return 0; }
EOF
if cc_check -lposix ; then
  _ld_arch="$_ld_arch -lposix"
  echores "yes"
else
  echores "no"
fi

echocheck "-lm"
cat > $TMPC <<EOF
int main(void) { return 0; }
EOF
if cc_check -lm ; then
  _ld_lm="-lm"
  echores "yes"
else
  _ld_lm=""
  echores "no"
fi


echocheck "langinfo"
if test "$_langinfo" = auto ; then
  cat > $TMPC <<EOF
#include <langinfo.h>
int main(void) { nl_langinfo(CODESET); return 0; }
EOF
  _langinfo=no
  cc_check && _langinfo=yes
fi
if test "$_langinfo" = yes ; then
  _def_langinfo='#define USE_LANGINFO 1'
else
  _def_langinfo='#undef USE_LANGINFO'
fi
echores "$_langinfo"


echocheck "language"
test -z "$_language" && _language=$LINGUAS
_language=`echo $_language | sed 's/,/ /g'`
echo $_language | grep all > /dev/null || LANGUAGES="$_language en"
for lang in $_language ; do
  test "$lang" = all && lang=en
  if test -f "help/help_mp-${lang}.h" ; then
    _language=$lang
    break
  else
    echo -n "$lang not found, "
    _language=`echo $_language | sed "s/$lang *//"`
  fi
done
test -z "$_language" && _language=en
_mp_help="help/help_mp-${_language}.h"
test -f $_mp_help || die "$_mp_help not found"
for lang in $LANGUAGES ; do
  if test -f "DOCS/man/$lang/mplayer.1" ; then
    MAN_LANG="$MAN_LANG $lang"
  fi
done
_doc_lang=$_language
test -d DOCS/xml/$_doc_lang || _doc_lang=en
echores "using $_language (man pages: $MAN_LANG)"


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
  _optimizing="Runtime CPU-Detection enabled"
  _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
# Avoid infinite recursion loop ("#define restrict restrict")
if [ "$_def_restrict_keyword" != "restrict" ]; then
  _def_restrict_keyword="#define restrict $_def_restrict_keyword"
else
  _def_restrict_keyword=""
fi


echocheck "__builtin_expect"
# GCC branch prediction hint
cat > $TMPC << EOF
int foo (int a) {
    a = __builtin_expect (a, 10);
    return a == 10 ? 0 : 1;
}
int main() { return foo(10) && foo(0); }
EOF
_builtin_expect=no
cc_check && _builtin_expect=yes
if test "$_builtin_expect" = yes ; then
  _def_builtin_expect='#define HAVE_BUILTIN_EXPECT 1'
else
  _def_builtin_expect='#undef HAVE_BUILTIN_EXPECT'
fi
echores "$_builtin_expect"


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
  _def_kstat="#define HAVE_LIBKSTAT 1"
  _ld_arch="-lkstat $_ld_arch"
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 "lrintf"
cat > $TMPC << EOF
#include <math.h>
int main(void) { long (*foo)(float); foo = lrintf; (void)(*foo)(0.0); return 0; }
EOF
_lrintf=no
cc_check -D_GNU_SOURCE $_ld_lm && _lrintf=yes
if test "$_lrintf" = yes ; then
  _def_lrintf="#define HAVE_LRINTF 1"
else
  _def_lrintf="#undef HAVE_LRINTF"
fi
echores "$_lrintf"

echocheck "round"
cat > $TMPC << EOF
#include <math.h>
int main(void) { (void) round(0.0); return 0; }
EOF
_round=no
cc_check $_ld_lm && _round=yes
if test "$_round" = yes ; then
  _def_round="#define HAVE_ROUND 1"
else
  _def_round="#undef HAVE_ROUND"
fi
echores "$_round"

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):
# for BeOS (socket stuff is in -lsocket, gethostbyname and friends in -lbind):
cat > $TMPC << EOF
#include <netdb.h>
#include <sys/socket.h>
int main(void) { (void) gethostbyname(0); (void) socket(AF_INET, SOCK_STREAM, 0); return 0; }
EOF
_socklib=no
for _ld_tmp in "" "-lsocket -lbind" "-lsocket -ldnet" "-lsocket -lnsl" "-lnsl" "-lsocket" ; do
  cc_check $_ld_tmp && _ld_sock="$_ld_tmp" && _socklib=yes && break
done
if test $_winsock2 = auto && not cygwin ; then
  _winsock2=no
  cat > $TMPC << EOF
#include <winsock2.h>
int main(void) { (void) gethostbyname(0); return 0; }
EOF
  cc_check -lws2_32 && _ld_sock="-lws2_32" && _winsock2=yes
fi
test "$_ld_sock" && _res_comment="using $_ld_sock"
echores "$_socklib"


if test $_winsock2 = yes ; then
  _ld_sock="-lws2_32"
  _def_winsock2='#define HAVE_WINSOCK2 1'
else
  _def_winsock2='#undef HAVE_WINSOCK2'
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 test "$_winsock2" = yes ; then
    _res_comment="using winsock2 functions instead"
    echores "no"
elif cc_check $_ld_sock ; then
  # NOTE: Linux has libresolv but does not need it
  :
  _res_comment="using $_ld_sock"
  echores "yes"
elif cc_check $_ld_sock -lresolv ; then
  # NOTE: needed for SunOS at least
  _ld_sock="$_ld_sock -lresolv"
  _res_comment="using $_ld_sock"
  echores "yes"
else
  _res_comment="trying inet_aton next"
  echores "no"
  
  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
    :
    _res_comment="using $_ld_sock"
  elif cc_check $_ld_sock -lresolv ; then
    # NOTE: needed for SunOS at least
    _ld_sock="$_ld_sock -lresolv"
    _res_comment="using $_ld_sock"
  else
    _use_aton=no
    _network=no
    _res_comment="network support disabled"
  fi
  echores "$_use_aton"
fi

_def_use_aton='#undef USE_ATON'
if test "$_use_aton" = yes; 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
echores "$_inttypes"

if test "$_inttypes" = no ; then
  echocheck "bitypes.h (inttypes.h predecessor)"
  cat > $TMPC << EOF
#include <sys/bitypes.h>
int main(void) { return 0; }
EOF
  cc_check && _inttypes=yes
  if test "$_inttypes" = yes ; then
    die "You don't have inttypes.h, but sys/bitypes.h is present. Please copy etc/inttypes.h into the include path, and re-run configure."
  else
    die "Cannot find header either inttypes.h or bitypes.h (see DOCS/HTML/$_doc_lang/faq.html)."
  fi
fi


echocheck "int_fastXY_t in inttypes.h"
cat > $TMPC << EOF
#include <inttypes.h>
int main(void) { 
volatile int_fast16_t v= 0;
return v; }
EOF
_fast_inttypes=no
cc_check && _fast_inttypes=yes
if test "$_fast_inttypes" = yes ; then
  # nothing to do
  :
else
  _def_fast_inttypes='  
    typedef signed char int_fast8_t;
    typedef signed int  int_fast16_t;
    typedef signed int  int_fast32_t;
    typedef signed long long int_fast64_t;
    typedef unsigned char uint_fast8_t;
    typedef unsigned int  uint_fast16_t;
    typedef unsigned int  uint_fast32_t;
    typedef unsigned long long uint_fast64_t;'
fi
echores "$_fast_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'
 _def_map_memalign='#define memalign(a,b) malloc(b)'
 not darwin && _def_memalign_hack='#define MEMALIGN_HACK 1'
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"

cat > $TMPC << EOF
#include <sys/types.h>
#include <sys/mman.h>
int main(void) { void *p = MAP_FAILED; return 0; }
EOF
_mman_has_map_failed=no
cc_check && _mman_has_map_failed=yes
if test "$_mman_has_map_failed" = yes ; then
  _def_mman_has_map_failed=''
else
  _def_mman_has_map_failed='#define MAP_FAILED ((void *) -1)'
fi

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
for _ld_tmp in "" "-ldl" ; do
  cc_check $_ld_tmp && _ld_dl="$_ld_tmp" && _dl=yes && break
done
if test "$_dl" = yes ; then
 _def_dl='#define HAVE_LIBDL 1'
else
 _def_dl='#undef HAVE_LIBDL'
fi
echores "$_dl"


echocheck "dynamic a/v plugins support"
if test "$_dl" = no ; then
  _dynamic_plugins=no
fi
if test "$_dynamic_plugins" = yes ; then
  _def_dynamic_plugins='#define DYNAMIC_PLUGINS 1'
else
  _def_dynamic_plugins='#undef DYNAMIC_PLUGINS'
fi
echores "$_dynamic_plugins"


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

_def_threads='#undef HAVE_THREADS'

echocheck "pthread"
if test "$_pthreads" = auto ; then
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
_pthreads=no
if not hpux ; then
  for _ld_tmp in "-lpthreadGC2" "" "-lpthread" "-pthread" ; do
    # for crosscompilation, we cannot execute the program, be happy if we can link statically
    cc_check $_ld_tmp && (tmp_run || test "$_ld_static") && _ld_pthread="$_ld_tmp" && _pthreads=yes && break
  done
fi
fi
if test "$_pthreads" = yes ; then
  _res_comment="using $_ld_pthread"
  _def_pthreads='#define HAVE_PTHREADS 1'
  _def_threads='#define HAVE_THREADS 1'
else
  _res_comment="v4l, vo_gl, ao_alsa, ao_nas, ao_macosx, win32 loader disabled"
  _def_pthreads='#undef HAVE_PTHREADS'
  _nas=no ; _tv_v4l1=no ; _macosx=no
  if not mingw32 ; then
    _win32=no
  fi
fi
echores "$_pthreads"

echocheck "rpath"
netbsd &&_rpath=yes
if test "$_rpath" = yes ; then
  for I in `echo $_ld_extra | sed 's/-L//g'` ; do
    tmp="$tmp ` echo $I | sed 's/.*/ -L& -Wl,-R&/'`"
  done
_ld_extra=$tmp
fi
echores "$_rpath"

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) {
  size_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
  for _ld_tmp in "" "-liconv" "-liconv $_ld_dl" ; do
    cc_check $_ld_lm $_ld_tmp && _ld_iconv="$_ld_tmp" && _iconv=yes && break
  done
fi
if test "$_iconv" = yes ; then
  _def_iconv='#define USE_ICONV 1'
else
  _def_iconv='#undef USE_ICONV'
fi
echores "$_iconv"


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'
  _include_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 linux || test "$_ossaudio" != no ; then
  # use soundcard.h on Linux, or when OSS support is enabled
  echores "$_soundcard"
else
  # we don't want to use soundcard.h on non-Linux if OSS support not enabled!
  _res_comment= "but ignored!"
  echores "$_soundcard"
  _soundcard=no
fi
if test "$_soundcard" = yes ; then
  _def_soundcard='#define HAVE_SOUNDCARD_H 1'
  _include_soundcard='#include <soundcard.h>'
else
  _def_soundcard='#undef HAVE_SOUNDCARD_H'
fi
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"


if bsdos; then
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"
fi #if bsdos


if hpux; then
# also used by AIX, but AIX does not support VCD and/or libdvdread
echocheck "HP-UX 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_IO 1'
else
  _def_hpux_scsi_h='#undef HPUX_SCTL_IO'
fi
echores "$_hpux_scsi_h"
fi #if hpux


if sunos; then
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"
fi #if sunos


echocheck "termcap"
if test "$_termcap" = auto ; then
  cat > $TMPC <<EOF
int main(void) { tgetent(); return 0; }
EOF
  _termcap=no
  for _ld_tmp in "-lncurses" "-ltinfo" "-ltermcap"; do
    cc_check $_ld_tmp && _ld_termcap="$_ld_tmp" && _termcap=yes && break
  done
fi
if test "$_termcap" = yes ; then
  _def_termcap='#define USE_TERMCAP 1'
  _res_comment="using $_ld_termcap"
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=auto
  cc_check && _termios=yes
  _def_termios_h_name='sys/termios.h'
fi
# second test:
if test "$_termios" = auto ; 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
  _res_comment="using $_def_termios_h_name"
else
  _def_termios='#undef HAVE_TERMIOS'
  _def_termios_h_name=''
  _termios=no
fi
echores "$_termios"


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 "scandir()"
cat > $TMPC << EOF
int main (void) { scandir("", 0, 0, 0); alphasort(0, 0); return 0; }
EOF
_scandir=no
cc_check && _scandir=yes
if test "$_scandir" = yes ; then
 _def_scandir='#define HAVE_SCANDIR 1'
else
 _def_scandir='#undef HAVE_SCANDIR'
fi
echores "$_scandir"


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 "strlcpy()"
cat > $TMPC << EOF
#include <string.h>
int main (void) { char *s = "Hello, world!", t[20]; (void) strlcpy(t, s, sizeof( t )); return 0; }
EOF
_strlcpy=no
cc_check && _strlcpy=yes
if test "$_strlcpy" = yes ; then
 _def_strlcpy='#define HAVE_STRLCPY 1'
else
 _def_strlcpy='#undef HAVE_STRLCPY'
fi
echores "$_strlcpy"

echocheck "strlcat()"
cat > $TMPC << EOF
#include <string.h>
int main (void) { char *s = "Hello, world!", t[20]; (void) strlcat(t, s, sizeof( t )); return 0; }
EOF
_strlcat=no
cc_check && _strlcat=yes
if test "$_strlcat" = yes ; then
 _def_strlcat='#define HAVE_STRLCAT 1'
else
 _def_strlcat='#undef HAVE_STRLCAT'
fi
echores "$_strlcat"

echocheck "fseeko()"
cat > $TMPC << EOF
#include <stdio.h>
int main (void) { int i; i = fseeko(stdin, 0, 0); return 0; }
EOF
_fseeko=no
cc_check && _fseeko=yes
if test "$_fseeko" = yes ; then
 _def_fseeko='#define HAVE_FSEEKO 1'
else
 _def_fseeko='#undef HAVE_FSEEKO'
fi
echores "$_fseeko"

echocheck "localtime_r()"
cat > $TMPC << EOF
#include <time.h>
int main( void ) { localtime_r(NULL, NULL); }
EOF
_localtime_r=no
cc_check && _localtime_r=yes
if test "$_localtime_r" = yes ; then
 _def_localtime_r='#define HAVE_LOCALTIME_R 1'
else
 _def_localtime_r='#undef HAVE_LOCALTIME_R'
fi
echores "$_localtime_r"

echocheck "vsscanf()"
cat > $TMPC << EOF
#include <stdarg.h>
int main(void) { vsscanf(0, 0, 0); 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 "swab()"
cat > $TMPC << EOF
#include <unistd.h>
int main(void) { swab(0, 0, 0); return 0; }
EOF
_swab=no
cc_check && _swab=yes
if test "$_swab" = yes ; then
  _def_swab='#define HAVE_SWAB 1'
else
  _def_swab='#undef HAVE_SWAB'
fi
echores "$_swab"

echocheck "POSIX select()"
cat > $TMPC << EOF
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
int main(void) {int nfds = 1; fd_set readfds; struct timeval timeout; select(nfds,&readfds,NULL,NULL,&timeout); return 0; }
EOF
_posix_select=no
cc_check && _posix_select=yes
if test "$_posix_select" = no ; then
  _def_no_posix_select='#define HAVE_NO_POSIX_SELECT 1'
else
  _def_no_posix_select='#undef HAVE_NO_POSIX_SELECT'
fi
echores "$_posix_select"


echocheck "gettimeofday()"
cat > $TMPC << EOF
#include <stdio.h>
#include <sys/time.h>
int main(void) {struct timeval tv_start; gettimeofday(&tv_start, NULL); return 0; }
EOF
_gettimeofday=no
cc_check && _gettimeofday=yes
if test "$_gettimeofday" = yes ; then
  _def_gettimeofday='#define HAVE_GETTIMEOFDAY 1'
else
  _def_gettimeofday='#undef HAVE_GETTIMEOFDAY'
fi
echores "$_gettimeofday"


echocheck "glob()"
cat > $TMPC << EOF
#include <stdio.h>
#include <glob.h>
int main(void) { glob_t gg; glob("filename",0,NULL,&gg); return 0; }
EOF
_glob=no
cc_check && _glob=yes
if test "$_glob" = yes ; then
  _def_glob='#define HAVE_GLOB 1'
else
  _def_glob='#undef HAVE_GLOB'
fi
echores "$_glob"


echocheck "setenv()"
cat > $TMPC << EOF
#include <stdlib.h>
int main (void){ setenv("","",0); return 0; }
EOF
_setenv=no
cc_check && _setenv=yes
if test "$_setenv" = yes ; then
  _def_setenv='#define HAVE_SETENV 1'
else
  _def_setenv='#undef HAVE_SETENV'
fi
echores "$_setenv"


if sunos; then
echocheck "sysi86()"
cat > $TMPC << EOF
#include <sys/sysi86.h>
int main (void) { sysi86(0); return 0; }
EOF
_sysi86=no
cc_check && _sysi86=yes
if test "$_sysi86" = yes ; then
  _def_sysi86='#define HAVE_SYSI86 1'
else
  _def_sysi86='#undef HAVE_SYSI86'
fi
echores "$_sysi86"
fi #if sunos


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'
else
  _def_sys_sysinfo='#undef HAVE_SYS_SYSINFO_H'
fi
echores "$_sys_sysinfo"


if darwin; then

echocheck "Mac OS X APIs"
if test "$_macosx" = auto ; then
    productName=`/usr/bin/sw_vers -productName`
    if test "$productName" = "Mac OS X" ; then
        _macosx=yes
    else
	_macosx=no
	_def_macosx='#undef MACOSX'
	_noaomodules="macosx $_noaomodules"
	_novomodules="quartz $_novomodules"
    fi
fi
if test "$_macosx" = yes ; then
  cat > $TMPC <<EOF
#include <Carbon/Carbon.h>
#include <QuickTime/QuickTime.h>
#include <CoreAudio/CoreAudio.h>
int main(void) {
    EnterMovies();
    ExitMovies();
    CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
}
EOF
  if cc_check -framework Carbon -framework QuickTime -framework CoreAudio; then 
    _macosx=yes
    _macosx_frameworks="-framework Carbon -framework QuickTime -framework CoreAudio -framework AudioUnit -framework AudioToolbox"
    _def_macosx='#define MACOSX 1'
    _aosrc="$_aosrc ao_macosx.c"
    _aomodules="macosx $_aomodules"
    _vosrc="$_vosrc vo_quartz.c"
    _vomodules="quartz $_vomodules"
  else
    _macosx=no
    _def_macosx='#undef MACOSX'
    _noaomodules="macosx $_noaomodules"
    _novomodules="quartz $_novomodules"
  fi
cat > $TMPC <<EOF
#include <Carbon/Carbon.h>
#include <QuartzCore/CoreVideo.h>
int main(void) {}
EOF
	if cc_check -framework Carbon -framework QuartzCore -framework OpenGL; then
		_vosrc="$_vosrc vo_macosx.m"
		_vomodules="macosx $_vomodules"
		_macosx_frameworks="$_macosx_frameworks -framework Cocoa -framework QuartzCore -framework OpenGL"
		_def_macosx_corevideo='#define MACOSX_COREVIDEO 1'
		_macosx_corevideo=yes
	else
		_novomodules="macosx $_novomodules"
		_def_macosx_corevideo='#undef MACOSX_COREVIDEO'
		_macosx_corevideo=no
	fi
fi
echores "$_macosx"

echocheck "Mac OS X Finder Support"
if test "$_macosx_finder_support" = auto ; then
  _macosx_finder_support=$_macosx
fi
if test "$_macosx_finder_support" = yes; then
  _def_macosx_finder_support='#define MACOSX_FINDER_SUPPORT 1'
  _macosx_finder_support=yes
else
  _def_macosx_finder_support='#undef MACOSX_FINDER_SUPPORT'
  _macosx_finder_support=no
fi 
echores "$_macosx_finder_support"

echocheck "Mac OS X Bundle file locations"
if test "$_macosx_bundle" = auto ; then
  _macosx_bundle=$_macosx_finder_support
fi
if test "$_macosx_bundle" = yes; then
  _def_macosx_bundle='#define MACOSX_BUNDLE 1'
else
  _def_macosx_bundle='#undef MACOSX_BUNDLE'
  _macosx_bundle=no
fi 
echores "$_macosx_bundle"

fi #if darwin


echocheck "Samba support (libsmbclient)"
if test "$_smbsupport" = yes; then
	_ld_smb="-lsmbclient"
fi
if test "$_smbsupport" = auto; then
    _smbsupport=no
    cat > $TMPC << EOF
#include <libsmbclient.h>
int main(void) { smbc_opendir("smb://"); return 0; }
EOF
  for _ld_tmp in "-lsmbclient" "-lsmbclient $_ld_dl" "-lsmbclient $_ld_dl -lnsl" "-lsmbclient $_ld_dl -lssl -lnsl" ; do
    cc_check $_ld_tmp && _ld_smb="$_ld_tmp" && _smbsupport=yes && break
  done
fi

if test "$_smbsupport" = yes; then
    _def_smbsupport="#define LIBSMBCLIENT"
    _inputmodules="smb $_inputmodules"
else
    _def_smbsupport="#undef LIBSMBCLIENT"
    _noinputmodules="smb $_noinputmodules"
fi
echores "$_smbsupport"


#########
# 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 "s3fb"
if test "$_s3fb" = yes ; then
  _def_s3fb='#define HAVE_S3FB 1'
  _vosrc="$_vosrc vo_s3fb.c"
  _vomodules="s3fb $_vomodules"
else
  _def_s3fb='#undef HAVE_S3FB'
  _novomodules="s3fb $_novomodules"
fi
echores "$_s3fb"

echocheck "tdfxvid"
if test "$_tdfxvid" = yes ; then
  _def_tdfxvid='#define HAVE_TDFX_VID 1'
  _vosrc="$_vosrc vo_tdfx_vid.c"
  _vomodules="tdfx_vid $_vomodules"
else
  _def_tdfxvid='#undef HAVE_TDFX_VID'
  _novomodules="tdfx_vid $_novomodules"
fi
echores "$_tdfxfb"

echocheck "tga"
if test "$_tga" = yes ; then
  _def_tga='#define HAVE_TGA 1'
  _vosrc="$_vosrc vo_tga.c"
  _vomodules="tga $_vomodules"
else
  _def_tga='#undef HAVE_TGA'
  _novomodules="tga $_novomodules"
fi
echores "$_tga"


echocheck "DirectFB"
if test "$_directfb" = auto ; then
  _directfb=no
  cat > $TMPC <<EOF
#include <directfb.h>
int main(void) { IDirectFB *foo; DirectFBInit(0,0); return 0; }
EOF
  for _inc_tmp in "" -I/usr/local/include/directfb \
      -I/usr/include/directfb -I/usr/local/include -I/usr/include; do
    cc_check $_inc_tmp -ldirectfb && _directfb=yes && \
      _inc_extra="$_inc_extra $_inc_tmp" && break
  done
fi

dfb_version() {
	expr $1 \* 65536 + $2 \* 256 + $3
}

if test "$_directfb" = yes; then
  cat > $TMPC << EOF
#include <directfb_version.h>
int
dfb_ver = DIRECTFB_MAJOR_VERSION.DIRECTFB_MINOR_VERSION.DIRECTFB_MICRO_VERSION
;
EOF
  if $_cc -E $TMPC $_inc_extra > "$TMPO"; then
    _directfb_version=`sed -n 's/^dfb_ver[^0-9]*\(.*\)/\1/p' "$TMPO" | tr -d '()'`
    _dfb_major=`echo $_directfb_version | cut -d . -f 1`
    _dfb_minor=`echo $_directfb_version | cut -d . -f 2`
    _dfb_micro=`echo $_directfb_version | cut -d . -f 3`
    _dfb_version=$(dfb_version $_dfb_major $_dfb_minor $_dfb_micro)
    if test "$_dfb_version" -ge $(dfb_version 0 9 13); then
	_def_directfb_version="#define DIRECTFBVERSION $_dfb_version"
	_res_comment="$_directfb_version"
    else
        _def_directfb_version='#undef DIRECTFBVERSION'
	_directfb=no
	_res_comment="version >=0.9.13 required"
    fi
  else
    _directfb=no
    _res_comment="failed to get version"
  fi
fi
echores "$_directfb"

if test "$_directfb" = yes ; then
  _def_directfb='#define HAVE_DIRECTFB 1'
  if test "$_dfb_version" -ge $(dfb_version 0 9 13); then
    _vosrc="$_vosrc vo_directfb2.c"
    _vomodules="directfb $_vomodules"
    _ld_directfb='-ldirectfb'
  else
    _novomodules="directfb $_novomodules"
  fi

  if test "$_dfb_version" -ge $(dfb_version 0 9 15); then
    _vosrc="$_vosrc vo_dfbmga.c"
    _vomodules="dfbmga $_vomodules"
    _def_dfbmga='#define HAVE_DFBMGA 1'
  else
    _novomodules="dfbmga $_novomodules"
    _def_dfbmga='#undef HAVE_DFBMGA'
  fi
else
  _def_directfb='#undef HAVE_DIRECTFB'
  _novomodules="dfbmga directfb $_novomodules"
fi


echocheck "X11 headers presence"
  for I in `echo $_inc_extra | sed s/-I//g` /usr/X11/include /usr/X11R6/include /usr/include/X11R6 /usr/include /usr/openwin/include ; do
    if test -f "$I/X11/Xlib.h" ; then
      _inc_x11="-I$I"
      _x11_headers="yes"
      _res_comment="using $I"
      break
    fi
  done
  #FIXME: This is ugly as it can duplicate a -I parameter..
  _inc_extra="$_inc_extra $_inc_x11"
  if test -z "$_inc_x11" ; then
    _x11=no
    _x11_headers="no"
    _res_comment="check if the dev(el) packages are installed"
  fi
echores "$_x11_headers"


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
  for I in $_ld_x11 "" -L/usr/X11R6/lib -L/usr/lib/X11R6 -L/usr/X11/lib \
           -L/usr/lib32 -L/usr/openwin/lib -L/usr/X11R6/lib64 -L/usr/lib ; do
    _ld_x11="$I -lXext -lX11 $_ld_sock $_ld_pthread"
    if netbsd; then
      _ld_x11="$_ld_x11 -Wl,-R`echo $I | sed s/^-L//`"
    fi
    cc_check $_ld_x11 && _x11=yes && break
  done
fi
if test "$_x11" = yes ; then
  _def_x11='#define HAVE_X11 1'
  _vosrc="$_vosrc x11_common.c vo_x11.c vo_xover.c"
  _vomodules="x11 xover $_vomodules"
else
  _x11=no
  _def_x11='#undef HAVE_X11'
  _ld_x11=''
  _novomodules="x11 $_novomodules"
  _res_comment="check if the dev(el) packages are installed"
  # disable stuff that depends on X
  _xv=no ; _xvmc=no ; _xinerama=no ; _vm=no ; _xf86keysym=no ; _dga=no
fi
echores "$_x11"


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


echocheck "Xv"
if test "$_xv" = auto ; then
  cat > $TMPC <<EOF
#include <X11/Xlib.h>
#include <X11/extensions/Xvlib.h>
int main(void) {
  (void) XvGetPortAttribute(0, 0, 0, 0);
  (void) XvQueryPortAttributes(0, 0, 0);
  return 0; }
EOF
  _xv=no
  cc_check -lXv $_ld_x11 && _xv=yes
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 "XvMC"
if test "$_xv" = yes && test "$_xvmc" != no ; then
  _xvmc=no
  cat > $TMPC <<EOF
#include <X11/Xlib.h>
#include <X11/extensions/Xvlib.h>
#include <X11/extensions/XvMClib.h>
int main(void) { 
  (void) XvMCQueryExtension(0,0,0);
  (void) XvMCCreateContext(0,0,0,0,0,0,0);
  return 0; }
EOF
  for _ld_tmp in $_xvmclib XvMCNVIDIA XvMCW I810XvMC ; do
    cc_check -lXvMC -l$_ld_tmp $_ld_xv $_ld_x11 && _xvmc=yes && _xvmclib="$_ld_tmp" && break
  done
fi
if test "$_xvmc" = yes ; then
  _def_xvmc='#define HAVE_XVMC 1'
  _ld_xvmc="-lXvMC -l$_xvmclib"
  _vosrc="$_vosrc vo_xvmc.c"
  _vomodules="xvmc $_vomodules"
  _res_comment="using $_xvmclib"
else
  _def_xvmc='#undef HAVE_XVMC'
  _novomodules="xvmc $_novomodules"
fi
echores "$_xvmc"


echocheck "Xinerama"
if test "$_xinerama" = auto ; 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 -lXinerama $_ld_x11 && _xinerama=yes
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 "$_vm" = auto ; 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 -lXxf86vm $_ld_x11 && _vm=yes
fi
if test "$_vm" = yes ; then
  _def_vm='#define HAVE_XF86VM 1'
  _ld_vm='-lXxf86vm'
else
  _def_vm='#undef HAVE_XF86VM'
fi
echores "$_vm"

# Check for the presence of special keycodes, like audio control buttons
# that XFree86 might have.  Used to be bundled with the xf86vm check, but
# has nothing to do with xf86vm and XFree 3.x has xf86vm but does NOT
# have these new keycodes.
echocheck "XF86keysym"
if test "$_xf86keysym" = auto; then
  _xf86keysym=no
  cat > $TMPC <<EOF
#include <X11/Xlib.h>
#include <X11/XF86keysym.h>
int main(void) { return XF86XK_AudioPause; }
EOF
  cc_check $_ld_x11 && _xf86keysym=yes
fi
if test "$_xf86keysym" = yes ; then
  _def_xf86keysym='#define HAVE_XF86XK 1'
else
  _def_xf86keysym='#undef HAVE_XF86XK'
fi
echores "$_xf86keysym"

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 -lXxf86dga -lXxf86vm $_ld_x11 && _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 -lXxf86dga $_ld_x11 && _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"
  _res_comment="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"
  _res_comment="using DGA 2.0"
elif test "$_dga" = no ; then
  _novomodules="dga $_novomodules"
else
  die "DGA version must be 1 or 2"
fi
echores "$_dga"


echocheck "OpenGL"
#Note: this test is run even with --enable-gl since we autodetect $_ld_gl
if (test "$_x11" = yes || win32) && test "$_gl" != no ; then
  cat > $TMPC << EOF
#include <GL/gl.h>
int main(void) { return 0; }
EOF
  _gl=no
  if cc_check $_ld_x11 -lGL $_ld_lm ; then
    _gl=yes
    _ld_gl="-lGL $_ld_dl"
  elif cc_check $_ld_x11 -lGL $_ld_lm $_ld_pthread ; then
    _gl=yes
    _ld_gl="-lGL $_ld_pthread $_ld_dl"
  elif cc_check -lopengl32 ; then
    _gl=yes
    _gl_win32=yes
    _ld_gl="-lopengl32 -lgdi32"
  fi
else
  _gl=no
fi
if test "$_gl" = yes ; then
  _def_gl='#define HAVE_GL 1'
  _vosrc="$_vosrc vo_gl.c vo_gl2.c gl_common.c"
  if test "$_gl_win32" = yes ; then
    _def_gl_win32='#define GL_WIN32 1' 
    _vosrc="$_vosrc w32_common.c"
    _res_comment="win32 version"
  fi
  _vomodules="opengl $_vomodules"
else
  _def_gl='#undef HAVE_GL'
  _def_gl_win32='#undef GL_WIN32'
  _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 "GGI extension: libggiwmh"
if test "$_ggiwmh" = auto ; then
  _ggiwmh=no
  cat > $TMPC << EOF
#include <ggi/ggi.h>
#include <ggi/wmh.h>
int main(void) { return 0; }
EOF
  cc_check -lggi -lggiwmh && _ggiwmh=yes
fi
# needed to get right output on obscure combination
# like --disable-ggi --enable-ggiwmh
if test "$_ggi" = yes && test "$_ggiwmh" = yes ; then
  _def_ggiwmh='#define HAVE_GGIWMH 1'
  _ld_ggi="$_ld_ggi -lggiwmh"
else
  _ggiwmh=no
  _def_ggiwmh='#undef HAVE_GGIWMH'
fi
echores "$_ggiwmh"


echocheck "AA"
if test "$_aa" = auto ; then
  cat > $TMPC << EOF
#include <aalib.h>
extern struct aa_hardware_params aa_defparams;
extern struct aa_renderparams aa_defrenderparams;
int main(void) {
aa_context *c;
aa_renderparams *p;
(void) aa_init(0, 0, 0);
c = aa_autoinit(&aa_defparams);
p = aa_getrenderparams();
aa_autoinitkbd(c,0);
return 0; }
EOF
  _aa=no
  for _ld_tmp in "-laa" "$_ld_x11 -laa" ; do
    cc_check $_ld_tmp && _ld_aa=$_ld_tmp && _aa=yes && break
  done
fi
if test "$_aa" = yes ; then
  _def_aa='#define HAVE_AA 1'
  if cygwin ; then
    _ld_aa=`aalib-config --libs | cut -d " " -f 2,5,6`
  fi
  _vosrc="$_vosrc vo_aa.c"
  _vomodules="aa $_vomodules"
else
  _def_aa='#undef HAVE_AA'
  _novomodules="aa $_novomodules"
fi
echores "$_aa"


echocheck "CACA"
if test "$_caca" = auto ; then
  _caca=no
  if ( caca-config --version ) >> "$TMPLOG" 2>&1 ; then
  cat > $TMPC << EOF
#include <caca.h>
#ifdef CACA_API_VERSION_1
  #include <caca0.h>
#endif
int main(void) { (void) caca_init(); return 0; }
EOF
  cc_check `caca-config --libs` && _caca=yes
  fi
fi
if test "$_caca" = yes ; then
  _def_caca='#define HAVE_CACA 1'
  _inc_extra="$_inc_extra `caca-config --cflags`"
  _ld_caca=`caca-config --libs`
  _vosrc="$_vosrc vo_caca.c"
  _vomodules="caca $_vomodules"
else
  _def_caca='#undef HAVE_CACA'
  _novomodules="caca $_novomodules"
fi
echores "$_caca"


echocheck "SVGAlib"
if test "$_svga" = auto ; then
  cat > $TMPC << EOF
#include <vga.h>
int main(void) { return 0; }
EOF
  _svga=no
  cc_check -lvga $_ld_lm && _svga=yes
fi
if test "$_svga" = yes ; then
  _def_svga='#define HAVE_SVGALIB 1'
  _ld_svga="-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 vo_fbdev2.c"
  _vomodules="fbdev $_vomodules"
else
  _def_fbdev='#undef HAVE_FBDEV'
  _novomodules="fbdev $_novomodules"
fi
echores "$_fbdev"



echocheck "DVB"
if test "$_dvb" = auto ; then
  _dvb=no
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
  for _inc_tmp in "" "-I/usr/src/DVB/ost/include" ; do
    cc_check $_inc_tmp && _dvb=yes && \
     _inc_extra="$_inc_extra $_inc_tmp" && break
  done
fi
echores "$_dvb"
if test "$_dvb" = yes ; then
  _def_dvb='#define HAVE_DVB 1'
  _def_dvb_in='#define HAS_DVBIN_SUPPORT 1'
  _aomodules="mpegpes(dvb) $_aomodules"
  _vomodules="mpegpes(dvb) $_vomodules"
fi

echocheck "DVB HEAD"
if test "$_dvbhead" = auto ; then
  _dvbhead=no

cat >$TMPC << EOF
#include <sys/poll.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>

#include <linux/dvb/dmx.h>
#include <linux/dvb/frontend.h>
#include <linux/dvb/video.h>
#include <linux/dvb/audio.h>
int main(void) {return 0;}
EOF
  for _inc_tmp in "" "-I/usr/src/DVB/include" ; do
    cc_check $_inc_tmp && _dvbhead=yes && \
      _inc_extra="$_inc_extra $_inc_tmp" && break
  done
fi
echores "$_dvbhead"
if test "$_dvbhead" = yes ; then
  _def_dvb='#define HAVE_DVB_HEAD 1'
  _def_dvb_in='#define HAS_DVBIN_SUPPORT 1'
  _aomodules="mpegpes(dvb) $_aomodules"
  _vomodules="mpegpes(dvb) $_vomodules"
fi

if test "$_dvbhead" = no && test "$_dvb" = no ; then
  _def_dvb='#undef HAVE_DVB'
  _def_dvb_in='#undef HAS_DVBIN_SUPPORT '
  _aomodules="mpegpes(file) $_aomodules"
  _vomodules="mpegpes(file) $_vomodules"
fi

if test "$_dvb" = yes || test "$_dvbhead" = yes ; then
    _dvbin=yes
    _inputmodules="dvb $_inputmodules"
else
    _dvbin=no
    _noinputmodules="dvb $_noinputmodules"
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
    _res_comment="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 $_ld_lm ; then
      if tmp_run ; then
        _png=yes
      else
        _res_comment="mismatch of library and header versions"
      fi
    fi
  fi
fi
echores "$_png"
if test "$_png" = yes ; then
  _def_png='#define HAVE_PNG 1'
  _ld_png='-lpng -lz'
  _vosrc="$_vosrc vo_png.c"
  _vomodules="png $_vomodules"
else
  _def_png='#undef HAVE_PNG'
  _novomodules="png $_novomodules"
fi

echocheck "JPEG support"
if test "$_jpeg" = auto ; then
  _jpeg=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 $_ld_lm ; then
      if tmp_run ; then
        _jpeg=yes
      fi
    fi
fi
echores "$_jpeg"

if test "$_jpeg" = yes ; then
  _def_jpeg='#define HAVE_JPEG 1'
  _vosrc="$_vosrc vo_jpeg.c"
  _vomodules="jpeg $_vomodules"
  _ld_jpeg="-ljpeg"
else
  _def_jpeg='#undef HAVE_JPEG'
  _novomodules="jpeg $_novomodules"
fi



echocheck "PNM support"
if test "$_pnm" = yes; then
  _def_pnm="#define HAVE_PNM"
  _vosrc="$_vosrc vo_pnm.c"
  _vomodules="pnm $_vomodules"
else
  _def_pnm="#undef HAVE_PNM"
  _novomodules="pnm $_novomodules"
fi
echores "$_pnm"



echocheck "GIF support"
# This is to appease people who want to force gif support.
# If it is forced to yes, then we still do checks to determine
# which gif library to use.
if test "$_gif" = yes ; then
  _force_gif=yes
  _gif=auto
fi

if test "$_gif" = auto ; then
  _gif=no
cat > $TMPC << EOF
#include <gif_lib.h>
int main(void) {
  return 0;
}
EOF
  for _ld_tmp in "-lungif" "-lungif $_ld_x11" "-lgif" "-lgif $_ld_x11" ; do
    cc_check $_ld_tmp && tmp_run && _ld_gif="$_ld_tmp" && _gif=yes && break
  done
fi

# If no library was found, and the user wants support forced,
# then we force it on with libgif, as this is the safest
# assumption IMHO.  (libungif & libregif both create symbolic
# links to libgif.  We also assume that no x11 support is needed,
# because if you are forcing this, then you _should_ know what
# you are doing.  [ Besides, package maintainers should never
# have compiled x11 deps into libungif in the first place. ] )
# </rant>
#   --Joey
if test "$_force_gif" = yes && test "$_gif" = no ; then
  _gif=yes
  _ld_gif="-lgif"
fi

if test "$_gif" = yes ; then
  _def_gif='#define HAVE_GIF 1'
  _vosrc="$_vosrc vo_gif89a.c"
  _codecmodules="gif $_codecmodules"
  _vomodules="gif89a $_vomodules"
  _res_comment="old version, some encoding 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" && tmp_run ; then
    _def_gif_4='#define HAVE_GIF_4 1'
    _res_comment=""
  fi
else
  _def_gif='#undef HAVE_GIF'
  _def_gif_4='#undef HAVE_GIF_4'
  _novomodules="gif89a $_novomodules"
  _nocodecmodules="gif $_nocodecmodules"
fi
echores "$_gif"


case "$_gif" in yes*)
  echocheck "broken giflib workaround"
  _def_gif_tvt_hack='#define HAVE_GIF_TVT_HACK 1'

  cat > $TMPC << EOF
#include <gif_lib.h>
int main(void) {
  GifFileType gif;
  printf("UserData is at address %p\n", gif.UserData);
  return 0;
}
EOF
  if cc_check "$_ld_gif" && tmp_run ; then
    _def_gif_tvt_hack='#undef HAVE_GIF_TVT_HACK'
    echores "disabled"
  else
    echores "enabled"
  fi
  ;;
esac


echocheck "VESA support"
if test "$_vesa" = auto ; then
  cat > $TMPC << EOF
#include <vbe.h>
int main(void) { vbeVersion(); return 0; }
EOF
  _vesa=no
  cc_check -lvbe -llrmi && _vesa=yes
fi
if test "$_vesa" = yes ; then
  _def_vesa='#define HAVE_VESA 1'
  _ld_vesa="-lvbe -llrmi"
  _vosrc="$_vosrc vo_vesa.c vesa_lvo.c gtf.c"
  _vomodules="vesa $_vomodules"
else
  _def_vesa='#undef HAVE_VESA'
  _novomodules="vesa $_novomodules"
fi
echores "$_vesa"

#################
# 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
          _res_comment="outdated"
        fi
     fi
  fi
fi
if test "$_sdl" = yes ; then
  _def_sdl='#define HAVE_SDL 1'
  if cygwin ; then
    _ld_sdl=`$_sdlconfig --libs | cut -d " " -f 1,4,6 | sed s/no-cygwin/cygwin/`
    _inc_extra="$_inc_extra `$_sdlconfig --cflags | cut -d " " -f 1,5,6 | sed s/no-cygwin/cygwin/`"
  elif mingw32 ; then
    _ld_sdl=`$_sdlconfig --libs | sed s/-mwindows//`
    _inc_extra="$_inc_extra `$_sdlconfig --cflags | sed s/-Dmain=SDL_main//`"
  else
    _ld_sdl=`$_sdlconfig --libs`
    _inc_extra="$_inc_extra `$_sdlconfig --cflags`"
  fi
  _vosrc="$_vosrc vo_sdl.c"
  _vomodules="sdl $_vomodules"
  _aosrc="$_aosrc ao_sdl.c"
  _aomodules="sdl $_aomodules"
  _res_comment="using $_sdlconfig"
else
  _def_sdl='#undef HAVE_SDL'
  _novomodules="sdl $_novomodules"
  _noaomodules="sdl $_noaomodules"
fi
echores "$_sdl"


if win32; then

echocheck "Windows waveout"
if test "$_win32waveout" = auto ; then
  cat > $TMPC << EOF
#include <windows.h>
#include <mmsystem.h>
int main(void) { return 0; }
EOF
  _win32waveout=no
  cc_check -lwinmm && _win32waveout=yes
fi
if test "$_win32waveout" = yes ; then
  _def_win32waveout='#define HAVE_WIN32WAVEOUT 1'
  _ld_win32libs="-lwinmm $_ld_win32libs"
  _aosrc="$_aosrc ao_win32.c"
  _aomodules="win32 $_aomodules"
else
  _def_win32waveout='#undef HAVE_WIN32WAVEOUT'
  _noaomodules="win32 $_noaomodules"
fi
echores "$_win32waveout"

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

fi #if win32; then


echocheck "NAS"
if test "$_nas" = auto ; then
  cat > $TMPC << EOF
#include <audio/audiolib.h>
int main(void) { return 0; }
EOF
  _nas=no
  cc_check $_ld_lm -laudio -lXt $_ld_x11 && _nas=yes
fi
if test "$_nas" = yes ; then
  _def_nas='#define HAVE_NAS 1'
  _ld_nas="-laudio -lXt $_ld_x11"
  _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
    cat > $TMPC << EOF
#include <dxr2ioctl.h>
int main(void) { return 0; }
EOF
  for _inc_tmp in "" -I/usr/local/include/dxr2 -I/usr/include/dxr2; do
    cc_check $_inc_tmp && _dxr2=yes && \
     _inc_extra="$_inc_extra $_inc_tmp" && 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"
else
  _def_dxr2='#undef HAVE_DXR2'
  _noaomodules="dxr2 $_noaomodules"
  _novomodules="dxr2 $_novomodules"
fi
echores "$_dxr2"

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"
fi
echores "$_dxr3"


echocheck "IVTV TV-Out"
if test "$_ivtv" = auto ; then
  cat > $TMPC << EOF
#include <stdlib.h>
#include <inttypes.h>
#include <linux/types.h>
#include <linux/videodev2.h>
#include <linux/ivtv.h>
int main(void) { return 0; }
EOF
  _ivtv=no
  cc_check && _ivtv=yes
fi
if test "$_ivtv" = yes ; then
  _def_ivtv='#define HAVE_IVTV 1'
  _vosrc="$_vosrc vo_ivtv.c"
  _vomodules="ivtv $_vomodules"
  _aosrc="$_aosrc ao_ivtv.c"
  _aomodules="ivtv $_aomodules"
else
  _def_ivtv='#undef HAVE_IVTV'
  _novomodules="ivtv $_novomodules"
  _noaomodules="ivtv $_noaomodules"
fi
echores "$_ivtv"


echocheck "libfame"
if test "$_libfame" = auto ; then
  _libfame=no
  test "$_dxr2" = yes && _libfame=auto
  test "$_dxr3" = yes && _libfame=auto
  test "$_dvb"  = yes && _libfame=auto
fi
if test "$_libfame" = auto ; then
  _libfame=no
  if test -d libfame && test -f libfame/fame.h ; then
    # disable libfame on Cygwin as porting makes no sense
    cygwin || _libfame=yes
  else
    _res_comment="no libfame dir"
  fi
fi
echores "$_libfame"

_def_libfame='#undef USE_LIBFAME'
if test "$_libfame" = yes ; then
  _def_libfame='#define USE_LIBFAME 1'
  _ld_libfame='libfame/libfame.a'
fi


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


echocheck "OSS Audio"
if test "$_ossaudio" = auto ; then
  cat > $TMPC << EOF
#include <sys/ioctl.h>
$_include_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
     cat > $TMPC << EOF
#include <sys/ioctl.h>
$_include_soundcard
#ifdef OPEN_SOUND_SYSTEM
int main(void) { return 0; }
#else
#error Not the real thing
#endif
EOF
     _real_ossaudio=no
     cc_check && _real_ossaudio=yes
     if test "$_real_ossaudio" = yes; then
       _def_ossaudio_devdsp='#define PATH_DEV_DSP "/dev/dsp"'
     elif netbsd || openbsd ; then
       _def_ossaudio_devdsp='#define PATH_DEV_DSP "/dev/sound"'
       _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` && tmp_run && _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_extra="$_inc_extra `artsc-config --cflags`"
else
  _noaomodules="arts $_noaomodules"
fi
echores "$_arts"


echocheck "EsounD"
if test "$_esd" = auto ; then
  _esd=no
  if ( esd-config --version ) >> "$TMPLOG" 2>&1 ; then

cat > $TMPC << EOF
#include <esd.h>
int main(void) { return 0; }
EOF
cc_check `esd-config --libs` `esd-config --cflags` && tmp_run && _esd=yes

  fi
fi
echores "$_esd"

if test "$_esd" = yes ; then
  _def_esd='#define USE_ESD 1'
  _aosrc="$_aosrc ao_esd.c"
  _aomodules="esd $_aomodules"
  _ld_esd=`esd-config --libs`
  _inc_extra="$_inc_extra `esd-config --cflags`"

  echocheck "esd_get_latency()"
  cat > $TMPC << EOF
#include <esd.h>
int main(void) { return esd_get_latency(0); }
EOF
  cc_check `esd-config --libs` `esd-config --cflags` && _esd_latency=yes && _def_esd_latency='#define HAVE_ESD_LATENCY'
  echores "$_esd_latency"
else
  _def_esd='#undef USE_ESD'
  _def_esd_latency='#undef HAVE_ESD_LATENCY'
  _noaomodules="esd $_noaomodules"
fi

echocheck "pulse"
if test "$_pulse" = auto ; then
  _pulse=no
  if pkg-config --exists 'pulse >= 0.9' ; then

cat > $TMPC << EOF
#include <pulse/pulseaudio.h>
int main(void) { return 0; }
EOF
cc_check `pkg-config --libs --cflags libpulse` && tmp_run && _pulse=yes

  fi
fi
echores "$_pulse"

if test "$_pulse" = yes ; then
  _def_pulse='#define USE_PULSE 1'
  _aosrc="$_aosrc ao_pulse.c"
  _aomodules="pulse $_aomodules"
  _ld_pulse=`pkg-config --libs libpulse`
  _inc_extra="$_inc_extra `pkg-config --cflags libpulse`"
else
  _def_pulse='#undef USE_PULSE'
  _noaomodules="pulse $_noaomodules"
fi


echocheck "JACK"
if test "$_jack" = auto ; then
  _jack=yes

cat > $TMPC << EOF
#include <jack/jack.h>
int main(void) { jack_client_new("test"); return 0; }
EOF
  if cc_check -ljack ; then
    _ld_jack="-ljack"
  elif cc_check `pkg-config --libs --cflags --silence-errors jack` ; then
    _ld_jack="`pkg-config --libs jack`"
    _inc_extra="$_inc_extra "`pkg-config --cflags jack`""
  else
    _jack=no
  fi
fi

if test "$_jack" = yes ; then
  _def_jack='#define USE_JACK 1'
  _aosrc="$_aosrc ao_jack.c"
  _aomodules="jack $_aomodules"
else
  _noaomodules="jack $_noaomodules"
fi
echores "$_jack"

echocheck "OpenAL"
if test "$_openal" = auto ; then
  _openal=no
cat > $TMPC << EOF
#include <AL/al.h>
int main(void) {
  alSourceQueueBuffers(0, 0, 0);
//  alGetSourcei(0, AL_SAMPLE_OFFSET, 0);
  return 0;
}
EOF
  if cc_check -lopenal ; then
    _ld_openal="-lopenal"
    _openal=yes
  fi
fi
if test "$_openal" = yes ; then
  _def_openal='#define USE_OPENAL 1'
  _aosrc="$_aosrc ao_openal.c"
  _aomodules="openal $_aomodules"
else
  _noaomodules="openal $_noaomodules"
fi
echores "$_openal"

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

  cat > $TMPC << EOF
#include <sys/asoundlib.h>
#if !((SND_LIB_MAJOR == 0) && (SND_LIB_MINOR == 9))
#error "alsa version != 0.9.x"
#endif
int main(void) { return 0; }
EOF
  cc_check -lasound $_ld_dl $_ld_pthread && _alsaver='0.9.x-sys'
  cat > $TMPC << EOF
#include <alsa/asoundlib.h>
#if !((SND_LIB_MAJOR == 0) && (SND_LIB_MINOR == 9))
#error "alsa version != 0.9.x"
#endif
int main(void) { return 0; }
EOF
  cc_check -lasound $_ld_dl $_ld_pthread && _alsaver='0.9.x-alsa'

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


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"


if sunos; then
echocheck "Sun mediaLib"
if test "$_mlib" = auto ; then
  _mlib=no
  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 $_ld_mlib -lmlib && _mlib=yes
fi
if test "$_mlib" = yes ; then
  _def_mlib='#define HAVE_MLIB 1'
  _ld_mlib="$_ld_mlib `echo $_ld_mlib | sed s/^-L/-R/` -lmlib"
else
  _def_mlib='#undef HAVE_MLIB'
fi
echores "$_mlib"
fi #if sunos


if irix; then
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"
fi #if irix


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

echocheck "DVD support (libdvdnav)"
if test "$_dvdnav" = auto ; then
  $_dvdnavconfig --version >> $TMPLOG 2>&1 || _dvdnav=no
fi
if test "$_dvdnav" = auto ; then
  cat > $TMPC <<EOF
#include <dvdnav.h>
int main(void) { dvdnav_t *dvd=0; return 0; }
EOF
  _dvdnav=no
  _dvdnavdir=`$_dvdnavconfig --cflags`
  _dvdnavlibs=`$_dvdnavconfig --libs`
  _dvdnavvsn=`$_dvdnavconfig --version | sed "s/\.//g"`
  _used_css=
  _dvdnavmajor=`echo $_dvdnavvsn | cut -d. -f2`
  test "$_dvdnavmajor" -ge 2 -o "$_dvdnavvsn" -ge 0110 && \
       cc_check $_dvdnavdir $_dvdnavlibs $_used_css $_ld_dl $_ld_pthread && _dvdnav=yes
fi
if test "$_dvdnav" = yes ; then
  _largefiles=yes
  _def_dvdnav='#define USE_DVDNAV 1'
  _ld_dvdnav=`$_dvdnavconfig --libs`
  _dvdnav_version=`$_dvdnavconfig --version | sed "s/\.//g"`
  _def_dvdnav_version="#define DVDNAVVERSION $_dvdnav_version"
  _inc_extra="$_inc_extra `$_dvdnavconfig --cflags`"
  _inputmodules="dvdnav $_inputmodules"
  
  #disable mpdvdkit and dvdread checks: dvdread will be enabled using dvdnav's version of dvdread
  _mpdvdkit=no
  _dvdread=yes
else
  _def_dvdnav='#undef USE_DVDNAV'
  _noinputmodules="dvdnav $_noinputmodules"
fi
echores "$_dvdnav"

echocheck "DVD support (libmpdvdkit2)"
if test "$_mpdvdkit" = auto ; then
 _mpdvdkit=no
 if linux || freebsd || netbsd || darwin || openbsd || win32 || sunos || hpux; then
  test -f "./libmpdvdkit2/Makefile" && _mpdvdkit=yes
 fi
fi
if test "$_mpdvdkit" = yes ; then
  if test "$_dvd" = yes || test "$_cdrom" = yes || test "$_cdio" = yes || test "$_dvdio" = yes || test "$_bsdi_dvd" = yes || test "$_hpux_scsi_h" = yes || darwin || win32 ; then
    _inputmodules="mpdvdkit2 $_inputmodules"
    _dvdread=libmpdvdkit2
  else
    _noinputmodules="mpdvdkit2 $_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'
  _def_dvd_darwin='#undef DARWIN_DVD_IOCTL'
  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'
    else
      if darwin ; then
       _def_dvd_darwin='#define DARWIN_DVD_IOCTL'
      fi
    fi
  fi
else
  _noinputmodules="mpdvdkit2 $_noinputmodules"
fi
echores "$_mpdvdkit"

echocheck "DVD support (libdvdread)"
if test "$_dvdread" = auto ; then
  cat > $TMPC << EOF
#include <inttypes.h>
#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'
        if test "$_dvdnav" != yes ; then
          _ld_dvdread='-ldvdread'
        fi
	_inputmodules="dvdread $_inputmodules"
	_have_dvd=yes
	;;
  no)
	_def_dvdread='#undef USE_DVDREAD'
	_noinputmodules="dvdread $_noinputmodules"
	;;
  libmpdvdkit2)
	_largefiles=yes
	_def_dvdread='#define USE_DVDREAD 1'
	_ld_dvdread='-Llibmpdvdkit2 -lmpdvdkit'
	_noinputmodules="dvdread $_noinputmodules"
	_def_mpdvdkit="#define USE_MPDVDKIT 2"
	_have_dvd=yes
	_dvdread=no
	_res_comment="disabled by libmpdvdkit2"
	;;
esac
echores "$_dvdread"

if test "$_have_dvd" = yes ; then
  _def_have_dvd='#define HAVE_DVD 1'
else
  _def_have_dvd='#undef HAVE_DVD'
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
    for _inc_tmp in "" "-I/usr/include/cdda" "-I/usr/local/include/cdda" ; do
      cc_check $_inc_tmp $_ld_cdparanoia -lcdda_interface -lcdda_paranoia $_ld_lm && \
        _cdparanoia=yes && _inc_extra="$_inc_extra $_inc_tmp" && break
    done
fi
if test "$_cdparanoia" = yes ; then
    _cdda='yes'
    _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 "libcdio"
if test "$_libcdio" = auto && test "$_cdparanoia" = no ; then
    if pkg-config --exists libcdio ; then
        cat > $TMPC << EOF
#include <stdio.h>
#include <cdio/version.h>
#include <cdio/cdda.h>
#include <cdio/paranoia.h>
int main()
{
    printf("%s\n", CDIO_VERSION);
    return 0;
    
}
EOF
        _libcdio=no
    for _inc_tmp in "" "-I/usr/include/cdio" "-I/usr/local/include/cdio" ; do
        cc_check `pkg-config --cflags --libs libcdio_paranoia` $_inc_tmp $_ld_lm \
          && tmp_run && _libcdio=yes && _inc_extra="$_inc_extra $_inc_tmp" && break
    done
    else
        _libcdio=no
    fi
fi
if test "$_libcdio" = yes && test "$_cdparanoia" = no ; then
    _cdda='yes'
    _def_libcdio='#define HAVE_LIBCDIO'
    _def_cdparanoia='#define HAVE_CDDA'
    _def_havelibcdio='yes'
    _inputmodules="cdda $_inputmodules"
    _inc_extra="$_inc_extra `pkg-config --cflags libcdio`"
    _ld_libcdio=`pkg-config --libs libcdio_paranoia`
else
    if test "$_cdparanoia" = yes ; then
       _res_comment="using cdparanoia"
    fi
    _def_libcdio='#undef HAVE_LIBCDIO'
    _def_havelibcdio='no'
fi
echores "$_libcdio"


echocheck "bitmap font support"
if test "$_bitmap_font" = yes ; then
  _def_bitmap_font="#define HAVE_BITMAP_FONT 1"
else
  _def_bitmap_font="#undef HAVE_BITMAP_FONT"
fi
echores "$_bitmap_font"


echocheck "freetype >= 2.0.9"

# freetype depends on iconv
if test "$_iconv" = no ; then
    _freetype=no
    _res_comment="iconv support needed"
fi

if test "$_freetype" = auto ; then
    if ( $_freetypeconfig --version ) >/dev/null 2>&1 ; then
	cat > $TMPC << EOF
#include <stdio.h>
#include <ft2build.h>
#include FT_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` && tmp_run && _freetype=yes
    else
	_freetype=no
    fi
fi
if test "$_freetype" = yes ; then
    _def_freetype='#define HAVE_FREETYPE'
    _inc_extra="$_inc_extra `$_freetypeconfig --cflags`"
    _ld_freetype=`$_freetypeconfig --libs`
else
    _def_freetype='#undef HAVE_FREETYPE'
fi
echores "$_freetype"

if test "$_freetype" = no ; then
    _fontconfig=no
    _res_comment="freetype support needed"
fi
echocheck "fontconfig"
if test "$_fontconfig" = auto ; then
        cat > $TMPC << EOF
#include <stdio.h>
#include <fontconfig/fontconfig.h>
int main()
{
    int err = FcInit();
    if(err == FcFalse){
        printf("Couldn't initialize fontconfig lib\n");
        exit(err);
    }
    return 0;
    
}
EOF
  _fontconfig=yes
  if cc_check -lfontconfig ; then
    _ld_fontconfig="-lfontconfig"
  elif cc_check `pkg-config --silence-errors --cflags --libs fontconfig` ; then
    _inc_extra="$_inc_extra `pkg-config --cflags fontconfig`"
    _ld_fontconfig=`pkg-config --libs fontconfig`
  else
    _fontconfig=no
  fi
fi
if test "$_fontconfig" = yes ; then
    _def_fontconfig='#define HAVE_FONTCONFIG'
else
    _def_fontconfig='#undef HAVE_FONTCONFIG'
fi
_ld_fontconfig="-lfontconfig"
echores "$_fontconfig"


echocheck "SSA/ASS support"
# libass depends on FreeType
if test "$_freetype" = no ; then
    _ass=no
    _res_comment="FreeType support needed"
fi

if test "$_ass" = auto ; then
    cat > $TMPC << EOF
#include <ft2build.h>
#include FT_FREETYPE_H
#if ((FREETYPE_MAJOR < 2) || (FREETYPE_MINOR < 1) || ((FREETYPE_MINOR == 1) && (FREETYPE_PATCH < 8)))
#error "Need FreeType 2.1.8 or newer"
#endif
int main() { return 0; }
EOF
    _ass=no
    cc_check `$_freetypeconfig --cflags` `$_freetypeconfig --libs` && tmp_run && _ass=yes
    if test "$_ass" = no ; then
        _res_comment="FreeType >= 2.1.8 needed"
    fi
fi
if test "$_ass" = yes ; then
    _def_ass='#define USE_ASS'
else
    _def_ass='#undef USE_ASS'
fi
echores "$_ass"


echocheck "fribidi with charsets"
if test "$_fribidi" = auto ; then
    if ( $_fribidiconfig --version ) >/dev/null 2>&1 ; then
	cat > $TMPC << EOF
#include <stdio.h>
/* workaround for fribidi 0.10.4 and below */
#define FRIBIDI_CHARSET_UTF8 FRIBIDI_CHAR_SET_UTF8
#include <fribidi/fribidi.h>
int main()
{
    if(fribidi_parse_charset("UTF-8") != FRIBIDI_CHAR_SET_UTF8) {
       printf("Fribidi headers are not consistents with the library!\n");
       exit(1);
    }
    return 0;
}
EOF
	_fribidi=no
	cc_check `$_fribidiconfig --cflags` `$_fribidiconfig --libs` && tmp_run && _fribidi=yes
    else
	_fribidi=no
    fi
fi
if test "$_fribidi" = yes ; then
    _def_fribidi='#define USE_FRIBIDI'
    _inc_extra="$_inc_extra `$_fribidiconfig --cflags`"
    _ld_fribidi=`$_fribidiconfig --libs`
else
    _def_fribidi='#undef USE_FRIBIDI'
fi
echores "$_fribidi"


echocheck "ENCA"
if test "$_enca" = auto ; then
    cat > $TMPC << EOF
#include <enca.h>
int main()
{
    const char **langs;
    size_t langcnt;
    langs = enca_get_languages(&langcnt);
    return 0;
}
EOF
    _enca=no
    cc_check -lenca $_ld_lm && _enca=yes
fi
    if test "$_enca" = yes ; then
	_def_enca='#define HAVE_ENCA 1'
	_ld_enca='-lenca'
    else
	_def_enca='#undef HAVE_ENCA'
    fi
echores "$_enca"


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 test "$_rtc" = auto ; then
  cat > $TMPC << EOF
#include <sys/ioctl.h>
#ifdef __linux__
#include <linux/rtc.h>
#else
#include <rtc.h>
#define RTC_PIE_ON RTCIO_PIE_ON
#endif
int main(void) { return RTC_PIE_ON; }
EOF
  _rtc=no
  cc_check && _rtc=yes
  ppc && _rtc=no
fi
if test "$_rtc" = yes ; then
  _def_rtc='#define HAVE_RTC 1'
else
  _def_rtc='#undef HAVE_RTC'
fi
echores "$_rtc"


echocheck "external liblzo support"
if test "$_liblzo" = auto ; then
  _liblzo=no
  cat > $TMPC << EOF
#include <lzo1x.h>
int main(void) { lzo_init();return 0; }
EOF
  cc_check -llzo && _liblzo=yes
fi
if test "$_liblzo" = yes ; then
  _def_liblzo='#define USE_LIBLZO 1'
  _ld_liblzo='-llzo'
  _codecmodules="liblzo $_codecmodules"
else
  _def_liblzo='#undef USE_LIBLZO'
  _nocodecmodules="liblzo $_nocodecmodules"
fi
echores "$_liblzo"


echocheck "mad support"
if test "$_mad" = auto ; then
  _mad=no
  cat > $TMPC << EOF
#include <mad.h>
int main(void) { return 0; }
EOF
  cc_check -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 "Toolame"
if test "$_toolame" = auto ; then
  cat > $TMPC <<EOF
#include <toolame.h>
int main(void) { toolame_init(); return 0; }
EOF
  _toolame=no
  cc_check $_ld_toolame -ltoolame $_ld_lm && _toolame=yes
fi
if test "$_toolame" = yes ; then
  _def_toolame='#define HAVE_TOOLAME 1'
  _toolame_lib="-ltoolame"
  _codecmodules="toolame $_codecmodules"
else
  _def_toolame='#undef HAVE_TOOLAME'
  _nocodecmodules="toolame $_nocodecmodules"
fi
if test "$_toolamedir" ; then
  _res_comment="using $_toolamedir"
fi
echores "$_toolame"

echocheck "Twolame"
if test "$_twolame" = auto ; then
  cat > $TMPC <<EOF
#include <twolame.h>
int main(void) { twolame_init(); return 0; }
EOF
  _twolame=no
  _twolame_lib="-ltwolame"
  cc_check $_twolame_lib $_ld_lm && _twolame=yes
fi
if test "$_twolame" = yes ; then
  _def_twolame='#define HAVE_TWOLAME 1'
  _codecmodules="twolame $_codecmodules"
else
  _def_twolame='#undef HAVE_TWOLAME'
  _twolame_lib=""
  _nocodecmodules="twolame $_nocodecmodules"
fi
echores "$_twolame"

echocheck "OggVorbis support"
if test "$_tremor_internal" = yes; then
  _libvorbis=no
elif test "$_tremor_external" = auto; then
  _tremor_external=no
  cat > $TMPC << EOF
#include <tremor/ivorbiscodec.h>
int main(void) { vorbis_packet_blocksize(0,0); return 0; }
EOF
  cc_check -logg -lvorbisidec $_ld_lm && _tremor_external=yes && _libvorbis=no
fi
if test "$_libvorbis" = auto; then
  _libvorbis=no
  cat > $TMPC << EOF
#include <vorbis/codec.h>
int main(void) { vorbis_packet_blocksize(0,0); return 0; }
EOF
  cc_check -lvorbis -logg $_ld_lm && _libvorbis=yes
fi
if test "$_tremor_internal" = yes ; then
  _vorbis=yes
  _def_vorbis='#define HAVE_OGGVORBIS 1'
  _def_tremor='#define TREMOR 1'
  _codecmodules="tremor(internal) $_codecmodules"
  _res_comment="internal Tremor"
  if test "$_tremor_low" = yes ; then
    _tremor_flags='-D_LOW_ACCURACY_'
    _res_comment="internal low accuracy Tremor"
  fi
elif test "$_tremor_external" = yes ; then
  _vorbis=yes
  _def_vorbis='#define HAVE_OGGVORBIS 1'
  _def_tremor='#define TREMOR 1'
  _codecmodules="tremor(external) $_codecmodules"
  _res_comment="external Tremor"
  _ld_vorbis='-logg -lvorbisidec'
elif test "$_libvorbis" = yes ; then
  _vorbis=yes
  _def_vorbis='#define HAVE_OGGVORBIS 1'
  _codecmodules="libvorbis $_codecmodules"
  _res_comment="libvorbis"
  _ld_vorbis='-lvorbis -logg'
else
  _vorbis=no
  _nocodecmodules="libvorbis $_nocodecmodules"
fi
echores "$_vorbis"

echocheck "libspeex (version >= 1.1 required)"
if test "$_speex" = auto ; then
  _speex=no
  cat > $TMPC << EOF
#include <speex/speex.h>
int main(void) {
  SpeexBits bits;
  void *dec;
  speex_decode_int(dec, &bits, dec);
}
EOF
  cc_check -lspeex $_ld_lm && _speex=yes
fi
if test "$_speex" = yes ; then
  _def_speex='#define HAVE_SPEEX 1'
  _ld_speex='-lspeex'
  _codecmodules="speex $_codecmodules"
else
  _def_speex='#undef HAVE_SPEEX'
  _nocodecmodules="speex $_nocodecmodules"
fi
echores "$_speex"

echocheck "OggTheora support"
if test "$_theora" = auto ; then
  _theora=no
    cat > $TMPC << EOF
#include <theora/theora.h>
#include <string.h>
int main(void) 
{ 
  /* theora is in flux, make sure that all interface routines and 
   * datatypes exist and work the way we expect it, so we don't break
   * mplayer */
  ogg_packet op;
  theora_comment tc;
  theora_info inf;
  theora_state st;
  yuv_buffer yuv;
  int r;
  double t;

  theora_info_init (&inf);
  theora_comment_init (&tc);
 
  return 0;

  /* we don't want to execute this kind of nonsense; just for making sure
   * that compilation works... */
  memset(&op, 0, sizeof(op));
  r = theora_decode_header (&inf, &tc, &op);
  r = theora_decode_init (&st, &inf);
  t = theora_granule_time (&st, op.granulepos);
  r = theora_decode_packetin (&st, &op);
  r = theora_decode_YUVout (&st, &yuv);
  theora_clear (&st);

  return 0;
}
EOF
  for _ld_theora in "`pkg-config --silence-errors --libs --cflags theora`" "-ltheora"; do
    cc_check $_ld_theora && _theora=yes && break
  done
  if test "$_theora" = no && test "$_tremor_internal" = yes; then
    for _ld_theora in "`pkg-config --silence-errors --libs --cflags theora`" "-ltheora"; do
      cc_check -I. tremor/bitwise.c $_ld_theora && _theora=yes && break
    done
  fi
fi
if test "$_theora" = yes ; then
  _def_theora='#define HAVE_OGGTHEORA 1'
  _codecmodules="libtheora $_codecmodules"
  # when --enable-theora is forced, we'd better provide a probably sane
  # $_ld_theora than nothing
  test -z "$_ld_theora" && _ld_theora="-ltheora -logg"
else
  _def_theora='#undef HAVE_OGGTHEORA'
  _nocodecmodules="libtheora $_nocodecmodules"
  _ld_theora=""
fi
echores "$_theora"

echocheck "mp3lib support"
if test "$_mp3lib" = yes ; then
  _def_mp3lib='#define USE_MP3LIB 1'
  _codecmodules="mp3lib $_codecmodules"
else
  _def_mp3lib='#undef USE_MP3LIB'
  _nocodecmodules="mp3lib $_nocodecmodules"
fi
echores "$_mp3lib"

echocheck "liba52 support"
if test "$_liba52" = yes ; then
  _def_liba52='#define USE_LIBA52 1'
  _codecmodules="liba52 $_codecmodules"
else
  _def_liba52='#undef USE_LIBA52'
  _nocodecmodules="liba52 $_nocodecmodules"
fi
echores "$_liba52"

echocheck "libdts support"
if test "$_libdts" = auto ; then
  _libdts=no
  cat > $TMPC << EOF
#include <inttypes.h>
#include <dts.h>
int main(void) { dts_init (0); return 0; }
EOF
  cc_check $_ld_libdts -ldts $_ld_lm && _libdts=yes
fi
if test "$_libdts" = yes ; then
  _def_libdts='#define CONFIG_DTS 1'
  _ld_libdts="$_ld_libdts -ldts"
  _codecmodules="libdts $_codecmodules"
else
  _def_libdts='#undef CONFIG_DTS'
  _nocodecmodules="libdts $_nocodecmodules"
fi
echores "$_libdts"

echocheck "libmpeg2 support"
if test "$_libmpeg2" = yes ; then
  _def_libmpeg2='#define USE_LIBMPEG2 1'
  _codecmodules="libmpeg2 $_codecmodules"
else
  _def_libmpeg2='#undef USE_LIBMPEG2'
  _nocodecmodules="libmpeg2 $_nocodecmodules"
fi
echores "$_libmpeg2"

echocheck "libmpcdec (musepack, version >= 1.2.1 required)"
if test "$_musepack" = auto ; then
  _musepack=no
  cat > $TMPC << EOF
#include <mpcdec/mpcdec.h>
int main(void) {
  mpc_streaminfo info;
  mpc_decoder decoder;
  mpc_decoder_set_streaminfo(&decoder, &info);
  mpc_decoder_decode_frame(&decoder, NULL, 0, NULL);
}
EOF
  cc_check -lmpcdec $_ld_lm && _musepack=yes
fi
if test "$_musepack" = yes ; then
  _def_musepack='#define HAVE_MUSEPACK 1'
  _ld_musepack='-lmpcdec'
  _codecmodules="musepack $_codecmodules"
else
  _def_musepack='#undef HAVE_MUSEPACK'
  _nocodecmodules="musepack $_nocodecmodules"
fi
echores "$_musepack"


echocheck "FAAC (AAC encoder) support"
if test "$_faac" = auto ; then
  cat > $TMPC <<EOF
#include <inttypes.h> 
#include <faac.h>
int main(void) { unsigned long x, y; faacEncOpen(48000, 2, &x, &y); return 0; }
EOF
  _faac=no
  for _ld_tmp in "-lfaac" "-lfaac -lmp4v2 -lstdc++" ; do
    cc_check -c -O4 $_ld_tmp $_ld_lm && _ld_faac="$_ld_tmp" && _faac=yes && break
  done
fi
if test "$_faac" = yes ; then
  _def_faac="#define HAVE_FAAC 1"
  _def_lavc_faac="#define CONFIG_FAAC 1"
  _codecmodules="faac $_codecmodules"
  _ld_faac="-lfaac -lmp4v2 -lstdc++"
else
  _def_faac="#undef HAVE_FAAC"
  _nocodecmodules="faac $_nocodecmodules"
fi
echores "$_faac"


echocheck "FAAD2 (AAC) support"
if test "$_faad_internal" = auto ; then
  if x86 && test cc_vendor=gnu; then
    case $cc_version in
      3.1*|3.2) # ICE/insn with these versions
        _faad_internal=no
        _res_comment="broken gcc"
        ;;
      *)
        _faad_internal=yes
        ;;
    esac
  else
    _faad_internal=yes
  fi
elif test "$_faad_internal" = no && test "$_faad_external" = auto ; then
  _ld_faad='-lfaad'
  _faad_external=no
  cat > $TMPC << EOF
#include <faad.h>
#ifndef FAAD_MIN_STREAMSIZE
#error Too old version
#endif
int main(void) { faacDecHandle testhand; faacDecFrameInfo testinfo; testhand = faacDecOpen(); faacDecInit(0, 0, 0, 0, 0); return 0; }
EOF
  cc_check $_ld_faad $_ld_lm && _faad_external=yes
fi

if test "$_faad_internal" = yes ; then
  _def_faad_internal="#define USE_FAAD_INTERNAL 1"
  _faad=yes
  _res_comment="internal floating-point"
  test "$_faad_fixed" = yes && _res_comment="internal fixed-point"
elif test "$_faad_external" = yes ; then
  _faad=yes
else
  _def_faad_internal="#undef USE_FAAD_INTERNAL"
  _faad=no
fi

if test "$_faad" = yes ; then
  _def_faad='#define HAVE_FAAD 1'
  _codecmodules="faad2 $_codecmodules"
else
  _def_faad='#undef HAVE_FAAD'
  _nocodecmodules="faad2 $_nocodecmodules"
  _ld_faad=
fi
echores "$_faad"


echocheck "LADSPA plugin support"
if test "$_ladspa" = auto ; then
  cat > $TMPC <<EOF
#include <stdio.h>
#include <ladspa.h>
int main(void) {
const LADSPA_Descriptor *ld = NULL;
return 0;
}
EOF
  _ladspa=no
  cc_check && _ladspa=yes
fi
if test "$_ladspa" = yes; then
  _def_ladspa="#define HAVE_LADSPA"
  _afsrc="$_afsrc af_ladspa.c"
  _afmodules="ladspa $_afmodules"
else
  _def_ladspa="#undef HAVE_LADSPA"
  _noafmodules="ladspa $_noafmodules"
fi
echores "$_ladspa"



if x86 && not qnx; then

if test "$_win32" = auto ; then
    if test -z "$_win32libdir" ; then
      for I in "$_libdir/codecs" "$_libdir/win32" /usr/local/lib/codecs /usr/lib/codecs /usr/local/lib/win32 /usr/lib/win32 ; do
        if test -d "$I" ; then
          _win32libdir="$I"
          break;
        fi;
      done
      # Fall back on a subfolder of the current dir on Windows
      mingw32 && _win32libdir="codecs"
    fi
fi

echocheck "Win32 codec DLL support"
if test "$_win32" = auto ; then
  _win32=no
  test -n "$_win32libdir" && _win32=yes
fi
if test "$_win32" = yes ; then
  _def_win32='#define USE_WIN32DLL 1'
  _res_comment="using $_win32libdir"
else
  _def_win32='#undef USE_WIN32DLL'
  _nocodecmodules="win32 $_nocodecmodules"
fi
echores "$_win32"

if test "$_win32" != no ; then
  _def_win32_loader='#undef WIN32_LOADER'
  echocheck "Win32 loader support"
  _ld_win32='loader/libloader.a loader/dshow/libDS_Filter.a loader/dmo/libDMO_Filter.a'
  _dep_win32='loader/libloader.a loader/dshow/libDS_Filter.a loader/dmo/libDMO_Filter.a'
  _codecmodules="win32 $_codecmodules"
  if openbsd ; then
    x86 && _ld_win32="$_ld_win32 -li386"
  fi
  if not win32 ; then
    _def_win32_loader='#define WIN32_LOADER 1'
  else
    _ld_win32libs="$_ld_win32libs -ladvapi32 -lole32"
    _res_comment="using native windows"
  fi
  echores "$_win32"
fi

fi #if x86 && not qnx



echocheck "XAnim DLL"
if test "$_xanim" = auto ; then
  _xanim=no
  _res_comment="dynamic loader support needed"
  if test "$_dl" = yes ; then
    _res_comment="no suitable directory found - see DOCS/HTML/$_doc_lang/codecs.html"
    if test -z "$_xanimlibdir" ; then
	for I in "$_libdir/codecs" /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
  fi
fi
if test "$_xanim" = yes ; then
  _def_xanim='#define USE_XANIM 1'
  _def_xanim_path="#define XACODEC_PATH \"$_xanimlibdir\""
  _codecmodules="xanim $_codecmodules"
  _res_comment="using $_xanimlibdir"
else
  _def_xanim='#undef USE_XANIM'
  _def_xanim_path='#undef XACODEC_PATH'
  _nocodecmodules="xanim $_nocodecmodules"
fi
echores "$_xanim"

echocheck "RealPlayer DLL"
if test "$_real" = auto ; then
  _real=no
  _res_comment="dynamic loader support needed"
  if test "$_dl" = yes || test "$_win32" = yes ; then
#  if test "$_dl" = yes  ; then
    _res_comment="tested only on Linux/FreeBSD/NetBSD/Cygwin/MinGW/Darwin"
    if linux || freebsd || netbsd || win32 || darwin ; then
      _res_comment="no suitable directory found - see DOCS/HTML/$_doc_lang/codecs.html"
      if test -z "$_reallibdir" ; then
	for I in "$_libdir/codecs" "$_libdir/real" /usr/lib/real \
	  /usr/lib/RealPlayer{9,8,}/Codecs /usr/local/RealPlayer{9,8,}/Codecs \
	  /usr/local/lib/RealPlayer{9,8,}/Codecs /opt/RealPlayer{9,8,}/{Real/,}Codecs \
	  {~,}/Applications/RealOne\ Player.app/Contents/MacOS/Library/Codecs \
	  "$_win32libdir"; do
          if test -d "$I" ; then
            _reallibdir="$I"
            break
          fi
          # Fall back on a subfolder of the current dir on Windows
          mingw32 && _reallibdir="codecs"
        done
      fi
      test "$_reallibdir" && _real=yes
    fi
  fi
fi
if test "$_real" = yes ; then
  _def_real='#define USE_REALCODECS 1'
  _def_real_path="#define REALCODEC_PATH \"$_reallibdir\""
  _codecmodules="real $_codecmodules"
  _res_comment="using $_reallibdir"
else
  _def_real='#undef USE_REALCODECS'
  _def_real_path="#undef REALCODEC_PATH"
  _nocodecmodules="real $_nocodecmodules"
fi
echores "$_real"


echocheck "LIVE555 Streaming Media libraries"
if test "$_live" = auto  && test "$_network" = yes ; then
  cat > $TMPCPP << EOF
#include <liveMedia.hh>
#if (LIVEMEDIA_LIBRARY_VERSION_INT < 1090195200)
#error Please upgrade to version 2004.07.19 or later of the "LIVE555 Streaming Media" libraries - available from <www.live555.com/liveMedia/>
#endif
int main(void) {}
EOF

  _live=no
  for I in "$_livelibdir" "$_libdir/live" "/usr/lib/live" "/usr/local/live" "/usr/local/lib/live" ; do
    cxx_check -I$I/liveMedia/include -I$I/UsageEnvironment/include -I$I/groupsock/include && _livelibdir=$I && _live=yes && break
  done
  if test "$_live" != yes ; then
      if cxx_check -I/usr/include/liveMedia -I/usr/include/UsageEnvironment -I/usr/include/groupsock; then
	  _live_dist=yes
      fi
  fi
fi
if test "$_live" = yes && test "$_network" = yes ; then
  _res_comment="using $_livelibdir"
  _def_live='#define STREAMING_LIVE555 1'
  _ld_live="/usr/lib/libliveMedia.a \
           /usr/lib/libgroupsock.a \
           /usr/lib/libUsageEnvironment.a \
           /usr/lib/libBasicUsageEnvironment.a \
           -lstdc++"
  _inc_extra="$_inc_extra -I/usr/include/liveMedia \
             -I/usr/include/UsageEnvironment \
             -I/usr/include/BasicUsageEnvironment \
             -I/usr/include/groupsock"
 _inputmodules="live555 $_inputmodules"
elif test "$_live_dist" = yes && test "$_network" = yes ; then
  _res_comment="using distribution version"
  _live="yes"
  _def_live='#define STREAMING_LIVE555 1'
  _ld_live="-lliveMedia -lgroupsock -lUsageEnvironment -lBasicUsageEnvironment -lstdc++"
  _inc_extra="$_inc_extra -I/usr/include/liveMedia -I/usr/include/UsageEnvironment \
             -I/usr/include/BasicUsageEnvironment -I/usr/include/groupsock"
 _inputmodules="live555 $_inputmodules"
else
  _def_live='#undef STREAMING_LIVE555'
  _noinputmodules="live555 $_noinputmodules"
fi
echores "$_live"


echocheck "FFmpeg libavutil (static)"
if test "$_libavutil" = auto ; then
  if test -d libavutil ; then
    _libavutil=yes
  else
    _libavutil=no
  fi
fi
echores "$_libavutil"

echocheck "FFmpeg libavcodec (static)"
if test "$_libavcodec" = auto ; then
  # Note: static linking is preferred to dynamic linking
  _libavcodec=no
  _res_comment="see DOCS/HTML/$_doc_lang/codecs.html"
  if test -d libavcodec && test -f libavcodec/utils.c ; then
    _res_comment="old ffmpeg version, use CVS !"
    if grep avcodec_find_encoder_by_name libavcodec/utils.c > /dev/null 2>&1 ; then
      # check if libavutil is a required
      cat > $TMPC << EOF
#include "libavcodec/avcodec.h"
#if LIBAVCODEC_BUILD >= 3211265
#error We need libavutil!
#endif
int main(void) { return 0; }
EOF
      
      if cc_check -I. -I./libavutil; then
        _libavutil_required="no"
      else
        _libavutil_required="yes"
      fi
      _res_comment="libavutil availability does not fit libavcodec version"
      if test "$_libavutil_required" = "$_libavutil"; then
        _libavcodec="yes"
        _res_comment=""
      fi
    fi
  fi
fi
echores "$_libavcodec"

echocheck "FFmpeg libavformat (static)"
if test "$_libavformat" = auto ; then
  # Note: static linking is preferred to dynamic linking
  _libavformat=no
  if test -d libavformat && test -f libavformat/utils.c ; then
    _libavformat=yes
  fi
fi
echores "$_libavformat"

echocheck "FFmpeg libpostproc (static)"
if test "$_libpostproc" = auto ; then
_libpostproc=no
if test -d libpostproc && test -f libpostproc/postprocess.h ; then
   _libpostproc='yes'
fi
fi
echores "$_libpostproc"


if test "$_libavutil" != yes ; then
echocheck "FFmpeg libavutil (dynamic)"
if test "$_libavutil_so" = auto ; then
  _libavutil_so=no
  cat > $TMPC << EOF
#include <ffmpeg/common.h>
int main(void) { ff_gcd(1,1); return 0; }
EOF
  if pkg-config --exists libavutil ; then
    _inc_libavutil=`pkg-config --cflags libavutil`
    _ld_libavutil=`pkg-config --libs libavutil`
    cc_check $_inc_libavutil $_ld_libavutil && _libavutil_so=yes
  elif cc_check -lavutil $_ld_lm ; then
    _libavutil_so=yes
  fi
  if test "$_libavutil_so" = yes ; then
    _res_comment="using libavutil.so, but static libavutil is recommended"
  fi
fi
# neither static nor shared libavutil is available, but it is mandatory ...
if test "$_libavutil_so" = no ; then
  die "You need static or shared libavutil, MPlayer will not compile without!"
fi
echores "$_libavutil_so"
fi #if test "$_libavutil" != yes ; then

if test "$_libavcodec" != yes ; then
echocheck "FFmpeg libavcodec (dynamic)"
if test "$_libavcodec_so" = auto ; then
  _libavcodec_so=no
  _res_comment="libavcodec.so is broken/obsolete"
# FIXME : check for avcodec_find_encoder_by_name() for mencoder
  cat > $TMPC << EOF
#include <ffmpeg/avcodec.h>
int main(void) { 
    avcodec_find_encoder_by_name("");
    return 0; 
}
EOF
  if pkg-config --exists libavcodec ; then
    _inc_libavcodec=`pkg-config --cflags libavcodec`
    _ld_libavcodec=`pkg-config --libs libavcodec`
    cc_check $_inc_libavcodec $_ld_libavcodec && _libavcodec_so=yes
  elif cc_check -lavcodec $_ld_lm ; then
    _libavcodec_so=yes
  fi
  if test "$_libavcodec_so" = yes ; then
    _res_comment="using libavcodec.so, but static libavcodec is recommended"
  fi
fi
echores "$_libavcodec_so"
fi #if test "$_libavcodec" != yes ; then

if test "$_libavformat" != yes ; then
echocheck "FFmpeg libavformat (dynamic)"
if test "$_libavformat_so" = auto ; then
  _libavformat_so=no
  cat > $TMPC <<EOF
  #include <ffmpeg/avformat.h>
  #include <ffmpeg/opt.h>
  int main(void) { av_alloc_format_context(); return 0; }
EOF
  if pkg-config --exists libavformat ; then
    _inc_libavformat=`pkg-config --cflags libavformat`
    _ld_libavformat=`pkg-config --libs libavformat`
    cc_check $_inc_libavformat $_ld_libavformat && _libavformat_so=yes
  elif cc_check $_ld_lm -lavformat ; then
    _libavformat_so=yes  
  fi
  if test "$_libavformat_so" = yes ; then
    _res_comment="using libavformat.so, but static libavformat is recommended"
  fi
fi
echores "$_libavformat_so"
fi #if test "$_libavformat" != yes ; then

if test "$_libpostproc" != yes ; then
echocheck "FFmpeg libpostproc (dynamic)"
if test "$_libpostproc_so" = auto ; then
  _libpostproc_so=no
  cat > $TMPC << EOF
  #define USE_LIBPOSTPROC 1
  #include <inttypes.h>
  #include <postproc/postprocess.h>
  int main(void) {
      pp_get_mode_by_name_and_quality("de", 0);
      return 0;}
EOF
  if cc_check -lpostproc $_ld_lm ; then
    _libpostproc_so=yes
    _res_comment="using libpostproc.so, but static libpostproc is recommended"
  fi
fi
echores "$_libpostproc_so"
fi #if test "$_libpostproc" != yes ; then

_def_libavutil='#undef USE_LIBAVUTIL'
_def_libavutil_so='#undef USE_LIBAVUTIL_SO'
if test "$_libavutil" = yes ; then
  _def_libavutil='#define USE_LIBAVUTIL 1'
elif test "$_libavutil_so" = yes ; then
  _def_libavutil_so='#define USE_LIBAVUTIL_SO 1'
fi

_def_libavcodec='#undef USE_LIBAVCODEC'
_def_libavcodec_so='#undef USE_LIBAVCODEC_SO'
_def_lavc_dsputil='#undef USE_LIBAVCODEC_DSPUTIL'
if test "$_libavcodec_mpegaudio_hp" = yes ; then
  _def_libavcodec_mpegaudio_hp='#define CONFIG_MPEGAUDIO_HP 1'
fi
if test "$_libavcodec" = yes ; then
  _def_libavcodec='#define USE_LIBAVCODEC 1'
  _def_lavc_dsputil='#define USE_LIBAVCODEC_DSPUTIL'
  _ld_libavcodec='libavcodec/libavcodec.a'
  _dep_libavcodec='libavcodec/libavcodec.a'
  _codecmodules="libavcodec $_codecmodules"
  if test "$_libavutil" = yes; then
    _ld_libavutil='libavutil/libavutil.a'
    _dep_libavutil='libavutil/libavutil.a'
  fi
elif test "$_libavcodec_so" = yes ; then
  _def_libavcodec='#define USE_LIBAVCODEC 1'
  _def_libavcodec_so='#define USE_LIBAVCODEC_SO 1'
  test "$_ld_libavcodec" || _ld_libavcodec='-lavcodec'
  _codecmodules="libavcodec.so $_codecmodules"
else
  _nocodecmodules="libavcodec $_nocodecmodules"
fi

_def_libavformat='#undef USE_LIBAVFORMAT'
_def_libavformat_so='#undef USE_LIBAVFORMAT_SO'
_def_libavformat_win32='#undef CONFIG_WIN32'
if test "$_libavformat" = yes ; then
  _def_libavformat='#define USE_LIBAVFORMAT 1'
  _ld_libavformat='libavformat/libavformat.a'
  _dep_libavformat='libavformat/libavformat.a'
  if win32 ; then
    _def_libavformat_win32='#define CONFIG_WIN32 1'
  fi
else
  if test "$_libavformat_so" = yes ; then
    _def_libavformat_so='#define USE_LIBAVFORMAT_SO 1'
    test "$_ld_libavformat" || _ld_libavformat='-lavformat'
    if win32 ; then
      _def_libavformat_win32='#define CONFIG_WIN32 1'
    fi
  fi
fi

_def_libpostproc='#undef USE_LIBPOSTPROC'
_def_libpostproc_so='#undef USE_LIBPOSTPROC_SO'
if test "$_libpostproc" = yes ; then
  _def_libpostproc='#define USE_LIBPOSTPROC 1'
  _ld_libpostproc='libpostproc/libpostproc.a'
  _dep_libpostproc='libpostproc/libpostproc.a'
else
  if test "$_libpostproc_so" = yes ; then
    _def_libpostproc_so='#define USE_LIBPOSTPROC_SO 1'
    _ld_libpostproc='-lpostproc'
  fi
fi

echocheck "md5sum support"
if test "$_md5sum" = yes; then
  _def_md5sum="#define HAVE_MD5SUM"
  _vosrc="$_vosrc vo_md5sum.c"
  _vomodules="md5sum $_vomodules"
else
  _def_md5sum="#undef HAVE_MD5SUM"
  _novomodules="md5sum $_novomodules"
fi
echores "$_md5sum"

echocheck "AMR narrowband"
if test "$_amr_nb" = auto ; then
  _amr_nb=no
  if test -f libavcodec/amr_float/sp_dec.c ; then
    if test "$_libavcodec" = yes ; then
      _amr_nb=yes
    else
      _res_comment="libavcodec (static) is required by amr_nb, sorry"
    fi
  fi
fi
if test "$_amr_nb" = yes ; then
  _amr=yes
  _def_amr='#define CONFIG_AMR 1'
  _def_amr_nb='#define CONFIG_AMR_NB 1'
else
  _def_amr_nb='#undef CONFIG_AMR_NB'
fi
echores "$_amr_nb"

echocheck "AMR narrowband, fixed point"
if test "$_amr_nb_fixed" = auto ; then
  _amr_nb_fixed=no
  if test -f libavcodec/amr/dtx_dec.c ; then
    if test "$_libavcodec" = yes ; then
      if test "$_amr_nb" = no ; then
        _amr_nb_fixed=yes
      else
        _res_comment="disabled by amr_nb"
      fi
    else
      _res_comment="libavcodec (static) is required by amr_nb-fixed, sorry"
    fi
  fi
fi
if test "$_amr_nb_fixed" = yes ; then
  _amr=yes
  _def_amr='#define CONFIG_AMR 1'
  _def_amr_nb_fixed='#define CONFIG_AMR_NB_FIXED 1'
else
  _def_amr_nb_fixed='#undef CONFIG_AMR_NB_FIXED'
fi
echores "$_amr_nb_fixed"

if test "$_amr_nb" = yes || test "$_amr_nb_fixed" = yes ; then
  _codecmodules="amr_nb $_codecmodules"
else
  _nocodecmodules="amr_nb $_nocodecmodules"
fi

echocheck "AMR wideband"
if test "$_amr_wb" = auto ; then
  _amr_wb=no
  if test -f libavcodec/amrwb_float/dec_dtx.c ; then
    if test "$_libavcodec" = yes ; then
      _amr_wb=yes
    else
      _res_comment="libavcodec (static) is required by amr_wb, sorry"
    fi
  fi
fi
if test "$_amr_wb" = yes ; then
  _amr=yes
  _def_amr='#define CONFIG_AMR 1'
  _def_amr_wb='#define CONFIG_AMR_WB 1'
  _codecmodules="amr_wb $_codecmodules"
else
  _def_amr_wb='#undef CONFIG_AMR_WB'
  _nocodecmodules="amr_wb $_nocodecmodules"
fi
echores "$_amr_wb"

echocheck "libdv-0.9.5+"
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 $_ld_pthread $_ld_lm && _libdv=yes
fi
if test "$_libdv" = yes ; then
  _def_libdv='#define HAVE_LIBDV095 1'
  _ld_libdv="-ldv"
  _codecmodules="libdv $_codecmodules"
else
  _def_libdv='#undef HAVE_LIBDV095'
  _nocodecmodules="libdv $_nocodecmodules"
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_zr2.c vo_zr.c jpeg_enc.c"
    _vomodules="zr zr2 $_vomodules"
  else
    _res_comment="libavcodec (static) is required by zr, sorry"
    _novomodules="zr $_novomodules"
    _def_zr='#undef HAVE_ZR'
  fi
else
  _def_zr='#undef HAVE_ZR'
  _novomodules="zr zr2 $_novomodules"
fi
echores "$_zr"

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>
int main(void) { xvid_init(0, 0, 0, 0); return 0; }
EOF
_ld_xvid="$_ld_xvid -lxvidcore"
_xvid4=no
if test "$_xvid" != no && cc_check $_ld_xvid $_ld_lm ; then
  _xvid=yes
  _def_xvid3='#define HAVE_XVID3 1'
  _def_xvid4='#undef HAVE_XVID4'
  _codecmodules="xvid $_codecmodules"
else
cat > $TMPC << EOF
#include <xvid.h>
int main(void) { xvid_global(0, 0, 0, 0); return 0; }
EOF
  if test "$_xvid" != no ;then 
    if cc_check $_ld_xvid $_ld_lm ; then 
    _xvid4=yes 
    elif cc_check $_ld_xvid $_ld_lm $_ld_pthread ; then
    _xvid4=yes;
    _ld_xvid="$_ld_xvid $_ld_pthread"
    fi
  fi
  
  if test "$_xvid4" = yes ; then
    _xvid=yes
    _xvid4=yes
    _def_xvid3='#undef HAVE_XVID3'
    _def_xvid4='#define HAVE_XVID4 1'
    _codecmodules="xvid $_codecmodules"
  else
    _xvid=no
    _ld_xvid=''
    _def_xvid3='#undef HAVE_XVID3'
    _def_xvid4='#undef HAVE_XVID4'
    _nocodecmodules="xvid $_nocodecmodules"
  fi
fi
echores "$_xvid"

if test "$_xvid4" = yes ; then
  echocheck "XviD two pass plugin"
  cat > $TMPC << EOF
#include <xvid.h>
int main(void) { xvid_plugin_2pass2_t s; s.vbv_size=0; return 0; }
EOF
  if cc_check $_ld_xvid $_ld_lb ; then
    _lavc_xvid=yes
    _def_lavc_xvid='#define CONFIG_XVID 1'
  else
    _lavc_xvid=no
    _def_lavc_xvid='#undef CONFIG_XVID'
  fi
  echores "$_lavc_xvid"
fi

_xvidcompat=no
_def_decore_xvid='#undef DECORE_XVID'
_def_encore_xvid='#undef ENCORE_XVID'
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 $_ld_lm "$_ld_xvid" && _xvidcompat=yes
  echores "$_xvidcompat"
fi

echocheck "x264"
if test "$_x264" = auto ; then
  cat > $TMPC << EOF
#include <inttypes.h>
#include <x264.h>
#if X264_BUILD < 53
#error We do not support old versions of x264. Get the latest from SVN.
#endif
int main(void) { x264_encoder_open((void*)0); return 0; }
EOF
  _ld_x264="$_ld_x264 -lx264 $_ld_pthread"
  _x264=no
  if cc_check $_ld_x264 $_ld_lm ; then 
    _x264=yes
  elif  test "$_x11" = yes && cc_check $_ld_x264 $_ld_x11 $_ld_lm ; then
    _x264=yes
    _ld_x264="$_ld_x264 $_ld_x11"
  fi
fi

if test "$_x264" = yes ; then
  _x264=yes
  _def_x264='#define HAVE_X264 1'
  _def_lavc_x264='#define CONFIG_X264 1'
  _codecmodules="x264 $_codecmodules"
else
  _x264=no
  _ld_x264=''
  _def_x264='#undef HAVE_X264'
  _def_lavc_x264='#undef CONFIG_X264'
  _nocodecmodules="x264 $_nocodecmodules"
fi
echores "$_x264"


echocheck "nut"
if test "$_nut" = auto ; then
  cat > $TMPC << EOF
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <nut.h>
int main(void) { (void)nut_error(0); return 0; }
EOF
  _ld_nut="-lnut"
  _nut=no
   cc_check $_ld_nut && _nut=yes
fi

if test "$_nut" = yes ; then
  _def_nut='#define HAVE_LIBNUT 1'
else
  _ld_nut=''
  _def_nut='#undef HAVE_LIBNUT'
fi
echores "$_nut"


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

  echocheck "libmp3lame (for mencoder)"
  _mp3lame=no
  _def_mp3lame_preset='#undef HAVE_MP3LAME_PRESET'
  _def_mp3lame_preset_medium='#undef HAVE_MP3LAME_PRESET_MEDIUM'
  cat > $TMPC <<EOF
#include <lame/lame.h>
int main(void) { lame_version_t lv; (void) lame_init(); get_lame_version_numerical(&lv);  printf("%d%d\n",lv.major,lv.minor); return 0; }
EOF
  # Note: libmp3lame usually depends on vorbis
  cc_check -lmp3lame $_ld_vorbis $_ld_lm && tmp_run && _mp3lame=yes
  if test "$_mp3lame" = yes ; then
    _def_mp3lame="#define HAVE_MP3LAME"
    _def_lavc_mp3lame="#define CONFIG_MP3LAME 1"
    _ld_mp3lame="-lmp3lame $_ld_vorbis"
    cat > $TMPC << EOF
#include <lame/lame.h>
int main(void) { int p = STANDARD_FAST; return 0; }
EOF
    cc_check $_ld_mp3lame $_ld_lm && _def_mp3lame_preset="#define HAVE_MP3LAME_PRESET"
    cat > $TMPC << EOF
#include <lame/lame.h>
int main(void) { int p = MEDIUM_FAST; return 0; }
EOF
    cc_check $_ld_mp3lame $_ld_lm && _def_mp3lame_preset_medium="#define HAVE_MP3LAME_PRESET_MEDIUM"
    echo $_libavencoders | grep -q mp3lame && _lavc_mp3lame=yes || _lavc_mp3lame=no
  else
    _def_mp3lame='#undef HAVE_MP3LAME'
  fi
  echores "$_mp3lame"

fi

echocheck "mencoder"
_mencoder_flag='#undef HAVE_MENCODER'
if test "$_mencoder" = yes ; then
  _mencoder_flag='#define HAVE_MENCODER'
  _def_muxers='#define CONFIG_MUXERS 1'
else
  # mpeg1video for vf_lavc, snow for vf_uspp and vf_mcdeint
  _libavencoders="mpeg1video_encoder snow_encoder"
  _libavmuxers=""
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"


if bsd; then
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"
fi #if bsd


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


echocheck "Video 4 Linux 2 TV interface"
if test "$_tv_v4l2" = auto ; then
 _tv_v4l2=no
 if test "$_tv" = yes && linux ; then
  cat > $TMPC <<EOF
#include <stdlib.h>
#include <linux/types.h>
#include <linux/videodev2.h>
int main(void) { return 0; }
EOF
  cc_check && _tv_v4l2=yes
 fi
fi
if test "$_tv_v4l2" = yes ; then
  _tv_v4l=yes
  _def_tv_v4l='#define HAVE_TV_V4L 1'
  _def_tv_v4l2='#define HAVE_TV_V4L2 1'
  _inputmodules="tv-v4l2 $_inputmodules"
else
  _noinputmodules="tv-v4l2 $_noinputmodules"
  _def_tv_v4l2='#undef HAVE_TV_V4L2'
fi
echores "$_tv_v4l2"


echocheck "Radio interface"
if test "$_radio" = yes ; then
  _def_radio='#define USE_RADIO 1'
  _inputmodules="radio $_inputmodules"
  if test "$_alsa9" != yes -a "$_alsa1x" != yes -a "$_ossaudio" != yes ; then
    _radio_capture=no
  fi
  if test "$_radio_capture" = yes ; then
    _def_radio_capture="#define USE_RADIO_CAPTURE 1"
  else
    _def_radio_capture="#undef USE_RADIO_CAPTURE"
  fi
else
  _noinputmodules="radio $_noinputmodules"
  _def_radio='#undef USE_RADIO'
  _def_radio_capture="#undef USE_RADIO_CAPTURE"
  _radio_capture=no
fi
echores "$_radio"
echocheck "Capture for Radio interface"
echores "$_radio_capture"

echocheck "Video 4 Linux 2 Radio interface"
if test "$_radio_v4l2" = auto ; then
  _radio_v4l2=no
  if test "$_radio" = yes && linux ; then
    cat > $TMPC <<EOF
#include <stdlib.h>
#include <linux/types.h>
#include <linux/videodev2.h>
int main(void) { return 0; }
EOF
    cc_check && _radio_v4l2=yes
  fi
fi
if test "$_radio_v4l2" = yes ; then
  _def_radio_v4l2='#define HAVE_RADIO_V4L2 1'
else
  _def_radio_v4l2='#undef HAVE_RADIO_V4L2'
fi
echores "$_radio_v4l2"

echocheck "Video 4 Linux Radio interface"
if test "$_radio_v4l" = auto ; then
  _radio_v4l=no
  if test "$_radio" = yes && linux ; then
    cat > $TMPC <<EOF
#include <stdlib.h>
#include <linux/videodev.h>
int main(void) { return 0; }
EOF
    cc_check && _radio_v4l=yes
  fi
fi
if test "$_radio_v4l" = yes ; then
  _def_radio_v4l='#define HAVE_RADIO_V4L 1'
else
  _def_radio_v4l='#undef HAVE_RADIO_V4L'
fi
echores "$_radio_v4l"

if test "$_radio_v4l" = no && test "$_radio_v4l2" = no && test "$_radio" = yes ; then
    die "Radio driver requires V4L or V4L2!"
fi

echocheck "Video 4 Linux 2 MPEG PVR interface"
if test "$_pvr" = auto ; then
 _pvr=no
 if test "$_tv_v4l2" = yes && linux ; then
  cat > $TMPC <<EOF
#include <stdlib.h>
#include <inttypes.h>
#include <linux/types.h>
#include <linux/videodev2.h>
int main(void) { struct v4l2_ext_controls ext; return 0; }
EOF
  cc_check && _pvr=yes
 fi
fi
if test "$_pvr" = yes ; then
  _def_pvr='#define HAVE_PVR 1'
  _inputmodules="pvr $_inputmodules"
else
  _noinputmodules="pvr $_noinputmodules"
  _def_pvr='#undef HAVE_PVR'
fi
echores "$_pvr"


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 "network"
# FIXME network check
if test "$_network" = yes ; then
  _def_network='#define MPLAYER_NETWORK 1'
  _ld_network="$_ld_sock"
  _inputmodules="network $_inputmodules"
else
  _noinputmodules="network $_noinputmodules"
  _def_network='#undef MPLAYER_NETWORK'
  _ftp=no
fi
echores "$_network"

echocheck "ftp"
if not beos && test "$_ftp" = yes ; then
  _def_ftp='#define HAVE_FTP 1'
  _inputmodules="ftp $_inputmodules"
else
  _noinputmodules="ftp $_noinputmodules"
  _def_ftp='#undef HAVE_FTP'
fi
echores "$_ftp"

echocheck "vstream client"
if test "$_vstream" = auto ; then
  _vstream=no
  cat > $TMPC <<EOF
#include <vstream-client.h>
void vstream_error(const char *format, ... ) {}
int main(void) { vstream_start(); return 0; }
EOF
  cc_check -lvstream-client && _vstream=yes
fi
if test "$_vstream" = yes ; then
  _def_vstream='#define HAVE_VSTREAM 1'
  _inputmodules="vstream $_inputmodules"
  _ld_vstream='-lvstream-client'
else
  _noinputmodules="vstream $_noinputmodules"
  _def_vstream='#undef HAVE_VSTREAM'
fi
echores "$_vstream"

# endian testing
echocheck "byte order"
if test "$_big_endian" = auto ; then
  cat > $TMPC <<EOF
short ascii_name[] = { (('M'<<8)|'P'),(('l'<<8)|'a'),(('y'<<8)|'e'),(('r'<<8)|'B'),
                      (('i'<<8)|'g'),(('E'<<8)|'n'),(('d'<<8)|'i'),(('a'<<8)|'n'),0};
int main(){
  return (int)ascii_name;
} 
EOF
  if cc_check ; then 
    if strings $TMPO | grep -l MPlayerBigEndian >/dev/null ; 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"

echocheck "OSD menu"
if test "$_menu" = yes ; then
    _def_menu='#define HAVE_MENU 1'
else
_def_menu='#undef HAVE_MENU'
fi
echores "$_menu"


echocheck "QuickTime codecs"
if test "$_qtx" = auto ; then
  test "$_win32" = yes || darwin && _qtx=yes
fi
if test "$_qtx" = yes ; then
    _def_qtx='#define USE_QTX_CODECS 1'
    _codecmodules="qtx $_codecmodules"
else
    _def_qtx='#undef USE_QTX_CODECS'
    _nocodecmodules="qtx $_nocodecmodules"
fi
echores "$_qtx"


echocheck "Subtitles sorting"
if test "$_sortsub" = yes ; then
    _def_sortsub='#define USE_SORTSUB 1'
else
    _def_sortsub='#undef USE_SORTSUB'
fi
echores "$_sortsub"


echocheck "XMMS inputplugin support"
if test "$_xmms" = yes ; then

  if ( xmms-config --version ) >/dev/null 2>&1 ; then
    if test -z "$_xmmsplugindir" ; then
      _xmmsplugindir=`xmms-config --input-plugin-dir`
    fi
    if test -z "$_xmmslibdir" ; then
      _xmmslibdir=`xmms-config --exec-prefix`/lib
    fi
  else
    if test -z "$_xmmsplugindir" ; then
      _xmmsplugindir=/usr/lib/xmms/Input
    fi
    if test -z "$_xmmslibdir" ; then
      _xmmslibdir=/usr/lib
    fi
  fi

  _def_xmms='#define HAVE_XMMS 1'
  if darwin ; then
     _xmms_lib="${_xmmslibdir}/libxmms.dylib"
  else
     _xmms_lib="${_xmmslibdir}/libxmms.so.1 -export-dynamic"
  fi
else
  _def_xmms='#undef HAVE_XMMS'
fi
echores "$_xmms"

echocheck "inet6"
if test "$_inet6" = auto ; then
  cat > $TMPC << EOF
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int main(void) { struct sockaddr_in6 six; socket(AF_INET6, SOCK_STREAM, AF_INET6); }
EOF
  _inet6=no
  if cc_check ; then
    _inet6=yes
  fi
fi
if test "$_inet6" = yes ; then
  _def_inet6='#define HAVE_AF_INET6 1'
else
  _def_inet6='#undef HAVE_AF_INET6'
fi
echores "$_inet6"


echocheck "gethostbyname2"
if test "$_gethostbyname2" = auto ; then
cat > $TMPC << EOF
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
int main(void) { gethostbyname2("", AF_INET); }
EOF
  _gethostbyname2=no
  if cc_check ; then
    _gethostbyname2=yes
  fi
fi

if test "$_gethostbyname2" = yes ; then
  _def_gethostbyname2='#define HAVE_GETHOSTBYNAME2 1'
else
  _def_gethostbyname2='#undef HAVE_GETHOSTBYNAME2'
fi
echores "$_gethostbyname2"


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

  # Required libraries
  test "$_png" != yes && die "The GUI requires PNG support, please install libpng and libpng-dev packages."
if not win32 ; then
  test "$_x11" != yes && die "X11 support required for GUI compilation."

  echocheck "XShape extension"
  if test "$_xshape" = auto ; then
    _xshape=no
    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 $_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
if test "$_gtk1" = no ; then
  #Check for GTK2 :
  echocheck "GTK+ version"

  if pkg-config gtk+-2.0 --exists ; then
    _gtk=`pkg-config gtk+-2.0 --modversion 2>/dev/null`
    _inc_extra="$_inc_extra `pkg-config gtk+-2.0 --cflags 2>/dev/null`"
    _ld_gtk=`pkg-config gtk+-2.0 --libs 2>/dev/null`
    echores "$_gtk"

    # Check for GLIB2
    if pkg-config glib-2.0 --exists ; then
      echocheck "glib version"
      _glib=`pkg-config glib-2.0 --modversion 2>/dev/null`
      _ld_glib=`pkg-config glib-2.0 --libs 2>/dev/null`
      echores "$_glib"

      _def_gui='#define HAVE_NEW_GUI 1'
      _def_gtk2_gui='#define HAVE_GTK2_GUI 1'
    else
      _gtk1=yes
      echo "GLIB-2 devel packages were not found, trying GTK 1.2"
    fi
  else
    echo "GTK-2 devel packages were not found, trying GTK 1.2"
    _gtk1=yes
  fi
fi

if test "$_gtk1" = yes ; then
  # Check for old GTK (1.2.x)
  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 devel packages (which were not found)."
    fi
  fi
  _gtk=`$_gtkconfig --version 2>&1`
  _inc_extra="$_inc_extra `$_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 devel packages (which were not found)"
    fi
  fi
  _glib=`$_glibconfig --version 2>&1`
  _ld_glib=`$_glibconfig --libs 2>&1`
  echores "$_glib (using $_glibconfig)"

  _def_gui='#define HAVE_NEW_GUI 1'
  _def_gtk2_gui='#undef HAVE_GTK2_GUI'
fi

else #if not win32
  _ld_win32libs="-lcomdlg32 -lcomctl32 -lshell32 -lkernel32 $_ld_win32libs"
  _def_gui='#define HAVE_NEW_GUI 1'
  _def_gtk2_gui='#undef HAVE_GTK2_GUI'
fi #if not win32

else #if test "$_gui"
  _def_gui='#undef HAVE_NEW_GUI'
  _def_gtk2_gui='#undef HAVE_GTK2_GUI'
fi #if test "$_gui"
# --------------- GUI specific tests end -------------------


if test "$_charset" = "noconv" ; then
  _charset=""
elif test -z "$_charset" ; then
  if test "$_gtk1" = yes ; then
    _charset=`cat ${_mp_help}.charset`
  else
    _charset="UTF-8"
  fi
fi
if test "$_charset" ; then
  _def_charset="#define MSG_CHARSET \"$_charset\""
else
  _def_charset="#undef MSG_CHARSET"
fi

if test "$_charset" = `cat ${_mp_help}.charset` ; then
  # hack to disable conversion in the Makefile
  _charset=""
fi

if test "$_charset" ; then
echocheck "iconv program"
iconv -f `cat ${_mp_help}.charset` -t $_charset ${_mp_help} > /dev/null 2>> "$TMPLOG"
if test "$?" -ne 0 ; then
  echores "no"
    echo "No working iconv program found, use "
    echo "--charset=`cat ${_mp_help}.charset` to continue anyway."
    echo "If you also have problems with iconv library functions use --charset=noconv."
    echo "Messages in the GTK-2 interface will be broken then."
    exit 1
else
  echores "yes"
fi
fi

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

echocheck "automatic gdb attach"
if test "$_crash_debug" = yes ; then
  _def_crash_debug='#define CRASH_DEBUG 1'
else
  _def_crash_debug='#undef CRASH_DEBUG'
  _crash_debug=no
fi
echores "$_crash_debug"

if darwin ; then
  CFLAGS="$CFLAGS -mdynamic-no-pic -falign-loops=16 -DSYS_DARWIN -DCONFIG_DARWIN -shared-libgcc"  
  if x86 ; then
  CFLAGS="$CFLAGS -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
  fi
  if [ "$_cc_major" = 3 ] && [ "$_cc_minor" -lt 1 ]; then
    CFLAGS="$CFLAGS -no-cpp-precomp"
  fi

  # libavcodec (from ffmpeg) requires CONFIG_DARWIN to enable AltiVec on Darwin/MacOSX
  test "$_altivec" = yes && CFLAGS="$CFLAGS -DCONFIG_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 "compiler support for -fno-PIC"
if x86; then
cat > $TMPC <<EOF
int main(void) { return 0; }
EOF
if cc_check -fno-PIC ; then
  CFLAGS="-fno-PIC $CFLAGS"
  echores "yes"
else
  echores "no"
fi
else
  echores "only used for x86"
fi

echocheck "compiler support for noexecstack"
cat > $TMPC <<EOF
int main(void) { return 0; }
EOF
if cc_check -Wl,-z,noexecstack ; then
  _ld_extra="-Wl,-z,noexecstack $_ld_extra"
  echores "yes"
else
  echores "no"
fi

if cc_check -Wdeclaration-after-statement ; then
  CFLAGS="-Wdeclaration-after-statement $CFLAGS"
fi

echocheck "ftello()"
# if we don't have ftello use the osdep/ compatibility module
cat > $TMPC << EOF
#include <stdio.h>
#include <sys/types.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
  _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__"
fi

if win32 ; then
  _confwin32='TARGET_WIN32 = yes'
else
  _confwin32='TARGET_WIN32 = no'
fi

# Dynamic linking flags 
# (FIXME: 'echocheck "dynamic linking"' above and modify here accordingly)
_ld_dl_dynamic=''
bsd && _ld_dl_dynamic='-rdynamic'
if test "$_real" = yes || test "$_xanim" = yes && not win32 && not qnx && not darwin ; then
  _ld_dl_dynamic='-rdynamic'
fi

_ld_arch="$_ld_arch $_ld_pthread $_ld_dl $_ld_dl_dynamic"
bsdos && _ld_arch="$_ld_arch -ldvd"
if netbsd ; then
  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
echocheck "VIDIX (internal)"
echores "$_vidix_internal"

echocheck "VIDIX (external)"
if test "$_vidix_external" = auto; then
 _vidix_external=no
 cat > $TMPC <<EOF
#include <vidix/vidix.h>
int main(void) { return 0; }
EOF
  cc_check -lvidix && _vidix_external=yes
fi
echores "$_vidix_external"

if test "$_vidix_internal" = yes || test "$_vidix_external" = yes ; then
  _vidix=yes
  _def_vidix='#define CONFIG_VIDIX 1'
else
  _vidix=no
  _def_vidix='#undef CONFIG_VIDIX'
fi

if test "$_vidix_internal" = yes ; then
  _def_vidix_pfx="#define MP_VIDIX_PFX \"$_libdir\" \"/mplayer/vidix/\" "
elif test "$_vidix_external" = yes ; then
  _ld_vidix_external="-lvidix"
  _def_vidix_pfx='#define MP_VIDIX_PFX "" '
fi

if test "$_vidix" = yes; then
  _vosrc="$_vosrc vo_cvidix.c"
  _vomodules="cvidix $_vomodules"
else
  _novomodules="cvidix $_novomodules"
fi
if test "$_vidix" = yes && win32; then
  _vosrc="$_vosrc vo_winvidix.c"
  _vomodules="winvidix $_vomodules"
  _ld_win32libs="-lgdi32 $_ld_win32libs"
else
  _novomodules="winvidix $_novomodules"
fi
if test "$_vidix" = yes && test "$_x11" = yes; then
  _vosrc="$_vosrc vo_xvidix.c"
  _vomodules="xvidix $_vomodules"
else
  _novomodules="xvidix $_novomodules"
fi

echocheck "joystick"
_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
echores "$_joystick"

echocheck "lirc"
if test "$_lirc" = auto ; then
  _lirc=no
  cat > $TMPC <<EOF
#include <lirc/lirc_client.h>
int main(void) { return 0; }
EOF
  cc_check -llirc_client && _lirc=yes
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"

echocheck "lircc"
if test "$_lircc" = auto ; then
  _lircc=no
  cat > $TMPC <<EOF
#include <lirc/lircc.h>
int main(void) { return 0; }
EOF
  cc_check -llircc && _lircc=yes
fi
if test "$_lircc" = yes ; then
  _def_lircc='#define HAVE_LIRCC 1'
  _ld_lircc='-llircc'
else
  _def_lircc='#undef HAVE_LIRCC'
fi
echores "$_lircc"

if arm; then
# Detect maemo development platform libraries availability (http://www.maemo.org),
# they are used when run on Nokia 770
echocheck "maemo (Nokia 770)"
if test "$_maemo" = auto ; then
  _maemo=no
  cat > $TMPC << EOF
#include <libosso.h>
int main(void) { (void) osso_initialize("", "", 0, NULL); return 0; }
EOF
  cc_check `pkg-config --cflags --libs libosso 2>/dev/null` && _maemo=yes
fi
if test "$_maemo" = yes ; then
  _def_maemo='#define HAVE_MAEMO 1'
  _inc_extra="$_inc_extra `pkg-config --cflags libosso`"
  _ld_extra="$_ld_extra `pkg-config --libs libosso` -lXsp"
else
  _def_maemo='#undef HAVE_MAEMO'
fi
echores "$_maemo"
fi

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

LANG = C
MAN_LANG = $MAN_LANG
TARGET_OS = $system_name
DESTDIR =
prefix = \$(DESTDIR)$_prefix
BINDIR = \$(DESTDIR)$_bindir
DATADIR = \$(DESTDIR)$_datadir
MANDIR = \$(DESTDIR)$_mandir
CONFDIR = \$(DESTDIR)$_confdir
LIBDIR = \$(DESTDIR)$_libdir
# FFmpeg uses libdir instead of LIBDIR
libdir = \$(LIBDIR)
#AR = ar
CC = $_cc
HOST_CC = $_host_cc
AWK = $_awk
RANLIB = $_ranlib
INSTALL = $_install
# FIXME: Should only be _inc_extra eventually.
EXTRA_INC = $_inc_extra
OPTFLAGS = $CFLAGS \$(EXTRA_INC)
STRIPBINARIES = $_stripbinaries
CHARSET = $_charset
HELP_FILE = $_mp_help

PRG = $_prg
PRG_MENCODER = $_prg_mencoder

MPLAYER_NETWORK = $_network
FTP = $_ftp
STREAMING_LIVE555 = $_live
VSTREAM = $_vstream
MPLAYER_NETWORK_LIB = $_ld_live $_ld_vstream $_ld_network
STREAM_CACHE = yes
DVBIN = $_dvbin
VIDIX = $_vidix_internal
EXTERNAL_VIDIX = $_vidix_external
EXTERNAL_VIDIX_LIB = $_ld_vidix_external
CONFIG_PP = yes
CONFIG_MP3LAME = $_mp3lame
LIBMENU = $_menu

MP3LIB = $_mp3lib
LIBA52 = $_liba52
LIBMPEG2 = $_libmpeg2
TREMOR_INTERNAL = $_tremor_internal
TREMOR_FLAGS = $_tremor_flags
FAAD = $_faad

SPEEX = $_speex
MUSEPACK = $_musepack

UNRARLIB = $_unrarlib
PNG = $_png
JPEG = $_jpeg
GIF = $_gif

EXTRALIBS = $_extra_libs
EXTRA_LIB = $_ld_extra
Z_LIB =  $_ld_static $_ld_zlib
HAVE_MLIB = $_mlib
WIN32_LIB = $_ld_win32libs
STATIC_LIB = $_ld_static
ENCA_LIB = $_ld_enca
HAVE_PTHREADS = $_pthreads
MATH_LIB = $_ld_lm
LIBC_LIB = $_ld_libC

HAVE_XVMC_ACCEL = $_xvmc

# for FFmpeg
SRC_PATH=..
BUILD_ROOT=..
LIBPREF=lib
LIBSUF=.a
LIB=\$(LIBPREF)\$(NAME)\$(LIBSUF)

# video output
X_LIB = $_ld_gl $_ld_dga $_ld_xv $_ld_xvmc $_ld_vm $_ld_xinerama $_ld_x11 $_ld_sock
GGI_LIB = $_ld_ggi
MLIB_LIB =  $_ld_mlib
PNG_LIB = $_ld_png
JPEG_LIB = $_ld_jpeg
GIF_LIB = $_ld_gif
SDL_LIB = $_ld_sdl
SVGA_LIB = $_ld_svga
VESA_LIB = $_ld_vesa
AA_LIB = $_ld_aa
CACA_LIB = $_ld_caca

# audio output
OSS = $_ossaudio
ALSA = $_alsa
ALSA5 = $_alsa5
ALSA9 = $_alsa9
ALSA1X = $_alsa1x
ALSA_LIB = $_ld_alsa
NAS_LIB = $_ld_nas
ARTS_LIB = $_ld_arts
ESD_LIB = $_ld_esd
PULSE_LIB = $_ld_pulse
JACK_LIB = $_ld_jack
OPENAL_LIB = $_ld_openal
SGIAUDIO_LIB = $_ld_sgiaudio

# input/demuxer/codecs
TERMCAP_LIB = $_ld_termcap
JOYSTICK = $_joystick
LIRC = $_lirc
LIRC_LIB = $_ld_lirc
LIRCC_LIB = $_ld_lircc
TV = $_tv
TV_V4L  = $_tv_v4l
TV_V4L1 = $_tv_v4l1
TV_V4L2 = $_tv_v4l2
TV_BSDBT848 = $_tv_bsdbt848
PVR = $_pvr
VCD = $_vcd
HAVE_DVD = $_have_dvd
DVDREAD = $_dvdread
DVDREAD_LIB = $_ld_dvdread
DVDKIT2 = $_mpdvdkit
DVDNAV = $_dvdnav
DVDNAV_LIB = $_ld_dvdnav
WIN32DLL = $_win32
W32_DEP = $_dep_win32
W32_LIB = $_ld_win32
QTX_CODECS = $_qtx
REAL_CODECS = $_real
XANIM_CODECS = $_xanim
AV_DEP = $_dep_libavformat $_dep_libavcodec $_dep_libavutil $_dep_libpostproc
AV_LIB = $_ld_libavformat  $_ld_libavcodec  $_ld_libavutil  $_ld_libpostproc
CONFIG_LIBAVUTIL = $_libavutil
CONFIG_LIBAVUTIL_SO = $_libavutil_so
CONFIG_LIBAVCODEC = $_libavcodec
CONFIG_LIBAVCODEC_SO = $_libavcodec_so
CONFIG_LIBAVFORMAT = $_libavformat
CONFIG_LIBAVFORMAT_SO = $_libavformat_so
CONFIG_LIBPOSTPROC = $_libpostproc
CONFIG_LIBPOSTPROC_SO = $_libpostproc_so
ZORAN = $_zr
FAME = $_libfame
FAME_LIB = $_ld_libfame
LIBDV = $_libdv
LIBDV_LIB = $_ld_libdv
ARCH_LIB =  $_ld_arch $_ld_iconv
XVID = $_xvid
XVID4 = $_xvid4
XVID_LIB = $_ld_xvid
X264 = $_x264
X264_LIB = $_ld_x264
LIBNUT = $_nut
NUT_LIB = $_ld_nut
CONFIG_DTS = $_libdts
DTS_LIB = $_ld_libdts
MENCODER = $_mencoder
MP3LAME_LIB = $_ld_mp3lame
LAVC_MP3LAME = $_lavc_mp3lame
DIRECTFB_LIB = $_ld_directfb
CDDA = $_cdda
CDPARANOIA_LIB = $_ld_cdparanoia
BITMAP_FONT = $_bitmap_font
FREETYPE = $_freetype
FREETYPE_LIB = $_ld_freetype
FONTCONFIG_LIB = $_ld_fontconfig
CONFIG_ASS = $_ass
FRIBIDI_LIB = $_ld_fribidi
LIBCDIO_LIB = $_ld_libcdio
LIBLZO_LIB= $_ld_liblzo
LIBMAD = $_mad
MAD_LIB = $_ld_mad
LIBVORBIS = $_vorbis
VORBIS_LIB = $_ld_vorbis
SPEEX_LIB = $_ld_speex
LIBTHEORA = $_theora
THEORA_LIB = $_ld_theora
FAAD_LIB = $_ld_faad
FAAD_INTERNAL = $_faad_internal
FAAD_FIXED = $_faad_fixed
LIBSMBCLIENT = $_smbsupport
SMBSUPPORT_LIB = $_ld_smb
XMMS_PLUGINS = $_xmms
XMMS_LIB = $_xmms_lib
MACOSX = $_macosx
MACOSX_FINDER_SUPPORT = $_macosx_finder_support
MACOSX_BUNDLE = $_macosx_bundle
MACOSX_FRAMEWORKS = $_macosx_frameworks
MACOSX_COREVIDEO = $_macosx_corevideo
TOOLAME=$_toolame
TOOLAME_LIB=$_toolame_lib
TWOLAME=$_twolame
TWOLAME_LIB=$_twolame_lib
MUSEPACK_LIB = $_ld_musepack
FAAC=$_faac
FAAC_LIB=$_ld_faac
CONFIG_AMR=$_amr
CONFIG_AMR_NB=$_amr_nb
CONFIG_AMR_NB_FIXED=$_amr_nb_fixed
CONFIG_AMR_WB=$_amr_wb
`echo $_libavdecoders | tr '[a-z] ' '[A-Z]\n' | sed 's/^/CONFIG_/;s/$/=yes/'`
`echo $_libavencoders | tr '[a-z] ' '[A-Z]\n' | sed 's/^/CONFIG_/;s/$/=yes/'`
`echo $_libavparsers | tr '[a-z] ' '[A-Z]\n' | sed 's/^/CONFIG_/;s/$/=yes/'`
`echo $_libavdemuxers | tr '[a-z] ' '[A-Z]\n' | sed 's/^/CONFIG_/;s/$/=yes/'`
`echo $_libavmuxers | tr '[a-z] ' '[A-Z]\n' | sed 's/^/CONFIG_/;s/$/=yes/'`
CONFIG_FAAC=$_faac
CONFIG_XVID=$_lavc_xvid
CONFIG_X264=$_x264
CONFIG_GPL=yes
CONFIG_ENCODERS=$_mencoder
CONFIG_MUXERS=$_mencoder
RADIO=$_radio
RADIO_CAPTURE=$_radio_capture

# --- Some stuff for autoconfigure ----
$_target_arch
$_confwin32
TARGET_CPU=$iproc
TARGET_MMX = $_mmx
TARGET_MMX2 = $_mmxext
TARGET_3DNOW = $_3dnow
TARGET_3DNOWEX = $_3dnowext
TARGET_SSE = $_sse
TARGET_ALTIVEC = $_altivec
TARGET_ARMV5TE = $_armv5te
TARGET_IWMMXT = $_iwmmxt
TARGET_VIS = $_vis
TARGET_BUILTIN_VECTOR = $_builtin_vector
TARGET_BUILTIN_3DNOW  = $_mm3dnow

# --- GUI stuff ---
GTKLIB = $_ld_gtk
GLIBLIB = $_ld_glib
GTK_LIBS = $_ld_static \$(GTKLIB) \$(GLIBLIB)
GUI = $_gui

# --- libvo stuff ---
VO_SRCS = $_vosrc

# --- libao2 stuff ---
AO_SRCS = $_aosrc

# --- libaf stuff ---
AF_SRCS = $_afsrc

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. */

/* Protect against multiple inclusion */
#ifndef MPLAYER_CONFIG_H
#define MPLAYER_CONFIG_H 1

/* use GNU internationalization */
$_def_i18n

/* name of messages charset */
$_def_charset

/* Runtime CPU detection */
$_def_runtime_cpudetection

/* Dynamic a/v plugins */
$_def_dynamic_plugins

/* "restrict" keyword */
$_def_restrict_keyword

/* __builtin_expect branch prediction hint */
$_def_builtin_expect
#ifdef HAVE_BUILTIN_EXPECT
#define likely(x) __builtin_expect ((x) != 0, 1)
#define unlikely(x) __builtin_expect ((x) != 0, 0)
#else
#define likely(x) (x)
#define unlikely(x) (x)
#endif

/* attribute(used) as needed by some compilers */
#if (__GNUC__ * 100 + __GNUC_MINOR__ >= 300)
# define attribute_used __attribute__((used))
#else
# define attribute_used
#endif

/* compiler support for named assembler arguments */
$_def_named_asm_args

#define PREFIX "$_prefix"

#define USE_OSD 1
#define USE_SUB 1

/* enable/disable SIGHANDLER */
$_def_sighandler

/* enable/disable automatic gdb attach on crash, requires SIGHANDLER */
$_def_crash_debug

/* Toggles debugging informations */
$_def_debug

/* Toggles colorized output */
//#define MSG_USE_COLORS 1

/* Indicates that libcdio is available for VCD and CD-DA playback */
$_def_libcdio

/* 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_dvd_darwin
$_def_sol_scsi_h
$_def_hpux_scsi_h
$_def_stddef
$_def_have_dvd

/* Common data directory (for fonts, etc) */
#define MPLAYER_DATADIR "$_datadir"
#define MPLAYER_CONFDIR "$_confdir"
#define MPLAYER_LIBDIR "$_libdir"

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

/* Define if you are using XviD library */
$_def_xvid3
$_def_xvid4
$_def_decore_xvid
$_def_encore_xvid

/* Define if you are using the X.264 library */
$_def_x264

/* Define if you are using libnut */
$_def_nut

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

/* If build mencoder */
$_mencoder_flag

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

/* 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 nl_langinfo function */
$_def_langinfo

/* define this to use RTC (/dev/rtc) for video timers */
$_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 has ftello() */

$_def_ftello
#ifndef HAVE_FTELLO
/* Need these for FILE and off_t an config.h is usually before other includes*/
#include <stdio.h>
#include <sys/types.h>
off_t ftello(FILE *);
#endif

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

/* memalign is mapped to malloc if unsupported */
$_def_memalign
$_def_map_memalign
$_def_memalign_hack

/* assembler handling of .align */
$_def_asmalign_pot

/* 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
$_def_mman_has_map_failed

/* 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
#ifdef HAVE_ZLIB
#define CONFIG_ZLIB 1
#endif

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

/* Define this if your system has scandir & alphasort */
$_def_scandir

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

/* Define this if your system has strlcpy */
$_def_strlcpy
#ifndef HAVE_STRLCPY
unsigned int strlcpy (char *dest, const char *src, unsigned int size);
#endif

/* Define this if your system has strlcat */
$_def_strlcat
#ifndef HAVE_STRLCAT
unsigned int strlcat (char *dest, const char *src, unsigned int size);
#endif

/* Define this if your system has fseeko */
$_def_fseeko
#ifndef HAVE_FSEEKO
/* Need these for FILE and off_t an config.h is usually before other includes*/
#include <stdio.h>
#include <sys/types.h>
int fseeko(FILE *, off_t, int);
#endif

$_def_localtime_r

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

/* Define this if your system has swab */
$_def_swab

/* Define this if your system has no posix select */
$_def_no_posix_select

/* Define this if your system has gettimeofday */
$_def_gettimeofday

/* Define this if your system has glob */
$_def_glob

/* Define this if your system has setenv */
$_def_setenv
#ifndef HAVE_SETENV
int setenv(const char *name, const char *val, int overwrite);
#endif

/* Define this if your system has sysi86 */
$_def_sysi86

/* Define this if your system has pthreads */
$_def_pthreads

/* Define this if you enabled thread support for libavcodec */
$_def_threads

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

/* Support for maemo (http://www.maemo.org) */
$_def_maemo

/*
 * LIRCCD (LIRC client daemon)
 * See http://www.dolda2000.cjb.net/~fredrik/lirccd/
 */
$_def_lircc

/* 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_libpostproc
$_def_libpostproc_so

/* Win32 DLL support */
$_def_win32
#define WIN32_PATH "$_win32libdir"

/* Mac OS X specific features */
$_def_macosx
$_def_macosx_finder_support
$_def_macosx_bundle
$_def_macosx_corevideo

/* Build our Win32-loader */
$_def_win32_loader

/* ffmpeg's libavcodec support (requires libavcodec source) */
$_def_libavcodec
$_def_libavcodec_so
$_def_lavc_dsputil
$_def_libavcodec_mpegaudio_hp

/* ffmpeg's libavformat support (requires libavformat source) */
$_def_libavformat
$_def_libavformat_so
$_def_libavformat_win32

$_def_libavutil
$_def_libavutil_so

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

/* Use libavformat's demuxers */
#define CONFIG_DEMUXERS 1
/* Use libavformat's muxers */
$_def_muxers

#define CONFIG_GPL 1

/* Use amr codecs from libavcodec (requires amr sources) */
$_def_amr
$_def_amr_nb
$_def_amr_nb_fixed
$_def_amr_wb

/* Use specific parts from FFmpeg. */
`echo $_libavdecoders | tr '[a-z] ' '[A-Z]\n' | sed 's/^/#define CONFIG_/;s/$/ 1/'`
`echo $_libavencoders | tr '[a-z] ' '[A-Z]\n' | sed 's/^/#define CONFIG_/;s/$/ 1/'`
`echo $_libavparsers | tr '[a-z] ' '[A-Z]\n' | sed 's/^/#define CONFIG_/;s/$/ 1/'`
`echo $_libavdemuxers | tr '[a-z] ' '[A-Z]\n' | sed 's/^/#define CONFIG_/;s/$/ 1/'`
`echo $_libavmuxers | tr '[a-z] ' '[A-Z]\n' | sed 's/^/#define CONFIG_/;s/$/ 1/'`
$_def_lavc_faac
$_def_lavc_xvid
$_def_lavc_mp3lame
$_def_lavc_x264

/* Use codec libs included in mplayer CVS / source dist: */
$_def_mp3lib
$_def_liba52
$_def_libdts
$_def_libmpeg2

/* Use libfame encoder filter */
$_def_libfame

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

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

/* LIVE555 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
$_def_gtk2_gui

/* Audio output drivers */
$_def_ossaudio
$_def_ossaudio_devdsp
$_def_ossaudio_devmixer
$_def_alsa5
$_def_alsa9
$_def_alsa1x
$_def_arts
$_def_esd
$_def_esd_latency
$_def_pulse
$_def_jack
$_def_openal
$_def_sys_asoundlib_h
$_def_alsa_asoundlib_h
$_def_sunaudio
$_def_sgiaudio
$_def_win32waveout
$_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 Video 4 Linux 1 TV interface support */
$_def_tv_v4l1

/* Enable Video 4 Linux 2 TV interface support */
$_def_tv_v4l2

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

/* Enable Radio Interface support */
$_def_radio

/* Enable Capture for Radio Interface support */
$_def_radio_capture

/* Enable Video 4 Linux Radio interface support */
$_def_radio_v4l

/* Enable Video 4 Linux 2 Radio interface support */
$_def_radio_v4l2

/* Enable Video 4 Linux 2 MPEG PVR support */
$_def_pvr

/* 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

/* For the PPC.  G5 has the dcbzl when in 64bit mode but G4s and earlier do not
   have the instruction. */
$_def_dcbzl

/* libmpeg2 wants ARCH_PPC and the rest of mplayer use ARCH_POWERPC,
 * define ARCH_PPC if ARCH_POWERPC is set to cope with that.
 */
#ifdef ARCH_POWERPC
#define ARCH_PPC 1
#endif

/* the same issue as with ARCH_POWERPC but with ffmpeg/libavcodec */
#ifdef ARCH_ARMV4L
#define ARCH_ARM 1
#endif

/* only gcc3 can compile mvi instructions */
$_def_gcc_mvi_support

/* 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:"
#elif defined(SYS_DARWIN)
#define DEFAULT_CDROM_DEVICE    "/dev/disk1"
#define DEFAULT_DVD_DEVICE	"/dev/rdiskN"
#elif defined(__OpenBSD__)
#define DEFAULT_CDROM_DEVICE	"/dev/rcd0a"
#define DEFAULT_DVD_DEVICE	DEFAULT_CDROM_DEVICE
#elif defined(__FreeBSD__)
#define DEFAULT_CDROM_DEVICE	"/dev/acd0"
#define DEFAULT_DVD_DEVICE	DEFAULT_CDROM_DEVICE
#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.
**
*---------------------------------------------------------------------------*/

/* C99 lrintf function available */
$_def_lrintf

/* round function is available */
$_def_round

/* yes, we have inttypes.h */
#define HAVE_INTTYPES_H 1

/* int_fastXY_t emulation */
$_def_fast_inttypes

/* nanosleep support */
$_def_nanosleep

/* SMB support */
$_def_smbsupport

/* 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_jpeg

/* enable PNM support */
$_def_pnm

/* enable md5sum support */
$_def_md5sum

/* enable GIF support */
$_def_gif
$_def_gif_4
$_def_gif_tvt_hack

/* enable bitmap font support */
$_def_bitmap_font

/* enable FreeType support */
$_def_freetype

/* enable Fontconfig support */
$_def_fontconfig

/* enable SSA/ASS support */
$_def_ass

/* enable FriBiDi usage */
$_def_fribidi

/* enable ENCA usage */
$_def_enca

/* liblzo support */
$_def_liblzo
#ifdef USE_LIBLZO
#define CONFIG_LZO 1
#endif

/* libmad support */
$_def_mad

/* enable OggVorbis support */
$_def_vorbis
$_def_tremor

/* enable Speex support */
$_def_speex

/* enable musepack support */
$_def_musepack

/* enable OggTheora support */
$_def_theora

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

/* enable FAAC (AAC encoder) support */
$_def_faac

/* enable LADSPA plugin support */
$_def_ladspa

/* enable network */
$_def_network

/* enable ftp support */
$_def_ftp

/* enable vstream support */
$_def_vstream

/* enable winsock2 instead of Unix functions*/
$_def_winsock2

/* 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
$_def_vidix_pfx

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

/* enables / disables QTX codecs */
$_def_qtx

/* enables / disables osd menu */
$_def_menu

/* enables / disables subtitles sorting */
$_def_sortsub

/* XMMS input plugin support */
$_def_xmms
#define XMMS_INPUT_PLUGIN_DIR "$_xmmsplugindir"

/* enables inet6 support */
$_def_inet6

/* do we have gethostbyname2? */
$_def_gethostbyname2

/* Extension defines */
$_def_3dnow	// only define if you have 3DNOW (AMD k6-2, AMD Athlon, iDT WinChip, etc.)
$_def_3dnowext	// only define if you have 3DNOWEXT (AMD Athlon, etc.)
$_def_mmx	// only define if you have MMX (newer x86 chips, not P54C/PPro)
$_def_mmxext	// 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)
$_def_altivec	// only define if you have Altivec (G4)
$_def_armv5te	// only define if you have Enhanced DSP Extensions (ARM)
$_def_iwmmxt	// only define if you have XScale IWMMX (ARM)

$_def_altivec_h	// enables usage of altivec.h

$_def_mlib  // Sun mediaLib, available only on solaris
$_def_vis	// only define if you have VIS ( ultrasparc )

/* 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_xvmc
$_def_vm
$_def_xf86keysym
$_def_xinerama
$_def_gl
$_def_gl_win32
$_def_dga
$_def_dga2
$_def_sdl
/* defined for SDLlib with keyrepeat bugs (before 1.2.1) */
$_def_sdlbuggy
$_def_directx
$_def_ggi
$_def_ggiwmh
$_def_3dfx
$_def_s3fb
$_def_tdfxfb
$_def_tdfxvid
$_def_directfb
$_def_directfb_version
$_def_dfbmga
$_def_zr
$_def_bl
$_def_mga
$_def_xmga
$_def_syncfb
$_def_fbdev
$_def_dxr2
$_def_dxr3
$_def_ivtv
$_def_dvb
$_def_dvb_in
$_def_svga
$_def_vesa
$_def_xdpms
$_def_aa
$_def_caca
$_def_tga
$_def_toolame
$_def_twolame

/* used by GUI: */
$_def_xshape

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

#endif /* MPLAYER_CONFIG_H */
EOF

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

cat << EOF

Config files successfully generated by ./configure !

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

  Byte order: $_byte_order
  Optimizing for: $_optimizing

  Languages:
    Messages/GUI: $_language
EOF

echo -n "    Manual pages: $MAN_LANG"
test "$LANGUAGES" = en && echo -n " (no localization selected, use --language=all)"
echo
  
cat << EOF

  Enabled optional drivers:
    Input: $_inputmodules
    Codecs: $_codecmodules
    Audio output: $_aomodules
    Video output: $_vomodules
    Audio filters: $_afmodules
  Disabled optional drivers:
    Input: $_noinputmodules
    Codecs: $_nocodecmodules
    Audio output: $_noaomodules
    Video output: $_novomodules
    Audio filters: $_noafmodules

'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/HTML/$_doc_lang/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
      echo "Failed to find a Win32 codecs dir at $_win32libdir!"
    else
      echo "Failed to find a Win32 codecs directory! (default: /usr/local/lib/codecs/)"
    fi
    cat << EOF
Create it and copy the DLL files there! You can download the codecs from our
homepage at http://www.mplayerhq.hu/MPlayer/releases/codecs/

EOF
  fi
else
  cat <<EOF
NOTE: Win32 codec DLLs are not supported on your CPU ($host_arch) or your
operating system ($system_name). You may encounter a few 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).
Do not report compilation errors if you used any of the --enable-* options
(except --enable-gui and maybe --enable-debug).

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

EOF

if test "$_warn_CFLAGS" = yes; then
  cat <<EOF

MPlayer compilation will use the CPPFLAGS/CFLAGS/LDFLAGS 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

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