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