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 salut_nano_version to 0.
9
10m4_define([salut_major_version], [0])
11m4_define([salut_minor_version], [8])
12m4_define([salut_micro_version], [1])
13m4_define([salut_nano_version], [0])
14
15# Some magic
16m4_define([salut_base_version],
17          [salut_major_version.salut_minor_version.salut_micro_version])
18m4_define([salut_version],
19          [m4_if(salut_nano_version, 0, [salut_base_version], [salut_base_version].[salut_nano_version])])dnl
20
21AC_INIT([Telepathy Salut], [salut_version],
22[https://bugs.freedesktop.org/enter_bug.cgi?product=Telepathy&component=telepathy-salut])
23
24AC_CONFIG_MACRO_DIR([m4])
25AC_LANG([C])
26AM_INIT_AUTOMAKE([1.9 -Wno-portability tar-ustar])
27m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
28AM_PROG_LIBTOOL
29AM_CONFIG_HEADER(config.h)
30
31dnl check for tools
32AC_PROG_CC
33AC_PROG_CC_STDC
34AM_PROG_AS
35AM_PROG_MKDIR_P
36
37dnl add common command line switches
38SALUT_ARG_DEBUG
39SALUT_ARG_VALGRIND
40SALUT_ARG_COVERAGE
41
42dnl Detect Windows Verion
43AC_MSG_CHECKING([for operating system])
44case "$host" in
45  *-*-*mingw*|*-*-*cygwin*)
46    platform=win32
47    ;;
48  *)
49    platform=generic
50    ;;
51esac
52
53AC_MSG_RESULT($platform)
54
55AM_CONDITIONAL([OS_WINDOWS], [test "$platform" = "win32"])
56
57dnl decide error flags
58ifelse(salut_nano_version, 0,
59    [ official_release=yes ],
60    [ official_release=no ])
61
62TP_COMPILER_WARNINGS([ERROR_CFLAGS], [test "x$official_release" = xno],
63  [all \
64   extra \
65   declaration-after-statement \
66   shadow \
67   strict-prototypes \
68   missing-prototypes \
69   sign-compare \
70   nested-externs \
71   pointer-arith \
72   format-security \
73   init-self],
74  [missing-field-initializers \
75   unused-parameter \
76   deprecated-declarations])
77AC_SUBST([ERROR_CFLAGS])
78
79ifelse(salut_nano_version, 0,
80    [ # Salut is version x.y.z - disable coding style checks by default
81AC_ARG_ENABLE(coding-style-checks,
82  AC_HELP_STRING([--enable-coding-style-checks],
83                 [check coding style using grep]),
84    [ENABLE_CODING_STYLE_CHECKS=$enableval], [ENABLE_CODING_STYLE_CHECKS=no] )
85    ],
86    [ # Salut is version x.y.z.1 - enable coding style checks by default
87AC_ARG_ENABLE(coding-style-checks,
88  AC_HELP_STRING([--disable-coding-style-checks],
89                 [do not check coding style using grep]),
90    [ENABLE_CODING_STYLE_CHECKS=$enableval], [ENABLE_CODING_STYLE_CHECKS=yes])
91    ])
92
93if test x$enable_debug = xyes; then
94  AC_DEFINE(ENABLE_DEBUG, [], [Enable debug code])
95fi
96
97AC_SUBST([ENABLE_CODING_STYLE_CHECKS])
98
99dnl Check for code generation tools
100XSLTPROC=
101AC_CHECK_PROGS([XSLTPROC], [xsltproc])
102if test -z "$XSLTPROC"; then
103  AC_MSG_ERROR([xsltproc (from the libxslt source package) is required])
104fi
105
106AM_PATH_PYTHON([2.5])
107
108# Check for a python >= 2.5 with twisted to run python tests
109AC_MSG_CHECKING([for Python with Avahi, Twisted and XMPP protocol support])
110if $PYTHON -c "import twisted.words.xish.domish, twisted.words.protocols.jabber, twisted.internet.reactor, avahi" >/dev/null 2>&1; then
111    TEST_PYTHON="$PYTHON"
112else
113    TEST_PYTHON=false
114fi
115AC_MSG_RESULT([$TEST_PYTHON])
116AC_SUBST(TEST_PYTHON)
117AM_CONDITIONAL([WANT_TWISTED_TESTS], test false != "$TEST_PYTHON")
118
119dnl enable avahi tests
120AC_ARG_ENABLE(avahi-tests,
121  AC_HELP_STRING([ --enable-avahi-tests],
122    [Enable tests that use the system avahi to hit the network ]),
123    enable_avahi_tests=$enableval, enable_avahi_tests=yes)
124
125if test x$enable_avahi_tests = xyes; then
126  if test false = "$TEST_PYTHON"; then
127    AC_MSG_ERROR(
128      [Python with twisted support is needed for avahi twisted tests])
129  fi
130fi
131AM_CONDITIONAL(WANT_TWISTED_AVAHI_TESTS, test "x$enable_avahi_tests" = "xyes")
132
133dnl olpc specific code switch
134AC_ARG_ENABLE(olpc,
135  AC_HELP_STRING([--enable-olpc],[compile with olpc specific code]),
136    enable_olpc=$enableval, enable_olpc=no )
137
138if test x$enable_olpc = xyes; then
139  AC_DEFINE(ENABLE_OLPC, [], [Enable olpc code])
140fi
141
142AM_CONDITIONAL(ENABLE_OLPC, test "x$enable_olpc" = "xyes")
143
144AC_SUBST(ENABLE_OLPC)
145
146AC_HEADER_STDC([])
147AC_C_INLINE
148
149AC_CHECK_HEADERS_ONCE([
150    arpa/inet.h
151    arpa/nameser.h
152    fcntl.h
153    ifaddrs.h
154    netdb.h
155    netinet/in.h
156    sys/ioctl.h
157    sys/un.h
158    unistd.h
159    ])
160
161# on Darwin, these headers are interdependent, according to autoconf.info
162AC_CHECK_HEADERS([sys/socket.h], [], [],
163[
164#include <stdio.h>
165#include <stdlib.h>
166#include <sys/types.h>
167])
168
169# Autoconf has a handy macro for this, since it tends to have dependencies
170AC_HEADER_RESOLV
171
172dnl GTK docs
173GTK_DOC_CHECK
174
175dnl Check for Glib
176PKG_CHECK_MODULES(GLIB,
177    [glib-2.0 >= 2.24, gobject-2.0 >= 2.16, gthread-2.0 >= 2.4, gio-2.0])
178
179AC_SUBST(GLIB_CFLAGS)
180AC_SUBST(GLIB_LIBS)
181
182
183if test "$platform" = "win32"; then
184PKG_CHECK_MODULES(GIO_WINDOWS,
185    [gio-windows-2.0])
186AC_SUBST(GIO_WINDOWS_CFLAGS)
187AC_SUBST(GIO_WINDOWS_LIBS)
188else
189PKG_CHECK_MODULES(GIO_UNIX,
190    [gio-unix-2.0])
191AC_SUBST(GIO_UNIX_CFLAGS)
192AC_SUBST(GIO_UNIX_LIBS)
193fi
194
195GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
196AC_SUBST(GLIB_GENMARSHAL)
197
198dnl Check for D-Bus
199PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.1.0, dbus-glib-1 >= 0.61])
200
201AC_SUBST(DBUS_CFLAGS)
202AC_SUBST(DBUS_LIBS)
203
204dnl Check for libxml2
205PKG_CHECK_MODULES(LIBXML2, [libxml-2.0])
206
207AC_SUBST(LIBXML2_CFLAGS)
208AC_SUBST(LIBXML2_LIBS)
209
210dnl Check for telepathy-glib
211PKG_CHECK_MODULES(TELEPATHY_GLIB, [telepathy-glib >= 0.17.1])
212
213AC_SUBST(TELEPATHY_GLIB_CFLAGS)
214AC_SUBST(TELEPATHY_GLIB_LIBS)
215
216dnl check the backend to use
217if test "$platform" = "win32"; then
218AC_ARG_WITH(backend,
219  AC_HELP_STRING([--with-backend=[bonjour/no]],
220                 [Zeroconf backend to use]),
221  [], [with_backend=bonjour])
222else
223AC_ARG_WITH(backend,
224  AC_HELP_STRING([--with-backend=[avahi/bonjour/no]],
225                 [Zeroconf backend to use]),
226  [], [with_backend=avahi])
227fi
228
229AM_CONDITIONAL(USE_BACKEND_AVAHI, [test "x$with_backend" = "xavahi"])
230AM_CONDITIONAL(USE_BACKEND_BONJOUR, [test "x$with_backend" = "xbonjour"])
231AM_CONDITIONAL(USE_BACKEND_DUMMY, [test "x$with_backend" = "xno"])
232
233dnl Check for Avahi
234if test x$with_backend = xavahi; then
235  PKG_CHECK_MODULES(AVAHI, [avahi-gobject, avahi-client])
236  AC_DEFINE(USE_BACKEND_AVAHI, [], [Use Avahi backend])
237  AC_SUBST(AVAHI_CFLAGS)
238  AC_SUBST(AVAHI_LIBS)
239  AC_SUBST(USE_BACKEND_AVAHI)
240fi
241
242dnl Check for Bonjour Client Library libdns_sd
243if test x$with_backend = xbonjour; then
244  PKG_CHECK_MODULES(BONJOUR, [libdns_sd])
245  AC_DEFINE(USE_BACKEND_BONJOUR, [], [Use Bonjour backend])
246  AC_SUBST(BONJOUR_CFLAGS)
247  AC_SUBST(BONJOUR_LIBS)
248  AC_SUBST(USE_BACKEND_BONJOUR)
249fi
250
251if test x$with_backend = xno; then
252  AC_DEFINE(USE_BACKEND_DUMMY, [], [Use dummy backend])
253  AC_SUBST(USE_BACKEND_DUMMY)
254fi
255
256dnl Check for libsoup
257PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4])
258AC_SUBST(LIBSOUP_CFLAGS)
259AC_SUBST(LIBSOUP_LIBS)
260
261dnl check for libuuid
262PKG_CHECK_MODULES([UUID], [uuid], [HAVE_UUID=yes], [HAVE_UUID=no])
263AC_SUBST([UUID_CFLAGS])
264AC_SUBST([UUID_LIBS])
265if test x"$HAVE_UUID" = xyes; then
266  AC_DEFINE([HAVE_UUID], [1], [Define if libuuid is available])
267else
268  AC_MSG_WARN([libuuid not found, falling back to generating random IDs])
269fi
270
271AC_ARG_ENABLE(submodules,
272  AS_HELP_STRING([--disable-submodules],
273                 [Use system version of Wocky rather than a submodule]),
274  build_submodules=$enableval,
275  build_submodules=yes )
276
277# These must contain "exec" for automake to work right (install-exec,
278# not install-data).
279#
280# Private directory for Wocky and the salut-plugins library
281if test "x$pluginexeclibdir" = x; then
282  pluginexeclibdir='${libdir}/telepathy/salut-0/lib'
283fi
284AC_ARG_VAR([pluginexeclibdir])
285# The actual plugins
286if test "x$pluginexecdir" = x; then
287  pluginexecdir='${libdir}/telepathy/salut-0/plugins'
288fi
289AC_ARG_VAR([pluginexecdir])
290
291dnl plugins
292AC_ARG_ENABLE(plugins,
293  AC_HELP_STRING([--disable-plugins],
294                 [disable plugin loader]),
295    [enable_plugins=$enableval], [enable_plugins=yes])
296
297if test x$enable_plugins = xyes; then
298  AC_DEFINE(ENABLE_PLUGINS, [], [Enable plugins])
299  PKG_CHECK_MODULES(GMODULE, [gmodule-2.0])
300
301  AC_ARG_ENABLE(plugin-api,
302    AC_HELP_STRING([--enable-plugin-api],
303                   [install headers for third-party plugins (experimental)]),
304    [
305      enable_plugin_api=$enableval
306      wocky_install_headers_dir="${includedir}/telepathy-salut-0"
307    ],
308    [enable_plugin_api=no])
309fi
310
311AC_SUBST(GMODULE_CFLAGS)
312AC_SUBST(GMODULE_LIBS)
313
314AM_CONDITIONAL(ENABLE_PLUGINS, test x$enable_plugins = xyes)
315AC_SUBST(ENABLE_PLUGINS)
316
317AM_CONDITIONAL(ENABLE_PLUGIN_API, test x$enable_plugin_api = xyes)
318
319# We have to run Wocky's configure *before* looking for it with
320# PKG_CHECK_MODULES so wocky-uninstalled.pc has been generated
321
322# If you don't specify --prefix, it starts off as NONE. Autoconf
323# would normally do this defaulting for us later, but that's too
324# late to help Wocky.
325if test "x${prefix}" = "xNONE"; then
326  prefix=/usr/local
327fi
328
329# We tell Wocky to install its headers alongside gabble's so that an actual
330# separate Wocky installation won't clash with them. This is a bit of a hack.
331# AX_CONFIG_DIR doesn't make it very easy to pass extra arguments to the
332# submodule's configure.
333
334prev_ac_configure_args=$ac_configure_args
335ac_configure_args="$ac_configure_args --with-installed-headers=${wocky_install_headers_dir} --enable-shared-suffix=${PACKAGE}-${VERSION} --libdir=${pluginexeclibdir}"
336
337if test "x$ENABLE_CODING_STYLE_CHECKS" = xyes ; then
338  ac_configure_args="$ac_configure_args --enable-coding-style-checks"
339else
340  ac_configure_args="$ac_configure_args --disable-coding-style-checks"
341fi
342
343if test "x$tp_werror" = xyes && test "x$official_release" = xno; then
344  ac_configure_args="$ac_configure_args --enable-Werror"
345else
346  ac_configure_args="$ac_configure_args --disable-Werror"
347fi
348
349prev_top_build_prefix=$ac_top_build_prefix
350AX_CONFIG_DIR([lib/ext/wocky])
351ac_top_build_prefix=$prev_top_build_prefix
352
353ac_configure_args=$prev_ac_configure_args
354
355PKG_CONFIG_PATH="${PKG_CONFIG_PATH:+"$PKG_CONFIG_PATH:"}${ac_abs_top_builddir}/lib/ext/wocky/wocky"
356export PKG_CONFIG_PATH
357PKG_CHECK_MODULES([WOCKY], [wocky >= 0.0.0])
358AC_SUBST([WOCKY_CFLAGS])
359AC_SUBST([WOCKY_LIBS])
360
361AC_SUBST(PACKAGE_STRING)
362
363AC_OUTPUT( Makefile                       \
364           docs/Makefile                  \
365           lib/Makefile                   \
366           lib/ext/Makefile               \
367           lib/gibber/Makefile            \
368           lib/gibber/tests/Makefile      \
369           src/Makefile                   \
370           m4/Makefile                    \
371           data/Makefile                  \
372           extensions/Makefile            \
373           tools/Makefile                 \
374           tests/Makefile                 \
375           tests/twisted/Makefile         \
376           tests/twisted/tools/Makefile   \
377           plugins/Makefile               \
378           salut/Makefile                 \
379           salut/telepathy-salut-uninstalled.pc \
380           salut/telepathy-salut.pc
381)
382