[tracker] configure: Check that sqlite3 has sqlite3_auto_extension() enabled
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] configure: Check that sqlite3 has sqlite3_auto_extension() enabled
- Date: Sun, 27 Mar 2016 13:45:27 +0000 (UTC)
commit f3db8b289136e7be384505c85778fe22fc18df2d
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Mar 27 14:22:21 2016 +0200
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.
configure.ac | 6 ++++++
m4/sqlite-auto-extension.m4 | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c5a006e..6bd6d93 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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])
diff --git a/m4/sqlite-auto-extension.m4 b/m4/sqlite-auto-extension.m4
new file mode 100644
index 0000000..60cee93
--- /dev/null
+++ b/m4/sqlite-auto-extension.m4
@@ -0,0 +1,40 @@
+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"
+])
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]