dnl Process this file with autoconf to produce a configure script.

AC_INIT(configure.in)
AM_INIT_AUTOMAKE(syncml_plugin, 0.82)
AM_MAINTAINER_MODE
AM_CONFIG_HEADER(config.h)

AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AC_HEADER_STDC

pkg_modules="libgnomeui-2.0 glib-2.0 libxml-2.0"
PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)


AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AC_HEADER_STDC
AC_PROG_LIBTOOL

AC_CHECK_LIB(pthread,pthread_create,,AC_MSG_ERROR(You must have libpthread installed.))
AC_CHECK_LIB(crypto,RAND_bytes,,AC_MSG_ERROR(You must have libcrypto (OpenSSL) installed.))
AC_CHECK_LIB(ssl,SSL_write,,AC_MSG_ERROR(You must have libssl (OpenSSL) installed.))
dnl Disable kerberos stuff
AC_DEFINE(OPENSSL_NO_KRB5,1,Disable SSL kerberos)
dnl Check for 0.8.1 or later of libwbxml2
AC_CHECK_LIB(wbxml2, wbxml_conv_wbxml2xml)
AC_MSG_CHECKING(for correct libwbxml2 version)
AC_TRY_COMPILE([#include <wbxml.h>],[WBXMLConvXML2WBXMLParams w; w.wbxml_version = WBXML_VERSION_11 ],AC_MSG_RESULT(yes);LIBWBXML=1,AC_MSG_RESULT(no);LIBWBXML=0)
AC_DEFINE_UNQUOTED(USE_LIBWBXML, ${LIBWBXML},Defined if the correct libwbxml2 version exists.)
if test "x${LIBWBXML}" = "x0"; then
   echo "To enable WBXML communication (for e.g. cell phones) you must have version 0.8.1 or later of libwbxml2."
fi

dnl Debug feature
AC_ARG_ENABLE(debug, Turn on debug output, DEBUG=1, DEBUG=0)
AC_DEFINE_UNQUOTED(SYNCML_DEBUG,${DEBUG},Debug printouts)

dnl Info for the RPM
MULTISYNC_TOP="../.."
AC_SUBST(VERSION)
AC_SUBST(prefix)
MULTISYNC_VERSION=`grep "#define VERSION" ${MULTISYNC_TOP}/config.h | sed -e 's/#define VERSION //g' | sed -e 's/\"//g'`
AC_SUBST(MULTISYNC_VERSION)
AC_SUBST(EVO_RPM_VER)

AC_OUTPUT([
Makefile
src/Makefile
${MULTISYNC_TOP}/specs/multisync-syncml.spec
])

