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

AC_INIT(ChangeLog)

AM_CONFIG_HEADER(config.h)


AM_INIT_AUTOMAKE(gail, 1.8.2)

# libtool versioning
LT_CURRENT=17
LT_REVISION=1
LT_AGE=0
LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE`
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)
AC_SUBST(LT_CURRENT_MINUS_AGE)

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

GETTEXT_PACKAGE=gail
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, ["$GETTEXT_PACKAGE"],
  [Define the gettext package to be used])

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_WITH(html-dir, [	 --with-html-dir=PATH	 path to installed docs ])

if test "x$with_html_dir" = "x" ; then
  HTML_DIR='${datadir}/gtk-doc/html'
else
  HTML_DIR=$with_html_dir
fi

AC_SUBST(HTML_DIR)

GTK_DOC_CHECK([1.0])

dnl NOTE: We need to use a separate automake conditional for this
dnl	  to make this work with the tarballs.
AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)

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"
LIBGNOMECANVAS_PACKAGES="libgnomecanvas-2.0"
ATK_REQUIRED_VERSION=1.7.0
GTK_REQUIRED_VERSION=2.3.5
LIBGNOMECANVAS_REQUIRED_VERSION=2.0.0

PKG_CHECK_MODULES(DEPS, $ATK_PACKAGES >= $ATK_REQUIRED_VERSION \
	$GTK_PACKAGES >= $GTK_REQUIRED_VERSION \
	$LIBGNOMECANVAS_PACKAGES >= $LIBGNOMECANVAS_REQUIRED_VERSION)

ALL_LINGUAS="ar az be bg bn bs ca cs cy da de el en_CA en_GB es et fa fi fr ga gl gu hi hr hu id is it ja ko lt mi mn ms nb ne nl nn no or pa pl pt pt_BR ro ru sq sr sr@Latn sv ta th tk tr uk zh_CN zh_TW"
AM_GLIB_GNU_GETTEXT

AM_GLIB_DEFINE_LOCALEDIR(GAIL_LOCALEDIR)

AC_CHECK_FUNCS(bind_textdomain_codeset)

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

dnl check for the sockaddr_un.sun_len member
AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
		[struct_sockaddr_un_sun_len=true],
		[struct_sockaddr_un_sun_len=false],
		[#include <sys/types.h>
		 #include <sys/un.h>]
		)
case $struct_sockaddr_un_sun_len in 
	true)
		AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_UN_SUN_LEN, 1, Have the sockaddr_un.sun_len member.)
		;;
	*)
		;;
esac

INET_LIBS="$LIBS"
AC_SUBST(INET_LIBS)

LIBS="$old_LIBS"

DEP_CFLAGS=`$PKG_CONFIG --cflags $ATK_PACKAGES $GTK_PACKAGES $LIBGNOMECANVAS_PACKAGES`
DEP_LIBS=`$PKG_CONFIG --libs $ATK_PACKAGES $GTK_PACKAGES $LIBGNOMECANVAS_PACKAGES`

AC_SUBST(DEP_CFLAGS)
AC_SUBST(DEP_LIBS)

AC_CONFIG_FILES([
Makefile
po/Makefile.in
gail.pc
gail-uninstalled.pc
libgail-util/Makefile
gail/Makefile
tests/Makefile
docs/Makefile
docs/reference/Makefile
docs/reference/libgail-util/Makefile
])

AC_OUTPUT
