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