dnl
dnl Check location of Qt documentation
dnl
AC_DEFUN([KDEV_PATH_QTDOC],
[
AC_MSG_CHECKING([for Qt documentation])

ac_qt_docdirs=""
AC_ARG_WITH(qtdoc_dir,
[  --with-qtdoc-dir=DIR    where the Qt documentation is installed ],
ac_qt_docdirs=""
qt_docdirs=""
[
  ac_qt_docdirs=$withval
],
)

dnl
dnl not currently used
dnl
qt_docdirs="/usr/doc/qt-doc/html /usr/local/qt/html /usr/local/lib/qt/html /usr/lib/qt/doc/html /usr/X11/lib/qt/html /usr/X11/lib/qt/doc/html /usr/X11R6/share/doc/qt/html /usr/share/doc/packages/qt/html"
test -n "$QTDIR" && qt_docdirs="$QTDIR/html $QTDIR/doc/html $QTDIR/doc $qt_docdirs"
qt_docdirs="$ac_qt_docdirs $qt_docdirs"
AC_FIND_FILE(classes.html, $qt_docdirs, qt_docdir)
AC_MSG_RESULT($qt_docdir)
if test "$qt_docdir" = NO; then
  qt_docdir=""
fi
AC_DEFINE_UNQUOTED(QT_DOCDIR, "$qt_docdir", [Where the Qt documentation is installed])
])


dnl
dnl Check location of kdelibs documentation generated by Doxygen
dnl
AC_DEFUN([KDEV_PATH_KDELIBSDOXY],
[
AC_MSG_CHECKING([for kdelibs documentation generated by Doxygen])

ac_kdelibs_doxydirs=""
AC_ARG_WITH(kdelibsdoxy_dir,
[  --with-kdelibsdoxy-dir=DIR         where the kdelibs documentation is installed ],
ac_kdelibs_doxydirs=""
kdelibs_doxydirs=""
[
  ac_kdelibs_doxydirs=$withval
],
)

if test "${prefix}" = NONE; then
  ac_kde_htmldir="$ac_default_prefix"/share/doc/HTML
else
  ac_kde_htmldir="$prefix"/share/doc/HTML
fi

kdelibs_doxydirs="$ac_kdelibs_doxydirs $ac_kde_htmldir/default/kdelibs-apidocs $ac_kde_htmldir/en/kdelibs-apidocs"
AC_FIND_FILE(kdecore/html/classKApplication.html, $kdelibs_doxydirs, kdelibs_doxydir)
AC_MSG_RESULT($kdelibs_doxydir)
if test "$kdelibs_doxydir" = NO; then
  kdelibs_doxydir=""
fi
AC_DEFINE_UNQUOTED(KDELIBS_DOXYDIR, "$kdelibs_doxydir", [where KDE documentation is installed])
])
AC_SUBST(kdelibs_doxydir)


dnl
dnl Check location of kdelibs documentation
dnl
AC_DEFUN([KDEV_PATH_KDELIBSDOC],
[
AC_MSG_CHECKING([for kdelibs documentation])

ac_kdelibs_docdirs=""
AC_ARG_WITH(kdelibsdoc_dir,
[  --with-kdelibsdoc-dir=DIR         where the kdelibs documentation is installed ],
ac_kdelibs_docdirs=""
kdelibs_docdirs=""
[
  ac_kdelibs_docdirs=$withval
],
)

if test "${prefix}" = NONE; then
  ac_kde_htmldir="$ac_default_prefix"/share/doc/HTML
else
  ac_kde_htmldir="$prefix"/share/doc/HTML
fi

kdelibs_docdirs="/usr/doc/kdelibs-doc/html"
if test "$ac_kde_htmldir" != ""; then
 kdelibs_docdirs="$kdelibs_docdirs $ac_kde_htmldir/default/kdelibs $ac_kde_htmldir/en/kdelibs"
fi
kdelibs_docdirs="$ac_kdelibs_docdirs $kdelibs_docdirs"
AC_FIND_FILE(kdecore/index.html, $kdelibs_docdirs, kdelibs_docdir)
AC_MSG_RESULT($kdelibs_docdir)
if test "$kdelibs_docdir" = NO; then
  kdelibs_docdir=""
fi
AC_DEFINE_UNQUOTED(KDELIBS_DOCDIR, "$kdelibs_docdir", [where KDE documentation is installed])
])


dnl
dnl Check whether we support Debian docbase
dnl
AC_DEFUN([KDEV_CHECK_DOCBASE],
[
AC_MSG_CHECKING(for docbase)
AC_ARG_ENABLE(docbase,
[  --enable-docbase        enable Debian docbase support],
[if test "$enableval" = yes; then
  enable_docbase=yes
fi],
enable_docbase=no)
AC_MSG_RESULT($enable_docbase)

if test "$enable_docbase" = "yes"; then
  AC_DEFINE_UNQUOTED(WITH_DOCBASE, 1, [If Debian docbase should be supported])
fi
])


dnl
dnl Check whether we support Python scripting
dnl
AC_DEFUN([KDEV_CHECK_SCRIPTING],
[
AC_MSG_CHECKING(if scripting enabled)
AC_ARG_ENABLE(scripting,
[  --enable-scripting      enable python scripting support],
[if test "$enableval" = yes; then
  enable_scripting=yes
fi],
enable_scripting=no)
AC_MSG_RESULT($enable_scripting)

SCRIPTING=
if test "$enable_scripting" = "yes"; then
  KDE_CHECK_PYTHON(1.5, [
	AC_MSG_ERROR([You enabled scripting but have no python installed.])
  ])
  SCRIPTING=scripting
fi
  AC_SUBST(SCRIPTING)
  AM_CONDITIONAL(include_scripting, test -n "$SCRIPTING")
])


dnl
dnl Check for Python documentation dir
dnl
AC_DEFUN([KDEV_PATH_PYTHONDOCDIR],
[
AC_MSG_CHECKING(for Python documentation directory)
AC_ARG_WITH(pythondocdir,
  [  --with-pythondocdir=pythondocdir    where the Python documentation is installed ],
  kdev_pythondocdir=$withval,
  kdev_pythondocdir=/usr/local/python2.0/html
)

AC_CACHE_VAL(kdev_cv_pythondocdir,
[
  pythondocdirs="/usr/share/doc/packages/python/html /usr/share/doc/python-docs-2.0 /usr/share/doc/python/html $kdev_pythondocdir"
  AC_FIND_FILE(ref/comparisons.html, $pythondocdirs, kdev_cv_pythondocdir)
])

AC_MSG_RESULT($kdev_cv_pythondocdir)
PYTHONDOCDIR=$kdev_cv_pythondocdir
AC_SUBST(PYTHONDOCDIR)
])


dnl
dnl Check for Python documentation dir
dnl
AC_DEFUN([KDEV_PATH_PHPDOCDIR],
[
AC_MSG_CHECKING(for PHP documentation directory)
AC_ARG_WITH(phpdocdir,
  [  --with-phpdocdir=phpdocdir          where the PHP documentation is installed ],
  kdev_phpdocdir=$withval,
  kdev_phpdocdir=/usr/local/php/doc/manual
)

AC_CACHE_VAL(kdev_cv_phpdocdir,
[
  phpdocdirs="/usr/share/doc/packages/phpdoc/manual /usr/share/doc/php3-doc/html $kdev_phpdocdir"
  AC_FIND_FILE(ref.ftp.html, $phpdocdirs, kdev_cv_phpdocdir)
])

AC_MSG_RESULT($kdev_cv_phpdocdir)
PHPDOCDIR=$kdev_cv_phpdocdir
AC_SUBST(PHPDOCDIR)
])


dnl
dnl Check for GNUstep documentation
dnl
AC_DEFUN([KDEV_PATH_GNUSTEPDOCDIR],
[
AC_MSG_CHECKING([for GNUstep documentation])
if test -z ${GNUSTEP_SYSTEM_ROOT:-""} ; then
GNUSTEPDOCDIR=
AC_MSG_RESULT(not found)
else
GNUSTEPDOCDIR=$GNUSTEP_SYSTEM_ROOT/Documentation/Developer
AC_MSG_RESULT($GNUSTEPDOCDIR)
fi
AC_SUBST(GNUSTEPDOCDIR)
AM_CONDITIONAL(GNUSTEPDOCS, test x$GNUSTEPDOCDIR != x)
])


dnl
dnl Check for Gtk documentation dirs
dnl
AC_DEFUN([KDEV_PATH_GTKDOCDIR],
[
AC_ARG_WITH(glibdocdir,
  [  --with-glibdocdir=glibdocdir        where the glib documentation is installed ],
  kdev_glibdocdir=$withval,
  kdev_glibdocdir=""
)
AC_ARG_WITH(gdkdocdir,
  [  --with-gdkdocdir=gdkdocdir          where the gdk documentation is installed ],
  kdev_gdkdocdir=$withval,
  kdev_gdkdocdir=""
)
AC_ARG_WITH(gdkpbdocdir,
  [  --with-gdkpbdocdir=gdkpbdocdir      where the gdk-pixbuf documentation is installed ],
  kdev_gdkpbdocdir=$withval,
  kdev_gdkpbdocdir=""
)
AC_ARG_WITH(gtkdocdir,
  [  --with-gtkdocdir=gtkdocdir          where the gtk documentation is installed ],
  kdev_gtkdocdir=$withval,
  kdev_gtkdocdir=""
)
AC_ARG_WITH(gnomedocdir,
  [  --with-gnomedocdir=gnomedocdir      where the gnome documentation is installed ],
  kdev_gnomedocdir=$withval,
  kdev_gnomedocdir=""
)
AC_ARG_WITH(gnomeuidocdir,
  [  --with-gnomeuidocdir=gnomeuidocdir  where the gnomeui documentation is installed ],
  kdev_gnomeuidocdir=$withval,
  kdev_gnomeuidocdir=""
)

AC_MSG_CHECKING(for GLib documentation directory)
AC_CACHE_VAL(kdev_cv_glibdocdir,
[
  glibdocdirs="/usr/share/doc/packages/glib $kdev_glibdocdir"
  AC_FIND_FILE(glib-arrays.html, $glibdocdirs, kdev_cv_glibdocdir)
])
AC_MSG_RESULT($kdev_cv_glibdocdir)
AC_MSG_CHECKING(for Gdk documentation directory)
AC_CACHE_VAL(kdev_cv_gdkdocdir,
[
  gdkdocdirs="/usr/share/doc/packages/gdk $kdev_gdkdocdir"
  AC_FIND_FILE(gdk-events.html, $gdkdocdirs, kdev_cv_gdkdocdir)
])
AC_MSG_RESULT($kdev_cv_gdkdocdir)
AC_MSG_CHECKING(for Gdk-Pixbuf documentation directory)
AC_CACHE_VAL(kdev_cv_gdkpbdocdir,
[
  gdkpbdocdirs="/usr/share/doc/packages/gdk-pixbuf/html $kdev_gdkpbdocdir"
  AC_FIND_FILE(gdk-pixbuf-rendering.html, $gdkpbdocdirs, kdev_cv_gdkpbdocdir)
])
AC_MSG_RESULT($kdev_cv_gdkpbdocdir)
AC_MSG_CHECKING(for Gtk documentation directory)
AC_CACHE_VAL(kdev_cv_gtkdocdir,
[
  gtkdocdirs="/usr/share/doc/packages/gtk $kdev_gtkdocdir"
  AC_FIND_FILE(gtkcombo.html, $gtkdocdirs, kdev_cv_gtkdocdir)
])
AC_MSG_RESULT($kdev_cv_gtkdocdir)
AC_MSG_CHECKING(for libgnome documentation directory)
AC_CACHE_VAL(kdev_cv_gnomedocdir,
[
  gnomedocdirs="/usr/share/doc/packages/gnome-libs-devel/devel-docs/gnome/html $kdev_gnomedocdir"
  AC_FIND_FILE(libgnome.html, $gnomedocdirs, kdev_cv_gnomedocdir)
])
AC_MSG_RESULT($kdev_cv_gnomedocdir)
AC_MSG_CHECKING(for libgnomeui documentation directory)
AC_CACHE_VAL(kdev_cv_gnomeuidocdir,
[
  gnomeuidocdirs="/usr/share/doc/packages/gnome-libs-devel/devel-docs/gnomeui/html $kdev_gnomeuidocdir"
  AC_FIND_FILE(libgnomeui.html, $gnomeuidocdirs, kdev_cv_gnomeuidocdir)
])
AC_MSG_RESULT($kdev_cv_gnomeuidocdir)

dnl We need all directories or none

if test "$kdev_cv_glibdocdir" = NO; then
  kdev_cv_glib_docdir=""
fi
if test "$kdev_cv_gdkdocdir" = NO; then
  kdev_cv_glib_docdir=""
  kdev_cv_gdk_docdir=""
fi
if test "$kdev_cv_gdkpbdocdir" = NO; then
  kdev_cv_glib_docdir=""
  kdev_cv_gdkpb_docdir=""
fi
if test "$kdev_cv_gtkdocdir" = NO; then
  kdev_cv_glib_docdir=""
  kdev_cv_gtk_docdir=""
fi
if test "$kdev_cv_gnomedocdir" = NO; then
  kdev_cv_glib_docdir=""
  kdev_cv_gnome_docdir=""
fi
if test "$kdev_cv_gnomeuidocdir" = NO; then
  kdev_cv_glib_docdir=""
  kdev_cv_gnomeui_docdir=""
fi

GLIBDOCDIR=$kdev_cv_glibdocdir
AC_SUBST(GLIBDOCDIR)
GDKDOCDIR=$kdev_cv_gdkdocdir
AC_SUBST(GDKDOCDIR)
GDKPBDOCDIR=$kdev_cv_gdkpbdocdir
AC_SUBST(GDKPBDOCDIR)
GTKDOCDIR=$kdev_cv_gtkdocdir
AC_SUBST(GTKDOCDIR)
GNOMEDOCDIR=$kdev_cv_gnomedocdir
AC_SUBST(GNOMEDOCDIR)
GNOMEUIDOCDIR=$kdev_cv_gnomeuidocdir
AC_SUBST(GNOMEUIDOCDIR)
AM_CONDITIONAL(GTKDOCS, test x$kdev_cv_glibdocdir != x)
])


dnl
dnl Check whether we support Java
dnl
AC_DEFUN([KDEV_CHECK_JAVA],
[
AC_MSG_CHECKING(if javasupport enabled)
AC_ARG_ENABLE(javasupport,
[  --enable-javasupport    enable java support],
[if test "$enableval" = yes; then
  enable_javasupport=yes
fi],
enable_javasupport=no)
AC_MSG_RESULT($enable_javasupport)

JAVASUPPORT_SUBDIR=
if test "$enable_javasupport" = "yes"; then
  KDE_CHECK_JAVA_DIR
  if test "x$kde_cv_java_bindir" = xno; then
    AC_MSG_RESULT([not found -- parts/javasupport will NOT be built])
    JAVA_SUBDIRS=""
  else
    JAVA_SUBDIRS="javasupport javadebugger"
  fi
fi
AC_SUBST(JAVA_SUBDIRS)
])

dnl  **********
dnl  Simple Check for Berkeley DB >= 3
dnl  **********

AC_DEFUN([KDEV_CHECK_BDB],
[
  ac_db_includedir=""
  ac_db_libdir=""
  ac_db_lib="db"
  AC_ARG_WITH(db_includedir,
[  --with-db-includedir=DIR    
                          where the DB3 headers are installed ],
[
  ac_db_includedir="-I$withval"
],
  ac_db_includedir=""
)
  AC_ARG_WITH(db_libdir,
[  --with-db-libdir=DIR    where the DB3 libraries are installed ],
[
  ac_db_libdir="-L$withval"
],
  ac_db_libdir=""
)
  AC_ARG_WITH(db_lib,
[  --with-db-lib=LIB       library name for the DB3 library ],
[
  ac_db_lib=$withval
],
ac_db_lib=db
)

  AC_MSG_CHECKING(for Berkeley DB >= 3)

  AC_CACHE_VAL(ac_cv_bdb,
  [
    AC_LANG_SAVE
    AC_LANG_CPLUSPLUS

    save_CXXFLAGS="$CXXFLAGS"

    CXXFLAGS="$CXXFLAGS $ac_db_includedir $ac_db_libdir -l$ac_db_lib"

    AC_TRY_LINK([
      #include <db.h>
    ],
    [
      #if DB_VERSION_MAJOR < 3
         choke me
      #else
         DB *db;
         db->open( db, 0, NULL, DB_BTREE, DB_CREATE, 0644 );
      #endif
    ],
      ac_cv_bdb=yes_3or40,

      AC_TRY_LINK([
        #include <db.h>
      ],
      [
        #if DB_VERSION_MAJOR < 3
           choke me
        #else
           DB *db;
           db->open( db, 0, 0, NULL, DB_BTREE, DB_CREATE, 0644 );
        #endif
      ],
        ac_cv_bdb=yes_ge_41,
        ac_cv_bdb=no
      )

    )
    CXXFLAGS="$save_CXXFLAGS"
    AC_LANG_RESTORE
   ])

  if test "$ac_cv_bdb" = "no"; then
    AC_MSG_ERROR(no - please install Berkeley DB >= 3 and <= 4.1)
  else
    if test "$ac_cv_bdb" = "yes_3or40" ; then
      bdb_open_hack=""
      AC_MSG_RESULT([yes - <=4.0])
    else
      bdb_open_hack=",0"
      AC_MSG_RESULT([yes - >=4.1])
    fi
  fi

DB3LIB="$ac_db_lib"
DB3INCLUDES="$ac_db_includedir"
DB3LDFLAGS="$ac_db_libdir"
AC_SUBST(DB3LIB)
AC_SUBST(DB3INCLUDES)
AC_SUBST(DB3LDFLAGS)

  AC_DEFINE_UNQUOTED(BDB_OPEN_HACK, $bdb_open_hack, [account for Berkeley DB API different from v4.1 onwards])
])

dnl  **********
dnl  check whether we need the qextmdi lib
dnl  **********

AC_DEFUN([KDEV_CHECK_MDI],
[
  AC_MSG_CHECKING(whether to use kmdi lib from kdelibs)
  AC_CACHE_VAL(ac_cv_mdi_setup,
  [
    AC_LANG_SAVE
    AC_LANG_CPLUSPLUS
    save_CXXFLAGS=$CXXFLAGS
    CXXFLAGS="$CXXFLAGS -I$ac_qt_includes -I$ac_kde_includes"

    AC_TRY_COMPILE([
      #include <kdeversion.h>
    ],
    [
      #if !KDE_IS_VERSION(3,2,90)
         KDE_choke me
      #endif
    ],
      ac_cv_mdi_setup=yes,
      ac_cv_mdi_setup=no
    )
    CXXFLAGS="$save_CXXFLAGS"
    AC_LANG_RESTORE
   ])

  if test "$ac_cv_mdi_setup" = "yes"; then
    LIB_KDEVMDI="-lkmdi"
    QEXTMDIR=""
    KDEVMDI_INCLUDES=""
    AC_MSG_RESULT(yes)
  else
    LIB_KDEVMDI='$(top_builddir)/lib/qextmdi/libkdevelopqextmdi.la'
    QEXTMDIR="qextmdi"
    KDEVMDI_INCLUDES='-I$(top_srcdir)/lib/qextmdi'
    AC_MSG_RESULT(no)
  fi

  AC_SUBST(LIB_KDEVMDI)
  AC_SUBST(KDEVMDI_INCLUDES)
  AC_SUBST(QEXTMDIR)
  AM_CONDITIONAL(include_qextmdi, test -n "$QEXTMDIR")
])

dnl  **********
dnl  check whether we need the compat lib
dnl  **********

AC_DEFUN([KDEV_CHECK_COMPAT],
[
  AC_MSG_CHECKING(whether to build the compat lib)

  AC_CACHE_VAL(ac_cv_qt31_setup,
  [
    AC_LANG_SAVE
    AC_LANG_CPLUSPLUS

    save_CXXFLAGS="$CXXFLAGS"

    CXXFLAGS="$CXXFLAGS $QT_INCLUDES -I$ac_kde_includes"

    AC_TRY_COMPILE([
      #include <qglobal.h>
      #include <kdeversion.h>
    ],
    [
      #if QT_VERSION < 0x030100
         choke me
      #endif
      #if KDE_VERSION < 0x030100
         KDE_choke me
      #endif
    ],
      ac_cv_qt31_setup=yes,
      ac_cv_qt31_setup=no
    )
    CXXFLAGS="$save_CXXFLAGS"
    AC_LANG_RESTORE
  ])

  if test "$ac_cv_qt31_setup" = "yes"; then
    AC_MSG_RESULT(no)
  else
    AC_MSG_RESULT(yes)
    COMPAT=compat
  fi
AC_SUBST(COMPAT)
AM_CONDITIONAL(include_compat, test -n "$COMPAT")
])


dnl  **********
dnl  check whether we have necessary svn libraries to compile vcs compat lib
dnl  **********

AC_DEFUN([KDEV_CHECK_SVN],
[
    AC_MSG_CHECKING(for svn libraries)

    APR_CONFIGS="apr-config /usr/local/apr/bin/apr-config"
    SVN_SUBDIR="svn"
    AC_ARG_WITH(apr-config,
    [[  --with-apr-config=FILE    Use the given path to apr-config when determining
                                APR configuration; defaults to "apr-config"]],
    [
        if test "$withval" != "yes" -a "$withval" != ""; then
            APR_CONFIGS=$withval
        fi
    ])
    AC_MSG_CHECKING([for APR])
    APR_CONFIG=""
    for VALUE in $APR_CONFIGS ; do
            if $VALUE --cflags > /dev/null; then
                    APR_CONFIG=$VALUE
                    break
            fi
    done
    test $VALUE && APR_CONFIG=$VALUE
    if test $APR_CONFIG ; then
        AC_MSG_RESULT([found])
    else
        AC_MSG_RESULT([not found])
            SVN_SUBDIR=
    dnl    AC_MSG_ERROR([APR is required. Try --with-apr-config.])
    fi
            
    APR_CPPFLAGS="`$APR_CONFIG --cppflags`"
    APR_INCLUDE="`$APR_CONFIG --includes`"
    APR_LIBS="`$APR_CONFIG --link-ld --libs`"
    
    dnl
    dnl APR util
    dnl
    
    APU_CONFIGS="apu-config /usr/local/apr/bin/apu-config"
    AC_ARG_WITH(apu-config,
    [[  --with-apu-config=FILE    Use the given path to apu-config when determining
                                APR util configuration; defaults to "apu-config"]],
    [
        if test "$withval" != "yes" -a "$withval" != ""; then
            APU_CONFIGS=$withval
        fi
    ])
    AC_MSG_CHECKING([for APR util])
    APU_CONFIG=""
    for VALUE in $APU_CONFIGS ; do
            if $VALUE --includes > /dev/null; then
                    APU_CONFIG=$VALUE
                    break
            fi
    done
    if test $APU_CONFIG ; then
        AC_MSG_RESULT([found])
    else
        AC_MSG_RESULT([not found])
            SVN_SUBDIR=
    dnl    AC_MSG_ERROR([APR util is required. Try --with-apu-config.])
    fi
    dnl APR_CPPFLAGS="$APR_CPPFLAGS `$APU_CONFIG --includes`"
    APR_INCLUDE="$APR_INCLUDE `$APU_CONFIG --includes`"
    APR_LIBS="$APR_LIBS `$APU_CONFIG --link-ld --libs`"
    
    AC_MSG_CHECKING(for Subversion svn-config)
    AC_ARG_WITH(subversion-dir,
            [  --with-subversion-dir=DIR           where Subversion is installed ],
            [
                    SVNCONFIG="$withval/bin/svn-config"
            ])
    
    if test -z "$SVNCONFIG"; then
            _SVNCONFIG="`svn-config --prefix 2> /dev/null`"
            if test -n "$_SVNCONFIG"; then
                    SVNCONFIG="$_SVNCONFIG/bin/svn-config"
            fi
    fi
    
    AC_SUBST(SVNCONFIG)
    if test -x "$SVNCONFIG"; then
            SVNLD="`$SVNCONFIG --ldflags`"
            SVN_LIB="`$SVNCONFIG --libs --cppflags` -lsvn_client-1"
            dnl ugly hack for subversion svn-config problems in 0.14.x, to be removed when svn-config is fixed
            SVN_INCLUDE="`$SVNCONFIG --includes` -I$_SVNCONFIG/include/subversion-1/"
            AC_MSG_RESULT(yes)
    else
            AC_MSG_RESULT(not found)
            dnl just a fallback to debian's config so that it works for me :)
            AC_ARG_WITH(svn-include,
                                    [[  --with-svn-include=DIR   Use the given path to the subversion headers.]],
                                    [
                                    if test "$withval" != "yes" -a "$withval" != ""; then
                                            SVN_INCLUDES=$withval
                                    fi
                                    ])
            if test -z "$SVN_INCLUDES"; then
                SVN_INCLUDES="/usr/local/include /usr/include"
            fi
            AC_MSG_CHECKING([for Subversion headers])
            SVN_INCLUDE=""
            for VALUE in $SVN_INCLUDES ; do
                    if test -f $VALUE/subversion-1/svn_types.h ; then
                            SVN_INCLUDE=$VALUE
                            break
                    fi
            done
            if test $SVN_INCLUDE ; then
                    AC_MSG_RESULT([found])
            else
                    AC_MSG_RESULT([not found])
                    SVN_SUBDIR=
    dnl		AC_MSG_ERROR([Subversion headers are required. Try --with-svn-include.])
            fi
            SVN_LIBS="/usr/local/lib$kdelibsuff /usr/lib$kdelibsuff"
            AC_ARG_WITH(svn-lib,
                            [[  --with-svn-lib=DIR  Use the given path to the subversion libraries.]],
                            [
                                if test "$withval" != "yes" -a "$withval" != ""; then
                                    SVN_LIBS=$withval
                                fi
                            ])
            AC_MSG_CHECKING([for Subversion libraries])
            SVN_LIB=""
            for VALUE in $SVN_LIBS ; do
                    if ls $VALUE/libsvn_client-1.* 1>/dev/null 2>&1; then
                            SVN_LIB=$VALUE
                            break
                    fi
            done
            if test $SVN_LIB ; then
                    AC_MSG_RESULT([found])
            else
                    AC_MSG_RESULT([not found])
                    SVN_SUBDIR=
            fi
    fi
    
    
    NEON_CONFIGS="neon-config"
    AC_ARG_WITH(neon-config,
    [[  --with-neon-config=FILE    Use the given path to neon-config when determining
                                Neon configuration; defaults to "neon-config"]],
    [
        if test "$withval" != "yes" -a "$withval" != ""; then
            NEON_CONFIGS=$withval
        fi
    ])
    AC_MSG_CHECKING([for Neon])
    NEON_CONFIG=""
    for VALUE in $NEON_CONFIGS ; do
            if $VALUE --cflags > /dev/null; then
                    NEON_CONFIG=$VALUE
                    break
            fi
    done
    if test $NEON_CONFIG ; then
        AC_MSG_RESULT([found])
    else
        AC_MSG_RESULT([not found])
            SVN_SUBDIR=
    dnl    AC_MSG_ERROR([Neon is required. Try --with-neon-config.])
    fi
    
    SVN_LIB="-L$SVN_LIB $APR_LIBS -lsvn_client-1"
    SVN_INCLUDE="-I$SVN_INCLUDE $APR_INCLUDE"
    SVN_CPPFLAGS="$APR_CPPFLAGS"
    
    AC_SUBST(SVN_INCLUDE)
    AC_SUBST(SVN_LIB)
    AC_SUBST(SVN_CPPFLAGS)
    AM_CONDITIONAL(include_kioslave_svn, test -n "$SVN_SUBDIR")
])



dnl  **********
dnl  check whether we need the vcs compat lib
dnl  **********

AC_DEFUN([KDEV_CHECK_VCSCOMPAT],
[
  AC_MSG_CHECKING(whether to build the vcs compat lib)
  
  AC_CACHE_VAL(ac_cv_vcs_compat,
  [
    AC_LANG_SAVE
    AC_LANG_CPLUSPLUS
    save_CXXFLAGS="$CXXFLAGS"
    CXXFLAGS="$CXXFLAGS -I$ac_qt_includes -I$ac_kde_includes"

    AC_TRY_COMPILE([
      #include <kdeversion.h>
    ],
    [
      #if !KDE_IS_VERSION(3,3,90)
         KDE_choke me
      #endif
    ],
      ac_cv_vcs_compat=yes,
      ac_cv_vcs_compat=no
    )
    CXXFLAGS="$save_CXXFLAGS"
    AC_LANG_RESTORE
   ])

  if test "$ac_cv_vcs_compat" = "yes"; then
    AC_MSG_RESULT(no)
  else
    if test -n "$SVN_SUBDIR"; then
      VCSCOMPAT=vcscompat
      AC_MSG_RESULT(yes)
    else
      DISABLE_SUBVERSION="yes"
      AC_MSG_RESULT(no)
    fi
  fi

  AM_CONDITIONAL(include_vcscompat, test -n "$VCSCOMPAT")
])


dnl  **********
dnl  check for new valgrind version (>= 2.1.0)
dnl  **********

AC_DEFUN([KDEV_CHECK_VALGRIND],
[
  AC_CHECK_PROG(ac_have_valgrind, [valgrind], [yes])
  if test "yes" == $ac_have_valgrind; then
    AC_MSG_CHECKING(valgrind version)
    if test "valgrind-20" == `valgrind --version | $AWK -F \. '{print @S|@1@S|@2}'`; then
      ac_valgrind_ver=20
      AC_MSG_RESULT(< 2.1.0)
    elif test "valgrind-1" == `valgrind --version | $AWK -F \. '{print @S|@1}'`; then
      ac_valgrind_ver=20
      AC_MSG_RESULT(< 2.1.0)
    else
      ac_valgrind_ver=21
      AC_MSG_RESULT(>= 2.1.0)
    fi
  fi
  AC_DEFINE_UNQUOTED(VALGRIND_VERSION, $ac_valgrind_ver, [valgrind version number - 20 for older and 21 for newer])
])
