AC_INIT(eel)

dnl ===========================================================================

ART_REQUIRED=2.3.8
GCONF_REQUIRED=1.1.11
GDK_PIXBUF_REQUIRED=2
GLIB_REQUIRED=2
GNOME_REQUIRED=2.0
GNOME_UI_REQUIRED=2.7.92
GNOME_VFS_REQUIRED=2.7.91
GTK_REQUIRED=2.3.0
POPT_REQUIRED=1.5
XML_REQUIRED=2.4.7
GAIL_REQUIRED=0.16
LIBGLADE_REQUIRED=2.0.0

AC_SUBST(ART_REQUIRED)
AC_SUBST(GCONF_REQUIRED)
AC_SUBST(GDK_PIXBUF_REQUIRED)
AC_SUBST(GLIB_REQUIRED)
AC_SUBST(GNOME_REQUIRED)
AC_SUBST(GNOME_UI_REQUIRED)
AC_SUBST(GNOME_VFS_REQUIRED)
AC_SUBST(GTK_REQUIRED)
AC_SUBST(POPT_REQUIRED)
AC_SUBST(XML_REQUIRED)
AC_SUBST(GAIL_REQUIRED)
AC_SUBST(LIBGLADE_REQUIRED)

dnl ===========================================================================

EEL_MAJOR_VERSION=2
EEL_MINOR_VERSION=8
EEL_MICRO_VERSION=2
# If you need a modifier for the version number. 
# Normally empty, but can be used to make "fixup" releases.
LIBGNOMEVFS_EXTRAVERSION=
	
EEL_VERSION=$EEL_MAJOR_VERSION.$EEL_MINOR_VERSION.$EEL_MICRO_VERSION$LIBGNOMEVFS_EXTRAVERSION
EEL_VERSION_INFO=`expr $EEL_MAJOR_VERSION + $EEL_MINOR_VERSION`:$EEL_MICRO_VERSION:$EEL_MINOR_VERSION

AC_SUBST(EEL_MAJOR_VERSION)
AC_SUBST(EEL_MINOR_VERSION)
AC_SUBST(EEL_MICRO_VERSION)
AC_SUBST(EEL_VERSION)
AC_SUBST(EEL_VERSION_INFO)

VERSION=$EEL_VERSION

AM_INIT_AUTOMAKE(eel, $VERSION)
AM_CONFIG_HEADER(config.h)

AM_MAINTAINER_MODE

AC_ISC_POSIX
AC_PROG_CC
AC_PROG_CPP
AC_PROG_AWK
AM_DISABLE_STATIC
AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL
AC_STDC_HEADERS
AM_SANITY_CHECK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_C_CONST
AC_C_BIGENDIAN

PKG_CHECK_MODULES(EEL, [
	gail			>= $GAIL_REQUIRED
	gconf-2.0		>= $GCONF_REQUIRED
	gdk-pixbuf-2.0		>= $GDK_PIXBUF_REQUIRED
	glib-2.0		>= $GLIB_REQUIRED
	gnome-vfs-2.0		>= $GNOME_VFS_REQUIRED
	gnome-vfs-module-2.0	>= $GNOME_VFS_REQUIRED
	gthread-2.0		>= $GLIB_REQUIRED
	gtk+-2.0		>= $GTK_REQUIRED
	libart-2.0		>= $ART_REQUIRED
	libglade-2.0		>= $LIBGLADE_REQUIRED
	libgnome-2.0		>= $GNOME_REQUIRED
	libgnomeui-2.0		>= $GNOME_UI_REQUIRED
	libxml-2.0		>= $XML_REQUIRED
])
AC_SUBST(EEL_CFLAGS)
AC_SUBST(EEL_LIBS)

dnl ===========================================================================

dnl strftime checks

AC_TRY_RUN([#include <time.h>
                int main ()
                {
                  char buf[100];
                  struct tm tm = {0};
                  tm.tm_year = 99;
                  if (strftime(buf, 100, "%EY", &tm) == 4 &&
		      strcmp (buf, "1999")==0)
                    return 0;
                  return 1;
                }
            ],
	    AC_DEFINE(HAVE_STRFTIME_EXTENSION, 1, [Define if strftime supports %E and %O modifiers.])
            )

dnl ===========================================================================

dnl X development libraries check

#
# If Pango included the shared library dependencies from X11 in
# the pkg-config output, then we use that (to avoid duplicates).
# but if they were omitted to avoid binary compatibility problems
# then we need to repeat the checks.
#
if $PKG_CONFIG --exists pangoxft ; then
  PANGO_PACKAGES="pangox pangoxft"
else
  PANGO_PACKAGES="pangox"
fi

x_libs="`$PKG_CONFIG --libs $PANGO_PACKAGES`"
case x_libs in
  *-lX11*) pango_omitted_x_deps=no ;;
  *)       pango_omitted_x_deps=yes ;;
esac

if test $pango_omitted_x_deps = yes ; then
  AC_PATH_XTRA

  if test x$no_x = xyes ; then
    AC_MSG_ERROR([X development libraries not found])
  else
    X_LIBS="$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
  fi
fi

AC_SUBST(X_LIBS)

dnl ===========================================================================

ALL_LINGUAS="am ang ar az be bg bn br bs ca cs cy da de el en_CA en_GB es et eu fa fi fr ga gl gu he hi hr hu id is it ja kn ko li lt lv mk ml mn mr ms nb ne nl nn no or pa pl pt pt_BR ro ru sk sl sq sr sr@Latn sv ta th tr uk vi wa zh_CN zh_TW"

GETTEXT_PACKAGE=eel-2.0
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE")
AC_DEFINE_UNQUOTED(GNOME_EXPLICIT_TRANSLATION_DOMAIN, "$GETTEXT_PACKAGE")

AM_GLIB_GNU_GETTEXT

# AM_GNOME2_GETTEXT above substs $DATADIRNAME
# this is the directory where the *.{mo,gmo} files are installed
gnomelocaledir='${prefix}/${DATADIRNAME}/locale'
AC_SUBST(gnomelocaledir)

AC_CHECK_FUNCS(bind_textdomain_codeset)

dnl ===========================================================================

AC_PROG_AWK
AC_CHECK_PROGS(PERL, perl5 perl)
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)

dnl ===========================================================================

ENABLE_PROFILER=
AC_ARG_ENABLE(profiler,
[  --enable-profiler		Enable profiler],
ENABLE_PROFILER=1
AC_DEFINE(ENABLE_PROFILER))

if test "x$ENABLE_PROFILER" = "x1"
then
	CFLAGS="-g -O -gdwarf-2 -finstrument-functions -D__NO_STRING_INLINES"
	LDFLAGS="/gnome/PROFILE/lib/libprofiler.so -lpthread"
fi

AC_SUBST(ENABLE_PROFILER)
AM_CONDITIONAL(ENABLE_PROFILER, test "x$ENABLE_PROFILER" = "x1")

dnl ===========================================================================

AC_CHECK_LIB(popt, poptParseArgvString, [POPT_LIBS="-lpopt"])
AC_SUBST(POPT_LIBS)

dnl ===========================================================================

AC_CHECK_FUNCS(setenv unsetenv putenv)

dnl ===========================================================================


#
# Checks for Xft/XRender
#
have_render=false
RENDER_LIBS=""

AC_CHECK_LIB(Xrender, XRenderFindFormat, 
    have_render=true,:,-lXext $EEL_LIBS)

if $have_render ; then
   RENDER_LIBS="-lXrender -lXext"
   AC_DEFINE(HAVE_RENDER)
fi

AC_SUBST(RENDER_LIBS)


dnl ===========================================================================

dnl Turn on the additional warnings last, so -Werror doesn't affect other tests.

AC_ARG_ENABLE(more-warnings,
[  --enable-more-warnings  Maximum compiler warnings],
set_more_warnings="$enableval",[
if test -f $srcdir/CVSVERSION; then
	is_cvs_version=true
	set_more_warnings=yes
else
	set_more_warnings=no
fi
])
AC_MSG_CHECKING(for more warnings, including -Werror)
if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
	AC_MSG_RESULT(yes)
	CFLAGS="\
	-Wall \
	-Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \
	-Wnested-externs -Wpointer-arith \
	-Wsign-compare \
	-Werror \
	$CFLAGS"

	for option in -Wno-strict-aliasing -Wno-sign-compare; do
		SAVE_CFLAGS="$CFLAGS"
		CFLAGS="$CFLAGS $option"
		AC_MSG_CHECKING([whether gcc understands $option])
		AC_TRY_COMPILE([], [],
			has_option=yes,
			has_option=no,)
		if test $has_option = no; then
			CFLAGS="$SAVE_CFLAGS"
		fi
		AC_MSG_RESULT($has_option)
		unset has_option
		unset SAVE_CFLAGS
	done
	unset option
else
	AC_MSG_RESULT(no)
fi

dnl ===========================================================================

AC_OUTPUT([
Makefile
eel-2.0.pc
eel-2.0-uninstalled.pc
eel.spec
eel/Makefile
eel/eel-features.h
po/Makefile.in
test/Makefile
])
