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