#MIN_CONFIG(3.2)
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h sys/sysctl.h sys/param.h sys/time.h sys/types.h unistd.h)

AC_CHECK_SETENV
AC_CHECK_UNSETENV

KDE_NEED_FLEX

if test "$x_includes" != "NONE"; then
  AC_DEFINE(HAVE_X11_HEADERS,1,Define if you have X11 header files)
fi

KDE_INIT_DOXYGEN([The KDE-PIM API Reference], [Version $VERSION])

KDE_CHECK_THREADING

dnl For apps that NEED threads
if test -z "$LIBPTHREAD" && test -z "$USE_THREADS"; then
  DO_NOT_COMPILE="$DO_NOT_COMPILE knode"
fi

CXXFLAGS="$CXXFLAGS $KDE_DEFAULT_CXXFLAGS"

# check for libbluetooth (Bluetooth library) because gnokii may require it
AC_DEFUN([KDE_CHECK_BLUETOOTH],
[
  AC_CHECK_HEADERS(bluetooth/bluetooth.h)
  LIB_BLUETOOTH=
  AC_CHECK_LIB(bluetooth, hci_open_dev,
       [ LIB_BLUETOOTH="-lbluetooth" ],
       [],
       [] )
  AC_SUBST(LIB_BLUETOOTH)
])


# check for libgnokii (Nokia mobile phone library)
AC_DEFUN([KDE_CHECK_GNOKII],
[
  AC_CHECK_HEADERS(gnokii.h)
  AC_REQUIRE([AC_HAVE_XPM])
  LIB_GNOKII=
  AC_CHECK_LIB(gnokii, gn_cfg_read,
       [ LIB_GNOKII="-lgnokii $LIB_BLUETOOTH" ],
       [],
       $all_libraries -lXpm -lX11 $LIB_BLUETOOTH )
  AC_SUBST(LIB_GNOKII)
])


dnl the below is copied from kdenetwork's configure as too many apps moved
dnl and noone can say which tests are needed and which are obsolete for kdepim ;(

dnl Checks for header files.
AC_CHECK_HEADERS(linux/tcp.h linux/if_ppp.h)
AC_CHECK_HEADERS(net/errno.h net/if_ppp.h)
AC_CHECK_HEADERS(asm/param.h)
AC_CHECK_HEADERS(sys/file.h sys/stat.h sys/time.h sys/cdefs.h sys/sockio.h)
AC_CHECK_HEADERS(fcntl.h unistd.h fnmatch.h sysent.h strings.h paths.h)
AC_CHECK_HEADERS(utmp.h re_comp.h getopt.h byteswap.h)
AC_CHECK_HEADER([resolv.h],,,[#include <netinet/in.h>])

KDE_CHECK_LARGEFILE

AC_CHECK_FUNCS(flock)
AC_CHECK_USLEEP

dnl Checks for library functions.
AC_CHECK_FUNCS(socket fabsl strdup vsnprintf tzset)
AC_CHECK_GETDOMAINNAME
AC_CHECK_GETHOSTNAME
AC_C_BIGENDIAN

AC_CHECK_FUNC(res_init)
if test "$ac_cv_func_res_init" = no; then
  AC_CHECK_LIB(resolv, res_init, LIBRESOLV="-lresolv $LIBSOCKET", , $LIBSOCKET)
fi
AC_SUBST(LIBRESOLV)

AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
	AC_TRY_COMPILE([
		#include <time.h>
	], [
		timezone = 1;
	], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
if test $ac_cv_var_timezone = yes; then
	AC_DEFINE(HAVE_TIMEZONE, 1, [define if you have a timezone variable])
fi
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

