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