Only check for libsocialweb Vala deps if Vala is enabled.
[platform/upstream/folks.git] / configure.ac
1 # If not 1, append datestamp to the version number
2 m4_define([folks_released], [0])
3
4 m4_define([folks_major_version], [0])
5 m4_define([folks_minor_version], [5])
6 m4_define([folks_micro_version], [1])
7 m4_define([folks_nano_version], [1])
8
9 # If library source has changed since last release, increment revision
10 # If interfaces have been added, removed or changed since last release,
11 #  increment current and set revision to 0
12 # If interfaces have been added since last release, increment age
13 # If interfaces have been removed since last release, set age to 0
14 m4_define([folks_lt_current], [24])
15 m4_define([folks_lt_revision], [0])
16 m4_define([folks_lt_age], [0])
17
18 # Display the nano_version only if it's not '0'
19 m4_define([folks_base_version],
20           folks_major_version.folks_minor_version.folks_micro_version)
21 m4_define([folks_full_version],
22           [m4_if(folks_nano_version, [0],
23                  folks_base_version, folks_base_version.folks_nano_version)])
24
25 m4_define([folks_maybe_datestamp],
26           m4_if(folks_released, [1],
27                 [], [m4_esyscmd([date +.%Y%m%d | tr -d '\n\r'])]))
28
29 m4_define([folks_version], folks_full_version[]folks_maybe_datestamp)
30 m4_define([folks_major_minor_version], folks_major_version.folks_minor_version)
31 m4_define([folks_module_version], folks_lt_current)
32
33 AC_INIT([folks], folks_version,
34         [https://bugzilla.gnome.org/browse.cgi?product=folks], [folks],
35         [http://telepathy.freedesktop.org/wiki/Folks])
36 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
37
38 AC_PREREQ([2.65])
39 AC_COPYRIGHT([Copyright (C) 2010 Collabora Ltd.])
40
41 AC_CONFIG_MACRO_DIR([m4])
42 AC_CONFIG_SRCDIR([Makefile.am])
43 AC_CONFIG_HEADERS(config.h)
44 AC_CONFIG_SRCDIR([configure.ac])
45 AM_INIT_AUTOMAKE([1.11 dist-bzip2 no-define
46                   no-dist-gzip tar-ustar -Wno-portability])
47 AM_MAINTAINER_MODE
48
49 AC_PROG_CC
50 AM_PROG_CC_C_O
51 AC_DISABLE_STATIC
52 LT_INIT
53 PKG_PROG_PKG_CONFIG([0.21])
54
55 AC_SUBST([CFLAGS])
56 AC_SUBST([CPPFLAGS])
57 AC_SUBST([LDFLAGS])
58
59 LT_CURRENT=folks_lt_current
60 LT_REVISION=folks_lt_revision
61 LT_AGE=folks_lt_age
62 AC_SUBST([LT_CURRENT])
63 AC_SUBST([LT_REVISION])
64 AC_SUBST([LT_AGE])
65
66 FOLKS_MAJOR_MINOR_VERSION=folks_major_minor_version
67 AC_SUBST([FOLKS_MAJOR_MINOR_VERSION])
68
69 API_VERSION=0.6
70 AC_SUBST([API_VERSION])
71
72 AC_ARG_ENABLE(tracker-backend,
73         AC_HELP_STRING([--enable-tracker-backend],
74                        [ build the Tracker backend]),
75         enable_tracker_backend=$enableval,
76         enable_tracker_backend=no )
77
78 AM_CONDITIONAL([ENABLE_TRACKER], [test "x$enable_tracker_backend" = "xyes"])
79
80 # Automatically check the dependencies for the libsocialweb backend
81 SW_CLIENT_REQUIRED=0.25.15
82 AC_ARG_ENABLE(libsocialweb-backend,
83         AC_HELP_STRING([--enable-libsocialweb-backend=@<:@no/yes/auto@:>@],
84                        [build the Libsocialweb backend (default: auto)]),
85         enable_libsocialweb_backend=$enableval,
86         enable_libsocialweb_backend=auto )
87
88 if test "x$enable_libsocialweb_backend" != "xno"; then
89   PKG_CHECK_MODULES([SW_CLIENT], [libsocialweb-client >= $SW_CLIENT_REQUIRED],
90       have_libsocialweb_backend="yes", have_libsocialweb_backend="no")
91   if test "x$have_libsocialweb_backend" = "xyes" -a \
92           "x$enable_vala" = "xyes"; then
93     VALA_CHECK_PACKAGES([telepathy-glib
94                          dbus-glib-1
95                          gio-2.0
96                          gee-1.0
97                          libsocialweb-client],
98         ,
99         have_libsocialweb_backend="no")
100   fi
101
102   if test "x$have_libsocialweb_backend" = "xyes"; then
103     AC_DEFINE(HAVE_TELEPATHY, [], [Define if you have libsocialweb_backend])
104   fi
105 else
106    have_libsocialweb_backend=no
107 fi
108
109 if test "x$enable_libsocialweb_backend" = "xyes" -a \
110   "x$have_libsocialweb_backend" != "xyes"; then
111     AC_MSG_ERROR([Cannot find libsocialweb dependencies.])
112 fi
113
114 AM_CONDITIONAL([ENABLE_LIBSOCIALWEB],
115         [test "x$have_libsocialweb_backend" = "xyes"])
116
117 # -----------------------------------------------------------
118 # Dependencies
119 # -----------------------------------------------------------
120
121 GLIB_REQUIRED=2.24.0
122 TP_GLIB_REQUIRED=0.13.1
123 VALA_REQUIRED=0.12.0
124 VALADOC_REQUIRED=0.2.1
125 TRACKER_SPARQL_REQUIRED=0.10
126 GCONF2_REQUIRED=2.31
127
128 PKG_CHECK_MODULES([GLIB],
129                   [glib-2.0 >= $GLIB_REQUIRED
130                    gobject-2.0 >= $GLIB_REQUIRED])
131 PKG_CHECK_MODULES([GMODULE], [gmodule-no-export-2.0])
132 PKG_CHECK_MODULES([GIO], [gio-2.0 >= $GLIB_REQUIRED])
133 PKG_CHECK_MODULES([DBUS_GLIB], [dbus-glib-1])
134 PKG_CHECK_MODULES([GCONF2], [gconf-2.0 >= $GCONF2_REQUIRED])
135
136 # FIXME: We depend on libgee < 0.7 because 0.7 breaks API. bgo#627746
137 PKG_CHECK_MODULES([GEE], [gee-1.0 < 0.7])
138 PKG_CHECK_MODULES([TP_GLIB], [telepathy-glib >= $TP_GLIB_REQUIRED])
139
140 if test x$enable_tracker_backend = xyes; then
141         PKG_CHECK_MODULES([TRACKER_SPARQL],
142                           [tracker-sparql-0.10 >= $TRACKER_SPARQL_REQUIRED])
143 fi
144
145 #
146 # Vala building options -- allows tarball builds without installing Vala
147 #
148 AC_ARG_ENABLE([vala],
149               AS_HELP_STRING([--enable-vala],
150                              [Enable building from the Vala sources]),
151               [enable_vala=$enableval],
152               [enable_vala=no])
153
154 # will be re-set as necessary below
155 AM_CONDITIONAL([HAVE_INTROSPECTION], [test "x$enable_vala" = "xyes"])
156 sd=${srcdir}/
157
158 # Force Vala for non-release builds
159 m4_if(folks_released, [1], [],
160     [
161         enable_vala=yes
162         echo "Vala compiler required for non-release builds; requiring Vala..."
163     ])
164
165 # Force Vala if generated source is missing or outdated
166 if test \
167         ! -e ${sd}tools/folks_import_vala.stamp -o \
168         ! -e ${sd}tests/folks/aggregation_vala.stamp -o \
169         ! -e ${sd}tests/folks/backend_loading_vala.stamp -o \
170         ! -e ${sd}tests/folks/field_details_vala.stamp -o \
171         ! -e ${sd}tests/key-file/individual_retrieval_vala.stamp -o \
172         ! -e ${sd}tests/lib/folks-test.vapi -o \
173         ! -e ${sd}tests/lib/key-file/kf-test.vapi -o \
174         ! -e ${sd}tests/lib/key-file/libkf_test_la_vala.stamp -o \
175         ! -e ${sd}tests/lib/telepathy/contactlist/tp-test-contactlist.gir -o \
176         ! -e ${sd}tests/lib/telepathy/contactlist/tp-test-contactlist.vapi -o \
177         ! -e ${sd}tests/lib/libfolks_test_la_vala.stamp -o \
178         ! -e ${sd}tests/telepathy/persona_store_capabilities_vala.stamp -o \
179         ! -e ${sd}tests/telepathy/individual_retrieval_vala.stamp -o \
180         ! -e ${sd}tests/telepathy/individual_properties_vala.stamp -o \
181         ! -e ${sd}tests/folks/backend_loading_vala.stamp -o \
182         ! -e ${sd}backends/key-file/libfolks_backend_key_file_la_vala.stamp -o \
183         ! -e ${sd}backends/telepathy/libfolks_backend_telepathy_la_vala.stamp \
184                 -o \
185         ! -e ${sd}backends/telepathy/lib/folks-telepathy.vapi -o \
186         ! -e ${sd}backends/telepathy/lib/tp-lowlevel.gir -o \
187         ! -e ${sd}backends/telepathy/lib/tp-lowlevel.vapi -o \
188         ! -e ${sd}backends/telepathy/lib/libfolks_telepathy_la_vala.stamp -o \
189         ! -e ${sd}folks/folks.vapi -o \
190         ! -e ${sd}folks/libfolks_la_vala.stamp ; then
191         enable_vala=yes
192         echo "Vala source needs to be re-compiled; requiring Vala..."
193 fi
194
195 if test "x$enable_vala" = "xyes" ; then
196         AM_PROG_VALAC([$VALA_REQUIRED])
197         if test "x$VALAC" = "x"; then
198               AC_MSG_ERROR([Vala requested but valac is not installed])
199         fi
200
201         AC_PATH_PROG([VAPIGEN], [vapigen], [])
202         if test "x$VAPIGEN" = "x"; then
203               AC_MSG_ERROR([Vala must be built with --enable-vapigen])
204         fi
205
206         # require GLib >= 2.24 so GLib.Array, etc. reffing is handled
207         # automatically
208         VALAFLAGS="$VALAFLAGS --target-glib=2.24"
209         AC_SUBST([VALAFLAGS])
210         AC_SUBST([VAPIGENFLAGS])
211         AC_SUBST([VAPIDIR])
212
213         VALA_CHECK_PACKAGES([telepathy-glib
214                              dbus-glib-1
215                              gio-2.0
216                              gee-1.0])
217
218         if test x$enable_tracker_backend = xyes; then
219           VALA_CHECK_PACKAGES([tracker-sparql-0.10])
220         fi
221
222 fi
223
224 # this will set HAVE_INTROSPECTION
225 GOBJECT_INTROSPECTION_REQUIRE([0.9.12])
226
227 AM_CONDITIONAL([HAVE_VALA], [test "x$enable_vala" = "xyes"])
228
229 # Various functions that we need (used in C code generated from Vala)
230 AC_CHECK_FUNCS([memset])
231 AC_CHECK_FUNCS([strstr])
232
233 # -----------------------------------------------------------
234 # Backends
235 # -----------------------------------------------------------
236
237 FOLKS_MODULE_VERSION=folks_module_version
238 AC_SUBST([FOLKS_MODULE_VERSION])
239 AC_DEFINE([MODULE_VERSION], "folks_module_version", [Module interface version])
240
241 BACKEND_DIR='$(libdir)/folks/$(FOLKS_MODULE_VERSION)/backends'
242 AC_SUBST([BACKEND_DIR])
243
244 BACKEND_KF='$(top_builddir)/backends/key-file/.libs/libfolks-backend-key-file.so'
245 AC_SUBST([BACKEND_KF])
246 BACKEND_TP='$(top_builddir)/backends/telepathy/.libs/libfolks-backend-telepathy.so'
247 AC_SUBST([BACKEND_TP])
248
249 if test x$have_libsocialweb_backend = xyes; then
250   BACKEND_LIBSOCIALWEB='$(top_builddir)/backends/libsocialweb/.libs/libfolks-backend-libsocialweb.so'
251   AC_SUBST([BACKEND_LIBSOCIALWEB])
252 fi
253
254 if test x$enable_tracker_backend = xyes; then
255   BACKEND_TRACKER='$(top_builddir)/backends/tracker/.libs/libfolks-backend-tracker.so'
256   AC_SUBST([BACKEND_TRACKER])
257 fi
258
259 # All of the backend libraries in our tree; to be used by the tests
260 BACKEND_UNINST_PATH='$(BACKEND_KF):$(BACKEND_TP)'
261 if test x$have_libsocialweb_backend = xyes; then
262   LIBSOCIALWEB_BACKEND_UNINST_PATH='$(BACKEND_LIBSOCIALWEB)'
263   BACKEND_UNINST_PATH="$BACKEND_UNINST_PATH:$LIBSOCIALWEB_BACKEND_UNINST_PATH"
264 fi
265 if test x$enable_tracker_backend = xyes; then
266   TRACKER_BACKEND_UNINST_PATH='$(BACKEND_TRACKER)'
267   BACKEND_UNINST_PATH="$BACKEND_UNINST_PATH:$TRACKER_BACKEND_UNINST_PATH"
268 fi
269 AC_SUBST([BACKEND_UNINST_PATH])
270
271 # -----------------------------------------------------------
272 # Tools
273 # -----------------------------------------------------------
274
275 AC_ARG_ENABLE([import-tool],
276               AS_HELP_STRING([--enable-import-tool],
277                              [Enable building the meta-contact import tool]),
278               [enable_import_tool=$enableval with_import_tool=$enableval],
279               [enable_import_tool=maybe with_import_tool=no])
280 AS_IF([test "$enable_import_tool" != "no"],
281       [PKG_CHECK_MODULES([LIBXML], [libxml-2.0],
282                          [with_import_tool=yes], [with_import_tool=no])])
283 AS_IF([test "$enable_import_tool" = "yes" -a "$with_import_tool" = "no"],
284       [AC_MSG_ERROR([Import tool explicitly enabled, but libxml2 not found])])
285 AM_CONDITIONAL([ENABLE_IMPORT_TOOL], [test "$with_import_tool" = "yes"])
286
287 # Readline's required for the folks-inspect program
288 AC_ARG_ENABLE([inspect-tool],
289               AS_HELP_STRING([--enable-inspect-tool],
290                              [Enable building the data inspection tool]),
291               [enable_inspect_tool=$enableval with_inspect_tool=$enableval],
292               [enable_inspect_tool=maybe with_inspect_tool=no])
293 AS_IF([test "$enable_inspect_tool" = "yes" -a "$enable_vala" != "yes"],
294       [AC_MSG_ERROR([Inspect tool explicitly enabled, but Vala wasn't enabled \
295                      using --enable-vala])])
296 AS_IF([test "$enable_inspect_tool" = "maybe" -a "$enable_vala" != "yes"],
297       [AC_MSG_NOTICE([Inspect tool disabled, as Vala wasn't enabled using \
298                       --enable-vala])])
299 AS_IF([test "$enable_inspect_tool" != "no" -a "x$enable_vala" = "xyes"],
300       [AC_CHECK_LIB([readline], [main],
301                     [with_inspect_tool=yes], [with_inspect_tool=no],
302                     [-lncurses])])
303 AS_IF([test "$enable_inspect_tool" != "no" -a "$with_inspect_tool" = "yes" -a \
304        "x$enable_vala" = "xyes"],
305       [VALA_CHECK_PACKAGES([readline])
306        LIBREADLINE="-lreadline -lncurses"
307        AC_DEFINE([HAVE_LIBREADLINE], [1], [Define if you have libreadline])
308        AC_SUBST([LIBREADLINE])])
309 AS_IF([test "$enable_inspect_tool" = "yes" -a "$with_inspect_tool" = "no"],
310       [AC_MSG_ERROR([Inspect tool explicitly enabled, but readline not found])])
311 AM_CONDITIONAL([ENABLE_INSPECT_TOOL], [test "$with_inspect_tool" = "yes"])
312
313 # -----------------------------------------------------------
314 # Documentation
315 # -----------------------------------------------------------
316
317 AC_ARG_ENABLE([docs],
318               AS_HELP_STRING([--enable-docs],[Enable documentation generation]),
319               [enable_docs=$enableval], [enable_docs=no])
320 AM_CONDITIONAL([ENABLE_DOCS], [test x$enable_docs = xyes])
321
322 AS_IF([test "x$enable_docs" != xno],
323       [PKG_CHECK_MODULES([VALADOC_PC], [valadoc-1.0 >= $VALADOC_REQUIRED])
324        AC_PATH_PROG([VALADOC], [valadoc], [:])
325        AS_IF([test "$VALADOC" != :],
326              have_valadoc=yes)])
327 AM_CONDITIONAL([HAVE_VALADOC], [test x$have_valadoc = xyes])
328
329 # -----------------------------------------------------------
330 # Gettext
331 # -----------------------------------------------------------
332
333 GETTEXT_PACKAGE=AC_PACKAGE_NAME
334 AC_SUBST(GETTEXT_PACKAGE)
335 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, ["$GETTEXT_PACKAGE"], [Define the gettext package to be used])
336 IT_PROG_INTLTOOL([0.35.0])
337
338 # -----------------------------------------------------------
339 # Error flags
340 # -----------------------------------------------------------
341
342 AS_COMPILER_FLAG([-Wall], [ERROR_CFLAGS="-Wall"], [ERROR_CFLAGS=""])
343 AS_COMPILER_FLAG([-Werror], [werror=yes], [werror=no])
344
345 AC_ARG_ENABLE([debug],
346               AS_HELP_STRING([--disable-debug],[compile without debug code]),
347               [enable_debug=$enableval], [enable_debug=yes])
348
349 AC_ARG_ENABLE([Werror],
350               AS_HELP_STRING([--disable-Werror],
351                              [compile without -Werror (normally enabled in
352                               development builds)]),
353               [werror=$enableval], [werror=yes])
354
355 AS_COMPILER_FLAG([-Wextra], [wextra=yes], [wextra=no])
356 AS_COMPILER_FLAG([-Wno-missing-field-initializers],
357                  [wno_missing_field_initializers=yes],
358                  [wno_missing_field_initializers=no])
359 AS_COMPILER_FLAG([-Wno-unused-parameter],
360                  [wno_unused_parameter=yes], [wno_unused_parameter=no])
361
362 m4_if(folks_released, [1], [],
363     [
364         if test x$werror = xyes; then
365             ERROR_CFLAGS="$ERROR_CFLAGS -Werror"
366         fi
367         if test x$wextra = xyes -a \
368             x$wno_missing_field_initializers = xyes -a \
369             x$wno_unused_parameter = xyes; then
370             ERROR_CFLAGS="$ERROR_CFLAGS -Wextra \
371                 -Wno-missing-field-initializers -Wno-unused-parameter"
372         fi
373     ])
374
375 AS_COMPILER_FLAG([-D_POSIX_SOURCE], [ERROR_CFLAGS="$ERROR_CFLAGS -D_POSIX_SOURCE"])
376 AS_COMPILER_FLAG([-std=c99], [ERROR_CFLAGS="$ERROR_CFLAGS -std=c99"])
377 AS_COMPILER_FLAG([-Wshadow], [ERROR_CFLAGS="$ERROR_CFLAGS -Wshadow"])
378 AS_COMPILER_FLAG([-Wmissing-prototypes], [ERROR_CFLAGS="$ERROR_CFLAGS \
379                                           -Wmissing-prototypes"])
380 AS_COMPILER_FLAG([-Wmissing-declarations], [ERROR_CFLAGS="$ERROR_CFLAGS \
381                                             -Wmissing-declarations"])
382 AS_COMPILER_FLAG([-Wstrict-prototypes], [ERROR_CFLAGS="$ERROR_CFLAGS \
383                                          -Wstrict-prototypes"])
384
385 AC_SUBST([ERROR_CFLAGS])
386
387 # Vala-related flags
388 AS_IF([test "x$enable_vala" = "xyes"],
389       [ERROR_INTROSPECTION_SCANNER_ARGS="\
390                         $ERROR_INTROSPECTION_SCANNER_ARGS --warn-error"
391        ERROR_VALAFLAGS="$ERROR_VALAFLAGS --fatal-warnings"])
392
393 AC_SUBST([ERROR_INTROSPECTION_SCANNER_ARGS])
394 AC_SUBST([ERROR_VALAFLAGS])
395
396 # -----------------------------------------------------------
397 # Final output
398 # -----------------------------------------------------------
399
400 AC_CONFIG_FILES([
401     backends/telepathy/lib/folks-telepathy.pc
402     backends/telepathy/lib/folks-telepathy-uninstalled.pc
403     backends/tracker/lib/folks-tracker.pc
404     backends/tracker/lib/folks-tracker-uninstalled.pc
405     folks/folks.pc
406     folks/folks-uninstalled.pc
407     Makefile
408     backends/Makefile
409     backends/key-file/Makefile
410     backends/libsocialweb/Makefile
411     backends/libsocialweb/lib/Makefile
412     backends/libsocialweb/lib/folks-libsocialweb.pc
413     backends/libsocialweb/lib/folks-libsocialweb-uninstalled.pc
414     backends/telepathy/Makefile
415     backends/telepathy/lib/Makefile
416     backends/tracker/Makefile
417     backends/tracker/lib/Makefile
418     folks/Makefile
419     docs/Makefile
420     po/Makefile.in
421     tests/Makefile
422     tests/data/Makefile
423     tests/data/gconf.path
424     tests/folks/Makefile
425     tests/key-file/Makefile
426     tests/libsocialweb/Makefile
427     tests/telepathy/Makefile
428     tests/tracker/Makefile
429     tests/lib/Makefile
430     tests/lib/folks-test-uninstalled.pc
431     tests/lib/key-file/Makefile
432     tests/lib/libsocialweb/Makefile
433     tests/lib/libsocialweb/session.conf
434     tests/lib/telepathy/Makefile
435     tests/lib/tracker/Makefile
436     tests/lib/telepathy/contactlist/Makefile
437     tests/lib/telepathy/contactlist/session.conf
438     tests/tools/Makefile
439     tools/Makefile
440     tools/inspect/Makefile
441 ])
442
443 AC_OUTPUT
444
445 echo "
446 Configure summary:
447
448         Vala........................:  ${enable_vala}
449         Vala Compiler...............:  ${VALAC}
450         C Compiler Flags............:  ${CFLAGS} ${ERROR_CFLAGS}
451         Prefix......................:  ${prefix}
452         Bugreporting URL............:  ${PACKAGE_BUGREPORT}
453         Documentation...............:  ${HAVE_VALADOC}
454         Tests.......................:  ${have_tp_glib_for_tests}
455         Import tool.................:  ${with_import_tool}
456         Inspector tool..............:  ${with_inspect_tool}
457         Tracker backend.............:  ${enable_tracker_backend}
458         Libsocialweb backend........:  ${have_libsocialweb_backend}
459
460
461 "