 @@ -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

+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
 bitcoind_LDADD += libbitcoin_wallet.a
 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_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

+	@echo "Building the LevelDB shared library..." && $(MAKE) -C ./leveldb
+
 endif
 
 BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config
@@ -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
