system-controller: tune the surface construction
[profile/ivi/murphy.git] / configure.ac
1
2 #                                               -*- Autoconf -*-
3 # Process this file with autoconf to produce a configure script.
4
5 AC_PREREQ(2.59)
6
7 AC_INIT([murphy], m4_esyscmd([build-aux/git-version-gen .tarball-version]))
8
9 AC_CONFIG_SRCDIR([src])
10 AC_CONFIG_MACRO_DIR([m4])
11 AC_CONFIG_HEADER([src/config.h])
12 AM_INIT_AUTOMAKE([-Wno-portability])
13
14 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
15
16 m4_define(version_major, `echo $VERSION | cut -d. -f1 | cut -d- -f1`)
17 m4_define(version_minor, `echo $VERSION | cut -d. -f2 | cut -d- -f1`)
18 m4_define(version_patch, `echo $VERSION | cut -d. -f3 | cut -d- -f1`)
19
20 AC_SUBST(VERSION)
21 AC_SUBST(VERSION_MAJOR, version_major)
22 AC_SUBST(VERSION_MINOR, version_minor)
23 AC_SUBST(VERSION_PATCH, version_patch)
24 AC_SUBST(VERSION_FULL, version_major.version_minor.version_patch)
25
26 MURPHY_VERSION_INFO="0:0:0"
27 AC_SUBST(MURPHY_VERSION_INFO)
28
29 # Disable static libraries.
30 AC_DISABLE_STATIC
31
32 # Checks for programs.
33 AC_PROG_CC
34 AC_PROG_CC_C99
35 # We need AC_PROG_CXX if Qt support is enabled but (at least some
36 # versions of autotools) cannot handle conditional use of this.
37 AC_PROG_CXX
38 AC_PROG_AWK
39 AC_PROG_INSTALL
40 AM_PROG_CC_C_O
41 AM_PROG_LIBTOOL
42 AC_PROG_LEX
43 AC_PROG_YACC
44 AM_PROG_LEX
45 AC_SUBST(LEXLIB)
46
47 # Check that we have flex/bison and not lex/yacc.
48 AC_MSG_CHECKING([for flex vs. lex])
49 case $LEX in
50     *missing\ flex*)
51         AC_MSG_ERROR([looks like you're missing flex])
52         ;;
53     *flex*)
54         AC_MSG_RESULT([ok, looks like we have flex])
55         ;;
56     *)
57         AC_MSG_ERROR([flex is required])
58         ;;
59 esac
60
61 AC_MSG_CHECKING([for bison vs. yacc])
62 case $YACC in
63     *missing\ *)
64         AC_MSG_ERROR([looks like you're missing bison])
65         ;;
66     *bison*)
67         AC_MSG_RESULT([ok, looks like we have bison])
68         ;;
69     *)
70         AC_MSG_ERROR([bison is required])
71         ;;
72 esac
73
74 # Guesstimate native compiler if we're cross-compiling.
75 if test "$cross_compiling" != "no"; then
76     AC_MSG_NOTICE([Looks like we're being cross-compiled...])
77     if test -z "$CC_FOR_BUILD"; then
78         CC_FOR_BUILD=cc
79     fi
80 else
81     AC_MSG_NOTICE([Looks like we're doing a native compilation...])
82     CC_FOR_BUILD='$(CC)'
83 fi
84 AC_SUBST(CC_FOR_BUILD)
85 UNSHAVED_CC_FOR_BUILD="$CC_FOR_BUILD"
86
87 # Make first invocation of PKG_CHECK_MODULES 'if-then-else-fi'-safe.
88 PKG_PROG_PKG_CONFIG
89
90 # Checks for libraries.
91 AC_CHECK_LIB([dl], [dlopen dlclose dlsym dlerror])
92
93 # Checks for header files.
94 AC_PATH_X
95 AC_CHECK_HEADERS([fcntl.h stddef.h stdint.h stdlib.h string.h sys/statvfs.h sys/vfs.h syslog.h unistd.h])
96
97 # Checks for typedefs, structures, and compiler characteristics.
98 AC_HEADER_STDBOOL
99 AC_C_INLINE
100 AC_TYPE_INT16_T
101 AC_TYPE_INT32_T
102 AC_TYPE_INT64_T
103 AC_TYPE_MODE_T
104 AC_TYPE_PID_T
105 AC_TYPE_SIZE_T
106 AC_TYPE_SSIZE_T
107 AC_CHECK_MEMBERS([struct stat.st_rdev])
108 AC_TYPE_UINT16_T
109 AC_TYPE_UINT32_T
110 AC_TYPE_UINT64_T
111 AC_TYPE_UINT8_T
112 AC_CHECK_TYPES([ptrdiff_t])
113
114 # Checks for library functions.
115 AC_FUNC_ERROR_AT_LINE
116 AC_HEADER_MAJOR
117 if test "$cross_compiling" = "no"; then
118     AC_FUNC_MALLOC
119 fi
120 AC_FUNC_STRTOD
121 AC_CHECK_FUNCS([clock_gettime memmove memset regcomp strcasecmp strchr strdup strrchr strtol strtoul])
122
123 # Check and enable extra compiler warnings if they are supported.
124 AC_ARG_ENABLE(extra-warnings,
125               [  --enable-extra-warnings enable extra compiler warnings],
126               [extra_warnings=$enableval], [extra_warnings=auto])
127
128 WARNING_CFLAGS=""
129 warncflags="-Wall -Wextra"
130 if test "$extra_warnings" != "no"; then
131     save_CPPFLAGS="$CPPFLAGS"
132     for opt in $warncflags; do
133         AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
134                           [WARNING_CFLAGS="$WARNING_CFLAGS $opt"])
135     done
136     CPPFLAGS="$save_CPPFLAGS"
137 fi
138
139 AC_SUBST(WARNING_CFLAGS)
140
141 # By default try to find the system default Lua (assumed to be
142 # called lua(.pc). If that is not found, try to look for
143 # packages lua5.2 and lua5.1, which can be found in Debian-based
144 # distributions.
145 #
146 # You can override this using the --with-lua option. For instance
147 # to use Lua 5.1 on Ubuntu while having 5.2 installed, you'd use
148 # --with-lua=lua5.1.
149 AC_ARG_WITH(lua,
150             [  --with-lua                build with specified Lua (pkgconfig filename without .pc suffix)],
151             [with_lua=$withval], [with_lua=default])
152
153 if test "x$with_lua" = "xdefault"; then
154     # Check for "lua" first, then "lua5.2" and finally for "lua5.1"
155     AC_MSG_NOTICE([Checking for an installed Lua...])
156     PKG_CHECK_MODULES([LUA], [lua >= 5.1.1],
157         [with_lua=lua],
158         [PKG_CHECK_MODULES([LUA52], [lua5.2],
159             [with_lua=lua5.2
160              LUA_CFLAGS=$LUA52_CFLAGS
161              LUA_LIBS=$LUA52_LIBS],
162             [PKG_CHECK_MODULES([LUA51], [lua5.1 >= 5.1.1],
163                 [with_lua=lua5.1
164                  LUA_CFLAGS=$LUA51_CFLAGS
165                  LUA_LIBS=$LUA51_LIBS],
166                 [AC_MSG_ERROR(Package requirement (lua >= 5.1.1) was not met!)])
167          ])
168     ])
169 else
170     # Check for pre-defined Lua.
171     AC_MSG_NOTICE([Compiling with Lua package $with_lua.])
172     PKG_CHECK_MODULES(LUA, $with_lua >= 5.1.1)
173 fi
174
175 AC_SUBST(LUA_CFLAGS)
176 AC_SUBST(LUA_LIBS)
177
178 # Check if potentially GPL bits are allowed to be enabled.
179 AC_ARG_ENABLE(gpl,
180               [  --enable-gpl            enable linking against GPL code],
181               [enable_gpl=$enableval], [enable_gpl=no])
182
183 # Check if original libdbus-based DBUS support was enabled.
184 AC_ARG_ENABLE(libdbus,
185               [  --enable-libdbus        enable libdbus-based D-BUS support],
186               [enable_libdbus=$enableval], [enable_libdbus=no])
187
188 if test "$enable_libdbus" = "yes"; then
189     if test "$enable_gpl" = "no"; then
190         AC_MSG_ERROR([libdbus D-Bus support requires the --enable-gpl option.])
191     fi
192     PKG_CHECK_MODULES(LIBDBUS, dbus-1 >= 0.70)
193
194     DBUS_SESSION_DIR="`pkg-config --variable session_bus_services_dir dbus-1`"
195     AC_SUBST(DBUS_SESSION_DIR)
196
197     AC_DEFINE([LIBDBUS_ENABLED], 1, [Enable libdbus D-Bus support ?])
198 else
199     AC_MSG_NOTICE([libdbus-based D-Bus support is disabled.])
200 fi
201
202 AM_CONDITIONAL(LIBDBUS_ENABLED, [test "$enable_libdbus" = "yes"])
203 AC_SUBST(LIBDBUS_ENABLED)
204 AC_SUBST(LIBDBUS_CFLAGS)
205 AC_SUBST(LIBDBUS_LIBS)
206
207 # Check if systemd-bus-based D-Bus support was enabled.
208 AC_ARG_ENABLE(sdbus,
209               [  --enable-sdbus         enable systemd-based D-BUS support],
210               [enable_sdbus=$enableval], [enable_sdbus=no])
211
212 if test "$enable_sdbus" = "yes"; then
213     PKG_CHECK_MODULES(SDBUS, libsystemd-bus)
214     AC_DEFINE([SDBUS_ENABLED], 1, [Enable systemd-bus support ?])
215
216     if test -z "$DBUS_SESSION_DIR"; then
217         # Try to determine the session bus service directory.
218         DBUS_SESSION_DIR="`pkg-config --variable \
219                                session_bus_services_dir dbus-1`"
220         if test "$?" != "0" -o -z "$DBUS_SESSION_DIR"; then
221             DBUS_SESSION_DIR="/usr/share/dbus-1/services"
222         fi
223         AC_SUBST(DBUS_SESSION_DIR)
224     fi
225 else
226     AC_MSG_NOTICE([libsystemd-bus based D-Bus support is disabled.])
227 fi
228
229 AM_CONDITIONAL(SDBUS_ENABLED, [test "$enable_sdbus" = "yes"])
230 AC_SUBST(SDBUS_ENABLED)
231 AC_SUBST(SDBUS_CFLAGS)
232 AC_SUBST(SDBUS_LIBS)
233
234 # Check if PulseAudio mainloop support was enabled.
235 AC_ARG_ENABLE(pulse,
236               [  --enable-pulse          enable PulseAudio mainloop support],
237               [enable_pulse=$enableval], [enable_pulse=auto])
238
239 if test "$enable_pulse" != "no"; then
240     PKG_CHECK_MODULES(PULSE, libpulse >= 0.9.22,
241                              [have_pulse=yes], [have_pulse=no])
242     if test "$have_pulse" = "no" -a "$enable_pulse" = "yes"; then
243         AC_MSG_ERROR([PulseAudio development libraries not found.])
244     fi
245
246     if test "$enable_gpl" = "no"; then
247         if test "$enable_pulse" = "yes"; then
248            AC_MSG_ERROR([PulseAudio support requires the --enable-gpl option.])
249         else
250            enable_pulse="no"
251         fi
252     else
253         enable_pulse="$have_pulse"
254     fi
255 else
256     AC_MSG_NOTICE([PulseAudio mainloop support is disabled.])
257 fi
258
259 if test "$enable_pulse" = "yes"; then
260     AC_DEFINE([PULSE_ENABLED], 1, [Enable PulseAudio mainloop support ?])
261 fi
262 AM_CONDITIONAL(PULSE_ENABLED, [test "$enable_pulse" = "yes"])
263 AC_SUBST(PULSE_ENABLED)
264 AC_SUBST(PULSE_CFLAGS)
265 AC_SUBST(PULSE_LIBS)
266
267 # Check if EFL/ecore mainloop support was enabled.
268 AC_ARG_ENABLE(ecore,
269               [  --enable-ecore          enable EFL/ecore mainloop support],
270               [enable_ecore=$enableval], [enable_ecore=auto])
271
272
273 if test "$enable_ecore" != "no"; then
274     # We are using features which are present only at ecore 1.2 onwards.
275     PKG_CHECK_MODULES(ECORE, ecore >= 1.2,
276                       [have_ecore=yes], [have_ecore=no])
277     if test "$have_ecore" = "no" -a "$enable_ecore" = "yes"; then
278         AC_MSG_ERROR([EFL/ecore development libraries not found.])
279     fi
280
281     enable_ecore="$have_ecore"
282 else
283     AC_MSG_NOTICE([EFL/ecore mainloop support is disabled.])
284 fi
285
286 if test "$enable_ecore" = "yes"; then
287     AC_DEFINE([ECORE_ENABLED], 1, [Enable EFL/ecore mainloop support ?])
288 fi
289 AM_CONDITIONAL(ECORE_ENABLED, [test "$enable_ecore" = "yes"])
290 AC_SUBST(ECORE_ENABLED)
291 AC_SUBST(ECORE_CFLAGS)
292 AC_SUBST(ECORE_LIBS)
293
294 # Check if glib mainloop support was enabled.
295 AC_ARG_ENABLE(glib,
296               [  --enable-glib           enable glib mainloop support],
297               [enable_glib=$enableval], [enable_glib=auto])
298
299 if test "$enable_glib" != "no"; then
300     PKG_CHECK_MODULES(GLIB, glib-2.0,
301                       [have_glib=yes], [have_glib=no])
302     if test "$have_glib" = "no" -a "$enable_glib" = "yes"; then
303         AC_MSG_ERROR([glib development libraries not found.])
304     fi
305
306     enable_glib="$have_glib"
307 else
308     AC_MSG_NOTICE([glib mainloop support is disabled.])
309 fi
310
311 if test "$enable_glib" = "yes"; then
312     AC_DEFINE([GLIB_ENABLED], 1, [Enable glib mainloop support ?])
313 fi
314 AM_CONDITIONAL(GLIB_ENABLED, [test "$enable_glib" = "yes"])
315 AC_SUBST(GLIB_ENABLED)
316 AC_SUBST(GLIB_CFLAGS)
317 AC_SUBST(GLIB_LIBS)
318
319 # Check if qt mainloop support was enabled.
320 AC_ARG_ENABLE(qt,
321               [  --enable-qt             enable qt mainloop support],
322               [enable_qt=$enableval], [enable_qt=auto])
323
324 if test "$enable_qt" != "no"; then
325     PKG_CHECK_MODULES(QTCORE, QtCore,
326                       [have_qt=yes], [have_qt=no])
327     if test "$have_qt" = "no" -a "$enable_qt" = "yes"; then
328         AC_MSG_ERROR([Qt(Core) development libraries not found.])
329     fi
330
331     enable_qt="$have_qt"
332 else
333     AC_MSG_NOTICE([Qt mainloop support is disabled.])
334 fi
335
336 if test "$enable_qt" = "yes"; then
337     AC_DEFINE([QT_ENABLED], 1, [Enable qt mainloop support ?])
338     QT_MOC="`pkg-config --variable moc_location QtCore`"
339     AC_SUBST(QT_MOC)
340 fi
341 AM_CONDITIONAL(QT_ENABLED, [test "$enable_qt" = "yes"])
342 AC_SUBST(QT_ENABLED)
343 AC_SUBST(QTCORE_CFLAGS)
344 AC_SUBST(QTCORE_LIBS)
345
346 # Check if building murphy-console was enabled.
347 AC_ARG_ENABLE(console,
348               [  --enable-console        build Murphy console],
349               [enable_console=$enableval], [enable_console=yes])
350
351 if test "$enable_console" = "no"; then
352     AC_MSG_NOTICE([Murphy console binary is disabled.])
353 else
354     AC_MSG_NOTICE([Murphy console binary is enabled.])
355 fi
356
357 if test "$enable_console" = "yes"; then
358     AC_DEFINE([CONSOLE_ENABLED], 1, [Build Murphy console ?])
359 fi
360 AM_CONDITIONAL(CONSOLE_ENABLED, [test "$enable_console" = "yes"])
361 AC_SUBST(CONSOLE_ENABLED)
362 AC_SUBST(READLINE_CFLAGS)
363 AC_SUBST(READLINE_LIBS)
364
365 # Check for json(-c).
366 PKG_CHECK_MODULES(JSON, [json], [have_json=yes], [have_json=no])
367
368 if test "$have_json" = "no"; then
369     PKG_CHECK_MODULES(JSON, [json-c >= 0.11])
370 fi
371
372 AC_MSG_CHECKING([if json-c has headers under json-c include path])
373 saved_CFLAGS="$CFLAGS"
374 saved_LIBS="$LIBS"
375 CFLAGS="${JSON_CFLAGS}"
376 LIBS="${JSON_LIBS}"
377 AC_LINK_IFELSE(
378    [AC_LANG_PROGRAM(
379          [[#include <../json-c/json.h>]],
380          [[return 0;]])],
381     [json_include_jsonc=yes],
382     [json_include_jsonc=no])
383 AC_MSG_RESULT([$json_include_jsonc])
384 CFLAGS="$saved_CFLAGS"
385 LIBS="$saved_LIBS"
386
387 if test "$json_include_jsonc" = "yes"; then
388     AC_DEFINE([JSON_INCLUDE_PATH_JSONC], 1, [json headers under json-c ?])
389 fi
390
391 AC_MSG_CHECKING([for json_tokener_get_error()])
392 saved_CFLAGS="$CFLAGS"
393 saved_LIBS="$LIBS"
394 CFLAGS="${JSON_CFLAGS}"
395 LIBS="${JSON_LIBS}"
396 AC_LINK_IFELSE(
397    [AC_LANG_PROGRAM(
398          [[#include <json.h>]],
399          [[json_tokener *tok = NULL;
400            if (json_tokener_get_error(tok) != json_tokener_success)
401               return 0;
402            else
403                return 1;]])],
404     [have_json_tokener_get_error=yes],
405     [have_json_tokener_get_error=no])
406 AC_MSG_RESULT([$have_json_tokener_get_error])
407 CFLAGS="$saved_CFLAGS"
408 LIBS="$saved_LIBS"
409
410 if test "$have_json_tokener_get_error" = "yes"; then
411     AC_DEFINE([HAVE_JSON_TOKENER_GET_ERROR], 1, [json_tokener_get_error ?])
412 fi
413
414 # Check if websocket support was/can be enabled.
415 CHECK_WEBSOCKETS()
416
417 # Check if SMACK support should be enabled.
418 AC_ARG_ENABLE(smack,
419               [  --enable-smack          enable SMACK support],
420               [enable_smack=$enableval], [enable_smack=auto])
421
422 if test "$enable_smack" != "no"; then
423     PKG_CHECK_MODULES(SMACK, libsmack, [have_smack=yes], [have_smack=no])
424     if test "$have_smack" = "no" -a "$enable_smack" = "yes"; then
425         AC_MSG_ERROR([SMACK development libraries not found.])
426     fi
427
428     enable_smack="$have_smack"
429 else
430     AC_MSG_NOTICE([SMACK support is disabled.])
431 fi
432
433 if test "$enable_smack" = "yes"; then
434     AC_DEFINE([SMACK_ENABLED], 1, [Enable SMACK support ?])
435 fi
436 AM_CONDITIONAL(SMACK_ENABLED, [test "$enable_smack" = "yes"])
437 AC_SUBST(SMACK_ENABLED)
438 AC_SUBST(SMACK_CFLAGS)
439 AC_SUBST(SMACK_LIBS)
440
441 # Check if systemd support should be enabled.
442 AC_ARG_ENABLE(systemd,
443               [  --enable-systemd          enable systemd support],
444               [enable_systemd=$enableval], [enable_systemd=auto])
445
446 if test "$enable_systemd" != "no"; then
447     PKG_CHECK_MODULES(SYSTEMD, libsystemd-journal libsystemd-daemon,
448                       [have_systemd=yes], [have_systemd=no])
449     if test "$have_systemd" = "no" -a "$enable_systemd" = "yes"; then
450         AC_MSG_ERROR([systemd development libraries not found.])
451     fi
452
453     enable_systemd="$have_systemd"
454 else
455     AC_MSG_NOTICE([systemd support is disabled.])
456 fi
457
458 if test "$enable_systemd" = "yes"; then
459     AC_DEFINE([SYSTEMD_ENABLED], 1, [Enable systemd support ?])
460 fi
461 AM_CONDITIONAL(SYSTEMD_ENABLED, [test "$enable_systemd" = "yes"])
462 AC_SUBST(SYSTEMD_ENABLED)
463 AC_SUBST(SYSTEMD_CFLAGS)
464 AC_SUBST(SYSTEMD_LIBS)
465
466 # Check if telephony was enabled.
467 AC_ARG_ENABLE(telephony,
468               [  --enable-telephony           enable telephony support],
469               [enable_telephony=$enableval], [enable_telephony=no])
470
471 if test "$enable_telephony" = "yes"; then
472     if test "$enable_gpl" = "no"; then
473         AC_MSG_ERROR([Telephony support requires the --enable-gpl option.])
474     fi
475     PKG_CHECK_MODULES(OFONO, ofono >= 1.1)
476 else
477     AC_MSG_NOTICE([Telephony support is disabled.])
478 fi
479
480 if test "$enable_telephony" = "yes"; then
481     AC_DEFINE([TELEPHONY_ENABLED], 1, [Enable D-BUS support ?])
482 fi
483
484 AM_CONDITIONAL(TELEPHONY_ENABLED, [test "$enable_telephony" = "yes"])
485 AC_SUBST(TELEPHONY_ENABLED)
486 AC_SUBST(TELEPHONY_CFLAGS)
487 AC_SUBST(TELEPHONY_LIBS)
488
489 PKG_CHECK_MODULES(AUL, aul,
490            [have_aul=yes], [have_aul=no])
491 enable_aul="$have_aul"
492 if test "$enable_aul" = "yes"; then
493     AC_DEFINE([AUL_ENABLED], 1, [Enable Application Utility Library support ?])
494 fi
495 AM_CONDITIONAL(AUL_ENABLED, [test "$enable_aul" = "yes"])
496 AC_SUBST(AUL_ENABLED)
497 AC_SUBST(AUL_CFLAGS)
498 AC_SUBST(AUL_LIBS)
499
500 PKG_CHECK_MODULES(TZCONFIG, libtzplatform-config,
501            [have_tzconfig=yes], [have_tzconfig=no])
502 enable_tzconfig="$have_tzconfig"
503 if test "$enable_tzconfig" = "yes"; then
504     AC_DEFINE([TZCONFIG_ENABLED], 1, [Enable Tizen configuration support ?])
505 fi
506 AM_CONDITIONAL(TZCONFIG_ENABLED, [test "$enable_tzconfig" = "yes"])
507 AC_SUBST(TZCONFIG_ENABLED)
508 AC_SUBST(TZCONFIG_CFLAGS)
509 AC_SUBST(TZCONFIG_LIBS)
510
511 # Check if system-controller (plugin) support should be enabled.
512 AC_ARG_ENABLE(system-controller,
513               [  --enable-system-controller enable system-controller support],
514               [enable_systemctl=$enableval], [enable_systemctl=no])
515
516 if test "$enable_systemctl" = "yes"; then
517     if test "$enable_websockets" != "yes"; then
518         AC_MSG_ERROR([System controller requires websocket support.])
519     fi
520     if test "$have_aul" != "yes"; then
521         AC_MSG_ERROR([System controller requires AUL support.])
522     fi
523     AC_MSG_NOTICE([System-controller support is enabled.])
524     AC_DEFINE([SYSTEMCTL_ENABLED], 1, [Enable system-controller support ?])
525     PKG_CHECK_MODULES(WAYLAND_CLIENT, wayland-client)
526     PKG_CHECK_MODULES(LIBXML2, libxml-2.0)
527     AC_CHECK_HEADER(
528         [ico-uxf-weston-plugin/ico_input_mgr-client-protocol.h],
529         [weston_ico_plugins=yes], [weston_ico_plugins=false]
530     )
531     if test "$weston_ico_plugins" = "yes"; then
532         AC_MSG_NOTICE([System-controller uses ICO weston plugins.])
533     else
534         PKG_CHECK_MODULES(IVI_EXTENSION_PROTOCOL, ivi-extension-protocol)
535     fi
536     PKG_CHECK_MODULES(AIL, ail)
537 else
538     AC_MSG_NOTICE([System-controller support is disabled.])
539 fi
540
541 AM_CONDITIONAL(SYSTEMCTL_ENABLED, [test "$enable_systemctl" = "yes"])
542 AM_CONDITIONAL(WESTON_ICO_PLUGINS,[test "$weston_ico_plugins" = "yes"])
543 AC_SUBST(SYSTEMCTL_ENABLED)
544 AC_SUBST(WESTON_ICO_PLUGINS)
545 AC_SUBST(WAYLAND_CLIENT_CFLAGS)
546 AC_SUBST(WAYLAND_CLIENT_LIBS)
547 AC_SUBST(IVI_EXTENSION_PROTOCOL_CFLAGS)
548 AC_SUBST(IVI_EXTENSION_PROTOCOL_LIBS)
549 AC_SUBST(LIBXML2_CFLAGS)
550 AC_SUBST(LIBXML2_LIBS)
551 AC_SUBST(AIL_CFLAGS)
552 AC_SUBST(AIL_LIBS)
553
554 # Check if system-monitor (plugin) support should be enabled.
555 AC_ARG_ENABLE(system-monitor,
556               [  --enable-system-monitor enable system-monitor support],
557               [enable_sysmon=$enableval], [enable_sysmon=yes])
558
559 if test "$enable_sysmon" = "yes"; then
560     AC_MSG_NOTICE([System-monitor support is enabled.])
561     AC_DEFINE([SYSMON_ENABLED], 1, [Enable system-monitor support ?])
562 else
563     AC_MSG_NOTICE([System-monitor support is disabled.])
564 fi
565
566 AM_CONDITIONAL(SYSMON_ENABLED, [test "$enable_sysmon" = "yes"])
567 AC_SUBST(SYSMON_ENABLED)
568
569
570 # Check if dlog support was enabled.
571 AC_ARG_ENABLE(dlog,
572               [  --enable-dlog           enable dlog support],
573               [enable_dlog=$enableval], [enable_dlog=auto])
574
575 if test "$enable_dlog" != "no"; then
576     PKG_CHECK_MODULES(DLOG, dlog,
577                       [have_dlog=yes], [have_dlog=no])
578     if test "$have_dlog" = "no" -a "$enable_dlog" = "yes"; then
579         AC_MSG_ERROR([dlog development libraries not found.])
580     fi
581
582     enable_dlog="$have_dlog"
583 else
584     AC_MSG_NOTICE([dlog support is disabled.])
585 fi
586
587 if test "$enable_dlog" = "yes"; then
588     AC_DEFINE([DLOG_ENABLED], 1, [Enable dlog support ?])
589 fi
590 AM_CONDITIONAL(DLOG_ENABLED, [test "$enable_dlog" = "yes"])
591 AC_SUBST(DLOG_ENABLED)
592 AC_SUBST(DLOG_CFLAGS)
593 AC_SUBST(DLOG_LIBS)
594
595 # Check if Audio Session Manager plugin was enabled.
596 AC_ARG_ENABLE(resource-asm,
597               [  --enable-resource-asm        build Murphy Audio Session Manager plugin],
598               [enable_resource_asm=$enableval], [enable_resource_asm=no])
599
600 if test "$enable_resource_asm" != "no"; then
601     PKG_CHECK_MODULES(AUDIO_SESSION_MANAGER, audio-session-mgr,
602                       [have_resource_asm=yes], [have_resource_asm=no])
603     if test "$have_resource_asm" = "no" -a "$enable_resource_asm" = "yes"; then
604         AC_MSG_ERROR([Audio Session Manager development libraries not found.])
605     fi
606     AC_SUBST(AUDIO_SESSION_MANAGER_CFLAGS)
607     AC_SUBST(AUDIO_SESSION_MANAGER_LIBS)
608
609     enable_resource_asm="$have_resource_asm"
610 else
611     AC_MSG_NOTICE([Audio Session Manager support is disabled.])
612 fi
613 if test "$enable_resource_asm" = "yes"; then
614     AC_DEFINE([RESOURCE_ASM_ENABLED], 1, [Enable Audio Session Manager support ?])
615 fi
616 AM_CONDITIONAL(RESOURCE_ASM_ENABLED, [test "$enable_resource_asm" = "yes"])
617 AC_SUBST(RESOURCE_ASM_ENABLED)
618
619 # Set up murphy CFLAGS and LIBS.
620 MURPHY_CFLAGS=""
621 MURPHY_LIBS=""
622 AC_SUBST(MURPHY_CFLAGS)
623 AC_SUBST(MURPHY_LIBS)
624
625 # Allow substitution for LIBDIR and SYSCONFDIR.
626 AC_MSG_CHECKING([libdir])
627 AC_MSG_RESULT([$libdir])
628 AC_SUBST(LIBDIR, [$libdir])
629 AC_MSG_CHECKING([sysconfdir])
630 AC_MSG_RESULT([$sysconfdir])
631 AC_SUBST(SYSCONFDIR, [$sysconfdir])
632
633 #Check whether we build resources or not
634 AC_ARG_WITH(resources,
635             [  --with-resources wheter to build resource management support],
636             [with_resources=$withval],[with_resources=yes])
637
638 AM_CONDITIONAL(BUILD_RESOURCES,  [ test x$with_resources = "xyes" ])
639
640
641 # Check which plugins should be disabled.
642 AC_ARG_WITH(disabled-plugins,
643             [  --with-disabled-plugins=<plugin-list> specify which plugins to disable],
644             [disabled_plugins=$withval],[disabled_plugins=none])
645
646 # Check which plugins should be compiled as standalone DSOs.
647 AC_ARG_WITH(dynamic-plugins,
648             [  --with-dynamic-plugins=<plugin-list>  specify which plugins compile as DSOs],
649             [dynamic_plugins=$withval],[dynamic_plugins=none])
650
651 all_plugins=$(find src/plugins/. -name plugin-*.c 2>/dev/null | \
652               sed 's#^.*/plugin-##g;s#\.c$##g' | tr '\n' ' ')
653
654 #echo "all plugins: [$all_plugins]"
655
656 case $dynamic_plugins in
657     all)  dynamic_plugins="$all_plugins";;
658     none) dynamic_plugins="";;
659 esac
660
661 internal=""; it=""
662 external=""; et=""
663 disabled=""; dt=""
664 for plugin in $all_plugins; do
665     type=internal
666
667     for p in ${dynamic_plugins//,/ }; do
668         if test "$plugin" = "$p"; then
669             type=external
670         fi
671     done
672
673     for p in ${disabled_plugins//,/ }; do
674         if test "$plugin" = "$p"; then
675             type=disabled
676         fi
677     done
678
679     case $type in
680         internal) internal="$internal$it$plugin"; it=" ";;
681         external) external="$external$et$plugin"; et=" ";;
682         disabled) disabled="$disabled$dt$plugin"; dt=" ";;
683     esac
684 done
685
686 DISABLED_PLUGINS="$disabled"
687 INTERNAL_PLUGINS="$internal"
688 EXTERNAL_PLUGINS="$external"
689
690
691 function check_if_disabled() {
692     for p in $DISABLED_PLUGINS; do
693         if test "$1" = "$p"; then
694             return 0
695         fi
696     done
697
698     return 1
699 }
700
701 function check_if_internal() {
702     for p in $INTERNAL_PLUGINS; do
703         if test "$1" = "$p"; then
704             return 0
705         fi
706     done
707
708     return 1
709 }
710
711 AM_CONDITIONAL(DISABLED_PLUGIN_TEST,     [check_if_disabled test])
712 AM_CONDITIONAL(DISABLED_PLUGIN_DBUS,     [check_if_disabled dbus])
713 AM_CONDITIONAL(DISABLED_PLUGIN_GLIB,     [check_if_disabled glib])
714 AM_CONDITIONAL(DISABLED_PLUGIN_CONSOLE,  [check_if_disabled console])
715 AM_CONDITIONAL(DISABLED_PLUGIN_DLOG,     [check_if_disabled dlog])
716 AM_CONDITIONAL(DISABLED_PLUGIN_RESOURCE_DBUS, [check_if_disabled resource-dbus])
717 AM_CONDITIONAL(DISABLED_PLUGIN_RESOURCE_WRT, [check_if_disabled resource-wrt])
718 AM_CONDITIONAL(DISABLED_PLUGIN_AMB, [check_if_disabled amb])
719 AM_CONDITIONAL(DISABLED_PLUGIN_DOMAIN_CONTROL,
720                [check_if_disabled domain-control])
721 AM_CONDITIONAL(DISABLED_PLUGIN_SYSTEMD,  [check_if_disabled systemd])
722 AM_CONDITIONAL(DISABLED_PLUGIN_TELEPHONY, [check_if_disabled telephony])
723 AM_CONDITIONAL(DISABLED_PLUGIN_RESOURCE_ASM,     [check_if_disabled resource-asm])
724
725 AM_CONDITIONAL(DISABLED_PLUGIN_SYSTEMCTL,  [test $enable_systemctl != yes])
726 AM_CONDITIONAL(DISABLED_PLUGIN_SYSMON,  [test $enable_sysmon != yes])
727
728 AM_CONDITIONAL(BUILTIN_PLUGIN_TEST,     [check_if_internal test])
729 AM_CONDITIONAL(BUILTIN_PLUGIN_DBUS,     [check_if_internal dbus])
730 AM_CONDITIONAL(BUILTIN_PLUGIN_GLIB,     [check_if_internal glib])
731 AM_CONDITIONAL(BUILTIN_PLUGIN_CONSOLE,  [check_if_internal console])
732 AM_CONDITIONAL(BUILTIN_PLUGIN_DLOG,     [check_if_internal dlog])
733 AM_CONDITIONAL(BUILTIN_PLUGIN_RESOURCE_DBUS, [check_if_internal resource-dbus])
734 AM_CONDITIONAL(BUILTIN_PLUGIN_RESOURCE_WRT, [check_if_internal resource-wrt])
735 AM_CONDITIONAL(BUILTIN_PLUGIN_AMB, [check_if_internal amb])
736 AM_CONDITIONAL(BUILTIN_PLUGIN_DOMAIN_CONTROL,
737                [check_if_internal domain-control])
738 AM_CONDITIONAL(BUILTIN_PLUGIN_LUA,      [check_if_internal lua])
739 AM_CONDITIONAL(BUILTIN_PLUGIN_SYSTEMD,  [check_if_internal systemd])
740 AM_CONDITIONAL(BUILTIN_PLUGIN_TELEPHONY, [check_if_internal telephony])
741 AM_CONDITIONAL(BUILTIN_PLUGIN_RESOURCE_ASM,      [check_if_internal resource-asm])
742 AM_CONDITIONAL(BUILTIN_PLUGIN_SYSTEMCTL, [check_if_internal system-controller])
743 AM_CONDITIONAL(BUILTIN_PLUGIN_SYSMON, [check_if_internal system-monitor])
744
745 # Check for Check (unit test framework).
746 PKG_CHECK_MODULES(CHECK,
747                   check >= 0.9.4,
748                   [has_check="yes"], [has_check="no"])
749 AM_CONDITIONAL(HAVE_CHECK, test "x$has_check" = "xyes")
750
751 AC_SUBST(CHECK_CFLAGS)
752 AC_SUBST(CHECK_LIBS)
753
754 if test "x$has_check" = "xno"; then
755     AC_MSG_WARN([Check framework not found, unit tests are DISABLED.])
756 fi
757
758 # Check for documentation tools
759 AC_ARG_WITH([documentation],
760             [AS_HELP_STRING([--with-documentation],
761                             [generate pdf, html and other doc files])],
762             [],
763             [with_documentation=auto]
764 )
765
766 AS_IF( [ test x$with_documentation = xno ],
767        [ has_doc_tools="no" ],
768        [ AC_PATH_TOOL([MRP_DOXYGEN], doxygen)
769          AC_PATH_TOOL([MRP_LYX], lyx)
770          AC_PATH_TOOL([MRP_INKSCAPE], inkscape)
771          AC_PATH_TOOL([MRP_PYTHON], python)
772          AC_PATH_TOOL([MRP_TOUCH], touch)
773          AC_PATH_TOOL([MRP_DBLATEX], dblatex)
774          AC_PATH_TOOL([MRP_XMLTO], xmlto)
775
776          AS_IF( [ test x$MRP_DOXYGEN = x -o x$MRP_LYX = x -o \
777                        x$MRP_INKSCAPE = x -o x$MRP_PYTHON = x -o \
778                        x$MRP_TOUCH = x],
779                 [ has_doc_tools="no";
780                   AC_MSG_WARN([Some essential doc-tool is missing]) ],
781                 [ has_doc_tools="yes";
782                   MRP_DOCINIT() ]
783          ) ]
784 )
785
786 AS_IF( [ test x$has_doc_tools == "xno" -o x$MRP_DBLATEX = x ],
787        [ can_make_pdfs="no";
788          AC_WARN([No PDF documentation will be generated]) ],
789        [ can_make_pdfs="yes"]
790 )
791
792 AS_IF([ test x$has_doc_tools == "xno" -o x$MRP_XMLTO = x ],
793       [ can_make_html="no";
794         AC_WARN([No HTML documentation will be generated]) ],
795       [ can_make_html="yes" ]
796 )
797
798
799 AM_CONDITIONAL(BUILD_DOCUMENTATION,  [ test x$has_doc_tools = "xyes" ])
800 AM_CONDITIONAL(BUILD_PDF_DOCUMENTS,  [ test x$can_make_pdfs = "xyes" ])
801 AM_CONDITIONAL(BUILD_HTML_DOCUMENTS, [ test x$can_make_html = "xyes" ])
802
803 AC_SUBST(MRP_DOCDIR, [`pwd`/doc])
804 AC_SUBST(MRP_FIGDIR, [$MRP_DOCDIR/common/figures])
805 AC_SUBST(MRP_MAKE_DOCRULES, [$MRP_DOCDIR/Makefile.rules])
806 AC_SUBST(MRP_DOCSCRIPT_DIR, [$MRP_DOCDIR/scripts])
807 AC_SUBST(MRP_ABNF, [$MRP_DOCSCRIPT_DIR/abnf.py])
808 AC_SUBST(MRP_DBLYXFIX, [$MRP_DOCSCRIPT_DIR/dblyxfix.py])
809 AC_SUBST(MRP_DOXML2DB, [$MRP_DOCSCRIPT_DIR/doxml2db.py])
810 AC_SUBST(MRP_DOXYDEPS, [$MRP_DOCSCRIPT_DIR/doxydeps.py])
811
812
813 # Shave by default.
814 SHAVE_INIT([build-aux], [enable])
815
816 # Create murphy symlink to match domain controller's
817 # placing with how it is installed.
818 if test ! -L murphy/domain-control; then
819     AC_MSG_NOTICE([Symlinking src/plugins/domain-control to src/domain-control...])
820     cd src
821     ln -s plugins/domain-control domain-control
822     cd ..
823 fi
824
825 # Create murphy symlink to src.
826 if test ! -L murphy; then
827     AC_MSG_NOTICE([Symlinking src to murphy...])
828     ln -s src murphy
829 fi
830
831 # Generate output.
832 AC_CONFIG_FILES([build-aux/shave
833                  build-aux/shave-libtool
834                  Makefile
835                  utils/Makefile
836                  src/Makefile
837                  src/common/tests/Makefile
838                  src/core/tests/Makefile
839                  src/core/lua-decision/tests/Makefile
840                  src/daemon/tests/Makefile
841                  src/plugins/tests/Makefile
842                  src/common/murphy-common.pc
843                  src/common/murphy-libdbus.pc
844                  src/common/murphy-dbus-libdbus.pc
845                  src/common/murphy-dbus-sdbus.pc
846                  src/common/murphy-pulse.pc
847                  src/common/murphy-ecore.pc
848                  src/common/murphy-glib.pc
849                  src/common/murphy-qt.pc
850                  src/core/murphy-core.pc
851                  src/core/lua-utils/murphy-lua-utils.pc
852                  src/core/lua-decision/murphy-lua-decision.pc
853                  src/breedline/breedline.pc
854                  src/breedline/breedline-murphy.pc
855                  src/breedline/breedline-glib.pc
856                  src/breedline/tests/Makefile
857                  src/murphy-db/Makefile
858                  src/murphy-db/mdb/Makefile
859                  src/murphy-db/mqi/Makefile
860                  src/murphy-db/mql/Makefile
861                  src/murphy-db/include/Makefile
862                  src/murphy-db/tests/Makefile
863                  src/resolver/murphy-resolver.pc
864                  src/resolver/tests/Makefile
865                  src/plugins/domain-control/murphy-domain-controller.pc
866                  src/plugins/resource-asm/Makefile
867                  doc/Makefile
868                  doc/plugin-developer-guide/Makefile
869                  doc/plugin-developer-guide/db/Makefile
870                  doc/plugin-developer-guide/doxml/Makefile
871                  src/plugins/resource-native/libmurphy-resource/murphy-resource.pc
872                  packaging.in/org.Murphy.conf
873                  ])
874 AC_OUTPUT
875
876
877 # Display the configuration.
878 echo "----- configuration -----"
879 echo "Extra C warnings flags: $WARNING_CFLAGS"
880 echo "Cross-compiling: $cross_compiling"
881 if test "$cross_compiling" != "no"; then
882     echo "     * native compiler: $UNSHAVED_CC_FOR_BUILD"
883 fi
884 echo "Lua (pkgconfig file) to use: $with_lua"
885 echo "    * cflags: $LUA_CFLAGS"
886 echo "    * libs: $LUA_LIBS"
887 echo "D-Bus (libdbus) support: $enable_libdbus"
888 echo "D-Bus (systemd-bus) support: $enable_sdbus"
889 echo "PulseAudio mainloop support: $enable_pulse"
890 echo "EFL/ecore mainloop support: $enable_ecore"
891 echo "glib mainloop support: $enable_glib"
892 echo "Qt mainloop support: $enable_qt"
893 echo "Murphy console plugin and client: $enable_console"
894 echo "Resource management support: $with_resources"
895 echo "Websockets support: $enable_websockets"
896 echo "systemd support: $enable_systemd"
897 echo "Telephony support: $enable_telephony"
898 echo "System controller support: $enable_systemctl"
899 echo "System monitor support: $enable_sysmon"
900 echo "Plugins:"
901 echo "  - linked-in:"
902 for plugin in ${INTERNAL_PLUGINS:-none}; do
903     echo "      $plugin"
904 done
905 echo "  - dynamic:"
906 for plugin in ${EXTERNAL_PLUGINS:-none}; do
907     echo "      $plugin"
908 done
909 echo "  - disabled:"
910 for plugin in ${DISABLED_PLUGINS:-none}; do
911     echo "      $plugin"
912 done