Commit f3db8b28 authored by Carlos Garnacho's avatar Carlos Garnacho

configure: Check that sqlite3 has sqlite3_auto_extension() enabled

Only do this if we need to load the FTS5 module, sqlite3 might have
been compiled with SQLITE_OMIT_LOAD_EXTENSION, which will make things
go very wrong (poking NULL vfuncs in a 0'ed out sqlite3_api_routines)
at runtime.

This facility must be enabled if we need to load our FTS module, so
bail out at configure time if it's not there.
parent 7e72eb23
......@@ -831,6 +831,12 @@ if test "x$have_tracker_fts" = "xyes"; then
AC_DEFINE(HAVE_BUILTIN_FTS, [], [Defined if Sqlite has FTS5 compiled in])
else
have_builtin_fts5="no"
# Make sure SQLite has extension loading enabled
AX_SQLITE_AUTO_EXTENSION
if test "x$ax_cv_sqlite_auto_extension" != "xyes"; then
AC_MSG_ERROR([sqlite3 cannot load extensions])
fi
fi
else
AC_DEFINE(HAVE_TRACKER_FTS, [0], [Define to 0 if tracker FTS is not compiled])
......
AC_DEFUN([AX_SQLITE_AUTO_EXTENSION],
[
AC_REQUIRE([AC_PROG_CC])
OLD_CFLAGS="$CFLAGS"
OLD_LDFLAGS="$LDFLAGS"
OLD_LIBS="$LIBS"
CFLAGS="$SQLITE3_CFLAGS"
LDFLAGS="$SQLITE3_LDFLAGS"
LIBS="$SQLITE3_LIBS"
AC_CHECK_HEADERS([sqlite3.h])
AC_CACHE_CHECK([whether SQLite3 has extension loading enabled],
[ax_cv_sqlite_auto_extension],
[
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[#include <sqlite3.h>
static int initialized = 0;
int extEntryPoint(sqlite3 *db, const char **err, void **api){
initialized = 1;
if (api != 0 && *api != 0)
return SQLITE_OK;
return SQLITE_ERROR;
}]],
[[sqlite3 *db;
int rc;
sqlite3_auto_extension((void (*)(void))extEntryPoint);
rc = sqlite3_open(":memory:", &db);
if (rc!=SQLITE_OK) return -1;
if (initialized==0) return -1]])],
[ax_cv_sqlite_auto_extension=yes],
[ax_cv_sqlite_auto_extension=no],
[ax_cv_sqlite_auto_extension=no])])
CFLAGS="$OLD_CFLAGS"
LDFLAGS="$OLD_LDFLAGS"
LIBS="$OLD_LIBS"
])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment