[51af53]: configure.in Maximize Restore History

Repo status: analyzing...

Download this file

configure.in    1502 lines (1380 with data), 54.0 kB

#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT("xbmc", 9.11, http://trac.xbmc.org)
AC_CONFIG_HEADERS([config.h])
AH_TOP([#pragma once])

AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign])
AC_CANONICAL_HOST

# General message strings
configure_debug="ERROR: this is a configure debug statement"
missing_library="Could not find a required library. Please see the README for your platform."
missing_headers="Could not find some required headers. Please see the README for your platform."
missing_program="Could not find a required program. Please see the README for your platform."
xrandr_not_found="== Could not find libXRandR. SDL will be used for resolution support. =="
xrandr_disabled="== XRandR support disabled. SDL will be used for resolution support. =="
goom_enabled="== GOOM enabled. =="
goom_disabled="== GOOM disabled. =="
pulse_not_found="== Could not find libpulse. PulseAudio support disabled. =="
pulse_disabled="== PulseAudio support manually disabled. =="
faac_not_found="== Could not find libfaac. FAAC support disabled. =="
faac_disabled="== FAAC support manually disabled. =="
dvdcss_enabled="== DVDCSS support enabled. =="
dvdcss_disabled="== DVDCSS support disabled. =="
avahi_not_found="== Could not find libavahi-common or libavahi-client. Avahi support disabled. =="
avahi_disabled="== Avahi support disabled. =="
vdpau_not_found="== Could not find libvdpau. VDPAU support disabled. =="
vdpau_disabled="== VDPAU support manually disabled. =="
crystalhd_not_found="== Could not find libldil. CrystalHD support disabled. =="
crystalhd_disabled="== CrystalHD support manually disabled. =="
ssh_not_found="== Could not find libssh. SSH FTP VFS support disabled. =="

# External library message strings
external_libraries_enabled="== Use of all supported external libraries enabled. =="
external_libraries_disabled="== Use of all supported external libraries disabled. =="
external_ffmpeg_enabled="== Use of external ffmpeg enabled. =="
external_ffmpeg_disabled="== Use of external ffmpeg disabled. =="
external_liba52_enabled="== Use of external liba52 enabled. =="
external_liba52_disabled="== Use of external liba52 disabled. =="
external_libdts_enabled="== Use of external libdts enabled. =="
external_libdts_disabled="== Use of external libdts disabled. =="
external_libass_enabled="== Use of external libass enabled. =="
external_libass_disabled="== Use of external libass disabled. =="
external_python_enabled="== Use of external python enabled. =="
external_python_disabled="== Use of external python disabled. =="
ffmpeg_vdpau_not_supported="== External ffmpeg doesn't support VDPAU. VDPAU support disabled. =="

case $host in
    i*86*-linux-gnu*)
       ARCH="i486-linux"
       ;;
    x86_64-*-linux-gnu*)
       ARCH="x86_64-linux"
       ;;
    i386-apple-darwin*)
       ARCH="x86-osx"
       # define i386 or x86_64, cannot use $HOSTTYPE as it reports x86_64 on 10.6 regardless of kernel flavor
       ARCHTYPE=`uname -m`
       AC_SUBST([ARCHTYPE])
       AC_SUBST(ARCH_DEFINES, "-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk")
       ;;
    powerpc-apple-darwin*)
       ARCH="powerpc-osx"
       # define ppc
       ARCHTYPE=`arch`
       AC_SUBST([ARCHTYPE])
       AC_SUBST(ARCH_DEFINES, "-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk")
       ;;
    powerpc-*-linux-gnu*)
       ARCH="powerpc-linux"
       AC_SUBST(ARCH_DEFINES, "-D_POWERPC")
       ;;
    powerpc64-*-linux-gnu*)
       ARCH="powerpc64-linux"
       AC_SUBST(ARCH_DEFINES, "-D_POWERPC64")
       ;;
    *)
       AC_MSG_ERROR(unsupported host ($host))
esac
AC_SUBST([ARCH])

AC_ARG_ENABLE([debug],
            [AS_HELP_STRING([--enable-debug],
               [enable debugging information (default is yes)])],
            [use_debug=$enableval],
            [use_debug=yes])

AC_ARG_ENABLE([optimizations],
            [AS_HELP_STRING([--enable-optimizations],
               [enable optimization (default is yes)])],
            [use_optimizations=$enableval],
            [use_optimizations=yes])

AC_ARG_ENABLE([gl],
            [AS_HELP_STRING([--enable-gl],
               [enable OpenGL rendering (default is yes)])],
            [use_gl=$enableval],
            [use_gl=yes])

AC_ARG_ENABLE([vdpau],
            [AS_HELP_STRING([--enable-vdpau],
               [enable VDPAU decoding (default is yes)])],
            [use_vdpau=$enableval],
            [use_vdpau=yes])

AC_ARG_ENABLE([crystalhd],
            [AS_HELP_STRING([--enable-crystalhd],
               [enable CrystalHD decoding (default is yes)])],
            [use_crystalhd=$enableval],
            [use_crystalhd=yes])

AC_ARG_ENABLE([profiling],
            [AS_HELP_STRING([--enable-profiling],
               [enable gprof profiling (default is no)])],
            [use_profiling=$enableval],
            [use_profiling=no])

AC_ARG_ENABLE([joystick],
            [AS_HELP_STRING([--enable-joystick],
               [enable SDL joystick support (default is yes)])],
            [use_joystick=$enableval],
            [use_joystick=yes])

AC_ARG_ENABLE([xrandr],
            [AS_HELP_STRING([--enable-xrandr],
               [enable XRandR support (default is yes)])],
            [use_xrandr=$enableval],
            [use_xrandr=yes])

AC_ARG_ENABLE([goom],
            [AS_HELP_STRING([--enable-goom],
               [enable GOOM visualisation (default is no)])],
            [use_goom=$enableval],
            [use_goom=no])

AC_PATH_PROG(CCACHE,ccache,none)
AC_ARG_ENABLE([ccache],
            [AS_HELP_STRING([--enable-ccache],
               [enable building with ccache feature (default is yes if ccache is installed)])],
            [use_ccache=$enableval],
            [use_ccache=yes])

AC_ARG_ENABLE([pulse],
            [AS_HELP_STRING([--enable-pulse],
               [enable PulseAudio support (default is yes)])],
            [use_pulse=$enableval],
            [use_pulse=yes])

AC_ARG_ENABLE([faac],
            [AS_HELP_STRING([--enable-faac],
               [enable FAAC support (default is yes)])],
            [use_faac=$enableval],
            [use_faac=yes])

AC_ARG_ENABLE([dvdcss],
            [AS_HELP_STRING([--enable-dvdcss],
               [enable DVDCSS support (default is yes)])],
            [use_dvdcss=$enableval],
            [use_dvdcss=yes])

AC_ARG_ENABLE([mid],
            [AS_HELP_STRING([--enable-mid],
               [enable MID support (default is no)])],
            [use_mid=$enableval],
            [use_mid=no])
AC_ARG_ENABLE([avahi],
             [AS_HELP_STRING([--disable-avahi],
                [disable Avahi support (default is enabled if libavahi-common and libavahi-client is found)])],
             [use_avahi=$enableval],
             [use_avahi=yes])
AC_ARG_ENABLE([non-free],
              [AS_HELP_STRING([--disable-non-free],
                [disable componentents with non-compliant licenses])],
              [use_nonfree=$enableval],
              [use_nonfree=yes])
AC_ARG_ENABLE([asap-codec],
              [AS_HELP_STRING([--enable-asap-codec],
                [enable ASAP ADPCM support])],
              [use_asap=$enableval],
              [use_asap=no])
AC_ARG_ENABLE([webserver],
              [AS_HELP_STRING([--disable-webserver],
                [disable webserver])],
              [use_webserver=$enableval],
              [use_webserver=yes])
AC_ARG_ENABLE([libdts],
              [AS_HELP_STRING([--enable-libdts],
                [enable deprecated libdts support])],
              [use_libdts=$enableval],
              [use_libdts=no])
AC_ARG_ENABLE([liba52],
              [AS_HELP_STRING([--enable-liba52],
                [enable deprecated liba52 support])],
              [use_liba52=$enableval],
              [use_liba52=no])

### External libraries options
AC_ARG_ENABLE([external-libraries],
            [AS_HELP_STRING([--enable-external-libraries],
            [enable use of all supported external libraries (default is no) 'Linux only'])],
            [use_external_libraries=$enableval],
            [use_external_libraries=no])

AC_ARG_ENABLE([external-ffmpeg],
            [AS_HELP_STRING([--enable-external-ffmpeg],
            [enable use of external ffmpeg libraries (default is no) 'Linux only'])],
            [use_external_ffmpeg=$enableval],
            [use_external_ffmpeg=no])

AC_ARG_ENABLE([external-liba52],
            [AS_HELP_STRING([--enable-external-liba52],
            [enable use of external liba52 library (default is no) 'Linux only'])],
            [use_external_liba52=$enableval],
            [use_external_liba52=no])

AC_ARG_ENABLE([external-libdts],
            [AS_HELP_STRING([--enable-external-libdts],
            [enable use of external libdts library (default is no) 'Linux only'])],
            [use_external_libdts=$enableval],
            [use_external_libdts=no])

AC_ARG_ENABLE([external-libass],
            [AS_HELP_STRING([--enable-external-libass],
            [enable use of external libass library (default is no) 'Linux only'])],
            [use_external_libass=$enableval],
            [use_external_libass=no])

AC_ARG_ENABLE([external-python],
            [AS_HELP_STRING([--enable-external-python],
            [enable use of external python library (default is no) 'Linux only'])],
            [use_external_python=$enableval],
            [use_external_python=no])

### End of external library options

# PCRE is a requirement
use_pcre="yes"

# Checks for programs.
PASSED_CXXFLAGS=$CXXFLAGS # Hack to override autoconf default values
AC_PROG_CXX
CXXFLAGS=$PASSED_CXXFLAGS
PASSED_CFLAGS=$CFLAGS # Hack to override autoconf default values
AC_PROG_CC
CFLAGS=$PASSED_CFLAGS
AC_PROG_AWK
AC_PROG_LN_S
AC_PROG_MAKE_SET

# platform specific flags
if test "$host_vendor" = "apple" ; then
  AC_SUBST(MACOSX_DEPLOYMENT_TARGET, "10.4")
  # need these in CFLAGS/CXXFLAGS so AC_CHECK_LIB works
  CFLAGS="$CFLAGS -I/opt/local/include"
  CXXFLAGS="$CXXFLAGS -I/opt/local/include"
  # standard xbmc paths
  INCLUDES="$INCLUDES -I\$(abs_top_srcdir)/xbmc/osx"
  LDFLAGS="$LDFLAGS -mmacosx-version-min=10.4"
  LDFLAGS="$LDFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
  LDFLAGS="$LDFLAGS -framework IOKit"
  LDFLAGS="$LDFLAGS -framework Cocoa"
  LDFLAGS="$LDFLAGS -framework OpenGL"
  LDFLAGS="$LDFLAGS -framework AppKit"
  LDFLAGS="$LDFLAGS -framework Carbon"
  LDFLAGS="$LDFLAGS -framework CoreAudio"
  LDFLAGS="$LDFLAGS -framework QuickTime"
  LDFLAGS="$LDFLAGS -framework AudioUnit"
  LDFLAGS="$LDFLAGS -framework Foundation"
  LDFLAGS="$LDFLAGS -framework CoreServices"
  LDFLAGS="$LDFLAGS -framework CoreVideo"
  LDFLAGS="$LDFLAGS -framework CoreAudio"
  LDFLAGS="$LDFLAGS -framework AudioToolbox"
  LDFLAGS="$LDFLAGS -framework CoreFoundation"
  LDFLAGS="$LDFLAGS -framework DiskArbitration"
  LDFLAGS="$LDFLAGS -framework ApplicationServices"
  LDFLAGS="$LDFLAGS -L/opt/local/lib"
  LDFLAGS="$LDFLAGS -L/opt/local/lib/mysql5/mysql"
  LDFLAGS="$LDFLAGS -L/opt/local/lib/samba3"
fi

# Add top source directory for all builds so we can use config.h
INCLUDES="$INCLUDES -I\$(abs_top_srcdir)"

# Checks for boost headers using CXX instead of CC
AC_LANG_PUSH([C++])
AC_CHECK_HEADER([boost/shared_ptr.hpp],, AC_MSG_ERROR($missing_library))
AC_LANG_POP([C++])

# Checks for platforms libraries.
if test "$use_gl" = "yes"; then
  if test "$host_vendor" = "apple" ; then
    # linking to OpenGL.framework instead of libGL, libGLU
    AC_CHECK_LIB([GLEW],    [main],, AC_MSG_ERROR($missing_library))
  else
    AC_CHECK_LIB([GL],      [main],, AC_MSG_ERROR($missing_library))
    AC_CHECK_LIB([GLEW],    [main],, AC_MSG_ERROR($missing_library))
    AC_CHECK_LIB([GLU],     [main],, AC_MSG_ERROR($missing_library))
  fi
else
  AC_MSG_RESULT(== WARNING: OpenGL support is disabled. XBMC will run VERY slow. ==)
  AC_CHECK_LIB([SDL_gfx], [main])
fi

if test "$host_vendor" != "apple" ; then
  if test "$use_webserver" = "yes"; then
    AC_CHECK_LIB([microhttpd],  [main],, AC_MSG_ERROR($missing_library))
  fi
else
  if test "$use_webserver" = "yes"; then
    AC_DEFINE([HAVE_LIBMICROHTTPD], [1],)
  fi
fi


# platform independent libraries
AC_CHECK_HEADER([mad.h],,            AC_MSG_ERROR($missing_library))
AC_CHECK_HEADER([jpeglib.h],,        AC_MSG_ERROR($missing_library))
AC_CHECK_HEADER([samplerate.h],,     AC_MSG_ERROR($missing_library))
AC_CHECK_HEADER([ogg/ogg.h],,        AC_MSG_ERROR($missing_library))
AC_CHECK_HEADER([vorbis/vorbisfile.h],, AC_MSG_ERROR($missing_library))
AC_CHECK_HEADER([vorbis/vorbisenc.h],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([bz2],         [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([jpeg],        [main],, AC_MSG_ERROR($missing_library)) # check for cximage
AC_CHECK_LIB([pthread],     [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([lzo2],        [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([z],           [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([ssl],         [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([crypto],      [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([wavpack],     [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([mpeg2],       [main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([mpeg2convert],[main],, AC_MSG_ERROR($missing_library))
AC_CHECK_LIB([ssh],         [sftp_tell64],, AC_MSG_RESULT([Could not find suitable version of libssh]))
PKG_CHECK_MODULES([MAD],        [mad],
                  [INCLUDES+=" $MAD_CFLAGS"; LIBS+=" $MAD_LIBS"],
                  AC_MSG_ERROR($missing_library))
PKG_CHECK_MODULES([FONTCONFIG], [fontconfig],
                  [INCLUDES+=" $FONTCONFIG_CFLAGS"; LIBS+=" $FONTCONFIG_LIBS"],
                  AC_MSG_ERROR($missing_library))
PKG_CHECK_MODULES([FRIBIDI],    [fribidi],
                  [INCLUDES+=" $FRIBIDI_CFLAGS"; LIBS+=" $FRIBIDI_LIBS"],
                  AC_MSG_ERROR($missing_library))
PKG_CHECK_MODULES([SQLITE3],    [sqlite3],
                  [INCLUDES+=" $SQLITE3_CFLAGS"; LIBS+=" $SQLITE3_LIBS"],
                  AC_MSG_ERROR($missing_library))
PKG_CHECK_MODULES([PNG],        [libpng],
                  [INCLUDES+=" $PNG_CFLAGS"; LIBS+=" $PNG_LIBS"],
                  AC_MSG_ERROR($missing_library))
PKG_CHECK_MODULES([PCRE],       [libpcre],
                  [INCLUDES+=" $PCRE_CFLAGS"; LIBS+=" $PCRE_LIBS"]; \
                  AC_DEFINE([HAVE_LIBPCRE],[1],["Define to 1 if libpcre is installed"]),
                  AC_MSG_ERROR($missing_library))
PKG_CHECK_MODULES([PCRECPP],    [libpcrecpp],
                  [INCLUDES+=" $PCRECPP_CFLAGS"; LIBS+=" $PCRECPP_LIBS"]; \
                  AC_DEFINE([HAVE_LIBPCRECPP],[1],["Define to 1 if libpcrecpp is installed"]),
                  AC_MSG_ERROR($missing_library))
PKG_CHECK_MODULES([CDIO],       [libcdio],
                  [INCLUDES+=" $CDIO_CFLAGS"; LIBS+=" $CDIO_LIBS"],
                  AC_MSG_ERROR($missing_library))
PKG_CHECK_MODULES([SAMPLERATE], [samplerate],
                  [INCLUDES+=" $SAMPLERATE_CFLAGS"; LIBS+=" $SAMPLERATE_LIBS"],
                  AC_MSG_ERROR($missing_library))
PKG_CHECK_MODULES([MMS],        [libmms],
                  [INCLUDES+=" $MMS_CFLAGS"; LIBS+=" $MMS_LIBS"],
                  AC_MSG_ERROR($missing_library))
PKG_CHECK_MODULES([FREETYPE2],  [freetype2],
                  [INCLUDES+=" $FREETYPE2_CFLAGS"; LIBS+=" $FREETYPE2_LIBS"],
                  AC_MSG_ERROR($missing_library))
PKG_CHECK_MODULES([OGG],        [ogg],
                  [INCLUDES+=" $OGG_CFLAGS"; LIBS+=" $OGG_LIBS"],
                  AC_MSG_ERROR($missing_library))
PKG_CHECK_MODULES([VORBIS],     [vorbis],
                  [INCLUDES+=" $VORBIS_CFLAGS"; LIBS+=" $VORBIS_LIBS"],
                  AC_MSG_ERROR($missing_library))
PKG_CHECK_MODULES([VORBISENC],     [vorbisenc],
                  [INCLUDES+=" $VORBISENC_CFLAGS"; LIBS+=" $VORBISENC_LIBS"],
                  AC_MSG_ERROR($missing_library))

# platform dependent libraries
if test "$host_vendor" = "apple" ; then
  AC_CHECK_LIB([iconv],     [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([mysqlclient], [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([smbclient], [main],, AC_MSG_ERROR($missing_library))
  PKG_CHECK_MODULES([VORBISFILE],     [vorbisfile],
                    [INCLUDES+=" $VORBISFILE_CFLAGS"; LIBS+=" $VORBISFILE_LIBS"],
                    AC_MSG_ERROR($missing_library))
else
  AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, "yes", "no")
  if test $MYSQL_CONFIG = "yes"; then
                  INCLUDES+=" `mysql_config --include`"
                  LIBS+=" `mysql_config --libs`"
  else
                  AC_MSG_ERROR($missing_program)
  fi
  # don't combine with mysqlclient check in apple section above, Linux needs
  # paths from mysql_config
  AC_CHECK_LIB([modplug],     [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([mysqlclient], [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([faad],      [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_HEADER([FLAC/stream_decoder.h],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([smbclient], [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([SDL_mixer], [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([dl],        [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([resolv],    [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([jasper],    [main],, AC_MSG_ERROR($missing_library)) # check for cximage
  AC_CHECK_LIB([tiff],      [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([rt],        [clock_gettime],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([SDL_image], [main],, AC_MSG_ERROR($missing_library))
  
  PKG_CHECK_MODULES([ALSA],       [alsa],
                  [INCLUDES+=" $ALSA_CFLAGS"; LIBS+=" $ALSA_LIBS"],
                  AC_MSG_ERROR($missing_library))
  PKG_CHECK_MODULES([ENCA],         [enca],
                    [INCLUDES+=" $ENCA_CFLAGS"; LIBS+=" $ENCA_LIBS"],
                    AC_MSG_ERROR($missing_library))
  PKG_CHECK_MODULES([XT],           [xt],
                    [INCLUDES+=" $XT_CFLAGS"; LIBS+=" $XT_LIBS"],
                    AC_MSG_ERROR($missing_library))
  PKG_CHECK_MODULES([XTST],         [xtst],
                    [INCLUDES+=" $XTST_CFLAGS"; LIBS+=" $XTST_LIBS"],
                    AC_MSG_ERROR($missing_library))
  PKG_CHECK_MODULES([XMU],          [xmu],
                    [INCLUDES+=" $XMU_CFLAGS"; LIBS+=" $XMU_LIBS"],
                    AC_MSG_ERROR($missing_library))
  PKG_CHECK_MODULES([XINERAMA],     [xinerama],
                    [INCLUDES+=" $XINERAMA_CFLAGS"; LIBS+=" $XINERAMA_LIBS"],
                    AC_MSG_ERROR($missing_library))
  PKG_CHECK_MODULES([CURL],         [libcurl],
                    [INCLUDES+=" $CURL_CFLAGS"; LIBS+=" $CURL_LIBS"],
                    AC_MSG_ERROR($missing_library))
  PKG_CHECK_MODULES([DBUS],         [dbus-1],
                    [INCLUDES+=" $DBUS_CFLAGS"; LIBS+=" $DBUS_LIBS"],
                    AC_MSG_ERROR($missing_library))
  PKG_CHECK_MODULES([HAL_STORAGE],  [hal-storage],
                    [INCLUDES+=" $HAL_STORAGE_CFLAGS"; LIBS+=" $HAL_STORAGE_LIBS"], 
                    AC_MSG_ERROR($missing_library))
  PKG_CHECK_MODULES([SDL],          [sdl],
                    [INCLUDES+=" $SDL_CFLAGS"; LIBS+=" $SDL_LIBS"],
                    AC_MSG_ERROR($missing_library))
  PKG_CHECK_MODULES([HAL],          [hal],
                    [INCLUDES+=" $HAL_CFLAGS"; LIBS+=" $HAL_LIBS"],
                    AC_MSG_ERROR($missing_library))
fi

# PulseAudio
if test "$host_vendor" = "apple" ; then
  use_pulse="no"
  AC_MSG_RESULT($pulse_disabled)
else
  if test "$use_pulse" = "yes"; then
    AC_CHECK_LIB([pulse], [main],, 
      use_pulse=no;AC_MSG_RESULT($pulse_not_found))
  else
    AC_MSG_RESULT($pulse_disabled)
  fi
fi

# FAAC
if test "$host_vendor" = "apple" ; then
  use_faac="no"
  AC_MSG_RESULT($faac_disabled)
else
  if test "$use_faac" = "yes"; then
    AC_CHECK_LIB([faac], [main],,
      use_faac=no;AC_MSG_RESULT($faac_not_found))
  else
    AC_MSG_RESULT($faac_disabled)
  fi
fi

# avahi
if test "$host_vendor" = "apple" ; then
  use_avahi="no"
  AC_MSG_RESULT($avahi_disabled)
else
  if test "$use_avahi" = "yes"; then
    AC_CHECK_LIB([avahi-common], [main],,
      use_avahi=no;AC_MSG_RESULT($avahi_not_found))
	if test "$use_avahi" = "yes"; then
		#either both libs or none
    	AC_CHECK_LIB([avahi-client], [main],,
	      use_avahi=no;AC_MSG_RESULT($avahi_not_found))
	fi
    else
     AC_MSG_RESULT($avahi_disabled)
   fi
fi

# XRandR
if test "$host_vendor" = "apple" ; then
  use_xrandr="no"
  AC_MSG_RESULT($xrandr_disabled)
else
  if test "$use_xrandr" = "yes" ; then
    AC_CHECK_LIB([Xrandr], [main],, 
      use_xrandr="no";AC_MSG_RESULT($xrandr_not_found))
  else
    AC_MSG_RESULT($xrandr_disabled)
  fi
fi

# GOOM
if test "$host_vendor" = "apple" ; then
  AC_MSG_NOTICE($goom_disabled)
  BUILD_GOOM=1
else
  if test "$use_goom" = "yes"; then
    AC_MSG_NOTICE($goom_enabled)
    BUILD_GOOM=0
  else
    AC_MSG_NOTICE($goom_disabled)
    BUILD_GOOM=1
  fi
fi

### External libraries checks
if test "$use_external_libraries" = "yes"; then
  AC_MSG_NOTICE($external_libraries_enabled)
  USE_EXTERNAL_LIBRARIES=1
  AC_DEFINE([USE_EXTERNAL_LIBRARIES], [1], [Whether to use external libraries.])
else
  AC_MSG_NOTICE($external_libraries_disabled)
  USE_EXTERNAL_LIBRARIES=0
fi

# External FFmpeg
if test "$use_external_libraries" = "yes" || test "$use_external_ffmpeg" = "yes"; then
  AC_CHECK_LIB([avcodec],          [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([avformat],         [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([avutil],           [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([postproc],         [main],, AC_MSG_ERROR($missing_library))
  AC_CHECK_LIB([swscale],          [main],, AC_MSG_ERROR($missing_library))

  # Determine whether AVPacket and relevant functions are defined in libavformat
  # or libavcodec
  AC_CHECK_LIB([avcodec], [av_free_packet],
  [AC_MSG_NOTICE(== AVPacket and relevant functions defined in libavcodec. ==)],
  [AC_MSG_NOTICE(== AVPacket and relevant functions defined in libavformat. ==)
   AC_DEFINE([AVPACKET_IN_AVFORMAT], [1], [Whether AVPacket is in libavformat.])])

  # Possible places the ffmpeg headers may be
  AC_CHECK_HEADERS([libavcodec/avcodec.h libavformat/avformat.h libavutil/avutil.h libpostproc/postprocess.h libswscale/swscale.h],,
  [AC_CHECK_HEADERS([ffmpeg/avcodec.h ffmpeg/avformat.h ffmpeg/avutil.h postproc/postprocess.h ffmpeg/swscale.h],,
  [AC_MSG_ERROR($missing_headers)])])

  # We'll support the use of rgb2rgb.h if it exists.
  AC_CHECK_HEADERS([libswscale/rgb2rgb.h],,)
  AC_CHECK_HEADERS([ffmpeg/rgb2rgb.h],,)

  AC_MSG_NOTICE($external_ffmpeg_enabled)
  USE_EXTERNAL_FFMPEG=1
  AC_DEFINE([USE_EXTERNAL_FFMPEG], [1], [Whether to use external FFmpeg libraries.])

  # Disable vdpau support if external libavcodec doesn't have it
  AC_CHECK_LIB([avcodec], [ff_vdpau_vc1_decode_picture],,
    use_vdpau=no;AC_MSG_RESULT($ffmpeg_vdpau_not_supported))

  # Check for 'PIX_FMT_VDPAU_MPEG4' from libavutil
  if test "$use_vdpau" = "yes"; then
    AC_LANG_PUSH([C++])
    AC_LINK_IFELSE([
        #include <libavutil/pixfmt.h>
        int main() { PixelFormat format = PIX_FMT_VDPAU_MPEG4; }
      ],
      [AC_DEFINE([PIX_FMT_VDPAU_MPEG4_IN_AVUTIL], [1],
       [Whether AVUtil defines PIX_FMT_VDPAU_MPEG4.])],)
    AC_LANG_POP([C++])
  fi
else
  AC_MSG_NOTICE($external_ffmpeg_disabled)
  USE_EXTERNAL_FFMPEG=0
  AC_DEFINE([PIX_FMT_VDPAU_MPEG4_IN_AVUTIL], [1], [Whether AVUtil defines PIX_FMT_VDPAU_MPEG4.])
fi

# External liba52
if test "$use_external_libraries" = "yes" || test "$use_external_liba52" = "yes"; then
  AC_CHECK_LIB([a52],          [main],, AC_MSG_ERROR($missing_library))

  AC_MSG_NOTICE($external_liba52_enabled)
  USE_EXTERNAL_LIBA52=1
  AC_DEFINE([USE_EXTERNAL_LIBA52], [1], [Whether to use external liba52 library.])
else
  AC_MSG_NOTICE($external_liba52_disabled)
  USE_EXTERNAL_LIBA52=0
fi

# External libdts
if test "$use_external_libraries" = "yes" || test "$use_external_libdts" = "yes"; then
  AC_CHECK_LIB([dts],          [main],, AC_MSG_ERROR($missing_library))

  AC_MSG_NOTICE($external_libdts_enabled)
  USE_EXTERNAL_LIBDTS=1
  AC_DEFINE([USE_EXTERNAL_LIBDTS], [1], [Whether to use external libdts library.])
else
  AC_MSG_NOTICE($external_libdts_disabled)
  USE_EXTERNAL_LIBDTS=0
fi

# External libass
if test "$use_external_libraries" = "yes" || test "$use_external_libass" = "yes"; then
  # We need libass >= 0.9.7.
  AC_CHECK_LIB([ass], [ass_set_message_cb],
  [AC_CHECK_LIB([ass], [main],,)
  AC_MSG_NOTICE($external_libass_enabled)
  USE_EXTERNAL_LIBASS=1
   AC_DEFINE([USE_EXTERNAL_LIBASS], [1], [Whether to use external libass library.])],
  [AC_MSG_WARN(== Need libass >= 0.9.7. Disabling external libass. ==)
   USE_EXTERNAL_LIBASS=0])
else
  AC_MSG_NOTICE($external_libass_disabled)
  USE_EXTERNAL_LIBASS=0
fi

# External Python
if test "$use_external_libraries" = "yes" || test "$use_external_python" = "yes"; then
  AC_CHECK_LIB([python2.6], [main],
    [AC_DEFINE([HAVE_LIBPYTHON2_6], [1],
    [Define to 1 if you have the `python2.6' library.])
    USE_PYTHON2_6=1],
  [AC_CHECK_LIB([python2.5], [main],
    [AC_DEFINE([HAVE_LIBPYTHON2_5], [1],
    [Define to 1 if you have the `python2.5' library.])
    USE_PYTHON2_5=1],
  [AC_CHECK_LIB([python2.4], [main],
    [AC_DEFINE([HAVE_LIBPYTHON2_4], [1],
    [Define to 1 if you have the `python2.4' library.])
    USE_PYTHON2_4=1],
  [AC_MSG_ERROR($missing_library)] )] )] )

  AC_MSG_NOTICE($external_python_enabled)
  test "$USE_PYTHON2_6" && AC_MSG_NOTICE([Using Python 2.6])
  test "$USE_PYTHON2_5" && AC_MSG_NOTICE([Using Python 2.5])
  test "$USE_PYTHON2_4" && AC_MSG_NOTICE([Using Python 2.4])
  USE_EXTERNAL_PYTHON=1
  AC_DEFINE([USE_EXTERNAL_PYTHON], [1], [Whether to use external python library.])
else
  AC_MSG_NOTICE($external_python_disabled)
  USE_EXTERNAL_PYTHON=0

  # We'll need zip in this case.
  AC_CHECK_PROG(HAVE_ZIP,zip,"yes","no",)
  if test "$HAVE_ZIP" = "no" ; then
    AC_MSG_ERROR($missing_program)
  fi
fi

# VDPAU
if test "$host_vendor" = "apple" ; then
  use_vdpau="no"
  AC_MSG_NOTICE($vdpau_disabled)
else
  if test "$use_vdpau" = "yes"; then
    AC_CHECK_HEADER([vdpau/vdpau.h],AC_DEFINE([HAVE_LIBVDPAU], [], [Define to 1 if you have the 'vdpau' library (-lvdpau).]),
      use_vdpau=no;AC_MSG_RESULT($vdpau_not_found))
  else
    AC_MSG_NOTICE($vdpau_disabled)
  fi
fi

# CrystalHD
if test "$use_crystalhd" = "yes"; then
  AC_CHECK_HEADER([libcrystalhd/libcrystalhd_if.h],AC_DEFINE([HAVE_LIBCRYSTALHD], [], 
    [Define to 1 if you have the `Broadcom Crystal HD' library.]), 
    use_crystalhd=no;AC_MSG_RESULT($crystalhd_not_found), [#define __LINUX_USER__])
else
  AC_MSG_NOTICE($crystalhd_disabled)
fi

# platform specific bin utilities
if test "$host_vendor" != "apple" ; then
  AC_CHECK_PROG(HAVE_GAWK,gawk,"yes","no",)
  if test "$HAVE_GAWK" = "no" ; then
    AC_MSG_ERROR($missing_program)
  fi
fi

AC_CHECK_PROG(HAVE_CMAKE,cmake,"yes","no",)
if test "$HAVE_CMAKE" = "no" ; then
  AC_MSG_ERROR($missing_program)
fi

AC_CHECK_PROG(HAVE_GPERF,gperf,"yes","no",)
if test "$HAVE_GPERF" = "no" ; then
  AC_MSG_ERROR($missing_program)
fi

AC_CHECK_PROG(HAVE_UNZIP,unzip,"yes","no",)
if test "$HAVE_UNZIP" = "no" ; then
  AC_MSG_ERROR($missing_program)
fi

if test "$ARCH" != "x86_64-linux"; then
  AC_CHECK_PROG(HAVE_NASM,nasm,"yes","no",)
  if test "$HAVE_NASM" = "no" ; then
    AC_MSG_ERROR($missing_program)
  fi
fi

AC_CHECK_PROG(HAVE_SVNVERSION,svnversion,"yes","no",)
AC_CHECK_PROG(HAVE_GIT,git,"yes","no",)

# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([lzo/lzo1.h])
AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h inttypes.h limits.h locale.h \
  malloc.h memory.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h \
  strings.h sys/file.h sys/ioctl.h sys/mount.h sys/param.h sys/socket.h \
  sys/time.h sys/timeb.h sys/vfs.h termios.h unistd.h utime.h wchar.h wctype.h])
AC_CHECK_HEADERS([cdio/iso9660.h],,AC_MSG_ERROR([$missing_headers]))

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STAT
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_UID_T
AC_C_INLINE
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_C_RESTRICT
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_CHECK_MEMBERS([struct stat.st_rdev])
AC_HEADER_TIME
AC_STRUCT_TM
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_C_BIGENDIAN

# Checks for library functions.
AC_FUNC_ALLOCA
AC_FUNC_CHOWN
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FSEEKO
AC_PROG_GCC_TRADITIONAL
AC_FUNC_LSTAT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MEMCMP
AC_FUNC_MKTIME
AC_FUNC_MMAP
# Boxee is apparently having compile problems
# if HAVE_REALLOC is defined.  Sort this later.
#AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_SETVBUF_REVERSED
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_STRCOLL
AC_FUNC_STRFTIME
AC_FUNC_STRTOD
AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF
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])

# Check for various sizes
AC_CHECK_SIZEOF([int])
AC_CHECK_SIZEOF([size_t])

dashes="------------------------"
final_message="\n  XBMC Configuration:"
final_message="\n$dashes$final_message\n$dashes"

if test "$use_debug" = "yes"; then
  final_message="$final_message\n  Debugging:\tYes"
  if test "$use_profiling" = "yes"; then
    final_message="$final_message\n  Profiling:\tYes"
    DEBUG_FLAGS="-g -pg -D_DEBUG -Wall"
  else
    final_message="$final_message\n  Profiling:\tNo"
    DEBUG_FLAGS="-g -D_DEBUG -Wall"
  fi
else
  final_message="$final_message\n  Debugging:\tNo"
  if test "$use_profiling" = "yes"; then
    final_message="$final_message\n  Profiling:\tYes"
    DEBUG_FLAGS="-pg -DNDEBUG=1"
  else
    final_message="$final_message\n  Profiling:\tNo"
    DEBUG_FLAGS="-DNDEBUG=1"
  fi
fi

if test "$use_optimizations" = "yes"; then
  final_message="$final_message\n  Optimization:\tYes"
  CXXFLAGS="$CXXFLAGS -O2"
  CFLAGS="$CFLAGS -O2"
else
  final_message="$final_message\n  Optimization:\tNo"
fi

if test "$use_gl" = "yes"; then
  final_message="$final_message\n  OpenGL:\tYes"
else
  final_message="$final_message\n  OpenGL:\tNo (Very Slow)"
  SDL_DEFINES="-DHAS_SDL_2D"
fi

if test "$use_vdpau" = "yes"; then
  final_message="$final_message\n  VDPAU:\tYes"
else
  final_message="$final_message\n  VDPAU:\tNo"
fi

if test "$use_crystalhd" = "yes"; then
  final_message="$final_message\n  CrystalHD:\tYes"
else
  final_message="$final_message\n  CrystalHD:\tNo"
fi

if test "$use_joystick" = "yes"; then
  final_message="$final_message\n  Joystick:\tYes"
  SDL_DEFINES="$SDL_DEFINES -DHAS_SDL_JOYSTICK"
else
  final_message="$final_message\n  Joystick:\tNo"
fi

if test "$use_xrandr" = "yes"; then
  final_message="$final_message\n  XRandR:\tYes"
else
  final_message="$final_message\n  XRandR:\tNo"
fi

if test "$use_goom" = "yes"; then
  final_message="$final_message\n  GOOM:\t\tYes"
else
  final_message="$final_message\n  GOOM:\t\tNo"
fi

if test "$use_pcre" = "yes"; then
  final_message="$final_message\n  PCRE Support:\tYes"
else
  final_message="$final_message\n  PCRE Support:\tNo"
fi

if test "$use_mid" = "yes"; then
  final_message="$final_message\n  MID Support:\tYes"
  SDL_DEFINES="$SDL_DEFINES -DMID"
else
  final_message="$final_message\n  MID Support:\tNo"
fi

if test -d "/usr/include/lzo"; then
  INCLUDES="$INCLUDES -I/usr/include/lzo"
else
  INCLUDES="$INCLUDES"
fi

if test "$use_ccache" = "yes"; then
  if test "$ac_cv_path_CCACHE" = "none"; then
     echo "ccache not found. Falling back to default CC"
     final_message="$final_message\n  ccache:\tNo"
  else
    CC="$ac_cv_path_CCACHE $CC"
    CXX="$ac_cv_path_CCACHE $CXX"
    AC_MSG_NOTICE(enabling ccache)
    final_message="$final_message\n  ccache:\tYes"
  fi
else
  final_message="$final_message\n  ccache:\tNo"
fi

if test "$use_pulse" = "yes"; then
  final_message="$final_message\n  PulseAudio:\tYes"
else
  final_message="$final_message\n  PulseAudio:\tNo"
fi

if test "$use_faac" = "yes"; then
  final_message="$final_message\n  FAAC:\t\tYes"
else
  final_message="$final_message\n  FAAC:\t\tNo"
fi

# DVDCSS
if test "$use_dvdcss" = "yes"; then
  AC_MSG_NOTICE($dvdcss_enabled)
  final_message="$final_message\n  DVDCSS:\tYes"
  BUILD_DVDCSS=1
  SKIP_CONFIG_DVDCSS=0
  DVDREAD_CFLAGS="-D_XBMC -DHAVE_DVDCSS_DVDCSS_H"
else
  AC_MSG_NOTICE($dvdcss_disabled)
  final_message="$final_message\n  DVDCSS:\tNo"
  BUILD_DVDCSS=0
  SKIP_CONFIG_DVDCSS=1
  DVDREAD_CFLAGS="-D_XBMC -UHAVE_DVDCSS_DVDCSS_H"
fi
if test "$use_avahi" = "yes"; then
  final_message="$final_message\n  Avahi:\tYes"
else
  final_message="$final_message\n  Avahi:\tNo"
fi

if ! test -n "$SVN_REV" -a "$SVN_REV" != "" ; then
  if test "$HAVE_SVNVERSION" = "yes" ; then
    SVN_REV=$(svnversion -n -c 2>/dev/null | grep -iv ^exported | sed -e 's/.*\://')
  fi
  if test "$SVN_REV" = ""; then
    if test "$HAVE_GIT" = "yes"; then
      SVN_REV=$(echo -n `sh gitrev.sh`)
    fi
  fi
  if test "$SVN_REV" = ""; then
    SVN_REV="Unknown"
  fi
fi
if test "$host_vendor" = "apple"; then
  echo "#define SVN_REV \"$SVN_REV\"" > svn_revision.h
else
  SDL_DEFINES="$SDL_DEFINES -D'SVN_REV=\"$SVN_REV\"'"
fi

if test "$use_nonfree" = "yes"; then
  final_message="$final_message\n  Non-free:\tYes"
  HAVE_XBMC_NONFREE=1
  AC_DEFINE([HAVE_XBMC_NONFREE], [1], [Define to 1 to enable non-free components.])
else
  HAVE_XBMC_NONFREE=0
  final_message="$final_message\n  Non-free:\tNo"
fi

if test "$use_asap" = "yes"; then
  AC_CHECK_PROG(HAVE_GDC,gdc,"yes","no")
  if test "$HAVE_GDC" = "no"; then
    AC_MSG_ERROR($missing_program);
  fi
  AC_CHECK_PROG(HAVE_FPC,fpc,"yes","no")
  if test "$HAVE_FPC" = "no"; then
    AC_MSG_ERROR($missing_program);
  fi
  USE_ASAP_CODEC=1
  AC_DEFINE([USE_ASAP_CODEC], [1], [Define to 1 to enable ASAP codec.])
  final_message="$final_message\n  ASAP Codec:\tYes"
else
  USE_ASAP_CODEC=0
  final_message="$final_message\n  ASAP Codec:\tNo"
fi

if test "$use_webserver" = "yes"; then
  final_message="$final_message\n  Webserver:\tYes"
else
  final_message="$final_message\n  Webserver:\tNo"
fi

if test "$use_libdts" = "yes"; then
  USE_LIBDTS_DECODER=1
  AC_DEFINE([USE_LIBDTS_DECODER], [1], [Define to 1 to enable deprecated libdts support])
  final_message="$final_message\n  Deprecated libdts:\tYes"
else
  final_message="$final_message\n  Deprecated libdts:\tNo"
fi

if test "$use_liba52" = "yes"; then
  USE_LIBA52_DECODER=1
  AC_DEFINE([USE_LIBA52_DECODER], [1], [Define to 1 to enable deprecated liba52 support])
  final_message="$final_message\n  Deprecated liba52:\tYes"
else
  final_message="$final_message\n  Deprecated liba52:\tNo"
fi

### External libraries messages
if test "$use_external_libraries" = "yes"; then
  final_message="$final_message\n  External Libraries:\tYes"
else
  final_message="$final_message\n  External Libraries:\tNo"
  if test "$use_external_ffmpeg" = "yes"; then
    final_message="$final_message\n  External FFmpeg:\tYes"
  else
    final_message="$final_message\n  External FFmpeg:\tNo"
  fi
  if test "$use_external_liba52" = "yes"; then
    final_message="$final_message\n  External liba52:\tYes"
  else
    final_message="$final_message\n  External liba52:\tNo"
  fi
  if test "$use_external_libdts" = "yes"; then
    final_message="$final_message\n  External libdts:\tYes"
  else
    final_message="$final_message\n  External libdts:\tNo"
  fi
  if test "$use_external_libass" = "yes"; then
    final_message="$final_message\n  External libass:\tYes"
  else
    final_message="$final_message\n  External libass:\tNo"
  fi
  if test "$use_external_python" = "yes"; then
    final_message="$final_message\n  External Python:\tYes"
  else
    final_message="$final_message\n  External Python:\tNo"
  fi
fi

OUTPUT_FILES="Makefile \
             Makefile.include \
             xbmc/Makefile \
             xbmc/cores/Makefile \
             xbmc/cores/VideoRenderers/Makefile \
             xbmc/cores/dvdplayer/Makefile \
             xbmc/cores/dvdplayer/Codecs/Makefile \
             xbmc/cores/dvdplayer/Codecs/libdvd/Makefile \
             xbmc/cores/dvdplayer/DVDCodecs/Makefile \
             xbmc/cores/dvdplayer/DVDCodecs/Audio/Makefile \
             xbmc/cores/dvdplayer/DVDCodecs/Overlay/Makefile \
             xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile \
             xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD/Makefile \
             xbmc/cores/dvdplayer/DVDDemuxers/Makefile \
             xbmc/cores/dvdplayer/DVDSubtitles/Makefile \
             xbmc/cores/AudioRenderers/Makefile \
             xbmc/cores/paplayer/Makefile \
             xbmc/cores/paplayer/timidity/Makefile \
             xbmc/cores/paplayer/AC3Codec/Makefile \
             xbmc/cores/paplayer/ADPCMCodec/Makefile \
             xbmc/cores/paplayer/GYMCodec/Makefile \
             xbmc/cores/paplayer/NSFCodec/Makefile \
             xbmc/cores/paplayer/SIDCodec/Makefile \
             xbmc/cores/paplayer/vgmstream/Makefile \
             xbmc/cores/paplayer/SPCCodec/SNES/SNESAPU/Makefile \
             xbmc/cores/paplayer/YMCodec/StSoundLibrary/Makefile \
             xbmc/cores/playercorefactory/Makefile \
             xbmc/karaoke/Makefile \
             guilib/Makefile \
             guilib/common/Makefile \
             xbmc/lib/libass/xbmc/Makefile \
             xbmc/lib/libXBMS/Makefile \
             xbmc/lib/libRTV/Makefile \
             xbmc/lib/libexif/Makefile \
             xbmc/lib/libXDAAP/Makefile \
             xbmc/lib/libhdhomerun/Makefile \
             xbmc/lib/libhttpapi/Makefile \
             lib/jsoncpp/jsoncpp/src/lib_json/Makefile \
             xbmc/lib/libjsonrpc/Makefile \
             xbmc/lib/libshout/Makefile \
             xbmc/lib/libsquish/Makefile \
             xbmc/lib/libid3tag/Makefile \
             xbmc/lib/cximage-6.0/Makefile \
             xbmc/lib/libPython/linux/Makefile \
             xbmc/lib/libUPnP/Makefile \
             xbmc/DllPaths_generated.h \
             xbmc/linux/Makefile \
             xbmc/FileSystem/Makefile \
             xbmc/addons/Makefile \
             xbmc/screensavers/rsxs-0.9/xbmc/Makefile \
             xbmc/visualizations/XBMCProjectM/Makefile \
             xbmc/visualizations/Goom/Makefile \
             xbmc/visualizations/OpenGLSpectrum/Makefile \
             xbmc/visualizations/WaveForm/Makefile \
             xbmc/visualizations/iTunes/Makefile \
             xbmc/FileSystem/Makefile \
             tools/Linux/xbmc.sh \
             tools/TexturePacker/Makefile \
             tools/EventClients/Clients/OSXRemote/Makefile"

if test "$host_vendor" = "apple"; then
  OUTPUT_FILES+=" \
                xbmc/cores/paplayer/FLACCodec/Makefile"
fi

# Line below is used so we can use AM_INIT_AUTOMAKE. The corresponding
# .dummy.am does nothing.
AC_CONFIG_FILES([.dummy])

AC_CONFIG_FILES([${OUTPUT_FILES}])
OUTPUT_FILES+=" \
             .dummy"
AC_SUBST(CFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(INCLUDES)
AC_SUBST(LDFLAGS)
AC_SUBST(DEBUG_FLAGS)
AC_SUBST(SDL_DEFINES)
AC_SUBST(BUILD_DVDCSS)
AC_SUBST(BUILD_GOOM)
AC_SUBST(USE_EXTERNAL_LIBRARIES)
AC_SUBST(USE_EXTERNAL_FFMPEG)
AC_SUBST(USE_EXTERNAL_LIBA52)
AC_SUBST(USE_EXTERNAL_LIBDTS)
AC_SUBST(USE_EXTERNAL_LIBMPEG2)
AC_SUBST(USE_EXTERNAL_LIBASS)
AC_SUBST(USE_EXTERNAL_LIBWAVPACK)
AC_SUBST(USE_EXTERNAL_PYTHON)
AC_SUBST(USE_PYTHON2_6)
AC_SUBST(USE_PYTHON2_5)
AC_SUBST(USE_PYTHON2_4)
AC_SUBST(OUTPUT_FILES)
AC_SUBST(HAVE_XBMC_NONFREE)
AC_SUBST(USE_ASAP_CODEC)
# Function to run the configure scripts in our submodules
# Consists of three paramaters, the path to the submodule, the configure command
# with appropriate arguments, and a third parameter set to 1 if we are to skip
# running the script, anything else if not.
AC_DEFUN([XB_CONFIG_MODULE],[
AC_CONFIG_COMMANDS_POST([
if [[ $3 != "1" ]]; then
    if [[ -d $1 ]]; then
        pushd $1
        $2
        if [[ $? -ne 0 ]]; then
            popd
            AC_MSG_ERROR([[Submodule $1 failed to configure]])
        else
            popd
        fi
    else
        AC_MSG_ERROR([[Submodule $1 doesn't exist]])
    fi
else
    AC_MSG_NOTICE([[Skipping configuration of submodule $1.]])
fi
])
])

XB_CONFIG_MODULE([xbmc/lib/libPython/Python], [
  if test "$host_vendor" = "apple" ; then
    ./configure \
      --enable-ipv6 \
      --enable-unicode=ucs4 \
      --without-cxx \
      --enable-shared \
      --without-pymalloc \
      --with-suffix=.exe \
      LDFLAGS="-L/opt/local/lib" \
      OPT="-Wno-deprecated-declarations -I/opt/local/include" \
      MACOSX_DEPLOYMENT_TARGET=10.4 &&
    sed -i bak -e "s/define HAVE_GETC_UNLOCKED 1/undef HAVE_GETC_UNLOCKED/" pyconfig.h && 
    sed -i bak -e "s/define HAVE_FSEEKO 1/undef HAVE_FSEEKO/" pyconfig.h &&
    sed -i bak -e "s/define HAVE_FTELLO 1/undef HAVE_FTELLO/" pyconfig.h &&
    sed -i bak -e "s/define HAVE_FTRUNCATE 1/undef HAVE_FTRUNCATE/" pyconfig.h &&
    sed -i bak -e "s/define HAVE_FPATHCONF 1/undef HAVE_FPATHCONF/" pyconfig.h &&
    sed -i bak -e "s/define HAVE_FSYNC 1/undef HAVE_FSYNC/" pyconfig.h &&
    sed -i bak -e "s/define HAVE_FCHDIR 1/undef HAVE_FCHDIR/" pyconfig.h &&
    sed -i bak -e "s/define _POSIX_C_SOURCE 200112L/undef _POSIX_C_SOURCE/" pyconfig.h &&
    sed -i bak -e "s/define _XOPEN_SOURCE 600/undef _XOPEN_SOURCE/" pyconfig.h &&
    sed -i bak -e "s/define _XOPEN_SOURCE_EXTENDED 1/undef _XOPEN_SOURCE_EXTENDED/" pyconfig.h &&
    echo "#define   SETPGRP_HAVE_ARG 1" >> pyconfig.h &&
    cp pyconfig.h Include	
  else
    ./configure \
      --enable-ipv6 \
      --enable-unicode=ucs4 \
      --without-cxx \
      --enable-shared \
      --without-pymalloc \
      --prefix=`pwd`/../linux/python-lib CFLAGS=-fPIC &&
    sed -i -e "s/define HAVE_GETC_UNLOCKED 1/undef HAVE_GETC_UNLOCKED/" pyconfig.h &&
    sed -i -e "s/define _POSIX_C_SOURCE 200112L/undef _POSIX_C_SOURCE/" pyconfig.h &&
    sed -i -e "s/define _XOPEN_SOURCE 600/undef _XOPEN_SOURCE/" pyconfig.h &&
    cp pyconfig.h Include
  fi
], [$USE_EXTERNAL_PYTHON])

XB_CONFIG_MODULE([xbmc/cores/paplayer/FLACCodec/flac-1.2.1], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \    
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 -C \
      --with-pic \
      --disable-asm-optimizations \
      --disable-xmms-plugin \
      --disable-cpplibs \
      CC="$CC" \
      CXX="$CXX"
  else
    true
  fi
], [0])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/ffmpeg], [
  if test "$host_vendor" = "apple" ; then
    ./configure \
      --extra-cflags="-w -D_DARWIN_C_SOURCE -Dattribute_deprecated= -isysroot /Developer/SDKs/MacOSX10.4u.sdk" \
      --disable-amd3dnow \
      --disable-static \
      `if test "$use_debug" = "no"; then echo --disable-debug; fi` \
      --disable-muxers \
      --enable-muxer=spdif \
      --enable-muxer=adts \
      --disable-encoders \
      --enable-encoder=ac3 \
      --enable-encoder=aac \
      --disable-devices \
      --disable-ffplay \
      --disable-ffserver \
      --disable-ffmpeg \
      --enable-shared \
      --disable-decoder=mpeg_xvmc \
      --enable-postproc \
      --enable-gpl \
      --enable-protocol=http \
      --enable-pthreads \
      --enable-runtime-cpudetect \
      --cc="$CC" &&
    sed -i "" -e "s#define HAVE_POSIX_MEMALIGN 1#define HAVE_POSIX_MEMALIGN 0#" config.h &&
    sed -i "" -e "s#YASM=yasm#YASM=/opt/local/bin/yasm#" config.mak &&
    sed -i "" -e "s# -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 # #" config.mak &&
    sed -i "" -e "s#libswscale_VERSION_MAJOR=0#libswscale_VERSION_MAJOR=0.7.1#" config.mak &&
    sed -i "" -e "s#libavfilter_VERSION_MAJOR=0#libavfilter_VERSION_MAJOR=0.4.0#" config.mak

  else
    ./configure \
      --disable-static \
      `if test "$use_debug" = "no"; then echo --disable-debug; fi` \
      --disable-muxers \
      --enable-muxer=spdif \
      --enable-muxer=adts \
      --disable-encoders \
      --enable-encoder=ac3 \
      --enable-encoder=aac \
      --disable-decoder=mpeg_xvmc \
      --disable-devices \
      --disable-ffplay \
      --disable-ffserver \
      --disable-ffmpeg \
      --disable-vaapi \
      --enable-shared \
      --enable-postproc \
      --enable-gpl \
      `if test "$use_vdpau" = "yes"; then echo --enable-vdpau; else echo --disable-vdpau; fi` \
      --enable-libfaad \
      --enable-protocol=http \
      --enable-pthreads \
      `if test "$host_cpu" = "powerpc" || test "$host_cpu" = "powerpc64"; then echo --enable-pic; fi` \
      --cc="$CC"
  fi
], [$USE_EXTERNAL_FFMPEG])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libdts], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    LDFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure \
      --disable-oss \
      --disable-solaris-audio \
      --disable-al-audio \
      --disable-win
  else
    ./configure \
      --disable-oss \
      --disable-solaris-audio \
      --disable-al-audio \
      --disable-win \
      CFLAGS="-fPIC"
  fi
], [$USE_EXTERNAL_LIBDTS])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libdvd/libdvdcss], [
  if test "$host_vendor" = "apple" ; then
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
    CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
      --disable-doc \
      --enable-static \
      --with-pic
  else
    ./configure \
      --disable-doc \
      --enable-static \
      --with-pic
  fi
], [$SKIP_CONFIG_DVDCSS])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libdvd/libdvdread], [
  if test "$host_vendor" = "apple" ; then
    ./configure2 MACOSX_DEPLOYMENT_TARGET=10.4 \
      --extra-cflags="$DVDREAD_CFLAGS -D__DARWIN__ -fPIC -DPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -I`pwd`/../libdvdcss/src" \
      --enable-static \
      --disable-shared \
      --cc="$CC" &&
    make dvdread-config &&
    mkdir -p `pwd`/../includes/dvdread
    cp `pwd`/../libdvdread/src/*.h `pwd`/../includes/dvdread
  else
    ./configure2 \
      --extra-cflags="$CFLAGS $DVDREAD_CFLAGS -fPIC -DPIC -I`pwd`/../libdvdcss/src" \
      --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
      --enable-static \
      --disable-shared \
      --disable-strip \
      --disable-opts \
      --cc="$CC" &&
    make dvdread-config &&
    mkdir -p `pwd`/../includes/dvdread
    cp `pwd`/../libdvdread/src/*.h `pwd`/../includes/dvdread
  fi

], [0])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libdvd/libdvdnav], [
  if test "$host_vendor" = "apple" ; then
    ./configure2 MACOSX_DEPLOYMENT_TARGET=10.4 \
      --extra-cflags="$DVDREAD_CFLAGS -fPIC -DPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -I`pwd`/../includes" \
      --extra-ldflags="-L`pwd`/../libdvdread/obj" \
      --with-dvdread-config="`pwd`/../libdvdread/obj/dvdread-config" \
      --enable-static \
      --disable-shared \
      --cc="$CC"
  else
    ./configure2 \
      --extra-cflags="$DVDREAD_CFLAGS -fPIC -DPIC -I`pwd`/../includes" \
      --extra-ldflags="-L`pwd`/../libdvdread/obj" \
      --with-dvdread-config="`pwd`/../libdvdread/obj/dvdread-config" \
      --enable-static \
      --disable-shared \
      --cc="$CC"
  fi
], [0])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libfaad2], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-O3 -fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
      --with-pic
  else
    true
  fi
], [0])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/liba52], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
      --with-pic \
      --disable-static \
      --enable-shared \
      --disable-oss \
      --disable-solaris-audio \
      --disable-win \
      --disable-al-audio
  else
    ./configure \
      --with-pic \
      --disable-static \
      --enable-shared \
      --disable-oss \
      --disable-solaris-audio \
      --disable-win \
      --disable-al-audio \
      CFLAGS=-fPIC
  fi
], [$USE_EXTERNAL_LIBA52])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libmad], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
      --with-pic
  else
    true
  fi
], 0)

XB_CONFIG_MODULE([xbmc/lib/cximage-6.0/zlib], [
  if test "$host_vendor" = "apple" ; then
    export MACOSX_DEPLOYMENT_TARGET=10.4
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure
  fi
], [0])

XB_CONFIG_MODULE([xbmc/lib/libass], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-fPIC -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4
  else
    CFLAGS="$CFLAGS -fPIC" \
    ./configure
  fi
], [$USE_EXTERNAL_LIBASS])

XB_CONFIG_MODULE([xbmc/lib/libid3tag/libid3tag],[
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -fno-common" \
    CPPFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -fno-common" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 \
      --disable-static \
      --disable-debugging \
      --with-pic
  else
    ./configure \
      CPPFLAGS="$CPPFLAGS" \
      CFLAGS="$CFLAGS -fPIC" \ 
      CXXFLAGS="$CXXFLAGS -fPIC" \
      --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
      --disable-static \
      --with-pic
  fi
], [0])

XB_CONFIG_MODULE([xbmc/visualizations/XBMCProjectM/libprojectM],[
  if test "$host_vendor" = "apple" ; then
    rm -f CMakeCache.txt && CC="" CXX=""  cmake -D CMAKE_C_FLAGS:STRING="-fno-common" -D CMAKE_CXX_FLAGS:STRING="-fno-common" -D CMAKE_BUILD_TYPE:STRING=RelWithDebInfo -D USE_FTGL:BOOL=OFF .
  else
set -x
    rm -f CMakeCache.txt && cmake -DCMAKE_BUILD_TYPE=None -DUSE_FTGL:BOOL=OFF \
      -DCMAKE_C_FLAGS="${CFLAGS}" -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
      -DCMAKE_INSTALL_PREFIX="${prefix}" -DCMAKE_INSTALL_LIBDIR:PATH="${libdir}" \
      -DINCLUDE_INSTALL_DIR:PATH="${includedir}" -DLIB_INSTALL_DIR:PATH="${libdir}" \
      -DSYSCONF_INSTALL_DIR:PATH="${sysconfdir}" -DSHARE_INSTALL_PREFIX:PATH="${datadir}" .
set +x
  fi
], [0])

XB_CONFIG_MODULE([xbmc/visualizations/Goom/goom2k4-0],[
  if test "$host_vendor" != "apple" ; then
    ./configure  \
        CPPFLAGS="$CPPFLAGS" \
        CFLAGS="$CFLAGS -fPIC" \ 
        CXXFLAGS="$CXXFLAGS -fPIC" \
      --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
      --disable-shared \
      --enable-static \
      --with-pic
  fi
], [$BUILD_GOOM])

XB_CONFIG_MODULE([xbmc/screensavers/rsxs-0.9/], [
  if test "$host_vendor" = "apple" ; then
    ./configure \
      CFLAGS="-fPIC -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
      CXXFLAGS="-fPIC -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" \
      LDFLAGS="-L/opt/local/lib" \
      LIBS="-lz" \
      --x-includes=/usr/X11/include --x-libraries=/usr/X11/lib \
      --without-xscreensaver \
      --disable-sound \
      --disable-cyclone \
      --disable-fieldlines \
      --disable-flocks \
      --disable-flux \
      --disable-helios \
      --disable-hyperspace \
      --disable-lattice \
      --disable-skyrocket
  else
    ./configure \
      CPPFLAGS="$CPPFLAGS" \
      CFLAGS="$CFLAGS -fPIC" \ 
      CXXFLAGS="$CXXFLAGS -fPIC" \
      --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
      --without-xscreensaver \
      --disable-sound \
      --disable-cyclone \
      --disable-fieldlines \
      --disable-flocks \
      --disable-flux \
      --disable-helios \
      --disable-hyperspace \
      --disable-lattice \
      --disable-skyrocket
  fi
], [0])

XB_CONFIG_MODULE([xbmc/cores/dvdplayer/Codecs/libbdnav/], [
  if test "$host_vendor" = "apple" ; then
	./configure --with-ssl-dir=/opt/local/include
  else
	./configure --without-openssl
  fi
], [0])

XB_CONFIG_MODULE([xbmc/lib/libapetag], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -fno-common" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 --disable-shared
  else
    ./configure
  fi
], [0])

XB_CONFIG_MODULE([lib/libmodplug], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -fno-common" \
    CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -fno-common" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 --with-pic --disable-shared --enable-static
  else
    true
  fi
], [0])

XB_CONFIG_MODULE([lib/libmicrohttpd], [
  if test "$host_vendor" = "apple" ; then
    CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -fno-common" \
    CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -fno-common" \
    ./configure MACOSX_DEPLOYMENT_TARGET=10.4 --with-pic --disable-shared --enable-static
  else
    true
  fi
], [0])

AC_OUTPUT

final_message="$final_message\n  prefix:\t$prefix\n$dashes"
echo -e "$final_message\n"