dnl Process this file with autoconf to produce a configure script.

# get rid of that stupid cache mechanism
rm -f config.cache

AC_INIT(configure.in)
AM_INIT_AUTOMAKE(ecdb, 0.0.1)
AM_CONFIG_HEADER(src/config.h)

AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AM_PROG_CC_C_O
AC_HEADER_STDC
AC_C_CONST
AM_ENABLE_SHARED
AM_PROG_LIBTOOL

AM_WITH_DMALLOC

dnl Add the languages which your application supports here.
ALL_LINGUAS=""

dnl Set PACKAGE_LOCALE_DIR in config.h.
if test "x${prefix}" = "xNONE"; then
  AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${ac_default_prefix}/${DATADIRNAME}/locale", [Locale-specific data directory])
else
  AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${prefix}/${DATADIRNAME}/locale", [Locale-specific data directory])
fi

dnl Set PACKAGE_DATA_DIR in config.h.
if test "x${prefix}" = "xNONE"; then
  AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${ac_default_prefix}/share/${PACKAGE}", [PACKAGE_DATA_DIR])
else
  AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${prefix}/share/${PACKAGE}", [PACKAGE_DATA_DIR])
fi

dnl Set PACKAGE_BIN_DIR in config.h.
if test "x${datadir}" = 'x${prefix}/bin'; then
  if test "x${prefix}" = "xNONE"; then
    AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${ac_default_prefix}/bin", [Installation directory for user executables])
  else
    AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${prefix}/bin", [Installation directory for user executables])
  fi
else
  AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${bindir}", [Installation directory for user executables])
fi

dnl Set PACKAGE_LIB_DIR in config.h.
if test "x${datadir}" = 'x${prefix}/lib'; then
  if test "x${prefix}" = "xNONE"; then
    AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${ac_default_prefix}/lib", [Installation directory for libraries])
  else
    AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${prefix}/lib", [Installation directory for libraries])
  fi
else
  AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${libdir}", [Installation directory for libraries])
fi

dnl Set PACKAGE_SOURCE_DIR in config.h.
packagesrcdir=`cd $srcdir && pwd`
AC_DEFINE_UNQUOTED(PACKAGE_SOURCE_DIR, "${packagesrcdir}", [Source code directory])

dnl Use -Wall if we have gcc.
changequote(,)dnl
if test "x$GCC" = "xyes"; then
  case " $CFLAGS " in
  *[\ \	]-Wall[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wall" ;;
  esac
fi
changequote([,])dnl

LIBBURN_REQUIRED=0.4.2
LIBISOFS_REQUIRED=0.6.10
GST_MAJORMINOR=0.10
GST_REQS=0.10.2
GSTPLUG_REQS=0.10.1

PKG_CHECK_MODULES(GSTREAMER, [
  gstreamer-$GST_MAJORMINOR >= $GST_REQS
  gstreamer-plugins-base-$GST_MAJORMINOR >= $GSTPLUG_REQS],
  [
   have_gstreamer="yes"
   AC_DEFINE(BUILD_GSTREAMER_SUPPORT, 1, [Enable Gstreamer Support for Ecdb])
  ],
  [have_gstreamer="false"])

AM_CONDITIONAL(GSTREAMER_BUILD_SUPPORT, test "x$have_gstreamer" = "xyes")

dnl Make gstreamer an optional dependancy at some point
PKG_CHECK_MODULES(ECDB, [
  ecore-file
  ecore-evas
  ecore
  eina-0
  evas
  ewl
  edje
  efreet-mime
  efreet
  libburn-1 >= $LIBBURN_REQUIRED
  libisofs-1 >= $LIBISOFS_REQUIRED
])

AC_OUTPUT([
Makefile 
src/Makefile
tools/Makefile
tools/ecdb_transcode_helper/Makefile
data/Makefile
data/themes/Makefile
data/themes/default/Makefile
data/themes/default/groups/Makefile
])

echo
echo "ECDB"
echo
echo "Optional Components:"
echo "Gstreamer Support............................: $have_gstreamer"
echo

