flocore-node/etc/bitcoin.patch

280 lines
8.1 KiB
Diff

From 5aeac9628b35cee9dc61cba7fc4636f96b522dd7 Mon Sep 17 00:00:00 2001
From: Chris Kleeschulte <chrisk@bitpay.com>
Date: Mon, 15 Jun 2015 18:34:03 -0400
Subject: [PATCH] New patch using AC_DEFINE's and without the wallet stuff.
---
configure.ac | 31 +++++++++++++++++++++++++++++--
src/Makefile.am | 31 +++++++++++++++++++------------
src/bitcoind.cpp | 8 ++++++--
src/init.h | 6 ++++++
src/leveldbwrapper.h | 13 ++++++++++++-
5 files changed, 72 insertions(+), 17 deletions(-)
diff --git a/configure.ac b/configure.ac
index 579035f..cd20489 100644
--- a/configure.ac
+++ b/configure.ac
@@ -126,6 +126,12 @@ AC_ARG_ENABLE([reduce-exports],
[use_reduce_exports=$enableval],
[use_reduce_exports=auto])
+AC_ARG_ENABLE([daemonlib],
+ [AS_HELP_STRING([--enable-daemonlib],
+ [compile all of bitcoind as a library (default is no)])],
+ [use_daemonlib=$enableval],
+ [use_daemonlib=no])
+
AC_ARG_ENABLE([ccache],
[AS_HELP_STRING([--enable-ccache],
[use ccache for building (default is yes if ccache is found)])],
@@ -409,6 +415,9 @@ fi
if test x$use_hardening != xno; then
AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"])
AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"])
+ 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],[
@@ -422,7 +431,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
AX_CHECK_COMPILE_FLAG([-fPIE],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fPIE"])
AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"])
@@ -440,6 +449,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
+ AX_CHECK_COMPILE_FLAG([-fPIC],[DAEMONLIB_CXXFLAGS="$DAEMONLIB_CXXFLAGS -fPIC"])
+ AC_DEFINE([ENABLE_DAEMONLIB],[1],[Enable daemonlib.])
+ AM_CONDITIONAL([ENABLE_DAEMONLIB],[true])
+ CXXFLAGS="$CXXFLAGS $DAEMONLIB_CXXFLAGS"
+ CPPFLAGS="$CPPFLAGS $DAEMONLIB_CPPFLAGS"
+ OBJCXXFLAGS="$CXXFLAGS"
+fi
+
dnl this flag screws up non-darwin gcc even when the check fails. special-case it.
if test x$TARGET_OS = xdarwin; then
AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"])
@@ -485,7 +505,7 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([
]
)
-if test x$use_reduce_exports != xno; then
+if test x$use_reduce_exports != xno -a x$use_daemonlib = xno; then
AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[RE_CXXFLAGS="-fvisibility=hidden"],
[
if test x$use_reduce_exports = xyes; then
@@ -496,6 +516,13 @@ if test x$use_reduce_exports != xno; then
])
fi
+AC_MSG_CHECKING([whether to compile as daemonlib])
+if test x$use_daemonlib != xno; then
+ AC_MSG_RESULT([yes])
+else
+ AC_MSG_RESULT([no])
+fi
+
LEVELDB_CPPFLAGS=
LIBLEVELDB=
LIBMEMENV=
diff --git a/src/Makefile.am b/src/Makefile.am
index 81b16d1..b64eb24 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,7 +7,6 @@ LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/include
LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/helpers/memenv
LIBLEVELDB += $(builddir)/leveldb/libleveldb.a
LIBMEMENV += $(builddir)/leveldb/libmemenv.a
-
# NOTE: This dependency is not strictly necessary, but without it make may try to build both in parallel, which breaks the LevelDB build system in a race
$(LIBLEVELDB): $(LIBMEMENV)
@@ -49,22 +48,26 @@ BITCOIN_INCLUDES += $(BDB_CPPFLAGS)
EXTRA_LIBRARIES += libbitcoin_wallet.a
endif
-if BUILD_BITCOIN_LIBS
-lib_LTLIBRARIES = libbitcoinconsensus.la
-LIBBITCOIN_CONSENSUS=libbitcoinconsensus.la
-else
-LIBBITCOIN_CONSENSUS=
-endif
-
+lib_LTLIBRARIES =
+LIBBITCOIN_CONSENSUS =
bin_PROGRAMS =
TESTS =
+if BUILD_BITCOIN_LIBS
+lib_LTLIBRARIES += libbitcoinconsensus.la
+LIBBITCOIN_CONSENSUS += libbitcoinconsensus.la
+endif
+
+if !ENABLE_DAEMONLIB
if BUILD_BITCOIND
- bin_PROGRAMS += bitcoind
+bin_PROGRAMS += bitcoind
endif
if BUILD_BITCOIN_UTILS
- bin_PROGRAMS += bitcoin-cli bitcoin-tx
+bin_PROGRAMS += bitcoin-cli bitcoin-tx
+endif
+else
+lib_LTLIBRARIES += libbitcoind.la
endif
.PHONY: FORCE
@@ -156,6 +159,7 @@ 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
# server: shared between bitcoind and bitcoin-qt
@@ -305,15 +309,19 @@ if ENABLE_WALLET
bitcoind_LDADD += libbitcoin_wallet.a
endif
bitcoind_SOURCES = bitcoind.cpp
-#
+libbitcoind_la_SOURCES = bitcoind.cpp
if TARGET_WINDOWS
bitcoind_SOURCES += bitcoind-res.rc
+libbitcoind_la_SOURCES += bitcoind-res.rc
endif
bitcoind_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS)
+libbitcoind_la_LIBADD = $(bitcoind_LDADD)
bitcoind_CPPFLAGS = $(BITCOIN_INCLUDES)
+libbitcoind_la_CPPFLAGS = $(BITCOIN_INCLUDES)
bitcoind_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
+libbitcoind_la_LDFLAGS = $(RELDFLAGS) -no-undefined
# bitcoin-cli binary #
bitcoin_cli_LDADD = \
@@ -386,7 +394,6 @@ CLEANFILES = leveldb/libleveldb.a leveldb/libmemenv.a *.gcda *.gcno
DISTCLEANFILES = obj/build.h
EXTRA_DIST = leveldb
-
clean-local:
-$(MAKE) -C leveldb clean
-$(MAKE) -C secp256k1 clean
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index be7757b..e2c1698 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -10,11 +10,13 @@
#include "noui.h"
#include "ui_interface.h"
#include "util.h"
-
#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
#include <boost/thread.hpp>
-
+#if ENABLE_DAEMONLIB
+extern void DetectShutdownThread(boost::thread_group* threadGroup);
+extern bool AppInit(int argc, char* argv[]);
+#endif
/* Introduction text for doxygen: */
/*! \mainpage Developer documentation
@@ -175,6 +177,7 @@ bool AppInit(int argc, char* argv[])
return fRet;
}
+#if !ENABLE_DAEMONLIB
int main(int argc, char* argv[])
{
SetupEnvironment();
@@ -184,3 +187,4 @@ int main(int argc, char* argv[])
return (AppInit(argc, argv) ? 0 : 1);
}
+#endif
diff --git a/src/init.h b/src/init.h
index f2f7ac6..ce9ce2f 100644
--- a/src/init.h
+++ b/src/init.h
@@ -17,6 +17,12 @@ class thread_group;
extern CWallet* pwalletMain;
+#if ENABLE_DAEMONLIB
+#include <boost/filesystem/path.hpp>
+#include <boost/thread/mutex.hpp>
+void ThreadImport(std::vector<boost::filesystem::path> vImportFiles);
+#endif
+
void StartShutdown();
bool ShutdownRequested();
void Shutdown();
diff --git a/src/leveldbwrapper.h b/src/leveldbwrapper.h
index 4247920..aa18fe4 100644
--- a/src/leveldbwrapper.h
+++ b/src/leveldbwrapper.h
@@ -4,7 +4,6 @@
#ifndef BITCOIN_LEVELDBWRAPPER_H
#define BITCOIN_LEVELDBWRAPPER_H
-
#include "clientversion.h"
#include "serialize.h"
#include "streams.h"
@@ -29,10 +28,16 @@ class CLevelDBBatch
{
friend class CLevelDBWrapper;
+#if ENABLE_DAEMONLIB
+public:
+#else
private:
+#endif
leveldb::WriteBatch batch;
+#if !ENABLE_DAEMONLIB
public:
+#endif
template <typename K, typename V>
void Write(const K& key, const V& value)
{
@@ -63,7 +68,11 @@ public:
class CLevelDBWrapper
{
+#if ENABLE_DAEMONLIB
+public:
+#else
private:
+#endif
//! custom environment this database is using (may be NULL in case of default environment)
leveldb::Env* penv;
@@ -85,7 +94,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)