[evolution-exchange] Bug #591953 - Rewrite of build system



commit 2721f837044dffb956053df372868e3511bafcda
Author: H. Habighorst <h habighorst googlemail com>
Date:   Fri Oct 9 12:33:53 2009 +0200

    Bug #591953 - Rewrite of build system

 Makefile.am                     |    2 +
 acinclude.m4                    |  333 ------------------------
 addressbook/Makefile.am         |   45 ++--
 autogen.sh                      |    5 +-
 calendar/Makefile.am            |    8 +-
 camel/Makefile.am               |    5 +-
 camel/camel-exchange-utils.c    |    2 +-
 configure.ac                    |  535 +++++++++++++++++++--------------------
 docs/reference/Makefile.am      |   32 +--
 docs/reference/gtk-doc.make     |  149 -----------
 eplugin/Makefile.am             |    3 +-
 m4/as-compiler-flag.m4          |   61 +++++
 m4/evo_ldap_check.m4            |   92 +++++++
 m4/evo_pthread_check.m4         |   16 ++
 m4/evo_sunldap_check.m4         |   94 +++++++
 server/lib/e2k-global-catalog.c |    3 +-
 tools/Makefile.am               |   37 ++-
 17 files changed, 599 insertions(+), 823 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 3b7447e..40b1f59 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,5 @@
+ACLOCAL_AMFLAGS=-I m4
+
 SUBDIRS = \
 	server \
 	eplugin \
diff --git a/addressbook/Makefile.am b/addressbook/Makefile.am
index 81b27a3..2a50377 100644
--- a/addressbook/Makefile.am
+++ b/addressbook/Makefile.am
@@ -1,16 +1,3 @@
-AM_CPPFLAGS = \
-	-I$(top_srcdir) \
-	-I$(top_srcdir)/server/lib \
-	-I$(top_srcdir)/server/storage \
-	-I$(top_builddir)/server/lib \
-	-DG_LOG_DOMAIN=\"e-book-backend-exchange\" \
-	$(EVOLUTION_DATA_SERVER_CFLAGS) \
-	$(LDAP_CFLAGS)
-
-if HAVE_LIBDB
-AM_CPPFLAGS += $(DB_CFLAGS)
-endif
-
 # GConf schemas
 
 schemadir = $(GCONF_SCHEMA_FILE_DIR)
@@ -41,30 +28,36 @@ endif
 
 extension_LTLIBRARIES = libebookbackendexchange.la
 
+libebookbackendexchange_la_CPPFLAGS = \
+	$(AM_CPPFLAGS) \
+	-I$(top_srcdir) \
+	-I$(top_srcdir)/server/lib \
+	-I$(top_srcdir)/server/storage \
+	-I$(top_builddir)/server/lib \
+	-DG_LOG_DOMAIN=\"e-book-backend-exchange\" \
+	$(EVOLUTION_DATA_SERVER_CFLAGS) \
+	$(LDAP_CFLAGS) \
+	$(DB_CFLAGS)
+
 libebookbackendexchange_la_SOURCES = \
 	e-book-backend-exchange.c \
 	e-book-backend-exchange.h \
 	e-book-backend-exchange-factory.c \
 	e-book-backend-gal.c \
-	e-book-backend-gal.h
-
-libebookbackendexchange_la_LIBADD = \
-	$(top_builddir)/tools/libevolution-exchange-shared.la \
-	$(EVOLUTION_DATA_SERVER_LIBS)
-
-if HAVE_LIBDB
-libebookbackendexchange_la_SOURCES += \
+	e-book-backend-gal.h \
 	e-book-backend-db-cache.c \
 	e-book-backend-db-cache.h
 
 libebookbackendexchange_la_LDFLAGS = \
 	-module -avoid-version $(NO_UNDEFINED)
-endif
 
-EXTRA_DIST = \
-	$(schema_in_files)
+libebookbackendexchange_la_LIBADD = \
+	$(EVOLUTION_DATA_SERVER_LIBS) \
+	$(DB_LIBS) \
+	$(top_builddir)/tools/libevolution-exchange-shared.la
+
+EXTRA_DIST = $(schema_in_files)
 
-CLEANFILES = \
-	apps_exchange_addressbook-$(BASE_VERSION).schemas
+CLEANFILES = apps_exchange_addressbook-$(BASE_VERSION).schemas
 
 -include $(top_srcdir)/git.mk
diff --git a/autogen.sh b/autogen.sh
index dbbfd8b..a4cae7d 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -5,7 +5,10 @@ srcdir=`dirname $0`
 test -z "$srcdir" && srcdir=.
 
 PKG_NAME="evolution-exchange"
-REQUIRED_AUTOMAKE_VERSION=1.6
+REQUIRED_AUTOCONF_VERSION=2.58
+REQUIRED_AUTOMAKE_VERSION=1.9
+REQUIRED_LIBTOOL_VERSION=2.2
+REQUIRED_INTLTOOL_VERSION=0.35.5
 
 (test -f $srcdir/configure.ac \
   && test -f $srcdir/ChangeLog \
diff --git a/calendar/Makefile.am b/calendar/Makefile.am
index 53b3ae2..b7855a9 100644
--- a/calendar/Makefile.am
+++ b/calendar/Makefile.am
@@ -1,4 +1,7 @@
-AM_CPPFLAGS = \
+extension_LTLIBRARIES = libecalbackendexchange.la
+
+libecalbackendexchange_la_CPPFLAGS = \
+	$(AM_CPPFLAGS) \
 	-I$(top_srcdir) \
 	-I$(top_srcdir)/server/lib \
 	-I$(top_srcdir)/server/storage \
@@ -7,9 +10,6 @@ AM_CPPFLAGS = \
 	$(EVOLUTION_DATA_SERVER_CFLAGS) \
 	$(LDAP_CFLAGS)
 
-extension_LTLIBRARIES = \
-        libecalbackendexchange.la
-
 libecalbackendexchange_la_SOURCES = \
 	e-cal-backend-exchange.c \
 	e-cal-backend-exchange.h \
diff --git a/camel/Makefile.am b/camel/Makefile.am
index 155f68a..ce989b4 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -3,10 +3,11 @@
 CAMEL_provider_LTLIBRARIES = libcamelexchange.la
 CAMEL_provider_DATA = libcamelexchange.urls
 
-AM_CPPFLAGS = \
-	$(WARN_CFLAGS) \
+libcamelexchange_la_CPPFLAGS = \
+	$(AM_CPPFLAGS) \
 	$(EVOLUTION_PLUGIN_CFLAGS) \
 	-I$(top_srcdir) \
+	-I$(top_srcdir)/tools \
 	-I$(top_srcdir)/server/lib \
 	-I$(top_srcdir)/server/storage \
 	-I$(top_builddir)/server/lib \
diff --git a/camel/camel-exchange-utils.c b/camel/camel-exchange-utils.c
index c53f18d..0b6bfa4 100644
--- a/camel/camel-exchange-utils.c
+++ b/camel/camel-exchange-utils.c
@@ -43,7 +43,7 @@
 #include "camel-exchange-utils.h"
 #include "mail-utils.h"
 
-#include "tools/exchange-share-config-listener.h"
+#include "exchange-share-config-listener.h"
 
 #define d(x)
 
diff --git a/configure.ac b/configure.ac
index 9e29c44..18e258d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,80 +1,36 @@
-# Process this file with autoconf to produce a configure script.
-AC_PREREQ(2.52)
-
+dnl Sets the evolution exchange version.
 m4_define([eex_version], [2.29.1])
 
-AC_INIT(evolution-exchange, [eex_version], http://bugzilla.gnome.org/enter_bug.cgi?product=Evolution%20Exchange)
+dnl Initializes automake/autoconf
+AC_PREREQ(2.58)
+AC_INIT([evolution-exchange], [eex_version], [http://bugzilla.gnome.org/enter_bug.cgi?product=Evolution%20Exchange])
+AM_INIT_AUTOMAKE([gnu 1.9])
+AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_SRCDIR(camel)
-AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
+AC_CONFIG_HEADERS(config.h)
+
+dnl Automake 1.11 - Silent Build Rules
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
-# Required Package Versions
+dnl Required Package Versions
 m4_define([glib_minimum_version], [2.16.0])
 m4_define([gtk_minimum_version], [2.10.0])
 m4_define([eds_minimum_version], [eex_version])
 m4_define([evo_minimum_version], [eex_version])
-m4_define([gconf_minimum_version], [2.0.0])             # XXX Just a Guess
-m4_define([libxml_minimum_version], [2.0.0])            # XXX Just a Guess
+m4_define([gconf_minimum_version], [2.0.0])		dnl XXX Just a Guess
+m4_define([libxml_minimum_version], [2.0.0])		dnl XXX Just a Guess
 m4_define([libsoup_minimum_version], [2.3.0])
 
-AM_CONFIG_HEADER(config.h)
-
-# Automake 1.11 - Silent Build Rules
-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
-
-AC_ARG_WITH(e2k-debug,     [  --with-e2k-debug              Allow debugging])
-case $withval in
-no)
-	;;
-*)
-	AC_DEFINE(E2K_DEBUG, 1, [Define if you want E2K_DEBUG to be available])
-	;;
-esac
-
-dnl Update these for every new development release of evolution. These numbers
-dnl actually correspond to the next stable release number
+dnl ******************************************************************
+dnl Update these for every new development release of evolution. These
+dnl numbers actually correspond to the next stable release number.
+dnl ******************************************************************
 EVOLUTION_API_VERSION=2.30
 EDS_BASE_VERSION=2.30
 
-LIBEXCHANGE_STORAGE_CURRENT=3
-LIBEXCHANGE_STORAGE_REVISION=0
-LIBEXCHANGE_STORAGE_AGE=0
-
-AC_SUBST(LIBEXCHANGE_STORAGE_CURRENT)
-AC_SUBST(LIBEXCHANGE_STORAGE_REVISION)
-AC_SUBST(LIBEXCHANGE_STORAGE_AGE)
-
-AC_MSG_CHECKING(Evolution version)
-EVOLUTION_VERSION=`pkg-config --modversion evolution-shell 2>/dev/null`
-if test -z "$EVOLUTION_VERSION"; then
-	AC_MSG_ERROR(Evolution development libraries not installed)
-fi
-AC_SUBST(EVOLUTION_VERSION)
-AC_MSG_RESULT($EVOLUTION_VERSION)
-
-EVOLUTION_BASE_VERSION=$EVOLUTION_API_VERSION
-AC_DEFINE_UNQUOTED(EVOLUTION_BASE_VERSION,"$EVOLUTION_BASE_VERSION",Evolution version)
-
-BASE_VERSION=$EVOLUTION_API_VERSION
-AC_DEFINE_UNQUOTED(BASE_VERSION, "$BASE_VERSION", Connector base version)
-AC_SUBST(BASE_VERSION)
-
-AC_SUBST(EDS_BASE_VERSION)
-
-dnl Initialize maintainer mode
-AM_MAINTAINER_MODE
-
-AC_ISC_POSIX
-AC_PROG_CC
-AC_STDC_HEADERS
-AC_PROG_INSTALL
-AC_PROG_LN_S
-AC_PROG_MAKE_SET
-
-dnl Initialize libtool
-AM_PROG_LIBTOOL
-
-# Compiler Warning Flags
-
+dnl **********************
+dnl Compiler Warning Flags
+dnl **********************
 AS_COMPILER_FLAGS(WARNING_FLAGS,
 	"-DG_DISABLE_DEPRECATED
 	-DPANGO_DISABLE_DEPRECATED
@@ -95,28 +51,29 @@ AS_COMPILER_FLAGS(WARNING_FLAGS,
 	-Wredundant-decls -Wundef -Wwrite-strings")
 AC_SUBST(WARNING_FLAGS)
 
-# Other useful compiler warnings for test builds only.
-# These may produce warnings we have no control over.
-#
-#	-Wformat-nonliteral
-#	-Wmissing-format-attribute
-#	-Wshadow
+dnl Other useful compiler warnings for test builds only.
+dnl These may produce warnings we have no control over.
+dnl
+dnl	-Wformat-nonliteral
+dnl	-Wmissing-format-attribute
+dnl	-Wshadow
 
-CFLAGS="$CFLAGS $WARNING_FLAGS"
+dnl ***************
+dnl Set AM_CPPFLAGS
+dnl ***************
+AM_CPPFLAGS="$WARNING_FLAGS"
+AC_SUBST(AM_CPPFLAGS)
 
-dnl ****
-dnl i18n
-dnl ****
-
-IT_PROG_INTLTOOL([0.35.5])
-AM_GLIB_GNU_GETTEXT
-
-GETTEXT_PACKAGE=evolution-exchange-${BASE_VERSION}
-AC_SUBST(GETTEXT_PACKAGE)
-AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Package name for gettext])
+dnl **************************
+dnl Initialize maintainer mode
+dnl **************************
+AM_MAINTAINER_MODE
 
-localedir='$(prefix)/$(DATADIRNAME)/locale'
-AC_SUBST(localedir)
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
 
 dnl ******************************
 dnl Check for Win32
@@ -125,71 +82,130 @@ dnl ******************************
 AC_MSG_CHECKING([for Win32])
 case "$host" in
 *-mingw*)
-    os_win32=yes
-    NO_UNDEFINED='-no-undefined'
-    SOCKET_LIBS='-lws2_32'
-    ;;
-*)  os_win32=no
-    NO_UNDEFINED='-no-undefined'
-    SOCKET_LIBS=''
-    ;;
+	os_win32=yes
+	NO_UNDEFINED='-no-undefined'
+	SOCKET_LIBS='-lws2_32'
+	;;
+*)
+	os_win32=no
+	NO_UNDEFINED='-no-undefined'
+	SOCKET_LIBS=''
+	;;
 esac
+
 AC_MSG_RESULT([$os_win32])
-AM_CONDITIONAL(OS_WIN32, [test $os_win32 = yes])
+AM_CONDITIONAL(OS_WIN32, [test "x$os_win32" = "xyes"])
 AC_SUBST(NO_UNDEFINED)
 AC_SUBST(SOCKET_LIBS)
 
-# Check for base dependencies early.
+dnl ******************
+dnl Initialize libtool
+dnl ******************
+LT_PREREQ(2.2)
+LT_INIT(disable-static win32-dll)
+
+PKG_PROG_PKG_CONFIG
+
+dnl ***************
+dnl Initialize i18n
+dnl ***************
+IT_PROG_INTLTOOL([0.35.5])
+AM_GLIB_GNU_GETTEXT
+
+GETTEXT_PACKAGE=evolution-exchange-${BASE_VERSION}
+AC_SUBST(GETTEXT_PACKAGE)
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Package name for gettext])
+
+localedir='$(prefix)/$(DATADIRNAME)/local'
+AC_SUBST(localedir)
+
+dnl **********************************
+dnl Check for base dependencies early.
+dnl **********************************
+
 PKG_CHECK_MODULES(GNOME_PLATFORM,
 	[glib-2.0 >= glib_minimum_version
-	 gtk+-2.0 >= gtk_minimum_version
-	 gconf-2.0 >= gconf_minimum_version
-	 libxml-2.0 >= libxml_minimum_version
-	 libsoup-2.4 >= libsoup_minimum_version])
+	gtk+-2.0 >= gtk_minimum_version
+	gconf-2.0 >= gconf_minimum_version
+	libxml-2.0 >= libxml_minimum_version
+	libsoup-2.4 >= libsoup_minimum_version])
 
 PKG_CHECK_MODULES(EVOLUTION_DATA_SERVER,
 	[libebook-1.2 >= eds_minimum_version
-	 libecal-1.2 >= eds_minimum_version
-	 libedataserver-1.2 >= eds_minimum_version
-	 libedataserverui-1.2 >= eds_minimum_version
-	 libegroupwise-1.2 >= eds_minimum_version
-	 libebackend-1.2 >= eds_minimum_version])
+	libecal-1.2 >= eds_minimum_version
+	libedataserver-1.2 >= eds_minimum_version
+	libedataserverui-1.2 >= eds_minimum_version
+	libegroupwise-1.2 >= eds_minimum_version
+	libebackend-1.2 >= eds_minimum_version])
+
+dnl ************************
+dnl Check for socklen_t type
+dnl ************************
+AC_EGREP_HEADER([socklen_t], [sys/socket.h], [:], [AC_DEFINE(socklen_t, int, [Define to "int" if socklen_t is not defined])])
+
+dnl *******************
+dnl GObject marshalling
+dnl *******************
+AM_PATH_GLIB_2_0
+
+dnl ***********
+dnl GConf stuff
+dnl ***********
+AC_PATH_PROG([GCONFTOOL],[gconftool-2],[no])
+AM_GCONF_SOURCE_2
+
+dnl *************
+dnl Gtk-Doc stuff
+dnl *************
+GTK_DOC_CHECK(1.9)
+
+dnl **************
+dnl Exchange debug
+dnl **************
+AC_ARG_ENABLE([e2k-debug],
+	AS_HELP_STRING([--enable-e2kdebug],
+	[Allow debugging]),
+	[enable_e2kdebug=$enableval],[enable_e2kdebug="no"])
+
+if test "x$enable_e2kdebug" = "xyes"; then
+	AC_DEFINE([E2K_DEBUG],[1],[Define if you want E2K_DEBUG to be available])
+fi
 
 dnl *************************
-dnl CFLAGS and LIBS and stuff
+dnl Set the connector datadir
 dnl *************************
+CONNECTOR_DATADIR='$(datadir)/evolution-exchange/$(BASE_VERSION)'
+AC_SUBST(CONNECTOR_DATADIR)
 
-GNOME_COMPILE_WARNINGS(maximum)
-CFLAGS="$CFLAGS $WARN_CFLAGS"
-case $CFLAGS in
-*-Wall*)
-	CFLAGS="$CFLAGS -Wno-sign-compare"
-	;;
-esac
-
-AC_EGREP_HEADER(socklen_t, sys/socket.h, :, AC_DEFINE(socklen_t, int, [Define to "int" if socklen_t is not defined]))
+dnl *************************************
+dnl Check for evo/eds and version setting
+dnl *************************************
+AC_MSG_CHECKING(Evolution version)
+EVOLUTION_VERSION="`$PKG_CONFIG --modversion evolution-shell 2>/dev/null`"
+if test -z "$EVOLUTION_VERSION"; then
+	AC_MSG_ERROR(Evolution development libraries not installed)
+fi
+AC_SUBST(EVOLUTION_VERSION)
 
-AM_PATH_GLIB_2_0
-AM_PATH_ORBIT2
-AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
-AM_GCONF_SOURCE_2
+EVOLUTION_BASE_VERSION=$EVOLUTION_API_VERSION
+AC_DEFINE_UNQUOTED(EVOLUTION_BASE_VERSION, "$EVOLUTION_BASE_VERSION", Evolution version)
 
-CONNECTOR_DATADIR='$(datadir)/evolution-exchange/$(BASE_VERSION)'
-AC_SUBST(CONNECTOR_DATADIR)
+BASE_VERSION=$EVOLUTION_API_VERSION
+AC_DEFINE_UNQUOTED(BASE_VERSION, "$BASE_VERSION", Connector base version)
 
-plugindir=`$PKG_CONFIG --variable=plugindir evolution-plugin`
+plugindir="`$PKG_CONFIG --variable=plugindir evolution-plugin`"
 AC_SUBST(plugindir)
 
-EVOLUTION_PLUGIN_errordir="`pkg-config --variable=errordir evolution-plugin`"
+EVOLUTION_PLUGIN_errordir="`$PKG_CONFIG --variable=errordir evolution-plugin`"
 AC_SUBST(EVOLUTION_PLUGIN_errordir)
 
-extensiondir="`pkg-config --variable=extensiondir evolution-data-server-1.2`"
+extensiondir="`$PKG_CONFIG --variable=extensiondir evolution-data-server-1.2`"
 AC_SUBST(extensiondir)
 
-EVOLUTION_imagesdir="`pkg-config --variable=imagesdir evolution-shell`"
+EVOLUTION_imagesdir="`$PKG_CONFIG --variable=imagesdir evolution-shell`"
 AC_SUBST(EVOLUTION_imagesdir)
 
-CAMEL_providerdir="`pkg-config --variable=camel_providerdir camel-provider-1.2`"
+CAMEL_providerdir="`$PKG_CONFIG --variable=camel_providerdir camel-provider-1.2`"
 AC_SUBST(CAMEL_providerdir)
 
 dnl ***************************
@@ -202,11 +218,11 @@ AC_SUBST(EVOLUTION_PLUGIN_LIBS)
 dnl *********************
 dnl Pilot license support
 dnl *********************
-# This does not take leap years into account, but that's not
-# important: having the build time be slightly too early is good
-# to support slight clock skew anyway.
-# 946684800 is 2000-01-01T00:00:00Z.
-# Don't change this without testing under /bin/sh on Solaris.
+dnl This does not take leap years into account, but that's not
+dnl important: having the build time be slightly too early is good
+dnl to support slight clock skew anyway.
+dnl 946684800 is 2000-01-01T00:00:00Z.
+dnl Don't change this without testing under /bin/sh on Solaris.
 abt=`eval expr \`date '+\( \( %y \* 365 \) + %j - 1 \) \* 24 \* 60 \* 60 + 946684800'\``
 case $abt in
 "")
@@ -215,10 +231,9 @@ case $abt in
 	abt="0"
 	;;
 esac
-AC_DEFINE_UNQUOTED(E2K_APPROX_BUILD_TIME, $abt, [Used to prevent clock-setting attacks against pilot licenses])
-
+AC_DEFINE_UNQUOTED([E2K_APPROX_BUILD_TIME],[$abt],[Used to prevent clock-setting attacks against pilot licenses])
 
-AC_DEFINE(HANDLE_LIBICAL_MEMORY, 1, [Define it once memory returned by libical is free'ed properly])
+AC_DEFINE([HANDLE_LIBICAL_MEMORY],[1],[Define it once memory returned by libical is free'ed properly])
 
 dnl *************
 dnl pthread check
@@ -228,142 +243,109 @@ EVO_PTHREAD_CHECK
 dnl *********************
 dnl OpenLDAP NTLM support
 dnl *********************
-if test "$os_win32" != yes; then
-EVO_SUNLDAP_CHECK(no)
-case $with_sunldap in
-no)
-	EVO_LDAP_CHECK(yes)
-	case $with_openldap in
-	no)
-		AC_ERROR(LDAP support is required for Connector)
-		;;
-	*)
-		case $with_static_ldap in
-		yes)
-			msg_ldap="$with_openldap (static)"
-			;;
-		*)
-			msg_ldap="$with_openldap (dynamic)"
-			;;
-		esac
-	esac
-	;;
-*)
-	case $with_static_sunldap in
-	yes)
-		msg_ldap="$with_sunldap (static)"
-		;;
-	*)
-		msg_ldap="$with_sunldap (dynamic)"
-		;;
-	esac
-esac
+if test "x$os_win32" != "xyes"; then
+	EVO_SUNLDAP_CHECK(no)
+	if test "x$with_sunldap" = "xno"; then
+		EVO_LDAP_CHECK(yes)
+		if test "x$with_openldap" = "xno"; then
+			AC_MSG_ERROR([LDAP support is required for Connector])
+		fi
+	fi
 
-SAVE_CFLAGS="$CFLAGS"
-SAVE_LIBS="$LIBS"
-LDAP_CFLAGS="$LDAP_CFLAGS -DLDAP_DEPRECATED"
-CFLAGS="$CFLAGS $LDAP_CFLAGS"
-LIBS="$LIBS $LDAP_LIBS"
-AC_CHECK_FUNCS(ldap_ntlm_bind)
-CFLAGS="$SAVE_CFLAGS"
-LIBS="$SAVE_LIBS"
-else # Win32
-LDAP_CFLAGS="$LDAP_CFLAGS -DLDAP_DEPRECATED"
-LDAP_LIBS="-lwldap32"
-AC_SUBST(LDAP_CFLAGS)
-AC_SUBST(LDAP_LIBS)
-AC_DEFINE(HAVE_LDAP,1,[Define if you have LDAP support])
-AM_CONDITIONAL(ENABLE_LDAP, true)
-fi # Win32
-
-AM_CONDITIONAL(SUNLDAP, test "$with_sunldap" != no)
-
-AC_MSG_CHECKING(for LDAP Paged Control)
-AC_TRY_RUN([
-#include <ldap.h>
-#include <stdlib.h>
-
-int main(int argc, char **argv)
-{
-#ifdef LDAP_CONTROL_PAGEDRESULTS	
-		exit(0);
-#else		
-		exit(1);
-#endif		
-}],[
-AC_DEFINE(HAVE_LDAP_PAGED, 1, [Supports Paged results])
-ac_cv_ldappaged=yes
-],ac_cv_ldappaged="no (GAL Caching disabled)",ac_cv_ldappaged="no (GAL Caching disabled)",[
-AC_DEFINE(HAVE_LDAP_PAGED, 1, [Supports Paged results])
-ac_cv_ldappaged=yes
-])
-AC_MSG_RESULT($ac_cv_ldappaged)
-
-dnl *******
-dnl gtk-doc
-dnl *******
-dnl Putting a space before the macro call here makes gnome-autogen not
-dnl notice it, which makes it not run gtkdocize and copy gtk-doc.make
-dnl into the top level where I don't want it.
- GTK_DOC_CHECK([1.0])
-
-dnl **************************************************
-dnl * libdb checking - taken from EDS
-dnl **************************************************
-
-AC_ARG_WITH(libdb, AC_HELP_STRING([--with-libdb],[Prefix where libdb is installed]), dynamic_libdb=yes, dynamic_libdb=no)
-if test "x${dynamic_libdb}" = "xyes"; then
-        DB_CFLAGS="-I$withval/include"
-        DB_LIBS="-L$withval/lib -ldb"
+	SAVE_CFLAGS="$CFLAGS"
+	SAVE_LIBS="$LIBS"
+	LDAP_CFLAGS="$LDAP_CFLAGS -DLDAP_DEPRECATED"
+	CFLAGS="$CFLAGS $LDAP_CFLAGS"
+	LIBS="$LIBS $LDAP_LIBS"
+	AC_CHECK_FUNCS(ldap_ntlm_bind)
+	CFLAGS="$SAVE_CFLAGS"
+	LIBS="$SAVE_LIBS"
+dnl Win32 support
 else
-	DB_CFLAGS="$CFLAGS -I /usr/include"
-	DB_LIBS="$LIBS -ldb"
+	LDAP_CFLAGS="$LDAP_CFLAGS -DLDAP_DEPRECATED"
+	LDAP_LIBS="-lwldap32"
+	AC_SUBST(LDAP_CFLAGS)
+	AC_SUBST(LDAP_LIBS)
+	AC_DEFINE(HAVE_LDAP,1,[Define if you have LDAP support])
+	AM_CONDITIONAL(ENABLE_LDAP, true)
+fi
+
+AM_CONDITIONAL(SUNLDAP, test "x$with_sunldap" != "xno")
+
+AC_CACHE_CHECK([for LDAP Paged Control], [ac_cv_ldappaged],
+	AC_RUN_IFELSE([AC_LANG_PROGRAM(
+	[[	#include <ldap.h>
+		#include <stdlib.h>
+	]],
+	[[	int main(int argc, char **argv) {
+		#ifdef LDAP_CONTROL_PAGEDRESULTS
+			exit(0);
+		#else
+			exit(1);
+		#endif
+		}
+	]],
+	)], [ac_cv_ldappaged="yes"], [ac_cv_ladppaged="no"], [ac_cv_ldappaged="yes"]))
+
+if test "x$ac_cv_ldappaged" = "xyes"; then
+	AC_DEFINE([HAVE_LDAP_PAGED], 1, [Supports Paged results])
 fi
 
+dnl **************
+dnl libdb checking
+dnl **************
+AC_ARG_WITH([libdb],
+	AC_HELP_STRING([--with-libdb=PREFIX],
+	[Prefix where libdb is installed]),
+	[libdb_prefix="$withval"], [libdb_prefix='${prefix}'])
+
+DB_CFLAGS="-I$libdb_prefix/include"
+DB_LIBS="-L$libdb_prefix/lib -ldb"
+
 AC_MSG_CHECKING([Berkeley DB])
-save_cflags=$CFLAGS; CFLAGS=$DB_CFLAGS
-save_libs=$LIBS; LIBS="$DB_LIBS"
-AC_LINK_IFELSE(
-        [AC_LANG_PROGRAM([[#include <db.h>]],
-                         [db_create(NULL, NULL, 0)])],
-        check_db=yes,
-        check_db=no)
-AC_MSG_RESULT($check_db)
-AM_CONDITIONAL(HAVE_LIBDB, [test $check_db = yes])
-
-if test "$check_db" = "yes"; then
-  AC_DEFINE(ENABLE_CACHE, 1,
-	    [Enabling GAL Caching])
+save_cflags=$CFLAGS
+save_libs=$LIBS
+CFLAGS=$DB_CFLAGS
+LIBS="$DB_LIBS"
+AC_LINK_IFELSE([AC_LANG_PROGRAM(
+	[[#include <db.h>]],
+	[db_create(NULL, NULL, 0)])],
+	[check_db=yes],
+	[check_db=no])
+
+if test "x$check_db" = "xyes"; then
+	AC_MSG_RESULT([$check_db])
 else
-  AC_DEFINE(ENABLE_CACHE, 0,
-	    [Disabling GAL Caching])
-  DB_CFLAGS=""
-  DB_LIBS=""
+	AC_MSG_FAILURE([Cannot find libdb / Berkeley DB. Use --with-libdb to specify an PREFIX .])
 fi
+AM_CONDITIONAL(HAVE_LIBDB, [test "x$check_db" = "xyes"])
+
 CFLAGS=$save_cflags
 LIBS=$save_libs
 AC_SUBST(DB_CFLAGS)
 AC_SUBST(DB_LIBS)
 
-dnl ****************
-dnl Kerberos Support
-dnl ****************
-
-AC_ARG_WITH(krb5,
-  AC_HELP_STRING( [--with-krb5=DIR],
-		  [Location of Kerberos 5 install dir]),
-  with_krb5="$withval", with_krb5="no")
+dnl ******************************
+dnl Kerberos
+dnl ******************************
+AC_ARG_WITH([krb5],
+	AS_HELP_STRING([--with-krb5=PATH],
+	[Location of Kerberos 5 install dir]),
+	[with_krb5="$withval"], [with_krb5="no"])
 
-AC_ARG_WITH(krb5-libs,
-  AC_HELP_STRING( [--with-krb5-libs=DIR],
-		  [Location of Kerberos 5 libraries]),
-  with_krb5_libs="$withval", with_krb5_libs="$with_krb5/lib")
+AC_ARG_WITH([krb5-libs],
+	AS_HELP_STRING([--with-krb5-libs=PATH],
+	[Location of Kerberos 5 libraries]),
+	[with_krb5_libs="$withval"], [with_krb5_libs="$with_krb5/lib"])
 
-AC_ARG_WITH(krb5-includes,
-  AC_HELP_STRING( [--with-krb5-includes=DIR],
-		  [Location of Kerberos 5 headers]),
-  with_krb5_includes="$withval", with_krb5_includes="")
+AC_ARG_WITH([krb5-includes],
+	AS_HELP_STRING([--with-krb5-includes=PATH],
+	[Location of Kerberos 5 headers]),
+	[with_krb5_includes="$withval"], [with_krb5_includes="$with_krb5/include"])
 
+dnl ******************************
+dnl Kerberos 5
+dnl ******************************
 msg_krb5="no"
 if test "x${with_krb5}" != "xno"; then
 	LIBS_save="$LIBS"
@@ -371,16 +353,19 @@ if test "x${with_krb5}" != "xno"; then
 	mitlibs="-lkrb5 -lk5crypto -lcom_err -lgssapi_krb5"
 	heimlibs="-lkrb5 -lcrypto -lasn1 -lcom_err -lroken -lgssapi"
 	sunlibs="-lkrb5 -lgss"
-	AC_CACHE_CHECK([for Kerberos 5], ac_cv_lib_kerberos5,
+	AC_CACHE_CHECK([for Kerberos 5], [ac_cv_lib_kerberos5],
 	[
 		LIBS="$LIBS -L$with_krb5_libs $mitlibs"
-		AC_TRY_LINK([#include <krb5.h>],krb5_init_context, ac_cv_lib_kerberos5="$mitlibs",
+		AC_LINK_IFELSE([AC_LANG_CALL([], [krb5_init_context])],
+		[ac_cv_lib_kerberos5="$mitlibs"],
 		[
 			LIBS="$LIBS_save -L$with_krb5_libs $heimlibs"
-			AC_TRY_LINK_FUNC(krb5_init_context, ac_cv_lib_kerberos5="$heimlibs",
+			AC_LINK_IFELSE([AC_LANG_CALL([], [krb5_init_context])],
+			[ac_cv_lib_kerberos5="$heimlibs"],
 			[
 				LIBS="$LIBS_save -L$with_krb5_libs $sunlibs"
-				AC_TRY_LINK_FUNC(krb5_init_context, ac_cv_lib_kerberos5="$sunlibs", ac_cv_lib_kerberos5="no")
+				AC_LINK_IFELSE([AC_LANG_CALL([], [krb5_init_context])],
+				[ac_cv_lib_kerberos5="$sunlibs"], [ac_cv_lib_kerberos5="no"])
 			])
 		])
 		LIBS="$LIBS_save"
@@ -414,8 +399,8 @@ if test "x${with_krb5}" != "xno"; then
 				msg_krb5="yes (Sun)"
 			fi
 		fi
-		KRB5_LDFLAGS="-L$with_krb5_libs $ac_cv_lib_kerberos5"
-		AC_MSG_RESULT(msg_krb5)
+		KRB5_LIBS="-L$with_krb5_libs $ac_cv_lib_kerberos5"
+		AC_MSG_RESULT([msg_krb5])
 	else
 		dnl AC_MSG_CHECKING([for Kerberos 5])
 		AC_MSG_RESULT([no])
@@ -425,13 +410,29 @@ else
 	AC_MSG_WARN([krb5 support disabled])
 fi
 
-AM_CONDITIONAL(ENABLE_KRB5, test x$with_krb5 != xno)
+AM_CONDITIONAL(ENABLE_KRB5, [test "x$with_krb5" != "xno"])
+
+AC_CHECK_HEADER([et/com_err.h],
+	[AC_DEFINE([HAVE_ET_COM_ERR_H], 1, [Have <et/comm_err.h>])],,
+	[[	#if HAVE_ET_COM_ERR_H
+		#include <com_err.h>
+		#endif
+	]])
+AC_CHECK_HEADER([com_err.h],
+	[AC_DEFINE([HAVE_COM_ERR_H], 1, [Have <comm_err.h>])],,
+	[[	#if HAVE_COM_ERR_H
+		#include <com_err.h>
+		#endif
+	]])
+
+AC_SUBST(KRB5_CFLAGS)
+AC_SUBST(KRB5_LIBS)
 
 dnl ******************************
 dnl Makefiles
 dnl ******************************
 
-AC_OUTPUT([
+AC_CONFIG_FILES([
 Makefile
 evolution-exchange-zip
 eplugin/Makefile
@@ -447,21 +448,13 @@ server/lib/Makefile
 server/storage/Makefile
 server/xntlm/Makefile
 ])
+AC_OUTPUT
 
-echo "
-	evolution-exchange has been configured as follows:
-	Kerberos 5:       $msg_krb5
-	LDAP support:     $msg_ldap
-"
-
-case $ac_cv_func_ldap_ntlm_bind in
-no)
-	echo ""
+if test "x$ac_cv_func_ldap_ntlm_bind" = "xno"; then
 	AC_MSG_WARN([
 No NTLM support in OpenLDAP; Plaintext password authentication will be
 used when connecting to the Global Catalog server. Consider installing
 the evo-openldap package, or building OpenLDAP with the patch in
 docs/openldap-ntlm.diff
 ])
-	;;
-esac
+fi
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index eca0b6e..63701ce 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -1,14 +1,9 @@
-## Process this file with automake to produce Makefile.in
-
 # The name of the module.
 DOC_MODULE=evolution-exchange
 
 # The top-level SGML file.
 DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
 
-# Extra options to supply to gtkdoc-scan
-SCAN_OPTIONS=
-
 # Files/directories to ignore when scanning.
 IGNORE_HFILES= \
 	config.h \
@@ -30,12 +25,14 @@ IGNORE_HFILES= \
 # The directory containing the source code. Relative to $(srcdir)
 DOC_SOURCE_DIR=../../
 
+# Used for dependencies. The docs will be rebuilt if any of these change.
 HFILE_GLOB=$(top_srcdir)/*/*.h
 CFILE_GLOB=$(top_srcdir)/*/*.c
 
-# CFLAGS and LDFLAGS for compiling scan program. Only needed
-# if $(DOC_MODULE).types is non-empty.
-INCLUDES = \
+# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
+# Only needed if you are using gtkdoc-scangobj to dynamically query widget
+# signals and properties.
+GTKDOC_CFLAGS = \
 	-I$(top_srcdir)/server/lib \
 	-I$(top_srcdir)/server/storage \
 	$(GNOME_PLATFORM_CFLAGS) \
@@ -46,23 +43,8 @@ GTKDOC_LIBS = \
 	$(GNOME_PLATFORM_LIBS) \
 	$(LDAP_LIBS)
 
-# Extra options to supply to gtkdoc-mkdb
-MKDB_OPTIONS=--ignore-files="$(IGNORE_HFILES)"
-
-# Images to copy into HTML directory
-HTML_IMAGES =
-
-# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE)
-content_files =
-
-# Extra options to supply to gtkdoc-fixref
-FIXXREF_OPTIONS=
-
-include gtk-doc.make
-
-# Other files to distribute
-EXTRA_DIST += \
-	gtk-doc.make
+# This includes the standard gtk-doc make rules, copied by gtkdocize.
+include $(top_srcdir)/gtk-doc.make
 
 dist-hook-local:
 	mkdir $(distdir)/features
diff --git a/eplugin/Makefile.am b/eplugin/Makefile.am
index b91487d..f658f2a 100644
--- a/eplugin/Makefile.am
+++ b/eplugin/Makefile.am
@@ -59,7 +59,8 @@ liborg_gnome_exchange_operations_la_SOURCES = \
 liborg_gnome_exchange_operations_la_LIBADD = \
 	$(EVOLUTION_DATA_SERVER_LIBS) \
 	$(EVOLUTION_PLUGIN_LIBS) \
-	$(CAMEL_EXCHANGE_LIBS)
+	$(CAMEL_EXCHANGE_LIBS) \
+	$(top_builddir)/server/storage/libexchange-storage.la
 
 liborg_gnome_exchange_operations_la_LDFLAGS = \
 	-module -avoid-version $(NO_UNDEFINED)
diff --git a/m4/as-compiler-flag.m4 b/m4/as-compiler-flag.m4
new file mode 100644
index 0000000..1c74267
--- /dev/null
+++ b/m4/as-compiler-flag.m4
@@ -0,0 +1,61 @@
+dnl as-compiler-flag.m4 0.1.0
+
+dnl autostars m4 macro for detection of compiler flags
+
+dnl David Schleef <ds schleef org>
+
+dnl $Id: as-compiler-flag.m4,v 1.1 2005/12/15 23:35:19 ds Exp $
+
+dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
+dnl Tries to compile with the given CFLAGS.
+dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
+dnl and ACTION-IF-NOT-ACCEPTED otherwise.
+
+AC_DEFUN([AS_COMPILER_FLAG],
+[
+  AC_MSG_CHECKING([to see if compiler understands $1])
+
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS $1"
+
+  AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
+  CFLAGS="$save_CFLAGS"
+
+  if test "X$flag_ok" = Xyes ; then
+    m4_ifvaln([$2],[$2])
+    true
+  else
+    m4_ifvaln([$3],[$3])
+    true
+  fi
+  AC_MSG_RESULT([$flag_ok])
+])
+
+dnl AS_COMPILER_FLAGS(VAR, FLAGS)
+dnl Tries to compile with the given CFLAGS.
+
+AC_DEFUN([AS_COMPILER_FLAGS],
+[
+  list=$2
+  flags_supported=""
+  flags_unsupported=""
+  AC_MSG_CHECKING([for supported compiler flags])
+  for each in $list
+  do
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS $each"
+    AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
+    CFLAGS="$save_CFLAGS"
+
+    if test "X$flag_ok" = Xyes ; then
+      flags_supported="$flags_supported $each"
+    else
+      flags_unsupported="$flags_unsupported $each"
+    fi
+  done
+  AC_MSG_RESULT([$flags_supported])
+  if test "X$flags_unsupported" != X ; then
+    AC_MSG_WARN([unsupported compiler flags: $flags_unsupported])
+  fi
+  $1="$$1 $flags_supported"
+])
diff --git a/m4/evo_ldap_check.m4 b/m4/evo_ldap_check.m4
new file mode 100644
index 0000000..a029ac7
--- /dev/null
+++ b/m4/evo_ldap_check.m4
@@ -0,0 +1,92 @@
+dnl EVO_LDAP_CHECK(default)
+dnl Add --with-openldap and --with-static-ldap options. --with-openldap
+dnl defaults to the given value if not specified. If LDAP support is
+dnl configured, HAVE_LDAP will be defined and the automake conditional
+dnl ENABLE_LDAP will be set. LDAP_CFLAGS and LDAP_LIBS will be set
+dnl appropriately.
+#serial 0.1
+AC_DEFUN([EVO_LDAP_CHECK],[
+	default="$1"
+	AC_ARG_WITH([openldap],
+		[AS_HELP_STRING([--with-openldap],
+		[Enable LDAP support in evolution])])
+	AC_ARG_WITH([static-ldap],
+		[AS_HELP_STRING([--with-static-ldap],
+		[Link LDAP support statically into evolution])])
+	AC_CACHE_CHECK([for OpenLDAP], [ac_cv_with_openldap], [ac_cv_with_openldap="${with_openldap:=$default}"])
+	case $ac_cv_with_openldap in
+	no|"")
+		with_openldap=no
+		;;
+	yes)
+		with_openldap=/usr
+		;;
+	*)
+		with_openldap=$ac_cv_with_openldap
+		LDAP_CFLAGS="-I$ac_cv_with_openldap/include"
+		LDAP_LDFLAGS="-L$ac_cv_with_openldap/lib"
+		;;
+	esac
+
+	if test "$with_openldap" != no; then
+		AC_DEFINE(HAVE_LDAP,1,[Define if you have LDAP support])
+
+		case $with_static_ldap in
+		no|"")
+			with_static_ldap=no
+			;;
+		*)
+			with_static_ldap=yes
+			;;
+		esac
+
+		AC_CACHE_CHECK([if OpenLDAP is version 2.x], [ac_cv_openldap_version2], [
+			CPPFLAGS_save="$CPPFLAGS"
+			CPPFLAGS="$CPPFLAGS $LDAP_CFLAGS"
+			AC_EGREP_CPP(yes, [
+				#include "ldap.h"
+				#if LDAP_VENDOR_VERSION > 20000
+				yes
+				#endif
+			], [ac_cv_openldap_version2=yes], [ac_cv_openldap_version2=no])
+			CPPFLAGS="$CPPFLAGS_save"
+		])
+		if test "$ac_cv_openldap_version2" = no; then
+			AC_MSG_ERROR([evolution requires OpenLDAP version >= 2])
+		fi
+
+		AC_CHECK_LIB(resolv, res_query, [LDAP_LIBS="-lresolv"])
+		AC_CHECK_LIB(socket, bind, [LDAP_LIBS="$LDAP_LIBS -lsocket"])
+		AC_CHECK_LIB(nsl, gethostbyaddr, [LDAP_LIBS="$LDAP_LIBS -lnsl"])
+		AC_CHECK_LIB(lber, ber_get_tag, [
+			if test "$with_static_ldap" = "yes"; then
+				LDAP_LIBS="$with_openldap/lib/liblber.a $LDAP_LIBS"
+
+				# libldap might depend on OpenSSL... We need to pull
+				# in the dependency libs explicitly here since we're
+				# not using libtool for the configure test.
+				if test -f $with_openldap/lib/libldap.la; then
+					LDAP_LIBS="`. $with_openldap/lib/libldap.la; echo $dependency_libs` $LDAP_LIBS"
+				fi
+			else
+				LDAP_LIBS="-llber $LDAP_LIBS"
+			fi
+			AC_CHECK_LIB(ldap, ldap_open, [
+					if test $with_static_ldap = "yes"; then
+						LDAP_LIBS="$with_openldap/lib/libldap.a $LDAP_LIBS"
+					else
+						LDAP_LIBS="-lldap $LDAP_LIBS"
+					fi],
+				[LDAP_LIBS=""], [$LDAP_LDFLAGS $LDAP_LIBS])
+			LDAP_LIBS="$LDAP_LDFLAGS $LDAP_LIBS"
+		], [LDAP_LIBS=""], [$LDAP_LDFLAGS $LDAP_LIBS])
+
+		if test -z "$LDAP_LIBS"; then
+			AC_MSG_ERROR([could not find OpenLDAP libraries])
+		fi
+
+		AC_SUBST(LDAP_CFLAGS)
+		AC_SUBST(LDAP_LIBS)
+	fi
+	AM_CONDITIONAL(ENABLE_LDAP, test "$with_openldap" != "no")
+])
diff --git a/m4/evo_pthread_check.m4 b/m4/evo_pthread_check.m4
new file mode 100644
index 0000000..5a96fc5
--- /dev/null
+++ b/m4/evo_pthread_check.m4
@@ -0,0 +1,16 @@
+dnl EVO_PTHREAD_CHECK
+#serial 0.1
+AC_DEFUN([EVO_PTHREAD_CHECK],[
+	PTHREAD_LIB=""
+	AC_CHECK_LIB(pthread, pthread_create, [PTHREAD_LIB="-lpthread"],
+		[AC_CHECK_LIB(pthreads, pthread_create, [PTHREAD_LIB="-lpthreads"],
+			[AC_CHECK_LIB(c_r, pthread_create, [PTHREAD_LIB="-lc_r"],
+			[AC_CHECK_LIB(pthread, __pthread_attr_init_system, [PTHREAD_LIB="-lpthread"],
+				[AC_CHECK_FUNC(pthread_create)]
+			)]
+			)]
+		)]
+	)
+	AC_SUBST(PTHREAD_LIB)
+	AC_PROVIDE([EVO_PTHREAD_CHECK])
+])
diff --git a/m4/evo_sunldap_check.m4 b/m4/evo_sunldap_check.m4
new file mode 100644
index 0000000..bd85534
--- /dev/null
+++ b/m4/evo_sunldap_check.m4
@@ -0,0 +1,94 @@
+dnl EVO_SUNLDAP_CHECK
+dnl Add --with-sunldap and --with-static-sunldap options. --with-sunldap
+dnl defaults to the given value if not specified. If LDAP support is
+dnl configured, HAVE_LDAP will be defined and the automake conditional
+dnl ENABLE_LDAP will be set. LDAP_CFLAGS and LDAP_LIBS will be set
+dnl appropriately, and --with-sunldap and --with-openldap is mutually exclusive.
+#serial 0.1
+AC_DEFUN([EVO_SUNLDAP_CHECK], [
+	default="$1"
+
+	AC_ARG_WITH([sunldap],
+		[AS_HELP_STRING([--with-sunldap],
+		[Enable SunLDAP support in evolution])])
+	AC_ARG_WITH([static-sunldap],
+		[AS_HELP_STRING([--with-static-sunldap],
+		[Link SunLDAP support statically into evolution])])
+	AC_CACHE_CHECK([for SunLDAP],[ac_cv_with_sunldap],[ac_cv_with_sunldap="${with_sunldap:=$default}"])
+	case $ac_cv_with_sunldap in
+	no|"")
+		with_sunldap=no
+		;;
+	yes)
+		with_sunldap=/usr
+		;;
+	*)
+		with_sunldap=$ac_cv_with_sunldap
+		LDAP_CFLAGS="-I$ac_cv_with_sunldap/include"
+		LDAP_LDFLAGS="-L$ac_cv_with_sunldap/lib"
+		;;
+	esac
+
+	if test "$with_sunldap" != no; then
+		AC_DEFINE(HAVE_LDAP,1,[Define if you have LDAP support])
+		AC_DEFINE(SUNLDAP, 1, [Define if you use SunLDAP])
+
+		case $with_static_sunldap in
+		no|"")
+			with_static_sunldap=no
+			;;
+		*)
+			with_static_sunldap=yes
+			;;
+		esac
+
+		AC_CACHE_CHECK([if SunLDAP is version 2.x], [ac_cv_sunldap_version2], [
+			CPPFLAGS_save="$CPPFLAGS"
+			CPPFLAGS="$CPPFLAGS $LDAP_CFLAGS"
+			AC_EGREP_CPP(yes, [
+				#include "ldap.h"
+				#if LDAP_VENDOR_VERSION >= 500
+				yes
+				#endif
+			],[ac_cv_sunldap_version2=yes],[ac_cv_sunldap_version2=no])
+			CPPFLAGS="$CPPFLAGS_save"
+		])
+		if test "$ac_cv_sunldap_version2" = no; then
+		       AC_MSG_ERROR([evolution requires SunLDAP version >= 2])
+		fi
+
+		AC_CHECK_LIB(resolv, res_query, [LDAP_LIBS="-lresolv"])
+		AC_CHECK_LIB(socket, bind, [LDAP_LIBS="$LDAP_LIBS -lsocket"])
+		AC_CHECK_LIB(nsl, gethostbyaddr, [LDAP_LIBS="$LDAP_LIBS -lnsl"])
+		AC_CHECK_LIB(ldap, ldap_open, [
+			if test $with_static_sunldap = "yes"; then
+				LDAP_LIBS="$with_sunldap/lib/libldap.a $LDAP_LIBS"
+			else
+				LDAP_LIBS="-lldap $LDAP_LIBS"
+			fi
+			if test `uname -s` != "SunOS" ; then
+				AC_CHECK_LIB(lber, ber_get_tag, [
+					if test "$with_static_sunldap" = "yes"; then
+						LDAP_LIBS="$with_sunldap/lib/liblber.a $LDAP_LIBS"
+						# libldap might depend on OpenSSL... We need to pull
+						# in the dependency libs explicitly here since we're
+						# not using libtool for the configure test.
+						if test -f $with_sunldap/lib/libldap.la; then
+							LDAP_LIBS="`. $with_sunldap/lib/libldap.la; echo $dependency_libs` $LDAP_LIBS"
+						fi
+					else
+						LDAP_LIBS="-llber $LDAP_LIBS"
+					fi], [LDAP_LIBS=""], [$LDAP_LDFLAGS $LDAP_LIBS])
+			fi
+			LDAP_LIBS="$LDAP_LDFLAGS $LDAP_LIBS"
+		], [LDAP_LIBS=""], [$LDAP_LDFLAGS $LDAP_LIBS])
+
+		if test -z "$LDAP_LIBS"; then
+			AC_MSG_ERROR([could not find SunLDAP libraries])
+		fi
+
+		AC_SUBST(LDAP_CFLAGS)
+		AC_SUBST(LDAP_LIBS)
+	fi
+	AM_CONDITIONAL(ENABLE_LDAP, test "$with_sunldap" != "no")
+])
diff --git a/server/lib/e2k-global-catalog.c b/server/lib/e2k-global-catalog.c
index b5b04c9..7bea46b 100644
--- a/server/lib/e2k-global-catalog.c
+++ b/server/lib/e2k-global-catalog.c
@@ -355,8 +355,9 @@ connect_ldap (E2kGlobalCatalog *gc, E2kOperation *op, LDAP *ldap)
 
 	if (ldap_error != LDAP_SUCCESS)
 		g_warning ("LDAP authentication failed (0x%02x (%s))", ldap_error, ldap_err2string (ldap_error) ? ldap_err2string (ldap_error) : "Unknown error");
-	else
+	else {
 		E2K_GC_DEBUG_MSG(("GC: connected\n\n"));
+	}
 
 	return ldap_error;
 }
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 1b5d6bc..d8b7c5f 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,4 +1,9 @@
-AM_CPPFLAGS = \
+noinst_PROGRAMS = exchange-connector-setup
+
+noinst_LTLIBRARIES = libevolution-exchange-shared.la
+
+libevolution_exchange_shared_la_CPPFLAGS = \
+	$(AM_CPPFLAGS) \
 	-I$(top_srcdir) \
 	-I$(top_srcdir)/camel \
 	-I$(top_srcdir)/server/lib \
@@ -17,11 +22,6 @@ AM_CPPFLAGS = \
 	-DCONNECTOR_UIDIR=\""$(uidir)"\" \
 	-DCONNECTOR_LOCALEDIR=\""$(localedir)"\"
 
-noinst_PROGRAMS = \
-	exchange-connector-setup
-
-noinst_LTLIBRARIES = libevolution-exchange-shared.la
-
 libevolution_exchange_shared_la_SOURCES = \
 	exchange-share-config-listener.h \
 	exchange-share-config-listener.c
@@ -30,10 +30,31 @@ libevolution_exchange_shared_la_LIBADD = \
 	$(top_builddir)/server/storage/libexchange-storage.la \
 	$(GNOME_PLATFORM_LIBS) \
 	$(EVOLUTION_DATA_SERVER_LIBS) \
-	$(EVOLUTION_PLUGIN_LIBS)
+	$(EVOLUTION_PLUGIN_LIBS) \
+	$(LDAP_LIBS)
 
 libevolution_exchange_shared_la_LDFLAGS = -avoid-version $(NO_UNDEFINED)
 
+exchange_connector_setup_CPPFLAGS = \
+	$(AM_CPPFLAGS) \
+	-I$(top_srcdir) \
+	-I$(top_srcdir)/camel \
+	-I$(top_srcdir)/server/lib \
+	-I$(top_srcdir)/server/storage \
+	-I$(top_builddir)/server/lib \
+	-DG_LOG_DOMAIN="\"evolution-exchange-storage\"" \
+	$(GNOME_PLATFORM_CFLAGS) \
+	$(EVOLUTION_DATA_SERVER_CFLAGS) \
+	$(EVOLUTION_PLUGIN_CFLAGS) \
+	$(LDAP_CFLAGS) \
+	-DPREFIX=\""$(prefix)"\" \
+	-DSYSCONFDIR=\""$(sysconfdir)"\" \
+	-DDATADIR=\""$(datadir)"\" \
+	-DLIBDIR=\""$(datadir)"\" \
+	-DCONNECTOR_IMAGESDIR=\""$(imagesdir)"\" \
+	-DCONNECTOR_UIDIR=\""$(uidir)"\" \
+	-DCONNECTOR_LOCALEDIR=\""$(localedir)"\"
+
 exchange_connector_setup_SOURCES = \
 	ximian-connector-setup.c \
 	exchange-autoconfig-wizard.h \
@@ -65,8 +86,6 @@ images_DATA = \
 uidir   = $(CONNECTOR_DATADIR)/ui
 ui_DATA = ximian-connector.xml
 
-#DISTCLEANFILES =
-
 EXTRA_DIST = \
 	$(images_DATA) \
 	$(ui_DATA)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]