AC_PREREQ(2.54)

# Making releases:
#   libgnome_micro_version += 1;
#   libgnome_interface_age += 1;
# if any functions have been added, set libgnome_interface_age to 0.
# if backwards compatibility has been broken,
# set LIBGNOME_BINARY_AGE and LIBGNOME_INTERFACE_AGE to 0.
#
m4_define([libgnome_major_version], [2])
m4_define([libgnome_minor_version], [8])
m4_define([libgnome_micro_version], [1])
m4_define([libgnome_interface_age], [1])
# If you need a modifier for the version number. 
# Normally empty, but can be used to make "fixup" releases.
m4_define([libgnome_extraversion], [])

dnl required versions of other tools.
m4_define([audiofile_required_version], [0.2.3])
m4_define([esound_required_version],    [0.2.26])
m4_define([gconf_required_version],     [1.1.11])
m4_define([glib_required_version],      [2.0.3])
m4_define([gnome_vfs_required_version], [2.5.3])
m4_define([libbonobo_required_version], [2.0.0])


dnl libtool versioning from libgnome
m4_define([libgnome_current], [m4_eval(100 * libgnome_minor_version + libgnome_micro_version - libgnome_interface_age)])
m4_define([libgnome_binary_age], [m4_eval(100 * libgnome_minor_version + libgnome_micro_version)])
m4_define([libgnome_revision], [libgnome_interface_age])
m4_define([libgnome_age], [m4_eval(libgnome_binary_age - libgnome_interface_age)])
m4_define([libgnome_version], [libgnome_major_version().libgnome_minor_version().libgnome_micro_version()libgnome_extraversion()])

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

LIBGNOME_MAJOR_VERSION=libgnome_major_version
LIBGNOME_MINOR_VERSION=libgnome_minor_version
LIBGNOME_MICRO_VERSION=libgnome_micro_version
LIBGNOME_INTERFACE_AGE=libgnome_interface_age

LIBGNOME_CURRENT=libgnome_current
LIBGNOME_REVISION=libgnome_revision
LIBGNOME_AGE=libgnome_age

AC_SUBST(LIBGNOME_CURRENT)
AC_SUBST(LIBGNOME_REVISION)
AC_SUBST(LIBGNOME_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)

dnl
dnl Due to the sed scripts being split on 90 line
dnl blocks, this macro needs to be right at the beginning.
dnl
AC_PROG_INTLTOOL([0.21])

AC_ISC_POSIX
AC_PROG_CC
AC_STDC_HEADERS
AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL

AC_CHECK_FUNCS([setenv unsetenv clearenv setfsgid])
AC_CHECK_HEADERS(sys/fsuid.h)
AC_CHECK_FUNCS(bind_textdomain_codeset)

GETTEXT_PACKAGE=libgnome-2.0
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [The gettext package])

ALL_LINGUAS="am ar az be bg bn 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 ko 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 th tr uk vi wa yi zh_CN zh_TW"
AM_GLIB_GNU_GETTEXT
AM_GLIB_DEFINE_LOCALEDIR([LIBGNOME_LOCALEDIR])

GNOME_COMPILE_WARNINGS

dnl Define GNOME_ENABLE_DEBUG if the --enable-debug switch was given.
GNOME_DEBUG_CHECK

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)

# 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)

dnl
dnl Start of pkg-config checks
dnl
dnl We first check for esound and audiofile (which has conditional
dnl support built in)
dnl

SOUND_MODULES="esound >= esound_required_version dnl
 audiofile >= audiofile_required_version"
PKG_CHECK_MODULES(SOUND_TEST, [$SOUND_MODULES],
[
  AC_DEFINE(HAVE_LIBAUDIOFILE,, [Compile with audiofile support])
  AC_DEFINE(HAVE_ESD,, [Compile with esd support])
],[
  SOUND_MODULES=""
])

PKG_CHECK_MODULES(LIBGNOME, dnl
 [glib-2.0 >= glib_required_version dnl
  gmodule-2.0 >= glib_required_version dnl
  gobject-2.0 >= glib_required_version dnl
  gnome-vfs-2.0 >= gnome_vfs_required_version dnl
  libbonobo-2.0 >= libbonobo_required_version dnl
  gconf-2.0 >= gconf_required_version dnl
  $SOUND_MODULES])

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

dnl Specify the gconf configuration source, 
dnl default to xml::$(sysconfdir)/gconf/gconf.xml.defaults

dnl ==============================================
dnl Special GConf section 
dnl ==============================================

AC_PATH_PROG(GCONFTOOL, gconftool-2, no)

if test x"$GCONFTOOL" = xno; then
  AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
fi

AM_GCONF_SOURCE_2

dnl
dnl Substitute these
dnl
GNOME_VFS_VERSION=`$PKG_CONFIG --modversion gnome-vfs-2.0`
AC_SUBST(GNOME_VFS_VERSION)

AC_CHECK_LIB(popt, poptStrippedArgv,, AC_MSG_ERROR([popt 1.5 or newer is required to build
libgnome. You can download the latest version from ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/]))

AC_CONFIG_FILES([
Makefile
po/Makefile.in
libgnome/Makefile
monikers/Makefile
schemas/Makefile
gnome-data/Makefile
libgnome/libgnome-2.0.pc
libgnome/libgnome-2.0-uninstalled.pc
doc/Makefile
doc/reference/Makefile
doc/reference/version.xml
])

AC_OUTPUT
