dnl -*- mode: Autoconf; -*-
dnl Invoke autogen.sh to produce a configure script.

dnl Checks for required libraries.
dnl
dnl This is from the sqlite backend:
dnl PKG_CHECK_MODULES(SQLITE, sqlite3, SQLITEFOUND=yes, [SQLITEFOUND=no])
dnl AC_SUBST(SQLITE_CFLAGS)
dnl AC_SUBST(SQLITE_LIBS)

dnl No pkg-config available for xmlrpc-c
dnl PKG_CHECK_MODULES(XMLRPC,xmlrpc-c,XMLRPCFOUND=yes, [XMLRPCFOUND=no])

dnl name of backend library (there could be more than one per directory),
dnl name of the directory,
dnl help string,
dnl --enable/disable chosen explicitly
dnl default, may depend on availability of prerequisites in more complex backends
SE_ARG_ENABLE_BACKEND(xmlrpc,
                      xmlrpc,
                      [AS_HELP_STRING([--enable-xmlrpc],
                                      [enable XMLRPC-based backend which stores items on a central web service (default off)])],
                      [enable_xmlrpc="$enableval"],
                      [enable_xmlrpc="no"]
                     )

if test "$enable_xmlrpc" = "yes"; then
        dnl It's good to check the prerequisites here, in case --enable-xmlrpc was used.
        dnl test "x${SQLITEFOUND}" = "xyes" || AC_MSG_ERROR([--enable-sqlite requires pkg-config information for sqlite3, which was not found])

        AC_PATH_PROG([XMLRPC_C_CONFIG], [xmlrpc-c-config], [no])

        test "x$XMLRPC_C_CONFIG" != 'xno' || AC_MSG_ERROR([--enable-xmlrpc requires xmlrpc-c-config, which was not found])

        XMLRPC_CFLAGS=`$XMLRPC_C_CONFIG c++2 client --cflags`
        XMLRPC_LIBS=`$XMLRPC_C_CONFIG c++2 client --libs`
        AC_SUBST(XMLRPC_CFLAGS)
        AC_SUBST(XMLRPC_LIBS)

        dnl If additional compile flags are necessary to include the header
        dnl files of the backend, then add them here.
        BACKEND_CPPFLAGS="$BACKEND_CPPFLAGS $XMLRPC_CFLAGS"

        AC_DEFINE(ENABLE_XMLRPC, 1, [XMLRPC available])
fi
