AC_INIT(libgnome)

AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(libgnome-2, 1.96.0)

AM_MAINTAINER_MODE

if test -z "$CERTIFIED_GNOMIE"; then
  cat $srcdir/message-of-doom
  exit 1
fi

GNOME_COMMON_INIT
GNOME_PLATFORM_GNOME_2(yes, force)

if test -e .using-gnome-libs-package ; then
  USING_GNOME_LIBS_PACKAGE=true
else
  USING_GNOME_LIBS_PACKAGE=false
fi
AM_CONDITIONAL(USING_GNOME_LIBS_PACKAGE, test x$USING_GNOME_LIBS_PACKAGE = xtrue)

AC_ISC_POSIX
AC_PROG_CC
AC_STDC_HEADERS
AC_ARG_PROGRAM
AM_PROG_LIBTOOL
AM_PROG_LEX
AC_PROG_YACC
AC_PATH_PROGS(PATH_TO_XRDB, "xrdb")

dnl utility conditional
AM_CONDITIONAL(FALSE, test "x" = "y")

ALL_LINGUAS=""
AM_GNOME2_GETTEXT
gnomelocaledir='${prefix}/${DATADIRNAME}/locale'
AC_SUBST(gnomelocaledir)

AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)

GNOME_COMPILE_WARNINGS(maximum)

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

AC_ARG_ENABLE(prefer-db1, [  --enable-prefer-db1     Prefer Berkeley DB 1.x],[prefer_db1="$enableval"],[prefer_db1=yes])
dnl
dnl Check for db stuff (gnome-metadata)
dnl
DB_LIB=
AC_CHECK_FUNC(dbopen, [],
if test "$prefer_db1" = "yes"; then
 AC_CHECK_LIB(db1, dbopen, DB_LIB="-ldb1",
  AC_CHECK_LIB(db, dbopen, DB_LIB="-ldb",
   AC_CHECK_LIB(db-3, __db185_open, DB_LIB="-ldb-3",
    AC_MSG_ERROR([Your db library is missing db 1.85 compatibility mode])
   )
  )
 )
else
 AC_CHECK_LIB(db, dbopen, DB_LIB="-ldb",
  AC_CHECK_LIB(db1, dbopen, DB_LIB="-ldb1",
   AC_CHECK_LIB(db-3, __db185_open, DB_LIB="-ldb-3",
    AC_MSG_ERROR([Your db library is missing db 1.85 compatibility mode])
   )
  )
 )
fi
)

dnl look for db headers
if test "$prefer_db1" = "yes"; then
	AC_CHECK_HEADERS(db_185.h db1/db.h)
	if test "$ac_cv_header_db_185_h$ac_cv_header_db1_db_h" = nono; then
	  AC_MSG_ERROR([Berkeley db library required for Gnome])
	fi
	AC_DEFINE(PREFER_DB1)
else
	AC_CHECK_HEADERS(db.h db_185.h db1/db.h)

	if test "$ac_cv_header_db_h$ac_cv_header_db_185_h$ac_cv_header_db1_db_h" = nonono; then
	  AC_MSG_ERROR([Berkeley db library required for Gnome])
	fi
fi

dnl
dnl Start of pkg-config checks
dnl
GNOME_PKGCONFIG_CHECK_MODULES(ORBIT, ORBit-2.0:2.5.7)
AC_PATH_PROG(ORBIT_IDL, orbit-idl, no)
AC_SUBST(ORBIT_CFLAGS)
AC_SUBST(ORBIT_LIBS)

GNOME_PKGCONFIG_CHECK_MODULES(GNOMESUPPORT, gnome-support-2.0:1.2.1)
AC_SUBST(GNOMESUPPORT_CFLAGS)
AC_SUBST(GNOMESUPPORT_LIBS)

GNOME_PKGCONFIG_CHECK_MODULES(GLIB, glib-2.0:1.3.1)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)

GNOME_PKGCONFIG_CHECK_MODULES(GNOME_VFS, gnomevfs-2.0)
GNOME_VFS_VERSION=`$PKG_CONFIG --modversion gnomevfs-2.0`
AC_SUBST(GNOME_VFS_VERSION)
AC_SUBST(GNOME_VFS_CFLAGS)
AC_SUBST(GNOME_VFS_LIBS)

GNOME_PKGCONFIG_CHECK_MODULES(OAF, oaf-2.0)
AC_SUBST(OAF_CFLAGS)
AC_SUBST(OAF_LIBS)

GNOME_PKGCONFIG_CHECK_MODULES(GCONF, gconfgtk-2.0)
AC_SUBST(GCONF_CFLAGS)
AC_SUBST(GCONF_LIBS)

GNOME_PKGCONFIG_CHECK_MODULES(LIBXML, libxml-2.0:2.3.1)
AC_SUBST(LIBXML_CFLAGS)
AC_SUBST(LIBXML_LIBS)

AC_CHECK_LIB(popt, poptStrippedArgv,, AC_MSG_ERROR([popt 1.5 or newer is required to build
gnome-libs. You can download the latest version from ftp://people.redhat.com/sopwith/popt/]))

dnl This is installed from GTK+ 2.0's gdk-pixbuf
AC_PATH_PROG(MAKE_INLINE_PIXBUF, make-inline-pixbuf)
test -z "$MAKE_INLINE_PIXBUF" && AC_MSG_ERROR([
*** You need the make-inline-pixbuf tool which is installed
*** from GTK+ 2.0's gdk-pixbuf.
***
*** Either the location where you installed your GTK+ 2.0 is
*** not in your PATH or something is screwed up with your
*** GTK+ 2.0 installation
])

AC_OUTPUT([
Makefile
po/Makefile.in
intl/Makefile
libgnome/Makefile
libgnome/gnome-portability.h
libgnome/libgnome-2.0.pc
])

cat $srcdir/message-of-doom
