dnl Process this file with autoconf to produce a configure script.

AC_PREREQ(2.58)
AC_INIT([OpenSync File Plugin], 0.22, [], [libopensync-plugin-file])
AM_INIT_AUTOMAKE(foreign)
AC_CONFIG_SRCDIR(src/file_sync.c)
AM_CONFIG_HEADER(config.h)

export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/lib/pkgconfig:$prefix/lib/pkgconfig:/usr/local/lib/pkgconfig
pkg_modules="glib-2.0 opensync-1.0 libxml-2.0"
PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)

## Defaults ##
CRASH_TEST=no
STRESS_TEST=no
ERROR_TEST=no

AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AC_HEADER_STDC
AC_DISABLE_STATIC
AC_PROG_LIBTOOL

OPENSYNC_CONFIGDIR=$(pkg-config --variable=configdir opensync-1.0)
OPENSYNC_PLUGINDIR=$(pkg-config --variable=plugindir opensync-1.0)
OPENSYNC_FORMATSDIR=$(pkg-config --variable=formatsdir opensync-1.0)
OPENSYNC_HEADERDIR=$(pkg-config --variable=headerdir opensync-1.0)

AC_SUBST(OPENSYNC_CONFIGDIR)
AC_SUBST(OPENSYNC_PLUGINDIR)
AC_SUBST(OPENSYNC_FORMATSDIR)
AC_SUBST(OPENSYNC_HEADERDIR)

##AC_CHECK_HEADER(fam.h,HAVE_FAM=1,HAVE_FAM=0)
HAVE_FAM=0
AM_CONDITIONAL(ENABLE_FAM, test x$HAVE_FAM = x1)
AC_SUBST(HAVE_FAM)
FAM_LIBS=""
if test "x${HAVE_FAM}" = "x1"; then
	FAM_LIBS="-lfam"
	AC_DEFINE(HAVE_FAM,1,[Having FAM])
fi
AC_SUBST(FAM_LIBS)

AC_OUTPUT([
Makefile
src/Makefile
tests/Makefile
])

echo "================================"
if test "x${HAVE_FAM}" = "x1"; then
	echo "FAM available."
else
	echo "FAM not available."
	echo "No sync alerts are supported."
	echo "To enable sync alerts you must"
	echo "have libfam-dev installed."
fi
echo ""
echo "Plugin will be installed in ${OPENSYNC_PLUGINDIR}"
echo "Default config will be installed in ${OPENSYNC_CONFIGDIR}"
echo "Format will be installed in ${OPENSYNC_FORMATSDIR}"
echo "================================"
