# -*- Mode: m4; indent-tabs-mode: nil; tab-width: 2 -*-
# 
#  Copyright (C) 2009,2010 Canonical Ltd.
#  Authors:
#   Gustavo Sverzut Barbieri <gustavo.barbieri@canonical.com>
#   Michael Terry <michael.terry@canonical.com>
# 
#  This file is part of Netbook Launcher EFL.
# 
#  Netbook Launcher EFL is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, version 3 of the License.
# 
#  Netbook Launcher EFL is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
# 
#  You should have received a copy of the GNU General Public License
#  along with Netbook Launcher EFL.  If not, see <http://www.gnu.org/licenses/>.

AC_INIT([Netbook Launcher EFL],[0.3.0],[oem-services@canonical.com])
AC_PREREQ(2.64)
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_HOST

AM_INIT_AUTOMAKE(1.6 dist-bzip2)
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AM_CONFIG_HEADER(config.h)

AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC_C99
AM_PROG_CC_C_O
AC_C_CONST
AC_FUNC_ALLOCA
AC_C___ATTRIBUTE__

define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])
define([AC_LIBTOOL_LANG_GCJ_CONFIG], [:])
define([AC_LIBTOOL_LANG_F77_CONFIG], [:])
AC_DISABLE_STATIC
AC_PROG_LIBTOOL

GETTEXT_PACKAGE=netbook-launcher-efl
AC_SUBST(GETTEXT_PACKAGE)
AC_SUBST([CONFIG_STATUS_DEPENDENCIES],['$(top_srcdir)/po/LINGUAS'])
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Define to the Gettext package name])
ALL_LINGUAS="`cat "$srcdir/po/LINGUAS" | grep -v '^#'`"

IT_PROG_INTLTOOL([0.34])
AM_GLIB_GNU_GETTEXT


PKG_CHECK_MODULES(
        [NETBOOK_LAUNCHER],
        [eina-0 ecore evas ecore-evas ecore-x ecore-file eet edje
         elementary glib-2.0 gthread-2.0 gconf-2.0 gtk+-2.0 gio-2.0
         launcher-0.3 libnotify >= 0.3.2 libcanberra unique-1.0])

AC_ARG_ENABLE([google-gadgets],
    AS_HELP_STRING([--enable-google-gadgets],[enable google gadgets]),
    [
     if test "x${enableval}" = "xyes"; then
        use_ggadgets="yes"
     else
        use_ggadgets="no"
    fi
    ], [use_ggadgets="no"])

if test "x${use_ggadgets}" = "xyes"; then
    PKG_CHECK_MODULES(
            [GOOGLE_GADGETS],
            [cairo gdk-2.0 gadget],
            [AC_DEFINE(HAVE_GOOGLE_GADGETS, 1, [have google gadgets.])])
fi

AM_CONDITIONAL(USE_GOOGLE_GADGETS, test "x${use_ggadgets}" = "xyes")

AC_ARG_ENABLE([quit],
    AS_HELP_STRING([--enable-quit],[enable quit button (yes, no, gnome)]),
    [
     if test "x${enableval}" = "xyes"; then
        use_quit="yes"
     elif test "x${enableval}" = "xgnome"; then
        use_quit="gnome"
     else
        use_quit="no"
    fi
    ], [use_quit="no"])

if test "x${use_quit}" = "xyes"; then
  quit_val=1
elif test "x${use_quit}" = "xgnome"; then
  quit_val=2
else
  quit_val=0
fi

AC_DEFINE_UNQUOTED([USE_QUIT], $quit_val, [whether to use a quit button])
AM_CONDITIONAL(BUILD_QUIT, test "x${use_quit}" = "xyes")

if test "x${use_quit}" = "xyes"; then
  PKG_CHECK_MODULES(
          [NETBOOK_LAUNCHER_QUIT],
          [gtk+-2.0 dbus-glib-1 libgnome-2.0 libgnomeui-2.0  xau])
fi

AC_ARG_WITH([edje-cc],
[AS_HELP_STRING([--with-edje-cc=PATH],
        [specify a specific path to edje_cc])],
[
  edje_cc=$withval
  AC_MSG_NOTICE([edje_cc explicitly set to $edje_cc])
],[
  edje_cc=$(pkg-config --variable=prefix edje)/bin/edje_cc
])
AC_SUBST(edje_cc)

# use --as-needed if supported
LDFLAGS_SAVE="${LDFLAGS}"
LDFLAGS="${LDFLAGS} -Wl,--as-needed"
AC_LINK_IFELSE(
   [AC_LANG_PROGRAM([[]], [])],
   [],
   [LDFLAGS="${LDFLAGS_SAVE}"]
)

# use --fvisibility=hidden if supported
LDFLAGS_SAVE="${LDFLAGS}"
CFLAGS_SAVE="${CFLAGS}"
LDFLAGS="${LDFLAGS} -fvisibility=hidden"
CFLAGS="${CFLAGS} -fvisibility=hidden"
AC_LINK_IFELSE(
   [AC_LANG_PROGRAM([[]], [])],
   [],
   [
   LDFLAGS="${LDFLAGS_SAVE}"
   CFLAGS="${CFLAGS_SAVE}"
   ]
)

AC_PATH_PROG(GCONFTOOL, gconftool-2)
AM_GCONF_SOURCE_2


AC_CONFIG_FILES([
Makefile
m4/Makefile
data/Makefile
data/themes/Makefile
data/themes/default/Makefile
data/themes/alternative/Makefile
data/themes/hedley/Makefile
data/desktop/Makefile
data/schemas/Makefile
src/Makefile
src/launcher/Makefile
src/quit/Makefile
po/Makefile.in
])

AC_OUTPUT

cat <<EOF

PROJECT: $PACKAGE_NAME $PACKAGE_VERSION

Summary:
   * prefix.: $prefix
   * CFLAGS.: $CFLAGS
   * LDFLAGS: $LDFLAGS
   * Google gadgets: $use_ggadgets
   * Quit button: $use_quit

Type 'make all' to compile.

EOF
