# ================= initialization =================== #
AC_INIT([Audio Recorder], [0.3], [https://bugs.launchpad.net/audio-recorder/+filebug], [audio-recorder])

AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADER([src/config.h])
AM_MAINTAINER_MODE

# ============== basic compiler settings ============= #
AC_PROG_CC
AC_HEADER_STDC

# *************************
# Checks for programs.
# *************************
AC_PROG_CXX
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET

# ========== export compiler / linker options ======== #
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(LIBS)

# ---- compile with -Wall -----
CFLAGS="$CFLAGS -Wall"

# ---- lib math (-lm) -----
LDFLAGS="$LDFLAGS -lm"

# ============== look for dependencies =============== #
# check for headers needed for standard interfaces
AC_CHECK_HEADERS(
	stdlib.h \
	string.h \ 
	stdio.h \
	unistd.h
)   

GLIB_REQUIRED=2.14.0
GTK_REQUIRED=2.14.0
PANEL_REQUIRED=2.0.0
GCONF_REQUIRED=2.0.0
GTHREAD_REQUIRED=2.0.0
GSTREAMER_REQUIRED=0.8.0
APPINDICATOR_REQUIRED=0.2

PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)

PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_REQUIRED)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)

PKG_CHECK_MODULES(GCONF, gconf-2.0 >= $GCONF_REQUIRED)
AC_SUBST(GCONF_CFLAGS)
AC_SUBST(GCONF_LIBS)

#PKG_CHECK_MODULES(PANEL, libpanelapplet-2.0 >= $PANEL_REQUIRED)
#AC_SUBST(PANEL_CFLAGS)
#AC_SUBST(PANEL_LIBS)

PKG_CHECK_MODULES(GSTREAMER, gstreamer-0.10 >= $GSTREAMER_REQUIRED)
AC_SUBST(GSTREAMER_CFLAGS)
AC_SUBST(GSTREAMER_LIBS)

PKG_CHECK_MODULES(GSTREAMER_INTERFACE, gstreamer-interfaces-0.10 >= $GSTREAMER_REQUIRED)
AC_SUBST(GSTREAMER_INTERFACE_CFLAGS)
AC_SUBST(GSTREAMER_INTERFACE_LIBS)

PKG_CHECK_MODULES(GTHREAD,  gthread-2.0 >= $GTHREAD_REQUIRED)
AC_SUBST(GTHREAD_CFLAGS)
AC_SUBST(GTHREAD_LIBS)

#PKG_CHECK_MODULES(GNOME_VFS, gnome-vfs-module-2.0 >= 2.0)
#AC_SUBST(GNOME_VFS_CFLAGS)
#AC_SUBST(GNOME_VFS_LIBS)

PKG_CHECK_MODULES(PULSEAUDIO, libpulse >= 0.0)
AC_SUBST(PULSEAUDIO_CFLAGS)
AC_SUBST(PULSEAUDIO_LIBS)

PKG_CHECK_MODULES(MEDIA_PROFILES, gnome-media-profiles >= 0.0)
AC_SUBST(MEDIA_PROFILES_CFLAGS)
AC_SUBST(MEDIA_PROFILES_LIBS)

# current dbus-1 version is 1.4 
PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.8)
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS)

# current dbus-glib-1 version is 0.88
PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1 >= 0.4)
AC_SUBST(DBUS_GLIB_CFLAGS)
AC_SUBST(DBUS_GLIB_LIBS)

# Supports AppIndicator?
# Ref: https://launchpad.net/indicator-application
PKG_CHECK_EXISTS([appindicator-0.1 >= $APPINDICATOR_REQUIRED],
                enable_appindicator="yes",
                enable_appindicator="no")

if test x$enable_appindicator = xyes ; then
    PKG_CHECK_EXISTS([appindicator-0.1 >= $APPINDICATOR_REQUIRED],,
                     AC_MSG_ERROR([appindicator-0.1 is not installed]))

    PKG_CHECK_MODULES(APP_INDICATOR,
                    appindicator-0.1 >= $APPINDICATOR_REQUIRED)
    AC_SUBST(APP_INDICATOR_CFLAGS)
    AC_SUBST(APP_INDICATOR_LIBS)
    AC_DEFINE(HAS_APP_INDICATOR, 1, [Has AppIndicator])
fi
AM_CONDITIONAL(HAS_APP_INDICATOR, test x"$enable_appindicator" = xyes)

# *************************
# Checks for library functions.
# *************************
AC_FUNC_STAT
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([exp pow])

# *************************
# Add languages which your application supports here.
# *************************
ALL_LINGUAS="de en_AU fi fr hu nb pt_BR pt"

GETTEXT_PACKAGE=audio-recorder

AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])

AM_GLIB_GNU_GETTEXT

AC_PROG_INTLTOOL

# Change default from /usr/local to /usr 
AC_PREFIX_DEFAULT(/usr)

AC_CONFIG_FILES([Makefile
                 src/Makefile
                 pixmaps/Makefile
                 data/Makefile
                 po/Makefile.in])

AC_OUTPUT



