1dnl Set the version number to e.g. 5.x.y immediately before a release.
2dnl Set the version number to e.g. 5.x.y+ immediately after (this will
3dnl enable -Werror).
4AC_INIT([telepathy-mission-control], [5.16.6])
5
6AC_CONFIG_MACRO_DIR([m4])
7AC_CONFIG_AUX_DIR([build-aux])
8AC_CONFIG_SRCDIR(Makefile.am)
9AM_INIT_AUTOMAKE([1.9 tar-ustar -Wno-portability])
10m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
11AC_CONFIG_HEADERS(config.h)
12
13AC_CANONICAL_HOST
14
15AC_PROG_CC
16AC_PROG_CPP
17AC_PROG_CXX
18AC_PROG_INSTALL
19AC_PROG_LIBTOOL
20AM_PROG_MKDIR_P
21
22AC_HEADER_STDC
23AC_CHECK_HEADERS([sys/stat.h sys/types.h sysexits.h])
24AC_CHECK_FUNCS([umask])
25
26case "$PACKAGE_VERSION" in
27  *+)
28    mc_is_release=no
29    ;;
30  *)
31    mc_is_release=yes
32    ;;
33esac
34
35# If API has been removed or changed since last release, change MCP_API (which
36# is part of the directory name under /usr/include) to the version that
37# changed it
38MCP_API_VERSION=5.5
39AC_SUBST([MCP_API_VERSION])
40
41# If ABI has been removed or changed since last release
42#     increment current
43#     set age and revision to 0
44# else if ABI has been added since last release
45#     increment age and current
46#     set revision to 0
47# else if library source has changed since last release
48#     increment revision
49MCP_LT_CURRENT=5
50MCP_LT_REVISION=1
51MCP_LT_AGE=5
52AC_SUBST([MCP_LT_CURRENT])
53AC_SUBST([MCP_LT_REVISION])
54AC_SUBST([MCP_LT_AGE])
55# The ABI version appears in the name of the plugin directory
56MCP_ABI_VERSION=`expr ${MCP_LT_CURRENT} - ${MCP_LT_AGE}`
57AC_SUBST([MCP_ABI_VERSION])
58
59# Recommended CFLAGS for pedantic checking, from telepathy-glib
60
61TP_COMPILER_WARNINGS([ERROR_CFLAGS],
62  [test "x$mc_is_release" = xno],   dnl <- Disable -Werror in releases
63  [all \
64   extra \
65   declaration-after-statement \
66   shadow \
67   strict-prototypes \
68   missing-prototypes \
69   missing-declarations \
70   sign-compare \
71   nested-externs \
72   pointer-arith \
73   format-security \
74   init-self \
75   ],
76  [missing-field-initializers \
77   deprecated-declarations \
78   unused-parameter])
79AC_SUBST([ERROR_CFLAGS])
80
81XSLTPROC=
82AC_CHECK_PROGS([XSLTPROC], [xsltproc])
83if test -z "$XSLTPROC"; then
84    AC_MSG_ERROR([xsltproc (from the libxslt source package) is required])
85fi
86
87AM_PATH_PYTHON([2.6])
88AC_MSG_CHECKING([for enough Python for the tests])
89mc_want_twisted_tests=no
90if $PYTHON -c "import twisted.internet.reactor, dbus.mainloop.glib"\
91    >/dev/null 2>&1; then
92    mc_want_twisted_tests=yes
93fi
94AC_MSG_RESULT([$mc_want_twisted_tests])
95AM_CONDITIONAL([WANT_TWISTED_TESTS], test yes = "$mc_want_twisted_tests")
96
97AC_ARG_ENABLE(debug,            [  --disable-debug               compile without debug code],[enable_debug=${enableval}], enable_debug=yes )
98if test "x$enable_debug" = "xyes"; then
99	CFLAGS="$CFLAGS -DENABLE_DEBUG"
100fi
101
102AC_ARG_ENABLE(cast-checks,      [  --disable-cast-checks         compile with GLIB cast checks disabled],[cchecks=${enableval}],cchecks=yes)
103if test "x$cchecks" = "xno"; then
104	CFLAGS="$CFLAGS -DG_DISABLE_CAST_CHECKS"
105fi
106
107AC_ARG_ENABLE(asserts,      [  --disable-asserts        compile with GLIB assertions disabled],[asserts=${enableval}],asserts=yes)
108if test "x$asserts" = "xno"; then
109	CFLAGS="$CFLAGS -DG_DISABLE_ASSERTS"
110fi
111
112AC_ARG_ENABLE(checks,       [  --disable-checks         compile with GLIB checks disabled],[checks=${enableval}],checks=yes)
113if test "x$checks" = "xno"; then
114	CFLAGS="$CFLAGS -DG_DISABLE_CHECKS"
115fi
116
117AC_ARG_ENABLE(coverage,       [  --enable-coverage         compile with coverage info],[enable_coverage=${enableval}],enable_coverage=no)
118if test "x$enable_coverage" = "xyes"; then
119       CFLAGS="$CFLAGS -g -fprofile-arcs -ftest-coverage"
120fi
121
122AC_ARG_ENABLE([installed-tests],
123  AC_HELP_STRING([--enable-installed-tests],
124    [make tests installable]),
125    [installed_tests=$enableval], [installed_tests=no])
126
127if test x$installed_tests = xyes; then
128  AC_DEFINE(ENABLE_INSTALLED_TESTS, [],
129      [Make tests installable])
130fi
131AM_CONDITIONAL([ENABLE_INSTALLED_TESTS], [test "x$installed_tests" = xyes])
132
133mctestsdir=${libdir}/telepathy-mission-control-tests
134AC_SUBST(mctestsdir)
135
136AC_ARG_WITH([accounts_dir], [AS_HELP_STRING([--with-accounts-dir=<path>],[Directory in which accounts were previously stored])])
137if test -z "$with_accounts_dir" ; then
138    ACCOUNTS_DIR="~/.mission-control/accounts"
139else
140    ACCOUNTS_DIR=$with_accounts_dir
141fi
142AC_SUBST(ACCOUNTS_DIR)
143AC_DEFINE_UNQUOTED([ACCOUNTS_DIR], ["$ACCOUNTS_DIR"], [Directory in which accounts were previously stored])
144
145
146AC_ARG_WITH(accounts_cache_dir, AS_HELP_STRING([--with-accounts-cache-dir=<path>],[Directory for account/connection mapping for crash recovery]))
147if test -z "$with_accounts_cache_dir" ; then
148    ACCOUNTS_CACHE_DIR=""
149else
150    ACCOUNTS_CACHE_DIR=$with_accounts_cache_dir
151fi
152AC_SUBST(ACCOUNTS_CACHE_DIR)
153AC_DEFINE_UNQUOTED(ACCOUNTS_CACHE_DIR,"$ACCOUNTS_CACHE_DIR", [Directory for account/connection mapping for crash recovery])
154
155aegis_enabled="no"
156AC_MSG_CHECKING([whether to build with Aegis (libcreds) support])
157AC_ARG_ENABLE(aegis,
158              AC_HELP_STRING([--enable-aegis],
159                             [Aegis security framework support]),
160              [
161                AC_CHECK_LIB(creds, creds_init,
162                             [
163                               AC_DEFINE([ENABLE_AEGIS], [1],
164                                         [Define if Aegis is supported])
165                               AC_SUBST([AEGIS_LIBS], [-lcreds])
166                             ],
167                             [ AC_MSG_ERROR([Aegis: libcreds not found]) ])
168                aegis_enabled="yes"
169              ],
170              [
171                aegis_enabled="no"
172                AC_MSG_RESULT(no)
173                AC_DEFINE([ENABLE_AEGIS], [0], [Define if Aegis is supported])
174              ])
175
176AM_CONDITIONAL(ENABLE_AEGIS, [test x$aegis_enabled = xyes])
177
178PKG_PROG_PKG_CONFIG()
179
180dnl libaccounts-glib SSO
181libaccounts_sso_enabled="no"
182AC_MSG_CHECKING(whether to build with libaccounts-glib SSO suport)
183
184AC_ARG_ENABLE([libaccounts-sso],
185              AC_HELP_STRING([--enable-libaccounts-sso],
186                             [build with SSO suport. default=no]),
187              [ AC_MSG_RESULT(${enableval})
188                libaccounts_sso_enabled="${enableval}" ],
189              [ AC_MSG_RESULT(no) ] )
190
191AS_IF([ test "x$libaccounts_sso_enabled" = xauto ],
192      [ PKG_CHECK_EXISTS([libaccounts-glib],
193                         [libaccounts_sso_enabled=yes],
194                         [libaccounts_sso_enabled=no]) ])
195
196dnl set up the shell/make variable, the #define and check the package version
197AS_IF([ test "x$libaccounts_sso_enabled" = xyes ],
198      [ ENABLE_LIBACCOUNTS_SSO=yes
199        AC_DEFINE(ENABLE_LIBACCOUNTS_SSO, [1],
200                  [Define if libaccounts SSO support is required])
201        PKG_CHECK_MODULES([LIBACCOUNTS_SSO], [libaccounts-glib >= 0.26]) ],
202      [ AC_DEFINE(ENABLE_LIBACCOUNTS_SSO, [0]) ])
203
204dnl export the CFLAGS and LDFLAGS equivalents determined by PKG_CHECK_MODULES
205AC_SUBST(LIBACCOUNTS_SSO_CFLAGS)
206AC_SUBST(LIBACCOUNTS_SSO_LIBS)
207
208dnl the automake conditional
209AM_CONDITIONAL(ENABLE_LIBACCOUNTS_SSO, [test x$libaccounts_sso_enabled = xyes])
210dnl /libaccounts-glib SSO
211
212AC_ARG_WITH([accounts-glib-hidden-service-type],
213    [AS_HELP_STRING([--with-accounts-glib-hidden-service-type],
214      [mark accounts with the provided service type as hidden @<:@default=no@:>@])],
215    [],
216    [with_accounts_glib_hidden_service_type=no])
217AS_IF([ test "x$with_accounts_glib_hidden_service_type" != xno ],
218    [AC_DEFINE_UNQUOTED(ACCOUNTS_GLIB_HIDDEN_SERVICE_TYPE,
219        ["$with_accounts_glib_hidden_service_type"],
220        [Defined to the non-IM service type for hidden accounts, if any])])
221
222AM_CONDITIONAL(ENABLE_LIBACCOUNTS_GLIB_HIDDEN,
223    [test x$with_accounts_glib_hidden_service_type != xno])
224
225PKG_CHECK_MODULES(DBUS, [dbus-1 >= 0.95, dbus-glib-1 >= 0.82])
226AC_SUBST(DBUS_CFLAGS)
227AC_SUBST(DBUS_LIBS)
228
229PKG_CHECK_MODULES([TELEPATHY], [telepathy-glib >= 0.20.0])
230AC_DEFINE([TP_VERSION_MIN_REQUIRED], [TP_VERSION_0_18],
231  [Ignore post-0.18 deprecations])
232AC_DEFINE([TP_VERSION_MAX_ALLOWED], [TP_VERSION_0_20],
233  [Prevent post-0.20 APIs])
234AC_DEFINE([TP_SEAL_ENABLE], [], [Define to hide deprecated struct fields])
235AC_DEFINE([TP_DISABLE_SINGLE_INCLUDE], [], [Avoid individual headers])
236
237PKG_CHECK_MODULES([GLIB],
238	[glib-2.0 >= 2.46, gobject-2.0, gmodule-no-export-2.0, gio-2.0])
239
240PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0],
241  [
242  AC_DEFINE(HAVE_GIO_UNIX, [], [Define if GIO-Unix is available])
243  GLIB_CFLAGS="$GLIB_CFLAGS $GIO_UNIX_CFLAGS"
244  GLIB_LIBS="$GLIB_LIBS $GIO_UNIX_LIBS"
245  ],
246  [])
247
248AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_46], [Ignore post 2.46 deprecations])
249AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_46], [Prevent post 2.46 APIs])
250
251dnl Check for MCE, a Maemo service used to determine when the device is idle.
252PKG_CHECK_MODULES([MCE], mce >= 1.5, [HAVE_MCE=yes], [HAVE_MCE=no])
253AM_CONDITIONAL([HAVE_MCE], [test x"$HAVE_MCE" = xyes])
254if test x"$HAVE_MCE" = xyes; then
255  AC_DEFINE([HAVE_MCE], [1], [Define if mce is available])
256fi
257
258# -----------------------------------------------------------
259# Connectivity integration
260# -----------------------------------------------------------
261AC_ARG_WITH(connectivity,
262              AS_HELP_STRING([--with-connectivity=@<:@nm/auto/no@:>@],
263                             [build with connectivity support]), ,
264                             with_connectivity=auto)
265
266# --with-connectivity=connman always used to turn off NM support,
267# so treat it as "no" now that ConnMan doesn't need anything special.
268if test "x$with_connectivity" = "xno" || test "x$with_connectivity" = "xconnman"; then
269   have_nm=no
270else
271   PKG_CHECK_MODULES(NETWORK_MANAGER,
272   [
273      libnm
274   ], have_nm="yes", have_nm="no")
275
276   if test "x$have_nm" = "xyes"; then
277      AC_DEFINE(HAVE_NM, 1, [Define if you have libnm-glib])
278   fi
279fi
280
281if test "x$with_connectivity" = "xnm" -a "x$have_nm" != "xyes"; then
282   AC_MSG_ERROR([Couldn't find Network Manager dependencies:
283
284$NETWORK_MANAGER_PKG_ERRORS])
285fi
286
287AM_CONDITIONAL(HAVE_NM, test "x$have_nm" = "xyes")
288
289AC_ARG_ENABLE([conn-setting],
290    [AS_HELP_STRING([--enable-conn-setting],
291         [use a GSetting to control automatic connectivity @<:@default=yes@:>@])],
292    [],
293    [enable_conn_setting=yes])
294if test x"$enable_conn_setting" = xyes; then
295  AC_DEFINE([ENABLE_CONN_SETTING], [1], [Define to use the "use-conn" GSetting])
296fi
297AM_CONDITIONAL([ENABLE_CONN_SETTING], [test x"$enable_conn_setting" = xyes])
298
299# -----------------------------------------------------------
300# Suspend/resume tracking goop
301# -----------------------------------------------------------
302
303AC_ARG_ENABLE([upower],
304    [AS_HELP_STRING([--enable-upower],
305        [monitor device suspending and resuming using upower-glib @<:@default=auto@:>@])],
306    [],
307    [enable_upower=auto])
308
309if test "x$enable_upower" != xno; then
310    PKG_CHECK_MODULES([UPOWER_GLIB], [upower-glib < 0.99],
311        [AC_DEFINE([HAVE_UPOWER], [1], [Define to use upower-glib])
312         have_upower=yes
313        ],
314        [if test "x$enable_upower" == xyes; then
315            AC_MSG_ERROR([$UPOWER_GLIB_PKG_ERRORS])
316         else
317            have_upower=no
318         fi
319        ])
320else
321    have_upower=no
322fi
323
324AC_SUBST([UPOWER_GLIB_CFLAGS])
325AC_SUBST([UPOWER_GLIB_LIBS])
326
327dnl ***************************************************************************
328dnl Check for marshal and enum generators
329dnl ***************************************************************************
330GLIB_GENMARSHAL="`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`"
331AC_SUBST(GLIB_GENMARSHAL)
332GLIB_MKENUMS="`$PKG_CONFIG --variable=glib_mkenums glib-2.0`"
333AC_SUBST(GLIB_MKENUMS)
334
335GTK_DOC_CHECK([1.17],[--flavour no-tmpl])
336GLIB_GSETTINGS
337
338pluginlibdir=$libdir/mission-control
339AC_SUBST(pluginlibdir)
340
341AC_OUTPUT([
342Makefile \
343data/Makefile \
344doc/Makefile \
345doc/reference/Makefile \
346doc/reference/mission-control-plugins/Makefile \
347m4/Makefile \
348mission-control-plugins.pc \
349mission-control-plugins-uninstalled.pc \
350mission-control-plugins/Makefile \
351plugins/Makefile \
352server/Makefile \
353src/Makefile \
354tests/Makefile \
355tests/twisted/Makefile \
356tests/twisted/tools/Makefile \
357tools/Makefile \
358util/Makefile \
359xml/Makefile \
360])
361
362echo "
363Configure summary:
364
365        Compiler.....................:  ${CC}
366        Compiler Flags...............:  ${CFLAGS} ${ERROR_CFLAGS}
367        Linker Flags.................:  ${LDFLAGS}
368        Prefix.......................:  ${prefix}
369        Enable debug.................:  ${enable_debug}
370        Python tests.................:  ${mc_want_twisted_tests}
371        Install unit tests...........:  ${installed_tests}
372
373    Options:
374        Account storage directory....:  ${ACCOUNTS_DIR}
375        Crash recovery directory.....:  ${ACCOUNTS_CACHE_DIR:-\$XDG_CACHE_HOME}
376
377    Features:
378        Plugin API documentation.....:  ${enable_gtk_doc}
379        Network Manager integration..:  ${have_nm}
380        ConnMan integration..........:  ${have_connman}
381        Connectivity GSetting........:  ${enable_conn_setting}
382        Suspend tracking with UPower.:  ${have_upower}
383        Aegis........................:  ${aegis_enabled}
384        libaccounts-glib backend.....:  ${libaccounts_sso_enabled}
385        Hidden accounts-glib accounts:  ${with_accounts_glib_hidden_service_type}
386        Nokia Mode Control Entity....:  ${HAVE_MCE}
387"
388