AC_INIT(README)
AC_CANONICAL_SYSTEM
AC_PROG_LIBTOOL
AM_INIT_AUTOMAKE(gsf-sharp, 0.8)
AM_MAINTAINER_MODE

dnl Defines CC to avoid warnings
AC_PROG_INSTALL

AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "x$PKG_CONFIG" = "xno"; then
	AC_MSG_ERROR(['pkg-config' is not in your PATH.])
fi

PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= 1.0, has_mono=true, has_mono=false)

if test `uname -s` = "Darwin"; then
	AC_PATH_PROG(RUNTIME, mono, no)
	AC_PATH_PROG(CSC, mcs, no)
	LIB_PREFIX=
	LIB_SUFFIX=.dylib
else
	AC_PATH_PROG(RUNTIME, mono, no)
	AC_PATH_PROG(CSC, mcs, no)
	LIB_PREFIX=.so
	LIB_SUFFIX=
fi

CS="C#"
if test "x$CSC" = "xno" ; then
    AC_MSG_ERROR([No $CS compiler found])
fi

AC_PATH_PROG(GACUTIL, gacutil, no)
if test "x$GACUTIL" = "xno" ; then
	AC_MSG_ERROR([No gacutil tool found])
fi

GACUTIL_FLAGS='/package gtk-sharp /gacdir $(prefix)/lib /root $(DESTDIR)$(prefix)/lib'
                                     
AC_SUBST(RUNTIME)
AC_SUBST(CSC)
AC_SUBST(GACUTIL)
AC_SUBST(GACUTIL_FLAGS)
AC_SUBST(LIB_PREFIX)
AC_SUBST(LIB_SUFFIX)

PKG_CHECK_MODULES(GTK_SHARP, gtk-sharp-2.0 >= 2.3.90)
AC_SUBST(GTK_SHARP_CFLAGS)
AC_SUBST(GTK_SHARP_LIBS)

PKG_CHECK_MODULES(GSF, libgsf-1 >= 1.14 libgsf-1 < 1.15)
AC_SUBST(GSF_CFLAGS)
AC_SUBST(GSF_LIBS)
gsf_prefix=`pkg-config --variable=prefix libgsf-1`
AC_SUBST(gsf_prefix)

dnl Remember to update this when it changes!
GSF_SO_VERSION=114
AC_SUBST(GSF_SO_VERSION)

AC_PATH_PROG(GAPI_FIXUP, gapi2-fixup, no)
AC_SUBST(GAPI_FIXUP)

AC_PATH_PROG(GAPI_CODEGEN, gapi2-codegen, no)
AC_SUBST(GAPI_CODEGEN)

MONODOC_REQUIRED_VERSION=1.0
PKG_CHECK_MODULES(MONODOC_DEPENDENCY, monodoc >= $MONODOC_REQUIRED_VERSION, enable_monodoc=yes, enable_monodoc=no)
                                                                                
if test "x$enable_monodoc" = "xyes"; then 
    AC_PATH_PROG(MONODOC, monodoc, no)
    if test "x$MONODOC" = "xno"; then
       enable_monodoc=no
    fi
else
    MONODOC=
fi
AC_SUBST(MONODOC)

API_VERSION="0.0.0.7"
AC_SUBST(API_VERSION)

AM_CONDITIONAL(ENABLE_MONODOC, test "x$enable_monodoc" = "xyes")

AC_OUTPUT([
makefile
gsf/AssemblyInfo.cs
gsf/gsf-sharp.dll.config
gsf/makefile
gsf-sharp.pc
glue/Makefile
])
