diff --git a/bin/build-libbitcoind b/bin/build-libbitcoind index 46575ec5..98f6d3ab 100755 --- a/bin/build-libbitcoind +++ b/bin/build-libbitcoind @@ -4,11 +4,10 @@ cd "${root_dir}" options=`cat ${root_dir}/bin/config_options.sh` os_dir=$(./platform/os.sh osdir) - +host=$(./platform/os.sh host) build_dependencies () { if [ -d "${btc_dir}" ]; then pushd "${btc_dir}"/depends - host=`uname -m`-`uname -a | awk '{print tolower($1)}'` echo "using host for dependencies: ${host}" make HOST=${host} NO_QT=1 NO_WALLET=1 NO_UPNP=1 #host is arch-os, e.g. x86_64-linux popd diff --git a/binding.gyp b/binding.gyp old mode 100644 new mode 100755 index 947966a5..6fd8b87d --- a/binding.gyp +++ b/binding.gyp @@ -33,7 +33,8 @@ '\"$($(package)_cxxflags) $($(package)_cppflags)\" \"$($(package)_ldflags)\" \"$(boost_archiver_$(host_os))\" \"$(host_STRIP)\" \"$(host_RANLIB)\" \"$(host_WINDRES)\" : ;" > user-config.jam + endef + diff --git a/src/Makefile.am b/src/Makefile.am -index 1c2f770..ddcae0f 100644 +old mode 100644 +new mode 100755 +index 1c2f770..427bb14 --- a/src/Makefile.am +++ b/src/Makefile.am -@@ -1,6 +1,8 @@ +@@ -1,6 +1,10 @@ DIST_SUBDIRS = secp256k1 AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) +lib_LTLIBRARIES = +libbitcoind_la_LIBADD = ++libbitcoind_la_LDFLAGS = ++STATIC_BOOST_LIBS = if EMBEDDED_LEVELDB LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/include -@@ -15,6 +17,10 @@ $(LIBLEVELDB) $(LIBMEMENV): +@@ -15,6 +19,7 @@ $(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" -+ -+LIBLEVELDB_SHARED: -+ @echo "Building the LevelDB shared library..." && $(MAKE) -C ./leveldb + endif BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config -@@ -49,16 +55,16 @@ BITCOIN_INCLUDES += $(BDB_CPPFLAGS) +@@ -49,16 +54,16 @@ BITCOIN_INCLUDES += $(BDB_CPPFLAGS) EXTRA_LIBRARIES += libbitcoin_wallet.a endif @@ -127,7 +177,7 @@ index 1c2f770..ddcae0f 100644 if BUILD_BITCOIND bin_PROGRAMS += bitcoind endif -@@ -66,6 +72,9 @@ endif +@@ -66,6 +71,9 @@ endif if BUILD_BITCOIN_UTILS bin_PROGRAMS += bitcoin-cli bitcoin-tx endif @@ -137,18 +187,20 @@ index 1c2f770..ddcae0f 100644 .PHONY: FORCE # bitcoin core # -@@ -169,8 +178,9 @@ obj/build.h: FORCE +@@ -169,8 +177,11 @@ 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 ++ARCH_PLATFORM = $(shell ../../platform/os.sh host) ++ +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 +319,18 @@ nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h +@@ -309,9 +320,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) @@ -167,7 +219,7 @@ index 1c2f770..ddcae0f 100644 endif bitcoind_LDADD = \ -@@ -326,9 +345,19 @@ bitcoind_LDADD = \ +@@ -326,10 +346,20 @@ bitcoind_LDADD = \ if ENABLE_WALLET bitcoind_LDADD += libbitcoin_wallet.a @@ -175,18 +227,20 @@ index 1c2f770..ddcae0f 100644 +libbitcoind_la_SOURCES += $(libbitcoin_wallet_a_SOURCES) endif -+MEMOBJ = helpers/memenv/memenv.lo -+$(MEMOBJ): -+ @echo "Building the Memenv shared library..." && $(MAKE) -C ./leveldb $@ ++STATIC_BOOST_LIBS += ../depends/$(ARCH_PLATFORM)/lib/libboost_filesystem-mt.a ../depends/$(ARCH_PLATFORM)/lib/libboost_system-mt.a ../depends/$(ARCH_PLATFORM)/lib/libboost_chrono-mt.a ../depends/$(ARCH_PLATFORM)/lib/libboost_thread-mt.a ../depends/$(ARCH_PLATFORM)/lib/libboost_program_options-mt.a + 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 += $(SSL_LIBS) $(LIBSECP256K1) $(CRYPTO_LIBS) $(LIBLEVELDB) $(LIBMEMENV) $(STATIC_BOOST_LIBS) +libbitcoind_la_CPPFLAGS = $(BITCOIN_INCLUDES) -+libbitcoind_la_LDFLAGS = -lleveldb -L./leveldb $(RELDFLAGS) -no-undefined -+libbitcoind_la_DEPENDENCIES = $(LIBSECP256K1) LIBLEVELDB_SHARED $(MEMOBJ) - # ++if TARGET_DARWIN ++libbitcoind_la_LDFLAGS += -Wl,-all_load ++else ++libbitcoind_la_LDFLAGS += -Wl,--whole-archive $(BOOST_LIBS) -Wl,--no-whole-archive ++endif # bitcoin-cli binary # + bitcoin_cli_SOURCES = bitcoin-cli.cpp diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index cce687a..0f162ff 100644 --- a/src/bitcoind.cpp @@ -232,28 +286,20 @@ index dcb2b29..5ce68ba 100644 bool ShutdownRequested(); void Shutdown(); diff --git a/src/leveldb/Makefile b/src/leveldb/Makefile -index 2bd2cad..490ba66 100644 +index 2bd2cad..a85d3ca 100644 --- a/src/leveldb/Makefile +++ b/src/leveldb/Makefile -@@ -103,7 +103,7 @@ check: all $(PROGRAMS) $(TESTS) - for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done +@@ -16,10 +16,9 @@ OPT ?= -O2 -DNDEBUG - 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) + # detect what platform we're building on + $(shell CC="$(CC)" CXX="$(CXX)" TARGET_OS="$(TARGET_OS)" \ +- ./build_detect_platform build_config.mk ./) ++ ./build_detect_platform build_config.mk .) + # this file is generated by the previous line to set build flags and sources + include build_config.mk +- + CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT) + CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) diff --git a/src/leveldbwrapper.h b/src/leveldbwrapper.h index c65e842..0e44bb5 100644 diff --git a/platform/os.sh b/platform/os.sh index 11a29804..b6e8afbe 100755 --- a/platform/os.sh +++ b/platform/os.sh @@ -7,9 +7,10 @@ BITCOIN_DIR="${root_dir}/libbitcoind" os= ext=so -boost_dir="${root_dir}"/libbitcoind/depends/x86_64-linux/lib -thread="${boost_dir}"/libboost_thread-mt.so -filesystem="${boost_dir}"/libboost_filesystem.so +host=`uname -m`-`uname -a | awk '{print tolower($1)}'` +boost_dir="${root_dir}"/libbitcoind/depends/${host}/lib +thread="${boost_dir}"/libboost_thread-mt.a +filesystem="${boost_dir}"/libboost_filesystem-mt.a if test -f /etc/centos-release \ || grep -q 'CentOS' /etc/redhat-release \ @@ -24,8 +25,6 @@ elif uname -a | grep -q '^Darwin'; then os=osx ext=dylib boost_dir="${root_dir}"/libbitcoind/depends/x86_64-darwin/lib - thread="${boost_dir}"/libboost_thread-mt.dylib - filesystem="${boost_dir}"/libboost_filesystem.dylib elif test -f /etc/SuSE-release; then os=suse elif test -f /etc/mandrake-release \ @@ -87,6 +86,18 @@ if test -z "$1" -o x"$1" = x'boost_dir'; then echo -n "${boost_dir}" fi +if test -z "$1" -o x"$1" = x'host'; then + echo -n "${host}" +fi + +if test -z "$1" -o x"$1" = x'load_archive'; then + if [ "${os}" == "osx" ]; then + echo -n "-Wl,-all_load" + else + echo -n "-Wl,--whole-archive ${filesystem} ${thread} -Wl,--no-whole-archive" + fi +fi + if test -z "$1" -o x"$1" = x'lib'; then if test -e "${os_dir}/libbitcoind.${ext}" -o -e "${os_dir}/lib/libbitcoind.${ext}"; then if test -e "${os_dir}/lib/libbitcoind.${ext}"; then