AC_DEFUN(SVN_LIB_SQLITE,
[
SQLITE_MINIMUM_VER="$1"
SQLITE_RECOMMENDED_VER="$2"
SQLITE_URL="$3"
SQLITE_PKGNAME="sqlite3"
SVN_SQLITE_MIN_VERNUM_PARSE
AC_MSG_NOTICE([checking sqlite library])
AC_ARG_WITH(sqlite,
AS_HELP_STRING([--with-sqlite=PREFIX],
[Use installed SQLite library or amalgamation file.]),
[
if test "$withval" = "yes" ; then
AC_MSG_ERROR([--with-sqlite requires an argument.])
else
sqlite_dir="$withval"
fi
if test -d $sqlite_dir; then
SVN_SQLITE_DIR_CONFIG($sqlite_dir)
else
SVN_SQLITE_FILE_CONFIG($sqlite_dir)
fi
if test -z "$svn_lib_sqlite"; then
AC_MSG_WARN([no suitable sqlite found in $sqlite_dir])
SVN_DOWNLOAD_SQLITE
fi
],
[
SVN_SQLITE_FILE_CONFIG($abs_srcdir/sqlite-amalgamation/sqlite3.c)
if test -z "$svn_lib_sqlite"; then
SVN_SQLITE_FILE_CONFIG($abs_builddir/sqlite-amalgamation/sqlite3.c)
fi
if test -z "$svn_lib_sqlite"; then
SVN_SQLITE_DIR_CONFIG()
fi
if test -z "$svn_lib_sqlite"; then
SVN_SQLITE_PKG_CONFIG
fi
if test -z "$svn_lib_sqlite"; then
SVN_DOWNLOAD_SQLITE
fi
])
AC_SUBST(SVN_SQLITE_INCLUDES)
AC_SUBST(SVN_SQLITE_LIBS)
])
AC_DEFUN(SVN_SQLITE_PKG_CONFIG,
[
if test -n "$PKG_CONFIG"; then
AC_MSG_CHECKING([sqlite library version (via pkg-config)])
sqlite_version=`$PKG_CONFIG $SQLITE_PKGNAME --modversion --silence-errors`
if test -n "$sqlite_version"; then
SVN_SQLITE_VERNUM_PARSE([$sqlite_version], [sqlite_ver_num])
if test "$sqlite_ver_num" -ge "$sqlite_min_ver_num"; then
AC_MSG_RESULT([$sqlite_version])
svn_lib_sqlite="yes"
SVN_SQLITE_INCLUDES="`$PKG_CONFIG $SQLITE_PKGNAME --cflags`"
SVN_SQLITE_LIBS="`$PKG_CONFIG $SQLITE_PKGNAME --libs`"
else
AC_MSG_RESULT([none or unsupported $sqlite_version])
fi
fi
fi
if test -z "$svn_lib_sqlite"; then
AC_MSG_RESULT(no)
fi
])
AC_DEFUN(SVN_SQLITE_DIR_CONFIG,
[
if test -z "$1"; then
sqlite_dir=""
sqlite_include="sqlite3.h"
else
sqlite_dir="$1"
sqlite_include="$1/include/sqlite3.h"
fi
save_CPPFLAGS="$CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
if test ! -z "$1"; then
CPPFLAGS="$CPPFLAGS -I$sqlite_dir/include"
LDFLAGS="$LDFLAGS -L$sqlite_dir/lib"
fi
AC_CHECK_HEADER(sqlite3.h,
[
AC_MSG_CHECKING([sqlite library version (via header)])
AC_EGREP_CPP(SQLITE_VERSION_OKAY,[
SQLITE_VERSION_OKAY
[AC_MSG_RESULT([okay])
AC_CHECK_LIB(sqlite3, sqlite3_close, [
svn_lib_sqlite="yes"
if test -z "$sqlite_dir" -o ! -d "$sqlite_dir"; then
SVN_SQLITE_LIBS="-lsqlite3"
else
SVN_SQLITE_INCLUDES="-I$sqlite_dir/include"
SVN_SQLITE_LIBS="`SVN_REMOVE_STANDARD_LIB_DIRS(-L$sqlite_dir/lib -lsqlite3)`"
fi
])], [AC_MSG_RESULT([unsupported SQLite version])])
])
CPPFLAGS="$save_CPPFLAGS"
LDFLAGS="$save_LDFLAGS"
])
AC_DEFUN(SVN_SQLITE_FILE_CONFIG,
[
sqlite_amalg="$1"
AC_MSG_CHECKING([sqlite amalgamation])
if test ! -e $sqlite_amalg; then
AC_MSG_RESULT([no])
else
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([sqlite amalgamation file version])
AC_EGREP_CPP(SQLITE_VERSION_OKAY,[
SQLITE_VERSION_OKAY
[AC_MSG_RESULT([amalgamation found and is okay])
_SVN_SQLITE_DSO_LIBS
AC_DEFINE(SVN_SQLITE_INLINE, 1,
[Defined if svn should use the amalgamated version of sqlite])
SVN_SQLITE_INCLUDES="-I`dirname $sqlite_amalg`"
if test -n "$svn_sqlite_dso_ldflags"; then
SVN_SQLITE_LIBS="$svn_sqlite_dso_ldflags -lpthread"
else
SVN_SQLITE_LIBS="-lpthread"
fi
svn_lib_sqlite="yes"],
[AC_MSG_RESULT([unsupported amalgamation SQLite version])])
fi
])
AC_DEFUN(SVN_SQLITE_VERNUM_PARSE,
[
version_string="$1"
major=`expr $version_string : '\([[0-9]]*\)'`
minor=`expr $version_string : '[[0-9]]*\.\([[0-9]]*\)'`
micro=`expr $version_string : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
if test -z "$micro"; then
micro=0
fi
$2=`expr $major \* 1000000 \
\+ $minor \* 1000 \
\+ $micro`
])
AC_DEFUN(SVN_SQLITE_MIN_VERNUM_PARSE,
[
SVN_SQLITE_VERNUM_PARSE([$SQLITE_MINIMUM_VER], [sqlite_min_ver_num])
])
AC_DEFUN(SVN_DOWNLOAD_SQLITE,
[
echo ""
echo "An appropriate version of sqlite could not be found. We recommmend"
echo "${SQLITE_RECOMMENDED_VER}, but require at least ${SQLITE_MINIMUM_VER}."
echo "Please either install a newer sqlite on this system"
echo ""
echo "or"
echo ""
echo "get the sqlite ${SQLITE_RECOMMENDED_VER} amalgamation from:"
echo " ${SQLITE_URL}"
echo "unpack the archive using unzip and rename the resulting"
echo "directory to:"
echo "$abs_srcdir/sqlite-amalgamation"
if test x"$abs_srcdir" != x"$abs_builddir"; then
echo "or to:"
echo "$abs_builddir/sqlite-amalgamation"
fi
echo ""
AC_MSG_ERROR([Subversion requires SQLite])
])
AC_DEFUN(_SVN_SQLITE_DSO_LIBS,
[
case $host_os in
beos* | mingw* | pw32* | cegcc* | cygwin*)
svn_sqlite_dso_ldflags=
;;
darwin*)
AC_CHECK_LIB([dl], [dlopen],
[lt_cv_dlopen="dlopen" svn_sqlite_dso_ldflags="-ldl"],[
svn_sqlite_dso_ldflags=
])
;;
*)
AC_CHECK_FUNC([shl_load],
[svn_sqlite_dso_ldflags=],
[AC_CHECK_LIB([dld], [shl_load],
[svn_sqlite_dso_ldflags="-ldld"],
[AC_CHECK_FUNC([dlopen],
[svn_sqlite_dso_ldflags=],
[AC_CHECK_LIB([dl], [dlopen],
[svn_sqlite_dso_ldflags="-ldl"],
[AC_CHECK_LIB([svld], [dlopen],
[svn_sqlite_dso_ldflags="-lsvld"],
[AC_CHECK_LIB([dld], [dld_link],
[svn_sqlite_dso_ldflags="-ldld"])
])
])
])
])
])
;;
esac
AC_MSG_CHECKING([additional libraries for sqlite])
if test -n "$svn_sqlite_dso_ldflags"; then
AC_MSG_RESULT(${svn_sqlite_dso_ldflags})
else
AC_MSG_RESULT(none)
fi
])