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