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(e_utils, 0.0.1)
AM_CONFIG_HEADER(config.h)

AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AC_HEADER_STDC
AC_C_CONST
AM_ENABLE_SHARED
AM_PROG_LIBTOOL
AC_C___ATTRIBUTE__

if test "x${bindir}" = 'x${exec_prefix}/bin'; then
  if test "x${exec_prefix}" = "xNONE"; then
    if test "x${prefix}" = "xNONE"; then
      bindir="${ac_default_prefix}/bin";
    else
      bindir="${prefix}/bin";
    fi
  else
    if test "x${prefix}" = "xNONE"; then
      bindir="${ac_default_prefix}/bin";
    else
      bindir="${prefix}/bin";
    fi
  fi
fi

if test "x${libdir}" = 'x${exec_prefix}/lib'; then
  if test "x${exec_prefix}" = "xNONE"; then
    if test "x${prefix}" = "xNONE"; then
      libdir="${ac_default_prefix}/lib";
    else
      libdir="${prefix}/lib";
    fi
  else
    if test "x${prefix}" = "xNONE"; then
      libdir="${ac_default_prefix}/lib";
    else
      libdir="${prefix}/lib";
    fi
  fi
fi

dnl Set PACKAGE_BIN_DIR in config.h.
if test "x${bindir}" = 'xNONE'; then
  if test "x${prefix}" = "xNONE"; then
    AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${ac_default_prefix}/bin", "Package installed binaries destination")
  else
    AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${prefix}/bin", "Package installed binaries destination")
  fi
else
  AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${bindir}", "Package installed binaries destination")
fi

dnl Set PACKAGE_LIB_DIR in config.h.
if test "x${libdir}" = 'xNONE'; then
  if test "x${prefix}" = "xNONE"; then
    AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${ac_default_prefix}/lib", "Package installed libraries destination")
  else
    AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${prefix}/lib", "Package installed libraries destination")
  fi
else
  AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${libdir}", "Package installed libraries destination")
fi

dnl Set PACKAGE_DATA_DIR in config.h.
if test "x${datadir}" = 'x${prefix}/share'; then
  if test "x${prefix}" = "xNONE"; then
    AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${ac_default_prefix}/share/${PACKAGE}", "Package installed data destination")
  else
    AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${prefix}/share/${PACKAGE}", "Package installed data destination")
  fi
else
  AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${datadir}/${PACKAGE}", "Package installed data destination")
fi
	  
#AC_CHECK_LIB(dl, dlopen, dlopen_libs=-ldl)
#AC_SUBST(dlopen_libs)

AC_PATH_GENERIC(evas, 0.9.9,
  [have_evas="yes"],
  [have_evas="no"]
)

AC_PATH_GENERIC(ecore, 0.9.9,
  [have_ecore="yes"],
  [have_ecore="no"]
)

AC_PATH_GENERIC(esmart, 0.9.0,
  [have_esmart="yes"],
  [have_esmart="no"]
)

AC_PATH_GENERIC(edje, 0.5.0,
  [have_edje="yes"],
  [have_edje="no"]
)

AC_PATH_GENERIC(eet, 0.9.10,
  [have_eet="yes"],
  [have_eet="no"]
)

AC_PATH_GENERIC(ewl, 0.0.4,
  [have_ewl="yes"],
  [have_ewl="no"]
)

AC_PATH_GENERIC(engrave, 0.1.0,
  [have_engrave="yes"],
  [have_engrave="no"]
)

AC_PATH_GENERIC(imlib2, 1.0.0,
  [have_imlib2="yes"],
  [have_imlib2="no"]
)

AC_PATH_GENERIC(enlightenment, 0.16.999,
  [have_enlightenment="yes"],
  [have_enlightenment="no"]
)

e_config_apps_dir=`$ENLIGHTENMENT_CONFIG --config-apps-dir`
AC_SUBST(e_config_apps_dir)
	
AC_PATH_GENERIC(epsilon, 0.3.0,
  [have_epsilon="yes"],
  [have_epsilon="no"]
)

build_e17genmenu="no"
build_eapp_edit="no"
build_e17setroot="no"
build_entangle="no"
build_emblem="no"
build_exige="no"
build_ethemes="no"

if test "x$have_ewl" = "xyes" -a "x$have_engrave" = "xyes"; then
  build_eapp_edit="yes"
fi

if test "x$have_eet" = "xyes" -a "x$have_ecore" = "xyes" -a "x$have_engrave" = "xyes"; then
  build_e17genmenu="yes"
fi

if test "x$have_imlib2" = "xyes" -a "x$have_ecore" = "xyes" -a "x$have_engrave" = "xyes" -a "x$have_enlightenment" = "xyes"; then
  build_e17setroot="yes"
fi

if test "x$have_eet" = "xyes" -a "x$have_evas" = "xyes" -a "x$have_ecore" = "xyes" -a "x$have_edje" = "xyes" -a "x$have_esmart" = "xyes" -a "x$have_enlightenment" = "xyes"; then
  build_entangle="yes"
fi

if test "x$have_evas" = "xyes" -a "x$have_ecore" = "xyes" -a "x$have_edje" = "xyes" -a "x$have_esmart" = "xyes" -a "x$have_epsilon" = "xyes" -a "x$have_enlightenment" = "xyes"; then
  build_emblem="yes"
fi

if test "x$have_eet" = "xyes" -a "x$have_evas" = "xyes" -a "x$have_ecore" = "xyes" -a "x$have_edje" = "xyes" -a "x$have_esmart" = "xyes"; then
  build_exige="yes"
fi

if test "x$have_evas" = "xyes" -a "x$have_ecore" = "xyes" -a "x$have_edje" = "xyes" -a "x$have_esmart" = "xyes" -a "x$have_enlightenment" = "xyes"; then
  build_ethemes="yes"
fi

AM_CONDITIONAL(BUILD_E17GENMENU, test "x$build_e17genmenu" = "xyes")
AM_CONDITIONAL(BUILD_EAPP_EDIT, test "x$build_eapp_edit" = "xyes")
AM_CONDITIONAL(BUILD_E17SETROOT, test "x$build_e17setroot" = "xyes")
AM_CONDITIONAL(BUILD_ENTANGLE, test "x$build_entangle" = "xyes")
AM_CONDITIONAL(BUILD_EMBLEM, test "x$build_emblem" = "xyes")
AM_CONDITIONAL(BUILD_EXIGE, test "x$build_exige" = "xyes")
AM_CONDITIONAL(BUILD_ETHEMES, test "x$build_ethemes" = "xyes")


AC_MSG_CHECKING(debug code support)
AC_ARG_ENABLE(debug, 
[  --enable-debug              enable debug code], [
  want_debug=$enableval
], [
  want_debug="no"
])
AC_MSG_RESULT($want_debug)
if test "x$want_debug" = "xyes"; then
   AC_DEFINE(DEBUG, 1, [Define to 1 to enable debug code])
fi
AM_CONDITIONAL(DEBUG, test "x$want_debug" = "xyes")


AC_OUTPUT([
Makefile
e_utils.spec
data/Makefile
data/e17genmenu/Makefile
data/e17genmenu/icons/Makefile
data/emblem/Makefile
data/emblem/default/Makefile
data/emblem/gant/Makefile
data/entangle/Makefile
data/entangle/default/Makefile
data/exige/Makefile
data/exige/default/Makefile
data/eapp_edit/Makefile
data/eapp_edit/default/Makefile
src/Makefile
src/bin/Makefile
src/bin/e17genmenu/Makefile
src/bin/eapp_edit/Makefile
src/bin/e17setroot/Makefile
src/bin/emblem/Makefile
src/bin/entangle/Makefile
src/bin/exige/Makefile
src/bin/ethemes/Makefile
debian/changelog
],[
])

#####################################################################
## Info

echo
echo
echo
echo "------------------------------------------------------------------------"
echo "$PACKAGE $VERSION"
echo "------------------------------------------------------------------------"
echo
echo "Configuration Options Summary:"
echo
echo "  Imlib2..........: "$have_imlib2
echo "  eet.............: "$have_eet
echo "  Evas............: "$have_evas
echo "  Ecore...........: "$have_ecore
echo "  Edje............: "$have_edje
echo "  Esmart..........: "$have_esmart
echo "  Engrave.........: "$have_engrave
echo "  Epsilon.........: "$have_epsilon
echo "  Ewl.............: "$have_ewl
echo "  Enlightenment...: "$have_enlightenment
echo
echo "Utilities that will be built:"
echo
echo "  e17genmenu......: "$build_e17genmenu
echo "  Eapp_Edit.......: "$build_eapp_edit
echo "  E17 Setroot.....: "$build_e17setroot
echo "  Entangle........: "$build_entangle
echo "  Emblem..........: "$build_emblem
echo "  Exige...........: "$build_exige
echo "  Ethemes.........: "$build_ethemes
echo
echo "Compilation..........: make"
echo
echo "Installation.........: make install"
echo
echo "  prefix.........: $prefix"
echo "  binaries.......: $bindir"
echo
