1AC_PREREQ([2.59])
2
3# Making releases:
4#   set the new version number:
5#     odd minor -> development series
6#     even minor -> stable series
7#     increment micro for each release within a series
8#   set gabble_nano_version to 0.
9
10m4_define([gabble_major_version], [0])
11m4_define([gabble_minor_version], [18])
12m4_define([gabble_micro_version], [4])
13m4_define([gabble_nano_version], [0])
14
15# Some magic
16m4_define([gabble_base_version],
17          [gabble_major_version.gabble_minor_version.gabble_micro_version])
18m4_define([gabble_version],
19          [m4_if(gabble_nano_version, 0, [gabble_base_version],
20              [gabble_base_version].[gabble_nano_version])])
21
22AC_INIT([Telepathy Gabble], [gabble_version],
23        [https://bugs.freedesktop.org/enter_bug.cgi?product=Telepathy&component=gabble])
24
25AC_CONFIG_MACRO_DIR([m4])
26
27AM_INIT_AUTOMAKE([1.9 -Wno-portability tar-ustar])
28AM_CONFIG_HEADER(config.h)
29
30AC_USE_SYSTEM_EXTENSIONS
31
32m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
33
34dnl check for tools
35AC_PROG_CC
36AC_PROG_CC_STDC
37AC_PROG_INSTALL
38AC_PROG_LIBTOOL
39AC_PROG_MKDIR_P
40
41AC_CHECK_HEADERS_ONCE([
42    arpa/inet.h
43    arpa/nameser.h
44    fcntl.h
45    ifaddrs.h
46    netdb.h
47    netinet/in.h
48    sys/ioctl.h
49    sys/un.h
50    unistd.h
51    ])
52
53# on Darwin, these headers are interdependent, according to autoconf.info
54AC_CHECK_HEADERS([sys/socket.h], [], [],
55[
56#include <stdio.h>
57#include <stdlib.h>
58#include <sys/types.h>
59])
60AC_CHECK_HEADERS([net/if.h], [], [],
61[
62#include <stdio.h>
63#include <stdlib.h>
64#include <sys/types.h>
65#ifdef HAVE_SYS_SOCKET_H
66# include <sys/socket.h>
67#endif
68])
69
70# Autoconf has a handy macro for this, since it tends to have dependencies
71AC_HEADER_RESOLV
72
73COMPILER_OPTIMISATIONS
74COMPILER_COVERAGE
75
76ifelse(gabble_nano_version, 0,
77    [ official_release=yes ],
78    [ official_release=no ])
79
80AM_CONDITIONAL([OFFICIAL_RELEASE], [test "x$official_release" = xyes])
81
82TP_COMPILER_WARNINGS([ERROR_CFLAGS], [test "x$official_release" = xno],
83  [all \
84   extra \
85   declaration-after-statement \
86   shadow \
87   strict-prototypes \
88   missing-declarations \
89   missing-prototypes \
90   sign-compare \
91   nested-externs \
92   pointer-arith \
93   format-security \
94   init-self],
95  [missing-field-initializers \
96   deprecated-declarations \
97   unused-parameter])
98AC_SUBST([ERROR_CFLAGS])
99
100
101#------------------------------------------------------------
102# Detect Operating system based on $host
103#------------------------------------------------------------
104AC_MSG_CHECKING([operating system])
105
106case "$host" in
107  *-*-*mingw*|*-*-*cygwin*)
108    platform=win32
109    AC_MSG_RESULT($platform)
110    ;;
111  *)
112    platform=unix
113    AC_MSG_RESULT($platform)
114    ;;
115esac
116
117AM_CONDITIONAL([WINDOWS], [test "$platform" = "win32"])
118
119# -----------------------------------------------------------
120# Make CA certificates path configurable
121# Stolen from GIO's TLS
122# -----------------------------------------------------------
123AC_MSG_CHECKING([location of system Certificate Authority list])
124AC_ARG_WITH(ca-certificates,
125            [AC_HELP_STRING([--with-ca-certificates=@<:@path@:>@],
126                            [path to system Certificate Authority list])])
127if test "$with_ca_certificates" = "no"; then
128    AC_MSG_RESULT([disabled])
129else
130    if test -z "$with_ca_certificates"; then
131        for f in /etc/pki/tls/certs/ca-bundle.crt \
132                 /etc/ssl/certs/ca-certificates.crt; do
133            if test -f "$f"; then
134                with_ca_certificates="$f"
135            fi
136        done
137        if test -z "$with_ca_certificates"; then
138            AC_MSG_ERROR([could not find. Use --with-ca-certificates=path to set, or --without-ca-certificates to disable])
139        fi
140    fi
141
142    AC_MSG_RESULT($with_ca_certificates)
143    AC_DEFINE_UNQUOTED([GTLS_SYSTEM_CA_CERTIFICATES], ["$with_ca_certificates"], [path to system Certificate Authority list])
144fi
145
146if test -n "$with_ca_certificates"; then
147    if ! test -f "$with_ca_certificates"; then
148        AC_MSG_WARN([Specified certificate authority file '$with_ca_certificates' does not exist])
149    fi
150fi
151
152AC_ARG_ENABLE(debug,
153  AC_HELP_STRING([--disable-debug],[compile without debug code]),
154    enable_debug=$enableval, enable_debug=yes )
155
156ifelse(gabble_nano_version, 0,
157    [ # Gabble is version x.y.z - disable coding style checks by default
158AC_ARG_ENABLE(coding-style-checks,
159  AC_HELP_STRING([--enable-coding-style-checks],
160                 [check coding style using grep]),
161    [ENABLE_CODING_STYLE_CHECKS=$enableval], [ENABLE_CODING_STYLE_CHECKS=no] )
162    ],
163    [ # Gabble is version x.y.z.1 - enable coding style checks by default
164AC_ARG_ENABLE(coding-style-checks,
165  AC_HELP_STRING([--disable-coding-style-checks],
166                 [do not check coding style using grep]),
167    [ENABLE_CODING_STYLE_CHECKS=$enableval], [ENABLE_CODING_STYLE_CHECKS=yes])
168    ])
169
170if test x$enable_debug = xyes; then
171  AC_DEFINE(ENABLE_DEBUG, [], [Enable debug code])
172fi
173AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = xyes])
174
175AC_SUBST([ENABLE_CODING_STYLE_CHECKS])
176
177AC_ARG_ENABLE([installed-tests],
178  AC_HELP_STRING([--enable-installed-tests],
179    [make tests installable]),
180    [installed_tests=$enableval], [installed_tests=no])
181
182if test x$installed_tests = xyes; then
183  AC_DEFINE(ENABLE_INSTALLED_TESTS, [],
184      [Make tests installable])
185fi
186AM_CONDITIONAL([ENABLE_INSTALLED_TESTS], [test "x$installed_tests" = xyes])
187
188gabbletestsdir=${libdir}/telepathy-gabble-tests
189AC_SUBST(gabbletestsdir)
190
191AC_ARG_ENABLE([is-a-phone],
192  AC_HELP_STRING([--enable-is-a-phone],
193    [advertise that we are a phone, not a PC]),
194    [is_a_phone=$enableval], [is_a_phone=no])
195
196if test x$is_a_phone = xyes; then
197  AC_DEFINE(CLIENT_TYPE, ["phone"],
198      [Client type from http://xmpp.org/registrar/disco-categories.html#client])
199  CLIENT_TYPE=phone
200else
201  AC_DEFINE(CLIENT_TYPE, ["pc"],
202      [Client type from http://xmpp.org/registrar/disco-categories.html#client])
203  CLIENT_TYPE=pc
204fi
205
206AC_SUBST(CLIENT_TYPE)
207
208# whether to assert when g_critical() is used
209AC_ARG_ENABLE([fatal-criticals],
210  AC_HELP_STRING([--disable-fatal-criticals],
211    [do not assert because of critical warnings]),
212    [fatal_criticals=$enableval], [fatal_criticals=yes])
213
214if test x$fatal_criticals = xyes; then
215  AC_DEFINE(ENABLE_FATAL_CRITICALS, [],
216      [Critical warnings will result in an assertion])
217fi
218AM_CONDITIONAL([ENABLE_FATAL_CRITICALS], [test "x$fatal_criticals" = xyes])
219
220dnl dummy check for gtk-doc
221AC_ARG_ENABLE(gtk-doc,
222  AC_HELP_STRING([--enable-gtk-doc],[does not actually do anything]),
223  enable_gtk_doc=yes, enable_gtk_doc=no)
224AM_CONDITIONAL([ENABLE_GTK_DOC], [test "x$enable_gtk_doc" = xyes])
225
226dnl Check for Glib
227PKG_CHECK_MODULES(GLIB,
228    [glib-2.0 >= 2.32, gobject-2.0, gthread-2.0, gio-2.0])
229PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.32])
230
231AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_30, [Ignore post 2.30 deprecations])
232AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_32, [Prevent post 2.32 APIs])
233
234AC_SUBST(GLIB_CFLAGS)
235AC_SUBST(GLIB_LIBS)
236
237
238GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
239AC_SUBST(GLIB_GENMARSHAL)
240
241# These must contain "exec" for automake to work right (install-exec,
242# not install-data).
243#
244# Private directory for Wocky and the gabble-plugins library
245if test "x$pluginexeclibdir" = x; then
246  pluginexeclibdir='${libdir}/telepathy/gabble-0/lib'
247fi
248AC_ARG_VAR([pluginexeclibdir])
249# The actual plugins
250if test "x$pluginexecdir" = x; then
251  pluginexecdir='${libdir}/telepathy/gabble-0/plugins'
252fi
253AC_ARG_VAR([pluginexecdir])
254
255AC_ARG_ENABLE(plugins,
256  AC_HELP_STRING([--disable-plugins],
257                 [disable plugin loader]),
258    [enable_plugins=$enableval], [enable_plugins=yes])
259
260if test x$enable_plugins = xyes; then
261  AC_DEFINE(ENABLE_PLUGINS, [], [Enable plugins])
262  PKG_CHECK_MODULES(GMODULE, [gmodule-2.0])
263
264  AC_ARG_ENABLE(plugin-api,
265    AC_HELP_STRING([--enable-plugin-api],
266                   [install headers for third-party plugins (experimental)]),
267    [
268      enable_plugin_api=$enableval
269      wocky_install_headers_dir="${includedir}/telepathy-gabble-0"
270    ],
271    [enable_plugin_api=no])
272fi
273
274AC_SUBST(GMODULE_CFLAGS)
275AC_SUBST(GMODULE_LIBS)
276
277AM_CONDITIONAL(ENABLE_PLUGINS, test x$enable_plugins = xyes)
278AC_SUBST(ENABLE_PLUGINS)
279
280AM_CONDITIONAL(ENABLE_PLUGIN_API, test x$enable_plugin_api = xyes)
281
282AC_ARG_ENABLE(channel-type-call,
283  AC_HELP_STRING([--disable-channel-type-call],
284                 [disable support for the draft Channel.Type.Call]),
285    [enable_channel_type_call=$enableval], [enable_channel_type_call=yes])
286
287if test x$enable_channel_type_call = xyes; then
288  AC_DEFINE(ENABLE_CHANNEL_TYPE_CALL, [], [Enable Channel.Type.Call])
289fi
290
291AM_CONDITIONAL(ENABLE_CHANNEL_TYPE_CALL, test x$enable_channel_type_call = xyes)
292
293dnl Check for D-Bus
294PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.1.0, dbus-glib-1 >= 0.82])
295
296AC_SUBST(DBUS_CFLAGS)
297AC_SUBST(DBUS_LIBS)
298
299AC_DEFINE(TP_SEAL_ENABLE, [], [Prevent to use sealed variables])
300AC_DEFINE(TP_DISABLE_SINGLE_INCLUDE, [], [Disable single header include])
301AC_DEFINE(TP_VERSION_MIN_REQUIRED, TP_VERSION_0_18, [Ignore post 0.18 deprecations])
302AC_DEFINE(TP_VERSION_MAX_ALLOWED, TP_VERSION_0_20, [Prevent post 0.20 APIs])
303PKG_CHECK_MODULES(TP_GLIB, [telepathy-glib >= 0.19.9])
304
305AC_SUBST(TP_GLIB_CFLAGS)
306AC_SUBST(TP_GLIB_LIBS)
307
308dnl Check for code generation tools
309XSLTPROC=
310AC_CHECK_PROGS([XSLTPROC], [xsltproc])
311if test -z "$XSLTPROC"; then
312  AC_MSG_ERROR([xsltproc (from the libxslt source package) is required])
313fi
314
315AM_PATH_PYTHON([2.5])
316
317# Check for a Python >= 2.5 with Twisted, to run the tests
318AC_MSG_CHECKING([for Python with Twisted and XMPP protocol support])
319if $PYTHON -c "import twisted.words.xish.domish, twisted.words.protocols.jabber, twisted.internet.reactor" >/dev/null 2>&1; then
320    TEST_PYTHON="$PYTHON"
321else
322    TEST_PYTHON=false
323fi
324AC_MSG_RESULT([$TEST_PYTHON])
325AC_SUBST(TEST_PYTHON)
326AM_CONDITIONAL([WANT_TWISTED_TESTS], test false != "$TEST_PYTHON")
327
328# We have to run Wocky's configure *before* looking for it with PKG_CHECK_MODULES so wocky-uninstalled.pc has been generated
329
330# If you don't specify --prefix, it starts off as NONE. Autoconf
331# would normally do this defaulting for us later, but that's too
332# late to help Wocky.
333if test "x${prefix}" = "xNONE"; then
334  prefix=/usr/local
335fi
336
337# We tell Wocky to install its headers alongside gabble's so that an actual
338# separate Wocky installation won't clash with them. This is a bit of a hack.
339# AX_CONFIG_DIR doesn't make it very easy to pass extra arguments to the
340# submodule's configure.
341prev_ac_configure_args=$ac_configure_args
342
343ac_configure_args="$ac_configure_args --with-installed-headers=${wocky_install_headers_dir} --enable-shared-suffix=${PACKAGE}-${VERSION} --libdir=${pluginexeclibdir}"
344
345if test "x$ENABLE_CODING_STYLE_CHECKS" = xyes ; then
346  ac_configure_args="$ac_configure_args --enable-coding-style-checks"
347else
348  ac_configure_args="$ac_configure_args --disable-coding-style-checks"
349fi
350
351if test "x$tp_werror" = xyes && test "x$official_release" = xno; then
352  ac_configure_args="$ac_configure_args --enable-Werror"
353else
354  ac_configure_args="$ac_configure_args --disable-Werror"
355fi
356
357dnl wocky
358prev_top_build_prefix=$ac_top_build_prefix
359AX_CONFIG_DIR([lib/ext/wocky])
360ac_top_build_prefix=$prev_top_build_prefix
361
362ac_configure_args=$prev_ac_configure_args
363
364dnl Check if Android build
365AC_ARG_ENABLE(submodules,
366              AS_HELP_STRING([--disable-submodules],[Use system versions of Wocky, rather than submodules]),
367              build_submodules=$enableval, build_submodules=yes )
368
369dnl Check for Wocky
370# re-enable once Wocky has been released as a lib
371if test x$build_submodules = xyes; then
372    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:"$ac_top_build_prefix"lib/ext/wocky/wocky
373fi
374
375PKG_CHECK_MODULES(WOCKY, wocky >= 0.0.0)
376AC_SUBST(WOCKY_CFLAGS)
377AC_SUBST(WOCKY_LIBS)
378
379AC_ARG_ENABLE(google-relay,
380  AC_HELP_STRING([--disable-google-relay],
381                 [disable Google Jingle relay support]),
382    [enable_google_relay=$enableval], [enable_google_relay=yes])
383
384if test x$enable_google_relay = xyes; then
385  AC_DEFINE(ENABLE_GOOGLE_RELAY, [], [Enable Google Jingle relay support])
386
387  dnl Check for libsoup
388  PKG_CHECK_MODULES(SOUP, libsoup-2.4)
389else
390  SOUP_CFLAGS=
391  SOUP_LIBS=
392fi
393AC_SUBST(SOUP_CFLAGS)
394AC_SUBST(SOUP_LIBS)
395AM_CONDITIONAL([ENABLE_GOOGLE_RELAY], [test "x$enable_google_relay" = xyes])
396
397AC_ARG_ENABLE(file-transfer,
398  AC_HELP_STRING([--disable-file-transfer],
399                 [disable file transfer support]),
400    [enable_ft=$enableval], [enable_ft=yes])
401
402if test x$enable_ft = xyes; then
403    AC_DEFINE(ENABLE_FILE_TRANSFER, [], [Enable file transfer])
404fi
405AM_CONDITIONAL([ENABLE_FILE_TRANSFER], [test "x$enable_ft" = xyes])
406
407AC_ARG_ENABLE(voip,
408  AC_HELP_STRING([--disable-voip],
409                 [disable VoIP support (and, consequently, Jingle-based file transfer support]),
410    [enable_voip=$enableval], [enable_voip=yes])
411
412if test x$enable_voip = xyes; then
413    AC_DEFINE(ENABLE_VOIP, [], [Enable VoIP])
414fi
415AM_CONDITIONAL([ENABLE_VOIP], [test "x$enable_voip" = xyes])
416
417if test x$enable_voip = xyes -a x$enable_ft = xyes; then
418    enable_jingle_ft=yes
419    AC_DEFINE(ENABLE_JINGLE_FILE_TRANSFER, [], [Enable file transfer])
420    dnl Check for libnice
421    PKG_CHECK_MODULES(NICE, nice >= 0.0.11)
422else
423    enable_jingle_ft=no
424    NICE_CFLAGS=
425    NICE_LIBS=
426fi
427AC_SUBST(NICE_CFLAGS)
428AC_SUBST(NICE_LIBS)
429AM_CONDITIONAL([ENABLE_JINGLE_FILE_TRANSFER], [test "x$enable_jingle_ft" = xyes])
430
431AC_CHECK_FUNCS(getifaddrs memset select strndup setresuid setreuid strerror)
432
433AC_OUTPUT( Makefile \
434           docs/Makefile \
435           extensions/Makefile \
436           src/Makefile \
437           m4/Makefile \
438           data/Makefile \
439           tests/Makefile \
440           tools/Makefile \
441           tests/suppressions/Makefile \
442           tests/twisted/Makefile \
443           lib/Makefile \
444           lib/ext/Makefile \
445           lib/gibber/Makefile \
446           plugins/Makefile \
447           gabble/Makefile \
448           gabble/telepathy-gabble-uninstalled.pc \
449           gabble/telepathy-gabble.pc
450)
451
452if test false != "$TEST_PYTHON"; then
453  tests_enabled=yes
454else
455  tests_enabled=no
456fi
457
458echo "
459Configure summary:
460
461        Compiler....................:  ${CC}
462        Compiler Flags..............:  ${CFLAGS} ${ERROR_CFLAGS}
463        Prefix......................:  ${prefix}
464        Coding style checks.........:  ${ENABLE_CODING_STYLE_CHECKS}
465        Enable debug................:  ${enable_debug}
466        Python tests................:  ${tests_enabled}
467        Install unit tests..........:  ${installed_tests}
468
469    Features:
470
471        Client type.................:  \"${CLIENT_TYPE}\"
472        Plugin support..............:  ${enable_plugins}
473        Plugin headers installed....:  ${enable_plugin_api}
474        Channel.Type.Call support...:  ${enable_channel_type_call}
475        Google relay support........:  ${enable_google_relay}
476        File transfer support.......:  ${enable_ft}
477        Jingle file transfer support:  ${enable_jingle_ft}
478        VoIP support................:  ${enable_voip}
479
480"
481