packaging: collect and package full datadir.
[profile/ivi/murphy.git] / configure.ac
index f10716c..ac916d1 100644 (file)
@@ -4,14 +4,12 @@
 
 AC_PREREQ(2.59)
 
-AC_INIT([murphy],
-        m4_esyscmd([build-aux/git-version-gen .tarball-version]),
-        [krisztian.litkey at intel.com])
+AC_INIT([murphy], m4_esyscmd([build-aux/git-version-gen .tarball-version]))
 
 AC_CONFIG_SRCDIR([src])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_HEADER([src/config.h])
-AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
+AM_INIT_AUTOMAKE([-Wno-portability])
 
 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
 
@@ -46,19 +44,48 @@ AC_PROG_YACC
 AM_PROG_LEX
 AC_SUBST(LEXLIB)
 
-# Don't require ctags (we keep linker scripts and debug files in the repo now).
-#AC_CHECK_PROG(CTAGS, ctags, "ctags")
-#if test "$CTAGS" != "ctags" ; then
-#   AC_MSG_ERROR([ctags is required])
-#fi
+# Check that we have flex/bison and not lex/yacc.
+AC_MSG_CHECKING([for flex vs. lex])
+case $LEX in
+    *missing\ flex*)
+        AC_MSG_ERROR([looks like you're missing flex])
+        ;;
+    *flex*)
+        AC_MSG_RESULT([ok, looks like we have flex])
+        ;;
+    *)
+        AC_MSG_ERROR([flex is required])
+        ;;
+esac
 
-if test "$LEX" != "flex" ; then
-   AC_MSG_ERROR([flex is required])
-fi
+AC_MSG_CHECKING([for bison vs. yacc])
+case $YACC in
+    *missing\ *)
+        AC_MSG_ERROR([looks like you're missing bison])
+        ;;
+    *bison*)
+        AC_MSG_RESULT([ok, looks like we have bison])
+        ;;
+    *)
+        AC_MSG_ERROR([bison is required])
+        ;;
+esac
 
-if test "$YACC" != "bison -y" ; then
-   AC_MSG_ERROR([bison is required])
+# Guesstimate native compiler if we're cross-compiling.
+if test "$cross_compiling" != "no"; then
+    AC_MSG_NOTICE([Looks like we're being cross-compiled...])
+    if test -z "$CC_FOR_BUILD"; then
+        CC_FOR_BUILD=cc
+    fi
+else
+    AC_MSG_NOTICE([Looks like we're doing a native compilation...])
+    CC_FOR_BUILD='$(CC)'
 fi
+AC_SUBST(CC_FOR_BUILD)
+UNSHAVED_CC_FOR_BUILD="$CC_FOR_BUILD"
+
+# Make first invocation of PKG_CHECK_MODULES 'if-then-else-fi'-safe.
+PKG_PROG_PKG_CONFIG
 
 # Checks for libraries.
 AC_CHECK_LIB([dl], [dlopen dlclose dlsym dlerror])
@@ -87,7 +114,9 @@ AC_CHECK_TYPES([ptrdiff_t])
 # Checks for library functions.
 AC_FUNC_ERROR_AT_LINE
 AC_HEADER_MAJOR
-AC_FUNC_MALLOC
+if test "$cross_compiling" = "no"; then
+    AC_FUNC_MALLOC
+fi
 AC_FUNC_STRTOD
 AC_CHECK_FUNCS([clock_gettime memmove memset regcomp strcasecmp strchr strdup strrchr strtol strtoul])
 
@@ -109,13 +138,40 @@ fi
 
 AC_SUBST(WARNING_CFLAGS)
 
-# check for Lua
-PKG_CHECK_MODULES(LUA, lua >= 5.1.1, [try_lua51=no], [try_lua51=yes])
-
-# At least Ubuntu packages lua 5.1 as lua5.1... try that if needed.
-if test "$try_lua51" = "yes"; then
-    PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1.1)
+# By default try to find the system default Lua (assumed to be
+# called lua(.pc). If that is not found, try to look for
+# packages lua5.2 and lua5.1, which can be found in Debian-based
+# distributions.
+#
+# You can override this using the --with-lua option. For instance
+# to use Lua 5.1 on Ubuntu while having 5.2 installed, you'd use
+# --with-lua=lua5.1.
+AC_ARG_WITH(lua,
+            [  --with-lua                build with specified Lua (pkgconfig filename without .pc suffix)],
+            [with_lua=$withval], [with_lua=default])
+
+if test "x$with_lua" = "xdefault"; then
+    # Check for "lua" first, then "lua5.2" and finally for "lua5.1"
+    AC_MSG_NOTICE([Checking for an installed Lua...])
+    PKG_CHECK_MODULES([LUA], [lua >= 5.1.1],
+        [with_lua=lua],
+        [PKG_CHECK_MODULES([LUA52], [lua5.2],
+            [with_lua=lua5.2
+             LUA_CFLAGS=$LUA52_CFLAGS
+             LUA_LIBS=$LUA52_LIBS],
+            [PKG_CHECK_MODULES([LUA51], [lua5.1 >= 5.1.1],
+                [with_lua=lua5.1
+                 LUA_CFLAGS=$LUA51_CFLAGS
+                 LUA_LIBS=$LUA51_LIBS],
+                [AC_MSG_ERROR(Package requirement (lua >= 5.1.1) was not met!)])
+         ])
+    ])
+else
+    # Check for pre-defined Lua.
+    AC_MSG_NOTICE([Compiling with Lua package $with_lua.])
+    PKG_CHECK_MODULES(LUA, $with_lua >= 5.1.1)
 fi
+
 AC_SUBST(LUA_CFLAGS)
 AC_SUBST(LUA_LIBS)
 
@@ -124,31 +180,56 @@ AC_ARG_ENABLE(gpl,
               [  --enable-gpl            enable linking against GPL code],
              [enable_gpl=$enableval], [enable_gpl=no])
 
-# Check if DBUS was enabled.
-AC_ARG_ENABLE(dbus,
-              [  --enable-dbus           enable D-BUS support],
-             [enable_dbus=$enableval], [enable_dbus=no])
+# Check if original libdbus-based DBUS support was enabled.
+AC_ARG_ENABLE(libdbus,
+              [  --enable-libdbus        enable libdbus-based D-BUS support],
+             [enable_libdbus=$enableval], [enable_libdbus=no])
 
-if test "$enable_dbus" = "yes"; then
+if test "$enable_libdbus" = "yes"; then
     if test "$enable_gpl" = "no"; then
-        AC_MSG_ERROR([D-Bus support requires the --enable-gpl option.])
+        AC_MSG_ERROR([libdbus D-Bus support requires the --enable-gpl option.])
     fi
-    PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.70)
+    PKG_CHECK_MODULES(LIBDBUS, dbus-1 >= 0.70)
 
     DBUS_SESSION_DIR="`pkg-config --variable session_bus_services_dir dbus-1`"
     AC_SUBST(DBUS_SESSION_DIR)
+
+    AC_DEFINE([LIBDBUS_ENABLED], 1, [Enable libdbus D-Bus support ?])
 else
-    AC_MSG_NOTICE([D-Bus support is disabled.])
+    AC_MSG_NOTICE([libdbus-based D-Bus support is disabled.])
 fi
 
-if test "$enable_dbus" = "yes"; then
-    AC_DEFINE([DBUS_ENABLED], 1, [Enable D-BUS support ?])
+AM_CONDITIONAL(LIBDBUS_ENABLED, [test "$enable_libdbus" = "yes"])
+AC_SUBST(LIBDBUS_ENABLED)
+AC_SUBST(LIBDBUS_CFLAGS)
+AC_SUBST(LIBDBUS_LIBS)
+
+# Check if systemd-bus-based D-Bus support was enabled.
+AC_ARG_ENABLE(sdbus,
+              [  --enable-sdbus         enable systemd-based D-BUS support],
+             [enable_sdbus=$enableval], [enable_sdbus=no])
+
+if test "$enable_sdbus" = "yes"; then
+    PKG_CHECK_MODULES(SDBUS, libsystemd-bus)
+    AC_DEFINE([SDBUS_ENABLED], 1, [Enable systemd-bus support ?])
+
+    if test -z "$DBUS_SESSION_DIR"; then
+        # Try to determine the session bus service directory.
+        DBUS_SESSION_DIR="`pkg-config --variable \
+                               session_bus_services_dir dbus-1`"
+        if test "$?" != "0" -o -z "$DBUS_SESSION_DIR"; then
+            DBUS_SESSION_DIR="/usr/share/dbus-1/services"
+        fi
+        AC_SUBST(DBUS_SESSION_DIR)
+    fi
+else
+    AC_MSG_NOTICE([libsystemd-bus based D-Bus support is disabled.])
 fi
 
-AM_CONDITIONAL(DBUS_ENABLED, [test "$enable_dbus" = "yes"])
-AC_SUBST(DBUS_ENABLED)
-AC_SUBST(DBUS_CFLAGS)
-AC_SUBST(DBUS_LIBS)
+AM_CONDITIONAL(SDBUS_ENABLED, [test "$enable_sdbus" = "yes"])
+AC_SUBST(SDBUS_ENABLED)
+AC_SUBST(SDBUS_CFLAGS)
+AC_SUBST(SDBUS_LIBS)
 
 # Check if PulseAudio mainloop support was enabled.
 AC_ARG_ENABLE(pulse,
@@ -288,6 +369,25 @@ if test "$have_json" = "no"; then
     PKG_CHECK_MODULES(JSON, [json-c >= 0.11])
 fi
 
+AC_MSG_CHECKING([if json-c has headers under json-c include path])
+saved_CFLAGS="$CFLAGS"
+saved_LIBS="$LIBS"
+CFLAGS="${JSON_CFLAGS}"
+LIBS="${JSON_LIBS}"
+AC_LINK_IFELSE(
+   [AC_LANG_PROGRAM(
+         [[#include <../json-c/json.h>]],
+         [[return 0;]])],
+    [json_include_jsonc=yes],
+    [json_include_jsonc=no])
+AC_MSG_RESULT([$json_include_jsonc])
+CFLAGS="$saved_CFLAGS"
+LIBS="$saved_LIBS"
+
+if test "$json_include_jsonc" = "yes"; then
+    AC_DEFINE([JSON_INCLUDE_PATH_JSONC], 1, [json headers under json-c ?])
+fi
+
 AC_MSG_CHECKING([for json_tokener_get_error()])
 saved_CFLAGS="$CFLAGS"
 saved_LIBS="$LIBS"
@@ -363,16 +463,90 @@ AC_SUBST(SYSTEMD_ENABLED)
 AC_SUBST(SYSTEMD_CFLAGS)
 AC_SUBST(SYSTEMD_LIBS)
 
+# Check if telephony was enabled.
+AC_ARG_ENABLE(telephony,
+              [  --enable-telephony           enable telephony support],
+             [enable_telephony=$enableval], [enable_telephony=no])
+
+if test "$enable_telephony" = "yes"; then
+    if test "$enable_gpl" = "no"; then
+        AC_MSG_ERROR([Telephony support requires the --enable-gpl option.])
+    fi
+    PKG_CHECK_MODULES(OFONO, ofono >= 1.3)
+else
+    AC_MSG_NOTICE([Telephony support is disabled.])
+fi
+
+if test "$enable_telephony" = "yes"; then
+    AC_DEFINE([TELEPHONY_ENABLED], 1, [Enable D-BUS support ?])
+fi
+
+AM_CONDITIONAL(TELEPHONY_ENABLED, [test "$enable_telephony" = "yes"])
+AC_SUBST(TELEPHONY_ENABLED)
+AC_SUBST(TELEPHONY_CFLAGS)
+AC_SUBST(TELEPHONY_LIBS)
+
+# Check if dlog support was enabled.
+AC_ARG_ENABLE(dlog,
+              [  --enable-dlog           enable dlog support],
+             [enable_dlog=$enableval], [enable_dlog=auto])
+
+if test "$enable_dlog" != "no"; then
+    PKG_CHECK_MODULES(DLOG, dlog,
+                      [have_dlog=yes], [have_dlog=no])
+    if test "$have_dlog" = "no" -a "$enable_dlog" = "yes"; then
+        AC_MSG_ERROR([dlog development libraries not found.])
+    fi
+
+    enable_dlog="$have_dlog"
+else
+    AC_MSG_NOTICE([dlog support is disabled.])
+fi
+
+if test "$enable_dlog" = "yes"; then
+    AC_DEFINE([DLOG_ENABLED], 1, [Enable dlog support ?])
+fi
+AM_CONDITIONAL(DLOG_ENABLED, [test "$enable_dlog" = "yes"])
+AC_SUBST(DLOG_ENABLED)
+AC_SUBST(DLOG_CFLAGS)
+AC_SUBST(DLOG_LIBS)
+
+# Check if Audio Session Manager plugin was enabled.
+AC_ARG_ENABLE(resource-asm,
+              [  --enable-resource-asm        build Murphy Audio Session Manager plugin],
+             [enable_resource_asm=$enableval], [enable_resource_asm=no])
+
+if test "$enable_resource_asm" != "no"; then
+    PKG_CHECK_MODULES(AUDIO_SESSION_MANAGER, audio-session-mgr,
+                      [have_resource_asm=yes], [have_resource_asm=no])
+    if test "$have_resource_asm" = "no" -a "$enable_resource_asm" = "yes"; then
+        AC_MSG_ERROR([Audio Session Manager development libraries not found.])
+    fi
+    AC_SUBST(AUDIO_SESSION_MANAGER_CFLAGS)
+    AC_SUBST(AUDIO_SESSION_MANAGER_LIBS)
+    enable_resource_asm="$have_resource_asm"
+else
+    AC_MSG_NOTICE([Audio Session Manager support is disabled.])
+fi
+if test "$enable_resource_asm" = "yes"; then
+    AC_DEFINE([RESOURCE_ASM_ENABLED], 1, [Enable Audio Session Manager support ?])
+fi
+AM_CONDITIONAL(RESOURCE_ASM_ENABLED, [test "$enable_resource_asm" = "yes"])
+AC_SUBST(RESOURCE_ASM_ENABLED)
+
 # Set up murphy CFLAGS and LIBS.
 MURPHY_CFLAGS=""
 MURPHY_LIBS=""
 AC_SUBST(MURPHY_CFLAGS)
 AC_SUBST(MURPHY_LIBS)
 
-# Add LIBDIR to config.h.
+# Allow substitution for LIBDIR and SYSCONFDIR.
 AC_MSG_CHECKING([libdir])
 AC_MSG_RESULT([$libdir])
 AC_SUBST(LIBDIR, [$libdir])
+AC_MSG_CHECKING([sysconfdir])
+AC_MSG_RESULT([$sysconfdir])
+AC_SUBST(SYSCONFDIR, [$sysconfdir])
 
 #Check whether we build resources or not
 AC_ARG_WITH(resources,
@@ -456,22 +630,30 @@ AM_CONDITIONAL(DISABLED_PLUGIN_TEST,     [check_if_disabled test])
 AM_CONDITIONAL(DISABLED_PLUGIN_DBUS,     [check_if_disabled dbus])
 AM_CONDITIONAL(DISABLED_PLUGIN_GLIB,     [check_if_disabled glib])
 AM_CONDITIONAL(DISABLED_PLUGIN_CONSOLE,  [check_if_disabled console])
+AM_CONDITIONAL(DISABLED_PLUGIN_DLOG,     [check_if_disabled dlog])
 AM_CONDITIONAL(DISABLED_PLUGIN_RESOURCE_DBUS, [check_if_disabled resource-dbus])
 AM_CONDITIONAL(DISABLED_PLUGIN_RESOURCE_WRT, [check_if_disabled resource-wrt])
+AM_CONDITIONAL(DISABLED_PLUGIN_AMB, [check_if_disabled amb])
 AM_CONDITIONAL(DISABLED_PLUGIN_DOMAIN_CONTROL,
                [check_if_disabled domain-control])
 AM_CONDITIONAL(DISABLED_PLUGIN_SYSTEMD,  [check_if_disabled systemd])
+AM_CONDITIONAL(DISABLED_PLUGIN_TELEPHONY, [check_if_disabled telephony])
+AM_CONDITIONAL(DISABLED_PLUGIN_RESOURCE_ASM,     [check_if_disabled resource-asm])
 
 AM_CONDITIONAL(BUILTIN_PLUGIN_TEST,     [check_if_internal test])
 AM_CONDITIONAL(BUILTIN_PLUGIN_DBUS,     [check_if_internal dbus])
 AM_CONDITIONAL(BUILTIN_PLUGIN_GLIB,     [check_if_internal glib])
 AM_CONDITIONAL(BUILTIN_PLUGIN_CONSOLE,  [check_if_internal console])
+AM_CONDITIONAL(BUILTIN_PLUGIN_DLOG,     [check_if_internal dlog])
 AM_CONDITIONAL(BUILTIN_PLUGIN_RESOURCE_DBUS, [check_if_internal resource-dbus])
 AM_CONDITIONAL(BUILTIN_PLUGIN_RESOURCE_WRT, [check_if_internal resource-wrt])
+AM_CONDITIONAL(BUILTIN_PLUGIN_AMB, [check_if_internal amb])
 AM_CONDITIONAL(BUILTIN_PLUGIN_DOMAIN_CONTROL,
                [check_if_internal domain-control])
 AM_CONDITIONAL(BUILTIN_PLUGIN_LUA,      [check_if_internal lua])
 AM_CONDITIONAL(BUILTIN_PLUGIN_SYSTEMD,  [check_if_internal systemd])
+AM_CONDITIONAL(BUILTIN_PLUGIN_TELEPHONY, [check_if_internal telephony])
+AM_CONDITIONAL(BUILTIN_PLUGIN_RESOURCE_ASM,      [check_if_internal resource-asm])
 
 # Check for Check (unit test framework).
 PKG_CHECK_MODULES(CHECK, 
@@ -544,6 +726,15 @@ AC_SUBST(MRP_DOXYDEPS, [$MRP_DOCSCRIPT_DIR/doxydeps.py])
 # Shave by default.
 SHAVE_INIT([build-aux], [enable])
 
+# Create murphy symlink to match domain controller's
+# placing with how it is installed.
+if test ! -L murphy/domain-control; then
+    AC_MSG_NOTICE([Symlinking src/plugins/domain-control to src/domain-control...])
+    cd src
+    ln -s plugins/domain-control domain-control
+    cd ..
+fi
+
 # Create murphy symlink to src.
 if test ! -L murphy; then
     AC_MSG_NOTICE([Symlinking src to murphy...])
@@ -562,14 +753,16 @@ AC_CONFIG_FILES([build-aux/shave
                 src/daemon/tests/Makefile
                 src/plugins/tests/Makefile
                 src/common/murphy-common.pc
-                src/common/murphy-dbus.pc
+                src/common/murphy-libdbus.pc
+                src/common/murphy-dbus-libdbus.pc
+                src/common/murphy-dbus-sdbus.pc
                 src/common/murphy-pulse.pc
                 src/common/murphy-ecore.pc
                 src/common/murphy-glib.pc
-         src/common/murphy-qt.pc
+                 src/common/murphy-qt.pc
                 src/core/murphy-core.pc
-         src/core/lua-utils/murphy-lua-utils.pc
-         src/core/lua-decision/murphy-lua-decision.pc
+                 src/core/lua-utils/murphy-lua-utils.pc
+                 src/core/lua-decision/murphy-lua-decision.pc
                 src/breedline/breedline.pc
                 src/breedline/breedline-murphy.pc
                 src/breedline/breedline-glib.pc
@@ -583,6 +776,7 @@ AC_CONFIG_FILES([build-aux/shave
                 src/resolver/murphy-resolver.pc
                 src/resolver/tests/Makefile
                 src/plugins/domain-control/murphy-domain-controller.pc
+                src/plugins/resource-asm/Makefile
                 doc/Makefile
                 doc/plugin-developer-guide/Makefile
                 doc/plugin-developer-guide/db/Makefile
@@ -595,7 +789,15 @@ AC_OUTPUT
 # Display the configuration.
 echo "----- configuration -----"
 echo "Extra C warnings flags: $WARNING_CFLAGS"
-echo "D-Bus support: $enable_dbus"
+echo "Cross-compiling: $cross_compiling"
+if test "$cross_compiling" != "no"; then
+    echo "     * native compiler: $UNSHAVED_CC_FOR_BUILD"
+fi
+echo "Lua (pkgconfig file) to use: $with_lua"
+echo "    * cflags: $LUA_CFLAGS"
+echo "    * libs: $LUA_LIBS"
+echo "D-Bus (libdbus) support: $enable_libdbus"
+echo "D-Bus (systemd-bus) support: $enable_sdbus"
 echo "PulseAudio mainloop support: $enable_pulse"
 echo "EFL/ecore mainloop support: $enable_ecore"
 echo "glib mainloop support: $enable_glib"
@@ -604,6 +806,7 @@ echo "Murphy console plugin and client: $enable_console"
 echo "Resource management support: $with_resources"
 echo "Websockets support: $enable_websockets"
 echo "systemd support: $enable_systemd"
+echo "Telephony support: $enable_telephony"
 echo "Plugins:"
 echo "  - linked-in:"
 for plugin in ${INTERNAL_PLUGINS:-none}; do