 this file with autoconf to produce a configure script.
AC_PREREQ(2.52)

AC_INIT(evolution-data-server, 1.0.4)
AC_CONFIG_SRCDIR(README)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)

AM_CONFIG_HEADER(config.h)

# Libtool versioning
LIBEDATASERVER_CURRENT=5
LIBEDATASERVER_REVISION=3
LIBEDATASERVER_AGE=2

LIBECAL_CURRENT=9
LIBECAL_REVISION=0
LIBECAL_AGE=3

LIBEDATACAL_CURRENT=6
LIBEDATACAL_REVISION=6
LIBEDATACAL_AGE=1

LIBEDATABOOK_CURRENT=1
LIBEDATABOOK_REVISION=1
LIBEDATABOOK_AGE=0

LIBEBOOK_CURRENT=8
LIBEBOOK_REVISION=7
LIBEBOOK_AGE=0

LIBEGROUPWISE_CURRENT=7
LIBEGROUPWISE_REVISION=0
LIBEGROUPWISE_AGE=1

AC_SUBST(LIBEDATASERVER_CURRENT)
AC_SUBST(LIBEDATASERVER_REVISION)
AC_SUBST(LIBEDATASERVER_AGE)
AC_SUBST(LIBECAL_CURRENT)
AC_SUBST(LIBECAL_REVISION)
AC_SUBST(LIBECAL_AGE)
AC_SUBST(LIBEDATACAL_CURRENT)
AC_SUBST(LIBEDATACAL_REVISION)
AC_SUBST(LIBEDATACAL_AGE)
AC_SUBST(LIBEBOOK_CURRENT)
AC_SUBST(LIBEBOOK_REVISION)
AC_SUBST(LIBEBOOK_AGE)
AC_SUBST(LIBEDATABOOK_CURRENT)
AC_SUBST(LIBEDATABOOK_REVISION)
AC_SUBST(LIBEDATABOOK_AGE)
AC_SUBST(LIBEGROUPWISE_CURRENT)
AC_SUBST(LIBEGROUPWISE_REVISION)
AC_SUBST(LIBEGROUPWISE_AGE)


dnl Put the ACLOCAL flags in the Makefile
ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"

dnl Initialize maintainer mode
AM_MAINTAINER_MODE

AC_ISC_POSIX
AC_PROG_CC
AC_PROG_CPP
AC_C_INLINE
AM_PROG_LEX
AC_PROG_YACC
case $YACC in
*yacc*)
	AC_MSG_ERROR(You need bison to build evolution-data-server)
	;;
esac
AC_STDC_HEADERS
AC_ARG_PROGRAM
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

dnl  Test whether jw is installed
AC_PATH_PROG(JW,jw,no)
if test x$JW = xno; then
  HAVE_JW="no"
else
  HAVE_JW="yes"
fi
AM_CONDITIONAL(HAVE_JW, test "x$HAVE_JW" = "xyes")
AC_SUBST(HAVE_JW)

dnl I18N stuff
AC_PROG_INTLTOOL

ALL_LINGUAS="am ar az be bg bn ca cs cy da de el en_AU en_CA en_GB es et eu fa fi fr ga gl gu hr hu id it ja ko lt lv mn ms nb nl nn no pa pl pt pt_BR ro ru sk sl sq sr sr@Latn sv tr uk vi zh_CN zh_TW"
AM_GLIB_GNU_GETTEXT

GETTEXT_PACKAGE=evolution-data-server-1.0
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Package name for gettext])

localedir='$(prefix)/$(DATADIRNAME)/locale'
AC_SUBST(localedir)

dnl Initialize libtool
AM_DISABLE_STATIC
AM_PROG_LIBTOOL

dnl alloca()
AC_CHECK_HEADERS(alloca.h)

dnl
dnl Purify support
dnl
EVO_PURIFY_SUPPORT

dnl **************************************************
dnl LDAP support.
dnl **************************************************
EVO_LDAP_CHECK(no)
case $with_openldap in
no)
	msg_ldap=no
	;;
*)
	case $with_static_ldap in
	yes)
		msg_ldap="$with_openldap (static)"
		;;
	*)
		msg_ldap="$with_openldap (dynamic)"
		;;
	esac
esac

LIBBONOBO_REQUIRED="2.4.2"
ORBIT_REQUIRED="2.9.8"

AC_SUBST(LIBBONOBO_REQUIRED)
AC_SUBST(ORBIT_REQUIRED)

dnl *******************
dnl GObject marshalling
dnl *******************
AM_PATH_GLIB_2_0

dnl We use AC_SUBST_FILE because AC_SUBST won't deal with newlines
EVO_MARSHAL_RULE=$srcdir/marshal.mk
AC_SUBST_FILE(EVO_MARSHAL_RULE)

dnl *************************
dnl CFLAGS and LIBS and stuff
dnl *************************

GNOME_COMPILE_WARNINGS(yes)
CFLAGS="$CFLAGS $WARN_CFLAGS"
case $CFLAGS in
*-Wall*)
	# Turn off the annoying "comparison between signed and unsigned"
	# warning in gcc 3.3
	CFLAGS="$CFLAGS -Wno-sign-compare"
	;;
esac

AM_PATH_ORBIT2(2.9.8)

AC_MSG_CHECKING(for CORBA include paths)
IDL_INCLUDES="-I "`pkg-config --variable=idldir libbonobo-2.0`" -I "`pkg-config --variable=idldir bonobo-activation-2.0`
AC_MSG_RESULT($IDL_INCLUDES)
AC_SUBST(IDL_INCLUDES)

AC_MSG_CHECKING(for libgnomeui server directory)
GNOMEUI_SERVERDIR="`$PKG_CONFIG --variable=libgnomeui_serverdir libgnomeui-2.0`"
AC_MSG_RESULT($GNOMEUI_SERVERDIR)
AC_DEFINE_UNQUOTED(GNOMEUI_SERVERDIR, "$GNOMEUI_SERVERDIR", [Path where we can find gnome_segv2])

dnl Utility macro to set compiler flags for a specific lib.
AC_DEFUN(EVO_SET_COMPILE_FLAGS, [
	deps="$2"
	extra_cflags="$3"
	extra_libs="$4"
	PKG_CHECK_MODULES(EVOLUTION, $deps)
	$1_CFLAGS="$EVOLUTION_CFLAGS \$(WERROR) $extra_cflags"
	$1_LIBS="$EVOLUTION_LIBS $extra_libs"
])

dnl --- Flags to get all the GNOME stuff

FULL_GNOME_DEPS="gnome-vfs-2.0 libgnome-2.0 libxml-2.0 gconf-2.0 ORBit-2.0 >= $ORBIT_REQUIRED"

EVO_SET_COMPILE_FLAGS(GNOME_FULL, $FULL_GNOME_DEPS)
AC_SUBST(GNOME_FULL_CFLAGS)
AC_SUBST(GNOME_FULL_LIBS)

dnl --- Flags for the various libraries we build

EVO_SET_COMPILE_FLAGS(E_NAME, glib-2.0)
AC_SUBST(E_NAME_CFLAGS)
AC_SUBST(E_NAME_LIBS)

EVO_SET_COMPILE_FLAGS(E_DATA_SERVER, libxml-2.0 libbonobo-2.0 >= $LIBBONOBO_REQUIRED libgnome-2.0, $THREADS_CFLAGS, $THREADS_LIBS)
AC_SUBST(E_DATA_SERVER_CFLAGS)
AC_SUBST(E_DATA_SERVER_LIBS)

dnl --- evolution-addressbook flags

EVOLUTION_ADDRESSBOOK_DEPS="libxml-2.0 gconf-2.0 libbonobo-2.0 >= $LIBBONOBO_REQUIRED libgnome-2.0 gnome-vfs-2.0"

EVO_SET_COMPILE_FLAGS(EVOLUTION_ADDRESSBOOK, $EVOLUTION_ADDRESSBOOK_DEPS)
AC_SUBST(EVOLUTION_ADDRESSBOOK_CFLAGS)
AC_SUBST(EVOLUTION_ADDRESSBOOK_LIBS)

dnl --- evolution-calendar flags

EVO_SET_COMPILE_FLAGS(EVOLUTION_CALENDAR, libxml-2.0 libgnome-2.0 libbonobo-2.0 >= $LIBBONOBO_REQUIRED gnome-vfs-2.0)
AC_SUBST(EVOLUTION_CALENDAR_CFLAGS)
AC_SUBST(EVOLUTION_CALENDAR_LIBS)

dnl --- Groupwise flags
LIBSOUP_REQUIRED="2.2.2"
AC_SUBST(LIBSOUP_REQUIRED)
EVO_SET_COMPILE_FLAGS(SOUP, libsoup-2.2 >= $LIBSOUP_REQUIRED)
AC_SUBST(SOUP_CFLAGS)
AC_SUBST(SOUP_LIBS)

dnl *******************
dnl Special directories
dnl *******************

dnl --- If you add something here, consider whether or not you also
dnl --- need to add it to one or more .pc.in files (for Connector,
dnl --- etc)

dnl BASE_VERSION=`echo $VERSION | awk -F. '{print $1 "." $2;}'`
BASE_VERSION=1.0
AC_SUBST(BASE_VERSION)
AC_DEFINE_UNQUOTED(BASE_VERSION, "$BASE_VERSION", [Base version (Major.Minor)])

privdatadir='${datadir}'/evolution-data-server-$BASE_VERSION
AC_SUBST(privdatadir)

privincludedir='${includedir}'/evolution-data-server-$BASE_VERSION
AC_SUBST(privincludedir)

idldir="$datadir/idl/evolution-data-server-$BASE_VERSION"
AC_SUBST(idldir)

serverdir="$libdir/bonobo/servers"
AC_SUBST(serverdir)

dnl ************************
dnl IDL/Component Versioning
dnl ************************

INTERFACE_VERSION="$BASE_VERSION"
AC_SUBST(INTERFACE_VERSION)
AC_DEFINE_UNQUOTED(INTERFACE_VERSION, "$INTERFACE_VERSION", [IDL interface version (Major.Minor)])

EVO_SUBST_SERVER_RULE='%.server.in: %.server.in.in ; sed -e "s|\@BINDIR\@|$(bindir)|" -e "s|\@LIBEXECDIR\@|$(libexecdir)|" -e "s|\@COMPONENTDIR\@|$(componentdir)|" -e "s|\@IMPORTERSDIR\@|$(importersdir)|" -e "s|\@VERSION\@|$(BASE_VERSION)|" -e "s|\@INTERFACE_VERSION\@|$(INTERFACE_VERSION)|" $< > $@'
EVO_NAME_SERVER_RULE='%_$(BASE_VERSION).server: %.server ; mv $< $@'
AC_SUBST(EVO_SUBST_SERVER_RULE)
AC_SUBST(EVO_NAME_SERVER_RULE)

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.0)

dnl ******************************
dnl Makefiles
dnl ******************************

export privlibdir
export privincludedir
export privdatadir
AC_CONFIG_SUBDIRS(calendar/libical)
AC_CONFIG_SUBDIRS(libdb/dist)

AC_OUTPUT([
Makefile
evolution-data-server-1.0.pc
addressbook/Makefile
addressbook/idl/Makefile
addressbook/libebook/Makefile
addressbook/libebook/libebook-1.0.pc
addressbook/libedata-book/Makefile
addressbook/libedata-book/libedata-book-1.0.pc
addressbook/backends/Makefile
addressbook/backends/file/Makefile
addressbook/backends/vcf/Makefile
addressbook/backends/ldap/Makefile
addressbook/backends/groupwise/Makefile
addressbook/tests/Makefile
addressbook/tests/ebook/Makefile
addressbook/tests/vcard/Makefile
calendar/Makefile
calendar/idl/Makefile
calendar/libecal/Makefile
calendar/libecal/libecal-1.0.pc
calendar/libedata-cal/Makefile
calendar/libedata-cal/libedata-cal-1.0.pc
calendar/backends/Makefile
calendar/backends/file/Makefile
calendar/backends/groupwise/Makefile
calendar/backends/http/Makefile
calendar/backends/contacts/Makefile
calendar/tests/Makefile
calendar/tests/ecal/Makefile
libdb/Makefile
libedataserver/Makefile
libedataserver/libedataserver-1.0.pc
servers/Makefile
servers/groupwise/Makefile
servers/groupwise/libegroupwise-1.0.pc 
src/Makefile
docs/Makefile
docs/reference/Makefile
docs/reference/addressbook/Makefile
docs/reference/addressbook/libebook/Makefile
docs/reference/calendar/Makefile
docs/reference/calendar/libecal/Makefile
po/Makefile.in
])

echo "
	evolution-data-server has been configured as follows:
	LDAP support:     $msg_ldap
	Gtk Doc:          $enable_gtk_doc
"
