# Original Author was Kalle@kde.org
# I lifted it in some mater. (Stephan Kulow)
# I used much code from Janos Farkas

dnl Process this file with autoconf to produce a configure script.
AC_INIT(acinclude.m4) dnl a source file from your sub dir

dnl This is so we can use kde-common
AC_CONFIG_AUX_DIR(admin)

KDE_SET_PREFIX

AC_CANONICAL_SYSTEM
AC_ARG_PROGRAM

dnl Automake doc recommends to do this only here. (Janos)
AM_INIT_AUTOMAKE(kdelibs, "3.1.3") dnl searches for some needed programs

AC_PROG_INSTALL

dnl generate the config header
AM_CONFIG_HEADER(config.h) dnl at the distribution this done

dnl Checks for programs.
AC_CHECK_COMPILERS
AC_LIBLTDL_CONVENIENCE

AC_ENABLE_SHARED(yes)
AC_ENABLE_STATIC(no)
KDE_PROG_LIBTOOL

AC_LANG_SAVE
AC_LANG_C
KDE_LIB_LTDL
AC_LANG_RESTORE

dnl for NLS support. Call them in this order!
dnl WITH_NLS is for the po files, GNU_GETTEXT for the sources
AM_KDE_WITH_NLS
AM_KDE_GNU_GETTEXT

dnl Checks for header files.
KDE_CHECK_STL
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/param.h sys/mman.h sys/time.h sys/cdefs.h fnmatch.h sysent.h strings.h sys/stat.h sys/select.h sys/socket.h linux/socket.h socketbits.h sigaction.h paths.h malloc.h monetary.h limits.h sys/soundcard.h dlfcn.h)

DCOPIDL2CPP="compiled"
DCOPIDL="compiled"
MEINPROC="compiled"
KDECONFIG="compiled"

dnl Checks for libraries etc
AC_BASE_PATH_KDE([don't test]) dnl kdelibs is a special case
AC_CREATE_KFSSTND(default)
AC_SUBST_KFSSTND

KDE_CREATE_LIBS_ALIASES

AC_DEFUN([KDE_DO_UIC_AGAIN],
[
AC_REQUIRE([AC_PATH_QT_MOC_UIC])
UIC=$UIC_PATH
if test x$ac_uic_supports_nounload = xyes; then
    UIC="$UIC -nounload"
fi
AC_SUBST(UIC)
])
KDE_DO_UIC_AGAIN

# configure would do this very late. Too late for us!
test "x$prefix" = xNONE && prefix=$ac_default_prefix

AC_DEFINE_UNQUOTED(KDEDIR, "$prefix", [The prefix to use as fallback])

ac_cpp_safe=$ac_cpp
ac_CPPFLAGS_safe=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $X_INCLUDES"
ac_cpp='$CXXCPP $CPPFLAGS'
KDE_CHECK_HEADERS(X11/extensions/shape.h,,,
[
#include <X11/Xlib.h>
#include <X11/Xutil.h>
])
KDE_CHECK_HEADERS(X11/extensions/XShm.h, 
  [have_mitshm=yes], [have_mitshm=no], [#include <X11/Xlib.h>])
KDE_CHECK_HEADERS(X11/ICE/ICElib.h)
ac_cpp=$ac_cpp_safe
CPPFLAGS=$ac_CPPFLAGS_safe

dnl Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_TIME

AC_LANG_SAVE
AC_LANG_C
dnl AC_C_BIGENDIAN has a bug (one of its tests uses "main()" instead of
dnl "int main()") so C++ compilers would break. Thats why we switch languages
AC_C_BIGENDIAN
AC_LANG_RESTORE

dnl check if the compiler has bool
AC_CHECK_BOOL

dnl Checks for library functions.
AC_CHECK_SETENV
AC_CHECK_UNSETENV
AC_CHECK_RANDOM
AC_CHECK_MKSTEMP
AC_CHECK_MKSTEMPS
KDE_CHECK_STRLCPY
AC_CHECK_FUNCS(strtoll socket seteuid setegid strfmon stpcpy gettimeofday)

AH_BOTTOM([
/* provide a definition for a 32 bit entity, usable as a typedef, possibly
   extended by "unsigned" */
#undef INT32_BASETYPE
#ifdef SIZEOF_INT
#if SIZEOF_INT == 4
#define INT32_BASETYPE int
#endif
#endif
#if !defined(INT32_BASETYPE) && defined(SIZEOF_LONG)
#if SIZEOF_LONG == 4
#define INT32_BASETYPE long
#endif
#endif
#ifndef INT32_BASETYPE
#define INT32_BASETYPE int
#endif

#ifndef HAVE_SETEUID
#define HAVE_SETEUID
#define HAVE_SETEUID_FAKE
#ifdef __cplusplus
extern "C"
#endif
int seteuid(INT32_BASETYPE euid); /* defined in fakes.c */
#endif
])

AC_LANG_SAVE
AC_LANG_C
dnl the vfork test in autoconf has a bug with C++ compilers (it declares
dnl the prototype for sparc_address_test() correctly but calls it without
dnl arguments), so we switch languages here.
AC_FUNC_VFORK
AC_LANG_RESTORE

AC_CHECK_INITGROUPS
AC_CHECK_USLEEP
AC_CHECK_GETHOSTNAME
AC_CHECK_RANDOM
AC_CHECK_S_ISSOCK
dnl AC_CHECK_SOCKLEN_T already in kde_misc_tests

AC_MSG_CHECKING([for mount tab file])
AC_CACHE_VAL(kde_cv_mtab_file,
[
    kde_cv_mtab_file=no

    for ac_file in    \
                      \
        /etc/mtab \
        /etc/mnttab \
     ; \
    do
    if test -r "$ac_file"; then
       kde_cv_mtab_file=$ac_file
       break
    fi
    done
])

AC_MSG_RESULT($kde_cv_mtab_file)
if test "$kde_cv_mtab_file" != "no"; then
    AC_DEFINE_UNQUOTED(MTAB_FILE, "$kde_cv_mtab_file", [Define the file for mount entries])
fi

if test -n "$qt_includes"; then
  QNAMESPACE_H="$qt_includes/qnamespace.h"
fi
AC_SUBST(QNAMESPACE_H)

dnl output files
AC_SUBST(x_includes)
AC_SUBST(x_libraries)
AC_SUBST(LIBSOCKET)
AC_SUBST(LIBCOMPAT)
AC_SUBST(LIBUTIL)
AC_SUBST(LIBRESOLV)
AC_SUBST(LIBICE)

AC_SUBST(LIB_KDECORE, '$(top_builddir)/kdecore/libkdecore.la')
AC_SUBST(LIB_KDEUI, '$(top_builddir)/kdeui/libkdeui.la')
AC_SUBST(LIB_KIO, '$(top_builddir)/kio/libkio.la')
AC_SUBST(LIB_KPARTS, '$(top_builddir)/kparts/libkparts.la')

AC_SUBST(EXTRA_SUBDIRS)

AC_MSG_CHECKING(if malloc debugging is wanted)
AC_ARG_WITH(dmalloc,
[  --with-dmalloc          use dmalloc, as in
			  http://dmalloc.com/releases/],
[if test "$withval" = yes; then
  AC_MSG_RESULT(yes)
  AC_DEFINE(WITH_DMALLOC,1,
            [Define if using the dmalloc debugging malloc package])
  LIB_DMALLOC="-ldmalloc"
  LDFLAGS="$LDFLAGS -g"
else
  AC_MSG_RESULT(no)
fi], [AC_MSG_RESULT(no)])

AC_SUBST(LIB_DMALLOC)

AC_MSG_CHECKING(if MIT-SHM support is wanted)
AC_ARG_ENABLE(mitshm,
[  --enable-mitshm         use MIT-SHM for pixmap loading/saving],
[if test "$enableval" = yes; then
  AC_MSG_RESULT(yes)
  want_mitshm="yes"
else
  AC_MSG_RESULT(no)
fi], [AC_MSG_RESULT(yes); want_mitshm="yes"])

if test "$want_mitshm" = "yes" -a "$have_mitshm" = "yes"; then
  AC_SUBST(HAVE_MITSHM)
  AC_DEFINE(HAVE_MITSHM,1,[Define if you want MIT-SHM support])
fi

AC_SUBST(ICE_SUBDIR, 'ICE')
AC_SUBST(ICE_RLIB, 'ICE/libkICE.la')

AC_SUBST(DCOPIDL, '$(top_builddir)/dcop/dcopidl/dcopidl')
AC_SUBST(DCOPIDL2CPP, '$(top_builddir)/dcop/dcopidl2cpp/dcopidl2cpp')

ac_save_LIBS="$LIBS"
LIBS="$LIBS $X_LDFLAGS -lICE"
AC_CHECK_FUNCS(_IceTransNoListen)
LIBS="$ac_save_LIBS"

if test "x$kde_use_qt_emb" != "xyes"; then
   CXXFLAGS="$CXXFLAGS $USE_RTTI"
fi

rgb_file="$x_libraries/X11/rgb.txt"
AC_DEFINE_UNQUOTED(X11_RGBFILE, "$rgb_file", [where rgb.txt is in])

AC_MSG_CHECKING([for Compiler version])
case "$CXX" in
xlC*)
  # The __IBMCPP__ macro contains the C++ compiler version in decimal notation.
  echo "__IBMCPP__" > conftest.C

  # Preprocess and at least make sure it's returned a number.
  changequote(, )dnl
  $CXX -E conftest.C 2>&1 | grep "^[0-9][0-9][0-9]" > conftest.i
  changequote([, ])dnl

  # "502" would signify version 5.0.2.
  clean_compiler_version="$CXX version "`cut -b1 conftest.i`"."`cut -b2 conftest.i`"."`cut -b3 conftest.i`
  rm -f conftest.C conftest.i
 ;;
KCC*)
  # KCC doesn't give it's version, if nothing is compiled (the frontend
  # isn't called in that case)
  rm -f conftest.C conftest.o
  echo "void f(void) {}" > conftest.C
  clean_compiler_version=`$CXX -V -c conftest.C -o conftest.o 2>&1 | sed 's/--.*//'`
  rm -f conftest.C conftest.o
 ;;
*)
  for flag in '-v' '-V' '--version' '-version'; do
    compiler_version=`$CXX $flag 2>&1 | egrep -v "Reading specs|Using built-?in specs|Configured with|Thread model" | head -n 1`
    clean_compiler_version=`echo $compiler_version | egrep -vi 'Usage|ERROR|unknown option|WARNING|missing|###'`
    test -n "$clean_compiler_version" && break
  done
 ;;
esac

# Quote backslashesm, as we are going to make this a string.
clean_compiler_version=`echo $clean_compiler_version | sed 's/\([\\\\]\)/\\\\\\1/g'`
if test -z "$clean_compiler_version"; then
  clean_compiler_version="unknown"
fi
AC_DEFINE_UNQUOTED(KDE_COMPILER_VERSION, "$clean_compiler_version", [what C++ compiler was used for compilation])
AC_MSG_RESULT($clean_compiler_version)

AC_MSG_CHECKING([for uname])
case `uname -s` in
AIX)
  IBM_ARCH=PowerPC #good default
  if [ -x /usr/sbin/lsdev -a -x /usr/sbin/lsattr ]; then
    IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -n 1 | awk '{ print $1 }'`
    if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
      IBM_ARCH=POWER
    fi
  fi
  uname_string=`uname -svr | awk '{ print $1" "$3"."$2 }'`" ${IBM_ARCH}"
 ;;
*)
  uname_string=`uname -smr`
 ;;
esac
AC_DEFINE_UNQUOTED(KDE_COMPILING_OS, "$uname_string", [what OS used for compilation])
AC_MSG_RESULT($uname_string)

AC_MSG_CHECKING([for distribution channel])
AC_ARG_WITH(distribution,
[  --with-distribution     indicate the distribution in bug reports],
[kde_distribution_text="$withval"
], [kde_distribution_text='compiled sources'])
AC_DEFINE_UNQUOTED(KDE_DISTRIBUTION_TEXT, "$kde_distribution_text", [Distribution Text to append to OS])
AC_MSG_RESULT($kde_distribution_text)

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

dnl aRts specific configure tests
dnl

dnl
dnl ensure that the user has aRts-1.1.0 or newer installed
dnl

dnl Check for artsc-config
dnl no need to, AC_BASE_PATH_KDE does it for us already (see also
dnl comment below for mcopidl)
dnl AC_PATH_PROG(ARTSCCONFIG, artsc-config, no)

ARTS_WANT_VERSION=1.1.x
ARTS_HAVE_VERSION=none
ARTS_HAVE_PREFIX=none

dnl Check for Glib-2.0
AC_MSG_CHECKING(for aRts-$ARTS_WANT_VERSION)

ARTS_OK=no

if test "x$ARTSCCONFIG" != "xno"; then
	ARTS_HAVE_VERSION=`$ARTSCCONFIG --arts-version`
	ARTS_HAVE_PREFIX=`$ARTSCCONFIG --arts-prefix`
fi

# And delete superflous '/' to make compares easier
ARTS_HAVE_PREFIX=`echo "$ARTS_HAVE_PREFIX" | sed 's,//*,/,g' | sed -e 's,/$,,'`

dnl don't look at the micro version
if test "x`echo $ARTS_HAVE_VERSION | sed 's/\.[[0-9]]*$/.x/'`" = "x$ARTS_WANT_VERSION"; then
        realartsprefix=`(cd $ARTS_HAVE_PREFIX; /bin/pwd)`
        realprefix=`(cd $prefix; /bin/pwd)`
	if test "x$realartsprefix" = "x$realprefix"; then
		ARTS_OK=yes
	else
AC_MSG_ERROR([aRts $ARTS_WANT_VERSION not installed in the same prefix as KDE!
Please reinstall aRts in the same prefix as KDE, different prefixes are not
supported right now.

(kdelibs prefix is $prefix, aRts prefix is $ARTS_HAVE_PREFIX)
])
	fi
fi

AC_MSG_RESULT($ARTS_OK)

if test "x$ARTS_OK" = "xno"; then
AC_MSG_ERROR([aRts $ARTS_WANT_VERSION not found.

You'll need to install a suitable version of aRts in the same prefix as KDE
before you build kdelibs.

(found
 * artsc-config: $ARTSCCONFIG
 * kdelibs prefix: $prefix
 * aRts prefix: $ARTS_HAVE_PREFIX
 * aRts version: $ARTS_HAVE_VERSION (required: $ARTS_WANT_VERSION)
)
])
fi

dnl AC_BASE_PATH_KDE already checks for mcopidl, and it does it the
dnl right way using KDE_FIND_PATH
dnl AC_PATH_PROG(MCOPIDL, mcopidl, no)
dnl AC_SUBST(MCOPIDL)
dnl don't remove
dnl AC_OUTPUT(dcop/dcop-path.h)
AC_MSG_CHECKING(whether to compile LDAP support)
AC_ARG_WITH(ldap,
[  --with-ldap=PATH     Set path for LDAP files [default=check]],
[ case "$withval" in
  yes)
    with_ldap=CHECK
    ;;
  esac ],
[ with_ldap=CHECK ]
)dnl

if test "x$with_ldap" = "xCHECK" ; then
  with_ldap=NOTFOUND
  search_incs="$kde_includes /usr/include /usr/local/include"
  AC_FIND_FILE(ldap.h, $search_incs, ldap_incdir)
  if test -r $ldap_incdir/ldap.h ; then
    test "x$ldap_incdir" != "x/usr/include" && LDAP_INCS="-I$ldap_incdir"
    with_ldap=FOUND
  fi
  if test $with_ldap = FOUND ; then
    with_ldap=NOTFOUND
    for ext in la so sl a ; do
      AC_FIND_FILE(libldap.$ext, $kde_libraries /usr/lib /usr/local/lib,
        ldap_libdir)
      if test -r $ldap_libdir/libldap.$ext ; then
        if test "x$ldap_libdir" != "x/usr/lib" ; then
          LDAP_LIBS="-L$ldap_libdir "
          test "$USE_RPATH" = yes && LDAP_RPATH="-R $ldap_libdir"
        fi
        LDAP_LIBS="${LDAP_LIBS}-lldap -llber ${LIBRESOLV}"
        with_ldap=FOUND
        break
      fi
    done
  fi
fi

case "$with_ldap" in
no) AC_MSG_RESULT(no) ;;
NOTFOUND) AC_MSG_RESULT(searched but not found) ;;
*)
  if test "x$with_ldap" = "xFOUND" ; then
    msg="incs=$ldap_incdir libs=$ldap_libdir"
  else
    msg="$with_ldap"
    LDAP_ROOT="$with_ldap"
    if test "x$LDAP_ROOT" != "x/usr" ; then
      LDAP_INCS="-I${LDAP_ROOT}/include"
      LDAP_LIBS="-L${LDAP_ROOT}/lib "
      if test "$USE_RPATH" = "yes" ; then
        LDAP_RPATH="-R ${LDAP_ROOT}/lib"
      fi
    fi
    LDAP_LIBS="${LDAP_LIBS}-lldap -llber ${LIBRESOLV}"
  fi
  kde_safe_LIBS="$LIBS"
  kde_safe_CFLAGS="$CFLAGS"
  LIBS="$LIBS $all_libraries $LDAP_LIBS $KERBEROS_LIBS $X_EXTRA_LIBS"
  CFLAGS="$CFLAGS $all_includes $LDAP_INCS $KERBEROS_INCS"
  AC_LANG_SAVE
  AC_LANG_C
  AC_TRY_LINK(dnl
  [
  #include <lber.h>
  #include <ldap.h>
  #if LDAP_VENDOR_VERSION < 20000
  #error OpenLDAP version too old, please upgrade to version 2 or higher
  #endif
  ],
  [
  LDAP *ldap;
  ],
  , with_ldap=no
  )
  AC_LANG_RESTORE
  CFLAGS=$kde_safe_CFLAGS
  LIBS=$kde_safe_LIBS
  if test "$with_ldap" = "no" ; then
    LDAP_INCS=
    LDAP_LIBS=
    LDAP_RPATH=
    LDAP_SUBDIR=
    AC_MSG_RESULT(no (but first try gave $msg))
  else
    AC_DEFINE_UNQUOTED(HAVE_LIBLDAP, 1, [Define if you have LDAP libraries])
    LDAP_SUBDIR="ldap"
    AC_MSG_RESULT($msg)
  fi
  ;;
esac

AC_SUBST(LDAP_INCS)
AC_SUBST(LDAP_LIBS)
AC_SUBST(LDAP_RPATH)

AM_CONDITIONAL(include_LDAP, test -n "$LDAP_SUBDIR")

dnl Compile in the exec prefix to help kstddirs in finding dynamic libs
AC_DEFINE_UNQUOTED(__KDE_EXECPREFIX, "$exec_prefix", [execprefix or NONE if not set, for libloading])

dnl --------
dnl KSocketAddress/KExtendedSocket extra configuration
dnl --------
dnl
dnl This is to be merged with toplevel configure.in.in soon

kde_safe_LIBS="$LIBS"
LIBS="$LIBS $all_libraries $X_EXTRA_LIBS"
AC_CHECK_FUNCS(inet_ntop inet_pton getpeername getsockname getsockopt gethostbyname2_r gethostbyname_r gethostbyname2)
LIBS="$kde_safe_LIBS"

AC_MSG_CHECKING([for struct addrinfo])
AC_TRY_COMPILE(dnl
      [
        #include <netdb.h>
      ],
      [
        struct addrinfo ai;
      ],
      [
        AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1, [Define if netdb.h defines struct addrinfo])
	AC_MSG_RESULT(yes)
      ],
      AC_MSG_RESULT(no)
)
AC_MSG_CHECKING([for GLIBC function backtrace])
AC_TRY_LINK(dnl
      [
        #include <execinfo.h>
      ],
      [
        void* trace[256];
        backtrace(trace, 256);
      ],
      [
        AC_DEFINE(HAVE_BACKTRACE, 1, [Define if execinfo.h exists and defines backtrace (GLIBC >= 2.1)])
	AC_MSG_RESULT(yes)
      ],
      AC_MSG_RESULT(no)
)

my_LIBS="$LIBS"
LIBS="$LIBS $LIBSOCKET"
AC_CHECK_FUNC(getaddrinfo,
  [
    AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo is present])

    dnl Even though we now know that getaddrinfo is there, make sure getnameinfo is there too
    kde_gai_ok=true
    AC_CHECK_FUNCS(freeaddrinfo getnameinfo gai_strerror, : , 
    [
      kde_gai_ok=false
      AC_DEFINE(HAVE_BROKEN_GETADDRINFO, 1, [Define if getaddrinfo is broken and should be replaced])
      AC_DEFINE(GETADDRINFO_RETURNS_UNIX, 1, [Define if getaddrinfo returns AF_UNIX sockets])
      break
    ])

    AC_MSG_CHECKING([if getaddrinfo works using numeric service with null host])
    dnl On AIX (4.3), getaddrinfo returns NULL if the hint
    dnl is AF_INET/SOCK_STREAM/AI_PASSIVE.
    dnl The error code reports "Host not found".
    dnl It only seems to return non-NULL if the port is known (eg. in
    dnl /etc/services).
    AC_TRY_RUN(dnl
    [
      #include <sys/types.h>
      #include <sys/socket.h>
      #include <netdb.h>
      #include <string.h>
      int main()
      {
        struct addrinfo hint, *res;
        int err;
        memset(&hint, 0, sizeof(hint));
        hint.ai_family = AF_INET;
        hint.ai_protocol = 0;
        hint.ai_socktype = SOCK_STREAM;
        hint.ai_flags = AI_PASSIVE;
        err = getaddrinfo(0, "18300", &hint, &res); /* kxmlrpc tries this */
        if (err != 0 || res == 0 || res->ai_family != AF_INET)
          return 1;
        return 0;
      }
    ],
    [
      AC_MSG_RESULT(yes)
    ],
    [
      AC_MSG_RESULT(no)
      AC_DEFINE(HAVE_BROKEN_GETADDRINFO, 1, [Define if getaddrinfo is broken and should be replaced])
    ],
    [
      AC_MSG_RESULT(cross compiling. We hope so)
    ])

    if $kde_gai_ok ; then
      AC_MSG_CHECKING([if getaddrinfo returns AF_UNIX])
      dnl At least one system has a bad implementation of getaddrinfo
      dnl FreeBSD's libc getaddrinfo code has AF_UNIX disabled
      dnl This is rather stupid, but since it's there...
      AC_TRY_RUN(dnl
      [
        #include <sys/types.h>
        #include <sys/socket.h>
        #include <netdb.h>
        #include <string.h>
	int main()
	{
	  struct addrinfo hint, *res;
	  int err;
	  memset(&hint, 0, sizeof(hint));
	  hint.ai_family = AF_UNSPEC;
	  hint.ai_protocol = 0;
	  hint.ai_socktype = SOCK_STREAM;
	  hint.ai_flags = 0;
	  err = getaddrinfo(0, "/tmp/conftest-sock", &hint, &res);
	  if (err != 0 || res == 0 || res->ai_family != AF_UNIX)
	    return 1;
	  return 0;
	}
      ],
      [
        AC_MSG_RESULT(yes)
	AC_DEFINE(GETADDRINFO_RETURNS_UNIX, 1, [Define if getaddrinfo returns AF_UNIX sockets])
      ],
      [
        AC_MSG_RESULT(no)
      ],
      [
        case "$target" in
	  *-*-freebsd*)
	    AC_MSG_RESULT(assuming it doesn't)
	    ;;
	  *)
	    AC_MSG_RESULT(assuming it does)
	    AC_DEFINE(GETADDRINFO_RETURNS_UNIX, 1, [Define if getaddrinfo returns AF_UNIX sockets])
	    ;;
	esac
      ]
      )
    fi		# test $kde_gai_broken
  ],
  [
    dnl Our getaddrinfo returns AF_UNIX sockets
    AC_DEFINE(GETADDRINFO_RETURNS_UNIX, 1, [Define if getaddrinfo returns AF_UNIX sockets])
  ]
)
case "$target" in
  *-*-openbsd2.*|*-*-openbsd3.[0-2])
    dnl OpenBSD's getaddrinfo is not thread-safe up to 3.2
    AC_DEFINE(HAVE_BROKEN_GETADDRINFO, 1, [Define if getaddrinfo is broken and should be replaced])
    ;;
esac
LIBS="$my_LIBS"

AC_MSG_CHECKING([if struct sockaddr has member sa_len])
AC_TRY_COMPILE(
  [
    #include <sys/types.h>
    #include <sys/socket.h>
  ],
  [
    struct sockaddr sa;
    sa.sa_len = sizeof(sa);
  ],
  [
    AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[Define if struct sockaddr has member sa_len])
    AC_MSG_RESULT(yes)
  ],
  AC_MSG_RESULT(no)
)

AC_CHECK_HEADERS(netinet/in.h,
  [

    dnl Check for sockaddr_in6. We don't have to check for in6_addr
    dnl if sockaddr_in6 is there, so is in6_addr
    AC_MSG_CHECKING([for struct sockaddr_in6])
    AC_TRY_COMPILE(
      [
	#include <sys/types.h>
	#include <stdlib.h>
	#include <netinet/in.h>
      ],
      [
	struct sockaddr_in6 sin6;
      ],
      [
	AC_DEFINE(HAVE_SOCKADDR_IN6,1,[Define if we have struct sockaddr_in6 in netinet/in.h])
	AC_MSG_RESULT(yes)

	dnl Check if this system's sockaddr_in6 already supports sin6_scope_id
	dnl All systems should support it, but some still don't
	AC_MSG_CHECKING([if struct sockaddr_in6 has member sin6_scope_id])
	AC_TRY_COMPILE(
	  [
	    #include <sys/types.h>
	    #include <stdlib.h>
	    #include <netinet/in.h>
	  ],
	  [
	    struct sockaddr_in6 sin6;
	    sin6.sin6_scope_id = 0;
	  ],
	  [
	    AC_DEFINE(HAVE_SOCKADDR_IN6_SCOPE_ID,1,[Define if this system already has sin6_scope_id in sockaddr_in6])
	    AC_MSG_RESULT(yes)
	  ],
	  AC_MSG_RESULT(no)
	)
      ],
      AC_MSG_RESULT(no)
    )
  ]
)

AC_ARG_WITH(ipv6-lookup, 
[  --with-ipv6-lookup=mode Set the mode for IPv6 lookups: yes, auto and no],
[
  AC_MSG_CHECKING([how we should treat IPv6 lookups])
  if test "$withval" = yes -o "$withval" = always; then
    AC_DEFINE(KDE_IPV6_LOOKUP_MODE, 0, [Lookup mode for IPv6 addresses: 0 for always, 1 for check and 2 for disabled])
    AC_MSG_RESULT([always do the lookup])
  elif test "$withval" = auto; then
    AC_DEFINE(KDE_IPV6_LOOKUP_MODE, 1, [Lookup mode for IPv6 addresses: 0 for always, 1 for check and 2 for disabled])
    AC_MSG_RESULT([check for IPv6 stack])
  else
    AC_DEFINE(KDE_IPV6_LOOKUP_MODE, 2, [Lookup mode for IPv6 addresses: 0 for always, 1 for check and 2 for disabled])
    AC_MSG_RESULT([never do the lookup])
  fi
], [    
  AC_DEFINE(KDE_IPV6_LOOKUP_MODE, 1, [Lookup mode for IPv6 addresses: 0 for always, 1 for check and 2 for disabled])
])
  

dnl AC_OUTPUT(kdecore/kde-config.cpp)

SVGICONS=
	
KDE_FIND_PATH(libart2-config, LIBART_CONFIG, [${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin], [
  AC_MSG_WARN([Could not find libart anywhere, check http://www.levien.com/libart/])
])

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

     AC_DEFINE_UNQUOTED(HAVE_LIBART, 1, [Defines if your system has the libart library])
  else
     AC_MSG_WARN([You need at least libart 2.3.8])
  fi
fi


AC_SUBST(LIBART_LIBS)
AC_SUBST(LIBART_CFLAGS)
AC_SUBST(LIBART_RPATH)
AM_CONDITIONAL(include_SVGICONS, test -n "$SVGICONS")

AC_MSG_CHECKING([for revoke(tty) in unistd.h])
AC_TRY_LINK(dnl
      [
        #include <unistd.h>
      ],
      [
	revoke("/dev/tty");
      ],
      [
        AC_DEFINE(HAVE_REVOKE, 1, [Define if revoke(tty) is present in unistd.h])
        AC_MSG_RESULT(yes)
      ],
      AC_MSG_RESULT(no)
)
dnl --enable-fast-malloc depends on $KDE_MALLOC
dnl --disable-fast-malloc disabled
dnl --enable-fast-malloc=full enabled always
dnl
dnl enable on x86 Linux and x86 FreeBSD
dnl gcc3.0 needs -finline-limit=100000 (large num)

kde_fast_malloc=
AC_ARG_ENABLE(fast-malloc,
    [  --enable-fast-malloc    Use own malloc implementation : yes,no,full,debug],
    [
    if test "$enableval" = "full"; then
        kde_fast_malloc=full
    elif test "$enableval" = "yes"; then
        kde_fast_malloc=yes
    elif test "$enableval" = "debug"; then
        kde_fast_malloc=debug
    else
        kde_fast_malloc=no
    fi
    ],
    [
    kde_fast_malloc=notgiven
    ])

dnl gcc needed for __inline__
if test "$kde_fast_malloc" != "no"; then
    if test "$GCC" != "yes"; then
        if test "$kde_fast_malloc" = "notgiven"; then
            kde_fast_malloc=no
        else
            AC_MSG_ERROR([Fast malloc needs GCC.])
            kde_fast_malloc=no
        fi
    fi
fi

if test "$kde_fast_malloc" != "no"; then
dnl platforms for which there's a spinlock implementation
    case $target_cpu in
        i?86)
            AC_DEFINE(KDE_MALLOC_X86, 1, [The platform is x86])
            ;;
        *)
            if test "$kde_fast_malloc" = "notgiven"; then
                kde_fast_malloc=no
            else
                AC_MSG_ERROR([Fast malloc is not supported on this platform (missing spinlock implementation).])
            fi
            ;;
    esac
dnl warn on untested platforms
    case $target_os in
        linux*) ;;
        freebsd*) ;;
        *)
            if test "$kde_fast_malloc" = "notgiven"; then
                kde_fast_malloc=no
            else
                AC_MSG_WARN([Fast malloc is not tested on this platform. The build may fail or the executables may crash.])
            fi
            ;;
    esac
fi

if test "$kde_fast_malloc" = "yes" -o "$kde_fast_malloc" = "notgiven" -o "$kde_fast_malloc" = "debug"; then
dnl $KDE_MALLOC needs glibc (__libc_malloc etc.)
    AC_CACHE_CHECK([if the libc is glibc],kde_cv_libc_glibc,
        [AC_TRY_COMPILE(
            [#include<stdlib.h>],
            [
            #ifndef __GLIBC__
            error no glibc
            #endif
            ],
            [kde_cv_libc_glibc=yes],
            [kde_cv_libc_glibc=no])
        ])
    if test "$kde_cv_libc_glibc" = "yes"; then
        AC_DEFINE(KDE_MALLOC_GLIBC, 1, [The libc used is glibc])
    else
        if test "$kde_fast_malloc" = "notgiven"; then
            kde_fast_malloc=notgiven_full
        elif test "$enableval" = "debug"; then
            AC_MSG_WARN([This libc is not supported for fast malloc. Runtime disabling won't work.])
            kde_fast_malloc=debug_full
        else
            AC_MSG_ERROR([This libc is not supported for fast malloc. Either use --enable-fast-malloc=full, or don't use it at all.])
        fi
    fi
fi

dnl enable by default where possible
dnl on FreeBSD (no glibc), the default is =full, as =yes doesn't work there,
dnl   unless --enable-debug is used, in which case it's =no
dnl on Linux (glibc), the default is =yes
if test "$kde_fast_malloc" = "notgiven"; then
    kde_fast_malloc=yes
fi
if test "$kde_fast_malloc" = "notgiven_full"; then
    if test "$kde_use_debug_code" = "no"; then
        kde_fast_malloc=full
    else
        kde_fast_malloc=no
    fi
fi

AC_MSG_CHECKING(whether to enable fast malloc)
if test "$kde_fast_malloc" = "yes"; then
    AC_MSG_RESULT(yes)
elif test "$kde_fast_malloc" = "full"; then
    AC_MSG_RESULT([yes(full)])
elif test "$kde_fast_malloc" = "debug"; then
    AC_MSG_RESULT([yes(debug)])
elif test "$kde_fast_malloc" = "debug_full"; then
    AC_MSG_RESULT([yes(full+debug)])
else
    AC_MSG_RESULT(no)
fi

if test "$kde_fast_malloc" != "no"; then
    AC_DEFINE(KDE_MALLOC, 1, [Use own malloc implementation])
fi

if test "$kde_fast_malloc" = "debug" -o "$kde_fast_malloc" = "debug_full"; then
    AC_DEFINE(KDE_MALLOC_DEBUG, 1, [Enable debugging in fast malloc])
fi

if test "$kde_fast_malloc" = "full" -o "$kde_fast_malloc" = "debug_full"; then
    AC_DEFINE(KDE_MALLOC_FULL, 1, [Make alloc as fast as possible])
fi

dnl -finline-limit=<large num> is needed for gcc3 in order to inline large functions
KDE_CHECK_COMPILER_FLAG(finline-limit=100000,
    [KDE_FORCE_INLINE="-finline-limit=100000"],
    [KDE_FORCE_INLINE= ])
AC_SUBST(KDE_FORCE_INLINE)

dnl -----------------------------------------------------
dnl XRender check
dnl -----------------------------------------------------
KDE_CHECK_HEADER(X11/extensions/Xrender.h, [xrender_h=yes], [xrender_h=no])
if test "$xrender_h" = yes; then
  KDE_CHECK_LIB(Xrender, XRenderComposite, [
    LIB_XRENDER=-lXrender
    AC_DEFINE_UNQUOTED(HAVE_XRENDER, 1, [Defined if your system has XRender support])
  ], [], -lXext -lX11 $X_EXTRA_LIBS)
else
  LIB_XRENDER=
fi
AC_SUBST(LIB_XRENDER)

AC_DEFUN(AC_CHECK_CUPS_VERSION,
[
kde_save_cflags="$CFLAGS"
kde_save_libs="$LIBS"
LIBS="$all_libraries $USER_LDFLAGS -lcups $LIBDL $LIBSOCKET"
CFLAGS="$CFLAGS $all_includes $USER_INCLUDES"
AC_MSG_CHECKING(CUPS version >= $1)
kde_save_link=$ac_link
ac_link='${CC} $CFLAGS -o conftest conftest.c $LIBS 1>&5'
cat > conftest.c <<EOF
#include <cups/cups.h>
#include <stdio.h>
int main()
{
  if (CUPS_VERSION <
EOF
echo "$1" >> conftest.c
cat >> conftest.c <<EOF
)
    printf("no\n");
  else
    printf("yes\n");
}
EOF
if AC_TRY_EVAL(ac_link) && test -x conftest; then
  ac_have_new_cups=`./conftest`
else
  AC_MSG_ERROR([Unable to compile test program. See config.log for more informations])
  echo "configure: failed program was:" >&AC_FD_CC
  cat conftest.c >&AC_FD_CC
  ac_have_new_cups="no"
fi
rm -f conftest*
ac_link="$kde_save_link"
CFLAGS="$kde_save_cflags"
LIBS="$kde_save_libs"
AC_MSG_RESULT($ac_have_new_cups)
])

dnl CUPS stuffs (to be changed)
ac_use_cups="yes"
ac_have_new_cups="yes"
ac_cups_libs=0
CUPSSUBDIR=
LIB_CUPS=
AC_ARG_ENABLE(cups,[  --disable-cups          disable CUPS support [default=auto]],ac_use_cups=$enableval, ac_use_cups=yes)
if test "$ac_use_cups" = "yes"; then
  ac_CPPFLAGS_save="$CPPFLAGS"
  CPPFLAGS="$CPPFLAGS $all_includes"
  ac_LDFLAGS_save="$LDFLAGS"
  LDFLAGS="$LDFLAGS $all_libraries"
  AC_CHECK_LIB(cups,cupsServer,[ac_cups_libs=1],[ac_cups_libs=0],$LIBDL $LIBSOCKET)
  if test "$ac_cups_libs" = "0"; then
    AC_MSG_WARN(CUPS library not found. CUPS support disabled)
    ac_use_cups="no"
  fi
  if test "$ac_use_cups" = "yes"; then
    dnl check existence of CUPS header files
    ac_cups_headers=0
    AC_CHECK_HEADER(cups/cups.h,[ac_cups_headers=1])
    if test "$ac_cups_headers" = "0"; then
      AC_MSG_WARN(CUPS headers not found. CUPS support disabled)
      ac_use_cups="no"
    else
      dnl check that version is at least 1.1.9
      AC_CHECK_CUPS_VERSION(1.0109)
      if test "$ac_have_new_cups" = "no"; then
        AC_MSG_WARN(CUPS version too old. You should upgrade to version >= 1.1.9)
	ac_use_cups="no"
      fi
    fi
  fi
  LDFLAGS="$ac_LDFLAGS_save"
  CPPFLAGS="$ac_CPPFLAGS_save"
fi
if test "$ac_use_cups" = "yes"; then
  CUPSSUBDIR="cups"
  LIB_CUPS="-lcups $LIBDL $LIBSOCKET"
  AC_DEFINE(HAVE_CUPS, 1, [Defines if you have CUPS (Common UNIX Printing System)])
fi
AM_CONDITIONAL(include_cups_SUBDIR, test -n "$CUPSSUBDIR")
AC_SUBST(LIB_CUPS)

dnl check for Qt-3.1 feature: QPrinter::setMargins()
AC_MSG_CHECKING(Qt contains QPrinter::setMargins())
kdeprint_use_margins="no"
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
kdeprint_save_cxxflags="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $all_includes"
AC_TRY_COMPILE(
[
#include <qprinter.h>
],
[
QPrinter prt;
prt.setMargins(0, 0, 0, 0);
],
kdeprint_use_margins="yes"
)
AC_LANG_RESTORE
CXXFLAGS="$kdeprint_save_cxxflags"
AC_MSG_RESULT($kdeprint_use_margins)
if test "$kdeprint_use_margins" = "yes"; then
  AC_DEFINE(KDEPRINT_USE_MARGINS, 1, [Defines if KDEPrint should include user-specified margins support])
fi
dnl Whether to install the PostScript driver
AC_MSG_CHECKING([installation of PS driver needed])
ac_cups_share_test="/usr/share/cups /usr/local/share/cups /opt/share/cups /opt/local/share/cups"
cups_modeldir=""
for d in $ac_cups_share_test; do
	if test -d $d && test -d $d/model; then
		cups_modeldir=$d/model
		break
	fi
done

AC_SUBST(cups_modeldir)

if test -n "$cups_modeldir"; then
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi

dnl Check for su
AC_PATH_PROG(path_su, "su", "no")
if test "$path_su" = "no"; then
    AC_MSG_WARN(su was not found)
else
    AC_DEFINE_UNQUOTED(__PATH_SU, "$path_su", [path to su])
fi

dnl Check for POSIX.1b scheduling
AC_MSG_CHECKING([POSIX.1b scheduling])
AC_TRY_LINK([
    #include <sched.h>
],
[
    sched_getscheduler(0);
],
have_rtsched="yes", have_rtsched="no")
if test "$have_rtsched" = "yes"; then
    AC_DEFINE(POSIX1B_SCHEDULING, 1, [Define if you have POSIX.1b scheduling])
    AC_MSG_RESULT(yes)
else
    AC_MSG_RESULT(no)
fi

dnl Check for initgroups()
AC_CHECK_FUNCS(initgroups)

dnl Compile in kde_bindir to safely find kdesu_stub.
if test "$exec_prefix" = "NONE"; then
    bindir_str="\"$prefix/bin\""
else
    bindir_str="\"$exec_prefix/bin\""
fi
AC_DEFINE_UNQUOTED(__KDE_BINDIR, $bindir_str, [KDE bindir])

dnl openpty stuff
AC_CHECK_HEADERS(libutil.h util.h pty.h)
AC_CHECK_LIB(util, openpty, [AC_DEFINE_UNQUOTED(HAVE_OPENPTY, 1, [Define if you have openpty in -lutil])])
AC_CHECK_FUNCS(openpty initgroups setgroups getgroups grantpt setpriority getpt unlockpt ptsname)

AH_VERBATIM(_OPENPTY,
[
/*
 * Steven Schultz <sms at to.gd-es.com> tells us :
 * BSD/OS 4.2 doesn't have a prototype for openpty in its system header files
 */
#ifdef __bsdi__
__BEGIN_DECLS
int openpty(int *, int *, char *, struct termios *, struct winsize *);
__END_DECLS
#endif
])

dnl irix pty stuff
AC_CHECK_FUNCS(_getpty)

AC_MSG_CHECKING([for struct ucred])
AC_CACHE_VAL(kde_cv_have_struct_ucred,
[
  AC_TRY_COMPILE(
  [
    #include <sys/socket.h>
  ],
  [
    struct ucred cred;
  ], kde_cv_have_struct_ucred=yes,
  kde_cv_have_struct_ucred=no)
])

AC_MSG_RESULT($kde_cv_have_struct_ucred)
if test "$kde_cv_have_struct_ucred" = yes; then
   AC_DEFINE(HAVE_STRUCT_UCRED,1, [Define if struct ucred is present from sys/socket.h])
fi
AC_CHECK_FUNCS(getpeereid)

# don't use it yet
HELP_SUBDIR=kdoctools

KDE_FIND_PATH(xml2-config, XML_CONFIG, [${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin], [
  AC_MSG_WARN([Could not find libxml2 anywhere, check ftp://xmlsoft.org/ for libxml >= 2.4.8. (we also keep a version of it in kdesupport for CVS users' convience)])
  HELP_SUBDIR=
])

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], [XMLLINT=""])
     AC_DEFINE_UNQUOTED(XMLLINT, "$XMLLINT", [Defines the executable of xmllint])
  else
     AC_MSG_WARN([You need at least libxml 2.4.8])
     HELP_SUBDIR=
  fi
fi

if test -n "$HELP_SUBDIR"; then

  KDE_FIND_PATH(xslt-config, XSLT_CONFIG, [${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin], [
    AC_MSG_WARN([Could not find libxslt anywhere, check ftp://xmlsoft.org/ for libxslt >= 1.0.7. (we also keep a version of it in kdesupport for CVS users' convience)])
    HELP_SUBDIR=
  ])

  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`"

     else
       AC_MSG_WARN([You need at least libxslt 1.0.7])
       HELP_SUBDIR=
     fi
  fi
fi

AC_DEFUN(KDOCTOOLS_CHECK_BZIP2,
[
AC_REQUIRE([AC_FIND_BZIP2])
AC_MSG_CHECKING([for present bzip2 support])
if test -z "$LIBBZ2"; then
	AC_MSG_RESULT([no - disabling doc compiler])
	HELP_SUBDIR=
else
	AC_MSG_RESULT([ok])
fi
])
KDOCTOOLS_CHECK_BZIP2

if test -n "$HELP_SUBDIR"; then  
  MEINPROC='KDELIBS_UNINSTALLED=yes $(top_builddir)/kdoctools/meinproc'
  MEINPROC_DEP='$(top_builddir)/kdoctools/meinproc'
  KDE_XSL_STYLESHEET='$(top_srcdir)/kdoctools/customization/kde-chunk.xsl'
else
  MEINPROC=""
  MEINPROC_DEP=""
  KDE_XSL_STYLESHEET=""
  DO_NOT_COMPILE="$DO_NOT_COMPILE kdoctools"
fi

if test ! "$USE_RPATH" = "yes"; then
  LIBXSLT_RPATH=
  LIBXML_RPATH=
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(HELP_SUBDIR)
AC_SUBST(MEINPROC) 
AC_SUBST(MEINPROC_DEP)
AC_SUBST(KDE_XSL_STYLESHEET)

dnl AC_OUTPUT(kdoctools/checkXML)

AM_CONDITIONAL(DOJAVA, test "x$kde_use_qt_emb" != "xyes")

dnl don't remove
dnl AC_OUTPUT(khtml/java/kjava.policy)
eval KJAVA_POLICYPATH=${kde_datadir}/kjava/-
AC_SUBST(KJAVA_POLICYPATH)
KDE_CHECK_KIMGIO
AM_CONDITIONAL(include_TIFF_MODULES, test -n "$LIBTIFF")
dnl ------------------------------------------------------------------------
dnl Try to find if FAM is installed
dnl ------------------------------------------------------------------------
dnl
kde_have_fam=yes
AC_ARG_ENABLE(libfam, [  --disable-libfam        don't search for libfam and do not use it],
[ kde_have_fam=$enableval ], [])dnl

dnl Bloody libfam is C++ and certainly compiled by GNU C++.  This means,
dnl we can't use it, when compiling with another C++ compiler, as the
dnl runtime systems would conflict (e.g. in KAI C++) (matz)
test "$GXX" = yes || kde_have_fam=no

if test "$kde_have_fam" = "yes" ; then
  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  KDE_CHECK_LIB(fam, FAMOpen, [LIBFAM="-lfam"; kde_have_fam=yes],kde_have_fam=no)
  if test $kde_have_fam = yes; then
    AC_DEFINE_UNQUOTED(HAVE_FAM, 1, [Define if your system has libfam])
  fi
  AC_LANG_RESTORE
fi
AC_SUBST(LIBFAM)
dnl ------------------------------------------------------------------------
dnl Try to find if LIBZ is installed
dnl ------------------------------------------------------------------------
dnl

AC_FIND_ZLIB

AC_CHECK_HEADERS(sys/mnttab.h mntent.h fstab.h sys/ucred.h sys/mount.h)
AC_CHECK_FUNCS(setmntent getmntinfo)

AH_VERBATIM(_GETMNTINFO, [
#ifdef __osf__
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/mount.h>
int getmntinfo(struct statfs **mntbufp, int flags);
#include <sys/fs_types.h>    /* for mnt_names[] */
#ifdef __cplusplus
}
#endif
#endif
])

dnl ------------------------------------------------------------------------
dnl Try to find if libvolmgt is installed (Solaris)
dnl ------------------------------------------------------------------------
kde_have_volmgt=yes
AC_CHECK_LIB(volmgt, volmgt_running, [LIBVOLMGT=-lvolmgt], kde_have_volmgt=no)
AC_SUBST(LIBVOLMGT)
if test "$kde_have_volmgt" = "yes"; then
  AC_DEFINE_UNQUOTED(HAVE_VOLMGT, 1, [Define, to enable volume management (Solaris 2.x), if you have -lvolmgt])
fi

dnl ------------------------------------------------------------------------
dnl Try to find if we have Linux Dir Notification
dnl ------------------------------------------------------------------------

AC_ARG_ENABLE(dnotify, [  --enable-dnotify        enable use of Linux directory notifications],
[ kde_enable_dnotify=$enableval ], [])dnl

AC_CHECK_GNU_EXTENSIONS

if test "x$kde_enable_dnotify" = "xyes"; then
  AC_MSG_CHECKING([for Linux Directory Notification])
  AC_CACHE_VAL(kde_cv_have_dnotify,
  [
  kde_cv_have_dnotify=no
  AC_LANG_SAVE
  AC_LANG_C

  AC_TRY_COMPILE(
  [
#include <fcntl.h>
#include <signal.h>
  ],
  [
#ifndef F_NOTIFY
#error no dir notification
#endif
    int fd;
    siginfo_t *t = 0;

    fcntl(fd, F_SETSIG, SIGRTMIN);
    fcntl(fd, F_NOTIFY, DN_DELETE|DN_CREATE|DN_MULTISHOT);

  ],kde_cv_have_dnotify=yes)

  AC_LANG_RESTORE
  ])

  if test "$kde_cv_have_dnotify" = "yes" ; then
    AC_DEFINE_UNQUOTED(HAVE_DNOTIFY, 1, [Define if your system has Linux Directory Notification])
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no)
  fi
fi
KDE_CHECK_SSL

DO_WE_HAVE_SSL=""

if test "$have_ssl" = yes; then
	DO_WE_HAVE_SSL="#define KSSL_HAVE_SSL 1"
fi

AC_SUBST(DO_WE_HAVE_SSL)
dnl AC_OUTPUT(kio/kssl/ksslconfig.h)

dnl some setgroups() implementations seem to have short* instead of gid_t*
dnl and use some flags in the fiels that follows the gids
AC_MSG_CHECKING([for setgroups with short argument])
AC_CACHE_VAL([kde_cv_shortsetgroups],[
    AC_TRY_RUN([
        int main()
        {
            short x[4];
            x[0] = x[1] = 1;
            if (getgroups(1, x) == 0) if (setgroups(1, x) == -1) exit(1);

            if (getgroups(1, x) == -1) exit(1);
            if (x[1] != 1) exit(1);
            x[1] = 2;
            if (getgroups(1, x) == -1) exit(1);
            if (x[1] != 2) exit(1);
            exit(0);
        }
    ],[kde_cv_shortsetgroups="yes"],[kde_cv_shortsetgroups="no"])
])
AC_MSG_RESULT($kde_cv_shortsetgroups)
if test "$kde_cv_shortsetgroups" = "yes"; then
    AC_DEFINE(HAVE_SHORTSETGROUPS,1,[if setgroups() takes short *as second arg])
fi
AC_FIND_BZIP2

AM_CONDITIONAL(include_bzip2, test -n "$BZIP2DIR")
if test -n "$BZIP2DIR"; then
  AC_DEFINE(HAVE_BZIP2_SUPPORT, 1, [Defines if bzip2 is compiled])
fi

dnl For kio_ftp
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_CHECK_FUNCS( setfsent )
AC_LANG_RESTORE  

dnl KDE JavaScript specific configure tests

AC_CHECK_HEADERS(ieeefp.h float.h)
AC_CHECK_LIB(m, isinf, [
  AC_DEFINE_UNQUOTED(HAVE_FUNC_ISINF, 1, [Define if you have isinf])
])
AC_CHECK_LIB(m, finite, [
  AC_DEFINE_UNQUOTED(HAVE_FUNC_FINITE, 1, [Define if you have finite])
])
AC_CHECK_LIB(m, _finite, [
  AC_DEFINE_UNQUOTED(HAVE_FUNC__FINITE, 1, [Define if you have _finite])
])
AC_CHECK_LIB(m, isnan, [
  AC_DEFINE_UNQUOTED(HAVE_FUNC_ISNAN, 1, [Define if you have isnan])
])

AC_DEFUN(AC_CHECK_PCREPOSIX,
[
  dnl define the configure option that disables pcre
  AC_ARG_ENABLE(pcre, [  --disable-pcre          don't require libpcre (poor RegExp support in Javascript)],
      with_pcre=$enableval, with_pcre=yes)

 if test "$with_pcre" = "yes"; then
   if test -n "$ac_cv_have_pcreposix"; then
     dnl doing this conditionnally because KDE_FIND_PATH outputs stuff too
     AC_MSG_CHECKING([for pcreposix])
    fi
    AC_CACHE_VAL(ac_cv_have_pcreposix,
    [
      ac_save_libs="$LIBS"
      KDE_FIND_PATH(pcre-config, PCRE_CONFIG, [${prefix}/bin /usr/local/bin /opt/local/bin], [PCRE_CONFIG="" ])
      if test -n "$PCRE_CONFIG" && $PCRE_CONFIG --libs >/dev/null 2>&1; then
          LIBS=`$PCRE_CONFIG --libs --libs-posix`
          PCRECFLAGS=`$PCRE_CONFIG --cflags`
          CPPFLAGS="$CPPFLAGS $PCRECFLAGS"
      else
          LIBS="-lpcre -lpcreposix"
      fi
      ac_CPPFLAGS_save="$CPPFLAGS"
      CPPFLAGS="$CPPFLAGS $all_includes"
      ac_LDFLAGS_save="$LDFLAGS"
      LDFLAGS="$LDFLAGS $all_libraries"
      AC_TRY_LINK(
        [#include <pcreposix.h>],
        [regfree(0);],
        [ac_cv_have_pcreposix="yes"],
        [ac_cv_have_pcreposix="no"]
      )
      LIBS="$ac_save_libs"
      LDFLAGS="$ac_LDFLAGS_save"
      CPPFLAGS="$ac_CPPFLAGS_save"
      dnl doing this last because KDE_FIND_PATH outputs stuff too
      AC_MSG_CHECKING([for pcreposix])
    ])
    AC_MSG_RESULT($ac_cv_have_pcreposix)
    if test "$ac_cv_have_pcreposix" = "yes"; then
      LIBPCRE="-lpcre -lpcreposix"
      AC_DEFINE(HAVE_PCREPOSIX, 1, [Define if you have pcreposix libraries and header files.])
    else
      AC_MSG_ERROR([You're missing libpcre.
Download libpcre from http://www.pcre.org or find a binary package for your platform.
Alternatively, you can specify --disable-pcre, but some web pages - using regular
expressions in Javascript code - will not work correctly, the regexp support being
quite limited if libpcre isn't present.])
    fi
    AC_MSG_CHECKING([for pcre cflags])
    AC_CACHE_VAL(ac_cv_pcre_cflags,[ac_cv_pcre_cflags="$PCRECFLAGS"])
    if test -z "$ac_cv_pcre_cflags"; then
      AC_MSG_RESULT("none")
    else
      AC_MSG_RESULT($ac_cv_pcre_cflags)
      PCRECFLAGS="$ac_cv_pcre_cflags"
    fi
  fi
])
AC_CHECK_PCREPOSIX
AC_SUBST(LIBPCRE)
AC_SUBST(PCRECFLAGS)
DO_NOT_COMPILE="$DO_NOT_COMPILE ksmartcard"
SMARTCARDDIR=
AC_SUBST(SMARTCARDDIR)
PCSC_LDFLAGS=
AC_SUBST(PCSC_LDFLAGS)
PCSC_INCLUDES=
AC_SUBST(PCSC_INCLUDES)
DO_NOT_COMPILE="$DO_NOT_COMPILE kwallet"
dnl libkmid's specific checks

#AC_MSG_CHECKING(if libkmid would compile)
#AC_CACHE_VAL(kde_libkmid_compiles,
#[
#AC_TRY_COMPILE([
##ifndef __FreeBSD__
##include <sys/soundcard.h>
##else
##include <machine/soundcard.h>
##endif
#],
#[
#],
#  kde_libmid_compiles=yes,
#kde_libmid_compiles=no)
#])
#AC_MSG_RESULT($kde_libmid_compiles)
#if test $kde_libmid_compiles = no; then
#  DO_NOT_COMPILE="$DO_NOT_COMPILE libkmid"
#fi

#AC_MSG_CHECKING([for OSS support])
#AC_CACHE_VAL(ac_cv_header_soundcard_h,
#[
#AC_TRY_COMPILE([
##include <unistd.h>
#],
#[ ],
#ac_cv_header_soundcard_h=yes,
#ac_cv_header_soundcard_h=no)
#])
#AC_MSG_RESULT($ac_cv_header_soundcard_h)
#if eval "test \"`echo $ac_cv_header_soundcard_h`\" = yes"; then
#  AC_DEFINE(HAVE_GETHOSTNAME, 1, [Define if you have getdomainname])
#fi
#CXXFLAGS="$save_CXXFLAGS"
#])


AC_CHECK_HEADERS(sys/soundcard.h machine/soundcard.h linux/awe_voice.h awe_voice.h /usr/src/sys/i386/isa/sound/awe_voice.h /usr/src/sys/gnu/i386/isa/sound/awe_voice.h)  

dnl check for ALSA audio support

kde_with_alsa=yes
AC_ARG_WITH(alsa, [  --with-alsa             enable libKMid ALSA support],
[kde_with_alsa=$withval])

if test "$kde_with_alsa" = "yes"; then
AC_DEFUN([AC_CHECK_LIBASOUND],
[
  ac_ldflags_save="$LDFLAGS"
  LDFLAGS="$all_libraries $LDFLAGS"
  kde_has_asoundlib=no

  AC_CHECK_HEADERS([ sys/asoundlib.h alsa/asoundlib.h ],
  [
    kde_has_asoundlib=yes
  ])

  dnl trial and error version check for ALSA 0.5.x / ALSA 0.9.x
  AC_LANG_SAVE
  AC_LANG_C
  if test "x$kde_has_asoundlib" = "xyes"; then
    AC_TRY_COMPILE([
      #include "confdefs.h"
      #ifdef HAVE_SYS_ASOUNDLIB_H
      #include <sys/asoundlib.h>
      #endif
      #ifdef HAVE_ALSA_ASOUNDLIB_H
      #include <alsa/asoundlib.h>
      #endif
    ],[
      #if (SND_LIB_MAJOR == 0) && (SND_LIB_MINOR == 9)
        /* we have ALSA 0.9.x */
      #else
        #error not ALSA 0.9.x
      #endif
    ],
    kde_has_alsa_0_9=yes,
    kde_has_alsa_0_9=no)
  fi

  if test "x$kde_has_asoundlib" = "xyes"; then
    AC_TRY_COMPILE([
      #include "confdefs.h"
      #ifdef HAVE_SYS_ASOUNDLIB_H
      #include <sys/asoundlib.h>
      #endif
      #ifdef HAVE_ALSA_ASOUNDLIB_H
      #include <alsa/asoundlib.h>
      #endif
    ],[
    #if (SND_LIB_MAJOR == 0) && (SND_LIB_MINOR == 5)
      /* we have ALSA 0.5.x */
    #else
      #error not ALSA 0.5.x
    #endif
    ],
    kde_has_alsa_0_5=yes,
    kde_has_alsa_0_5=no)
  fi
  AC_LANG_RESTORE

  if test "x$kde_has_asoundlib" = "xyes"; then
    AC_CHECK_LIB(asound,snd_seq_create_simple_port,[
      if test "x$kde_has_alsa_0_5" = "xyes"; then
        LIBASOUND="-lasound"
        AC_DEFINE(HAVE_LIBASOUND, 1,
        [Define if you have libasound.so.1 (required for ALSA 0.5.x support)])
      fi
      if test "x$kde_has_alsa_0_9" = "xyes"; then
        LIBASOUND="-lasound"
        AC_DEFINE(HAVE_LIBASOUND2, 1,
          [Define if you have libasound.so.2 (required for ALSA 0.9.x support)])
        AC_CHECK_LIB(asound,snd_pcm_resume,[
          AC_DEFINE(HAVE_SND_PCM_RESUME, 1,
            [Define if libasound has snd_pcm_resume()])])
      fi
    ])
  fi
  AC_SUBST(LIBASOUND)
  LDFLAGS="$ac_ldflags_save"
])
AC_CHECK_LIBASOUND
fi

AC_SUBST(LIBASOUND)

dnl put here things which have to be done after all usual autoconf macros
dnl have been run, but before the Makefiles are created

all_includes='-I$(top_srcdir)/dcop -I$(top_srcdir)/libltdl -I$(top_srcdir)/kdecore -I$(top_srcdir)/kdeui -I$(top_srcdir)/kio -I$(top_srcdir)/kio/kio -I$(top_srcdir)/kio/kfile -I$(top_srcdir) $(QT_INCLUDES) $(X_INCLUDES) $(KDE_INCLUDES) $(USER_INCLUDES)'
AC_SUBST(all_includes)

CXXFLAGS="$CXXFLAGS -DQT_NO_TRANSLATION -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_COMPAT"
KDE_CREATE_SUBDIRSLIST
AM_CONDITIONAL(dcop_SUBDIR_included, test "x$dcop_SUBDIR_included" = xyes)
AM_CONDITIONAL(libltdl_SUBDIR_included, test "x$libltdl_SUBDIR_included" = xyes)
AM_CONDITIONAL(kdefx_SUBDIR_included, test "x$kdefx_SUBDIR_included" = xyes)
AM_CONDITIONAL(kdecore_SUBDIR_included, test "x$kdecore_SUBDIR_included" = xyes)
AM_CONDITIONAL(kdeui_SUBDIR_included, test "x$kdeui_SUBDIR_included" = xyes)
AM_CONDITIONAL(kdesu_SUBDIR_included, test "x$kdesu_SUBDIR_included" = xyes)
AM_CONDITIONAL(kjs_SUBDIR_included, test "x$kjs_SUBDIR_included" = xyes)
AM_CONDITIONAL(kio_SUBDIR_included, test "x$kio_SUBDIR_included" = xyes)
AM_CONDITIONAL(arts_SUBDIR_included, test "x$arts_SUBDIR_included" = xyes)
AM_CONDITIONAL(kab_SUBDIR_included, test "x$kab_SUBDIR_included" = xyes)
AM_CONDITIONAL(kconf_update_SUBDIR_included, test "x$kconf_update_SUBDIR_included" = xyes)
AM_CONDITIONAL(kded_SUBDIR_included, test "x$kded_SUBDIR_included" = xyes)
AM_CONDITIONAL(kdewidgets_SUBDIR_included, test "x$kdewidgets_SUBDIR_included" = xyes)
AM_CONDITIONAL(kdoctools_SUBDIR_included, test "x$kdoctools_SUBDIR_included" = xyes)
AM_CONDITIONAL(kimgio_SUBDIR_included, test "x$kimgio_SUBDIR_included" = xyes)
AM_CONDITIONAL(kioslave_SUBDIR_included, test "x$kioslave_SUBDIR_included" = xyes)
AM_CONDITIONAL(kparts_SUBDIR_included, test "x$kparts_SUBDIR_included" = xyes)
AM_CONDITIONAL(ksmartcard_SUBDIR_included, test "x$ksmartcard_SUBDIR_included" = xyes)
AM_CONDITIONAL(kspell_SUBDIR_included, test "x$kspell_SUBDIR_included" = xyes)
AM_CONDITIONAL(kstyles_SUBDIR_included, test "x$kstyles_SUBDIR_included" = xyes)
AM_CONDITIONAL(kutils_SUBDIR_included, test "x$kutils_SUBDIR_included" = xyes)
AM_CONDITIONAL(kwallet_SUBDIR_included, test "x$kwallet_SUBDIR_included" = xyes)
AM_CONDITIONAL(libkmid_SUBDIR_included, test "x$libkmid_SUBDIR_included" = xyes)
AM_CONDITIONAL(libkscreensaver_SUBDIR_included, test "x$libkscreensaver_SUBDIR_included" = xyes)
AM_CONDITIONAL(licenses_SUBDIR_included, test "x$licenses_SUBDIR_included" = xyes)
AM_CONDITIONAL(mimetypes_SUBDIR_included, test "x$mimetypes_SUBDIR_included" = xyes)
AM_CONDITIONAL(pics_SUBDIR_included, test "x$pics_SUBDIR_included" = xyes)
AM_CONDITIONAL(kabc_SUBDIR_included, test "x$kabc_SUBDIR_included" = xyes)
AM_CONDITIONAL(doc_SUBDIR_included, test "x$doc_SUBDIR_included" = xyes)
AM_CONDITIONAL(kcert_SUBDIR_included, test "x$kcert_SUBDIR_included" = xyes)
AM_CONDITIONAL(interfaces_SUBDIR_included, test "x$interfaces_SUBDIR_included" = xyes)
AM_CONDITIONAL(kinit_SUBDIR_included, test "x$kinit_SUBDIR_included" = xyes)
AM_CONDITIONAL(kdeprint_SUBDIR_included, test "x$kdeprint_SUBDIR_included" = xyes)
AM_CONDITIONAL(khtml_SUBDIR_included, test "x$khtml_SUBDIR_included" = xyes)
AM_CONDITIONAL(kate_SUBDIR_included, test "x$kate_SUBDIR_included" = xyes)
AC_CONFIG_FILES([ Makefile ])
AC_CONFIG_FILES([ arts/Makefile ])
AC_CONFIG_FILES([ arts/kde/Makefile ])
AC_CONFIG_FILES([ arts/kde/mcop-dcop/Makefile ])
AC_CONFIG_FILES([ arts/knotify/Makefile ])
AC_CONFIG_FILES([ arts/message/Makefile ])
AC_CONFIG_FILES([ dcop/Makefile ])
AC_CONFIG_FILES([ dcop/KDE-ICE/Makefile ])
AC_CONFIG_FILES([ dcop/client/Makefile ])
AC_CONFIG_FILES([ dcop/dcopidl/Makefile ])
AC_CONFIG_FILES([ dcop/dcopidl2cpp/Makefile ])
AC_CONFIG_FILES([ doc/Makefile ])
AC_CONFIG_FILES([ doc/common/Makefile ])
AC_CONFIG_FILES([ doc/kspell/Makefile ])
AC_CONFIG_FILES([ interfaces/Makefile ])
AC_CONFIG_FILES([ interfaces/kio/Makefile ])
AC_CONFIG_FILES([ interfaces/kmediaplayer/Makefile ])
AC_CONFIG_FILES([ interfaces/kregexpeditor/Makefile ])
AC_CONFIG_FILES([ interfaces/kscript/Makefile ])
AC_CONFIG_FILES([ interfaces/kscript/sample/Makefile ])
AC_CONFIG_FILES([ interfaces/ktexteditor/Makefile ])
AC_CONFIG_FILES([ kab/Makefile ])
AC_CONFIG_FILES([ kabc/Makefile ])
AC_CONFIG_FILES([ kabc/formats/Makefile ])
AC_CONFIG_FILES([ kabc/plugins/Makefile ])
AC_CONFIG_FILES([ kabc/plugins/dir/Makefile ])
AC_CONFIG_FILES([ kabc/plugins/imap/Makefile ])
AC_CONFIG_FILES([ kabc/plugins/ldap/Makefile ])
AC_CONFIG_FILES([ kabc/plugins/net/Makefile ])
AC_CONFIG_FILES([ kabc/plugins/sql/Makefile ])
AC_CONFIG_FILES([ kabc/vcard/Makefile ])
AC_CONFIG_FILES([ kate/Makefile ])
AC_CONFIG_FILES([ kate/data/Makefile ])
AC_CONFIG_FILES([ kate/interfaces/Makefile ])
AC_CONFIG_FILES([ kate/part/Makefile ])
AC_CONFIG_FILES([ kate/plugins/Makefile ])
AC_CONFIG_FILES([ kate/plugins/insertfile/Makefile ])
AC_CONFIG_FILES([ kate/plugins/isearch/Makefile ])
AC_CONFIG_FILES([ kate/plugins/kdatatool/Makefile ])
AC_CONFIG_FILES([ kcert/Makefile ])
AC_CONFIG_FILES([ kconf_update/Makefile ])
AC_CONFIG_FILES([ kdecore/Makefile ])
AC_CONFIG_FILES([ kdecore/malloc/Makefile ])
AC_CONFIG_FILES([ kdecore/svgicons/Makefile ])
AC_CONFIG_FILES([ kdecore/tests/Makefile ])
AC_CONFIG_FILES([ kded/Makefile ])
AC_CONFIG_FILES([ kded/test/Makefile ])
AC_CONFIG_FILES([ kdefx/Makefile ])
AC_CONFIG_FILES([ kdeprint/Makefile ])
AC_CONFIG_FILES([ kdeprint/cups/Makefile ])
AC_CONFIG_FILES([ kdeprint/cups/cupsdconf/Makefile ])
AC_CONFIG_FILES([ kdeprint/cups/cupsdconf2/Makefile ])
AC_CONFIG_FILES([ kdeprint/ext/Makefile ])
AC_CONFIG_FILES([ kdeprint/filters/Makefile ])
AC_CONFIG_FILES([ kdeprint/foomatic/Makefile ])
AC_CONFIG_FILES([ kdeprint/lpd/Makefile ])
AC_CONFIG_FILES([ kdeprint/lpdunix/Makefile ])
AC_CONFIG_FILES([ kdeprint/lpr/Makefile ])
AC_CONFIG_FILES([ kdeprint/management/Makefile ])
AC_CONFIG_FILES([ kdeprint/pics/Makefile ])
AC_CONFIG_FILES([ kdeprint/rlpr/Makefile ])
AC_CONFIG_FILES([ kdeprint/tests/Makefile ])
AC_CONFIG_FILES([ kdeprint/tools/Makefile ])
AC_CONFIG_FILES([ kdeprint/tools/escputil/Makefile ])
AC_CONFIG_FILES([ kdesu/Makefile ])
AC_CONFIG_FILES([ kdeui/Makefile ])
AC_CONFIG_FILES([ kdeui/tests/Makefile ])
AC_CONFIG_FILES([ kdewidgets/Makefile ])
AC_CONFIG_FILES([ kdewidgets/pics/Makefile ])
AC_CONFIG_FILES([ kdoctools/Makefile ])
AC_CONFIG_FILES([ khtml/Makefile ])
AC_CONFIG_FILES([ khtml/css/Makefile ])
AC_CONFIG_FILES([ khtml/dom/Makefile ])
AC_CONFIG_FILES([ khtml/ecma/Makefile ])
AC_CONFIG_FILES([ khtml/html/Makefile ])
AC_CONFIG_FILES([ khtml/java/Makefile ])
AC_CONFIG_FILES([ khtml/java/dummy/Makefile ])
AC_CONFIG_FILES([ khtml/java/tests/Makefile ])
AC_CONFIG_FILES([ khtml/kmultipart/Makefile ])
AC_CONFIG_FILES([ khtml/misc/Makefile ])
AC_CONFIG_FILES([ khtml/pics/Makefile ])
AC_CONFIG_FILES([ khtml/rendering/Makefile ])
AC_CONFIG_FILES([ khtml/xml/Makefile ])
AC_CONFIG_FILES([ kimgio/Makefile ])
AC_CONFIG_FILES([ kinit/Makefile ])
AC_CONFIG_FILES([ kinit/tests/Makefile ])
AC_CONFIG_FILES([ kio/Makefile ])
AC_CONFIG_FILES([ kio/bookmarks/Makefile ])
AC_CONFIG_FILES([ kio/kfile/Makefile ])
AC_CONFIG_FILES([ kio/kfile/tests/Makefile ])
AC_CONFIG_FILES([ kio/kio/Makefile ])
AC_CONFIG_FILES([ kio/kpasswdserver/Makefile ])
AC_CONFIG_FILES([ kio/kssl/Makefile ])
AC_CONFIG_FILES([ kio/kssl/kssl/Makefile ])
AC_CONFIG_FILES([ kio/kssl/kssl/caroot/Makefile ])
AC_CONFIG_FILES([ kio/misc/Makefile ])
AC_CONFIG_FILES([ kio/misc/kdesasl/Makefile ])
AC_CONFIG_FILES([ kio/misc/kfile/Makefile ])
AC_CONFIG_FILES([ kio/misc/kpac/Makefile ])
AC_CONFIG_FILES([ kio/misc/ksendbugmail/Makefile ])
AC_CONFIG_FILES([ kio/misc/kssld/Makefile ])
AC_CONFIG_FILES([ kio/pics/Makefile ])
AC_CONFIG_FILES([ kio/tests/Makefile ])
AC_CONFIG_FILES([ kioslave/Makefile ])
AC_CONFIG_FILES([ kioslave/bzip2/Makefile ])
AC_CONFIG_FILES([ kioslave/file/Makefile ])
AC_CONFIG_FILES([ kioslave/ftp/Makefile ])
AC_CONFIG_FILES([ kioslave/gzip/Makefile ])
AC_CONFIG_FILES([ kioslave/http/Makefile ])
AC_CONFIG_FILES([ kioslave/http/kcookiejar/Makefile ])
AC_CONFIG_FILES([ kioslave/http/kcookiejar/tests/Makefile ])
AC_CONFIG_FILES([ kioslave/metainfo/Makefile ])
AC_CONFIG_FILES([ kjs/Makefile ])
AC_CONFIG_FILES([ kparts/Makefile ])
AC_CONFIG_FILES([ kparts/tests/Makefile ])
AC_CONFIG_FILES([ ksmartcard/Makefile ])
AC_CONFIG_FILES([ ksmartcard/kardimpl/Makefile ])
AC_CONFIG_FILES([ ksmartcard/kardlib/Makefile ])
AC_CONFIG_FILES([ ksmartcard/kardsvc/Makefile ])
AC_CONFIG_FILES([ kspell/Makefile ])
AC_CONFIG_FILES([ kstyles/Makefile ])
AC_CONFIG_FILES([ kstyles/highcolor/Makefile ])
AC_CONFIG_FILES([ kstyles/keramik/Makefile ])
AC_CONFIG_FILES([ kstyles/klegacy/Makefile ])
AC_CONFIG_FILES([ kstyles/kthemestyle/Makefile ])
AC_CONFIG_FILES([ kstyles/light/Makefile ])
AC_CONFIG_FILES([ kstyles/pics/Makefile ])
AC_CONFIG_FILES([ kstyles/riscos/Makefile ])
AC_CONFIG_FILES([ kstyles/themes/Makefile ])
AC_CONFIG_FILES([ kstyles/utils/Makefile ])
AC_CONFIG_FILES([ kstyles/utils/installtheme/Makefile ])
AC_CONFIG_FILES([ kstyles/web/Makefile ])
AC_CONFIG_FILES([ kutils/Makefile ])
AC_CONFIG_FILES([ kutils/tests/Makefile ])
AC_CONFIG_FILES([ kwallet/Makefile ])
AC_CONFIG_FILES([ kwallet/backend/Makefile ])
AC_CONFIG_FILES([ kwallet/backend/tests/Makefile ])
AC_CONFIG_FILES([ kwallet/client/Makefile ])
AC_CONFIG_FILES([ libkmid/Makefile ])
AC_CONFIG_FILES([ libkmid/tests/Makefile ])
AC_CONFIG_FILES([ libkscreensaver/Makefile ])
AC_CONFIG_FILES([ libltdl/Makefile ])
AC_CONFIG_FILES([ licenses/Makefile ])
AC_CONFIG_FILES([ mimetypes/Makefile ])
AC_CONFIG_FILES([ mimetypes/application/Makefile ])
AC_CONFIG_FILES([ mimetypes/audio/Makefile ])
AC_CONFIG_FILES([ mimetypes/image/Makefile ])
AC_CONFIG_FILES([ mimetypes/inode/Makefile ])
AC_CONFIG_FILES([ mimetypes/message/Makefile ])
AC_CONFIG_FILES([ mimetypes/multipart/Makefile ])
AC_CONFIG_FILES([ mimetypes/text/Makefile ])
AC_CONFIG_FILES([ mimetypes/video/Makefile ])
AC_CONFIG_FILES([ pics/Makefile ])
AC_CONFIG_FILES([ pics/crystalsvg/Makefile ])
AC_CONFIG_FILES([ pics/crystalsvg/kde/Makefile ])
AC_CONFIG_FILES([ pics/hicolor/Makefile ])
AC_CONFIG_FILES([ pics/hicolor/kde/Makefile ])
AC_CONFIG_FILES([ dcop/dcop-path.h ])
AC_CONFIG_FILES([ kdecore/kde-config.cpp ])
AC_CONFIG_FILES([ kdoctools/checkXML ])
AC_CONFIG_FILES([ khtml/java/kjava.policy ])
AC_CONFIG_FILES([ kio/kssl/ksslconfig.h ])
AC_OUTPUT
dnl put here things which have to be done as very last part of configure

if test "x$have_ssl" != xyes; then
  echo ""
  echo "You're missing openSSL, or your version is too old (before 0.9.5a)."
  echo "KDE won't be able to access secure websites without it, so you should"
  echo "consider installing or upgrading it."
  echo "Have a look at http://www.openssl.org, or find a binary package for"
  echo "your platform."
  echo ""
  all_tests=bad
fi

if test -z "$LIBART_CONFIG"; then
  echo ""
  echo "You're missing libART LGPL, or your version is too old (before 2.3.8)."
  echo "KDE won't be able to render SVG icons without it, so you should"
  echo "consider installing or upgrading it."
  echo "Have a look at http://www.levien.com (official site) or"
  echo "http://svg.kde.org/download.html for sources, or find a binary"
  echo "package for your platform."
  echo ""
  all_tests=bad
fi

if test -z "$LIBPCRE"; then
  echo ""
  echo "You're missing libpcre."
  echo "Some web pages (using regular expressions in Javascript code) will not "
  echo "work correctly, the regexp support being limited without libpcre. "
  echo "If you plan to use Konqueror as a Web Browser, download libpcre from "
  echo "http://www.pcre.org or find a binary package for your platform."
  echo ""
  all_tests=bad
fi

if test -z "$LIBBZ2"; then
  echo ""
  echo "You're missing bzip2 development files."
  echo "KDE won't be able to provide a help ioslave (help://) without it,"
  echo "so if you want helpfiles you should consider installing it."
  echo "Have a look at http://sources.redhat.com/bzip2/ for sources, "
  echo "or find a binary package for your platform."
  echo ""
  all_tests=bad
fi

if test -z "$LIBXML_CFLAGS"; then
  echo ""
  echo "You're missing libxml2 2.4.8 or later."
  echo "KDE won't be able to provide a help ioslave (help://) without it,"
  echo "so if you want helpfiles you should consider installing it."
  echo "Have a look at ftp://xmlsoft.org/ for sources, or find a binary"
  echo "package for your platform."
  echo "You can find a copy of libxml2 in the kdesupport module if you're using CVS."
  echo ""
  all_tests=bad
fi

if test -z "$LIBXSLT_CFLAGS"; then
  echo ""
  echo "You're missing libxslt 1.0.7 or later."
  echo "KDE won't be able to provide a help ioslave (help://) without it,"
  echo "so if you want helpfiles you should consider installing it."
  echo "Have a look at ftp://xmlsoft.org/ for sources, or find a binary"
  echo "package for your platform."
  echo "You can find a copy of libxslt in the kdesupport module if you're using CVS."
  echo ""
  all_tests=bad
fi

if test -z "$jpeg_incdir" || test -z "$LIBJPEG" ; then
  echo ""
  echo "You're missing libjpeg 6 or later."
  echo "KDE won't be able to display JPEG and many web pages won't"
  echo "work because of this."
  echo "You may need to either provide correct --with-extra-... options,"
  echo "or the development package of libjpeg6b. You can get a source "
  echo "package of libjpeg from http://www.ijg.org/"
  echo ""
  all_tests=bad
fi 

if test "$ac_use_cups" != "yes"; then
  if test "$ac_have_new_cups" != "yes"; then
    echo ""
    echo "The installed CUPS version is too old. The minimum"
    echo "required version is 1.1.9. Please upgrade your CUPS"
    echo "installation from http://www.cups.org. CUPS support"
    echo "has been disabled."
    echo ""
  else
    echo ""
    echo "You're missing CUPS (Common UNIX Printing System) support."
    echo "If you want CUPS support, please install CUPS from http://www.cups.org"
    echo "or the development packages of your distribution."
    echo ""
  fi
  all_tests=bad
fi
if test "$all_tests" = "bad"; then
  if test ! "$cache_file" = "/dev/null"; then
    echo ""    
    echo "Please remove the file $cache_file after changing your setup"
    echo "so that configure will find the changes next time."
    echo ""
  fi
else
  echo ""
  echo "Good - your configure finished. Start make now"
  echo ""
fi
