AC_INIT(bonobo/pybonobo.h)
AM_INIT_AUTOMAKE(bonobo-python, 0.2.0)
AM_CONFIG_HEADER(config.h)

AM_ACLOCAL_INCLUDE(macros)

AC_DISABLE_STATIC
AC_PROG_LIBTOOL

AM_PATH_PYTHON(1.5)
AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])

dnl PY_INIT(Makefile, Setup)
PY_CHECK_MOD(gtk, GtkObject,,[AC_MSG_ERROR([Can't find pygtk])])
PY_CHECK_MOD(gnome.config, sync,,[AC_MSG_ERROR([Can't find pygnome])])

dnl ORBit-python
AC_MSG_CHECKING(for ORBit-python >= 0.3.0)
vers=`orbit-python-config --version | sed -e "s/ORBit-python //" | \
     awk 'BEGIN { FS = "."; } { printf "%d", $1 * 1000 + $2;}'`
if test "$vers" -ge 3; then
    AC_MSG_RESULT(yes)
else
    AC_MSG_ERROR(ORBit-python 0.3.0 or newer is required to compile bonobo-python, Check out: http://orbit-python.sault.org/)
fi

AM_PATH_GLIB(1.2.6)
AM_PATH_GTK(1.2.6)

dnl GNOME_INIT

dnl ******************************
dnl ORBit checking
dnl ******************************
AM_PATH_ORBIT(0.5.8,,AC_MSG_ERROR([ORBit 0.5.8+ not installed or installation problem]))

IDL_FLAGS=`gnome-config --cflags idl`
AC_SUBST(IDL_FLAGS)

dnl ***
dnl OAF
dnl ***
AM_PATH_OAF(0.6.4)

dnl ******
dnl Bonobo
dnl ******
AC_MSG_CHECKING(for Bonobo >= 1.0.0)
if gnome-config --libs bonobox > /dev/null 2>&1; then
    vers=`gnome-config --modversion bonobo | sed -e "s/bonobo-//" | \
        awk 'BEGIN { FS = "."; } { printf "%d", $1 * 1000 + $2;}'`
    if test "$vers" -ge 1000; then
        bonobo_ok=true
	else
	    bonobo_ok=false
    fi
else
    bonobo_ok=false
fi
if $bonobo_ok; then
    AC_MSG_RESULT($vers found)
else
    AC_MSG_ERROR(Bonobo 1.0.0 or newer is required to compile bonobo-python)
fi

dnl ********
dnl Nautilus
dnl ********
AC_MSG_CHECKING(for Nautilus >= 1.0.0)
if gnome-config --libs nautilus > /dev/null 2>&1; then
    vers=`gnome-config --modversion nautilus | sed -e "s/nautilus-//" | \
        awk 'BEGIN { FS = "."; } { printf "%d", $1 * 1000 + $2;}'`
    if test "$vers" -ge 1000; then
        nautilus_ok=true
	else
	    nautilus_ok=false
    fi
else
    nautilus_ok=false
fi

if $nautilus_ok; then
    AC_MSG_RESULT($vers found)
else
	AC_MSG_RESULT(not found)
fi
AM_CONDITIONAL(BUILD_NAUTILUS, $nautilus_ok)

BONOBO_LIBS="`gnome-config --libs bonobo`"
BONOBO_CFLAGS="`gnome-config --cflags bonobo`"
BONOBOX_LIBS="`gnome-config --libs bonobox`"
BONOBOX_CFLAGS="`gnome-config --cflags bonobox`"
BONOBOX_PRINT_LIBS="`gnome-config --libs bonobox_print`"
BONOBOX_PRINT_CFLAGS="`gnome-config --cflags bonobox_print`"
ORBIT_CFLAGS="`orbit-config --cflags client server`"

if $nautilus_ok; then
   NAUTILUS_LIBS="`gnome-config --libs nautilus`"
   NAUTILUS_CFLAGS="`gnome-config --cflags nautilus`"
   AC_SUBST(NAUTILUS_LIBS)
   AC_SUBST(NAUTILUS_CFLAGS)
fi

AC_SUBST(BONOBO_LIBS)
AC_SUBST(BONOBO_CFLAGS)
AC_SUBST(BONOBOX_LIBS)
AC_SUBST(BONOBOX_CFLAGS)
AC_SUBST(BONOBOX_PRINT_LIBS)
AC_SUBST(BONOBOX_PRINT_CFLAGS)
AC_SUBST(ORBIT_CFLAGS)

AC_OUTPUT(Makefile macros/Makefile bonobo/Makefile nautilus/Makefile oaf/Makefile)
