summaryrefslogtreecommitdiffstats
path: root/configure
blob: 5adcd71aaba7204e2256deae30acab0694572f3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
#! /bin/sh
#
# Original version (C) 2000 Pontscho/fresh!mindworkz
#                      pontscho@makacs.poliod.hu
#
# History / Contributors: Check the Subversion 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, look at the existing checks
# and try to use helper functions where you can.
#
# 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
export LC_ALL=C

# Store the configure line that was used
configuration="$*"

# Prefer these macros to full length text !
# These macros only return an error code - NO display is done
compile_check() {
  source="$1"
  shift
  echo >> "$TMPLOG"
  cat "$source" >> "$TMPLOG"
  echo >> "$TMPLOG"
  echo "$_cc $WARNFLAGS $WARN_CFLAGS $CFLAGS $source $extra_cflags $_ld_static $extra_ldflags $libs_mplayer -o $TMPEXE $@" >> "$TMPLOG"
  rm -f "$TMPEXE"
  $_cc $WARNFLAGS $WARN_CFLAGS $CFLAGS "$source" $extra_cflags $_ld_static $extra_ldflags $libs_mplayer -o "$TMPEXE" "$@" >> "$TMPLOG" 2>&1
  TMPRES="$?"
  echo >> "$TMPLOG"
  echo >> "$TMPLOG"
  return "$TMPRES"
}

cc_check() {
  compile_check $TMPC $@
}

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

cflag_check() {
  cat > $TMPC << EOF
int main(void) { return 0; }
EOF
  compile_check $TMPC $@
}

header_check() {
  cat > $TMPC << EOF
#include <$1>
int main(void) { return 0; }
EOF
  shift
  compile_check $TMPC $@
}

return_check() {
  cat > $TMPC << EOF
#include <$1>
int main(void) { return $2; }
EOF
  shift 2
  compile_check $TMPC $@
}

statement_check() {
  cat > $TMPC << EOF
#include <$1>
int main(void) { $2; return 0; }
EOF
  shift
  shift
  compile_check $TMPC $@
}

define_statement_check() {
  cat > $TMPC << EOF
#define $1
#include <$2>
int main(void) { $3; return 0; }
EOF
  shift 3
  compile_check $TMPC $@
}

return_statement_check() {
  cat > $TMPC << EOF
#include <$1>
int main(void) { $2; return $3; }
EOF
  shift 3
  compile_check $TMPC $@
}

inline_asm_check() {
  cat > $TMPC << EOF
int main(void) { __asm__ volatile ($1); return 0; }
EOF
  shift
  compile_check $TMPC $@
}

# The following checks are special and should only be used with broken and
# non-selfsufficient headers that do not include all of their dependencies.

header_check_broken() {
  cat > $TMPC << EOF
#include <$1>
#include <$2>
int main(void) { return 0; }
EOF
  shift
  shift
  compile_check $TMPC $@
}

statement_check_broken() {
  cat > $TMPC << EOF
#include <$1>
#include <$2>
int main(void) { $3; return 0; }
EOF
  shift 3
  compile_check $TMPC $@
}

pkg_config_add() {
  unset IFS  # shell should not be used for programming
  echo >> "$TMPLOG"
  echo "$_pkg_config --cflags $@" >> "$TMPLOG"
  ctmp=$($_pkg_config --cflags "$@" 2>> "$TMPLOG") || return $?
  echo >> "$TMPLOG"
  echo "$_pkg_config --libs $@" >> "$TMPLOG"
  ltmp=$($_pkg_config --libs "$@" 2>> "$TMPLOG") || return $?
  echo >> "$TMPLOG"
  echo "cflags: $ctmp" >> "$TMPLOG"
  echo "libs: $ltmp" >> "$TMPLOG"
  echo >> "$TMPLOG"
  extra_cflags="$extra_cflags $ctmp"
  extra_ldflags="$extra_ldflags $ltmp"
}

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

# Display error message, flushes tempfile, exit
die () {
  echo
  echo "Error: $@" >&2
  echo >&2
  rm -f "$TMPEXE" "$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)"
}
cygwin()    { issystem "CYGWIN"; }
darwin()    { issystem "Darwin"; }
dragonfly() { issystem "DragonFly"; }
freebsd()   { issystem "FreeBSD" || issystem "GNU/kFreeBSD"; }
gnu()       { issystem "GNU"; }
linux()     { issystem "Linux"; }
mingw32()   { issystem "MINGW32"; }
morphos()   { issystem "MorphOS"; }
netbsd()    { issystem "NetBSD"; }
openbsd()   { issystem "OpenBSD"; }
win32()     { cygwin || mingw32; }

# arch test boolean functions
x86_32() {
  case "$host_arch" in
    i[3-9]86|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
}

x86() {
  x86_32 || x86_64
}

ppc() {
  case "$host_arch" in
    ppc|ppc64|powerpc|powerpc64) 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
}

# 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

msg_lang_all=''
ls po/*.po >/dev/null 2>&1 && msg_lang_all=$(echo po/*.po | sed -e 's:po/\([^[:space:]]*\)\.po:\1:g')
man_lang_all=$(echo DOCS/man/??/mplayer.1 DOCS/man/??_??/mplayer.1 | sed -e "s:DOCS/man/\(..\)/mplayer.1:\1:g" -e "s:DOCS/man/\(.._..\)/mplayer.1:\1:g")
doc_lang_all=$(echo DOCS/xml/??/ DOCS/xml/??_??/ | sed -e "s:DOCS/xml/\(..\)/:\1:g" -e "s:DOCS/xml/\(.._..\)/:\1:g")

show_help(){
cat << EOF
Usage: $0 [OPTIONS]...

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

Installation directories:
  --prefix=DIR           prefix directory for installation [/usr/local]
  --bindir=DIR           directory for installing binaries [PREFIX/bin]
  --datadir=DIR          directory for installing machine independent
                         data files (skins, etc) [PREFIX/share/mplayer]
  --mandir=DIR           directory for installing man pages [PREFIX/share/man]
  --confdir=DIR          directory for installing configuration files
                         [PREFIX/etc/mplayer]
  --localedir=DIR        directory for locale tree [PREFIX/share/locale]
  --libdir=DIR           directory for object code libraries [PREFIX/lib]
  --codecsdir=DIR        directory for binary codecs [LIBDIR/codecs]

Optional features:
  --disable-mplayer      disable MPlayer compilation [enable]
  --enable-termcap       use termcap database for key codes [autodetect]
  --enable-termios       use termios database for key codes [autodetect]
  --disable-iconv        disable iconv for encoding conversion [autodetect]
  --enable-lirc          enable LIRC (remote control) support [autodetect]
  --enable-lircc         enable LIRCCD (LIRC client daemon) input [autodetect]
  --enable-joystick      enable joystick support [disable]
  --enable-apple-remote  enable Apple Remote input (Mac OS X only) [autodetect]
  --enable-apple-ir      enable Apple IR Remote input (Linux only) [autodetect]
  --disable-vm           disable X video mode extensions [autodetect]
  --disable-xf86keysym   disable support for multimedia keys [autodetect]
  --enable-radio         enable radio interface [disable]
  --enable-radio-capture enable radio capture (through PCI/line-in) [disable]
  --disable-radio-v4l2   disable Video4Linux2 radio interface [autodetect]
  --disable-radio-bsdbt848   disable BSD BT848 radio interface [autodetect]
  --disable-tv           disable TV interface (TV/DVB grabbers) [enable]
  --disable-tv-v4l1      disable Video4Linux TV interface [autodetect]
  --disable-tv-v4l2      disable Video4Linux2 TV interface [autodetect]
  --disable-tv-bsdbt848  disable BSD BT848 interface [autodetect]
  --disable-pvr          disable Video4Linux2 MPEG PVR [autodetect]
  --disable-networking   disable networking [enable]
  --enable-winsock2_h    enable winsock2_h [autodetect]
  --enable-smb           enable Samba (SMB) input [autodetect]
  --enable-live          enable LIVE555 Streaming Media [disable]
  --enable-libquvi       enable libquvi [autodetect]
  --enable-nemesi        enable Nemesi Streaming Media [autodetect]
  --enable-lcms2         enable LCMS2 support [autodetect]
  --disable-vcd          disable VCD support [autodetect]
  --disable-bluray       disable Blu-ray support [autodetect]
  --disable-dvdnav       disable libdvdnav [autodetect]
  --disable-dvdread      disable libdvdread [autodetect]
  --disable-dvdread-internal  disable internal libdvdread [autodetect]
  --disable-libdvdcss-internal  disable internal libdvdcss [autodetect]
  --disable-cddb         disable cddb [autodetect]
  --disable-sortsub      disable subtitle sorting [enabled]
  --disable-enca         disable ENCA charset oracle library [autodetect]
  --enable-macosx-finder 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  gethostbyname2 part of 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-w32threads   disable Win32 threads support [autodetect]
  --disable-libass       disable subtitle rendering with libass [autodetect]
  --disable-libass-osd   disable OSD rendering with libass [autodetect]
  --enable-rpath         enable runtime linker path for extra libs [disabled]
  --disable-libpostproc  disable postprocess filter (vf_pp) [autodetect]

Codecs:
  --enable-gif              enable GIF support [autodetect]
  --enable-png              enable PNG input/output support [autodetect]
  --enable-mng              enable MNG input support [autodetect]
  --enable-jpeg             enable JPEG input/output support [autodetect]
  --enable-libcdio          enable libcdio support [autodetect]
  --disable-win32dll        disable Win32 DLL support [disabled]
  --disable-qtx             disable QuickTime codecs support [enabled]
  --disable-xanim           disable XAnim codecs support [enabled]
  --disable-real            disable RealPlayer codecs support [enabled]
  --enable-libav            skip Libav autodetection [autodetect]
  --enable-faad             enable FAAD2 (AAC) [autodetect]
  --disable-ladspa          disable LADSPA plugin support [autodetect]
  --disable-libbs2b         disable libbs2b audio filter support [autodetect]
  --disable-libdv           disable libdv 0.9.5 en/decoding support [autodetect]
  --disable-mpg123          disable libmpg123 MP3 decoding support [autodetect]
  --disable-mad             disable libmad (MPEG audio) support [autodetect]
  --enable-libdca           enable libdca support [autodetect]
  --disable-liba52          disable liba52 [autodetect]

Video output:
  --enable-gl              enable OpenGL video output [autodetect]
  --enable-caca            enable CACA  video output [autodetect]
  --enable-direct3d        enable Direct3D video output [autodetect]
  --enable-directx         enable DirectX video output [autodetect]
  --enable-v4l2            enable V4L2 Decoder audio/video output [autodetect]
  --enable-xv              enable Xv video output [autodetect]
  --enable-vdpau           enable VDPAU acceleration [autodetect]
  --enable-vm              enable XF86VidMode support [autodetect]
  --enable-xinerama        enable Xinerama support [autodetect]
  --enable-x11             enable X11 video output [autodetect]
  --enable-xshape          enable XShape support [autodetect]
  --disable-xss            disable screensaver support via xss [autodetect]
  --enable-directfb        enable DirectFB video output [autodetect]
  --disable-tga            disable Targa video output [enable]
  --disable-pnm            disable PNM video output [enable]
  --disable-md5sum         disable md5sum video output [enable]
  --disable-yuv4mpeg       disable yuv4mpeg video output [enable]
  --disable-corevideo      disable CoreVideo video output [autodetect]
  --disable-cocoa          disable Cocoa OpenGL backend [autodetect]
  --disable-sharedbuffer   disable OSX shared buffer video output [autodetect]

Audio output:
  --disable-alsa         disable ALSA audio output [autodetect]
  --disable-ossaudio     disable OSS audio output [autodetect]
  --disable-rsound       disable RSound audio output [autodetect]
  --disable-pulse        disable Pulseaudio audio output [autodetect]
  --disable-portaudio    disable PortAudio audio output [autodetect]
  --disable-jack         disable JACK audio output [autodetect]
  --enable-openal        enable OpenAL audio output [disable]
  --disable-coreaudio    disable CoreAudio audio output [autodetect]
  --disable-select       disable using select() on the audio device [enable]

Language options:
  --enable-translation   enable support for translated output [disable]
  --language-doc=lang    language to use for the documentation [en]
  --language-man=lang    language to use for the man pages [en]
  --language-msg=lang    extra languages for program messages [all]
  --language=lang        default language to use [en]
Specific options override --language. You can pass a list of languages separated
by whitespace or commas instead of a single language. Nonexisting translations
will be dropped from each list. All translations available in the list will be
installed. The value "all" will activate all translations. The LINGUAS
environment variable is honored. In all cases the fallback is English.
The program always supports English-language output; additional message
languages are only installed if --enable-translation is also specified.
Available values for --language-doc are: all $doc_lang_all
Available values for --language-man are: all $man_lang_all
Available values for --language-msg are: all $msg_lang_all

Miscellaneous options:
  --enable-cross-compile enable cross-compilation [disable]
  --cc=COMPILER          C compiler to build MPlayer [gcc]
  --pkg-config=PKGCONFIG pkg-config to find some libraries [pkg-config]
  --windres=WINDRES      windres to build MPlayer [windres]
  --target=PLATFORM      target platform (i386-linux, arm-linux, etc)
  --enable-static        build a statically linked binary
  --with-install=PATH    path to a custom install program

Advanced options:
  --enable-shm              enable shm [autodetect]
  --enable-debug[=1-3]      compile-in debugging information [disable]
  --enable-profile          compile-in profiling information [disable]

Use these options if autodetection fails:
  --extra-cflags=FLAGS        extra CFLAGS
  --extra-ldflags=FLAGS       extra LDFLAGS
  --extra-libs=FLAGS          extra linker flags
  --extra-libs-mplayer=FLAGS  extra linker flags for MPlayer

  --with-dvdnav-config=PATH   path to dvdnav-config
  --with-dvdread-config=PATH  path to dvdread-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()

# 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
_install=install
_pkg_config=auto
_windres=auto
_cc=auto
test "$CC" && _cc="$CC"
_cross_compile=no
_prefix="/usr/local"
ffmpeg=auto
ffmpeg_internals=no
_mplayer=yes
_x11=auto
_xshape=auto
_xss=auto
_xv=auto
_vdpau=auto
_direct3d=auto
_directx=auto
_nas=auto
_png=auto
_mng=auto
_jpeg=auto
_pnm=yes
_md5sum=yes
_yuv4mpeg=yes
_gif=auto
_gl=auto
_aa=auto
_caca=auto
_dvb=auto
_v4l2=auto
_iconv=auto
_ossaudio=auto
_rsound=auto
_pulse=auto
_portaudio=auto
_jack=auto
_openal=no
_libcdio=auto
_mad=auto
_mpg123=auto
_liba52=auto
_libdca=auto
_faad=auto
_ladspa=auto
_libbs2b=auto
_vcd=auto
_bluray=auto
_dvdnav=auto
_dvdnavconfig=dvdnav-config
_dvdreadconfig=dvdread-config
_dvdread=auto
_dvdread_internal=auto
_libdvdcss_internal=auto
_xanim=auto
_real=auto
_live=no
_nemesi=auto
_lcms2=auto
_xinerama=auto
_vm=auto
_xf86keysym=auto
_alsa=auto
_win32dll=no
_select=yes
_radio=no
_radio_capture=no
_radio_v4l=auto
_radio_v4l2=auto
_radio_bsdbt848=auto
_tv=yes
_tv_v4l1=auto
_tv_v4l2=auto
_tv_bsdbt848=auto
_tv_dshow=auto
_pvr=auto
networking=yes
_winsock2_h=auto
_smb=auto
_libquvi=auto
_joystick=no
_lirc=auto
_lircc=auto
_apple_remote=auto
_apple_ir=auto
_termcap=auto
_termios=auto
_tga=yes
_directfb=auto
#language=en
_shm=auto
_translation=no
_libdv=auto
_cdda=auto
_cddb=auto
_qtx=auto
_coreaudio=auto
_corevideo=auto
_cocoa=auto
_sharedbuffer=auto
quicktime=auto
_macosx_finder=no
_macosx_bundle=auto
_sortsub=yes
_enca=auto
_inet6=auto
_gethostbyname2=auto
_ftp=auto
_vstream=auto
_pthreads=auto
_w32threads=auto
_ass=auto
_libass_osd=auto
_rpath=no
libpostproc=auto
_asmalign_pot=auto
_stream_cache=yes
_priority=no
def_dos_paths="#define HAVE_DOS_PATHS 0"
def_stream_cache="#define CONFIG_STREAM_CACHE 1"
def_priority="#undef CONFIG_PRIORITY"
def_pthread_cache="#undef PTHREAD_CACHE"
need_shmem=yes
for ac_option do
  case "$ac_option" in
  --help|-help|-h)
    show_help
    ;;
  --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)
    ;;
  --codecsdir=*)
    _codecsdir=$(echo $ac_option | cut -d '=' -f 2)
    ;;
  --localedir=*)
    _localedir=$(echo $ac_option | cut -d '=' -f 2)
    ;;

  --with-install=*)
    _install=$(echo $ac_option | cut -d '=' -f 2 )
    ;;

  --with-dvdnav-config=*)
    _dvdnavconfig=$(echo $ac_option | cut -d '=' -f 2)
    ;;
  --with-dvdread-config=*)
    _dvdreadconfig=$(echo $ac_option | cut -d '=' -f 2)
    ;;

  --extra-cflags=*)
    extra_cflags="$extra_cflags $(echo $ac_option | cut -d '=' -f 2-)"
    ;;
  --extra-ldflags=*)
    extra_ldflags="$extra_ldflags $(echo $ac_option | cut -d '=' -f 2-)"
    ;;
  --extra-libs=*)
    extra_libs=$(echo $ac_option | cut -d '=' -f 2)
    ;;
  --extra-libs-mplayer=*)
    libs_mplayer=$(echo $ac_option | cut -d '=' -f 2)
    ;;

  --target=*)
    _target=$(echo $ac_option | cut -d '=' -f 2)
    ;;
  --cc=*)
    _cc=$(echo $ac_option | cut -d '=' -f 2)
    ;;
  --pkg-config=*)
    _pkg_config=$(echo $ac_option | cut -d '=' -f 2)
    ;;
  --windres=*)
    _windres=$(echo $ac_option | cut -d '=' -f 2)
    ;;
  --language-doc=*)
    language_doc=$(echo $ac_option | cut -d '=' -f 2)
    ;;
  --language-man=*)
    language_man=$(echo $ac_option | cut -d '=' -f 2)
    ;;
  --language-msg=*)
    language_msg=$(echo $ac_option | cut -d '=' -f 2)
    ;;
  --language=*)
    language=$(echo $ac_option | cut -d '=' -f 2)
    ;;

  --enable-static)
    _ld_static='-static'
    ;;
  --disable-static)
    _ld_static=''
    ;;
  --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=
    ;;
  --enable-translation)              _translation=yes           ;;
  --disable-translation)             _translation=no            ;;
  --enable-cross-compile)           _cross_compile=yes          ;;
  --disable-cross-compile)          _cross_compile=no           ;;
  --enable-mplayer)     _mplayer=yes    ;;
  --disable-mplayer)    _mplayer=no     ;;
  --enable-x11)         _x11=yes        ;;
  --disable-x11)        _x11=no         ;;
  --enable-xshape)      _xshape=yes     ;;
  --disable-xshape)     _xshape=no      ;;
  --enable-xss)         _xss=yes        ;;
  --disable-xss)        _xss=no         ;;
  --enable-xv)          _xv=yes         ;;
  --disable-xv)         _xv=no          ;;
  --enable-vdpau)       _vdpau=yes      ;;
  --disable-vdpau)      _vdpau=no       ;;
  --enable-direct3d)    _direct3d=yes   ;;
  --disable-direct3d)   _direct3d=no    ;;
  --enable-directx)     _directx=yes    ;;
  --disable-directx)    _directx=no     ;;
  --enable-png)         _png=yes        ;;
  --disable-png)        _png=no         ;;
  --enable-mng)         _mng=yes        ;;
  --disable-mng)        _mng=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-yuv4mpeg)    _yuv4mpeg=yes   ;;
  --disable-yuv4mpeg)   _yuv4mpeg=no    ;;
  --enable-gif)         _gif=yes        ;;
  --disable-gif)        _gif=no         ;;
  --enable-gl)          _gl=yes         ;;
  --disable-gl)         _gl=no          ;;
  --enable-caca)        _caca=yes       ;;
  --disable-caca)       _caca=no        ;;
  --enable-dvb)         _dvb=yes        ;;
  --disable-dvb)        _dvb=no         ;;
  --enable-v4l2)        _v4l2=yes       ;;
  --disable-v4l2)       _v4l2=no        ;;
  --enable-iconv)       _iconv=yes      ;;
  --disable-iconv)      _iconv=no       ;;
  --enable-libdv)       _libdv=yes      ;;
  --disable-libdv)      _libdv=no       ;;
  --enable-ossaudio)    _ossaudio=yes   ;;
  --disable-ossaudio)   _ossaudio=no    ;;
  --enable-rsound)      _rsound=yes     ;;
  --disable-rsound)     _rsound=no      ;;
  --enable-pulse)       _pulse=yes      ;;
  --disable-pulse)      _pulse=no       ;;
  --enable-portaudio)   _portaudio=yes  ;;
  --disable-portaudio)  _portaudio=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-libcdio)     _libcdio=yes    ;;
  --disable-libcdio)    _libcdio=no     ;;
  --enable-mpg123)      _mpg123=yes     ;;
  --disable-mpg123)     _mpg123=no      ;;
  --enable-liba52)      _liba52=yes     ;;
  --disable-liba52)     _liba52=no      ;;
  --enable-libdca)      _libdca=yes     ;;
  --disable-libdca)     _libdca=no      ;;
  --enable-faad)        _faad=yes       ;;
  --disable-faad)       _faad=no        ;;
  --enable-ladspa)      _ladspa=yes     ;;
  --disable-ladspa)     _ladspa=no      ;;
  --enable-libbs2b)     _libbs2b=yes    ;;
  --disable-libbs2b)    _libbs2b=no     ;;
  --enable-vcd)         _vcd=yes        ;;
  --disable-vcd)        _vcd=no         ;;
  --enable-bluray)      _bluray=yes     ;;
  --disable-bluray)     _bluray=no      ;;
  --enable-dvdread)     _dvdread=yes    ;;
  --disable-dvdread)    _dvdread=no     ;;
  --enable-dvdread-internal)    _dvdread_internal=yes   ;;
  --disable-dvdread-internal)   _dvdread_internal=no    ;;
  --enable-libdvdcss-internal)  _libdvdcss_internal=yes ;;
  --disable-libdvdcss-internal) _libdvdcss_internal=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-nemesi)      _nemesi=yes     ;;
  --disable-nemesi)     _nemesi=no      ;;
  --enable-lcms2)       _lcms2=yes      ;;
  --disable-lcms2)      _lcms2=no       ;;
  --enable-xinerama)    _xinerama=yes   ;;
  --disable-xinerama)   _xinerama=no    ;;
  --enable-vm)          _vm=yes         ;;
  --disable-vm)         _vm=no          ;;
  --enable-xf86keysym)  _xf86keysym=yes ;;
  --disable-xf86keysym) _xf86keysym=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-tv-dshow)    _tv_dshow=yes   ;;
  --disable-tv-dshow)   _tv_dshow=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-radio-bsdbt848)      _radio_bsdbt848=yes     ;;
  --disable-radio-bsdbt848)     _radio_bsdbt848=no      ;;
  --enable-pvr)         _pvr=yes        ;;
  --disable-pvr)        _pvr=no         ;;
  --enable-networking)     networking=yes    ;;
  --disable-networking)    networking=no     ;;
  --enable-winsock2_h)  _winsock2_h=yes ;;
  --disable-winsock2_h) _winsock2_h=no  ;;
  --enable-smb)         _smb=yes        ;;
  --disable-smb)        _smb=no ;;
  --enable-libquvi)     _libquvi=yes    ;;
  --disable-libquvi)    _libquvi=no     ;;
  --enable-joystick)    _joystick=yes   ;;
  --disable-joystick)   _joystick=no    ;;
  --enable-libav)       ffmpeg=yes      ;;
  --ffmpeg-source-dir=*)
    _ffmpeg_source=$(echo $ac_option | cut -d '=' -f 2 ) ;;

  --enable-lirc)        _lirc=yes       ;;
  --disable-lirc)       _lirc=no        ;;
  --enable-lircc)       _lircc=yes      ;;
  --disable-lircc)      _lircc=no       ;;
  --enable-apple-remote)  _apple_remote=yes ;;
  --disable-apple-remote) _apple_remote=no  ;;
  --enable-apple-ir)    _apple_ir=yes   ;;
  --disable-apple-ir)   _apple_ir=no    ;;
  --enable-termcap)     _termcap=yes    ;;
  --disable-termcap)    _termcap=no     ;;
  --enable-termios)     _termios=yes    ;;
  --disable-termios)    _termios=no     ;;
  --disable-tga)        _tga=no         ;;
  --enable-tga)         _tga=yes        ;;
  --enable-directfb)    _directfb=yes   ;;
  --disable-directfb)   _directfb=no    ;;
  --enable-shm)         _shm=yes        ;;
  --disable-shm)        _shm=no         ;;
  --enable-select)      _select=yes     ;;
  --disable-select)     _select=no      ;;
  --enable-cddb)        _cddb=yes       ;;
  --disable-cddb)       _cddb=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-w32threads)  _w32threads=yes ;;
  --disable-w32threads) _w32threads=no  ;;
  --enable-libass)      _ass=yes        ;;
  --disable-libass)     _ass=no         ;;
  --enable-libass-osd)  _libass_osd=yes ;;
  --disable-libass-osd) _libass_osd=no  ;;
  --enable-rpath)       _rpath=yes      ;;
  --disable-rpath)      _rpath=no       ;;
  --enable-libpostproc) libpostproc=yes ;;
  --disable-libpostproc) libpostproc=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-qtx) _qtx=yes ;;
  --disable-qtx) _qtx=no ;;

  --enable-coreaudio) _coreaudio=yes ;;
  --disable-coreaudio) _coreaudio=no ;;
  --enable-corevideo) _corevideo=yes ;;
  --disable-corevideo) _corevideo=no ;;
  --enable-cocoa) _cocoa=yes ;;
  --disable-cocoa) _cocoa=no ;;
  --enable-sharedbuffer) _sharedbuffer=yes ;;
  --disable-sharedbuffer) _sharedbuffer=no ;;
  --enable-macosx-finder) _macosx_finder=yes ;;
  --disable-macosx-finder) _macosx_finder=no ;;
  --enable-macosx-bundle) _macosx_bundle=yes ;;
  --disable-macosx-bundle) _macosx_bundle=no ;;

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

  --enable-win32dll) _win32dll=yes ;;
  --disable-win32dll) _win32dll=no ;;

  *)
    echo "Unknown parameter: $ac_option" >&2
    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/share/man"
test -z "$_confdir" && _confdir="$_prefix/etc/mplayer"
test -z "$_libdir"  && _libdir="$_prefix/lib"
test -z "$_localedir"  && _localedir="$_prefix/share/locale"

for tmpdir in "$TMPDIR" "$TEMPDIR" "/tmp" ; do
  test "$tmpdir" && break
done

mplayer_tmpdir="$tmpdir/mplayer-configure-$RANDOM-$$"
mkdir $mplayer_tmpdir || die "Unable to create tmpdir."

TMPLOG="config.log"

rm -f "$TMPLOG"
echo Parameters configure was run with: > "$TMPLOG"
if test -n "$CFLAGS" ; then
    echo ${_echo_n} CFLAGS="'$CFLAGS' ${_echo_c}" >> "$TMPLOG"
fi
if test -n "$PKG_CONFIG_PATH" ; then
    echo ${_echo_n} PKG_CONFIG_PATH="'$PKG_CONFIG_PATH' ${_echo_c}" >> "$TMPLOG"
fi
echo ./configure $configuration >> "$TMPLOG"
echo >> "$TMPLOG"


echocheck "cross compilation"
echores $_cross_compile

if test $_cross_compile = yes; then
  tmp_run() {
    return 0
  }
fi

tool_prefix=""

if test $_cross_compile = yes ; then
    # Usually cross-compiler prefixes match with the target triplet
    test -n "$_target" && tool_prefix="$_target"-
fi

test "$_windres" = auto && _windres="$tool_prefix"windres
test "$_pkg_config" = auto && _pkg_config="$tool_prefix"pkg-config

if test "$_cc" = auto ; then
    if test -n "$tool_prefix" ; then
        _cc="$tool_prefix"gcc
    else
        _cc=cc
    fi
fi

# 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|OpenBSD|DragonFly|Darwin|GNU|MorphOS)
    ;;
  Haiku)
    system_name=Haiku
    ;;
  GNU/kFreeBSD)
    system_name=FreeBSD
    ;;
  [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.

      case "$(uname -m 2>&1)" in
      x86_64|amd64|i[3-9]86*|k5|k6|k6_2|k6_3|k6-2|k6-3|pentium*|athlon*|i586_i686|i586-i686|BePC) host_arch=i386 ;;
      ia64) host_arch=ia64 ;;
      macppc|ppc) host_arch=ppc ;;
      ppc64) host_arch=ppc64 ;;
      alpha) host_arch=alpha ;;
      sparc) host_arch=sparc ;;
      sparc64) host_arch=sparc64 ;;
      parisc*|hppa*|9000*) host_arch=hppa ;;
      arm*|zaurus|cats) host_arch=arm ;;
      sh3|sh4|sh4a) host_arch=sh ;;
      s390) host_arch=s390 ;;
      s390x) host_arch=s390x ;;
      *mips*) host_arch=mips ;;
      vax) host_arch=vax ;;
      xtensa*) host_arch=xtensa ;;
      *) host_arch=UNKNOWN ;;
    esac
    ;;
  esac
else # if test -z "$_target"
  for i in 2 3; do
    system_name=$(echo $_target | cut -d '-' -f $i)
    case "$(echo $system_name | tr A-Z a-z)" in
      linux) system_name=Linux ;;
      freebsd) system_name=FreeBSD ;;
      gnu/kfreebsd) system_name=FreeBSD ;;
      netbsd) system_name=NetBSD ;;
      openbsd) system_name=OpenBSD ;;
      dragonfly) system_name=DragonFly ;;
      morphos) system_name=MorphOS ;;
      mingw32*) system_name=MINGW32 ;;
      *) continue ;;
    esac
    break
  done
  # 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)
  if test $(echo $host_arch) != "x86_64" ; then
    host_arch=$(echo $host_arch | tr '_' '-')
  fi
fi

extra_cflags="-I. $extra_cflags"
_timer=timer-linux.c
_getch=getch2.c
if freebsd ; then
  extra_ldflags="$extra_ldflags -L/usr/local/lib"
  extra_cflags="$extra_cflags -I/usr/local/include"
fi

if netbsd || dragonfly ; then
  extra_ldflags="$extra_ldflags -L/usr/pkg/lib"
  extra_cflags="$extra_cflags -I/usr/pkg/include"
fi

if darwin; then
  extra_cflags="-mdynamic-no-pic $extra_cflags"
  _timer=timer-darwin.c
fi

if win32 ; then
  _exesuf=".exe"
  extra_cflags="$extra_cflags -fno-common"
  # -lwinmm is always needed for osdep/timer-win2.c
  extra_ldflags="$extra_ldflags -lwinmm"
  _pe_executable=yes
  _timer=timer-win2.c
  _priority=yes
  def_dos_paths="#define HAVE_DOS_PATHS 1"
  def_priority="#define CONFIG_PRIORITY 1"
fi

if mingw32 ; then
  _getch=getch2-win.c
  need_shmem=no
  extra_cflags="$extra_cflags -D__USE_MINGW_ANSI_STDIO=1"
fi

TMPC="$mplayer_tmpdir/tmp.c"
TMPCPP="$mplayer_tmpdir/tmp.cpp"
TMPEXE="$mplayer_tmpdir/tmp$_exesuf"
TMPH="$mplayer_tmpdir/tmp.h"
TMPS="$mplayer_tmpdir/tmp.S"

# Checking CC version...
# 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 -n 1 | cut -d ',' -f 1)
  cc_version=$($_cc -V 2>&1 | head -n 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_fail=yes
      ;;
    10.1|11.0|11.1)
      cc_version="$cc_version, ok"
      ;;
    *)
      cc_version="$cc_version, bad"
      cc_fail=yes
      ;;
  esac
  echores "$cc_version"
else
  for _cc in "$_cc" gcc cc ; do
    cc_name_tmp=$($_cc -v 2>&1 | tail -n 1 | cut -d ' ' -f 1)
    if test "$cc_name_tmp" = "gcc"; then
      cc_name=$cc_name_tmp
      echocheck "$_cc version"
      cc_vendor=gnu
      cc_version=$($_cc -dumpversion 2>&1)
      case $cc_version in
        2.96*)
          cc_fail=yes
          ;;
        *)
          _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)
          ;;
      esac
      echores "$cc_version"
      break
    fi
    if $_cc -v 2>&1 | grep -q "clang"; then
      echocheck "$_cc version"
      cc_vendor=clang
      cc_version=$($_cc -dumpversion 2>&1)
      res_comment="experimental support only"
      echores "clang $cc_version"
      break
    fi
    cc_name_tmp=$($_cc -V 2>&1 | head -n 1 | cut -d ' ' -f 2,3)
  done
fi # icc
test "$cc_fail" = yes && die "unsupported compiler version"

echocheck "working compiler"
cflag_check "" || die "Compiler is not functioning correctly. Check your installation and custom CFLAGS $CFLAGS ."
echo "yes"

if test -z "$_target" && x86 ; then
  cat > $TMPC << EOF
int main(void) {
    int test[(int)sizeof(char *)-7];
    return 0;
}
EOF
  cc_check && host_arch=x86_64 || host_arch=i386
fi

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

# ---

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


def_fast_64bit='#define HAVE_FAST_64BIT 0'
arch_all='X86 IA64 SPARC ARM AVR32 SH4 PPC ALPHA MIPS PA_RISC S390 S390X VAX BFIN XTENSA TOMI GENERIC'
subarch_all='X86_32 X86_64 PPC64'
case "$host_arch" in
  i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686)
    arch='x86'
    subarch='x86_32'
    iproc=486
    proc=i486
    ;;

  ia64)
    arch='ia64'
    def_fast_64bit='#define HAVE_FAST_64BIT 1'
    iproc='ia64'
    ;;

  x86_64|amd64)
    arch='x86'
    subarch='x86_64'
    def_fast_64bit='#define HAVE_FAST_64BIT 1'
    iproc='x86_64'
    ;;

  sparc|sparc64)
    arch='sparc'
    iproc='sparc'
    ;;

  arm*)
    arch='arm'
    iproc='arm'
    ;;

  avr32)
    arch='avr32'
    iproc='avr32'
    ;;

  sh|sh4)
    arch='sh4'
    iproc='sh4'
    ;;

  ppc|ppc64|powerpc|powerpc64)
    arch='ppc'
    iproc='ppc'
    ;;

  alpha*)
    arch='alpha'
    iproc='alpha'
    ;;

  mips*)
    arch='mips'
    iproc='mips'
    ;;

  hppa)
    arch='pa_risc'
    iproc='PA-RISC'
    ;;

  s390)
    arch='s390'
    iproc='390'
    ;;

  s390x)
    arch='s390x'
    iproc='390x'
    ;;

  vax)
    arch='vax'
    iproc='vax'
    ;;

  xtensa)
    arch='xtensa'
    iproc='xtensa'
    ;;

  generic)
    arch='generic'
    ;;

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

echocheck "assembler support of -pipe option"
# -I. helps to detect compilers that just misunderstand -pipe like Sun C
cflag_check -pipe -I. && _pipe="-pipe" && echores "yes" || echores "no"

# Checking for CFLAGS
_install_strip="-s"
if test "$_profile" != "" || test "$_debug" != "" ; then
  _install_strip=
fi
if test -z "$CFLAGS" ; then
  if test "$cc_vendor" = "intel" ; then
    CFLAGS="-O2 $_debug $_profile $_march $_mcpu $_pipe -fomit-frame-pointer"
    WARNFLAGS="-wd167 -wd556 -wd144"
  elif test "$cc_vendor" = "clang"; then
    CFLAGS="-O2 $_debug $_profile $_march $_pipe"
    WARNFLAGS="-Wall -Wno-switch-enum -Wno-logical-op-parentheses -Wpointer-arith -Wundef -Wno-pointer-sign -Wmissing-prototypes"
    ERRORFLAGS="-Werror=implicit-function-declaration"
  elif test "$cc_vendor" != "gnu" ; then
    CFLAGS="-O2 $_debug $_profile $_march $_mcpu $_pipe"
  else
    CFLAGS="-O2 $_debug $_profile $_march $_mcpu $_pipe -ffast-math -fomit-frame-pointer"
    WARNFLAGS="-Wall -Wno-switch -Wno-parentheses -Wpointer-arith -Wredundant-decls"
    ERRORFLAGS="-Werror-implicit-function-declaration"
    extra_ldflags="$extra_ldflags -ffast-math"
  fi
else
  warn_cflags=yes
fi

if test "$cc_vendor" = "gnu" ; then
  cflag_check -Wundef && WARNFLAGS="-Wundef $WARNFLAGS"
  # -std=gnu99 is not a warning flag but is placed in WARN_CFLAGS because
  # that's the only variable specific to C now, and this option is not valid
  # for C++.
  cflag_check -std=gnu99 && WARN_CFLAGS="-std=gnu99 $WARN_CFLAGS"
  cflag_check -Wno-pointer-sign && WARN_CFLAGS="-Wno-pointer-sign $WARN_CFLAGS"
  cflag_check -Wdisabled-optimization && WARN_CFLAGS="-Wdisabled-optimization $WARN_CFLAGS"
  cflag_check -Wmissing-prototypes && WARN_CFLAGS="-Wmissing-prototypes $WARN_CFLAGS"
  cflag_check -Wstrict-prototypes && WARN_CFLAGS="-Wstrict-prototypes $WARN_CFLAGS"
else
  CFLAGS="-D_ISOC99_SOURCE -D_BSD_SOURCE $CFLAGS"
fi

cflag_check -mno-omit-leaf-frame-pointer && cflags_no_omit_leaf_frame_pointer="-mno-omit-leaf-frame-pointer"
cflag_check -MD -MP && DEPFLAGS="-MD -MP"


if test -n "$LDFLAGS" ; then
  extra_ldflags="$extra_ldflags $LDFLAGS"
  warn_cflags=yes
elif test "$cc_vendor" = "intel" ; then
  extra_ldflags="$extra_ldflags -i-static"
fi
if test -n "$CPPFLAGS" ; then
  extra_cflags="$extra_cflags $CPPFLAGS"
  warn_cflags=yes
fi


echocheck "PIC"
pic=no
cat > $TMPC << EOF
int main(void) {
#if !(defined(__PIC__) || defined(__pic__) || defined(PIC))
#error PIC not enabled
#endif
    return 0;
}
EOF
cc_check && pic=yes && extra_cflags="$extra_cflags -DPIC"
echores $pic


if x86 ; then

echocheck ".align is a power of two"
if test "$_asmalign_pot" = auto ; then
_asmalign_pot=no
inline_asm_check '".align 3"' && _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


echocheck "ebx availability"
ebx_available=no
def_ebx_available='#define HAVE_EBX_AVAILABLE 0'
cat > $TMPC << EOF
int main(void) {
    int x;
    __asm__ volatile(
        "xor %0, %0"
        :"=b"(x)
        // just adding ebx to clobber list seems unreliable with some
        // compilers, e.g. Haiku's gcc 2.95
    );
    // and the above check does not work for OSX 64 bit...
    __asm__ volatile("":::"%ebx");
    return 0;
}
EOF
cc_check && ebx_available=yes && def_ebx_available='#define HAVE_EBX_AVAILABLE 1'
echores $ebx_available

fi #if x86

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


echocheck "-lposix"
if cflag_check -lposix ; then
  extra_ldflags="$extra_ldflags -lposix"
  echores "yes"
else
  echores "no"
fi

echocheck "-lm"
if cflag_check -lm ; then
  _ld_lm="-lm"
  echores "yes"
else
  _ld_lm=""
  echores "no"
fi


echocheck "translation support"
if test "$_translation" = yes; then
  def_translation="#define CONFIG_TRANSLATION 1"
else
  def_translation="#undef CONFIG_TRANSLATION"
fi
echores "$_translation"

echocheck "language"
# Set preferred languages, "all" uses English as main language.
test -z "$language" && language=$LINGUAS
test -z "$language_doc" && language_doc=$language
test -z "$language_man" && language_man=$language
test -z "$language_msg" && language_msg=$language
test -z "$language_msg" && language_msg="all"
language_doc=$(echo $language_doc | tr , " ")
language_man=$(echo $language_man | tr , " ")
language_msg=$(echo $language_msg | tr , " ")

test "$language_doc" = "all" && language_doc=$doc_lang_all
test "$language_man" = "all" && language_man=$man_lang_all
test "$language_msg" = "all" && language_msg=$msg_lang_all

if test "$_translation" != yes ; then
  language_msg=""
fi

# Prune non-existing translations from language lists.
# Set message translation to the first available language.
# Fall back on English.
for lang in $language_doc ; do
  test -d DOCS/xml/$lang && tmp_language_doc="$tmp_language_doc $lang"
done
language_doc=$tmp_language_doc
test -z "$language_doc" && language_doc=en

for lang in $language_man ; do
  test -d DOCS/man/$lang && tmp_language_man="$tmp_language_man $lang"
done
language_man=$tmp_language_man
test -z "$language_man" && language_man=en

for lang in $language_msg ; do
  test -f po/$lang.po && tmp_language_msg="$tmp_language_msg $lang"
done
language_msg=$tmp_language_msg

echores "messages (en+): $language_msg - man pages: $language_man - documentation: $language_doc"


echocheck "restrict keyword"
for restrict_keyword in restrict __restrict __restrict__ ; do
  echo "void foo(char * $restrict_keyword p); int main(void) { return 0; }" > $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
static int foo(int a) {
    a = __builtin_expect(a, 10);
    return a == 10 ? 0 : 1;
}
int main(void) { 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"
_kstat=no
statement_check kstat.h 'kstat_open()' -lkstat && _kstat=yes
if test "$_kstat" = yes ; then
  def_kstat="#define HAVE_LIBKSTAT 1"
  extra_ldflags="$extra_ldflags -lkstat"
else
  def_kstat="#undef HAVE_LIBKSTAT"
fi
echores "$_kstat"


echocheck "posix4"
# required for nanosleep on some systems
_posix4=no
statement_check time.h 'nanosleep(0, 0)' -lposix4 && _posix4=yes
if test "$_posix4" = yes ; then
  extra_ldflags="$extra_ldflags -lposix4"
fi
echores "$_posix4"

for func in exp2 exp2f llrint log2 log2f lrint lrintf round roundf truncf; do
echocheck $func
eval _$func=no
statement_check math.h "${func}(2.0)" -D_ISOC99_SOURCE $_ld_lm && eval _$func=yes
if eval test "x\$_$func" = "xyes"; then
  eval def_$func="\"#define HAVE_$(echo $func | tr '[a-z]' '[A-Z]') 1\""
  echores yes
else
  eval def_$func="\"#define HAVE_$(echo $func | tr '[a-z]' '[A-Z]') 0\""
  echores no
fi
done


echocheck "mkstemp"
_mkstemp=no
define_statement_check "_XOPEN_SOURCE 600" "stdlib.h" 'mkstemp("")' && _mkstemp=yes
if test "$_mkstemp" = yes ; then
  def_mkstemp='#define HAVE_MKSTEMP 1'
else
  def_mkstemp='#define HAVE_MKSTEMP 0'
fi
echores "$_mkstemp"


echocheck "nanosleep"
_nanosleep=no
statement_check time.h 'nanosleep(0, 0)' && _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) { gethostbyname(0); 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
test $_socklib = yes && test $_winsock2_h = auto && _winsock2_h=no
if test $_winsock2_h = auto ; then
  _winsock2_h=no
  statement_check winsock2.h 'gethostbyname(0)' -lws2_32 && _ld_sock="-lws2_32" && _winsock2_h=yes
fi
test "$_ld_sock" && res_comment="using $_ld_sock"
echores "$_socklib"


if test $_winsock2_h = yes ; then
  _ld_sock="-lws2_32"
  def_winsock2_h='#define HAVE_WINSOCK2_H 1'
else
  def_winsock2_h='#define HAVE_WINSOCK2_H 0'
fi


echocheck "arpa/inet.h"
arpa_inet_h=no
def_arpa_inet_h='#define HAVE_ARPA_INET_H 0'
header_check arpa/inet.h && arpa_inet_h=yes &&
  def_arpa_inet_h='#define HAVE_ARPA_INET_H 1'
echores "$arpa_inet_h"


echocheck "inet_pton()"
def_inet_pton='#define HAVE_INET_PTON 0'
inet_pton=no
for _ld_tmp in "$_ld_sock" "$_ld_sock -lresolv" ; do
  statement_check arpa/inet.h 'inet_pton(0, 0, 0)' $_ld_tmp && inet_pton=yes && break
done
if test $inet_pton = yes ; then
  test "$_ld_tmp" && res_comment="using $_ld_tmp"
  def_inet_pton='#define HAVE_INET_PTON 1'
fi
echores "$inet_pton"


echocheck "inet_aton()"
def_inet_aton='#define HAVE_INET_ATON 0'
inet_aton=no
for _ld_tmp in "$_ld_sock" "$_ld_sock -lresolv" ; do
  statement_check arpa/inet.h 'inet_aton(0, 0)' $_ld_tmp && inet_aton=yes && break
done
if test $inet_aton = yes ; then
  test "$_ld_tmp" && res_comment="using $_ld_tmp"
  def_inet_aton='#define HAVE_INET_ATON 1'
fi
echores "$inet_aton"


echocheck "socklen_t"
_socklen_t=no
for header in "sys/socket.h" "ws2tcpip.h" "sys/types.h" ; do
  statement_check $header 'socklen_t v = 0' && _socklen_t=yes && break
done
if test "$_socklen_t" = yes ; then
  def_socklen_t='#define HAVE_SOCKLEN_T 1'
else
  def_socklen_t='#define HAVE_SOCKLEN_T 0'
fi
echores "$_socklen_t"


echocheck "closesocket()"
_closesocket=no
statement_check winsock2.h 'closesocket(~0)' $_ld_sock && _closesocket=yes
if test "$_closesocket" = yes ; then
  def_closesocket='#define HAVE_CLOSESOCKET 1'
else
  def_closesocket='#define HAVE_CLOSESOCKET 0'
fi
echores "$_closesocket"


echocheck "networking"
test $_winsock2_h = no && test $inet_pton = no &&
  test $inet_aton = no && networking=no
if test "$networking" = yes ; then
  def_network='#define CONFIG_NETWORK 1'
  def_networking='#define CONFIG_NETWORKING 1'
  extra_ldflags="$extra_ldflags $_ld_sock"
  inputmodules="networking $inputmodules"
else
  noinputmodules="networking $noinputmodules"
  def_network='#define CONFIG_NETWORK 0'
  def_networking='#undef CONFIG_NETWORKING'
fi
echores "$networking"


echocheck "inet6"
if test "$_inet6" = auto ; then
  cat > $TMPC << EOF
#include <sys/types.h>
#if !defined(_WIN32)
#include <sys/socket.h>
#include <netinet/in.h>
#else
#include <ws2tcpip.h>
#endif
int main(void) { struct sockaddr_in6 six; socket(AF_INET6, SOCK_STREAM, AF_INET6); return 0; }
EOF
  _inet6=no
  if cc_check $_ld_sock ; 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); return 0; }
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"


echocheck "inttypes.h (required)"
_inttypes=no
header_check inttypes.h && _inttypes=yes
echores "$_inttypes"

if test "$_inttypes" = no ; then
  echocheck "sys/bitypes.h (inttypes.h predecessor)"
  header_check sys/bitypes.h && _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. There is no chance for compilation to succeed."
  fi
fi


echocheck "mman.h"
_mman=no
statement_check sys/mman.h 'mmap(0, 0, 0, 0, 0, 0)' && _mman=yes
if test "$_mman" = yes ; then
  def_mman_h='#define HAVE_SYS_MMAN_H 1'
else
  def_mman_h='#undef HAVE_SYS_MMAN_H'
fi
echores "$_mman"

_mman_has_map_failed=no
statement_check sys/mman.h 'void *p = MAP_FAILED' && _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"
_dl=no
for _ld_tmp in "" "-ldl"; do
  statement_check dlfcn.h 'dlopen("", 0)' $_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"


def_threads='#define HAVE_THREADS 0'

echocheck "pthread"
if linux ; then
  THREAD_CFLAGS=-D_REENTRANT
elif freebsd || netbsd || openbsd ; then
  THREAD_CFLAGS=-D_THREAD_SAFE
fi
if test "$_pthreads" = auto ; then
cat > $TMPC << EOF
#include <pthread.h>
static void *func(void *arg) { return arg; }
int main(void) {
 pthread_t tid;
#ifdef PTW32_STATIC_LIB
 pthread_win32_process_attach_np();
 pthread_win32_thread_attach_np();
#endif
 return pthread_create (&tid, 0, func, 0) != 0;
}
EOF
_pthreads=no
for _ld_tmp in "-lpthreadGC2" "" "-lpthread" "-pthread" ; do
# for crosscompilation, we cannot execute the program, be happy if we can link statically
cc_check $THREAD_CFLAGS $_ld_tmp && (tmp_run || test "$_ld_static") && _ld_pthread="$_ld_tmp" && _pthreads=yes && break
done
if test "$_pthreads" = no && mingw32 ; then
_ld_tmp="-lpthreadGC2 -lws2_32"
cc_check $_ld_tmp -DPTW32_STATIC_LIB && (tmp_run || test "$_ld_static") && _ld_pthread="$_ld_tmp" && _pthreads=yes && CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
fi
fi
if test "$_pthreads" = yes ; then
  test $_ld_pthread && res_comment="using $_ld_pthread"
  def_pthreads='#define HAVE_PTHREADS 1'
  def_threads='#define HAVE_THREADS 1'
  extra_cflags="$extra_cflags $THREAD_CFLAGS"
else
  res_comment="v4l, v4l2, ao_nas, win32 loader disabled"
  def_pthreads='#undef HAVE_PTHREADS'
  _nas=no ; _tv_v4l1=no ; _tv_v4l2=no
  mingw32 || _win32dll=no
fi
echores "$_pthreads"

if cygwin ; then
  if test "$_pthreads" = yes ; then
    def_pthread_cache="#define PTHREAD_CACHE 1"
  else
    _stream_cache=no
    def_stream_cache="#undef CONFIG_STREAM_CACHE"
  fi
fi

echocheck "w32threads"
if test "$_pthreads" = yes ; then
  res_comment="using pthread instead"
  _w32threads=no
fi
if test "$_w32threads" = auto ; then
  _w32threads=no
  mingw32 && _w32threads=yes
fi
test "$_w32threads" = yes && def_threads='#define HAVE_THREADS 1'
echores "$_w32threads"

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

echocheck "iconv"
if test "$_iconv" = auto ; then
  cat > $TMPC << EOF
#include <stdio.h>
#include <unistd.h>
#include <iconv.h>
#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, &iptr, &inleft, &optr, &outleft)
          != (size_t)(-1)) {
        write(1, outbuffer, OUTBUFSIZE - outleft);
      }
    }
    if (iconv_close(icdsc) == -1)
      ;
  }
  return 0;
}
EOF
  _iconv=no
  for _ld_tmp in "" "-liconv" "-liconv $_ld_dl" ; do
    cc_check $_ld_lm $_ld_tmp && extra_ldflags="$extra_ldflags $_ld_tmp" &&
      _iconv=yes && break
  done
  if test "$_iconv" != yes ; then
    die "Unable to find iconv which should be part of standard compilation environment. Aborting. If you really mean to compile without iconv support use --disable-iconv."
  fi
fi
if test "$_iconv" = yes ; then
  def_iconv='#define CONFIG_ICONV 1'
else
  def_iconv='#undef CONFIG_ICONV'
fi
echores "$_iconv"


echocheck "soundcard.h"
_soundcard_h=no
def_soundcard_h='#undef HAVE_SOUNDCARD_H'
def_sys_soundcard_h='#undef HAVE_SYS_SOUNDCARD_H'
for _soundcard_header in "sys/soundcard.h" "soundcard.h"; do
  header_check $_soundcard_header && _soundcard_h=yes &&
    res_comment="$_soundcard_header" && break
done

if test "$_soundcard_h" = yes ; then
  if test $_soundcard_header = "sys/soundcard.h"; then
    def_sys_soundcard_h='#define HAVE_SYS_SOUNDCARD_H 1'
  else
    def_soundcard_h='#define HAVE_SOUNDCARD_H 1'
  fi
fi
echores "$_soundcard_h"


echocheck "sys/videoio.h"
sys_videoio_h=no
def_sys_videoio_h='#undef HAVE_SYS_VIDEOIO_H'
header_check sys/videoio.h && sys_videoio_h=yes &&
    def_sys_videoio_h='#define HAVE_SYS_VIDEOIO_H 1'
echores "$sys_videoio_h"


echocheck "termcap"
if test "$_termcap" = auto ; then
  _termcap=no
  for _ld_tmp in "-lncurses" "-ltinfo" "-ltermcap"; do
    statement_check term.h 'tgetent(0, 0)' $_ld_tmp &&
      extra_ldflags="$extra_ldflags $_ld_tmp" && _termcap=yes && break
  done
fi
if test "$_termcap" = yes ; then
  def_termcap='#define HAVE_TERMCAP 1'
  test $_ld_tmp && res_comment="using $_ld_tmp"
else
  def_termcap='#undef HAVE_TERMCAP'
fi
echores "$_termcap"


echocheck "termios"
def_termios='#undef HAVE_TERMIOS'
def_termios_h='#undef HAVE_TERMIOS_H'
def_termios_sys_h='#undef HAVE_SYS_TERMIOS_H'
if test "$_termios" = auto ; then
  _termios=no
  for _termios_header in "termios.h" "sys/termios.h"; do
  header_check $_termios_header && _termios=yes &&
    res_comment="using $_termios_header" && break
done
fi

if test "$_termios" = yes ; then
  def_termios='#define HAVE_TERMIOS 1'
  if test "$_termios_header" = "termios.h" ; then
    def_termios_h='#define HAVE_TERMIOS_H 1'
  else
    def_termios_sys_h='#define HAVE_SYS_TERMIOS_H 1'
  fi
fi
echores "$_termios"


echocheck "shm"
if test "$_shm" = auto ; then
  _shm=no
  statement_check sys/shm.h 'shmget(0, 0, 0); shmat(0, 0, 0); shmctl(0, 0, 0)' && _shm=yes
fi
if test "$_shm" = yes ; then
  def_shm='#define HAVE_SHM 1'
else
  def_shm='#undef HAVE_SHM'
fi
echores "$_shm"


echocheck "strsep()"
_strsep=no
statement_check string.h 'char *s = "Hello, world!"; strsep(&s, ",")' && _strsep=yes
if test "$_strsep" = yes ; then
  def_strsep='#define HAVE_STRSEP 1'
 need_strsep=no
else
  def_strsep='#undef HAVE_STRSEP'
 need_strsep=yes
fi
echores "$_strsep"


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


echocheck "swab()"
_swab=no
define_statement_check "_XOPEN_SOURCE 600" "unistd.h" 'int a, b; swab(&a, &b, 0)' ||
    statement_check "string.h" 'int a, b; swab(&a, &b, 0)' && _swab=yes
if test "$_swab" = yes ; then
  def_swab='#define HAVE_SWAB 1'
  need_swab=no
else
  def_swab='#undef HAVE_SWAB'
  need_swab=yes
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
def_posix_select='#undef HAVE_POSIX_SELECT'
cc_check && _posix_select=yes &&
    def_posix_select='#define HAVE_POSIX_SELECT 1'
echores "$_posix_select"


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 "gettimeofday()"
_gettimeofday=no
statement_check sys/time.h 'struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz)' && _gettimeofday=yes
if test "$_gettimeofday" = yes ; then
  def_gettimeofday='#define HAVE_GETTIMEOFDAY 1'
  need_gettimeofday=no
else
  def_gettimeofday='#undef HAVE_GETTIMEOFDAY'
  need_gettimeofday=yes
fi
echores "$_gettimeofday"


echocheck "glob()"
_glob=no
statement_check glob.h 'glob("filename", 0, 0, 0)' && _glob=yes
need_glob=no
if test "$_glob" = yes ; then
  def_glob='#define HAVE_GLOB 1'
else
  def_glob='#undef HAVE_GLOB'
  # HACK! need_glob currently enables compilation of a
  # win32-specific glob()-replacement.
  # Other OS neither need it nor can they use it (mf:// is disabled for them).
  win32 && need_glob=yes
fi
echores "$_glob"


echocheck "setenv()"
_setenv=no
statement_check stdlib.h 'setenv("", "", 0)' && _setenv=yes
if test "$_setenv" = yes ; then
  def_setenv='#define HAVE_SETENV 1'
  need_setenv=no
else
  def_setenv='#undef HAVE_SETENV'
  need_setenv=yes
fi
echores "$_setenv"


echocheck "setmode()"
_setmode=no
def_setmode='#define HAVE_SETMODE 0'
statement_check io.h 'setmode(0, 0)' && _setmode=yes && def_setmode='#define HAVE_SETMODE 1'
echores "$_setmode"


echocheck "sys/sysinfo.h"
_sys_sysinfo=no
statement_check sys/sysinfo.h 'struct sysinfo s_info; s_info.mem_unit=0; sysinfo(&s_info)' && _sys_sysinfo=yes
if test "$_sys_sysinfo" = yes ; then
  def_sys_sysinfo_h='#define HAVE_SYS_SYSINFO_H 1'
else
  def_sys_sysinfo_h='#undef HAVE_SYS_SYSINFO_H'
fi
echores "$_sys_sysinfo"


if darwin; then

echocheck "Mac OS X Finder Support"
def_macosx_finder='#undef CONFIG_MACOSX_FINDER'
if test "$_macosx_finder" = yes ; then
  def_macosx_finder='#define CONFIG_MACOSX_FINDER 1'
  extra_ldflags="$extra_ldflags -framework Cocoa"
fi
echores "$_macosx_finder"

echocheck "Mac OS X Bundle file locations"
def_macosx_bundle='#undef CONFIG_MACOSX_BUNDLE'
test "$_macosx_bundle" = auto && _macosx_bundle=$_macosx_finder
if test "$_macosx_bundle" = yes ; then
  def_macosx_bundle='#define CONFIG_MACOSX_BUNDLE 1'
fi
echores "$_macosx_bundle"

echocheck "Apple Remote"
if test "$_apple_remote" = auto ; then
  _apple_remote=no
  cat > $TMPC <<EOF
#include <stdio.h>
#include <IOKit/IOCFPlugIn.h>
int main(void) {
  io_iterator_t hidObjectIterator = (io_iterator_t)NULL;
  CFMutableDictionaryRef hidMatchDictionary;
  IOReturn ioReturnValue;

  // Set up a matching dictionary to search the I/O Registry by class.
  // name for all HID class devices
  hidMatchDictionary = IOServiceMatching("AppleIRController");

  // Now search I/O Registry for matching devices.
  ioReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault,
                      hidMatchDictionary, &hidObjectIterator);

  // If search is unsuccessful, return nonzero.
  if (ioReturnValue != kIOReturnSuccess ||
                       !IOIteratorIsValid(hidObjectIterator)) {
    return 1;
  }
  return 0;
}
EOF
  cc_check -framework IOKit && _apple_remote=yes
fi
if test "$_apple_remote" = yes ; then
  def_apple_remote='#define CONFIG_APPLE_REMOTE 1'
  libs_mplayer="$libs_mplayer -framework IOKit -framework Cocoa"
else
  def_apple_remote='#undef CONFIG_APPLE_REMOTE'
fi
echores "$_apple_remote"

fi #if darwin

if linux; then

echocheck "Apple IR"
if test "$_apple_ir" = auto ; then
  _apple_ir=no
  statement_check linux/input.h 'struct input_event ev; struct input_id id' && _apple_ir=yes
fi
if test "$_apple_ir" = yes ; then
  def_apple_ir='#define CONFIG_APPLE_IR 1'
else
  def_apple_ir='#undef CONFIG_APPLE_IR'
fi
echores "$_apple_ir"
fi #if linux

echocheck "pkg-config"
if $($_pkg_config --version > /dev/null 2>&1); then
  if test "$_ld_static"; then
    _pkg_config="$_pkg_config --static"
  fi
  echores "yes"
else
  _pkg_config=false
  echores "no"
fi


echocheck "Samba support (libsmbclient)"
if test "$_smb" = yes; then
  extra_ldflags="$extra_ldflags -lsmbclient"
fi
if test "$_smb" = auto; then
  _smb=no
  for _ld_tmp in "-lsmbclient" "-lsmbclient $_ld_dl" "-lsmbclient $_ld_dl -lnsl" "-lsmbclient $_ld_dl -lssl -lnsl" ; do
    statement_check libsmbclient.h 'smbc_opendir("smb://")' $_ld_tmp &&
      extra_ldflags="$extra_ldflags $_ld_tmp" && _smb=yes && break
  done
fi

if test "$_smb" = yes; then
    def_smb="#define CONFIG_LIBSMBCLIENT 1"
    inputmodules="smb $inputmodules"
else
    def_smb="#undef CONFIG_LIBSMBCLIENT"
    noinputmodules="smb $noinputmodules"
fi
echores "$_smb"

echocheck "libquvi support"
if test "$_libquvi" = auto ; then
    _libquvi=no
    if pkg_config_add libquvi ; then
        _libquvi=yes
    fi
fi
if test "$_libquvi" = yes; then
    def_libquvi="#define CONFIG_LIBQUVI 1"
else
    def_libquvi="#undef CONFIG_LIBQUVI"
fi
echores "$_libquvi"

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


echocheck "tga"
if test "$_tga" = yes ; then
  def_tga='#define CONFIG_TGA 1'
  vomodules="tga $vomodules"
else
  def_tga='#undef CONFIG_TGA'
  novomodules="tga $novomodules"
fi
echores "$_tga"


echocheck "md5sum support"
if test "$_md5sum" = yes; then
  def_md5sum="#define CONFIG_MD5SUM 1"
  vomodules="md5sum $vomodules"
else
  def_md5sum="#undef CONFIG_MD5SUM"
  novomodules="md5sum $novomodules"
fi
echores "$_md5sum"


echocheck "yuv4mpeg support"
if test "$_yuv4mpeg" = yes; then
  def_yuv4mpeg="#define CONFIG_YUV4MPEG 1"
  vomodules="yuv4mpeg $vomodules"
else
  def_yuv4mpeg="#undef CONFIG_YUV4MPEG"
  novomodules="yuv4mpeg $novomodules"
fi
echores "$_yuv4mpeg"


echocheck "DirectFB"
if test "$_directfb" = auto ; then
  _directfb=no
  cat > $TMPC << EOF
#include <directfb.h>
#include <directfb_version.h>
#if (DIRECTFB_MAJOR_VERSION << 16 | DIRECTFB_MINOR_VERSION << 8 | DIRECTFB_MICRO_VERSION) < (0 << 16 | 9 << 8 | 22)
#error "DirectFB version too old."
#endif
int main(void) { DirectFBInit(0, 0); return 0; }
EOF
  for _inc_tmp in "" -I/usr/local/include/directfb -I/usr/include/directfb -I/usr/local/include; do
    cc_check $_inc_tmp -ldirectfb &&
      _directfb=yes && extra_cflags="$extra_cflags $_inc_tmp" && break
  done
fi
if test "$_directfb" = yes ; then
  def_directfb='#define CONFIG_DIRECTFB 1'
  vomodules="directfb $vomodules"
  libs_mplayer="$libs_mplayer -ldirectfb"
else
  def_directfb='#undef CONFIG_DIRECTFB'
  novomodules="directfb $novomodules"
fi
echores "$_directfb"


if darwin; then

echocheck "QuickTime"
if test "$quicktime" = auto ; then
  quicktime=no
  statement_check QuickTime/QuickTime.h 'ImageDescription *desc; EnterMovies(); ExitMovies()' -framework QuickTime && quicktime=yes
fi
if test "$quicktime" = yes ; then
  extra_ldflags="$extra_ldflags -framework QuickTime"
  def_quicktime='#define CONFIG_QUICKTIME 1'
else
  def_quicktime='#undef CONFIG_QUICKTIME'
fi
echores $quicktime

echocheck "Cocoa"
if test "$_cocoa" = auto ; then
  cat > $TMPC <<EOF
#include <CoreServices/CoreServices.h>
#include <OpenGL/OpenGL.h>
int main(void) {
  NSApplicationLoad();
}
EOF
  _cocoa=no
  cc_check -framework Cocoa -framework OpenGL && _cocoa=yes
fi
if test "$_cocoa" = yes ; then
  libs_mplayer="$libs_mplayer -framework Cocoa -framework OpenGL"
  def_cocoa='#define CONFIG_COCOA 1'
else
  def_cocoa='#undef CONFIG_COCOA'
fi
echores "$_cocoa"

echocheck "CoreVideo"
if test "$_cocoa" = yes && test "$_corevideo" = auto ; then
  cat > $TMPC <<EOF
#include <QuartzCore/CoreVideo.h>
int main(void) { return 0; }
EOF
  _corevideo=no
  cc_check -framework Cocoa -framework QuartzCore -framework OpenGL && _corevideo=yes
fi
if test "$_corevideo" = yes ; then
  vomodules="corevideo $vomodules"
  libs_mplayer="$libs_mplayer -framework QuartzCore"
  def_corevideo='#define CONFIG_COREVIDEO 1'
else
  novomodules="corevideo $novomodules"
  def_corevideo='#undef CONFIG_COREVIDEO'
fi
echores "$_corevideo"

echocheck "SharedBuffer"
if test "$_sharedbuffer" = auto ; then
  cat > $TMPC <<EOF
int main(void) {
  NSApplicationLoad();
}
EOF
  _sharedbuffer=no
  cc_check -framework Cocoa && _sharedbuffer=yes
fi
if test "$_sharedbuffer" = yes ; then
  vomodules="sharedbuffer $vomodules"
  libs_mplayer="$libs_mplayer -framework Cocoa"
  def_sharedbuffer='#define CONFIG_SHAREDBUFFER 1'
else
  novomodules="sharedbuffer $novomodules"
  def_sharedbuffer='#undef CONFIG_SHAREDBUFFER'
fi
echores "$_sharedbuffer"

depends_on_application_services(){
  test "$_corevideo" = yes
}

fi #if darwin


echocheck "X11 headers presence"
  _x11_headers="no"
  res_comment="check if the dev(el) packages are installed"
  for I in $(echo $extra_cflags | sed s/-I//g) /usr/include ; do
    if test -f "$I/X11/Xlib.h" ; then
      _x11_headers="yes"
      res_comment=""
      break
    fi
  done
  if test $_cross_compile = no; then
    for I in /usr/X11/include /usr/X11R7/include /usr/local/include /usr/X11R6/include \
             /usr/include/X11R6 /usr/openwin/include ; do
      if test -f "$I/X11/Xlib.h" ; then
        extra_cflags="$extra_cflags -I$I"
        _x11_headers="yes"
        res_comment="using $I"
        break
      fi
    done
  fi
echores "$_x11_headers"


echocheck "X11"
if test "$_x11" = auto && test "$_x11_headers" = yes ; then
  for I in "" -L/usr/X11R7/lib -L/usr/local/lib -L/usr/X11R6/lib -L/usr/lib/X11R6 \
           -L/usr/X11/lib -L/usr/lib32 -L/usr/openwin/lib -L/usr/local/lib64 -L/usr/X11R6/lib64 \
           -L/usr/lib ; do
    if netbsd; then
      _ld_tmp="$I -lXext -lX11 $_ld_pthread -Wl,-R$(echo $I | sed s/^-L//)"
    else
      _ld_tmp="$I -lXext -lX11 $_ld_pthread"
    fi
    statement_check X11/Xutil.h 'XCreateWindow(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)' $_ld_tmp &&
      _x11=yes
    # Check that there aren't conflicting headers between ApplicationServices
    # and X11. On versions of Mac OSX prior to 10.7 the deprecated QuickDraw API
    # is included by -framework ApplicationServices and clashes with the X11
    # definition of the "Cursor" type.
    if darwin && depends_on_application_services && test "$_x11" = yes ; then
      _x11=no
      header_check_broken ApplicationServices/ApplicationServices.h \
        X11/Xutil.h $_ld_tmp && _x11=yes
    fi
    if test "$_x11" = yes ; then
      libs_mplayer="$libs_mplayer $_ld_tmp"
      break
    fi
  done
fi
if test "$_x11" = yes ; then
  def_x11='#define CONFIG_X11 1'
  vomodules="x11 xover $vomodules"
else
  _x11=no
  def_x11='#undef CONFIG_X11'
  novomodules="x11 $novomodules"
  res_comment="check if the dev(el) packages are installed"
fi
echores "$_x11"

echocheck "Xss screensaver extensions"
if test "$_xss" = auto ; then
  _xss=no
  statement_check "X11/extensions/scrnsaver.h" 'XScreenSaverSuspend(NULL, True)' -lXss && _xss=yes
fi
if test "$_xss" = yes ; then
  def_xss='#define CONFIG_XSS 1'
  libs_mplayer="$libs_mplayer -lXss"
else
  def_xss='#undef CONFIG_XSS'
fi
echores "$_xss"

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) { DPMSQueryExtension(0, 0, 0); return 0; }
EOF
  cc_check -lXdpms && _xdpms3=yes
  statement_check_broken X11/Xlib.h X11/extensions/dpms.h 'DPMSQueryExtension(0, 0, 0)' -lXext && _xdpms4=yes
fi
if test "$_xdpms4" = yes ; then
  def_xdpms='#define CONFIG_XDPMS 1'
  res_comment="using Xdpms 4"
  echores "yes"
elif test "$_xdpms3" = yes ; then
  def_xdpms='#define CONFIG_XDPMS 1'
  libs_mplayer="$libs_mplayer -lXdpms"
  res_comment="using Xdpms 3"
  echores "yes"
else
  def_xdpms='#undef CONFIG_XDPMS'
  echores "no"
fi


echocheck "Xv"
if test "$_xv" = auto && test "$_x11" = yes ; then
  _xv=no
  statement_check_broken X11/Xlib.h X11/extensions/Xvlib.h 'XvGetPortAttribute(0, 0, 0, 0)' -lXv && _xv=yes
fi

if test "$_xv" = yes ; then
  def_xv='#define CONFIG_XV 1'
  libs_mplayer="$libs_mplayer -lXv"
  vomodules="xv $vomodules"
else
  def_xv='#undef CONFIG_XV'
  novomodules="xv $novomodules"
fi
echores "$_xv"


echocheck "VDPAU"
if test "$_vdpau" = auto && test "$_x11" = yes ; then
  _vdpau=no
  if test "$_dl" = yes ; then
    pkg_config_add 'vdpau >= 0.2' && _vdpau=yes
  fi
fi
if test "$_vdpau" = yes ; then
  def_vdpau='#define CONFIG_VDPAU 1'
  vomodules="vdpau $vomodules"
else
  def_vdpau='#define CONFIG_VDPAU 0'
  novomodules="vdpau $novomodules"
fi
echores "$_vdpau"


echocheck "Xinerama"
if test "$_xinerama" = auto && test "$_x11" = yes ; then
  _xinerama=no
  statement_check X11/extensions/Xinerama.h 'XineramaIsActive(0)' -lXinerama && _xinerama=yes
fi

if test "$_xinerama" = yes ; then
  def_xinerama='#define CONFIG_XINERAMA 1'
  libs_mplayer="$libs_mplayer -lXinerama"
else
  def_xinerama='#undef CONFIG_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 && test "$_x11" = yes ; then
  _vm=no
  statement_check_broken X11/Xlib.h X11/extensions/xf86vmode.h 'XF86VidModeQueryExtension(0, 0, 0)' -lXxf86vm && _vm=yes
fi
if test "$_vm" = yes ; then
  def_vm='#define CONFIG_XF86VM 1'
  libs_mplayer="$libs_mplayer -lXxf86vm"
else
  def_vm='#undef CONFIG_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 && test "$_x11" = yes ; then
  _xf86keysym=no
  return_check X11/XF86keysym.h XF86XK_AudioPause && _xf86keysym=yes
fi
if test "$_xf86keysym" = yes ; then
  def_xf86keysym='#define CONFIG_XF86XK 1'
else
  def_xf86keysym='#undef CONFIG_XF86XK'
fi
echores "$_xf86keysym"


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) { caca_init(); return 0; }
EOF
  cc_check $(caca-config --libs) && _caca=yes
  fi
fi
if test "$_caca" = yes ; then
  def_caca='#define CONFIG_CACA 1'
  extra_cflags="$extra_cflags $(caca-config --cflags)"
  libs_mplayer="$libs_mplayer $(caca-config --libs)"
  vomodules="caca $vomodules"
else
  def_caca='#undef CONFIG_CACA'
  novomodules="caca $novomodules"
fi
echores "$_caca"


echocheck "DVB"
if test "$_dvb" = auto ; then
  _dvb=no
cat >$TMPC << EOF
#include <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 && _dvb=yes &&
      extra_cflags="$extra_cflags $_inc_tmp" && break
  done
fi
echores "$_dvb"
if test "$_dvb" = yes ; then
  _dvbin=yes
  inputmodules="dvb $inputmodules"
  def_dvb='#define CONFIG_DVB 1'
  def_dvbin='#define CONFIG_DVBIN 1'
else
  _dvbin=no
  noinputmodules="dvb $noinputmodules"
  def_dvb='#undef CONFIG_DVB'
  def_dvbin='#undef CONFIG_DVBIN '
fi


echocheck "PNG support"
if test "$_png" = auto ; then
  _png=no
cat > $TMPC << EOF
#include <stdio.h>
#include <string.h>
#include <png.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
  cc_check -lpng -lz $_ld_lm && _png=yes
fi
echores "$_png"
if test "$_png" = yes ; then
  def_png='#define CONFIG_PNG 1'
  extra_ldflags="$extra_ldflags -lpng -lz"
else
  def_png='#undef CONFIG_PNG'
fi

echocheck "MNG support"
if test "$_mng" = auto ; then
  _mng=no
  return_statement_check libmng.h 'const char * p_ver = mng_version_text()' '!p_ver || p_ver[0] == 0' -lmng -lz $_ld_lm && _mng=yes
fi
echores "$_mng"
if test "$_mng" = yes ; then
  def_mng='#define CONFIG_MNG 1'
  extra_ldflags="$extra_ldflags -lmng -lz"
else
  def_mng='#undef CONFIG_MNG'
fi

echocheck "JPEG support"
if test "$_jpeg" = auto ; then
  _jpeg=no
  header_check_broken stdio.h jpeglib.h -ljpeg $_ld_lm && _jpeg=yes
fi
echores "$_jpeg"

if test "$_jpeg" = yes ; then
  def_jpeg='#define CONFIG_JPEG 1'
  vomodules="jpeg $vomodules"
  extra_ldflags="$extra_ldflags -ljpeg"
else
  def_jpeg='#undef CONFIG_JPEG'
  novomodules="jpeg $novomodules"
fi



echocheck "PNM support"
if test "$_pnm" = yes; then
  def_pnm="#define CONFIG_PNM 1"
  vomodules="pnm $vomodules"
else
  def_pnm="#undef CONFIG_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
  for _ld_gif in "-lungif" "-lgif" ; do
    statement_check gif_lib.h 'QuantizeBuffer(0, 0, 0, 0, 0, 0, 0, 0)' $_ld_gif && _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 CONFIG_GIF 1'
  codecmodules="gif $codecmodules"
  vomodules="gif89a $vomodules"
  res_comment="old version, some encoding functions disabled"
  def_gif_4='#undef CONFIG_GIF_4'
  extra_ldflags="$extra_ldflags $_ld_gif"

  cat > $TMPC << EOF
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <gif_lib.h>
static void catch(int sig) { 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" ; then
    def_gif_4='#define CONFIG_GIF_4 1'
    res_comment=""
  fi
else
  def_gif='#undef CONFIG_GIF'
  def_gif_4='#undef CONFIG_GIF_4'
  novomodules="gif89a $novomodules"
  nocodecmodules="gif $nocodecmodules"
fi
echores "$_gif"


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

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


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


# make sure this stays below CoreVideo to avoid issues due to namespace
# conflicts between -lGL and -framework OpenGL
echocheck "OpenGL"
#Note: this test is run even with --enable-gl since we autodetect linker flags
if (test "$_x11" = yes || test "$_cocoa" = yes || win32) && test "$_gl" != no ; then
  cat > $TMPC << EOF
#ifdef GL_WIN32
#include <windows.h>
#include <GL/gl.h>
#else
#include <GL/gl.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
#endif
int main(int argc, char *argv[]) {
#ifdef GL_WIN32
  HDC dc;
  wglCreateContext(dc);
#else
  glXCreateContext(NULL, NULL, NULL, True);
#endif
  glFinish();
  return 0;
}
EOF
  _gl=no
  if test "$_x11" = yes ; then
    for _ld_tmp in "" -lGL "-lGL -lXdamage" "-lGL $_ld_pthread" ; do
      if cc_check $_ld_tmp $_ld_lm ; then
        _gl=yes
        _gl_x11=yes
        libs_mplayer="$libs_mplayer $_ld_tmp $_ld_dl"
        break
      fi
    done
  fi
  if win32 && cc_check -DGL_WIN32 -lopengl32 ; then
    _gl=yes
    _gl_win32=yes
    libs_mplayer="$libs_mplayer -lopengl32 -lgdi32"
  fi
  if test "$_cocoa" = yes ; then
    _gl=yes
    _gl_cocoa=yes
  fi
else
  _gl=no
fi
if test "$_gl" = yes ; then
  def_gl='#define CONFIG_GL 1'
  res_comment="backends:"
  if test "$_gl_cocoa" = yes ; then
    def_gl_cocoa='#define CONFIG_GL_COCOA 1'
    res_comment="$res_comment cocoa"
  fi
  if test "$_gl_win32" = yes ; then
    def_gl_win32='#define CONFIG_GL_WIN32 1'
    res_comment="$res_comment win32"
  fi
  if test "$_gl_x11" = yes ; then
    def_gl_x11='#define CONFIG_GL_X11 1'
    res_comment="$res_comment x11"
  fi
  vomodules="opengl $vomodules"
else
  def_gl='#undef CONFIG_GL'
  def_gl_cocoa='#undef CONFIG_GL_COCOA'
  def_gl_win32='#undef CONFIG_GL_WIN32'
  def_gl_x11='#undef CONFIG_GL_X11'
  novomodules="opengl $novomodules"
fi
echores "$_gl"


if win32; then

echocheck "Direct3D"
if test "$_direct3d" = auto ; then
  _direct3d=no
  header_check d3d9.h && _direct3d=yes
fi
if test "$_direct3d" = yes ; then
  def_direct3d='#define CONFIG_DIRECT3D 1'
  vomodules="direct3d $vomodules"
else
  def_direct3d='#undef CONFIG_DIRECT3D'
  novomodules="direct3d $novomodules"
fi
echores "$_direct3d"

echocheck "Directx"
if test "$_directx" = auto ; then
  cat > $TMPC << EOF
#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 CONFIG_DIRECTX 1'
  libs_mplayer="$libs_mplayer -lgdi32"
  vomodules="directx $vomodules"
  aomodules="dsound $aomodules"
else
  def_directx='#undef CONFIG_DIRECTX'
  novomodules="directx $novomodules"
  noaomodules="dsound $noaomodules"
fi
echores "$_directx"

fi #if win32; then


echocheck "V4L2 MPEG Decoder"
if test "$_v4l2" = auto ; then
  cat > $TMPC << EOF
#include <sys/time.h>
#include <linux/videodev2.h>
#include <linux/version.h>
int main(void) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
#error kernel headers too old, need 2.6.22
#endif
  struct v4l2_ext_controls ctrls;
  ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
  return 0;
}
EOF
  _v4l2=no
  cc_check && _v4l2=yes
fi
if test "$_v4l2" = yes ; then
  def_v4l2='#define CONFIG_V4L2_DECODER 1'
  vomodules="v4l2 $vomodules"
  aomodules="v4l2 $aomodules"
else
  def_v4l2='#undef CONFIG_V4L2_DECODER'
  novomodules="v4l2 $novomodules"
  noaomodules="v4l2 $noaomodules"
fi
echores "$_v4l2"



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


echocheck "OSS Audio"
if test "$_ossaudio" = auto ; then
  _ossaudio=no
  return_check $_soundcard_header SNDCTL_DSP_SETFRAGMENT && _ossaudio=yes
fi
if test "$_ossaudio" = yes ; then
  def_ossaudio='#define CONFIG_OSS_AUDIO 1'
  aomodules="oss $aomodules"
  cat > $TMPC << EOF
#include <$_soundcard_header>
#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"'
     # Check for OSS4 headers (override default headers)
     # Does not apply to systems where OSS4 is native (e.g. FreeBSD)
     if test -f /etc/oss.conf; then
       . /etc/oss.conf
       _ossinc="$OSSLIBDIR/include"
       if test -f "$_ossinc/sys/soundcard.h"; then
         extra_cflags="-I$_ossinc $extra_cflags"
       fi
     fi
   elif netbsd || openbsd ; then
     def_ossaudio_devdsp='#define PATH_DEV_DSP "/dev/sound"'
     extra_ldflags="$extra_ldflags -lossaudio"
   else
     def_ossaudio_devdsp='#define PATH_DEV_DSP "/dev/dsp"'
   fi
  def_ossaudio_devmixer='#define PATH_DEV_MIXER "/dev/mixer"'
else
  def_ossaudio='#undef CONFIG_OSS_AUDIO'
  def_ossaudio_devdsp='#define PATH_DEV_DSP ""'
  def_ossaudio_devmixer='#define PATH_DEV_MIXER ""'
  noaomodules="oss $noaomodules"
fi
echores "$_ossaudio"


echocheck "RSound"
if test "$_rsound" = auto ; then
   _rsound=no
   statement_check rsound.h 'rsd_init(NULL);' -lrsound && _rsound=yes
fi
echores "$_rsound"

if test "$_rsound" = yes ; then
   def_rsound='#define CONFIG_RSOUND 1'
   aomodules="rsound $aomodules"
   libs_mplayer="$libs_mplayer -lrsound"
else
   def_rsound='#undef CONFIG_RSOUND'
   noaomodules="rsound $noaomodules"
fi


echocheck "pulse"
if test "$_pulse" = auto ; then
  _pulse=no
  if pkg_config_add 'libpulse >= 0.9' ; then
      _pulse=yes
  fi
fi
echores "$_pulse"

if test "$_pulse" = yes ; then
  def_pulse='#define CONFIG_PULSE 1'
  aomodules="pulse $aomodules"
else
  def_pulse='#undef CONFIG_PULSE'
  noaomodules="pulse $noaomodules"
fi


echocheck "PortAudio"
if test "$_portaudio" = auto && test "$_pthreads" != yes ; then
    _portaudio=no
    res_comment="pthreads not enabled"
fi
if test "$_portaudio" = auto ; then
  _portaudio=no
  if pkg_config_add 'portaudio-2.0 >= 19' ; then
      _portaudio=yes
  fi
fi
echores "$_portaudio"

if test "$_portaudio" = yes ; then
  def_portaudio='#define CONFIG_PORTAUDIO 1'
  aomodules="portaudio $aomodules"
else
  def_portaudio='#undef CONFIG_PORTAUDIO'
  noaomodules="portaudio $noaomodules"
fi


echocheck "JACK"
if test "$_jack" = auto ; then
  _jack=no
  if pkg_config_add jack ; then
      _jack=yes
  fi
fi

if test "$_jack" = yes ; then
  def_jack='#define CONFIG_JACK 1'
  aomodules="jack $aomodules"
else
  noaomodules="jack $noaomodules"
fi
echores "$_jack"

echocheck "OpenAL"
if test "$_openal" = auto ; then
  _openal=no
cat > $TMPC << EOF
#ifdef OPENAL_AL_H
#include <OpenAL/al.h>
#else
#include <AL/al.h>
#endif
int main(void) {
  alSourceQueueBuffers(0, 0, 0);
//  alGetSourcei(0, AL_SAMPLE_OFFSET, 0);
  return 0;
}
EOF
  for I in "-lopenal" "-lopenal32" "-framework OpenAL" ; do
    cc_check $I && _openal=yes && break
    cc_check -DOPENAL_AL_H=1 $I && def_openal_h='#define OPENAL_AL_H 1' && _openal=yes && break
  done
  test "$_openal" = yes && libs_mplayer="$libs_mplayer $I"
fi
if test "$_openal" = yes ; then
  def_openal='#define CONFIG_OPENAL 1'
  aomodules="openal $aomodules"
else
  noaomodules="openal $noaomodules"
fi
echores "$_openal"

echocheck "ALSA audio"
if test "$_alsa" = auto ; then
    _alsa=no
    if pkg_config_add "alsa >= 1.0.9" ; then
        _alsa=yes
    fi
fi
def_alsa='#undef CONFIG_ALSA'
if test "$_alsa" = yes ; then
    aomodules="alsa $aomodules"
    def_alsa='#define CONFIG_ALSA 1'
else
    noaomodules="alsa $noaomodules"
fi
echores "$_alsa"


if darwin; then
echocheck "CoreAudio"
if test "$_coreaudio" = auto ; then
  cat > $TMPC <<EOF
#include <CoreAudio/CoreAudio.h>
#include <AudioToolbox/AudioToolbox.h>
#include <AudioUnit/AudioUnit.h>
int main(void) { return 0; }
EOF
  _coreaudio=no
  cc_check -framework CoreAudio -framework AudioUnit -framework AudioToolbox && _coreaudio=yes
fi
if test "$_coreaudio" = yes ; then
  libs_mplayer="$libs_mplayer -framework CoreAudio -framework AudioUnit -framework AudioToolbox"
  def_coreaudio='#define CONFIG_COREAUDIO 1'
  aomodules="coreaudio $aomodules"
else
  def_coreaudio='#undef CONFIG_COREAUDIO'
  noaomodules="coreaudio $noaomodules"
fi
echores $_coreaudio
fi #if darwin


# set default CD/DVD devices
if win32 ; then
  default_cdrom_device="D:"
elif darwin ; then
  default_cdrom_device="/dev/disk1"
elif dragonfly ; then
  default_cdrom_device="/dev/cd0"
elif freebsd ; then
  default_cdrom_device="/dev/acd0"
elif openbsd ; then
  default_cdrom_device="/dev/rcd0c"
else
  default_cdrom_device="/dev/cdrom"
fi

if win32 || dragonfly || freebsd || openbsd ; then
  default_dvd_device=$default_cdrom_device
elif darwin ; then
  default_dvd_device="/dev/rdiskN"
else
  default_dvd_device="/dev/dvd"
fi


echocheck "VCD support"
if test "$_vcd" = auto; then
  _vcd=no
  if linux || freebsd || netbsd || openbsd || dragonfly || darwin ; then
    _vcd=yes
  elif mingw32; then
  header_check ddk/ntddcdrm.h && _vcd=yes
  fi
fi
if test "$_vcd" = yes; then
  inputmodules="vcd $inputmodules"
  def_vcd='#define CONFIG_VCD 1'
else
  def_vcd='#undef CONFIG_VCD'
  noinputmodules="vcd $noinputmodules"
  res_comment="not supported on this OS"
fi
echores "$_vcd"



echocheck "Blu-ray support"
if test "$_bluray" = auto ; then
  _bluray=no
  pkg_config_add 'libbluray >= 0.2.1' && _bluray=yes
fi
if test "$_bluray" = yes ; then
  def_bluray='#define CONFIG_LIBBLURAY 1'
  inputmodules="bluray $inputmodules"
else
  def_bluray='#undef CONFIG_LIBBLURAY'
  noinputmodules="bluray $noinputmodules"
fi
echores "$_bluray"

echocheck "dvdread"
if test "$_dvdread_internal" = auto && test ! -f "libdvdread4/dvd_reader.c" ; then
  _dvdread_internal=no
fi
if test "$_dvdread_internal" = auto ; then
  _dvdread_internal=no
  _dvdread=no
  if (linux || freebsd || netbsd || openbsd || dragonfly) &&
     (test "$_dvd" = yes || test "$_cdrom" = yes || test "$_cdio" = yes ||
      test "$_dvdio" = yes || test "$_bsdi_dvd" = yes) ||
     darwin || win32; then
    _dvdread_internal=yes
    _dvdread=yes
    extra_cflags="-Ilibdvdread4 $extra_cflags"
  fi
elif test "$_dvdread" = auto ; then
  _dvdread=no
  if test "$_dl" = yes; then
    _dvdreadcflags=$($_dvdreadconfig --cflags 2> /dev/null)
    _dvdreadlibs=$($_dvdreadconfig --libs 2> /dev/null)
    if header_check dvdread/dvd_reader.h $_dvdreadcflags $_dvdreadlibs $_ld_dl ; then
      _dvdread=yes
      extra_cflags="$extra_cflags $_dvdreadcflags"
      extra_ldflags="$extra_ldflags $_dvdreadlibs"
      res_comment="external"
    fi
  fi
fi

if test "$_dvdread_internal" = yes; then
  def_dvdread='#define CONFIG_DVDREAD 1'
  inputmodules="dvdread(internal) $inputmodules"
  res_comment="internal"
elif test "$_dvdread" = yes; then
  def_dvdread='#define CONFIG_DVDREAD 1'
  extra_ldflags="$extra_ldflags -ldvdread"
  inputmodules="dvdread(external) $inputmodules"
  res_comment="external"
else
  def_dvdread='#undef CONFIG_DVDREAD'
  noinputmodules="dvdread $noinputmodules"
fi
echores "$_dvdread"


echocheck "internal libdvdcss"
if test "$_libdvdcss_internal" = auto ; then
  _libdvdcss_internal=no
  test "$_dvdread_internal" = yes && test -d libdvdcss && _libdvdcss_internal=yes
fi
if test "$_libdvdcss_internal" = yes ; then
  if linux || netbsd || openbsd ; then
    def_dvd_linux='#define HAVE_LINUX_DVD_STRUCT 1'
    openbsd && def_dvd_openbsd='#define HAVE_OPENBSD_DVD_STRUCT 1'
  elif freebsd || dragonfly ; then
    def_dvd_bsd='#define HAVE_BSD_DVD_STRUCT 1'
  elif darwin ; then
    def_dvd_darwin='#define DARWIN_DVD_IOCTL'
    extra_ldflags="$extra_ldflags -framework IOKit -framework Carbon"
  elif cygwin ; then
    cflags_libdvdcss="-DSYS_CYGWIN -DWIN32"
  fi
  cflags_libdvdcss_dvdread="-Ilibdvdcss"
  def_dvdcss="#define HAVE_DVDCSS_DVDCSS_H 1"
  inputmodules="libdvdcss(internal) $inputmodules"
else
  noinputmodules="libdvdcss(internal) $noinputmodules"
fi
echores "$_libdvdcss_internal"


echocheck "libcdio"
if test "$_libcdio" = auto ; then
    _libcdio=no
    if pkg_config_add libcdio_paranoia ; then
        _libcdio=yes
    fi
fi
if test "$_libcdio" = yes ; then
    _cdda='yes'
    def_cdda='#define CONFIG_CDDA 1'
    test $_cddb = auto && test $networking = yes && _cddb=yes
    inputmodules="cdda $inputmodules"
else
    _libcdio=no
    _cdda='no'
    def_cdda='#undef CONFIG_CDDA'
    noinputmodules="cdda $noinputmodules"
fi
echores "$_libcdio"

if test "$_cddb" = yes ; then
    def_cddb='#define CONFIG_CDDB 1'
    inputmodules="cddb $inputmodules"
else
    _cddb=no
    def_cddb='#undef CONFIG_CDDB'
    noinputmodules="cddb $noinputmodules"
fi


echocheck "SSA/ASS support"
if test "$_ass" = auto ; then
    if pkg_config_add libass ; then
        _ass=yes
        def_ass='#define CONFIG_ASS 1'
    else
        die "Unable to find development files for libass. Aborting. If you really mean to compile without libass support use --disable-libass."
    fi
else
    def_ass='#undef CONFIG_ASS'
fi
echores "$_ass"


echocheck "libass OSD support"
_dummy_osd=yes
if test "$_libass_osd" = auto ; then
    _libass_osd=no
    if test "$_ass" = yes ; then
        _libass_osd=yes
        _dummy_osd=no
    fi
fi
echores "$_libass_osd"


echocheck "ENCA"
if test "$_enca" = auto ; then
    _enca=no
    statement_check enca.h 'enca_get_languages(NULL)' -lenca $_ld_lm && _enca=yes
fi
    if test "$_enca" = yes ; then
        def_enca='#define CONFIG_ENCA 1'
        extra_ldflags="$extra_ldflags -lenca"
    else
        def_enca='#undef CONFIG_ENCA'
    fi
echores "$_enca"


echocheck "zlib"
_zlib=no
statement_check zlib.h 'inflate(0, Z_NO_FLUSH)' -lz && _zlib=yes
if test "$_zlib" = yes ; then
  def_zlib='#define CONFIG_ZLIB 1'
  extra_ldflags="$extra_ldflags -lz"
else
  def_zlib='#define CONFIG_ZLIB 0'
fi
echores "$_zlib"


echocheck "mad support"
if test "$_mad" = auto ; then
  _mad=no
  header_check mad.h -lmad && _mad=yes
fi
if test "$_mad" = yes ; then
  def_mad='#define CONFIG_LIBMAD 1'
  extra_ldflags="$extra_ldflags -lmad"
  codecmodules="libmad $codecmodules"
else
  def_mad='#undef CONFIG_LIBMAD'
  nocodecmodules="libmad $nocodecmodules"
fi
echores "$_mad"


# Any version of libmpg123 that knows MPG123_RESYNC_LIMIT shall be fine.
# That is, 1.2.0 onwards. Recommened is 1.14 onwards, though.
echocheck "mpg123 support"
def_mpg123='#undef CONFIG_MPG123'
if test "$_mpg123" = auto; then
  _mpg123=no
  pkg_config_add 'libmpg123 >= 1.2.0' && _mpg123=yes
fi
if test "$_mpg123" = yes ; then
  def_mpg123='#define CONFIG_MPG123 1'
  codecmodules="mpg123 $codecmodules"
else
  nocodecmodules="mpg123 $nocodecmodules"
fi
echores "$_mpg123"

echocheck "liba52 support"
def_liba52='#undef CONFIG_LIBA52'
if test "$_liba52" = auto ; then
  _liba52=no
  cat > $TMPC << EOF
#include <inttypes.h>
#include <a52dec/a52.h>
int main(void) { a52_state_t *testHand; testHand=a52_init(0); return 0; }
EOF
  cc_check -la52 && _liba52=yes && extra_ldflags="$extra_ldflags -la52"
fi
if test "$_liba52" = yes ; then
  def_liba52='#define CONFIG_LIBA52 1'
  codecmodules="liba52 $codecmodules"
else
  nocodecmodules="liba52 $nocodecmodules"
fi
echores "$_liba52"

echocheck "libdca support"
if test "$_libdca" = auto ; then
  _libdca=no
  for _ld_dca in -ldca -ldts ; do
    statement_check_broken stdint.h dts.h 'dts_init(0)' $_ld_dca $_ld_lm &&
      extra_ldflags="$extra_ldflags $_ld_dca" && _libdca=yes && break
  done
fi
if test "$_libdca" = yes ; then
  def_libdca='#define CONFIG_LIBDCA 1'
  codecmodules="libdca $codecmodules"
else
  def_libdca='#undef CONFIG_LIBDCA'
  nocodecmodules="libdca $nocodecmodules"
fi
echores "$_libdca"


echocheck "FAAD2 support"
if test "$_faad" = auto ; then
  _faad=no
  cat > $TMPC << EOF
#include <neaacdec.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 -lfaad $_ld_lm && _faad=yes
fi

def_faad='#undef CONFIG_FAAD'
if test "$_faad" = yes ; then
  def_faad='#define CONFIG_FAAD 1'
  extra_ldflags="$extra_ldflags -lfaad"
  codecmodules="faad2 $codecmodules"
else
  nocodecmodules="faad2 $nocodecmodules"
fi
echores "$_faad"


echocheck "LADSPA plugin support"
if test "$_ladspa" = auto ; then
  _ladspa=no
  statement_check ladspa.h 'LADSPA_Descriptor ld = {0}' && _ladspa=yes
fi
if test "$_ladspa" = yes; then
  def_ladspa="#define CONFIG_LADSPA 1"
else
  def_ladspa="#undef CONFIG_LADSPA"
fi
echores "$_ladspa"


echocheck "libbs2b audio filter support"
if test "$_libbs2b" = auto ; then
    _libbs2b=no
    if pkg_config_add libbs2b ; then
        _libbs2b=yes
    fi
fi
def_libbs2b="#undef CONFIG_LIBBS2B"
test "$_libbs2b" = yes && def_libbs2b="#define CONFIG_LIBBS2B 1"
echores "$_libbs2b"


if test -z "$_codecsdir" ; then
  for dir in "$_libdir/codecs" "$_libdir/win32" /usr/local/lib/codecs \
             /usr/lib/codecs /usr/local/lib/win32 /usr/lib/win32 ; do
    if test -d "$dir" ; then
      _codecsdir="$dir"
      break;
    fi;
  done
fi
# Fall back on default directory.
if test -z "$_codecsdir" ; then
  _codecsdir="$_libdir/codecs"
  mingw32 && _codecsdir="codecs"
fi


echocheck "Win32 codecs"
if test "$_win32dll" = auto ; then
  _win32dll=no
  if x86_32 ; then
    _win32dll=yes
  fi
fi
if test "$_win32dll" = yes ; then
  def_win32dll='#define CONFIG_WIN32DLL 1'
  if ! win32 ; then
    def_win32_loader='#define WIN32_LOADER 1'
    _win32_emulation=yes
  else
    extra_ldflags="$extra_ldflags -ladvapi32 -lole32"
    res_comment="using native windows"
  fi
  codecmodules="win32 $codecmodules"
else
  def_win32dll='#undef CONFIG_WIN32DLL'
  def_win32_loader='#undef WIN32_LOADER'
  nocodecmodules="win32 $nocodecmodules"
fi
echores "$_win32dll"


echocheck "XAnim codecs"
if test "$_xanim" = auto ; then
  _xanim=no
  res_comment="dynamic loader support needed"
  if test "$_dl" = yes ; then
    _xanim=yes
  fi
fi
if test "$_xanim" = yes ; then
  def_xanim='#define CONFIG_XANIM 1'
  codecmodules="xanim $codecmodules"
else
  def_xanim='#undef CONFIG_XANIM'
  nocodecmodules="xanim $nocodecmodules"
fi
echores "$_xanim"


echocheck "RealPlayer codecs"
if test "$_real" = auto ; then
  _real=no
  res_comment="dynamic loader support needed"
  if test "$_dl" = yes || test "$_win32dll" = yes &&
     (linux || freebsd || netbsd || openbsd || dragonfly || darwin || win32) ; then
    _real=yes
  fi
fi
if test "$_real" = yes ; then
  def_real='#define CONFIG_REALCODECS 1'
  codecmodules="real $codecmodules"
else
  def_real='#undef CONFIG_REALCODECS'
  nocodecmodules="real $nocodecmodules"
fi
echores "$_real"


echocheck "QuickTime codecs"
_qtx_emulation=no
def_qtx_win32='#undef CONFIG_QTX_CODECS_WIN32'
if test "$_qtx" = auto ; then
  test "$_win32dll" = yes || test "$quicktime" = yes && _qtx=yes
fi
if test "$_qtx" = yes ; then
    def_qtx='#define CONFIG_QTX_CODECS 1'
    win32 && _qtx_codecs_win32=yes && def_qtx_win32='#define CONFIG_QTX_CODECS_WIN32 1'
    codecmodules="qtx $codecmodules"
    darwin || win32 || _qtx_emulation=yes
else
    def_qtx='#undef CONFIG_QTX_CODECS'
    nocodecmodules="qtx $nocodecmodules"
fi
echores "$_qtx"

echocheck "LCMS2 support"
if test "$_lcms2" = auto ; then
    _lcms2=no
    if pkg_config_add lcms2 ; then
        _lcms2=yes
    fi
fi
if test "$_lcms2" = yes; then
    def_lcms2="#define CONFIG_LCMS2 1"
else
    def_lcms2="#undef CONFIG_LCMS2"
fi
echores "$_lcms2"

echocheck "Nemesi Streaming Media libraries"
if test "$_nemesi" = auto  && test "$networking" = yes ; then
    _nemesi=no
    if pkg_config_add libnemesi ; then
        _nemesi=yes
    fi
fi
if test "$_nemesi" = yes; then
    def_nemesi='#define CONFIG_LIBNEMESI 1'
    inputmodules="nemesi $inputmodules"
else
    _nemesi=no
    def_nemesi='#undef CONFIG_LIBNEMESI'
    noinputmodules="nemesi $noinputmodules"
fi
echores "$_nemesi"

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

  _live=no
  for I in $extra_cflags "-I$_libdir/live" "-I/usr/lib/live" "-I/usr/lib64/live" "-I/usr/local/live" "-I/usr/local/lib/live" ; do
    cxx_check $I/liveMedia/include $I/UsageEnvironment/include $I/groupsock/include &&
        _livelibdir=$(echo $I| sed s/-I//) &&
      extra_ldflags="$_livelibdir/liveMedia/libliveMedia.a \
                 $_livelibdir/groupsock/libgroupsock.a \
                 $_livelibdir/UsageEnvironment/libUsageEnvironment.a \
                 $_livelibdir/BasicUsageEnvironment/libBasicUsageEnvironment.a \
                 $extra_ldflags  -lstdc++" \
      extra_cxxflags="-I$_livelibdir/liveMedia/include \
                  -I$_livelibdir/UsageEnvironment/include \
                  -I$_livelibdir/BasicUsageEnvironment/include \
                  -I$_livelibdir/groupsock/include" &&
      _live=yes && break
  done
  if test "$_live" != yes ; then
      ld_tmp="-lliveMedia -lgroupsock -lUsageEnvironment -lBasicUsageEnvironment -lstdc++"
      if cxx_check -I/usr/include/liveMedia -I/usr/include/UsageEnvironment -I/usr/include/groupsock $ld_tmp; then
          _live_dist=yes
      fi
  fi
fi
if test "$_live" = yes && test "$networking" = yes; then
  test $_livelibdir && res_comment="using $_livelibdir"
  def_live='#define CONFIG_LIVE555 1'
 inputmodules="live555 $inputmodules"
elif test "$_live_dist" = yes && test "$networking" = yes; then
  res_comment="using distribution version"
  _live="yes"
  def_live='#define CONFIG_LIVE555 1'
  extra_ldflags="$extra_ldflags $ld_tmp"
  extra_cxxflags="-I/usr/include/liveMedia -I/usr/include/UsageEnvironment -I/usr/include/BasicUsageEnvironment -I/usr/include/groupsock"
 inputmodules="live555 $inputmodules"
else
  _live=no
  def_live='#undef CONFIG_LIVE555'
  noinputmodules="live555 $noinputmodules"
fi
echores "$_live"



# Test with > against Libav 0.8 versions which will NOT work rather than
# specify minimum version, to allow (future) point releases to possibly work.
all_libav_libs="libavutil > 51.21.0:libavcodec > 53.34.0:libavformat > 53.20.0:libswscale >= 2.0.0"
echocheck "Libav ($all_libav_libs)"
if test "$ffmpeg" = auto ; then
  IFS=":"   # shell should not be used for programming
  if ! pkg_config_add $all_libav_libs ; then
    die "Unable to find development files for some of the required Libav libraries above. Aborting."
  fi
fi
echores "yes"

def_ffmpeg_internals="#undef CONFIG_FFMPEG_INTERNALS"
if ! test -z "$_ffmpeg_source" ; then
  def_ffmpeg_internals="#define CONFIG_FFMPEG_INTERNALS 1" && ffmpeg_internals=yes
fi

echocheck "libpostproc >= 52.0.0"
if test "$libpostproc" = auto ; then
    libpostproc=no
    if pkg_config_add "libpostproc >= 52.0.0" ; then
        libpostproc=yes
    fi
fi
if test "$libpostproc" = yes ; then
    def_libpostproc='#define CONFIG_LIBPOSTPROC 1'
else
    def_libpostproc='#undef CONFIG_LIBPOSTPROC'
fi
echores "$libpostproc"


echocheck "libdv-0.9.5+"
if test "$_libdv" = auto ; then
  _libdv=no
  statement_check libdv/dv.h 'dv_encoder_new(1, 1, 1)' -ldv $_ld_pthread $_ld_lm && _libdv=yes
fi
if test "$_libdv" = yes ; then
  def_libdv='#define CONFIG_LIBDV095 1'
  extra_ldflags="$extra_ldflags -ldv"
  codecmodules="libdv $codecmodules"
else
  def_libdv='#undef CONFIG_LIBDV095'
  nocodecmodules="libdv $nocodecmodules"
fi
echores "$_libdv"


echocheck "TV interface"
if test "$_tv" = yes ; then
  def_tv='#define CONFIG_TV 1'
  inputmodules="tv $inputmodules"
else
  noinputmodules="tv $noinputmodules"
  def_tv='#undef CONFIG_TV'
fi
echores "$_tv"


if freebsd || netbsd || openbsd || dragonfly ; then
  echocheck "*BSD BT848 bt8xx header"
  _ioctl_bt848_h=no
  for file in "machine/ioctl_bt848.h" \
            "dev/bktr/ioctl_bt848.h" \
            "dev/video/bktr/ioctl_bt848.h" \
            "dev/ic/bt8xx.h" ; do
    cat > $TMPC <<EOF
#include <sys/types.h>
#include <sys/ioctl.h>
#include <$file>
int main(void) { ioctl(0, TVTUNER_GETFREQ, 0); return 0; }
EOF
    if cc_check ; then
     _ioctl_bt848_h=yes
     _ioctl_bt848_h_name="$file"
     break;
    fi
  done
  if test "$_ioctl_bt848_h" = yes ; then
    def_ioctl_bt848_h_name="#define IOCTL_BT848_H_NAME <$_ioctl_bt848_h_name>"
    res_comment="using $_ioctl_bt848_h_name"
  else
    def_ioctl_bt848_h_name="#undef IOCTL_BT848_H_NAME"
  fi
  echores "$_ioctl_bt848_h"

  echocheck "*BSD ioctl_meteor.h"
  _ioctl_meteor_h=no
  for ioctl_meteor_h_path in "machine/ioctl_meteor.h" "dev/bktr/ioctl_meteor.h" "dev/video/bktr/ioctl_meteor.h" ; do
    statement_check_broken "sys/types.h" "$ioctl_meteor_h_path" 'ioctl(0, METEORSINPUT, 0)' &&
      _ioctl_meteor_h=yes && break
  done
  if test "$_ioctl_meteor_h" = yes ; then
    def_ioctl_meteor_h_name="#define IOCTL_METEOR_H_NAME <$ioctl_meteor_h_path>"
    res_comment="using $ioctl_meteor_h_path"
  else
    def_ioctl_meteor_h_name="#undef IOCTL_METEOR_H_NAME"
  fi
  echores "$_ioctl_meteor_h"

  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>
$def_ioctl_meteor_h_name
$def_ioctl_bt848_h_name
#ifdef IOCTL_METEOR_H_NAME
#include IOCTL_METEOR_H_NAME
#endif
#ifdef IOCTL_BT848_H_NAME
#include IOCTL_BT848_H_NAME
#endif
int main(void) {
 ioctl(0, METEORSINPUT, 0);
 ioctl(0, TVTUNER_GETFREQ, 0);
 return 0;
}
EOF
      cc_check && _tv_bsdbt848=yes
    fi
  fi
  if test "$_tv_bsdbt848" = yes ; then
    def_tv_bsdbt848='#define CONFIG_TV_BSDBT848 1'
    inputmodules="tv-bsdbt848 $inputmodules"
  else
    def_tv_bsdbt848='#undef CONFIG_TV_BSDBT848'
    noinputmodules="tv-bsdbt848 $noinputmodules"
  fi
  echores "$_tv_bsdbt848"
fi #if freebsd || netbsd || openbsd || dragonfly


echocheck "DirectShow TV interface"
if test "$_tv_dshow" = auto ; then
  _tv_dshow=no
  if test "$_tv" = yes && win32 ; then
    statement_check ole2.h 'void* p; CoCreateInstance((GUID*)&GUID_NULL, NULL, CLSCTX_INPROC_SERVER, &GUID_NULL, &p)' -lole32 -luuid && _tv_dshow=yes
  fi
fi
if test "$_tv_dshow" = yes ; then
  inputmodules="tv-dshow $inputmodules"
  def_tv_dshow='#define CONFIG_TV_DSHOW 1'
  extra_ldflags="$extra_ldflags -lole32 -luuid"
else
  noinputmodules="tv-dshow $noinputmodules"
  def_tv_dshow='#undef CONFIG_TV_DSHOW'
fi
echores "$_tv_dshow"


echocheck "Video 4 Linux TV interface"
if test "$_tv_v4l1" = auto ; then
  _tv_v4l1=no
  if test "$_tv" = yes && linux ; then
    header_check_broken sys/time.h linux/videodev.h && _tv_v4l1=yes
  fi
fi
if test "$_tv_v4l1" = yes ; then
  _audio_input=yes
  _tv_v4l=yes
  def_tv_v4l='#define CONFIG_TV_V4L 1'
  def_tv_v4l1='#define CONFIG_TV_V4L1 1'
  inputmodules="tv-v4l $inputmodules"
else
  noinputmodules="tv-v4l1 $noinputmodules"
  def_tv_v4l='#undef CONFIG_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
    header_check_broken sys/time.h linux/videodev2.h && _tv_v4l2=yes
  elif test "$_tv" = yes && test "$sys_videoio_h" = "yes" ; then
    _tv_v4l2=yes
  fi
fi
if test "$_tv_v4l2" = yes ; then
  _audio_input=yes
  _tv_v4l=yes
  def_tv_v4l='#define CONFIG_TV_V4L 1'
  def_tv_v4l2='#define CONFIG_TV_V4L2 1'
  inputmodules="tv-v4l2 $inputmodules"
else
  noinputmodules="tv-v4l2 $noinputmodules"
  def_tv_v4l2='#undef CONFIG_TV_V4L2'
fi
echores "$_tv_v4l2"


echocheck "Radio interface"
if test "$_radio" = yes ; then
  def_radio='#define CONFIG_RADIO 1'
  inputmodules="radio $inputmodules"
  if test "$_alsa" != yes -a "$_ossaudio" != yes ; then
    _radio_capture=no
  fi
  if test "$_radio_capture" = yes ; then
    _audio_input=yes
    def_radio_capture="#define CONFIG_RADIO_CAPTURE 1"
  else
    def_radio_capture="#undef CONFIG_RADIO_CAPTURE"
  fi
else
  noinputmodules="radio $noinputmodules"
  def_radio='#undef CONFIG_RADIO'
  def_radio_capture="#undef CONFIG_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
    header_check linux/videodev2.h && _radio_v4l2=yes
  fi
fi
if test "$_radio_v4l2" = yes ; then
  def_radio_v4l2='#define CONFIG_RADIO_V4L2 1'
else
  def_radio_v4l2='#undef CONFIG_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
    header_check linux/videodev.h && _radio_v4l=yes
  fi
fi
if test "$_radio_v4l" = yes ; then
  def_radio_v4l='#define CONFIG_RADIO_V4L 1'
else
  def_radio_v4l='#undef CONFIG_RADIO_V4L'
fi
echores "$_radio_v4l"

if freebsd || netbsd || openbsd || dragonfly &&
  test "$_radio" = yes && test "$_radio_bsdbt848" = auto ; then
echocheck "*BSD BrookTree 848 Radio interface"
   _radio_bsdbt848=no
    cat > $TMPC <<EOF
#include <sys/types.h>
$def_ioctl_bt848_h_name
#ifdef IOCTL_BT848_H_NAME
#include IOCTL_BT848_H_NAME
#endif
int main(void) { ioctl(0, RADIO_GETFREQ, 0); return 0; }
EOF
    cc_check && _radio_bsdbt848=yes
echores "$_radio_bsdbt848"
fi #if freebsd || netbsd || openbsd || dragonfly && _radio && _radio_bsdbt848

if test "$_radio_bsdbt848" = yes ; then
  def_radio_bsdbt848='#define CONFIG_RADIO_BSDBT848 1'
else
  def_radio_bsdbt848='#undef CONFIG_RADIO_BSDBT848'
fi

if test "$_radio_v4l" = no && test "$_radio_v4l2" = no &&
   test "$_radio_bsdbt848" = no && test "$_radio" = yes ; then
    die "Radio driver requires BSD BT848,  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 <sys/time.h>
#include <linux/videodev2.h>
int main(void) { struct v4l2_ext_controls ext; return ext.controls->value; }
EOF
  cc_check && _pvr=yes
 fi
fi
if test "$_pvr" = yes ; then
  def_pvr='#define CONFIG_PVR 1'
  inputmodules="pvr $inputmodules"
else
  noinputmodules="pvr $noinputmodules"
  def_pvr='#undef CONFIG_PVR'
fi
echores "$_pvr"


echocheck "ftp"
if test "$_ftp" = "auto" ; then
test "$networking" = "yes" && _ftp=yes
fi
if test "$_ftp" = yes ; then
  def_ftp='#define CONFIG_FTP 1'
  inputmodules="ftp $inputmodules"
else
  noinputmodules="ftp $noinputmodules"
  def_ftp='#undef CONFIG_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 CONFIG_VSTREAM 1'
  inputmodules="vstream $inputmodules"
  extra_ldflags="$extra_ldflags -lvstream-client"
else
  noinputmodules="vstream $noinputmodules"
  def_vstream='#undef CONFIG_VSTREAM'
fi
echores "$_vstream"


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


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

echocheck "compiler support for noexecstack"
if cflag_check -Wl,-z,noexecstack ; then
  extra_ldflags="-Wl,-z,noexecstack $extra_ldflags"
  echores "yes"
else
  echores "no"
fi

echocheck "linker support for --nxcompat --no-seh --dynamicbase"
if cflag_check "-Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase" ; then
  extra_ldflags="-Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase $extra_ldflags"
  echores "yes"
else
  echores "no"
fi


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

extra_ldflags="$extra_ldflags $_ld_pthread $_ld_dl $_ld_dl_dynamic"
(netbsd || openbsd) && x86_32 && extra_ldflags="$extra_ldflags -li386"


echocheck "joystick"
def_joystick='#undef CONFIG_JOYSTICK'
if test "$_joystick" = yes ; then
  if linux || freebsd ; then
    # TODO add some check
    def_joystick='#define CONFIG_JOYSTICK 1'
  else
    _joystick="no"
    res_comment="unsupported under $system_name"
  fi
fi
echores "$_joystick"

echocheck "lirc"
if test "$_lirc" = auto ; then
  _lirc=no
  header_check lirc/lirc_client.h -llirc_client && _lirc=yes
fi
if test "$_lirc" = yes ; then
  def_lirc='#define CONFIG_LIRC 1'
  libs_mplayer="$libs_mplayer -llirc_client"
else
  def_lirc='#undef CONFIG_LIRC'
fi
echores "$_lirc"

echocheck "lircc"
if test "$_lircc" = auto ; then
  _lircc=no
  header_check lirc/lircc.h -llircc && _lircc=yes
fi
if test "$_lircc" = yes ; then
  def_lircc='#define CONFIG_LIRCC 1'
  libs_mplayer="$libs_mplayer -llircc"
else
  def_lircc='#undef CONFIG_LIRCC'
fi
echores "$_lircc"

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

CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE"

CXXFLAGS=" $CFLAGS -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS"

# This must be the last test to be performed. Any other tests following it
# could fail due to linker errors. libdvdnavmini is intentionally not linked
# against libdvdread (to permit MPlayer to use its own copy of the library).
# So any compilation using the flags added here but not linking against
# libdvdread can fail.
echocheck "DVD support (libdvdnav)"
if test "$_dvdread_internal" = yes && test ! -f "libdvdnav/dvdnav.c" ; then
  _dvdnav=no
fi
dvdnav_internal=no
if test "$_dvdnav" = auto ; then
  if test "$_dvdread_internal" = yes ; then
    _dvdnav=yes
    dvdnav_internal=yes
    res_comment="internal"
  else
    $_dvdnavconfig --version --minilibs >> $TMPLOG 2>&1 || _dvdnav=no
  fi
fi
if test "$_dvdnav" = auto ; then
  _dvdnav=no
  _dvdnavdir=$($_dvdnavconfig --cflags)
  _dvdnavlibs=$($_dvdnavconfig --libs)
  statement_check_broken stdint.h dvdnav/dvdnav.h 'dvdnav_t *dvd = 0' $_dvdnavdir $_dvdnavlibs $_ld_dl $_ld_pthread && _dvdnav=yes
fi
if test "$_dvdnav" = yes ; then
  def_dvdnav='#define CONFIG_DVDNAV 1'
  if test "$dvdnav_internal" = yes ; then
    cflags_libdvdnav="-Ilibdvdnav"
    inputmodules="dvdnav(internal) $inputmodules"
  else
    extra_cflags="$extra_cflags $($_dvdnavconfig --cflags)"
    extra_ldflags="$extra_ldflags $($_dvdnavconfig --minilibs)"
    inputmodules="dvdnav $inputmodules"
  fi
else
  def_dvdnav='#undef CONFIG_DVDNAV'
  noinputmodules="dvdnav $noinputmodules"
fi
echores "$_dvdnav"

# DO NOT ADD ANY TESTS THAT USE LINKER FLAGS HERE (like cc_check).
# Read dvdnav comment above.

mak_enable () {
list=$(echo $1 | tr '[a-z]' '[A-Z]')
item=$(echo $2 | tr '[a-z]' '[A-Z]')
nprefix=$3;
for part in $list; do
  if $(echo $item | grep -q -E "(^| )$part($| )"); then
    echo "${nprefix}_$part = yes"
  fi
done
}

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

# Ensure that locale settings do not interfere with shell commands.
export LC_ALL = C

CONFIGURATION = $configuration

DOC_LANGS = $language_doc
DOC_LANG_ALL = $doc_lang_all
MAN_LANGS = $language_man
MAN_LANG_ALL = $man_lang_all
MSG_LANGS = $language_msg
MSG_LANG_ALL = $msg_lang_all

prefix  = \$(DESTDIR)$_prefix
BINDIR  = \$(DESTDIR)$_bindir
DATADIR = \$(DESTDIR)$_datadir
LIBDIR  = \$(DESTDIR)$_libdir
MANDIR  = \$(DESTDIR)$_mandir
CONFDIR = \$(DESTDIR)$_confdir
LOCALEDIR = \$(DESTDIR)$_localedir

CC      = $_cc
CXX     = $_cc
INSTALL = $_install
INSTALLSTRIP = $_install_strip
WINDRES = $_windres

CFLAGS   = $WARNFLAGS $ERRORFLAGS $WARN_CFLAGS $CFLAGS $extra_cflags
CXXFLAGS = $WARNFLAGS $ERRORFLAGS $CXXFLAGS $extra_cflags $extra_cxxflags
DEPFLAGS = $DEPFLAGS

CFLAGS_LIBDVDCSS         = $cflags_libdvdcss
CFLAGS_LIBDVDCSS_DVDREAD = $cflags_libdvdcss_dvdread
CFLAGS_LIBDVDNAV         = $cflags_libdvdnav
CFLAGS_NO_OMIT_LEAF_FRAME_POINTER = $cflags_no_omit_leaf_frame_pointer
CFLAGS_STACKREALIGN      = $cflags_stackrealign

EXTRALIBS          = $extra_ldflags $_ld_static $_ld_lm $extra_libs
EXTRALIBS_MPLAYER  = $libs_mplayer

GETCH = $_getch
TIMER = $_timer

EXESUF      = $_exesuf
EXESUFS_ALL = .exe

ARCH = $arch
$(mak_enable "$arch_all"    "$arch"    ARCH)
$(mak_enable "$subarch_all" "$subarch" ARCH)

MPLAYER  = $_mplayer

NEED_GETTIMEOFDAY = $need_gettimeofday
NEED_GLOB         = $need_glob
NEED_SETENV       = $need_setenv
NEED_SHMEM        = $need_shmem
NEED_STRSEP       = $need_strsep
NEED_SWAB         = $need_swab
NEED_VSSCANF      = $need_vsscanf

# features
ALSA = $_alsa
APPLE_IR = $_apple_ir
APPLE_REMOTE = $_apple_remote
AUDIO_INPUT = $_audio_input
CACA = $_caca
CDDA = $_cdda
CDDB = $_cddb
COCOA = $_cocoa
COREAUDIO = $_coreaudio
COREVIDEO = $_corevideo
SHAREDBUFFER = $_sharedbuffer
DIRECT3D = $_direct3d
DIRECTFB = $_directfb
DIRECTX = $_directx
DVBIN = $_dvbin
DVDNAV = $_dvdnav
DVDNAV_INTERNAL = $dvdnav_internal
DVDREAD = $_dvdread
DVDREAD_INTERNAL = $_dvdread_internal
DXR3 = $_dxr3
FAAD = $_faad
FTP = $_ftp
GIF = $_gif
GL = $_gl
GL_COCOA = $_gl_cocoa
GL_WIN32 = $_gl_win32
GL_X11 = $_gl_x11
HAVE_POSIX_SELECT = $_posix_select
HAVE_SYS_MMAN_H = $_mman
JACK = $_jack
JOYSTICK = $_joystick
JPEG = $_jpeg
LADSPA = $_ladspa
LIBA52 = $_liba52
LIBASS = $_ass
LIBASS_OSD = $_libass_osd
DUMMY_OSD = $_dummy_osd
LIBBLURAY = $_bluray
LIBBS2B = $_libbs2b
LIBDCA = $_libdca
LIBDV = $_libdv
LIBDVDCSS_INTERNAL = $_libdvdcss_internal
LIBMAD = $_mad
LIBNEMESI = $_nemesi
LCMS2 = $_lcms2
LIBPOSTPROC = $libpostproc
LIBSMBCLIENT = $_smb
LIBQUVI = $_libquvi
LIBTHEORA = $_theora
LIRC = $_lirc
LIVE555 = $_live
MACOSX_FINDER = $_macosx_finder
MD5SUM = $_md5sum
MNG = $_mng
MPG123 = $_mpg123
NETWORKING = $networking
OPENAL = $_openal
OSS = $_ossaudio
PE_EXECUTABLE = $_pe_executable
PNG = $_png
PNM = $_pnm
PRIORITY = $_priority
PULSE = $_pulse
PORTAUDIO = $_portaudio
PVR = $_pvr
QTX_CODECS = $_qtx
QTX_CODECS_WIN32 = $_qtx_codecs_win32
QTX_EMULATION = $_qtx_emulation
RADIO=$_radio
RADIO_CAPTURE=$_radio_capture
REAL_CODECS = $_real
RSOUND = $_rsound
STREAM_CACHE = $_stream_cache
TGA = $_tga
TV = $_tv
TV_BSDBT848 = $_tv_bsdbt848
TV_DSHOW = $_tv_dshow
TV_V4L  = $_tv_v4l
TV_V4L1 = $_tv_v4l1
TV_V4L2 = $_tv_v4l2
V4L2 = $_v4l2
VCD = $_vcd
VDPAU = $_vdpau
VSTREAM = $_vstream
WIN32DLL = $_win32dll
WIN32_EMULATION = $_win32_emulation
X11 = $_x11
XANIM_CODECS = $_xanim
XV = $_xv
YUV4MPEG = $_yuv4mpeg

# FFmpeg
FFMPEG_INTERNALS = $ffmpeg_internals
FFMPEG_SOURCE_PATH = $_ffmpeg_source

CONFIG_VDPAU    = $_vdpau
CONFIG_ZLIB     = $_zlib

HAVE_PTHREADS   = $_pthreads
HAVE_SHM        = $_shm
HAVE_W32THREADS = $_w32threads

EOF

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

ff_config_enable () {
list=$(echo $1 | tr '[a-z]' '[A-Z]')
item=$(echo $2 | tr '[a-z]' '[A-Z]')
_nprefix=$3;
test -z "$_nprefix" && _nprefix='CONFIG'
for part in $list; do
  if $(echo $item | grep -q -E "(^| )$part($| )"); then
    echo "#define ${_nprefix}_$part 1"
  else
    echo "#define ${_nprefix}_$part 0"
  fi
done
}

echo "Creating config.h"
cat > $TMPH << EOF
/*----------------------------------------------------------------------------
** This file has been automatically generated by configure any changes in it
** will be lost when you run configure again.
** Instead of modifying definitions here, use the --enable/--disable options
** of the configure script! See ./configure --help for details.
*---------------------------------------------------------------------------*/

#ifndef MPLAYER_CONFIG_H
#define MPLAYER_CONFIG_H

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

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

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



#define CONFIGURATION "$configuration"

#define MPLAYER_DATADIR "$_datadir"
#define MPLAYER_CONFDIR "$_confdir"
#define MPLAYER_LOCALEDIR "$_localedir"

$def_translation

/* definitions needed by included libraries */
#define HAVE_INTTYPES_H 1
/* libdvdcss */
#define HAVE_ERRNO_H 1
/* libdvdcss + libdvdread */
#define HAVE_LIMITS_H 1
/* libdvdcss */
#define HAVE_UNISTD_H 1
/* libdvdread */
#define STDC_HEADERS 1
#define HAVE_MEMCPY 1
/* libdvdnav */
#define READ_CACHE_TRACE 0
/* libdvdread */
#define HAVE_DLFCN_H 1
$def_dvdcss


/* system headers */
$def_mman_h
$def_mman_has_map_failed
$def_soundcard_h
$def_sys_soundcard_h
$def_sys_sysinfo_h
$def_sys_videoio_h
$def_termios_h
$def_termios_sys_h
$def_winsock2_h


/* system functions */
$def_gethostbyname2
$def_gettimeofday
$def_glob
$def_lrintf
$def_nanosleep
$def_posix_select
$def_select
$def_setenv
$def_setmode
$def_shm
$def_strsep
$def_swab
$def_sysi86
$def_sysi86_iv
$def_termcap
$def_termios
$def_vsscanf


/* system-specific features */
$def_asmalign_pot
$def_builtin_expect
$def_dl
$def_dos_paths
$def_iconv
$def_kstat
$def_macosx_bundle
$def_macosx_finder
$def_priority
$def_quicktime
$def_restrict_keyword


/* configurable options */
$def_debug
$def_sortsub
$def_stream_cache
$def_pthread_cache


/* CPU stuff */
#define __CPU__ $iproc
$def_ebx_available
$(ff_config_enable "$arch_all" "$arch" "ARCH")
$(ff_config_enable "$subarch_all" "$subarch" "ARCH")

#define HAVE_MMX ARCH_X86
#define HAVE_MMX2 ARCH_X86
#define HAVE_SSE ARCH_X86
#define HAVE_SSE2 ARCH_X86
#define HAVE_SSSE3 ARCH_X86

/* Blu-ray/DVD/VCD/CD */
#define DEFAULT_CDROM_DEVICE "$default_cdrom_device"
#define DEFAULT_DVD_DEVICE   "$default_dvd_device"
$def_bluray
$def_bsdi_dvd
$def_cdda
$def_cddb
$def_cdio
$def_cdrom
$def_dvd
$def_dvd_bsd
$def_dvd_darwin
$def_dvd_linux
$def_dvd_openbsd
$def_dvdio
$def_dvdnav
$def_dvdread
$def_vcd


/* codec libraries */
$def_faad
$def_liba52
$def_libdca
$def_libdv
$def_mad
$def_mpg123
$def_zlib

$def_libpostproc


/* binary codecs */
$def_qtx
$def_qtx_win32
$def_real
$def_win32_loader
$def_win32dll
$def_xanim
#define BINARY_CODECS_PATH "$_codecsdir"


/* Audio output drivers */
$def_alsa
$def_coreaudio
$def_jack
$def_nas
$def_openal
$def_openal_h
$def_ossaudio
$def_ossaudio_devdsp
$def_ossaudio_devmixer
$def_pulse
$def_portaudio
$def_rsound

$def_ladspa
$def_libbs2b


/* input */
$def_apple_ir
$def_apple_remote
$def_ioctl_bt848_h_name
$def_ioctl_meteor_h_name
$def_joystick
$def_lirc
$def_lircc
$def_pvr
$def_radio
$def_radio_bsdbt848
$def_radio_capture
$def_radio_v4l
$def_radio_v4l2
$def_tv
$def_tv_bsdbt848
$def_tv_dshow
$def_tv_v4l
$def_tv_v4l1
$def_tv_v4l2


/* font stuff */
$def_ass
$def_enca

/* networking */
$def_closesocket
$def_ftp
$def_inet6
$def_inet_aton
$def_inet_pton
$def_live
$def_nemesi
$def_networking
$def_smb
$def_libquvi
$def_socklen_t
$def_vstream

$def_lcms2


/* libvo options */
$def_caca
$def_corevideo
$def_cocoa
$def_sharedbuffer
$def_direct3d
$def_directfb
$def_directx
$def_gif
$def_gif_4
$def_gif_tvt_hack
$def_gl
$def_gl_cocoa
$def_gl_win32
$def_gl_x11
$def_jpeg
$def_md5sum
$def_mng
$def_png
$def_pnm
$def_tga
$def_v4l2
$def_vdpau
$def_vm
$def_x11
$def_xdpms
$def_xf86keysym
$def_xinerama
$def_xss
$def_xv
$def_yuv4mpeg


/* FFmpeg */
$def_ffmpeg_internals

$def_arpa_inet_h
$def_bswap
$def_dcbzl
$def_exp2
$def_exp2f
$def_fast_64bit
$def_llrint
$def_log2
$def_log2f
$def_lrint
$def_mkstemp
$def_pthreads
$def_round
$def_roundf
$def_threads
$def_truncf
$def_xform_asm

#define HAVE_INLINE_ASM 1

/* Use these registers in x86 inline asm. No proper detection yet. */
#define HAVE_EBP_AVAILABLE 1

#endif /* MPLAYER_CONFIG_H */
EOF

# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
cmp -s "$TMPH" config.h || mv -f "$TMPH" config.h

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

cat << EOF

Config files successfully generated by ./configure $configuration !

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

  Languages:
    Messages (in addition to English): $language_msg
    Manual pages: $language_man
    Documentation: $language_doc

  Enabled optional drivers:
    Input: $inputmodules
    Codecs: $codecmodules
    Audio output: $aomodules
    Video output: $vomodules

  Disabled optional drivers:
    Input: $noinputmodules
    Codecs: $nocodecmodules
    Audio output: $noaomodules
    Video output: $novomodules

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

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

EOF


cat <<EOF
Check $TMPLOG if you wonder why an autodetection failed (make sure
development headers/packages are installed).

NOTE: The --enable-* parameters unconditionally force options on, completely
skipping autodetection. This behavior is unlike what you may be used to from
autoconf-based configure scripts that can decide to override you. This greater
level of control comes at a price. You may have to provide the correct compiler
and linker flags yourself.
If you used one of these options and experience a compilation or
linking failure, make sure you have passed the necessary compiler/linker flags
to configure.

If you suspect a bug, please read DOCS/HTML/$language_doc/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 -rf "$mplayer_tmpdir"