Merge pull request #3004 from nikolai-r/master
[vuplus_xbmc] / configure.in
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.59)
5 AC_INIT([xbmc], [12.9.7], [http://trac.xbmc.org])
6 AC_CONFIG_HEADERS([xbmc/config.h])
7 AH_TOP([#pragma once])
8 m4_include([m4/ax_python_devel.m4])
9 m4_include([m4/xbmc_arch.m4])
10
11 AC_CONFIG_AUX_DIR([build-aux])
12 AM_INIT_AUTOMAKE([foreign])
13 AC_CANONICAL_HOST
14
15 tolower(){
16   echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
17 }
18
19 # check for enabling additional players
20 AC_DEFUN([XB_ADD_PLAYER],
21 [
22   AC_MSG_CHECKING([for $2])
23   case $add_players in
24     *$2*)
25       AC_SUBST([USE_$1], 1)
26       AC_DEFINE([HAS_$1], 1, [using $2])
27       AC_MSG_RESULT([enabling $2])
28       ;;
29     *)
30       AC_MSG_RESULT([$2 is not enabled])
31   esac
32 ])
33
34 # check for enabling additional codecs
35 AC_DEFUN([XB_ADD_CODEC],
36 [
37   AC_MSG_CHECKING([for $2])
38   case $add_codecs in
39     *$2*)
40       AC_SUBST([USE_$1], 1)
41       AC_DEFINE([HAS_$1], 1, [using $2])
42       AC_MSG_RESULT([enabling $2])
43       ;;
44     *)
45       AC_MSG_RESULT([$2 is not enabled])
46   esac
47 ])
48
49 # check for library basenames
50 AC_DEFUN([XB_FIND_SONAME],
51 [
52   if echo "$host" | grep -q freebsd ; then
53     AC_MSG_CHECKING([for lib$2 soname])
54     $1_SONAME=[`ldconfig -r | sed -n "s;.* \(/.*lib$2\.so.*\)$;\1;p" | head -n 1`]
55     if test x$$1_SONAME != x ; then
56       $1_SONAME=[`basename $$1_SONAME`]
57     fi
58   elif [[ "$host_vendor" != "apple" ]]; then
59     AC_MSG_CHECKING([for lib$2 soname])
60     $1_FILENAME=$($CC -nostdlib -o /dev/null $LDFLAGS -l$2 -Wl,-M 2>/dev/null | grep "^LOAD.*$2" | awk '{V=2; print $V}')
61     if [[ -z $$1_FILENAME ]]; then
62       #try gold linker syntax
63       $1_FILENAME=$($CC -nostdlib -o /dev/null $LDFLAGS -l$2 -Wl,-t 3>&1 1>&2 2>&3 | grep "lib$2")
64     fi
65     if [[ ! -z $$1_FILENAME ]]; then
66       $1_SONAME=$($OBJDUMP -p $$1_FILENAME | grep "SONAME.*$2" | awk '{V=2; print $V}')
67     fi
68   else
69     AC_MSG_CHECKING([for lib$2 dylib])
70     gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
71     env_lib_path=[`echo $LDFLAGS | sed 's/-L[ ]*//g'`]
72     if test "$cross_compiling" = yes; then
73       host_lib_path=""
74     else
75       host_lib_path="/usr/lib /usr/local/lib"
76     fi
77     for path in $gcc_lib_path $env_lib_path $host_lib_path; do
78       lib=[`ls -- $path/lib$2.dylib 2>/dev/null`]
79       if test x$lib != x; then
80         # we want the path/name that is embedded in the dylib 
81         $1_SONAME=[`otool -L $lib | grep -v lib$2.dylib | grep lib$2 | awk '{V=1; print $V}'`]
82         $1_SONAME=[`basename $$1_SONAME`]
83       fi
84     done
85   fi
86   if [[ -z "$$1_SONAME" ]]; then
87     AC_MSG_RESULT([no])
88     if test -z "$3" || test "x${$3}" = "xyes"; then
89       AC_MSG_ERROR([Unable to determine soname of lib$2 library])
90     else
91       AC_MSG_WARN([Unable to determine soname of lib$2 library])
92       $3=no
93       AC_MSG_WARN([lib$2 support disabled])
94     fi
95   else
96     AC_MSG_RESULT([$$1_SONAME])
97     AC_SUBST($1_SONAME)
98   fi
99 ])
100
101 # Function to push and pop libs and includes for a command
102 AC_DEFUN([XB_PUSH_FLAGS], [
103   SAVE_LIBS="$LIBS"
104   SAVE_INCLUDES="$INCLUDES"
105   LIBS="[$2]"
106   INCLUDES="[$1]"
107   [$3]
108   LIBS="$SAVE_LIBS"
109   INCLUDES="$SAVE_INCLUDES"
110 ])
111
112 # General message strings
113 configure_debug="ERROR: this is a configure debug statement"
114 missing_library="Could not find a required library. Please see the README for your platform."
115 missing_headers="Could not find some required headers. Please see the README for your platform."
116 missing_program="Could not find a required program. Please see the README for your platform."
117 xrandr_not_found="== Could not find libXRandR. SDL will be used for resolution support. =="
118 xrandr_disabled="== XRandR support disabled. SDL will be used for resolution support. =="
119 waveform_enabled="== WAVEFORM enabled =="
120 waveform_disabled="== WAVEFORM disabled =="
121 spectrum_enabled="== SPECTRUM enabled =="
122 spectrum_disabled="== SPECTRUM disabled =="
123 goom_enabled="== GOOM enabled. =="
124 goom_disabled="== GOOM disabled. =="
125 alsa_disabled="== ALSA support disabled. =="
126 rsxs_enabled="== RSXS enabled. =="
127 rsxs_disabled="== RSXS disabled. =="
128 fishbmc_enabled="== FishBMC enabled. =="
129 fishbmc_disabled="== FishBMC disabled. =="
130 projectm_enabled="== ProjectM enabled. =="
131 projectm_disabled="== ProjectM disabled. =="
132 x11_enabled="== X11 enabled. =="
133 x11_disabled="== X11 disabled. =="
134 pulse_not_found="== Could not find libpulse. PulseAudio support disabled. =="
135 pulse_disabled="== PulseAudio support manually disabled. =="
136 dvdcss_enabled="== DVDCSS support enabled. =="
137 dvdcss_disabled="== DVDCSS support disabled. =="
138 hal_not_found="== Could not find hal. HAL support disabled. =="
139 halstorage_not_found="== Could not find hal-storage. HAL support disabled. =="
140 hal_disabled="== HAL support disabled. =="
141 avahi_not_found="== Could not find libavahi-common or libavahi-client. Avahi support disabled. =="
142 avahi_disabled="== Avahi support disabled. =="
143 mdnsembedded_not_found="== Could not find mDNSEmbedded. Might prevent zeroconf support. =="
144 mdnsembedded_disabled="== mDNSEmbedded support disabled. =="
145 vdpau_not_found="== Could not find libvdpau. VDPAU support disabled. =="
146 vdpau_disabled="== VDPAU support manually disabled. =="
147 vaapi_not_found="== Could not find libva. VAAPI support disabled. =="
148 vaapi_disabled="== VAAPI support manually disabled. =="
149 crystalhd_not_found="== Could not find libcrystalhd. CrystalHD support disabled. =="
150 crystalhd_disabled="== CrystalHD support manually disabled. =="
151 vtbdecoder_enabled="== VTBDecoder support enabled. =="
152 vtbdecoder_disabled="== VTBDecoder support manually disabled. =="
153 openmax_disabled="== OpenMax support manually disabled. =="
154 openmax_not_found="== Could not find libnvomx. OpenMax support disabled. =="
155 ssh_not_found="== Could not find libssh. =="
156 ssh_disabled="== SSH SFTP disabled. =="
157 librtmp_not_found="== Could not find libRTMP. RTMP support disabled. =="
158 librtmp_disabled="== RTMP support disabled. =="
159 libnfs_not_found="== Could not find libnfs. NFS client support disabled. =="
160 libnfs_disabled="== NFS support disabled. =="
161 libafpclient_not_found="== Could not find libafpclient. AFP client support disabled. =="
162 libafpclient_disabled="== AFP support disabled. =="
163 libshairport_not_found="== Could not find libshairport. =="
164 libshairplay_not_found="== Could not find libshairplay. =="
165 samba_disabled="== SAMBA support disabled. =="
166 libplist_not_found="== Could not find libplist. AirPlay support disabled. =="
167 libplist_disabled="== AirPlay support disabled. =="
168 alsa_not_found="== Could not find ALSA. ALSA support disabled. =="
169 dbus_not_found="== Could not find DBUS. DBUS support disabled. =="
170 libcap_disabled="== Capabilities detection support disabled. =="
171 libcap_not_found="== Could not find libcap. Capabilities detection support disabled. =="
172 gtest_enabled="== Google Test Framework will be configured. =="
173 gtest_disabled="== Google Test Framework will not be configured. =="
174
175 libudev_not_found="== Could not find libudev. Will use polling to check for device changes. =="
176 libudev_disabled="== udev support disabled. Will use polling to check for device changes. =="
177 libusb_not_found="== Could not find libusb. Plug and play USB device support will not be available. =="
178 libusb_disabled="== libusb disabled. Plug and play USB device support will not be available. =="
179 libusb_disabled_udev_found="== libusb disabled. =="
180 libcec_enabled="== libcec enabled. =="
181 libcec_disabled="== libcec disabled. CEC adapter support will not be available. =="
182
183 # External library message strings
184 external_libraries_enabled="== Use of all supported external libraries enabled. =="
185 external_libraries_disabled="== Use of all supported external libraries disabled. =="
186 external_ffmpeg_enabled="== Use of external ffmpeg enabled. =="
187 external_ffmpeg_disabled="== Use of external ffmpeg disabled. =="
188 ffmpeg_vdpau_not_supported="== External ffmpeg doesn't support VDPAU. VDPAU support disabled. =="
189 dashes="------------------------"
190 final_message="\n  XBMC Configuration:"
191 final_message="\n$dashes$final_message\n$dashes"
192
193 AC_ARG_ENABLE([shared-lib],
194   [AS_HELP_STRING([--enable-shared-lib],
195   [build libxbmc. helpful for tests (default is no)])],
196   [build_shared_lib=$enableval],
197   [build_shared_lib=no])
198
199 AC_ARG_ENABLE([debug],
200   [AS_HELP_STRING([--enable-debug],
201   [enable debugging information (default is yes)])],
202   [use_debug=$enableval],
203   [use_debug=yes])
204
205 AC_ARG_WITH([arch],
206   [AS_HELP_STRING([--with-arch],
207   [build with given arch passing to internal ffmpeg (default is no, needed for crosscompiling)])],
208   [use_arch=$withval],
209   [use_arch=no])
210
211 AC_ARG_WITH([platform],
212   [AS_HELP_STRING([--with-platform],
213   [use a pre-configured config for common arm boards])],
214   [use_platform=$withval],
215   [use_platform=none])
216
217 AC_ARG_WITH([cpu],
218   [AS_HELP_STRING([--with-cpu],
219   [build with given cpu passing to ffmpeg (default is no)])],
220   [use_cpu=$withval],
221   [use_cpu=no])
222
223 AC_ARG_ENABLE([neon],
224   [AS_HELP_STRING([--enable-neon],
225   [enable neon passing to ffmpeg (default is no)])],
226   [use_neon=$enableval],
227   [use_neon=no])
228
229 AC_ARG_ENABLE([optimizations],
230   [AS_HELP_STRING([--enable-optimizations],
231   [enable optimization (default is yes)])],
232   [use_optimizations=$enableval],
233   [use_optimizations=yes])
234
235 AC_ARG_ENABLE([gl],
236   [AS_HELP_STRING([--enable-gl],
237   [enable OpenGL rendering (default is yes)])],
238   [use_gl=$enableval],
239   [use_gl=yes])
240
241 AC_ARG_ENABLE([gles],
242   [AS_HELP_STRING([--enable-gles],
243   [enable OpenGLES rendering (default is no)])],
244   [use_gles=$enableval],
245   [use_gles=no])
246
247 AC_ARG_ENABLE([sdl],
248   [AS_HELP_STRING([--enable-sdl],
249   [enable SDL (default is auto)])],
250   [use_sdl=$enableval],
251   [use_sdl=auto])
252
253 AC_ARG_ENABLE([vdpau],
254   [AS_HELP_STRING([--enable-vdpau],
255   [enable VDPAU decoding (default is auto)])],
256   [use_vdpau=$enableval],
257   [use_vdpau=auto])
258
259 AC_ARG_ENABLE([vaapi],
260   [AS_HELP_STRING([--enable-vaapi],
261   [enable VAAPI decoding (default is auto)])],
262   [use_vaapi=$enableval],
263   [use_vaapi=auto])
264
265 AC_ARG_ENABLE([crystalhd],
266   [AS_HELP_STRING([--enable-crystalhd],
267   [enable CrystalHD decoding (default is auto)])],
268   [use_crystalhd=$enableval],
269   [use_crystalhd=auto])
270
271 AC_ARG_ENABLE([vtbdecoder],
272   [AS_HELP_STRING([--enable-vtbdecoder],
273   [enable VTBDecoder decoding (default is auto)])],
274   [use_vtbdecoder=$enableval],
275   [use_vtbdecoder=auto])
276
277 AC_ARG_ENABLE([openmax],
278   [AS_HELP_STRING([--enable-openmax],
279   [enable OpenMax decoding (default is auto, requires OpenGLES)])],
280   [use_openmax=$enableval],
281   [use_openmax=auto])
282
283 AC_ARG_ENABLE([tegra],
284   [AS_HELP_STRING([--enable-tegra],
285   [enable Tegra2 arm (default is no)])],
286   [use_tegra=$enableval],
287   [use_tegra=no])
288
289 AC_ARG_ENABLE([profiling],
290   [AS_HELP_STRING([--enable-profiling],
291   [enable gprof profiling (default is no)])],
292   [use_profiling=$enableval],
293   [use_profiling=no])
294
295 AC_ARG_ENABLE([joystick],
296   [AS_HELP_STRING([--enable-joystick],
297   [enable SDL joystick support (default is yes)])],
298   [use_joystick=$enableval],
299   [use_joystick=yes])
300
301 AC_ARG_ENABLE([xrandr],
302   [AS_HELP_STRING([--enable-xrandr],
303   [enable XRandR support (default is yes)])],
304   [use_xrandr=$enableval],
305   [use_xrandr=yes])
306
307 AC_ARG_ENABLE([waveform],
308   [AS_HELP_STRING([--enable-waveform],
309   [enable Waveform visualisation (default is yes)])],
310   [use_waveform=$enableval],
311   [use_waveform=yes])
312
313 AC_ARG_ENABLE([spectrum],
314   [AS_HELP_STRING([--enable-spectrum],
315   [enable Spectrum visualisation (default is yes)])],
316   [use_spectrum=$enableval],
317   [use_spectrum=yes])
318
319 AC_ARG_ENABLE([goom],
320   [AS_HELP_STRING([--enable-goom],
321   [enable GOOM visualisation (default is no)])],
322   [use_goom=$enableval],
323   [use_goom=no])
324
325 AC_ARG_ENABLE([rsxs],
326   [AS_HELP_STRING([--enable-rsxs],
327   [enable really slick X screensavers (default is yes)])],
328   [use_rsxs=$enableval],
329   [use_rsxs=yes])
330
331 AC_ARG_ENABLE([fishbmc],
332   [AS_HELP_STRING([--enable-fishbmc],
333   [enable FishBMC visualisation (default is yes)])],
334   [use_fishbmc=$enableval],
335   [use_fishbmc=yes])
336
337 AC_ARG_ENABLE([projectm],
338   [AS_HELP_STRING([--enable-projectm],
339   [enable ProjectM visualisation (default is yes)])],
340   [use_projectm=$enableval],
341   [use_projectm=yes])
342
343 AC_ARG_ENABLE([x11],
344   [AS_HELP_STRING([--enable-x11],
345   [enable x11 (default is yes) 'Linux Only'])],
346   [use_x11=$enableval],
347   [use_x11=yes])
348
349 AC_ARG_ENABLE([ccache],
350   [AS_HELP_STRING([--enable-ccache],
351   [enable building with ccache feature (default is auto)])],
352   [use_ccache=$enableval],
353   [use_ccache=auto])
354
355 AC_ARG_ENABLE([alsa],
356   [AS_HELP_STRING([--disable-alsa],
357   [disable ALSA support (only for linux/freebsd)])],
358   [use_alsa=$enableval],
359   [use_alsa=yes])
360
361 AC_ARG_ENABLE([pulse],
362   [AS_HELP_STRING([--enable-pulse],
363   [enable PulseAudio support (default is no)])],
364   [use_pulse=$enableval],
365   [use_pulse=no])
366
367 AC_ARG_ENABLE([ssh],
368   [AS_HELP_STRING([--disable-ssh],
369   [disable SSH SFTP support (default is enabled)])],
370   [use_ssh=$enableval],
371   [use_ssh=yes])
372
373 AC_ARG_ENABLE([rtmp],
374   [AS_HELP_STRING([--enable-rtmp],
375   [enable RTMP support via librtmp (default is auto)])],
376   [use_librtmp=$enableval],
377   [use_librtmp=auto])
378
379 AC_ARG_ENABLE([samba],
380   [AS_HELP_STRING([--disable-samba],
381   [disable SAMBA support (default is enabled)])],
382   [use_samba=$enableval],
383   [use_samba=yes])
384
385 AC_ARG_ENABLE([nfs],
386   [AS_HELP_STRING([--enable-nfs],
387   [enable NFS support via libnfs (default is auto)])],
388   [use_libnfs=$enableval],
389   [use_libnfs=auto])
390
391 AC_ARG_ENABLE([afpclient],
392   [AS_HELP_STRING([--enable-afpclient],
393   [enable AFP support via libafpclient (default is auto)])],
394   [use_libafpclient=$enableval],
395   [use_libafpclient=auto])
396
397 AC_ARG_ENABLE([airplay],
398   [AS_HELP_STRING([--enable-airplay],
399   [enable AirPlay support(default is auto)])],
400   [use_airplay=$enableval],
401   [use_airplay=auto])
402
403 AC_ARG_ENABLE([airtunes],
404   [AS_HELP_STRING([--enable-airtunes],
405   [enable AirTunes support(default is auto)])],
406   [use_airtunes=$enableval],
407   [use_airtunes=auto])
408
409 AC_ARG_ENABLE([upnp],
410   [AS_HELP_STRING([--disable-upnp],
411   [disable UPnP support (default is enabled)])],
412   [use_upnp=$enableval],
413   [use_upnp=yes])
414
415 AC_ARG_ENABLE([ffmpeg_libvorbis],
416   [AS_HELP_STRING([--enable-ffmpeg-libvorbis],
417   [enable FFmpeg vorbis encoding (default is no)])],
418   [use_ffmpeg_libvorbis=$enableval],
419   [use_ffmpeg_libvorbis=no])
420
421 AC_ARG_ENABLE([dvdcss],
422   [AS_HELP_STRING([--enable-dvdcss],
423   [enable DVDCSS support (default is yes)])],
424   [use_dvdcss=$enableval],
425   [use_dvdcss=yes])
426
427 AC_ARG_ENABLE([mid],
428   [AS_HELP_STRING([--enable-mid],
429   [enable MID support (default is no)])],
430   [use_mid=$enableval],
431   [use_mid=no])
432
433 AC_ARG_ENABLE([hal],
434   [AS_HELP_STRING([--disable-hal],
435   [disable HAL support (default is enabled if hal and hal-storage is found)])],
436   [use_hal=$enableval],
437   [use_hal=yes])
438
439 AC_ARG_ENABLE([avahi],
440   [AS_HELP_STRING([--disable-avahi],
441   [disable Avahi support (default is enabled if libavahi-common and libavahi-client is found)])],
442   [use_avahi=$enableval],
443   [use_avahi=yes])
444   
445   AC_ARG_ENABLE([mdnsembedded],
446   [AS_HELP_STRING([--disable-mdnsembedded],
447   [disable mDNSEmbedded support (default is auto)])],
448   [use_mdnsembedded=$enableval],
449   [use_mdnsembedded=auto])
450
451 AC_ARG_ENABLE([non-free],
452   [AS_HELP_STRING([--disable-non-free],
453   [disable componentents with non-compliant licenses])],
454   [use_nonfree=$enableval],
455   [use_nonfree=yes])
456
457 AC_ARG_ENABLE([asap-codec],
458   [AS_HELP_STRING([--enable-asap-codec],
459   [enable ASAP ADPCM support])],
460   [use_asap=$enableval],
461   [use_asap=no])
462
463 AC_ARG_ENABLE([mysql],
464   [AS_HELP_STRING([--disable-mysql],
465   [disable mysql])],
466   [use_mysql=$enableval],
467   [use_mysql=yes])
468
469 AC_ARG_ENABLE([webserver],
470   [AS_HELP_STRING([--disable-webserver],
471   [disable webserver])],
472   [use_webserver=$enableval],
473   [use_webserver=yes])
474
475 AC_ARG_ENABLE([optical-drive],
476   [AS_HELP_STRING([--disable-optical-drive],
477   [disable optical drive])],
478   [use_optical_drive=$enableval],
479   [use_optical_drive=yes])
480
481 AC_ARG_ENABLE([libbluray],
482   [AS_HELP_STRING([--enable-libbluray],
483   [enable libbluray support])],
484   [use_libbluray=$enableval],
485   [use_libbluray=auto])
486
487 AC_ARG_ENABLE([texturepacker],
488   [AS_HELP_STRING([--enable-texturepacker],
489   [enable texturepacker support (default is yes)])],
490   [use_texturepacker=$enableval],
491   [use_texturepacker=auto])
492
493 AC_ARG_WITH([lirc-device],
494   [AS_HELP_STRING([--with-lirc-device=file],
495   [specify the default LIRC device (default is /dev/lircd)])],
496   [lirc_device=$withval],
497   [lirc_device=/dev/lircd])
498 AC_DEFINE_UNQUOTED([LIRC_DEVICE], ["$lirc_device"], [Default LIRC device])
499
500 AC_ARG_ENABLE([udev],
501   [AS_HELP_STRING([--enable-udev],
502   [enable udev support (default is auto)])],
503   [use_libudev=$enableval],
504   [use_libudev=auto])
505
506 AC_ARG_ENABLE([libusb],
507   [AS_HELP_STRING([--enable-libusb],
508   [enable libusb support (default is auto)])],
509   [use_libusb=$enableval],
510   [use_libusb=auto])
511
512 AC_ARG_ENABLE([libcec],
513   [AS_HELP_STRING([--enable-libcec],
514   [enable libcec support (default is auto)])],
515   [use_libcec=$enableval],
516   [use_libcec=auto])
517
518 AC_ARG_ENABLE([libmp3lame],
519   [AS_HELP_STRING([--enable-libmp3lame],
520   [enable lame mp3 encoder support (default is auto)])],
521   [use_libmp3lame=$enableval],
522   [use_libmp3lame=auto])
523
524 AC_ARG_ENABLE([libvorbisenc],
525   [AS_HELP_STRING([--enable-libvorbisenc],
526   [enable vorbis encoder support (default is auto)])],
527   [use_libvorbisenc=$enableval],
528   [use_libvorbisenc=auto])
529
530 AC_ARG_ENABLE([libcap],
531   [AS_HELP_STRING([--enable-libcap],
532   [enable libcap support (default is auto)])],
533   [use_libcap=$enableval],
534   [use_libcap=auto])
535
536 AC_ARG_ENABLE([player],
537   [AS_HELP_STRING([--enable-player],
538   [enable additional players from a list of comma separated names, (default is none, choices are amlplayer, omxplayer)])],
539   [add_players=$enableval],
540   [add_players=no])
541
542 AC_ARG_ENABLE([gtest],
543   [AS_HELP_STRING([--enable-gtest],
544   [configure Google Test Framework (default is no)])],
545   [configure_gtest=$enableval],
546   [configure_gtest=no])
547
548 AC_ARG_ENABLE([codec],
549   [AS_HELP_STRING([--enable-codec],
550   [enable additional codecs from a list of comma separated names, (default is none, choices are amcodec, libstagefright)])],
551   [add_codecs=$enableval],
552   [add_codecs=no])
553
554 ### External libraries options
555 AC_ARG_ENABLE([external-libraries],
556   [AS_HELP_STRING([--enable-external-libraries],
557   [enable use of all supported external libraries (default is no) 'Linux only'])],
558   [use_external_libraries=$enableval],
559   [use_external_libraries=no])
560
561 AC_ARG_ENABLE([external-ffmpeg],
562   [AS_HELP_STRING([--enable-external-ffmpeg],
563   [enable use of external ffmpeg libraries (default is no) 'Linux only'])],
564   [use_external_ffmpeg=$enableval],
565   [use_external_ffmpeg=$use_external_libraries])
566
567 AC_ARG_ENABLE([libav-compat],
568   [AS_HELP_STRING([--enable-libav-compat],
569   [build a wrapper around libav to provide the functions needed by XBMC. This is
570    *not* supported by XBMC developers and is provided only for convenience. (default is no) 'Linux only'])],
571   [use_libav_hacks=$enableval],
572   [use_libav_hacks=no])
573
574 ### End of external library options
575
576 if test "x$host_vendor" != "xapple"; then
577   DEFAULT_COMPILE_FLAGS="-fPIC -DPIC -D_REENTRANT"
578   DEFAULT_COMPILE_FLAGS="$DEFAULT_COMPILE_FLAGS -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64"
579 fi
580
581 # Checks for programs.
582 PASSED_CXXFLAGS=$CXXFLAGS # Hack to override autoconf default values
583 AC_PROG_CXX
584 CXXFLAGS="$PASSED_CXXFLAGS $DEFAULT_COMPILE_FLAGS"
585 PASSED_CFLAGS=$CFLAGS # Hack to override autoconf default values
586 AC_PROG_CC
587 AC_PROG_LIBTOOL
588 CFLAGS="$PASSED_CFLAGS $DEFAULT_COMPILE_FLAGS"
589 AC_PROG_AWK
590 AC_PROG_LN_S
591 AC_PROG_MAKE_SET
592 MAKE="${MAKE:-make}"
593 OBJDUMP="${OBJDUMP:-objdump}"
594
595 # ffmpeg needs the output of uname -s (e.x. linux, darwin) for the target_os
596 # there is no autoconf variable which will give
597 # the correct output format when doing cross compilation
598 # so we have to use our own var here
599 # defaults to the build side target_os
600 # and should be overridden for cross below (see android)
601 ffmpeg_target_os=$(tolower $(uname -s))
602
603 # host detection and setup
604 case $host in
605   i*86*-android-linux-gnu*)
606      target_platform=target_android
607      ARCH="i486-linux"
608      use_arch="x86"
609      use_cpu="i686"
610      ffmpeg_target_os=linux
611      ;;
612   i*86*-linux-gnu*)
613      ARCH="i486-linux"
614      ;;
615   x86_64-*-linux-gnu*)
616      ARCH="x86_64-linux"
617      ;;
618   i386-*-freebsd*)
619      ARCH="x86-freebsd"
620      MAKE="gmake"
621      ;;
622   amd64-*-freebsd*)
623      ARCH="x86_64-freebsd"
624      MAKE="gmake"
625      ;;
626   arm-apple-darwin*)
627      use_joystick=no
628      use_neon=yes
629      use_libcec=no
630      use_crystalhd=no
631      use_vtbdecoder=yes
632      use_optical_drive=no
633      use_dvdcss=no
634      use_gles=yes
635      use_cpu=cortex-a8
636      use_texturepacker_native=yes
637      ARCH="arm-osx"
638      use_arch="arm"
639      PYTHON_VERSION="2.6"
640      PYTHON_LDFLAGS="-L${prefix}/lib -lpython2.6"
641      PYTHON_CPPFLAGS="-I${prefix}/include/python2.6"
642      PYTHON_SITE_PKG="${prefix}/lib/python2.6/site-packages"
643      PYTHON_NOVERSIONCHECK="no-check"
644      ;;
645   *86*-apple-darwin*)
646      use_joystick=no
647      use_vtbdecoder=no
648      use_texturepacker_native=yes
649      ARCH="x86-osx"
650      ;;
651   powerpc-apple-darwin*)
652      use_joystick=no
653      use_vtbdecoder=no
654      use_crystalhd=no
655      ARCH="powerpc-osx"
656      use_arch="ppc"
657      ;;
658   powerpc-*-linux-gnu*)
659      ARCH="powerpc-linux"
660      ;;
661   powerpc64-*-linux-gnu*)
662      ARCH="powerpc64-linux"
663      ;;
664   arm*-*-linux-gnu*)
665      use_texturepacker=no
666      ARCH="arm"
667      use_arch="arm"
668      ffmpeg_target_os=linux
669      use_joystick=no
670      use_neon=yes
671      use_gles=yes
672      use_sdl=no
673      use_x11=no
674      ;;
675   arm*-*linux-android*)
676      target_platform=target_android
677      use_arch="arm"
678      use_cpu=cortex-a9
679      ARCH="arm"
680      ffmpeg_target_os=linux
681      use_joystick=no
682      use_neon=yes
683      use_gles=yes
684      use_optical_drive=no
685      use_sdl=no
686      use_x11=no
687      build_shared_lib=yes
688      ;;
689   *)
690      AC_MSG_ERROR(unsupported host ($host))
691 esac
692 AC_SUBST([ARCH])
693
694 check_sdl_arch=[`file $USE_TEXTUREPACKER_NATIVE_ROOT/lib/libSDL_image.dylib | awk '{print $NF}'`]
695 if test "x$check_sdl_arch" = "xi386" ; then
696   DARWIN_NATIVE_ARCH=-m32
697 elif test "x$check_sdl_arch" = "xx86_64" ; then
698   DARWIN_NATIVE_ARCH=-m64
699 fi
700 AC_SUBST([DARWIN_NATIVE_ARCH])
701
702 if test "$target_platform" = "target_android" ; then
703   USE_ANDROID=1
704   use_texturepacker_native=yes
705   webserver_checkdepends=yes
706   CFLAGS="$CFLAGS -Wno-psabi"
707   CXXFLAGS="$CXXFLAGS -Wno-psabi"
708   AC_DEFINE(HAS_EGLGLES, [1], [Define if supporting EGL based GLES Framebuffer])
709 fi
710
711 case $use_platform in
712   raspberry-pi)
713      target_platform=target_raspberry_pi
714      use_neon=no
715      use_texturepacker=yes
716      use_texturepacker_native=yes
717      use_arch="arm"
718      use_cpu=arm1176jzf-s
719      use_hardcoded_tables="yes"
720      use_alsa="no"
721      ARCH="arm"
722      AC_DEFINE(HAS_EGLGLES, [1], [Define if supporting EGL based GLES Framebuffer])
723      USE_OMXLIB=1; AC_DEFINE([HAVE_OMXLIB],[1],["Define to 1 if OMX libs is enabled"])
724      CFLAGS="$CFLAGS"
725      CXXFLAGS="$CXXFLAGS"
726      ffmpeg_target_os=linux
727      ;;
728 esac
729
730 XBMC_SETUP_ARCH_DEFINES()
731
732 # check for GIT_REV
733 AC_CHECK_PROG(HAVE_GIT,git,"yes","no",)
734 if test "$GIT_REV" = ""; then
735   if test -f VERSION ; then
736     GIT_REV=$(awk 'END{print substr($1,1,16)}' VERSION)
737   elif test "$HAVE_GIT" = "yes"; then
738     GIT_REV=$(git --no-pager log --abbrev=7 -n 1 --pretty=format:"%h %ci" HEAD | awk '{gsub("-", "");print $2"-"$1}')
739   else
740     GIT_REV="Unknown"
741   fi
742 fi
743 final_message="$final_message\n  git Rev.:\t${GIT_REV}"
744
745 if test "$host_vendor" = "apple"; then
746   echo "#define GIT_REV \"$GIT_REV\"" > git_revision.h
747 else
748   SDL_DEFINES="$SDL_DEFINES -D'GIT_REV=\"$GIT_REV\"'"
749 fi
750
751 if test "$build_shared_lib" = "yes"; then
752   final_message="$final_message\n Shared lib\tYes"
753   AC_SUBST(USE_LIBXBMC,1)
754 fi
755
756
757 # platform debug flags
758 if test "$use_debug" = "yes"; then
759   final_message="$final_message\n  Debugging:\tYes"
760   if test "$use_profiling" = "yes"; then
761     final_message="$final_message\n  Profiling:\tYes"
762     DEBUG_FLAGS="-g -pg -D_DEBUG -Wall"
763   else
764     final_message="$final_message\n  Profiling:\tNo"
765     DEBUG_FLAGS="-g -D_DEBUG -Wall"
766   fi
767 else
768   final_message="$final_message\n  Debugging:\tNo"
769   if test "$use_profiling" = "yes"; then
770     final_message="$final_message\n  Profiling:\tYes"
771     DEBUG_FLAGS="-pg -DNDEBUG=1"
772   else
773     final_message="$final_message\n  Profiling:\tNo"
774     DEBUG_FLAGS="-DNDEBUG=1"
775   fi
776 fi
777 CFLAGS="$CFLAGS $DEBUG_FLAGS"
778 CXXFLAGS="$CXXFLAGS $DEBUG_FLAGS"
779
780
781 if test "$use_optimizations" = "yes"; then
782   final_message="$final_message\n  Optimization:\tYes"
783   if test "$target_platform" = "target_raspberry_pi"; then
784     CXXFLAGS="$CXXFLAGS"
785     CFLAGS="$CFLAGS"
786   else
787     CXXFLAGS="-O2 $CXXFLAGS"
788     CFLAGS="-O2 $CFLAGS"
789   fi
790 else
791   final_message="$final_message\n  Optimization:\tNo"
792 fi
793
794
795 # platform specific flags
796 if echo "$ARCH" | grep -q "freebsd" ; then
797   LOCALBASE="${LOCALBASE:-/usr/local}"
798   CFLAGS="$CFLAGS -I$LOCALBASE/include"
799   CXXFLAGS="$CXXFLAGS -I$LOCALBASE/include"
800   CPPFLAGS="$CPPFLAGS -I$LOCALBASE/include"
801   LDFLAGS="$LDFLAGS -L$LOCALBASE/lib"
802   FFMPEG_EXTRACFLAGS="-I$LOCALBASE/include"
803 fi
804 if test "$host_vendor" = "apple" ; then
805   # standard xbmc paths
806   INCLUDES="$INCLUDES -I\$(abs_top_srcdir)/xbmc/osx"
807   if test "$use_arch" != "arm"; then
808     LIBS="$LIBS -framework ApplicationServices"
809     LIBS="$LIBS -framework AudioUnit"
810     LIBS="$LIBS -framework AudioToolbox"
811     LIBS="$LIBS -framework Cocoa"
812     LIBS="$LIBS -framework CoreAudio"
813     LIBS="$LIBS -framework CoreVideo"
814     LIBS="$LIBS -framework CoreServices"
815     LIBS="$LIBS -framework CoreFoundation"
816     LIBS="$LIBS -framework DiskArbitration"
817     LIBS="$LIBS -framework IOKit"
818     LIBS="$LIBS -framework IOSurface"
819     LIBS="$LIBS -framework QuartzCore"
820     LIBS="$LIBS -framework SystemConfiguration"
821   fi
822   USE_EXTERNAL_FFMPEG=1
823 elif test "$target_platform" = "target_raspberry_pi"; then
824   ARCH="arm"
825   use_arch="arm"
826 elif test "$use_arch" = "arm"; then
827   CFLAGS="$CFLAGS -mno-apcs-stack-check"
828   CXXFLAGS="$CXXFLAGS -mno-apcs-stack-check"
829   FFMPEG_EXTRACFLAGS=""
830   if test "$use_tegra" = "yes"; then
831     # Compile for ARMv7a architecture, need to test gcc for vfpv3-d16 support 
832     SAVE_CFLAGS="$CFLAGS"
833     CFLAGS="-mfpu=vfpv3-d16"
834     AC_COMPILE_IFELSE(
835       [AC_LANG_SOURCE([int foo;])],
836       [ CFLAGS="$SAVE_CFLAGS -Wno-psabi -Wa,-march=armv7a -mtune=cortex-a9 -mfpu=vfpv3-d16 -mthumb-interwork"
837         CXXFLAGS="$CXXFLAGS -Wno-psabi -Wa,-march=armv7a -mtune=cortex-a9 -mfpu=vfpv3-d16 -mthumb-interwork"
838         FFMPEG_EXTRACFLAGS="$FFMPEG_EXTRACFLAGS -mtune=cortex-a9 -mfpu=vfpv3-d16"
839         use_cpu=cortex-a9],
840       [ CFLAGS="$SAVE_CFLAGS -Wa,-march=armv6 -mtune=cortex-a8 -mthumb-interwork"
841         CXXFLAGS="$CXXFLAGS -Wa,-march=armv6 -mtune=cortex-a8 -mthumb-interwork"    
842         use_cpu=cortex-a8])
843   else
844     if test "$use_neon" = "yes"; then 
845       CFLAGS="$CFLAGS -mfpu=neon -mvectorize-with-neon-quad"
846       CXXFLAGS="$CXXFLAGS -mfpu=neon -mvectorize-with-neon-quad"
847       FFMPEG_EXTRACFLAGS="$FFMPEG_EXTRACFLAGS -mfpu=neon"
848     fi
849   fi
850 fi
851
852 # Checks for library functions.
853 AC_FUNC_ALLOCA
854 AC_FUNC_CHOWN
855 AC_FUNC_CLOSEDIR_VOID
856 AC_FUNC_ERROR_AT_LINE
857 AC_FUNC_FSEEKO
858 AC_PROG_GCC_TRADITIONAL
859 AC_FUNC_LSTAT
860 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
861 AC_FUNC_MEMCMP
862 AC_FUNC_MKTIME
863 AC_FUNC_MMAP
864 # Boxee is apparently having compile problems
865 # if HAVE_REALLOC is defined.  Sort this later.
866 #AC_FUNC_REALLOC
867 AC_FUNC_SELECT_ARGTYPES
868 AC_FUNC_SETVBUF_REVERSED
869 AC_TYPE_SIGNAL
870 AC_FUNC_STAT
871 AC_FUNC_STRCOLL
872 AC_FUNC_STRFTIME
873 AC_FUNC_STRTOD
874 AC_FUNC_UTIME_NULL
875 AC_FUNC_VPRINTF
876 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 posix_fadvise])
877
878 # Check for various sizes
879 AC_CHECK_SIZEOF([int])
880 AC_CHECK_SIZEOF([size_t])
881
882 # Check for intrinsics
883 AC_MSG_CHECKING([for __sync_add_and_fetch(temp, 1)])
884 AC_TRY_LINK([],[long* temp=0; long ret=__sync_add_and_fetch(temp, 1);],
885                 [have_builtin_sync_add_and_fetch=yes],
886                 [have_builtin_sync_add_and_fetch=no])
887 AC_MSG_RESULT($have_builtin_sync_add_and_fetch)
888 if test "x$have_builtin_sync_add_and_fetch" = "xyes"; then
889     AC_DEFINE(HAS_BUILTIN_SYNC_ADD_AND_FETCH, 1,
890         [Define to 1 if your compiler supports the __sync_add_and_fetch() intrinsic.])
891 fi
892
893 AC_MSG_CHECKING([for __sync_sub_and_fetch(temp, 1)])
894 AC_TRY_LINK([],[long* temp=0; long ret=__sync_sub_and_fetch(temp, 1);],
895                 [have_builtin_sync_sub_and_fetch=yes],
896                 [have_builtin_sync_sub_and_fetch=no])
897 AC_MSG_RESULT($have_builtin_sync_sub_and_fetch)
898 if test "x$have_builtin_sync_sub_and_fetch" = "xyes"; then
899     AC_DEFINE(HAS_BUILTIN_SYNC_SUB_AND_FETCH, 1,
900         [Define to 1 if your compiler supports the __sync_sub_and_fetch() intrinsic.])
901 fi
902
903 AC_MSG_CHECKING([for __sync_val_compare_and_swap(temp, 1, 1)])
904 AC_TRY_LINK([],[long *temp = 0; long ret=__sync_val_compare_and_swap(temp, 1, 1);],
905                 [have_builtin_sync_val_compare_and_swap=yes],
906                 [have_builtin_sync_val_compare_and_swap=no])
907 AC_MSG_RESULT($have_builtin_sync_val_compare_and_swap)
908 if test "x$have_builtin_sync_val_compare_and_swap" = "xyes"; then
909     AC_DEFINE(HAS_BUILTIN_SYNC_VAL_COMPARE_AND_SWAP, 1,
910         [Define to 1 if your compiler supports the __sync_val_compare_and_swap() intrinsic.])
911 fi
912
913 # Add top source directory for all builds so we can use config.h
914 INCLUDES="-I\$(abs_top_srcdir) $INCLUDES" 
915
916 # Check inotify availability
917 AC_CHECK_HEADER([sys/inotify.h], AC_DEFINE([HAVE_INOTIFY],[1],[Define if we have inotify]),)
918
919 # Checks for boost headers using CXX instead of CC
920 AC_LANG_PUSH([C++])
921 AC_CHECK_HEADER([boost/shared_ptr.hpp],, AC_MSG_ERROR($missing_library))
922 AC_LANG_POP([C++])
923
924 # Python
925 if test -z "$PYTHON_NOVERSIONCHECK"; then
926   AX_PYTHON_DEVEL([>= 2.4])
927   PYTHON_VERSION=$ac_python_version
928 fi
929
930 if test -z "$PYTHON_VERSION"; then
931   AC_MSG_ERROR([Can't find a Python version.])
932 else
933   LIBS="$LIBS $PYTHON_LDFLAGS"
934   AC_MSG_NOTICE([Using Python $PYTHON_VERSION])
935 fi
936
937 # Checks for platforms libraries.
938 if test "$use_gles" = "yes"; then
939   use_gl="no"
940   # GLES overwrites GL if both set to yes.
941   if test "$host_vendor" = "apple" ; then
942     AC_DEFINE([HAVE_LIBEGL],[1],["Define to 1 if you have the `EGL' library (-lEGL)."])
943     AC_DEFINE([HAVE_LIBGLESV2],[1],["Define to 1 if you have the `GLESv2' library (-lGLESv2)."])
944     AC_MSG_RESULT(== WARNING: OpenGLES support is assumed.)
945   else
946     if test "$target_platform" = "target_raspberry_pi"; then
947       AC_DEFINE([HAVE_LIBEGL],[1],["Define to 1 if you have the `EGL' library (-lEGL)."])
948       AC_DEFINE([HAVE_LIBGLESV2],[1],["Define to 1 if you have the `GLESv2' library (-lGLESv2)."])
949       AC_MSG_RESULT(== WARNING: OpenGLES support is assumed.)
950       LIBS="$LIBS -lEGL -lGLESv2 -lbcm_host -lvcos -lvchiq_arm"
951     else
952       AC_CHECK_LIB([EGL],   [main],, AC_MSG_ERROR($missing_library))
953       AC_CHECK_LIB([GLESv2],[main],, AC_MSG_ERROR($missing_library))
954     fi
955   fi
956 else
957   if test "$use_gl" = "yes"; then
958     if test "$host_vendor" = "apple" ; then
959       # linking to OpenGL.framework instead of libGL, libGLU so AC_CHECK_LIB will fail
960       LIBS="$LIBS -framework OpenGL"
961       AC_DEFINE([HAVE_LIBGL],[1],["Define to 1 if you have the `GL' library (-lGL)."])
962       AC_MSG_RESULT(== WARNING: OpenGL support is assumed.)
963       AC_DEFINE([HAVE_LIBGLU],[1],["Define to 1 if you have the `GLU' library (-lGLU)."])
964       AC_MSG_RESULT(== WARNING: OpenGLU support is assumed.)
965       AC_CHECK_LIB([GLEW],[main],, AC_MSG_ERROR($missing_library))
966     else
967       AC_CHECK_LIB([GL],  [main],, AC_MSG_ERROR($missing_library))
968       AC_CHECK_LIB([GLEW],[main],, AC_MSG_ERROR($missing_library))
969       AC_CHECK_LIB([GLU], [main],, AC_MSG_ERROR($missing_library))
970     fi
971   else
972     AC_MSG_RESULT(== WARNING: OpenGL support is disabled. XBMC will run VERY slow. ==)
973     AC_CHECK_LIB([SDL_gfx],[main])
974   fi
975 fi
976
977 # platform common libraries
978 if test "$use_mysql" = "yes"; then
979   AC_PATH_PROG(MYSQL_CONFIG, mysql_config,"no")
980   if test "x$MYSQL_CONFIG" != "xno"; then
981     AC_DEFINE([HAVE_MYSQL],[1],["Define to 1 if you have the `mysql' library (-lmysqlclient)."])
982     INCLUDES="$INCLUDES `$MYSQL_CONFIG --include`"
983     MYSQL_LIBS=`$MYSQL_CONFIG --libs`
984     LIBS="$LIBS $MYSQL_LIBS"
985     AC_SUBST(MYSQL_LIBS)
986   else
987     AC_MSG_ERROR($missing_program)
988   fi
989 fi
990 AC_CHECK_HEADER([ass/ass.h],, AC_MSG_ERROR($missing_library))
991 AC_CHECK_HEADER([mpeg2dec/mpeg2.h],, AC_MSG_ERROR($missing_library))
992 AC_CHECK_HEADER([mpeg2dec/mpeg2convert.h],, AC_MSG_ERROR($missing_library),
993   AC_INCLUDES_DEFAULT()
994   [#include <mpeg2dec/mpeg2.h>])
995 AC_CHECK_HEADER([mad.h],,            AC_MSG_ERROR($missing_library))
996 AC_CHECK_HEADER([jpeglib.h],,        AC_MSG_ERROR($missing_library))
997 AC_CHECK_HEADER([samplerate.h],,     AC_MSG_ERROR($missing_library))
998 AC_CHECK_HEADER([ogg/ogg.h],,        AC_MSG_ERROR($missing_library))
999 AC_CHECK_HEADER([vorbis/vorbisfile.h],, AC_MSG_ERROR($missing_library))
1000 AC_CHECK_HEADER([libmodplug/modplug.h],, AC_MSG_ERROR($missing_library))
1001 AC_CHECK_HEADER([curl/curl.h],, AC_MSG_ERROR($missing_library))
1002 AC_CHECK_HEADER([FLAC/stream_decoder.h],, AC_MSG_ERROR($missing_library))
1003
1004 # we need to check for the header because if it exists we set the openssl
1005 # and gcrypt MT callback hooks. This is mostly so that libcurl operates 
1006 # in MT manner correctly.
1007 AC_CHECK_HEADER([openssl/crypto.h], AC_DEFINE([HAVE_OPENSSL],[1],[Define if we have openssl]),)
1008 AC_CHECK_HEADER([gcrypt.h], gcrypt_headers_available=yes,gcrypt_headers_available=no)
1009 if test "$gcrypt_headers_available" = "yes"; then
1010    # if we have the headers then we must have the lib
1011    AC_CHECK_LIB([gpg-error],[main],, AC_MSG_ERROR($missing_library))
1012    AC_CHECK_LIB([gcrypt],[gcry_control],, AC_MSG_ERROR($missing_library))
1013    AC_DEFINE([HAVE_GCRYPT],[1],[Define if we have gcrypt])
1014 fi
1015
1016 AC_CHECK_LIB([bz2],         [main],, AC_MSG_ERROR($missing_library))
1017 AC_CHECK_LIB([jpeg],        [main],, AC_MSG_ERROR($missing_library)) # check for cximage
1018 AC_CHECK_LIB([tiff],        [main],, AC_MSG_ERROR($missing_library))
1019 if echo "$ARCH" | grep -q freebsd; then
1020 AC_CHECK_LIB([pthread],     [main],LIBS="-pthread $LIBS", AC_MSG_ERROR($missing_library))
1021 AC_CHECK_LIB([pthread],     [pthread_set_name_np],
1022   AC_DEFINE([HAVE_PTHREAD_SET_NAME_NP],[1],["Define to 1 if pthread has pthread_set_name_np"]),
1023   AC_MSG_RESULT([Could not find pthread_set_name_np in pthread]))
1024 else
1025 if test "$target_platform" != "target_android" ; then
1026   AC_CHECK_LIB([pthread],     [main],, AC_MSG_ERROR($missing_library))
1027   AC_CHECK_LIB([pthread],     [pthread_setname_np],
1028     AC_DEFINE([HAVE_PTHREAD_SETNAME_NP],[1],["Define to 1 if pthread has pthread_setname_np"]),
1029     AC_MSG_RESULT([Could not find pthread_setname_np in pthread]))
1030 fi
1031 fi
1032 AC_CHECK_LIB([lzo2],        [main],, AC_MSG_ERROR($missing_library))
1033 AC_CHECK_LIB([z],           [main],, AC_MSG_ERROR($missing_library))
1034 AC_CHECK_LIB([crypto],      [main],, AC_MSG_ERROR($missing_library))
1035 AC_CHECK_LIB([ssl],         [main],, AC_MSG_ERROR($missing_library))
1036 if test "$use_mysql" = "yes"; then
1037   AC_CHECK_LIB([mysqlclient], [main],, AC_MSG_ERROR($missing_library))
1038 fi
1039 AC_CHECK_LIB([bluetooth],   [hci_devid],, AC_MSG_RESULT([Could not find suitable version of libbluetooth]))
1040 AC_CHECK_LIB([yajl],        [main],, AC_MSG_ERROR($missing_library))
1041 AC_CHECK_LIB([tinyxml],     [main],, AC_MSG_ERROR($missing_library))
1042 if test "$target_platform" = "target_android" ; then
1043   AC_CHECK_LIB([android],     [main],, AC_MSG_ERROR($missing_library))
1044   AC_CHECK_LIB([log],         [__android_log_vprint],, AC_MSG_ERROR($missing_library))
1045   AC_CHECK_LIB([jnigraphics],     [main],, AC_MSG_ERROR($missing_library))
1046 fi
1047 PKG_CHECK_MODULES([FRIBIDI],    [fribidi],
1048   [INCLUDES="$INCLUDES $FRIBIDI_CFLAGS"; LIBS="$LIBS $FRIBIDI_LIBS"],
1049   AC_MSG_ERROR($missing_library))
1050 PKG_CHECK_MODULES([SQLITE3],    [sqlite3],
1051   [INCLUDES="$INCLUDES $SQLITE3_CFLAGS"; LIBS="$LIBS $SQLITE3_LIBS"],
1052   AC_MSG_ERROR($missing_library))
1053 PKG_CHECK_MODULES([PNG],        [libpng],
1054   [INCLUDES="$INCLUDES $PNG_CFLAGS"; LIBS="$LIBS $PNG_LIBS"],
1055   AC_MSG_ERROR($missing_library))
1056 PKG_CHECK_MODULES([PCRECPP],    [libpcrecpp],
1057   [INCLUDES="$INCLUDES $PCRECPP_CFLAGS"; LIBS="$LIBS $PCRECPP_LIBS"]; \
1058   AC_DEFINE([HAVE_LIBPCRECPP],[1],["Define to 1 if libpcrecpp is installed"]),
1059   AC_MSG_ERROR($missing_library))
1060 PKG_CHECK_MODULES([PCRE],       [libpcre],
1061   [INCLUDES="$INCLUDES $PCRE_CFLAGS"; LIBS="$LIBS $PCRE_LIBS"]; \
1062   AC_DEFINE([HAVE_LIBPCRE],[1],["Define to 1 if libpcre is installed"]),
1063   AC_MSG_ERROR($missing_library))
1064 PKG_CHECK_MODULES([SAMPLERATE], [samplerate],
1065   [INCLUDES="$INCLUDES $SAMPLERATE_CFLAGS"; LIBS="$LIBS $SAMPLERATE_LIBS"],
1066   AC_MSG_ERROR($missing_library))
1067 PKG_CHECK_MODULES([FREETYPE2],  [freetype2],
1068   [INCLUDES="$INCLUDES $FREETYPE2_CFLAGS"; LIBS="$LIBS $FREETYPE2_LIBS"],
1069   AC_MSG_ERROR($missing_library))
1070 PKG_CHECK_MODULES([TAGLIB],  [taglib >= 1.8],
1071   [INCLUDES="$INCLUDES $TAGLIB_CFLAGS"; LIBS="$LIBS $TAGLIB_LIBS"],
1072   AC_MSG_ERROR($missing_library))
1073
1074 if test "$use_optical_drive" = "yes"; then
1075   PKG_CHECK_MODULES([CDIO],       [libcdio],
1076     [INCLUDES="$INCLUDES $CDIO_CFLAGS"; LIBS="$LIBS $CDIO_LIBS"],
1077     AC_MSG_ERROR($missing_library))
1078 fi
1079
1080 if test "$target_platform" = "target_android" ; then
1081 PKG_CHECK_MODULES([ZIP],       [libzip],
1082   [INCLUDES="$INCLUDES $ZIP_CFLAGS"; LIBS="$LIBS $ZIP_LIBS"],
1083   AC_MSG_ERROR($missing_library))
1084 fi
1085
1086 # check for libbluray
1087 AS_CASE([x$use_libbluray],
1088   [xyes],[
1089     PKG_CHECK_MODULES([LIBBLURAY],[libbluray >= 0.2.1],[use_libbluray="yes"], AC_MSG_ERROR($missing_library))
1090   ],
1091   [xauto],[
1092     PKG_CHECK_MODULES([LIBBLURAY],[libbluray >= 0.2.1],[use_libbluray="yes"], [use_libbluray="no"])
1093   ])
1094
1095 AS_CASE([x$use_libbluray],
1096   [xyes],[
1097     INCLUDES="$INCLUDES $LIBBLURAY_CFLAGS";
1098     XB_FIND_SONAME([BLURAY], [bluray], [use_libbluray])
1099     AC_DEFINE([HAVE_LIBBLURAY], 1, [System has libbluray library])
1100     AC_SUBST([HAVE_LIBBLURAY], 1)
1101     AC_CHECK_LIB([bluray], [bd_register_argb_overlay_proc],
1102       AC_CHECK_DECL([BD_EVENT_IDLE],
1103         AC_DEFINE([HAVE_LIBBLURAY_BDJ], 1, [System has libbluray library with bdj support]),,
1104         [[#include <libbluray/bluray.h>]]))
1105   ],[
1106     AC_SUBST([HAVE_LIBBLURAY], 0)
1107   ]
1108 )
1109
1110 #Check to see if libs are needed for functions that are often built-in to libc
1111 AC_SEARCH_LIBS([iconv_open],iconv,,AC_SEARCH_LIBS([libiconv_open],iconv,,AC_MSG_ERROR($missing_library)))
1112 AC_SEARCH_LIBS([dlopen],dl)
1113 AC_SEARCH_LIBS([clock_gettime],rt)
1114 AC_SEARCH_LIBS([dn_expand],  resolv)
1115 AC_SEARCH_LIBS([_dn_expand], resolv)
1116 AC_SEARCH_LIBS([__dn_expand],resolv)
1117
1118 # platform dependent libraries
1119 if test "$host_vendor" = "apple" ; then
1120   if test "$use_arch" != "arm"; then
1121     AC_CHECK_LIB([SDL],      [main],, AC_MSG_ERROR($missing_library))
1122     AC_DEFINE([HAVE_SDL],[1],["Define to 1 if using sdl"])
1123   fi
1124 else
1125 if test "$target_platform" != "target_android" ; then
1126   AC_CHECK_LIB([jasper],     [main],, AC_MSG_ERROR($missing_library)) # check for cximage
1127 fi
1128 if test "x$use_alsa" != "xno"; then
1129   PKG_CHECK_MODULES([ALSA],  [alsa],
1130     [INCLUDES="$INCLUDES $ALSA_CFLAGS"; LIBS="$LIBS $ALSA_LIBS"; use_alsa=yes],
1131     AC_MSG_NOTICE($alsa_not_found); use_alsa=no)
1132 fi
1133   PKG_CHECK_MODULES([DBUS],    [dbus-1],
1134     [INCLUDES="$INCLUDES $DBUS_CFLAGS"; LIBS="$LIBS $DBUS_LIBS"; use_dbus=yes]; \
1135     AC_DEFINE([HAVE_DBUS],[1],["Define to 1 if dbus is installed"]),
1136     AC_MSG_NOTICE($missing_library); use_dbus=no)
1137   if test "x$use_sdl" != "xno"; then
1138     PKG_CHECK_MODULES([SDL],   [sdl],
1139       [INCLUDES="$INCLUDES $SDL_CFLAGS"; LIBS="$LIBS $SDL_LIBS"],
1140       AC_MSG_ERROR($missing_library))
1141     AC_CHECK_LIB([SDL_image],  [main],, AC_MSG_ERROR($missing_library))
1142     AC_DEFINE([HAVE_SDL],[1],["Define to 1 if using sdl"])
1143   fi
1144 fi
1145
1146 XB_FIND_SONAME([MAD],         [mad])
1147 XB_FIND_SONAME([OGG],         [ogg])
1148 XB_FIND_SONAME([CURL],        [curl])
1149 XB_FIND_SONAME([FLAC],        [FLAC])
1150 XB_FIND_SONAME([VORBIS],      [vorbis])
1151 XB_FIND_SONAME([VORBISFILE],  [vorbisfile])
1152 XB_FIND_SONAME([MODPLUG],     [modplug])
1153 XB_FIND_SONAME([ASS],         [ass])
1154 XB_FIND_SONAME([MPEG2],       [mpeg2])
1155
1156 # Audio encoders
1157 if test "x$use_libmp3lame" != "xno"; then
1158   XB_FIND_SONAME([LAMEENC], [mp3lame], [use_libmp3lame])
1159   if test "x$use_libmp3lame" != "xno"; then
1160     AC_CHECK_HEADER([lame/lame.h],, AC_MSG_ERROR($missing_headers))
1161   fi
1162 fi
1163 AS_CASE([x$use_libmp3lame],
1164   [xno],[
1165     AC_SUBST([HAVE_LIBMP3LAME], 0)
1166   ],
1167   [
1168     AC_DEFINE([HAVE_LIBMP3LAME], 1, [System has libmp3lame library])
1169     AC_SUBST([HAVE_LIBMP3LAME], 1)
1170   ]
1171 )
1172 if test "x$use_libvorbisenc" != "xno"; then
1173   XB_FIND_SONAME([VORBISENC], [vorbisenc], [use_libvorbisenc])
1174   if test "x$use_libvorbisenc" != "xno"; then
1175     AC_CHECK_HEADER([vorbis/vorbisenc.h],, AC_MSG_ERROR($missing_headers))
1176   fi
1177 fi
1178 AS_CASE([x$use_libvorbisenc],
1179   [xno],[
1180     AC_SUBST([HAVE_LIBVORBISENC], 0)
1181   ],[
1182     AC_DEFINE([HAVE_LIBVORBISENC], 1, [System has libvorbisenc library])
1183     AC_SUBST([HAVE_LIBVORBISENC], 1)
1184   ]
1185 )
1186
1187 # WebServer
1188 if test "$use_webserver" = "yes"; then
1189   AC_CHECK_LIB([microhttpd],  [main],, AC_MSG_ERROR($missing_library))
1190 fi
1191
1192 # Optical
1193 if test "$use_optical_drive" = "yes"; then
1194   AC_DEFINE([HAS_DVD_DRIVE], [1], [Define to 1 to have optical drive support])
1195 fi
1196
1197 # Alsa
1198 if test "$use_alsa" = "yes" && test "$host_vendor" != "apple"; then
1199   PKG_CHECK_MODULES([ALSA],  [alsa],
1200     [INCLUDES="$INCLUDES $ALSA_CFLAGS"; LIBS="$LIBS $ALSA_LIBS"],
1201     AC_MSG_ERROR($missing_library))
1202   AC_DEFINE([HAS_ALSA], [1], [Define to 0 to disable ALSA support])
1203 else
1204   use_alsa="no"
1205   AC_MSG_RESULT($alsa_disabled)
1206 fi
1207
1208 # PulseAudio
1209 if test "x$use_pulse" != "xno"; then
1210   if test "$host_vendor" = "apple" ; then
1211     if test "x$use_pulse" = "xyes"; then
1212       AC_MSG_ERROR($pulse_disabled)
1213     else
1214       use_pulse="no"
1215       AC_MSG_RESULT($pulse_disabled)
1216     fi
1217     USE_PULSE=0
1218   else
1219     AC_CHECK_LIB([pulse],[main],,pulse_found="no")
1220     AC_CHECK_LIB([pulse-simple],[main],,pulse_found="no")
1221
1222     if test "x$pulse_found" != "xno"; then
1223       USE_PULSE=1
1224     elif test "x$use_pulse" = "xyes"; then
1225       AC_MSG_ERROR($pulse_not_found)
1226     else
1227       use_pulse=no
1228       USE_PULSE=0
1229       AC_MSG_RESULT($pulse_not_found)
1230     fi
1231   fi
1232 else
1233   AC_MSG_RESULT($pulse_disabled)
1234   USE_PULSE=0
1235 fi
1236
1237 # HAL
1238 if test "$host_vendor" = "apple" ; then
1239   use_hal="no"
1240   AC_MSG_RESULT($hal_disabled)
1241 else
1242   if test "$use_hal" = "yes"; then
1243     PKG_CHECK_MODULES([HAL], [hal],
1244       [INCLUDES="$INCLUDES $HAL_CFLAGS"; LIBS="$LIBS $HAL_LIBS"],
1245       use_hal=no;AC_MSG_RESULT($hal_not_found))
1246     PKG_CHECK_MODULES([HAL_STORAGE], [hal-storage],
1247       [INCLUDES="$INCLUDES $HAL_STORAGE_CFLAGS"; LIBS="$LIBS $HAL_STORAGE_LIBS"],
1248       use_hal=no;AC_MSG_RESULT($halstorage_not_found))
1249   else
1250     AC_MSG_RESULT($hal_disabled)
1251   fi
1252   if test "$use_hal" = "yes"; then
1253     AC_DEFINE([HAS_HAL], [1], [Define to 1 if you have HAL installed])
1254   fi
1255 fi
1256
1257 # avahi
1258 if test "$host_vendor" = "apple" ; then
1259   use_avahi="no"
1260   AC_MSG_RESULT($avahi_disabled)
1261 else
1262   if test "$use_avahi" = "yes"; then
1263     AC_CHECK_LIB([avahi-common], [main],,
1264       use_avahi=no;AC_MSG_RESULT($avahi_not_found))
1265     if test "$use_avahi" = "yes"; then
1266       #either both libs or none
1267       AC_CHECK_LIB([avahi-client], [main],,
1268         use_avahi=no;AC_MSG_RESULT($avahi_not_found))
1269     fi
1270   else
1271     AC_MSG_RESULT($avahi_disabled)
1272   fi
1273 fi
1274
1275 # mdnsembedded
1276 if test "$use_mdnsembedded" != "no"; then
1277   AC_CHECK_LIB([mDNSEmbedded], [embedded_mDNSInit],,
1278     [if test "$use_mdnsembedded" = "yes"; then
1279       AC_MSG_ERROR($mdnsembedded_not_found)
1280       USE_MDNSEMBEDDED=0
1281     elif test "$use_mdnsembedded" != "no"; then
1282       AC_MSG_NOTICE($mdnsembedded_not_found)
1283       use_mdnsembedded="no"
1284       USE_MDNSEMBEDDED=0
1285     fi
1286    ])
1287   if test $use_mdnsembedded != "no"; then
1288     USE_MDNSEMBEDDED=1
1289   fi
1290 else
1291   AC_MSG_RESULT($mdnsembedded_disabled)
1292   USE_MDNSEMBEDDED=0
1293 fi
1294 AC_SUBST(USE_MDNSEMBEDDED)
1295
1296 # X11
1297 if test "$use_x11" = "yes" && test "$host_vendor" != "apple"; then
1298   AC_MSG_NOTICE($x11_enabled)
1299   PKG_CHECK_MODULES([X11],    [x11],
1300     [INCLUDES="$INCLUDES $X11_CFLAGS"; LIBS="$LIBS $X11_LIBS"],
1301     AC_MSG_ERROR($missing_library))
1302   PKG_CHECK_MODULES([XEXT],  [xext],
1303     [INCLUDES="$INCLUDES $XEXT_CFLAGS"; LIBS="$LIBS $XEXT_LIBS"],
1304     AC_MSG_ERROR($missing_library))
1305   AC_DEFINE([HAVE_X11], [1], [Define to 1 if you have X11 libs installed.])
1306 else
1307   AC_MSG_RESULT($x11_disabled)
1308 fi
1309
1310 # XRandR
1311 if test "$host_vendor" = "apple" || test "$use_x11" = "no"; then
1312   use_xrandr="no"
1313   AC_MSG_RESULT($xrandr_disabled)
1314 else
1315   if test "$use_xrandr" = "yes" ; then
1316     AC_CHECK_LIB([Xrandr], [main],,
1317       use_xrandr="no";AC_MSG_RESULT($xrandr_not_found))
1318   else
1319     AC_MSG_RESULT($xrandr_disabled)
1320   fi
1321 fi
1322
1323 # WAVEFORM
1324 if test "$use_waveform" = "yes"; then
1325   AC_MSG_NOTICE($waveform_enabled)
1326     DISABLE_WAVEFORM=0
1327 else
1328   AC_MSG_NOTICE($waveform_disabled)
1329   DISABLE_WAVEFORM=1
1330 fi
1331
1332 # SPECTRUM
1333 if test "$use_spectrum" = "yes"; then
1334   AC_MSG_NOTICE($spectrum_enabled)
1335     DISABLE_SPECTRUM=0
1336 else
1337   AC_MSG_NOTICE($spectrum_disabled)
1338   DISABLE_SPECTRUM=1
1339 fi
1340
1341 # GOOM
1342 if test "$host_vendor" = "apple" ; then
1343   AC_MSG_NOTICE($goom_disabled)
1344   DISABLE_GOOM=1
1345 else
1346   if test "$use_goom" = "yes" && test "$use_gl" = "yes"; then
1347     AC_MSG_NOTICE($goom_enabled)
1348     DISABLE_GOOM=0
1349   else
1350     AC_MSG_NOTICE($goom_disabled)
1351     DISABLE_GOOM=1
1352   fi
1353 fi
1354
1355 # RSXS
1356 if test "$use_rsxs" = "no" || test "$use_gl" = "no"; then
1357   AC_MSG_NOTICE($rsxs_disabled)
1358   DISABLE_RSXS=1
1359 else
1360   AC_MSG_NOTICE($rsxs_enabled)
1361   DISABLE_RSXS=0
1362   # darwin osx can do rsxs but does not use x11, so do not pkg-config check for them
1363   if test "$host_vendor" != "apple" ; then
1364     PKG_CHECK_MODULES([XT],    [xt],
1365       [INCLUDES="$INCLUDES $XT_CFLAGS"; LIBS="$LIBS $XT_LIBS"],
1366       AC_MSG_ERROR($missing_library))
1367     PKG_CHECK_MODULES([XMU],   [xmu],
1368       [INCLUDES="$INCLUDES $XMU_CFLAGS"; LIBS="$LIBS $XMU_LIBS"],
1369       AC_MSG_ERROR($missing_library))
1370   fi
1371 fi
1372
1373 # FISHBMC
1374 if test "$use_fishbmc" = "no" || test "$use_gl" = "no"; then
1375   AC_MSG_NOTICE($fishbmc_disabled)   
1376   DISABLE_FISHBMC=1
1377   use_fishbmc="no"
1378 else
1379   AC_MSG_NOTICE($fishbmc_enabled)
1380   DISABLE_FISHBMC=0
1381 fi
1382
1383 # PROJECTM
1384 if test "$use_projectm" = "no" || test "$use_gl" = "no"; then
1385   AC_MSG_NOTICE($projectm_disabled)
1386   DISABLE_PROJECTM=1
1387   use_projectm="no"
1388 else
1389   AC_MSG_NOTICE($projectm_enabled)
1390   DISABLE_PROJECTM=0
1391 fi
1392
1393 # skin touched
1394 use_skin_touched=no
1395 if [[ -f "addons/skin.touched/addon.xml" ]]; then 
1396   use_skin_touched=yes
1397   USE_SKIN_TOUCHED=1
1398   AC_DEFINE([HAS_SKIN_TOUCHED], [1], [Whether to build skin touched.])
1399 else
1400   USE_SKIN_TOUCHED=0
1401 fi
1402
1403 # libssh
1404 if test "x$use_ssh" = "xno"; then
1405   AC_MSG_NOTICE($ssh_disabled)
1406   use_libssh="no"
1407 else
1408   AC_CHECK_LIB([ssh], [sftp_tell64],, AC_MSG_ERROR($ssh_not_found))
1409   AC_DEFINE([HAVE_LIBSSH], [1], [Whether to use libSSH library.])
1410 fi
1411
1412 # libRTMP
1413 if test "$use_librtmp" != "no"; then
1414   AC_CHECK_HEADERS([librtmp/log.h librtmp/amf.h librtmp/rtmp.h],,
1415    [if test "$use_librtmp" = "yes"; then
1416       AC_MSG_ERROR($librtmp_not_found)
1417     elif test "$use_librtmp" != "no"; then
1418       AC_MSG_NOTICE($librtmp_not_found)
1419       use_librtmp="no"
1420     fi
1421    ])
1422   if test "$use_librtmp" != "no"; then
1423     XB_FIND_SONAME([RTMP], [rtmp], [use_librtmp])
1424   fi
1425   if test "$use_librtmp" != "no"; then
1426     AC_DEFINE([HAS_LIBRTMP], [1], [Whether to use libRTMP library.])
1427   fi
1428 else
1429   AC_MSG_NOTICE($librtmp_disabled)
1430 fi
1431
1432 # samba
1433 if test "x$use_samba" != "xno"; then
1434   AC_CHECK_LIB([smbclient], [main],,
1435     use_samba=no;AC_MSG_ERROR($missing_library))
1436     USE_LIBSMBCLIENT=0
1437 else
1438   AC_MSG_RESULT($samba_disabled)
1439   USE_LIBSMBCLIENT=0
1440 fi
1441
1442 if test "x$use_samba" != "xno"; then
1443   AC_DEFINE([HAVE_LIBSMBCLIENT], [1], [Define to 1 if you have Samba installed])
1444   USE_LIBSMBCLIENT=1
1445 fi
1446
1447 # libnfs
1448 if test "$use_libnfs" != "no"; then
1449   AC_CHECK_HEADERS([nfsc/libnfs.h],,
1450    [if test "$use_libnfs" = "yes"; then
1451       AC_MSG_ERROR($libnfs_not_found)
1452       USE_LIBNFS=0
1453     elif test "$use_libnfs" != "no"; then
1454       AC_MSG_NOTICE($libnfs_not_found)
1455       use_libnfs="no"
1456       USE_LIBNFS=0
1457     fi
1458    ])
1459   if test "$use_libnfs" != "no"; then
1460     XB_FIND_SONAME([NFS], [nfs], [use_libnfs])
1461   fi
1462   if test "$use_libnfs" != "no"; then
1463     AC_DEFINE([HAVE_LIBNFS], [1], [Whether to use libnfs library.])
1464     USE_LIBNFS=1
1465   fi
1466 else
1467   USE_LIBNFS=0
1468   AC_MSG_NOTICE($libnfs_disabled)
1469 fi
1470
1471 # libafpclient
1472 USE_LIBAFPCLIENT=0
1473 if test "x$use_libafpclient" != "xno"; then
1474   AC_CHECK_HEADERS([afpfs-ng/libafpclient.h],,
1475    [if test "x$use_libafpclient" = "xyes"; then
1476       AC_MSG_ERROR($libafpclient_not_found)
1477     elif test "x$use_libafpclient" != "xno"; then
1478       AC_MSG_NOTICE($libafpclient_not_found)
1479       use_libafpclient="no"
1480     fi
1481    ])
1482   if test "x$use_libafpclient" != "xno"; then
1483     XB_FIND_SONAME([AFPCLIENT], [afpclient], [use_libafpclient])
1484     AC_DEFINE([HAVE_LIBAFPCLIENT], [1], [Whether to use libafpclient library.])
1485     USE_LIBAFPCLIENT=1
1486   fi
1487 else
1488   AC_MSG_NOTICE($libafpclient_disabled)
1489 fi
1490
1491 # libplist for airplay feature
1492 USE_AIRPLAY=0
1493 if test "$use_airplay" != "no"; then
1494   AC_CHECK_HEADER([plist/plist.h],,
1495    [if test "$use_airplay" = "yes"; then
1496       AC_MSG_ERROR($libplist_not_found)
1497     elif test "$use_airplay" != "no"; then
1498       AC_MSG_NOTICE($libplist_not_found)
1499       use_airplay="no"
1500     fi
1501    ])
1502
1503   if test "$use_airplay" != "no"; then
1504     XB_FIND_SONAME([PLIST], [plist], [use_airplay])
1505     USE_AIRPLAY=1
1506     AC_DEFINE([HAVE_LIBPLIST],[1],["Define to 1 if you have libplist."])
1507   fi
1508 fi
1509
1510 # libshairplay for AirTunes (prefered lib)
1511 USE_AIRTUNES=0
1512 if test "x$use_airtunes" != "xno"; then
1513   AC_CHECK_HEADERS([shairplay/raop.h],,
1514    [if test "x$use_airtunes" = "xyes"; then
1515       AC_MSG_ERROR($libshairplay_not_found)
1516     elif test "x$use_airtunes" != "xno"; then
1517       AC_MSG_NOTICE($libshairplay_not_found)
1518       use_airtunes="no"
1519     fi
1520    ])
1521
1522   if test "x$use_airtunes" != "xno"; then
1523     XB_FIND_SONAME([SHAIRPLAY], [shairplay], [use_airtunes])
1524     USE_AIRTUNES=1
1525     USE_LIBSHAIRPORT=1
1526     AC_CHECK_MEMBERS([struct raop_callbacks_s.cls],,,
1527                      [[#include <shairplay/raop.h>]])
1528     AC_DEFINE([HAVE_LIBSHAIRPLAY],[1],["Define to 1 if you have libshairplay."])
1529   fi
1530
1531   #libshairport - as a fallback for AirTunes
1532   if test "x$USE_AIRTUNES" == "x0"; then
1533     AC_CHECK_HEADERS([shairport/shairport.h],,
1534      [if test "x$use_airtunes" = "xyes"; then
1535         AC_MSG_ERROR($libshairport_not_found)
1536       elif test "x$use_airtunes" != "xno"; then
1537         AC_MSG_NOTICE($libshairport_not_found)
1538         use_airtunes="no"
1539       fi
1540      ])
1541
1542     if test "x$use_airtunes" != "xno"; then
1543       XB_FIND_SONAME([SHAIRPORT], [shairport], [use_airtunes])
1544       USE_AIRTUNES=1
1545       AC_CHECK_MEMBERS([struct AudioOutput.ao_set_metadata],,,
1546                        [[#include <shairport/shairport.h>]])
1547       AC_DEFINE([HAVE_LIBSHAIRPORT],[1],["Define to 1 if you have libshairport."])
1548     fi
1549   fi
1550 fi
1551
1552 # libudev
1553 USE_LIBUDEV=0
1554 if test "$host_vendor" = "apple" ; then
1555   use_libudev="no"
1556   AC_MSG_NOTICE($libudev_disabled)
1557 else
1558   if test "$use_libudev" = "auto"; then
1559     PKG_CHECK_MODULES([UDEV],[libudev],,[use_libudev="no";AC_MSG_RESULT($libudev_not_found)])
1560   elif test "$use_libudev" = "yes" ; then
1561     PKG_CHECK_MODULES([UDEV],[libudev],,[use_libudev="no";AC_MSG_ERROR($libudev_not_found)])
1562   else
1563     AC_MSG_NOTICE($libudev_disabled)
1564   fi
1565
1566   if test "x$use_libudev" != "xno"; then
1567     USE_LIBUDEV=1;INCLUDES="$INCLUDES $UDEV_CFLAGS";LIBS="$LIBS $UDEV_LIBS"
1568     AC_DEFINE([HAVE_LIBUDEV],[1],["Define to 1 if libudev is installed"])
1569   fi
1570 fi
1571
1572 # libusb
1573 USE_LIBUSB=0
1574
1575 # if libudev is available, we don't need libusb
1576 if test "x$use_libudev" != "xno"; then
1577   use_libusb="no"
1578   AC_MSG_NOTICE($libusb_disabled_udev_found)
1579 else
1580   if test "$host_vendor" = "apple" ; then
1581     use_libusb="no"
1582     AC_MSG_NOTICE($libusb_disabled)
1583   else
1584     if echo "$ARCH" | grep -q freebsd ; then
1585       AC_CHECK_LIB([usb],[main],
1586                 [use_libusb="yes";USB_LIBS="-lusb"],
1587                 [use_libusb="no";AC_MSG_RESULT($libusb_not_found)])
1588     elif test "$use_libusb" = "auto"; then
1589       PKG_CHECK_MODULES([USB],[libusb],,[use_libusb="no";AC_MSG_RESULT($libusb_not_found)])
1590     elif test "$use_libusb" = "yes"; then
1591       PKG_CHECK_MODULES([USB],[libusb],,[use_libusb="no";AC_MSG_ERROR($libusb_not_found)])
1592     else
1593       AC_MSG_NOTICE($libusb_disabled)
1594     fi
1595   
1596     if test "x$use_libusb" != "xno"; then
1597       USE_LIBUSB=1;INCLUDES="$INCLUDES $USB_CFLAGS";LIBS="$LIBS $USB_LIBS"
1598       AC_DEFINE([HAVE_LIBUSB],[1],["Define to 1 if libusb is installed"])
1599     fi
1600   fi
1601 fi
1602
1603 # libcec
1604 USE_LIBCEC=0
1605 if test "x$use_libcec" != "xno"; then
1606   # libcec is dyloaded, so we need to check for its headers and link any depends.
1607   if test "x$use_libcec" != "xno"; then
1608     if test "x$use_libcec" != "xauto"; then
1609       PKG_CHECK_MODULES([CEC],[libcec >= 2.1.0],,[use_libcec="no";AC_MSG_ERROR($libcec_disabled)])
1610     else
1611       PKG_CHECK_MODULES([CEC],[libcec >= 2.1.0],,[use_libcec="no";AC_MSG_RESULT($libcec_disabled)])
1612     fi
1613
1614     if test "x$use_libcec" != "xno"; then
1615       INCLUDES="$INCLUDES $CEC_CFLAGS"
1616       USE_LIBCEC=1;AC_DEFINE([HAVE_LIBCEC],[1],["Define to 1 if libcec is installed"])
1617       XB_FIND_SONAME([LIBCEC],[cec],[use_libcec])
1618       AC_MSG_NOTICE($libcec_enabled)
1619     else
1620       use_libcec="no"
1621       AC_MSG_NOTICE($libcec_disabled)
1622     fi
1623   fi
1624 else
1625   use_libcec="no"
1626   AC_MSG_NOTICE($libcec_disabled)
1627 fi
1628
1629 # libcap
1630 if test "$use_libcap" != "no"; then
1631   AC_CHECK_HEADERS([sys/capability.h],,
1632    [if test "$use_libcap" = "yes"; then
1633       AC_MSG_ERROR($libcap_not_found)
1634     elif test "$use_libcap" != "no"; then
1635       AC_MSG_NOTICE($libcap_not_found)
1636       use_libcap="no"
1637     fi
1638    ])
1639   if test "$use_libcap" != "no"; then
1640     AC_CHECK_LIB([cap], main, LIBS="$LIBS -lcap", use_libcap=no)
1641   fi
1642   if test "$use_libcap" != "no"; then
1643     AC_DEFINE([HAVE_LIBCAP], [1], [Whether to use libcap library.])
1644   fi
1645 else
1646   AC_MSG_NOTICE($libcap_disabled)
1647 fi
1648
1649 ### External libraries checks
1650
1651 # Hacks for supporting libav
1652
1653 USE_LIBAV_HACKS=0
1654 if test "$use_libav_hacks" = "yes"; then
1655     export PKG_CONFIG_PATH="${srcdir}/lib/xbmc-libav-hacks/pkgconfig/:$PKG_CONFIG_PATH"
1656     USE_LIBAV_HACKS=1
1657     AC_DEFINE([USE_LIBAV_HACKS], [1], [Whether to use libav compatibility hacks.])
1658 fi
1659
1660 # External FFmpeg
1661 if test "$use_external_ffmpeg" = "yes"; then
1662   FFMPEG_LIBNAMES="libavcodec libavfilter libavformat libavutil libpostproc libswscale libswresample"
1663
1664   PKG_CHECK_MODULES([FFMPEG], [$FFMPEG_LIBNAMES],
1665                     [INCLUDES="$INCLUDES $FFMPEG_CFLAGS"; LIBS="$LIBS $FFMPEG_LIBS"],
1666                     AC_MSG_ERROR($missing_library))
1667
1668   # in case the headers are in a custom directory
1669   SAVE_CPPFLAGS="$CPPFLAGS"
1670   CPPFLAGS="$CPPFLAGS $FFMPEG_CFLAGS"
1671
1672   AC_CHECK_HEADERS([libavcodec/avcodec.h libavfilter/avfilter.h libavformat/avformat.h libavutil/avutil.h libpostproc/postprocess.h libswscale/swscale.h],,
1673   [AC_MSG_ERROR($missing_headers)])
1674
1675   AC_MSG_NOTICE($external_ffmpeg_enabled)
1676   USE_EXTERNAL_FFMPEG=1
1677   AC_DEFINE([USE_EXTERNAL_FFMPEG], [1], [Whether to use external FFmpeg libraries.])
1678
1679   CPPFLAGS="$SAVE_CPPFLAGS"
1680 else
1681   AC_MSG_NOTICE($external_ffmpeg_disabled)
1682   USE_EXTERNAL_FFMPEG=0
1683 fi
1684
1685 echo "Checking for SWIG installation"
1686 AC_PATH_PROG(SWIG_EXE, swig, "none")
1687 if test "$SWIG_EXE" = "none"; then
1688   AC_PATH_PROG(SWIG20_EXE, swig2.0, "none")
1689   if test "$SWIG20_EXE" != "none" ; then
1690     SWIG_EXE=$SWIG20_EXE
1691   fi
1692 fi
1693 if test "$SWIG_EXE" = "none"; then
1694   AC_MSG_ERROR($missing_program)
1695 fi
1696 final_message="$final_message\n  SWIG Available:\tYes"
1697
1698 echo "Checking for a jre installation"
1699 AC_PATH_PROG(JAVA_EXE, java, "none")
1700 if test "$JAVA_EXE" = "none"; then
1701   AC_MSG_ERROR($missing_program)
1702 fi
1703 final_message="$final_message\n  JRE Available:\tYes"
1704
1705 echo "Checking for doxygen installation"
1706 AC_PATH_PROG(DOXYGEN_EXE, doxygen, "none")
1707 if test "$DOXYGEN_EXE" = "none"; then
1708   AC_MSG_WARN([Unable to find doxygen installation. Will not be able to make docstrings for the python api])
1709   final_message="$final_message\n  Doxygen Available:\tNo"
1710   USE_DOXYGEN=0
1711 else
1712   final_message="$final_message\n  Doxygen Available:\tYes"
1713   USE_DOXYGEN=1
1714 fi
1715
1716 # VDPAU
1717 if test "x$use_vdpau" != "xno"; then
1718   if test "$host_vendor" = "apple" ; then
1719     if test "x$use_vdpau" = "xyes"; then
1720       AC_MSG_ERROR([VDPAU not supported on this platform])
1721     else
1722       use_vdpau="no"
1723       AC_MSG_NOTICE($vdpau_disabled)
1724     fi
1725     USE_VDPAU=0
1726   else
1727     USE_VDPAU=1
1728     AC_CHECK_HEADER([vdpau/vdpau.h],AC_DEFINE([HAVE_LIBVDPAU], [],
1729       [Define to 1 if you have the 'vdpau' library (-lvdpau).]),
1730     [if test "x$use_vdpau" = "xyes"; then
1731       USE_VDPAU=0
1732       AC_MSG_ERROR([$vdpau_not_found])
1733     else
1734       use_vdpau="no"
1735       USE_VDPAU=0
1736       AC_MSG_RESULT($vdpau_not_found)
1737     fi])
1738   fi
1739 else
1740   USE_VDPAU=0
1741   AC_MSG_NOTICE($vdpau_disabled)
1742 fi
1743
1744 # VAAPI
1745 if test "x$use_vaapi" != "xno"; then
1746   if test "$host_vendor" = "apple" ; then
1747     if test "x$use_vaapi" = "xyes"; then
1748       AC_MSG_ERROR([VAAPI not supported on this platform])
1749     else
1750       use_vaapi="no"
1751       AC_MSG_NOTICE($vaapi_disabled)
1752     fi
1753     USE_VAAPI=0
1754   else
1755     initial_val=$use_vaapi
1756     AC_CHECK_LIB([va], main, :, use_vaapi=no)
1757     if test "x$use_vaapi" != "xno"; then
1758       AC_CHECK_LIB([va-glx], main, LIBS="-lva -lva-glx $LIBS", use_vaapi=no, -lva)
1759     fi
1760
1761     if test "x$use_vaapi" = "xno"; then
1762       if test "x$initial_val" = "xyes"; then
1763         AC_MSG_ERROR($vaapi_not_found)
1764       else
1765         AC_MSG_RESULT($vaapi_not_found)
1766       fi
1767       USE_VAAPI=0
1768     else
1769       AC_DEFINE([HAVE_LIBVA], [1], [Define to 1 if you have the 'vaapi' libraries (-lva AND -lva-glx)])
1770       USE_VAAPI=1
1771     fi
1772   fi
1773 else
1774   AC_MSG_NOTICE($vaapi_disabled)
1775   USE_VAAPI=0
1776 fi
1777
1778 # CrystalHD
1779 if test "x$use_crystalhd" != "xno"; then
1780   SAVE_CFLAGS="$CFLAGS"
1781   CFLAGS="-D__LINUX_USER__"
1782   AC_CHECK_HEADER([libcrystalhd/libcrystalhd_if.h], [],
1783     [ if test "x$use_crystalhd" = "xyes"; then
1784         AC_MSG_ERROR($crystalhd_not_found)
1785       else
1786         use_crystalhd=no
1787         AC_MSG_RESULT($crystalhd_not_found)
1788       fi
1789       USE_CRYSTALHD=0
1790     ])
1791     CFLAGS="$SAVE_CFLAGS"
1792     if test "$host_vendor" != "apple"; then
1793       XB_FIND_SONAME([CRYSTALHD], [crystalhd], [use_crystalhd])
1794     fi
1795     if test "x$use_crystalhd" != "xno"; then
1796       SAVE_CFLAGS="$CFLAGS"
1797       CFLAGS="-D__LINUX_USER__ -lcrystalhd"
1798       # check for new crystalhd lib
1799       AC_COMPILE_IFELSE(
1800         [AC_LANG_SOURCE([#include <libcrystalhd/bc_dts_types.h>
1801           #include <libcrystalhd/bc_dts_defs.h>
1802           PBC_INFO_CRYSTAL bCrystalInfo;])],
1803         [ AC_DEFINE([HAVE_LIBCRYSTALHD], [2], [Define to 2 if you have the 'New Broadcom Crystal HD' library.]) ], 
1804         [ AC_DEFINE([HAVE_LIBCRYSTALHD], [1], [Define to 1 if you have the 'Old Broadcom Crystal HD' library.]) ])
1805       CFLAGS="$SAVE_CFLAGS"
1806       USE_CRYSTALHD=1
1807     fi
1808 else
1809   AC_MSG_NOTICE($crystalhd_disabled)
1810   USE_CRYSTALHD=0
1811 fi
1812
1813 # VTBDecoder
1814 if test "x$use_vtbdecoder" != "xno"; then
1815   if test "$host_vendor" = "apple" ; then
1816     HAVE_VIDEOTOOLBOXDECODER=1
1817     AC_DEFINE([HAVE_VIDEOTOOLBOXDECODER], [1], [Define to 1 if you have the 'VTBDecoder' library.])
1818     AC_MSG_NOTICE($vtbdecoder_enabled)
1819   else
1820     if test "x$use_vtbdecoder" = "xyes"; then
1821       AC_MSG_ERROR([VTB Decoder not supported on this platform])
1822     else
1823       use_vtbdecoder="no"
1824       AC_MSG_NOTICE($vtbdecoder_disabled)
1825     fi
1826   fi
1827 else
1828   AC_MSG_NOTICE($vtbdecoder_disabled)
1829 fi
1830
1831 # OpenMax
1832 if test "$host_vendor" = "apple" ; then
1833   use_openmax="no"
1834   USE_OPENMAX=0
1835   AC_MSG_NOTICE($openmax_disabled)
1836 elif test "$target_platform" = "target_raspberry_pi"; then
1837   use_openmax="no"
1838   USE_OPENMAX=0
1839   AC_MSG_NOTICE($openmax_disabled)
1840 else
1841   if test "$use_gles" = "yes" && test "$use_openmax" = "auto"; then
1842     PKG_CHECK_MODULES([OPENMAX], [libomxil-bellagio],
1843                       USE_OPENMAX=1;[INCLUDES="$INCLUDES $OPENMAX_CFLAGS"; LIBS="$LIBS $OPENMAX_LIBS"],
1844                       use_openmax=no;USE_OPENMAX=0;AC_MSG_RESULT($openmax_not_found))
1845   elif test "$use_gles" = "yes" && test "$use_openmax" = "yes"; then
1846     PKG_CHECK_MODULES([OPENMAX], [libomxil-bellagio],
1847                       USE_OPENMAX=1;[INCLUDES="$INCLUDES $OPENMAX_CFLAGS"; LIBS="$LIBS $OPENMAX_LIBS"],
1848                       AC_MSG_ERROR($openmax_not_found))
1849   else
1850     AC_MSG_NOTICE($openmax_disabled)
1851     use_openmax=no
1852     USE_OPENMAX=0
1853   fi
1854 fi
1855
1856 # yajl version check (yajl_version.h was added in yajl 2.0)
1857 AC_CHECK_HEADERS([yajl/yajl_version.h], [], [
1858 AC_DEFINE(YAJL_MAJOR, 1, [yajl version 1])
1859 ], [])
1860
1861 # additional internal players
1862 case $add_players in
1863   *amlplayer*)
1864       AC_CHECK_HEADER([amplayer/player_error.h],, AC_MSG_ERROR($missing_headers))
1865       XB_ADD_PLAYER([AMLPLAYER], [amlplayer])
1866       ;;
1867   *omxplayer*)
1868       XB_ADD_PLAYER([OMXPLAYER], [omxplayer])
1869       ;;
1870 esac
1871
1872 # additional internal codecs
1873 case $add_codecs in
1874   *amcodec*)
1875       AC_CHECK_HEADER([amcodec/codec_error.h],, AC_MSG_ERROR($missing_headers))
1876       XB_ADD_CODEC([LIBAMCODEC], [amcodec])
1877       ;;
1878   *libstagefright*)
1879       LIBS+="-L${prefix}/opt/android-libs -lstdc++ -lutils -lcutils -lstagefright -lbinder -lui -lgui"
1880       XB_ADD_CODEC([LIBSTAGEFRIGHT], [libstagefright])
1881       ;;
1882   *)
1883 esac
1884
1885 # platform specific bin utilities
1886 if test "$build_vendor" != "apple" ; then
1887   AC_CHECK_PROG(HAVE_GAWK,gawk,"yes","no",)
1888   if test "$HAVE_GAWK" = "no" ; then
1889     AC_MSG_ERROR($missing_program)
1890   fi
1891 fi
1892
1893 if test "$use_arch" != "arm" ; then
1894   AC_CHECK_PROG(HAVE_CMAKE,cmake,"yes","no",)
1895   if test "$HAVE_CMAKE" = "no" ; then
1896     AC_MSG_ERROR($missing_program)
1897   fi
1898 fi
1899
1900 AC_CHECK_PROG(HAVE_GPERF,gperf,"yes","no",)
1901 if test "$HAVE_GPERF" = "no" ; then
1902   AC_MSG_ERROR($missing_program)
1903 fi
1904
1905 AC_CHECK_PROG(HAVE_UNZIP,unzip,"yes","no",)
1906 if test "$HAVE_UNZIP" = "no" ; then
1907   AC_MSG_ERROR($missing_program)
1908 fi
1909
1910 AC_CHECK_PROG(HAVE_ZIP,zip,"yes","no",)
1911 if test "$HAVE_ZIP" = "no" ; then
1912   AC_MSG_ERROR($missing_program)
1913 fi
1914
1915 if test "$ARCH" = "i486-linux" || test "$ARCH" = "x86-freebsd"; then
1916   AC_CHECK_PROG(HAVE_NASM,nasm,"yes","no",)
1917   if test "$HAVE_NASM" = "no" ; then
1918     AC_MSG_ERROR($missing_program)
1919   fi
1920 fi
1921
1922 # Checks for header files.
1923 AC_HEADER_DIRENT
1924 AC_HEADER_STDC
1925 AC_HEADER_SYS_WAIT
1926 AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h inttypes.h limits.h locale.h \
1927   malloc.h memory.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h \
1928   strings.h sys/file.h sys/ioctl.h sys/mount.h sys/param.h sys/socket.h \
1929   sys/time.h sys/timeb.h sys/vfs.h termios.h unistd.h utime.h wchar.h wctype.h])
1930 AC_CHECK_HEADERS([cdio/iso9660.h],,AC_MSG_ERROR([$missing_headers]))
1931
1932 # Checks for typedefs, structures, and compiler characteristics.
1933 AC_HEADER_STAT
1934 AC_HEADER_STDBOOL
1935 AC_C_CONST
1936 AC_TYPE_UID_T
1937 AC_C_INLINE
1938 AC_TYPE_INT8_T
1939 AC_TYPE_INT16_T
1940 AC_TYPE_INT32_T
1941 AC_TYPE_INT64_T
1942 AC_TYPE_MODE_T
1943 AC_TYPE_OFF_T
1944 AC_TYPE_PID_T
1945 AC_C_RESTRICT
1946 AC_TYPE_SIZE_T
1947 AC_TYPE_SSIZE_T
1948 AC_CHECK_MEMBERS([struct stat.st_rdev])
1949 AC_HEADER_TIME
1950 AC_STRUCT_TM
1951 AC_TYPE_UINT8_T
1952 AC_TYPE_UINT16_T
1953 AC_TYPE_UINT32_T
1954 AC_TYPE_UINT64_T
1955 AC_C_BIGENDIAN
1956
1957 if test "$cross_compiling" = "yes"; then
1958   final_message="$final_message\n  Crosscomp.:\tYes"
1959 else
1960   final_message="$final_message\n  Crosscomp.:\tNo"
1961 fi
1962
1963 final_message="$final_message\n  target ARCH:\t$use_arch"
1964 final_message="$final_message\n  target CPU:\t$use_cpu"
1965
1966 if test "$use_gles" = "yes"; then
1967   final_message="$final_message\n  OpenGLES:\tYes"
1968   USE_OPENGLES=1
1969   USE_OPENGL=0
1970 else
1971   USE_OPENGLES=0
1972   if test "$use_gl" = "yes"; then
1973     final_message="$final_message\n  OpenGL:\tYes"
1974     USE_OPENGL=1
1975   else
1976     final_message="$final_message\n  OpenGL:\tNo (Very Slow)"
1977     SDL_DEFINES="$SDL_DEFINES -DHAS_SDL_2D"
1978     USE_OPENGL=0
1979   fi
1980 fi
1981
1982 if test "$use_alsa" = "yes"; then
1983   USE_ALSA=1
1984   AC_DEFINE([USE_ALSA],[1],["Define to 1 if alsa is installed"])
1985   final_message="$final_message\n  ALSA:\t\tYes"
1986 else
1987   USE_ALSA=0
1988   final_message="$final_message\n  ALSA:\t\tNo"
1989 fi
1990
1991 if test "$use_dbus" = "yes"; then
1992   final_message="$final_message\n  DBUS:\t\tYes"
1993 else
1994   final_message="$final_message\n  DBUS:\t\tNo"
1995 fi
1996
1997 if test "x$use_vdpau" != "xno"; then
1998   final_message="$final_message\n  VDPAU:\tYes"
1999 else
2000   final_message="$final_message\n  VDPAU:\tNo"
2001 fi
2002
2003 if test "x$use_vaapi" != "xno"; then
2004   final_message="$final_message\n  VAAPI:\tYes"
2005 else
2006   final_message="$final_message\n  VAAPI:\tNo"
2007 fi
2008
2009 if test "x$use_crystalhd" != "xno"; then
2010   final_message="$final_message\n  CrystalHD:\tYes"
2011 else
2012   final_message="$final_message\n  CrystalHD:\tNo"
2013 fi
2014
2015 if test "x$use_vtbdecoder" != "xno"; then
2016   final_message="$final_message\n  VTBDecoder:\tYes"
2017 else
2018   final_message="$final_message\n  VTBDecoder:\tNo"
2019 fi
2020
2021 if test "$use_openmax" != "no"; then
2022   final_message="$final_message\n  OpenMax:\tYes"
2023 else
2024   final_message="$final_message\n  OpenMax:\tNo"
2025 fi
2026
2027 if test "$use_joystick" = "yes"; then
2028   final_message="$final_message\n  Joystick:\tYes"
2029   SDL_DEFINES="$SDL_DEFINES -DHAS_SDL_JOYSTICK"
2030 else
2031   final_message="$final_message\n  Joystick:\tNo"
2032 fi
2033
2034 if test "$use_xrandr" = "yes"; then
2035   final_message="$final_message\n  XRandR:\tYes"
2036   USE_XRANDR=1
2037 else
2038   final_message="$final_message\n  XRandR:\tNo"
2039   USE_XRANDR=0
2040 fi
2041
2042 if test "$use_waveform" = "yes"; then
2043   final_message="$final_message\n  Waveform:\tYes"
2044 else
2045   final_message="$final_message\n  Waveform:\tNo"
2046 fi
2047
2048 if test "$use_spectrum" = "yes"; then
2049   final_message="$final_message\n  Spectrum:\tYes"
2050 else
2051   final_message="$final_message\n  Spectrum:\tNo"
2052 fi
2053
2054 if test "$use_goom" = "yes"; then
2055   final_message="$final_message\n  GOOM:\t\tYes"
2056 else
2057   final_message="$final_message\n  GOOM:\t\tNo"
2058 fi
2059
2060 if test "$use_rsxs" = "yes"; then
2061   final_message="$final_message\n  RSXS:\t\tYes"
2062 else
2063   final_message="$final_message\n  RSXS:\t\tNo"
2064 fi
2065
2066 if test "$use_fishbmc" = "yes"; then
2067   final_message="$final_message\n  FishBMC:\tYes"
2068 else
2069   final_message="$final_message\n  FishBMC:\tNo"
2070 fi
2071
2072 if test "$use_projectm" = "yes"; then
2073   final_message="$final_message\n  ProjectM:\tYes"
2074 else
2075   final_message="$final_message\n  ProjectM:\tNo"
2076 fi
2077
2078 if test "$use_skin_touched" = "yes"; then
2079   final_message="$final_message\n  Skin Touched:\tYes"
2080 else
2081   final_message="$final_message\n  Skin Touched:\tNo"
2082 fi
2083
2084 if test "$use_x11" = "yes"; then
2085   final_message="$final_message\n  X11:\t\tYes"
2086 else
2087   final_message="$final_message\n  X11:\t\tNo"
2088 fi
2089
2090 if test "$use_libbluray" = "yes"; then
2091   final_message="$final_message\n  Bluray:\tYes"
2092 else
2093   final_message="$final_message\n  Bluray:\tNo"
2094 fi
2095
2096 USE_TEXTUREPACKER_NATIVE=0
2097 if test "x$use_texturepacker" != "xno"; then
2098   final_message="$final_message\n  TexturePacker:Yes"
2099   USE_TEXTUREPACKER=1
2100   if test "x$use_texturepacker_native" = "xyes"; then
2101     USE_TEXTUREPACKER_NATIVE=1
2102     if [[ ! -d "$USE_TEXTUREPACKER_NATIVE_ROOT" ]]; then 
2103       USE_TEXTUREPACKER_NATIVE_ROOT= 
2104     fi
2105   fi
2106 else
2107   final_message="$final_message\n  TexturePacker:No"
2108   USE_TEXTUREPACKER=0
2109 fi
2110
2111 if test "$use_mid" = "yes"; then
2112   final_message="$final_message\n  MID Support:\tYes"
2113   SDL_DEFINES="$SDL_DEFINES -DMID"
2114 else
2115   final_message="$final_message\n  MID Support:\tNo"
2116 fi
2117
2118 ORIGCC=$CC
2119 ORIGCXX=$CXX
2120 if test "x$use_ccache" != "xno"; then
2121   AC_PATH_PROG(CCACHE,ccache,none)
2122   if test "$ac_cv_path_CCACHE" = "none"; then
2123     if test "x$use_ccache" = "xyes"; then
2124       AC_MSG_ERROR([ccache not found.]);
2125     else
2126       AC_MSG_NOTICE([ccache not found. Falling back to default CC])
2127       final_message="$final_message\n  ccache:\tNo"
2128     fi
2129   else
2130     CC="$ac_cv_path_CCACHE $CC"
2131     CXX="$ac_cv_path_CCACHE $CXX"
2132     AC_MSG_NOTICE(enabling ccache)
2133     final_message="$final_message\n  ccache:\tYes"
2134   fi
2135 else
2136   final_message="$final_message\n  ccache:\tNo"
2137 fi
2138
2139 if test "$use_alsa" = "yes"; then
2140   final_message="$final_message\n  ALSA Support:\tYes"
2141 else
2142   final_message="$final_message\n  ALSA Support:\tNo"
2143 fi
2144
2145 if test "x$use_pulse" != "xno"; then
2146   XBMC_STANDALONE_SH_PULSE=tools/Linux/xbmc-standalone.sh.pulse
2147   final_message="$final_message\n  PulseAudio:\tYes"
2148 else
2149   XBMC_STANDALONE_SH_PULSE=/dev/null
2150   final_message="$final_message\n  PulseAudio:\tNo"
2151 fi
2152
2153 if test "$use_hal" = "yes"; then
2154   final_message="$final_message\n  HAL Support:\tYes"
2155 else
2156   final_message="$final_message\n  HAL Support:\tNo"
2157 fi
2158
2159 # DVDCSS
2160 if test "$use_dvdcss" = "yes"; then
2161   AC_MSG_NOTICE($dvdcss_enabled)
2162   final_message="$final_message\n  DVDCSS:\tYes"
2163   BUILD_DVDCSS=1
2164   SKIP_CONFIG_DVDCSS=0
2165   DVDREAD_CFLAGS="-D_XBMC -DHAVE_DVDCSS_DVDCSS_H"
2166 else
2167   AC_MSG_NOTICE($dvdcss_disabled)
2168   final_message="$final_message\n  DVDCSS:\tNo"
2169   BUILD_DVDCSS=0
2170   SKIP_CONFIG_DVDCSS=1
2171   DVDREAD_CFLAGS="-D_XBMC -UHAVE_DVDCSS_DVDCSS_H"
2172 fi
2173 if test "$host_vendor" = "apple"; then
2174  DVDREAD_CFLAGS="$DVDREAD_CFLAGS -D__DARWIN__"
2175 fi
2176
2177 # Google Test Framework
2178 if test "$configure_gtest" = "yes"; then
2179   AC_MSG_NOTICE($gtest_enabled)
2180   final_message="$final_message\n  Google Test Framework Configured:\tYes"
2181   GTEST_CONFIGURED=1
2182   SKIP_CONFIG_GTEST=0
2183 else
2184   AC_MSG_NOTICE($gtest_disabled)
2185   final_message="$final_message\n  Google Test Framework Configured:\tNo"
2186   GTEST_CONFIGURED=0
2187   SKIP_CONFIG_GTEST=1
2188 fi
2189
2190 if test "$use_avahi" = "yes"; then
2191   final_message="$final_message\n  Avahi:\tYes"
2192 else
2193   final_message="$final_message\n  Avahi:\tNo"
2194 fi
2195
2196 if test "$use_mdnsembedded" != "no"; then
2197   final_message="$final_message\n  mDNSEmbedded:\tYes"
2198 else
2199   final_message="$final_message\n  mDNSEmbedded:\tNo"
2200 fi
2201
2202 if test "$use_nonfree" = "yes"; then
2203   final_message="$final_message\n  Non-free:\tYes"
2204   HAVE_XBMC_NONFREE=1
2205   AC_DEFINE([HAVE_XBMC_NONFREE], [1], [Define to 1 to enable non-free components.])
2206 else
2207   HAVE_XBMC_NONFREE=0
2208   final_message="$final_message\n  Non-free:\tNo"
2209 fi
2210
2211 if test "$use_asap" = "yes"; then
2212   AC_CHECK_PROGS(HAVE_GDC,gdc-4.4 gdc-4.3 gdc,"no")
2213   if test "$HAVE_GDC" = "no"; then
2214     AC_MSG_ERROR($missing_program);
2215   fi
2216   AC_CHECK_PROG(HAVE_FPC,fpc,"yes","no")
2217   if test "$HAVE_FPC" = "no"; then
2218     AC_MSG_ERROR($missing_program);
2219   fi
2220   USE_ASAP_CODEC=1
2221   AC_DEFINE([USE_ASAP_CODEC], [1], [Define to 1 to enable ASAP codec.])
2222   final_message="$final_message\n  ASAP Codec:\tYes"
2223 else
2224   USE_ASAP_CODEC=0
2225   final_message="$final_message\n  ASAP Codec:\tNo"
2226 fi
2227
2228 if test "$use_mysql" = "yes"; then
2229   final_message="$final_message\n  MySQL:\tYes"
2230   USE_MYSQL=1
2231 else
2232   final_message="$final_message\n  MySQL:\tNo"
2233   USE_MYSQL=0
2234 fi
2235 if test "$use_webserver" = "yes"; then
2236   final_message="$final_message\n  Webserver:\tYes"
2237   USE_WEB_SERVER=1
2238 else
2239   final_message="$final_message\n  Webserver:\tNo"
2240   USE_WEB_SERVER=0
2241 fi
2242
2243 if test "$use_libssh" != "no"; then
2244   final_message="$final_message\n  libssh support:\tYes"
2245 else
2246   final_message="$final_message\n  libssh support:\tNo"
2247 fi
2248
2249 if test "$use_librtmp" != "no"; then
2250   final_message="$final_message\n  libRTMP support:\tYes"
2251 else
2252   final_message="$final_message\n  libRTMP support:\tNo"
2253 fi
2254
2255 if test "x$use_samba" != "xno"; then
2256   final_message="$final_message\n  libsmbclient support:\tYes"
2257 else
2258   final_message="$final_message\n  libsmbclient support:\tNo"
2259 fi
2260
2261 if test "$use_libnfs" != "no"; then
2262   final_message="$final_message\n  libnfs client support:Yes"
2263 else
2264   final_message="$final_message\n  libnfs client support:No"
2265 fi
2266
2267 if test "x$use_libafpclient" != "xno"; then
2268   final_message="$final_message\n  libafpclient support:\tYes"
2269 else  
2270   final_message="$final_message\n  libafpclient support:\tNo"
2271 fi
2272
2273 if test "$use_airplay" != "no"; then
2274   final_message="$final_message\n  AirPlay support:\tYes"
2275 else
2276   final_message="$final_message\n  AirPLay support:\tNo"
2277 fi
2278
2279 if test "x$use_airtunes" != "xno"; then
2280   if test "x$USE_LIBSHAIRPORT" == "x1"; then
2281     final_message="$final_message\n  AirTunes support (libshairplay):\tYes"  
2282   else
2283     final_message="$final_message\n  AirTunes support (libshairport):\tYes"
2284   fi
2285 else
2286   final_message="$final_message\n  AirTunes support:\tNo"
2287 fi
2288
2289 if test "x$use_upnp" != "xno"; then
2290   final_message="$final_message\n  UPnP support:\t\tYes"
2291   USE_UPNP=1
2292   AC_DEFINE([USE_UPNP], [1], [Define to 1 to enable UPnP support.])
2293 else
2294   USE_UPNP=0
2295   final_message="$final_message\n  UPnP support:\t\tNo"
2296 fi
2297
2298 if test "$use_optical_drive" = "yes"; then
2299   final_message="$final_message\n  Optical drive:\tYes"
2300 else
2301   final_message="$final_message\n  Optical drive:\tNo"
2302 fi
2303
2304 if test "x$use_libudev" != "xno"; then
2305   final_message="$final_message\n  libudev support:\tYes"
2306 else
2307   final_message="$final_message\n  libudev support:\tNo"
2308 fi
2309
2310 if test "x$use_libusb" != "xno"; then
2311   final_message="$final_message\n  libusb support:\tYes"
2312 else
2313   final_message="$final_message\n  libusb support:\tNo"
2314 fi
2315
2316 if test "x$use_libcec" != "xno"; then
2317   final_message="$final_message\n  libcec support:\tYes"
2318 else
2319   final_message="$final_message\n  libcec support:\tNo"
2320 fi
2321
2322 if test "x$use_libmp3lame" != "xno"; then
2323   final_message="$final_message\n  libmp3lame support:\tYes"
2324 else
2325   final_message="$final_message\n  libmp3lame support:\tNo"
2326 fi
2327
2328 if test "x$use_libvorbisenc" != "xno"; then
2329   final_message="$final_message\n  libvorbisenc support:\tYes"
2330 else
2331   final_message="$final_message\n  libvorbisenc support:\tNo"
2332 fi
2333
2334 if test "x$use_libcap" != "xno"; then
2335   final_message="$final_message\n  libcap support:\tYes"
2336 else
2337   final_message="$final_message\n  libcap support:\tNo"
2338 fi
2339
2340 if test "x$add_players" != "xno"; then
2341   final_message="$final_message\n  additional players:\tYes"
2342 else
2343   final_message="$final_message\n  additional players:\tNo"
2344 fi
2345
2346 ### External libraries messages
2347
2348 if test "$use_external_ffmpeg" = "yes"; then
2349   final_message="$final_message\n  External FFmpeg:\tYes"
2350 else
2351   final_message="$final_message\n  External FFmpeg:\tNo"
2352 fi
2353
2354 if test "$host_vendor" = "apple" ; then
2355   # built internal but referenced as external, we link directly to them.
2356   # this MUST be the last thing before OUTPUT_FILES as they do not
2357   # exist until after we build FFMpeg.
2358   LIBS="$LIBS -L\$(abs_top_srcdir)/lib/ffmpeg/libavcodec -lavcodec"
2359   LIBS="$LIBS -L\$(abs_top_srcdir)/lib/ffmpeg/libavfilter -lavfilter"
2360   LIBS="$LIBS -L\$(abs_top_srcdir)/lib/ffmpeg/libswresample -lswresample"
2361   LIBS="$LIBS -L\$(abs_top_srcdir)/lib/ffmpeg/libavformat -lavformat"
2362   LIBS="$LIBS -L\$(abs_top_srcdir)/lib/ffmpeg/libavutil -lavutil"
2363   LIBS="$LIBS -L\$(abs_top_srcdir)/lib/ffmpeg/libpostproc -lpostproc"
2364   LIBS="$LIBS -L\$(abs_top_srcdir)/lib/ffmpeg/libswscale -lswscale"
2365 fi
2366
2367 USE_PVR_ADDONS=0
2368 DISABLE_PVR_ADDON_CONFIG=1
2369 if [[ -f "pvr-addons/Makefile.am" ]]; then
2370   final_message="$final_message\n  PVR add-ons:\t\tYes"
2371   USE_PVR_ADDONS=1
2372   DISABLE_PVR_ADDON_CONFIG=0
2373 else
2374   final_message="$final_message\n  PVR add-ons:\t\tNo"
2375 fi
2376
2377 OUTPUT_FILES="Makefile \
2378     Makefile.include \
2379     addons/skin.confluence/media/Makefile \
2380     xbmc/Makefile \
2381     xbmc/cdrip/Makefile \
2382     xbmc/cores/Makefile \
2383     xbmc/cores/VideoRenderers/Makefile \
2384     xbmc/cores/dvdplayer/Makefile \
2385     lib/Makefile \
2386     lib/libdvd/Makefile \
2387     xbmc/cores/DllLoader/Makefile \
2388     xbmc/cores/DllLoader/exports/Makefile \
2389     xbmc/cores/dvdplayer/DVDCodecs/Makefile \
2390     xbmc/cores/dvdplayer/DVDCodecs/Audio/Makefile \
2391     xbmc/cores/dvdplayer/DVDCodecs/Overlay/Makefile \
2392     xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile \
2393     xbmc/cores/dvdplayer/DVDDemuxers/Makefile \
2394     xbmc/cores/dvdplayer/DVDSubtitles/Makefile \
2395     xbmc/cores/AudioEngine/Makefile \
2396     xbmc/cores/paplayer/Makefile \
2397     xbmc/cores/amlplayer/Makefile \
2398     xbmc/cores/omxplayer/Makefile \
2399     lib/timidity/Makefile \
2400     lib/xbadpcm/Makefile \
2401     lib/asap/Makefile \
2402     lib/nosefart/Makefile \
2403     lib/libsidplay2/Makefile \
2404     lib/vgmstream/Makefile \
2405     lib/snesapu/SNES/SNESAPU/Makefile \
2406     lib/stsound/StSoundLibrary/Makefile \
2407     xbmc/cores/playercorefactory/Makefile \
2408     xbmc/music/karaoke/Makefile \
2409     xbmc/osx/Makefile \
2410     xbmc/guilib/Makefile \
2411     xbmc/interfaces/Makefile \
2412     xbmc/network/Makefile \
2413     xbmc/network/upnp/Makefile \
2414     lib/libRTV/Makefile \
2415     lib/libexif/Makefile \
2416     lib/libXDAAP/Makefile \
2417     lib/cmyth/Makefile \
2418     lib/libhdhomerun/Makefile \
2419     lib/libsquish/Makefile \
2420     lib/cximage-6.0/Makefile \
2421     lib/libUPnP/Makefile \
2422     xbmc/DllPaths_generated.h \
2423     xbmc/DllPaths_generated_android.h \
2424     xbmc/freebsd/Makefile \
2425     xbmc/linux/Makefile \
2426     xbmc/filesystem/Makefile \
2427     xbmc/screensavers/rsxs-0.9/xbmc/Makefile \
2428     xbmc/visualizations/XBMCProjectM/Makefile \
2429     xbmc/visualizations/Goom/Makefile \
2430     xbmc/visualizations/OpenGLSpectrum/Makefile \
2431     xbmc/visualizations/fishBMC/Makefile \
2432     xbmc/visualizations/WaveForm/Makefile \
2433     lib/addons/library.xbmc.addon/Makefile \
2434     lib/addons/library.xbmc.codec/Makefile \
2435     lib/addons/library.xbmc.gui/Makefile \
2436     lib/addons/library.xbmc.pvr/Makefile \
2437     xbmc/visualizations/EGLHelpers/Makefile \
2438     tools/Linux/xbmc.sh \
2439     tools/Linux/xbmc-standalone.sh \
2440     tools/TexturePacker/Makefile \
2441     tools/EventClients/Clients/OSXRemote/Makefile \
2442     xbmc/peripherals/bus/Makefile \
2443     xbmc/peripherals/devices/Makefile \
2444     xbmc/android/activity/Makefile \
2445     xbmc/android/loader/Makefile \
2446     xbmc/android/jni/Makefile \
2447     xbmc/utils/Makefile \
2448     xbmc/main/Makefile \
2449     project/cmake/xbmc-config.cmake"
2450
2451 if test "$use_skin_touched" = "yes"; then
2452 OUTPUT_FILES="$OUTPUT_FILES addons/skin.touched/media/Makefile"
2453 fi
2454
2455 OUTPUT_FILES="$OUTPUT_FILES \
2456   xbmc/interfaces/python/Makefile \
2457   xbmc/interfaces/python/test/Makefile"
2458
2459 # Line below is used so we can use AM_INIT_AUTOMAKE. The corresponding
2460 # .dummy.am does nothing.
2461 AC_CONFIG_FILES([.dummy])
2462
2463 AC_CONFIG_FILES([${OUTPUT_FILES}])
2464 OUTPUT_FILES="$OUTPUT_FILES \
2465   .dummy"
2466 AC_SUBST(CFLAGS)
2467 AC_SUBST(CXXFLAGS)
2468 AC_SUBST(INCLUDES)
2469 AC_SUBST(LDFLAGS)
2470 AC_SUBST(SDL_DEFINES)
2471 AC_SUBST(BUILD_DVDCSS)
2472 AC_SUBST(DISABLE_WAVEFORM)
2473 AC_SUBST(DISABLE_SPECTRUM)
2474 AC_SUBST(DISABLE_GOOM)
2475 AC_SUBST(DISABLE_RSXS)
2476 AC_SUBST(DISABLE_FISHBMC)
2477 AC_SUBST(DISABLE_PROJECTM)
2478 AC_SUBST(USE_SKIN_TOUCHED)
2479 AC_SUBST(USE_EXTERNAL_FFMPEG)
2480 AC_SUBST(USE_LIBAV_HACKS)
2481 AC_SUBST(PYTHON_VERSION)
2482 AC_SUBST(OUTPUT_FILES)
2483 AC_SUBST(HAVE_XBMC_NONFREE)
2484 AC_SUBST(USE_ASAP_CODEC)
2485 AC_SUBST(LIBCURL_BASENAME)
2486 AC_SUBST(LIBFLAC_BASENAME)
2487 AC_SUBST(LIBVORBISFILE_BASENAME)
2488 AC_SUBST(LIBMODPLUG_BASENAME)
2489 AC_SUBST(LIBMAD_BASENAME)
2490 AC_SUBST(LIBOGG_BASENAME)
2491 AC_SUBST(LIBVORBISENC_BASENAME)
2492 AC_SUBST(LIBVORBIS_BASENAME)
2493 AC_SUBST(LIBASS_BASENAME)
2494 AC_SUBST(LIBMEPG2_BASENAME)
2495 AC_SUBST_FILE(XBMC_STANDALONE_SH_PULSE)
2496 AC_SUBST(USE_OPENGL)
2497 AC_SUBST(USE_OPENGLES)
2498 AC_SUBST(USE_VDPAU)
2499 AC_SUBST(USE_VAAPI)
2500 AC_SUBST(USE_CRYSTALHD)
2501 AC_SUBST(USE_LIBSMBCLIENT)
2502 AC_SUBST(USE_LIBNFS)
2503 AC_SUBST(USE_LIBAFPCLIENT)
2504 AC_SUBST(USE_AIRPLAY)
2505 AC_SUBST(USE_OPENMAX)
2506 AC_SUBST(USE_PULSE)
2507 AC_SUBST(USE_XRANDR)
2508 AC_SUBST(USE_ALSA)
2509 AC_SUBST(USE_TEXTUREPACKER)
2510 AC_SUBST(USE_TEXTUREPACKER_NATIVE)
2511 AC_SUBST(USE_TEXTUREPACKER_NATIVE_ROOT)
2512 AC_SUBST(USE_AIRTUNES)
2513 AC_SUBST(USE_LIBUDEV)
2514 AC_SUBST(USE_LIBUSB)
2515 AC_SUBST(USE_LIBCEC)
2516 AC_SUBST(USE_MYSQL)
2517 AC_SUBST(USE_WEB_SERVER)
2518 AC_SUBST(USE_UPNP)
2519 AC_SUBST(USE_OMXLIB)
2520 AC_SUBST(USE_ANDROID)
2521 AC_SUBST(GTEST_CONFIGURED)
2522 AC_SUBST(USE_DOXYGEN)
2523 AC_SUBST(USE_PVR_ADDONS)
2524
2525 # pushd and popd are not available in other shells besides bash, so implement
2526 # our own pushd/popd functions
2527 XB_DIRSTACK="$PWD"
2528 xb_pushd()
2529 {
2530   local dirname="$1"
2531   if [[ -d "$dirname" ]] && [[ -x "$dirname" ]]; then
2532     cd "$dirname"
2533     XB_DIRSTACK="$dirname ${XB_DIRSTACK:-$PWD}"
2534     return 0
2535   else
2536     AC_MSG_ERROR(xb_pushd: unable to change to $dirname)
2537   fi
2538 }
2539 xb_popd()
2540 {
2541   if [[ -n "$XB_DIRSTACK" ]]; then
2542     XB_DIRSTACK="${XB_DIRSTACK#* }"
2543     cd "${XB_DIRSTACK%% *}"
2544     return 0
2545   else
2546     AC_MSG_ERROR(xb_popd: unable to go back to previous directory)
2547   fi
2548 }
2549
2550 # Function to run the configure scripts in our submodules
2551 # Consists of three paramaters, the path to the submodule, the configure command
2552 # with appropriate arguments, and a third parameter set to 1 if we are to skip
2553 # running the script, anything else if not.
2554 AC_DEFUN([XB_CONFIG_MODULE],[
2555 AC_CONFIG_COMMANDS_POST([
2556 if [[ $3 != "1" ]]; then
2557     if [[ -d $1 ]]; then
2558       xb_pushd $1
2559       $2
2560       if [[ $? -ne 0 ]]; then
2561         xb_popd
2562         AC_MSG_ERROR([[Submodule $1 failed to configure]])
2563       else
2564         xb_popd
2565       fi
2566     else
2567       AC_MSG_ERROR([[Submodule $1 does not exist]])
2568     fi
2569 else
2570     AC_MSG_NOTICE([[Skipping configuration of submodule $1.]])
2571 fi
2572 ])
2573 ])
2574
2575 XB_CONFIG_MODULE([lib/ffmpeg], [
2576   if test "$host_vendor" = "apple" ; then
2577     ffmpg_config="--target-os=$ffmpeg_target_os"
2578     # handle disables first, we do individual enables later
2579     ffmpg_config="$ffmpg_config --disable-muxers   --disable-encoders"
2580     ffmpg_config="$ffmpg_config --disable-devices  --disable-doc"
2581     ffmpg_config="$ffmpg_config --disable-ffplay   --disable-ffmpeg"
2582     ffmpg_config="$ffmpg_config --disable-ffprobe  --disable-ffserver"
2583     ffmpg_config="$ffmpg_config --enable-vda       --disable-crystalhd"
2584     ffmpg_config="$ffmpg_config --disable-decoder=mpeg_xvmc"
2585
2586     # handle conditional enables/disables
2587     if test "$use_debug" = "no"; then
2588       ffmpg_config="$ffmpg_config --disable-debug"
2589     fi
2590     if test "$use_cpu"  != "no";  then
2591       ffmpg_config="$ffmpg_config --cpu=$use_cpu"
2592     fi
2593     if test "$use_arch" != "no"; then
2594       ffmpg_config="$ffmpg_config --arch=$use_arch --enable-cross-compile"
2595     fi
2596     if test "$use_arch"  = "arm"; then
2597       ffmpg_config="$ffmpg_config --enable-pic"
2598       ffmpg_config="$ffmpg_config --disable-armv5te --disable-armv6t2"
2599       if test "$use_neon"  = "yes"; then
2600         ffmpg_config="$ffmpg_config --enable-neon"
2601       else
2602         ffmpg_config="$ffmpg_config --disable-neon"
2603       fi
2604     else
2605       ffmpg_config="$ffmpg_config --disable-amd3dnow"
2606     fi
2607     if test "$use_ffmpeg_libvorbis" = "yes"; then
2608       ffmpg_config="$ffmpg_config --enable-libvorbis --enable-muxer=ogg --enable-encoder=libvorbis"
2609     else
2610       ffmpg_config="$ffmpg_config --disable-libvorbis"
2611     fi
2612
2613     # handle individual enables
2614     ffmpg_config="$ffmpg_config --enable-gpl"
2615     ffmpg_config="$ffmpg_config --enable-postproc"
2616     ffmpg_config="$ffmpg_config --enable-static      --enable-pthreads"
2617     ffmpg_config="$ffmpg_config --enable-muxer=spdif --enable-muxer=adts --enable-muxer=asf --enable-muxer=ipod"
2618     ffmpg_config="$ffmpg_config --enable-encoder=ac3 --enable-encoder=aac --enable-encoder=wmav2"
2619     ffmpg_config="$ffmpg_config --enable-protocol=http"
2620     ffmpg_config="$ffmpg_config --enable-runtime-cpudetect"
2621
2622     # ffmpeg will not compile with llvm-gcc-4.2, use clang instead
2623     case $CC in
2624       *llvm-gcc-4.2*)
2625         ffmpg_config="$ffmpg_config --cc=clang" ;;
2626       *)
2627         ffmpg_config="$ffmpg_config --cc=$CC" ;;
2628     esac
2629     
2630     # extra-cflags must be passed alone or it gets expanded wrong by the ffmpeg configure
2631     FFMPEG_EXTRACFLAGS="$CFLAGS $FFMPEG_EXTRACFLAGS -w -D_DARWIN_C_SOURCE -Dattribute_deprecated="
2632
2633     LDFLAGS="$LDFLAGS" ./configure --extra-cflags="$FFMPEG_EXTRACFLAGS" $ffmpg_config --as="$AS"
2634
2635     # if using llvm-gcc-4.2 as assembler, -MMD is not enough to generate
2636     # dependency files in the right place, replace it with something that works
2637     case $AS in
2638       *llvm-gcc-4.2*)
2639         sed -ie "s#AS_DEPFLAGS=-MMD#AS_DEPFLAGS=-MMD -MF \$(\@:.o=.d) -MT \$\@#" config.mak ;;
2640     esac
2641
2642     # ffmpeg will use yasm found at ${prefix}/bin during configure
2643     # but then hardcodes 'yasm' in config.mak, fix it.
2644     sed -ie "s#YASM=yasm#YASM=${YASM}#" config.mak
2645     sed -ie "s#YASMDEP=yasm#YASMDEP=${YASM}#" config.mak
2646     sed -ie "s# -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 # #" config.mak
2647   else
2648     CFLAGS="" \
2649     CPPFLAGS="" \
2650     CXXFLAGS="" \
2651     LDFLAGS="$(echo "$LDFLAGS" | sed "s/-Wl,-Bsymbolic-functions//g")" \
2652     ./configure \
2653       --extra-cflags="$PASSED_CFLAGS $FFMPEG_EXTRACFLAGS" \
2654       --disable-static \
2655       `if test "$use_debug" = "no"; then echo --disable-debug; fi` \
2656       `if test "$cross_compiling" = "yes"; then echo --enable-cross-compile; fi` \
2657       `if test "$use_arch" != "no"; then echo --arch=$use_arch; fi`\
2658       `if test "$use_cpu" != "no"; then echo --cpu=$use_cpu; fi`\
2659       `if test "$use_neon" = "yes"; then echo --enable-neon; else echo --disable-neon; fi`\
2660       --target-os=$ffmpeg_target_os \
2661       --disable-muxers \
2662       --enable-muxer=spdif \
2663       --enable-muxer=adts \
2664       --enable-muxer=asf \
2665       --enable-muxer=ipod \
2666       --disable-encoders \
2667       --enable-encoder=ac3 \
2668       --enable-encoder=aac \
2669       --enable-encoder=wmav2 \
2670       `if test "$use_ffmpeg_libvorbis" = "yes"; then echo --enable-libvorbis --enable-muxer=ogg --enable-encoder=libvorbis; else echo --disable-libvorbis; fi` \
2671       --disable-decoder=mpeg_xvmc \
2672       --disable-devices \
2673       --disable-ffprobe \
2674       --disable-ffplay \
2675       --disable-ffserver \
2676       --disable-ffmpeg \
2677       --disable-crystalhd \
2678       --enable-shared \
2679       --disable-doc \
2680       --enable-postproc \
2681       --enable-gpl \
2682       `if test "x$use_vdpau" != "xno"; then echo --enable-vdpau; else echo --disable-vdpau; fi` \
2683       `if test "x$use_vaapi" != "xno"; then echo --enable-vaapi; else echo --disable-vaapi; fi` \
2684       `if test "$use_optimizations" != "no"; then echo --enable-optimizations; else echo --disable-optimizations; fi` \
2685       --enable-protocol=http \
2686       --enable-pthreads \
2687       --enable-runtime-cpudetect \
2688       `if test "$use_hardcoded_tables" = "yes"; then echo --enable-hardcoded-tables; else echo --disable-hardcoded-tables; fi`\
2689       `if test "$target_platform" = "target_android" && test "$host_cpu" = "i686"; then echo --disable-mmx; fi #workaround for gcc 4.6 bug` \
2690       `if test "$target_platform" = "target_android"; then echo "--custom-libname-with-major=\\$(SLIBPREF)\\$(FULLNAME)-\\$(LIBMAJOR)-${ARCH}\\$(SLIBSUF)"; \
2691        else echo "--custom-libname-with-major=\\$(FULLNAME)-\\$(LIBMAJOR)-${ARCH}\\$(SLIBSUF)"; fi` \
2692       `case $host_cpu in i?86*) echo --disable-pic ;; *) echo --enable-pic ;; esac` \
2693       --cc="$CC" &&
2694       sed -i -e "s#define HAVE_SYMVER 1#define HAVE_SYMVER 0#" config.h &&
2695       sed -i -e "s#define HAVE_SYMVER_GNU_ASM 1#define HAVE_SYMVER_GNU_ASM 0#" config.h
2696   fi
2697 ], [$USE_EXTERNAL_FFMPEG])
2698
2699 XB_CONFIG_MODULE([lib/libdvd/libdvdcss], [
2700   ./configure \
2701     CC="$CC" \
2702     CXX="$CXX" \
2703     CFLAGS="$CFLAGS" \
2704     --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
2705     --host=$host_alias \
2706     --build=$build_alias \
2707     --target=$target_alias \      
2708     --disable-doc \
2709     --enable-static \
2710     --with-pic
2711 ], [$SKIP_CONFIG_DVDCSS])
2712
2713 XB_CONFIG_MODULE([lib/libdvd/libdvdread], [
2714   ./configure2 \
2715     --extra-cflags="$CFLAGS $DVDREAD_CFLAGS -I`pwd`/../libdvdcss/src" \
2716     --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
2717     --host=$host_alias \
2718     --build=$build_alias \
2719     --target=$target_alias \      
2720     --enable-static \
2721     --disable-shared \
2722     --disable-strip \
2723     --disable-opts \
2724     --cc="$CC" &&
2725   $MAKE dvdread-config &&
2726   mkdir -p `pwd`/../includes/dvdread
2727   cp `pwd`/../libdvdread/src/*.h `pwd`/../includes/dvdread
2728   cp `pwd`/../libdvdread/src/dvdread/*.h `pwd`/../includes/dvdread
2729 ], [0])
2730
2731 XB_CONFIG_MODULE([lib/libdvd/libdvdnav], [
2732   ./configure2 \
2733     --extra-cflags="$CFLAGS $DVDREAD_CFLAGS -I`pwd`/../includes" \
2734     --extra-ldflags="-L`pwd`/../libdvdread/obj" \
2735     --with-dvdread-config="`pwd`/../libdvdread/obj/dvdread-config" \
2736     --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
2737     --host=$host_alias \
2738     --build=$build_alias \
2739     --target=$target_alias \      
2740     --enable-static \
2741     --disable-shared \
2742     --cc="$CC"
2743 ], [0])
2744
2745 XB_CONFIG_MODULE([xbmc/visualizations/XBMCProjectM/libprojectM],[
2746   set -x
2747   rm -f CMakeCache.txt &&                              \
2748   CC="$ORIGCC" CXX="$ORIGCXX" LDFLAGS="$LDFLAGS" cmake \
2749     -DCMAKE_BUILD_TYPE=None -DUSE_FTGL:BOOL=OFF        \
2750     -DCMAKE_C_FLAGS:STRING="${CPPFLAGS} ${CFLAGS}"     \
2751     -DCMAKE_CXX_FLAGS:STRING="${CPPFLAGS} ${CXXFLAGS}" \
2752     -DCMAKE_INSTALL_PREFIX="${prefix}"                 \
2753     -DCMAKE_INSTALL_LIBDIR:PATH="${libdir}"            \
2754     -DINCLUDE_INSTALL_DIR:PATH="${includedir}"         \
2755     -DLIB_INSTALL_DIR:PATH="${libdir}"                 \
2756     -DSYSCONF_INSTALL_DIR:PATH="${sysconfdir}"         \
2757     -DSHARE_INSTALL_PREFIX:PATH="${datadir}" . &&
2758   if test "$host_vendor" = "apple" ; then
2759     # cmake has hardcoded paths to macports which bork our darwin depends cross/ppc, remove them
2760     sed -ie "s|-L/opt/local/lib| |" CMakeFiles/projectM.dir/link.txt
2761     sed -ie "s|-L/opt/local/lib| |" CMakeFiles/projectM.dir/flags.make
2762     sed -ie "s|-I/opt/local/include| |" CMakeFiles/projectM.dir/flags.make
2763   fi
2764   set +x
2765 ], [$DISABLE_PROJECTM])
2766
2767 XB_CONFIG_MODULE([xbmc/visualizations/Goom/goom2k4-0],[
2768   ./configure  \
2769     CFLAGS="$CFLAGS" \ 
2770     CXXFLAGS="$CXXFLAGS" \
2771     --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
2772     --host=$host_alias \
2773     --build=$build_alias \
2774     --target=$target_alias \      
2775     --disable-shared \
2776     --enable-static \
2777     --with-pic
2778 ], [$DISABLE_GOOM])
2779
2780 XB_CONFIG_MODULE([xbmc/screensavers/rsxs-0.9/], [
2781   if test "$host_vendor" = "apple"; then
2782     TEMPCFLAGS="${CFLAGS} -fgnu89-inline";
2783   else
2784     TEMPCFLAGS="$CFLAGS";
2785   fi
2786   ./configure \
2787     CC="$CC" \
2788     CXX="$CXX" \
2789     CFLAGS="$TEMPCFLAGS" \ 
2790     CXXFLAGS="$CXXFLAGS" \
2791     `if test "$host_vendor" = "apple"; then echo --with-png=${prefix} --x-includes=/usr/X11/include --x-libraries=/usr/X11/lib; fi` \
2792     --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
2793     --host=$host_alias \
2794     --build=$build_alias \
2795     --target=$target_alias \      
2796     --without-xscreensaver \
2797     --disable-sound \
2798     --disable-cyclone \
2799     --disable-fieldlines \
2800     --disable-flocks \
2801     --disable-flux \
2802     --disable-helios \
2803     --disable-hyperspace \
2804     --disable-lattice \
2805     --disable-skyrocket
2806   if echo "$ARCH" | grep -q freebsd ; then
2807     sed -i.back "s;\(STDBOOL_H = \)stdbool.h;\1;" lib/Makefile
2808   fi
2809 ], [$DISABLE_RSXS])
2810
2811 XB_CONFIG_MODULE([lib/cpluff], [
2812   ./configure --disable-nls \
2813     --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
2814     --host=$host_alias \
2815     --build=$build_alias \
2816     --target=$target_alias CFLAGS="$CFLAGS" CC="$CC" CXX="$CXX" LDFLAGS="$LDFLAGS" LIBS=""
2817     #LDFLAGS="$LDFLAGS -Wl,-read_only_relocs,suppress"    
2818 ], [0])
2819
2820 XB_CONFIG_MODULE([lib/gtest], [
2821   ./configure \
2822     CC="$CC" \
2823     CXX="$CXX" \
2824     CFLAGS="$CFLAGS" \
2825     --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
2826     --host=$host_alias \
2827     --build=$build_alias \
2828     --target=$target_alias \
2829     --disable-shared \
2830     --enable-static \
2831     --with-pthreads
2832 ], [$SKIP_CONFIG_GTEST])
2833
2834 XB_CONFIG_MODULE([pvr-addons], [
2835   ./configure \
2836     --prefix="${prefix}" \
2837     --host=$host_alias \
2838     --build=$build_alias \
2839     --target=$target_alias \
2840     CC="$CC" \
2841     CXX="$CXX" \
2842     CFLAGS="$CFLAGS" \
2843     CXXFLAGS="$CXXFLAGS"
2844 ], [$DISABLE_PVR_ADDON_CONFIG])
2845
2846 AC_OUTPUT
2847
2848 final_message="$final_message\n  prefix:\t$prefix\n$dashes"
2849 echo -e "$final_message\n"