summaryrefslogtreecommitdiff
path: root/configure.ac
blob: cc4486136c3e729ee59ee43c6ab449ccfec81b1e (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
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
# If not 1, append datestamp to the version number
m4_define([folks_released], [0])

m4_define([folks_major_version], [0])
m4_define([folks_minor_version], [11])
m4_define([folks_micro_version], [0])
m4_define([folks_nano_version], [0])

# Core library LT version. When updating this, don't forget to bump the backend
# library LT versions too, below.
#
# To update the version, follow these instructions sequentially:
#
#  1. If the library source code has changed at all since the last update, then
#     increment revision (‘c:r:a’ becomes ‘c:r+1:a’).
#  2. If any interfaces have been added, removed, or changed since the last
#     update, increment current, and set revision to 0.
#  3. If any interfaces have been added since the last public release, then
#     increment age.
#  4. If any interfaces have been removed or changed since the last public
#     release, then set age to 0.
#
# The LT current version number is additionally used as libfolks' module API
# version number: a given libfolks.so will only load modules which were compiled
# against a core with the same LT current number as itself. This allows the API
# which is exposed to the modules to be changed.
m4_define([folks_lt_current], [42])
m4_define([folks_lt_revision], [3])
m4_define([folks_lt_age], [17])

# Each of the backend libraries (e.g. libfolks-eds.so; *not* the loadable
# modules, eds.so) has its own LT version. These should be incremented when the
# core folks_lt_* variables are incremented (as all the backend libraries are
# binary-dependent on libfolks.so), but should also be incremented when
# incompatible changes are made in the backend library APIs themselves.
m4_define([folks_eds_lt_current], [42])
m4_define([folks_eds_lt_revision], [3])
m4_define([folks_eds_lt_age], [17])

m4_define([folks_libsocialweb_lt_current], [42])
m4_define([folks_libsocialweb_lt_revision], [3])
m4_define([folks_libsocialweb_lt_age], [17])

m4_define([folks_telepathy_lt_current], [42])
m4_define([folks_telepathy_lt_revision], [3])
m4_define([folks_telepathy_lt_age], [17])

m4_define([folks_tracker_lt_current], [42])
m4_define([folks_tracker_lt_revision], [3])
m4_define([folks_tracker_lt_age], [17])

m4_define([folks_dummy_lt_current], [42])
m4_define([folks_dummy_lt_revision], [3])
m4_define([folks_dummy_lt_age], [17])

# Display the nano_version only if it's not '0'
m4_define([folks_base_version],
          folks_major_version.folks_minor_version.folks_micro_version)
m4_define([folks_full_version],
          [m4_if(folks_nano_version, [0],
                 folks_base_version, folks_base_version.folks_nano_version)])

m4_define([folks_maybe_datestamp],
          m4_if(folks_released, [1],
                [], [m4_esyscmd([date +.%Y%m%d | tr -d '\n\r'])]))

m4_define([folks_version], folks_full_version[]folks_maybe_datestamp)
m4_define([folks_module_version], folks_lt_current)

AC_INIT([folks],[folks_version],
        [https://bugzilla.gnome.org/browse.cgi?product=folks],[folks],
        [https://wiki.gnome.org/Projects/Folks])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

AC_PREREQ([2.65])
AC_COPYRIGHT([Copyright (C) 2010 Collabora Ltd.])

AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_SRCDIR([configure.ac])
AM_INIT_AUTOMAKE([1.12 dist-xz no-define
                  no-dist-gzip tar-ustar -Wno-portability color-tests
                  parallel-tests])
AM_MAINTAINER_MODE([enable])

AC_PROG_CC
AM_PROG_CC_C_O
LT_INIT([disable-static])
PKG_PROG_PKG_CONFIG([0.21])
GLIB_GSETTINGS

AC_SUBST([CFLAGS])
AC_SUBST([CPPFLAGS])
AC_SUBST([LDFLAGS])

# Core library LT version
LT_CURRENT=folks_lt_current
LT_REVISION=folks_lt_revision
LT_AGE=folks_lt_age
AC_SUBST([LT_CURRENT])
AC_SUBST([LT_REVISION])
AC_SUBST([LT_AGE])

# Backend library LT versions
FOLKS_EDS_LT_VERSION=folks_eds_lt_current:folks_eds_lt_revision:folks_eds_lt_age
AC_SUBST([FOLKS_EDS_LT_VERSION])

FOLKS_LIBSOCIALWEB_LT_VERSION=folks_libsocialweb_lt_current:folks_libsocialweb_lt_revision:folks_libsocialweb_lt_age
AC_SUBST([FOLKS_LIBSOCIALWEB_LT_VERSION])

FOLKS_TELEPATHY_LT_VERSION=folks_telepathy_lt_current:folks_telepathy_lt_revision:folks_telepathy_lt_age
AC_SUBST([FOLKS_TELEPATHY_LT_VERSION])

FOLKS_TRACKER_LT_VERSION=folks_tracker_lt_current:folks_tracker_lt_revision:folks_tracker_lt_age
AC_SUBST([FOLKS_TRACKER_LT_VERSION])

FOLKS_DUMMY_LT_VERSION=folks_dummy_lt_current:folks_dummy_lt_revision:folks_dummy_lt_age
AC_SUBST([FOLKS_DUMMY_LT_VERSION])

# Core library API version (potentially used for parallel installation)
# When updating this, don’t forget to update the backend library API versions
# below.
API_VERSION_MAJOR=0
AC_SUBST([API_VERSION_MAJOR])
API_VERSION_MINOR=6
AC_SUBST([API_VERSION_MINOR])
API_VERSION_DOT=$API_VERSION_MAJOR.$API_VERSION_MINOR
AC_SUBST([API_VERSION_DOT])

# Backend library API versions
AC_SUBST([FOLKS_EDS_API_VERSION], [0.6])
AC_SUBST([FOLKS_LIBSOCIALWEB_API_VERSION], [0.6])
AC_SUBST([FOLKS_TELEPATHY_API_VERSION], [0.6])
AC_SUBST([FOLKS_TRACKER_API_VERSION], [0.6])
AC_SUBST([FOLKS_DUMMY_API_VERSION], [0.6])

# Backend configuration
AC_ARG_ENABLE(tracker-backend,
        AS_HELP_STRING([--enable-tracker-backend],
                       [ build the Tracker backend]),
        enable_tracker_backend=$enableval,
        enable_tracker_backend=no )

AM_CONDITIONAL([ENABLE_TRACKER], [test "x$enable_tracker_backend" = "xyes"])

AS_IF([test "x$enable_tracker_backend" = "xyes"], [
        AC_DEFINE(HAVE_TRACKER, [1],
                  [Define as 1 if you have the Tracker backend])
], [
        AC_DEFINE(HAVE_TRACKER, [0],
                  [Define as 1 if you have the Tracker backend])
])

AC_ARG_ENABLE(eds-backend,
        AS_HELP_STRING([--enable-eds-backend],
                       [build the EDS backend]),
        enable_eds_backend=$enableval,
        enable_eds_backend=yes )

AS_IF([test "x$enable_eds_backend" = "xyes"], [
        AC_DEFINE(HAVE_EDS, [1], [Define as 1 if you have the eds backend])
], [
        AC_DEFINE(HAVE_EDS, [0], [Define as 1 if you have the eds backend])
])

AM_CONDITIONAL([ENABLE_EDS], [test "x$enable_eds_backend" = "xyes"])

AC_ARG_ENABLE(ofono-backend,
	AS_HELP_STRING([--enable-ofono-backend],
	               [build the oFono backend]),
	enable_ofono_backend=$enableval,
	enable_ofono_backend=yes )

AS_IF([test "x$enable_ofono_backend" = "xyes"], [
        AC_DEFINE(HAVE_OFONO, [1], [Define as 1 if you have the ofono backend])
], [
        AC_DEFINE(HAVE_OFONO, [0], [Define as 1 if you have the ofono backend])
])

AM_CONDITIONAL([ENABLE_OFONO], [test "x$enable_ofono_backend" = "xyes"])

AC_ARG_ENABLE(bluez-backend,
	AS_HELP_STRING([--enable-bluez-backend],
	               [build the BlueZ backend]),
	enable_bluez_backend=$enableval,
	enable_bluez_backend=yes )

AS_IF([test "x$enable_bluez_backend" = "xyes"], [
        AC_DEFINE(HAVE_BLUEZ, [1], [Define as 1 if you have the BlueZ backend])
], [
        AC_DEFINE(HAVE_BLUEZ, [0], [Define as 1 if you have the BlueZ backend])
])

AM_CONDITIONAL([ENABLE_BLUEZ], [test "x$enable_bluez_backend" = "xyes"])

AC_ARG_ENABLE(telepathy-backend,
        AS_HELP_STRING([--enable-telepathy-backend],
                       [build the Telepathy backend]),
        enable_telepathy_backend=$enableval,
        enable_telepathy_backend=yes )

AS_IF([test "x$enable_telepathy_backend" = "xyes"], [
        AC_DEFINE(HAVE_TELEPATHY, [1], [Define as 1 if you have the Telepathy backend])
], [
        AC_DEFINE(HAVE_TELEPATHY, [0], [Define as 1 if you have the Telepathy backend])
])

AM_CONDITIONAL([ENABLE_TELEPATHY], [test "x$enable_telepathy_backend" = "xyes"])

AC_ARG_ENABLE(zeitgeist,
        AS_HELP_STRING([--enable-zeitgeist],
                       [ build Zeitgeist support in the Telepathy backend]),
        enable_zeitgeist=$enableval,
        enable_zeitgeist=auto)

# Automatically check the dependencies for the libsocialweb backend
SW_CLIENT_REQUIRED=0.25.20
AC_ARG_ENABLE(libsocialweb-backend,
        AS_HELP_STRING([--enable-libsocialweb-backend=@<:@no/yes/auto@:>@],
                       [build the Libsocialweb backend (default: auto)]),
        enable_libsocialweb_backend=$enableval,
        enable_libsocialweb_backend=auto )

# this may be overwritten farther down
AC_DEFINE(HAVE_LIBSOCIALWEB, [0],
          [Define as 1 if you have the libsocialweb backend])
AS_IF([test "x$enable_libsocialweb_backend" != "xno"], [
  PKG_CHECK_MODULES([SW_CLIENT], [libsocialweb-client >= $SW_CLIENT_REQUIRED],
      have_libsocialweb_backend="yes", have_libsocialweb_backend="no")
  AS_IF([test "x$have_libsocialweb_backend" = "xyes" -a \
          "x$enable_vala" = "xyes"], [
    VALA_CHECK_PACKAGES([telepathy-glib
                         gio-2.0
                         gee-0.8
                         libsocialweb-client],
        ,
        have_libsocialweb_backend="no")
  ])

  AS_IF([test "x$have_libsocialweb_backend" = "xyes"], [
    AC_DEFINE(HAVE_LIBSOCIALWEB, [1],
              [Define if you have the libsocialweb backend])
  ])
], [
   have_libsocialweb_backend=no
])

AS_IF([test "x$enable_libsocialweb_backend" = "xyes" -a \
  "x$have_libsocialweb_backend" != "xyes"], [
    AC_MSG_ERROR([Cannot find libsocialweb dependencies.])
])

AM_CONDITIONAL([ENABLE_LIBSOCIALWEB],
        [test "x$have_libsocialweb_backend" = "xyes"])

# -----------------------------------------------------------
# Dependencies
# -----------------------------------------------------------

GLIB_REQUIRED=2.38.2
VALA_REQUIRED=0.22.0.28-9090
VALADOC_REQUIRED=0.3.1
TRACKER_SPARQL_REQUIRED=0.15.2
EBOOK_REQUIRED=3.8
EBOOK_REQUIRED_FOR_BLUEZ=3.9.1
EDATASERVER_REQUIRED=3.5.3.1
ZEITGEIST_REQUIRED=0.9.14
GEE_REQUIRED=0.8.4

PKG_CHECK_MODULES([GLIB],
                  [glib-2.0 >= $GLIB_REQUIRED
                   gobject-2.0 >= $GLIB_REQUIRED])
PKG_CHECK_MODULES([GMODULE], [gmodule-no-export-2.0])
PKG_CHECK_MODULES([GIO], [gio-2.0 >= $GLIB_REQUIRED])
# FIXME: get rid of this when our dependencies stop using dbus-1 (GNOME#696177)
PKG_CHECK_MODULES([DBUS_GLIB], [dbus-glib-1 dbus-1])

PKG_CHECK_MODULES([GEE], [gee-0.8 >= $GEE_REQUIRED])

TP_GLIB_REQUIRED=0.19.0

AS_IF([test x$enable_telepathy_backend = xyes], [
        PKG_CHECK_MODULES([TP_GLIB], [telepathy-glib >= $TP_GLIB_REQUIRED])])
case "x$enable_zeitgeist" in
  xyes)
    AS_IF([test x$enable_telepathy_backend = xyes],
          [PKG_CHECK_MODULES([ZEITGEIST], [zeitgeist-2.0 >= $ZEITGEIST_REQUIRED],
           ,
           [AC_MSG_ERROR([Zeitgeist support requires Zeitgeist development package])])])
    have_zeitgeist=yes
    ;;
  xauto)
    AS_IF([test x$enable_telepathy_backend = xyes],
          [PKG_CHECK_MODULES([ZEITGEIST], [zeitgeist-2.0 >= $ZEITGEIST_REQUIRED],
                             have_zeitgeist="yes",have_zeitgeist="no")],
          [have_zeitgeist=no])
    ;;
  xno)
    have_zeitgeist=no
    ;;
  x*)
    AC_MSG_ERROR([Unknown --enable-zeitgeist argument: $enable_zeitgeist])
esac

AS_IF([test "x$have_zeitgeist" == "xyes"], [
   ZEITGEIST_VALAFLAGS="-D HAVE_ZEITGEIST"
   AC_SUBST([ZEITGEIST_VALAFLAGS])
   ZEITGEIST_PKG="--pkg zeitgeist-2.0"
   AC_SUBST([ZEITGEIST_PKG])
])
AM_CONDITIONAL([ENABLE_ZEITGEIST], [test "x$have_zeitgeist" = "xyes"])

# Ignore post 0.20 deprecations
TP_GLIB_CFLAGS="$TP_GLIB_CFLAGS -DTP_VERSION_MIN_REQUIRED=TP_VERSION_0_20"
# Prevent post 0.20 APIs
TP_GLIB_CFLAGS="$TP_GLIB_CFLAGS -DTP_VERSION_MAX_ALLOWED=TP_VERSION_0_20"

AS_IF([test x$enable_tracker_backend = xyes], [
        PKG_CHECK_MODULES([TRACKER_SPARQL],
                          [tracker-sparql-0.16 >= $TRACKER_SPARQL_REQUIRED],
                          [TRACKER_SPARQL_MAJOR=0.16], [
          PKG_CHECK_MODULES([TRACKER_SPARQL],
                            [tracker-sparql-0.18 >= $TRACKER_SPARQL_REQUIRED],
                            [TRACKER_SPARQL_MAJOR=0.18], [
            PKG_CHECK_MODULES([TRACKER_SPARQL],
                              [tracker-sparql-1.0 >= $TRACKER_SPARQL_REQUIRED],
                              [TRACKER_SPARQL_MAJOR=1.0])
          ])
        ])
])

AC_SUBST([TRACKER_SPARQL_MAJOR])
AC_DEFINE_UNQUOTED(TRACKER_SPARQL_MAJOR, ["$TRACKER_SPARQL_MAJOR"], [Tracker major version])

AS_IF([test x$enable_bluez_backend = xyes], [EBOOK_REQUIRED=$EBOOK_REQUIRED_FOR_BLUEZ])

AS_IF([test x$enable_eds_backend = xyes], [
        PKG_CHECK_MODULES([EBOOK], [libebook-1.2 >= $EBOOK_REQUIRED
                                    libebook-contacts-1.2 >= $EBOOK_REQUIRED])
        PKG_CHECK_MODULES([EDATASERVER], [libedataserver-1.2 >= $EDATASERVER_REQUIRED])
])

AS_IF([test x$enable_ofono_backend = xyes], [
        PKG_CHECK_MODULES([EBOOK], [libebook-1.2 >= $EBOOK_REQUIRED])
])

AS_IF([test x$enable_bluez_backend = xyes], [
        PKG_CHECK_MODULES([EBOOK], [libebook-1.2 >= $EBOOK_REQUIRED])

        # Dependencies for the BlueZ tests
        PKG_CHECK_MODULES([GLIB_2_39_2], [glib-2.0 >= 2.39.2],
                          [have_glib_2_39_2=yes], [have_glib_2_39_2=no])
        AM_PATH_PYTHON([3.0], [have_python=yes], [have_python=no])

        AC_MSG_CHECKING([for python-dbusmock])
        AS_IF([! $PYTHON -c 'import dbusmock' > /dev/null 2>&1],
              [have_dbusmock=no], [have_dbusmock=yes])
        AC_MSG_RESULT([$have_dbusmock])

        AM_PROG_VALAC([0.22.0.45-383d-dirty],
                      [have_valac_0_22_2=yes], [have_valac_0_22_2=no])

        LT_LIB_M
])

# The BlueZ tests are conditional on several bleeding-edge dependencies.
# FIXME: Remove this once things have stabilised a bit.
AM_CONDITIONAL([HAVE_BLUEZ_TESTS],
               [test "x$have_glib_2_39_2" = "xyes" -a \
                     "x$have_python" = "xyes" -a \
                     "x$have_dbusmock" = "xyes" -a \
                     "x$have_valac_0_22_2" = "xyes"])

#
# Vala building options -- allows tarball builds without installing Vala
#
AC_ARG_ENABLE([vala],
              AS_HELP_STRING([--enable-vala],
                             [Enable building from the Vala sources]),
              [enable_vala=$enableval],
              [enable_vala=no])

# http://people.gnome.org/~walters/docs/build-api.txt
# We don't support separate builddir when building from git;
# The automake vala rules run cd srcdir which screws up the
# top_srcdir variable references.
echo \#buildapi-variable-no-builddir >/dev/null

# will be re-set as necessary below
AM_CONDITIONAL([HAVE_INTROSPECTION], [test "x$enable_vala" = "xyes"])
sd=${srcdir}/

# Force Vala for non-release builds
m4_if(folks_released, [1], [],
    [
        enable_vala=yes
        echo "Vala compiler required for non-release builds; requiring Vala..."
    ])

# Force Vala if generated source is missing or outdated
AS_IF([test \
        ! -e ${sd}tools/folks_import_vala.stamp -o \
        ! -e ${sd}tests/folks/abstract_field_details_vala.stamp -o \
        ! -e ${sd}tests/folks/aggregation_vala.stamp -o \
        ! -e ${sd}tests/folks/backend_loading_vala.stamp -o \
        ! -e ${sd}tests/key-file/individual_retrieval_vala.stamp -o \
        ! -e ${sd}tests/lib/folks-test.vapi -o \
        ! -e ${sd}tests/lib/dummy/dummy-test.vapi -o \
        ! -e ${sd}tests/lib/dummy/libdummy_test_la_vala.stamp -o \
        ! -e ${sd}tests/lib/key-file/kf-test.vapi -o \
        ! -e ${sd}tests/lib/key-file/libkf_test_la_vala.stamp -o \
        ! -e ${sd}tests/lib/telepathy/contactlist/tp-test-contactlist.gir -o \
        ! -e ${sd}tests/lib/telepathy/contactlist/tp-test-contactlist.vapi -o \
        ! -e ${sd}tests/lib/libfolks_test_la_vala.stamp -o \
        ! -e ${sd}tests/telepathy/persona_store_capabilities_vala.stamp -o \
        ! -e ${sd}tests/telepathy/individual_retrieval_vala.stamp -o \
        ! -e ${sd}tests/telepathy/individual_properties_vala.stamp -o \
        ! -e ${sd}tests/folks/backend_loading_vala.stamp -o \
        ! -e ${sd}backends/dummy/dummy_la_vala.stamp -o \
        ! -e ${sd}backends/key-file/key_file_la_vala.stamp -o \
        ! -e ${sd}backends/telepathy/telepathy_la_vala.stamp \
                -o \
        ! -e ${sd}backends/telepathy/lib/folks-telepathy.vapi -o \
        ! -e ${sd}backends/telepathy/lib/tp-lowlevel.gir -o \
        ! -e ${sd}backends/telepathy/lib/tp-lowlevel.vapi -o \
        ! -e ${sd}backends/telepathy/lib/libfolks_telepathy_la_vala.stamp -o \
        ! -e ${sd}folks/folks-internal.h -o \
        ! -e ${sd}folks/folks-internal.vapi -o \
        ! -e ${sd}folks/libfolks_internal_la_vala.stamp -o \
        ! -e ${sd}folks/folks.vapi -o \
        ! -e ${sd}folks/libfolks_la_vala.stamp \
      ], [
        enable_vala=yes
        echo "Vala source needs to be re-compiled; requiring Vala..."
])

AS_IF([test "x$enable_vala" = "xyes"], [
        AM_PROG_VALAC([$VALA_REQUIRED])
        AS_IF([test "x$VALAC" = "x"], [
              AC_MSG_ERROR([Vala requested but valac is not installed])
        ])

        AC_PATH_PROG([VAPIGEN], [vapigen], [])
        AS_IF([test "x$VAPIGEN" = "x"], [
              AC_MSG_ERROR([Vala must be built with --enable-vapigen])
        ])

        # require GLib >= 2.24 so GLib.Array, etc. reffing is handled
        # automatically
        TARGET_VALAFLAGS="--target-glib=2.24"
        # within the libfolks tree, select inline code paths
        TARGET_VALAFLAGS="$TARGET_VALAFLAGS -D FOLKS_COMPILATION"
        AC_SUBST([TARGET_VALAFLAGS])
        AC_SUBST([VAPIDIR])

        VALA_CHECK_PACKAGES([gio-2.0
                             gee-0.8])

        AS_IF([test x$enable_telepathy_backend = xyes], [
          VALA_CHECK_PACKAGES([telepathy-glib])
	  AS_IF([test "x$have_zeitgeist" == "xyes"], [
	      VALA_CHECK_PACKAGES([zeitgeist-2.0])
	  ])
        ])

        AS_IF([test x$enable_tracker_backend = xyes], [
          VALA_CHECK_PACKAGES([tracker-sparql-$TRACKER_SPARQL_MAJOR])
        ])

        AS_IF([test x$enable_eds_backend = xyes], [
          VALA_CHECK_PACKAGES([libebook-1.2 libebook-contacts-1.2 libedataserver-1.2 libxml-2.0])
        ])

        AS_IF([test x$enable_ofono_backend = xyes], [
          VALA_CHECK_PACKAGES([libebook-1.2])
        ])

        AS_IF([test x$enable_bluez_backend = xyes], [
          VALA_CHECK_PACKAGES([libebook-1.2])
        ])
])

# this will set HAVE_INTROSPECTION
GOBJECT_INTROSPECTION_REQUIRE([1.30])

AM_CONDITIONAL([HAVE_VALA], [test "x$enable_vala" = "xyes"])

# Various functions that we need (used in C code generated from Vala)
AC_CHECK_FUNCS([memset])
AC_CHECK_FUNCS([strstr])

AM_CONDITIONAL([NOT_RELEASE], [test "x$folks_released" = "x0"])

# -----------------------------------------------------------
# Backends
# -----------------------------------------------------------

FOLKS_MODULE_VERSION=folks_module_version
AC_SUBST([FOLKS_MODULE_VERSION])
AC_DEFINE([MODULE_VERSION], "folks_module_version", [Module interface version])

BACKEND_DIR='$(libdir)/folks/$(FOLKS_MODULE_VERSION)/backends'
AC_SUBST([BACKEND_DIR])

# -----------------------------------------------------------
# Tools
# -----------------------------------------------------------

AC_ARG_ENABLE([import-tool],
              AS_HELP_STRING([--enable-import-tool],
                             [Enable building the meta-contact import tool]),
              [enable_import_tool=$enableval with_import_tool=$enableval],
              [enable_import_tool=maybe with_import_tool=no])
AS_IF([test "$enable_import_tool" != "no"],
      [PKG_CHECK_MODULES([LIBXML], [libxml-2.0],
                         [with_import_tool=yes], [with_import_tool=no])])
AS_IF([test "$enable_import_tool" = "yes" -a "$with_import_tool" = "no"],
      [AC_MSG_ERROR([Import tool explicitly enabled, but libxml2 not found])])
AM_CONDITIONAL([ENABLE_IMPORT_TOOL], [test "$with_import_tool" = "yes"])

# Readline's required for the folks-inspect program
AC_ARG_ENABLE([inspect-tool],
              AS_HELP_STRING([--enable-inspect-tool],
                             [Enable building the data inspection tool]),
              [enable_inspect_tool=$enableval with_inspect_tool=$enableval],
              [enable_inspect_tool=maybe with_inspect_tool=no])
AS_IF([test "$enable_inspect_tool" = "yes" -a "$enable_vala" != "yes"],
      [AC_MSG_ERROR([Inspect tool explicitly enabled, but Vala wasn't enabled \
                     using --enable-vala])])
AS_IF([test "$enable_inspect_tool" = "maybe" -a "$enable_vala" != "yes"],
      [AC_MSG_NOTICE([Inspect tool disabled, as Vala wasn't enabled using \
                      --enable-vala])])
AS_IF([test "$enable_inspect_tool" != "no" -a "x$enable_vala" = "xyes"],
      [AC_CHECK_LIB([readline], [main],
                    [with_inspect_tool=yes], [with_inspect_tool=no],
                    [-lncurses])])
AS_IF([test "$enable_inspect_tool" != "no" -a "$with_inspect_tool" = "yes" -a \
       "x$enable_vala" = "xyes"],
      [VALA_CHECK_PACKAGES([readline])
       LIBREADLINE="-lreadline -lncurses"
       AC_DEFINE([HAVE_LIBREADLINE], [1], [Define if you have libreadline])
       AC_SUBST([LIBREADLINE])])
AS_IF([test "$enable_inspect_tool" = "yes" -a "$with_inspect_tool" = "no"],
      [AC_MSG_ERROR([Inspect tool explicitly enabled, but readline not found])])
AM_CONDITIONAL([ENABLE_INSPECT_TOOL], [test "$with_inspect_tool" = "yes"])

# -----------------------------------------------------------
# Tests
# -----------------------------------------------------------

AC_ARG_ENABLE([modular_tests],
              AS_HELP_STRING([--disable-modular-tests],
                             [Disable build of test programs (default: no)]),,
              [enable_modular_tests=yes])
AC_ARG_ENABLE([installed_tests],
              AS_HELP_STRING([--enable-installed-tests],
                             [Install test programs (default: no)]),,
              [enable_installed_tests=no])

AS_IF([test "$enable_modular_tests" = "yes" ||
       test "$enable_installed_tests" = "yes"],
      [enable_build_tests=yes],[enable_build_tests=no])
AM_CONDITIONAL([ENABLE_BUILD_TESTS],
               [test "$enable_build_tests" = "yes"])
AC_SUBST([ENABLE_BUILD_TESTS],[$enable_build_tests])

AM_CONDITIONAL([ENABLE_INSTALL_TESTS],
               [test "$enable_installed_tests" = "yes"])
AC_SUBST([ENABLE_INSTALL_TESTS],[$enable_installed_tests])

# -----------------------------------------------------------
# Documentation
# -----------------------------------------------------------

AC_ARG_ENABLE([docs],
              AS_HELP_STRING([--enable-docs],[Enable documentation generation]),
              [enable_docs=$enableval], [enable_docs=no])
AM_CONDITIONAL([ENABLE_DOCS], [test x$enable_docs = xyes])

have_valadoc=no
AS_IF([test x$enable_docs = xyes], [
  # make sure the library is new enough and the program exists
  PKG_CHECK_MODULES([VALADOC], [valadoc-1.0 >= $VALADOC_REQUIRED])
  AC_PATH_PROG([VALADOC], [valadoc], [:])
  AS_IF([test "$VALADOC" != :], have_valadoc=yes)
])
AM_CONDITIONAL([HAVE_VALADOC], [test x$have_valadoc = xyes])

AS_IF([test "x$enable_docs" = "xyes" -a "x$have_valadoc" != "xyes"], [
    AC_MSG_ERROR([Doc building requested but valadoc not installed.])
])

# -----------------------------------------------------------
# Gettext
# -----------------------------------------------------------

GETTEXT_PACKAGE=AC_PACKAGE_NAME
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, ["$GETTEXT_PACKAGE"], [Define the gettext package to be used])
IT_PROG_INTLTOOL([0.50.0])

# -----------------------------------------------------------
# Error flags
# -----------------------------------------------------------

# Disable GLib deprecation warnings for now (#670196); GValueArray is deprecated
# but we need it for dbus-glib. Porting to GDBus will solve this (#653198)
AC_DEFINE(GLIB_DISABLE_DEPRECATION_WARNINGS, 1, [Build with GLib deprecated])

# C_ERROR_CFLAGS are only used for C code from telepathy-glib for now,
# while ERROR_CFLAGS are used for everything.

ERROR_CFLAGS=

AC_ARG_ENABLE([fatal-warnings],
              AS_HELP_STRING([--disable-fatal-warnings],
                             [Make various warnings non-fatal]),
              [enable_fatal_warnings=$enableval], [enable_fatal_warnings=yes])

AC_DEFUN([FOLKS_ADD_WARNING],
  [
    AS_COMPILER_FLAG([-Werror=$2],
      [
        AS_IF([test "x$enable_fatal_warnings" = xyes],
          [$1="[$]$1 -Werror=$2"],
	  [$1="[$]$1 -W$2"])
      ])
  ])

# It isn't 1970 any more. Require that we write proper ISO C with declarations,
# avoiding hard-to-trace bugs on platforms where sizeof(int) != sizeof(void *).
FOLKS_ADD_WARNING([ERROR_CFLAGS], [implicit])
FOLKS_ADD_WARNING([ERROR_CFLAGS], [missing-declarations])
FOLKS_ADD_WARNING([ERROR_CFLAGS], [missing-parameter-type])
FOLKS_ADD_WARNING([ERROR_CFLAGS], [missing-prototypes])
FOLKS_ADD_WARNING([ERROR_CFLAGS], [nested-externs])
FOLKS_ADD_WARNING([ERROR_CFLAGS], [old-style-declaration])
FOLKS_ADD_WARNING([ERROR_CFLAGS], [old-style-definition])
FOLKS_ADD_WARNING([ERROR_CFLAGS], [strict-prototypes])

# Enable colourised compiler output.
AS_COMPILER_FLAG([-fdiagnostics-color=auto],
                 [ERROR_CFLAGS="$ERROR_CFLAGS -fdiagnostics-color=auto"])

AS_COMPILER_FLAG([-Wall], [C_ERROR_CFLAGS="-Wall"], [C_ERROR_CFLAGS=""])
AS_COMPILER_FLAG([-Werror], [werror=yes], [werror=no])

AC_ARG_ENABLE([debug],
              AS_HELP_STRING([--disable-debug],[compile without debug code]),
              [enable_debug=$enableval], [enable_debug=yes])

AS_COMPILER_FLAG([-Wextra], [wextra=yes], [wextra=no])
AS_COMPILER_FLAG([-Wno-missing-field-initializers],
                 [wno_missing_field_initializers=yes],
                 [wno_missing_field_initializers=no])
AS_COMPILER_FLAG([-Wno-unused-parameter],
                 [wno_unused_parameter=yes], [wno_unused_parameter=no])
AS_COMPILER_FLAG([-Wstrict-prototypes], [wstrict_prototypes=yes],
                 [wstrict_prototypes=no])
AS_COMPILER_FLAG([-Wmissing-prototypes], [wmissing_prototypes=yes],
                 [wmissing_prototypes=no])
AS_COMPILER_FLAG([-Wimplicit-function-declaration],
                 [wimplicit_function_declaration=yes],
                 [wimplicit_function_declaration=no])
AS_COMPILER_FLAG([-Wpointer-arith], [wpointer_arith=yes], [wpointer_arith=no])
AS_COMPILER_FLAG([-Winit-self], [winit_self=yes], [winit_self=no])
AS_COMPILER_FLAG([-Wformat=2], [wformat=yes], [wformat=no])
AS_COMPILER_FLAG([-Wmissing-include-dirs], [wmissing_include_dirs=yes],
                 [wmissing_include_dirs=no])
AS_COMPILER_FLAG([-Waggregate-return], [waggregate_return=yes],
                 [waggregate_return=no])
AS_COMPILER_FLAG([-Wdeclaration-after-statement],
                 [wdeclaration_after_statement=yes],
                 [wdeclaration_after_statement=no])

m4_if(folks_released, [1], [],
    [
        # Iff we support -Werror, then use it with all our compiler warnings.
        if test x$werror = xyes; then
            flag="-Werror="
        else
            flag="-W"
        fi

        if test x$wextra = xyes -a \
            x$wno_missing_field_initializers = xyes -a \
            x$wno_unused_parameter = xyes -a x$wstrict_prototypes = xyes -a \
            x$wmissing_prototypes = xyes -a \
            x$wimplicit_function_declaration = xyes -a x$wpointer_arith = xyes \
            -a x$winit_self = xyes -a x$wformat = xyes -a \
            x$wmissing_include_dirs = xyes -a x$waggregate_return = xyes -a \
            x$wdeclaration_after_statement = xyes; then
            C_ERROR_CFLAGS="$C_ERROR_CFLAGS -Wextra \
                -Wno-missing-field-initializers \
                -Wno-unused-parameter ${flag}strict-prototypes \
                ${flag}missing-prototypes ${flag}implicit-function-declaration \
                ${flag}pointer-arith ${flag}init-self ${flag}format=2 \
                ${flag}missing-include-dirs ${flag}aggregate-return \
                ${flag}declaration-after-statement"
        fi
    ])

AS_COMPILER_FLAG([-D_POSIX_SOURCE], [C_ERROR_CFLAGS="$C_ERROR_CFLAGS -D_POSIX_SOURCE"])
AS_COMPILER_FLAG([-std=c99], [C_ERROR_CFLAGS="$C_ERROR_CFLAGS -std=c99"])
AS_COMPILER_FLAG([-Wshadow], [C_ERROR_CFLAGS="$C_ERROR_CFLAGS -Wshadow"])
AS_COMPILER_FLAG([-Wmissing-prototypes], [C_ERROR_CFLAGS="$C_ERROR_CFLAGS \
                                          -Wmissing-prototypes"])
AS_COMPILER_FLAG([-Wmissing-declarations], [C_ERROR_CFLAGS="$C_ERROR_CFLAGS \
                                            -Wmissing-declarations"])
AS_COMPILER_FLAG([-Wstrict-prototypes], [C_ERROR_CFLAGS="$C_ERROR_CFLAGS \
                                         -Wstrict-prototypes"])

AC_SUBST([ERROR_CFLAGS])
AC_SUBST([C_ERROR_CFLAGS])

# -----------------------------------------------------------
# Code coverage flags
# -----------------------------------------------------------

AC_ARG_ENABLE([code-coverage],
              AS_HELP_STRING([--enable-code-coverage],
                             [compile with code coverage code]),
              [enable_code_coverage=$enableval], [enable_code_coverage=no])

# Only enable code coverage if this isn't a release.
m4_if(folks_released, [1], [],
    [
        if test "x$GCC" = "xyes"; then
            if test "x$enable_code_coverage" = "xyes"; then
                CODE_COVERAGE_CFLAGS="-fprofile-arcs -ftest-coverage -O0 -ggdb"
                CODE_COVERAGE_LDFLAGS="-lgcov"
            fi
        fi
    ])

AC_SUBST([CODE_COVERAGE_CFLAGS])
AC_SUBST([CODE_COVERAGE_LDFLAGS])

# Vala-related flags
AS_IF([test "x$enable_vala" = "xyes" && test "x$enable_fatal_warnings" = "xyes"],
      [ERROR_INTROSPECTION_SCANNER_ARGS="\
                        $ERROR_INTROSPECTION_SCANNER_ARGS --warn-error"
       ERROR_VALAFLAGS="$ERROR_VALAFLAGS --fatal-warnings"])

# Disable -g if we're building with code coverage enabled, since Vala's
# insertion of #line directives into .c files confuses lcov. For the moment,
# we'll have to do with looking at code coverage of the generated C files only.
# We set the debug flags in CODE_COVERAGE_CFLAGS instead in that case.
m4_if(folks_released, [1], [],
    [
        if test "x$enable_code_coverage" != "xyes" -o "x$GCC" != "xyes"; then
            ERROR_VALAFLAGS="$ERROR_VALAFLAGS -g"
        fi
    ])

AC_SUBST([ERROR_INTROSPECTION_SCANNER_ARGS])
AC_SUBST([ERROR_VALAFLAGS])

# -----------------------------------------------------------
# Profiling
# -----------------------------------------------------------

AC_ARG_ENABLE([profiling],
              AS_HELP_STRING([--enable-profiling],
                             [Enable building profiling points]),
              [enable_profiling=$enableval],
              [enable_profiling=no])
AM_CONDITIONAL([ENABLE_PROFILING], [test "$enable_profiling" = "yes"])

# -----------------------------------------------------------
# Final output
# -----------------------------------------------------------

AC_CONFIG_FILES([
    backends/telepathy/lib/folks-telepathy.pc
    backends/telepathy/lib/folks-telepathy-uninstalled.pc
    backends/tracker/lib/folks-tracker.deps
    backends/tracker/lib/folks-tracker.pc
    backends/tracker/lib/folks-tracker-uninstalled.pc
    backends/eds/lib/folks-eds.pc
    backends/eds/lib/folks-eds-uninstalled.pc
    backends/dummy/lib/folks-dummy.pc
    backends/dummy/lib/folks-dummy-uninstalled.pc
    folks/folks.pc
    folks/folks-uninstalled.pc
    folks/org.freedesktop.folks.gschema.xml
    Makefile
    backends/Makefile
    backends/dummy/Makefile
    backends/dummy/lib/Makefile
    backends/key-file/Makefile
    backends/libsocialweb/Makefile
    backends/libsocialweb/lib/Makefile
    backends/libsocialweb/lib/folks-libsocialweb.pc
    backends/libsocialweb/lib/folks-libsocialweb-uninstalled.pc
    backends/telepathy/Makefile
    backends/telepathy/lib/Makefile
    backends/tracker/Makefile
    backends/tracker/lib/Makefile
    backends/eds/Makefile
    backends/eds/lib/Makefile
    backends/ofono/Makefile
    backends/bluez/Makefile
    folks/Makefile
    docs/Makefile
    po/Makefile.in
    tests/Makefile
    tests/bluez/Makefile
    tests/data/Makefile
    tests/eds/Makefile
    tests/folks/Makefile
    tests/dummy/Makefile
    tests/key-file/Makefile
    tests/libsocialweb/Makefile
    tests/telepathy/Makefile
    tests/tracker/Makefile
    tests/lib/Makefile
    tests/lib/folks-test-uninstalled.pc
    tests/lib/bluez/Makefile
    tests/lib/eds/Makefile
    tests/lib/dummy/Makefile
    tests/lib/key-file/Makefile
    tests/lib/libsocialweb/Makefile
    tests/lib/telepathy/Makefile
    tests/lib/tracker/Makefile
    tests/lib/telepathy/contactlist/Makefile
    tests/tools/Makefile
    tools/Makefile
    tools/inspect/Makefile
])

AC_OUTPUT

echo "
Configure summary:

        Vala........................:  ${enable_vala}
        Vala Compiler...............:  ${VALAC}
        C Compiler Flags............:  ${CFLAGS} ${ERROR_CFLAGS} ${CODE_COVERAGE_CFLAGS}
        Linker Flags................:  ${LDFLAGS} ${CODE_COVERAGE_LDFLAGS}
        Prefix......................:  ${prefix}
        Bugreporting URL............:  ${PACKAGE_BUGREPORT}
        Documentation...............:  ${have_valadoc}
        Import tool.................:  ${with_import_tool}
        Inspector tool..............:  ${with_inspect_tool}
        Telepathy backend...........:  ${enable_telepathy_backend}
        Tracker backend.............:  ${enable_tracker_backend}
        Libsocialweb backend........:  ${have_libsocialweb_backend}
        E-D-S backend...............:  ${enable_eds_backend}
        Ofono backend...............:  ${enable_ofono_backend}
        BlueZ backend...............:  ${enable_bluez_backend}
        Zeitgeist support...........:  ${have_zeitgeist}
        Build tests.................:  ${enable_modular_tests}
        Install tests...............:  ${enable_installed_tests}
"