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