summaryrefslogtreecommitdiffstats
path: root/vlc/build/vlc-1.0.SlackBuild
blob: e01a011f5b25b00e185f5ff1ef77ef177d9f577a (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
#!/bin/sh
# $Id$
# Copyright (c) 2007,2008, 2009  Eric Hameleers, Eindhoven, Netherlands
#
#   Permission to use, copy, modify, and distribute this software for
#   any purpose with or without fee is hereby granted, provided that
#   the above copyright notice and this permission notice appear in all
#   copies.
#
#   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
#   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
#   IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
#   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
#   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
#   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
#   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
#   SUCH DAMAGE.
# -----------------------------------------------------------------------------
#
# Slackware SlackBuild script 
# ===========================
# By:         Eric Hameleers <alien@slackware.com>
# For:        vlc
# Descr:      multimedia player for various audio and video formats
# URL:        http://www.videolan.org/vlc/
# Needs:      
# Changelog: 
# 0.8.6a-1:   15/Mar/2007 by Eric Hameleers <alien@slackware.com>
#             * Initial build.
# 0.8.6b-1:   25/apr/2007 by Eric Hameleers <alien@slackware.com>
#             * Update.
# 0.8.6c-1:   04/sep/2007 by Eric Hameleers <alien@slackware.com>
#             * Update. Allow vlc to be built without patented code (lame/amr).
# 0.8.6d-1:   12/dec/2007 by Eric Hameleers <alien@slackware.com>
#             * Update with a vulnerability bugfix. All external libraries
#               were updated to their most recent release.
#               This pkg adds support for firewire cameras, DV and DVB cards.
#               AMR audio codec is not supported in this build (I could not
#               create a vlc binary successfully).
#               Again, the resulting binary package requires no additional
#               non-Slackware packages, except for libdvdcss in case you want
#               to watch an encrypted DVD.
# 0.8.6d-2:   29/jan/2008 by Eric Hameleers <alien@slackware.com>
#             * Disable building AMR. The 0.8.6d official release does
#               not have support for AMR audio codec re-added yet.
#               Also, add the AAC en/decoder to the PATENTED software.
#               Build with dll loader support only on 32bit platform.
# 0.8.6e-1:   02/mar/2008 by Eric Hameleers <alien@slackware.com>
#             * New release fixes security issues.
# 0.8.6e-2:   23/mar/2008 by Eric Hameleers <alien@slackware.com>
#             * Update libebml; new ffmpeg,live555 snapshots
# 0.8.6f-1:   03/apr/2008 by Eric Hameleers <alien@slackware.com>
#             * New release (bugfixes). Also updated the snapshot for ffmpeg
# 0.8.6f-2:   03/apr/2008 by Eric Hameleers <alien@slackware.com>
#             * Updated the snapshot for ffmpeg
# 0.8.6g-1:   31/may/2008 by Eric Hameleers <alien@slackware.com>
#             * New release. Updated the snapshot for ffmpeg and live555,
#               updated libtheora.
# 0.8.6h-1:   10/jun/2008 by Eric Hameleers <alien@slackware.com>
#             * New release. Repaired the broken matroska support (thanks to
#               Thomas Morper who submitted a fix for the SlackBuild.
# 0.8.6h-2:   15/jun/2008 by Eric Hameleers <alien@slackware.com>
#             * Fixed the broken DTS audio codec support (did not play
#               6 channel sound here)
# 0.8.6h-3:   17/jun/2008 by Eric Hameleers <alien@slackware.com>
#             * Added Universal Plug'n'Play (upnp) client support.
#               Updated the live555 tarball to 20080605.
#               Updated the x264 snapshot- this now requires the yasm assembler
#               to be installed in order to compile successfully. If you don't
#               have/want that, set the variable REQUIRE_YASM to a value of "NO"
#               (see further down) so that the script will fall back to an older
#               x264 snapshot that does not require yasm to compile. Updated
#               libcdio to 0.80. Re-introduce AMR audio encoding to the package.
# 0.8.6i-1:   09/jul/2008 by Eric Hameleers <alien@slackware.com>
#             * New release. Also updated to the new lame-3.98.
# 0.9.1-1:    31/aug/2008 by Eric Hameleers <alien@slackware.com>
#             * The first in a new series of 0.9.x - these are source-only
#               releases for now, meaning that the developers are not yet
#               convinced 0.9.x is ready to replace 0.8.x.
#               Note that the vlc 0.9 releases fail to compile a static vlc.
#               According to the developers whis will not be fixed. Still, this
#               vlc package is without external dependencies as always ;-)
#               Updated lame to v3.89, speex to 1.2rc1 and libmpeg2 to 1.5.1.
#               Updated snapshots for ffmpeg to r14080; live555 to 2008.07.25;
#               started using libdvdread/libdvdnav releases from mplayerhq.hu.
#               For dirac video I now use the far better schroedinger instead
#               of the reference 'dirac' implementation.
#               I added documentation for all the libraries which I include.
#               Notes for package (re)builders:
#               The SlackBuild will by default use a static version of the Qt4
#               library. If you already have Qt4 installed, you may choose to
#               build vlc against that dynamic library; in that case run:
#                 # STATIC_QT4=NO ./vlc.SlackBuild
#               to build your vlc package.
#               If you already have ffmpeg installed and want to use that, run
#                 # STATIC_FFMPEG=NO ./vlc.SlackBuild
#               to build your vlc package.
#               Of course, if you have both QT4 and ffmpeg already available,
#               you can combine the above two commands to:
#                 # STATIC_QT4=NO STATIC_FFMPEG=NO ./vlc.SlackBuild
#               Lastly, it is worth noting that building any recent X264
#               library fails with Slackware 12.1 (and earlier)'s nasm.
#               Either install yasm, or let the script automatically fall back
#               to an older version of the X264 like this:
#                 # REQUIRE_YASM=NO ./vlc.SlackBuild
# 0.9.2-1:    10/sep/2008 by Eric Hameleers <alien@slackware.com>
#             * Updated to 0.9.2
# 0.9.3-1:    30/sep/2008 by Eric Hameleers <alien@slackware.com>
#             * Updated to 0.9.3
#               Fixed video playback thanks to phobos3576 of the slacky.eu
#               forum for finding the fix and Andrea Tornese for reporting it.
# 0.9.4-1:    07/oct/2008 by Eric Hameleers <alien@slackware.com>
#             * Updated to 0.9.4. Added libass to render 'formatted'
#               subtitles. Updated live555 to 2008.09.02. Updated the ffmpeg
#               snapshot to 20081007. Now default to using dynamically linked
#               QT4 (requires that you install a QT4 package yourself
#               prior to compiling VLC!)
# 0.9.5-1:    26/oct/2008 by Eric Hameleers <alien@slackware.com>
#             * Updated to 0.9.5. New snapshots for ffmpeg x264 added. QT4
#               compiled statically again because VLC is sensitive to the
#               version it builds against.
# 0.9.5-2:    29/oct/2008 by Eric Hameleers <alien@slackware.com>
#             * Re-enable embedded video display. Thanks to Thomas Morper who
#               verified that this works reliably with vlc-0.9.5 and qt-4.4.3 !
# 0.9.5-3:    05/nov/2008 by Eric Hameleers <alien@slackware.com>
#             * Updated libtheora to 1.0 and libcdio to 0.81
# 0.9.6-1:    08/nov/2008 by Eric Hameleers <alien@slackware.com>
#             * New release. Updated ffmpeg/x264 snapshots.
# 0.9.8-1:    02/dec/2008 by Eric Hameleers <alien@slackware.com>
#             * New release. Updated ffmpeg/x264/live555 versions. Added midi
#               playback support through fluidsynth
# 0.9.8a-1:   04/dec/2008 by Eric Hameleers <alien@slackware.com>
#             * VLC bugfix release... also took the opportunity to fix *my*
#               broken build of the dca and fluidsynth modules.
# 0.9.8a-2:   04/dec/2008 by Eric Hameleers <alien@slackware.com>
#             * Updated ffmpeg/x264 snapshots, and re-adding firewire support
# 0.9.8a-3:   28/dec/2008 by Eric Hameleers <alien@slackware.com>
#             * Updated ffmpeg/x264 snapshots, made it build on x86_64 with the
#               help of Attila Craciun.
# 20090307-1: 07/mar/2009 by Eric Hameleers <alien@slackware.com>
#             * Updated ffmpeg/x264/live55 snapshots, fix default font for
#               x86_64, fix DTS audio decoding on x86_64
# 0.9.9.rc2-1:18/mar/2009 by Eric Hameleers <alien@slackware.com>
#             * Building the first release candidate.
# 0.9.9.rc2-2:27/mar/2009 by Eric Hameleers <alien@slackware.com>
#             * Fix AAC decoding by removing "--with-drm"
# 0.9.9-1:    27/mar/2009 by Eric Hameleers <alien@slackware.com>
#             * Try to fix ffmeg video decoding as well as upgrade to 0.9.9;
#               apply several fixes taken from 1.0.0-git to fix x264 encoding.
# 1.0.0.pre2-1: 04/may/2009 by Eric Hameleers <alien@slackware.com>
#             * This is 1.0.0-pre2. I like it much more than the
#               'stable' 0.9.x. Furthermore, DVD playback was broken in
#               my 0.9.9 package, so I needed to release an update.
# 1.0.0.rc1-1: 11/may/2009 by Eric Hameleers <alien@slackware.com>
#             * The first release candidate for 1.0.0
# 1.0.0.rc2-1: 26/may/2009 by Eric Hameleers <alien@slackware.com>
#             * The second release candidate for 1.0.0
# 1.0.0.rc3-1: 09/jun/2009 by Eric Hameleers <alien@slackware.com>
#             * The third release candidate for 1.0.0
# 1.0.0.rc4-1: 18/jun/2009 by Eric Hameleers <alien@slackware.com>
#             * The fourth release candidate for 1.0.0.
#               Also updated live plugin to 2009.06.02
# 1.0.0-1:    06/jul/2009 by Eric Hameleers <alien@slackware.com>
#             * VLC 1.0.0 has been released!
# 1.0.1-1:    28/jul/2009 by Eric Hameleers <alien@slackware.com>
#             * An update that fixes a realrtsp vulnerability. Also updated
#               x264/live555 snapshots and added support for lua playlist,
#               metafetcher and interface plugins. By default, this script
#               no longer links Qt4 statically and instead links against an
#               already installed Qt libray.
# 1.0.1-2:    30/jul/2009 by Eric Hameleers <alien@slackware.com>
#             * Fix the swscale plugin
# 1.0.2-1:    19/sep/2009 by Eric Hameleers <alien@slackware.com>
#             * Update.
# 1.0.3-1:    31/oct/2009 by Eric Hameleers <alien@slackware.com>
#             * Update. New version of the theora encoder.
#               Other upgrades: libkate, schroedinger.
#               Downgraded libraw1394 to 1.2.0 which is the last 1.x version
#               found on sourceforge, now that the original linux1394.org site
#               has disappeared (using new download URL too).
# 1.0.3-2:    02/nov/2009 by Eric Hameleers <alien@slackware.com>
#             * Try to fix broken firewire support (libraw1394). Allow root to
#               run vlc.
# 1.0.3-3:    13/nov/2009 by Eric Hameleers <alien@slackware.com>
#             * Fix the broken fullscreen in KDE-4.3.3; added a newer snapshot
#               for live555 and x264.
# 1.0.3-4:    08/dec/2009 by Eric Hameleers <alien@slackware.com>
#             * Upgrade internal ffmpeg to latest SVN, and update the x86_64
#               assembler patch for ffmpeg to enable mmx/sse support which
#               (according to Thomas Morper who supplied the updated patch)
#               fixes choppy HD video playback. Disabled vdpau support because
#               that will not compile unless you have NVIDIA binary drivers
#               installed.
#               Also updated live555/x264 to their latest snapshots.
#               Switched to the GPL'ed opencore AMR codec (spin-off from
#               Google Android project). 
# 1.0.3-5:    10/dec/2009 by Eric Hameleers <alien@slackware.com>
#             * Make the dc1394 plugin work by patching VLC to use the new API.
# 1.0.4-1:    11/dec/2009 by Eric Hameleers <alien@slackware.com>
#             * New release. The ffmpeg/x264 snapshots were updated.
# 1.0.5-1:    28/jan/2010 by Eric Hameleers <alien@slackware.com>
#             * New release. Fix compilation with gcc-4.4.2. Update snapshots
#               for live555 and x264.
# 1.0.6-1:    22/apr/2010 by Eric Hameleers <alien@slackware.com>
#             * New release. Updated snapshots for live555, x264 and ffmpeg.
#               Updated versions of fluidsynth, kate, lame, libass and
#               libv4l plugins. I am separately working on a further improved
#               SlackBuild script for vlc-1.1.0.
# 
# Run 'sh vlc.SlackBuild' to build a Slackware package.
# The package (.tgz) plus descriptive .txt file are created in /tmp .
# Install using 'installpkg'. 
#
# -----------------------------------------------------------------------------

#
# NOTE: this SlackBuild is a monster - it tries to wrap all dependencies to
# vlc into the resulting package by building these deps as static libraries
# and then in the final stage linking vlc against all the static libraries.
# The resulting package has all the vlc functionality and does not depend on
# any software that is not present in a standard full install of Slackware.
# This makes my package quite different from all the other vlc builds that are
# floating around on the Internet.
# /Eric Hameleers/
#

# -----------------------------------------------------------------------------
# Set initial variables:

PRGNAM=vlc
PRGNAM2=mozplugin
BUILD=${BUILD:-"1"}
TAG=${TAG:-"alien"}

# SRCVER and VERSION values may be modified later!
# If SRCVER is set to "HEAD" then you get a git snapshot, else we look
# for the tarball in vlc's releases directory.
# These are the acceptible formats for VERSION:
#   SRCVER=${SRCVER:-"20090114"}
#   SRCVER=${SRCVER:-"1.0.6"}
#   SRCVER=${SRCVER:-"HEAD"}
SRCVER=${SRCVER:-"1.0.6"}

VERSION=${VERSION:-$(echo $SRCVER | tr '-' '.')}

DOCS="ABOUT-NLS AUTHORS COPYING ChangeLog HACKING INSTALL MAINTAINERS \
      NEWS README THANKS"

NUMJOBS=${NUMJOBS:-7}  # Number of parallel jobs for the compiler 

# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) export ARCH=i486 ;;
    arm*) export ARCH=arm ;;
    # Unless $ARCH is already set, use uname -m for all other archs:
       *) export ARCH=$( uname -m ) ;;
  esac
fi

case "$ARCH" in
  i486)      SLKCFLAGS="-O2 -march=i486 -mtune=i686"
             SLKLDFLAGS=""; LIBDIRSUFFIX=""
             ;;
  s390)      SLKCFLAGS="-O2"
             SLKLDFLAGS=""; LIBDIRSUFFIX=""
             ;;
  x86_64)    SLKCFLAGS="-O2 -fPIC"
             SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64"
             ;;
  *)         SLKCFLAGS="-O2"
             SLKLDFLAGS=""; LIBDIRSUFFIX=""
             ;;
esac

# -----------------------------------------------------------------------------

# -- PATENT ALERT! --
# FFmpeg can be built with MP3 (lame) audio encoder (needed for FLV videos)
# but this library is 'contaminated' with patents from Fraunhofer and GGP.
# Also, the AAC encoder has patent issues.
# You can build these patended algorithms into ffmpeg, and if you are an
# ordinary end user, no one will bother you for using them.
# For the binaries based on this SlackBuild that I distribute, it is a
# different story. I am not allowed to distribute binary packages that
# incorporate patented code. So here you go. My Slackware package was built
# with "USE_PATENTS=NO" i.e. without using the lame mp3 libary and without the
# aac libraries.
#USE_PATENTS="NO"
USE_PATENTS=${USE_PATENTS:-"YES"}

# If you set REQUIRE_YASM to "NO" then the script won't refuse to build
#   VLC in case you don't have yasm installed (it is needed to
#   build x264 newer than the 20080301 snapshot). In this case, the script will
#   automatically 'downgrade' x264 to the 20080301-2245 snapshot.
REQUIRE_YASM=${REQUIRE_YASM:-"YES"}

# VLC uses Qt4 for it's GUI.
# Slackware 13.0 already has Qt4 installed, this will speed up
# the compilation a lot, and create a smaller vlc package.
# In that case, define STATIC_QT4="NO" to use the system version of Qt4.
# If you want an all-in package (including static version of Qt4), then
# define STATIC_QT4="YES":
STATIC_QT4=${STATIC_QT4:-"NO"}

# VLC uses ffmpeg's avcodec for a lot of the AV processing.
# If you already have ffmpeg installed, it will speed up the compilation a lot,
# and create a smaller vlc package, if you define STATIC_FFMPEG="NO":
# Note: I _strongly_ suggest you compile ffmpeg statically!
STATIC_FFMPEG=${STATIC_FFMPEG:-"YES"}

# By default do not build the Mozilla plugin (Slackware's seamonkey post-13.0
# no longer supports building this).
# You can enable building the Mozilla plugin by defining MOZPLUGIN="YES":
MOZPLUGIN=${MOZPLUGIN:-"NO"}

# -----------------------------------------------------------------------------
# We're done with the initials. Let's move on:
# -----------------------------------------------------------------------------

# The script needs the seamonkey SDK in order to build a mozilla plugin.
# If no version of Seamonkey is found, no plugin will be compiled:
if [ "$MOZPLUGIN" == "NO" ]; then
  DO_MOZPLUGIN=""
else
  SEAMONKEY=$( readlink /usr/lib${LIBDIRSUFFIX}/seamonkey )
  [ -n "${SEAMONKEY}" ] && MOZBROWSER=$(basename ${SEAMONKEY}) || MOZBROWSER=""
  if [ -z "$MOZBROWSER" ]; then
    MOZPLUGIN="NO"
    DO_MOZPLUGIN=""
  else
    MOZPLUGIN="YES"
    DO_MOZPLUGIN="--enable-mozilla"
  fi
fi

# Dependent package versions
A52=0.7.4
AMR=0.1.2
ASS=0.9.9
AVC1394=0.5.3
CDDB=1.3.2
CDIO=0.81
DAAP=0.4.0
DC1394=2.1.2
DCA=0.0.5
DV=1.0.0
DVBPSI=0.1.6
DVDNAV=4.1.3
DVDREAD=4.1.3
DVDCSS=1.2.10
EBML=0.7.8
FAAC=1.28
FAAD2=2.7
FFMPEG=r22900   # 20100417
#FFMPEG=0.5
FLUID=1.1.0
GGI=2.2.2
GII=1.0.2
GOOM=2k4-0
KATE=0.3.7
LAME=3.98.4
LIVE=latest
LUA=5.1.4
MATROSKA=0.8.1
MPCDEC=1.2.6
MPEG2DEC=0.5.1
OIL=0.3.16
QT4=4.4.3
RAW1394=2.0.3
SCHROEDINGER=1.0.8
SHOUT=2.2.2
SPEEX=1.2rc1
THEORA=1.1.1
TIGER=0.3.3
TWOLAME=0.3.12
UPNP=1.6.6
V4L=0.6.4
VCD=0.7.23
X264_SAFE=20080301-2245 # In later versions nasm complains
                        # about 'function hidden'
X264=20100421-2245      # Needs yasm installed

# Determine what X we're running (the modular X returns the prefix
# in the next command, while older versions stay silent):
XPREF=$(pkg-config --variable=prefix x11) || true
[ "$XPREF" == "" ] && XPREF='/usr/X11R6'

# Where do we look for sources?
SRCDIR=$(cd $(dirname $0); pwd)

# Place to build (TMP) package (PKG) and output (OUTPUT) the program:
TMP=${TMP:-"/tmp/build"}
PKG=$TMP/package-$PRGNAM
PKG2=$TMP/package-$PRGNAM-$PRGNAM2
OUTPUT=${OUTPUT:-"/tmp"}

# Check for yasm, use older x264 snapshot if not found:
if ! which yasm >/dev/null 2>&1 ; then
  echo "##"
  echo "## The 'yasm' program does not seem to be installed."
  echo "## The X264 codec compilation needs yasm (nasm will not do)"
  if [ "$REQUIRE_YASM" != "YES" ]; then 
    X264=$X264_SAFE
    echo "## Continuing the build anyway, but will use an older X264 ($X264)..."
    echo "##"
  else
    echo "## Aborting the build - set the internal script variable:"
    echo "##   REQUIRE_YASM to 'NO' if you don't have yasm installed,"
    echo "##   and want to fall back to an old (hopefully still useable)"
    echo "##   version of X264 that builds with nasm instead."
    echo "##"
    exit 1
  fi
fi

# ---------------------------------------------------------------------------
# Source tarballs and source URLs.
# Sources which are not patented should have SRCPAT[n]="NO"
# Sources which are patented should have SRCPAT[n]="YES" which prevents then
#   from being downloaded and used if we build a patent-free package.
# ---------------------------------------------------------------------------

# VLC source
if [ "$VERSION" == "HEAD"  ]; then
  # We check out git's HEAD:
  SRCVER=$(date +%Y%m%d)
  VERSION=${SRCVER}
  SRCURL[0]=""
  #SRCURL[0]="http://nightlies.videolan.org/build/source/latest/vlc-snapshot-${SRCVER}.tar.bz2"
else
  SRCURL[0]="http://download.videolan.org/pub/videolan/${PRGNAM}/${SRCVER}/${PRGNAM}-${SRCVER}.tar.bz2"
fi
SOURCE[0]="$SRCDIR/${PRGNAM}-${SRCVER}.tar.bz2"
SRCPAT[0]="NO"
USE[0]="YES"

# ffmpeg libraries
SOURCE[1]="$SRCDIR/ffmpeg-${FFMPEG}.tar.bz2"
#SRCURL[1]="http://ffmpeg.mplayerhq.hu/ffmpeg-export-snapshot.tar.bz2"
#SRCURL[1]="http://ffmpeg.mplayerhq.hu/releases/ffmpeg-${FFMPEG}.tar.bz2"
SRCURL[1]=""
SRCPAT[1]="NO"
USE[1]="YES"

# AMR de/encoder libraries used in ffmpeg to encode 3GPP audio
SOURCE[2]="$SRCDIR/opencore-amr-${AMR}.tar.gz"
SRCURL[2]="http://downloads.sourceforge.net/opencore-amr/opencore-amr-${AMR}.tar.gz"
SRCPAT[2]="NO"
USE[2]="YES"

# Kate - a karaoke/text stream overlay codec
SOURCE[3]="$SRCDIR/libkate-${KATE}.tar.gz"
SRCURL[3]="http://libkate.googlecode.com/files/libkate-${KATE}.tar.gz"
SRCPAT[3]="NO"
USE[3]="YES"

# Libtiger - A rendering library for Kate streams using Pango and Cairo
SOURCE[4]="$SRCDIR/libtiger-${TIGER}.tar.gz"
SRCURL[4]="http://libtiger.googlecode.com/files/libtiger-${TIGER}.tar.gz"
SRCPAT[4]="NO"
USE[4]="YES"

# Lua - embedded interpreter for lua playlist, metafetcher and interface plugins
SOURCE[5]="$SRCDIR/lua-${LUA}.tar.gz"
SRCURL[5]="http://www.lua.org/ftp/lua-${LUA}.tar.gz"
SRCPAT[5]="NO"
USE[5]="YES"

# Lame is used for the audio in FLV videos; will statically link with ffmpeg
SOURCE[6]="$SRCDIR/lame-$LAME.tar.gz"
SRCURL[6]="http://downloads.sourceforge.net/lame/lame-$LAME.tar.gz"
SRCPAT[6]="YES"
USE[6]="YES"

SOURCE[7]="$SRCDIR/libdv-${DV}.tar.gz"
SRCURL[7]="http://downloads.sourceforge.net/libdv/libdv-${DV}.tar.gz"
SRCPAT[7]="NO"
USE[7]="YES"

# FAAC library, will be statically linked with ffmpeg
SOURCE[8]="$SRCDIR/faac-$FAAC.tar.gz"
SRCURL[8]="http://downloads.sourceforge.net/faac/faac-$FAAC.tar.gz"
SRCPAT[8]="YES"
USE[8]="YES"

# Qt4 is used for the GUI - VLC will link statically against it
SOURCE[9]="$SRCDIR/qt-x11-opensource-src-$QT4.tar.gz"
SRCURL[9]="http://wftp.tu-chemnitz.de/pub/Qt/qt/source/qt-x11-opensource-src-${QT4}.tar.gz"
SRCPAT[9]="NO"
USE[9]="NO"

# FAAD2 support:
SOURCE[10]="$SRCDIR/faad2-$FAAD2.tar.gz"
SRCURL[10]="http://downloads.sourceforge.net/faac/faad2-$FAAD2.tar.gz"
SRCPAT[10]="NO"
USE[10]="YES"

# Matroska support:
SOURCE[11]="$SRCDIR/libebml-$EBML.tar.bz2"
SRCURL[11]="http://dl.matroska.org/downloads/libebml/libebml-$EBML.tar.bz2"
SRCPAT[11]="NO"
USE[11]="YES"

SOURCE[12]="$SRCDIR/libmatroska-$MATROSKA.tar.bz2"
SRCURL[12]="http://dl.matroska.org/downloads/libmatroska/libmatroska-$MATROSKA.tar.bz2"
SRCPAT[12]="NO"
USE[12]="YES"

# libmpeg2
SOURCE[13]="$SRCDIR/libmpeg2-$MPEG2DEC.tar.gz"
SRCURL[13]="http://libmpeg2.sourceforge.net/files/libmpeg2-$MPEG2DEC.tar.gz"
SRCPAT[13]="NO"
USE[13]="YES"

# DVD support:
SOURCE[14]="$SRCDIR/libdvdnav-$DVDNAV.tar.bz2"
SRCURL[14]="http://www1.mplayerhq.hu/MPlayer/releases/dvdnav/libdvdnav-${DVDNAV}.tar.bz2"
#SRCURL[14]=""
SRCPAT[14]="NO"
USE[14]="YES"

SOURCE[15]="$SRCDIR/libdvdread-${DVDREAD}.tar.bz2"
SRCURL[15]="http://www1.mplayerhq.hu/MPlayer/releases/dvdnav/libdvdread-${DVDREAD}.tar.bz2"
#SRCURL[15]=""
SRCPAT[15]="NO"
USE[15]="YES"

# CD media read/access support (including iso/cue/nrg formats):
SOURCE[16]="$SRCDIR/libcdio-${CDIO}.tar.gz"
SRCURL[16]="http://ftp.gnu.org/gnu/libcdio/libcdio-$CDIO.tar.gz"
SRCPAT[16]="NO"
USE[16]="YES"

# Since www.vcdimager.org is down, we use a GNU videolan mirror:
SOURCE[17]="$SRCDIR/vcdimager-${VCD}.tar.gz"
SRCURL[17]="http://ftp.gnu.org/gnu/vcdimager/vcdimager-$VCD.tar.gz"
SRCPAT[17]="NO"
USE[17]="YES"

# MP2 audio (de)coding support:
SOURCE[18]="$SRCDIR/twolame-${TWOLAME}.tar.gz"
SRCURL[18]="http://downloads.sourceforge.net/twolame/twolame-$TWOLAME.tar.gz"
SRCPAT[18]="NO"
USE[18]="YES"

# Musepack (MPC) audio demuxing support:
SOURCE[19]="$SRCDIR/libmpcdec-${MPCDEC}.tar.bz2"
SRCURL[19]="http://files.musepack.net/source/libmpcdec-${MPCDEC}.tar.bz2"
SRCPAT[19]="NO"
USE[19]="YES"

# Liboil is a dependency for schroedinger
SOURCE[20]="$SRCDIR/liboil-${OIL}.tar.gz"
SRCURL[20]="http://liboil.freedesktop.org/download/liboil-${OIL}.tar.gz"
SRCPAT[20]="NO"
USE[20]="YES"

# Dirac video codec support by schroedinger:
SOURCE[21]="$SRCDIR/schroedinger-${SCHROEDINGER}.tar.gz"
SRCURL[21]="http://www.diracvideo.org/download/schroedinger/schroedinger-${SCHROEDINGER}.tar.gz"
SRCPAT[21]="NO"
USE[21]="YES"

# CDDB lookups:
SOURCE[22]="$SRCDIR/libcddb-${CDDB}.tar.bz2"
SRCURL[22]="http://downloads.sourceforge.net/libcddb/libcddb-${CDDB}.tar.bz2"
SRCPAT[22]="NO"
USE[22]="YES"

# Act as a source client to Icecast/Shoutcast:
SOURCE[23]="$SRCDIR/libshout-${SHOUT}.tar.gz"
SRCURL[23]="http://downloads.us.xiph.org/releases/libshout/libshout-${SHOUT}.tar.gz"
SRCPAT[23]="NO"
USE[23]="YES"

# SPEEX is used by libshout and vlc:
SOURCE[24]="$SRCDIR/speex-${SPEEX}.tar.gz"
SRCURL[24]="http://downloads.us.xiph.org/releases/speex/speex-${SPEEX}.tar.gz"
SRCPAT[24]="NO"
USE[24]="YES"

# Goom, a visualisation library for audio player
SOURCE[25]="$SRCDIR/goom-${GOOM}-src.tar.gz"
SRCURL[25]="http://downloads.sourceforge.net/goom/goom-${GOOM}-src.tar.gz"
SRCPAT[25]="NO"
USE[25]="YES"

# GGI, output plugin
SOURCE[26]="$SRCDIR/ggi-${GGI}-bundle.src.tar.bz2"
SRCURL[26]="http://www.ggi-project.org/ftp/ggi/v2.2/ggi-${GGI}-bundle.src.tar.bz2"
SRCPAT[26]="NO"
USE[26]="YES"

# X264 encoder - for H264/AVC video streams
SOURCE[27]="$SRCDIR/x264-snapshot-${X264}.tar.bz2"
SRCURL[27]="ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-${X264}.tar.bz2"
SRCPAT[27]="NO"
USE[27]="YES"

# The A52 decoder - aka AC3
SOURCE[28]="$SRCDIR/a52dec-$A52.tar.gz"
SRCURL[28]="http://liba52.sourceforge.net/files/a52dec-$A52.tar.gz"
SRCPAT[28]="NO"
USE[28]="YES"

# Live555 support:
SOURCE[29]="$SRCDIR/live555-${LIVE}.tar.gz"
SRCURL[29]="http://www.live555.com/liveMedia/public/live555-${LIVE}.tar.gz"
SRCPAT[29]="NO"
USE[29]="YES"

# Library needed to control IEEE 1394 (firewire-) based cameras
SOURCE[30]="$SRCDIR/libraw1394-${RAW1394}.tar.gz"
SRCURL[30]="http://downloads.sourceforge.net/libraw1394/libraw1394-${RAW1394}.tar.gz"
SRCPAT[30]="NO"
USE[30]="YES"

SOURCE[31]="$SRCDIR/libdc1394-${DC1394}.tar.gz"
SRCURL[31]="http://downloads.sourceforge.net/libdc1394/libdc1394-${DC1394}.tar.gz"
SRCPAT[31]="NO"
USE[31]="YES"

SOURCE[32]="$SRCDIR/libavc1394-${AVC1394}.tar.gz"
SRCURL[32]="http://downloads.sourceforge.net/libavc1394/libavc1394-${AVC1394}.tar.gz"
SRCPAT[32]="NO"
USE[32]="YES"

# Library designed for decoding and generation of MPEG TS and DVB PSI tables.
SOURCE[33]="$SRCDIR/libdvbpsi5-${DVBPSI}.tar.bz2"
SRCURL[33]="http://download.videolan.org/pub/libdvbpsi/${DVBPSI}/libdvbpsi5-${DVBPSI}.tar.bz2"
SRCPAT[33]="NO"
USE[33]="YES"

# a free DTS Coherent Acoustics decoder
SOURCE[34]="$SRCDIR/libdca-${DCA}.tar.bz2"
SRCURL[34]="http://download.videolan.org/pub/videolan/libdca/${DCA}/libdca-${DCA}.tar.bz2"
SRCPAT[34]="NO"
USE[34]="YES"

# Theora encoder/decoder libraries
SOURCE[35]="$SRCDIR/libtheora-${THEORA}.tar.gz"
SRCURL[35]="http://downloads.xiph.org/releases/theora/libtheora-${THEORA}.tar.gz"
SRCPAT[35]="NO"
USE[35]="YES"

# Universal Plug'n'Play
SOURCE[36]="$SRCDIR/libupnp-${UPNP}.tar.bz2"
SRCURL[36]="http://downloads.sourceforge.net/pupnp/libupnp-${UPNP}.tar.bz2"
SRCPAT[36]="NO"
USE[36]="YES"

# DAAP support (iTunes)
SOURCE[37]="$SRCDIR/libopendaap-${DAAP}.tar.bz2"
# This one seems not the right daap lib...:
#SRCURL[37]="http://downloads.sourceforge.net/daap/libopenndaap-${DAAP}.tar.bz2"
SRCURL[37]="http://crazney.net/programs/itunes/files/libopendaap-${DAAP}.tar.bz2"
SRCPAT[37]="NO"
USE[37]="YES"

# Libass - portable library for SSA/ASS subtitles rendering
SOURCE[38]="$SRCDIR/libass-$ASS.tar.bz2"
SRCURL[38]="http://downloads.sourceforge.net/libass/libass-$ASS.tar.bz2"
SRCPAT[38]="NO"
USE[38]="YES"

# FluidSynth - midi playback
SOURCE[39]="$SRCDIR/fluidsynth-${FLUID}.tar.gz"
SRCURL[39]="http://download.savannah.gnu.org/releases/fluid/fluidsynth-${FLUID}.tar.gz"
SRCPAT[39]="NO"
USE[39]="YES"

# libv4l: Collection of video4linux support libraries
SOURCE[40]="$SRCDIR/libv4l-${V4L}.tar.gz"
SRCURL[40]="http://people.fedoraproject.org/~jwrdegoede/libv4l-${V4L}.tar.gz"
SRCPAT[40]="NO"
USE[40]="YES"

# CSS decoding- VLC can do without if you install an external libdvdcss package.
#SOURCE[XX]="$SRCDIR/libdvdcss-${DVDCSS}.tar.bz2"
#SRCURL[XX]="http://download.videolan.org/pub/libdvdcss/${DVDCSS}/libdvdcss-${DVDCSS}.tar.bz2"
#SRCPAT[XX]="YES"
#USE[XX]="YES"

# Use the src_checkout() function if no downloadable tarball exists.
# This function checks out sources from SVN/CVS and creates a tarball of them.
src_checkout() {
  # Param #1 : index in the SOURCE[] array.
  # Param #2 : full path to where SOURCE[$1] tarball should be created.
  # Determine the tarball extension:
  PEXT=$(echo "${2}" | sed -r -e 's/.*[^.].(tar.xz|tar.gz|tar.bz2|tgz).*/\1/')
  case "$PEXT" in
    "tar.xz") TARCOMP="J" ;;
    "tar.gz") TARCOMP="z" ;;
    "tgz") TARCOMP="z" ;;
    "tar.bz2") TARCOMP="j" ;;
    *) echo "Archive can only have extension 'tar.xz', '.tar.gz' '.tar.bz2' or '.tgz'" ; exit 1 ;;
  esac
  case ${1} in
  0) # vlc-$SRCVER
     mkdir vlc_temp_checkout_$$ \
       && cd vlc_temp_checkout_$$ \
       && git clone --depth=1 git://git.videolan.org/vlc.git vlc-${SRCVER} \
       && chown -R root:root . \
       && tar --exclude .git -${TARCOMP}cf ${2} vlc-${SRCVER}
     cd ..
     rm -rf vlc_temp_checkout_$$
     ;;
  1) # ffmpeg-$FFMPEG
     if [ "$(echo ${FFMPEG}|cut -c1)" == 'r' ]; then # revision instead of date
       REV=$(echo ${FFMPEG} | cut -c2-)
     else
       REV="{${FFMPEG}}"
     fi
     mkdir ffmpeg-${FFMPEG} \
       && cd ffmpeg-${FFMPEG} \
       && svn checkout --revision $REV svn://svn.mplayerhq.hu/ffmpeg/trunk . \
       && find . -type d -name '.svn' -depth | xargs rm -rf \
       && chown -R root:root . \
       && cd .. \
       && tar -${TARCOMP}cf ${2} ffmpeg-${FFMPEG}
     rm -rf ffmpeg-${FFMPEG}
     ;;
 14) # libdvdnav-$DVDNAV
     if [ "$(echo ${DVDNAV}|cut -c1)" == 'r' ]; then # revision instead of date
       REV=$(echo ${DVDNAV} | cut -c2-)
     else
       REV="{${DVDNAV}}"
     fi
     mkdir libdvdnav-${DVDNAV} \
       && cd libdvdnav-${DVDNAV} \
       && svn checkout --revision $REV svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdnav . \
       && find . -type d -name '.svn' -depth | xargs rm -rf \
       && chown -R root:root . \
       && cd .. \
       && tar -${TARCOMP}cf ${2} libdvdnav-${DVDNAV}
     rm -rf libdvdnav-${DVDNAV}
     ;;
 15) # libdvdread-$DVDREAD
     if [ "$(echo ${DVDREAD}|cut -c1)" == 'r' ]; then # revision instead of date
       REV=$(echo ${DVDREAD} | cut -c2-)
     else
       REV="{${DVDREAD}}"
     fi
     mkdir libdvdread-${DVDREAD} \
       && cd libdvdread-${DVDREAD} \
       && svn checkout --revision $REV svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdread . \
       && find . -type d -name '.svn' -depth | xargs rm -rf \
       && chown -R root:root . \
       && cd .. \
       && tar -${TARCOMP}cf ${2} libdvdread-${DVDREAD}
     rm -rf libdvdread-${DVDREAD}
     ;;
  *) # Do nothing
     ;;
  esac
}

if [ "${USE_PATENTS}" == "YES" ]; then
  echo ""
  echo "**"
  echo "** This build uses patented code (MP3 / AMR / AAC encoders)"
  echo "** Run the command 'USE_PATENTS=NO $0 $*' to avoid patent issues."
  echo "**"
  echo ""
  sleep 1
fi

##
## --- with a little luck, you won't have to edit below this point --- ##
##

# Exit the script on errors:
set -e
trap 'echo "$0 FAILED at line $LINENO!" | tee $OUTPUT/error-${PRGNAM}.log' ERR
# Catch unitialized variables:
set -u
P1=${1:-1}

# Create working directories:
mkdir -p $TMP/tmp-$PRGNAM # location to build the source
mkdir -p $PKG             # place for the package to be built
rm -rf $PKG/*             # We always erase old package's contents:
mkdir -p $OUTPUT          # place for the package to be saved

if [ "$P1" != "--oldbuild" -a  "$P1" != "--download" ]; then
  # If the "--oldbuild" parameter is present, we keep
  #  the old build files and continue;
  # By default we remove the remnants of previous build and continue:
  echo -e "**\n**  Cleaning up old build ...\n**"
  rm -rf $TMP/tmp-$PRGNAM/*
  rm -f $OUTPUT/*${PRGNAM}*.log   # Delete old logfiles
fi

# We may not need to download and unpack the Qt4 sources:
if [ "$STATIC_QT4" != "NO" ]; then
  echo "**"
  echo "** Building with a static QT4..."
  echo "**"
  USE[9]="YES"
fi

# We may not need to download and unpack the ffmpeg sources:
if [ "$STATIC_FFMPEG" != "YES" ]; then
  echo "**"
  echo "** Not building static FFMPEG plus dependencies..."
  echo "**"
  USE[1]="NO" # ffmpeg
  USE[2]="NO" # opencore-amr
  USE[6]="NO" # lame
  USE[8]="NO" # faac
  USE[35]="NO" # theora
fi

# Source file availability:
for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do
  # Do we actually use this source?
  [ "${USE[$i]}" = "YES" ] || continue
  # Only download patented code if we are allowing it:
  if [ "${USE_PATENTS}" == "YES" -o "${SRCPAT[$i]}" != "YES" ]; then
    if ! [ -f ${SOURCE[$i]} ]; then
      echo "Source '$(basename ${SOURCE[$i]})' not available yet..."
      # Check if the $SRCDIR is writable at all - if not, download to $OUTPUT
      [ -w "$SRCDIR" ] || SOURCE[$i]="$OUTPUT/$(basename ${SOURCE[$i]})"
      if ! [ "x${SRCURL[$i]}" == "x" ]; then
        echo "Will download file to $(dirname $SOURCE[$i])"
        if ! $(wget -nv -T 20 -O "${SOURCE[$i]}" "${SRCURL[$i]}"); then
          echo "Downloading '$(basename ${SOURCE[$i]})' failed.. aborting the build."
          mv -f "${SOURCE[$i]}" "${SOURCE[$i]}".FAIL
          exit 1
        fi
      else
        # Try if we have a SVN/CVS download routine for ${SOURCE[$i]}
        echo "Will checkout sources to $(dirname $SOURCE[$i])"
        src_checkout $i "${SOURCE[$i]}" 2>&1 > $OUTPUT/checkout-$(basename ${SOURCE[$i]}).log
      fi
      if [ ! -f "${SOURCE[$i]}" -o ! -s "${SOURCE[$i]}" ]; then
        echo "File '$(basename ${SOURCE[$i]})' not available.. aborting the build."
        exit 1
      fi
    fi
  fi
done

if [ "$P1" == "--download" ]; then
  echo "Download complete."
  exit 0
fi

# Package building:
echo "++"
echo "|| $PRGNAM-$VERSION"
echo "++"

cd $TMP/tmp-$PRGNAM
if [ "$P1" != "--oldbuild" ]; then
  echo "Extracting the source archive(s) for $PRGNAM..."
  for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do
    # Do we actually use this source?
    [ "${USE[$i]}" = "YES" ] || continue
    # Only extract and use patented code if we are allowing it:
    if [ "${USE_PATENTS}" == "YES" -o "${SRCPAT[$i]}" != "YES" ]; then
      if $(file ${SOURCE[$i]} | grep -q ": bzip2"); then
        tar -xjvf ${SOURCE[$i]}
      elif $(file ${SOURCE[$i]} | grep -q ": gzip"); then
        tar -xzvf ${SOURCE[$i]}
      elif $(file ${SOURCE[$i]} | grep -iq ": zip"); then
        unzip ${SOURCE[$i]}
      fi
    fi
  done
  chown -R root:root *
  chmod -R u+w,go+r-w,a-s *
fi

# Building the source code:
echo Building ...

# We will be installing static libs into the following directory:
mkdir -p $TMP/tmp-$PRGNAM/vlcdeps/usr/{bin,doc,include,lib,man}
VLCDEPSDIR="$TMP/tmp-$PRGNAM/vlcdeps"

# -----------------------------------------------------------------------------
# Compile theora libraries
# The ffmpeg will use these
# -----------------------------------------------------------------------------
make_theora()
{
echo -e "**\n**  theora ...\n**"
cd $TMP/tmp-$PRGNAM/libtheora-${THEORA}
# Hope this is temporary - add a forgotten file for 1.0beta3:
if [ ! -f doc/spec/ltablex.sty -a -f $SRCDIR/ltablex.sty ]; then
  echo "Adding missing 'ltablex.sty'..."
  cp $SRCDIR/ltablex.sty ./doc/spec/
fi
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --disable-examples \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_theora.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_theora.log
# Install theora into a temp location so ffmpeg can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_theora.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libtheora/
cp AUTHORS CHANGES COPYING LICENSE README \
  $VLCDEPSDIR/doc/libtheora/ || true
cd -
}

# -----------------------------------------------------------------------------
# Compile lame libraries
# The ffmpeg will use these
# -----------------------------------------------------------------------------
make_lame()
{
echo -e "**\n**  lame ...\n**"
cd $TMP/tmp-$PRGNAM/lame-${LAME}
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_lame.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_lame.log
# Install lame into a temp location so ffmpeg can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_lame.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/lame/
cp API COPYING ChangeLog* DEFINES HACKING LICENSE README* STYLEGUIDE TODO \
  $VLCDEPSDIR/doc/lame/ || true
cd -
}

# -----------------------------------------------------------------------------
# Compile faac library
# The ffmpeg will use these
# -----------------------------------------------------------------------------
make_faac()
{
echo -e "**\n**  faac ...\n**"
cd $TMP/tmp-$PRGNAM/faac-$FAAC
#sh bootstrap
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --with-mp4v2 \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_faac.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_faac.log
# Install faac into a temp location so ffmpeg can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_faac.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/faac/
cp AUTHORS COPYING ChangeLog NEWS README TODO \
  $VLCDEPSDIR/doc/faac/ || true
cd -
}

# -----------------------------------------------------------------------------
# Compile amr wideband/narrowband library
# The ffmpeg will use these
# -----------------------------------------------------------------------------
make_amr()
{
echo -e "**\n**  amr ...\n**"
cd $TMP/tmp-$PRGNAM/opencore-amr-${AMR}
LDFLAGS="$SLKLDFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=$VLCDEPSDIR/usr \
  --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
  --disable-shared \
  --program-prefix= \
  --program-suffix= \
  --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_amr.log
make $NUMJOBS 2>&1 | tee $OUTPUT/make-${PRGNAM}_amr.log
make install PREFIX=/usr LIBDIR=/usr/lib${LIBDIRSUFFIX} \
  2>&1 | tee -a $OUTPUT/make-${PRGNAM}_amr.log
# Add DOCS to the vlcdeps to have it added to ffmpeg package later:          
mkdir -p $VLCDEPSDIR/doc/amr
cp -a AUTHORS COPYING ChangeLog LICENSE NEWS README \
  $VLCDEPSDIR/doc/amr || true
cd -
}


# -----------------------------------------------------------------------------
# Compile ffmpeg with support for AMR, LAME, XVID, FAAC
# Later, we will statically link VLC to the generated libavcodec libraries
# -----------------------------------------------------------------------------
make_ffmpeg()
{
echo -e "**\n**  ffmpeg ...\n**"
OLDDIR=$(pwd)
cd $TMP/tmp-$PRGNAM
# Take care of snaphot directory:
if [ -d ffmpeg-export-* ]; then
  rm -rf ffmpeg-${FFMPEG}
  mv ffmpeg-export-* ffmpeg-${FFMPEG}
fi

# Only use patented code if we are allowing it:
if [ "${USE_PATENTS}" == "YES" ]; then
  USE_PATENTED="--enable-libmp3lame --enable-libfaac --enable-nonfree"
else
  USE_PATENTED=" "
fi

cd $TMP/tmp-$PRGNAM/ffmpeg-${FFMPEG}

if [ "$ARCH" = "x86_64" ]; then
  # Prefer a specific versioned patch over the version-less patch:
  if [ -f $SRCDIR/ffmpeg-${FFMPEG}_x86_64_asm.patch ]; then
    FFMPEGASM=ffmpeg-${FFMPEG}_x86_64_asm
  else
    FFMPEGASM=ffmpeg_x86_64_asm
  fi
  # Assembler patch fixes vlc's swscale plugin as well as enables MMX/SSE:
  cat $SRCDIR/${FFMPEGASM}.patch | patch -p1 --verbose \
    2>&1 | tee $OUTPUT/patch-${PRGNAM}_ffmpeg.log
  ARCHOPTS="--arch=x86_64 --enable-pic"
else
  ARCHOPTS=""
fi

# Stamp the version into the source:
[ -f version.sh ] && sed -i -e "s/UNKNOWN/$FFMPEG/" version.sh

TMPDIR="$TMP" \
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
PKG_CONFIG_PATH="${VLCDEPSDIR}/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --shlibdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            ${USE_PATENTED} \
            --enable-gpl \
            --enable-version3 \
            --enable-libopencore-amrnb \
            --enable-libopencore-amrwb \
            --enable-libtheora \
            --enable-avfilter \
            --enable-postproc \
            --enable-pthreads \
            --disable-ffserver \
            --disable-ffplay \
            --disable-ffmpeg \
            --enable-hardcoded-tables \
            --enable-fastdiv \
            --disable-debug \
            --disable-shared \
            --enable-static \
            --enable-memalign-hack \
            --enable-bzlib \
            --enable-zlib \
            --disable-vdpau \
            $ARCHOPTS \
            --extra-cflags="-I${VLCDEPSDIR}/usr/include -DRUNTIME_CPUDETECT" \
            --extra-ldflags="-L${VLCDEPSDIR}/usr/lib${LIBDIRSUFFIX}" \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_ffmpeg.log

            # Do not add '-fPIC -DPIC' to extra-cflags or "can't find
            # a register in class 'GENERAL_REGS' while reloading 'asm'" occurs
            # --enable-libogg \ Newer ffmpeg no longer need this.
            # --enable-libxvid \ generates vlc linker errors, so we use ffmpeg's
            #   native xvid encoder implementation instead
            #--enable-libvorbis \  # Use ffmpeg's native support
            #--disable-vhook \
            #--disable-devices \
            #--disable-protocols \
            #--logfile=$OUTPUT/ffmpeg.conf.log \

make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_ffmpeg.log
[ $? -ne 0 ] && return 1

# Install ffmpeg into a temp location so vlc can pickup the libraries
make install-libs install-headers \
  2>&1 | tee -a $OUTPUT/make-${PRGNAM}_ffmpeg.log

# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/ffmpeg/
cp COPYING* CREDITS Changelog MAINTAINERS README \
  $VLCDEPSDIR/doc/ffmpeg/ || true

cd $OLDDIR
}

# -----------------------------------------------------------------------------
# Next, compile Qt4
# We will link VLC statically to the generated libraries
# -----------------------------------------------------------------------------
make_qt4()
{
echo -e "**\n**  Qt4 ...\n**"
cd $TMP/tmp-$PRGNAM/qt-x11-opensource-src-${QT4}

export CFLAGS="$SLKCFLAGS"
export CXXFLAGS="$SLKCFLAGS"
export OPENSOURCE_CXXFLAGS="$SLKCFLAGS"
export LDFLAGS="$SLKLDFLAGS"
echo "yes" | \
./configure -prefix $VLCDEPSDIR/usr \
            -qt-gif \
            -release \
            -static \
            -fast \
            -no-qt3support \
            -no-exceptions \
            -system-libpng \
            -system-libjpeg \
            -system-zlib \
            -nomake examples \
            -nomake demos \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_qt4.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_qt4.log || exit 1
# With the above prefix we can install without INSTALL_ROOT; we need this
# so the Qt4 binaries will be picked up by vlc's configure script:
#make install INSTALL_ROOT=$VLCDEPSDIR \
make install \
  2>&1 | tee $OUTPUT/install-${PRGNAM}_qt4.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/qt4/
cp GPL* LICENSE* OPENSOURCE-NOTICE.TXT README \
  $VLCDEPSDIR/doc/qt4/ || true
cd -
}

# -----------------------------------------------------------------------------
# ADDITIONAL CODECS AND INPUT LIBRARIES FOR VLC
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Compile faad2
# -----------------------------------------------------------------------------
make_faad2()
{
echo -e "**\n**  faad2 ...\n**"
cd $TMP/tmp-$PRGNAM/faad2-$FAAD2
#autoreconf -vif
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --without-xmms \
            --enable-static \
            --disable-shared \
            --program-prefix="" \
            --program-suffix="" \
            --build=$ARCH-slackware-linux \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_faad2.log
            # No longer available:
            #--with-mp4v2 \
            # Gives errors "faad bitstream value not allowed by specification":
            #--with-drm \
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_faad2.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/faad2/
cp AUTHORS COPYING ChangeLog README* TODO \
  $VLCDEPSDIR/doc/faad2/ || true
cd -
}

# -----------------------------------------------------------------------------
# Compile a52 libraries
# -----------------------------------------------------------------------------
make_a52()
{
echo -e "**\n**  a52 ...\n**"
cd $TMP/tmp-$PRGNAM/a52dec-${A52}
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --program-prefix="" \
            --program-suffix="" \
            --build=$ARCH-slackware-linux \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_a52.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_a52.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/a52dec/
cp AUTHORS COPYING ChangeLog HISTORY INSTALL NEWS README TODO \
  $VLCDEPSDIR/doc/a52dec/ || true
cd -
}

# -----------------------------------------------------------------------------
# Compile live555
# -----------------------------------------------------------------------------
make_live555()
{
echo -e "**\n**  live555 ...\n**"
cd $TMP/tmp-$PRGNAM/live
# Force the use of our CFLAGS
sed -i -e "s|-O2|${SLKCFLAGS}|g" config.linux
# Live555 is not useable with vlc unless linked statically.
# We need this patch for the tarballs around end september 2009:
if ! $(grep -q Bstatic config.linux) ; then
  sed -i -e 's/\(LIBRARY_LINK =\).*/\1 $(LD) -o/g' \
         -e 's/\(LIBRARY_LINK_OPTS =\).*/\1 $(LINK_OPTS) -r -Bstatic/g' \
         config.linux
fi
./genMakefiles linux 2>&1 | tee $OUTPUT/configure-${PRGNAM}_live.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_live.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/live555/
cp COPYING README \
  $VLCDEPSDIR/doc/live555/ || true
cd -
}

# -----------------------------------------------------------------------------
# Compile ebml
# -----------------------------------------------------------------------------
make_ebml()
{
echo -e "**\n**  ebml ...\n**"
OLDDIR=$(pwd)
cd $TMP/tmp-$PRGNAM/libebml-$EBML/make/linux
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
make -j${NUMJOBS} staticlib prefix=/usr \
  2>&1 | tee $OUTPUT/make-${PRGNAM}_ebml.log
# Install into a temp directory where vlc & matroska can pick it up:
make install_staticlib install_headers \
  prefix=$VLCDEPSDIR/usr \
  includedir=$VLCDEPSDIR/usr/include/ebml \
  libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
  2>&1 | tee -a $OUTPUT/make-${PRGNAM}_ebml.log
cd $TMP/tmp-$PRGNAM/libebml-$EBML
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libebml/
cp ChangeLog LICENSE.LGPL \
  $VLCDEPSDIR/doc/libebml/ || true
cd $OLDDIR
}

# -----------------------------------------------------------------------------
# Compile matroska
# -----------------------------------------------------------------------------
make_matroska()
{
echo -e "**\n**  matroska ...\n**"
OLDDIR=$(pwd)
cd $TMP/tmp-$PRGNAM/libmatroska-$MATROSKA/make/linux
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
make -j${NUMJOBS} staticlib prefix=/usr \
  LIBEBML_INCLUDE_DIR=$(pwd)/../../../libebml-$EBML \
  LIBEBML_LIB_DIR=$(pwd)/../../../libebml-$EBML/make/linux \
  2>&1 | tee $OUTPUT/make-${PRGNAM}_matroska.log
# Install into a temp directory where vlc can pick it up:
make install_staticlib install_headers \
  prefix=$VLCDEPSDIR/usr \
  includedir=$VLCDEPSDIR/usr/include/matroska \
  libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
  LIBEBML_INCLUDE_DIR=$(pwd)/../../../libebml-$EBML \
  LIBEBML_LIB_DIR=$(pwd)/../../../libebml-$EBML/make/linux \
  2>&1 | tee -a $OUTPUT/make-${PRGNAM}_matroska.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
cd $TMP/tmp-$PRGNAM/libmatroska-$MATROSKA
mkdir -p $VLCDEPSDIR/doc/libmatroska/
cp ChangeLog LICENSE.LGPL \
  $VLCDEPSDIR/doc/libmatroska/ || true
cd $OLDDIR
}

# -----------------------------------------------------------------------------
# Compile libmpeg2
# -----------------------------------------------------------------------------
make_libmpeg2()
{
echo -e "**\n**  libmpeg2 ...\n**"
cd $TMP/tmp-$PRGNAM/libmpeg2-$MPEG2DEC
if [ ! -r configure ]; then
  sh bootstrap
fi
# Without --prefix=$VLCDEPSDIR/usr , vlc 0.9 will not find the includes:
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_libmpeg2.log
            #--without-x \
            #--disable-sdl \
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_libmpeg2.log
# Install libmpeg2 into a temp location so vlc can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_mbpeg2.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libmpeg2/
cp AUTHORS COPYING ChangeLog NEWS README TODO \
  $VLCDEPSDIR/doc/libmpeg2/ || true
cd -
}

# -----------------------------------------------------------------------------
# Compile libmpcdec
# -----------------------------------------------------------------------------
make_mpcdec()
{
echo -e "**\n**  libmpcdec ...\n**"
cd $TMP/tmp-$PRGNAM/libmpcdec-$MPCDEC
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_mpcdec.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_mpcdec.log
# Install mpcdec into a temp location so vlc can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_mpcdec.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libmpcdec/
cp AUTHORS COPYING ChangeLog README \
  $VLCDEPSDIR/doc/libmpcdec/ || true
cd -
}

# -----------------------------------------------------------------------------
# Compile libdvdnav
# -----------------------------------------------------------------------------
make_dvdnav()
{
echo -e "**\n**  libdvdnav  ...\n**"
cd $TMP/tmp-$PRGNAM/libdvdnav-$DVDNAV
CFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
CXXFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
LDFLAGS="$SLKLDFLAGS -L$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}" \
PKG_CONFIG_PATH="$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
PATH="$VLCDEPSDIR/usr/bin:$PATH" \
./autogen.sh --prefix=$VLCDEPSDIR/usr \
             --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
             --enable-static \
             --disable-shared \
             --program-prefix= \
             --program-suffix= \
             --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_dvdnav.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_dvdnav.log
# Install libdvdnav into a temp location so vlc can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_dvdnav.log
# Make a symlink which vlc-20080730 needs:
( cd $VLCDEPSDIR/usr/include
  ln -s dvdread libdvdread
)
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libdvdnav/
cp AUTHORS COPYING ChangeLog NEWS README TODO \
  $VLCDEPSDIR/doc/libdvdnav/ || true
cd -
}

# -----------------------------------------------------------------------------
# Compile libdvdcss
# -----------------------------------------------------------------------------
make_dvdcss()
{
echo -e "**\n**  libdvdcss  ...\n**"
cd $TMP/tmp-$PRGNAM/libdvdcss-$DVDCSS
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --enable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_dvdcss.log
            # Shared library needed so that libdvdread can query the library
            #--disable-shared \
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_dvdcss.log
# Install libdvdcss into a temp location so libdvdread can pickup the library
echo -e "\n**\n**\n"
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_dvdcss.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libdvdcss/
cp AUTHORS COPYING ChangeLog NEWS README \
  $VLCDEPSDIR/doc/libdvdcss/ || true
cd -
}

# -----------------------------------------------------------------------------
# Compile libdvdread
# -----------------------------------------------------------------------------
make_dvdread()
{
echo -e "**\n**  libdvdread  ...\n**"
cd $TMP/tmp-$PRGNAM/libdvdread-$DVDREAD
#cat $SRCDIR/libdvdread_autogen.patch | patch -p0 --verbose \
#  2>&1 | tee $OUTPUT/patch-${PRGNAM}_dvdread.log
./autogen.sh noconfig \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_dvdread.log
# Unfortunately, I still cannot get dvdcss statically linked-in:
DO_CSS=""
#if [ "${USE_PATENTS}" == "YES" ]; then
#  # If we allow patented software, we also link libdvdcss statically into
#  # libdvdread. Otherwise, you can just install libdvdcss additionally
#  # and the dvdread library will find and load dvdcss support at runtime.
#  cat $SRCDIR/libdvdread_static_dvdcss.patch | patch -p0 --verbose \
#    2>&1 | tee -a $OUTPUT/patch-${PRGNAM}_dvdread.log
#  DO_CSS="--with-libdvdcss=$VLCDEPSDIR/usr"
#else
#  DO_CSS=""
#fi

CFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
CXXFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
LDFLAGS="$SLKLDFLAGS -I$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            ${DO_CSS} \
            --build=$ARCH-slackware-linux \
  2>&1 | tee -a $OUTPUT/configure-${PRGNAM}_dvdread.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_dvdread.log
# Install libdvdread into a temp location so libdvdnav can pickup the library
echo -e "\n**\n**\n"
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_dvdread.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libdvdread/
cp AUTHORS COPYING ChangeLog NEWS README TODO \
  $VLCDEPSDIR/doc/libdvdread/ || true
cd -
}

# -----------------------------------------------------------------------------
# Compile libcddb
# -----------------------------------------------------------------------------
make_cddb()
{
echo -e "**\n**  libcddb  ...\n**"
cd $TMP/tmp-$PRGNAM/libcddb-$CDDB
CFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
CXXFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
LDFLAGS="$SLKLDFLAGS -I$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_cddb.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_cddb.log
# Install libcddb into a temp location so cdio and vlc can pickup the library
echo -e "\n**\n**\n"
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_cddb.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libcddb/
cp ABOUT-NLS AUTHORS COPYING ChangeLog NEWS README THANKS TODO \
  $VLCDEPSDIR/doc/libcddb/ || true
cd -
}

# -----------------------------------------------------------------------------
# Compile libcdio
# -----------------------------------------------------------------------------
make_cdio()
{
echo -e "**\n**  libcdio  ...\n**"
DO_VCD=${1:-" "}
cd $TMP/tmp-$PRGNAM/libcdio-$CDIO
## Patch that allows vlc to detect required libs for cdio:
#cat $SRCDIR/libcdio-0.80_Makefile.patch | patch -p0 --verbose \
#  2>1 | tee -a $OUTPUT/patch-${PRGNAM}.log
## Because of patching a .am file, need to reconf:
#autoreconf -vif
# Seems I need this ugly prefix or else I have to dig into the problem of libvcd
# incorrectly interpreting libcdio.la contents...
CFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
CXXFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
LDFLAGS="$SLKLDFLAGS -L$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}" \
PKG_CONFIG_PATH="$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --enable-joliet \
            --enable-rock \
            --disable-cddb \
            $DO_VCD \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_cdio.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_cdio.log
# Install libcdio into a temp location so vlc can pickup the library
echo -e "\n**\n**\n"
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_cdio.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libcdio/
cp ABOUT-NLS AUTHORS COPYING ChangeLog NEWS README* THANKS TODO \
  $VLCDEPSDIR/doc/libcdio/  || true
cd -
}

# -----------------------------------------------------------------------------
# Compile libvcd
# -----------------------------------------------------------------------------
make_vcd()
{
echo -e "**\n**  libvcd  ...\n**"
cd $TMP/tmp-$PRGNAM/vcdimager-$VCD
CFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
CXXFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
LDFLAGS="$SLKLDFLAGS -L$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}" \
PKG_CONFIG_PATH="$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_vcd.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_vcd.log
# Install libvcd into a temp location so vlc can pickup the library
echo -e "\n**\n**\n"
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_vcd.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/vcdimager/
cp AUTHORS BUGS COPYING ChangeLog* FAQ HACKING NEWS README THANKS TODO \
  $VLCDEPSDIR/doc/vcdimager/  || true
cd -
}

# -----------------------------------------------------------------------------
# Compile twolame
# -----------------------------------------------------------------------------
make_twolame()
{
echo -e "**\n**  twolame  ...\n**"
cd $TMP/tmp-$PRGNAM/twolame-$TWOLAME
# Fix a bug that gets uncovered by gcc 4.4:
cat $SRCDIR/twolame-0.3.12_mem.diff | patch -p1 --verbose 2>&1 \
  | tee $OUTPUT/patch-${PRGNAM}_twolame.log
# For gcc 4.3 and onwards:
if [ $(gcc -dumpversion |tr -d  '.' |cut -c 1-2) -ge 43 ]; then
  cat $SRCDIR/twolame-0.3.12_gcc43.diff | patch -p1 --verbose 2>&1 \
    | tee -a $OUTPUT/patch-${PRGNAM}_twolame.log
fi
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --disable-debug \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_twolame.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_twolame.log
## Install twolame into a temp location so vlc can pickup the library
#echo -e "\n**\n**\n"
#make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_twolame.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/twolame/
cp AUTHORS COPYING ChangeLog README TODO \
  $VLCDEPSDIR/doc/twolame/  || true
cd -
}

# -----------------------------------------------------------------------------
# Compile libdaap
# -----------------------------------------------------------------------------
make_daap()
{
echo -e "**\n**  libdaap  ...\n**"
cd $TMP/tmp-$PRGNAM/libopendaap-$DAAP
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --disable-debug \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_daap.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_daap.log
# Install libdaap into a temp location so vlc can pickup the library
echo -e "\n**\n**\n"
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_daap.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libopendaap/
cp AUTHORS COPYING ChangeLog NEWS README \
  $VLCDEPSDIR/doc/libopendaap/  || true
cd -
}


# -----------------------------------------------------------------------------
# Compile libupnp
# -----------------------------------------------------------------------------
make_upnp()
{
echo -e "**\n**  libupnp  ...\n**"
cd $TMP/tmp-$PRGNAM/libupnp-$UPNP
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --enable-client \
            --disable-webserver \
            --disable-samples \
            --disable-debug \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_upnp.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_upnp.log
# Install libupnp into a temp location so vlc can pickup the library
echo -e "\n**\n**\n"
# The 'make install' will install into $VLCDEPSDIR :
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_upnp.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libupnp/
cp AUTHORS COPYING ChangeLog LICENSE NEWS README THANKS TODO \
  $VLCDEPSDIR/doc/libupnp/  || true
cd -
}

# -----------------------------------------------------------------------------
# Compile liboil
# -----------------------------------------------------------------------------
make_oil()
{
echo -e "**\n**  oil ...\n**"
cd $TMP/tmp-$PRGNAM/liboil-$OIL
cat $SRCDIR/liboil-noshared.patch | patch -p1 --verbose \
  2>&1 | tee $OUTPUT/patch-${PRGNAM}_oil.log
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --disable-debug \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_oil.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_oil.log
# Install liboil into a temp location so schroedinger can pickup the library
echo -e "\n**\n**\n"
# We used --prefix=$VLCDEPSDIR/usr so that schroedinger's build will find the
# headers in the $VLCDEPS instead of the filesystem root:
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_oil.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/liboil/
cp AUTHORS BUG-REPORTING COPYING HACKING NEWS README \
  $VLCDEPSDIR/doc/liboil/  || true
cd -
}

# -----------------------------------------------------------------------------
# Compile schroedinger
# -----------------------------------------------------------------------------
make_schroedinger()
{
echo -e "**\n**  schroedinger ...\n**"
if [ "$ARCH" = "x86_64" ]; then
  ARCHOPTS="--with-pic"
else
  ARCHOPTS=""
fi
cd $TMP/tmp-$PRGNAM/schroedinger-$SCHROEDINGER
# With "--disable-shared" schrodinger 1.0.8 refuses to compile errorfree,
# unless this patch is applied:
cat $SRCDIR/schroedinger-1.0.8_test.patch | patch -p1 --verbose \
  2>&1 | tee $OUTPUT/patch-${PRGNAM}_schroedinger.patch
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
PKG_CONFIG_PATH="$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --disable-shared \
            --with-thread=none \
            --disable-gstreamer \
            --program-prefix= \
            --program-suffix= \
            $ARCHOPTS \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_schroedinger.log
make  2>&1 | tee $OUTPUT/make-${PRGNAM}_schroedinger.log
# Install schroedinger into a temp location so vlc can pickup the library
echo -e "\n**\n**\n"
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_schroedinger.log
# Or else the vlc build wil fail:
cp schroedinger.pc $VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig/schroedinger.pc
cp schroedinger.pc $VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig/schroedinger-1.0.pc
( cd $VLCDEPSDIR/usr/include
  ln -sf schroedinger-1.0/schroedinger 
)
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/schroedinger/
cp AUTHORS COPYING* NEWS TODO \
  $VLCDEPSDIR/doc/schroedinger/  || true
cd -
}

# -----------------------------------------------------------------------------
# Compile speex codec
# -----------------------------------------------------------------------------
make_speex()
{
echo -e "**\n**  speex  ...\n**"
cd $TMP/tmp-$PRGNAM/speex-$SPEEX
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_speex.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_speex.log
# Install speex into a temp location so libshout and vlc can pickup the library
echo -e "\n**\n**\n"
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_speex.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/speex/
cp AUTHORS COPYING ChangeLog NEWS README* TODO \
  $VLCDEPSDIR/doc/speex/  || true
cd -
}

# -----------------------------------------------------------------------------
# Compile libshout
# -----------------------------------------------------------------------------
make_shout()
{
echo -e "**\n**  libshout  ...\n**"
cd $TMP/tmp-$PRGNAM/libshout-$SHOUT
CFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
CPPFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
LDFLAGS="$SLKLDFLAGS -L$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}" \
PKG_CONFIG_PATH="$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-speex \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_shout.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_shout.log
# Install libshout into a temp location so vlc can pickup the library
echo -e "\n**\n**\n"
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_shout.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libshout/
cp COPYING NEWS README \
  $VLCDEPSDIR/doc/libshout/  || true
cd -
}

# -----------------------------------------------------------------------------
# Compile goom
# -----------------------------------------------------------------------------
make_goom()
{
echo -e "**\n**  goom  ...\n**"
# First, fix a blatant bug in the archive:
find $TMP/tmp-$PRGNAM/goom${GOOM} -type d -exec chmod 755 {} \;
cd $TMP/tmp-$PRGNAM/goom${GOOM}
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_goom.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_goom.log
# No need to install, vlc wants the source tree
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/goom/
cp AUTHORS COPYING ChangeLog KNOWNBUGS NEWS README \
  $VLCDEPSDIR/doc/goom/  || true
cd -
}

# -----------------------------------------------------------------------------
# Compile ggi
# -----------------------------------------------------------------------------
make_ggi()
{
echo -e "**\n**  ggi  ...\n**"
INDIR=$(pwd)
# First libgii which is a dependency
cd $TMP/tmp-$PRGNAM/ggi-${GGI}-bundle/libgii-$GII
# Do not add '-fPIC' or "undefined reference to `ggGetSwarType'" will occur
# when building cpuinfo:
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
	    --disable-debug \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_ggi.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_ggi.log
# Install gii into a temp location so libggi can pickup the library
echo -e "\n**\n**\n"
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_ggi.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libgii/
cp ChangeLog* FAQ NEWS README \
  $VLCDEPSDIR/doc/libgii/  || true

# Next, libggi
cd $TMP/tmp-$PRGNAM/ggi-${GGI}-bundle/libggi-$GGI
CFLAGS="$SLKCFLAGS" \
CPPFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
	    --disable-debug \
            --with-gii=$VLCDEPSDIR/usr \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee -a $OUTPUT/configure-${PRGNAM}_ggi.log
make -j${NUMJOBS} 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_ggi.log
# Install ggi into a temp location so vlc can pickup the library
echo -e "\n**\n**\n"
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_ggi.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libggi/
cp ChangeLog* FAQ NEWS README \
  $VLCDEPSDIR/doc/libggi/  || true

cd $INDIR
}

# -----------------------------------------------------------------------------
# Compile x264
# -----------------------------------------------------------------------------
make_x264()
{
echo -e "**\n**  x264  ...\n**"
if [ "$ARCH" = "x86_64" ]; then
  ARCHOPTS="--enable-pic"
else
  ARCHOPTS=""
fi
cd $TMP/tmp-$PRGNAM/x264-snapshot-${X264}
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure \
  --prefix=$VLCDEPSDIR/usr \
  --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
  $ARCHOPTS \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_x264.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_x264.log
# Install x264 into a temp location so vlc can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_x264.log
## Need this to link vlc successfully on x86_64:
#if [ "$ARCH" == "x86_64" ]; then
#  find . -name libx264.a -exec strip {} \;
#  find $VLCDEPSDIR -name libx264.a -exec strip {} \;
#fi
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/x264/
cp AUTHORS COPYING \
  $VLCDEPSDIR/doc/x264/  || true
cd -
}

# -----------------------------------------------------------------------------
# Compile dv
# -----------------------------------------------------------------------------
make_dv()
{
echo -e "**\n**  dv  ...\n**"
cd $TMP/tmp-$PRGNAM/libdv-${DV}
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --disable-gtk \
            --disable-xv \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_dv.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_dv.log
# Install dv into a temp location so vlc can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_dv.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libdv/
cp AUTHORS COPYING COPYRIGHT ChangeLog NEWS README* TODO \
  $VLCDEPSDIR/doc/libdv/  || true
cd -
}

# -----------------------------------------------------------------------------
# Compile libdvbpsi library
# -----------------------------------------------------------------------------
make_dvbpsi()
{
echo -e "**\n**  dvbpsi ...\n**"
cd $TMP/tmp-$PRGNAM/libdvbpsi5-${DVBPSI}
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --disable-debug \
            --enable-release \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_dvbpsi.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_dvbpsi.log
# Install dvbpsi into a temp location so vlc can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_dvbpsi.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libdvbpsi/
cp AUTHORS COPYING ChangeLog NEWS README \
  $VLCDEPSDIR/doc/libdvbpsi/  || true
cd -
}

# -----------------------------------------------------------------------------
# Compile libdca library
# -----------------------------------------------------------------------------
make_dca()
{
echo -e "**\n**  dca ...\n**"
cd $TMP/tmp-$PRGNAM/libdca-${DCA}
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --disable-debug \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_dca.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_dca.log
# Install dca into a temp location so vlc can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_dca.log
# Fix a broken symlink:
( cd $VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}
  if [ -L libdts.a ] ; then
    rm -f libdts.a ; ln -s libdca.a libdts.a
  fi
)
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libdca/
cp AUTHORS COPYING ChangeLog NEWS README TODO \
  $VLCDEPSDIR/doc/libdca/  || true
cd -
}

# -----------------------------------------------------------------------------
# Compile avc1394 raw1394 and dc1394 libraries
# VLC will use these
# -----------------------------------------------------------------------------
make_1394()
{
echo -e "**\n**  1394 ...\n**"
OLDDIR=$(pwd)
cd $TMP/tmp-$PRGNAM/libraw1394-${RAW1394}

# Or else vlc compilation fails with "error: redefinition of typedef 'byte_t'"
patch -p0 --verbose < $SRCDIR/libraw1394_typedef.patch \
  2>&1 | tee -a $OUTPUT/patch-${PRGNAM}_raw1394.log

[ ! -x configure ] && ./autogen.sh

# Seems I need this ugly prefix or else I have to dig into the problem of vlc
# incorrectly interpreting *.la contents...
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --mandir=/usr/man \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_raw1394.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_raw1394.log
# Install libraw1394 into a temp location so vlc can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_raw1394.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libraw1394/
cp AUTHORS COPYING.LIB ChangeLog NEWS README \
  $VLCDEPSDIR/doc/libraw1394/  || true

echo -e "**\n**"

cd $TMP/tmp-$PRGNAM/libavc1394-${AVC1394}

CFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
CPPFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
LDFLAGS="$SLKLDFLAGS -L$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}" \
PKG_CONFIG_PATH="$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
LIBRAW1394_CFLAGS="-I$VLCDEPSDIR/usr/include" \
LIBRAW1394_LIBS="-L$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} -lraw1394" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_avc1394.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_avc1394.log
# Install libavc1394 into a temp location so vlc can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_avc1394.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libavc1394/
cp AUTHORS COPYING ChangeLog NEWS README TODO \
  $VLCDEPSDIR/doc/libavc1394/  || true

echo -e "**\n**"

cd $TMP/tmp-$PRGNAM/libdc1394-${DC1394}

# Skip building the examples - those cause errors:
cat $SRCDIR/libdc1394-noexamples.patch | patch -p1 --verbose \
  2>&1 | tee $OUTPUT/patch-${PRGNAM}_dc1394.log

# Make sure that the static libdc1394 is found in the vlcdeps:
CFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
CPPFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
LDFLAGS="$SLKLDFLAGS -L$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}" \
PKG_CONFIG_PATH="$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_dc1394.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_dc1394.log
# Install libdc1394 into a temp location so vlc can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_dc1394.log
# Install a pkgconfig file or else the libdc1394_control library will not
# be linked to correctly and libdc1394_plugin.so will not load:
mkdir -p $VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig
cat <<EOT > $VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig/libdc1394.pc
prefix=$VLCDEPSDIR/usr
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib${LIBDIRSUFFIX}
includedir=\${prefix}/include

Name: libdc1394
Description: High level programming interface for IEEE1394 digital camera.
Version: ${DC1394}
Libs: -L\${libdir} -ldc1394_control -lraw1394
Cflags: -I\${includedir}/libdc1394
EOT
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libdc1394/
cp AUTHORS COPYING ChangeLog NEWS README \
  $VLCDEPSDIR/doc/libdc1394/  || true

cd $OLDDIR
}


# -----------------------------------------------------------------------------
# Compile libass
# -----------------------------------------------------------------------------
make_ass()
{
echo -e "**\n**  ass  ...\n**"
cd $TMP/tmp-$PRGNAM/libass-$ASS
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_ass.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_ass.log
# Install libass into a temp location so vlc can pickup the library
echo -e "\n**\n**\n"
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_ass.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libass/
cp COPYING Changelog $VLCDEPSDIR/doc/libass/  || true
cd -
}


# -----------------------------------------------------------------------------
# Compile fluidsynth
# -----------------------------------------------------------------------------
make_fluid()
{
echo -e "**\n**  fluidsynth  ...\n**"
cd $TMP/tmp-$PRGNAM/fluidsynth-$FLUID
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --without-readline \
            --disable-jack-support \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}_fluid.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_fluid.log
# Install fluid into a temp location so vlc can pickup the library
echo -e "\n**\n**\n"
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_fluid.log
# Fix a missing link dependency (resolves 'unknown symbols' runtime):
sed -i -e "/^Libs:/s/$/ -lasound -lglib-2.0/" $VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig/fluidsynth.pc
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/fluidsynth/
cp AUTHORS COPYING ChangeLog NEWS README THANKS TODO \
  $VLCDEPSDIR/doc/fluidsynth/  || true
cd -
}


# -----------------------------------------------------------------------------
# Compile kate
# -----------------------------------------------------------------------------
make_kate()
{
echo -e "**\n**  kate ...\n**"
cd $TMP/tmp-$PRGNAM/libkate-${KATE}

CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
PKG_CONFIG_PATH="$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --disable-valgrind \
            --disable-doc \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_kate.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_kate.log
# Install kate into a temp location so vlc can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_kate.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libkate/
cp AUTHORS COPYING README THANKS \
  $VLCDEPSDIR/doc/libkate/ || true
cd -
}


# -----------------------------------------------------------------------------
# Compile libtiger
# -----------------------------------------------------------------------------
make_tiger()
{
echo -e "**\n**  tiger ...\n**"
cd $TMP/tmp-$PRGNAM/libtiger-${TIGER}

CFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
CXXFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
LDFLAGS="$SLKLDFLAGS -L$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}" \
PKG_CONFIG_PATH="$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
./configure --prefix=$VLCDEPSDIR/usr \
            --libdir=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
            --enable-static \
            --disable-shared \
            --disable-doc \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}_tiger.log
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}_tiger.log
# Install tiger into a temp location so vlc can pickup the library
make install 2>&1 | tee -a $OUTPUT/make-${PRGNAM}_tiger.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libtiger/
cp AUTHORS COPYING README THANKS \
  $VLCDEPSDIR/doc/libtiger/ || true
cd -
}


# -----------------------------------------------------------------------------
# Compile lua
# -----------------------------------------------------------------------------
make_lua()
{
echo -e "**\n**  lua ...\n**"
cd $TMP/tmp-$PRGNAM/lua-${LUA}

# Make it use our CFLAGS:
sed -i "s/-DLUA_USE_LINUX/\"-DLUA_USE_LINUX $SLKCFLAGS\"/g" src/Makefile

# Fix paths (lib64 for x86_64):
sed -i "s#/lib#/lib${LIBDIRSUFFIX}#" Makefile
sed -i "s#/usr/local#/usr#" Makefile

MYLDFLAGS="$SLKLDFLAGS -ld" make linux -j${NUMJOBS} \
  2>&1 | tee $OUTPUT/make-${PRGNAM}_lua.log
# Install lua into a temp location so vlc can pickup the library
make install INSTALL_TOP=$VLCDEPSDIR/usr \
  2>&1 | tee -a $OUTPUT/make-${PRGNAM}_lua.log
# Install a pkg-config file:
install -D -m 0644 etc/lua.pc $VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig/lua.pc
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/lua
cp COPYRIGHT HISTORY README $VLCDEPSDIR/doc/lua/ || true
cd -
}


# -----------------------------------------------------------------------------
# Compile v4l libraries
# -----------------------------------------------------------------------------
make_v4l()
{
echo -e "**\n**  v4l ...\n**"
cd $TMP/tmp-$PRGNAM/libv4l-${V4L}
export CFLAGS="$SLKCFLAGS"
export CPPFLAGS="$SLKCFLAGS"
export LDFLAGS="$SLKLDFLAGS"
make -j${NUMJOBS} LINKTYPE=static PREFIX=$VLCDEPSDIR/usr LIBDIR=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} 2>&1 | tee $OUTPUT/make-${PRGNAM}_v4l.log
# Strip the static lib to prevent linking errors in 64-bit,
# and fix the pkg-config file (to fix unresolved symbols in the plugin)
find . -name "*.a" | xargs strip --strip-unneeded
sed -i "/^Libs: /s/ -lv4l2/ -lv4l2 -lv4lconvert/" libv4l2/libv4l2.pc
# Install libv4l into a temp directory so that vlc can pick it up later:
make install LINKTYPE=static PREFIX=$VLCDEPSDIR/usr LIBDIR=$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX} \
  2>&1 | tee -a $OUTPUT/make-${PRGNAM}_v4l.log
# Add DOCS to the vlcdeps to have it added to vlc package later:
mkdir -p $VLCDEPSDIR/doc/libv4l/
cp COPYING.LIB ChangeLog README README.multi-threading TODO  \
  $VLCDEPSDIR/doc/libv4l/ || true
cd -
}


# -----------------------------------------------------------------------------
# VLC
# -----------------------------------------------------------------------------
make_vlc()
{
echo -e "**\n**  VLC ...\n**"
OLDDIR=$(pwd)
cd $TMP/tmp-$PRGNAM
if [ ! -d {PRGNAM}-${SRCVER} ]; then
  NEWVER=$(ls -1 -d --indicator-style=none vlc-* 2>/dev/null)
  if [ -n "$NEWVER" ]; then
    echo "##"
    echo -n "## Changing vlc VERSION from '$VERSION' to "
    SRCVER=$(echo $NEWVER | cut -d- -f2-)
    VERSION=$(echo $SRCVER | tr '-' '.')
    echo "'$VERSION'"
    echo "##"
  else
    echo "Can not determine which version of VLC I should build!"
    exit 1
  fi
fi
cd $TMP/tmp-$PRGNAM/${PRGNAM}-${SRCVER}
echo "" >$OUTPUT/patch-${PRGNAM}.log

# Configure a default Slackware TTF font:
cat $SRCDIR/vlc-0.9.0_deffont.patch \
  | sed -e "s#@@XPREFIX@@#$XPREF#" -e "s#@@LIB@@#lib${LIBDIRSUFFIX}#" \
  | patch -p1 --verbose 2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log

# Fix PLUGIN_PATH path for lib64
sed -i -e 's#/lib/vlc#/usr/lib${LIBDIRSUFFIX}/vlc#g' vlc-config.in.in configure* \
  2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log

# Detection of libupnp needs some extra libs:
cat $SRCDIR/vlc-0.9.0_upnp.patch | patch -p1 --verbose \
  2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log

## Detection of mplayer team's new libdvdread needs a temporary patch:
#cat $SRCDIR/vlc-0.9.0_libdvdread_configure.patch | patch -p1 --verbose \
#  2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log

# Now works without patching:
## Re-enable embedded video. With qt.4.4.3 this should work reliably:
#cat $SRCDIR/vlc-1.0.0_embedded_video.patch | patch -p1 --verbose \
#  2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log

## Make vlc link against a static libx264 (fixed post 1.0.0-pre2)
#cat $SRCDIR/vlc_x264_static.diff | patch -p1 --verbose \
#  2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log

## Allow the use of recent x264 on vlc-0.9.x (fixed in 1.0.0-git)
#if [ "$(echo $VERSION|cut -d. -f1-2)" == "0.9" -a "$X264" != "$X264_SAFE" ];
#then
#  cat $SRCDIR/vlc-0.9.9_x264_remove_pre_scenecut.diff | patch -p1 --verbose \
#    2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log
#  cat $SRCDIR/vlc-0.9.9_x264_obsolete_pre_scenecut.diff | patch -p1 --verbose \
#    2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log
#fi

## Fix compilation errors because of redefining gettext
## (this patch is not needed on slackware > 12.2):
#cat $SRCDIR/vlc-1.0.0_fixgettext.diff | patch -p1 --verbose \
#  2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log

# I want to be able to compile VLC on Slackware 12.2 (glibc 2.7):
cat $SRCDIR/vlc-1.0.0_allow_older_glibc.diff | patch -p1 --verbose \
  2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log

# Fix fullscreen in KDE-4.3.3 and vlc-1.0.3:
if [ "$VERSION" = "1.0.3" ]; then
  cat $SRCDIR/vlc-1.0.3_fixfullscreen.diff | patch -p1 --verbose \
  2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log
fi

# Patch the dc1394 plugin (vlc 1.0.x) to use the new libdc1394 2.x API:
if [ "$(echo $VERSION |cut -d. -f1-2)" = "1.0" ]; then
 cat $SRCDIR/vlc-1.0.3_ieee1394.diff | patch -p1 --verbose \
   2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log
fi

# Add compatibility with libpng14 (fixed in 1.1git):
if [ "$(echo $VERSION |cut -d. -f1-2)" = "1.0" ]; then
  cat $SRCDIR/vlc-1.0.5_png14.diff | patch -p1 --verbose \
     2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log
fi

# Preparations for building a separate vlc mozilla plugin :
if [ "$MOZPLUGIN" == "YES" ]; then
  echo "+++ Building mozilla plugin using $MOZBROWSER sdk +++"
  # Fix Seamonkey includes for mozilla vlc plugin.
  find projects/mozilla -type f -name "*.cpp" -exec sed -i \
    "s#<mozilla-config.h>#<${MOZBROWSER}/mozilla-config.h>#" \{} \;
  find projects/mozilla -type f -name "*.h" -exec sed -i \
    "s#<npapi.h>#<${MOZBROWSER}/plugin/npapi.h>#" \{} \;
  # Fix mozilla plugin:
  export XPIDL="/usr/lib${LIBDIRSUFFIX}/${MOZBROWSER}/xpidl"
  export XPIDL_INCL="-I/usr/include/${MOZBROWSER}  \
                     -I/usr/share/idl/$MOZBROWSER}"
else
  echo "+++ NOT building mozilla plugin - this needs the Seamonkey package! +++"
fi

# Only enable DLL loader on ELF ix86 platforms:
if [ "$ARCH" == "i486" -o "$ARCH" == "i686" ]; then
  DO_LOADER="--enable-loader"
else
  DO_LOADER=""
fi

# Only include libs for patented codecs if we are allowing/needing it:
if [ "${USE_PATENTS}" == "YES" -a "$STATIC_FFMPEG" == "YES" ]; then
  DO_FFMPEG_LIBS_PAT="-lmp3lame -lfaac"
else
  DO_FFMPEG_LIBS_PAT=""
fi

# VLC 0.9.6 but also 0.9.9 needs to regenerate libtool (known bug)
if ls m4/lt*.m4 1>/dev/null 2>/dev/null ; then
  rm -f m4/{lt,lib}*.m4; autoreconf -svif
fi

# vlc checks eventfd availability in glibc rather awkwardly. Our glibc 2.7
# implements the function but does not export it in a header. Still vlc thinks
# it can make use of it. NOTE: with glibc 2.8 it will work... have to wait...
sed -i -e 's/^#ifdef HAVE_EVENTFD/#ifdef HAVE_SYS_EVENTFD_H/' src/misc/objects.c

sh bootstrap

CPPFLAGS="-I$VLCDEPSDIR/usr/include" \
CFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
CXXFLAGS="$SLKCFLAGS -I$VLCDEPSDIR/usr/include" \
LDFLAGS="$SLKLDFLAGS -L$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}" \
PKG_CONFIG_PATH="$VLCDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
PATH="$VLCDEPSDIR/usr/bin:$PATH" \
./configure --prefix=/usr \
            --libdir=/usr/lib${LIBDIRSUFFIX} \
            --sysconfdir=/etc \
            --mandir=/usr/man \
            --localstatedir=/var \
            --without-contrib \
            --disable-rpath \
            --disable-debug \
            --disable-testsuite \
            --disable-static \
	    --disable-gnomevfs \
            --disable-zvbi \
            --disable-snapshot \
            --enable-shared \
            --enable-release \
            --enable-optimize-memory=no \
            --enable-qt4 \
            --enable-lua \
            --enable-pvr \
            --enable-dc1394 \
            --enable-dv \
            --enable-dvbpsi \
            --enable-dvdnav \
            --with-dvdnav-config-path=$VLCDEPSDIR/usr/bin \
            --enable-libcdio \
            --enable-cddax \
            --enable-vcdx \
            --enable-libcddb \
            --enable-svg \
            --enable-svgalib \
            --enable-telx \
            --enable-libass \
            --enable-v4l \
            --enable-caca \
            --enable-aa \
            --disable-galaktos \
            --enable-switcher \
            --enable-upnp \
            --enable-flac \
            --enable-shout \
            --enable-schroedinger \
            --enable-live555 \
            --with-live555-tree=$TMP/tmp-$PRGNAM/live \
            --enable-real \
            --enable-realrtsp \
            --enable-speex \
            --with-speex-tree=$TMP/tmp-$PRGNAM/speex-$SPEEX \
            --enable-x264 \
            --enable-a52 \
            --with-a52-tree=$TMP/tmp-$PRGNAM/a52dec-$A52 \
            --enable-faad \
            --with-faad-tree=$TMP/tmp-$PRGNAM/faad2-$FAAD2 \
            --enable-twolame \
            --with-twolame-tree=$TMP/tmp-$PRGNAM/twolame-$TWOLAME \
            --enable-ogg \
            --enable-vorbis \
            --enable-theora \
            --enable-avcodec \
            --enable-avformat \
            --enable-swscale \
	    ${DO_MOZPLUGIN} \
            ${DO_LOADER} \
            --enable-run-as-root \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux \
            2>&1 | tee $OUTPUT/configure-${PRGNAM}.log

            # Enabled by default:
            #--enable-dca \
            #--with-dca-tree=$TMP/tmp-$PRGNAM/libdca-$DCA \

            # Libdvdnav is now the default (which uses libdvdread in turn)
            #--enable-dvdread \
            #--with-dvdread-tree=$TMP/tmp-$PRGNAM/libdvdread-$DVDREAD \
            #--enable-goom \
            #--with-goom-tree=$TMP/tmp-$PRGNAM/goom$GOOM \
            #--enable-ggi \

            # Sometimes skins support breaks and we'll have to disable it:
            #--disable-skins2 \

            # Got errors about missing sdt.h in ./modules/access/dvb/access.c
            #--with-dvbpsi-tree=$TMP/tmp-$PRGNAM/libdvbpsi5-${DVBPSI} \

            # Leave this out so that linking the static x264.a into a shared
            # library works on x86_64: 
            #--with-x264-tree=$TMP/tmp-$PRGNAM/x264-snapshot-$X264 \

            # Without these, we get also rid of "unknown symbols" runtime
            #--with-dv-raw1394=$TMP/tmp-$PRGNAM/libraw1394-${RAW1394} \
            #--with-dv-avc1394=$TMP/tmp-$PRGNAM/libavc1394-${AVC1394} \

            # Deprecated:
            #--enable-ffmpeg \
            #--with-ffmpeg-tree=$TMP/tmp-$PRGNAM/ffmpeg-${FFMPEG} \
            #--enable-daap \
            #--disable-musicbrainz \
            #--disable-arts \
            #--enable-esd \
            #--with-dv-raw1394-tree=$TMP/tmp-$PRGNAM/libraw1394-${RAW1394} \
            #--with-dv-avc1394-tree=$TMP/tmp-$PRGNAM/libavc1394-${AVC1394} \

            # Now finds the required libraries without manual tweaking:
            #AVCODEC_LIBS="-lavcodec -lbz2 -lz ${DO_FFMPEG_LIBS_PAT} -ldl -ltheora -lvorbisenc -lswscale -lavutil -lvorbis -lm -logg" \
            #AVCODEC_CFLAGS="" \

# At some time, I needed to remove access_mmap from vlc-config because that
# caused my vlc to die after only a few seconds of playtime...
# You can test this by adding "--no-file-mmap" as a parameter (or not) to vlc
# if you did not strip access_mmap from vlc-config:
#sed -i -e "s/access_mmap//" vlc-config

# Force dtstofloat32 (back) in:
if ! $(grep -q dtstofloat32 vlc-config) ; then
  sed -i -e "s/dtstospdif /dtstofloat32 dtstospdif /" vlc-config
fi

# Now, we are ready for the compile:
make -j${NUMJOBS} 2>&1 | tee $OUTPUT/make-${PRGNAM}.log

cd $OLDDIR
}

# -----------------------------------------------------------------------------
# These routines do all the work of setting up the package contents
# and creating the actual Slackware packages in $OUTPUT
# -----------------------------------------------------------------------------

build_mozplugin()
{
echo -e "**\n**  mozplugin ...\n**"
cd $TMP/tmp-$PRGNAM/${PRGNAM}-${SRCVER}
# Get the plugin file from the vlc build directory:
mkdir -p $PKG2/usr/lib${LIBDIRSUFFIX}/mozilla/plugins/
if [ -f ./projects/mozilla/libvlcplugin.so ]; then
  VLCPLUGINSO=./projects/mozilla/libvlcplugin.so
else
  VLCPLUGINSO=./projects/mozilla/.libs/libvlcplugin.so
fi
cp -a ${VLCPLUGINSO} $PKG2/usr/lib${LIBDIRSUFFIX}/mozilla/plugins/
strip --strip-unneeded $PKG2/usr/lib${LIBDIRSUFFIX}/mozilla/plugins/libvlcplugin.so

mkdir -p $PKG2/install
cat $SRCDIR/slack-desc.$PRGNAM2 > $PKG2/install/slack-desc
if [ -f $SRCDIR/slack-required.$PRGNAM2 ]; then
  cat $SRCDIR/slack-required.$PRGNAM2 > $PKG2/install/slack-required
fi

cd $PKG2
makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${PRGNAM2}-${VERSION}-${ARCH}-${BUILD}${TAG}.tgz 2>&1 | tee $OUTPUT/makepkg-${PRGNAM2}.log
cd $OUTPUT
md5sum ${PRGNAM}-${PRGNAM2}-${VERSION}-${ARCH}-${BUILD}${TAG}.tgz > ${PRGNAM}-${PRGNAM2}-${VERSION}-${ARCH}-${BUILD}${TAG}.tgz.md5
cd -
cat $PKG2/install/slack-desc | grep "^${PRGNAM}-${PRGNAM2}" > $OUTPUT/${PRGNAM}-${PRGNAM2}-${VERSION}-${ARCH}-${BUILD}${TAG}.txt
if [ -f $PKG2/install/slack-required ]; then
  cat $PKG2/install/slack-required > $OUTPUT/${PRGNAM}-${PRGNAM2}-${VERSION}-${ARCH}-${BUILD}${TAG}.dep
fi

}

build_slackpkg()
{
echo -e "**\n**  building the package ...\n**"
#
# Install all the needed stuff to the package dir
#
cd $TMP/tmp-$PRGNAM/${PRGNAM}-${SRCVER}

# Use installwatch if available, to produce a logfile of the installation
# process that is more easily readable:
if $(which installwatch > /dev/null 2>&1); then
  installwatch -o $OUTPUT/install-${PRGNAM}.log make DESTDIR=$PKG install
else
  make DESTDIR=$PKG install 2>&1 |tee $OUTPUT/install-${PRGNAM}.log
fi

# Even though I modified vlc-config to exclude access_mmap from building, it
# does get built... so now we remove it forcibly:
#rm -f $PKG/usr/lib${LIBDIRSUFFIX}/vlc/access/libaccess_mmap_plugin.*

# We don't want the mozilla plugin here:
[ -d $PKG/usr/lib${LIBDIRSUFFIX}/mozilla ] && rm -rf $PKG/usr/lib${LIBDIRSUFFIX}/mozilla

# Add the icons to be used in menu entries:
for res in 16 32 48 128; do
  mkdir -p  $PKG/usr/share/icons/hicolor/${res}x${res}/apps
  cp -a share/vlc${res}x${res}.png \
    $PKG/usr/share/icons/hicolor/${res}x${res}/apps/vlc.png
done

# Add the man page:
mkdir -p $PKG/usr/man/man1
gzip -9c doc/vlc.1 > $PKG/usr/man/man1/vlc.1.gz

# Add a vlc log syntax definition file for vim:
mkdir -p $PKG/$(cd /usr/share/vim/vim*/syntax ; pwd)
cp extras/analyser/vlc.vim $PKG/$(cd /usr/share/vim/vim*/syntax ; pwd)/

# Add package documentation:
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
mv $PKG/usr/share/doc/vlc/* $PKG/usr/doc/$PRGNAM-$VERSION || true
rm -rf $PKG/usr/share/doc
cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION || true
# Add all the supporting packages' documentation too:
cp -a $VLCDEPSDIR/doc/* $PKG/usr/doc/$PRGNAM-$VERSION || true
# Add the SlackBuild script with the values we used for the main variables:
cat $SRCDIR/$(basename $0) | sed \
  -e "/^VERSION=/s/:-.*}/:-$VERSION}/" \
  -e "/^ARCH=/s/:-.*}/:-$ARCH}/" \
  -e "/^BUILD=/s/:-.*}/:-$BUILD}/" \
  > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
find $PKG/usr/doc -type f -exec chmod 644 {} \;
chown -R root:root $PKG/usr/doc/$PRGNAM-$VERSION/*

# Compress the man page(s):
if [ -d $PKG/usr/man ]; then
  find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \;
  for i in $(find $PKG/usr/man -type l -name "*.?") ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
fi

# Strip binaries:
find $PKG | xargs file | grep -e "executable" -e "shared object" \
  | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

# Add a package description:
mkdir -p $PKG/install
cat $SRCDIR/slack-desc > $PKG/install/slack-desc
if [ -f $SRCDIR/doinst.sh ]; then
  cat $SRCDIR/doinst.sh >> $PKG/install/doinst.sh
fi
if [ -f $SRCDIR/slack-required ]; then
  cat $SRCDIR/slack-required > $PKG/install/slack-required
fi

# Build the package:
cd $PKG
makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.tgz 2>&1 | tee $OUTPUT/makepkg-${PRGNAM}.log
cd $OUTPUT
md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.tgz > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.tgz.md5
cd -
cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txt
if [ -f $PKG/install/slack-required ]; then
  cat $PKG/install/slack-required > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.dep
fi

}

# -----------------------------------------------------------------------------
# OK - we wrapped the separate components into convenience functions
# - now call them one by one:
# -----------------------------------------------------------------------------

if echo "$*" | grep -qw -- --unwrapvlcdeps ; then
  # We use a tarball with precompiled binaries instead of compiling all
  # dependencies at this moment (saves time when all we change is VLC code):
  cd $TMP/tmp-$PRGNAM
  echo "Extracting tarball with pre-compiled binary library code..."
  tar -xvf $SRCDIR/$PRGNAM-vlcdeps-$ARCH.tar.bz2
  #find . -name "*.la" -exec sed -i -e "s#/usr/share/vlcdeps#$TMP/tmp-$PRGNAM#g" {} \;
  find . -name "*.la" -exec sed -i -e "s#/mnt/hd#$TMP#g" {} \;
  cd -

else
  #if [ "xy" == "x" ]; then
  # CD/VCD image support:
  # Circular dependencies need these loops:
  make_cdio --disable-vcd-info
  make_vcd
  make_cdio

  # vlc wants this, but cdio chokes with "cannot find -lcddb" so build it after
  # cdio (which only used cddb for the cd-info binary which we don't use):
  make_cddb

  # DVD support:
  # I can not get dvdcss statically linked into libdvdread:
  #make_dvdcss
  make_dvdread
  make_dvdnav

  if [ "$STATIC_FFMPEG" == "YES" ]; then
    # Needed before ffmpeg:
    make_theora
    make_amr
    # Only use patented code if we are allowing it:
    if [ "${USE_PATENTS}" == "YES" ]; then
      make_lame
      make_faac
    fi

    # ffmpeg uses the above static libraries:
    make_ffmpeg
  fi

  # qt4 is used for the vlc gui:
  if [ "$STATIC_QT4" = "YES" -o "$STATIC_QT4" = "yes" ]; then
    make_qt4
  fi

  # Additional libraries that vlc will use:
  make_faad2
  make_a52
  make_dca
  make_ebml
  make_matroska
  make_x264
  make_libmpeg2
  make_mpcdec
  make_twolame
  #make_daap
  make_upnp
  make_oil
  make_schroedinger
  make_live555
  make_ass
  make_fluid
  make_1394
  make_kate
  make_tiger
  make_lua
  make_v4l

  make_goom
  #make_ggi

  make_dv
  make_dvbpsi

  # Speex before shout and vlc:
  make_speex
  make_shout

  #fi # End  ( "xy" == "x" )
fi

if echo "$*" | grep -qw -- --wrapvlcdeps ; then
  # Wrap the vlcdeps tree with all pre-compiled dependencies into a tarball:
  cd $TMP/tmp-$PRGNAM
  tar -jcf $OUTPUT/$PRGNAM-vlcdeps-$ARCH.tar.bz2 \
    vlcdeps \
    a52dec-$A52 \
    faad2-$FAAD2 \
    libraw1394-${RAW1394} \
    libavc1394-${AVC1394} \
    live \
    speex-$SPEEX \
    twolame-$TWOLAME \
    x264-snapshot-$X264
  find . -name "*.la" -exec sed -i -e "s#$TMP/tmp-$PRGNAM#/usr/share/vlcdeps#g" {} \;
  echo "Created vlcdeps binary tarball in '$OUTPUT/$PRGNAM-vlcdeps-$ARCH.tar.bz2'..."
  cd -
else
  # Compile VLC using all the precompiled static libs in $VLCDEPSDIR :
  make_vlc

  # Should we also build a package for the mozilla plugin?
  if [ "$MOZPLUGIN" == "YES" ]; then
    build_mozplugin
  fi

  # Pack all this stuff into a Slackware package (this routine also will execute
  # the '--cleanup' functionality if requested):
  build_slackpkg "$*"
fi