summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2010-10-06 09:47:32 +0200
committerAleksander Morgado <aleksander@lanedo.com>2010-10-06 10:27:52 +0200
commit9961f2d1571d8a667d8a214cdf2b2a920ffa30dd (patch)
tree19185e71e3a26923a8bfae7c96ba7ca6e835ae4f /m4
parentd11327fe0adfaec9d2deb9dc6c9fda18df1329ff (diff)
downloadtracker-9961f2d1571d8a667d8a214cdf2b2a920ffa30dd.tar.gz
configure.ac: Make sure sqlite is compiled thread-safe
Diffstat (limited to 'm4')
-rw-r--r--m4/sqlite-threadsafe.m448
1 files changed, 48 insertions, 0 deletions
diff --git a/m4/sqlite-threadsafe.m4 b/m4/sqlite-threadsafe.m4
new file mode 100644
index 000000000..bfa20a88a
--- /dev/null
+++ b/m4/sqlite-threadsafe.m4
@@ -0,0 +1,48 @@
+# sqlite-threadsafe.m4 serial 1
+
+dnl Copyright (C) 2010 Aleksander Morgado <aleksander@gnu.org>
+dnl This file is free software; unlimited permission to copy and/or distribute
+dnl it is given, with or without modifications, as long as this notice is
+dnl preserved.
+
+dnl This program will execute the sqlite3_threadsafe() method to check
+dnl whether the sqlite3 library was compiled in threadsafe mode or not,
+dnl and will fill the ax_cv_sqlite_threadsafe cached variable accordingly.
+dnl See http://sqlite.org/c3ref/threadsafe.html for more information.
+
+dnl Once this m4 macro has been evaluated, you can for example issue an error
+dnl when sqlite3 was not compiled thread-safe:
+dnl
+dnl AX_SQLITE_THREADSAFE
+dnl if test "x$ax_cv_sqlite_threadsafe" != "xyes"; then
+dnl AC_MSG_ERROR([sqlite3 is not compiled in a thread-safe mode])
+dnl fi
+
+
+AC_DEFUN([AX_SQLITE_THREADSAFE],
+[
+ AC_REQUIRE([AC_PROG_CC])
+
+ AC_CHECK_HEADERS([sqlite3.h])
+ AC_CHECK_LIB([sqlite3],[sqlite3_threadsafe])
+
+ AC_CACHE_CHECK([whether sqlite was compiled thread-safe],
+ [ax_cv_sqlite_threadsafe],
+ [
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <sqlite3.h>
+int main ()
+{
+ /* sqlite3_threadsafe() returns the value of the SQLITE_THREADSAFE
+ * preprocessor macro used when compiling. If this is 0, sqlite3
+ * library was NOT compiled in a thread-safe mode */
+
+ return sqlite3_threadsafe () == 0 ? -1 : 0;
+}
+
+ ]])],
+ [ax_cv_sqlite_threadsafe=yes],
+ [ax_cv_sqlite_threadsafe=no],
+ [ax_cv_sqlite_threadsafe=no])])
+])
+