AC_PREREQ(2.54)

# Making releases:
#   LIBGNOMECANVAS_MICRO_VERSION += 1;
#   LIBGNOMECANVAS_INTERFACE_AGE += 1;
# if any functions have been added, set LIBGNOMECANVAS_INTERFACE_AGE to 0.
# if backwards compatibility has been broken,
# set LIBGNOMECANVAS_BINARY_AGE and LIBGNOMECANVAS_INTERFACE_AGE to 0.
#
m4_define([libgnomecanvas_major_version], [2])
m4_define([libgnomecanvas_minor_version], [8])
m4_define([libgnomecanvas_micro_version], [0])
m4_define([libgnomecanvas_interface_age], [0])
# If you need a modifier for the version number. 
# Normally empty, but can be used to make "fixup" releases.
m4_define([libgnomecanvas_extraversion],  [])

dnl required versions of other programs
m4_define([gtk_required_version],      [2.0.3])
m4_define([libart_required_version],   [2.3.8])
m4_define([pango_required_version],    [1.0.1])
m4_define([libglade_required_version], [2.0.0])


dnl libtool versioning from libgnome

m4_define([libgnomecanvas_current], [m4_eval(100 * libgnomecanvas_minor_version + libgnomecanvas_micro_version - libgnomecanvas_interface_age)])
m4_define([libgnomecanvas_binary_age], [m4_eval(100 * libgnomecanvas_minor_version + libgnomecanvas_micro_version)])
m4_define([libgnomecanvas_revision], [libgnomecanvas_interface_age])
m4_define([libgnomecanvas_age], [m4_eval(libgnomecanvas_binary_age - libgnomecanvas_interface_age)])
m4_define([libgnomecanvas_version], [libgnomecanvas_major_version().libgnomecanvas_minor_version().libgnomecanvas_micro_version()libgnomecanvas_extraversion()])

AC_INIT([libgnomecanvas], [libgnomecanvas_version],
        [http://bugzilla.gnome.org/enter_bug.cgi?product=libgnomecanvas])
AC_CONFIG_SRCDIR([libgnomecanvas/libgnomecanvas.h])

LIBGNOMECANVAS_MAJOR_VERSION=libgnomecanvas_major_version
LIBGNOMECANVAS_MINOR_VERSION=libgnomecanvas_minor_version
LIBGNOMECANVAS_MICRO_VERSION=libgnomecanvas_micro_version
LIBGNOMECANVAS_INTERFACE_AGE=libgnomecanvas_interface_age

dnl libtool versioning from libgnome

LIBGNOMECANVAS_CURRENT=libgnomecanvas_current
LIBGNOMECANVAS_REVISION=libgnomecanvas_revision
LIBGNOMECANVAS_AGE=libgnomecanvas_age

AC_SUBST(LIBGNOMECANVAS_CURRENT)
AC_SUBST(LIBGNOMECANVAS_REVISION)
AC_SUBST(LIBGNOMECANVAS_AGE)

AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h)

AM_MAINTAINER_MODE

dnl make aclocal calls respect $ACLOCAL_FLAGS
ACLOCAL_AMFLAGS="\${ACLOCAL_FLAGS}"
AC_SUBST(ACLOCAL_AMFLAGS)

AC_ISC_POSIX
AC_PROG_CC
AC_STDC_HEADERS
AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL

GNOME_COMPILE_WARNINGS

GETTEXT_PACKAGE=libgnomecanvas-2.0
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[Gettext package])

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

dnl
dnl GTK+ check
dnl
CANVAS_MODULES="dnl
  gtk+-2.0 >= gtk_required_version dnl
  libart-2.0 >= libart_required_version dnl
  pango >= pango_required_version dnl
  pangoft2 >= pango_required_version"
PKG_CHECK_MODULES(LIBGNOMECANVAS, $CANVAS_MODULES)

PKG_CHECK_MODULES(CANVAS_GLADE, $CANVAS_MODULES libglade-2.0 >= libglade_required_version)

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

AC_MSG_CHECKING([for Win32 platform in general])
case "$host" in
  *-*-mingw*|*-*-cygwin*)
    platform_win32=yes
    ;;
  *)
    platform_win32=no
    ;;
esac
AC_MSG_RESULT($platform_win32)
AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = yes)

# Ensure MSVC-compatible struct packing convention is used when
# compiling for Win32 with gcc. GTK+ uses this convention, so we must, too.
# What flag to depends on gcc version: gcc3 uses "-mms-bitfields", while
# gcc2 uses "-fnative-struct".
if test x"$native_win32" = xyes; then
  if test x"$GCC" = xyes; then
    msnative_struct=''
    AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
    if test -z "$ac_cv_prog_CC"; then
      our_gcc="$CC"
    else
      our_gcc="$ac_cv_prog_CC"
    fi
    case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
      2.)
	if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
	  msnative_struct='-fnative-struct'
	fi
	;;
      *)
	if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
	  msnative_struct='-mms-bitfields'
	fi
	;;
    esac
    if test x"$msnative_struct" = x ; then
      AC_MSG_RESULT([no way])
      AC_MSG_WARN([produced libraries will be incompatible with prebuilt GTK+ DLLs])
    else
      CFLAGS="$CFLAGS $msnative_struct"
      AC_MSG_RESULT([${msnative_struct}])
    fi
  fi
fi

dnl Don't use AC_PROG_AWK since we need the full pathname.
AC_PATH_PROGS(AWK, mawk gawk nawk awk, )
AC_PATH_PROGS(PERL, perl5 perl)

# glib-genmarshal
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)

dnl
dnl Check for gtk-doc
dnl
GTK_DOC_CHECK([1.0])

# define a MAINT-like variable REBUILD which is set if Perl
# and awk are found, so autogenerated sources can be rebuilt
AC_ARG_ENABLE(rebuilds,
              AC_HELP_STRING([--disable-rebuilds],
                             [disable all source autogeneration rules]),,
              [enable_rebuilds=yes])
REBUILD=\#
if test "x$enable_rebuilds" = "xyes" && \
     test -n "$PERL" && \
     $PERL -e 'exit !($] >= 5.002)' > /dev/null 2>&1 && \
     test -n "$AWK" ; then
  REBUILD=
fi
AC_SUBST(REBUILD)

AC_CONFIG_FILES([
Makefile
po/Makefile.in
libgnomecanvas/Makefile
libgnomecanvas/libgnomecanvas-2.0.pc
libgnomecanvas/libgnomecanvas-2.0-uninstalled.pc
glade/Makefile
demos/Makefile
tests/Makefile
docs/Makefile
docs/reference/Makefile
])

AC_OUTPUT
