aboutsummaryrefslogtreecommitdiff
path: root/configure.in
blob: 27ac5f58ebad19e6371963a45a42c99e1963fb49 (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
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT("xbmc", 9.04, http://xbmc.org/trac/)
AC_CONFIG_HEADERS([config.h])
AH_TOP([#pragma once])

# Ensure config.guess and config.sub exist and is executable
# Also install latest version of these files if available
AC_MSG_NOTICE([Ensuring config.guess and config.sub exist and is executable])
test -f config.guess && chmod a+x config.guess
if [[ -x /usr/share/misc/config.guess ]] && \
    [[ $($PWD/config.guess -t | sed 's/-//g') -lt \
    $(/usr/share/misc/config.guess -t | sed 's/-//g') ]]; then
    cp -f /usr/share/misc/config.guess config.guess
fi
test -f config.sub && chmod a+x config.sub
if [[ -x /usr/share/misc/config.sub ]] && \
    [[ $($PWD/config.sub -t | sed 's/-//g') -lt \
    $(/usr/share/misc/config.sub -t | sed 's/-//g') ]]; then
    cp -f /usr/share/misc/config.sub config.sub
fi

AC_CANONICAL_HOST

# General message strings
configure_debug="ERROR: this is a configure debug statement"
missing_library="Could not find a required library. Please see the README for your platform."
missing_headers="Could not find some required headers. Please see the README for your platform."
missing_program="Could not find a required program. Please see the README for your platform."
xrandr_not_found="== Could not find libXRandR. SDL will be used for resolution support. =="
xrandr_disabled="== XRandR support disabled. SDL will be used for resolution support. =="
pulse_not_found="== Could not find libpulse. PulseAudio support disabled. =="
pulse_disabled="== PulseAudio support manually disabled. =="
faac_not_found="== Could not find libfaac. FAAC support disabled. =="
faac_disabled="== FAAC support manually disabled. =="
dvdcss_enabled="== DVDCSS support enabled. =="
dvdcss_disabled="== DVDCSS support disabled. =="
avahi_not_found="== Could not find libavahi-common or libavahi-client. Avahi support disabled. =="
avahi_disabled="== Avahi support disabled. =="
vdpau_not_found="== Could not find libvdpau. VDPAU support disabled. =="
vdpau_disabled="== VDPAU support manually disabled. =="

# External library message strings
external_libraries_enabled="== Use of all supported external libraries enabled. =="
external_libraries_disabled="== Use of all supported external libraries disabled. =="
external_ffmpeg_enabled="== Use of external ffmpeg enabled. =="
external_ffmpeg_disabled="== Use of external ffmpeg disabled. =="
external_libmad_enabled="== Use of external libmad enabled. =="
external_libmad_disabled="== Use of external libmad disabled. =="
external_liba52_enabled="== Use of external liba52 enabled. =="
external_liba52_disabled="== Use of external liba52 disabled. =="
external_libdts_enabled="== Use of external libdts enabled. =="
external_libdts_disabled="== Use of external libdts disabled. =="
external_libfaad_enabled="== Use of external libfaad enabled. =="
external_libfaad_disabled="== Use of external libfaad disabled. =="
external_libmpeg2_enabled="== Use of external libmpeg2 enabled. =="
external_libmpeg2_disabled="== Use of external libmpeg2 disabled. =="
external_libass_enabled="== Use of external libass enabled. =="
external_libass_disabled="== Use of external libass disabled. =="
external_libvorbis_enabled="== Use of external libvorbis enabled. =="
external_libvorbis_disabled="== Use of external libvorbis disabled. =="
external_libogg_enabled="== Use of external libogg enabled. =="
external_libogg_disabled="== Use of external libogg disabled. =="
external_libmpcdec_enabled="== Use of external libmpcdec enabled. =="
external_libmpcdec_disabled="== Use of external libmpcdec disabled. =="
external_libflac_enabled="== Use of external libflac enabled. =="
external_libflac_disabled="== Use of external libflac disabled. =="
external_libwavpack_enabled="== Use of external libwavpack enabled. =="
external_libwavpack_disabled="== Use of external libwavpack disabled. =="
external_python_enabled="== Use of external python enabled. =="
external_python_disabled="== Use of external python disabled. =="
ffmpeg_vdpau_not_supported="== External ffmpeg doesn't support VDPAU. VDPAU support disabled. =="

case $host in
    i*86*-linux-gnu*)
       ARCH="i486-linux"
       ;;
    x86_64-*-linux-gnu*)
       ARCH="x86_64-linux"
       ;;
    i386-apple-darwin*)
       ARCH="x86-osx"
       AC_SUBST(ARCH_DEFINES, "-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk")
       ;;
    powerpc-apple-darwin*)
       ARCH="powerpc-osx"
       AC_SUBST(ARCH_DEFINES, "-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk")
       ;;
    powerpc-*-linux-gnu*)
       ARCH="powerpc-linux"
       AC_SUBST(ARCH_DEFINES, "-D_POWERPC")
       ;;
    powerpc64-*-linux-gnu*)
       ARCH="powerpc64-linux"
       AC_SUBST(ARCH_DEFINES, "-D_POWERPC64")
       ;;
    *)
       AC_MSG_ERROR(unsupported host ($host))
esac
AC_SUBST([ARCH])

AC_ARG_ENABLE([debug],
            [AS_HELP_STRING([--enable-debug],
               [enable debugging information (default is yes)])],
            [use_debug=$enableval],
            [use_debug=yes])

AC_ARG_ENABLE([optimizations],
            [AS_HELP_STRING([--enable-optimizations],
               [enable optimization (default is yes)])],
            [use_optimizations=$enableval],
            [use_optimizations=yes])

AC_ARG_ENABLE([gl],
            [AS_HELP_STRING([--enable-gl],
               [enable OpenGL rendering (default is yes)])],
            [use_gl=$enableval],
            [use_gl=yes])

AC_ARG_ENABLE([vdpau],
            [AS_HELP_STRING([--enable-vdpau],
               [enable VDPAU decoding (default is yes)])],
            [use_vdpau=$enableval],
            [use_vdpau=yes])

AC_ARG_ENABLE([profiling],
            [AS_HELP_STRING([--enable-profiling],
               [enable gprof profiling (default is no)])],
            [use_profiling=$enableval],
            [use_profiling=no])

AC_ARG_ENABLE([joystick],
            [AS_HELP_STRING([--enable-joystick],
               [enable SDL joystick support (default is yes)])],
            [use_joystick=$enableval],
            [use_joystick=yes])

AC_ARG_ENABLE([xrandr],
            [AS_HELP_STRING([--enable-xrandr],
               [enable XRandR support (default is yes)])],
            [use_xrandr=$enableval],
            [use_xrandr=yes])

AC_PATH_PROG(CCACHE,ccache,none)
AC_ARG_ENABLE([ccache],
            [AS_HELP_STRING([--enable-ccache],
               [enable building with ccache feature (default is yes if ccache is installed)])],
            [use_ccache=$enableval],
            [use_ccache=yes])

AC_ARG_ENABLE([pulse],
            [AS_HELP_STRING([--enable-pulse],
               [enable PulseAudio support (default is yes)])],
            [use_pulse=$enableval],
            [use_pulse=yes])

AC_ARG_ENABLE([faac],
            [AS_HELP_STRING([--enable-faac],
               [enable FAAC support (default is yes)])],
            [use_faac=$enableval],
            [use_faac=yes])

AC_ARG_ENABLE([dvdcss],
            [AS_HELP_STRING([--enable-dvdcss],
               [enable DVDCSS support (default is yes)])],
            [use_dvdcss=$enableval],
            [use_dvdcss=yes])

AC_ARG_ENABLE([mid],
            [AS_HELP_STRING([--enable-mid],
               [enable MID support (default is no)])],
            [use_mid=$enableval],
            [use_mid=no])
AC_ARG_ENABLE([avahi],
             [AS_HELP_STRING([--disable-avahi],
                [disable Avahi support (default is enabled if libavahi-common and libavahi-client is found)])],
             [use_avahi=$enableval],
             [use_avahi=yes])

### External libraries options
AC_ARG_ENABLE([external-libraries],
            [AS_HELP_STRING([--enable-external-libraries],
            [enable use of all supported external libraries (default is no) 'Linux only'])],
            [use_external_libraries=$enableval],
            [use_external_libraries=no])

AC_ARG_ENABLE([external-ffmpeg],
            [AS_HELP_STRING([--enable-external-ffmpeg],
            [enable use of external ffmpeg libraries (default is no) 'Linux only'])],
            [use_external_ffmpeg=$enableval],
            [use_external_ffmpeg=no])

AC_ARG_ENABLE([external-libmad],
            [AS_HELP_STRING([--enable-external-libmad],
            [enable use of external libmad library (default is no) 'Linux only'])],
            [use_external_libmad=$enableval],
            [use_external_libmad=no])

AC_ARG_ENABLE([external-liba52],
            [AS_HELP_STRING([--enable-external-liba52],
            [enable use of external liba52 library (default is no) 'Linux only'])],
            [use_external_liba52=$enableval],
            [use_external_liba52=no])

AC_ARG_ENABLE([external-libdts],
            [AS_HELP_STRING([--enable-external-libdts],
            [enable use of external libdts library (default is no) 'Linux only'])],
            [use_external_libdts=$enableval],
            [use_external_libdts=no])

AC_ARG_ENABLE([external-libfaad],
            [AS_HELP_STRING([--enable-external-libfaad],
            [enable use of external libfaad library (default is no) 'Linux only'])],
            [use_external_libfaad=$enableval],
            [use_external_libfaad=no])

AC_ARG_ENABLE([external-libmpeg2],
            [AS_HELP_STRING([--enable-external-libmpeg2],
            [enable use of external libmpeg2 library (default is no) 'Linux only'])],
            [use_external_libmpeg2=$enableval],
            [use_external_libmpeg2=no])

AC_ARG_ENABLE([external-libass],
            [AS_HELP_STRING([--enable-external-libass],
            [enable use of external libass library (default is no) 'Linux only'])],
            [use_external_libass=$enableval],
            [use_external_libass=no])

AC_ARG_ENABLE([external-libvorbis],
            [AS_HELP_STRING([--enable-external-libvorbis],
            [enable use of external libvorbis library (default is no) 'Linux only'])],
            [use_external_libvorbis=$enableval],
            [use_external_libvorbis=no])

AC_ARG_ENABLE([external-libogg],
            [AS_HELP_STRING([--enable-external-libogg],
            [enable use of external libogg library (default is no) 'Linux only'])],
            [use_external_libogg=$enableval],
            [use_external_libogg=no])

AC_ARG_ENABLE([external-libmpcdec],
            [AS_HELP_STRING([--enable-external-libmpcdec],
            [enable use of external libmpcdec library (default is no) 'Linux only'])],
            [use_external_libmpcdec=$enableval],
            [use_external_libmpcdec=no])

AC_ARG_ENABLE([external-libflac],
            [AS_HELP_STRING([--enable-external-libflac],
            [enable use of external libflac library (default is no) 'Linux only'])],
            [use_external_libflac=$enableval],
            [use_external_libflac=no])

AC_ARG_ENABLE([external-libwavpack],
            [AS_HELP_STRING([--enable-external-libwavpack],
            [enable use of external libwavpack library (default is no) 'Linux only'])],
            [use_external_libwavpack=$enableval],
            [use_external_libwavpack=no])

AC_ARG_ENABLE([external-python],
            [AS_HELP_STRING([--enable-external-python],
            [enable use of external python library (default is no) 'Linux only'])],
            [use_external_python=$enableval],
            [use_external_python=no])

### End of external library options

# PCRE is a requirement
use_pcre="yes"

# Checks for programs.
PASSED_CXXFLAGS=$CXXFLAGS # Hack to override autoconf default values
AC_PROG_CXX
CXXFLAGS=$PASSED_CXXFLAGS
PASSED_CFLAGS=$CFLAGS # Hack to override autoconf default values
AC_PROG_CC
CFLAGS=$PASSED_CFLAGS
AC_PROG_AWK
AC_PROG_LN_S
AC_PROG_MAKE_SET

# platform specific flags
if test "$host_vendor" = "apple" ; then
  AC_SUBST(MACOSX_DEPLOYMENT_TARGET, "10.4")
  # need these in CFLAGS/CXXFLAGS so AC_CHECK_LIB works
  CFLAGS="$CFLAGS -I/opt/local/include"
  CFLAGS="$CFLAGS -I/opt/local/include/freetype2"
  CFLAGS="$CFLAGS -I/opt/local/include/mysql5"
  CXXFLAGS="$CXXFLAGS -I/opt/local/include"
  CXXFLAGS="$CXXFLAGS -I/opt/local/include/freetype2"
  CXXFLAGS="$CXXFLAGS -I/opt/local/include/mysql5"
  # standard xbmc paths
  INCLUDES="$INCLUDES -I."
  INCLUDES="$INCLUDES -I\$(abs_top_srcdir)/xbmc"
  INCLUDES="$INCLUDES -I\$(abs_top_srcdir)/xbmc/lib"
  INCLUDES="$INCLUDES -I\$(abs_top_srcdir)/xbmc/osx"
  INCLUDES="$INCLUDES -I/opt/local/include"
  INCLUDES="$INCLUDES -I/opt/local/include/freetype2"
  INCLUDES="$INCLUDES -I/opt/local/include/mysql5"
  LDFLAGS="$LDFLAGS -mmacosx-version-min=10.4"
  LDFLAGS="$LDFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
  LDFLAGS="$LDFLAGS -framework IOKit"
  LDFLAGS="$LDFLAGS -framework Cocoa"
  LDFLAGS="$LDFLAGS -framework OpenGL"
  LDFLAGS="$LDFLAGS -framework AppKit"
  LDFLAGS="$LDFLAGS -framework Carbon"
  LDFLAGS="$LDFLAGS -framework CoreAudio"
  LDFLAGS="$LDFLAGS -framework QuickTime"
  LDFLAGS="$LDFLAGS -framework AudioUnit"
  LDFLAGS="$LDFLAGS -framework Foundation"
  LDFLAGS="$LDFLAGS -framework CoreServices"
  LDFLAGS="$LDFLAGS -framework CoreVideo"
  LDFLAGS="$LDFLAGS -framework CoreAudio"
  LDFLAGS="$LDFLAGS -framework AudioToolbox"
  LDFLAGS="$LDFLAGS -framework CoreFoundation"
  LDFLAGS="$LDFLAGS -framework DiskArbitration"
  LDFLAGS="$LDFLAGS -framework ApplicationServices"
  LDFLAGS="$LDFLAGS -L/opt/local/lib"
  LDFLAGS="$LDFLAGS -L/opt/local/lib/mysql5/mysql"
  LDFLAGS="$LDFLAGS -L/opt/local/lib/samba3"
fi

# Add top source directory for all builds so we can use config.h
INCLUDES="$INCLUDES -I\$(abs_top_srcdir)"

# Checks for boost headers using CXX instead of CC
AC_LANG_PUSH([C++])
AC_CHECK_HEADER([boost/shared_ptr.hpp],, AC_MSG_ERROR($missing_library))
AC_LANG_POP([C++])

# Checks for platforms libraries.
if test "$use_gl" = "yes"; then
  if test "$host_vendor" = "apple" ; then
    # linking to OpenGL.framework instead of libGL, libGLU
    AC_CHECK_LIB([GLEW],    [main],, AC_MSG_ERROR($missing_library))
  else
    AC_CHECK_LIB([GL],      [main],, AC_MSG_ERROR($missing_library))
    AC_CHECK_LIB([GLEW],    [main],, AC_MSG_ERROR($missing_library))
    AC_CHECK_LIB([GLU],     [main],, AC_MSG_ERROR($missing_library))
  fi
else
  AC_MSG_RESULT(== WARNING: OpenGL support is disabled. XBMC will run VERY slow. ==)
  AC_CHECK_LIB([SDL_gfx], [main])
fi


# platform independent libraries
AC_CHECK_HEADER([mad.h],,            AC_MSG_ERROR($missing_library))
AC_CHECK_HEADER([jpeglib.h],,        AC_MSG_ERROR($missing_library))
AC_CHECK_HEADER([samplerate.h],,     AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([mad],         [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([ogg],         [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([vorbis],      [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([vorbisenc],   [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([vorbisfile],  [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([freetype],    [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([fontconfig],  [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([bz2],         [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([fribidi],     [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([sqlite3],     [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([mysqlclient], [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([asound],      [main])           # check for asound, fedora
AC_CHECK_LIB([rt],          [clock_gettime])  # check for rt, required for clock_gettime
AC_CHECK_LIB([png12],       [main],, AC_MSG_ERROR($missing_library)) # check for cximage
AC_CHECK_LIB([jpeg],        [main],, AC_MSG_ERROR($missing_library)) # check for cximage
AC_CHECK_LIB([pcre],        [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([pthread],     [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([lzo2],        [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([cdio],        [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([samplerate],  [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([z],           [main],, AC_MSG_ERROR($missing_library))
# platform dependent libraries
if test "$host_vendor" = "apple" ; then
  AC_CHECK_LIB([iconv],     [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([smbclient], [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([mms],       [main],, AC_MSG_ERROR($missing_library))
else
  AC_CHECK_LIB([smbclient], [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([SDL],       [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([SDL_mixer], [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([dl],        [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([resolv],    [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([enca],      [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([jasper],    [main],, AC_MSG_ERROR($missing_library)) # check for cximage
  AC_CHECK_LIB([mms],       [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([Xt],        [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([Xtst],      [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([Xmu],       [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([Xinerama],  [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([curl],      [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([dbus-1],    [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([hal-storage], [main],, AC_MSG_ERROR($missing_library))
  PKG_CHECK_MODULES([HAL], [hal], [INCLUDES+=" $HAL_CFLAGS"], AC_MSG_ERROR([$missing_library]))
fi

# PulseAudio
if test "$host_vendor" = "apple" ; then
  use_pulse="no"
  AC_MSG_RESULT($pulse_disabled)
else
  if test "$use_pulse" = "yes"; then
    AC_CHECK_LIB([pulse], [main], 
      LIBS=" -lpulse $LIBS";INCLUDES="$INCLUDES -DHAS_PULSEAUDIO",
      use_pulse=no;AC_MSG_RESULT($pulse_not_found))
  else
    AC_MSG_RESULT($pulse_disabled)
  fi
fi

# FAAC
if test "$host_vendor" = "apple" ; then
  use_faac="no"
  AC_MSG_RESULT($faac_disabled)
else
  if test "$use_faac" = "yes"; then
    AC_CHECK_LIB([faac], [main],,
      use_faac=no;AC_MSG_RESULT($faac_not_found))
  else
    AC_MSG_RESULT($faac_disabled)
  fi
fi

# avahi
if test "$host_vendor" = "apple" ; then
  use_avahi="no"
  AC_MSG_RESULT($avahi_disabled)
else
  if test "$use_avahi" = "yes"; then
    AC_CHECK_LIB([avahi-common], [main], 
      LIBS=" -lavahi-common $LIBS";,
      use_avahi=no;AC_MSG_RESULT($avahi_not_found))
	if test "$use_avahi" = "yes"; then
		#either both libs or none
    	AC_CHECK_LIB([avahi-client], [main], 
	      LIBS=" -lavahi-client $LIBS";INCLUDES="$INCLUDES -DHAS_AVAHI",
	      use_avahi=no;AC_MSG_RESULT($avahi_not_found))
	fi
    else
     AC_MSG_RESULT($avahi_disabled)
   fi
fi
 

# XRandR
if test "$host_vendor" = "apple" ; then
  use_xrandr="no"
  AC_MSG_RESULT($xrandr_disabled)
else
  if test "$use_xrandr" = "yes" ; then
    AC_CHECK_LIB([Xrandr], [main],, 
      use_xrandr="no";AC_MSG_RESULT($xrandr_not_found))
  else
    AC_MSG_RESULT($xrandr_disabled)
  fi
fi

### External libraries checks
if test "$use_external_libraries" = "yes"; then
  AC_MSG_NOTICE($external_libraries_enabled)
  USE_EXTERNAL_LIBRARIES=1
  AC_DEFINE([USE_EXTERNAL_LIBRARIES], [1], [Whether to use external libraries.])
else
  AC_MSG_NOTICE($external_libraries_disabled)
  USE_EXTERNAL_LIBRARIES=0
fi

# External FFmpeg
if test "$use_external_libraries" = "yes" || test "$use_external_ffmpeg" = "yes"; then
  AC_CHECK_LIB([avcodec],          [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([avformat],         [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([avutil],           [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([postproc],         [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([swscale],          [main],, AC_MSG_ERROR($missing_library))

  # Determine whether AVPacket and relevant functions are defined in libavformat
  # or libavcodec
  AC_CHECK_LIB([avcodec], [av_free_packet],
  [AC_MSG_NOTICE(== AVPacket and relevant functions defined in libavcodec. ==)],
  [AC_MSG_NOTICE(== AVPacket and relevant functions defined in libavformat. ==)
   AC_DEFINE([AVPACKET_IN_AVFORMAT], [1], [Whether AVPacket is in libavformat.])])

  # Possible places the ffmpeg headers may be
  AC_CHECK_HEADERS([libavcodec/avcodec.h libavformat/avformat.h libavutil/avutil.h libpostproc/postprocess.h libswscale/swscale.h],,
  [AC_CHECK_HEADERS([ffmpeg/avcodec.h ffmpeg/avformat.h ffmpeg/avutil.h postproc/postprocess.h ffmpeg/swscale.h],,
  [AC_MSG_ERROR($missing_headers)])])

  # We'll support the use of rgb2rgb.h if it exists.
  AC_CHECK_HEADERS([libswscale/rgb2rgb.h],,)
  AC_CHECK_HEADERS([ffmpeg/rgb2rgb.h],,)

  AC_MSG_NOTICE($external_ffmpeg_enabled)
  USE_EXTERNAL_FFMPEG=1
  AC_DEFINE([USE_EXTERNAL_FFMPEG], [1], [Whether to use external FFmpeg libraries.])

  # Disable vdpau support if external libavcodec doesn't have it
  AC_CHECK_LIB([avcodec], [ff_vdpau_vc1_decode_picture],,
    use_vdpau=no;AC_MSG_RESULT($ffmpeg_vdpau_not_supported))
else
  AC_MSG_NOTICE($external_ffmpeg_disabled)
  USE_EXTERNAL_FFMPEG=0
fi

# External libmad
if test "$use_external_libraries" = "yes" || test "$use_external_libmad" = "yes"; then
  AC_CHECK_LIB([mad],          [main],, AC_MSG_ERROR($missing_library))

  AC_MSG_NOTICE($external_libmad_enabled)
  USE_EXTERNAL_LIBMAD=1
  AC_DEFINE([USE_EXTERNAL_LIBMAD], [1], [Whether to use external libmad library.])
else
  AC_MSG_NOTICE($external_libmad_disabled)
  USE_EXTERNAL_LIBMAD=0
fi

# External liba52
if test "$use_external_libraries" = "yes" || test "$use_external_liba52" = "yes"; then
  AC_CHECK_LIB([a52],          [main],, AC_MSG_ERROR($missing_library))

  AC_MSG_NOTICE($external_liba52_enabled)
  USE_EXTERNAL_LIBA52=1
  AC_DEFINE([USE_EXTERNAL_LIBA52], [1], [Whether to use external liba52 library.])
else
  AC_MSG_NOTICE($external_liba52_disabled)
  USE_EXTERNAL_LIBA52=0
fi

# External libdts
if test "$use_external_libraries" = "yes" || test "$use_external_libdts" = "yes"; then
  AC_CHECK_LIB([dts],          [main],, AC_MSG_ERROR($missing_library))

  AC_MSG_NOTICE($external_libdts_enabled)
  USE_EXTERNAL_LIBDTS=1
  AC_DEFINE([USE_EXTERNAL_LIBDTS], [1], [Whether to use external libdts library.])
else
  AC_MSG_NOTICE($external_libdts_disabled)
  USE_EXTERNAL_LIBDTS=0
fi

# External libfaad
if test "$use_external_libraries" = "yes" || test "$use_external_libfaad" = "yes"; then
  AC_CHECK_LIB([faad],          [main],, AC_MSG_ERROR($missing_library))
  # mp4ff is not included in Gentoo packages, which is why external libfaad
  # support has to be explicitely enabled
  AC_CHECK_LIB([mp4ff],          [main],, AC_MSG_ERROR($missing_library))

  # Test for the NeAACDecInitDRM function in libfaad as well
  AC_CHECK_LIB([faad],          [NeAACDecInitDRM],
    [AC_DEFINE([HAVE_LIBFAAD_NEAACDECINITDRM], [1], [Whether NeAACDecInitDRM function exists in libfaad library.])],)

  AC_LANG_PUSH(C++)
  AC_MSG_CHECKING([whether we have the Debian or Ubuntu < 2.7 FAAD ABI])
  AC_COMPILE_IFELSE(
    AC_LANG_PROGRAM([#include <neaacdec.h>], [char* x = NeAACDecGetErrorMessage(0)]),
    AC_MSG_RESULT(no),
    [
      AC_DEFINE([HAVE_LIBFAAD_DEBIAN_ABI], [1],
        [Whether we have the Debian or Ubuntu < 2.7 FAAD ABI])
      AC_MSG_RESULT(yes)
    ]
  )
  AC_LANG_POP()

  AC_MSG_NOTICE($external_libfaad_enabled)
  USE_EXTERNAL_LIBFAAD=1
  AC_DEFINE([USE_EXTERNAL_LIBFAAD], [1], [Whether to use external libfaad library.])
else
  AC_MSG_NOTICE($external_libfaad_disabled)
  USE_EXTERNAL_LIBFAAD=0
fi

# External libmpeg2
if test "$use_external_libraries" = "yes" || test "$use_external_libmpeg2" = "yes"; then
  AC_CHECK_LIB([mpeg2],          [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([mpeg2convert],          [main],, AC_MSG_ERROR($missing_library))

  AC_MSG_NOTICE($external_libmpeg2_enabled)
  USE_EXTERNAL_LIBMPEG2=1
  AC_DEFINE([USE_EXTERNAL_LIBMPEG2], [1], [Whether to use external libmpeg2 library.])
else
  AC_MSG_NOTICE($external_libmpeg2_disabled)
  USE_EXTERNAL_LIBMPEG2=0
fi

# External libass
if test "$use_external_libraries" = "yes" || test "$use_external_libass" = "yes"; then
  # We need libass >= 0.9.7.
  AC_CHECK_LIB([ass], [ass_set_message_cb],
  [AC_CHECK_LIB([ass], [main],,)
  AC_MSG_NOTICE($external_libass_enabled)
  USE_EXTERNAL_LIBASS=1
   AC_DEFINE([USE_EXTERNAL_LIBASS], [1], [Whether to use external libass library.])],
  [AC_MSG_WARN(== Need libass >= 0.9.7. Disabling external libass. ==)
   USE_EXTERNAL_LIBASS=0])
else
  AC_MSG_NOTICE($external_libass_disabled)
  USE_EXTERNAL_LIBASS=0
fi

# External libvorbis
if test "$use_external_libraries" = "yes" || test "$use_external_libvorbis" = "yes"; then
  AC_MSG_NOTICE($external_libvorbis_enabled)
  USE_EXTERNAL_LIBVORBIS=1
  AC_DEFINE([USE_EXTERNAL_LIBVORBIS], [1], [Whether to use external libvorbis library.])
else
  AC_MSG_NOTICE($external_libvorbis_disabled)
  USE_EXTERNAL_LIBVORBIS=0
fi

# External libogg
if test "$use_external_libraries" = "yes" || test "$use_external_libogg" = "yes"; then
  AC_MSG_NOTICE($external_libogg_enabled)
  USE_EXTERNAL_LIBOGG=1
  AC_DEFINE([USE_EXTERNAL_LIBOGG], [1], [Whether to use external libogg library.])
else
  AC_MSG_NOTICE($external_libogg_disabled)
  USE_EXTERNAL_LIBOGG=0
fi

# External libmpcdec
if test "$use_external_libraries" = "yes" || test "$use_external_libmpcdec" = "yes"; then
  AC_CHECK_LIB([mpcdec],          [main],, AC_MSG_ERROR($missing_library))

  AC_MSG_NOTICE($external_libmpcdec_enabled)
  USE_EXTERNAL_LIBMPCDEC=1
  AC_DEFINE([USE_EXTERNAL_LIBMPCDEC], [1], [Whether to use external libmpcdec library.])
else
  AC_MSG_NOTICE($external_libmpcdec_disabled)
  USE_EXTERNAL_LIBMPCDEC=0
fi

# External libflac
if test "$use_external_libraries" = "yes" || test "$use_external_libflac" = "yes"; then
  AC_CHECK_LIB([FLAC],          [main],, AC_MSG_ERROR($missing_library))

  AC_MSG_NOTICE($external_libflac_enabled)
  USE_EXTERNAL_LIBFLAC=1
  AC_DEFINE([USE_EXTERNAL_LIBFLAC], [1], [Whether to use external libflac library.])
else
  AC_MSG_NOTICE($external_libflac_disabled)
  USE_EXTERNAL_LIBFLAC=0
fi

# External libwavpack
if test "$use_external_libraries" = "yes" || test "$use_external_libwavpack" = "yes"; then
  AC_CHECK_LIB([wavpack],          [main],, AC_MSG_ERROR($missing_library))

  AC_MSG_NOTICE($external_libwavpack_enabled)
  USE_EXTERNAL_LIBWAVPACK=1
  AC_DEFINE([USE_EXTERNAL_LIBWAVPACK], [1], [Whether to use external libwavpack library.])
else
  AC_MSG_NOTICE($external_libwavpack_disabled)
  USE_EXTERNAL_LIBWAVPACK=0
fi

# External Python
if test "$use_external_libraries" = "yes" || test "$use_external_python" = "yes" || \
  $(test "$host_cpu" = "powerpc" && test "$host_vendor" != "apple"); then
  AC_CHECK_LIB([python2.6], [main],,
  [AC_CHECK_LIB([python2.5], [main],,
  [AC_CHECK_LIB([python2.4], [main],,
  [AC_MSG_ERROR($missing_library)] )] )] )

  # Test again, but this time just set some variables we need in Makefiles
  AC_CHECK_LIB([python2.6], [main],[USE_PYTHON2_6=1],
  [AC_CHECK_LIB([python2.5], [main],[USE_PYTHON2_5=1],
  [AC_CHECK_LIB([python2.4], [main],[USE_PYTHON2_4=1],
  [AC_MSG_ERROR($missing_library)] )] )] )

  AC_MSG_NOTICE($external_python_enabled)
  test "$USE_PYTHON2_6" && AC_MSG_NOTICE([Using Python 2.6])
  test "$USE_PYTHON2_5" && AC_MSG_NOTICE([Using Python 2.5])
  test "$USE_PYTHON2_4" && AC_MSG_NOTICE([Using Python 2.4])
  USE_EXTERNAL_PYTHON=1
  AC_DEFINE([USE_EXTERNAL_PYTHON], [1], [Whether to use external python library.])
else
  AC_MSG_NOTICE($external_python_disabled)
  USE_EXTERNAL_PYTHON=0

  # We'll need zip in this case.
  AC_CHECK_PROG(HAVE_ZIP,zip,"yes","no",)
  if test "$HAVE_ZIP" = "no" ; then
    AC_MSG_ERROR($missing_program)
  fi
fi

# VDPAU
if test "$host_vendor" = "apple" ; then
  use_vdpau="no"
  AC_MSG_NOTICE($vdpau_disabled)
else
  if test "$use_vdpau" = "yes"; then
    AC_CHECK_HEADER([vdpau/vdpau.h],AC_DEFINE([HAVE_LIBVDPAU], [], [Define to 1 if you have the 'vdpau' library (-lvdpau).]),
      use_vdpau=no;AC_MSG_RESULT($vdpau_not_found))
  else
    AC_MSG_NOTICE($vdpau_disabled)
  fi
fi

# platform specific bin utilities
if test "$host_vendor" != "apple" ; then
  AC_CHECK_PROG(HAVE_GAWK,gawk,"yes","no",)
  if test "$HAVE_GAWK" = "no" ; then
    AC_MSG_ERROR($missing_program)
  fi
fi

AC_CHECK_PROG(HAVE_CMAKE,cmake,"yes","no",)
if test "$HAVE_CMAKE" = "no" ; then
  AC_MSG_ERROR($missing_program)
fi

AC_CHECK_PROG(HAVE_GPERF,gperf,"yes","no",)
if test "$HAVE_GPERF" = "no" ; then
  AC_MSG_ERROR($missing_program)
fi

AC_CHECK_PROG(HAVE_UNZIP,unzip,"yes","no",)
if test "$HAVE_UNZIP" = "no" ; then
  AC_MSG_ERROR($missing_program)
fi

if test "$ARCH" != "x86_64-linux"; then
  AC_CHECK_PROG(HAVE_NASM,nasm,"yes","no",)
  if test "$HAVE_NASM" = "no" ; then
    AC_MSG_ERROR($missing_program)
  fi
fi

# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([lzo/lzo1.h])
AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h inttypes.h limits.h locale.h \
  malloc.h memory.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h \
  strings.h sys/file.h sys/ioctl.h sys/mount.h sys/param.h sys/socket.h \
  sys/time.h sys/timeb.h sys/vfs.h termios.h unistd.h utime.h wchar.h wctype.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STAT
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_UID_T
AC_C_INLINE
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_C_RESTRICT
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_CHECK_MEMBERS([struct stat.st_rdev])
AC_HEADER_TIME
AC_STRUCT_TM
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_C_BIGENDIAN

# Checks for library functions.
AC_FUNC_ALLOCA
AC_FUNC_CHOWN
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FSEEKO
AC_PROG_GCC_TRADITIONAL
AC_FUNC_LSTAT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MEMCMP
AC_FUNC_MKTIME
AC_FUNC_MMAP
# Boxee is apparently having compile problems
# if HAVE_REALLOC is defined.  Sort this later.
#AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_SETVBUF_REVERSED
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_STRCOLL
AC_FUNC_STRFTIME
AC_FUNC_STRTOD
AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([atexit dup2 fdatasync floor fs_stat_dev ftime ftruncate getcwd gethostbyaddr gethostbyname gethostname getpagesize getpass gettimeofday inet_ntoa lchown localeconv memchr memmove memset mkdir modf munmap pow rmdir select setenv setlocale socket sqrt strcasecmp strchr strcspn strdup strerror strncasecmp strpbrk strrchr strspn strstr strtol strtoul sysinfo tzset utime])

# Check for various sizes
AC_CHECK_SIZEOF([int])

dashes="------------------------"
final_message="\n  XBMC Configuration:"
final_message="\n$dashes$final_message\n$dashes"

if test "$use_debug" = "yes"; then
  final_message="$final_message\n  Debugging:\tYes"
  if test "$use_profiling" = "yes"; then
    final_message="$final_message\n  Profiling:\tYes"
    DEBUG_FLAGS="-g -pg -D_DEBUG -Wall"
  else
    final_message="$final_message\n  Profiling:\tNo"
    DEBUG_FLAGS="-g -D_DEBUG -Wall"
  fi
else
  final_message="$final_message\n  Debugging:\tNo"
  if test "$use_profiling" = "yes"; then
    final_message="$final_message\n  Profiling:\tYes"
    DEBUG_FLAGS="-pg -DNDEBUG=1"
  else
    final_message="$final_message\n  Profiling:\tNo"
    DEBUG_FLAGS="-DNDEBUG=1"
  fi
fi

if test "$use_optimizations" = "yes"; then
  final_message="$final_message\n  Optimization:\tYes"
  CXXFLAGS="$CXXFLAGS -O2"
  CFLAGS="$CFLAGS -O2"
else
  final_message="$final_message\n  Optimization:\tNo"
fi

if test "$use_gl" = "yes"; then
  final_message="$final_message\n  OpenGL:\tYes"
  SDL_DEFINES=""
else
  final_message="$final_message\n  OpenGL:\tNo (Very Slow)"
  SDL_DEFINES="-DHAS_SDL_2D"
fi

if test "$use_vdpau" = "yes"; then
  final_message="$final_message\n  VDPAU:\tYes"
else
  final_message="$final_message\n  VDPAU:\tNo"
fi

if test "$use_joystick" = "yes"; then
  final_message="$final_message\n  Joystick:\tYes"
  SDL_DEFINES="$SDL_DEFINES -DHAS_SDL_JOYSTICK"
else
  final_message="$final_message\n  Joystick:\tNo"
fi

if test "$use_xrandr" = "yes"; then
  final_message="$final_message\n  XRandR:\tYes"
  SDL_DEFINES="$SDL_DEFINES -DHAS_XRANDR"
else
  final_message="$final_message\n  XRandR:\tNo"
fi

if test "$use_pcre" = "yes"; then
  final_message="$final_message\n  PCRE Support:\tYes"
  SDL_DEFINES="$SDL_DEFINES -DHAS_PCRE"
else
  final_message="$final_message\n  PCRE Support:\tNo"
fi

if test "$use_mid" = "yes"; then
  final_message="$final_message\n  MID Support:\tYes"
  SDL_DEFINES="$SDL_DEFINES -DMID"
else
  final_message="$final_message\n  MID Support:\tNo"
fi

if test -d "/usr/include/lzo"; then
  INCLUDES="$INCLUDES -I/usr/include/lzo"
else
  INCLUDES="$INCLUDES"
fi

if test "$use_ccache" = "yes"; then
  if test "$ac_cv_path_CCACHE" = "none"; then
     echo "ccache not found. Falling back to default CC"
     final_message="$final_message\n  ccache:\tNo"
  else
    CC="$ac_cv_path_CCACHE $CC"
    CXX="$ac_cv_path_CCACHE $CXX"
    AC_MSG_NOTICE(enabling ccache)
    final_message="$final_message\n  ccache:\tYes"
  fi
else
  final_message="$final_message\n  ccache:\tNo"
fi

if test "$use_pulse" = "yes"; then
  final_message="$final_message\n  PulseAudio:\tYes"
else
  final_message="$final_message\n  PulseAudio:\tNo"
fi

if test "$use_faac" = "yes"; then
  final_message="$final_message\n  FAAC:\t\tYes"
else
  final_message="$final_message\n  FAAC:\t\tNo"
fi

# DVDCSS
if test "$use_dvdcss" = "yes"; then
  AC_MSG_NOTICE($dvdcss_enabled)
  final_message="$final_message\n  DVDCSS:\tYes"
  BUILD_DVDCSS=1
  SKIP_CONFIG_DVDCSS=0
  DVDREAD_CFLAGS="-D_XBMC -DHAVE_DVDCSS_DVDCSS_H"
else
  AC_MSG_NOTICE($dvdcss_disabled)
  final_message="$final_message\n  DVDCSS:\tNo"
  BUILD_DVDCSS=0
  SKIP_CONFIG_DVDCSS=1
  DVDREAD_CFLAGS="-D_XBMC -UHAVE_DVDCSS_DVDCSS_H"
fi
if test "$use_avahi" = "yes"; then
  final_message="$final_message\n  Avahi:\tYes"
else
  final_message="$final_message\n  Avahi:\tNo"
fi

if test -n "$SVN_REV" -a "$SVN_REV" != "" ; then
  SDL_DEFINES="$SDL_DEFINES -D'SVN_REV=\"$SVN_REV\"'"
elif test "$host_vendor" = "apple"; then
  AC_CHECK_PROG(HAVE_SVNVERSION,svnversion,"yes","no",)
  if test "$HAVE_SVNVERSION" = "no" ; then
    AC_MSG_WARN([svnversion not found. No SVN_REV in builds!])
    echo "#define SVN_REV" > svn_revision.h
  else
	SVN_REVISION=$(svnversion -n .)
	echo "#define SVN_REV \"$SVN_REVISION\"" > svn_revision.h
  fi
elif test -x "/usr/bin/svnversion" ; then
  SDL_DEFINES="$SDL_DEFINES -D'SVN_REV=\"$(svnversion -n .)\"'"
fi

### External libraries messages
if test "$use_external_libraries" = "yes"; then
  final_message="$final_message\n  External Libraries:\tYes"
else
  final_message="$final_message\n  External Libraries:\tNo"
  if test "$use_external_ffmpeg" = "yes"; then
    final_message="$final_message\n  External FFmpeg:\tYes"
  else
    final_message="$final_message\n  External FFmpeg:\tNo"
  fi
  if test "$use_external_libmad" = "yes"; then
    final_message="$final_message\n  External libmad:\tYes"
  else
    final_message="$final_message\n  External libmad:\tNo"
  fi
  if test "$use_external_liba52" = "yes"; then
    final_message="$final_message\n  External liba52:\tYes"
  else
    final_message="$final_message\n  External liba52:\tNo"
  fi
  if test "$use_external_libdts" = "yes"; then
    final_message="$final_message\n  External libdts:\tYes"
  else
    final_message="$final_message\n  External libdts:\tNo"
  fi
  if test "$use_external_libfaad" = "yes"; then
    final_message="$final_message\n  External libfaad:\tYes"
  else
    final_message="$final_message\n  External libfaad:\tNo"
  fi
  if test "$use_external_libmpeg2" = "yes"; then
    final_message="$final_message\n  External libmpeg2:\tYes"
  else
    final_message="$final_message\n  External libmpeg2:\tNo"
  fi
  if test "$use_external_libass" = "yes"; then
    final_message="$final_message\n  External libass:\tYes"
  else
    final_message="$final_message\n  External libass:\tNo"
  fi
  if test "$use_external_libvorbis" = "yes"; then
    final_message="$final_message\n  External libvorbis:\tYes"
  else
    final_message="$final_message\n  External libvorbis:\tNo"
  fi
  if test "$use_external_libogg" = "yes"; then
    final_message="$final_message\n  External libogg:\tYes"
  else
    final_message="$final_message\n  External libogg:\tNo"
  fi
  if test "$use_external_libmpcdec" = "yes"; then
    final_message="$final_message\n  External libmpcdec:\tYes"
  else
    final_message="$final_message\n  External libmpcdec:\tNo"
  fi
  if test "$use_external_libflac" = "yes"; then
    final_message="$final_message\n  External libflac:\tYes"
  else
    final_message="$final_message\n  External libflac:\tNo"
  fi
  if test "$use_external_libwavpack" = "yes"; then
    final_message="$final_message\n  External libwavpack:\tYes"
  else
    final_message="$final_message\n  External libwavpack:\tNo"
  fi
  if test "$use_external_python" = "yes"; then
    final_message="$final_message\n  External Python:\tYes"
  else
    final_message="$final_message\n  External Python:\tNo"
  fi
fi

OUTPUT_FILES="Makefile \
             Makefile.include \
             xbmc/cores/dvdplayer/Codecs/Makefile \
             xbmc/cores/dvdplayer/Codecs/libdvd/Makefile \
             xbmc/cores/AudioRenderers/Makefile \
             xbmc/cores/paplayer/Makefile \
             xbmc/cores/paplayer/MACDll/Makefile \
             xbmc/cores/paplayer/timidity/Makefile \
             xbmc/cores/paplayer/AACCodec/Makefile \
             xbmc/cores/paplayer/AC3Codec/Makefile \
             xbmc/cores/paplayer/ADPCMCodec/Makefile \
             xbmc/cores/paplayer/FLACCodec/Makefile \
             xbmc/cores/paplayer/ModuleCodec/Makefile \
             xbmc/cores/paplayer/GYMCodec/Makefile \
             xbmc/cores/paplayer/MPCCodec/xbmc/Makefile \
             xbmc/cores/paplayer/NSFCodec/Makefile \
             xbmc/cores/paplayer/SIDCodec/Makefile \
             xbmc/cores/paplayer/vgmstream/Makefile \
             xbmc/cores/paplayer/SPCCodec/SNES/SNESAPU/Makefile \
             xbmc/cores/paplayer/vorbisfile/Makefile \
             xbmc/cores/paplayer/WavPackCodec/Makefile \
             xbmc/cores/paplayer/YMCodec/StSoundLibrary/Makefile \
             guilib/common/Makefile \
             xbmc/lib/libass/xbmc/Makefile \
             xbmc/lib/libXBMS/Makefile \
             xbmc/lib/libRTV/Makefile \
             xbmc/lib/libexif/Makefile \
             xbmc/lib/libXDAAP/Makefile \
             xbmc/lib/libhdhomerun/Makefile \
             xbmc/lib/libGoAhead/Makefile \
             xbmc/lib/libshout/Makefile \
             xbmc/lib/libid3tag/Makefile \
             xbmc/lib/cximage-6.0/Makefile \
             xbmc/lib/libPython/linux/Makefile \
             xbmc/lib/libUPnP/Makefile \
             xbmc/DllPaths_generated.h \
             xbmc/linux/Makefile \
             xbmc/screensavers/Makefile \
             xbmc/screensavers/rsxs-0.9/xbmc/Makefile \
             xbmc/visualizations/XBMCProjectM/Makefile \
             xbmc/visualizations/Goom/Makefile \
             xbmc/visualizations/OpenGLSpectrum/Makefile \
             xbmc/visualizations/WaveForm/Makefile \
             xbmc/visualizations/iTunes/Makefile \
             tools/Linux/xbmc.sh \
             tools/XBMCTex/Makefile \
             tools/EventClients/Clients/OSXRemote/Makefile"
AC_CONFIG_FILES([${OUTPUT_FILES}])
AC_SUBST(CFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(INCLUDES)
AC_SUBST(LDFLAGS)
AC_SUBST(DEBUG_FLAGS)
AC_SUBST(SDL_DEFINES)
AC_SUBST(BUILD_DVDCSS)
AC_SUBST(USE_EXTERNAL_LIBRARIES)
AC_SUBST(USE_EXTERNAL_FFMPEG)
AC_SUBST(USE_EXTERNAL_LIBMAD)
AC_SUBST(USE_EXTERNAL_LIBA52)
AC_SUBST(USE_EXTERNAL_LIBDTS)
AC_SUBST(USE_EXTERNAL_LIBFAAD)
AC_SUBST(USE_EXTERNAL_LIBMPEG2)
AC_SUBST(USE_EXTERNAL_LIBASS)
AC_SUBST(USE_EXTERNAL_LIBVORBIS)
AC_SUBST(USE_EXTERNAL_LIBOGG)
AC_SUBST(USE_EXTERNAL_LIBMPCDEC)
AC_SUBST(USE_EXTERNAL_LIBFLAC)
AC_SUBST(USE_EXTERNAL_LIBWAVPACK)
AC_SUBST(USE_EXTERNAL_PYTHON)
AC_SUBST(USE_PYTHON2_6)
AC_SUBST(USE_PYTHON2_5)
AC_SUBST(USE_PYTHON2_4)
AC_SUBST(OUTPUT_FILES)
# Function to run the configure scripts in our submodules
# Consists of three paramaters, the path to the submodule, the configure command
# with appropriate arguments, and a third parameter set to 1 if we are to skip
# running the script, anything else if not.
AC_DEFUN([XB_CONFIG_MODULE],[
AC_CONFIG_COMMANDS_POST([
if [[ $3 != "1" ]]; then
    if [[ -d $1 ]]; then
        pushd $1
        $2
        if [[ $? -ne 0 ]]; then
            popd
            AC_MSG_ERROR([[Submodule $1 failed to configure]])
        else
            popd
        fi
    else
        AC_MSG_ERROR([[Submodule $1 doesn't exist]])
    fi
else
    AC_MSG_NOTICE([[Skipping configuration of submodule $1.]])
fi
])
])

XB_CONFIG_MODULE([xbmc/lib/libPython/Python], [
  if test "$host_vendor" = "apple" ; then
    ./configure \
      --enable-ipv6 \
      --enable-unicode=ucs4 \
      --without-cxx \
      --enable-shared \
      --without-pymalloc \
      LDFLAGS="-L/opt/local/lib" \
      OPT="-Wno-deprecated-declarations -I/opt/local/include" \
      MACOSX_DEPLOYMENT_TARGET=10.4 &&
    sed -i bak -e "s/define HAVE_GETC_UNLOCKED 1/undef HAVE_GETC_UNLOCKED/" pyconfig.h && 
    sed -i bak -e "s/define HAVE_FSEEKO 1/undef HAVE_FSEEKO/" pyconfig.h &&
    sed -i bak -e "s/define HAVE_FTELLO 1/undef HAVE_FTELLO/" pyconfig.h &&
    sed -i bak -e "s/define HAVE_FTRUNCATE 1/undef HAVE_FTRUNCATE/" pyconfig.h &&
    sed -i bak -e "s/define HAVE_FPATHCONF 1/undef HAVE_FPATHCONF/" pyconfig.h &&
    sed -i bak -e "s/define HAVE_FSYNC 1/undef HAVE_FSYNC/" pyconfig.h &&
    sed -i bak -e "s/define HAVE_FCHDIR 1/undef HAVE_FCHDIR/" pyconfig.h &&
    cp pyconfig.h Include	
  else
    ./configure \
      --enable-ipv6 \
      --enable-unicode=ucs4 \
      --without-cxx \
      --enable-shared \
      --without-pymalloc \
      --prefix=`pwd`/../linux/python-lib CFLAGS=-fPIC &&
    sed -i -e "s/define HAVE_GETC_UNLOCKED 1/undef HAVE_GETC_UNLOCKED/" pyconfig.h &&
    cp pyconfig.h Include
  fi
], [$USE_EXTERNAL_PYTHON])

XB_CONFIG_MODULE([xbmc/cores/paplayer/MPCCodec], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \    
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4
  else
    ./configure
  fi
], [$USE_EXTERNAL_LIBMPCDEC])

XB_CONFIG_MODULE([xbmc/cores/paplayer/FLACCodec/flac-1.2.1], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \    
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 -C \
      --with-pic \
      --disable-asm-optimizations \
      --disable-xmms-plugin \
      --disable-cpplibs \
      CC="$CC" \
      CXX="$CXX"
  else
    ./configure -C \
      --with-pic \
      --disable-asm-optimizations \
      --disable-xmms-plugin \
      --disable-cpplibs \
      CC="$CC" \
      CXX="$CXX"
  fi
], [$USE_EXTERNAL_LIBFLAC])

XB_CONFIG_MODULE([xbmc/cores/paplayer/vorbisfile/libvorbis], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 --with-pic
  else
    ./configure --with-pic
  fi
], [$USE_EXTERNAL_LIBVORBIS])

XB_CONFIG_MODULE([xbmc/cores/paplayer/vorbisfile/ogg], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 --with-pic
  else
    ./configure --with-pic
  fi
], [$USE_EXTERNAL_LIBOGG])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/ffmpeg], [
  if test "$host_vendor" = "apple" ; then
    ./configure \
      --extra-cflags="-w -D_DARWIN_C_SOURCE -D_XBOX -isysroot /Developer/SDKs/MacOSX10.4u.sdk" \
      --disable-static \
      `if test "$use_debug" = "no"; then echo --disable-debug; fi` \
      --disable-muxers \
      --disable-encoders \
      --disable-devices \
      --disable-ffplay \
      --disable-ffserver \
      --disable-ffmpeg \
      --enable-shared \
      --disable-ipv6 \
      --disable-decoder=mpeg_xvmc \
      --enable-postproc \
      --enable-gpl \
      --enable-protocol=http \
      --enable-pthreads \
      --cc="$CC" &&
    sed -i "" -e "s#YASM=yasm#YASM=/opt/local/bin/yasm#" config.mak &&
    sed -i "" -e "s# -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 # #" config.mak &&
    sed -i "" -e "s#libswscale_VERSION_MAJOR=0#libswscale_VERSION_MAJOR=0.7.1#" config.mak &&
    sed -i "" -e "s#libavfilter_VERSION_MAJOR=0#libavfilter_VERSION_MAJOR=0.4.0#" config.mak

  else
    ./configure \
      --extra-cflags="-D_XBOX" \
      --disable-static \
      --disable-ipv6 \
      `if test "$use_debug" = "no"; then echo --disable-debug; fi` \
      --disable-muxers \
      --disable-encoders \
      --disable-decoder=mpeg_xvmc \
      --disable-devices \
      --disable-ffplay \
      --disable-ffserver \
      --disable-ffmpeg \
      --enable-shared \
      --enable-postproc \
      --enable-gpl \
      `if test "$use_vdpau" = "yes"; then echo --enable-vdpau; fi` \
      `if test "$use_external_libfaad" = "yes"; then echo --enable-libfaad; fi` \
      --enable-protocol=http \
      --enable-pthreads \
      --cc="$CC"
  fi
], [$USE_EXTERNAL_FFMPEG])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libdts], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    LDFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure \
      --disable-oss \
      --disable-solaris-audio \
      --disable-al-audio \
      --disable-win
  else
    ./configure \
      --disable-oss \
      --disable-solaris-audio \
      --disable-al-audio \
      --disable-win \
      CFLAGS="-fPIC"
  fi
], [$USE_EXTERNAL_LIBDTS])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libdvd/libdvdcss], [
  if test "$host_vendor" = "apple" ; then
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
    CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
      --disable-doc \
      --enable-static \
      --with-pic
  else
    ./configure \
      --disable-doc \
      --enable-static \
      --with-pic
  fi
], [$SKIP_CONFIG_DVDCSS])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libdvd/libdvdread], [
  if test "$host_vendor" = "apple" ; then
    ./configure2 MACOSX_DEPLOYMENT_TARGET=10.4 \
      --extra-cflags="$DVDREAD_CFLAGS -D__DARWIN__ -fPIC -DPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -I`pwd`/../libdvdcss/src" \
      --enable-static \
      --disable-shared \
      --cc="$CC" &&
    make dvdread-config &&
    mkdir -p `pwd`/../includes/dvdread
    cp `pwd`/../libdvdread/src/*.h `pwd`/../includes/dvdread
  else
    ./configure2 \
      --extra-cflags="$DVDREAD_CFLAGS -fPIC -DPIC -I`pwd`/../libdvdcss/src" \
      --enable-static \
      --disable-shared \
      --cc="$CC" &&
    make dvdread-config &&
    mkdir -p `pwd`/../includes/dvdread
    cp `pwd`/../libdvdread/src/*.h `pwd`/../includes/dvdread
  fi

], [0])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libdvd/libdvdnav], [
  if test "$host_vendor" = "apple" ; then
    ./configure2 MACOSX_DEPLOYMENT_TARGET=10.4 \
      --extra-cflags="$DVDREAD_CFLAGS -fPIC -DPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -I`pwd`/../includes" \
      --extra-ldflags="-L`pwd`/../libdvdread/obj" \
      --with-dvdread-config="`pwd`/../libdvdread/obj/dvdread-config" \
      --enable-static \
      --disable-shared \
      --cc="$CC"
  else
    ./configure2 \
      --extra-cflags="$DVDREAD_CFLAGS -fPIC -DPIC -I`pwd`/../includes" \
      --extra-ldflags="-L`pwd`/../libdvdread/obj" \
      --with-dvdread-config="`pwd`/../libdvdread/obj/dvdread-config" \
      --enable-static \
      --disable-shared \
      --cc="$CC"
  fi
], [0])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libfaad2], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-O3 -fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
      --with-pic \
      --with-mp4v2
  else
    ./configure \
      --with-pic \
      --with-mp4v2 \
      CFLAGS="-O3"
  fi
], [$USE_EXTERNAL_LIBFAAD])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/liba52], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
      --with-pic \
      --disable-static \
      --enable-shared \
      --disable-oss \
      --disable-solaris-audio \
      --disable-win \
      --disable-al-audio
  else
    ./configure \
      --with-pic \
      --disable-static \
      --enable-shared \
      --disable-oss \
      --disable-solaris-audio \
      --disable-win \
      --disable-al-audio \
      CFLAGS=-fPIC
  fi
], [$USE_EXTERNAL_LIBA52])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libmpeg2], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
      --with-pic \
      --disable-static \
      --enable-shared \
      --disable-directx \
      --disable-sdl \
      --without-x
  else
    ./configure \
      --with-pic \
      --disable-static \
      --enable-shared \
      --disable-directx \
      --disable-sdl \
      --without-x
  fi
], [$USE_EXTERNAL_LIBMPEG2])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libmad], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
      --with-pic 
  else
    ./configure \
      --with-pic
  fi
], [$USE_EXTERNAL_LIBMAD])

XB_CONFIG_MODULE([xbmc/lib/cximage-6.0/zlib], [
  if test "$host_vendor" = "apple" ; then
    export MACOSX_DEPLOYMENT_TARGET=10.4
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure
  fi
], [0])

XB_CONFIG_MODULE([xbmc/lib/libass], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4
  else
    CFLAGS="$CFLAGS -fPIC" \
    ./configure
  fi
], [$USE_EXTERNAL_LIBASS])

XB_CONFIG_MODULE([xbmc/lib/libid3tag/libid3tag],[
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -fno-common" \
    CPPFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -fno-common" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
      --disable-static \
      --disable-debugging \
      --with-pic
  else
    CFLAGS=-O3 \
    ./configure \
      --disable-static \
      --disable-debugging \
      --with-pic
  fi
], [0])

XB_CONFIG_MODULE([xbmc/visualizations/XBMCProjectM/libprojectM],[
  if test "$host_vendor" = "apple" ; then
    rm -f CMakeCache.txt && CC="" CXX=""  cmake -D CMAKE_C_FLAGS:STRING="-fno-common" -D CMAKE_CXX_FLAGS:STRING="-fno-common" -D CMAKE_BUILD_TYPE:STRING=RelWithDebInfo -D USE_FTGL:BOOL=OFF .
  else
    rm -f CMakeCache.txt && CC="" CXX=""  cmake -D CMAKE_BUILD_TYPE:STRING=RelWithDebInfo -D USE_FTGL:BOOL=OFF .
  fi
], [0])

XB_CONFIG_MODULE([xbmc/visualizations/Goom/goom2k4-0],[
  if test "$host_vendor" = "apple" ; then
    ./configure \
      CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
      CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4"\
      --disable-shared \
      --enable-static \
      --with-pic

  else
    ./configure  \
      --disable-shared \
      --enable-static \
      --with-pic

  fi
], [0])

XB_CONFIG_MODULE([xbmc/screensavers/rsxs-0.9/], [
  if test "$host_vendor" = "apple" ; then
    ./configure \
      CFLAGS="-fPIC -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
      CXXFLAGS="-fPIC -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
      LDFLAGS="-L/opt/local/lib" \
      LIBS="-lz" \
      --x-includes=/usr/X11/include --x-libraries=/usr/X11/lib \
      --without-xscreensaver \
      --disable-sound \
      --disable-cyclone \
      --disable-fieldlines \
      --disable-flocks \
      --disable-flux \
      --disable-helios \
      --disable-hyperspace \
      --disable-lattice \
      --disable-skyrocket
  else
    ./configure \
      CFLAGS="-fPIC" \ 
      CXXFLAGS="-fPIC" \
      --without-xscreensaver \
      --disable-sound \
      --disable-cyclone \
      --disable-fieldlines \
      --disable-flocks \
      --disable-flux \
      --disable-helios \
      --disable-hyperspace \
      --disable-lattice \
      --disable-skyrocket
  fi
], [0])

AC_OUTPUT

final_message="$final_message\n  prefix:\t$prefix\n$dashes"
echo -e "$final_message\n"