aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2020-10-15 13:50:00 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2020-10-20 13:44:43 +0000
commit7b54d768e1514b328e1ac108d3db2f1bac3ba7ff (patch)
treeace67c61cc90f8b2dabbf5dbf47cdd2cf13404e5
parent711ddce94377aea38ce30fa93b3ee8ea1d96ba98 (diff)
downloadbitcoin-7b54d768e1514b328e1ac108d3db2f1bac3ba7ff.tar.xz
Make sqlite support optional (compile-time)
-rw-r--r--configure.ac30
-rw-r--r--doc/build-unix.md2
-rw-r--r--doc/dependencies.md2
-rw-r--r--src/Makefile.am7
-rw-r--r--src/wallet/walletdb.cpp8
-rw-r--r--src/wallet/walletutil.cpp4
6 files changed, 48 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index ab40991ce4..9a16b7c880 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,6 +128,12 @@ AC_ARG_ENABLE([wallet],
[enable_wallet=$enableval],
[enable_wallet=yes])
+AC_ARG_WITH([sqlite],
+ [AS_HELP_STRING([--with-sqlite=yes|no|auto],
+ [enable sqlite wallet support (default: auto, i.e., enabled if wallet is enabled and sqlite is found)])],
+ [use_sqlite=$withval],
+ [use_sqlite=auto])
+
AC_ARG_WITH([miniupnpc],
[AS_HELP_STRING([--with-miniupnpc],
[enable UPNP (default is yes if libminiupnpc is found)])],
@@ -1224,7 +1230,24 @@ if test x$enable_wallet != xno; then
fi
dnl Check for sqlite3
- PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.7.17], , [AC_MSG_ERROR([sqlite3 not found.])])
+ if test "x$use_sqlite" != "xno"; then
+ PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.7.17], [have_sqlite=yes], [have_sqlite=no])
+ fi
+ AC_MSG_CHECKING([whether to build wallet with support for sqlite])
+ if test "x$use_sqlite" = "xno"; then
+ use_sqlite=no
+ elif test "x$have_sqlite" = "xno"; then
+ if test "x$use_sqlite" = "xyes"; then
+ AC_MSG_ERROR([sqlite support requested but cannot be built. Use --without-sqlite])
+ fi
+ use_sqlite=no
+ else
+ if test x$use_sqlite != xno; then
+ AC_DEFINE([USE_SQLITE],[1],[Define if sqlite support should be compiled in])
+ use_sqlite=yes
+ fi
+ fi
+ AC_MSG_RESULT([$use_sqlite])
fi
dnl Check for libminiupnpc (optional)
@@ -1578,6 +1601,7 @@ AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin])
AM_CONDITIONAL([TARGET_LINUX], [test x$TARGET_OS = xlinux])
AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows])
AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes])
+AM_CONDITIONAL([USE_SQLITE], [test "x$use_sqlite" = "xyes"])
AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
AM_CONDITIONAL([ENABLE_FUZZ],[test x$enable_fuzz = xyes])
AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes])
@@ -1643,6 +1667,7 @@ AC_SUBST(AVX2_CXXFLAGS)
AC_SUBST(SHANI_CXXFLAGS)
AC_SUBST(ARM_CRC_CXXFLAGS)
AC_SUBST(LIBTOOL_APP_LDFLAGS)
+AC_SUBST(USE_SQLITE)
AC_SUBST(USE_UPNP)
AC_SUBST(USE_QRCODE)
AC_SUBST(BOOST_LIBS)
@@ -1718,6 +1743,9 @@ echo "Options used to compile and link:"
echo " boost process = $ax_cv_boost_process"
echo " multiprocess = $build_multiprocess"
echo " with wallet = $enable_wallet"
+if test "x$enable_wallet" != "xno"; then
+ echo " with sqlite = $use_sqlite"
+fi
echo " with gui / qt = $bitcoin_enable_qt"
if test x$bitcoin_enable_qt != xno; then
echo " with qr = $use_qr"
diff --git a/doc/build-unix.md b/doc/build-unix.md
index c076fb6fff..ab83ceff3d 100644
--- a/doc/build-unix.md
+++ b/doc/build-unix.md
@@ -46,7 +46,7 @@ Optional dependencies:
libqrencode | QR codes in GUI | Optional for generating QR codes (only needed when GUI enabled)
univalue | Utility | JSON parsing and encoding (bundled version will be used unless --with-system-univalue passed to configure)
libzmq3 | ZMQ notification | Optional, allows generating ZMQ notifications (requires ZMQ version >= 4.0.0)
- sqlite3 | SQLite DB | Wallet storage (only needed when wallet enabled)
+ sqlite3 | SQLite DB | Optional, wallet storage (only needed when wallet enabled)
For the versions used, see [dependencies.md](dependencies.md)
diff --git a/doc/dependencies.md b/doc/dependencies.md
index ddd50ef296..d1bf4b3a87 100644
--- a/doc/dependencies.md
+++ b/doc/dependencies.md
@@ -34,7 +34,7 @@ Some dependencies are not needed in all configurations. The following are some f
#### Options passed to `./configure`
* MiniUPnPc is not needed with `--with-miniupnpc=no`.
* Berkeley DB is not needed with `--disable-wallet`.
-* SQLite is not needed with `--disable-wallet`.
+* SQLite is not needed with `--disable-wallet` or `--without-sqlite`.
* Qt is not needed with `--without-gui`.
* If the qrencode dependency is absent, QR support won't be added. To force an error when that happens, pass `--with-qrencode`.
* ZeroMQ is needed only with the `--with-zmq` option.
diff --git a/src/Makefile.am b/src/Makefile.am
index b0d36717ce..67fd402603 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -356,7 +356,7 @@ endif
# wallet: shared between bitcoind and bitcoin-qt, but only linked
# when wallet enabled
-libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
+libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(SQLITE_CFLAGS)
libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_wallet_a_SOURCES = \
interfaces/wallet.cpp \
@@ -372,13 +372,16 @@ libbitcoin_wallet_a_SOURCES = \
wallet/rpcwallet.cpp \
wallet/salvage.cpp \
wallet/scriptpubkeyman.cpp \
- wallet/sqlite.cpp \
wallet/wallet.cpp \
wallet/walletdb.cpp \
wallet/walletutil.cpp \
wallet/coinselection.cpp \
$(BITCOIN_CORE_H)
+if USE_SQLITE
+libbitcoin_wallet_a_SOURCES += wallet/sqlite.cpp
+endif
+
libbitcoin_wallet_tool_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
libbitcoin_wallet_tool_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_wallet_tool_a_SOURCES = \
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
index 0092a29cb4..aa3b3c10b0 100644
--- a/src/wallet/walletdb.cpp
+++ b/src/wallet/walletdb.cpp
@@ -15,7 +15,9 @@
#include <util/time.h>
#include <util/translation.h>
#include <wallet/bdb.h>
+#ifdef USE_SQLITE
#include <wallet/sqlite.h>
+#endif
#include <wallet/wallet.h>
#include <atomic>
@@ -1012,6 +1014,7 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas
if (ExistsBerkeleyDatabase(path)) {
format = DatabaseFormat::BERKELEY;
}
+#ifdef USE_SQLITE
if (ExistsSQLiteDatabase(path)) {
if (format) {
error = Untranslated(strprintf("Failed to load database path '%s'. Data is in ambiguous format.", path.string()));
@@ -1020,6 +1023,7 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas
}
format = DatabaseFormat::SQLITE;
}
+#endif
} else if (options.require_existing) {
error = Untranslated(strprintf("Failed to load database path '%s'. Path does not exist.", path.string()));
status = DatabaseStatus::FAILED_NOT_FOUND;
@@ -1048,9 +1052,13 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas
// Format is not set when a db doesn't already exist, so use the format specified by the options if it is set.
if (!format && options.require_format) format = options.require_format;
+#ifdef USE_SQLITE
if (format && format == DatabaseFormat::SQLITE) {
return MakeSQLiteDatabase(path, options, status, error);
}
+#else
+ assert(format != DatabaseFormat::SQLITE);
+#endif
return MakeBerkeleyDatabase(path, options, status, error);
}
diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp
index a2a55f9751..2f3e597b90 100644
--- a/src/wallet/walletutil.cpp
+++ b/src/wallet/walletutil.cpp
@@ -8,7 +8,11 @@
#include <util/system.h>
bool ExistsBerkeleyDatabase(const fs::path& path);
+#ifdef USE_SQLITE
bool ExistsSQLiteDatabase(const fs::path& path);
+#else
+# define ExistsSQLiteDatabase(path) (false)
+#endif
fs::path GetWalletDir()
{