#MIN_CONFIG(3.3)
AC_HAVE_GL
KDE_INIT_DOXYGEN
AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
        AC_TRY_COMPILE([
                #include <time.h>
        ], [
                struct tm tm;
                tm.tm_gmtoff = 1;
        ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
if test $ac_cv_struct_tm_gmtoff = yes; then
        AC_DEFINE(HAVE_TM_GMTOFF, 1, [Define if you have a tm_gmtoff member in struct tm])
fi

KDE_CHECK_HEADERS(knotifydialog.h)

KOPETE_INCLUDES='-I$(top_srcdir)/kopete/libkopete -I$(top_builddir)/kopete/libkopete -I$(top_srcdir)/kopete/libkopete/avdevice -I$(top_srcdir)/kopete/libkopete/ui -I$(top_builddir)/kopete/libkopete/ui'

AC_MSG_CHECKING([for tdelibs newer than 3.3.x])
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
kcompat_save_CXXFLAGS="$CXXFLAGS"
kcompat_safe_LIBS="$LIBS"
LIBS="$LIBS $X_EXTRA_LIBS"
CXXFLAGS="$CXXFLAGS $all_includes"

AC_TRY_COMPILE([
#include <tdeversion.h>
#if !( KDE_IS_VERSION( 3, 3, 90 ) )
#error Kopete compatibility with KDE 3.3 needs to be enabled
#endif
],
[
],
	AC_MSG_RESULT(yes)
,
	KOPETE_COMPAT_INCLUDES='-I$(top_srcdir)/kopete/libkopete/compat'
	KOPETE_INCLUDES=$KOPETE_INCLUDES' $(KOPETE_COMPAT_INCLUDES)'
	LIB_KOPETECOMPAT='$(top_builddir)/kopete/libkopete/libkopete.la'
	AC_MSG_RESULT(no)
)
CXXFLAGS="$kcompat_save_CXXFLAGS"
LIBS="$kcompat_safe_LIBS"
AC_LANG_RESTORE
AM_CONDITIONAL(compile_LIBKOPETE_COMPAT, test -n "$LIB_KOPETECOMPAT")


AC_ARG_ENABLE(smpppd,
[AC_HELP_STRING([--enable-smpppd], [enable support for the SuSE Meta PPP Daemon (smpppd) (default is NO)])],
[
  if test $enableval = yes; then
    AC_DEFINE(USE_SMPPPD, 1, [enable support for the smpppd])
    COMPILESMPPPDCS=true
  else
    COMPILESMPPPDCS=
  fi
],
[ COMPILESMPPPDCS=
])
AM_CONDITIONAL(include_smpppdcs, test -n "$COMPILESMPPPDCS")

KDE_FIND_PATH(xml2-config, XML_CONFIG, [${exec_prefix}/bin ${prefix}/bin], [
  AC_MSG_WARN([libxml2 not found anywhere, check ftp://xmlsoft.org/ for libxml >= 2.4.8. ])
])

if test -n "$XML_CONFIG"; then
  vers=`$XML_CONFIG --version 2>/dev/null | sed -e 's/libxml //' | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
  if test -n "$vers" && test "$vers" -ge 2004008
  then
     LIBXML_LIBS="`$XML_CONFIG --libs`"
     LIBXML_RPATH=
     for args in $LIBXML_LIBS; do
	  case $args in
	    -L*)
	       LIBXML_RPATH="$LIBXML_RPATH $args"
	       ;;
          esac
     done
     LIBXML_RPATH=`echo $LIBXML_RPATH | sed -e "s/-L/-R/g"`
     LIBXML_CFLAGS="`$XML_CONFIG --cflags`"

     KDE_FIND_PATH(xmllint, XMLLINT, [${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin /usr/bin], [XMLLINT=""])
     AC_DEFINE_UNQUOTED(XMLLINT, "$XMLLINT", [Defines the executable of xmllint])
  else
     AC_MSG_WARN([You need at least libxml 2.4.8])
     DO_NOT_COMPILE="$DO_NOT_COMPILE kopete"
  fi
fi


  KDE_FIND_PATH(xslt-config, XSLT_CONFIG, [${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin /usr/bin], [
    AC_MSG_WARN([Could not find libxslt anywhere, check ftp://xmlsoft.org/ for libxslt >= 1.0.7.])
  ])

  if test -n "$XSLT_CONFIG"; then
     vers=`$XSLT_CONFIG --version 2>/dev/null | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
     if test -n "$vers" && test "$vers" -ge 1000007; then
       LIBXSLT_LIBS="`$XSLT_CONFIG --libs`"
       LIBXSLT_RPATH=
       for args in $LIBXSLT_LIBS; do
	  case $args in
	    -L*)
  	       LIBXSLT_RPATH="$LIBXSLT_RPATH $args"
 	       ;;
          esac
       done
       LIBXSLT_RPATH=`echo $LIBXSLT_RPATH | sed -e "s/-L/-R/g"`
       LIBXSLT_CFLAGS="`$XSLT_CONFIG --cflags`"
	   AC_DEFINE(HAVE_XSLT, 1, [Define if you have xslt libraries and header files])
     else
       AC_WARN([You need at least libxslt 1.0.7])
     fi
  fi

if test ! "$USE_RPATH" = "yes"; then
  LIBXSLT_RPATH=
  LIBXML_RPATH=
fi

if test -z "$XML_CONFIG"; then
  DO_NOT_COMPILE="$DO_NOT_COMPILE kopete"
fi

if test -z "$XSLT_CONFIG"; then
  DO_NOT_COMPILE="$DO_NOT_COMPILE kopete"
fi
AC_SUBST(LIBXSLT_LIBS)
AC_SUBST(LIBXSLT_CFLAGS)
AC_SUBST(LIBXSLT_RPATH)

AC_SUBST(LIBXML_LIBS)
AC_SUBST(LIBXML_CFLAGS)
AC_SUBST(LIBXML_RPATH)

AC_SUBST(KOPETE_INCLUDES)
AC_SUBST(KOPETE_COMPAT_INCLUDES)
AC_SUBST(LIB_KOPETECOMPAT)


KDE_CHECK_HEADERS(
	[libv4l1-videodev.h],
	[videodev_header="libv4l1-videodev.h"],
	[
	    KDE_CHECK_HEADERS([linux/videodev.h],
	     [videodev_header="linux/videodev.h"],
	     [videodev_header="no"])
	])
if test ! x$videodev_header = xno; then
    AC_DEFINE_UNQUOTED(VIDEODEV_HEADER, ["$videodev_header"], [Define header name for videodev])
fi

# -- Check for installed Valgrind headers --------------------

AC_MSG_CHECKING([for valgrind.h])

AC_TRY_COMPILE([
#define __VALGRIND_SOMESKIN_H
#include <valgrind/valgrind.h>
],
[
],
	ac_have_valgrind_h=yes
,
	ac_have_valgrind_h=no
)

if test $ac_have_valgrind_h = yes; then
	AC_DEFINE(HAVE_VALGRIND_H, 1, [Define if you have valgrind.h installed])
fi

AC_MSG_RESULT($ac_have_valgrind_h)

# -- End valgrind ----------------------------------------------

# -- Determine pointer size for sqlite -------------------------

KDE_CHECK_TYPES
AC_DEFINE(SQLITE_PTR_SZ, SIZEOF_CHAR_P, [Determine pointer size for SQLite])

# -- End sqlite ------------------------------------------------
