dnl Process this file with autoconf to produce a configure script.
dnl Created by Anjuta application wizard.

AC_INIT(unity_webapps, 2.5.1)

AC_CONFIG_HEADERS([config.h])

AM_INIT_AUTOMAKE([1.11 tar-pax])

AM_SILENT_RULES([yes])

AC_PROG_CC_C99

AC_CONFIG_MACRO_DIR([m4])

dnl ***************************************************************************
dnl Internationalization
dnl ***************************************************************************
IT_PROG_INTLTOOL([0.35.0])

GETTEXT_PACKAGE=unity_webapps
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [GETTEXT package name])
AM_GLIB_GNU_GETTEXT

LT_INIT

# Beware: remember that libunity-webapps will be pulled in at runtime in
# the browser runtime env. So watch out for bad mix ups in the dependancies/runtimes
# e.g. adding some dependancies on gtk3 when chromium & ff are still gtk2 based.
PKG_CHECK_MODULES(UNITY_WEBAPPS, [glib-2.0 gobject-2.0 gio-2.0
				 gio-unix-2.0 json-glib-1.0 libsoup-2.4 packagekit-glib2 polkit-gobject-1])
GLIB_GSETTINGS

PKG_CHECK_MODULES(TELEPATHY_GLIB, [telepathy-glib])
PKG_CHECK_MODULES(UNITY_WEBAPPS_DAEMON, [libnotify unity messaging-menu gtk+-3.0 sqlite3 gdk-pixbuf-2.0 libwnck-3.0])

PKG_CHECK_MODULES(UNITY_WEBAPPS_WM_PID_TRACKER, [libwnck-3.0])
PKG_CHECK_MODULES(GEOCLUE, [geoclue])

PKG_CHECK_MODULES(UNITY_WEBAPPS_SERVICE_TRACKER, [gtk+-3.0 dbusmenu-glib-0.4 dbusmenu-gtk3-0.4])

PKG_CHECK_MODULES(UNITY_WEBAPPS_TOOLS, [libwnck-3.0])

GOBJECT_INTROSPECTION_CHECK([0.6.7])

AC_PATH_PROG([GDBUS_CODEGEN], [gdbus-codegen], AC_MSG_ERROR([gdbus-codegen is required but was not found]))

AC_CHECK_LIB(gthread-2.0, g_thread_init)

AC_DEFINE([UNITY_WEBAPPS_CONTAINER_APP_NAME], ["webapp-container"], [Webapp container application name.])


dnl ========== Tests ==========
AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests],
    [Enable tests. [default=no]]),
    [enable_tests="yes"], [enable_tests="no"])

if test "x$enable_tests" = "xyes"; then
    AC_DEFINE([ENABLE_TESTS], 1, [Enable tests.])
    # Tests need debug to be enabled
    enable_debug="yes"
fi

AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" = "xyes"])


dnl ===== gcov coverage reporting =====
m4_include([m4/gcov.m4])
AC_TDD_GCOV
AC_SUBST(UNITY_WEBAPPS_COVERAGE_CFLAGS)
AC_SUBST(UNITY_WEBAPPS_COVERAGE_CXXFLAGS)
AC_SUBST(UNITY_WEBAPPS_COVERAGE_LDFLAGS)

dnl =============================Debug=========================================
AC_ARG_ENABLE(debug,
			  AC_HELP_STRING([--enable-debug],
							 [enable verbose debugging. [default=no]]),
			  [enable_debug="yes"],[enable_debug="no"])

if test "x$enable_debug" = "xyes"; then
	UNITY_WEBAPPS_DEBUG_CFLAGS="-DUNITY_WEBAPPS_ENABLE_DEBUG -g"
	CFLAGS="$CFLAGS -O0 -Wall"
else
	UNITY_WEBAPPS_DEBUG_CFLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
	CFLAGS="$CFLAGS -Wall"
	
	if test "x$need_debug" = "xyes"; then
		AC_MSG_ERROR([debug must be enabled in order to enable coverage.])
	fi
fi

m4_ifdef([GTK_DOC_CHECK], [
GTK_DOC_CHECK([1.18],[--flavour no-tmpl])
],[
AM_CONDITIONAL([ENABLE_GTK_DOC], false)
])

AC_SUBST(UNITY_WEBAPPS_DEBUG_CFLAGS)

saved_CFLAGS=$CFLAGS
saved_LIBS=$LIBS
CFLAGS=$JS_CFLAGS
LIBS=$JS_LIBS

AC_CHECK_LIB(unity, unity_music_player_export)
AC_CHECK_FUNC([unity_music_player_export], AC_DEFINE([HAVE_UNITY_MUSIC_PLAYER_EXPORT], [1], [Define if we already have unity_music_player_export]),)
CFLAGS=$saved_CFLAGS
LIBS=$saved_LIBS


AC_OUTPUT([
Makefile
src/libunity-webapps/libunity_webapps-0.2.pc
src/Makefile
src/libunity-webapps/Makefile
src/webapps-service/Makefile
src/context-daemon/Makefile
src/runner/Makefile
src/index-updater/Makefile
src/libunity-webapps-repository/libunity-webapps-repository.pc
src/libunity-webapps-repository/Makefile
tests/Makefile
tests/context-daemon/Makefile
tests/traced/Makefile
tests/traced/test-runner/Makefile
tests/traced/test-runner/post-actions/Makefile
tests/traced/misc/Makefile
tests/traced/notification/Makefile
tests/traced/indicator/Makefile
tests/traced/music-player/Makefile
tests/traced/launcher/Makefile
tests/traced/fuzz/Makefile
tests/traced/actions/Makefile
tests/traced/multicontext/Makefile
tests/traced/observer-api/Makefile
tests/traced/common/Makefile
tests/repository/Makefile
tests/repository/application-manifest/Makefile
tests/repository/available-application/Makefile
tests/repository/local-index/Makefile
tests/repository/application-repository/Makefile
tests/index-updater/Makefile
tests/libunity-webapps/Makefile
tests/misc/Makefile
data/Makefile
docs/Makefile
docs/dbus/Makefile
docs/reference/Makefile
docs/reference/libunity-webapps/Makefile
tools/Makefile
po/Makefile.in])
