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