Add very strict compiler warning flags.
[platform/upstream/evolution-data-server.git] / configure.ac
1  Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.52)
3
4 # Evolution-Data-Server version */
5 m4_define([eds_major_version], [2])
6 m4_define([eds_minor_version], [27])
7 m4_define([eds_micro_version], [2])
8
9 m4_define([eds_version],
10           [eds_major_version.eds_minor_version.eds_micro_version])
11
12 AC_INIT(evolution-data-server, [eds_version])
13 AC_CONFIG_SRCDIR(README)
14
15 # Gross hack to enable 'make dist' on automake 1.9+tar 1.14.
16 # The extra brackets are to foil regex-based scans.
17 m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
18
19 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
20
21 AM_CONFIG_HEADER(config.h)
22
23 # Required Package Versions
24 m4_define([glib_minimum_version], [2.16.1])
25 m4_define([gtk_minimum_version], [2.14.0])
26 m4_define([ORBit_minimum_version], [2.9.8])
27 m4_define([libbonobo_minimum_version], [2.20.3])
28 m4_define([gconf_minimum_version], [2.0.0])             # XXX Just a Guess
29 m4_define([libglade_minimum_version], [2.0.0])          # XXX Just a Guess
30 m4_define([libxml_minimum_version], [2.0.0])            # XXX Just a Guess
31 m4_define([libsoup_minimum_version], [2.3.0])
32 m4_define([gnome_keyring_minimum_version], [2.20.1])
33 m4_define([sqlite_minimum_version], [3.5])
34 m4_define([gweather_minimum_version], [2.25.4])
35 m4_define([libical_minimum_version], [0.43])
36
37 dnl *************************************************************************************************
38 dnl Base Version
39 dnl
40 dnl This is for api/versioning tracking for things like bonobo .server files
41 dnl
42 dnl This should always be the major/minor of the stable version or stable version to be
43 dnl *************************************************************************************************
44 BASE_VERSION=2.28
45 API_VERSION=1.2
46 AC_SUBST(BASE_VERSION)
47 AC_SUBST(API_VERSION)
48 AC_DEFINE_UNQUOTED(BASE_VERSION, "$BASE_VERSION", [Base version (Major.Minor)])
49 AC_DEFINE_UNQUOTED(API_VERSION, "$API_VERSION", [Api version (Major.Minor)])
50
51 EDS_MAJOR_VERSION=eds_major_version
52 EDS_MINOR_VERSION=eds_minor_version
53 EDS_MICRO_VERSION=eds_micro_version
54
55 # Libtool versioning
56 LIBEDATASERVER_CURRENT=11
57 LIBEDATASERVER_REVISION=1
58 LIBEDATASERVER_AGE=0
59
60 LIBEDATASERVERUI_CURRENT=9
61 LIBEDATASERVERUI_REVISION=1
62 LIBEDATASERVERUI_AGE=1
63
64 LIBECAL_CURRENT=9
65 LIBECAL_REVISION=2
66 LIBECAL_AGE=2
67
68 LIBEDATACAL_CURRENT=6
69 LIBEDATACAL_REVISION=2
70 LIBEDATACAL_AGE=0
71
72 LIBEDATABOOK_CURRENT=6
73 LIBEDATABOOK_REVISION=1
74 LIBEDATABOOK_AGE=4
75
76 LIBEBOOK_CURRENT=12
77 LIBEBOOK_REVISION=1
78 LIBEBOOK_AGE=3
79
80 LIBEGROUPWISE_CURRENT=13
81 LIBEGROUPWISE_REVISION=1
82 LIBEGROUPWISE_AGE=0
83
84 LIBCAMEL_CURRENT=14
85 LIBCAMEL_REVISION=1
86 LIBCAMEL_AGE=0
87
88 LIBEXCHANGE_STORAGE_CURRENT=3
89 LIBEXCHANGE_STORAGE_REVISION=0
90 LIBEXCHANGE_STORAGE_AGE=0
91
92 LIBGDATA_CURRENT=1
93 LIBGDATA_REVISION=0
94 LIBGDATA_AGE=0
95
96 LIBGDATA_GOOGLE_CURRENT=1
97 LIBGDATA_GOOGLE_REVISION=0
98 LIBGDATA_GOOGLE_AGE=0
99
100 LIBEBACKEND_CURRENT=0
101 LIBEBACKEND_REVISION=1
102 LIBEBACKEND_AGE=0
103
104 AC_SUBST(EDS_MAJOR_VERSION)
105 AC_SUBST(EDS_MINOR_VERSION)
106 AC_SUBST(EDS_MICRO_VERSION)
107 AC_SUBST(LIBEDATASERVER_CURRENT)
108 AC_SUBST(LIBEDATASERVER_REVISION)
109 AC_SUBST(LIBEDATASERVER_AGE)
110 AC_SUBST(LIBEDATASERVERUI_CURRENT)
111 AC_SUBST(LIBEDATASERVERUI_REVISION)
112 AC_SUBST(LIBEDATASERVERUI_AGE)
113 AC_SUBST(LIBECAL_CURRENT)
114 AC_SUBST(LIBECAL_REVISION)
115 AC_SUBST(LIBECAL_AGE)
116 AC_SUBST(LIBEDATACAL_CURRENT)
117 AC_SUBST(LIBEDATACAL_REVISION)
118 AC_SUBST(LIBEDATACAL_AGE)
119 AC_SUBST(LIBEBOOK_CURRENT)
120 AC_SUBST(LIBEBOOK_REVISION)
121 AC_SUBST(LIBEBOOK_AGE)
122 AC_SUBST(LIBEDATABOOK_CURRENT)
123 AC_SUBST(LIBEDATABOOK_REVISION)
124 AC_SUBST(LIBEDATABOOK_AGE)
125 AC_SUBST(LIBEGROUPWISE_CURRENT)
126 AC_SUBST(LIBEGROUPWISE_REVISION)
127 AC_SUBST(LIBEGROUPWISE_AGE)
128 AC_SUBST(LIBCAMEL_CURRENT)
129 AC_SUBST(LIBCAMEL_REVISION)
130 AC_SUBST(LIBCAMEL_AGE)
131 AC_SUBST(LIBEXCHANGE_STORAGE_CURRENT)
132 AC_SUBST(LIBEXCHANGE_STORAGE_REVISION)
133 AC_SUBST(LIBEXCHANGE_STORAGE_AGE)
134 AC_SUBST(LIBGDATA_CURRENT)
135 AC_SUBST(LIBGDATA_REVISION)
136 AC_SUBST(LIBGDATA_AGE)
137 AC_SUBST(LIBGDATA_GOOGLE_CURRENT)
138 AC_SUBST(LIBGDATA_GOOGLE_REVISION)
139 AC_SUBST(LIBGDATA_GOOGLE_AGE)
140 AC_SUBST(LIBEBACKEND_CURRENT)
141 AC_SUBST(LIBEBACKEND_REVISION)
142 AC_SUBST(LIBEBACKEND_AGE)
143
144 dnl Put the ACLOCAL flags in the Makefile
145 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
146
147 # Compiler Warning Flags
148
149 AS_COMPILER_FLAGS(WARNING_FLAGS,
150         "-DG_DISABLE_DEPRECATED
151         -DPANGO_DISABLE_DEPRECATED
152         -DGDK_DISABLE_DEPRECATED
153         -DGDK_PIXBUF_DISABLE_DEPRECATED
154         -Wall -Wextra
155         -Wno-missing-field-initializers
156         -Wno-sign-compare
157         -Wno-unused-parameter
158         -Wdeclaration-after-statement
159         -Werror-implicit-function-declaration
160         -Wformat-nonliteral -Wformat-security -Winit-self
161         -Wmissing-declarations -Wmissing-include-dirs
162         -Wmissing-noreturn -Wnested-externs -Wpointer-arith
163         -Wredundant-decls -Wundef -Wwrite-strings")
164 AC_SUBST(WARNING_FLAGS)
165
166 # Other useful compiler warnings for test builds only.
167 # These may produce warnings we have no control over.
168 #
169 #»······-Wmissing-format-attribute
170 #»······-Wshadow
171
172 CFLAGS="$CFLAGS $WARNING_FLAGS"
173
174 dnl Initialize maintainer mode
175 AM_MAINTAINER_MODE
176
177
178 AC_ISC_POSIX
179 AC_PROG_CC
180 AC_PROG_CPP
181 AC_C_INLINE
182 AM_PROG_LEX
183 AC_PROG_YACC
184 case $YACC in
185 *yacc*)
186         AC_MSG_ERROR(You need bison to build evolution-data-server)
187         ;;
188 esac
189 AC_STDC_HEADERS
190 AC_PROG_INSTALL
191 AC_PROG_LN_S
192 AC_PROG_MAKE_SET
193
194 dnl  Test whether jw is installed
195 AC_PATH_PROG(JW,jw,no)
196 if test x$JW = xno; then
197   HAVE_JW="no"
198 else
199   HAVE_JW="yes"
200 fi
201 AM_CONDITIONAL(HAVE_JW, test "x$HAVE_JW" = "xyes")
202 AC_SUBST(HAVE_JW)
203
204 dnl I18N stuff
205 IT_PROG_INTLTOOL([0.35.5])
206
207 AM_GLIB_GNU_GETTEXT
208
209 GETTEXT_PACKAGE=evolution-data-server-$BASE_VERSION
210 AC_SUBST(GETTEXT_PACKAGE)
211 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Package name for gettext])
212
213 localedir='$(prefix)/$(DATADIRNAME)/locale'
214 AC_SUBST(localedir)
215
216 dnl Initialize libtool
217 AM_DISABLE_STATIC
218 AC_LIBTOOL_WIN32_DLL
219 AM_PROG_LIBTOOL
220 DOLT
221
222 PKG_PROG_PKG_CONFIG
223
224 dnl ******************************
225 dnl Check for Win32
226 dnl ******************************
227
228 AC_MSG_CHECKING([for Win32])
229 case "$host" in
230 *-mingw*)
231     os_win32=yes
232     NO_UNDEFINED='-no-undefined'
233     SOCKET_LIBS='-lws2_32 -ldnsapi'
234     DL_LIB=''
235     SOFTOKN3_LIB=''
236     LIBEXECDIR_IN_SERVER_FILE='../../../libexec'
237     AC_CACHE_VAL(have_addrinfo, [have_addrinfo=yes])
238     AC_DEFINE(_WIN32_WINNT, 0x501, [To get getaddrinfo etc declarations])
239     ;;
240 *)  os_win32=no
241     NO_UNDEFINED=''
242     SOCKET_LIBS=''
243     DL_LIB='-ldl'
244     SOFTOKN3_LIB='-lsoftokn3'
245     LIBEXECDIR_IN_SERVER_FILE="$libexecdir"
246     ;;
247 esac
248 AC_MSG_RESULT([$os_win32])
249 AM_CONDITIONAL(OS_WIN32, [test $os_win32 = yes])
250 AC_SUBST(NO_UNDEFINED)
251 AC_SUBST(SOCKET_LIBS)
252 AC_SUBST(LIBEXECDIR_IN_SERVER_FILE)
253
254 AC_CHECK_HEADERS(pthread.h semaphore.h sys/wait.h)
255 AC_CHECK_FUNCS(fsync strptime strtok_r)
256
257 dnl alloca()
258 AC_CHECK_HEADERS(alloca.h)
259
260 # Check for base dependencies early.
261 PKG_CHECK_MODULES(GNOME_PLATFORM,
262         [glib-2.0 >= glib_minimum_version
263          gtk+-2.0 >= gtk_minimum_version
264          ORBit-2.0 >= ORBit_minimum_version
265          libbonobo-2.0 >= libbonobo_minimum_version
266          gconf-2.0 >= gconf_minimum_version
267          libglade-2.0 >= libglade_minimum_version
268          libxml-2.0 >= libxml_minimum_version
269          libsoup-2.4 >= libsoup_minimum_version])
270
271 LIBICAL_REQUIRED=libical_minimum_version
272 AC_SUBST(LIBICAL_REQUIRED)
273
274 dnl **************************************************
275 dnl * regex checking
276 dnl **************************************************
277 AC_CHECK_FUNCS(regexec,,[AC_CHECK_LIB(regex,regexec,
278                                       [REGEX_LIBS=-lregex
279                                        AC_DEFINE(HAVE_REGEXEC,1,[Define to 1 if you have the regexec function.])],
280                                       [AC_MSG_ERROR([No regex library found])])])
281 AC_SUBST(REGEX_LIBS)
282
283 dnl **************************************************
284 dnl * libdb checking
285 dnl **************************************************
286
287 AC_ARG_WITH(libdb, 
288   AC_HELP_STRING( [--with-libdb],
289                   [Prefix where libdb is installed]), 
290   dynamic_libdb=yes, dynamic_libdb=no)
291
292 if test "x${dynamic_libdb}" = "xyes"; then
293         DB_CFLAGS="-I$withval/include"
294         DB_LIBS="-L$withval/lib -ldb"
295
296         AC_MSG_CHECKING([Berkeley DB])
297         save_cflags=$CFLAGS; CFLAGS=$DB_CFLAGS
298         save_libs=$LIBS; LIBS="$DB_LIBS"
299         AC_LINK_IFELSE(
300                 [AC_LANG_PROGRAM([[#include <db.h>]],
301                                  [db_create(NULL, NULL, 0)])],
302                 AC_MSG_RESULT(yes),
303                 AC_MSG_ERROR(cannot find libdb))
304         CFLAGS=$save_cflags
305         LIBS=$save_libs
306
307         msg_libdb="dynamically linked"
308 else
309         DB_CFLAGS="-I\$(top_builddir)/libdb/dist"
310         DB_LIBS="\$(top_builddir)/libdb/dist/libdb-4.1.la"
311         if test $os_win32 = yes; then
312                 # Don't pointlessly auto-export the global symbols
313                 # from the static libdb
314                 DB_LIBS="$DB_LIBS -Wl,--exclude-libs=libdb-4.1.a"
315         fi
316         AC_MSG_NOTICE(Using local libdb)
317         msg_libdb="statically linked to local copy"
318 fi
319 AM_CONDITIONAL(WITH_LIBDB, test "x$dynamic_libdb" != "xno")
320 AC_SUBST(DB_CFLAGS)
321 AC_SUBST(DB_LIBS)
322
323
324 dnl ******************************
325 dnl iconv checking
326 dnl ******************************
327 have_iconv=no
328 AC_ARG_WITH(libiconv, 
329   AC_HELP_STRING( [--with-libiconv],
330                   [Prefix where libiconv is installed]))
331 if test -d $withval; then
332     ICONV_CFLAGS="-I$withval/include"
333     ICONV_LIBS="-L$withval/lib"
334 fi
335
336 save_CFLAGS="$CFLAGS"
337 save_LIBS="$LIBS"
338 CFLAGS="$CFLAGS $ICONV_CFLAGS"
339 LIBS="$LIBS $ICONV_LIBS -liconv"
340 AC_CACHE_CHECK(for iconv in -liconv, ac_cv_libiconv, AC_TRY_LINK([
341 #include <iconv.h>
342 #include <stdlib.h>],[
343
344 int main (int argc, char **argv)
345 {
346         iconv_t cd;
347         cd = iconv_open ("UTF-8", "ISO-8859-1");
348         exit (0);
349 }
350 ], ac_cv_libiconv=yes, ac_cv_libiconv=no))
351 if test $ac_cv_libiconv = yes; then
352         ICONV_LIBS="$ICONV_LIBS -liconv"
353         if test $os_win32 = yes; then
354                 # Don't pointlessly auto-export the global symbols
355                 # from a potentially static libiconv.a
356                 ICONV_LIBS="$ICONV_LIBS -Wl,--exclude-libs=libiconv.a"
357         fi
358         have_iconv=yes
359 else
360         CFLAGS="$save_CFLAGS"
361         LIBS="$save_LIBS"
362         AC_CHECK_FUNC(iconv, have_iconv=yes, have_iconv=no)
363 fi
364
365 if test $have_iconv = yes; then
366         if test $ac_cv_libiconv = no; then
367                 AC_CHECK_FUNCS(gnu_get_libc_version)
368         fi
369         AC_CACHE_CHECK([if iconv() handles UTF-8], ac_cv_libiconv_utf8, AC_TRY_RUN([
370 #include <iconv.h>
371 #include <stdlib.h>
372 #include <string.h>
373 #ifdef HAVE_GNU_GET_LIBC_VERSION
374 #include <gnu/libc-version.h>
375 #endif
376
377 int main (int argc, char **argv)
378 {
379         char *from = "Some Text \xA4";
380         char *utf8 = "Some Text \xC2\xA4";
381         char *transbuf = malloc (20), *trans = transbuf;
382         iconv_t cd;
383         size_t from_len = strlen (from), utf8_len = 20;
384         size_t utf8_real_len = strlen (utf8);
385
386 #ifdef HAVE_GNU_GET_LIBC_VERSION
387         /* glibc 2.1.2's iconv is broken in hard to test ways. */
388         if (!strcmp (gnu_get_libc_version (), "2.1.2"))
389                 exit (1);
390 #endif
391
392         cd = iconv_open ("UTF-8", "ISO-8859-1");
393         if (cd == (iconv_t) -1)
394                 exit (1);
395         if (iconv (cd, &from, &from_len, &trans, &utf8_len) == -1 || from_len != 0)
396                 exit (1);
397         if (memcmp (utf8, transbuf, utf8_real_len) != 0)
398                 exit (1);
399
400         exit (0);
401 }], ac_cv_libiconv_utf8=yes, [ac_cv_libiconv_utf8=no; have_iconv=no], ac_cv_libiconv_utf8=HOPEFULLY))
402 fi
403
404 if test "$have_iconv" = no; then
405         AC_MSG_ERROR([You need to install a working iconv implementation, such as ftp://ftp.gnu.org/pub/gnu/libiconv])
406 fi
407 AC_SUBST(ICONV_CFLAGS)
408 AC_SUBST(ICONV_LIBS)
409
410 CFLAGS="$CFLAGS -I$srcdir"
411
412 AC_MSG_CHECKING(preferred charset formats for system iconv)
413 AC_TRY_RUN([
414 #define CONFIGURE_IN
415 #include "iconv-detect.c"
416 ],[
417         AC_MSG_RESULT(found)
418 ],[
419         AC_MSG_RESULT(not found)
420         AC_WARN([
421         *** The iconv-detect program was unable to determine the
422         *** preferred charset formats recognized by your system
423         *** iconv library. It is suggested that you install a
424         *** working iconv library such as the one found at
425         *** ftp://ftp.gnu.org/pub/gnu/libiconv
426 ])
427 ],[
428   if test x$os_win32 = xyes; then
429     AC_MSG_RESULT(using cached win32 result)
430     echo "/* This is an auto-generated header, DO NOT EDIT! */" > iconv-detect.h
431     echo "" >>iconv-detect.h
432     echo "#define ICONV_ISO_D_FORMAT \"iso-%d-%d\"" >>iconv-detect.h
433     echo "#define ICONV_ISO_S_FORMAT \"iso-%d-%s\"" >>iconv-detect.h
434     echo "#define ICONV_10646 \"UCS-4BE\"" >>iconv-detect.h
435   else
436         AC_MSG_RESULT(unknown)
437         AC_WARN([
438         *** The iconv-detect program was unable to determine the
439         *** preferred charset formats recognized by your system
440         *** iconv library. You are crosscompiling and supposed
441         *** to know what you are doing. (:-)
442     ])
443   fi
444 ])
445
446 CFLAGS="$save_CFLAGS"
447 LIBS="$save_LIBS"
448
449 dnl Check for nl_langinfo and CODESET
450 AC_MSG_CHECKING([for nl_langinfo (CODESET)])
451 AC_TRY_COMPILE([#include <langinfo.h>],
452         [char *codeset = nl_langinfo (CODESET);],
453         [ac_cv_langinfo_codeset=yes],
454         [ac_cv_langinfo_codeset=no])
455 if test x$ac_cv_langinfo_codeset = xyes; then
456         AC_DEFINE(HAVE_CODESET, 1, [Have nl_langinfo (CODESET)])
457 fi
458 AC_MSG_RESULT($ac_cv_langinfo_codeset)
459
460 dnl Check to see if strftime supports the use of %l and %k
461
462 AC_MSG_CHECKING(for %l and %k support in strftime)
463 AC_TRY_RUN([
464 #include <stdlib.h>
465 #include <string.h>
466 #include <time.h>
467
468 int main(int argc, char **argv)
469 {
470         char buf[10];
471         time_t rawtime;
472         struct tm *timeinfo;
473
474         time(&rawtime);
475         timeinfo=localtime(&rawtime);
476         buf[0] = '\0';
477         strftime(buf, 10, "%lx%k", timeinfo);
478
479         if (buf[0] == '\0' || buf[0] == 'x' || strstr(buf, "l") || strstr(buf, "k"))
480                 exit(1);
481         else
482                 exit(0);
483 }],[
484 AC_DEFINE(HAVE_LKSTRFTIME, 1, [strftime supports use of l and k])
485 ac_cv_lkstrftime=yes
486 ],ac_cv_lkstrftime=no,ac_cv_lkstrftime=no,[
487 AC_DEFINE(HAVE_LKSTRFTIME, 1, [strftime supports use of l and k])
488 ac_cv_lkstrftime=yes
489 ])
490 AC_MSG_RESULT($ac_cv_lkstrftime)
491
492 dnl ********************************************************************************
493 dnl security extension support (SSL and S/MIME)
494 dnl
495 dnl The following voodoo does detection of mozilla libraries (nspr and nss) 
496 dnl needed by Camel (SSL and S/MIME).
497 dnl
498 dnl The Evolution security extensions are only built if these libraries are found
499 dnl ********************************************************************************
500 msg_ssl="no"
501 msg_smime="no"
502
503 dnl these 2 enable's are inverses of each other
504 AC_ARG_ENABLE(nss,
505   AC_HELP_STRING( [--enable-nss=@<:@yes/no/static@:>@],
506                   [Attempt to use Mozilla libnss for SSL support.]),
507   enable_nss="$enableval", enable_nss="yes")
508
509 AC_ARG_ENABLE(smime, 
510   AC_HELP_STRING( [--enable-smime=@<:@yes/no@:>@],
511                   [Attempt to use Mozilla libnss for SMIME support (this requires --enable-nss)]),
512   enable_smime="$enableval", enable_smime="yes")
513
514 AC_ARG_ENABLE(gnome-keyring, 
515   AC_HELP_STRING( [--enable-gnome-keyring=@<:@yes/no@:>@],
516                   [Attempt to use Gnome Keyring for storing passwords]),
517   enable_gnome_keyring="$enableval", enable_gnome_keyring="no")
518
519 AC_ARG_WITH(nspr-includes, 
520   AC_HELP_STRING( [--with-nspr-includes=PREFIX],
521                   [Location of Mozilla nspr4 includes.]),
522   with_nspr_includes="$withval")
523
524 AC_ARG_WITH(nspr-libs, 
525   AC_HELP_STRING( [--with-nspr-libs=PREFIX],
526                   [Location of Mozilla nspr4 libs.]),
527   with_nspr_libs="$withval")
528
529 AC_ARG_WITH(nss-includes, 
530   AC_HELP_STRING( [--with-nss-includes=PREFIX],
531                   [Location of Mozilla nss3 includes.]),
532   with_nss_includes="$withval")
533
534 AC_ARG_WITH(nss-libs, 
535   AC_HELP_STRING( [--with-nss-libs=PREFIX],
536                   [Location of Mozilla nss3 libs.]),
537   with_nss_libs="$withval")
538
539 if test "x${enable_gnome_keyring}" = "xyes"; then
540         PKG_CHECK_MODULES(GNOME_KEYRING, gnome-keyring-1 >= gnome_keyring_minimum_version, with_gnome_keyring="yes", with_gnome_keyring="no");
541         if test "x$with_gnome_keyring" = "xyes"; then
542                 AC_DEFINE(WITH_GNOME_KEYRING, 1, [Gnome Keyring available])     
543                 GNOME_KEYRING_REQUIREMENT="gnome-keyring-1"
544         else
545                 GNOME_KEYRING_REQUIREMENT=""
546         fi
547 fi
548
549 if test "x${enable_nss}" = "xyes" || test "x${enable_nss}" = "xstatic"; then
550         if test -n "${with_nspr_includes}" || test -n "${with_nspr_libs}" || test -n "${with_nss_includes}" || test -n "${with_nss_libs}" || test "x${enable_nss}" = "xstatic"; then
551                 check_manually="yes"
552         else
553                 check_manually="no"
554         fi
555         
556         if test "x${check_manually}" = "xno"; then
557                 AC_MSG_CHECKING(Mozilla NSPR pkg-config module name)
558                 mozilla_nspr_pcs="nspr mozilla-nspr firefox-nspr xulrunner-nspr seamonkey-nspr"
559                 for pc in $mozilla_nspr_pcs; do
560                         if $PKG_CONFIG --exists $pc; then
561                                 AC_MSG_RESULT($pc)
562                                 mozilla_nspr=$pc
563                                 break;
564                         fi
565                 done
566                 
567                 AC_MSG_CHECKING(Mozilla NSS pkg-config module name)
568                 mozilla_nss_pcs="nss mozilla-nss firefox-nss xulrunner-nss seamonkey-nss"
569                 for pc in $mozilla_nss_pcs; do
570                         if $PKG_CONFIG --exists $pc; then
571                                 AC_MSG_RESULT($pc)
572                                 mozilla_nss=$pc
573                                 break;
574                         fi
575                 done
576                 
577                 if test -n "$mozilla_nspr" -a -n "$mozilla_nss"; then
578                         msg_ssl="yes (Mozilla NSS)"
579                         if test "x$enable_smime" = "xyes"; then
580                                 AC_DEFINE(ENABLE_SMIME,1,[Define if SMIME should be enabled])
581                                 msg_smime="yes (Mozilla NSS)"
582                         fi
583                         AC_DEFINE(HAVE_NSS,1,[Define if you have NSS])
584                         AC_DEFINE(HAVE_SSL,1,[Define if you have a supported SSL library])
585                         MANUAL_NSPR_CFLAGS=""
586                         MANUAL_NSPR_LIBS=""
587                         MANUAL_NSS_CFLAGS=""
588                         MANUAL_NSS_LIBS=""
589                 else
590                         check_manually="yes"
591                         mozilla_nspr=""
592                         mozilla_nss=""
593                 fi
594         fi
595         
596         if test "x${check_manually}" = "xyes"; then
597                 have_nspr_includes="no"
598                 if test "x${with_nspr_includes}" != "xno"; then
599                         CPPFLAGS_save="$CPPFLAGS"
600                         
601                         AC_MSG_CHECKING(for Mozilla nspr4 includes in $with_nspr_includes)
602                         AC_MSG_RESULT("")
603                         
604                         CPPFLAGS="$CPPFLAGS -I$with_nspr_includes"
605                         AC_CHECK_HEADERS(nspr.h prio.h, [ moz_nspr_includes="yes" ])
606                         CPPFLAGS="$CPPFLAGS_save"
607                         
608                         if test "x{$moz_nspr_includes}" != "xno" -a "x{$moz_nspr_includes}" != "x" ; then
609                                 have_nspr_includes="yes"
610                                 MANUAL_NSPR_CFLAGS="-I$with_nspr_includes"
611                         fi
612                 else
613                         AC_MSG_CHECKING(for Mozilla nspr4 includes)
614                         AC_MSG_RESULT(no)
615                 fi
616                 
617                 have_nspr_libs="no"
618                 if test "x${with_nspr_libs}" != "xno" -a "x${have_nspr_includes}" != "xno"; then
619                         CFLAGS_save="$CFLAGS"
620                         LDFLAGS_save="$LDFLAGS"
621                         
622                         if test "$enable_nss" = "static"; then
623                                 if test -z "${with_nspr_libs}"; then
624                                         AC_MSG_ERROR([Static linkage requested, but path to nspr libraries not set.]
625 [Please specify the path to libnspr4.a]
626 [Example: --with-nspr-libs=/usr/lib])
627                                 else
628                                         nsprlibs="$DL_LIB $with_nspr_libs/libplc4.a $with_nspr_libs/libplds4.a $with_nspr_libs/libnspr4.a $PTHREAD_LIB"
629                                 fi
630                         else
631                                 nsprlibs="$DL_LIB -lplc4 -lplds4 -lnspr4 $PTHREAD_LIB"
632                         fi
633                         
634                         AC_CACHE_CHECK([for Mozilla nspr libraries], moz_nspr_libs,
635                         [
636                                 LIBS_save="$LIBS"
637                                 CFLAGS="$CFLAGS $MANUAL_NSPR_CFLAGS"
638                                 
639                                 if test "x${with_nspr_libs}" != "x"; then
640                                         LIBS="$nsprlibs"
641                                         LDFLAGS="$LDFLAGS -L$with_nspr_libs"
642                                 else
643                                         LIBS="$nsprlibs"
644                                         LDFLAGS="$LDFLAGS"
645                                 fi
646                                 
647                                 AC_TRY_LINK_FUNC(PR_Init, moz_nspr_libs="yes", moz_nspr_libs="no")
648                                 CFLAGS="$CFLAGS_save"
649                                 LDFLAGS="$LDFLAGS_save"
650                                 LIBS="$LIBS_save"
651                         ])
652                         if test "x$moz_nspr_libs" != "xno"; then
653                                 have_nspr_libs="yes"
654                                 MANUAL_NSPR_LIBS="-L$with_nspr_libs $nsprlibs"
655                         else
656                                 MANUAL_NSPR_CLFAGS=""
657                         fi
658                 else
659                         AC_MSG_CHECKING(for Mozilla nspr4 libraries)
660                         AC_MSG_RESULT(no)
661                 fi
662                 
663                 if test "x${with_nss_includes}" != "xno" -a "x${have_nspr_libs}" != "xno"; then
664                         CPPFLAGS_save="$CPPFLAGS"
665                         
666                         AC_MSG_CHECKING(for Mozilla nss3 includes in $with_nss_includes)
667                         AC_MSG_RESULT("")
668                         
669                         if test "x${with_nspr_includes}" != "x"; then
670                                 CPPFLAGS="$CPPFLAGS -I$with_nspr_includes -I$with_nss_includes"
671                         else
672                                 CPPFLAGS="$CPPFLAGS -I$with_nss_includes"
673                         fi
674                         
675                         AC_CHECK_HEADERS(nss.h ssl.h smime.h,
676                                 [ have_nss_includes="yes" ], 
677                                 [ have_nss_includes="no" ])
678                         
679                         CPPFLAGS="$CPPFLAGS_save"
680                         
681                         if test "x${have_nss_includes}" = "xyes"; then  
682                                 have_nss_includes="yes"
683                                 MANUAL_NSS_CFLAGS="-I$with_nss_includes"
684                         else
685                                 MANUAL_NSPR_CFLAGS=""
686                                 MANUAL_NSPR_LIBS=""
687                         fi
688                 else
689                         AC_MSG_CHECKING(for Mozilla nss3 includes)
690                         AC_MSG_RESULT(no)
691                 fi
692                 
693                 if test "x${with_nss_libs}" != "xno" -a "x${have_nss_includes}" != "xno"; then
694                         LDFLAGS_save="$LDFLAGS"
695                         
696                         if test "$enable_nss" = "static"; then
697                                 if test -z "${with_nss_libs}"; then
698                                         AC_MSG_ERROR([Static linkage requested, but path to nss libraries not set.]
699 [Please specify the path to libnss3.a]
700 [Example: --with-nspr-libs=/usr/lib/mozilla])
701                                 else
702                                         nsslibs="-ldb1 $with_nss_libs/libnssckfw.a $with_nss_libs/libasn1.a $with_nss_libs/libcrmf.a $with_nss_libs/libswfci.a $with_nss_libs/libjar.a $with_nss_libs/libpkcs12.a $with_nss_libs/libpkcs7.a $with_nss_libs/libpki1.a $with_nss_libs/libsmime.a $with_nss_libs/libssl.a $with_nss_libs/libnss.a $with_nss_libs/libpk11wrap.a $with_nss_libs/libsoftokn.a $with_nss_libs/libfreebl.a $with_nss_libs/libnsspki.a $with_nss_libs/libnssdev.a $with_nss_libs/libcryptohi.a $with_nss_libs/libcerthi.a $with_nss_libs/libcertdb.a $with_nss_libs/libsecutil.a $with_nss_libs/libnssb.a"
703                                         case "$host" in
704                                                 *solaris*)
705                                                 nsslibs="$nsslibs $with_nss_libs/libfreebl.a"
706                                         ;;
707                                         esac
708                                 fi
709                         else
710                                 nsslibs="-lssl3 -lsmime3 -lnss3 $SOFTOKN3_LIB"
711                         fi      
712                         
713                         AC_CACHE_CHECK([for Mozilla nss libraries], moz_nss_libs,
714                         [
715                                 LIBS_save="$LIBS"
716                                 LDFLAGS="$LDFLAGS -L$with_nspr_libs $nsprlibs -L$with_nss_libs $nsslibs"
717                                 LIBS="$nsslibs $nsprlibs"
718                                 AC_TRY_LINK_FUNC(NSS_Init, moz_nss_libs="yes", moz_nss_libs="no")
719                                 if test "$moz_nss_libs" = no; then
720                                         nsslibs="-lssl3 -lsmime3 -lnss3 $SOFTOKN3_LIB"
721                                         LDFLAGS="$LDFLAGS -L$with_nspr_libs $nsprlibs -L$with_nss_libs $nsslibs"
722                                         AC_TRY_LINK_FUNC(NSS_Init, moz_nss_libs="yes", moz_nss_libs="no")       
723                                 fi
724                                 LDFLAGS="$LDFLAGS_save"
725                                 LIBS="$LIBS_save"
726                         ])
727                         if test "$moz_nss_libs" != no; then
728                                 AC_DEFINE(HAVE_NSS)
729                                 AC_DEFINE(HAVE_SSL)
730                                 if test "$enable_nss" = "static"; then
731                                         msg_ssl="yes (Mozilla NSS:static)"
732                                 else
733                                         msg_ssl="yes (Mozilla NSS)"
734                                 fi # static_nss
735                                 if test "$enable_smime" = "yes"; then
736                                         AC_DEFINE(ENABLE_SMIME,1,[Define if SMIME should be enabled])
737                                         msg_smime="yes (Mozilla NSS)"
738                                 fi
739                                 MANUAL_NSS_LIBS="-L$with_nss_libs $nsslibs"
740                         else
741                                 MANUAL_NSS_CFLAGS=""
742                                 MANUAL_NSPR_CFLAGS=""
743                                 MANUAL_NSPR_LIBS=""
744                         fi
745                 else
746                         AC_MSG_CHECKING(for Mozilla nss libraries)
747                         AC_MSG_RESULT(no)
748                 fi
749                 
750                 MANUAL_NSS_CFLAGS="$MANUAL_NSPR_CFLAGS $MANUAL_NSS_CFLAGS"
751                 MANUAL_NSS_LIBS="$MANUAL_NSPR_LIBS $MANUAL_NSS_LIBS"
752         fi
753 fi
754
755 AM_CONDITIONAL(ENABLE_SMIME, test "x$msg_smime" != "xno")
756
757 AC_SUBST(MANUAL_NSPR_CFLAGS)
758 AC_SUBST(MANUAL_NSPR_LIBS)
759 AC_SUBST(MANUAL_NSS_CFLAGS)
760 AC_SUBST(MANUAL_NSS_LIBS)
761
762 if test $os_win32 != yes; then
763
764 dnl check for socklen_t (in Unix98)
765 AC_MSG_CHECKING(for socklen_t)
766 AC_TRY_COMPILE([#include <sys/types.h>
767 #include <sys/socket.h>
768 socklen_t x;
769 ],[],[AC_MSG_RESULT(yes)],[
770 AC_TRY_COMPILE([#include <sys/types.h>
771 #include <sys/socket.h>
772 int accept (int, struct sockaddr *, size_t *);
773 ],[],[
774 AC_MSG_RESULT(size_t)
775 AC_DEFINE(socklen_t,size_t,[Define to appropriate type if socklen_t is not defined])], [
776 AC_MSG_RESULT(int)
777 AC_DEFINE(socklen_t,int)])])
778
779 fi
780
781 dnl
782 dnl system mail stuff
783 dnl
784 AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, /usr/sbin:/usr/lib)
785 AC_DEFINE_UNQUOTED(SENDMAIL_PATH, "$SENDMAIL", [Path to a sendmail binary, or equivalent])
786
787 AC_MSG_CHECKING(system mail directory)
788 if test -d /var/mail -a '!' -h /var/mail ; then
789         system_mail_dir=/var/mail
790 else
791         system_mail_dir=/var/spool/mail
792 fi
793 AC_DEFINE_UNQUOTED(SYSTEM_MAIL_DIR, "$system_mail_dir", [Directory local mail is delivered to])
794
795 case `ls -ld $system_mail_dir 2>&1 | awk '{print $1;}'` in
796 d??????rw?)
797         CAMEL_LOCK_HELPER_USER=""
798         CAMEL_LOCK_HELPER_GROUP=""
799         system_mail_perm="world writable"
800         ;;
801
802 d???rw????)
803         CAMEL_LOCK_HELPER_USER=""
804         CAMEL_LOCK_HELPER_GROUP=`ls -ld $system_mail_dir 2>&1 | awk '{print $4;}'`
805         system_mail_perm="writable by group $CAMEL_LOCK_HELPER_GROUP"
806         ;;
807
808 drw???????)
809         CAMEL_LOCK_HELPER_USER=`ls -ld $system_mail_dir 2>&1 | awk '{print $3;}'`
810         CAMEL_LOCK_HELPER_GROUP=""
811         system_mail_perm="writable by user $CAMEL_LOCK_HELPER_USER"
812         ;;
813
814 *)
815         CAMEL_LOCK_HELPER_USER=""
816         CAMEL_LOCK_HELPER_GROUP=""
817         system_mail_perm="???"
818         ;;
819 esac
820
821 AC_MSG_RESULT([$system_mail_dir, $system_mail_perm])
822 AC_SUBST(CAMEL_LOCK_HELPER_USER)
823 AC_SUBST(CAMEL_LOCK_HELPER_GROUP)
824
825
826 dnl ***************
827 dnl Timezone checks
828 dnl ***************
829 AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
830         AC_TRY_COMPILE([
831                 #include <time.h>
832                 ], [
833                 struct tm tm;
834                 tm.tm_gmtoff = 1;
835                 ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
836 if test $ac_cv_struct_tm_gmtoff = yes; then
837         AC_DEFINE(HAVE_TM_GMTOFF, 1, [Define if struct tm has a tm_gmtoff member])
838 else
839         AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
840                 AC_TRY_COMPILE([
841                         #include <time.h>
842                 ], [
843                         timezone = 1;
844                 ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
845         if test $ac_cv_var_timezone = yes; then
846                 AC_DEFINE(HAVE_TIMEZONE, 1, [Define if libc defines a timezone variable])
847                 AC_CACHE_CHECK(for altzone variable, ac_cv_var_altzone,
848                         AC_TRY_COMPILE([
849                                 #include <time.h>
850                         ], [
851                                 altzone = 1;
852                         ], ac_cv_var_altzone=yes, ac_cv_var_altzone=no))
853                 if test $ac_cv_var_altzone = yes; then
854                         AC_DEFINE(HAVE_ALTZONE, 1, [Define if libc defines an altzone variable])
855                 fi
856         else
857                 AC_ERROR(unable to find a way to determine timezone)
858         fi
859 fi
860
861
862 dnl **************************************************
863 dnl ctime_r prototype
864 dnl **************************************************
865
866 AC_CACHE_CHECK([if ctime_r wants three arguments], ac_cv_ctime_r_three_args,
867 [
868         AC_TRY_COMPILE([
869                 #include <time.h>
870         ],[
871                 char *buf;
872                 time_t date;
873                 ctime_r (&date, buf, 100);
874         ],[
875                 ac_cv_ctime_r_three_args=yes
876         ],[
877                 ac_cv_ctime_r_three_args=no
878         ])
879 ])
880         
881 if test x"$ac_cv_ctime_r_three_args" = xyes ; then
882         AC_DEFINE(CTIME_R_THREE_ARGS, 1, [Solaris-style ctime_r])
883 fi
884
885 dnl **************************************************
886 dnl gethostbyname_r prototype
887 dnl **************************************************
888
889 AC_CHECK_FUNCS(gethostbyname_r,[
890 AC_CACHE_CHECK([if gethostbyname_r wants five arguments], ac_cv_gethostbyname_r_five_args,
891 [
892         AC_TRY_COMPILE([
893                 #include "confdefs.h"
894                 #include <sys/types.h>
895                 #include <sys/socket.h>
896                 #include <netinet/in.h>
897                 #include <netdb.h>
898
899                 #define BUFSIZE (sizeof(struct hostent)+10)
900         ],[
901                 struct hostent hent;
902                 char buffer[BUFSIZE];
903                 int bufsize=BUFSIZE;
904                 int h_errno;
905
906                 (void)gethostbyname_r ("www.ximian.com", &hent, buffer, bufsize, &h_errno);
907         ],[
908                 ac_cv_gethostbyname_r_five_args=yes
909         ],[
910                 ac_cv_gethostbyname_r_five_args=no
911         ])
912 ])])
913         
914 if test "x$ac_cv_gethostbyname_r_five_args" = "xyes" ; then
915         AC_DEFINE(GETHOSTBYNAME_R_FIVE_ARGS, 1, [Solaris-style gethostbyname_r])
916 fi
917
918 dnl **************************************************
919 dnl gethostbyaddr_r prototype
920 dnl **************************************************
921
922 AC_CHECK_FUNCS(gethostbyaddr_r,[
923 AC_CACHE_CHECK([if gethostbyaddr_r wants seven arguments], ac_cv_gethostbyaddr_r_seven_args,
924 [
925         AC_TRY_COMPILE([
926                 #include "confdefs.h"
927                 #include <sys/types.h>
928                 #include <sys/socket.h>
929                 #include <netinet/in.h>
930                 #include <netdb.h>
931
932                 #define BUFSIZE (sizeof(struct hostent)+10)
933         ],[
934                 struct hostent hent;
935                 char buffer[BUFSIZE];
936                 int bufsize=BUFSIZE;
937                 int h_errno;
938
939                 (void)gethostbyaddr_r ("www.ximian.com", 14, AF_INET, &hent, buffer, bufsize, &h_errno);
940         ],[
941                 ac_cv_gethostbyaddr_r_seven_args=yes
942         ],[
943                 ac_cv_gethostbyaddr_r_seven_args=no
944         ])
945 ])])
946         
947 if test "x$ac_cv_gethostbyaddr_r_seven_args" = "xyes" ; then
948         AC_DEFINE(GETHOSTBYADDR_R_SEVEN_ARGS, 1, [Solaris-style gethostbyaddr_r])
949 fi
950
951 dnl **************************************************
952 dnl stat(v)fs location/type
953 dnl **************************************************
954
955 AC_CHECK_HEADERS(sys/statvfs.h)
956 AC_CHECK_FUNCS(statvfs)
957 AC_CHECK_HEADERS(sys/param.h)
958 AC_CHECK_HEADERS(sys/mount.h)
959 AC_CHECK_FUNCS(statfs)
960
961 dnl **************************************************
962 dnl * IPv6 support and getaddrinfo calls
963 dnl **************************************************
964 AC_CACHE_CHECK([if system supports getaddrinfo and getnameinfo], have_addrinfo,
965 [
966         AC_TRY_COMPILE([
967                 #include "confdefs.h"
968                 #include <sys/types.h>
969                 #include <sys/socket.h>
970                 #include <netinet/in.h>
971                 #include <netdb.h>
972                 #include <stddef.h>
973
974         ],[
975                 #ifndef NI_MAXHOST
976                 #define NI_MAXHOST      1025
977                 #endif
978
979                 #ifndef NI_MAXSERV
980                 #define NI_MAXSERV      32
981                 #endif
982
983                 struct addrinfo hints, *res;
984                 struct sockaddr_in6 sin6;
985                 int af = AF_INET6;
986                 char host[NI_MAXHOST];
987                 char serv[NI_MAXSERV];
988
989                 getaddrinfo ("www.ximian.com", NULL, &hints, &res);
990                 freeaddrinfo (res);
991                 getnameinfo((struct sockaddr *)&sin6, sizeof(sin6), host, sizeof(host), serv, sizeof(serv), 0);
992         ],[
993                 have_addrinfo=yes
994         ],[
995                 have_addrinfo=no
996         ])
997 ])
998
999 if test x"$have_addrinfo" = "xno" ; then
1000    AC_DEFINE(NEED_ADDRINFO,1,[Enable getaddrinfo emulation])
1001    if test x"$enable_ipv6" = "xyes" ; then
1002       AC_ERROR(system doesn't support necessary interfaces for ipv6 support)
1003    fi
1004    msg_ipv6=no
1005 else
1006    AC_ARG_ENABLE(ipv6, 
1007      AC_HELP_STRING( [--enable-ipv6=@<:@no/yes@:>@],
1008                      [Enable support for resolving IPv6 addresses.]),
1009      ,enable_ipv6=yes)
1010    if test x"$enable_ipv6" = "xyes"; then
1011         msg_ipv6=yes
1012         AC_DEFINE(ENABLE_IPv6,1,[Enable IPv6 support])
1013         AC_TRY_COMPILE([
1014                 #include "confdefs.h"
1015                 #include <sys/types.h>
1016                 #include <sys/socket.h>
1017                 #include <netinet/in.h>
1018                 #include <netdb.h>
1019
1020         ],[
1021                 struct addrinfo hints;
1022                 
1023                 hints.ai_flags = AI_ADDRCONFIG;
1024         ],[
1025                 AC_DEFINE(HAVE_AI_ADDRCONFIG,1,[Define if the system defines the AI_ADDRCONFIG flag for getaddrinfo])
1026         ])
1027    else
1028         msg_ipv6=no
1029    fi
1030 fi
1031
1032 AM_CONDITIONAL(ENABLE_IPv6, test "x$enable_ipv6" = "xyes")
1033
1034 dnl **************************************************
1035 dnl Calendar support
1036 dnl **************************************************
1037 AC_MSG_CHECKING(if we should build the calendar)
1038 AC_ARG_ENABLE(calendar, 
1039   AC_HELP_STRING( [--enable-calendar=@<:@yes/no@:>@],
1040                   [Enable the calendar components (default yes)]),
1041   enable_calendar="$enableval", enable_calendar="yes")
1042
1043 if test "x${enable_calendar}" != "xno"; then
1044         AC_DEFINE(ENABLE_CALENDAR, 1, [Define if Calendar should be built])
1045 fi
1046 AM_CONDITIONAL(ENABLE_CALENDAR, test x$enable_calendar = xyes)
1047 AC_MSG_RESULT($enable_calendar)
1048 msg_calendar=$enable_calendar
1049
1050 dnl **************************************************
1051 dnl Weather calendar backend support
1052 dnl **************************************************
1053 AC_MSG_CHECKING(if we should build the weather calendar backend)
1054 AC_ARG_WITH([weather], 
1055   [AC_HELP_STRING([--with-weather], [Build the weather calendar backend (default=yes)])],
1056   [use_gweather=$withval], 
1057   [use_gweather=yes])
1058 if test $enable_calendar = no; then
1059         use_gweather="no (calendar support is disabled)"
1060 fi
1061 AC_MSG_RESULT($use_gweather)
1062
1063 if test $use_gweather = yes; then
1064         PKG_CHECK_MODULES([LIBGWEATHER], 
1065            [gweather >= gweather_minimum_version],
1066            [], 
1067            [AC_MSG_ERROR([The weather calendar backend requires GWeather >= gweather_minimum_version. Alternatively, you may specify --without-weather as a configure option to avoid building the backend.])])
1068 fi
1069
1070 AM_CONDITIONAL(ENABLE_WEATHER, test $use_gweather = yes)
1071
1072 dnl **************************************************
1073 dnl NNTP support.
1074 dnl **************************************************
1075 AC_ARG_ENABLE(nntp, 
1076   AC_HELP_STRING( [--enable-nntp=@<:@no/yes@:>@],
1077                   [Build Usenet news (NNTP) backend]),
1078   ,enable_nntp=yes)
1079
1080 if test "x$enable_nntp" = "xyes"; then
1081         AC_DEFINE(ENABLE_NNTP,1,[Build NNTP backend])
1082         msg_nntp=yes
1083 else
1084         msg_nntp=no
1085 fi
1086 AM_CONDITIONAL(ENABLE_NNTP, test x$enable_nntp = xyes)
1087
1088 dnl **************************************************
1089 dnl New IMAP code support.
1090 dnl **************************************************
1091 AC_ARG_ENABLE(imapp, 
1092   AC_HELP_STRING( [--enable-imapp=@<:@no/yes@:>@],
1093                   [Attempt to compile alternative, incomplete, very unsupported IMAPv4r1 code]),
1094   ,enable_imapp=no)
1095
1096 if test "x$enable_imapp" = "xyes"; then
1097         AC_DEFINE(ENABLE_IMAPP,1,[Really don't try this at home])
1098         msg_imapp=yes
1099 else
1100         msg_imapp=no
1101 fi
1102 AM_CONDITIONAL(ENABLE_IMAPP, test x$enable_imapp = xyes)
1103
1104 dnl **************************************************   
1105 dnl IMAP4rev1 code support.      
1106 dnl **************************************************   
1107 AC_ARG_ENABLE(imap4,     
1108   AC_HELP_STRING( [--enable-imap4=@<:@no/yes@:>@],
1109                   [Attempt to compile yet another, incomplete, very unsupported IMAPv4r1 implementation]),
1110   ,enable_imap4=no)      
1111
1112 if test "x$enable_imap4" = "xyes"; then          
1113          AC_DEFINE(ENABLE_IMAP4,1,[Really don't try this at home])       
1114          msg_imap4=yes   
1115 else     
1116          msg_imap4=no    
1117 fi       
1118 AM_CONDITIONAL(ENABLE_IMAP4, test x$enable_imap4 = xyes)
1119
1120 dnl **************************************************
1121 dnl Hula support
1122 dnl **************************************************
1123 AC_ARG_ENABLE(hula,
1124   AC_HELP_STRING( [--enable-hula=@<:@no/yes@:>@],
1125                   [Enable support for the now-defunct Hula project]),
1126   ,enable_hula=no)
1127
1128 if test "x$enable_hula" = "xyes"; then
1129         AC_DEFINE(ENABLE_HULA,1,[Build Hula backend])
1130         msg_hula=yes
1131 else
1132         msg_hula=no
1133 fi
1134 AM_CONDITIONAL(ENABLE_HULA, test x$enable_hula = xyes)
1135
1136 dnl **************************************************
1137 dnl * File locking
1138 dnl **************************************************
1139
1140 AC_ARG_ENABLE(dot-locking, 
1141   AC_HELP_STRING( [--enable-dot-locking=@<:@yes/no@:>@],
1142                   [Enable support for locking mail files with dot locking]),
1143   ,enable_dot_locking=yes)
1144
1145 if test $os_win32 != yes -a "x$enable_dot_locking" = "xyes"; then
1146   AC_DEFINE(USE_DOT,1,[Define to use dot locking for mbox files])
1147   msg_dot=yes
1148 else
1149   msg_dot=no    
1150 fi
1151
1152 AC_ARG_ENABLE(file-locking, 
1153   AC_HELP_STRING( [--enable-file-locking=@<:@fcntl/flock/no@:>@], 
1154                   [Enable support for locking mail files with file locking]),
1155   ,enable_file_locking=fcntl)
1156
1157 if test $os_win32 != yes -a "x$enable_file_locking" = "xfcntl"; then
1158   AC_DEFINE(USE_FCNTL,1,[Define to use fcntl locking for mbox files])
1159   msg_file=fcntl
1160 else
1161   if test $os_win32 != yes -a "x$enable_file_locking" = "xflock"; then
1162     AC_DEFINE(USE_FLOCK,1,[Define to use flock locking for mbox files])
1163     msg_file=flock
1164   else
1165     msg_file=no 
1166   fi
1167 fi
1168
1169 dnl **************************************************
1170 dnl * sendmail operation
1171 dnl **************************************************
1172
1173 AC_MSG_CHECKING(for SunOS broken spool format)
1174 if test "x$host_os" = "xsunos" ; then
1175    with_broken_spool="yes"
1176 fi
1177
1178 AC_ARG_WITH(broken-spool, 
1179   AC_HELP_STRING( [--with-broken-spool=@<:@yes/no@:>@],
1180                   [Using SunOS/Solaris sendmail which has a broken spool format]),
1181   ,with_broken_spool=${with_broken_spool:=no})
1182
1183 if test "x$with_broken_spool" = "xyes"; then
1184   AC_DEFINE(HAVE_BROKEN_SPOOL,1,[Define if mail delivered to the system mail directory is in broken Content-Length format])
1185 fi
1186
1187 AC_MSG_RESULT($with_broken_spool)
1188
1189 dnl ********
1190 dnl Kerberos
1191 dnl ********
1192 AC_ARG_WITH(krb5, 
1193   AC_HELP_STRING( [--with-krb5=DIR],
1194                   [Location of Kerberos 5 install dir]),
1195   with_krb5="$withval", with_krb5="no")
1196
1197 AC_ARG_WITH(krb5-libs, 
1198   AC_HELP_STRING( [--with-krb5-libs=DIR],
1199                   [Location of Kerberos 5 libraries]), 
1200   with_krb5_libs="$withval", with_krb5_libs="$with_krb5/lib")
1201
1202 AC_ARG_WITH(krb5-includes, 
1203   AC_HELP_STRING( [--with-krb5-includes=DIR],
1204                   [Location of Kerberos 5 headers]), 
1205   with_krb5_includes="$withval", with_krb5_includes="")
1206
1207 AC_ARG_WITH(krb4, 
1208   AC_HELP_STRING( [--with-krb4=DIR],
1209                   [Location of Kerberos 4 install dir]), 
1210   with_krb4="$withval", with_krb4="no")
1211
1212 AC_ARG_WITH(krb4-libs, 
1213   AC_HELP_STRING( [--with-krb4-libs=DIR],
1214                   [Location of Kerberos 4 libraries]), 
1215   with_krb4_libs="$withval", with_krb4_libs="$with_krb4/lib")
1216
1217 AC_ARG_WITH(krb4-includes, 
1218   AC_HELP_STRING( [--with-krb4-includes=DIR],
1219                   [Location of Kerberos 4 headers]), 
1220   with_krb4_includes="$withval", with_krb4_includes="")
1221
1222 msg_krb5="no"
1223 if test "x${with_krb5}" != "xno"; then
1224         LDFLAGS_save="$LDFLAGS"
1225         
1226         mitlibs="-lkrb5 -lk5crypto -lcom_err -lgssapi_krb5"
1227         heimlibs="-lkrb5 -lcrypto -lasn1 -lcom_err -lroken -lgssapi"
1228         sunlibs="-lkrb5 -lgss"
1229         AC_CACHE_CHECK([for Kerberos 5], ac_cv_lib_kerberos5,
1230         [
1231                 LDFLAGS="$LDFLAGS -L$with_krb5_libs $mitlibs"
1232                 AC_TRY_LINK([#include <krb5.h>],krb5_init_context, ac_cv_lib_kerberos5="$mitlibs",
1233                 [
1234                         LDFLAGS="$LDFLAGS_save -L$with_krb5_libs $heimlibs"
1235                         AC_TRY_LINK_FUNC(krb5_init_context, ac_cv_lib_kerberos5="$heimlibs", 
1236                         [
1237                                 LDFLAGS="$LDFLAGS_save -L$with_krb5_libs $sunlibs"
1238                                 AC_TRY_LINK_FUNC(krb5_init_context, ac_cv_lib_kerberos5="$sunlibs", ac_cv_lib_kerberos5="no")
1239                         ])
1240                 ])
1241                 LDFLAGS="$LDFLAGS_save"
1242         ])
1243         if test "$ac_cv_lib_kerberos5" != "no"; then
1244                 AC_DEFINE(HAVE_KRB5,1,[Define if you have Krb5])
1245                 if test "$ac_cv_lib_kerberos5" = "$mitlibs"; then
1246                         AC_DEFINE(HAVE_MIT_KRB5,1,[Define if you have MIT Krb5])
1247                         if test -z "$with_krb5_includes"; then
1248                                 KRB5_CFLAGS="-I$with_krb5/include"
1249                         else
1250                                 KRB5_CFLAGS="-I$with_krb5_includes"
1251                         fi
1252                         msg_krb5="yes (MIT)"
1253                 else
1254                         if test "$ac_cv_lib_kerberos5" = "$heimlibs"; then
1255                                 AC_DEFINE(HAVE_HEIMDAL_KRB5,1,[Define if you have Heimdal])
1256                                 if test -z "$with_krb5_includes"; then
1257                                         KRB5_CFLAGS="-I$with_krb5/include/heimdal"
1258                                 else
1259                                         KRB5_CFLAGS="-I$with_krb5_includes"
1260                                 fi
1261                                 msg_krb5="yes (Heimdal)"
1262                         else
1263                                 AC_DEFINE(HAVE_SUN_KRB5,1,[Define if you have Sun Kerberosv5])
1264                                 if test -z "$with_krb5_includes"; then
1265                                         KRB5_CFLAGS="-I$with_krb5/include/kerberosv5"
1266                                 else
1267                                         KRB5_CFLAGS="-I$with_krb5_includes"
1268                                 fi
1269                                 msg_krb5="yes (Sun)"
1270                         fi
1271                 fi
1272                 KRB5_LDFLAGS="-L$with_krb5_libs $ac_cv_lib_kerberos5"
1273                 AC_MSG_RESULT(msg_krb5)
1274         else
1275                 dnl AC_MSG_CHECKING([for Kerberos 5])
1276                 AC_MSG_RESULT([no])
1277                 AC_MSG_ERROR([You specified with krb5, but it was not found.])
1278         fi
1279 else
1280         AC_MSG_WARN([krb5 support disabled])
1281 fi
1282
1283 AM_CONDITIONAL(ENABLE_KRB5, test x$with_krb5 != xno)
1284
1285 AC_CHECK_HEADER([et/com_err.h],[AC_DEFINE([HAVE_ET_COM_ERR_H], 1, [Have et/comm_err.h])])
1286 AC_CHECK_HEADER([com_err.h],[AC_DEFINE([HAVE_COM_ERR_H], 1, [Have comm_err.h])])
1287
1288 msg_krb4="no"
1289 if test "x${with_krb4}" != "xno"; then
1290         LDFLAGS_save="$LDFLAGS"
1291         AC_CACHE_CHECK(for Kerberos 4, ac_cv_lib_kerberos4,
1292         [
1293                 ac_cv_lib_kerberos4="no"
1294
1295                 mitcompatlibs="-lkrb4 -ldes425 -lkrb5 -lk5crypto -lcom_err"
1296                 # Look for MIT krb5 compat krb4
1297                 LDFLAGS="$LDFLAGS -L$with_krb4_libs $mitcompatlibs"
1298                 AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="$mitcompatlibs")
1299                 
1300                 if test "$ac_cv_lib_kerberos4" = "no"; then
1301                         # Look for KTH krb4
1302                         LDFLAGS="$LDFLAGS_save -L$with_krb4_libs -lkrb -lcrypto -lcom_err -lroken"
1303                         AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb -lcrypto -lcom_err -lroken")
1304                 fi
1305                 if test "$ac_cv_lib_kerberos4" = "no"; then
1306                         # Look for old MIT krb4
1307                         LDFLAGS="$LDFLAGS_save -L$with_krb4_libs -lkrb"
1308                         AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb",
1309                         [
1310                                 LDFLAGS="$LDFLAGS -ldes"
1311                                 AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb -ldes")
1312                         ])
1313                 fi
1314         ])
1315         LDFLAGS="$LDFLAGS_save"
1316         if test "$ac_cv_lib_kerberos4" != "no"; then
1317                 AC_DEFINE(HAVE_KRB4,1,[Define if you have Krb4])
1318                 msg_krb4="yes"
1319
1320                 if test -z "$with_krb4_includes"; then
1321                         if test -f "$with_krb4/include/krb.h" -o -f "$with_krb4/include/port-sockets.h"; then
1322                                 KRB4_CFLAGS="-I$with_krb4/include"
1323                         fi
1324                         if test -d "$with_krb4/include/kerberosIV"; then
1325                                 KRB4_CFLAGS="$KRB4_CFLAGS -I$with_krb4/include/kerberosIV"
1326                         fi
1327                 else
1328                         KRB4_CFLAGS="-I$with_krb4_includes"
1329                 fi
1330                 KRB4_LDFLAGS="-L$with_krb4_libs $ac_cv_lib_kerberos4"
1331                 
1332                 CFLAGS_save="$CFLAGS"
1333                 CFLAGS="$CFLAGS $KRB4_CFLAGS"
1334                 AC_TRY_COMPILE([#include "krb.h"
1335                 int krb_sendauth;
1336                 ],[return 0],[AC_DEFINE(NEED_KRB_SENDAUTH_PROTO,1,[Need krb_sendauth proto])],)
1337                 CFLAGS="$CFLAGS_save"
1338         fi
1339 else
1340         AC_MSG_CHECKING(for Kerberos 4)
1341         AC_MSG_RESULT(${with_krb4})
1342 fi
1343
1344 AC_SUBST(KRB5_CFLAGS)
1345 AC_SUBST(KRB5_LDFLAGS)
1346 AC_SUBST(KRB4_CFLAGS)
1347 AC_SUBST(KRB4_LDFLAGS)
1348
1349 dnl
1350 dnl Purify support
1351 dnl
1352 EVO_PURIFY_SUPPORT
1353
1354 dnl **************************************************
1355 dnl Exchange debug
1356 dnl **************************************************
1357 AC_ARG_WITH(e2k-debug,
1358   AC_HELP_STRING( [--with-e2k-debug],
1359                   [Allow debugging]))
1360 case $withval in
1361 no)
1362         ;;
1363 *)
1364         AC_DEFINE(E2K_DEBUG, 1, [Define if you want E2K_DEBUG to be available])
1365         ;;
1366 esac
1367
1368 dnl **************************************************
1369 dnl LDAP support.
1370 dnl **************************************************
1371 if test "$os_win32" != yes; then
1372 EVO_LDAP_CHECK(no)
1373 case $with_openldap in
1374 no)
1375         msg_ldap=no
1376         ;;
1377 *)
1378         case $with_static_ldap in
1379         yes)
1380                 msg_ldap="$with_openldap (static)"
1381                 ;;
1382         *)
1383                 msg_ldap="$with_openldap (dynamic)"
1384                 ;;
1385         esac
1386 esac
1387
1388 dnl **************************************************
1389 dnl SunLDAP support, but if OpenLDAP support, skip check SunLDAP.
1390 dnl **************************************************
1391 if test "$with_openldap" = no ; then
1392         EVO_SUNLDAP_CHECK(no)
1393         case $with_sunldap in
1394         no)
1395                 msg_ldap=no
1396                 ;;
1397         *)
1398                 case $with_static_sunldap in
1399                 yes)
1400                         msg_ldap="$with_sunldap (static)"
1401                         ;;
1402                 *)
1403                         msg_ldap="$with_sunldap (dynamic)"
1404                         ;;
1405                 esac
1406         esac
1407 else
1408         with_sunldap=no
1409 fi
1410 AM_CONDITIONAL(SUNLDAP, test "$with_sunldap" != no)
1411
1412 SAVE_CFLAGS="$CFLAGS"
1413 SAVE_LIBS="$LIBS"
1414 LDAP_CFLAGS="$LDAP_CFLAGS -DLDAP_DEPRECATED"
1415 CFLAGS="$CFLAGS $LDAP_CFLAGS"
1416 LIBS="$LIBS $LDAP_LIBS"
1417 AC_CHECK_FUNCS(ldap_ntlm_bind)
1418 CFLAGS="$SAVE_CFLAGS"
1419 LIBS="$SAVE_LIBS"
1420 dnl You need to enable LDAP and Kerberos to enable Exchange support in e-d-s
1421 msg_no_ntlm="no"
1422 msg_exchange="no"
1423 if test "$msg_ldap" != "no" ; then
1424         if test "$ac_cv_func_ldap_ntlm_bind" != no ; then
1425                 msg_exchange="yes"
1426         else
1427 dnl The user wanted to build with openldap, but his openldap did not have NTLM 
1428 dnl support. Make him aware of this with a warning message at the end.
1429                 msg_no_ntlm="yes"
1430         fi
1431 fi
1432 else # Win32
1433 LDAP_CFLAGS="-DLDAP_DEPRECATED"
1434 LDAP_LIBS="-lwldap32"
1435 AC_SUBST(LDAP_CFLAGS)
1436 AC_SUBST(LDAP_LIBS)
1437 AC_DEFINE(HAVE_LDAP,1,[Define if you have LDAP support])
1438 AM_CONDITIONAL(ENABLE_LDAP, true)
1439 AM_CONDITIONAL(SUNLDAP, false)
1440 msg_ldap="yes"
1441 msg_no_ntlm="no"
1442 msg_exchange="yes"
1443 fi # Win32
1444
1445 LIBBONOBO_REQUIRED=libbonobo_minimum_version
1446 AC_SUBST(LIBBONOBO_REQUIRED)
1447
1448 ORBIT_REQUIRED=ORBit_minimum_version
1449 AC_SUBST(ORBIT_REQUIRED)
1450
1451 dnl *******************
1452 dnl GObject marshalling
1453 dnl *******************
1454 AM_PATH_GLIB_2_0
1455
1456 dnl We use AC_SUBST_FILE because AC_SUBST won't deal with newlines
1457 EVO_MARSHAL_RULE=$srcdir/marshal.mk
1458 AC_SUBST_FILE(EVO_MARSHAL_RULE)
1459
1460 dnl **************************************************
1461 dnl * Posix thread support
1462 dnl **************************************************
1463
1464 dnl GLIB_CONFIG=${GLIB_CONFIG-glib-config}
1465 dnl GNOME_PTHREAD_CHECK
1466
1467 dnl if test "x$PTHREAD_LIB" = "x" ; then
1468 dnl     AC_MSG_ERROR([POSIX threads are currently required for Evolution])
1469 dnl fi
1470
1471 dnl
1472 dnl Notice that this is a hack, and we wont be able to use this forever, but
1473 dnl at least for some time
1474 dnl
1475
1476 EVO_PTHREAD_CHECK
1477
1478 THREADS_LIBS="$PTHREAD_LIB"
1479 THREADS_CFLAGS="$PTHREAD_CFLAGS"
1480
1481 AC_SUBST(THREADS_LIBS)
1482 AC_SUBST(THREADS_CFLAGS)
1483 AC_DEFINE(ENABLE_THREADS,1,[Required])
1484
1485 PKG_CHECK_MODULES(ORBIT, ORBit-2.0 >= ORBit_minimum_version)
1486 test x$ORBIT_IDL = x && ORBIT_IDL=`$PKG_CONFIG --variable=orbit_idl ORBit-2.0`
1487 AC_SUBST(ORBIT_CFLAGS)
1488 AC_SUBST(ORBIT_LIBS)
1489 AC_SUBST(ORBIT_IDL)
1490
1491 AC_MSG_CHECKING(for CORBA include paths)
1492 IDL_INCLUDES="-I"`pkg-config --variable=idldir libbonobo-2.0`" -I"`pkg-config --variable=idldir bonobo-activation-2.0`
1493 AC_MSG_RESULT($IDL_INCLUDES)
1494 AC_SUBST(IDL_INCLUDES)
1495
1496 dnl Utility macro to set compiler flags for a specific lib.
1497 dnl  EVO_SET_COMPILE_FLAGS(VAR-PREFIX, DEPS, EXTRA-CFLAGS, EXTRA-LIBS)
1498 AC_DEFUN([EVO_SET_COMPILE_FLAGS], [
1499         PKG_CHECK_MODULES([$1], [$2])
1500         $1_CFLAGS="[$]$1_CFLAGS $3 "
1501         $1_LIBS="[$]$1_LIBS $4 "
1502 ])
1503
1504 dnl ****************************************
1505 dnl Flags for the various libraries we build
1506 dnl ****************************************
1507
1508 dnl --- libedataserver, libedataserverui, libebackend flags
1509
1510 E_DATA_SERVER_DEPS="libxml-2.0 libbonobo-2.0 libsoup-2.4 gconf-2.0 $mozilla_nspr"
1511
1512 EVO_SET_COMPILE_FLAGS(E_DATA_SERVER, $E_DATA_SERVER_DEPS, $THREADS_CFLAGS $MANUAL_NSPR_CFLAGS, $THREADS_LIBS $MANUAL_NSPR_LIBS)
1513 AC_SUBST(E_DATA_SERVER_CFLAGS)
1514 AC_SUBST(E_DATA_SERVER_LIBS)
1515
1516 E_DATA_SERVER_UI_DEPS="gtk+-2.0 libglade-2.0 gobject-2.0 gthread-2.0 gconf-2.0 $GNOME_KEYRING_REQUIREMENT"
1517
1518 EVO_SET_COMPILE_FLAGS(E_DATA_SERVER_UI, $E_DATA_SERVER_UI_DEPS, $THREADS_CFLAGS, $THREADS_LIBS)
1519 AC_SUBST(E_DATA_SERVER_UI_CFLAGS)
1520 AC_SUBST(E_DATA_SERVER_UI_LIBS)
1521
1522 E_BACKEND_DEPS="gobject-2.0 libxml-2.0 gmodule-2.0"
1523
1524 EVO_SET_COMPILE_FLAGS(E_BACKEND, $E_BACKEND_DEPS)
1525 AC_SUBST(E_BACKEND_CFLAGS)
1526 AC_SUBST(E_BACKEND_LIBS)
1527
1528 dnl --- evolution-addressbook flags
1529
1530 EVOLUTION_ADDRESSBOOK_DEPS="libxml-2.0 libbonobo-2.0 gobject-2.0 gthread-2.0 gconf-2.0"
1531
1532 EVO_SET_COMPILE_FLAGS(EVOLUTION_ADDRESSBOOK, $EVOLUTION_ADDRESSBOOK_DEPS)
1533 AC_SUBST(EVOLUTION_ADDRESSBOOK_CFLAGS)
1534 AC_SUBST(EVOLUTION_ADDRESSBOOK_LIBS)
1535
1536 dnl --- evolution-calendar flags
1537 if test "x${enable_calendar}" = "xyes"; then
1538         EVOLUTION_CALENDAR_DEPS="libical >= libical_minimum_version libxml-2.0 libbonobo-2.0 gio-2.0 gobject-2.0 gthread-2.0 gconf-2.0"
1539
1540 dnl *****
1541 dnl libical.pc from libical-0.43 has a bug in it's CFlags. 
1542 dnl It wants apps to include <libical/ical*.h> but it's CFlags make it difficult
1543 dnl to differentiate between <libical/ical.h> and <ical.h>
1544 dnl We have fixed all our instances to use <libical/ical.h>. Until the .pc from 
1545 dnl libical is fixed, we have to work-around the buggy CFlags.
1546 dnl *****
1547 LIBICAL_EXTRA_CFLAGS=" -I`$PKG_CONFIG --variable=includedir libical` "
1548 LIBICAL_EXTRA_LIBS=""
1549 AC_SUBST(LIBICAL_EXTRA_CFLAGS)
1550 AC_SUBST(LIBICAL_EXTRA_LIBS)
1551
1552         EVO_SET_COMPILE_FLAGS(EVOLUTION_CALENDAR, $EVOLUTION_CALENDAR_DEPS, $LIBICAL_EXTRA_CFLAGS, $LIBICAL_EXTRA_LIBS)
1553         AC_SUBST(EVOLUTION_CALENDAR_CFLAGS)
1554         AC_SUBST(EVOLUTION_CALENDAR_LIBS)
1555 fi
1556
1557 dnl --- factory flags
1558
1559 E_FACTORY_DEPS="$mozilla_nspr"
1560 if test "x${enable_calendar}" = "xyes"; then
1561    E_FACTORY_DEPS="$E_FACTORY_DEPS libical"
1562 fi
1563 EVO_SET_COMPILE_FLAGS(E_FACTORY, $E_FACTORY_DEPS, $THREADS_CFLAGS $MANUAL_NSPR_CFLAGS $LIBICAL_EXTRA_CFLAGS, $THREADS_LIBS $MANUAL_NSPR_LIBS $LIBICAL_EXTRA_LIBS)
1564 AC_SUBST(E_FACTORY_CFLAGS)
1565 AC_SUBST(E_FACTORY_LIBS)
1566
1567 dnl --- Google flags
1568 GDATA_DEPS="libsoup-2.4 libxml-2.0"
1569 EVO_SET_COMPILE_FLAGS(GDATA, $GDATA_DEPS)
1570 AC_SUBST(GDATA_CFLAGS)
1571 AC_SUBST(GDATA_LIBS)
1572
1573 dnl --- Groupwise flags
1574 LIBSOUP_REQUIRED=libsoup_minimum_version
1575 AC_SUBST(LIBSOUP_REQUIRED)
1576
1577 EVO_SET_COMPILE_FLAGS(SOUP, libsoup-2.4)
1578 AC_SUBST(SOUP_CFLAGS)
1579 AC_SUBST(SOUP_LIBS)
1580
1581 dnl --- Camel flags
1582 SQLITE_REQUIRED=sqlite_minimum_version
1583 AC_SUBST(SQLITE_REQUIRED)
1584
1585 zlib_found=false
1586 dnl deflateInit is a #define, use deflateEnd instead
1587 AC_CHECK_LIB(z, deflateEnd,
1588     [ AC_CHECK_HEADER(zlib.h, zlib_found=true) ])                                                                                                                                                                            
1589 if test "x$zlib_found" = "xfalse"; then
1590     AC_MSG_ERROR([*** zlib is required])
1591 fi
1592
1593 dnl *************************************
1594 dnl *** Checks for large file support ***
1595 dnl *************************************
1596 AC_ARG_ENABLE(largefile,
1597               AC_HELP_STRING([--enable-largefile],
1598               [enable support for large files [[default=no]]]),,
1599               enable_largefile="no")
1600 if test "x$enable_largefile" != "xno"; then
1601     AC_SYS_LARGEFILE
1602     AC_CACHE_CHECK([for _LARGEFILE64_SOURCE value needed for large files], largefile64_source,
1603     [
1604         AC_TRY_COMPILE([
1605                 #include <sys/types.h>
1606                 #include <sys/stat.h>
1607                 #include <fcntl.h>
1608         ],[
1609                 int fd = open ("__o_largefile", O_CREAT | O_RDWR | O_LARGEFILE, 0644);
1610         ],[
1611                 largefile64_source="no"
1612         ],[
1613                 AC_TRY_COMPILE([
1614                         #define _LARGEFILE64_SOURCE
1615                         #include <sys/types.h>
1616                         #include <sys/stat.h>
1617                         #include <fcntl.h>
1618                 ],[
1619                         int fd = open ("__o_largefile", O_CREAT | O_RDWR | O_LARGEFILE, 0644);
1620                 ],[
1621                         largefile64_source="yes"
1622                 ],[
1623                         largefile64_source="unknown"
1624                 ])
1625         ])
1626     ])
1627     
1628     enable_largefile="no"
1629     
1630     if test "x$largefile64_source" = "xyes"; then
1631         LARGEFILE_CFLAGS="-D_LARGEFILE64_SOURCE"
1632         enable_largefile="yes"
1633     elif test "x$largefile64_source" = "xunknown"; then
1634         AC_DEFINE(O_LARGEFILE, 0, [Define to 0 if your system does not have the O_LARGEFILE flag])
1635     fi
1636     
1637     if test -n "$ac_cv_sys_large_files" -a "x$ac_cv_sys_large_files" != "xno"; then
1638         LARGEFILE_CFLAGS="$LARGEFILE_CFLAGS -D_LARGE_FILES"
1639         enable_largefile="yes"
1640     fi
1641     
1642     if test "x$ac_cv_sys_file_offset_bits" != "xno"; then
1643         LARGEFILE_CFLAGS="$LARGEFILE_CFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
1644         enable_largefile="yes"
1645     fi
1646 else
1647     AC_DEFINE(O_LARGEFILE, 0, [Define to 0 if your system does not have the O_LARGEFILE flag])
1648     LARGEFILE_CFLAGS=""
1649 fi
1650
1651 AM_CONDITIONAL(ENABLE_LARGEFILE, test "x$enable_largefile" = "xyes")
1652
1653 EVO_SET_COMPILE_FLAGS(CAMEL, $mozilla_nss gio-2.0 sqlite3 >= sqlite_minimum_version gthread-2.0, 
1654                       $THREADS_CFLAGS $KRB4_CFLAGS $KRB5_CFLAGS $MANUAL_NSS_CFLAGS $LARGEFILE_CFLAGS,
1655                       -lz $THREADS_LIBS $KRB4_LDFLAGS $KRB5_LDFLAGS $MANUAL_NSS_LIBS)
1656 AC_SUBST(CAMEL_CFLAGS)
1657 AC_SUBST(CAMEL_LIBS)
1658 AC_SUBST(CAMEL_GROUPWISE_CFLAGS)
1659 AC_SUBST(CAMEL_GROUPWISE_LIBS)
1660
1661 dnl *******************
1662 dnl Special directories
1663 dnl *******************
1664
1665 dnl --- If you add something here, consider whether or not you also
1666 dnl --- need to add it to one or more .pc.in files (for Connector,
1667 dnl --- etc)
1668
1669 privdatadir='${datadir}'/evolution-data-server-$BASE_VERSION
1670 AC_SUBST(privdatadir)
1671
1672 privincludedir='${includedir}'/evolution-data-server-$BASE_VERSION
1673 AC_SUBST(privincludedir)
1674
1675 privlibdir='${libdir}'/evolution-data-server-$BASE_VERSION
1676 AC_SUBST(privlibdir)
1677
1678 idldir='${datadir}'/idl/evolution-data-server-$API_VERSION
1679 AC_SUBST(idldir)
1680
1681 imagesdir='${datadir}'/pixmaps/evolution-data-server
1682 AC_SUBST(imagesdir)
1683
1684 serverdir="$libdir/bonobo/servers"
1685 AC_SUBST(serverdir)
1686
1687 extensiondir='${libdir}'/evolution-data-server-$API_VERSION/extensions
1688 AC_SUBST(extensiondir)
1689
1690 gladedir="$privdatadir/glade"
1691 AC_SUBST(gladedir)
1692
1693 if test $use_gweather = yes; then
1694         weatherdatadir="$privdatadir/weather"
1695         AC_SUBST(weatherdatadir)
1696 fi
1697
1698 dnl separate camel from e-d-s?  or should it be under the same spot?  same for now.
1699 camel_providerdir='${libdir}'/evolution-data-server-$API_VERSION/camel-providers
1700 AC_SUBST(camel_providerdir)
1701
1702 dnl ************************
1703 dnl IDL/Component Versioning
1704 dnl ************************
1705
1706 INTERFACE_VERSION="$BASE_VERSION"
1707 AC_SUBST(INTERFACE_VERSION)
1708 AC_DEFINE_UNQUOTED(INTERFACE_VERSION, "$INTERFACE_VERSION", [IDL interface version (Major.Minor)])
1709
1710 EVO_SUBST_SERVER_RULE='%.server.in: %.server.in.in ; sed -e "s|\@BINDIR\@|$(bindir)|" -e "s|\@LIBEXECDIR_IN_SERVER_FILE\@|$(LIBEXECDIR_IN_SERVER_FILE)|" -e "s|\@COMPONENTDIR\@|$(componentdir)|" -e "s|\@IMPORTERSDIR\@|$(importersdir)|" -e "s|\@EXEEXT\@|$(EXEEXT)|" -e "s|\@VERSION\@|$(BASE_VERSION)|" -e "s|\@API_VERSION\@|$(API_VERSION)|" -e "s|\@INTERFACE_VERSION\@|$(INTERFACE_VERSION)|" $< > $@'
1711 EVO_NAME_SERVER_RULE='%_$(API_VERSION).server: %.server ; mv $< $@'
1712 AC_SUBST(EVO_SUBST_SERVER_RULE)
1713 AC_SUBST(EVO_NAME_SERVER_RULE)
1714
1715 dnl ***********
1716 dnl GConf stuff
1717 dnl ***********
1718 AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
1719 AM_GCONF_SOURCE_2
1720
1721 dnl *************
1722 dnl Gtk Doc stuff
1723 dnl *************
1724 GTK_DOC_CHECK(1.9)
1725
1726 dnl ******************************
1727 dnl Makefiles
1728 dnl ******************************
1729
1730 export privlibdir
1731 export privincludedir
1732 export privdatadir
1733
1734 if test $dynamic_libdb = no; then
1735         AC_CONFIG_SUBDIRS(libdb/dist)
1736 fi
1737 AC_OUTPUT([
1738 Makefile
1739 evolution-data-server-zip
1740 evolution-data-server.pc
1741 addressbook/Makefile
1742 addressbook/idl/Makefile
1743 addressbook/libebook/Makefile
1744 addressbook/libebook/libebook.pc
1745 addressbook/libedata-book/Makefile
1746 addressbook/libedata-book/libedata-book.pc
1747 addressbook/backends/Makefile
1748 addressbook/backends/file/Makefile
1749 addressbook/backends/vcf/Makefile
1750 addressbook/backends/ldap/Makefile
1751 addressbook/backends/google/Makefile
1752 addressbook/backends/groupwise/Makefile
1753 addressbook/backends/webdav/Makefile
1754 addressbook/tests/Makefile
1755 addressbook/tests/ebook/Makefile
1756 addressbook/tests/vcard/Makefile
1757 art/Makefile
1758 calendar/Makefile
1759 calendar/idl/Makefile
1760 calendar/libecal/Makefile
1761 calendar/libecal/libecal.pc
1762 calendar/libedata-cal/Makefile
1763 calendar/libedata-cal/libedata-cal.pc
1764 calendar/backends/Makefile
1765 calendar/backends/caldav/Makefile
1766 calendar/backends/file/Makefile
1767 calendar/backends/groupwise/Makefile
1768 calendar/backends/http/Makefile
1769 calendar/backends/contacts/Makefile
1770 calendar/backends/weather/Makefile
1771 calendar/backends/google/Makefile
1772 calendar/tests/Makefile
1773 calendar/tests/ecal/Makefile
1774 camel/Makefile
1775 camel/providers/Makefile
1776 camel/providers/groupwise/Makefile
1777 camel/providers/hula/Makefile
1778 camel/providers/imap/Makefile
1779 camel/providers/imapp/Makefile
1780 camel/providers/imap4/Makefile
1781 camel/providers/local/Makefile
1782 camel/providers/nntp/Makefile
1783 camel/providers/pop3/Makefile
1784 camel/providers/sendmail/Makefile
1785 camel/providers/smtp/Makefile
1786 camel/tests/Makefile
1787 camel/tests/folder/Makefile
1788 camel/tests/lib/Makefile
1789 camel/tests/message/Makefile
1790 camel/tests/mime-filter/Makefile
1791 camel/tests/misc/Makefile
1792 camel/tests/smime/Makefile
1793 camel/tests/stream/Makefile
1794 camel/camel.pc
1795 camel/camel-provider.pc
1796 libdb/Makefile
1797 libebackend/Makefile
1798 libebackend/libebackend.pc
1799 libedataserver/Makefile
1800 libedataserver/eds-version.h
1801 libedataserver/libedataserver.pc
1802 libedataserverui/Makefile
1803 libedataserverui/libedataserverui.pc
1804 servers/Makefile
1805 servers/groupwise/Makefile
1806 servers/groupwise/libegroupwise.pc
1807 servers/exchange/Makefile
1808 servers/exchange/xntlm/Makefile
1809 servers/exchange/lib/Makefile
1810 servers/exchange/storage/Makefile
1811 servers/exchange/storage/libexchange-storage.pc
1812 servers/google/Makefile
1813 servers/google/libgdata/Makefile
1814 servers/google/libgdata/libgdata.pc
1815 servers/google/libgdata-google/Makefile 
1816 servers/google/libgdata-google/libgdata-google.pc
1817 src/Makefile
1818 win32/Makefile
1819 docs/Makefile
1820 docs/reference/Makefile
1821 docs/reference/addressbook/Makefile
1822 docs/reference/addressbook/libebook/Makefile
1823 docs/reference/addressbook/libedata-book/Makefile
1824 docs/reference/calendar/Makefile
1825 docs/reference/calendar/libecal/Makefile
1826 docs/reference/calendar/libedata-cal/Makefile
1827 docs/reference/camel/Makefile
1828 docs/reference/libedataserver/Makefile
1829 docs/reference/libedataserverui/Makefile
1830 docs/reference/libebackend/Makefile
1831 po/Makefile.in
1832 ])
1833
1834 case $host in
1835 *-mingw*)
1836         # Override the old libtool in libdb/dist with the one from here
1837         cp libtool libdb/dist
1838         ;;
1839 esac
1840
1841 echo "
1842         evolution-data-server has been configured as follows:
1843         Calendar:         $msg_calendar
1844         Weather calendar: $use_gweather
1845         Mail Directory:   $system_mail_dir, $system_mail_perm
1846         LDAP support:     $msg_ldap"
1847 if test "$msg_nntp" = "yes"; then
1848 echo "\
1849         NNTP support:     $msg_nntp"
1850 fi
1851 if test "$msg_hula" = "yes"; then
1852 echo "\
1853         Hula support:     $msg_hula"
1854 fi
1855 echo "\
1856         Kerberos 4/5:     $msg_krb4/$msg_krb5
1857         Gnome Keyring:    $enable_gnome_keyring/$with_gnome_keyring
1858         SSL support:      $msg_ssl
1859         SMIME support:    $msg_smime
1860         IPv6 support:     $msg_ipv6
1861         Berkeley DB:      $msg_libdb
1862         Exchange support: $msg_exchange
1863         Dot Locking:      $msg_dot
1864         File Locking:     $msg_file
1865         Large files:      $largefile_support
1866         Gtk Doc:          $enable_gtk_doc
1867 "
1868 if test "$msg_no_ntlm" != "no" ; then
1869         echo ""
1870         AC_MSG_WARN([
1871 No NTLM support in OpenLDAP; Plaintext password authentication will be
1872 used when connecting to the Exchange Global Catalog server. Consider 
1873 installing the evo-openldap package, or building OpenLDAP with the 
1874 patch in servers/exchange/docs/openldap-ntlm.diff
1875 ])
1876 fi