Imported Upstream version 0.9
[platform/upstream/syncevolution.git] / configure.in
1 dnl -*- mode: Autoconf; -*-
2 dnl Invoke autogen.sh to produce a configure script.
3
4 AC_INIT([syncevolution], [0.9])
5 AM_INIT_AUTOMAKE([tar-ustar])
6 AC_CONFIG_MACRO_DIR([m4])
7 define([SYNTHESISSRC_REPO], [])
8 dnl Specify git revisions/branches without prefix, i.e., without 'origin'.
9 dnl We'll sort that out below.
10 define([SYNTHESISSRC_REVISION], [syncevolution-0.9])
11 AM_CONFIG_HEADER(config.h)
12 AC_LIBTOOL_DLOPEN
13
14 dnl default device type (see AC_DEFINE below)
15 DEVICE_TYPE=desktop
16
17 AC_ARG_WITH(synthesis-src,
18             AS_HELP_STRING([--with-synthesis-src=<base directory|svn URL|git URL>],
19                            [Specifies location of the Synthesis root directory.
20                            Use this when the Synthesis library is to
21                            be compiled as part of the SyncEvolution compilation. In release
22                            versions of SyncEvolution, a copy of the Synthesis code is bundled
23                            under 'src/synthesis' and compiled unless something else is
24                            specified. --with-synthesis-src can be given a path to sources
25                            checked out already, a Subversion repository URL or a git repository
26                            URL. When given a repository URL, then the configure script
27                            will checkout the sources into 'src/synthesis-workdir' or
28                            update that working copy if the directory already exists.
29                            Default: bundled source in src/synthesis (in released SyncEvolution sources),
30                            SYNTHESISSRC_REPO otherwise.]),
31             [SYNTHESISSRC="$withval"], [SYNTHESISSRC="$SYNTHESISSRC_DEF"; REVISION="SYNTHESISSRC_REVISION"])
32
33 AC_ARG_WITH(synthesis-username,
34             AS_HELP_STRING([--with-synthesis-username=<svn username>],
35                            [username to use when checking out --with-synthesis-src sources from Subversion, default 'guest']),
36             [USERNAME="$withval"], [USERNAME="guest"])
37
38 AC_ARG_WITH(synthesis-revision,
39             AS_HELP_STRING([--with-synthesis-revision=<git tag/branch/hash or Subversion revision>],
40                            [Identifies which source revision to use from --with-synthesis-src repository, empty string stands for latest. Default for default --synthesis-src: SYNTHESISSRC_REVISION]),
41             [REVISION="$withval"])
42
43 AC_ARG_ENABLE(shared,
44               AS_HELP_STRING([--enable-shared],
45                              [build backends as dynamically loadable modules]),
46               enable_shared="$enableval", enable_shared="no")
47
48 AC_ARG_ENABLE(static,
49               AS_HELP_STRING([--enable-static],
50                              [build backends also as static libraries]),
51               enable_static="$enableval", enable_static="no")
52
53 AC_ARG_ENABLE(unit-tests,
54               AS_HELP_STRING([--enable-unit-tests],
55                              [enables tests embedded in the source code of the library (changes content of executable)]),
56               enable_unit_tests="$enableval", enable_unit_tests="no")
57 AC_ARG_ENABLE(integration-tests,
58               AS_HELP_STRING([--enable-integration-tests],
59                              [enables tests outside of the library (can be used together with normal builds of the library)]),
60               enable_integration_tests="$enableval", enable_integration_tests="no")
61
62 AC_ARG_ENABLE(static-cxx,
63               AS_HELP_STRING([--enable-static-cxx],
64                              [build executables which contain libstdc++ instead of requiring suitable libstdc++.so to run]),
65               enable_static_cxx="$enableval", enable_static_cxx="no")
66
67 AC_ARG_ENABLE(evolution-compatibility,
68               AS_HELP_STRING([--enable-evolution-compatibility],
69                              [build executables which only call Evolution via dlopen/dlsym: this avoids all hard dependencies on EDS shared objects, but might lead to crashes when their ABI changes]),
70               enable_evolution_compatibility="$enableval", enable_evolution_compatibility="no")
71
72 # Maemo hacks:
73 # - set the (non-standard!) DBUS_DEFAULT_TIMEOUT
74 # - wrap e_book_from_string() to fix invalid parameter
75 # - don't use UTF-8 encoding in Perl script
76 AC_ARG_ENABLE(maemo,
77               AS_HELP_STRING([--enable-maemo],
78                              [enables some hacks which work around problems with the Maemo 2.0 until at least 3.0 EDS-Dbus]),
79               [AC_DEFINE(ENABLE_MAEMO, 1, [enable Maemo hacks])
80                DEVICE_TYPE=Maemo
81                MODIFY_SYNCCOMPARE='-e "s/use encoding/#use encoding/;" -e "s/:utf8//;"'])
82 AC_SUBST(MODIFY_SYNCCOMPARE)
83
84 AC_CHECK_HEADERS(signal.h dlfcn.h)
85
86 # cppunit needed?
87 if test $enable_unit_tests == "yes" || test $enable_integration_tests == yes; then
88         CPPUNIT_CXXFLAGS=`cppunit-config --cflags` || AC_MSG_ERROR("cppunit-config --cflags failed - is it installed?")
89         CPPUNIT_LDFLAGS=`cppunit-config --libs` || AC_MSG_ERROR("cppunit-config --libs failed - is it installed?")
90 fi
91 AC_SUBST(CPPUNIT_CXXFLAGS)
92 AC_SUBST(CPPUNIT_LDFLAGS)
93
94 if test "$enable_unit_tests" = "yes"; then
95         AC_DEFINE(ENABLE_UNIT_TESTS, 1, [enable unit tests inside the library's source code])
96 fi
97 AM_CONDITIONAL([ENABLE_UNIT_TESTS], [test "$enable_unit_tests" = "yes"])
98 AM_CONDITIONAL([ENABLE_TESTING], [test "$enable_unit_tests" = "yes" || test "$enable_integration_tests" = "yes" ])
99
100 if test $enable_static_cxx == "yes"; then
101         LIBS="$LIBS -L."
102         CORE_LDADD_DEP=libstdc++.a
103 fi
104 AC_SUBST(CORE_LDADD_DEP)
105
106 # preserve src/synthesis by default,
107 # always
108 CLEAN_SYNTHESIS_SRC=
109 SYNTHESIS_LIB=$PWD/src/build-synthesis/src/libsynthesissdk.la
110
111 AC_SUBST(CLEAN_CLIENT_SRC)
112
113 # Check for transport layer.
114 # Both curl and libsoup can be enabled and disabled explicitly.
115 # The default is to use libsoup if available, otherwise curl.
116
117 AC_MSG_CHECKING([for libcurl])
118 if LIBCURL_LIBS=`sh -c 'curl-config --libs' 2>&AS_MESSAGE_LOG_FD` && \
119     LIBCURL_CFLAGS=`sh -c 'curl-config --cflags' 2>&AS_MESSAGE_LOG_FD`; then
120     AC_MSG_RESULT([yes])
121     have_libcurl="yes"
122 else
123     AC_MSG_RESULT([no])
124     have_libcurl="no"
125 fi
126 PKG_CHECK_MODULES(LIBSOUP, libsoup-gnome-2.4,
127                   [have_libsoup="yes"
128                    AC_DEFINE(HAVE_LIBSOUP_SOUP_GNOME_FEATURES_H, 1, [enable GNOME specific libsoup])],
129                   [PKG_CHECK_MODULES(LIBSOUP, libsoup-2.4,
130                                      have_libsoup="yes",
131                                      have_libsoup="no")])
132 TRANSPORT=
133 TRANSPORT_LIBS=
134 TRANSPORT_CFLAGS=
135
136 AC_ARG_WITH(ca-certificates,
137             AS_HELP_STRING([--with-ca-certificates=<colon separated list of files>],
138                            [Specifies location of one or more CA certificate files.
139                            This sets the default value for the SSLServerCertificates option.
140                            Default: empty when using libcurl (because it has its own default),
141                            a list of paths known to work for Debian and Red Hat otherwise.]),
142             [CA_CERTIFICATES="$withval"])
143
144
145 # choose default transport (mirrors code in EvolutionSyncClient::createTransportAgent())
146 if test "$have_libsoup" = "yes"; then
147    default_transport="libsoup"
148 elif test "$have_libcurl" = "yes"; then
149    default_transport="libcurl"
150 fi
151
152 AC_ARG_ENABLE(libcurl,
153               AC_HELP_STRING([--enable-libcurl],
154                              [enable libcurl as transport layer]),
155               [ if test "$enableval" = "yes"; then
156                    test "$have_libcurl" = "yes" || AC_MSG_ERROR([libcurl not found])
157                    TRANSPORT="$TRANSPORT libcurl"
158                    TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBCURL_LIBS"
159                    TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBCURL_CFLAGS"
160                    AC_DEFINE(ENABLE_LIBCURL, 1, [enable libcurl transport])
161                 else
162                    libcurl_disabled="yes"
163                 fi ],
164               [ if test "$have_libcurl" = "yes" && test "$default_transport" = "libcurl" ; then
165                    TRANSPORT="$TRANSPORT libcurl"
166                    TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBCURL_LIBS"
167                    TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBCURL_CFLAGS"
168                    AC_DEFINE(ENABLE_LIBCURL, 1, [enable libcurl transport])
169                 fi ])
170
171 AC_ARG_ENABLE(libsoup,
172               AC_HELP_STRING([--enable-libsoup],
173                              [enable libsoup as transport layer]),
174               [ if test "$enableval" = "yes"; then
175                    test "$have_libsoup" = "yes" || AC_MSG_ERROR([libsoup not found])
176                    TRANSPORT="$TRANSPORT libsoup"
177                    TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBSOUP_LIBS"
178                    TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBSOUP_CFLAGS"
179                    AC_DEFINE(ENABLE_LIBSOUP, 1, [enable libsoup transport])
180                 else
181                    libsoup_disabled="yes"
182                 fi ],
183               [ if test "$have_libsoup" = "yes" && test "$default_transport" = "libsoup"; then
184                    TRANSPORT="$TRANSPORT libsoup"
185                    TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBSOUP_LIBS"
186                    TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBSOUP_CFLAGS"
187                    AC_DEFINE(ENABLE_LIBSOUP, 1, [enable libsoup transport])
188                 fi ])
189
190 if test ! "$TRANSPORT" &&
191    test "$libsoup_disabled" != "yes" &&
192    test "$libcurl_disabled" != "yes"; then
193    AC_ERROR([no transport library found, configure with --disable-libcurl --disable-libsoup to continue anyway (only useful if users of libsyncevolution provide transport implementation)])
194 fi
195
196 # for libsoup we must specify the SSL certificate file outself
197 if test "$libsoup_disabled" != "yes" && test -z "$CA_CERTIFICATES"; then
198    # Debian and Red Hat paths
199    CA_CERTIFICATES="/etc/ssl/certs/ca-certificates.crt:/etc/pki/tls/certs/ca-bundle.crt:/usr/share/ssl/certs/ca-bundle.crt"
200 fi
201 AC_DEFINE_UNQUOTED(SYNCEVOLUTION_SSL_SERVER_CERTIFICATES, "$CA_CERTIFICATES", [default value for SSLServerCertificates option])
202
203 AC_SUBST(TRANSPORT_LIBS)
204 AC_SUBST(TRANSPORT_CFLAGS)
205
206 # for dbus interface file mangling
207 AC_PATH_PROG(XSLT, xsltproc)
208
209 AC_ARG_ENABLE(gui,
210               AS_HELP_STRING([--enable-gui[=gui type]],
211                              [enables building the GTK+ UI that uses the SyncEvolution DBus API.
212                               Options: gtk, moblin, all (builds sync-ui-gtk and sync-ui-moblin)
213                               "gtk" is the default for --enable-gui without type. No GUI is
214                               built when --enable-gui is not used.
215                               --enable-gui implies --enable-dbus.]),
216               [ if test "$enableval" = "gtk" ; then
217                     enable_gui=gtk
218                 elif test "$enableval" = "yes" ; then
219                     enable_gui=gtk
220                 elif test "$enableval" = "moblin" ; then
221                     enable_gui=moblin
222                 elif test "$enableval" = "no" ; then
223                     enable_gui=no
224                 elif test "$enableval" = "all" ; then
225                     enable_gui=all
226                 else
227                     AC_ERROR([Unknown gui type: '$enableval'])
228                 fi
229               ],
230               [ enable_gui=no ])
231
232 AM_CONDITIONAL([COND_GUI], [test "$enable_gui" != "no"])
233
234 if test $enable_gui == "moblin"; then
235     AC_DEFINE(USE_MOBLIN_UX, 1, [Use the MUX widget library])
236 fi
237
238 AC_ARG_ENABLE(dbus-service,
239               AS_HELP_STRING([--enable-dbus-service],
240                              [enables building the dbus service executable and the wrapper library for it]),
241               enable_dbus_service="$enableval",
242               [if test $enable_gui == "no"; then
243                   enable_dbus_service="no"
244                else
245                   enable_dbus_service="yes"
246                fi])
247 AM_CONDITIONAL([COND_DBUS], [test "$enable_dbus_service" = "yes"])
248
249 if test $enable_gui != "no" && test $enable_dbus_service == "no"; then
250    AC_ERROR([cannot build GUI without building the D-Bus service])
251 fi
252
253 if test $enable_dbus_service == "yes"; then
254     PKG_CHECK_MODULES(KEYRING, [gnome-keyring-1], HAVE_KEYRING=yes, HAVE_KEYRING=no)
255     if test $HAVE_KEYRING == "yes"; then
256         AC_DEFINE(USE_GNOME_KEYRING, 1, [define if gnome keyring should be used in dbus service])
257     fi
258     PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1 glib-2.0)
259     AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool)
260     AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
261     if test -z "$XSLT"; then
262        AC_ERROR([xsltproc not found, is required for D-Bus service])
263     fi
264 fi
265 AC_SUBST(DBUS_GLIB_CFLAGS)
266 AC_SUBST(DBUS_GLIB_LIBS)
267 AC_SUBST(KEYRING_CFLAGS) 
268 AC_SUBST(KEYRING_LIBS) 
269 AC_SUBST(LIBEXECDIR)
270
271 DBUS_SERVICES_DIR="${datadir}/dbus-1/services"
272 AC_SUBST(DBUS_SERVICES_DIR)
273 AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [Location of D-Bus services directory])
274
275 # decide which sync-ui(s) we are building:
276 # sync-ui (in either GTK or Moblin mode) or both (in separate binaries)
277 case $enable_gui in
278      all) GUI_PROGRAMS='sync-ui-gtk${EXEEXT} sync-ui-moblin${EXEEXT}'; GUI_DESKTOP_FILES="sync-gtk.desktop sync-moblin.desktop";;
279      gtk|moblin) GUI_PROGRAMS='sync-ui${EXEEXT}'; GUI_DESKTOP_FILES="sync.desktop";;
280      no) GUI_PROGRAMS=; GUI_DESKTOP_FILES=;;
281      *) AC_ERROR([Unknown enable_gui type: '$enable_gui'])
282 esac
283
284 if test $enable_gui != "no"; then
285     gui_modules="glib-2.0 dbus-glib-1 >= 0.60 gtk+-2.0 libglade-2.0 gconf-2.0 gio-2.0 gnome-keyring-1"
286
287     PKG_CHECK_MODULES(UNIQUE, unique-1.0,
288                       have_unique="yes",
289                       have_unique="no")
290     if test $have_unique == "yes"; then
291         gui_modules="$gui_modules unique-1.0" 
292         AC_DEFINE(ENABLE_UNIQUE, 1, [enable single-app-instance functionality])
293     fi
294     PKG_CHECK_MODULES(GUI, $gui_modules)
295
296     AC_PATH_PROG([GTK_BUILDER_CONV], gtk-builder-convert)
297     IT_PROG_INTLTOOL([0.37.1])
298     GETTEXT_PACKAGE=syncevolution
299     AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The gettext package name])
300     AM_GLIB_GNU_GETTEXT
301     SYNCEVOLUTION_LOCALEDIR=[${datadir}/locale]
302 else
303     INTLTOOL_UPDATE="true"
304     USE_NLS="no"
305 fi
306 AC_SUBST(SYNCEVOLUTION_LOCALEDIR)
307 AC_SUBST(GETTEXT_PACKAGE)
308 AC_SUBST(GUI_CFLAGS)
309 AC_SUBST(GUI_LIBS)
310 AC_SUBST(GUI_PROGRAMS)
311 AC_SUBST(GUI_DESKTOP_FILES)
312
313
314 # Boost headers: boost/foreach.hpp is needed (1.33/Debian Etch
315 # doesn't have it, 1.34/Ubuntu 8.10 Hardy does). 1.35 is available
316 # as Debian Etch backport.
317 AX_BOOST_BASE(1.34)
318
319 # absolute patch to source of Synthesis client library
320 SYNTHESIS_SRC=no-synthesis-source
321 AC_SUBST(SYNTHESIS_SRC)
322 if test "$SYNTHESISSRC" && test "$SYNTHESISSRC" != "none"; then
323     # default: checkout a copy of the sources, remove it during maintainer-clean and distclean
324     CLEAN_CLIENT_SRC=synthesis-workdir
325     SYNTHESIS_SRC=$PWD/src/synthesis-workdir
326
327     AC_MSG_NOTICE( [updating the content of $SYNTHESIS_SRC from $SYNTHESISSRC] )
328     case "$SYNTHESISSRC" in
329         *.git) protocol=git;;
330         *://*) protocol="`echo $SYNTHESISSRC | sed -e 's;://.*;;'`";;
331         *) protocol="file";;
332     esac
333
334     mkdir -p src
335     case $protocol in
336         file)
337             # use existing copy of the sources
338             CLEAN_CLIENT_SRC=
339             case "$SYNTHESISSRC" in
340                  /*) SYNTHESIS_SRC="$SYNTHESISSRC";;
341                  *) SYNTHESIS_SRC="$PWD/$SYNTHESISSRC";;
342             esac
343             ;;
344         *svn*|*http*)
345             SYNTHESISSRCREV="$SYNTHESISSRC"
346             if test "$REVISION"; then
347                 revarg="-r $REVISION "
348                 if `echo $SYNTHESISSRC | grep '@[0123456789]*'` >/dev/null; then
349                     :
350                 else
351                     SYNTHESISSRCREV="$SYNTHESISSRC@$REVISION"
352                 fi
353             fi
354             if test -d $SYNTHESIS_SRC ; then
355                 ( set -x; cd $SYNTHESIS_SRC && svn --username=$USERNAME switch $revarg "$SYNTHESISSRC" ) || AC_ERROR([updating from $SYNTHESISSRC failed])
356             else
357                 (set -x; svn --username=$USERNAME checkout $revarg "$SYNTHESISSRCREV" $SYNTHESIS_SRC ) || AC_ERROR([checking out $SYNTHESISSRC failed])
358             fi
359             ;;
360         *)
361             if test -d $SYNTHESIS_SRC ; then
362                 ( set -x; cd $SYNTHESIS_SRC && git fetch "$SYNTHESISSRC" ) || AC_ERROR([updating from $SYNTHESISSRC failed])
363             else
364                 ( set -x; git clone "$SYNTHESISSRC" $SYNTHESIS_SRC ) || AC_ERROR([cloning $SYNTHESISSRC failed])
365             fi
366             if test "$REVISION"; then
367                 # git 1.6 finds tags and branches without explicit prefix, 1.4.4.4 doesn't
368                 ( set -x; cd $SYNTHESIS_SRC &&
369                   (git checkout "$REVISION" ||
370                    git checkout "tags/$REVISION" ||
371                    git checkout "origin/$REVISION") ) || AC_ERROR([checking out $SYNTHESISSRC failed])
372             fi
373             ;;
374     esac
375 elif test "$SYNTHESISSRC" != "none" && test -d $srcdir/src/synthesis; then
376     # use existing copy of the sources; beware of
377     # out-of-tree compilation
378     case $srcdir in
379          /*) SYNTHESIS_SRC="$srcdir/src/synthesis";;
380          *) SYNTHESIS_SRC="$PWD/$srcdir/src/synthesis";;
381     esac
382 else
383     PKG_CHECK_MODULES(SYNTHESIS, "synthesis")
384 fi
385
386 if test $SYNTHESIS_SRC != "no-synthesis-source"; then
387     ( cd $SYNTHESIS_SRC && ( test -f configure || sh autogen.sh ) ) || AC_MSG_ERROR([no configure script in $SYNTHESIS_SRC])
388
389     SYNTHESIS_CONFIGURE="$SYNTHESIS_SRC/configure"
390     chmod u+x $SYNTHESIS_SRC/configure $SYNTHESIS_SRC/config.sub $SYNTHESIS_SRC/config.guess
391
392     # use local copy of the sources, with dependencies
393     # to trigger building the synthesis library
394     SYNTHESIS_SUBDIR=$PWD/src/build-synthesis
395     SYNTHESIS_DEP=$PWD/src/build-synthesis/src/libsynthesissdk.la
396
397     SYNTHESIS_CFLAGS="-I$SYNTHESIS_SUBDIR/src"
398     SYNTHESIS_LIBS="-L$SYNTHESIS_SUBDIR/src -lsynthesissdk -lsynthesis"
399
400     AC_MSG_NOTICE( [configuring the Synthesis library] )
401     if (set -x; mkdir -p $SYNTHESIS_SUBDIR && cd $SYNTHESIS_SUBDIR && eval "\$SHELL \"\$SYNTHESIS_CONFIGURE\" $ac_configure_args \"--srcdir=\$SYNTHESIS_SRC\" " ); then true; else
402         AC_MSG_ERROR( [configuring Synthesis library failed] )
403     fi
404 fi
405
406 AC_SUBST(SYNTHESIS_CFLAGS)
407 AC_SUBST(SYNTHESIS_LIBS)
408 AC_SUBST(SYNTHESIS)
409 AC_SUBST(SYNTHESIS_SUBDIR)
410 AC_SUBST(SYNTHESIS_DEP)
411 AC_SUBST(SYNTHESIS_LIB)
412 AC_SUBST(SYNTHESISSRC)
413
414 dnl select backends
415 BACKENDS=""
416
417 # AC_ARG_ENABLE_BACKEND(BACKEND, DIR, HELP-STRING, [ACTION-IF-GIVEN],
418 #                       [ACTION-IF-NOT-GIVEN])
419 #
420 # Same as AC_ARG_ENABLE(), but also tells configure that the
421 # backend exists.
422 #
423 # BACKEND = name of modules built in that dir as .la files without the
424 #           obligatory sync prefix, e.g. "ebook"
425 # DIR = name of the directory inside src/backends, e.g., "evolution"
426 AC_DEFUN([AC_ARG_ENABLE_BACKEND],
427 [
428         AC_ARG_ENABLE($1, $3, $4, $5)
429         BACKENDS="$BACKENDS $1"
430         BACKEND_DEFINES="$BACKEND_DEFINES ENABLE_`echo $1 | tr a-z A-Z`"
431         for source in $2; do
432             SYNCSOURCES="$SYNCSOURCES backends/$2/sync$1.la"
433         done
434 ])
435 AC_SUBST(SYNCSOURCES)
436 AC_SUBST(BACKEND_DEFINES)
437
438 BACKEND_CPPFLAGS="$SYNTHESIS_CFLAGS $EPACKAGE_CFLAGS $EBOOK_CFLAGS $ECAL_CFLAGS $GLIB_CFLAGS"
439 AC_SUBST(BACKEND_CPPFLAGS)
440
441 dnl src/backends/*/configure-sub.in and configure-post.in follow
442 # vvvvvvvvvvvvvv src/backends/addressbook/configure-sub.in vvvvvvvvvvvvvv
443 dnl -*- mode: Autoconf; -*-
444 dnl Invoke autogen.sh to produce a configure script.
445
446 dnl hard-coded settings for Mac OS X AddressBook
447 ADDRESSBOOK_CFLAGS=
448
449 ADDRESSBOOK_LIBS="-framework AddressBook -framework CoreFoundation"
450 AC_SUBST(ADDRESSBOOK_CFLAGS)
451 AC_SUBST(ADDRESSBOOK_LIBS)
452 BACKEND_CPPFLAGS="$BACKEND_CPPFLAGS $ADDRESSBOOK_CFLAGS"
453
454 AC_ARG_ENABLE_BACKEND(addressbook, addressbook,
455                       AS_HELP_STRING([--enable-addressbook], [enable access to Mac OS X address book (default off)]),
456                       [enable_addressbook="$enableval"], [enable_addressbook="no"])
457
458 if test "$enable_addressbook" = "yes"; then
459         AC_DEFINE(ENABLE_ADDRESSBOOK, 1, [addressbook available])
460         DEVICE_TYPE=MacOS_X
461         enable_any="yes"
462 else
463         ADDRESSBOOK_LIBS=
464 fi
465
466 AC_CONFIG_FILES(src/backends/addressbook/Makefile)
467 # ^^^^^^^^^^^^^^ src/backends/addressbook/configure-sub.in ^^^^^^^^^^^^^^
468
469 # vvvvvvvvvvvvvv src/backends/evolution/configure-sub.in vvvvvvvvvvvvvv
470 dnl -*- mode: Autoconf; -*-
471 dnl Invoke autogen.sh to produce a configure script.
472
473 pkg_emodules_10="libedataserver-1.0"
474 pkg_emodules_11="libedataserver-1.1"
475 pkg_emodules_12="libedataserver-1.2"
476 pkg_ebook_10="libebook-1.0"
477 pkg_ebook_11="libebook-1.1"
478 pkg_ebook_12="libebook-1.2"
479 pkg_ecal_10="libecal-1.0"
480 pkg_ecal_11="libecal-1.1"
481 pkg_ecal_12="libecal-1.2"
482
483 anymissing="
484 Please install the development packages of Evolution and/or
485 set the PKG_CONFIG_PATH variable so that it points towards
486 the .pc files of libedataserver, libecal and libebook (the
487 latter two are optional).
488
489 You can check that these packages are available by running
490 pkg-config --list-all."
491
492 evomissing="No compatible evolution-data-server was found.
493 $anymissing"
494
495 dnl check for Evolution core packages
496 PKG_CHECK_MODULES(EPACKAGE, [$pkg_emodules_12], EDSFOUND=yes, [EDSFOUND=no])
497 if test "x${EDSFOUND}" = "xno"; then
498       PKG_CHECK_MODULES(EPACKAGE, [$pkg_emodules_11], EDSFOUND=yes, [EDSFOUND=no])
499       if test "x${EDSFOUND}" = "xno"; then
500               PKG_CHECK_MODULES(EPACKAGE, [$pkg_emodules_10], EDSFOUND=yes, [EDSFOUND=no])
501       fi
502 fi
503 AC_SUBST(EPACKAGE_CFLAGS)
504 AC_SUBST(EPACKAGE_LIBS)
505 BACKEND_CPPFLAGS="$BACKEND_CPPFLAGS $EPACKAGE_CFLAGS"
506
507 dnl check for Evolution calendar packages
508 PKG_CHECK_MODULES(ECAL, [$pkg_ecal_12], ECALFOUND=yes, [ECALFOUND=no])
509 if test "x${ECALFOUND}" = "xno"; then
510         PKG_CHECK_MODULES(ECAL, [$pkg_ecal_11], ECALFOUND=yes, [ECALFOUND=no])
511         if test "x${ECALFOUND}" = "xno"; then
512                 PKG_CHECK_MODULES(ECAL, [$pkg_ecal_10], ECALFOUND=yes, [ECALFOUND=no])
513         fi
514 fi
515 AC_SUBST(ECAL_CFLAGS)
516 AC_SUBST(ECAL_LIBS)
517 BACKEND_CPPFLAGS="$BACKEND_CPPFLAGS $ECAL_CFLAGS"
518
519 dnl check for Evolution contact packages
520 PKG_CHECK_MODULES(EBOOK, [$pkg_ebook_12], EBOOKFOUND=yes, [EBOOKFOUND=no])
521 if test "x${EBOOKFOUND}" = "xno"; then
522         PKG_CHECK_MODULES(EBOOK, [$pkg_ebook_11], EBOOKFOUND=yes, [EBOOKFOUND=no])
523         if test "x${EBOOKFOUND}" = "xno"; then
524                 PKG_CHECK_MODULES(EBOOK, [$pkg_ebook_10], EBOOKFOUND=yes, [EBOOKFOUND=no])
525         fi
526 fi
527 AC_SUBST(EBOOK_CFLAGS)
528 AC_SUBST(EBOOK_LIBS)
529 BACKEND_CPPFLAGS="$BACKEND_CPPFLAGS $EBOOK_CFLAGS"
530
531 AC_ARG_ENABLE_BACKEND(ebook, evolution,
532                       AS_HELP_STRING([--disable-ebook], [disable access to Evolution addressbooks (must be used to compile without it)]),
533                       [enable_ebook="$enableval"],
534                       [test "$EBOOKFOUND" = "yes" && enable_ebook="yes" ||
535                        AC_MSG_ERROR([libebook not found. Use --disable-ebook to compile without or install the necessary development files.])])
536 AC_ARG_ENABLE_BACKEND(ecal, evolution,
537                       AS_HELP_STRING([--disable-ecal], [disable access to Evolution calendars and tasks (must be used to compile without it)]),
538                       [enable_ecal="$enableval"],
539                       [test "$ECALFOUND" = "yes" && enable_ecal="yes" ||
540                        AC_MSG_ERROR([libecal not found. Use --disable-ecal to compile without or install the necessary development files.])])
541
542 enable_evo="no"
543 if test "$enable_ebook" = "yes"; then
544         test "x${EBOOKFOUND}" == "xyes" || AC_MSG_ERROR([--enable-ebook requires pkg-config information for libebook, which was not found])
545         AC_DEFINE(ENABLE_EBOOK, 1, [libebook available])
546         enable_evo="yes"
547 fi
548
549 AM_CONDITIONAL([ENABLE_ECAL], [test "$enable_ecal" == "yes"])
550 if test "$enable_ecal" = "yes"; then
551         test "x${ECALFOUND}" == "xyes" || AC_MSG_ERROR([--enable-ecal requires pkg-config information for libecal, which was not found"])
552         AC_DEFINE(ENABLE_ECAL, 1, [libecal available])
553         enable_evo="yes"
554 fi
555
556 need_glib="yes"
557
558 if test "$enable_evo" = "yes"; then
559         if test "$EDSFOUND" = "yes"; then
560                 AC_DEFINE(HAVE_EDS, 1, [evolution-dataserver available])
561         else
562                 AC_MSG_ERROR($evomissing)
563         fi
564 else
565         EPACKAGE_CFLAGS=
566         EPACKAGE_LIBS=
567 fi
568 AC_CONFIG_FILES(src/backends/evolution/Makefile)
569 # ^^^^^^^^^^^^^^ src/backends/evolution/configure-sub.in ^^^^^^^^^^^^^^
570
571 # vvvvvvvvvvvvvv src/backends/file/configure-sub.in vvvvvvvvvvvvvv
572 dnl -*- mode: Autoconf; -*-
573 dnl Invoke autogen.sh to produce a configure script.
574
575 dnl Checks for required libraris can go here; none required for simple files.
576 dnl
577 dnl This is from the sqlite backend:
578 dnl PKG_CHECK_MODULES(SQLITE, sqlite3, SQLITEFOUND=yes, [SQLITEFOUND=no])
579 dnl AC_SUBST(SQLITE_CFLAGS)
580 dnl AC_SUBST(SQLITE_LIBS)
581
582 FILE_CFLAGS=
583 FILE_LIBS=
584 AC_SUBST(FILE_CFLAGS)
585 AC_SUBST(FILE_LIBS)
586
587 dnl If additional compile flags are necessary to include the header
588 dnl files of the backend, then add them here.
589 BACKEND_CPPFLAGS="$BACKEND_CPPFLAGS $FILE_CFLAGS"
590
591 dnl name of backend library (there could be more than one per directory),
592 dnl name of the directory,
593 dnl help string,
594 dnl --enable/disable chosen explicitly
595 dnl default, may depend on availability of prerequisites in more complex backends
596 AC_ARG_ENABLE_BACKEND(file,
597                       file,
598                       AS_HELP_STRING([--disable-file],
599                                      [disable file-based backend which stores items in separate files in a fixed directory (default on)]),
600                       [enable_file="$enableval"],
601                       [enable_file="yes"]
602                       )
603
604 if test "$enable_file" = "yes"; then
605         dnl It's good to check the prerequisites here, in case --enable-file was used.
606         dnl test "x${SQLITEFOUND}" == "xyes" || AC_MSG_ERROR([--enable-sqlite requires pkg-config information for sqlite3, which was not found])
607         AC_DEFINE(ENABLE_FILE, 1, [file available])
608 fi
609 AC_CONFIG_FILES(src/backends/file/Makefile)
610 # ^^^^^^^^^^^^^^ src/backends/file/configure-sub.in ^^^^^^^^^^^^^^
611
612 # vvvvvvvvvvvvvv src/backends/sqlite/configure-sub.in vvvvvvvvvvvvvv
613 dnl -*- mode: Autoconf; -*-
614 dnl Invoke autogen.sh to produce a configure script.
615
616 dnl check for sqlite
617 PKG_CHECK_MODULES(SQLITE, sqlite3, SQLITEFOUND=yes, [SQLITEFOUND=no])
618 AC_SUBST(SQLITE_CFLAGS)
619 AC_SUBST(SQLITE_LIBS)
620 BACKEND_CPPFLAGS="$BACKEND_CPPFLAGS $SQLITE_CFLAGS"
621
622 AC_ARG_ENABLE_BACKEND(sqlite, sqlite,
623                       AS_HELP_STRING([--enable-sqlite], [enable access to PIM data stored in SQLite files (experimental, default off)]),
624                       [enable_sqlite="$enableval"], [enable_sqlite="no"])
625
626 if test "$enable_sqlite" = "yes"; then
627         test "x${SQLITEFOUND}" == "xyes" || AC_MSG_ERROR([--enable-sqlite requires pkg-config information for sqlite3, which was not found])
628         AC_DEFINE(ENABLE_SQLITE, 1, [sqlite available])
629 else
630         # avoid linking against it if not needed
631         SQLITE_CFLAGS=
632         SQLITE_LIBS=
633 fi
634 AC_CONFIG_FILES(src/backends/sqlite/Makefile)
635 # ^^^^^^^^^^^^^^ src/backends/sqlite/configure-sub.in ^^^^^^^^^^^^^^
636
637 dnl -*- mode: Autoconf; -*-
638 dnl Invoke autogen.sh to produce a configure script.
639 dnl configure-pre.in and src/backends/*/configure-sub.in and configure-post.in come before this part
640
641 AC_SUBST(BACKEND_CPPFLAGS)
642
643 enable_any="no"
644 backend_is_enabled () {
645     eval echo \${enable_${1}}
646 }
647 for backend in $BACKENDS; do
648     if test `backend_is_enabled $backend` == "yes"; then
649        enable_any="yes"
650        SYNCEVOLUTION_MODULES="$SYNCEVOLUTION_MODULES src/backends/sync${backend}.la"
651     fi
652 done
653
654 if test "$enable_any" = "no"; then
655         AC_MSG_ERROR([no backend enabled - refusing to continue: $anymissing])
656 fi
657
658 dnl check for glib - calling g_type_init() is expected on Maemo
659 PKG_CHECK_MODULES(GLIB, "glib-2.0", GLIBFOUND=yes, GLIBFOUND=no)
660 # This check here is broken on Ubuntu 8.04: it calls glib-config,
661 # which isn't found, but the error is not detected by configure.
662 #if test "x${GLIBFOUND}" = "xno"; then
663 #       PKG_CHECK_MODULES(GLIB, "glib", GLIBFOUND=yes, GLIBFOUND=no)
664 #fi
665 AC_SUBST(GLIB_CFLAGS)
666 AC_SUBST(GLIB_LIBS)
667
668 dnl check for programs.
669 AC_PROG_CXX
670 AC_PROG_LIBTOOL
671 AC_PROG_MAKE_SET
672
673 dnl glib initialization is done only if requested by some configure-sub.in,
674 dnl for not needed otherwise even if found
675 if test "$need_glib" != "yes"; then
676         GLIB_CFLAGS=
677         GLIB_LIBS=
678 else
679         if  test "x${GLIBFOUND}" = "xyes"; then
680             AC_DEFINE(HAVE_GLIB, 1, [glib found])
681         fi
682         BACKEND_CPPFLAGS="$BACKEND_CPPFLAGS $GLIB_CFLAGS"
683 fi
684
685 dnl figure out whether we link all code statically or as modules
686 AM_CONDITIONAL([ENABLE_MODULES], [test "$enable_shared" == "yes"])
687 if test "$enable_shared" == "yes"; then
688         AC_DEFINE(ENABLE_MODULES, 1, [enable dynamically opening sync source backends])
689 fi
690 AC_SUBST(SYNCEVOLUTION_LDADD)
691
692 dnl CXXFLAGS gets applied to SyncEvolution and the client library.
693 dnl For e.g. "-Wall -Werror" this might not be such a good idea;
694 dnl SYNCEVOLUTION_CXXFLAGS can be used instead. It applies only
695 dnl to the sources in the SyncEvolution repository.
696 AC_SUBST(SYNCEVOLUTION_CXXFLAGS)
697
698 dnl a quick-and-dirty way to detect compilation for the iPhone
699 if test "$host" == "arm-apple-darwin"; then
700    AC_DEFINE(IPHONE, 1, [compiling for iPhone])
701    DEVICE_TYPE=iPhone
702 fi
703
704 dnl --enable-evolution-compatibility
705 if test "$enable_evolution_compatibility" == "yes"; then
706    AC_DEFINE(EVOLUTION_COMPATIBILITY, 1, [avoid hard dependency on Evolution shared objects])
707 fi
708
709 dnl This string is sent as part of the SyncML DevInf (device
710 dnl information) structure to the server. All SyncEvolution platforms
711 dnl use "SyncEvolution" as HTTP user agent and "Mod" (model), so the
712 dnl device type is the only way how different kinds of clients can be
713 dnl distinguished.
714 AC_DEFINE_UNQUOTED(DEVICE_TYPE, "$DEVICE_TYPE", "SyncML DevInf DevType")
715
716 AC_CHECK_HEADERS(stdarg.h valgrind/valgrind.h execinfo.h)
717
718 AC_DEFINE(SYNTHESIS, 1, "using Synthesis engine")
719
720 AC_CONFIG_FILES(Makefile src/dbus/interfaces/Makefile src/dbus/Makefile src/Makefile src/core/Makefile src/gtk-ui/Makefile po/Makefile.in test/Makefile src/dbus/syncevo-dbus.pc)
721 AC_OUTPUT
722
723 echo
724 echo CONFIGURATION SUMMARY
725 for backend in $BACKENDS; do
726     eval echo $backend: \${enable_${backend}}
727 done
728 echo "DBus service: $enable_dbus_service"
729 echo "UI (DBus client): $enable_gui"
730 echo