From abf10a2c0200819f6bb99366220f4c7566c01028 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Sat, 1 Sep 2012 22:06:48 +0100
Subject: Allow forcing of bundled sqlite, and compile sqlite on OS X


diff --git a/3rdParty/SQLite/sqlite3.c b/3rdParty/SQLite/sqlite3.c
index 3c7c57f..f11bd5d 100644
--- a/3rdParty/SQLite/sqlite3.c
+++ b/3rdParty/SQLite/sqlite3.c
@@ -288,7 +288,7 @@
  * requires the #include of specific headers which differs between
  * platforms.
  */
-#define SQLITE_INT_TO_PTR(X)   ((void*)&((char*)0)[X])
+#define SQLITE_INT_TO_PTR(X)   ((void*)(X))
 #define SQLITE_PTR_TO_INT(X)   ((int)(((char*)X)-(char*)0))
 
 /*
diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot
index 917935d..32ec818 100644
--- a/BuildTools/SCons/SConscript.boot
+++ b/BuildTools/SCons/SConscript.boot
@@ -48,6 +48,7 @@ vars.Add("libidn_libname", "LibIDN library name", "libidn" if os.name == "nt" el
 vars.Add(PathVariable("sqlite_includedir", "SQLite headers location", None, PathVariable.PathAccept))
 vars.Add(PathVariable("sqlite_libdir", "SQLite library location", None, PathVariable.PathAccept))
 vars.Add("sqlite_libname", "SQLite library name", "libsqlite3" if os.name == "nt" else "sqlite3")
+vars.Add("sqlite_force_bundled", "Force use of the bundled SQLite", None)
 vars.Add(PathVariable("avahi_includedir", "Avahi headers location", None, PathVariable.PathAccept))
 vars.Add(PathVariable("avahi_libdir", "Avahi library location", None, PathVariable.PathAccept))
 vars.Add(PathVariable("qt", "Qt location", "", PathVariable.PathAccept))
diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index 42dc36a..3be4bd7 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -366,7 +366,7 @@ if env.get("sqlite_includedir", None) :
 	sqlite_flags["CPPPATH"] = [env["sqlite_includedir"]]
 sqlite_conf_env.MergeFlags(sqlite_flags)
 conf = Configure(sqlite_conf_env)
-if conf.CheckCHeader("sqlite3.h") and conf.CheckLib(env["sqlite_libname"]) :
+if conf.CheckCHeader("sqlite3.h") and conf.CheckLib(env["sqlite_libname"]) and not env.get("sqlite_force_bundled", False):
 	env["HAVE_SQLITE"] = 1
 	env["SQLITE_FLAGS"] = { "LIBS": [env["sqlite_libname"]] }
 	env["SQLITE_FLAGS"].update(sqlite_flags)
-- 
cgit v0.10.2-6-g49f6