[osx] we want basename, not the path
[xbmc:xbmc-antiquated.git] / 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], [9.11], [http://trac.xbmc.org])
6 AC_CONFIG_HEADERS([config.h])
7 AH_TOP([#pragma once])
8
9 AC_CONFIG_AUX_DIR([build-aux])
10 AM_INIT_AUTOMAKE([foreign])
11 AC_CANONICAL_HOST
12
13 tolower(){
14   echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
15 }
16
17 # check for library basenames
18 AC_DEFUN([XB_FIND_SONAME],
19 [
20   if [[ "$host_vendor" != "apple" ]]; then
21     AC_MSG_CHECKING([for lib$2 soname])
22     $1_SONAME=$( $CC -print-file-name=lib$2.so | \
23       while read output; do objdump -p $output | \
24         grep "SONAME" | \
25         sed -e 's/ \+SONAME \+//'; done 2> /dev/null )
26   else
27     AC_MSG_CHECKING([for lib$2 dylib])
28     gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
29     env_lib_path=[`echo $LDFLAGS | sed 's/-L[ ]*//g'`]
30     if test "$cross_compiling" = yes; then
31       host_lib_path=""
32     else
33       host_lib_path="/usr/lib /usr/local/lib"
34     fi
35     for path in $gcc_lib_path $env_lib_path $host_lib_path; do
36       lib=[`ls -- $path/lib$2.dylib 2>/dev/null`]
37       if test x$lib != x; then
38         # we want the path/name that is embedded in the dylib 
39         $1_SONAME=[`otool -L $lib | grep -v lib$2.dylib | grep lib$2 | awk '{V=1; print $V}'`]
40         $1_SONAME=[`basename $$1_SONAME`]
41       fi
42     done
43   fi
44   if [[ -z "$$1_SONAME" ]]; then
45     AC_MSG_RESULT([no])
46     if test -z "$3" || test "x${$3}" = "xyes"; then
47       AC_MSG_ERROR([Unable to determine soname of lib$2 library])
48     else
49       AC_MSG_WARN([Unable to determine soname of lib$2 library])
50       $3=no
51       AC_MSG_WARN([lib$2 support disabled])
52     fi
53   else
54     AC_MSG_RESULT([$$1_SONAME])
55     AC_SUBST($1_SONAME)
56   fi
57 ])
58
59 # General message strings
60 configure_debug="ERROR: this is a configure debug statement"
61 missing_library="Could not find a required library. Please see the README for your platform."
62 missing_headers="Could not find some required headers. Please see the README for your platform."
63 missing_program="Could not find a required program. Please see the README for your platform."
64 xrandr_not_found="== Could not find libXRandR. SDL will be used for resolution support. =="
65 xrandr_disabled="== XRandR support disabled. SDL will be used for resolution support. =="
66 goom_enabled="== GOOM enabled. =="
67 goom_disabled="== GOOM disabled. =="
68 pulse_not_found="== Could not find libpulse. PulseAudio support disabled. =="
69 pulse_disabled="== PulseAudio support manually disabled. =="
70 dvdcss_enabled="== DVDCSS support enabled. =="
71 dvdcss_disabled="== DVDCSS support disabled. =="
72 hal_not_found="== Could not find hal. HAL support disabled. =="
73 halstorage_not_found="== Could not find hal-storage. HAL support disabled. =="
74 hal_disabled="== HAL support disabled. =="
75 avahi_not_found="== Could not find libavahi-common or libavahi-client. Avahi support disabled. =="
76 avahi_disabled="== Avahi support disabled. =="
77 vdpau_not_found="== Could not find libvdpau. VDPAU support disabled. =="
78 vdpau_disabled="== VDPAU support manually disabled. =="
79 vaapi_not_found="== Could not find libva. VAAPI support disabled. =="
80 vaapi_disabled="== VAAPI support manually disabled. =="
81 crystalhd_not_found="== Could not find libcrystalhd. CrystalHD support disabled. =="
82 crystalhd_disabled="== CrystalHD support manually disabled. =="
83 vdadecoder_enabled="== VDADecoder support enabled. =="
84 vdadecoder_disabled="== VDADecoder support manually disabled. =="
85 openmax_disabled="== OpenMax support manually disabled. =="
86 openmax_not_found="== Could not find libnvomx. OpenMax support disabled. =="
87 libass_using_internal="== External Libass not found, using internal. =="
88 ssh_not_found="== Could not find libssh. SSH FTP VFS support disabled. =="
89 librtmp_not_found="== Could not find libRTMP. RTMP support disabled. =="
90 librtmp_disabled="== RTMP support disabled. =="
91
92 # External library message strings
93 external_libraries_enabled="== Use of all supported external libraries enabled. =="
94 external_libraries_disabled="== Use of all supported external libraries disabled. =="
95 external_ffmpeg_enabled="== Use of external ffmpeg enabled. =="
96 external_ffmpeg_disabled="== Use of external ffmpeg disabled. =="
97 external_liba52_enabled="== Use of external liba52 enabled. =="
98 external_liba52_disabled="== Use of external liba52 disabled. =="
99 external_libdts_enabled="== Use of external libdts enabled. =="
100 external_libdts_disabled="== Use of external libdts disabled. =="
101 external_python_enabled="== Use of external python enabled. =="
102 external_python_disabled="== Use of external python disabled. =="
103 ffmpeg_vdpau_not_supported="== External ffmpeg doesn't support VDPAU. VDPAU support disabled. =="
104 dashes="------------------------"
105 final_message="\n  XBMC Configuration:"
106 final_message="\n$dashes$final_message\n$dashes"
107
108
109 AC_ARG_ENABLE([debug],
110   [AS_HELP_STRING([--enable-debug],
111   [enable debugging information (default is yes)])],
112   [use_debug=$enableval],
113   [use_debug=yes])
114
115 AC_ARG_WITH([arch],
116   [AS_HELP_STRING([--with-arch],
117   [build with given arch passing to internal ffmpeg (default is no, needed for crosscompiling)])],
118   [use_arch=$withval],
119   [use_arch=no])
120
121 AC_ARG_WITH([cpu],
122   [AS_HELP_STRING([--with-cpu],
123   [build with given cpu passing to ffmpeg (default is no)])],
124   [use_cpu=$withval],
125   [use_cpu=no])
126
127 AC_ARG_ENABLE([optimizations],
128   [AS_HELP_STRING([--enable-optimizations],
129   [enable optimization (default is yes)])],
130   [use_optimizations=$enableval],
131   [use_optimizations=yes])
132
133 AC_ARG_ENABLE([gl],
134   [AS_HELP_STRING([--enable-gl],
135   [enable OpenGL rendering (default is yes)])],
136   [use_gl=$enableval],
137   [use_gl=yes])
138
139 AC_ARG_ENABLE([gles],
140   [AS_HELP_STRING([--enable-gles],
141   [enable OpenGLES rendering (default is no)])],
142   [use_gles=$enableval],
143   [use_gles=no])
144
145 AC_ARG_ENABLE([vdpau],
146   [AS_HELP_STRING([--enable-vdpau],
147   [enable VDPAU decoding (default is auto)])],
148   [use_vdpau=$enableval],
149   [use_vdpau=auto])
150
151 AC_ARG_ENABLE([vaapi],
152   [AS_HELP_STRING([--enable-vaapi],
153   [enable VAAPI decoding (default is auto)])],
154   [use_vaapi=$enableval],
155   [use_vaapi=auto])
156
157 AC_ARG_ENABLE([crystalhd],
158   [AS_HELP_STRING([--enable-crystalhd],
159   [enable CrystalHD decoding (default is auto)])],
160   [use_crystalhd=$enableval],
161   [use_crystalhd=auto])
162
163 AC_ARG_ENABLE([vdadecoder],
164   [AS_HELP_STRING([--enable-vdadecoder],
165   [enable VDADecoder decoding (default is auto)])],
166   [use_vdadecoder=$enableval],
167   [use_vdadecoder=auto])
168
169 AC_ARG_ENABLE([openmax],
170   [AS_HELP_STRING([--enable-openmax],
171   [enable OpenMax decoding (default is yes)])],
172   [use_openmax=$enableval],
173   [use_openmax=yes])
174
175 AC_ARG_ENABLE([tegra],
176   [AS_HELP_STRING([--enable-tegra],
177   [enable Tegra2 arm (default is no)])],
178   [use_tegra=$enableval],
179   [use_tegra=no])
180
181 AC_ARG_ENABLE([profiling],
182   [AS_HELP_STRING([--enable-profiling],
183   [enable gprof profiling (default is no)])],
184   [use_profiling=$enableval],
185   [use_profiling=no])
186
187 AC_ARG_ENABLE([joystick],
188   [AS_HELP_STRING([--enable-joystick],
189   [enable SDL joystick support (default is yes)])],
190   [use_joystick=$enableval],
191   [use_joystick=yes])
192
193 AC_ARG_ENABLE([xrandr],
194   [AS_HELP_STRING([--enable-xrandr],
195   [enable XRandR support (default is yes)])],
196   [use_xrandr=$enableval],
197   [use_xrandr=yes])
198
199 AC_ARG_ENABLE([goom],
200   [AS_HELP_STRING([--enable-goom],
201   [enable GOOM visualisation (default is no)])],
202   [use_goom=$enableval],
203   [use_goom=no])
204
205 AC_ARG_ENABLE([ccache],
206   [AS_HELP_STRING([--enable-ccache],
207   [enable building with ccache feature (default is auto)])],
208   [use_ccache=$enableval],
209   [use_ccache=auto])
210
211 AC_ARG_ENABLE([pulse],
212   [AS_HELP_STRING([--enable-pulse],
213   [enable PulseAudio support (default is auto)])],
214   [use_pulse=$enableval],
215   [use_pulse=auto])
216
217 AC_ARG_ENABLE([rtmp],
218   [AS_HELP_STRING([--enable-rtmp],
219   [enable RTMP support via librtmp (default is auto)])],
220   [use_librtmp=$enableval],
221   [use_librtmp=auto])
222
223 AC_ARG_ENABLE([ffmpeg_libvorbis],
224   [AS_HELP_STRING([--enable-ffmpeg-libvorbis],
225   [enable FFmpeg vorbis encoding (default is no)])],
226   [use_ffmpeg_libvorbis=$enableval],
227   [use_ffmpeg_libvorbis=no])
228
229 AC_ARG_ENABLE([dvdcss],
230   [AS_HELP_STRING([--enable-dvdcss],
231   [enable DVDCSS support (default is yes)])],
232   [use_dvdcss=$enableval],
233   [use_dvdcss=yes])
234
235 AC_ARG_ENABLE([mid],
236   [AS_HELP_STRING([--enable-mid],
237   [enable MID support (default is no)])],
238   [use_mid=$enableval],
239   [use_mid=no])
240
241 AC_ARG_ENABLE([hal],
242   [AS_HELP_STRING([--disable-hal],
243   [disable HAL support (default is enabled if hal and hal-storage is found)])],
244   [use_hal=$enableval],
245   [use_hal=yes])
246
247 AC_ARG_ENABLE([avahi],
248   [AS_HELP_STRING([--disable-avahi],
249   [disable Avahi support (default is enabled if libavahi-common and libavahi-client is found)])],
250   [use_avahi=$enableval],
251   [use_avahi=yes])
252
253 AC_ARG_ENABLE([non-free],
254   [AS_HELP_STRING([--disable-non-free],
255   [disable componentents with non-compliant licenses])],
256   [use_nonfree=$enableval],
257   [use_nonfree=yes])
258
259 AC_ARG_ENABLE([asap-codec],
260   [AS_HELP_STRING([--enable-asap-codec],
261   [enable ASAP ADPCM support])],
262   [use_asap=$enableval],
263   [use_asap=no])
264
265 AC_ARG_ENABLE([webserver],
266   [AS_HELP_STRING([--disable-webserver],
267   [disable webserver])],
268   [use_webserver=$enableval],
269   [use_webserver=yes])
270
271 AC_ARG_ENABLE([optical-drive],
272   [AS_HELP_STRING([--disable-optical-drive],
273   [disable optical drive])],
274   [use_optical_drive=$enableval],
275   [use_optical_drive=yes])
276
277 AC_ARG_ENABLE([libdts],
278   [AS_HELP_STRING([--enable-libdts],
279   [enable deprecated libdts support])],
280   [use_libdts=$enableval],
281   [use_libdts=no])
282
283 AC_ARG_ENABLE([liba52],
284   [AS_HELP_STRING([--enable-liba52],
285   [enable deprecated liba52 support])],
286   [use_liba52=$enableval],
287   [use_liba52=no])
288
289 AC_ARG_ENABLE([libbluray],
290   [AS_HELP_STRING([--enable-libbluray],
291   [enable libbluray support])],
292   [use_libbluray=$enableval],
293   [use_libbluray=auto])
294
295 AC_ARG_WITH([lirc-device],
296   [AS_HELP_STRING([--with-lirc-device=file],
297   [specify the default LIRC device (default is /dev/lircd)])],
298   [lirc_device=$withval],
299   [lirc_device=/dev/lircd])
300 AC_DEFINE_UNQUOTED([LIRC_DEVICE], ["$lirc_device"], [Default LIRC device])
301
302 ### External libraries options
303 AC_ARG_ENABLE([external-libraries],
304   [AS_HELP_STRING([--enable-external-libraries],
305   [enable use of all supported external libraries (default is no) 'Linux only'])],
306   [use_external_libraries=$enableval],
307   [use_external_libraries=no])
308
309 AC_ARG_ENABLE([external-ffmpeg],
310   [AS_HELP_STRING([--enable-external-ffmpeg],
311   [enable use of external ffmpeg libraries (default is no) 'Linux only'])],
312   [use_external_ffmpeg=$enableval],
313   [use_external_ffmpeg=$use_external_libraries])
314
315 AC_ARG_ENABLE([external-liba52],
316   [AS_HELP_STRING([--enable-external-liba52],
317   [enable use of external liba52 library (default is no) 'Linux only'])],
318   [use_external_liba52=$enableval],
319   [use_external_liba52=$use_external_libraries])
320
321 AC_ARG_ENABLE([external-libdts],
322   [AS_HELP_STRING([--enable-external-libdts],
323   [enable use of external libdts library (default is no) 'Linux only'])],
324   [use_external_libdts=$enableval],
325   [use_external_libdts=$use_external_libraries])
326
327 AC_ARG_ENABLE([external-python],
328   [AS_HELP_STRING([--enable-external-python],
329   [enable use of external python library (default is no) 'Linux only'])],
330   [use_external_python=$enableval],
331   [use_external_python=$use_external_libraries])
332
333 use_external_libass="yes"
334 ### End of external library options
335 DEFAULT_COMPILE_FLAGS="-fPIC -DPIC -D_REENTRANT"
336 if test "x$host_vendor" = "xapple"; then
337   DEFAULT_COMPILE_FLAGS="$DEFAULT_COMPILE_FLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4"
338 else
339   DEFAULT_COMPILE_FLAGS="$DEFAULT_COMPILE_FLAGS -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64"
340 fi
341 # Checks for programs.
342 PASSED_CXXFLAGS=$CXXFLAGS # Hack to override autoconf default values
343 AC_PROG_CXX
344 CXXFLAGS="$PASSED_CXXFLAGS $DEFAULT_COMPILE_FLAGS"
345 PASSED_CFLAGS=$CFLAGS # Hack to override autoconf default values
346 AC_PROG_CC
347 AC_PROG_LIBTOOL
348 CFLAGS="$PASSED_CFLAGS $DEFAULT_COMPILE_FLAGS"
349 AC_PROG_AWK
350 AC_PROG_LN_S
351 AC_PROG_MAKE_SET
352
353 # host detection and setup
354 case $host in
355   i*86*-linux-gnu*)
356      ARCH="i486-linux"
357      ;;
358   x86_64-*-linux-gnu*)
359      ARCH="x86_64-linux"
360      ;;
361   i386-apple-darwin*)
362      ARCH="x86-osx"
363      # define i386 or x86_64, cannot use $HOSTTYPE as it reports x86_64 on 10.6 regardless of kernel flavor
364      ARCHTYPE=`uname -m`
365      AC_SUBST([ARCHTYPE])
366      ;;
367   powerpc-apple-darwin*)
368      ARCH="powerpc-osx"
369      # define ppc
370      ARCHTYPE=`arch`
371      AC_SUBST([ARCHTYPE])
372      ;;
373   powerpc-*-linux-gnu*)
374      ARCH="powerpc-linux"
375      AC_SUBST(ARCH_DEFINES, "-D_POWERPC")
376      ;;
377   powerpc64-*-linux-gnu*)
378      ARCH="powerpc64-linux"
379      AC_SUBST(ARCH_DEFINES, "-D_POWERPC64")
380      ;;
381   arm*-*-linux-gnu*)
382      ARCH="arm"
383      AC_SUBST(ARCH_DEFINES, "-D_ARMEL")
384      ;;
385   *)
386      AC_MSG_ERROR(unsupported host ($host))
387 esac
388 AC_SUBST([ARCH])
389 if test "$use_debug" = "yes"; then
390   final_message="$final_message\n  Debugging:\tYes"
391   if test "$use_profiling" = "yes"; then
392     final_message="$final_message\n  Profiling:\tYes"
393     DEBUG_FLAGS="-g -pg -D_DEBUG -Wall"
394   else
395     final_message="$final_message\n  Profiling:\tNo"
396     DEBUG_FLAGS="-g -D_DEBUG -Wall"
397   fi
398 else
399   final_message="$final_message\n  Debugging:\tNo"
400   if test "$use_profiling" = "yes"; then
401     final_message="$final_message\n  Profiling:\tYes"
402     DEBUG_FLAGS="-pg -DNDEBUG=1"
403   else
404     final_message="$final_message\n  Profiling:\tNo"
405     DEBUG_FLAGS="-DNDEBUG=1"
406   fi
407 fi
408
409 CFLAGS="$CFLAGS $DEBUG_FLAGS"
410 CXXFLAGS="$CXXFLAGS $DEBUG_FLAGS"
411
412 if test "$use_optimizations" = "yes"; then
413   final_message="$final_message\n  Optimization:\tYes"
414   CXXFLAGS="$CXXFLAGS -O2"
415   CFLAGS="$CFLAGS -O2"
416 else
417   final_message="$final_message\n  Optimization:\tNo"
418 fi
419
420
421 # platform specific flags
422 if test "$host_vendor" = "apple" ; then
423   AC_SUBST(MACOSX_DEPLOYMENT_TARGET, "10.4")
424   # need these in CFLAGS/CXXFLAGS so AC_CHECK_LIB works
425   CFLAGS="$CFLAGS -I/opt/local/include"
426   CXXFLAGS="$CXXFLAGS -I/opt/local/include"
427   # standard xbmc paths
428   INCLUDES="$INCLUDES -I\$(abs_top_srcdir)/xbmc/osx"
429   LDFLAGS="$LDFLAGS -mmacosx-version-min=10.4"
430   LDFLAGS="$LDFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
431   LDFLAGS="$LDFLAGS -L/opt/local/lib"
432   LDFLAGS="$LDFLAGS -L/opt/local/lib/mysql5/mysql"
433   LDFLAGS="$LDFLAGS -L/opt/local/lib/samba3"
434   LIBS="$LIBS -framework IOKit"
435   LIBS="$LIBS -framework Cocoa"
436   LIBS="$LIBS -framework OpenGL"
437   LIBS="$LIBS -framework AppKit"
438   LIBS="$LIBS -framework Carbon"
439   LIBS="$LIBS -framework CoreAudio"
440   LIBS="$LIBS -framework QuickTime"
441   LIBS="$LIBS -framework AudioUnit"
442   LIBS="$LIBS -framework Foundation"
443   LIBS="$LIBS -framework CoreServices"
444   LIBS="$LIBS -framework CoreVideo"
445   LIBS="$LIBS -framework CoreAudio"
446   LIBS="$LIBS -framework AudioToolbox"
447   LIBS="$LIBS -framework CoreFoundation"
448   LIBS="$LIBS -framework DiskArbitration"
449   LIBS="$LIBS -framework ApplicationServices"
450 elif expr "X$host_cpu" : 'Xarm.*' > /dev/null; then
451   use_arch=arm
452   CFLAGS="$CFLAGS -mfloat-abi=softfp -mno-apcs-stack-check"
453   CXXFLAGS="$CXXFLAGS -mfloat-abi=softfp -mno-apcs-stack-check"
454   FFMPEG_EXTRACFLAGS="-mfloat-abi=softfp"
455   if test "$use_tegra" = "yes"; then
456     # Compile for ARMv7a architecture, need to test gcc for vfpv3-d16 support 
457     SAVE_CFLAGS="$CFLAGS"
458     CFLAGS="-mfpu=vfpv3-d16"
459     AC_COMPILE_IFELSE(
460       [int foo;],
461       [ CFLAGS="$SAVE_CFLAGS -Wno-psabi -Wa,-march=armv7a -mtune=cortex-a9 -mfpu=vfpv3-d16 -mthumb-interwork"
462         CXXFLAGS="$CXXFLAGS -Wno-psabi -Wa,-march=armv7a -mtune=cortex-a9 -mfpu=vfpv3-d16 -mthumb-interwork"
463         FFMPEG_EXTRACFLAGS+=" -mtune=cortex-a9 -mfpu=vfpv3-d16"
464         use_cpu=cortex-a9],
465       [ CFLAGS="$SAVE_CFLAGS -Wa,-march=armv6 -mtune=cortex-a8 -mthumb-interwork"
466         CXXFLAGS="$CXXFLAGS -Wa,-march=armv6 -mtune=cortex-a8 -mthumb-interwork"    
467         use_cpu=cortex-a8])
468   else
469     # Compile for ARMv7a architecture, CortexA8 cpu and NEON coprocessor
470     CFLAGS+=" -Wa,-march=armv7a -mcpu=cortex-a8 -mfpu=neon -mvectorize-with-neon-quad"
471     CXXFLAGS+=" -Wa,-march=armv7a -mcpu=cortex-a8 -mfpu=neon -mvectorize-with-neon-quad"
472     FFMPEG_EXTRACFLAGS+=" -mfpu=neon"
473   fi
474 fi
475
476 # Checks for library functions.
477 AC_FUNC_ALLOCA
478 AC_FUNC_CHOWN
479 AC_FUNC_CLOSEDIR_VOID
480 AC_FUNC_ERROR_AT_LINE
481 AC_FUNC_FSEEKO
482 AC_PROG_GCC_TRADITIONAL
483 AC_FUNC_LSTAT
484 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
485 AC_FUNC_MEMCMP
486 AC_FUNC_MKTIME
487 AC_FUNC_MMAP
488 # Boxee is apparently having compile problems
489 # if HAVE_REALLOC is defined.  Sort this later.
490 #AC_FUNC_REALLOC
491 AC_FUNC_SELECT_ARGTYPES
492 AC_FUNC_SETVBUF_REVERSED
493 AC_TYPE_SIGNAL
494 AC_FUNC_STAT
495 AC_FUNC_STRCOLL
496 AC_FUNC_STRFTIME
497 AC_FUNC_STRTOD
498 AC_FUNC_UTIME_NULL
499 AC_FUNC_VPRINTF
500 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])
501
502 # Check for various sizes
503 AC_CHECK_SIZEOF([int])
504 AC_CHECK_SIZEOF([size_t])
505
506 # Add top source directory for all builds so we can use config.h
507 INCLUDES="$INCLUDES -I\$(abs_top_srcdir)"
508
509 # Checks for boost headers using CXX instead of CC
510 AC_LANG_PUSH([C++])
511 AC_CHECK_HEADER([boost/shared_ptr.hpp],, AC_MSG_ERROR($missing_library))
512 AC_LANG_POP([C++])
513
514 # Checks for platforms libraries.
515 if test "$use_gles" = "yes"; then
516   # GLES overwrites GL if both set to yes.
517   AC_CHECK_LIB([EGL],     [main],, AC_MSG_ERROR($missing_library))
518   AC_CHECK_LIB([GLESv2],  [main],, AC_MSG_ERROR($missing_library))
519 else
520   if test "$use_gl" = "yes"; then
521     if test "$host_vendor" = "apple" ; then
522       # linking to OpenGL.framework instead of libGL, libGLU
523       AC_CHECK_LIB([GLEW],[main],, AC_MSG_ERROR($missing_library))
524     else
525       AC_CHECK_LIB([GL],  [main],, AC_MSG_ERROR($missing_library))
526       AC_CHECK_LIB([GLEW],[main],, AC_MSG_ERROR($missing_library))
527       AC_CHECK_LIB([GLU], [main],, AC_MSG_ERROR($missing_library))
528     fi
529   else
530     AC_MSG_RESULT(== WARNING: OpenGL support is disabled. XBMC will run VERY slow. ==)
531     AC_CHECK_LIB([SDL_gfx],[main])
532   fi
533 fi
534
535 # platform common libraries
536 AC_CHECK_HEADER([mad.h],,            AC_MSG_ERROR($missing_library))
537 AC_CHECK_HEADER([jpeglib.h],,        AC_MSG_ERROR($missing_library))
538 AC_CHECK_HEADER([samplerate.h],,     AC_MSG_ERROR($missing_library))
539 AC_CHECK_HEADER([ogg/ogg.h],,        AC_MSG_ERROR($missing_library))
540 AC_CHECK_HEADER([vorbis/vorbisfile.h],, AC_MSG_ERROR($missing_library))
541 AC_CHECK_HEADER([vorbis/vorbisenc.h],, AC_MSG_ERROR($missing_library))
542 AC_CHECK_LIB([ass], [ass_set_message_cb],,use_external_libass="no")
543 AC_CHECK_LIB([bz2],         [main],, AC_MSG_ERROR($missing_library))
544 AC_CHECK_LIB([jpeg],        [main],, AC_MSG_ERROR($missing_library)) # check for cximage
545 AC_CHECK_LIB([pthread],     [main],, AC_MSG_ERROR($missing_library))
546 AC_CHECK_LIB([lzo2],        [main],, AC_MSG_ERROR($missing_library))
547 AC_CHECK_LIB([z],           [main],, AC_MSG_ERROR($missing_library))
548 AC_CHECK_LIB([ssl],         [main],, AC_MSG_ERROR($missing_library))
549 AC_CHECK_LIB([crypto],      [main],, AC_MSG_ERROR($missing_library))
550 AC_CHECK_LIB([wavpack],     [main],, AC_MSG_ERROR($missing_library))
551 AC_CHECK_LIB([mpeg2],       [main],, AC_MSG_ERROR($missing_library))
552 AC_CHECK_LIB([mpeg2convert],[main],, AC_MSG_ERROR($missing_library))
553 AC_CHECK_LIB([ssh],         [sftp_tell64],, AC_MSG_RESULT([Could not find suitable version of libssh]))
554 PKG_CHECK_MODULES([MAD],        [mad],
555   [INCLUDES="$INCLUDES $MAD_CFLAGS"; LIBS="$LIBS $MAD_LIBS"],
556   AC_MSG_ERROR($missing_library))
557 PKG_CHECK_MODULES([FONTCONFIG], [fontconfig],
558   [INCLUDES="$INCLUDES $FONTCONFIG_CFLAGS"],
559   AC_MSG_ERROR($missing_library))
560 PKG_CHECK_MODULES([FRIBIDI],    [fribidi],
561   [INCLUDES="$INCLUDES $FRIBIDI_CFLAGS"; LIBS="$LIBS $FRIBIDI_LIBS"],
562   AC_MSG_ERROR($missing_library))
563 PKG_CHECK_MODULES([SQLITE3],    [sqlite3],
564   [INCLUDES="$INCLUDES $SQLITE3_CFLAGS"; LIBS="$LIBS $SQLITE3_LIBS"],
565   AC_MSG_ERROR($missing_library))
566 PKG_CHECK_MODULES([PNG],        [libpng],
567   [INCLUDES="$INCLUDES $PNG_CFLAGS"; LIBS="$LIBS $PNG_LIBS"],
568   AC_MSG_ERROR($missing_library))
569 PKG_CHECK_MODULES([PCRE],       [libpcre],
570   [INCLUDES="$INCLUDES $PCRE_CFLAGS"; LIBS="$LIBS $PCRE_LIBS"]; \
571   AC_DEFINE([HAVE_LIBPCRE],[1],["Define to 1 if libpcre is installed"]),
572   AC_MSG_ERROR($missing_library))
573 PKG_CHECK_MODULES([PCRECPP],    [libpcrecpp],
574   [INCLUDES="$INCLUDES $PCRECPP_CFLAGS"; LIBS="$LIBS $PCRECPP_LIBS"]; \
575   AC_DEFINE([HAVE_LIBPCRECPP],[1],["Define to 1 if libpcrecpp is installed"]),
576   AC_MSG_ERROR($missing_library))
577 PKG_CHECK_MODULES([CDIO],       [libcdio],
578   [INCLUDES="$INCLUDES $CDIO_CFLAGS"; LIBS="$LIBS $CDIO_LIBS"],
579   AC_MSG_ERROR($missing_library))
580 PKG_CHECK_MODULES([SAMPLERATE], [samplerate],
581   [INCLUDES="$INCLUDES $SAMPLERATE_CFLAGS"; LIBS="$LIBS $SAMPLERATE_LIBS"],
582   AC_MSG_ERROR($missing_library))
583 PKG_CHECK_MODULES([MMS],        [libmms],
584   [INCLUDES="$INCLUDES $MMS_CFLAGS"; LIBS="$LIBS $MMS_LIBS"],
585   AC_MSG_ERROR($missing_library))
586 PKG_CHECK_MODULES([FREETYPE2],  [freetype2],
587   [INCLUDES="$INCLUDES $FREETYPE2_CFLAGS"; LIBS="$LIBS $FREETYPE2_LIBS"],
588   AC_MSG_ERROR($missing_library))
589 PKG_CHECK_MODULES([OGG],        [ogg],
590   [INCLUDES="$INCLUDES $OGG_CFLAGS"; LIBS="$LIBS $OGG_LIBS"],
591   AC_MSG_ERROR($missing_library))
592 PKG_CHECK_MODULES([VORBIS],     [vorbis],
593   [INCLUDES="$INCLUDES $VORBIS_CFLAGS"; LIBS="$LIBS $VORBIS_LIBS"],
594   AC_MSG_ERROR($missing_library))
595 PKG_CHECK_MODULES([VORBISENC],     [vorbisenc],
596   [INCLUDES="$INCLUDES $VORBISENC_CFLAGS"; LIBS="$LIBS $VORBISENC_LIBS"],
597   AC_MSG_ERROR($missing_library))
598
599 # check for libbluray
600 AS_CASE([x$use_libbluray],
601   [xyes],[
602     PKG_CHECK_MODULES([LIBBLURAY],[libbluray],[use_libbluray="yes"], AC_MSG_ERROR($missing_library))
603   ],
604   [xauto],[
605     PKG_CHECK_MODULES([LIBBLURAY],[libbluray],[use_libbluray="yes"], [use_libbluray="no"])
606   ])
607
608 AS_CASE([x$use_libbluray],
609   [xyes],[
610     INCLUDES="$INCLUDES $LIBBLURAY_CFLAGS";
611     if test "$host_vendor" != "apple"; then
612       XB_FIND_SONAME([BLURAY], [bluray], [use_libbluray])
613     fi;
614     AC_DEFINE([HAVE_LIBBLURAY], 1, [System has libbluray library])
615     AC_SUBST([HAVE_LIBBLURAY], 1)
616   ],[
617 #    AC_DEFINE([HAVE_LIBBLURAY], 0, [System has libbluray library])
618     AC_SUBST([HAVE_LIBBLURAY], 0)
619   ]
620 )
621
622 # platform dependent libraries
623 if test "$host_vendor" = "apple" ; then
624   AC_CHECK_LIB([iconv],     [main],, AC_MSG_ERROR($missing_library))
625   AC_CHECK_LIB([mysqlclient], [main],, AC_MSG_ERROR($missing_library))
626   AC_CHECK_LIB([smbclient], [main],, AC_MSG_ERROR($missing_library))
627   PKG_CHECK_MODULES([VORBISFILE],     [vorbisfile],
628     [INCLUDES="$INCLUDES $VORBISFILE_CFLAGS"; LIBS="$LIBS $VORBISFILE_LIBS"],
629     AC_MSG_ERROR($missing_library))
630 else
631   AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, "yes", "no")
632   if test $MYSQL_CONFIG = "yes"; then
633     INCLUDES="$INCLUDES `mysql_config --include`"
634     LIBS="$LIBS `mysql_config --libs`"
635   else
636     AC_MSG_ERROR($missing_program)
637   fi
638   # don't combine with mysqlclient check in apple section above, Linux needs
639   # paths from mysql_config
640   AC_CHECK_LIB([modplug],    [main],, AC_MSG_ERROR($missing_library))
641   AC_CHECK_LIB([mysqlclient],[main],, AC_MSG_ERROR($missing_library))
642   AC_CHECK_LIB([faad],       [main],, AC_MSG_ERROR($missing_library))
643   AC_CHECK_HEADER([FLAC/stream_decoder.h],, AC_MSG_ERROR($missing_library))
644   AC_CHECK_LIB([smbclient],  [main],, AC_MSG_ERROR($missing_library))
645   AC_CHECK_LIB([SDL_mixer],  [main],, AC_MSG_ERROR($missing_library))
646   AC_CHECK_LIB([dl],         [main],, AC_MSG_ERROR($missing_library))
647   AC_CHECK_LIB([resolv],     [main],, AC_MSG_ERROR($missing_library))
648   AC_CHECK_LIB([jasper],     [main],, AC_MSG_ERROR($missing_library)) # check for cximage
649   AC_CHECK_LIB([tiff],       [main],, AC_MSG_ERROR($missing_library))
650   AC_CHECK_LIB([rt],         [clock_gettime],, AC_MSG_ERROR($missing_library))
651   AC_CHECK_LIB([SDL_image],  [main],, AC_MSG_ERROR($missing_library))
652
653   PKG_CHECK_MODULES([ALSA],  [alsa],
654     [INCLUDES="$INCLUDES $ALSA_CFLAGS"; LIBS="$LIBS $ALSA_LIBS"],
655     AC_MSG_ERROR($missing_library))
656   PKG_CHECK_MODULES([ENCA],  [enca],
657     [INCLUDES="$INCLUDES $ENCA_CFLAGS"; LIBS="$LIBS $ENCA_LIBS"],
658     AC_MSG_ERROR($missing_library))
659   PKG_CHECK_MODULES([XT],    [xt],
660     [INCLUDES="$INCLUDES $XT_CFLAGS"; LIBS="$LIBS $XT_LIBS"],
661     AC_MSG_ERROR($missing_library))
662   PKG_CHECK_MODULES([XTST],  [xtst],
663     [INCLUDES="$INCLUDES $XTST_CFLAGS"; LIBS="$LIBS $XTST_LIBS"],
664     AC_MSG_ERROR($missing_library))
665   PKG_CHECK_MODULES([XEXT],  [xext],
666     [INCLUDES="$INCLUDES $XEXT_CFLAGS"; LIBS="$LIBS $XEXT_LIBS"],
667     AC_MSG_ERROR($missing_library))
668   PKG_CHECK_MODULES([XMU],   [xmu],
669     [INCLUDES="$INCLUDES $XMU_CFLAGS"; LIBS="$LIBS $XMU_LIBS"],
670     AC_MSG_ERROR($missing_library))
671   PKG_CHECK_MODULES([CURL],  [libcurl],
672     [INCLUDES="$INCLUDES $CURL_CFLAGS"],
673     AC_MSG_ERROR($missing_library))
674   PKG_CHECK_MODULES([DBUS],  [dbus-1],
675     [INCLUDES="$INCLUDES $DBUS_CFLAGS"; LIBS="$LIBS $DBUS_LIBS"],
676     AC_MSG_ERROR($missing_library))
677   PKG_CHECK_MODULES([SDL],   [sdl],
678     [INCLUDES="$INCLUDES $SDL_CFLAGS"; LIBS="$LIBS $SDL_LIBS"],
679     AC_MSG_ERROR($missing_library))
680 fi
681
682 # This is used to skip some submodule configuration on non-Apple hardware
683 HOST_NOT_APPLE=1
684 if [[ "$host_vendor" = "apple" ]]; then
685   HOST_NOT_APPLE=0
686 fi
687
688 if test "$host_vendor" != "apple"; then
689   XB_FIND_SONAME([CURL],        [curl])
690   XB_FIND_SONAME([FLAC],        [FLAC])
691   XB_FIND_SONAME([MODPLUG],     [modplug])
692   XB_FIND_SONAME([FAAD],        [faad])
693   XB_FIND_SONAME([MAD],         [mad])
694 fi
695 XB_FIND_SONAME([OGG],         [ogg])
696 XB_FIND_SONAME([VORBIS],      [vorbis])
697 XB_FIND_SONAME([VORBISENC],   [vorbisenc])
698 XB_FIND_SONAME([VORBISFILE],  [vorbisfile])
699
700 # WebServer
701 if test "$host_vendor" != "apple" ; then
702   if test "$use_webserver" = "yes"; then
703     AC_CHECK_LIB([microhttpd],  [main],, AC_MSG_ERROR($missing_library))
704   fi
705 else
706   if test "$use_webserver" = "yes"; then
707     AC_DEFINE([HAVE_LIBMICROHTTPD], [1],)
708   fi
709 fi
710
711 # Optical
712 if test "$use_optical_drive" = "yes"; then
713   AC_DEFINE([HAS_DVD_DRIVE], [1], [Define to 1 to have optical drive support])
714 fi
715
716 # PulseAudio
717 if test "x$use_pulse" != "xno"; then
718   if test "$host_vendor" = "apple" ; then
719     if test "x$use_pulse" = "xyes"; then
720       AC_MSG_ERROR($pulse_disabled)
721     else
722       use_pulse="no"
723       AC_MSG_RESULT($pulse_disabled)
724     fi
725   else
726     AC_CHECK_LIB([pulse], [main],,
727       [if test "x$use_pulse" = "xyes"; then
728         AC_MSG_ERROR($pulse_not_found)
729       else
730         use_pulse=no
731         AC_MSG_RESULT($pulse_not_found)
732       fi])
733   fi
734 else
735   AC_MSG_RESULT($pulse_disabled)
736 fi
737
738 # HAL
739 if test "$host_vendor" = "apple" ; then
740   use_hal="no"
741   AC_MSG_RESULT($hal_disabled)
742 else
743   if test "$use_hal" = "yes"; then
744     PKG_CHECK_MODULES([HAL], [hal],
745       [INCLUDES="$INCLUDES $HAL_CFLAGS"; LIBS="$LIBS $HAL_LIBS"],
746       use_hal=no;AC_MSG_RESULT($hal_not_found))
747     PKG_CHECK_MODULES([HAL_STORAGE], [hal-storage],
748       [INCLUDES="$INCLUDES $HAL_STORAGE_CFLAGS"; LIBS="$LIBS $HAL_STORAGE_LIBS"],
749       use_hal=no;AC_MSG_RESULT($halstorage_not_found))
750   else
751     AC_MSG_RESULT($hal_disabled)
752   fi
753   if test "$use_hal" = "yes"; then
754     AC_DEFINE([HAS_HAL], [1], [Define to 1 if you have HAL installed])
755   fi
756 fi
757
758 # avahi
759 if test "$host_vendor" = "apple" ; then
760   use_avahi="no"
761   AC_MSG_RESULT($avahi_disabled)
762 else
763   if test "$use_avahi" = "yes"; then
764     AC_CHECK_LIB([avahi-common], [main],,
765       use_avahi=no;AC_MSG_RESULT($avahi_not_found))
766         if test "$use_avahi" = "yes"; then
767                 #either both libs or none
768     AC_CHECK_LIB([avahi-client], [main],,
769       use_avahi=no;AC_MSG_RESULT($avahi_not_found))
770         fi
771     else
772      AC_MSG_RESULT($avahi_disabled)
773    fi
774 fi
775
776 # XRandR
777 if test "$host_vendor" = "apple" ; then
778   use_xrandr="no"
779   AC_MSG_RESULT($xrandr_disabled)
780 else
781   if test "$use_xrandr" = "yes" ; then
782     AC_CHECK_LIB([Xrandr], [main],, 
783       use_xrandr="no";AC_MSG_RESULT($xrandr_not_found))
784   else
785     AC_MSG_RESULT($xrandr_disabled)
786   fi
787 fi
788
789 # GOOM
790 if test "$host_vendor" = "apple" ; then
791   AC_MSG_NOTICE($goom_disabled)
792   BUILD_GOOM=1
793 else
794   if test "$use_goom" = "yes"; then
795     AC_MSG_NOTICE($goom_enabled)
796     BUILD_GOOM=0
797   else
798     AC_MSG_NOTICE($goom_disabled)
799     BUILD_GOOM=1
800   fi
801 fi
802
803 # libRTMP
804 if test "$use_librtmp" != "no"; then
805   AC_CHECK_HEADERS([librtmp/log.h librtmp/amf.h librtmp/rtmp.h],,
806    [if test "$use_librtmp" = "yes"; then
807       AC_MSG_ERROR($librtmp_not_found)
808     elif test "$use_librtmp" != "no"; then
809       AC_MSG_NOTICE($librtmp_not_found)
810       use_librtmp="no"
811     fi
812    ])
813   if test "$use_librtmp" != "no" && test "$host_vendor" != "apple"; then
814     XB_FIND_SONAME([RTMP], [rtmp], [use_librtmp])
815   fi
816   if test "$use_librtmp" != "no"; then
817     AC_DEFINE([HAS_LIBRTMP], [1], [Whether to use libRTMP library.])
818   fi
819 else
820   AC_MSG_NOTICE($librtmp_disabled)
821 fi
822
823 ### External libraries checks
824 # External FFmpeg
825 if test "$use_external_ffmpeg" = "yes"; then
826   PKG_CHECK_MODULES([FFMPEG], [libavcodec libavformat libavutil libpostproc libswscale],
827                     [INCLUDES="$INCLUDES $FFMPEG_CFLAGS"; LIBS="$LIBS $FFMPEG_LIBS"],
828                     AC_MSG_ERROR($missing_library))
829
830   # Determine whether AVPacket and relevant functions are defined in libavformat
831   # or libavcodec
832   AC_CHECK_LIB([avcodec], [av_free_packet],
833   [AC_MSG_NOTICE(== AVPacket and relevant functions defined in libavcodec. ==)],
834   [AC_MSG_NOTICE(== AVPacket and relevant functions defined in libavformat. ==)
835    AC_DEFINE([AVPACKET_IN_AVFORMAT], [1], [Whether AVPacket is in libavformat.])])
836
837   # in case the headers are in a custom directory
838   SAVE_CPPFLAGS="$CPPFLAGS"
839   CPPFLAGS="$CPPFLAGS $FFMPEG_CFLAGS"
840
841   # Possible places the ffmpeg headers may be
842   AC_CHECK_HEADERS([libavcodec/avcodec.h libavformat/avformat.h libavutil/avutil.h libpostproc/postprocess.h libswscale/swscale.h],,
843   [AC_CHECK_HEADERS([ffmpeg/avcodec.h ffmpeg/avformat.h ffmpeg/avutil.h postproc/postprocess.h ffmpeg/swscale.h],,
844   [AC_MSG_ERROR($missing_headers)])])
845
846   # We'll support the use of rgb2rgb.h if it exists.
847   AC_CHECK_HEADERS([libswscale/rgb2rgb.h],,)
848   AC_CHECK_HEADERS([ffmpeg/rgb2rgb.h],,)
849
850   AC_MSG_NOTICE($external_ffmpeg_enabled)
851   USE_EXTERNAL_FFMPEG=1
852   AC_DEFINE([USE_EXTERNAL_FFMPEG], [1], [Whether to use external FFmpeg libraries.])
853
854   # Disable vdpau support if external libavcodec doesn't have it
855   AC_CHECK_LIB([avcodec], [ff_vdpau_vc1_decode_picture],,
856     [if test "x$use_vdpau" = "xyes"; then
857       AC_MSG_ERROR($ffmpeg_vdpau_not_supported)
858     else
859       use_vdpau=no
860       AC_MSG_RESULT($ffmpeg_vdpau_not_supported)
861     fi])
862
863   # Check for 'PIX_FMT_VDPAU_MPEG4' from libavutil
864   if test "x$use_vdpau" != "xno"; then
865     AC_LANG_PUSH([C++])
866     AC_LINK_IFELSE(
867       [ #include <libavutil/pixfmt.h>
868         int main() { PixelFormat format = PIX_FMT_VDPAU_MPEG4; }],
869       [AC_DEFINE([PIX_FMT_VDPAU_MPEG4_IN_AVUTIL], [1],
870       [Whether AVUtil defines PIX_FMT_VDPAU_MPEG4.])],)
871     AC_LANG_POP([C++])
872   fi
873   CPPFLAGS="$SAVE_CPPFLAGS"
874 else
875   AC_MSG_NOTICE($external_ffmpeg_disabled)
876   USE_EXTERNAL_FFMPEG=0
877   AC_DEFINE([PIX_FMT_VDPAU_MPEG4_IN_AVUTIL], [1], [Whether AVUtil defines PIX_FMT_VDPAU_MPEG4.])
878 fi
879
880 # External liba52 if deprecated a52 support is enabled
881 if test "$use_liba52" = "yes" && "$use_external_liba52" = "yes"; then
882   AC_CHECK_LIB([a52],          [main],, AC_MSG_ERROR($missing_library))
883
884   AC_MSG_NOTICE($external_liba52_enabled)
885   USE_EXTERNAL_LIBA52=1
886   AC_DEFINE([USE_EXTERNAL_LIBA52], [1], [Whether to use external liba52 library.])
887   USE_INTERNAL_LIBA52=0
888   SKIP_CONFIG_LIBA52=1
889 else
890   AC_MSG_NOTICE($external_liba52_disabled)
891   USE_EXTERNAL_LIBA52=0
892 fi
893
894 # External libdts if deprecated dts support enabled
895 if test "$use_libdts" = "yes" && "$use_external_libdts" = "yes"; then
896   AC_CHECK_LIB([dts],          [main],, AC_MSG_ERROR($missing_library))
897
898   AC_MSG_NOTICE($external_libdts_enabled)
899   USE_EXTERNAL_LIBDTS=1
900   AC_DEFINE([USE_EXTERNAL_LIBDTS], [1], [Whether to use external libdts library.])
901   USE_INTERNAL_LIBDTS=0
902   SKIP_CONFIG_LIBDTS=1
903 else
904   AC_MSG_NOTICE($external_libdts_disabled)
905   USE_EXTERNAL_LIBDTS=0
906 fi
907
908 # External Python
909 if test "$use_external_python" = "yes"; then
910   AC_CHECK_LIB([python2.6], [main],
911     [AC_DEFINE([HAVE_LIBPYTHON2_6], [1],
912     [Define to 1 if you have the 'python2.6' library.])
913     USE_PYTHON2_6=1],
914   [AC_CHECK_LIB([python2.5], [main],
915     [AC_DEFINE([HAVE_LIBPYTHON2_5], [1],
916     [Define to 1 if you have the 'python2.5' library.])
917     USE_PYTHON2_5=1],
918   [AC_CHECK_LIB([python2.4], [main],
919     [AC_DEFINE([HAVE_LIBPYTHON2_4], [1],
920     [Define to 1 if you have the 'python2.4' library.])
921     USE_PYTHON2_4=1],
922   [AC_MSG_ERROR($missing_library)] )] )] )
923
924   AC_MSG_NOTICE($external_python_enabled)
925   test "$USE_PYTHON2_6" && AC_MSG_NOTICE([Using Python 2.6])
926   test "$USE_PYTHON2_5" && AC_MSG_NOTICE([Using Python 2.5])
927   test "$USE_PYTHON2_4" && AC_MSG_NOTICE([Using Python 2.4])
928   USE_EXTERNAL_PYTHON=1
929   AC_DEFINE([USE_EXTERNAL_PYTHON], [1], [Whether to use external python library.])
930 else
931   AC_MSG_NOTICE($external_python_disabled)
932   USE_EXTERNAL_PYTHON=0
933 fi
934
935 # VDPAU
936 if test "x$use_vdpau" != "xno"; then
937   if test "$host_vendor" = "apple" ; then
938     if test "x$use_vdpau" = "xyes"; then
939       AC_MSG_ERROR([VDPAU not supported on this platform])
940     else
941       use_vdpau="no"
942       AC_MSG_NOTICE($vdpau_disabled)
943     fi
944   else
945     AC_CHECK_HEADER([vdpau/vdpau.h],AC_DEFINE([HAVE_LIBVDPAU], [],
946       [Define to 1 if you have the 'vdpau' library (-lvdpau).]),
947     [if test "x$use_vdpau" = "xyes"; then 
948       AC_MSG_ERROR([$vdpau_not_found])
949     else
950       use_vdpau="no"
951       AC_MSG_RESULT($vdpau_not_found)
952     fi])
953   fi
954 else
955   AC_MSG_NOTICE($vdpau_disabled)
956 fi
957
958 # VAAPI
959 if test "x$use_vaapi" != "xno"; then
960   if test "$host_vendor" = "apple" ; then
961     if test "x$use_vaapi" = "xyes"; then
962       AC_MSG_ERROR([VAAPI not supported on this platform])
963     else
964       use_vaapi="no"
965       AC_MSG_NOTICE($vaapi_disabled)
966     fi
967   else
968     initial_val=$use_vaapi
969     AC_CHECK_LIB([va], main, :, use_vaapi=no)
970     if test "x$use_vaapi" != "xno"; then
971       AC_CHECK_LIB([va-glx], main, LIBS="-lva -lva-glx $LIBS", use_vaapi=no, -lva)
972     fi
973
974     if test "x$use_vaapi" = "xno"; then
975       if test "x$initial_val" = "xyes"; then
976         AC_MSG_ERROR($vaapi_not_found)
977       else
978         AC_MSG_RESULT($vaapi_not_found)
979       fi
980     else
981       AC_DEFINE([HAVE_LIBVA], [1], [Define to 1 if you have the 'vaapi' libraries (-lva AND -lva-glx)])
982     fi
983   fi
984 else
985   AC_MSG_NOTICE($vaapi_disabled)
986 fi
987
988 # CrystalHD
989 if test "x$use_crystalhd" != "xno"; then
990   AC_CHECK_HEADER([libcrystalhd/libcrystalhd_if.h], [], 
991     [ if test "x$use_crystalhd" = "xyes"; then
992         AC_MSG_ERROR($crystalhd_not_found)
993       else
994         use_crystalhd=no
995         AC_MSG_RESULT($crystalhd_not_found)
996       fi],
997     [#define __LINUX_USER__])
998     if test "$host_vendor" != "apple"; then
999       XB_FIND_SONAME([CRYSTALHD], [crystalhd], [use_crystalhd])
1000     fi
1001     if test "x$use_crystalhd" != "xno"; then
1002       SAVE_CFLAGS="$CFLAGS"
1003       CFLAGS="-llibcrystalhd"
1004       # check for new crystalhd lib
1005       AC_COMPILE_IFELSE(
1006         [ #define __LINUX_USER__
1007           #include <libcrystalhd/bc_dts_types.h>
1008           #include <libcrystalhd/bc_dts_defs.h>
1009           PBC_INFO_CRYSTAL bCrystalInfo;],
1010         [ AC_DEFINE([HAVE_LIBCRYSTALHD], [2], [Define to 2 if you have the 'New Broadcom Crystal HD' library.]) ], 
1011         [ AC_DEFINE([HAVE_LIBCRYSTALHD], [1], [Define to 1 if you have the 'Old Broadcom Crystal HD' library.]) ])
1012       CFLAGS="$SAVE_CFLAGS"
1013     fi
1014 else
1015   AC_MSG_NOTICE($crystalhd_disabled)
1016 fi
1017
1018 # VDADecoder
1019 if test "x$use_vdadecoder" != "xno"; then
1020   if test "$host_vendor" = "apple" ; then
1021     HAVE_LIBVDADECODER=1
1022     AC_DEFINE([HAVE_LIBVDADECODER], [1], [Define to 1 if you have the 'VDADecoder' library.])
1023     AC_MSG_NOTICE($vdadecoder_enabled)
1024   else
1025     if test "x$use_vdadecoder" = "xyes"; then
1026       AC_MSG_ERROR([VDA Decoder not supported on this platform])
1027     else
1028       use_vdadecoder="no"
1029       AC_MSG_NOTICE($vdadecoder_disabled)
1030     fi
1031   fi
1032 else
1033   AC_MSG_NOTICE($vdadecoder_disabled)
1034 fi
1035
1036 # OpenMax
1037 if test "$host_vendor" = "apple" ; then
1038   use_openmax="no"
1039   AC_MSG_NOTICE($openmax_disabled)
1040 else
1041   if test "$use_openmax" = "yes"; then
1042     AC_CHECK_HEADER([OpenMAX/IL/OMX_Types.h],
1043       AC_DEFINE([HAVE_LIBOPENMAX], [1], [Define to 1 if you have the 'OpenMax' library.]),
1044       use_openmax=no;AC_MSG_RESULT($openmax_not_found))
1045     if test "$use_openmax" = "yes"; then
1046       INCLUDES="$INCLUDES -I/usr/include/OpenMAX/IL"
1047     fi
1048   else
1049     AC_MSG_NOTICE($openmax_disabled)
1050   fi
1051 fi
1052
1053 # platform specific bin utilities
1054 if test "$host_vendor" != "apple" ; then
1055   AC_CHECK_PROG(HAVE_GAWK,gawk,"yes","no",)
1056   if test "$HAVE_GAWK" = "no" ; then
1057     AC_MSG_ERROR($missing_program)
1058   fi
1059 fi
1060
1061 AC_CHECK_PROG(HAVE_CMAKE,cmake,"yes","no",)
1062 if test "$HAVE_CMAKE" = "no" ; then
1063   AC_MSG_ERROR($missing_program)
1064 fi
1065
1066 AC_CHECK_PROG(HAVE_GPERF,gperf,"yes","no",)
1067 if test "$HAVE_GPERF" = "no" ; then
1068   AC_MSG_ERROR($missing_program)
1069 fi
1070
1071 AC_CHECK_PROG(HAVE_UNZIP,unzip,"yes","no",)
1072 if test "$HAVE_UNZIP" = "no" ; then
1073   AC_MSG_ERROR($missing_program)
1074 fi
1075
1076 AC_CHECK_PROG(HAVE_ZIP,zip,"yes","no",)
1077 if test "$HAVE_ZIP" = "no" ; then
1078   AC_MSG_ERROR($missing_program)
1079 fi
1080
1081 if test "$ARCH" != "x86_64-linux"; then
1082   AC_CHECK_PROG(HAVE_NASM,nasm,"yes","no",)
1083   if test "$HAVE_NASM" = "no" ; then
1084     AC_MSG_ERROR($missing_program)
1085   fi
1086 fi
1087
1088 AC_CHECK_PROG(HAVE_SVNVERSION,svnversion,"yes","no",)
1089 AC_CHECK_PROG(HAVE_GIT,git,"yes","no",)
1090
1091 # Checks for header files.
1092 AC_HEADER_DIRENT
1093 AC_HEADER_STDC
1094 AC_HEADER_SYS_WAIT
1095 AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h inttypes.h limits.h locale.h \
1096   malloc.h memory.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h \
1097   strings.h sys/file.h sys/ioctl.h sys/mount.h sys/param.h sys/socket.h \
1098   sys/time.h sys/timeb.h sys/vfs.h termios.h unistd.h utime.h wchar.h wctype.h])
1099 AC_CHECK_HEADERS([cdio/iso9660.h],,AC_MSG_ERROR([$missing_headers]))
1100
1101 # Checks for typedefs, structures, and compiler characteristics.
1102 AC_HEADER_STAT
1103 AC_HEADER_STDBOOL
1104 AC_C_CONST
1105 AC_TYPE_UID_T
1106 AC_C_INLINE
1107 AC_TYPE_INT8_T
1108 AC_TYPE_INT16_T
1109 AC_TYPE_INT32_T
1110 AC_TYPE_INT64_T
1111 AC_TYPE_MODE_T
1112 AC_TYPE_OFF_T
1113 AC_TYPE_PID_T
1114 AC_C_RESTRICT
1115 AC_TYPE_SIZE_T
1116 AC_TYPE_SSIZE_T
1117 AC_CHECK_MEMBERS([struct stat.st_rdev])
1118 AC_HEADER_TIME
1119 AC_STRUCT_TM
1120 AC_TYPE_UINT8_T
1121 AC_TYPE_UINT16_T
1122 AC_TYPE_UINT32_T
1123 AC_TYPE_UINT64_T
1124 AC_C_BIGENDIAN
1125
1126 if test "$cross_compiling" = "yes"; then
1127   final_message="$final_message\n  Crosscomp.:\tYes"
1128 else
1129   final_message="$final_message\n  Crosscomp.:\tNo"
1130 fi
1131
1132 final_message="$final_message\n  target ARCH:\t$use_arch"
1133 final_message="$final_message\n  target CPU:\t$use_cpu"
1134
1135 if test "$use_gles" = "yes"; then
1136   final_message="$final_message\n  OpenGLES:\tYes"
1137 else
1138   if test "$use_gl" = "yes"; then
1139     final_message="$final_message\n  OpenGL:\tYes"
1140   else
1141     final_message="$final_message\n  OpenGL:\tNo (Very Slow)"
1142     SDL_DEFINES="-DHAS_SDL_2D"
1143   fi
1144 fi
1145
1146 if test "x$use_vdpau" != "xno"; then
1147   final_message="$final_message\n  VDPAU:\tYes"
1148 else
1149   final_message="$final_message\n  VDPAU:\tNo"
1150 fi
1151
1152 if test "x$use_vaapi" != "xno"; then
1153   final_message="$final_message\n  VAAPI:\tYes"
1154 else
1155   final_message="$final_message\n  VAAPI:\tNo"
1156 fi
1157
1158 if test "x$use_crystalhd" != "xno"; then
1159   final_message="$final_message\n  CrystalHD:\tYes"
1160 else
1161   final_message="$final_message\n  CrystalHD:\tNo"
1162 fi
1163
1164 if test "x$use_vdadecoder" != "xno"; then
1165   final_message="$final_message\n  VDADecoder:\tYes"
1166 else
1167   final_message="$final_message\n  VDADecoder:\tNo"
1168 fi
1169
1170 if test "$use_openmax" != "no"; then
1171   final_message="$final_message\n  OpenMax:\tYes"
1172 else
1173   final_message="$final_message\n  OpenMax:\tNo"
1174 fi
1175
1176 if test "$use_joystick" = "yes"; then
1177   final_message="$final_message\n  Joystick:\tYes"
1178   SDL_DEFINES="$SDL_DEFINES -DHAS_SDL_JOYSTICK"
1179 else
1180   final_message="$final_message\n  Joystick:\tNo"
1181 fi
1182
1183 if test "$use_xrandr" = "yes"; then
1184   final_message="$final_message\n  XRandR:\tYes"
1185 else
1186   final_message="$final_message\n  XRandR:\tNo"
1187 fi
1188
1189 if test "$use_goom" = "yes"; then
1190   final_message="$final_message\n  GOOM:\t\tYes"
1191 else
1192   final_message="$final_message\n  GOOM:\t\tNo"
1193 fi
1194
1195 if test "$use_libbluray" = "yes"; then
1196   final_message="$final_message\n  Bluray:\tYes"
1197 else
1198   final_message="$final_message\n  Bluray:\tNo"
1199 fi
1200
1201 if test "$use_mid" = "yes"; then
1202   final_message="$final_message\n  MID Support:\tYes"
1203   SDL_DEFINES="$SDL_DEFINES -DMID"
1204 else
1205   final_message="$final_message\n  MID Support:\tNo"
1206 fi
1207
1208 if test "x$use_ccache" != "xno"; then
1209   AC_PATH_PROG(CCACHE,ccache,none)
1210   if test "$ac_cv_path_CCACHE" = "none"; then
1211     if test "x$use_ccache" = "xyes"; then
1212       AC_MSG_ERROR([ccache not found.]);
1213     else
1214       AC_MSG_NOTICE([ccache not found. Falling back to default CC])
1215       final_message="$final_message\n  ccache:\tNo"
1216     fi
1217   else
1218     CC="$ac_cv_path_CCACHE $CC"
1219     CXX="$ac_cv_path_CCACHE $CXX"
1220     AC_MSG_NOTICE(enabling ccache)
1221     final_message="$final_message\n  ccache:\tYes"
1222   fi
1223 else
1224   final_message="$final_message\n  ccache:\tNo"
1225 fi
1226
1227 if test "x$use_pulse" != "xno"; then
1228   XBMC_STANDALONE_SH_PULSE=tools/Linux/xbmc-standalone.sh.pulse
1229   final_message="$final_message\n  PulseAudio:\tYes"
1230 else
1231   XBMC_STANDALONE_SH_PULSE=/dev/null
1232   final_message="$final_message\n  PulseAudio:\tNo"
1233 fi
1234
1235 if test "$use_hal" = "yes"; then
1236   final_message="$final_message\n  HAL Support:\tYes"
1237 else
1238   final_message="$final_message\n  HAL Support:\tNo"
1239 fi
1240
1241 # DVDCSS
1242 if test "$use_dvdcss" = "yes"; then
1243   AC_MSG_NOTICE($dvdcss_enabled)
1244   final_message="$final_message\n  DVDCSS:\tYes"
1245   BUILD_DVDCSS=1
1246   SKIP_CONFIG_DVDCSS=0
1247   DVDREAD_CFLAGS="-D_XBMC -DHAVE_DVDCSS_DVDCSS_H"
1248 else
1249   AC_MSG_NOTICE($dvdcss_disabled)
1250   final_message="$final_message\n  DVDCSS:\tNo"
1251   BUILD_DVDCSS=0
1252   SKIP_CONFIG_DVDCSS=1
1253   DVDREAD_CFLAGS="-D_XBMC -UHAVE_DVDCSS_DVDCSS_H"
1254 fi
1255 if test "$use_avahi" = "yes"; then
1256   final_message="$final_message\n  Avahi:\tYes"
1257 else
1258   final_message="$final_message\n  Avahi:\tNo"
1259 fi
1260
1261 if ! test -n "$SVN_REV" -a "$SVN_REV" != "" ; then
1262   if test "$HAVE_SVNVERSION" = "yes" ; then
1263     SVN_REV=$(svnversion -n -c 2>/dev/null | grep -iv ^exported | sed -e 's/.*\://')
1264   fi
1265   if test "$SVN_REV" = ""; then
1266     if test "$HAVE_GIT" = "yes"; then
1267       SVN_REV=$(./gitrev.sh)
1268     fi
1269   fi
1270   if test "$SVN_REV" = ""; then
1271     SVN_REV="Unknown"
1272   fi
1273 fi
1274 if test "$host_vendor" = "apple"; then
1275   echo "#define SVN_REV \"$SVN_REV\"" > svn_revision.h
1276 else
1277   SDL_DEFINES="$SDL_DEFINES -D'SVN_REV=\"$SVN_REV\"'"
1278 fi
1279
1280 if test "$use_nonfree" = "yes"; then
1281   final_message="$final_message\n  Non-free:\tYes"
1282   HAVE_XBMC_NONFREE=1
1283   AC_DEFINE([HAVE_XBMC_NONFREE], [1], [Define to 1 to enable non-free components.])
1284 else
1285   HAVE_XBMC_NONFREE=0
1286   final_message="$final_message\n  Non-free:\tNo"
1287 fi
1288
1289 if test "$use_asap" = "yes"; then
1290   AC_CHECK_PROG(HAVE_GDC,gdc,"yes","no")
1291   if test "$HAVE_GDC" = "no"; then
1292     AC_MSG_ERROR($missing_program);
1293   fi
1294   AC_CHECK_PROG(HAVE_FPC,fpc,"yes","no")
1295   if test "$HAVE_FPC" = "no"; then
1296     AC_MSG_ERROR($missing_program);
1297   fi
1298   USE_ASAP_CODEC=1
1299   AC_DEFINE([USE_ASAP_CODEC], [1], [Define to 1 to enable ASAP codec.])
1300   final_message="$final_message\n  ASAP Codec:\tYes"
1301 else
1302   USE_ASAP_CODEC=0
1303   final_message="$final_message\n  ASAP Codec:\tNo"
1304 fi
1305
1306 if test "$use_webserver" = "yes"; then
1307   final_message="$final_message\n  Webserver:\tYes"
1308 else
1309   final_message="$final_message\n  Webserver:\tNo"
1310 fi
1311
1312 if test "$use_librtmp" != "no"; then
1313   final_message="$final_message\n  libRTMP support:\tYes"
1314 else
1315   final_message="$final_message\n  libRTMP support:\tNo"
1316 fi
1317
1318 if test "$use_optical_drive" = "yes"; then
1319   final_message="$final_message\n  Optical drive:\tYes"
1320 else
1321   final_message="$final_message\n  Optical drive:\tNo"
1322 fi
1323
1324 if test "$use_libdts" = "yes"; then
1325   USE_LIBDTS_DECODER=1
1326   AC_DEFINE([USE_LIBDTS_DECODER], [1], [Define to 1 to enable deprecated libdts support])
1327   if ! test "$USE_EXTERNAL_LIBDTS" = "1"; then
1328     USE_INTERNAL_LIBDTS=1
1329     SKIP_CONFIG_LIBDTS=0
1330   fi
1331   final_message="$final_message\n  Deprecated libdts:\tYes"
1332 else
1333   USE_INTERNAL_LIBDTS=0
1334   SKIP_CONFIG_LIBDTS=1
1335   final_message="$final_message\n  Deprecated libdts:\tNo"
1336 fi
1337
1338 if test "$use_liba52" = "yes"; then
1339   USE_LIBA52_DECODER=1
1340   AC_DEFINE([USE_LIBA52_DECODER], [1], [Define to 1 to enable deprecated liba52 support])
1341   if ! test "$USE_EXTERNAL_LIBA52" = "1"; then
1342     USE_INTERNAL_LIBA52=1
1343     SKIP_CONFIG_LIBA52=0
1344   fi
1345   final_message="$final_message\n  Deprecated liba52:\tYes"
1346 else
1347   USE_INTERNAL_LIBA52=0
1348   SKIP_CONFIG_LIBA52=1
1349   final_message="$final_message\n  Deprecated liba52:\tNo"
1350 fi
1351
1352 ### External libraries messages
1353 if test "$use_external_ffmpeg" = "yes"; then
1354   final_message="$final_message\n  External FFmpeg:\tYes"
1355 else
1356   final_message="$final_message\n  External FFmpeg:\tNo"
1357 fi
1358 if test "$use_liba52" = "yes"; then
1359   if test "$use_external_liba52" = "yes"; then
1360     final_message="$final_message\n  External liba52:\tYes"
1361   else
1362     final_message="$final_message\n  External liba52:\tNo"
1363   fi
1364 fi
1365 if test "$use_libdts" = "yes"; then
1366   if test "$use_external_libdts" = "yes"; then
1367     final_message="$final_message\n  External libdts:\tYes"
1368   else
1369     final_message="$final_message\n  External libdts:\tNo"
1370   fi
1371 fi
1372 if test "$use_external_python" = "yes"; then
1373   final_message="$final_message\n  External Python:\tYes"
1374 else
1375   final_message="$final_message\n  External Python:\tNo"
1376 fi
1377
1378 OUTPUT_FILES="Makefile \
1379     Makefile.include \
1380     xbmc/Makefile \
1381     xbmc/cdrip/Makefile \
1382     xbmc/cores/Makefile \
1383     xbmc/cores/VideoRenderers/Makefile \
1384     xbmc/cores/dvdplayer/Makefile \
1385     xbmc/cores/dvdplayer/Codecs/Makefile \
1386     xbmc/cores/dvdplayer/Codecs/libdvd/Makefile \
1387     xbmc/cores/dvdplayer/DVDCodecs/Makefile \
1388     xbmc/cores/dvdplayer/DVDCodecs/Audio/Makefile \
1389     xbmc/cores/dvdplayer/DVDCodecs/Overlay/Makefile \
1390     xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile \
1391     xbmc/cores/dvdplayer/DVDDemuxers/Makefile \
1392     xbmc/cores/dvdplayer/DVDSubtitles/Makefile \
1393     xbmc/cores/AudioRenderers/Makefile \
1394     xbmc/cores/paplayer/Makefile \
1395     xbmc/cores/paplayer/timidity/Makefile \
1396     xbmc/cores/paplayer/AC3Codec/Makefile \
1397     xbmc/cores/paplayer/ADPCMCodec/Makefile \
1398     xbmc/cores/paplayer/asap/Makefile \
1399     xbmc/cores/paplayer/NSFCodec/Makefile \
1400     xbmc/cores/paplayer/SIDCodec/Makefile \
1401     xbmc/cores/paplayer/vgmstream/Makefile \
1402     xbmc/cores/paplayer/SPCCodec/SNES/SNESAPU/Makefile \
1403     xbmc/cores/paplayer/YMCodec/StSoundLibrary/Makefile \
1404     xbmc/cores/playercorefactory/Makefile \
1405     xbmc/karaoke/Makefile \
1406     xbmc/osx/Makefile \
1407     guilib/Makefile \
1408     guilib/common/Makefile \
1409     xbmc/lib/libXBMS/Makefile \
1410     xbmc/lib/libRTV/Makefile \
1411     xbmc/lib/libexif/Makefile \
1412     xbmc/lib/libXDAAP/Makefile \
1413     xbmc/lib/libhdhomerun/Makefile \
1414     xbmc/lib/libhttpapi/Makefile \
1415     lib/jsoncpp/jsoncpp/src/lib_json/Makefile \
1416     xbmc/lib/libjsonrpc/Makefile \
1417     xbmc/lib/libsquish/Makefile \
1418     xbmc/lib/libid3tag/Makefile \
1419     xbmc/lib/cximage-6.0/Makefile \
1420     xbmc/lib/libPython/linux/Makefile \
1421     xbmc/lib/libUPnP/Makefile \
1422     xbmc/DllPaths_generated.h \
1423     xbmc/linux/Makefile \
1424     xbmc/FileSystem/Makefile \
1425     xbmc/screensavers/rsxs-0.9/xbmc/Makefile \
1426     xbmc/visualizations/XBMCProjectM/Makefile \
1427     xbmc/visualizations/Goom/Makefile \
1428     xbmc/visualizations/OpenGLSpectrum/Makefile \
1429     xbmc/visualizations/WaveForm/Makefile \
1430     xbmc/visualizations/iTunes/Makefile \
1431     xbmc/FileSystem/Makefile \
1432     tools/Linux/xbmc.sh \
1433     tools/Linux/xbmc-standalone.sh \
1434     tools/TexturePacker/Makefile \
1435     tools/EventClients/Clients/OSXRemote/Makefile"
1436
1437 if test "$host_vendor" = "apple"; then
1438   OUTPUT_FILES="$OUTPUT_FILES \
1439     xbmc/cores/paplayer/FLACCodec/Makefile"
1440 fi
1441
1442 if test "$use_external_libass" = "no"; then
1443   OUTPUT_FILES="$OUTPUT_FILES \
1444     lib/libass/xbmc/Makefile"
1445   USE_EXTERNAL_LIBASS=0
1446   AC_MSG_NOTICE($libass_using_internal)
1447 else
1448   AC_DEFINE([USE_EXTERNAL_LIBASS], [1], [Whether to use external libass library.])
1449   USE_EXTERNAL_LIBASS=1
1450 fi
1451
1452 # Line below is used so we can use AM_INIT_AUTOMAKE. The corresponding
1453 # .dummy.am does nothing.
1454 AC_CONFIG_FILES([.dummy])
1455
1456 AC_CONFIG_FILES([${OUTPUT_FILES}])
1457 OUTPUT_FILES="$OUTPUT_FILES \
1458   .dummy"
1459 AC_SUBST(CFLAGS)
1460 AC_SUBST(CXXFLAGS)
1461 AC_SUBST(INCLUDES)
1462 AC_SUBST(LDFLAGS)
1463 AC_SUBST(SDL_DEFINES)
1464 AC_SUBST(BUILD_DVDCSS)
1465 AC_SUBST(BUILD_GOOM)
1466 AC_SUBST(USE_EXTERNAL_FFMPEG)
1467 AC_SUBST(USE_EXTERNAL_LIBA52)
1468 AC_SUBST(USE_INTERNAL_LIBA52)
1469 AC_SUBST(USE_EXTERNAL_LIBASS)
1470 AC_SUBST(USE_EXTERNAL_LIBDTS)
1471 AC_SUBST(USE_INTERNAL_LIBDTS)
1472 AC_SUBST(USE_EXTERNAL_LIBMPEG2)
1473 AC_SUBST(USE_EXTERNAL_LIBWAVPACK)
1474 AC_SUBST(USE_EXTERNAL_PYTHON)
1475 AC_SUBST(USE_PYTHON2_6)
1476 AC_SUBST(USE_PYTHON2_5)
1477 AC_SUBST(USE_PYTHON2_4)
1478 AC_SUBST(OUTPUT_FILES)
1479 AC_SUBST(HAVE_XBMC_NONFREE)
1480 AC_SUBST(USE_ASAP_CODEC)
1481 AC_SUBST(LIBCURL_BASENAME)
1482 AC_SUBST(LIBFLAC_BASENAME)
1483 AC_SUBST(LIBVORBISFILE_BASENAME)
1484 AC_SUBST(LIBMODPLUG_BASENAME)
1485 AC_SUBST(LIBFAAD_BASENAME)
1486 AC_SUBST(LIBMAD_BASENAME)
1487 AC_SUBST(LIBOGG_BASENAME)
1488 AC_SUBST(LIBVORBISENC_BASENAME)
1489 AC_SUBST(LIBVORBIS_BASENAME)
1490 AC_SUBST_FILE(XBMC_STANDALONE_SH_PULSE)
1491
1492 # pushd and popd are not available in other shells besides bash, so implement
1493 # our own pushd/popd functions
1494 XB_DIRSTACK="$PWD"
1495 xb_pushd()
1496 {
1497   local dirname="$1"
1498   if [[ -d "$dirname" ]] && [[ -x "$dirname" ]]; then
1499     cd "$dirname"
1500     XB_DIRSTACK="$dirname ${XB_DIRSTACK:-$PWD}"
1501     return 0
1502   else
1503     AC_MSG_ERROR(xb_pushd: unable to change to $dirname)
1504   fi
1505 }
1506 xb_popd()
1507 {
1508   if [[ -n "$XB_DIRSTACK" ]]; then
1509     XB_DIRSTACK="${XB_DIRSTACK#* }"
1510     cd "${XB_DIRSTACK%% *}"
1511     return 0
1512   else
1513     AC_MSG_ERROR(xb_popd: unable to go back to previous directory)
1514   fi
1515 }
1516
1517 # Function to run the configure scripts in our submodules
1518 # Consists of three paramaters, the path to the submodule, the configure command
1519 # with appropriate arguments, and a third parameter set to 1 if we are to skip
1520 # running the script, anything else if not.
1521 AC_DEFUN([XB_CONFIG_MODULE],[
1522 AC_CONFIG_COMMANDS_POST([
1523 if [[ $3 != "1" ]]; then
1524     if [[ -d $1 ]]; then
1525       xb_pushd $1
1526       $2
1527       if [[ $? -ne 0 ]]; then
1528         xb_popd
1529         AC_MSG_ERROR([[Submodule $1 failed to configure]])
1530       else
1531         xb_popd
1532       fi
1533     else
1534       AC_MSG_ERROR([[Submodule $1 does not exist]])
1535     fi
1536 else
1537     AC_MSG_NOTICE([[Skipping configuration of submodule $1.]])
1538 fi
1539 ])
1540 ])
1541
1542 XB_CONFIG_MODULE([xbmc/lib/libPython/Python], [
1543   if test "$host_vendor" = "apple" ; then
1544     ./configure \
1545       --enable-ipv6 \
1546       --enable-unicode=ucs4 \
1547       --without-cxx \
1548       --enable-shared \
1549       --without-pymalloc \
1550       --with-suffix=.exe \
1551       LDFLAGS="-L/opt/local/lib" \
1552       OPT="-Wno-deprecated-declarations -I/opt/local/include" \
1553       MACOSX_DEPLOYMENT_TARGET=10.4 CFLAGS="$CFLAGS" &&
1554     sed -i bak -e "s/define HAVE_GETC_UNLOCKED 1/undef HAVE_GETC_UNLOCKED/" pyconfig.h && 
1555     sed -i bak -e "s/define HAVE_FSEEKO 1/undef HAVE_FSEEKO/" pyconfig.h &&
1556     sed -i bak -e "s/define HAVE_FTELLO 1/undef HAVE_FTELLO/" pyconfig.h &&
1557     sed -i bak -e "s/define HAVE_FTRUNCATE 1/undef HAVE_FTRUNCATE/" pyconfig.h &&
1558     sed -i bak -e "s/define HAVE_FPATHCONF 1/undef HAVE_FPATHCONF/" pyconfig.h &&
1559     sed -i bak -e "s/define HAVE_FSYNC 1/undef HAVE_FSYNC/" pyconfig.h &&
1560     sed -i bak -e "s/define HAVE_FCHDIR 1/undef HAVE_FCHDIR/" pyconfig.h &&
1561     sed -i bak -e "s/define _POSIX_C_SOURCE 200112L/undef _POSIX_C_SOURCE/" pyconfig.h &&
1562     sed -i bak -e "s/define _XOPEN_SOURCE 600/undef _XOPEN_SOURCE/" pyconfig.h &&
1563     sed -i bak -e "s/define _XOPEN_SOURCE_EXTENDED 1/undef _XOPEN_SOURCE_EXTENDED/" pyconfig.h &&
1564     echo "#define   SETPGRP_HAVE_ARG 1" >> pyconfig.h &&
1565     cp pyconfig.h Include       
1566   else
1567     ./configure \
1568       --host=$host_alias \
1569       --build=$build_alias \
1570       --target=$target_alias \
1571       --disable-ipv6 \
1572       --enable-unicode=ucs4 \
1573       --without-cxx \
1574       --enable-shared \
1575       --without-pymalloc \
1576       --prefix=`pwd`/../linux/python-lib CFLAGS="$CFLAGS" \
1577       CC="$CC" \
1578       CXX="$CXX" &&
1579     sed -i -e "s/define HAVE_GETC_UNLOCKED 1/undef HAVE_GETC_UNLOCKED/" pyconfig.h &&
1580     sed -i -e "s/define _POSIX_C_SOURCE 200112L/undef _POSIX_C_SOURCE/" pyconfig.h &&
1581     sed -i -e "s/define _XOPEN_SOURCE 600/undef _XOPEN_SOURCE/" pyconfig.h &&
1582     cp pyconfig.h Include
1583   fi
1584 ], [$USE_EXTERNAL_PYTHON])
1585
1586 XB_CONFIG_MODULE([xbmc/cores/paplayer/FLACCodec/flac-1.2.1], [
1587   if test "$host_vendor" = "apple" ; then
1588     CFLAGS="$CFLAGS -fno-common" \ 
1589     ./configure MACOSX_DEPLOYMENT_TARGET=10.4 -C \
1590       --with-pic \
1591       --disable-asm-optimizations \
1592       --disable-xmms-plugin \
1593       --disable-cpplibs \
1594       CC="$CC" \
1595       CXX="$CXX"
1596   fi
1597 ], [$HOST_NOT_APPLE])
1598
1599 XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/ffmpeg], [
1600   if test "$host_vendor" = "apple" ; then
1601     ./configure \
1602       --extra-cflags="$CFLAGS -w -D_DARWIN_C_SOURCE -Dattribute_deprecated=" \
1603       --disable-amd3dnow \
1604       --disable-static \
1605       `if test "$use_debug" = "no"; then echo --disable-debug; fi` \
1606       --disable-muxers \
1607       --enable-muxer=spdif \
1608       --enable-muxer=adts \
1609       --disable-encoders \
1610       --enable-encoder=ac3 \
1611       --enable-encoder=aac \
1612       `if test "$use_ffmpeg_libvorbis" == "yes"; then echo --enable-libvorbis --enable-muxer=ogg --enable-encoder=libvorbis; else echo --disable-libvorbis; fi` \
1613       --disable-devices \
1614       --disable-ffplay \
1615       --disable-ffserver \
1616       --disable-ffmpeg \
1617       --enable-shared \
1618       --disable-decoder=mpeg_xvmc \
1619       --enable-postproc \
1620       --enable-gpl \
1621       --enable-protocol=http \
1622       --enable-pthreads \
1623       --enable-runtime-cpudetect \
1624       --cc="$CC" &&
1625     sed -i "" -e "s#define HAVE_POSIX_MEMALIGN 1#define HAVE_POSIX_MEMALIGN 0#" config.h &&
1626     sed -i "" -e "s#YASM=yasm#YASM=/opt/local/bin/yasm#" config.mak &&
1627     sed -i "" -e "s# -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 # #" config.mak &&
1628     sed -i "" -e "s#libswscale_VERSION_MAJOR=0#libswscale_VERSION_MAJOR=0.7.1#" config.mak &&
1629     sed -i "" -e "s#libavfilter_VERSION_MAJOR=0#libavfilter_VERSION_MAJOR=0.4.0#" config.mak
1630
1631   else
1632     CFLAGS="" \
1633     ./configure \
1634       --extra-cflags="$PASSED_CFLAGS $FFMPEG_EXTRACFLAGS" \
1635       --disable-static \
1636       `if test "$use_debug" = "no"; then echo --disable-debug; fi` \
1637       `if test "$cross_compiling" = "yes"; then echo --enable-cross-compile; fi` \
1638       `if test "$use_arch" != "no"; then echo --arch=$use_arch; fi`\
1639       `if test "$use_cpu" != "no"; then echo --cpu=$use_cpu; fi`\
1640       --target-os=$(tolower $(uname -s)) \
1641       --disable-muxers \
1642       --enable-muxer=spdif \
1643       --enable-muxer=adts \
1644       --disable-encoders \
1645       --enable-encoder=ac3 \
1646       --enable-encoder=aac \
1647       `if test "$use_ffmpeg_libvorbis" == "yes"; then echo --enable-libvorbis --enable-muxer=ogg --enable-encoder=libvorbis; else echo --disable-libvorbis; fi` \
1648       --disable-decoder=mpeg_xvmc \
1649       --disable-devices \
1650       --disable-ffplay \
1651       --disable-ffserver \
1652       --disable-ffmpeg \
1653       --enable-shared \
1654       --enable-postproc \
1655       --enable-gpl \
1656       `if test "x$use_vdpau" != "xno"; then echo --enable-vdpau; else echo --disable-vdpau; fi` \
1657       `if test "x$use_vaapi" != "xno"; then echo --enable-vaapi; else echo --disable-vaapi; fi` \
1658       --enable-libfaad \
1659       --enable-protocol=http \
1660       --enable-pthreads \
1661       --enable-runtime-cpudetect \
1662       `case $host_cpu in i?86*) echo --disable-pic ;; *) echo --enable-pic ;; esac` \
1663       --cc="$CC" &&
1664       sed -i -e "s#define HAVE_SYMVER 1#define HAVE_SYMVER 0#" config.h &&
1665       sed -i -e "s#define HAVE_SYMVER_GNU_ASM 1#define HAVE_SYMVER_GNU_ASM 0#" config.h
1666   fi
1667 ], [$USE_EXTERNAL_FFMPEG])
1668
1669 XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libdts], [
1670   if test "$host_vendor" = "apple" ; then
1671     CFLAGS="$CFLAGS -fno-common"
1672     LDFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
1673     ./configure \
1674       --disable-oss \
1675       --disable-solaris-audio \
1676       --disable-al-audio \
1677       --disable-win
1678   else
1679     ./configure \
1680       --host=$host_alias \
1681       --build=$build_alias \
1682       --target=$target_alias \      
1683       --disable-oss \
1684       --disable-solaris-audio \
1685       --disable-al-audio \
1686       --disable-win \
1687       CFLAGS="$CFLAGS"
1688   fi
1689 ], [$SKIP_CONFIG_LIBDTS])
1690
1691 XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libdvd/libdvdcss], [
1692   if test "$host_vendor" = "apple" ; then
1693     ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
1694     CFLAGS="$CFLAGS -fno-common" \
1695       --disable-doc \
1696       --enable-static \
1697       --with-pic
1698   else
1699     ./configure \
1700       CC="$CC" \
1701       CXX="$CXX" \
1702       CFLAGS="$CFLAGS" \
1703       --host=$host_alias \
1704       --build=$build_alias \
1705       --target=$target_alias \      
1706       --disable-doc \
1707       --enable-static \
1708       --with-pic
1709   fi
1710 ], [$SKIP_CONFIG_DVDCSS])
1711
1712 XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libdvd/libdvdread], [
1713   if test "$host_vendor" = "apple" ; then
1714     ./configure2 MACOSX_DEPLOYMENT_TARGET=10.4 \
1715       --extra-cflags="$CFLAGS -fno-common $DVDREAD_CFLAGS -D__DARWIN__ -I`pwd`/../libdvdcss/src" \
1716       --enable-static \
1717       --disable-shared \
1718       --cc="$CC" &&
1719     make dvdread-config &&
1720     mkdir -p `pwd`/../includes/dvdread
1721     cp `pwd`/../libdvdread/src/*.h `pwd`/../includes/dvdread
1722   else
1723     ./configure2 \
1724       --extra-cflags="$CFLAGS $DVDREAD_CFLAGS -I`pwd`/../libdvdcss/src" \
1725       --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
1726       --host=$host_alias \
1727       --build=$build_alias \
1728       --target=$target_alias \      
1729       --enable-static \
1730       --disable-shared \
1731       --disable-strip \
1732       --disable-opts \
1733       --cc="$CC" &&
1734     make dvdread-config &&
1735     mkdir -p `pwd`/../includes/dvdread
1736     cp `pwd`/../libdvdread/src/*.h `pwd`/../includes/dvdread
1737   fi
1738
1739 ], [0])
1740
1741 XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libdvd/libdvdnav], [
1742   if test "$host_vendor" = "apple" ; then
1743     ./configure2 MACOSX_DEPLOYMENT_TARGET=10.4 \
1744       --extra-cflags="$CFLAGS -fno-common $DVDREAD_CFLAGS -I`pwd`/../includes" \
1745       --extra-ldflags="-L`pwd`/../libdvdread/obj" \
1746       --with-dvdread-config="`pwd`/../libdvdread/obj/dvdread-config" \
1747       --enable-static \
1748       --disable-shared \
1749       --cc="$CC"
1750   else
1751     ./configure2 \
1752       --extra-cflags="$CFLAGS $DVDREAD_CFLAGS -I`pwd`/../includes" \
1753       --extra-ldflags="-L`pwd`/../libdvdread/obj" \
1754       --with-dvdread-config="`pwd`/../libdvdread/obj/dvdread-config" \
1755       --host=$host_alias \
1756       --build=$build_alias \
1757       --target=$target_alias \      
1758       --enable-static \
1759       --disable-shared \
1760       --cc="$CC"
1761   fi
1762 ], [0])
1763
1764 XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libfaad2], [
1765   if test "$host_vendor" = "apple" ; then
1766     CFLAGS="$CFLAGS -O3 -fno-common" \
1767     ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
1768       --with-pic
1769   fi
1770 ], [$HOST_NOT_APPLE])
1771
1772 XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/liba52], [
1773   if test "$host_vendor" = "apple" ; then
1774     CFLAGS="$CFLAGS -fno-common" \
1775     ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
1776       --with-pic \
1777       --disable-static \
1778       --enable-shared \
1779       --disable-oss \
1780       --disable-solaris-audio \
1781       --disable-win \
1782       --disable-al-audio
1783   else
1784     ./configure \
1785       --host=$host_alias \
1786       --build=$build_alias \
1787       --target=$target_alias \      
1788       --with-pic \
1789       --disable-static \
1790       --enable-shared \
1791       --disable-oss \
1792       --disable-solaris-audio \
1793       --disable-win \
1794       --disable-al-audio \
1795       CFLAGS="$CFLAGS"
1796   fi
1797 ], [$SKIP_CONFIG_LIBA52])
1798
1799 XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libmad], [
1800   if test "$host_vendor" = "apple" ; then
1801     CFLAGS="$CFLAGS -fno-common" \
1802     ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
1803       --with-pic
1804   fi
1805 ], [$HOST_NOT_APPLE])
1806
1807 XB_CONFIG_MODULE([xbmc/lib/cximage-6.0/zlib], [
1808   if test "$host_vendor" = "apple" ; then
1809     export MACOSX_DEPLOYMENT_TARGET=10.4
1810     CFLAGS="$CFLAGS -fno-common" \
1811     ./configure
1812   fi
1813 ], [$HOST_NOT_APPLE])
1814
1815 XB_CONFIG_MODULE([lib/libass], [
1816   if test "$host_vendor" = "apple" ; then
1817     CFLAGS="$CFLAGS -fno-common" \
1818     ./configure MACOSX_DEPLOYMENT_TARGET=10.4
1819   else
1820     CFLAGS="$CFLAGS" \
1821     ./configure \
1822       --host=$host_alias \
1823       --build=$build_alias \
1824       --target=$target_alias
1825   fi
1826 ], [$USE_EXTERNAL_LIBASS])
1827
1828 XB_CONFIG_MODULE([xbmc/lib/libid3tag/libid3tag],[
1829   if test "$host_vendor" = "apple" ; then
1830     CFLAGS="$CFLAGS -fno-common" \
1831     ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
1832       --disable-static \
1833       --disable-debugging \
1834       --with-pic
1835   else
1836     ./configure \
1837       CC="$CC" \
1838       CXX="$CXX" \
1839       CFLAGS="$CFLAGS" \ 
1840       CXXFLAGS="$CXXFLAGS" \
1841       --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
1842       --host=$host_alias \
1843       --build=$build_alias \
1844       --target=$target_alias \      
1845       --disable-static \
1846       --with-pic
1847   fi
1848 ], [0])
1849
1850 XB_CONFIG_MODULE([xbmc/visualizations/XBMCProjectM/libprojectM],[
1851   if test "$host_vendor" = "apple" ; then
1852     rm -f CMakeCache.txt && CC="" CXX=""  cmake -D CMAKE_C_FLAGS:STRING="${CFLAGS} -fno-common" -D CMAKE_CXX_FLAGS:STRING="${CXXFLAGS} -fno-common" -D CMAKE_BUILD_TYPE:STRING=RelWithDebInfo -D USE_FTGL:BOOL=OFF .
1853   else
1854 set -x
1855     rm -f CMakeCache.txt && CC="$CC" CXX="$CXX" cmake -DCMAKE_BUILD_TYPE=None -DUSE_FTGL:BOOL=OFF \
1856       -DCMAKE_C_FLAGS:STRING="${CFLAGS}" -DCMAKE_CXX_FLAGS:STRING="${CXXFLAGS}" \
1857       -DCMAKE_INSTALL_PREFIX="${prefix}" -DCMAKE_INSTALL_LIBDIR:PATH="${libdir}" \
1858       -DINCLUDE_INSTALL_DIR:PATH="${includedir}" -DLIB_INSTALL_DIR:PATH="${libdir}" \
1859       -DSYSCONF_INSTALL_DIR:PATH="${sysconfdir}" -DSHARE_INSTALL_PREFIX:PATH="${datadir}" .
1860 set +x
1861   fi
1862 ], [0])
1863
1864 XB_CONFIG_MODULE([xbmc/visualizations/Goom/goom2k4-0],[
1865   if test "$host_vendor" != "apple" ; then
1866     ./configure  \
1867         CFLAGS="$CFLAGS" \ 
1868         CXXFLAGS="$CXXFLAGS" \
1869       --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
1870       --host=$host_alias \
1871       --build=$build_alias \
1872       --target=$target_alias \      
1873       --disable-shared \
1874       --enable-static \
1875       --with-pic
1876   fi
1877 ], [$BUILD_GOOM])
1878
1879 XB_CONFIG_MODULE([xbmc/screensavers/rsxs-0.9/], [
1880 if expr "X$host_cpu" : 'Xarm.*' > /dev/null; then :; else
1881   if test "$host_vendor" = "apple" ; then
1882     ./configure \
1883       CFLAGS="$CFLAGS" \
1884       CXXFLAGS="$CXXFLAGS" \
1885       LDFLAGS="-L/opt/local/lib" \
1886       LIBS="-lz" \
1887       --x-includes=/usr/X11/include --x-libraries=/usr/X11/lib \
1888       --without-xscreensaver \
1889       --disable-sound \
1890       --disable-cyclone \
1891       --disable-fieldlines \
1892       --disable-flocks \
1893       --disable-flux \
1894       --disable-helios \
1895       --disable-hyperspace \
1896       --disable-lattice \
1897       --disable-skyrocket
1898   else
1899     ./configure \
1900       CC="$CC" \
1901       CXX="$CXX" \
1902       CFLAGS="$CFLAGS" \ 
1903       CXXFLAGS="$CXXFLAGS" \
1904       --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
1905       --host=$host_alias \
1906       --build=$build_alias \
1907       --target=$target_alias \      
1908       --without-xscreensaver \
1909       --disable-sound \
1910       --disable-cyclone \
1911       --disable-fieldlines \
1912       --disable-flocks \
1913       --disable-flux \
1914       --disable-helios \
1915       --disable-hyperspace \
1916       --disable-lattice \
1917       --disable-skyrocket
1918   fi
1919 fi
1920 ], [0])
1921
1922 XB_CONFIG_MODULE([xbmc/lib/libapetag], [
1923   if test "$host_vendor" = "apple" ; then
1924     CFLAGS="$CFLAGS -fno-common" \
1925     ./configure MACOSX_DEPLOYMENT_TARGET=10.4 --disable-shared
1926   else
1927     ./configure \
1928       --host=$host_alias \
1929       --build=$build_alias \
1930       --target=$target_alias CFLAGS="$CFLAGS" CC="$CC" CXX="$CXX"
1931   fi
1932 ], [0])
1933
1934 XB_CONFIG_MODULE([lib/libmodplug], [
1935   if test "$host_vendor" = "apple" ; then
1936     CFLAGS="$CFLAGS -fno-common" \
1937     CXXFLAGS="$CXXFLAGS -fno-common" \
1938     ./configure MACOSX_DEPLOYMENT_TARGET=10.4 --with-pic --disable-shared --enable-static
1939   fi
1940 ], [$HOST_NOT_APPLE])
1941
1942 XB_CONFIG_MODULE([lib/libmicrohttpd], [
1943   if test "$host_vendor" = "apple" ; then
1944     CFLAGS="$CFLAGS -fno-common" \
1945     CXXFLAGS="$CXXFLAGS -fno-common" \
1946     ./configure MACOSX_DEPLOYMENT_TARGET=10.4 --with-pic --disable-shared --enable-static --with-libgcrypt-prefix=/dev/null
1947   fi
1948 ], [$HOST_NOT_APPLE])
1949
1950 XB_CONFIG_MODULE([lib/cpluff], [
1951   if test "$host_vendor" = "apple" ; then
1952     ./configure --disable-nls --with-libiconv-prefix=/opt/local --with-libintl-prefix=/opt/local --without-readline CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
1953   else
1954     ./configure --disable-nls \
1955       --host=$host_alias \
1956       --build=$build_alias \
1957       --target=$target_alias CFLAGS="$CFLAGS" CC="$CC" CXX="$CXX"
1958   fi
1959 ], [0])
1960
1961 AC_OUTPUT
1962
1963 final_message="$final_message\n  prefix:\t$prefix\n$dashes"
1964 echo -e "$final_message\n"