aboutsummaryrefslogtreecommitdiffstats
path: root/wombat/wombat.c
blob: 5c40b0530a3db30a58a93bcc9b189e38e9d8b254 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/* Wombat personal information server - main file
 *
 * Author: Nat Friedman <nat@helixcode.com>
 *
 * Copyright 2000, Helix Code, Inc.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdlib.h>
#include <glib.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-init.h>
#include <liboaf/liboaf.h>
#include <libgnomevfs/gnome-vfs-init.h>
#include <bonobo/bonobo-main.h>

#include "pas/pas-book-factory.h"
#include "pas/pas-backend-file.h"

#include "calendar/pcs/cal-factory.h"
#include "calendar/pcs/cal-backend-file.h"

#ifdef HAVE_LDAP
#include "pas/pas-backend-ldap.h"
#endif

#include "wombat-moniker.h"

/* The and addressbook calendar factories */

static CalFactory *cal_factory;
static PASBookFactory *pas_book_factory;

/* Timeout interval in milliseconds for termination */
#define EXIT_TIMEOUT 5000

/* Timeout ID for termination handler */
static guint termination_handler_id;



/* Termination */

/* Termination handler.  Checks if both factories have zero running backends,
 * and if so terminates the program.
 */
static gboolean
termination_handler (gpointer data)
{
    if (cal_factory_get_n_backends (cal_factory) == 0
        && pas_book_factory_get_n_backends (pas_book_factory) == 0) {
        fprintf (stderr, "termination_handler(): Terminating the Wombat.  Have a nice day.\n");
        gtk_main_quit ();
    }

    termination_handler_id = 0;
    return FALSE;
}

/* Queues a timeout for handling termination of Wombat */
static void
queue_termination (void)
{
    if (termination_handler_id)
        return;

    termination_handler_id = g_timeout_add (EXIT_TIMEOUT, termination_handler, NULL);
}



static void
last_book_gone_cb (PASBookFactory *factory, gpointer data)
{
    queue_termination ();
}

static gboolean
setup_pas (int argc, char **argv)
{
    pas_book_factory = pas_book_factory_new ();

    if (!pas_book_factory)
        return FALSE;

    pas_book_factory_register_backend (
        pas_book_factory, "file", pas_backend_file_new);

#ifdef HAVE_LDAP
    pas_book_factory_register_backend (
        pas_book_factory, "ldap", pas_backend_ldap_new);
#endif

    gtk_signal_connect (GTK_OBJECT (pas_book_factory),
                "last_book_gone",
                GTK_SIGNAL_FUNC (last_book_gone_cb),
                NULL);

    if (!pas_book_factory_activate (pas_book_factory)) {
        bonobo_object_unref (BONOBO_OBJECT (pas_book_factory));
        pas_book_factory = NULL;
        return FALSE;
    }

    return TRUE;
}



/* Personal calendar server */

/* Callback used when the calendar factory has no more running backends */
static void
last_calendar_gone_cb (CalFactory *factory, gpointer data)
{
    fprintf (stderr, "last_calendar_gone_cb() called!  Queueing termination...\n");
    queue_termination ();
}

/* Creates the calendar factory object and registers it */
static gboolean
setup_pcs (int argc, char **argv)
{
    cal_factory = cal_factory_new ();

    if (!cal_factory) {
        g_message ("setup_pcs(): Could not create the calendar factory");
        return FALSE;
    }

    cal_factory_register_method (cal_factory, "file", CAL_BACKEND_FILE_TYPE);

    if (!cal_factory_oaf_register (cal_factory)) {
        bonobo_object_unref (BONOBO_OBJECT (cal_factory));
        cal_factory = NULL;
        return FALSE;
    }

    gtk_signal_connect (GTK_OBJECT (cal_factory),
                "last_calendar_gone",
                GTK_SIGNAL_FUNC (last_calendar_gone_cb),
                NULL);

    return TRUE;
}



static gboolean
setup_config (int argc, char **argv)
{
    BonoboGenericFactory *factory;
    char *oafiid = "OAFIID:Bonobo_Moniker_wombat_Factory";

    factory = bonobo_generic_factory_new_multi (oafiid, 
                            wombat_moniker_factory,
                            NULL);
       
    // bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));
       

    return TRUE;
}

static void
setup_vfs (int argc, char **argv)
{
    if (!gnome_vfs_init ()) {
        g_message (_("setup_vfs(): could not initialize GNOME-VFS"));
        exit (EXIT_FAILURE);
    }
}



static void
init_corba (int *argc, char **argv)
{
    if (gnome_init_with_popt_table ("wombat", VERSION,
                    *argc, argv, oaf_popt_options, 0, NULL) != 0) {
        g_message (_("init_corba(): could not initialize GNOME"));
        exit (EXIT_FAILURE);
    }

    oaf_init (*argc, argv);
}

static void
init_bonobo (int *argc, char **argv)
{
    init_corba (argc, argv);

    if (!bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL)) {
        g_message (_("init_bonobo(): could not initialize Bonobo"));
        exit (EXIT_FAILURE);
    }
}

int
main (int argc, char **argv)
{
    gboolean did_pas=FALSE, did_pcs=FALSE, did_config=FALSE;

    bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR);
    textdomain (PACKAGE);

    g_message ("Starting wombat");

    init_bonobo (&argc, argv);
    setup_vfs (argc, argv);

    /*g_log_set_always_fatal (G_LOG_LEVEL_ERROR |
                G_LOG_LEVEL_CRITICAL |
                G_LOG_LEVEL_WARNING);*/

    if (!( (did_pas = setup_pas (argc, argv))
           && (did_pcs = setup_pcs (argc, argv))
           && (did_config = setup_config (argc, argv)))) {

        const gchar *failed = NULL;

        if (!did_pas)
          failed = "PAS";
        else if (!did_pcs)
          failed = "PCS";
        else if (!did_config)
          failed = "Config";

        g_message ("main(): could not initialize Wombat service \"%s\"; terminating", failed);

        if (pas_book_factory) {
            bonobo_object_unref (BONOBO_OBJECT (pas_book_factory));
            pas_book_factory = NULL;
        }

        if (cal_factory) {
            bonobo_object_unref (BONOBO_OBJECT (cal_factory));
            cal_factory = NULL;
        }

        exit (EXIT_FAILURE);
    }

    bonobo_main ();

    bonobo_object_unref (BONOBO_OBJECT (cal_factory));
    cal_factory = NULL;

    bonobo_object_unref (BONOBO_OBJECT (pas_book_factory));
    pas_book_factory = NULL;

    return 0;
}
'n1021' href='#n1021'>1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250
# Process this file with autoconf to produce a configure script.
AC_INIT(camel)
AM_CONFIG_HEADER(config.h)

EVOLUTION_MAJOR_VERSION=1
EVOLUTION_MINOR_VERSION=1
EVOLUTION_MICRO_VERSION=0
EVOLUTION_NANO_VERSION=99
VERSION=$EVOLUTION_MAJOR_VERSION.$EVOLUTION_MINOR_VERSION.$EVOLUTION_MICRO_VERSION.$EVOLUTION_NANO_VERSION
PACKAGE=evolution

AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
AC_SUBST(VERSION)

AC_DEFINE_UNQUOTED(VERSION_COMMENT, "(Preview Release)")

AC_DEFUN(EVO_CHECK_LIB, [
    dispname="$1"
    pkgname="$2"
    minvers="$3"
    maxvers="$4"

    AC_MSG_CHECKING(for $dispname)

    if gnome-config --libs $pkgname > /dev/null 2>&1; then
        pkgvers=`gnome-config --modversion $pkgname | sed -e 's/^[[^0-9]]*//'`
    else
        pkgvers=not
    fi
    AC_MSG_RESULT($pkgvers found)

    pkgvers=`echo $pkgvers | awk -F. '{ print $[]1 * 1000000 + $[]2 * 10000 + $[]3 * 100 + $[]4;}'`
    cmpminvers=`echo $minvers | awk -F. '{ print $[]1 * 1000000 + $[]2 * 10000 + $[]3 * 100 + $[]4;}'`
    cmpmaxvers=`echo $maxvers | awk -F. '{ print $[]1 * 1000000 + $[]2 * 10000 + $[]3 * 100 + $[]4;}'`
    ok=yes
    if test "$pkgvers" -lt $cmpminvers; then
        ok=no
    elif test -n "$maxvers"; then
        if test "$pkgvers" -gt $cmpmaxvers; then
            ok=no
        elif test "$maxvers" != "$minvers" -a "$cmpmaxvers" -eq "$pkgvers"; then
            ok=no
        fi
    fi
    if test $ok = no; then
        case $maxvers in
        "")
            dispvers="$minvers or higher"
            ;;
        $minvers)
            dispvers="$minvers (exactly)"
            ;;
        *)
            dispvers="$minvers or higher, but less than $maxvers,"
            ;;
        esac

        AC_MSG_ERROR([
""
"You need $dispname $dispvers to build Evolution"
"If you think you already have this installed, consult the README."])
    fi
])

SCROLLKEEPER_REQUIRED=0.1.4
AC_SUBST(SCROLLKEEPER_REQUIRED)

dnl Check for scrollkeeper
AC_PATH_PROG(SCROLLKEEPER_CONFIG, scrollkeeper-config,no)
if test x$SCROLLKEEPER_CONFIG = xno; then
  AC_MSG_ERROR(Couldn't find scrollkeeper-config -- please install the scrollkeeper package)
fi
SCROLLKEEPER_LOCALSTATE_DIR=`scrollkeeper-config --pkglocalstatedir`
AC_SUBST(SCROLLKEEPER_LOCALSTATE_DIR)

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 Initialize maintainer mode
AM_MAINTAINER_MODE

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

dnl Initialize xml-i18n-tools
AM_PROG_XML_I18N_TOOLS

dnl Initialize libtool
AM_PROG_LIBTOOL

AM_ACLOCAL_INCLUDE(macros)
GNOME_INIT()
GNOME_COMPILE_WARNINGS
GNOME_X_CHECKS
EVO_CHECK_LIB(gnome-libs, gnome, 1.2.9)
AC_CHECK_HEADERS(alloca.h)

ALL_LINGUAS="az bg ca da de el en_AU en_GB es eu fi fr ga gl hu it ja ko lt lv nl nn no pl pt pt_BR ro ru sk sl sv tr uk zh_CN zh_TW"
AM_GNOME_GETTEXT
localedir='$(prefix)/$(DATADIRNAME)/locale'
AC_SUBST(localedir)

dnl
dnl Purify support
dnl
AC_ARG_ENABLE(purify, 
[  --enable-purify=[no/yes]      Enable support for building executables with
                                Purify.],,enable_purify=no)
AC_PATH_PROG(PURIFY, purify, impure)
AC_ARG_WITH(purify-options, [  --with-purify-options=OPTIONS      Options passed to the purify command line (defaults to PURIFYOPTIONS variable).])
if test "x$with_purify_options" = "xno"; then
  with_purify_options="-always-use-cache-dir=yes -cache-dir=/gnome/lib/purify"
fi
if test "x$PURIFYOPTIONS" = "x"; then
  PURIFYOPTIONS=$with_purify_options
fi
AC_SUBST(PURIFY)
AM_CONDITIONAL(ENABLE_PURIFY, test "x$enable_purify" = "xyes" -a "x$PURIFY" != "ximpure")
PURIFY="$PURIFY $PURIFYOPTIONS"


AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, /usr/sbin:/usr/lib)
AC_DEFINE_UNQUOTED(SENDMAIL_PATH, "$SENDMAIL")

AC_MSG_CHECKING(system mail directory)
if test -d /var/mail -a '!' -h /var/mail ; then
    system_mail_dir=/var/mail
else
    system_mail_dir=/var/spool/mail
fi
AC_DEFINE_UNQUOTED(SYSTEM_MAIL_DIR, "$system_mail_dir")

case `ls -ld $system_mail_dir 2>&1 | awk '{print $1;}'` in
d??????rw?)
    CAMEL_LOCK_HELPER_USER=""
    CAMEL_LOCK_HELPER_GROUP=""
    system_mail_perm="world writable"
    ;;

d???rw????)
    CAMEL_LOCK_HELPER_USER=""
    CAMEL_LOCK_HELPER_GROUP=`ls -ld $system_mail_dir 2>&1 | awk '{print $4;}'`
    system_mail_perm="writable by group $CAMEL_LOCK_HELPER_GROUP"
    ;;

drw???????)
    CAMEL_LOCK_HELPER_USER=`ls -ld $system_mail_dir 2>&1 | awk '{print $3;}'`
    CAMEL_LOCK_HELPER_GROUP=""
    system_mail_perm="writable by user $CAMEL_LOCK_HELPER_USER"
    ;;

*)
    CAMEL_LOCK_HELPER_USER=""
    CAMEL_LOCK_HELPER_GROUP=""
    system_mail_perm="???"
    ;;
esac

AC_MSG_RESULT([$system_mail_dir, $system_mail_perm])
AC_SUBST(CAMEL_LOCK_HELPER_USER)
AC_SUBST(CAMEL_LOCK_HELPER_GROUP)

dnl * Time zone stuff
AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
    AC_TRY_COMPILE([
        #include <time.h>
    ], [
        timezone = 1;
    ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
if test $ac_cv_var_timezone = yes; then
    AC_DEFINE(HAVE_TIMEZONE)
else
    AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
        AC_TRY_COMPILE([
            #include <time.h>
            ], [
            struct tm tm;
            tm.tm_gmtoff = 1;
            ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
    if test $ac_cv_struct_tm_gmtoff = yes; then
        AC_DEFINE(HAVE_TM_GMTOFF)
    else
        AC_ERROR(unable to find a way to determine timezone)
    fi
fi

AC_CHECK_FUNCS(mkstemp mkdtemp isblank)

dnl **************************************************
dnl ctime_r prototype
dnl **************************************************

AC_CACHE_CHECK([if ctime_r wants three arguments], ac_cv_ctime_r_three_args,
[
    AC_TRY_COMPILE([
        #include <time.h>
    ],[
        char *buf;
        time_t date;
        ctime_r( &date, buf, 100 );
    ],[
        ac_cv_ctime_r_three_args=yes
    ],[
        ac_cv_ctime_r_three_args=no
    ])
])
    
if test x"$ac_cv_ctime_r_three_args" = xyes ; then
    AC_DEFINE(CTIME_R_THREE_ARGS)
fi

dnl **************************************************
dnl gethostbyname_r prototype
dnl **************************************************

AC_CHECK_FUNCS(gethostbyname_r,[
AC_CACHE_CHECK([if gethostbyname_r wants five arguments], ac_cv_gethostbyname_r_five_args,
[
    AC_TRY_COMPILE([
        #include "confdefs.h"
        #include <sys/types.h>
        #include <sys/socket.h>
        #include <netinet/in.h>
        #include <netdb.h>

        #define BUFSIZE (sizeof(struct hostent)+10)
    ],[
        struct hostent hent;
        char buffer[BUFSIZE];
        int bufsize=BUFSIZE;
        int h_errno;

        (void)gethostbyname_r( "www.ximian.com", &hent, buffer, bufsize, &h_errno);
    ],[
        ac_cv_gethostbyname_r_five_args=yes
    ],[
        ac_cv_gethostbyname_r_five_args=no
    ])
])])
    
if test x"$ac_cv_gethostbyname_r_five_args" = xyes ; then
    AC_DEFINE(GETHOSTBYNAME_R_FIVE_ARGS)
fi

dnl ***********
dnl * db3 stuff
dnl ***********

# To ensure that any copy of evolution of a given version can read
# the data files of any other copy, we require a precise db3 version.
# This can only change between Evolution versions (and then can only
# go up.)
evolution_db_version_major=3
evolution_db_version_minor=1
evolution_db_version_patch=17

evolution_db_version=${evolution_db_version_major}.${evolution_db_version_minor}.${evolution_db_version_patch}
AC_DEFINE_UNQUOTED(EVOLUTION_DB_VERSION_MAJOR,$evolution_db_version_major)
AC_DEFINE_UNQUOTED(EVOLUTION_DB_VERSION_MINOR,$evolution_db_version_minor)
AC_DEFINE_UNQUOTED(EVOLUTION_DB_VERSION_PATCH,$evolution_db_version_patch)


AC_ARG_WITH(db3,          [  --with-db3=PREFIX              Location of db3],
    [with_db3_includes="$withval/include"
     with_db3_libs="$withval/lib"])
AC_ARG_WITH(db3-includes, [  --with-db3-includes=PATH       Location of db3 includes],
    with_db3_includes="$withval")
AC_ARG_WITH(db3-libs,     [  --with-db3-libs=PATH           Location of db3 libs],
    with_db3_libs="$withval")

if test -z "$with_db3_libs"; then
    with_db3_libs="/usr/lib"
fi

dnl The AC_CACHE_CHECK lets you avoid having to specify --with-db3
dnl again with later configures
AC_CACHE_CHECK([for db3 compiler flags], ac_cv_db3_cflags,
[
    if test -n "${with_db3_includes}"; then
        ac_cv_db3_cflags="-I$with_db3_includes"
    fi
])
DB3_CFLAGS=$ac_cv_db3_cflags
AC_SUBST(DB3_CFLAGS)

CPPFLAGS_save="$CPPFLAGS"
CPPFLAGS="$DB3_CFLAGS $CPPFLAGS"
AC_CHECK_HEADERS(db.h db3/db.h, break)

AC_CACHE_CHECK([db3 header version], ac_cv_db3_header_version,
[
    AC_TRY_COMPILE([
        #ifdef HAVE_DB3_DB_H
        #include <db3/db.h>
        #else
        #include <db.h>
        #endif
    ],[
        #if DB_VERSION_MAJOR != $evolution_db_version_major || \
            DB_VERSION_MINOR != $evolution_db_version_minor || \
            DB_VERSION_PATCH != $evolution_db_version_patch
        #error
        #endif
    ], :, AC_MSG_ERROR(Found db.h is not version $evolution_db_version))

    ac_cv_db3_header_version=$evolution_db_version
])

AC_CACHE_CHECK([for db3 library name], ac_cv_db3_ldadd,
[
    LIBS_save="$LIBS"
    ac_cv_db3_ldadd=""

    for name in db db3 db-3.1; do
        LIBS="$LIBS_save $with_db3_libs/lib${name}.a"
        AC_TRY_LINK([
            #ifdef HAVE_DB3_DB_H
            #include <db3/db.h>
            #else
            #include <db.h>
            #endif
        ],[
            DB *db;
            db_create (&db, 0, 0);
        ], [
            ac_cv_db3_ldadd="$with_db3_libs/lib${name}.a"
            break
        ])
    done
    LIBS="$LIBS_save"

    if test -z "$ac_cv_db3_ldadd"; then
        AC_MSG_ERROR(Could not find db3 library)
    fi
])
DB3_LDADD=$ac_cv_db3_ldadd
AC_SUBST(DB3_LDADD)

AC_CACHE_CHECK([that db3 library version matches header version], ac_cv_db3_lib_version_match,
[
    LIBS="$DB3_LDADD $LIBS"
    AC_TRY_RUN([
        #ifdef HAVE_DB3_DB_H
        #include <db3/db.h>
        #else
        #include <db.h>
        #endif

        int
        main (void)
        {
            int major, minor, patch;

            db_version (&major, &minor, &patch);
            return !(major == DB_VERSION_MAJOR &&
                 minor == DB_VERSION_MINOR &&
                 patch == DB_VERSION_PATCH);
        }
    ], ac_cv_db3_lib_version_match=yes, ac_cv_db3_lib_version_match=no,
    ac_cv_db3_lib_version_match=yes)
])
if test "$ac_cv_db3_lib_version_match" = no; then
    AC_MSG_ERROR(db3 headers and library do not match... multiple copies installed?)
fi

CPPFLAGS="$CPPFLAGS_save"
LIBS="$LIBS_save"


dnl **************************************************
dnl * ldap related stuff.
dnl **************************************************
AC_ARG_WITH(openldap,     [  --with-openldap=[no/yes/PREFIX]      Enable LDAP support in evolution])
AC_ARG_WITH(static-ldap,  [  --with-static-ldap=[no/yes]          Link LDAP support statically into evolution ])
AC_CACHE_CHECK([for OpenLDAP], ac_cv_with_openldap, ac_cv_with_openldap="${with_openldap:=no}")
case $ac_cv_with_openldap in
no|"")
    msg_ldap=no
    ;;
yes)
    with_openldap=/usr
    msg_ldap=yes
    ;;
*)
    with_openldap=$ac_cv_with_openldap
    LDAP_CFLAGS="-I$ac_cv_with_openldap/include"
    LDAP_LDFLAGS="-L$ac_cv_with_openldap/lib"
    msg_ldap=yes
    ;;
esac

if test "$msg_ldap" = yes; then

    AC_DEFINE(HAVE_LDAP)

    if test -f $with_openldap/lib/libldap.la; then
        msg_ldap_linktype="(static)"
    else
        msg_ldap_linktype="(dynamic)"
    fi


    if test "${with_static_ldap+set}" = set; then
        case $with_static_ldap in
        no|"")
            msg_ldap_linktype="(dynamic)"
            ;;
        *)
            msg_ldap_linktype="(static)"
            ;;
        esac
    fi

    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 "$msg_ldap_linktype" = "(static)"; 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 $msg_ldap_linktype = "(static)"; 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)
    elif test "$msg_ldap_linktype" = "(static)"; then
        LDAP_LIBS="-Wl,-Bstatic $LDAP_LIBS -Wl,-Bdynamic"
    fi

    AC_SUBST(LDAP_CFLAGS)
    AC_SUBST(LDAP_LIBS)
fi
AM_CONDITIONAL(ENABLE_LDAP, test $msg_ldap = yes)

dnl **************************************************
dnl NNTP support.
dnl **************************************************
AC_ARG_ENABLE(nntp, 
[  --enable-nntp=[no/yes]      Attempt to compile incomplete, unsupported NNTP code],,enable_nntp=no)
if test "x$enable_nntp" = "xyes"; then
    AC_DEFINE(ENABLE_NNTP)
    msg_nntp=yes
else
    msg_nntp=no
fi
AM_CONDITIONAL(ENABLE_NNTP, test x$enable_nntp = xyes)

dnl **************************************************
dnl * Posix thread support
dnl **************************************************

dnl Hah! Threads are no longer an option
dnl AC_ARG_WITH(threads, [  --with-threads          Include thread support],[
dnl FIXME: support more thread types, pth at least

GLIB_CONFIG=${GLIB_CONFIG-glib-config}
GNOME_PTHREAD_CHECK

if test "x$PTHREAD_LIB" = "x" ; then
    AC_MSG_ERROR([POSIX threads are currently required for Evolution])
fi

dnl
dnl Notice that this is a hack, and we wont be able to use this forever, but
dnl at least for some time
dnl

THREADS_LIBS="$PTHREAD_LIB `$GLIB_CONFIG --libs gthread`"
THREADS_CFLAGS="`$GLIB_CONFIG --cflags gthread`"

AC_SUBST(THREADS_LIBS)
AC_SUBST(THREADS_CFLAGS)
AC_DEFINE(ENABLE_THREADS)

dnl **************************************************
dnl * File locking
dnl **************************************************

AC_ARG_ENABLE(dot-locking, 
[  --enable-dot-locking=[yes/no] Enable support for locking mail files with dot locking],,enable_dot_locking=yes)
if test "x$enable_dot_locking" = "xyes"; then
  AC_DEFINE(USE_DOT)
  msg_dot=yes
else
  msg_dot=no    
fi

AC_ARG_ENABLE(file-locking, 
[  --enable-file-locking=[fcntl/flock/no] Enable support for locking mail files with file locking],,enable_file_locking=fcntl)
if test "x$enable_file_locking" = "xfcntl"; then
  AC_DEFINE(USE_FCNTL)
  msg_file=fcntl
else
  if test "x$enable_file_locking" = "xflock"; then
    AC_DEFINE(USE_FLOCK)
    msg_file=flock
  else
    msg_file=no 
  fi
fi

dnl **************************************************
dnl * sendmail operation
dnl **************************************************

AC_MSG_CHECKING(for SunOS broken spool format)
if test "x$host_os" = "xsunos" ; then
   with_broken_spool="yes"
fi

AC_ARG_WITH(broken-spool, 
[  --with-broken-spool=[yes/no] Using SunOS/Solaris sendmail which has a broken spool format],,with_broken_spool=${with_broken_spool:=no})

if test "x$with_broken_spool" = "xyes"; then
  AC_DEFINE(HAVE_BROKEN_SPOOL)
fi

AC_MSG_RESULT($with_broken_spool)

dnl ***************
dnl GNOME Libraries
dnl ***************
EVO_CHECK_LIB(Bonobo, bonobox, 1.0.3)
EVO_CHECK_LIB(OAF, oaf, 0.6.2)
EVO_CHECK_LIB(libglade, libglade, 0.14)
EVO_CHECK_LIB(gdk-pixbuf with GNOME canvas support, gnomecanvaspixbuf, 0.9.0)
EVO_CHECK_LIB(GNOME-VFS, vfs, 1.0)
EVO_CHECK_LIB(libxml, xml, 1.8.10, 2.0)
EVO_CHECK_LIB(bonobo-conf, bonobo_conf, 0.11)

EVO_CHECK_LIB(GAL, gal, 0.19.99.5)
EVO_CHECK_LIB(GtkHTML, gtkhtml, 1.0)
EVO_CHECK_LIB(Libsoup, soup, 0.6)

dnl ******************************
dnl Pilot checking
dnl ******************************
AC_ARG_ENABLE(pilot-conduits, 
[  --enable-pilot-conduits=[no/yes] Enable support for building pilot conduits.],,enable_pilot_conduits=no)
if test "x$enable_pilot_conduits" = "xyes"; then
    GNOME_PILOT_CHECK

    CFLAGS_save="$CFLAGS"
    CFLAGS="$CFLAGS $PISOCK_CFLAGS"
    LDFLAGS_save="$LDFLAGS"
    LDFLAGS="$LDFLAGS $PISOCK_LIBS"

    AC_CACHE_CHECK([if pilot-link handles UTF-8 conversions], ac_cv_pilot_link_utf8, AC_TRY_RUN([

#include <stdlib.h>
#include <string.h>
#include <pi-util.h>

int main (int argc, char **argv)
{
    const char *utf8 = "\x66\x66\x66\x66\x66\x66\x66\xC2\xA9";
    size_t utf8_real_len = strlen (utf8);
    char *pstring;  

    if (convert_ToPilotChar ("UTF-8", utf8, utf8_real_len, &pstring) == -1)
            exit (1);

    exit (0);
}
], ac_cv_pilot_link_utf8=yes, ac_cv_pilot_link_utf8=no, ac_cv_pilot_link_utf8=no))

    CFLAGS="$CFLAGS_save"
    LDFLAGS="$LDFLAGS_save"

    if test "$ac_cv_pilot_link_utf8" = no; then
        AC_MSG_ERROR(evolution requires pilot-link to have working UTF-8 conversion routines)
    fi
fi
AM_CONDITIONAL(ENABLE_PILOT_CONDUITS, test "x$enable_pilot_conduits" = "xyes")
if test x$enable_pilot_conduits = xyes; then
   msg_pilot=yes
else
   msg_pilot=no
fi

dnl ********
dnl Kerberos
dnl ********
AC_ARG_WITH(krb5, [  --with-krb5=PREFIX      Location of Kerberos 5 libs/includes])
AC_ARG_WITH(krb4, [  --with-krb4=PREFIX      Location of Kerberos 4 libs/includes])
msg_krb5=no
if test ${with_krb5:=no} != no; then
    LDFLAGS_save="$LDFLAGS"

    mitlibs="-lkrb5 -lk5crypto -lcom_err"
    heimlibs="-lkrb5 -lcrypto -lasn1 -lcom_err -lroken"
    AC_CACHE_CHECK([for Kerberos 5], ac_cv_lib_kerberos5,
    [
        LDFLAGS="$LDFLAGS -L$with_krb5/lib $mitlibs"
        AC_TRY_LINK_FUNC(krb5_init_context, ac_cv_lib_kerberos5="$mitlibs",
        [
            LDFLAGS="$LDFLAGS_save -L$with_krb5/lib $heimlibs"
            AC_TRY_LINK_FUNC(krb5_init_context, ac_cv_lib_kerberos5="$heimlibs", ac_cv_lib_kerberos5=no)
        ])
        LDFLAGS="$LDFLAGS_save"
    ])
    if test "$ac_cv_lib_kerberos5" != no; then
        AC_DEFINE(HAVE_KRB5)
        msg_krb5=yes
        KRB5_CFLAGS="-I$with_krb5/include/krb5"
        KRB5_LDFLAGS="-L$with_krb5/lib $ac_cv_lib_kerberos5"
    fi
else
    AC_MSG_CHECKING(for Kerberos 5)
    AC_MSG_RESULT($with_krb5)
fi

msg_krb4=no
if test x${with_krb4:=no} != xno; then
    LDFLAGS_save="$LDFLAGS"
    AC_CACHE_CHECK(for Kerberos 4, ac_cv_lib_kerberos4,
    [
        ac_cv_lib_kerberos4=no

        case $ac_cv_lib_kerberos5 in
        *k5crypto*)
            # Look for MIT krb5 compat krb4
            LDFLAGS="$LDFLAGS -L$with_krb4/lib -lkrb4 -ldes425 $KRB5_LDFLAGS"
            AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb4 -ldes425 $KRB5_LDFLAGS")
            ;;
        esac

        if test "$ac_cv_lib_kerberos4" = no; then
            # Look for KTH krb4
            LDFLAGS="$LDFLAGS_save -L$with_krb4/lib -lkrb -lcrypto -lcom_err -lroken"
            AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb -lcrypto -lcom_err -lroken")
        fi
        if test "$ac_cv_lib_kerberos4" = no; then
            # Look for old MIT krb4
            LDFLAGS="$LDFLAGS_save -L$with_krb4/lib -lkrb"
            AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4=-lkrb,
            [
                LDFLAGS="$LDFLAGS -ldes"
                AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb -ldes")
            ])
        fi
    ])
    LDFLAGS="$LDFLAGS_save"
    if test "$ac_cv_lib_kerberos4" != no; then
        AC_DEFINE(HAVE_KRB4)
        msg_krb4=yes
        if test -f "$with_krb4/include/krb.h" -o -f "$with_krb4/include/port-sockets.h"; then
            KRB4_CFLAGS="-I$with_krb4/include"
        fi
        if test -d "$with_krb4/include/kerberosIV"; then
            KRB4_CFLAGS="-I$with_krb4/include/kerberosIV"
        fi
        KRB4_LDFLAGS="-L$with_krb4/lib $ac_cv_lib_kerberos4"

        CFLAGS_save="$CFLAGS"
        CFLAGS="$CFLAGS $KRB4_CFLAGS"
        AC_TRY_COMPILE([#include "krb.h"
        int krb_sendauth;
        ],[return 0],[AC_DEFINE(NEED_KRB_SENDAUTH_PROTO)],)
        CFLAGS="$CFLAGS_save"
    fi
else
    AC_MSG_CHECKING(for Kerberos 4)
    AC_MSG_RESULT(${with_krb4})
fi

AC_SUBST(KRB5_CFLAGS)
AC_SUBST(KRB5_LDFLAGS)
AC_SUBST(KRB4_CFLAGS)
AC_SUBST(KRB4_LDFLAGS)


dnl ==========================
dnl Pedantic PGP/MIME
dnl ==========================
AC_ARG_ENABLE(pedantic-pgp-mime, 
[  --enable-pedantic-pgp-mime=[no/yes] Enable pedantic PGP/MIME handling (not recommended)],,enable_pedantic_pgp_mime=no)
if test "x$enable_pedantic_pgp_mime" = "xyes"; then
    AC_DEFINE(ENABLE_PEDANTIC_PGPMIME)
fi


dnl ********************************************************************************
dnl security extension support (SSL and S/MIME)
dnl
dnl The following voodoo does detection of mozilla libraries (nspr and nss) 
dnl needed by Camel (SSL and S/MIME).
dnl
dnl The Evolution security extensions are only built if these libraries are found
dnl ********************************************************************************
msg_ssl=no
AC_ARG_WITH(nspr-includes, [  --with-nspr-includes=PREFIX     Location of Mozilla nspr4 includes.],
    with_nspr_includes="$withval", with_nspr_includes="/usr/include/nspr")
have_nspr_includes="no"
if test "x${with_nspr_includes}" != "xno"; then
    CPPFLAGS_save="$CPPFLAGS"
    
    AC_MSG_CHECKING(for Mozilla nspr4 includes in $with_nspr_includes)
    AC_MSG_RESULT("")
    
    CPPFLAGS="$CPPFLAGS -I$with_nspr_includes"
    AC_CHECK_HEADERS(nspr.h prio.h, [ moz_nspr_includes="yes" ])
    CPPFLAGS="$CPPFLAGS_save"
    
    if test "x{$moz_nspr_includes}" != "xno" -a "x{$moz_nspr_includes}" != "x" ; then
        have_nspr_includes="yes"
        NSPR_CFLAGS="-I$with_nspr_includes"
    fi
else
    AC_MSG_CHECKING(for Mozilla nspr4 includes)
    AC_MSG_RESULT(no)
fi

AC_ARG_WITH(nspr-libs, [  --with-nspr-libs=PREFIX     Location of Mozilla nspr4 libs.],
    with_nspr_libs="$withval")
have_nspr_libs="no"
if test "x${with_nspr_libs}" != "xno" -a "x${have_nspr_includes}" != "xno"; then
    CFLAGS_save="$CFLAGS"
    LDFLAGS_save="$LDFLAGS"
    
    nsprlibs="-lplc4 -lplds4 -lnspr4 $PTHREAD_LIB"
    AC_CACHE_CHECK([for Mozilla nspr libraries], moz_nspr_libs,
    [
        CFLAGS="$CFLAGS $NSPR_CFLAGS"
        
        if test "x${with_nspr_libs}" != "x"; then
            LDFLAGS="$LDFLAGS -L$with_nspr_libs $nsprlibs"
        else
            LDFLAGS="$LDFLAGS $nsprlibs"
        fi
        
        AC_TRY_LINK_FUNC(PR_Init, moz_nspr_libs="yes", moz_nspr_libs="no")
        CFLAGS="$CFLAGS_save"
        LDFLAGS="$LDFLAGS_save"
    ])
    if test "x$moz_nspr_libs" != "xno"; then
        have_nspr_libs="yes"
        NSPR_LDFLAGS="-L$with_nspr_libs $nsprlibs"
    else
        NSPR_CLFAGS=""
    fi
else
    AC_MSG_CHECKING(for Mozilla nspr4 libraries)
    AC_MSG_RESULT(no)
fi

AC_ARG_WITH(nss-includes, [  --with-nss-includes=PREFIX     Location of Mozilla nss3 includes.],
    with_nss_includes="$withval", with_nss_includes="/usr/include/moznss")
if test "x${with_nss_includes}" != "xno" -a "x${have_nspr_libs}" != "xno"; then
    CPPFLAGS_save="$CPPFLAGS"
    
    AC_MSG_CHECKING(for Mozilla nss3 includes in $with_nss_includes)
    AC_MSG_RESULT("")

        if test "x${with_nspr_includes}" != "x"; then
            CPPFLAGS="$CPPFLAGS -I$with_nspr_includes -I$with_nss_includes"
        else
            CPPFLAGS="$CPPFLAGS -I$with_nss_includes"
        fi

    AC_CHECK_HEADERS(nss.h ssl.h smime.h,
        [ have_nss_includes="yes" ], 
        [ have_nss_includes="no" ])

    CPPFLAGS="$CPPFLAGS_save"

    if test "x${have_nss_includes}" = xyes ; then   
        have_nss_includes="yes"
        NSS_CFLAGS="-I$with_nss_includes"
    else
        NSPR_CFLAGS=""
        NSPR_LDFLAGS=""
    fi
else
    AC_MSG_CHECKING(for Mozilla nss3 includes)
    AC_MSG_RESULT(no)
fi

AC_ARG_WITH(nss-libs, [  --with-nss-libs=PREFIX         Location of Mozilla nss3 libs.],
    with_nss_libs="$withval")
if test "x${with_nss_libs}" != "xno" -a "x${have_nss_includes}" != "xno"; then
    LDFLAGS_save="$LDFLAGS"
    
    nsprlibs="-lplc4 -lplds4 -lnspr4 $PTHREAD_LIB"
    nsslibs="-lssl3 -lsmime3 -lnss3"
    AC_CACHE_CHECK([for Mozilla nss libraries], moz_nss_libs,
    [
        LDFLAGS="$LDFLAGS -L$with_nspr_libs $nsprlibs -L$with_nss_libs $nsslibs"
        AC_TRY_LINK_FUNC(NSS_Init, moz_nss_libs="yes", moz_nss_libs="no")
        LDFLAGS="$LDFLAGS_save"
    ])
    if test "$moz_nss_libs" != no; then
        AC_DEFINE(HAVE_NSS)
        AC_DEFINE(HAVE_SSL)
        msg_ssl="yes (Mozilla NSS)"
        NSS_LDFLAGS="-L$with_nss_libs $nsslibs"
    else
        NSS_CFLAGS=""
        NSPR_CFLAGS=""
        NSPR_LDFLAGS=""
    fi
else
    AC_MSG_CHECKING(for Mozilla nss libraries)
    AC_MSG_RESULT(no)
fi

AC_SUBST(NSPR_CFLAGS)
AC_SUBST(NSPR_LDFLAGS)
AC_SUBST(NSS_CFLAGS)
AC_SUBST(NSS_LDFLAGS)

dnl ******************************
dnl OpenSSL
dnl ******************************

if test "$msg_ssl" = "no"; then
    AC_ARG_WITH(openssl-includes, [  --with-openssl-includes=PREFIX     Location of OpenSSL includes.],
        with_openssl_includes="$withval", with_openssl_includes="/usr/include")
    have_openssl_includes="no"
    if test "x${with_openssl_includes}" != "xno"; then
        CPPFLAGS_save="$CPPFLAGS"
        
        AC_MSG_CHECKING(for OpenSSL includes)
        AC_MSG_RESULT("")
        
        CPPFLAGS="$CPPFLAGS -I$with_openssl_includes"
        AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h, [ openssl_includes="yes" ])
        CPPFLAGS="$CPPFLAGS_save"
        
        if test "x{$openssl_includes}" != "xno" -a "x{$openssl_includes}" != "x"; then
            have_openssl_includes="yes"
            OPENSSL_CFLAGS="-I$with_openssl_includes"
        else
            OPENSSL_CFLAGS=""
        fi
    else
        AC_MSG_CHECKING(for OpenSSL includes)
        AC_MSG_RESULT(no)
    fi
    
    AC_ARG_WITH(openssl-libs, [  --with-openssl-libs=PREFIX         Location of OpenSSL libs.],
        with_openssl_libs="$withval")
    if test "x${with_openssl_libs}" != "xno" -a "x${have_openssl_includes}" != "xno"; then
        LDFLAGS_save="$LDFLAGS"
    
        case $with_openssl_libs in
        ""|-L*) ;;
        *) with_openssl_libs="-L$with_openssl_libs" ;;
        esac
    
        AC_CHECK_LIB(dl, dlopen, DL_LDFLAGS="-ldl", DL_LDFLAGS="")
        AC_CACHE_CHECK([for OpenSSL libraries], openssl_libs,
        [
            LDFLAGS="$LDFLAGS $with_openssl_libs -lssl -lcrypto $DL_LDFLAGS"
            AC_TRY_LINK_FUNC(SSL_read, openssl_libs="yes", openssl_libs="no")
            LDFLAGS="$LDFLAGS_save"
        ])
        if test "x${openssl_libs}" != "xno"; then
            AC_DEFINE(HAVE_OPENSSL)
            AC_DEFINE(HAVE_SSL)
            msg_ssl="yes (OpenSSL)"
            OPENSSL_LDFLAGS="$with_openssl_libs -lssl -lcrypto $DL_LDFLAGS"
        else
            OPENSSL_CFLAGS=""
            OPENSSL_LDFLAGS=""
        fi
    else
        AC_MSG_CHECKING(for OpenSSL libraries)
        AC_MSG_RESULT(no)
    fi
else
    OPENSSL_CFLAGS=""
    OPENSSL_LDFLAGS=""
fi
    
AC_SUBST(OPENSSL_CFLAGS)
AC_SUBST(OPENSSL_LDFLAGS)

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

AC_DEFUN(EVO_SET_COMPILE_FLAGS, [
    deps="$2"
    extra_cflags="$3"
    extra_libs="$4"
    $1_CFLAGS="`gnome-config --cflags $deps` $extra_cflags"
    $1_LIBS="`gnome-config --libs $deps` $extra_libs"
])

dnl --- Flags to get all the GNOME stuff

FULL_GNOME_DEPS="bonobo_conf bonobox_print gal gdk_pixbuf gnomecanvaspixbuf gnomeui gtkhtml libglade oaf vfs"

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

dnl -- Find the directory where the GtkHTML editing component has its
dnl    IDL files

GTKHTML_DATADIR=`gnome-config --moddatadir gtkhtml`
AC_SUBST(GTKHTML_DATADIR)

dnl --- Flags for the various libraries we build

EVO_SET_COMPILE_FLAGS(CAMEL, gal xml,
              $THREADS_CFLAGS $KRB4_CFLAGS $NSPR_CFLAGS $NSS_CFLAGS $OPENSSL_CFLAGS,
                  $THREADS_LIBS $KRB4_LDFLAGS $NSPR_LDFLAGS $NSS_LDFLAGS $OPENSSL_LDFLAGS)
AC_SUBST(CAMEL_CFLAGS)
AC_SUBST(CAMEL_LIBS)

EVO_SET_COMPILE_FLAGS(E_NAME, bonobox gal oaf)
AC_SUBST(E_NAME_CFLAGS)
AC_SUBST(E_NAME_LIBS)

EVO_SET_COMPILE_FLAGS(E_UTIL, bonobox gal oaf)
AC_SUBST(E_UTIL_CFLAGS)
AC_SUBST(E_UTIL_LIBS)

EVO_SET_COMPILE_FLAGS(E_WIDGETS, bonobo_conf bonobox_print gdk_pixbuf gnomecanvaspixbuf gnomeui libglade oaf vfs)
AC_SUBST(E_WIDGETS_CFLAGS)
AC_SUBST(E_WIDGETS_LIBS)

EVO_SET_COMPILE_FLAGS(IMPORTERS, bonobo_conf bonobox_print gdk_pixbuf gnomecanvaspixbuf gnomeui libglade oaf vfs)
AC_SUBST(IMPORTERS_CFLAGS)
AC_SUBST(IMPORTERS_LIBS)

EVO_SET_COMPILE_FLAGS(LIBIBEX, bonobo_conf bonobox_print gal gdk_pixbuf gnomecanvaspixbuf gnomeui libglade oaf vfs)
AC_SUBST(LIBIBEX_CFLAGS)
AC_SUBST(LIBIBEX_LIBS)

EVO_SET_COMPILE_FLAGS(LIBFILTER, bonobo gal gdk_pixbuf gnomecanvaspixbuf gnomeui libglade)
AC_SUBST(LIBFILTER_CFLAGS)
AC_SUBST(LIBFILTER_LIBS)

dnl --- evolution (shell) flags

EVO_SET_COMPILE_FLAGS(SHELL, bonobo_conf bonobox_print gal gdk_pixbuf gnomecanvaspixbuf gnomeui gtkhtml libglade oaf vfs)
AC_SUBST(SHELL_CFLAGS)
AC_SUBST(SHELL_LIBS)

dnl --- evolution-addressbook flags

EVOLUTION_ADDRESSBOOK_DEPS="bonobo_conf bonobox_print gdk_pixbuf gnomecanvaspixbuf gnomeui gtkhtml libglade oaf vfs"

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

EVO_SET_COMPILE_FLAGS(EVOLUTION_ADDRESSBOOK_CONDUIT, gpilot $EVOLUTION_ADDRESSBOOK_DEPS)
AC_SUBST(EVOLUTION_ADDRESSBOOK_CONDUIT_CFLAGS)
AC_SUBST(EVOLUTION_ADDRESSBOOK_CONDUIT_LIBS)

dnl -- evolution-executive-summary flags

EVO_SET_COMPILE_FLAGS(EVOLUTION_EXECUTIVE_SUMMARY,
                      bonobo_conf bonobox bonobox_print gal gdk_pixbuf gnomecanvaspixbuf gnomeui gtkhtml libglade oaf soup vfs)
AC_SUBST(EVOLUTION_EXECUTIVE_SUMMARY_CFLAGS)
AC_SUBST(EVOLUTION_EXECUTIVE_SUMMARY_LIBS)

dnl --- evolution-calendar flags

EVOLUTION_CALENDAR_DEPS="bonobo_conf bonobox bonobox_print gal gdk_pixbuf gnomecanvaspixbuf gnomeui gtkhtml libglade oaf vfs"

EVO_SET_COMPILE_FLAGS(EVOLUTION_CALENDAR, $EVOLUTION_CALENDAR_DEPS)
AC_SUBST(EVOLUTION_CALENDAR_CFLAGS)
AC_SUBST(EVOLUTION_CALENDAR_LIBS)

EVO_SET_COMPILE_FLAGS(EVOLUTION_CALENDAR_CONDUIT, gpilot $EVOLUTION_CALENDAR_DEPS)
AC_SUBST(EVOLUTION_CALENDAR_CONDUIT_CFLAGS)
AC_SUBST(EVOLUTION_CALENDAR_CONDUIT_LIBS)

dnl --- evolution-mail flags

camel_providerdir='$(libdir)/evolution/camel-providers/'$EVOLUTION_MAJOR_VERSION.$EVOLUTION_MINOR_VERSION
AC_SUBST(camel_providerdir)

EVO_SET_COMPILE_FLAGS(EVOLUTION_MAIL, $FULL_GNOME_DEPS, $THREADS_CFLAGS, $THREADS_LIBS)
AC_SUBST(EVOLUTION_MAIL_CFLAGS)
AC_SUBST(EVOLUTION_MAIL_LIBS)

dnl -- wombat flags

EVO_SET_COMPILE_FLAGS(WOMBAT, $FULL_GNOME_DEPS, $LDAP_CFLAGS, $LDAP_LIBS)
AC_SUBST(WOMBAT_CFLAGS)
AC_SUBST(WOMBAT_LIBS)

##################################################
# Check for gtk-doc.
##################################################

AC_ARG_WITH(html-dir, [  --with-html-dir=PATH path to installed docs ])

if test "x$with_html_dir" = "x" ; then
  HTML_DIR='${datadir}/gnome/html'
else
  HTML_DIR=$with_html_dir
fi

AC_SUBST(HTML_DIR)

AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)

gtk_doc_min_version=0.6
if $GTKDOC ; then 
    gtk_doc_version=`gtkdoc-mkdb --version`
    AC_MSG_CHECKING([gtk-doc version ($gtk_doc_version) >= $gtk_doc_min_version])
    if perl <<EOF ; then
      exit (("$gtk_doc_version" =~ /^[[0-9]]+\.[[0-9]]+$/) &&
            ("$gtk_doc_version" >= "$gtk_doc_min_version") ? 0 : 1);
EOF
      AC_MSG_RESULT(yes)
   else
      AC_MSG_RESULT(no)
      GTKDOC=false
   fi
fi

dnl Let people disable the gtk-doc stuff.
AC_ARG_ENABLE(gtk-doc, [  --enable-gtk-doc  Use gtk-doc to build documentation [default=auto]], enable_gtk_doc="$enableval", enable_gtk_doc=auto)

if test x$enable_gtk_doc = xauto ; then
  if test x$GTKDOC = xtrue ; then
    enable_gtk_doc=yes
  else
    enable_gtk_doc=no 
  fi
fi

AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)

dnl ******************
dnl Sub-version number
dnl ******************
AC_ARG_WITH(sub-version, [  --with-sub-version=VERSION Specify a sub-version string])
AC_DEFINE_UNQUOTED(SUB_VERSION, "$with_sub_version")

dnl ********************
dnl KDE applnk directory
dnl ********************
AC_ARG_WITH(kde-applnk-path, [  --with-kde-applnk-path=PATH    Location of KDE applnk files],
            [with_kde_applnk_path="$withval"])
AC_MSG_CHECKING(for the KDE applnk directory)
if test -z "$with_kde_applnk_path"; then
    with_kde_applnk_path="$prefix/share/applnk"
fi
if test -d "$with_kde_applnk_path" ; then
    AC_MSG_RESULT("$with_kde_applnk_path" found)
    AC_DEFINE(HAVE_KDE_APPLNK)
    KDE_APPLNK_DIR="$with_kde_applnk_path"
else
    AC_MSG_RESULT(not found)
    KDE_APPLNK_DIR=""
fi
AM_CONDITIONAL(HAVE_KDE_APPLNK, test x"$KDE_APPLNK_DIR" != x)
AC_SUBST(KDE_APPLNK_DIR)

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

AC_CONFIG_SUBDIRS(libical)

EVOLUTION_DIR=`(cd $srcdir; pwd)`
AC_SUBST(EVOLUTION_DIR)

AC_OUTPUT([
Makefile
addressbook/Makefile
addressbook/backend/Makefile
addressbook/backend/ebook/Makefile
addressbook/backend/idl/Makefile
addressbook/backend/pas/Makefile
addressbook/conduit/Makefile
addressbook/gui/Makefile
addressbook/gui/component/Makefile
addressbook/gui/component/select-names/Makefile
addressbook/gui/contact-editor/Makefile
addressbook/gui/contact-list-editor/Makefile
addressbook/gui/merging/Makefile
addressbook/gui/search/Makefile
addressbook/gui/widgets/Makefile
addressbook/printing/Makefile
art/Makefile
calendar/Makefile
calendar/cal-client/Makefile
calendar/cal-util/Makefile
calendar/conduits/Makefile
calendar/conduits/calendar/Makefile
calendar/conduits/todo/Makefile
calendar/gui/Makefile
calendar/gui/alarm-notify/Makefile
calendar/gui/dialogs/Makefile
calendar/idl/Makefile
calendar/importers/Makefile
calendar/pcs/Makefile
camel/Makefile
camel/providers/Makefile
camel/providers/imap/Makefile
camel/providers/local/Makefile
camel/providers/nntp/Makefile
camel/providers/pop3/Makefile
camel/providers/sendmail/Makefile
camel/providers/smtp/Makefile
camel/tests/Makefile
camel/tests/folder/Makefile
camel/tests/lib/Makefile
camel/tests/message/Makefile
camel/tests/mime-filter/Makefile
camel/tests/misc/Makefile
camel/tests/smime/Makefile
camel/tests/stream/Makefile
composer/Makefile
data/Makefile
default_user/Makefile
default_user/local/Makefile
default_user/local/Calendar/Makefile
default_user/local/Contacts/Makefile
default_user/local/Drafts/Makefile
default_user/local/Inbox/Makefile
default_user/local/Outbox/Makefile
default_user/local/Sent/Makefile
default_user/local/Tasks/Makefile
default_user/local/Trash/Makefile
doc/Makefile
doc/devel/Makefile
doc/devel/calendar/Makefile
doc/devel/calendar/cal-client/Makefile
doc/devel/calendar/cal-util/Makefile
e-util/Makefile
e-util/ename/Makefile
filter/Makefile
help/Makefile
help/C/Makefile
help/no/Makefile
importers/Makefile
intl/Makefile
libibex/Makefile
libversit/Makefile
libwombat/Makefile
macros/Makefile
mail/Makefile
mail/importers/Makefile
my-evolution/Makefile
omf-install/Makefile
po/Makefile.in
shell/Makefile
shell/glade/Makefile
shell/importer/Makefile
sounds/Makefile
tools/Makefile
ui/Makefile
views/Makefile
views/addressbook/Makefile
views/calendar/Makefile
views/mail/Makefile
views/tasks/Makefile
widgets/Makefile
widgets/e-timezone-dialog/Makefile
widgets/menus/Makefile
widgets/misc/Makefile
wombat/Makefile
])

if test "x$with_sub_version" != "x"; then
echo "
    Evolution ($with_sub_version) has been configured as follows: "
else
echo "
    Evolution has been configured as follows: "
fi

echo "
    Mail Directory:   $system_mail_dir, $system_mail_perm
    LDAP support:     $msg_ldap $msg_ldap_linktype"
if test "$msg_nntp" = "yes"; then
echo "\
    NNTP support:     $msg_nntp"
fi
echo "\
    Pilot conduits:   $msg_pilot
    Kerberos 4/5:     $msg_krb4/$msg_krb5
    SSL support:      $msg_ssl
    Dot Locking:      $msg_dot
    File Locking:     $msg_file
    Gtk-doc:      $enable_gtk_doc"

if test x$enable_gtk_doc = xyes; then
echo "
    Programming documentation files will be built automatically.
"
else
echo "
    Programming documentation files will not be built.
    You may want to install the gtk-doc package
    so that you will get the Evolution Developer's Guide.
"
fi