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