0cbdd3d9456bdb29a6feba1328258fbffa9b7e0b
[platform/upstream/syncevolution.git] / configure-pre.in
1 dnl -*- mode: Autoconf; -*-
2 dnl Invoke autogen.sh to produce a configure script.
3
4 # The STABLE_VERSION is used when building
5 # Debian packages. For prereleases (beta, alpha),
6 # set it to something like "0.9.2+" and the AC_INIT
7 # VERSION to 1.0beta1 to produce 0.9.2+1.0beta1.
8 #
9 # Starting with the 1.1 release cycle, the rpm-style
10 # .99 pseudo-version number is used to mark a pre-release.
11 AC_INIT([syncevolution], [1.0.99.7])
12 # STABLE_VERSION=1.0.1+
13 AC_SUBST(STABLE_VERSION)
14
15 AM_INIT_AUTOMAKE([tar-ustar])
16 AC_CONFIG_MACRO_DIR([m4])
17 define([SYNTHESISSRC_REPO], [])
18 dnl Specify git revisions/branches without prefix, i.e., without 'origin'.
19 dnl We'll sort that out below.
20 define([SYNTHESISSRC_REVISION], [syncevolution-0.9])
21 AM_CONFIG_HEADER(config.h)
22 AC_LIBTOOL_DLOPEN
23
24 dnl default device type (see AC_DEFINE below)
25 DEVICE_TYPE=workstation
26
27 AC_ARG_WITH(synthesis-src,
28             AS_HELP_STRING([--with-synthesis-src=<base directory|svn URL|git URL>],
29                            [Specifies location of the Synthesis root directory.
30                            Use this when the Synthesis library is to
31                            be compiled as part of the SyncEvolution compilation. In release
32                            versions of SyncEvolution, a copy of the Synthesis code is bundled
33                            under 'src/synthesis' and compiled unless something else is
34                            specified. --with-synthesis-src can be given a path to sources
35                            checked out already, a Subversion repository URL or a git repository
36                            URL. When given a repository URL, then the configure script
37                            will checkout the sources into 'src/synthesis-workdir' or
38                            update that working copy if the directory already exists.
39                            Default: bundled source in src/synthesis (in released SyncEvolution sources),
40                            SYNTHESISSRC_REPO otherwise.]),
41             [SYNTHESISSRC="$withval"
42              test "$SYNTHESISSRC" != "yes" || AC_MSG_ERROR([--with-synthesis-src requires a parameter (base directory, svn URL or git URL)])],
43             [SYNTHESISSRC="$SYNTHESISSRC_DEF"; REVISION="SYNTHESISSRC_REVISION"])
44
45 AC_ARG_WITH(syncml-engines,
46             AS_HELP_STRING([--with-syncml-engines=client|server|both],
47                            [Determines which kind of support for SyncML is compiled and linked into SyncEvolution. Default is both. Currently has no effect.]),
48             [SYNCML_ENGINES="$withval"], SYNCML_ENGINES=both)
49
50 case $SYNCML_ENGINES in both|client) AC_DEFINE(ENABLE_SYNCML_CLIENT, 1, [SyncML client support available]);; esac
51 case $SYNCML_ENGINES in both|server) AC_DEFINE(ENABLE_SYNCML_SERVER, 1, [SyncML server support available]);; esac
52 case $SYNCML_ENGINES in both|server|client) true;; *) AC_ERROR([Invalid value for --with-syncml-engines: $SYNCML_ENGINES]);; esac
53
54 AC_ARG_WITH(synthesis-username,
55             AS_HELP_STRING([--with-synthesis-username=<svn username>],
56                            [username to use when checking out --with-synthesis-src sources from Subversion, default 'guest']),
57             [USERNAME="$withval"], [USERNAME="guest"])
58
59 AC_ARG_WITH(synthesis-revision,
60             AS_HELP_STRING([--with-synthesis-revision=<git tag/branch/hash or Subversion revision>],
61                            [Identifies which source revision to use from --with-synthesis-src repository, empty string stands for latest. Default for default --synthesis-src: SYNTHESISSRC_REVISION]),
62             [REVISION="$withval"])
63
64 AC_ARG_ENABLE(shared,
65               AS_HELP_STRING([--enable-shared],
66                              [build backends as dynamically loadable modules]),
67               enable_shared="$enableval", enable_shared="no")
68
69 AC_ARG_ENABLE(static,
70               AS_HELP_STRING([--enable-static],
71                              [build backends also as static libraries]),
72               enable_static="$enableval", enable_static="no")
73
74 AC_ARG_ENABLE(unit-tests,
75               AS_HELP_STRING([--enable-unit-tests],
76                              [enables tests embedded in the source code of the library (changes content of executable)]),
77               enable_unit_tests="$enableval", enable_unit_tests="no")
78 AC_ARG_ENABLE(integration-tests,
79               AS_HELP_STRING([--enable-integration-tests],
80                              [enables tests outside of the library (can be used together with normal builds of the library)]),
81               enable_integration_tests="$enableval", enable_integration_tests="no")
82
83 AC_ARG_ENABLE(static-cxx,
84               AS_HELP_STRING([--enable-static-cxx],
85                              [build executables which contain libstdc++ instead of requiring suitable libstdc++.so to run]),
86               enable_static_cxx="$enableval", enable_static_cxx="no")
87
88 AC_ARG_ENABLE(evolution-compatibility,
89               AS_HELP_STRING([--enable-evolution-compatibility],
90                              [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]),
91               enable_evolution_compatibility="$enableval", enable_evolution_compatibility="no")
92
93 AC_ARG_ENABLE(developer-mode, 
94              AC_HELP_STRING([--enable-developer-mode], 
95                             [The dynamic loadble backend libraries is loaded from current build directory instead of the standard library path]),
96              enable_developer_mode="$enableval", enable_developer_mode="no")
97
98 # Maemo hacks:
99 # - wrap e_book_from_string() to fix invalid parameter
100 # - don't use UTF-8 encoding in Perl script
101 AC_ARG_ENABLE(maemo,
102               AS_HELP_STRING([--enable-maemo],
103                              [enables some hacks which work around problems with the Maemo 2.0 until at least 3.0 EDS-Dbus]),
104               [AC_DEFINE(ENABLE_MAEMO, 1, [enable Maemo hacks])
105                DEVICE_TYPE=Maemo
106                MODIFY_SYNCCOMPARE='-e "s/use encoding/#use encoding/;" -e "s/:utf8//;"'])
107 AC_SUBST(MODIFY_SYNCCOMPARE)
108
109 AC_CHECK_HEADERS(signal.h dlfcn.h)
110
111 # cppunit needed?
112 if test $enable_unit_tests == "yes" || test $enable_integration_tests == yes; then
113         CPPUNIT_CXXFLAGS=`cppunit-config --cflags` || AC_MSG_ERROR("cppunit-config --cflags failed - is it installed?")
114         CPPUNIT_LDFLAGS=`cppunit-config --libs` || AC_MSG_ERROR("cppunit-config --libs failed - is it installed?")
115 fi
116 AC_SUBST(CPPUNIT_CXXFLAGS)
117 AC_SUBST(CPPUNIT_LDFLAGS)
118
119 if test "$enable_unit_tests" = "yes"; then
120         AC_DEFINE(ENABLE_UNIT_TESTS, 1, [enable unit tests inside the library's source code])
121 fi
122 if test "$enable_integration_tests" = "yes"; then
123         AC_DEFINE(ENABLE_INTEGRATION_TESTS, 1, [enable integration tests inside the final library])
124 fi
125 AM_CONDITIONAL([ENABLE_UNIT_TESTS], [test "$enable_unit_tests" = "yes"])
126 AM_CONDITIONAL([ENABLE_TESTING], [test "$enable_unit_tests" = "yes" || test "$enable_integration_tests" = "yes" ])
127
128 if test $enable_static_cxx == "yes"; then
129         LIBS="$LIBS -L."
130         CORE_LDADD_DEP=libstdc++.a
131 fi
132 AC_SUBST(CORE_LDADD_DEP)
133
134 # Check for transport layer.
135 # Both curl and libsoup can be enabled and disabled explicitly.
136 # The default is to use libsoup if available, otherwise curl.
137
138 AC_MSG_CHECKING([for libcurl])
139 if LIBCURL_LIBS=`sh -c 'curl-config --libs' 2>&AS_MESSAGE_LOG_FD` && \
140     LIBCURL_CFLAGS=`sh -c 'curl-config --cflags' 2>&AS_MESSAGE_LOG_FD`; then
141     AC_MSG_RESULT([yes])
142     have_libcurl="yes"
143 else
144     AC_MSG_RESULT([no])
145     have_libcurl="no"
146 fi
147
148 PKG_CHECK_MODULES(LIBSOUP, libsoup-gnome-2.4,
149                   [have_libsoup="yes"
150                    AC_DEFINE(HAVE_LIBSOUP_SOUP_GNOME_FEATURES_H, 1, [enable GNOME specific libsoup])],
151                   [PKG_CHECK_MODULES(LIBSOUP, libsoup-2.4,
152                                      have_libsoup="yes",
153                                      have_libsoup="no")])
154
155 PKG_CHECK_MODULES(LIBOPENOBEX, openobex, have_obex="yes", have_obex="no")
156 have_bluetooth="no"
157 if test $have_obex = "yes"; then
158     PKG_CHECK_MODULES(BLUEZ, bluez, have_bluez="yes", have_bluez="no")
159     if test $have_bluez = "yes"; then
160         have_bluetooth="yes"
161     fi
162 fi
163 AC_SUBST(LIBOPENOBEX_CFLAGS)
164 AC_SUBST(LIBOPENOBEX_LIBS)
165 AC_SUBST(BLUEZ_CFLAGS)
166 AC_SUBST(BLUEZ_LIBS)
167
168 TRANSPORT=
169 TRANSPORT_LIBS=
170 TRANSPORT_CFLAGS=
171
172 AC_ARG_WITH(ca-certificates,
173             AS_HELP_STRING([--with-ca-certificates=<colon separated list of files>],
174                            [Specifies location of one or more CA certificate files.
175                            This sets the default value for the SSLServerCertificates option.
176                            Default: empty when using libcurl (because it has its own default),
177                            a list of paths known to work for Debian and Red Hat otherwise.]),
178             [CA_CERTIFICATES="$withval"])
179
180
181 # choose default http transport (mirrors code in EvolutionSyncClient::createTransportAgent())
182 if test "$have_libsoup" = "yes"; then
183    default_http_transport="libsoup"
184 elif test "$have_libcurl" = "yes"; then
185    default_http_transport="libcurl"
186 fi
187
188 AC_ARG_ENABLE(libcurl,
189               AC_HELP_STRING([--enable-libcurl],
190                              [enable libcurl as transport layer]),
191               [ if test "$enableval" = "yes"; then
192                    test "$have_libcurl" = "yes" || AC_MSG_ERROR([libcurl not found])
193                    TRANSPORT="$TRANSPORT libcurl"
194                    TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBCURL_LIBS"
195                    TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBCURL_CFLAGS"
196                    AC_DEFINE(ENABLE_LIBCURL, 1, [enable libcurl transport])
197                 else
198                    libcurl_disabled="yes"
199                 fi ],
200               [ if test "$have_libcurl" = "yes" && test "$default_http_transport" = "libcurl" ; then
201                    TRANSPORT="$TRANSPORT libcurl"
202                    TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBCURL_LIBS"
203                    TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBCURL_CFLAGS"
204                    AC_DEFINE(ENABLE_LIBCURL, 1, [enable libcurl transport])
205                 fi ])
206
207 AC_ARG_ENABLE(libsoup,
208               AC_HELP_STRING([--enable-libsoup],
209                              [enable libsoup as transport layer]),
210               [ if test "$enableval" = "yes"; then
211                    test "$have_libsoup" = "yes" || AC_MSG_ERROR([libsoup not found])
212                    TRANSPORT="$TRANSPORT libsoup"
213                    TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBSOUP_LIBS"
214                    TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBSOUP_CFLAGS"
215                    AC_DEFINE(ENABLE_LIBSOUP, 1, [enable libsoup transport])
216                 else
217                    libsoup_disabled="yes"
218                 fi ],
219               [ if test "$have_libsoup" = "yes" && test "$default_http_transport" = "libsoup"; then
220                    TRANSPORT="$TRANSPORT libsoup"
221                    TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBSOUP_LIBS"
222                    TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBSOUP_CFLAGS"
223                    AC_DEFINE(ENABLE_LIBSOUP, 1, [enable libsoup transport])
224                 fi ])
225
226 # SoupTransportAgent depends on glib
227 case "$TRANSPORT" in *libsoup*) need_glib=yes;; esac
228
229 bluetooth_disabled=no
230 AC_ARG_ENABLE(bluetooth,
231               AC_HELP_STRING([--enable-bluetooth],
232                              [enable bluetooth transport support]),
233               [ enable_bluetooth="$enableval"
234                 if test "$enableval" = "no"; then
235                     bluetooth_disabled=yes
236                 fi
237               ],
238               [ enable_bluetooth="$have_bluetooth" ])
239
240 if test "$enable_bluetooth" = "yes"; then
241    # currently we need Bluetooth and OBEX support
242    test "$have_bluetooth" = "yes" || AC_MSG_ERROR([openobex or bluez not found])   
243
244    AC_LANG(C)
245    CFLAGS_old="$CFLAGS"
246    CFLAGS="$CPPFLAGS $BLUEZ_CFLAGS"
247    # test in this order:
248    # - recent libbluetooth (no _safe variant, base function has bufsize)
249    # - intermediate with _safe
250    # - else assume old-style (no bufsize, no _safe)
251    #
252    # The source code checks the signature both by via pointer assignment and calling
253    # it (better safe than sorry). One these should fail if the signature is not right.
254    AC_COMPILE_IFELSE([#include <bluetooth/sdp.h>
255                       #include <bluetooth/sdp_lib.h>
256                       sdp_record_t *(*extract_pdu)(const uint8_t *pdata, int bufsize, int *scanned) =
257                            sdp_extract_pdu;
258                       void foo(void) {
259                           uint8_t *pdata = NULL;
260                           int scanned;
261                           sdp_extract_pdu(pdata, 100, &scanned);
262                       }
263                      ],
264                      AC_DEFINE(HAVE_BLUEZ_BUFSIZE, 1, [base libbluetooth functions accept bufsize parameter]),
265                      AC_COMPILE_IFELSE([#include <bluetooth/sdp.h>
266                                         #include <bluetooth/sdp_lib.h>
267                                         sdp_record_t *(*extract_pdu)(const uint8_t *pdata, int bufsize, int *scanned) =
268                                                sdp_extract_pdu_safe;
269                                         void foo(void) {
270                                             uint8_t *pdata = NULL;
271                                             int scanned;        
272                                             sdp_extract_pdu_safe(pdata, 100, &scanned);
273                                         }
274                                        ],
275                                        AC_DEFINE(HAVE_BLUEZ_SAFE, 1, [libbluetooth has _safe variants])))
276    CFLAGS="$CFLAGS_old"
277
278    if test "$have_obex" = "yes"; then
279       AC_DEFINE(ENABLE_OBEX, 1, [define if openobex library is available])
280    fi
281    if test "$have_bluez" = "yes"; then
282       AC_DEFINE(ENABLE_BLUETOOTH, 1, [define if bluez library is available])
283    fi
284 fi
285 AM_CONDITIONAL([ENABLE_OBEX], [test "$have_obex" = "yes" && test "$enable_bluetooth" = "yes"])
286 AM_CONDITIONAL([ENABLE_BLUETOOTH], [test "$have_bluetooth" = "yes" && test "$enable_bluetooth" = "yes"])
287
288 if test ! "$TRANSPORT" &&
289    test "$libsoup_disabled" != "yes" &&
290    test "$libcurl_disabled" != "yes" &&
291    test "$bluetooth_disabled" != "yes" &&
292    test "$have_bluetooth" != "yes" ; then
293    AC_ERROR([no transport library found, configure with --disable-libcurl --disable-libsoup --disable-bluetooth to continue anyway (only useful if users of libsyncevolution provide transport implementation)])
294 fi
295
296 # for libsoup we must specify the SSL certificate file outself
297 if test "$libsoup_disabled" != "yes" && test -z "$CA_CERTIFICATES"; then
298    # Debian and Red Hat paths
299    CA_CERTIFICATES="/etc/ssl/certs/ca-certificates.crt:/etc/pki/tls/certs/ca-bundle.crt:/usr/share/ssl/certs/ca-bundle.crt"
300 fi
301 AC_DEFINE_UNQUOTED(SYNCEVOLUTION_SSL_SERVER_CERTIFICATES, "$CA_CERTIFICATES", [default value for SSLServerCertificates option])
302
303 AC_SUBST(TRANSPORT_LIBS)
304 AC_SUBST(TRANSPORT_CFLAGS)
305
306 AC_ARG_ENABLE(ssl-certificate-check,
307               AC_HELP_STRING([--disable-ssl-certificate-check],
308                              [Disable SSL certificate checking in all server
309                               *templates*.  Users can still choose to enable or
310                               disable it in their configuration. This is necessary on
311                               platforms where the transport library has problems
312                               verifying the server's certificate (libsoup + Google,
313                               http://bugzilla.moblin.org/show_bug.cgi?id=4551)]),
314              enable_ssl_certificate_check="$enableval",
315              enable_ssl_certificate_check="yes")
316 if test "$enable_ssl_certificate_check" = "yes"; then
317    AC_DEFINE(ENABLE_SSL_CERTIFICATE_CHECK, 1, [enable SSL certificate check in server templates])
318 fi
319
320 # for dbus interface file mangling
321 AC_PATH_PROG(XSLT, xsltproc)
322
323 AC_ARG_ENABLE(gui,
324               AS_HELP_STRING([--enable-gui[=gui type]],
325                              [enables building the GTK+ UI that uses the SyncEvolution DBus API.
326                               Options: gtk, moblin, all (builds sync-ui-gtk and sync-ui-moblin)
327                               "gtk" is the default for --enable-gui without type. No GUI is
328                               built when --enable-gui is not used.]),
329               [ if test "$enableval" = "gtk" ; then
330                     enable_gui=gtk
331                 elif test "$enableval" = "yes" ; then
332                     enable_gui=gtk
333                 elif test "$enableval" = "moblin" ; then
334                     enable_gui=moblin
335                 elif test "$enableval" = "no" ; then
336                     enable_gui=no
337                 elif test "$enableval" = "all" ; then
338                     enable_gui=all
339                 else
340                     AC_ERROR([Unknown gui type: '$enableval'])
341                 fi
342               ],
343               [ enable_gui=no ])
344
345 AM_CONDITIONAL([COND_GUI], [test "$enable_gui" != "no"])
346
347 AC_ARG_ENABLE(core,
348               AS_HELP_STRING([--enable-core],
349                              [enables building the core SyncEvolution (library, backends)]),
350               enable_core="$enableval",
351               enable_core="yes")
352 AM_CONDITIONAL([COND_CORE], [test "$enable_core" = "yes"])
353
354 AC_ARG_ENABLE(dbus-service,
355               AS_HELP_STRING([--enable-dbus-service],
356                              [enables building the dbus service executable and all related features
357                              (the DBus wrapper library, command line usage of server, etc).]),
358               enable_dbus_service="$enableval",
359               [if test $enable_gui == "no"; then
360                   enable_dbus_service="no"
361                else
362                   enable_dbus_service="yes"
363                fi])
364 AM_CONDITIONAL([COND_DBUS], [test "$enable_dbus_service" = "yes"])
365
366 PKG_CHECK_MODULES(KEYRING, [gnome-keyring-1], HAVE_KEYRING=yes, HAVE_KEYRING=no)
367 AC_ARG_ENABLE(gnome-keyring,
368               AS_HELP_STRING([--enable-gnome-keyring],
369                              [enables or disables support for the GNOME keyring; default is on if development files are available]),
370               [enable_gnome_keyring="$enableval"
371                test "$enable_gnome_keyring" = "yes" || test "$enable_gnome_keyring" = "no" || AC_ERROR([invalid value for --enable-gnome-keyring: $enable_gnome_keyring])
372                test "$enable_gnome_keyring" = "no" || test "$HAVE_KEYRING" = "yes" || AC_ERROR([gnome-keyring-1 pkg not found, needed for --enable-gnome-keyring])],
373               enable_gnome_keyring="$HAVE_KEYRING")
374 if test $enable_gnome_keyring == "yes"; then
375     AC_DEFINE(USE_GNOME_KEYRING, 1, [define if gnome keyring should be used in dbus service])
376     PKG_CHECK_MODULES([KEYRING_2_20], [gnome-keyring-1 >= 2.20 ], KEYRING220=yes, KEYRING220=no)
377     if test $KEYRING220 == "yes"; then
378         AC_DEFINE(GNOME_KEYRING_220, 1, [define if gnome keyring version is above 2.20])
379     fi
380 fi
381
382 if test $enable_dbus_service == "yes"; then
383     if test -z "$XSLT"; then
384        AC_ERROR([xsltproc not found, is required for D-Bus service])
385     fi
386     PKG_CHECK_MODULES(DBUS, dbus-1, dummy=yes,
387                       AC_MSG_ERROR(libdbus-1 is required))
388     AC_CHECK_LIB(dbus-1, dbus_watch_get_unix_fd, dummy=yes,
389                  AC_DEFINE(NEED_DBUS_WATCH_GET_UNIX_FD, 1,
390                  [Define to 1 if you need the dbus_watch_get_unix_fd() function.]))
391     need_glib=yes
392     # Recent libnotify releases work with gtk+-2.0 and gtk+-3.0. We
393     # pick gtk+-2.0 here, to be compatible with old libnotify releases
394     # which had that hard-cored and because sync-ui also depends on
395     # gtk+-2.0.
396     PKG_CHECK_MODULES(LIBNOTIFY, [libnotify gtk+-2.0], HAVE_LIBNOTIFY=yes, HAVE_LIBNOTIFY=no)
397     AC_ARG_ENABLE(notify,
398                   AS_HELP_STRING([--enable-notify],
399                                  [send notifications for automatic sync events]),
400                   [ test "$enableval" = "no" || test $HAVE_LIBNOTIFY = "yes" || AC_ERROR([required libnotify package not found]) ],
401                   [ test $HAVE_LIBNOTIFY = "yes" || AC_ERROR([required libnotify package not found, use --disable-notify to compile without notifications]) ])
402     if test $HAVE_LIBNOTIFY == "yes"; then
403         AC_DEFINE(HAS_NOTIFY, 1, [define if libnotify could be used in dbus service])
404     fi
405     AC_DEFINE(DBUS_SERVICE, 1, [define if dbus service is enabled])
406 fi
407 AC_SUBST(DBUS_CFLAGS)
408 AC_SUBST(DBUS_LIBS)
409 AC_SUBST(DBUS_GLIB_CFLAGS)
410 AC_SUBST(DBUS_GLIB_LIBS)
411 AC_SUBST(KEYRING_CFLAGS) 
412 AC_SUBST(KEYRING_LIBS) 
413 AC_SUBST(LIBNOTIFY_CFLAGS)
414 AC_SUBST(LIBNOTIFY_LIBS)
415 AC_SUBST(LIBEXECDIR)
416
417 DBUS_SERVICES_DIR="${datadir}/dbus-1/services"
418 AC_SUBST(DBUS_SERVICES_DIR)
419 AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [Location of D-Bus services directory])
420
421 if test $enable_gui != "no" || test $enable_dbus_service == "yes"; then
422     IT_PROG_INTLTOOL([0.37.1])
423     GETTEXT_PACKAGE=syncevolution
424     AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The gettext package name])
425     AM_GLIB_GNU_GETTEXT
426     SYNCEVOLUTION_LOCALEDIR=[${datadir}/locale]
427 fi
428
429 # decide which sync-ui(s) we are building:
430 # sync-ui (in either GTK or Moblin mode) or both (in separate binaries)
431 case $enable_gui in
432      all) GUI_PROGRAMS='sync-ui-gtk${EXEEXT} sync-ui-moblin${EXEEXT}'; GUI_DESKTOP_FILES="sync-gtk.desktop sync-moblin.desktop";;
433      gtk|moblin) GUI_PROGRAMS='sync-ui${EXEEXT}'; GUI_DESKTOP_FILES="sync.desktop";;
434      no) GUI_PROGRAMS=; GUI_DESKTOP_FILES=;;
435      *) AC_ERROR([Unknown enable_gui type: '$enable_gui'])
436 esac
437
438 if test $enable_gui != "no"; then
439     PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1 glib-2.0)
440     AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool)
441     AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
442
443     gui_modules="glib-2.0 dbus-glib-1 >= 0.60 gtk+-2.0 libglade-2.0 gio-2.0"
444     if test $enable_gui == "moblin"; then
445         AC_DEFINE(USE_MOBLIN_UX, 1, [Use Moblin UI widgets])
446     fi
447     if test $enable_gui == "moblin" -o $enable_gui == "all"; then
448         gui_modules="$guimodules mx-gtk-1.0"
449
450         PKG_CHECK_MODULES(MX_GTK_0_99_1, mx-gtk-1.0 >= 0.99.1,
451                           have_mx_gtk_0_99_1="yes",
452                           have_mx_gtk_0_99_1="no")
453         if test $have_mx_gtk_0_99_1 == "yes"; then
454             AC_DEFINE(MX_GTK_0_99_1, 1, [we have Mx-Gtk 0.99.1 or better])
455         fi
456     fi
457
458     PKG_CHECK_MODULES(UNIQUE, unique-1.0,
459                       have_unique="yes",
460                       have_unique="no")
461     if test $have_unique == "yes"; then
462         gui_modules="$gui_modules unique-1.0" 
463         AC_DEFINE(ENABLE_UNIQUE, 1, [enable single-app-instance functionality])
464     fi
465
466     PKG_CHECK_MODULES(GTK_2_18, gtk+-2.0 >= 2.18,
467                       have_gtk_2_18="yes",
468                       have_gtk_2_18="no")
469     if test $have_gtk_2_18 == "yes"; then
470         AC_DEFINE(GTK_2_18, 1, [we have GTK+ 2.18 or better])
471     fi
472
473     PKG_CHECK_MODULES(GUI, $gui_modules)
474
475     AC_PATH_PROG([GTK_BUILDER_CONV], gtk-builder-convert)
476 elif test "$enable_dbus_service" = "yes"; then
477     # syncevo-dbus-server needs localization
478     :
479 else
480     INTLTOOL_UPDATE="true"
481     USE_NLS="no"
482 fi
483 AC_SUBST(SYNCEVOLUTION_LOCALEDIR)
484 AC_SUBST(GETTEXT_PACKAGE)
485 AC_SUBST(GUI_CFLAGS)
486 AC_SUBST(GUI_LIBS)
487 AC_SUBST(GUI_PROGRAMS)
488 AC_SUBST(GUI_DESKTOP_FILES)
489
490
491 # Boost headers: boost/foreach.hpp is needed (1.33/Debian Etch
492 # doesn't have it, 1.34/Ubuntu 8.10 Hardy does). 1.35 is available
493 # as Debian Etch backport.
494 AX_BOOST_BASE(1.34)
495
496 # need rst2man for man pages
497 AC_ARG_WITH(rst2man,
498             AS_HELP_STRING([--with-rst2man=<path to reStructuredText to man converter>],
499                            [Specifies an explicit path to the utility if not found in PATH.
500                             An explicit --without-rst2man or not having it installed turn off
501                             building of man pages.]),
502             [RST2MAN=$withval
503              if test "$RST2MAN" == "yes"; then
504                  AC_PATH_PROG(RST2MAN, rst2man, "no")
505              fi
506              test "$RST2MAN" == "no" || test -x "$RST2MAN" || AC_ERROR([--with-rst2man=$RST2MAN: tool not found])],
507             [AC_PATH_PROG(RST2MAN, rst2man, "no")])
508 AM_CONDITIONAL([COND_MAN_PAGES], [test "$RST2MAN" != "no"])
509
510 # need rst2html for HTML version of README
511 AC_ARG_WITH(rst2html,
512             AS_HELP_STRING([--with-rst2html=<path to reStructuredText to HTML converter>],
513                            [Specifies an explicit path to the utility if not found in PATH.
514                             An explicit --without-rst2html or not having it installed turn off
515                             building of README in HTML format.]),
516             [RST2HTML=$withval
517              if test "$RST2HTML" == "yes"; then
518                  AC_PATH_PROG(RST2HTML, rst2html, "no")
519              fi
520              test "$RST2HTML" == "no" || test -x "$RST2HTML" || AC_ERROR([--with-rst2html=$RST2HTML: tool not found])],
521             [AC_PATH_PROG(RST2HTML, rst2html, "no")])
522 AM_CONDITIONAL([COND_HTML_README], [test "$RST2HTML" != "no"])
523
524 # absolute patch to source of Synthesis client library
525 SYNTHESIS_SRC=no-synthesis-source
526 AC_SUBST(SYNTHESIS_SRC)
527 if test "$SYNTHESISSRC" && test "$SYNTHESISSRC" != "none"; then
528     # default: checkout a copy of the sources, remove it during maintainer-clean and distclean
529     CLEAN_CLIENT_SRC=synthesis-workdir
530     SYNTHESIS_SRC=$PWD/src/synthesis-workdir
531
532     AC_MSG_NOTICE( [updating the content of $SYNTHESIS_SRC from $SYNTHESISSRC] )
533     case "$SYNTHESISSRC" in
534         *.git) protocol=git;;
535         *://*) protocol="`echo $SYNTHESISSRC | sed -e 's;://.*;;'`";;
536         *) protocol="file";;
537     esac
538
539     mkdir -p src
540     case $protocol in
541         file)
542             # use existing copy of the sources
543             CLEAN_CLIENT_SRC=
544             case "$SYNTHESISSRC" in
545                  /*) SYNTHESIS_SRC="$SYNTHESISSRC";;
546                  *) SYNTHESIS_SRC="$PWD/$SYNTHESISSRC";;
547             esac
548             ;;
549         *svn*|*http*)
550             SYNTHESISSRCREV="$SYNTHESISSRC"
551             if test "$REVISION"; then
552                 revarg="-r $REVISION "
553                 if `echo $SYNTHESISSRC | grep '@[0123456789]*'` >/dev/null; then
554                     :
555                 else
556                     SYNTHESISSRCREV="$SYNTHESISSRC@$REVISION"
557                 fi
558             fi
559             if test -d $SYNTHESIS_SRC ; then
560                 ( set -x; cd $SYNTHESIS_SRC && svn --username=$USERNAME switch $revarg "$SYNTHESISSRC" ) || AC_ERROR([updating from $SYNTHESISSRC failed])
561             else
562                 (set -x; svn --username=$USERNAME checkout $revarg "$SYNTHESISSRCREV" $SYNTHESIS_SRC ) || AC_ERROR([checking out $SYNTHESISSRC failed])
563             fi
564             ;;
565         *)
566             if test -d $SYNTHESIS_SRC ; then
567                 ( set -x; cd $SYNTHESIS_SRC && git fetch "$SYNTHESISSRC" ) || AC_ERROR([updating from $SYNTHESISSRC failed])
568             else
569                 ( set -x; git clone "$SYNTHESISSRC" $SYNTHESIS_SRC ) || AC_ERROR([cloning $SYNTHESISSRC failed])
570             fi
571             if test "$REVISION"; then
572                 # git 1.6 finds tags and branches without explicit prefix, 1.4.4.4 doesn't
573                 ( set -x; cd $SYNTHESIS_SRC &&
574                   (git checkout "$REVISION" ||
575                    git checkout "tags/$REVISION" ||
576                    git checkout "origin/$REVISION") ) || AC_ERROR([checking out $SYNTHESISSRC failed])
577             fi
578             ;;
579     esac
580 elif test "$SYNTHESISSRC" != "none" && test -d $srcdir/src/synthesis; then
581     # use existing copy of the sources; beware of
582     # out-of-tree compilation
583     case $srcdir in
584          /*) SYNTHESIS_SRC="$srcdir/src/synthesis";;
585          *) SYNTHESIS_SRC="$PWD/$srcdir/src/synthesis";;
586     esac
587 elif test "$enable_shared" = "no"; then
588     # link against engine
589     PKG_CHECK_MODULES(SYNTHESIS, "synthesis")
590     SYNTHESIS_ENGINE="$SYNTHESIS_LIBS -lsynthesis"
591 else
592     # link against SDK alone, except in client-test
593     #PKG_CHECK_MODULES(SYNTHESIS, "synthesis-sdk")
594     #SYNTHESIS_ENGINE="`echo $SYNTHESIS_LIBS | sed -e 's/-lsynthesisstubs/-lsynthesis/'`"
595
596     # can't use the SDK alone because of sysync::SySyncDebugPuts()
597     PKG_CHECK_MODULES(SYNTHESIS, "synthesis")
598     SYNTHESIS_ENGINE="$SYNTHESIS_LIBS"
599 fi
600
601 if test $SYNTHESIS_SRC != "no-synthesis-source"; then
602     ( 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])
603
604     SYNTHESIS_CONFIGURE="$SYNTHESIS_SRC/configure"
605     chmod u+x $SYNTHESIS_SRC/configure $SYNTHESIS_SRC/config.sub $SYNTHESIS_SRC/config.guess
606
607     # use local copy of the sources, with dependencies
608     # to trigger building the synthesis library
609     SYNTHESIS_SUBDIR=$PWD/src/build-synthesis
610     SYNTHESIS_CFLAGS="-I$SYNTHESIS_SUBDIR/src"
611     SYNTHESIS_LIBS="$SYNTHESIS_SUBDIR/src/libsynthesissdk.la"
612
613     if test "$enable_core" = "no" && test "$enable_gui" != "no"; then
614        # SYNTHESIS_SUBDIR is ignored, at least build headers for GUI
615        SYNTHESIS_SUBDIR_INCLUDES=synthesis-includes
616     fi
617
618     if test "$enable_shared" = "no"; then
619         # link against the engines that were enabled
620         case $SYNCML_ENGINES in both|client|server) SYNTHESIS_LIBS="$SYNTHESIS_LIBS $SYNTHESIS_SUBDIR/src/libsynthesis.la";; esac
621         AC_DEFINE(ENABLE_SYNCML_LINKED, 1, [SyncML engines are linked directly])
622     else
623         # It would be nice if we could avoid linking against libsynthesis.la here.
624         # This doesn't work at the moment because sysync::SySyncDebugPuts()
625         # is called directly by the libsynthesissdk instead of going through
626         # the normal C function pointer lookup.
627         SYNTHESIS_LIBS="$SYNTHESIS_LIBS $SYNTHESIS_SUBDIR/src/libsynthesis.la"
628     fi
629     SYNTHESIS_DEP=$SYNTHESIS_LIBS
630
631     # for linking client-test
632     SYNTHESIS_ENGINE="$SYNTHESIS_SUBDIR/src/libsynthesis.la"
633
634     AC_MSG_NOTICE( [configuring the Synthesis library] )
635     if (set -x; mkdir -p $SYNTHESIS_SUBDIR && cd $SYNTHESIS_SUBDIR && eval "\$SHELL \"\$SYNTHESIS_CONFIGURE\" $ac_configure_args \"--srcdir=\$SYNTHESIS_SRC\" " ); then true; else
636         AC_MSG_ERROR( [configuring Synthesis library failed] )
637     fi
638 fi
639
640 AC_SUBST(SYNTHESIS_CFLAGS)
641 AC_SUBST(SYNTHESIS_LIBS)
642 AC_SUBST(SYNTHESIS)
643 AC_SUBST(SYNTHESIS_SUBDIR)
644 AC_SUBST(SYNTHESIS_SUBDIR_INCLUDES)
645 AC_SUBST(SYNTHESIS_DEP)
646 AC_SUBST(SYNTHESIS_ENGINE)
647 AC_SUBST(SYNTHESIS_LIB)
648 AC_SUBST(SYNTHESISSRC)
649
650 dnl select backends
651 BACKENDS=""
652
653 # AC_ARG_ENABLE_BACKEND(BACKEND, DIR, HELP-STRING, [ACTION-IF-GIVEN],
654 #                       [ACTION-IF-NOT-GIVEN])
655 #
656 # Same as AC_ARG_ENABLE(), but also tells configure that the
657 # backend exists.
658 #
659 # BACKEND = name of modules built in that dir as .la files without the
660 #           obligatory sync prefix, e.g. "ebook"
661 # DIR = name of the directory inside src/backends, e.g., "evolution"
662 AC_DEFUN([AC_ARG_ENABLE_BACKEND],
663 [
664         AC_ARG_ENABLE($1, $3, $4, $5)
665         BACKENDS="$BACKENDS $1"
666         BACKEND_DEFINES="$BACKEND_DEFINES ENABLE_`echo $1 | tr a-z A-Z`"
667         for source in $2; do
668             SYNCSOURCES="$SYNCSOURCES backends/$2/sync$1.la"
669         done
670 ])
671 AC_SUBST(SYNCSOURCES)
672 AC_SUBST(BACKEND_DEFINES)
673
674 BACKEND_CPPFLAGS="$SYNTHESIS_CFLAGS $EPACKAGE_CFLAGS $EBOOK_CFLAGS $ECAL_CFLAGS $GLIB_CFLAGS $BOOST_CPPFLAGS"
675 AC_SUBST(BACKEND_CPPFLAGS)
676
677 # GNOME Bluetooth Panel plugin
678 PKG_CHECK_MODULES(GNOMEBLUETOOTH, [gnome-bluetooth-1.0 >= 2.27.6],
679                   [have_gbt="yes"
680                    GNOMEBLUETOOTH_DIR=`$PKG_CONFIG --variable=libdir gnome-bluetooth-1.0 2>/dev/null`/gnome-bluetooth],
681                    have_gbt="no")
682 AC_SUBST(GNOMEBLUETOOTH_CFLAGS)
683 AC_SUBST(GNOMEBLUETOOTH_DIR)
684
685 AC_ARG_ENABLE(gnome-bluetooth-panel-plugin, 
686         AC_HELP_STRING([--enable-gnome-bluetooth-panel-plugin],
687                        [GNOME Bluetooth panel plugin adding a "sync" button for paired devices (off by default)]),
688                        [enable_gnome_bluetooth_panel="$enableval"],
689         [enable_gnome_bluetooth_panel="no"]
690         )
691 if test "$enable_gnome_bluetooth_panel" = "yes"; then
692    test "$have_gbt" = "yes" || AC_MSG_ERROR([--enable-gnome-bluetooth-panel requires
693            pkg-config information for gnome-bluetooth-1.0 >= 2.27.6 which was not found])
694 fi
695 AC_CONFIG_FILES(src/gnome-bluetooth/Makefile)
696 AM_CONDITIONAL([ENABLE_GNOME_BLUETOOTH_PANEL], [test "$have_gbt" = "yes" && test "$enable_gnome_bluetooth_panel" = "yes"])
697
698 AC_ARG_ENABLE(doc,
699               AC_HELP_STRING([--enable-doc],
700                              [generate backend and DBus API documentation]),
701               enable_doc="$enableval", enable_doc="no")
702             
703 AM_CONDITIONAL([COND_DOC], [test "$enable_doc" != "no"])
704
705 dnl src/backends/*/configure-sub.in and configure-post.in follow