Bug 263381 - "support --with-system-sqlite3 in storage builds" [p=mh+mozilla@glandium.org (Mike Hommey) r=bsmedberg a1.9=beltzner]
authorreed@reedloden.com
Fri, 22 Feb 2008 03:25:59 -0800
changeset 12096 f427531f200e99961336b208a9fb611d05306aa6
parent 12095 9f9c015f35cb14f87afd718c21f989c03af9c65b
child 12097 771ed41c703cff002daea996e8a06600f348eaf2
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs263381
milestone1.9b4pre
Bug 263381 - "support --with-system-sqlite3 in storage builds" [p=mh+mozilla@glandium.org (Mike Hommey) r=bsmedberg a1.9=beltzner]
config/autoconf.mk.in
config/static-config.mk
configure.in
db/sqlite3/README.MOZILLA
storage/Makefile.in
storage/build/Makefile.in
storage/src/Makefile.in
toolkit/library/libxul-config.mk
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -422,16 +422,20 @@ MOZ_NATIVE_LCMS	= @MOZ_NATIVE_LCMS@
 LCMS_CFLAGS	= @LCMS_CFLAGS@
 LCMS_LIBS	= @LCMS_LIBS@
 ifdef MOZ_NATIVE_LCMS
 LCMS_REQUIRES	=
 else
 LCMS_REQUIRES	= lcms
 endif
 
+MOZ_NATIVE_SQLITE = @MOZ_NATIVE_SQLITE@
+SQLITE_CFLAGS     = @SQLITE_CFLAGS@
+SQLITE_LIBS       = @SQLITE_LIBS@
+
 NSPR_CONFIG	= @NSPR_CONFIG@
 NSPR_CFLAGS	= @NSPR_CFLAGS@
 NSPR_LIBS	= @NSPR_LIBS@
 
 NSS_CONFIG	= @NSS_CONFIG@
 NSS_CFLAGS	= @NSS_CFLAGS@
 NSS_LIBS	= @NSS_LIBS@
 NSS_DEP_LIBS	= @NSS_DEP_LIBS@
--- a/config/static-config.mk
+++ b/config/static-config.mk
@@ -88,17 +88,17 @@ STATIC_EXTRA_LIBS	+= $(MOZ_CAIRO_LIBS)
 
 ifdef MOZ_ENABLE_GTK2
 STATIC_EXTRA_LIBS	+= $(XLDFLAGS) $(XT_LIBS) -lgthread-2.0
 STATIC_EXTRA_LIBS	+= $(MOZ_XFT_LIBS)
 STATIC_EXTRA_LIBS	+= $(MOZ_PANGO_LIBS)
 endif
 
 ifdef MOZ_STORAGE
-EXTRA_DSO_LIBS += sqlite3
+EXTRA_DSO_LDOPTS	+= $(SQLITE_LIBS)
 endif
 
 ifdef MOZ_ENABLE_STARTUP_NOTIFICATION
 STATIC_EXTRA_LIBS	+= $(MOZ_STARTUP_NOTIFICATION_LIBS)
 endif
 
 # Component Makefile always brings in this.
 # STATIC_EXTRA_LIBS	+= $(TK_LIBS)
--- a/configure.in
+++ b/configure.in
@@ -123,16 +123,17 @@ WINDRES_VERSION=2.14.90
 W32API_VERSION=3.8
 GNOMEVFS_VERSION=2.0
 GNOMEUI_VERSION=2.2.0
 GCONF_VERSION=1.2.1
 LIBGNOME_VERSION=2.0
 STARTUP_NOTIFICATION_VERSION=0.8
 DBUS_VERSION=0.60
 LCMS_VERSION=1.17
+SQLITE_VERSION=3.5
 
 MSMANIFEST_TOOL=
 
 dnl Set various checks
 dnl ========================================================
 MISSING_X=
 AC_PROG_AWK
 
@@ -5725,28 +5726,51 @@ if test -n "$MOZ_FEEDS"; then
 else
     if test "$MOZ_BUILD_APP" = "browser"; then
         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
     fi
 fi
 
 dnl ========================================================
 dnl = Enable mozStorage
-dnl = XXX need to implement --with-system-sqlite3 (see bug 263381)
 dnl ========================================================
 dnl Implicitly enabled by default if building calendar or places
 MOZ_ARG_ENABLE_BOOL(storage,
 [  --enable-storage        Enable mozStorage module and related components],
     MOZ_STORAGE=1,
     MOZ_STORAGE= )
 if test -n "$MOZ_STORAGE"; then
     AC_DEFINE(MOZ_STORAGE)
 fi
 
 dnl ========================================================
+dnl Check for sqlite
+dnl ========================================================
+
+MOZ_NATIVE_SQLITE=
+MOZ_ARG_ENABLE_BOOL(system-sqlite,
+[  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
+MOZ_NATIVE_SQLITE=1,
+MOZ_NATIVE_SQLITE= )
+
+if test -z "$MOZ_NATIVE_SQLITE"
+then
+    SQLITE_CFLAGS=
+    if test -z "$GNU_CC" && test "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "WINCE" -o "$OS_ARCH" = "OS2"; then
+        SQLITE_LIBS='$(DIST)/lib/$(LIB_PREFIX)sqlite3.$(LIB_SUFFIX)'
+    else
+        SQLITE_LIBS='-lsqlite3'
+    fi
+else
+    PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
+fi
+
+AC_SUBST(MOZ_NATIVE_SQLITE)
+
+dnl ========================================================
 dnl = Enable safe browsing (anti-phishing)
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(safe-browsing,
 [  --enable-safe-browsing        Enable safe browsing (anti-phishing) implementation],
     MOZ_SAFE_BROWSING=1,
     MOZ_SAFE_BROWSING= )
 if test -n "$MOZ_SAFE_BROWSING"; then
     AC_DEFINE(MOZ_SAFE_BROWSING)
--- a/db/sqlite3/README.MOZILLA
+++ b/db/sqlite3/README.MOZILLA
@@ -7,9 +7,12 @@ See http://www.sqlite.org/ for more info
 
 We have a mozilla-specific Makefile.in in src/ (normally no
 Makefile.in there) that we use to build.
 
 To move to a new version:
 
 Simply copy the sqlite3.h and sqlite3.c files from the amalgamation of sqlite.
 
+If mozstorage or nss code need changes due to API changes in sqlite3, be sure
+to update SQLITE_VERSION accordingly in $(topsrcdir)/configure.in.
+
 -- Shawn Wilsher <me@shawnwilsher.com> 01/2008
--- a/storage/Makefile.in
+++ b/storage/Makefile.in
@@ -39,20 +39,24 @@
 DEPTH		= ..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= storage
-DIRS		= ../db/sqlite3/src \
-		  public \
-		  src \
-		  build \
-		  $(NULL)
+
+ifndef MOZ_NATIVE_SQLITE
+DIRS		= ../db/sqlite3/src
+endif
+
+DIRS		+= public \
+		   src \
+		   build \
+		   $(NULL)
 
 ifdef ENABLE_TESTS
 TOOL_DIRS += test
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/storage/build/Makefile.in
+++ b/storage/build/Makefile.in
@@ -60,26 +60,25 @@ REQUIRES = \
 	xpconnect \
 	$(NULL)
 
 EXPORTS = mozStorageCID.h
 
 CPPSRCS = mozStorageModule.cpp
 
 LOCAL_INCLUDES = \
+	$(SQLITE_CFLAGS) \
 	-I$(srcdir)/../src
 
 SHARED_LIBRARY_LIBS = \
 	../src/$(LIB_PREFIX)storage_s.$(LIB_SUFFIX) \
 	$(NULL)
 
-EXTRA_DSO_LIBS += sqlite3
-
 EXTRA_DSO_LDOPTS += \
 	$(LIBS_DIR) \
-	$(EXTRA_DSO_LIBS) \
+	$(SQLITE_LIBS) \
 	$(MOZ_UNICHARUTIL_LIBS) \
 	$(MOZ_COMPONENT_LIBS) \
 	$(MOZ_JS_LIBS) \
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
--- a/storage/src/Makefile.in
+++ b/storage/src/Makefile.in
@@ -61,13 +61,16 @@ CPPSRCS = \
 	mozStorageService.cpp \
 	mozStorageConnection.cpp \
 	mozStorageStatement.cpp \
 	mozStorageStatementWrapper.cpp \
 	mozStorageValueArray.cpp \
 	mozStorageUnicodeFunctions.cpp \
 	$(NULL)
 
+LOCAL_INCLUDES = \
+	$(SQLITE_CFLAGS)
+
 # This is the default value.  If we ever change it when compiling sqlite, we
 # will need to change it here as well.
 DEFINES += -DSQLITE_MAX_LIKE_PATTERN_LENGTH=50000
 
 include $(topsrcdir)/config/rules.mk
--- a/toolkit/library/libxul-config.mk
+++ b/toolkit/library/libxul-config.mk
@@ -226,17 +226,17 @@ ifdef MOZ_XPFE_COMPONENTS
 COMPONENT_LIBS += fileview
 DEFINES += -DMOZ_FILEVIEW
 endif
 endif
 endif
 
 ifdef MOZ_STORAGE
 COMPONENT_LIBS += storagecomps
-EXTRA_DSO_LIBS += sqlite3
+EXTRA_DSO_LDOPTS += $(SQLITE_LIBS)
 endif
 
 ifdef MOZ_PLACES
 STATIC_LIBS += morkreader_s
 
 COMPONENT_LIBS += \
 	places \
 	$(NULL)