summaryrefslogtreecommitdiff
path: root/configure-pre.in
blob: 1184a6d9bcf48cc3f2ee7f59aedff97eb6fd1ea5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
dnl -*- mode: Autoconf; -*-
dnl Invoke autogen.sh to produce a configure script.

# The STABLE_VERSION is used when building
# Debian packages. For prereleases (beta, alpha),
# set it to something like "0.9.2+" and the AC_INIT
# VERSION to 1.0beta1 to produce 0.9.2+1.0beta1.
AC_INIT([syncevolution], [1.0beta2a])
STABLE_VERSION=0.9.2+
AC_SUBST(STABLE_VERSION)

AM_INIT_AUTOMAKE([tar-ustar])
AC_CONFIG_MACRO_DIR([m4])
define([SYNTHESISSRC_REPO], [])
dnl Specify git revisions/branches without prefix, i.e., without 'origin'.
dnl We'll sort that out below.
define([SYNTHESISSRC_REVISION], [syncevolution-0.9])
AM_CONFIG_HEADER(config.h)
AC_LIBTOOL_DLOPEN

dnl default device type (see AC_DEFINE below)
DEVICE_TYPE=workstation

AC_ARG_WITH(synthesis-src,
            AS_HELP_STRING([--with-synthesis-src=<base directory|svn URL|git URL>],
                           [Specifies location of the Synthesis root directory.
                           Use this when the Synthesis library is to
                           be compiled as part of the SyncEvolution compilation. In release
                           versions of SyncEvolution, a copy of the Synthesis code is bundled
                           under 'src/synthesis' and compiled unless something else is
                           specified. --with-synthesis-src can be given a path to sources
                           checked out already, a Subversion repository URL or a git repository
                           URL. When given a repository URL, then the configure script
                           will checkout the sources into 'src/synthesis-workdir' or
                           update that working copy if the directory already exists.
                           Default: bundled source in src/synthesis (in released SyncEvolution sources),
                           SYNTHESISSRC_REPO otherwise.]),
            [SYNTHESISSRC="$withval"
             test "$SYNTHESISSRC" != "yes" || AC_MSG_ERROR([--with-synthesis-src requires a parameter (base directory, svn URL or git URL)])],
            [SYNTHESISSRC="$SYNTHESISSRC_DEF"; REVISION="SYNTHESISSRC_REVISION"])

AC_ARG_WITH(syncml-engines,
            AS_HELP_STRING([--with-syncml-engines=client|server|both],
                           [Determines which kind of support for SyncML is compiled and linked into SyncEvolution. Default is both. Currently has no effect.]),
            [SYNCML_ENGINES="$withval"], SYNCML_ENGINES=both)

case $SYNCML_ENGINES in both|client) AC_DEFINE(ENABLE_SYNCML_CLIENT, 1, [SyncML client support available]);; esac
case $SYNCML_ENGINES in both|server) AC_DEFINE(ENABLE_SYNCML_SERVER, 1, [SyncML server support available]);; esac
case $SYNCML_ENGINES in both|server|client) true;; *) AC_ERROR([Invalid value for --with-syncml-engines: $SYNCML_ENGINES]);; esac

AC_ARG_WITH(synthesis-username,
            AS_HELP_STRING([--with-synthesis-username=<svn username>],
                           [username to use when checking out --with-synthesis-src sources from Subversion, default 'guest']),
            [USERNAME="$withval"], [USERNAME="guest"])

AC_ARG_WITH(synthesis-revision,
            AS_HELP_STRING([--with-synthesis-revision=<git tag/branch/hash or Subversion revision>],
                           [Identifies which source revision to use from --with-synthesis-src repository, empty string stands for latest. Default for default --synthesis-src: SYNTHESISSRC_REVISION]),
            [REVISION="$withval"])

AC_ARG_ENABLE(shared,
              AS_HELP_STRING([--enable-shared],
                             [build backends as dynamically loadable modules]),
              enable_shared="$enableval", enable_shared="no")

AC_ARG_ENABLE(static,
              AS_HELP_STRING([--enable-static],
                             [build backends also as static libraries]),
              enable_static="$enableval", enable_static="no")

AC_ARG_ENABLE(unit-tests,
              AS_HELP_STRING([--enable-unit-tests],
                             [enables tests embedded in the source code of the library (changes content of executable)]),
              enable_unit_tests="$enableval", enable_unit_tests="no")
AC_ARG_ENABLE(integration-tests,
              AS_HELP_STRING([--enable-integration-tests],
                             [enables tests outside of the library (can be used together with normal builds of the library)]),
              enable_integration_tests="$enableval", enable_integration_tests="no")

AC_ARG_ENABLE(static-cxx,
              AS_HELP_STRING([--enable-static-cxx],
                             [build executables which contain libstdc++ instead of requiring suitable libstdc++.so to run]),
              enable_static_cxx="$enableval", enable_static_cxx="no")

AC_ARG_ENABLE(evolution-compatibility,
              AS_HELP_STRING([--enable-evolution-compatibility],
                             [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]),
              enable_evolution_compatibility="$enableval", enable_evolution_compatibility="no")

AC_ARG_ENABLE(developer-mode, 
             AC_HELP_STRING([--enable-developer-mode], 
                            [The dynamic loadble backend libraries is loaded from current build directory instead of the standard library path]),
             enable_developer_mode="$enableval", enable_developer_mode="no")

# Maemo hacks:
# - set the (non-standard!) DBUS_DEFAULT_TIMEOUT
# - wrap e_book_from_string() to fix invalid parameter
# - don't use UTF-8 encoding in Perl script
AC_ARG_ENABLE(maemo,
              AS_HELP_STRING([--enable-maemo],
                             [enables some hacks which work around problems with the Maemo 2.0 until at least 3.0 EDS-Dbus]),
              [AC_DEFINE(ENABLE_MAEMO, 1, [enable Maemo hacks])
               DEVICE_TYPE=Maemo
               MODIFY_SYNCCOMPARE='-e "s/use encoding/#use encoding/;" -e "s/:utf8//;"'])
AC_SUBST(MODIFY_SYNCCOMPARE)

AC_CHECK_HEADERS(signal.h dlfcn.h)

# cppunit needed?
if test $enable_unit_tests == "yes" || test $enable_integration_tests == yes; then
        CPPUNIT_CXXFLAGS=`cppunit-config --cflags` || AC_MSG_ERROR("cppunit-config --cflags failed - is it installed?")
        CPPUNIT_LDFLAGS=`cppunit-config --libs` || AC_MSG_ERROR("cppunit-config --libs failed - is it installed?")
fi
AC_SUBST(CPPUNIT_CXXFLAGS)
AC_SUBST(CPPUNIT_LDFLAGS)

if test "$enable_unit_tests" = "yes"; then
        AC_DEFINE(ENABLE_UNIT_TESTS, 1, [enable unit tests inside the library's source code])
fi
if test "$enable_integration_tests" = "yes"; then
        AC_DEFINE(ENABLE_INTEGRATION_TESTS, 1, [enable integration tests inside the final library])
fi
AM_CONDITIONAL([ENABLE_UNIT_TESTS], [test "$enable_unit_tests" = "yes"])
AM_CONDITIONAL([ENABLE_TESTING], [test "$enable_unit_tests" = "yes" || test "$enable_integration_tests" = "yes" ])

if test $enable_static_cxx == "yes"; then
        LIBS="$LIBS -L."
        CORE_LDADD_DEP=libstdc++.a
fi
AC_SUBST(CORE_LDADD_DEP)

# Check for transport layer.
# Both curl and libsoup can be enabled and disabled explicitly.
# The default is to use libsoup if available, otherwise curl.

AC_MSG_CHECKING([for libcurl])
if LIBCURL_LIBS=`sh -c 'curl-config --libs' 2>&AS_MESSAGE_LOG_FD` && \
    LIBCURL_CFLAGS=`sh -c 'curl-config --cflags' 2>&AS_MESSAGE_LOG_FD`; then
    AC_MSG_RESULT([yes])
    have_libcurl="yes"
else
    AC_MSG_RESULT([no])
    have_libcurl="no"
fi

PKG_CHECK_MODULES(LIBSOUP, libsoup-gnome-2.4,
                  [have_libsoup="yes"
                   AC_DEFINE(HAVE_LIBSOUP_SOUP_GNOME_FEATURES_H, 1, [enable GNOME specific libsoup])],
                  [PKG_CHECK_MODULES(LIBSOUP, libsoup-2.4,
                                     have_libsoup="yes",
                                     have_libsoup="no")])

PKG_CHECK_MODULES(LIBOPENOBEX, openobex, have_obex="yes", have_obex="no")
have_bluetooth="no"
if test $have_obex = "yes"; then
    PKG_CHECK_MODULES(BLUEZ, bluez, have_bluez="yes", have_bluez="no")
    if test $have_bluez = "yes"; then
        have_bluetooth="yes"
    fi
fi
AC_SUBST(LIBOPENOBEX_CFLAGS)
AC_SUBST(LIBOPENOBEX_LIBS)
AC_SUBST(BLUEZ_CFLAGS)
AC_SUBST(BLUEZ_LIBS)

TRANSPORT=
TRANSPORT_LIBS=
TRANSPORT_CFLAGS=

AC_ARG_WITH(ca-certificates,
            AS_HELP_STRING([--with-ca-certificates=<colon separated list of files>],
                           [Specifies location of one or more CA certificate files.
                           This sets the default value for the SSLServerCertificates option.
                           Default: empty when using libcurl (because it has its own default),
                           a list of paths known to work for Debian and Red Hat otherwise.]),
            [CA_CERTIFICATES="$withval"])


# choose default http transport (mirrors code in EvolutionSyncClient::createTransportAgent())
if test "$have_libsoup" = "yes"; then
   default_http_transport="libsoup"
elif test "$have_libcurl" = "yes"; then
   default_http_transport="libcurl"
fi

AC_ARG_ENABLE(libcurl,
              AC_HELP_STRING([--enable-libcurl],
                             [enable libcurl as transport layer]),
              [ if test "$enableval" = "yes"; then
                   test "$have_libcurl" = "yes" || AC_MSG_ERROR([libcurl not found])
                   TRANSPORT="$TRANSPORT libcurl"
                   TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBCURL_LIBS"
                   TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBCURL_CFLAGS"
                   AC_DEFINE(ENABLE_LIBCURL, 1, [enable libcurl transport])
                else
                   libcurl_disabled="yes"
                fi ],
              [ if test "$have_libcurl" = "yes" && test "$default_http_transport" = "libcurl" ; then
                   TRANSPORT="$TRANSPORT libcurl"
                   TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBCURL_LIBS"
                   TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBCURL_CFLAGS"
                   AC_DEFINE(ENABLE_LIBCURL, 1, [enable libcurl transport])
                fi ])

AC_ARG_ENABLE(libsoup,
              AC_HELP_STRING([--enable-libsoup],
                             [enable libsoup as transport layer]),
              [ if test "$enableval" = "yes"; then
                   test "$have_libsoup" = "yes" || AC_MSG_ERROR([libsoup not found])
                   TRANSPORT="$TRANSPORT libsoup"
                   TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBSOUP_LIBS"
                   TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBSOUP_CFLAGS"
                   AC_DEFINE(ENABLE_LIBSOUP, 1, [enable libsoup transport])
                else
                   libsoup_disabled="yes"
                fi ],
              [ if test "$have_libsoup" = "yes" && test "$default_http_transport" = "libsoup"; then
                   TRANSPORT="$TRANSPORT libsoup"
                   TRANSPORT_LIBS="$TRANSPORT_LIBS $LIBSOUP_LIBS"
                   TRANSPORT_CFLAGS="$TRANSPORT_CFLAGS $LIBSOUP_CFLAGS"
                   AC_DEFINE(ENABLE_LIBSOUP, 1, [enable libsoup transport])
                fi ])

bluetooth_disabled=no
AC_ARG_ENABLE(bluetooth,
              AC_HELP_STRING([--enable-bluetooth],
                             [enable bluetooth transport support]),
              [ enable_bluetooth="$enableval"
                if test "$enableval" = "no"; then
                    bluetooth_disabled=yes
                fi
              ],
              [ enable_bluetooth="$have_bluetooth" ])

if test "$enable_bluetooth" = "yes"; then
   # currently we need Bluetooth and OBEX support
   test "$have_bluetooth" = "yes" || AC_MSG_ERROR([openobex or bluez not found])   

   AC_LANG(C)
   CFLAGS_old="$CFLAGS"
   CFLAGS="$CPPFLAGS $BLUEZ_CFLAGS"
   # test in this order:
   # - recent libbluetooth (no _safe variant, base function has bufsize)
   # - intermediate with _safe
   # - else assume old-style (no bufsize, no _safe)
   #
   # The source code checks the signature both by via pointer assignment and calling
   # it (better safe than sorry). One these should fail if the signature is not right.
   AC_COMPILE_IFELSE([#include <bluetooth/sdp.h>
                      #include <bluetooth/sdp_lib.h>
                      sdp_record_t *(*extract_pdu)(const uint8_t *pdata, int bufsize, int *scanned) =
                           sdp_extract_pdu;
                      void foo(void) {
                          uint8_t *pdata = NULL;
                          int scanned;
                          sdp_extract_pdu(pdata, 100, &scanned);
                      }
                     ],
                     AC_DEFINE(HAVE_BLUEZ_BUFSIZE, 1, [base libbluetooth functions accept bufsize parameter]),
                     AC_COMPILE_IFELSE([#include <bluetooth/sdp.h>
                                        #include <bluetooth/sdp_lib.h>
                                        sdp_record_t *(*extract_pdu)(const uint8_t *pdata, int bufsize, int *scanned) =
                                               sdp_extract_pdu_safe;
                                        void foo(void) {
                                            uint8_t *pdata = NULL;
                                            int scanned;        
                                            sdp_extract_pdu_safe(pdata, 100, &scanned);
                                        }
                                       ],
                                       AC_DEFINE(HAVE_BLUEZ_SAFE, 1, [libbluetooth has _safe variants])))
   CFLAGS="$CFLAGS_old"

   if test "$have_obex" = "yes"; then
      AC_DEFINE(ENABLE_OBEX, 1, [define if openobex library is available])
   fi
   if test "$have_bluez" = "yes"; then
      AC_DEFINE(ENABLE_BLUETOOTH, 1, [define if bluez library is available])
   fi
fi
AM_CONDITIONAL([ENABLE_OBEX], [test "$have_obex" = "yes" && test "$enable_bluetooth" = "yes"])
AM_CONDITIONAL([ENABLE_BLUETOOTH], [test "$have_bluetooth" = "yes" && test "$enable_bluetooth" = "yes"])

if test ! "$TRANSPORT" &&
   test "$libsoup_disabled" != "yes" &&
   test "$libcurl_disabled" != "yes" &&
   test "$bluetooth_disabled" != "yes" &&
   test "$have_bluetooth" != "yes" ; then
   AC_ERROR([no transport library found, configure with --disable-libcurl --disable-libsoup --disable-bluetooth to continue anyway (only useful if users of libsyncevolution provide transport implementation)])
fi

# for libsoup we must specify the SSL certificate file outself
if test "$libsoup_disabled" != "yes" && test -z "$CA_CERTIFICATES"; then
   # Debian and Red Hat paths
   CA_CERTIFICATES="/etc/ssl/certs/ca-certificates.crt:/etc/pki/tls/certs/ca-bundle.crt:/usr/share/ssl/certs/ca-bundle.crt"
fi
AC_DEFINE_UNQUOTED(SYNCEVOLUTION_SSL_SERVER_CERTIFICATES, "$CA_CERTIFICATES", [default value for SSLServerCertificates option])

AC_SUBST(TRANSPORT_LIBS)
AC_SUBST(TRANSPORT_CFLAGS)

AC_ARG_ENABLE(ssl-certificate-check,
              AC_HELP_STRING([--disable-ssl-certificate-check],
                             [Disable SSL certificate checking in all server
                              *templates*.  Users can still choose to enable or
                              disable it in their configuration. This is necessary on
                              platforms where the transport library has problems
                              verifying the server's certificate (libsoup + Google,
                              http://bugzilla.moblin.org/show_bug.cgi?id=4551)]),
             enable_ssl_certificate_check="$enableval",
             enable_ssl_certificate_check="yes")
if test "$enable_ssl_certificate_check" = "yes"; then
   AC_DEFINE(ENABLE_SSL_CERTIFICATE_CHECK, 1, [enable SSL certificate check in server templates])
fi

# for dbus interface file mangling
AC_PATH_PROG(XSLT, xsltproc)

AC_ARG_ENABLE(gui,
              AS_HELP_STRING([--enable-gui[=gui type]],
                             [enables building the GTK+ UI that uses the SyncEvolution DBus API.
                              Options: gtk, moblin, all (builds sync-ui-gtk and sync-ui-moblin)
                              "gtk" is the default for --enable-gui without type. No GUI is
                              built when --enable-gui is not used.
                              --enable-gui implies --enable-dbus.]),
              [ if test "$enableval" = "gtk" ; then
                    enable_gui=gtk
                elif test "$enableval" = "yes" ; then
                    enable_gui=gtk
                elif test "$enableval" = "moblin" ; then
                    enable_gui=moblin
                elif test "$enableval" = "no" ; then
                    enable_gui=no
                elif test "$enableval" = "all" ; then
                    enable_gui=all
                else
                    AC_ERROR([Unknown gui type: '$enableval'])
                fi
              ],
              [ enable_gui=no ])

AM_CONDITIONAL([COND_GUI], [test "$enable_gui" != "no"])

AC_ARG_ENABLE(dbus-service,
              AS_HELP_STRING([--enable-dbus-service],
                             [enables building the dbus service executable and the wrapper library for it]),
              enable_dbus_service="$enableval",
              [if test $enable_gui == "no"; then
                  enable_dbus_service="no"
               else
                  enable_dbus_service="yes"
               fi])
AM_CONDITIONAL([COND_DBUS], [test "$enable_dbus_service" = "yes"])

if test $enable_gui != "no" && test $enable_dbus_service == "no"; then
   AC_ERROR([cannot build GUI without building the D-Bus service])
fi

PKG_CHECK_MODULES(KEYRING, [gnome-keyring-1], HAVE_KEYRING=yes, HAVE_KEYRING=no)
if test $HAVE_KEYRING == "yes"; then
    AC_DEFINE(USE_GNOME_KEYRING, 1, [define if gnome keyring should be used in dbus service])
    PKG_CHECK_MODULES([KEYRING_2_20], [gnome-keyring-1 >= 2.20 ], KEYRING220=yes, KEYRING220=no)
    if test $KEYRING220 == "yes"; then
        AC_DEFINE(GNOME_KEYRING_220, 1, [define if gnome keyring version is above 2.20])
    fi
fi

if test $enable_dbus_service == "yes"; then
    PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1 glib-2.0)
    AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool)
    AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
    if test -z "$XSLT"; then
       AC_ERROR([xsltproc not found, is required for D-Bus service])
    fi
    PKG_CHECK_MODULES(DBUS, dbus-1, dummy=yes,
                      AC_MSG_ERROR(libdbus-1 is required))
    AC_CHECK_LIB(dbus-1, dbus_watch_get_unix_fd, dummy=yes,
                 AC_DEFINE(NEED_DBUS_WATCH_GET_UNIX_FD, 1,
                 [Define to 1 if you need the dbus_watch_get_unix_fd() function.]))
    need_glib=yes
fi
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS)
AC_SUBST(DBUS_GLIB_CFLAGS)
AC_SUBST(DBUS_GLIB_LIBS)
AC_SUBST(KEYRING_CFLAGS) 
AC_SUBST(KEYRING_LIBS) 
AC_SUBST(LIBEXECDIR)

DBUS_SERVICES_DIR="${datadir}/dbus-1/services"
AC_SUBST(DBUS_SERVICES_DIR)
AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [Location of D-Bus services directory])

# decide which sync-ui(s) we are building:
# sync-ui (in either GTK or Moblin mode) or both (in separate binaries)
case $enable_gui in
     all) GUI_PROGRAMS='sync-ui-gtk${EXEEXT} sync-ui-moblin${EXEEXT}'; GUI_DESKTOP_FILES="sync-gtk.desktop sync-moblin.desktop";;
     gtk|moblin) GUI_PROGRAMS='sync-ui${EXEEXT}'; GUI_DESKTOP_FILES="sync.desktop";;
     no) GUI_PROGRAMS=; GUI_DESKTOP_FILES=;;
     *) AC_ERROR([Unknown enable_gui type: '$enable_gui'])
esac

if test $enable_gui != "no"; then
    gui_modules="glib-2.0 dbus-glib-1 >= 0.60 gtk+-2.0 libglade-2.0 gio-2.0"
    if test $enable_gui == "moblin"; then
        AC_DEFINE(USE_MOBLIN_UX, 1, [Use Moblin UI widgets])
    fi
    if test $enable_gui == "moblin" -o $enable_gui == "all"; then
        gui_modules="$guimodules mx-gtk-1.0"
    fi

    PKG_CHECK_MODULES(UNIQUE, unique-1.0,
                      have_unique="yes",
                      have_unique="no")
    if test $have_unique == "yes"; then
        gui_modules="$gui_modules unique-1.0" 
        AC_DEFINE(ENABLE_UNIQUE, 1, [enable single-app-instance functionality])
    fi

    PKG_CHECK_MODULES(GTK_2_18, gtk+-2.0 >= 2.18,
                      have_gtk_2_18="yes",
                      have_gtk_2_18="no")
    if test $have_gtk_2_18 == "yes"; then
        AC_DEFINE(GTK_2_18, 1, [we have GTK+ 2.18 or better])
    fi

    PKG_CHECK_MODULES(GUI, $gui_modules)

    AC_PATH_PROG([GTK_BUILDER_CONV], gtk-builder-convert)
    IT_PROG_INTLTOOL([0.37.1])
    GETTEXT_PACKAGE=syncevolution
    AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The gettext package name])
    AM_GLIB_GNU_GETTEXT
    SYNCEVOLUTION_LOCALEDIR=[${datadir}/locale]
else
    INTLTOOL_UPDATE="true"
    USE_NLS="no"
fi
AC_SUBST(SYNCEVOLUTION_LOCALEDIR)
AC_SUBST(GETTEXT_PACKAGE)
AC_SUBST(GUI_CFLAGS)
AC_SUBST(GUI_LIBS)
AC_SUBST(GUI_PROGRAMS)
AC_SUBST(GUI_DESKTOP_FILES)


# Boost headers: boost/foreach.hpp is needed (1.33/Debian Etch
# doesn't have it, 1.34/Ubuntu 8.10 Hardy does). 1.35 is available
# as Debian Etch backport.
AX_BOOST_BASE(1.34)

# absolute patch to source of Synthesis client library
SYNTHESIS_SRC=no-synthesis-source
AC_SUBST(SYNTHESIS_SRC)
if test "$SYNTHESISSRC" && test "$SYNTHESISSRC" != "none"; then
    # default: checkout a copy of the sources, remove it during maintainer-clean and distclean
    CLEAN_CLIENT_SRC=synthesis-workdir
    SYNTHESIS_SRC=$PWD/src/synthesis-workdir

    AC_MSG_NOTICE( [updating the content of $SYNTHESIS_SRC from $SYNTHESISSRC] )
    case "$SYNTHESISSRC" in
        *.git) protocol=git;;
        *://*) protocol="`echo $SYNTHESISSRC | sed -e 's;://.*;;'`";;
        *) protocol="file";;
    esac

    mkdir -p src
    case $protocol in
        file)
            # use existing copy of the sources
            CLEAN_CLIENT_SRC=
            case "$SYNTHESISSRC" in
                 /*) SYNTHESIS_SRC="$SYNTHESISSRC";;
                 *) SYNTHESIS_SRC="$PWD/$SYNTHESISSRC";;
            esac
            ;;
        *svn*|*http*)
            SYNTHESISSRCREV="$SYNTHESISSRC"
            if test "$REVISION"; then
                revarg="-r $REVISION "
                if `echo $SYNTHESISSRC | grep '@[0123456789]*'` >/dev/null; then
                    :
                else
                    SYNTHESISSRCREV="$SYNTHESISSRC@$REVISION"
                fi
            fi
            if test -d $SYNTHESIS_SRC ; then
                ( set -x; cd $SYNTHESIS_SRC && svn --username=$USERNAME switch $revarg "$SYNTHESISSRC" ) || AC_ERROR([updating from $SYNTHESISSRC failed])
            else
                (set -x; svn --username=$USERNAME checkout $revarg "$SYNTHESISSRCREV" $SYNTHESIS_SRC ) || AC_ERROR([checking out $SYNTHESISSRC failed])
            fi
            ;;
        *)
            if test -d $SYNTHESIS_SRC ; then
                ( set -x; cd $SYNTHESIS_SRC && git fetch "$SYNTHESISSRC" ) || AC_ERROR([updating from $SYNTHESISSRC failed])
            else
                ( set -x; git clone "$SYNTHESISSRC" $SYNTHESIS_SRC ) || AC_ERROR([cloning $SYNTHESISSRC failed])
            fi
            if test "$REVISION"; then
                # git 1.6 finds tags and branches without explicit prefix, 1.4.4.4 doesn't
                ( set -x; cd $SYNTHESIS_SRC &&
                  (git checkout "$REVISION" ||
                   git checkout "tags/$REVISION" ||
                   git checkout "origin/$REVISION") ) || AC_ERROR([checking out $SYNTHESISSRC failed])
            fi
            ;;
    esac
elif test "$SYNTHESISSRC" != "none" && test -d $srcdir/src/synthesis; then
    # use existing copy of the sources; beware of
    # out-of-tree compilation
    case $srcdir in
         /*) SYNTHESIS_SRC="$srcdir/src/synthesis";;
         *) SYNTHESIS_SRC="$PWD/$srcdir/src/synthesis";;
    esac
elif test "$enable_shared" = "no"; then
    # link against engine
    PKG_CHECK_MODULES(SYNTHESIS, "synthesis")
    SYNTHESIS_ENGINE="$SYNTHESIS_LIBS -lsynthesis"
else
    # link against SDK alone, except in client-test
    #PKG_CHECK_MODULES(SYNTHESIS, "synthesis-sdk")
    #SYNTHESIS_ENGINE="`echo $SYNTHESIS_LIBS | sed -e 's/-lsynthesisstubs/-lsynthesis/'`"

    # can't use the SDK alone because of sysync::SySyncDebugPuts()
    PKG_CHECK_MODULES(SYNTHESIS, "synthesis")
    SYNTHESIS_ENGINE="$SYNTHESIS_LIBS"
fi

if test $SYNTHESIS_SRC != "no-synthesis-source"; then
    ( 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])

    SYNTHESIS_CONFIGURE="$SYNTHESIS_SRC/configure"
    chmod u+x $SYNTHESIS_SRC/configure $SYNTHESIS_SRC/config.sub $SYNTHESIS_SRC/config.guess

    # use local copy of the sources, with dependencies
    # to trigger building the synthesis library
    SYNTHESIS_SUBDIR=$PWD/src/build-synthesis
    SYNTHESIS_CFLAGS="-I$SYNTHESIS_SUBDIR/src"
    SYNTHESIS_LIBS="$SYNTHESIS_SUBDIR/src/libsynthesissdk.la"

    if test "$enable_shared" = "no"; then
        # link against the engines that were enabled
        case $SYNCML_ENGINES in both|client|server) SYNTHESIS_LIBS="$SYNTHESIS_LIBS $SYNTHESIS_SUBDIR/src/libsynthesis.la";; esac
        AC_DEFINE(ENABLE_SYNCML_LINKED, 1, [SyncML engines are linked directly])
    else
        # It would be nice if we could avoid linking against libsynthesis.la here.
        # This doesn't work at the moment because sysync::SySyncDebugPuts()
        # is called directly by the libsynthesissdk instead of going through
        # the normal C function pointer lookup.
        SYNTHESIS_LIBS="$SYNTHESIS_LIBS $SYNTHESIS_SUBDIR/src/libsynthesis.la"
    fi
    SYNTHESIS_DEP=$SYNTHESIS_LIBS

    # for linking client-test
    SYNTHESIS_ENGINE="$SYNTHESIS_SUBDIR/src/libsynthesis.la"

    AC_MSG_NOTICE( [configuring the Synthesis library] )
    if (set -x; mkdir -p $SYNTHESIS_SUBDIR && cd $SYNTHESIS_SUBDIR && eval "\$SHELL \"\$SYNTHESIS_CONFIGURE\" $ac_configure_args \"--srcdir=\$SYNTHESIS_SRC\" " ); then true; else
        AC_MSG_ERROR( [configuring Synthesis library failed] )
    fi
fi

AC_SUBST(SYNTHESIS_CFLAGS)
AC_SUBST(SYNTHESIS_LIBS)
AC_SUBST(SYNTHESIS)
AC_SUBST(SYNTHESIS_SUBDIR)
AC_SUBST(SYNTHESIS_DEP)
AC_SUBST(SYNTHESIS_ENGINE)
AC_SUBST(SYNTHESIS_LIB)
AC_SUBST(SYNTHESISSRC)

dnl select backends
BACKENDS=""

# AC_ARG_ENABLE_BACKEND(BACKEND, DIR, HELP-STRING, [ACTION-IF-GIVEN],
#                       [ACTION-IF-NOT-GIVEN])
#
# Same as AC_ARG_ENABLE(), but also tells configure that the
# backend exists.
#
# BACKEND = name of modules built in that dir as .la files without the
#           obligatory sync prefix, e.g. "ebook"
# DIR = name of the directory inside src/backends, e.g., "evolution"
AC_DEFUN([AC_ARG_ENABLE_BACKEND],
[
        AC_ARG_ENABLE($1, $3, $4, $5)
        BACKENDS="$BACKENDS $1"
        BACKEND_DEFINES="$BACKEND_DEFINES ENABLE_`echo $1 | tr a-z A-Z`"
        for source in $2; do
            SYNCSOURCES="$SYNCSOURCES backends/$2/sync$1.la"
        done
])
AC_SUBST(SYNCSOURCES)
AC_SUBST(BACKEND_DEFINES)

BACKEND_CPPFLAGS="$SYNTHESIS_CFLAGS $EPACKAGE_CFLAGS $EBOOK_CFLAGS $ECAL_CFLAGS $GLIB_CFLAGS $BOOST_CPPFLAGS"
AC_SUBST(BACKEND_CPPFLAGS)

# GNOME Bluetooth Panel plugin
PKG_CHECK_MODULES(GNOMEBLUETOOTH, [gnome-bluetooth-1.0 >= 2.27.6],
                  [have_gbt="yes"
                   GNOMEBLUETOOTH_DIR=`$PKG_CONFIG --variable=libdir gnome-bluetooth-1.0 2>/dev/null`/gnome-bluetooth],
                   have_gbt="no")
AC_SUBST(GNOMEBLUETOOTH_CFLAGS)
AC_SUBST(GNOMEBLUETOOTH_DIR)

AC_ARG_ENABLE(gnome-bluetooth-panel-plugin, 
        AC_HELP_STRING([--enable-gnome-bluetooth-panel-plugin],
                       [GNOME Bluetooth panel plugin adding a "sync" button for paired devices (off by default)]),
                       [enable_gnome_bluetooth_panel="$enableval"],
        [enable_gnome_bluetooth_panel="no"]
        )
if test "$enable_gnome_bluetooth_panel" = "yes"; then
   test "$have_gbt" = "yes" || AC_MSG_ERROR([--enable-gnome-bluetooth-panel requires
           pkg-config information for gnome-bluetooth-1.0 >= 2.27.6 which was not found])
fi
AC_CONFIG_FILES(src/gnome-bluetooth/Makefile)
AM_CONDITIONAL([ENABLE_GNOME_BLUETOOTH_PANEL], [test "$have_gbt" = "yes" && test "$enable_gnome_bluetooth_panel" = "yes"])


dnl src/backends/*/configure-sub.in and configure-post.in follow