From 66af5935b71ce84b90284610f403f5981bece886 Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Tue, 21 Jul 2015 10:34:19 -0400 Subject: [PATCH] Patch update for wallet inclusion under the test environment - Added the patch to allow the building of the test environment for which the wallet is required --- etc/bitcoin.patch | 112 +++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 60 deletions(-) diff --git a/etc/bitcoin.patch b/etc/bitcoin.patch index 5606ee64..c71c258f 100644 --- a/etc/bitcoin.patch +++ b/etc/bitcoin.patch @@ -1,18 +1,8 @@ -From 05084f2a640b862132588b322461ec8e13058fc3 Mon Sep 17 00:00:00 2001 -From: Chris Kleeschulte -Date: Mon, 13 Jul 2015 12:49:30 -0400 -Subject: [PATCH] libbitcoind +commit 29c1ca452ba6178d6b17be0a0b5a65567ba846af +Author: Chris Kleeschulte +Date: Mon Jul 13 16:35:37 2015 -0400 ---- - config_me.sh | 1 + - configure.ac | 37 ++++++++++++++++++++++++++++++++----- - src/Makefile.am | 42 ++++++++++++++++++++++++++++++++++-------- - src/bitcoind.cpp | 6 ++++++ - src/init.h | 5 +++++ - src/leveldb/Makefile | 6 +++++- - src/leveldbwrapper.h | 12 ++++++++++++ - 7 files changed, 95 insertions(+), 14 deletions(-) - create mode 100644 config_me.sh + allow compiling of libbitcoind.so. diff --git a/config_me.sh b/config_me.sh new file mode 100644 @@ -22,13 +12,13 @@ index 0000000..19e9a1b @@ -0,0 +1 @@ +./configure --enable-tests=no --enable-daemonlib --with-gui=no --without-qt --without-miniupnpc --without-bdb --enable-debug --disable-wallet --without-utils diff --git a/configure.ac b/configure.ac -index 37fe47e..27a9b9a 100644 +index 37fe47e..83cfe70 100644 --- a/configure.ac +++ b/configure.ac @@ -119,6 +119,12 @@ AC_ARG_ENABLE([reduce-exports], [use_reduce_exports=$enableval], [use_reduce_exports=no]) - + +AC_ARG_ENABLE([daemonlib], + [AS_HELP_STRING([--enable-daemonlib], + [compile all of bitcoind as a library (default is no)])], @@ -45,13 +35,13 @@ index 37fe47e..27a9b9a 100644 + if test x$use_daemonlib = xno; then + AX_CHECK_COMPILE_FLAG([-fPIE],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fPIE"]) + fi - + AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[ AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[ @@ -415,7 +424,7 @@ if test x$use_hardening != xno; then AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"]) AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"]) - + - if test x$TARGET_OS != xwindows; then + if test x$TARGET_OS != xwindows -a x$use_daemonlib = xno; then # All windows code is PIC, forcing it on just adds useless compile warnings @@ -60,7 +50,7 @@ index 37fe47e..27a9b9a 100644 @@ -433,6 +442,17 @@ if test x$use_hardening != xno; then OBJCXXFLAGS="$CXXFLAGS" fi - + +AC_DEFINE([ENABLE_DAEMONLIB],[0],[Enable daemonlib.]) +AM_CONDITIONAL([ENABLE_DAEMONLIB],[false]) +if test x$use_daemonlib != xno; then @@ -78,13 +68,13 @@ index 37fe47e..27a9b9a 100644 @@ -483,11 +503,18 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([ ] ) - + -if test x$use_reduce_exports = xyes; then +if test x$use_reduce_exports = xyes -a x$use_daemonlib = xno; then AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[RE_CXXFLAGS="-fvisibility=hidden"], [AC_MSG_ERROR([Cannot set default symbol visibility. Use --disable-reduce-exports.])]) fi - + +AC_MSG_CHECKING([whether to compile as daemonlib]) +if test x$use_daemonlib != xno; then + AC_MSG_RESULT([yes]) @@ -96,18 +86,19 @@ index 37fe47e..27a9b9a 100644 LIBLEVELDB= LIBMEMENV= diff --git a/src/Makefile.am b/src/Makefile.am -index 1c2f770..632f608 100644 +index 1c2f770..ddcae0f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am -@@ -1,6 +1,7 @@ +@@ -1,6 +1,8 @@ DIST_SUBDIRS = secp256k1 AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) - + +lib_LTLIBRARIES = - ++libbitcoind_la_LIBADD = + if EMBEDDED_LEVELDB LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/include -@@ -15,6 +16,10 @@ $(LIBLEVELDB) $(LIBMEMENV): +@@ -15,6 +17,10 @@ $(LIBLEVELDB) $(LIBMEMENV): @echo "Building LevelDB ..." && $(MAKE) -C $(@D) $(@F) CXX="$(CXX)" \ CC="$(CC)" PLATFORM=$(TARGET_OS) AR="$(AR)" $(LEVELDB_TARGET_FLAGS) \ OPT="$(CXXFLAGS) $(CPPFLAGS) -D__STDC_LIMIT_MACROS" @@ -116,12 +107,12 @@ index 1c2f770..632f608 100644 + @echo "Building the LevelDB shared library..." && $(MAKE) -C ./leveldb + endif - + BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config -@@ -49,16 +54,16 @@ BITCOIN_INCLUDES += $(BDB_CPPFLAGS) +@@ -49,16 +55,16 @@ BITCOIN_INCLUDES += $(BDB_CPPFLAGS) EXTRA_LIBRARIES += libbitcoin_wallet.a endif - + -if BUILD_BITCOIN_LIBS -lib_LTLIBRARIES = libbitcoinconsensus.la -LIBBITCOIN_CONSENSUS=libbitcoinconsensus.la @@ -132,7 +123,7 @@ index 1c2f770..632f608 100644 +LIBBITCOIN_CONSENSUS = bin_PROGRAMS = TESTS = - + +if BUILD_BITCOIN_LIBS +lib_LTLIBRARIES += libbitcoinconsensus.la +LIBBITCOIN_CONSENSUS += libbitcoinconsensus.la @@ -142,28 +133,28 @@ index 1c2f770..632f608 100644 if BUILD_BITCOIND bin_PROGRAMS += bitcoind endif -@@ -66,6 +71,9 @@ endif +@@ -66,6 +72,9 @@ endif if BUILD_BITCOIN_UTILS bin_PROGRAMS += bitcoin-cli bitcoin-tx endif +else +lib_LTLIBRARIES += libbitcoind.la +endif - + .PHONY: FORCE # bitcoin core # -@@ -169,8 +177,9 @@ obj/build.h: FORCE +@@ -169,8 +178,9 @@ obj/build.h: FORCE @$(MKDIR_P) $(builddir)/obj @$(top_srcdir)/share/genbuild.sh $(abs_top_builddir)/src/obj/build.h \ $(abs_top_srcdir) -libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h - + +libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h +clientversion.cpp: obj/build.h # server: shared between bitcoind and bitcoin-qt libbitcoin_server_a_CPPFLAGS = $(BITCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) libbitcoin_server_a_SOURCES = \ -@@ -309,9 +318,18 @@ nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h +@@ -309,9 +319,18 @@ nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h bitcoind_SOURCES = bitcoind.cpp bitcoind_CPPFLAGS = $(BITCOIN_INCLUDES) bitcoind_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) @@ -175,37 +166,41 @@ index 1c2f770..632f608 100644 +libbitcoind_la_SOURCES += $(libbitcoin_server_a_SOURCES) +libbitcoind_la_SOURCES += $(crypto_libbitcoin_crypto_a_SOURCES) +libbitcoind_la_SOURCES += $(univalue_libbitcoin_univalue_a_SOURCES) - + if TARGET_WINDOWS bitcoind_SOURCES += bitcoind-res.rc +libbitcoind_la_SOURCES += bitcoind-res.rc endif - + bitcoind_LDADD = \ -@@ -328,7 +346,15 @@ if ENABLE_WALLET +@@ -326,9 +345,19 @@ bitcoind_LDADD = \ + + if ENABLE_WALLET bitcoind_LDADD += libbitcoin_wallet.a ++libbitcoind_la_LIBADD += $(BDB_LIBS) ++libbitcoind_la_SOURCES += $(libbitcoin_wallet_a_SOURCES) endif - + +MEMOBJ = helpers/memenv/memenv.lo +$(MEMOBJ): + @echo "Building the Memenv shared library..." && $(MAKE) -C ./leveldb $@ + bitcoind_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) -+libbitcoind_la_LIBADD = $(BOOST_LIBS) $(SSL_LIBS) $(LIBSECP256K1) $(CRYPTO_LIBS) leveldb/$(MEMOBJ) ++libbitcoind_la_LIBADD += $(BOOST_LIBS) $(SSL_LIBS) $(LIBSECP256K1) $(CRYPTO_LIBS) leveldb/$(MEMOBJ) +libbitcoind_la_CPPFLAGS = $(BITCOIN_INCLUDES) +libbitcoind_la_LDFLAGS = -lleveldb -L./leveldb $(RELDFLAGS) -no-undefined +libbitcoind_la_DEPENDENCIES = $(LIBSECP256K1) LIBLEVELDB_SHARED $(MEMOBJ) # - + # bitcoin-cli binary # diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index cce687a..0f162ff 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -33,6 +33,10 @@ - + static bool fDaemon; - + +#if ENABLE_DAEMONLIB +extern void WaitForShutdown(boost::thread_group* threadGroup); +#endif @@ -216,13 +211,13 @@ index cce687a..0f162ff 100644 @@ -166,6 +170,7 @@ bool AppInit(int argc, char* argv[]) return fRet; } - + +#if !ENABLE_DAEMONLIB int main(int argc, char* argv[]) { SetupEnvironment(); @@ -175,3 +180,4 @@ int main(int argc, char* argv[]) - + return (AppInit(argc, argv) ? 0 : 1); } +#endif @@ -231,9 +226,9 @@ index dcb2b29..5ce68ba 100644 --- a/src/init.h +++ b/src/init.h @@ -18,6 +18,11 @@ class thread_group; - + extern CWallet* pwalletMain; - + +#if ENABLE_DAEMONLIB +#include +#include @@ -248,24 +243,24 @@ index 2bd2cad..490ba66 100644 +++ b/src/leveldb/Makefile @@ -103,7 +103,7 @@ check: all $(PROGRAMS) $(TESTS) for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done - + clean: - -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk + -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) */*.o */*/*.lo helpers/memenv/.deps/*.Plo helpers/memenv/.deps/*.Tpo */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk -rm -rf ios-x86/* ios-arm/* - + $(LIBRARY): $(LIBOBJECTS) @@ -192,6 +192,10 @@ $(MEMENVLIBRARY) : $(MEMENVOBJECTS) rm -f $@ $(AR) -rs $@ $(MEMENVOBJECTS) - + +helpers/memenv/memenv.lo: helpers/memenv/memenv.cc + -mkdir -p helpers/memenv/.deps + /bin/bash ../../libtool --tag=CXX --mode=compile $(CXX) $(CXXFLAGS) $(CFLAGS) -fPIC -MT $@ -MD -MP -MF helpers/memenv/.deps/memenv.Tpo -c -o $@ $< + memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) $(CXX) $(LDFLAGS) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@ $(LIBS) - + diff --git a/src/leveldbwrapper.h b/src/leveldbwrapper.h index c65e842..0e44bb5 100644 --- a/src/leveldbwrapper.h @@ -273,14 +268,14 @@ index c65e842..0e44bb5 100644 @@ -29,10 +29,16 @@ class CLevelDBBatch { friend class CLevelDBWrapper; - + +#if ENABLE_DAEMONLIB +public: +#else private: +#endif leveldb::WriteBatch batch; - + +#if !ENABLE_DAEMONLIB public: +#endif @@ -288,7 +283,7 @@ index c65e842..0e44bb5 100644 void Write(const K& key, const V& value) { @@ -63,7 +69,11 @@ public: - + class CLevelDBWrapper { +#if ENABLE_DAEMONLIB @@ -298,17 +293,14 @@ index c65e842..0e44bb5 100644 +#endif //! custom environment this database is using (may be NULL in case of default environment) leveldb::Env* penv; - + @@ -85,7 +95,9 @@ private: //! the database itself leveldb::DB* pdb; - + +#if !ENABLE_DAEMONLIB public: +#endif CLevelDBWrapper(const boost::filesystem::path& path, size_t nCacheSize, bool fMemory = false, bool fWipe = false); ~CLevelDBWrapper(); - --- -2.3.2 (Apple Git-55) - +