AC_PREREQ(2.52)
AC_INIT(acme, 2.0.2, http://bugzilla.gnome.org/enter_bug.cgi?product=acme)
AC_CONFIG_SRCDIR(src/acme.c)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AM_CONFIG_HEADER(config.h)

AC_DEFINE(PACKAGE, AC_PACKAGE_NAME, [package name])
AC_DEFINE(VERSION, AC_PACKAGE_VERSION, [package version])
AC_DEFINE(GETTEXT_PACKAGE, "AC_PACKAGE_NAME", [foo])
GETTEXT_PACKAGE=AC_PACKAGE_NAME
AC_SUBST(GETTEXT_PACKAGE)

AC_PROG_INTLTOOL([0.20])

GOB2_CHECK()

PKG_CHECK_MODULES(EXTRA_GNOME, libgnomeui-2.0 libglade-2.0 libwnck-1.0 >= 2.1.5)
AC_SUBST(EXTRA_GNOME_CFLAGS)
AC_SUBST(EXTRA_GNOME_LIBS)

AC_MSG_CHECKING(for l33tness)
if test "`uname -n`x" = "dozox" ; then
	AC_MSG_RESULT(l33t like h4d3zZ)
else
	AC_MSG_RESULT(l4m3)
fi

AC_PATH_PROG(GCONFTOOL, gconftool-2)
AM_GCONF_SOURCE_2

dnl
dnl Test for Audio interfaces and FB-Level compatibility
dnl
have_oss=no
AC_TRY_COMPILE([
	#ifdef __NetBSD__
	#include <soundcard.h>
	#else
	#include <sys/soundcard.h>
	#endif
	],[
	int arg = SNDCTL_DSP_SETFRAGMENT;
	],[
	have_oss=yes
])
AC_MSG_CHECKING(for OSS audio support)
AC_MSG_RESULT($have_oss)
AM_CONDITIONAL(HAVE_OSS, test x"$have_oss" = "xyes")

have_alsa=no
PKG_CHECK_MODULES(ALSA, alsa >= 0.9.0,
	have_alsa=yes,
	AC_MSG_RESULT(*** All of ALSA dependent parts will be disabled ***))
AM_CONDITIONAL(HAVE_ALSA, test x"$have_alsa" = "xyes")
AC_SUBST(ALSA_LIBS)
AC_SUBST(ALSA_CFLAGS)

have_fb=no
AC_TRY_COMPILE([
	#include <linux/fb.h>
	#include <linux/pmu.h>
	],[
	int arg = 0;
	],[
	have_fb=yes
])
AC_MSG_CHECKING(for Brightness control support)
AC_MSG_RESULT($have_fb)
AM_CONDITIONAL(HAVE_FB, test x"$have_fb" = "xyes")


dnl Multimedia keys
have_xfree=no
AC_TRY_COMPILE([
	#include <X11/XF86keysym.h>
	],[
	int arg = 0;
        ],[
        have_xfree=yes
])
AC_MSG_CHECKING(for X11 XFree86 headers)
AC_MSG_RESULT($have_xfree)
AM_CONDITIONAL(HAVE_XFREE, test x"$have_xfree" = "xyes")

have_xsun=no
AC_TRY_COMPILE([
	#include <X11/Sunkeysym.h>
	],[
	int arg = 0;
	],[
	have_xsun=yes
])
AC_MSG_CHECKING(for X11 Sun headers)
AC_MSG_RESULT($have_xsun)
AM_CONDITIONAL(HAVE_XSUN, test x"$have_xsun" = "xyes")

if test x"$have_xsun" = "xno" && test x"$have_xfree" = "xno" ; then
	AC_MSG_ERROR(Your system doesn't have any headers for multimedia buttons)
fi

dnl Add the languages which your application supports here.
ALL_LINGUAS="am bg ca cs da de el es fi fr he hu it ja ko lv mk mn ms nl no pl pt pt_BR ro ru sl sk sq sv uk vi zh_CN zh_TW"
AM_GLIB_GNU_GETTEXT

AC_OUTPUT([
Makefile
acme.spec
src/Makefile
po/Makefile.in
])

dnl Summary
echo
echo "Summary"
echo
echo "alsa          : "$have_alsa
echo "oss           : "$have_oss
echo "brightness    : "$have_fb
echo
