AC_DEFUN([KMAIL_CHECK_INDEXLIB],
[
AC_REQUIRE([KDE_CHECK_LIB64])

AC_MSG_CHECKING(for indexlib)

missing_indexlib=ignore
AC_ARG_ENABLE(indexlib,
	AC_HELP_STRING([--enable-indexlib],[Enable EXPERIMENTAL full-text indexing in KMail.
 Use are your own risk!]),
	AC_DEFINE(HAVE_INDEXLIB,1,[Define if you want EXPERIMENTAL full-text indexing in KMail])
	missing_indexlib=no
	)


AM_CONDITIONAL(add_indexlib, test no = "$missing_indexlib")



])

dnl The following test is taken from tdelibs/tdeio/tdeio
dnl ------------------------------------------------------------------------
dnl Try to find if we have Linux Inode based Dir Notification
dnl ------------------------------------------------------------------------

AC_ARG_ENABLE(inotify,
AC_HELP_STRING([--disable-inotify],[enable use of Linux inode notifications]),
[ kde_enable_inotify=$enableval ], [kde_enable_inotify=yes])dnl

if test "x$kde_enable_inotify" = "xyes"; then
  AC_MSG_CHECKING([for Linux Inotify Notification])
  AC_CACHE_VAL(kde_cv_have_inotify,
  [
  kde_cv_have_inotify=no
  AC_LANG_SAVE
  AC_LANG_C

  AC_TRY_COMPILE(
  [
#include <asm/unistd.h>
#define _S390_BITOPS_H
#include <linux/inotify.h>
  ],
  [
#ifndef IN_ALL_EVENTS
#error no inotify notification
#endif
#ifndef __NR_inotify_init
#error no __NR_inotify_init
#endif

  ],kde_cv_have_inotify=yes,kde_cv_have_inotify=no)

  AC_LANG_RESTORE
  ])

  AC_CACHE_VAL(kde_cv_have_sys_inotify,
  [
  kde_cv_have_sys_inotify=no
  AC_LANG_SAVE
  AC_LANG_C

  AC_TRY_COMPILE(
  [
#include <sys/inotify.h>
  ],
  [
#ifndef IN_ALL_EVENTS
#error no inotify notification
#endif
  ],kde_cv_have_sys_inotify=yes,kde_cv_have_sys_inotify=no)

  AC_LANG_RESTORE
  ])

  if test "$kde_cv_have_inotify" = "yes" -o "$kde_cv_have_sys_inotify" = "yes"; then
    AC_DEFINE_UNQUOTED(HAVE_INOTIFY, 1, [Define if your system has Linux Inode Notification])
    if test "$kde_cv_have_sys_inotify" = "yes"; then
      AC_DEFINE_UNQUOTED(HAVE_SYS_INOTIFY, 1, [Define if your system has glibc support for inotify])
    fi
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no)
  fi
fi

KMAIL_CHECK_INDEXLIB
