dnl Process this file with autoconf to produce a configure script.

AC_INIT(ChangeLog)

AM_CONFIG_HEADER(config.h)

GAIL_GNOME_MAJOR_VERSION=1
GAIL_GNOME_MINOR_VERSION=1
GAIL_GNOME_MICRO_VERSION=0
GAIL_GNOME_INTERFACE_AGE=0
GAIL_GNOME_BINARY_AGE=0
GAIL_GNOME_VERSION=$GAIL_GNOME_MAJOR_VERSION.$GAIL_GNOME_MINOR_VERSION.$GAIL_GNOME_MICRO_VERSION
AM_INIT_AUTOMAKE(libgail-gnome, $GAIL_GNOME_VERSION)

AC_SUBST(GAIL_GNOME_MAJOR_VERSION)
AC_SUBST(GAIL_GNOME_MINOR_VERSION)
AC_SUBST(GAIL_GNOME_MICRO_VERSION)
AC_SUBST(GAIL_GNOME_VERSION)

# libtool versioning
LT_RELEASE=$GAIL_GNOME_MAJOR_VERSION.$GAIL_GNOME_MINOR_VERSION
LT_CURRENT=`expr $GAIL_GNOME_MICRO_VERSION - $GAIL_GNOME_INTERFACE_AGE`
LT_REVISION=$GAIL_GNOME_INTERFACE_AGE
LT_AGE=`expr $GAIL_GNOME_BINARY_AGE - $GAIL_GNOME_INTERFACE_AGE`
LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE`
AC_SUBST(LT_RELEASE)
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)
AC_SUBST(LT_CURRENT_MINUS_AGE)


AC_PROG_CC
AM_DISABLE_STATIC
AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL

AC_MSG_CHECKING([for Win32])
case "$host" in
  *-*-mingw*)
    gail_native_win32=yes
    ;;
  *)
    gail_native_win32=no
    ;;
esac
AC_MSG_RESULT([$gail_native_win32])
AM_CONDITIONAL(OS_WIN32, test "$gail_native_win32" = "yes")

if test "$gail_native_win32" = "yes"; then
  AC_CHECK_PROG(ms_librarian, lib.exe, yes, no)
fi
AM_CONDITIONAL(MS_LIB_AVAILABLE, test x$ms_librarian = xyes)

dnl Cache $ACLOCAL_FLAGS
AC_CACHE_CHECK([for aclocal flags], ac_cv_atk_aclocal_flags,[
   ac_cv_atk_aclocal_flags="$ACLOCAL_FLAGS"
])
ACLOCAL="$ACLOCAL $ac_cv_atk_aclocal_flags"

AC_ARG_ENABLE(rebuilds, [  --disable-rebuilds	   disable all source autogeneration rules],,enable_rebuilds=yes)

AC_ARG_ENABLE(debug, [  --enable-debug=[no/yes] turn on debugging [default=no]],,enable_debug=no)
if test "$enable_debug" = "yes"; then
  GAIL_GNOME_DEBUG_CFLAGS="-DG_ENABLE_DEBUG"
else
  GAIL_GNOME_DEBUG_CFLAGS=""
fi
AC_SUBST(GAIL_GNOME_DEBUG_CFLAGS)

changequote(,)dnl
if test "x$GCC" = "xyes"; then
  case " $CFLAGS " in
  *[\ \ ]-Wall[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wall" ;;
  esac
fi
changequote([,])dnl

ATK_PACKAGES="atk"
GTK_PACKAGES="gtk+-2.0"
LIBBONOBO_PACKAGES="libbonobo-2.0"
LIBBONOBOUI_PACKAGES="libbonoboui-2.0"
LIBGNOMEUI_PACKAGES="libgnomeui-2.0"
PANEL_APPLET_PACKAGES="libpanelapplet-2.0"
AT_SPI_PACKAGES="libspi-1.0"
CSPI_PACKAGES="cspi-1.0"
ATK_REQUIRED_VERSION=1.7.2
GTK_REQUIRED_VERSION=1.3.11
LIBBONOBO_REQUIRED_VERSION=1.1.0
LIBBONOBOUI_REQUIRED_VERSION=1.1.0
LIBGNOMEUI_REQUIRED_VERSION=1.1.0
PANEL_APPLET_REQUIRED_VERSION=0.0.18
AT_SPI_REQUIRED_VERSION=0.10.0
CSPI_REQUIRED_VERSION=0.10.0

PKG_CHECK_MODULES(DEPS, $ATK_PACKAGES >= $ATK_REQUIRED_VERSION $GTK_PACKAGES >= $GTK_REQUIRED_VERSION $LIBBONOBO_PACKAGES >= $LIBBONOBO_REQUIRED_VERSION $LIBBONOBOUI_PACKAGES >= $LIBBONOBO_REQUIRED_VERSION $LIBGNOMEUI_PACKAGES >= $LIBGNOMEUI_REQUIRED_VERSION $AT_SPI_PACKAGES >= $AT_SPI_REQUIRED_VERSION $PANEL_APPLET_PACKAGES >= $PANEL_APPLET_REQUIRED_VERSION)

PKG_CHECK_MODULES(TEST, $ATK_PACKAGES >= $ATK_REQUIRED_VERSION $GTK_PACKAGES >= $GTK_REQUIRED_VERSION $LIBBONOBO_PACKAGES >= $LIBBONOBO_REQUIRED_VERSION $LIBBONOBOUI_PACKAGES >= $LIBBONOBO_REQUIRED_VERSION $LIBGNOMEUI_PACKAGES >= $LIBGNOMEUI_REQUIRED_VERSION $AT_SPI_PACKAGES >= $AT_SPI_REQUIRED_VERSION $CSPI_PACKAGES >= $CSPI_REQUIRED_VERSION $PANEL_APPLET_PACKAGES >= $PANEL_APPLET_REQUIRED_VERSION)

AC_SUBST(DEPS_CFLAGS)
AC_SUBST(DEPS_LIBS)
AC_SUBST(TEST_CFLAGS)
AC_SUBST(TEST_LIBS)

old_LIBS="$LIBS"
dnl Checks for inet libraries:
AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent))
AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
AC_CHECK_FUNC(connect, , AC_CHECK_LIB(inet, connect))

INET_LIBS="$LIBS"
AC_SUBST(INET_LIBS)

LIBS="$old_LIBS"

AC_OUTPUT([
Makefile
libgail-gnome.pc
gail-gnome/Makefile
test/Makefile
])
