Imported Upstream version 1.3.99.4
[platform/upstream/syncevolution.git] / configure.ac
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], [m4_esyscmd([build/gen-git-version.sh 1.3.99.4])])
12 # STABLE_VERSION=1.0.1+
13 AC_SUBST(STABLE_VERSION)
14
15 # Generate some files.
16 SE_GENERATE_AM_FILES
17 SE_GENERATE_LINGUAS
18
19 # Default value for --enable/disable-release-mode.
20 # Determined by gen-autotools.sh based on versioning.
21 # Official, stable releases enable it, pre-releases
22 # disable it.
23 #
24 SE_CHECK_FOR_STABLE_RELEASE
25
26 # Minimum version of libsynthesis as defined in its
27 # configure script and thus .pc files:
28 define([SYNTHESIS_MIN_VERSION], [3.4.0.16.10])
29
30 # Line above is patched by gen-autotools.sh. Handle
31 # both "yes" and "no".
32 m4_define([STABLE_RELEASE_HELP], m4_if(STABLE_RELEASE,[yes],[--disable-release-mode],[--enable-release-mode]))
33
34 AC_ARG_ENABLE(release-mode,
35               AS_HELP_STRING([STABLE_RELEASE_HELP],
36                              [Controls whether resulting binary is for end-users or
37                               testers/developers. For example, stable releases automatically
38                               migrate on-disk files without asking, whereas other releases
39                               ask before making downgrades impossible (or difficult).
40                               Default in this source code is
41                               "stable release: STABLE_RELEASE"]),
42               enable_release_mode="$enableval", enable_release_mode="STABLE_RELEASE")
43 if test "$enable_release_mode" = "yes"; then
44    AC_DEFINE(SYNCEVOLUTION_STABLE_RELEASE, 1, [binary is meant for end-users])
45 fi
46
47 AM_INIT_AUTOMAKE([1.11.1 tar-ustar silent-rules subdir-objects -Wno-portability])
48
49 AM_PROG_CC_C_O
50
51 AM_MAINTAINER_MODE([enable]) # needed for nightly builds where reconfiguration fails under certain chroots
52 AC_CONFIG_MACRO_DIR([m4])
53 define([SYNTHESISSRC_REPO], [])
54 dnl Specify git revisions/branches without prefix, i.e., without 'origin'.
55 dnl We'll sort that out below.
56 define([SYNTHESISSRC_REVISION], [syncevolution-0.9])
57 AC_CONFIG_HEADERS(config.h)
58 AC_LIBTOOL_DLOPEN
59 AC_PROG_LIBTOOL
60
61 dnl check for programs.
62 AC_PROG_CXX
63 AC_PROG_MAKE_SET
64
65 # Boost headers: boost/foreach.hpp is needed (1.33/Debian Etch
66 # doesn't have it, 1.34/Ubuntu 8.10 Hardy does). 1.35 is available
67 # as Debian Etch backport.
68 AX_BOOST_BASE(1.34)
69
70 # TODO: Fix code to pass with -pedantic -Wextra.
71 # -Wno-unknown-pragmas needed because icalstrdup.h
72 # currently uses the "#pragma }" trick. Should remove that.
73 # Fix code to work without deprecated methods: G GDK GDK_PIXBUF CAIRO PANGO GTK
74 DK_ARG_ENABLE_WARNINGS([SYNCEVO_WFLAGS],
75                        [-Wall -Wno-unknown-pragmas -Wno-deprecated-declarations],
76                        [-Wall -Wno-unknown-pragmas -Wno-deprecated-declarations],
77                        [])
78
79 dnl default device type (see AC_DEFINE below)
80 DEVICE_TYPE=workstation
81
82 AC_ARG_WITH(synthesis-src,
83             AS_HELP_STRING([--with-synthesis-src=<base directory|svn URL|git URL>],
84                            [Specifies location of the Synthesis root directory.
85                            Use this when the Synthesis library is to
86                            be compiled as part of the SyncEvolution compilation. In release
87                            versions of SyncEvolution, a copy of the Synthesis code is bundled
88                            under 'src/synthesis' and compiled unless something else is
89                            specified. --with-synthesis-src can be given a path to sources
90                            checked out already, a Subversion repository URL or a git repository
91                            URL. When given a repository URL, then the configure script
92                            will checkout the sources into 'src/synthesis-workdir' or
93                            update that working copy if the directory already exists.
94                            Default: bundled source in src/synthesis (in released SyncEvolution sources),
95                            SYNTHESISSRC_REPO otherwise.]),
96             [SYNTHESISSRC="$withval"
97              test "$SYNTHESISSRC" != "yes" || AC_MSG_ERROR([--with-synthesis-src requires a parameter (base directory, svn URL or git URL)])],
98             [SYNTHESISSRC="$SYNTHESISSRC_DEF"; REVISION="SYNTHESISSRC_REVISION"])
99
100 AC_ARG_WITH(syncml-engines,
101             AS_HELP_STRING([--with-syncml-engines=client|server|both],
102                            [Determines which kind of support for SyncML is compiled and linked into SyncEvolution. Default is both. Currently has no effect.]),
103             [SYNCML_ENGINES="$withval"], SYNCML_ENGINES=both)
104
105 case $SYNCML_ENGINES in both|client) AC_DEFINE(ENABLE_SYNCML_CLIENT, 1, [SyncML client support available]);; esac
106 case $SYNCML_ENGINES in both|server) AC_DEFINE(ENABLE_SYNCML_SERVER, 1, [SyncML server support available]);; esac
107 case $SYNCML_ENGINES in both|server|client) true;; *) AC_MSG_ERROR([Invalid value for --with-syncml-engines: $SYNCML_ENGINES]);; esac
108
109 AC_ARG_WITH(synthesis-username,
110             AS_HELP_STRING([--with-synthesis-username=<svn username>],
111                            [username to use when checking out --with-synthesis-src sources from Subversion, default 'guest']),
112             [USERNAME="$withval"], [USERNAME="guest"])
113
114 AC_ARG_WITH(synthesis-revision,
115             AS_HELP_STRING([--with-synthesis-revision=<git tag/branch/hash or Subversion revision>],
116                            [Identifies which source revision to use from --with-synthesis-src repository, empty string stands for latest. Default for default --synthesis-src: SYNTHESISSRC_REVISION]),
117             [REVISION="$withval"])
118
119 AC_ARG_ENABLE(shared,
120               AS_HELP_STRING([--enable-shared],
121                              [build backends as dynamically loadable modules]),
122               enable_shared="$enableval", enable_shared="no")
123
124 AC_ARG_ENABLE(static,
125               AS_HELP_STRING([--enable-static],
126                              [build backends also as static libraries]),
127               enable_static="$enableval", enable_static="no")
128
129 AC_ARG_ENABLE(unit-tests,
130               AS_HELP_STRING([--enable-unit-tests],
131                              [enables tests embedded in the source code of the library (changes content of executable)]),
132               enable_unit_tests="$enableval", enable_unit_tests="no")
133 AC_ARG_ENABLE(integration-tests,
134               AS_HELP_STRING([--enable-integration-tests],
135                              [enables tests outside of the library (can be used together with normal builds of the library)]),
136               enable_integration_tests="$enableval", enable_integration_tests="no")
137
138 AC_ARG_ENABLE(static-cxx,
139               AS_HELP_STRING([--enable-static-cxx],
140                              [build executables which contain libstdc++ instead of requiring suitable libstdc++.so to run]),
141               enable_static_cxx="$enableval", enable_static_cxx="no")
142
143 AC_ARG_ENABLE(evolution-compatibility,
144               AS_HELP_STRING([--enable-evolution-compatibility],
145                              [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]),
146               enable_evolution_compatibility="$enableval", enable_evolution_compatibility="no")
147
148 AC_ARG_ENABLE(developer-mode,
149               AS_HELP_STRING([--enable-developer-mode],
150                              [The dynamic loadble backend libraries is loaded from current build directory instead of the standard library path]),
151               enable_developer_mode="$enableval", enable_developer_mode="no")
152
153 # Maemo hacks:
154 # - wrap e_book_from_string() to fix invalid parameter
155 # - don't use UTF-8 encoding in Perl script
156 AC_ARG_ENABLE(maemo,
157               AS_HELP_STRING([--enable-maemo],
158                              [enables some hacks which work around problems with the Maemo 2.0 until at least 3.0 EDS-Dbus]),
159               [AC_DEFINE(ENABLE_MAEMO, 1, [enable Maemo hacks])
160                DEVICE_TYPE=Maemo
161                MODIFY_SYNCCOMPARE='-e "s/use encoding/#use encoding/;" -e "s/:utf8//;"'])
162 AC_SUBST(MODIFY_SYNCCOMPARE)
163
164 AC_CHECK_HEADERS(signal.h dlfcn.h)
165
166 # cppunit-config is used even when both unit tests and integration tests are disabled.
167 AC_PATH_PROG([CPPUNIT_CONFIG], [cppunit-config], [no])
168
169 test "x$CPPUNIT_CONFIG" != 'xno' || AC_MSG_ERROR("cppunit-config not found.")
170
171 # cppunit needed?
172 #if test "x$enable_unit_tests" = 'xyes' || test "x$enable_integration_tests" = 'xyes'
173 #then
174   CPPUNIT_CXXFLAGS=`$CPPUNIT_CONFIG --cflags`
175   CPPUNIT_LDFLAGS=`$CPPUNIT_CONFIG --libs`
176 #fi
177 AC_SUBST(CPPUNIT_CXXFLAGS)
178 AC_SUBST(CPPUNIT_LDFLAGS)
179
180 if test "x$enable_unit_tests" = 'xyes'; then
181         AC_DEFINE(ENABLE_UNIT_TESTS, 1, [enable unit tests inside the library's source code])
182 fi
183 if test "x$enable_integration_tests" = 'xyes'; then
184         AC_DEFINE(ENABLE_INTEGRATION_TESTS, 1, [enable integration tests inside the final library])
185 fi
186 AM_CONDITIONAL([ENABLE_UNIT_TESTS], [test "$enable_unit_tests" = "yes"])
187 AM_CONDITIONAL([ENABLE_TESTING], [test "$enable_unit_tests" = "yes" || test "$enable_integration_tests" = "yes" ])
188
189 if test $enable_static_cxx = "yes"; then
190         LIBS="$LIBS -L."
191         CORE_LDADD_DEP=libstdc++.a
192 fi
193 AC_SUBST(CORE_LDADD_DEP)
194
195 # Check for transport layer.
196 # Both curl and libsoup can be enabled and disabled explicitly.
197 # The default is to use libsoup if available, otherwise curl.
198
199 AC_MSG_CHECKING([for libcurl])
200 if LIBCURL_LIBS=`sh -c 'curl-config --libs' 2>&AS_MESSAGE_LOG_FD` && \
201     LIBCURL_CFLAGS=`sh -c 'curl-config --cflags' 2>&AS_MESSAGE_LOG_FD`; then
202     AC_MSG_RESULT([yes])
203     have_libcurl="yes"
204 else
205     AC_MSG_RESULT([no])
206     have_libcurl="no"
207 fi
208
209 PKG_CHECK_MODULES(LIBSOUP, libsoup-gnome-2.4,
210                   [have_libsoup="yes"
211                    AC_DEFINE(HAVE_LIBSOUP_SOUP_GNOME_FEATURES_H, 1, [enable GNOME specific libsoup])],
212                   [PKG_CHECK_MODULES(LIBSOUP, libsoup-2.4,
213                                      have_libsoup="yes",
214                                      have_libsoup="no")])
215
216 PKG_CHECK_MODULES(LIBOPENOBEX, openobex, have_obex="yes", have_obex="no")
217 have_bluetooth="no"
218 if test $have_obex = "yes"; then
219     PKG_CHECK_MODULES(BLUEZ, bluez, have_bluez="yes", have_bluez="no")
220     if test $have_bluez = "yes"; then
221         have_bluetooth="yes"
222     fi
223 fi
224 AC_SUBST(LIBOPENOBEX_CFLAGS)
225 AC_SUBST(LIBOPENOBEX_LIBS)
226 AC_SUBST(BLUEZ_CFLAGS)
227 AC_SUBST(BLUEZ_LIBS)
228
229 TRANSPORT=
230 TRANSPORT_LIBS=
231 TRANSPORT_CFLAGS=
232
233 AC_ARG_WITH(ca-certificates,
234             AS_HELP_STRING([--with-ca-certificates=<colon separated list of files>],
235                            [Specifies location of one or more CA certificate files.
236                            This sets the default value for the SSLServerCertificates option.
237                            Default: empty when using libcurl (because it has its own default),
238                            a list of paths known to work for Debian and Red Hat otherwise.]),
239             [CA_CERTIFICATES="$withval"])
240
241
242 # choose default http transport (mirrors code in EvolutionSyncClient::createTransportAgent())
243 if test "$have_libsoup" = "yes"; then
244    default_http_transport="libsoup"
245 elif test "$have_libcurl" = "yes"; then
246    default_http_transport="libcurl"
247 fi
248
249 AC_ARG_ENABLE(libcurl,
250               AS_HELP_STRING([--enable-libcurl],
251                              [enable libcurl as transport layer]),
252               [ if test "$enableval" = "yes"; then
253                    test "$have_libcurl" = "yes" || AC_MSG_ERROR([libcurl not found])
254                    TRANSPORT="$TRANSPORT libcurl"
255                    TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBCURL_LIBS"
256                    TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBCURL_CFLAGS"
257                    AC_DEFINE(ENABLE_LIBCURL, 1, [enable libcurl transport])
258                 else
259                    libcurl_disabled="yes"
260                 fi ],
261               [ if test "$have_libcurl" = "yes" && test "$default_http_transport" = "libcurl" ; then
262                    TRANSPORT="$TRANSPORT libcurl"
263                    TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBCURL_LIBS"
264                    TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBCURL_CFLAGS"
265                    AC_DEFINE(ENABLE_LIBCURL, 1, [enable libcurl transport])
266                 fi ])
267
268 AC_ARG_ENABLE(libsoup,
269               AS_HELP_STRING([--enable-libsoup],
270                              [enable libsoup as transport layer]),
271               [ if test "$enableval" = "yes"; then
272                    test "$have_libsoup" = "yes" || AC_MSG_ERROR([libsoup not found])
273                    TRANSPORT="$TRANSPORT libsoup"
274                    TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBSOUP_LIBS"
275                    TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBSOUP_CFLAGS"
276                    AC_DEFINE(ENABLE_LIBSOUP, 1, [enable libsoup transport])
277                 else
278                    libsoup_disabled="yes"
279                 fi ],
280               [ if test "$have_libsoup" = "yes" && test "$default_http_transport" = "libsoup"; then
281                    TRANSPORT="$TRANSPORT libsoup"
282                    TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBSOUP_LIBS"
283                    TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBSOUP_CFLAGS"
284                    AC_DEFINE(ENABLE_LIBSOUP, 1, [enable libsoup transport])
285                 fi ])
286
287 # SoupTransportAgent depends on glib
288 case "$TRANSPORT" in *libsoup*) need_glib=yes;; esac
289
290 bluetooth_disabled=no
291 AC_ARG_ENABLE(bluetooth,
292               AS_HELP_STRING([--enable-bluetooth],
293                              [enable bluetooth transport support]),
294               [ enable_bluetooth="$enableval"
295                 if test "$enableval" = "no"; then
296                     bluetooth_disabled=yes
297                 fi
298               ],
299               [ enable_bluetooth="$have_bluetooth" ])
300
301 if test "$enable_bluetooth" = "yes"; then
302    # currently we need Bluetooth and OBEX support
303    test "$have_bluetooth" = "yes" || AC_MSG_ERROR([openobex or bluez not found])
304
305    AC_LANG(C)
306    CFLAGS_old="$CFLAGS"
307    CFLAGS="$CPPFLAGS $BLUEZ_CFLAGS"
308    # test in this order:
309    # - recent libbluetooth (no _safe variant, base function has bufsize)
310    # - intermediate with _safe
311    # - else assume old-style (no bufsize, no _safe)
312    #
313    # The source code checks the signature both by via pointer assignment and calling
314    # it (better safe than sorry). One these should fail if the signature is not right.
315    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
316                       #include <bluetooth/sdp.h>
317                       #include <bluetooth/sdp_lib.h>
318                       sdp_record_t *(*extract_pdu)(const uint8_t *pdata, int bufsize, int *scanned) =
319                            sdp_extract_pdu;
320                       void foo(void) {
321                           uint8_t *pdata = NULL;
322                           int scanned;
323                           sdp_extract_pdu(pdata, 100, &scanned);
324                       }
325                      ])],
326                      AC_DEFINE(HAVE_BLUEZ_BUFSIZE, 1, [base libbluetooth functions accept bufsize parameter]),
327                      AC_COMPILE_IFELSE([AC_LANG_SOURCE([
328                                         #include <bluetooth/sdp.h>
329                                         #include <bluetooth/sdp_lib.h>
330                                         sdp_record_t *(*extract_pdu)(const uint8_t *pdata, int bufsize, int *scanned) =
331                                                sdp_extract_pdu_safe;
332                                         void foo(void) {
333                                             uint8_t *pdata = NULL;
334                                             int scanned;
335                                             sdp_extract_pdu_safe(pdata, 100, &scanned);
336                                         }
337                                        ])],
338                                        AC_DEFINE(HAVE_BLUEZ_SAFE, 1, [libbluetooth has _safe variants])))
339    CFLAGS="$CFLAGS_old"
340
341    if test "$have_obex" = "yes"; then
342       AC_DEFINE(ENABLE_OBEX, 1, [define if openobex library is available])
343    fi
344    if test "$have_bluez" = "yes"; then
345       AC_DEFINE(ENABLE_BLUETOOTH, 1, [define if bluez library is available])
346    fi
347 fi
348 AM_CONDITIONAL([ENABLE_OBEX], [test "$have_obex" = "yes" && test "$enable_bluetooth" = "yes"])
349 AM_CONDITIONAL([ENABLE_BLUETOOTH], [test "$have_bluetooth" = "yes" && test "$enable_bluetooth" = "yes"])
350
351 if test ! "$TRANSPORT" &&
352    test "$libsoup_disabled" != "yes" &&
353    test "$libcurl_disabled" != "yes" &&
354    test "$bluetooth_disabled" != "yes" &&
355    test "$have_bluetooth" != "yes" ; then
356    AC_MSG_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)])
357 fi
358
359 # for libsoup we must specify the SSL certificate file outself
360 if test "$libsoup_disabled" != "yes" && test -z "$CA_CERTIFICATES"; then
361    # Debian and Red Hat paths
362    CA_CERTIFICATES="/etc/ssl/certs/ca-certificates.crt:/etc/pki/tls/certs/ca-bundle.crt:/usr/share/ssl/certs/ca-bundle.crt"
363 fi
364 AC_DEFINE_UNQUOTED(SYNCEVOLUTION_SSL_SERVER_CERTIFICATES, "$CA_CERTIFICATES", [default value for SSLServerCertificates option])
365
366 AC_SUBST(TRANSPORT_LIBS)
367 AC_SUBST(TRANSPORT_CFLAGS)
368
369 AC_ARG_ENABLE(ssl-certificate-check,
370               AS_HELP_STRING([--disable-ssl-certificate-check],
371                              [Disable SSL certificate checking in all server
372                               *templates*.  Users can still choose to enable or
373                               disable it in their configuration. This is necessary on
374                               platforms where the transport library has problems
375                               verifying the server's certificate (libsoup + Google,
376                               http://bugzilla.moblin.org/show_bug.cgi?id=4551)]),
377              enable_ssl_certificate_check="$enableval",
378              enable_ssl_certificate_check="yes")
379 if test "$enable_ssl_certificate_check" = "yes"; then
380    AC_DEFINE(ENABLE_SSL_CERTIFICATE_CHECK, 1, [enable SSL certificate check in server templates])
381 fi
382
383 # for dbus interface file mangling
384 AC_PATH_PROG(XSLT, xsltproc)
385
386
387 # Changes in GTK3 mean that supporting both GTK3 and GTK2 in the same codebase
388 # is difficult. We want to support GTK2 for the time being so the code is forked.
389 AC_ARG_ENABLE(gtk,
390               AS_HELP_STRING([--enable-gtk=major version],
391                              [Selects the gtk+ version ("2" or "3") to use for the UI.
392                               If this option is used, --enable-gui should be used as well.
393                               "3" is the default option if available, otherwise "2".]),
394               [ if test "$enableval" = "3" ; then
395                     gtk_version=gtk+-3.0
396                 elif test "$enableval" = "2" ; then
397                     gtk_version=gtk+-2.0
398                 else
399                     AC_MSG_ERROR([Unknown gtk version: '$enableval'])
400                 fi
401               ],
402               [ PKG_CHECK_EXISTS([gtk+-3.0],
403                                  [gtk_version=gtk+-3.0],
404                                  [gtk_version=gtk+-2.0]) ])
405
406
407 AM_CONDITIONAL([COND_GTK2], [test "$gtk_version" = "gtk+-2.0"])
408
409 AC_ARG_ENABLE(gui,
410               AS_HELP_STRING([--enable-gui[=gui type]],
411                              [enables building the GTK+ UI that uses the SyncEvolution DBus API.
412                               Options: gtk, moblin, all (builds sync-ui-gtk and sync-ui-moblin)
413                               "gtk" is the default for --enable-gui without type. No GUI is
414                               built when --enable-gui is not used.]),
415               [ if test "$enableval" = "gtk" ; then
416                     enable_gui=gtk
417                 elif test "$enableval" = "yes" ; then
418                     enable_gui=gtk
419                 elif test "$enableval" = "moblin" ; then
420                     enable_gui=moblin
421                 elif test "$enableval" = "no" ; then
422                     enable_gui=no
423                 elif test "$enableval" = "all" ; then
424                     enable_gui=all
425                 else
426                     AC_MSG_ERROR([Unknown gui type: '$enableval'])
427                 fi
428               ],
429               [ enable_gui=no ])
430
431 AM_CONDITIONAL([COND_GUI], [test "$enable_gui" != "no"])
432
433 AC_ARG_ENABLE(core,
434               AS_HELP_STRING([--enable-core],
435                              [enables building the core SyncEvolution (library, backends)]),
436               enable_core="$enableval",
437               enable_core="yes")
438 AM_CONDITIONAL([COND_CORE], [test "$enable_core" = "yes"])
439
440 AC_ARG_ENABLE(dbus-service,
441               AS_HELP_STRING([--enable-dbus-service],
442                              [enables building the dbus service executable and all related features
443                              (the DBus wrapper library, command line usage of server, etc).]),
444               enable_dbus_service="$enableval",
445               [if test $enable_gui = "no"; then
446                   enable_dbus_service="no"
447                else
448                   enable_dbus_service="yes"
449                fi])
450 AM_CONDITIONAL([COND_DBUS], [test "$enable_dbus_service" = "yes"])
451
452 AC_ARG_WITH([gio-gdbus],
453             AS_HELP_STRING([--with-gio-gdbus],
454                            [enables use of GIO's GDBus instead of the in-tree, Bluez gdbus.]),
455             with_gio_gdbus="$withval",
456             PKG_CHECK_EXISTS([gio-2.0 >= 2.30],
457                              [with_gio_gdbus="yes"],
458                              [with_gio_gdbus="no"]))
459 AM_CONDITIONAL([COND_GIO_GDBUS], [test "x$with_gio_gdbus" = "xyes"])
460
461 # We only need to check for dbus-1 if gio-gdbus is not used.
462 #
463 # Local sync depends on D-Bus communication between parent
464 # and child process (works without a D-Bus daemon), and local
465 # sync is not an optional feature. Could be made one if
466 # someone is interested enough.
467 #
468 # Therefore, at the moment, either libdbus or gio-gdbus are needed
469 # unconditionally. glib is needed in all cases now.
470 need_glib=yes
471 AS_IF([test "x$with_gio_gdbus" = "xyes"],
472       [PKG_CHECK_MODULES([DBUS], [gio-2.0 >= 2.26])
473        AC_DEFINE([WITH_GIO_GDBUS],[],[Set if using GIO GDBus])],
474       [PKG_CHECK_MODULES(DBUS, dbus-1, dummy=yes,
475                          AC_MSG_ERROR(libdbus-1 is required))
476        AC_CHECK_LIB(dbus-1, dbus_watch_get_unix_fd, dummy=yes,
477                     AC_DEFINE(NEED_DBUS_WATCH_GET_UNIX_FD, 1,
478                     [Define to 1 if you need the dbus_watch_get_unix_fd() function.]))])
479
480 if test $enable_dbus_service = "yes"; then
481     if test -z "$XSLT"; then
482        AC_MSG_ERROR([xsltproc not found, is required for D-Bus service])
483     fi
484     # Recent libnotify releases work with gtk+-2.0 and gtk+-3.0.
485     AC_ARG_ENABLE([notify],
486         AS_HELP_STRING([--enable-notify],
487                        [send notifications for automatic sync events, using libnotify]),
488         enable_notify="$enableval",
489         PKG_CHECK_EXISTS([libnotify $gtk_version],
490                          [enable_notify="yes"],
491                          [enable_notify="no"]))
492     AS_IF([test "x$enable_notify" = "xyes"], [PKG_CHECK_MODULES([LIBNOTIFY], [libnotify $gtk_version])]
493                                              [AC_DEFINE(HAS_NOTIFY, 1,
494                                                         [define if libnotify could be used in dbus service])])
495
496     AC_ARG_ENABLE(notify-compatibility,
497                   AS_HELP_STRING([--enable-notify-compatibility],
498                                  [increase compatibility with binary libnotify installations by loading libnotify.so.1..4 dynamically instead of linking against it]),
499                                  [enable_notify_compat="$enableval"],
500                                  [enable_notify_compat="no"]
501                  )
502     if test "$enable_notify_compat" = "yes"; then
503         AC_DEFINE(NOTIFY_COMPATIBILITY, 1, [dynamically open libnotify])
504         LIBNOTIFY_LIBS="`echo $LIBNOTIFY_LIBS | sed -e 's/\(-lnotify\|[^ ]*libnotify.la\)/-ldl/'`"
505     fi
506
507     # Here we're using QtGui too because mlite fails to depend on it,
508     # despite using QAction.
509     PKG_CHECK_MODULES(MLITE, [mlite QtGui], HAVE_MLITE=yes, HAVE_MLITE=no)
510     AC_ARG_ENABLE(mlite,
511                   AS_HELP_STRING([--enable-mlite],
512                                  [send notifications for automatic sync events, using mlite (off by default)]),
513                   [ enable_mlite="$enableval"
514                     test "$enableval" = "no" || test $HAVE_MLITE = "yes" || AC_MSG_ERROR([required mlite package not found]) ],
515                   [ enable_mlite="no" ])
516     if test $enable_mlite = "yes"; then
517         AC_DEFINE(HAS_MLITE, 1, [define if mlite could be used in dbus service])
518     else
519         # don't use mlite, even if found
520         MLITE_CFLAGS=
521         MLITE_LIBS=
522     fi
523     AC_DEFINE(DBUS_SERVICE, 1, [define if dbus service is enabled])
524
525     AC_ARG_ENABLE(dbus-service-pim,
526                   AS_HELP_STRING([--enable-dbus-service-pim[=<locale>]],
527                                  [Enable implementation of org._01.pim D-Bus APIs (depends on libfolks),
528                                   using src/dbus/server/pim/locale-factory-<locale>.cpp to implement sorting
529                                   and searching. The default is <locale>=boost, which uses boost::locale.]),
530                   [ enable_dbus_pim="$enableval" ],
531                   [ enable_dbus_pim="no" ])
532     case "$enable_dbus_pim" in
533          no) ;;
534          *)
535                 if test "$enable_dbus_pim" = "yes"; then
536                     enable_dbus_pim=boost
537                 fi
538                 if ! test -r "$srcdir/src/dbus/server/pim/locale-factory-$enable_dbus_pim.cpp"; then
539                     AC_MSG_ERROR([invalid value '$enable_dbus_pim' for --enable-dbus-service-pim, $srcdir/src/dbus/server/pim/locale-factory-$enable_dbus_pim.cpp does not exist or is not readable])
540                 fi
541                 PKG_CHECK_MODULES(FOLKS, [folks folks-eds])
542                 AC_DEFINE(ENABLE_DBUS_PIM, 1, [org._01.pim D-Bus API enabled])
543                 DBUS_PIM_PLUGIN=$enable_dbus_pim
544                 AC_SUBST(DBUS_PIM_PLUGIN)
545
546                 case "$enable_dbus_pim" in
547                     boost)
548                         AX_BOOST_LOCALE
549                         # AX_BOOST_LOCALE incorrectly puts -L/... into LDFLAGS.
550                         # That's broken because it then overrides the search path
551                         # for *all* libraries in a link, not just for boost. Fix
552                         # this by putting the LDFLAGS before the lib and leaving
553                         # DBUS_PIM_PLUGIN_LDFLAGS empty (for now - might have to
554                         # be revised if there ever are any boost flags which need
555                         # to go to the start of the link line).
556                         DBUS_PIM_PLUGIN_LIBS='$(BOOST_LDFLAGS) $(BOOST_LOCALE_LIB)'
557                         DBUS_PIM_PLUGIN_LDFLAGS=
558                         # We need to call ICU directly for the Han->Latin transformation.
559                         PKG_CHECK_MODULES(ICU, [icu-uc])
560                         ;;
561                 esac
562                 AC_SUBST(DBUS_PIM_PLUGIN_CFLAGS)
563                 AC_SUBST(DBUS_PIM_PLUGIN_LIBS)
564                 AC_SUBST(DBUS_PIM_PLUGIN_LDFLAGS)
565
566                 # http://code.google.com/p/libphonenumber/
567                 AC_LANG(C++)
568                 SAVED_CPPFLAGS=$CPPFLAGS
569                 CPPFLAGS="$CPPFLAGS ${PHONENUMBERS_CFLAGS}"
570                 AC_CHECK_HEADERS([phonenumbers/phonenumberutil.h])
571                 SAVED_LIBS=$LIBS
572                 if test ! "$PHONENUMBERS_LIBS"; then
573                       PHONENUMBERS_LIBS=-lphonenumber
574                 fi
575                 LIBS="$LIBS $PHONENUMBERS_LIBS"
576                 AC_LINK_IFELSE(
577                       [AC_LANG_PROGRAM([#include <phonenumbers/phonenumberutil.h>],
578                                        [i18n::phonenumbers::PhoneNumberUtil::GetInstance()])],
579                       [true],
580                       [AC_ERROR([libphonebook not found, set PHONENUMBERS_CFLAGS and PHONENUMBERS_LIBS.])])
581                 AC_SUBST(PHONENUMBERS_CFLAGS)
582                 AC_SUBST(PHONENUMBERS_LIBS)
583                 LIBS=$SAVED_LIBS
584                 CPPFLAGS=$SAVED_CPPFLAGS
585                 ;;
586     esac
587 fi
588 AM_CONDITIONAL([NOTIFY_COMPATIBILITY], [test "$enable_notify_compat" = "yes"])
589 AM_CONDITIONAL([COND_DBUS_PIM], [test "$enable_dbus_pim" != "no"])
590
591 AC_SUBST(DBUS_CFLAGS)
592 AC_SUBST(DBUS_LIBS)
593 AC_SUBST(DBUS_GLIB_CFLAGS)
594 AC_SUBST(DBUS_GLIB_LIBS)
595 AC_SUBST(LIBNOTIFY_CFLAGS)
596 AC_SUBST(LIBNOTIFY_LIBS)
597 AC_SUBST(LIBEXECDIR)
598
599 DBUS_SERVICES_DIR="${datadir}/dbus-1/services"
600 AC_SUBST(DBUS_SERVICES_DIR)
601 AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [Location of D-Bus services directory])
602
603 if test $enable_gui != "no" || test $enable_dbus_service = "yes"; then
604     IT_PROG_INTLTOOL([0.37.1])
605     GETTEXT_PACKAGE=syncevolution
606     AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The gettext package name])
607     AM_GLIB_GNU_GETTEXT
608     SYNCEVOLUTION_LOCALEDIR=[${datadir}/locale]
609 fi
610
611 # decide which sync-ui(s) we are building:
612 # sync-ui (in either GTK or Moblin mode) or both (in separate binaries)
613
614 if test $gtk_version = "gtk+-3.0"; then
615     gtk_dir=src/gtk3-ui
616 else
617     gtk_dir=src/gtk-ui
618 fi
619
620 case $enable_gui in
621      all) GUI_PROGRAMS=${gtk_dir}'/sync-ui-gtk${EXEEXT} '${gtk_dir}'/sync-ui-moblin${EXEEXT}'; GUI_DESKTOP_FILES="${gtk_dir}/sync-gtk.desktop ${gtk_dir}/sync-moblin.desktop";;
622      gtk|moblin) GUI_PROGRAMS=${gtk_dir}'/sync-ui${EXEEXT}'; GUI_DESKTOP_FILES="${gtk_dir}/sync.desktop";;
623      no) GUI_PROGRAMS=; GUI_DESKTOP_FILES=;;
624      *) AC_MSG_ERROR([Unknown enable_gui type: '$enable_gui'])
625 esac
626
627 if test $enable_gui != "no"; then
628     PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1 glib-2.0)
629     AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool)
630     AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
631
632     gui_modules="$gtk_version glib-2.0 dbus-glib-1 >= 0.60 gio-2.0 gio-unix-2.0"
633     if test $enable_gui = "moblin"; then
634         AC_DEFINE(USE_MOBLIN_UX, 1, [Use Moblin UI widgets])
635     fi
636
637     # gtk3 provides a switch widget, otherwise we need mx-gtk
638     if test $gtk_version != "gtk+-3.0" &&
639        test $enable_gui = "moblin" -o $enable_gui = "all"; then
640         gui_modules="$gui_modules mx-gtk-1.0"
641
642         PKG_CHECK_MODULES(MX_GTK_0_99_1, mx-gtk-1.0 >= 0.99.1,
643                           have_mx_gtk_0_99_1="yes",
644                           have_mx_gtk_0_99_1="no")
645         if test $have_mx_gtk_0_99_1 = "yes"; then
646             AC_DEFINE(MX_GTK_0_99_1, 1, [we have Mx-Gtk 0.99.1 or better])
647         fi
648     fi
649
650     PKG_CHECK_MODULES(UNIQUE, unique-1.0,
651                       have_unique="yes",
652                       have_unique="no")
653     if test $have_unique = "yes"; then
654         gui_modules="$gui_modules unique-1.0"
655         AC_DEFINE(ENABLE_UNIQUE, 1, [enable single-app-instance functionality])
656     fi
657
658     PKG_CHECK_MODULES(GTK_2_18, gtk+-2.0 >= 2.18,
659                       have_gtk_2_18="yes",
660                       have_gtk_2_18="no")
661     if test $have_gtk_2_18 = "yes"; then
662         AC_DEFINE(GTK_2_18, 1, [we have GTK+ 2.18 or better])
663     fi
664
665     PKG_CHECK_MODULES(GUI, $gui_modules)
666
667 elif test "$enable_dbus_service" = "yes"; then
668     # syncevo-dbus-server needs localization
669     :
670 else
671     INTLTOOL_UPDATE="true"
672     USE_NLS="no"
673 fi
674 AC_SUBST(SYNCEVOLUTION_LOCALEDIR)
675 AC_SUBST(GETTEXT_PACKAGE)
676 AC_SUBST(GUI_CFLAGS)
677 AC_SUBST(GUI_LIBS)
678 AC_SUBST(GUI_PROGRAMS)
679 AC_SUBST(GUI_DESKTOP_FILES)
680
681 # C++ regular expression support is required often enough to make it
682 # mandatory.
683 PKG_CHECK_MODULES(PCRECPP, libpcrecpp,,
684 AC_CHECK_LIB(pcrecpp,main,
685 AC_SUBST(PCRECPP_LIBS,-lpcrecpp),
686 AC_MSG_ERROR([pcrecpp not found])
687 ))
688
689 # need rst2man for man pages
690 AC_ARG_WITH(rst2man,
691             AS_HELP_STRING([--with-rst2man=<path to reStructuredText to man converter>],
692                            [Specifies an explicit path to the utility if not found in PATH.
693                             An explicit --without-rst2man or not having it installed turn off
694                             building of man pages.]),
695             [RST2MAN=$withval
696              if test "$RST2MAN" = "yes"; then
697                  AC_PATH_PROG(RST2MAN, rst2man, "no")
698              fi
699              test "$RST2MAN" = "no" || test -x "$RST2MAN" || AC_MSG_ERROR([--with-rst2man=$RST2MAN: tool not found])],
700             [AC_PATH_PROG(RST2MAN, rst2man, "no")])
701 AM_CONDITIONAL([COND_MAN_PAGES], [test "$RST2MAN" != "no"])
702
703 # need rst2html for HTML version of README
704 AC_ARG_WITH(rst2html,
705             AS_HELP_STRING([--with-rst2html=<path to reStructuredText to HTML converter>],
706                            [Specifies an explicit path to the utility if not found in PATH.
707                             An explicit --without-rst2html or not having it installed turn off
708                             building of README in HTML format.]),
709             [RST2HTML=$withval
710              if test "$RST2HTML" = "yes"; then
711                  AC_PATH_PROG(RST2HTML, rst2html, "no")
712              fi
713              test "$RST2HTML" = "no" || test -x "$RST2HTML" || AC_MSG_ERROR([--with-rst2html=$RST2HTML: tool not found])],
714             [AC_PATH_PROG(RST2HTML, rst2html, "no")])
715 AM_CONDITIONAL([COND_HTML_README], [test "$RST2HTML" != "no"])
716
717 # absolute patch to source of Synthesis client library
718 SYNTHESIS_SRC=no-synthesis-source
719 AC_SUBST(SYNTHESIS_SRC)
720 if test "$SYNTHESISSRC" && test "$SYNTHESISSRC" != "none"; then
721     # default: checkout a copy of the sources, remove it during maintainer-clean and distclean
722     CLEAN_CLIENT_SRC=synthesis-workdir
723     SYNTHESIS_SRC=$PWD/src/synthesis-workdir
724
725     AC_MSG_NOTICE( [updating the content of $SYNTHESIS_SRC from $SYNTHESISSRC] )
726     case "$SYNTHESISSRC" in
727         *.git) protocol=git;;
728         *://*) protocol="`echo $SYNTHESISSRC | sed -e 's;://.*;;'`";;
729         *) protocol="file";;
730     esac
731
732     mkdir -p src
733     case $protocol in
734         file)
735             # use existing copy of the sources
736             CLEAN_CLIENT_SRC=
737             case "$SYNTHESISSRC" in
738                  /*) SYNTHESIS_SRC="$SYNTHESISSRC";;
739                  *) SYNTHESIS_SRC="$PWD/$SYNTHESISSRC";;
740             esac
741             ;;
742         *svn*|*http*)
743             SYNTHESISSRCREV="$SYNTHESISSRC"
744             if test "$REVISION"; then
745                 revarg="-r $REVISION "
746                 if `echo $SYNTHESISSRC | grep '@[0123456789]*'` >/dev/null; then
747                     :
748                 else
749                     SYNTHESISSRCREV="$SYNTHESISSRC@$REVISION"
750                 fi
751             fi
752             if test -d $SYNTHESIS_SRC ; then
753                 ( set -x; cd $SYNTHESIS_SRC && svn --username=$USERNAME switch $revarg "$SYNTHESISSRC" ) || AC_MSG_ERROR([updating from $SYNTHESISSRC failed])
754             else
755                 (set -x; svn --username=$USERNAME checkout $revarg "$SYNTHESISSRCREV" $SYNTHESIS_SRC ) || AC_MSG_ERROR([checking out $SYNTHESISSRC failed])
756             fi
757             ;;
758         *)
759             if test -d $SYNTHESIS_SRC ; then
760                 ( set -x; cd $SYNTHESIS_SRC && git fetch "$SYNTHESISSRC" ) || AC_MSG_ERROR([updating from $SYNTHESISSRC failed])
761             else
762                 ( set -x; git clone "$SYNTHESISSRC" $SYNTHESIS_SRC ) || AC_MSG_ERROR([cloning $SYNTHESISSRC failed])
763             fi
764             if test "$REVISION"; then
765                 # git 1.6 finds tags and branches without explicit prefix, 1.4.4.4 doesn't
766                 ( set -x; cd $SYNTHESIS_SRC &&
767                   (git checkout "$REVISION" ||
768                    git checkout "tags/$REVISION" ||
769                    git checkout "origin/$REVISION") ) || AC_MSG_ERROR([checking out $SYNTHESISSRC failed])
770             fi
771             ;;
772     esac
773 elif test "$SYNTHESISSRC" != "none" && test -d $srcdir/src/synthesis; then
774     # use existing copy of the sources; beware of
775     # out-of-tree compilation
776     case $srcdir in
777          /*) SYNTHESIS_SRC="$srcdir/src/synthesis";;
778          *) SYNTHESIS_SRC="$PWD/$srcdir/src/synthesis";;
779     esac
780 elif test "$enable_shared" = "no"; then
781     # link against engine
782     PKG_CHECK_MODULES([SYNTHESIS], [synthesis >= 3.4])
783     SYNTHESIS_ENGINE="$SYNTHESIS_LIBS -lsynthesis -lsmltk"
784 else
785     # link against SDK alone, except in client-test
786     #PKG_CHECK_MODULES(SYNTHESIS, "synthesis-sdk")
787     #SYNTHESIS_ENGINE="`echo $SYNTHESIS_LIBS | sed -e 's/-lsynthesisstubs/-lsynthesis/'`"
788
789     # can't use the SDK alone because of sysync::SySyncDebugPuts()
790     PKG_CHECK_MODULES([SYNTHESIS], [synthesis >= SYNTHESIS_MIN_VERSION])
791     SYNTHESIS_ENGINE="$SYNTHESIS_LIBS"
792 fi
793
794 if test $SYNTHESIS_SRC != "no-synthesis-source"; then
795     ( 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])
796
797     SYNTHESIS_CONFIGURE="$SYNTHESIS_SRC/configure"
798     chmod u+x $SYNTHESIS_SRC/configure $SYNTHESIS_SRC/config.sub $SYNTHESIS_SRC/config.guess
799
800     # use local copy of the sources, with dependencies
801     # to trigger building the synthesis library
802     SYNTHESIS_SUBDIR=$PWD/src/build-synthesis
803     SYNTHESIS_CFLAGS="-I$SYNTHESIS_SUBDIR/src"
804     SYNTHESIS_LIBS="$SYNTHESIS_SUBDIR/src/libsynthesissdk.la $SYNTHESIS_SUBDIR/src/libsmltk.la"
805
806     if test "x$enable_core" = "xno" && test "x$enable_gui" != "xno"; then
807        # SYNTHESIS_SUBDIR is ignored, at least build headers for GUI
808        SYNTHESIS_SUBDIR_INCLUDES=src/synthesis-includes
809     fi
810
811     if test "$enable_shared" = "no"; then
812         # link against the engines that were enabled
813         case $SYNCML_ENGINES in both|client|server) SYNTHESIS_LIBS="$SYNTHESIS_LIBS $SYNTHESIS_SUBDIR/src/libsynthesis.la $SYNTHESIS_SUBDIR/src/libsmltk.la";; esac
814         AC_DEFINE(ENABLE_SYNCML_LINKED, 1, [SyncML engines are linked directly])
815     else
816         # It would be nice if we could avoid linking against libsynthesis.la here.
817         # This doesn't work at the moment because sysync::SySyncDebugPuts()
818         # is called directly by the libsynthesissdk instead of going through
819         # the normal C function pointer lookup.
820         SYNTHESIS_LIBS="$SYNTHESIS_LIBS $SYNTHESIS_SUBDIR/src/libsynthesis.la $SYNTHESIS_SUBDIR/src/libsmltk.la"
821     fi
822     SYNTHESIS_DEP=$SYNTHESIS_LIBS
823
824     # for linking client-test
825     SYNTHESIS_ENGINE="$SYNTHESIS_SUBDIR/src/libsynthesis.la"
826
827     AC_MSG_NOTICE( [configuring the Synthesis library] )
828     if (set -x; mkdir -p $SYNTHESIS_SUBDIR && cd $SYNTHESIS_SUBDIR && eval "\$SHELL \"\$SYNTHESIS_CONFIGURE\" $ac_configure_args \"--srcdir=\$SYNTHESIS_SRC\" " ); then true; else
829         AC_MSG_ERROR( [configuring Synthesis library failed] )
830     fi
831
832     # do the version check with the .pc files prepared by the configure step above
833     export PKG_CONFIG_PATH=$SYNTHESIS_SUBDIR:$PKG_CONFIG_PATH
834     PKG_CHECK_MODULES([WITH_SYNTHESIS_SRC], [synthesis >= SYNTHESIS_MIN_VERSION],
835                       [],
836                       [AC_MSG_ERROR([need at least libsynthesis >= SYNTHESIS_MIN_VERSION; the latest libsynthesis for SyncEvolution is the one from http://cgit.freedesktop.org/SyncEvolution/])])
837
838 fi
839
840 AC_SUBST(SYNTHESIS_CFLAGS)
841 AC_SUBST(SYNTHESIS_LIBS)
842 AC_SUBST(SYNTHESIS)
843 AC_SUBST(SYNTHESIS_SUBDIR)
844 AC_SUBST(SYNTHESIS_SUBDIR_INCLUDES)
845 AC_SUBST(SYNTHESIS_DEP)
846 AC_SUBST(SYNTHESIS_ENGINE)
847 AC_SUBST(SYNTHESIS_LIB)
848 AC_SUBST(SYNTHESISSRC)
849
850 BACKEND_CPPFLAGS="$SYNTHESIS_CFLAGS $EPACKAGE_CFLAGS $EBOOK_CFLAGS $ECAL_CFLAGS $GLIB_CFLAGS $BOOST_CPPFLAGS"
851 AC_SUBST(BACKEND_CPPFLAGS)
852
853 # GNOME Bluetooth Panel plugin
854 PKG_CHECK_MODULES(GNOMEBLUETOOTH, [gnome-bluetooth-1.0 >= 2.27.6],
855                   [have_gbt="yes"
856                    GNOMEBLUETOOTH_DIR=`$PKG_CONFIG --variable=libdir gnome-bluetooth-1.0 2>/dev/null`/gnome-bluetooth],
857                    have_gbt="no")
858 AC_SUBST(GNOMEBLUETOOTH_CFLAGS)
859 AC_SUBST(GNOMEBLUETOOTH_DIR)
860
861 AC_ARG_ENABLE(gnome-bluetooth-panel-plugin,
862         AS_HELP_STRING([--enable-gnome-bluetooth-panel-plugin],
863                        [GNOME Bluetooth panel plugin adding a "sync" button for paired devices (off by default)]),
864                        [enable_gnome_bluetooth_panel="$enableval"],
865         [enable_gnome_bluetooth_panel="no"]
866         )
867 if test "$enable_gnome_bluetooth_panel" = "yes"; then
868    test "$have_gbt" = "yes" || AC_MSG_ERROR([--enable-gnome-bluetooth-panel requires
869            pkg-config information for gnome-bluetooth-1.0 >= 2.27.6 which was not found])
870 fi
871 AM_CONDITIONAL([ENABLE_GNOME_BLUETOOTH_PANEL], [test "$have_gbt" = "yes" && test "$enable_gnome_bluetooth_panel" = "yes"])
872
873 AC_ARG_ENABLE(doc,
874               AS_HELP_STRING([--enable-doc],
875                              [generate backend and DBus API documentation]),
876               enable_doc="$enableval", enable_doc="no")
877
878 AM_CONDITIONAL([COND_DOC], [test "$enable_doc" != "no"])
879
880 dnl add backends stuff.
881 SE_ADD_BACKENDS
882
883 dnl -*- mode: Autoconf; -*-
884 dnl Invoke autogen.sh to produce a configure script.
885
886 AC_ARG_ENABLE(qt-dbus,
887               AS_HELP_STRING([--enable-qt-dbus],
888                              [build Qt bindings for D-Bus]),
889               enable_qt_dbus="$enableval", enable_qt_dbus="no")
890
891 if test "$enable_qt_dbus" = "yes"; then
892         AC_DEFINE(ENABLE_QT_DBUS, 1, [Qt D-Bus bindings available])
893         need_qt_modules="$need_qt_modules +dbus"
894         AC_PATH_PROG([QDBUSXML_TO_CPP], [qdbusxml2cpp], [no])
895         test "x$QDBUSXML_TO_CPP" != 'xno' || AC_MSG_ERROR([--enable-qt-dbus requires qdbusxml2cpp, which was not found])
896 fi
897
898 AM_CONDITIONAL([ENABLE_QT_DBUS], [test "$enable_qt_dbus" = "yes"])
899
900 AC_SUBST(QT_DBUS_LIBS)
901 AC_CONFIG_FILES([src/dbus/qt/syncevolution-qt-dbus.pc])
902
903 dnl -*- mode: Autoconf; -*-
904 dnl Invoke autogen.sh to produce a configure script.
905 dnl configure-pre.in and src/backends/*/configure-sub.in and configure-post.in come before this part
906
907 AC_SUBST(BACKEND_CPPFLAGS)
908
909 enable_any="no"
910 backend_is_enabled () {
911     eval echo \${enable_${1}}
912 }
913 for backend in $BACKENDS; do
914     if test `backend_is_enabled $backend` = "yes"; then
915        enable_any="yes"
916        SYNCEVOLUTION_MODULES="$SYNCEVOLUTION_MODULES src/backends/sync${backend}.la"
917     fi
918 done
919
920 if test "$enable_any" = "no"; then
921         AC_MSG_ERROR([no backend enabled - refusing to continue: $anymissing])
922 fi
923
924 dnl glib initialization is done only if requested by some configure-sub.in,
925 dnl for not needed otherwise even if found
926 if test "$need_glib" = "yes"; then
927         # HAVE_GLIB (aka GLIBFOUND) are a catch-all for these
928         # three GNOME libs. Assume we have all three unless one of
929         # the checks fails.
930         GLIBFOUND=yes
931
932         dnl check for glib - calling g_type_init() is expected on Maemo
933         PKG_CHECK_MODULES(GLIB, "glib-2.0", , GLIBFOUND=no)
934         # This check here is broken on Ubuntu 8.04: it calls glib-config,
935         # which isn't found, but the error is not detected by configure.
936         #if test "x${GLIBFOUND}" = "xno"; then
937         #       PKG_CHECK_MODULES(GLIB, "glib", GLIBFOUND=yes, GLIBFOUND=no)
938         #fi
939
940         PKG_CHECK_MODULES(GTHREAD, "gthread-2.0", , GLIBFOUND=no)
941         PKG_CHECK_MODULES(GOBJECT, "gobject-2.0", , GLIBFOUND=no)
942         PKG_CHECK_MODULES(GIO, "gio-2.0", , GLIBFOUND=no)
943
944         if  test "x${GLIBFOUND}" = "xyes"; then
945             AC_DEFINE(HAVE_GLIB, 1, [glib found])
946         else
947             AC_MSG_ERROR([not all GNOME libraries found])
948         fi
949         BACKEND_CPPFLAGS="$BACKEND_CPPFLAGS $GLIB_CFLAGS $GTHREAD_CFLAGS $GOBJECT_CFLAGS"
950 fi
951
952 dnl use libical if and only if required by some backend
953 if test "$need_ical" = "yes"; then
954    PKG_CHECK_MODULES(LIBICAL, libical,
955                      [true],
956                      [PKG_CHECK_MODULES(LIBICAL, libecal-1.2)])
957    AC_DEFINE(ENABLE_ICAL, 1, [libical in use])
958 fi
959 AM_CONDITIONAL([ENABLE_ICAL], [test "$need_ical" = "yes"])
960
961
962 # Check for Qt if some backend needs it.
963 if test "$need_qt_modules"; then
964    AT_WITH_QT([-gui $need_qt_modules],
965               [$qt_config],
966               [$qt_misc])
967 fi
968
969 # determine from where we can get a SHA-256 implementation
970 have_sha="no"
971 if test "$GLIBFOUND" = "yes"; then
972    # only use glib if we need it anyway, also has to be at lease 2.16
973    PKG_CHECK_MODULES(GLIB216, [glib-2.0 >= 2.16],
974                      [AC_DEFINE(USE_SHA256, 1, [choose implementation of SHA-256])
975                       have_sha="glib"],
976                      [true])
977 fi
978 if test "$have_sha" = "no"; then
979    # Fallback is Mozilla NSS. In contrast to libgcrypt it has a .pc
980    # file and a simple API.
981    PKG_CHECK_MODULES(NSS, "nss",
982                      [AC_DEFINE(USE_SHA256, 2, [choose implementation of SHA-256])
983                       have_sha="nss"],
984                      [true])
985 fi
986
987 dnl figure out whether we link all code statically or as modules
988 AM_CONDITIONAL([ENABLE_MODULES], [test "$enable_shared" = "yes"])
989 if test "$enable_shared" = "yes"; then
990         AC_DEFINE(ENABLE_MODULES, 1, [enable dynamically opening sync source backends])
991 fi
992 AC_SUBST(SYNCEVOLUTION_LDADD)
993
994 dnl CXXFLAGS gets applied to SyncEvolution and the client library.
995 dnl For e.g. "-Wall -Werror" this might not be such a good idea;
996 dnl SYNCEVOLUTION_CXXFLAGS can be used instead. It applies only
997 dnl to the sources in the SyncEvolution repository.
998 AC_SUBST(SYNCEVOLUTION_CXXFLAGS)
999
1000 dnl a quick-and-dirty way to detect compilation for the iPhone
1001 if test "$host" = "arm-apple-darwin"; then
1002    AC_DEFINE(IPHONE, 1, [compiling for iPhone])
1003    DEVICE_TYPE=iPhone
1004 fi
1005
1006 dnl --enable-evolution-compatibility
1007 if test "$enable_evolution_compatibility" = "yes"; then
1008    AC_DEFINE(EVOLUTION_COMPATIBILITY, 1, [avoid hard dependency on Evolution shared objects])
1009    # don't link against libs wrapped by eds_abi_wrapper (no longer limited to EDS alone...)
1010    ECAL_LIBS=
1011    EBOOK_LIBS=
1012    EPACKAGE_LIBS=
1013    BLUEZ_LIBS=
1014 fi
1015 AM_CONDITIONAL([ENABLE_EVOLUTION_COMPATIBILITY], [test "$enable_evolution_compatibility" = "yes"])
1016 PKG_CHECK_MODULES(LIBICAL_AVAILABLE,
1017                   libical >= 0.43,
1018                   AC_DEFINE(HAVE_LIBICAL_R, 1, [have recent enough libical with _r variants]),
1019                   pass)
1020
1021 dnl --enable-developer-mode
1022 if test "$enable_developer_mode" = "yes"; then
1023 BACKENDS_SEARCH_DIRECTORY="`pwd`/src/backends/"
1024 else
1025 BACKENDS_SEARCH_DIRECTORY='$(libdir)/syncevolution/backends/'
1026 fi
1027
1028 BACKENDS_DIRECTORY='$(libdir)/syncevolution/backends'
1029 AC_SUBST(BACKENDS_DIRECTORY)
1030 AC_SUBST(BACKENDS_SEARCH_DIRECTORY)
1031
1032 # for ActiveSync backend
1033 syncevo_backenddir='$(libdir)'/syncevolution/backends
1034 AC_SUBST(syncevo_backenddir)
1035
1036 dnl This string is sent as part of the SyncML DevInf (device
1037 dnl information) structure to the server. All SyncEvolution platforms
1038 dnl use "SyncEvolution" as HTTP user agent and "Mod" (model), so the
1039 dnl device type is the only way how different kinds of clients can be
1040 dnl distinguished.
1041 AC_DEFINE_UNQUOTED(DEVICE_TYPE, "$DEVICE_TYPE", "SyncML DevInf DevType")
1042
1043 AC_CHECK_HEADERS(stdarg.h valgrind/valgrind.h execinfo.h)
1044
1045 AC_DEFINE(SYNTHESIS, 1, "using Synthesis engine")
1046
1047 # fallback for lack of --with-docdir support in older automake
1048 if test ! "$docdir"; then
1049    docdir = ${datadir}/doc/syncevolution
1050    AC_SUBST(docdir)
1051 fi
1052
1053 AC_ARG_ENABLE(dbus-timeout-hack,
1054               AS_HELP_STRING([--enable-dbus-timeout-hack],
1055                              [Enables code which overrides the default timeout in dbus_connection_send_with_reply() so that the method call never times out. Needed for libecal/ebook >= 2.30, so enabled by default if either of these is enabled.]),
1056               [enable_dbus_timeout_hack=$enableval],
1057               [if test $enable_ebook = "yes" || test $enable_ecal = "yes"; then
1058                   enable_dbus_timeout_hack="yes"
1059                fi])
1060 if test "$enable_dbus_timeout_hack" = "yes"; then
1061    AC_DEFINE(ENABLE_DBUS_TIMEOUT_HACK, 1, [overrides the default D-Bus timeout so that synchronous calls never time out])
1062 fi
1063
1064 # Avoid hard-coding paths in backends. These names are chosen so
1065 # that a backend can alternatively use its own top-level configure
1066 # with PKG_CHECK_MODULES(SYNCEVOLUTION, "syncevolution") to set them.
1067 # need absolute path, use pwd instead of relative $srcdir
1068 #
1069 # When adding something here, remember to also update syncevolution.pc.in.
1070 # -lrt is for clock_gettime() in the Timespec.h inline functions.
1071 SYNCEVOLUTION_CFLAGS=-I`cd $srcdir && pwd`/src
1072 # Linker flags including libsyncevolution.la and some libs.
1073 SYNCEVOLUTION_LIBS="src/syncevo/libsyncevolution.la -lrt"
1074 AC_SUBST(SYNCEVOLUTION_CFLAGS)
1075 AC_SUBST(SYNCEVOLUTION_LIBS)
1076
1077 # invoking syncevolution binary is allowed to fail when cross-compiling
1078 AM_CONDITIONAL([COND_CROSS_COMPILING], [test "$cross_compiling" = "yes"])
1079
1080 AC_CONFIG_FILES([
1081   Makefile
1082   src/syncevo/syncevolution.pc
1083   src/synthesis-includes/Makefile
1084   po/Makefile.in
1085   src/dbus/glib/syncevo-dbus.pc
1086 ])
1087 AC_OUTPUT
1088
1089 echo
1090 echo CONFIGURATION SUMMARY
1091 echo "Core SyncEvolution: $enable_core"
1092 for backend in $BACKENDS; do
1093     eval echo $backend: \${enable_${backend}}
1094 done
1095 echo "DBus service: $enable_dbus_service"
1096 echo "org._01.pim support in DBus service: $enable_dbus_pim"
1097 echo "Notifications: $enable_notify"
1098 echo "GIO GDBus: $with_gio_gdbus"
1099 echo "GNOME keyring: $enable_gnome_keyring"
1100 if test "$enable_gui" = "no"; then
1101     echo "UI (DBus client): no"
1102 else
1103     echo "UI (DBus client): $enable_gui (using $gtk_version)"
1104 fi
1105 echo "Bluetooth transport: $have_bluetooth"
1106 echo "GNOME Bluetooth panel plugin: $enable_gnome_bluetooth_panel"
1107 echo "SHA-256: $have_sha"
1108 echo "API documentation: $enable_doc"
1109 echo "D-Bus Timeout Hack: $enable_dbus_timeout_hack"
1110 echo