Generalized the static building of boost.

This commit is contained in:
Chris Kleeschulte 2015-07-27 14:03:14 -04:00
parent 245422a830
commit 7efa84fa86
4 changed files with 102 additions and 45 deletions

View File

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

3
binding.gyp Normal file → Executable file
View File

@ -33,7 +33,8 @@
'<!(./platform/os.sh lib)'
],
'ldflags': [
'-Wl,-rpath,<!(./platform/os.sh osdir),-rpath,<!(./platform/os.sh btcdir)/src/leveldb,-rpath,<!(./platform/os.sh boost_dir)'
'-Wl,-rpath,<!(./platform/os.sh osdir)',
'<!(./platform/os.sh load_archive)'
]
}
}]

View File

@ -79,31 +79,81 @@ index 37fe47e..83cfe70 100644
LEVELDB_CPPFLAGS=
LIBLEVELDB=
LIBMEMENV=
diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk
old mode 100644
new mode 100755
index e7aa48d..8447e79
--- a/depends/packages/boost.mk
+++ b/depends/packages/boost.mk
@@ -1,9 +1,8 @@
package=boost
-$(package)_version=1_55_0
-$(package)_download_path=http://sourceforge.net/projects/boost/files/boost/1.55.0
+$(package)_version=1_57_0
+$(package)_download_path=http://sourceforge.net/projects/boost/files/boost/1.57.0
$(package)_file_name=$(package)_$($(package)_version).tar.bz2
-$(package)_sha256_hash=fff00023dd79486d444c8e29922f4072e1d451fc5a4d2b6075852ead7f2b7b52
-$(package)_patches=darwin_boost_atomic-1.patch darwin_boost_atomic-2.patch gcc_5_no_cxx11.patch
+$(package)_sha256_hash=910c8c022a33ccec7f088bd65d4f14b466588dda94ba2124e78b8c57db264967
define $(package)_set_vars
$(package)_config_opts_release=variant=release
@@ -11,7 +10,7 @@ $(package)_config_opts_debug=variant=debug
$(package)_config_opts=--layout=tagged --build-type=complete --user-config=user-config.jam
$(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1
$(package)_config_opts_linux=threadapi=pthread runtime-link=shared
-$(package)_config_opts_darwin=--toolset=darwin-4.2.1 runtime-link=shared
+$(package)_config_opts_darwin=--toolset=clang runtime-link=shared
$(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static
$(package)_config_opts_x86_64_mingw32=address-model=64
$(package)_config_opts_i686_mingw32=address-model=32
@@ -20,15 +19,14 @@ $(package)_toolset_$(host_os)=gcc
$(package)_archiver_$(host_os)=$($(package)_ar)
$(package)_toolset_darwin=darwin
$(package)_archiver_darwin=$($(package)_libtool)
-$(package)_config_libraries=chrono,filesystem,program_options,system,thread,test
-$(package)_cxxflags=-fvisibility=hidden
-$(package)_cxxflags_linux=-fPIC
+$(package)_config_libraries=chrono,filesystem,program_options,system,thread
+$(package)_cxxflags=-fvisibility=default -fPIC
+$(package)_cxxflags_darwin=-std=c++11 -stdlib=libc++
+$(package)_linkflags=-stdlib=libc++
endef
+
define $(package)_preprocess_cmds
- patch -p2 < $($(package)_patch_dir)/darwin_boost_atomic-1.patch && \
- patch -p2 < $($(package)_patch_dir)/darwin_boost_atomic-2.patch && \
- patch -p2 < $($(package)_patch_dir)/gcc_5_no_cxx11.patch && \
echo "using $(boost_toolset_$(host_os)) : : $($(package)_cxx) : <cxxflags>\"$($(package)_cxxflags) $($(package)_cppflags)\" <linkflags>\"$($(package)_ldflags)\" <archiver>\"$(boost_archiver_$(host_os))\" <striper>\"$(host_STRIP)\" <ranlib>\"$(host_RANLIB)\" <rc>\"$(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

View File

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