diff --git a/Makefile.am b/Makefile.am index 21d779a4..e3815e53 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,8 +3,16 @@ ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = \ COPYING -SUBDIRS = src/leveldb -LEVELDB_LIB = src/leveldb/libleveldb.a src/leveldb/libmemenv.a +LIBLEVELDB = src/leveldb/libleveldb.a +LIBMEMENV = src/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) + +$(LIBLEVELDB) $(LIBMEMENV): + @echo "Building LevelDB ..." && $(MAKE) -C $(@D) $(@F) CXX="$(CXX)" \ + CC="$(CC)" PLATFORM=$(TARGET_OS) AR="$(AR)" $(LEVELDB_TARGET_FLAGS) \ + OPT="$(CXXFLAGS) $(CPPFLAGS)" bin_PROGRAMS = twisterd @@ -166,9 +174,9 @@ twisterd_SOURCES = $(LIBTORRENT_SOURCES) $(BITCOIN_TWISTER_SOURCES) twisterd_LDFLAGS = @OPENSSL_LDFLAGS@ @DB_CXX_LDFLAGS@ -twisterd_DEPENDENCIES = $(LEVELDB_LIB) +twisterd_DEPENDENCIES = $(LIBLEVELDB) $(LIBMEMENV) -twisterd_LDADD = $(LEVELDB_LIB) \ +twisterd_LDADD = $(LIBLEVELDB) $(LIBMEMENV) \ @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_PROGRAM_OPTIONS_LIB@ @BOOST_THREAD_LIB@ @BOOST_CHRONO_LIB@ @BOOST_LOCALE_LIB@ \ @BOOST_REGEX_LIB@ @DB_CXX_LIBS@ @OPENSSL_LIBS@ @@ -179,3 +187,9 @@ AM_CPPFLAGS = -ftemplate-depth-100 -DBOOST_SPIRIT_THREADSAFE -D_FILE_OFFSET_BITS @DEBUGFLAGS@ @OPENSSL_INCLUDES@ @DB_CXX_CPPFLAGS@ AM_LDFLAGS = @OPENSSL_LDFLAGS@ + +CLEANFILES = $(LIBLEVELDB) $(LIBMEMENV) + +clean-local: + -$(MAKE) -C src/leveldb clean + rm -f src/leveldb/*/*.gcno src/leveldb/helpers/memenv/*.gcno diff --git a/configure.ac b/configure.ac index 9ac392b3..d6634f9a 100644 --- a/configure.ac +++ b/configure.ac @@ -51,6 +51,82 @@ AS_ECHO "Initializing Libtool:" LT_PREREQ([2.2.6]) LT_INIT +# host checks from bitcoin's configure.ac +case $host in + *mingw*) + TARGET_OS=windows + AC_CHECK_LIB([mingwthrd], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([kernel32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([user32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([gdi32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([comdlg32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([winspool], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([winmm], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([shell32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([comctl32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([ole32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([oleaut32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([uuid], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([rpcrt4], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([advapi32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([ws2_32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([mswsock], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([shlwapi], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([iphlpapi], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([crypt32], [main],, AC_MSG_ERROR(lib missing)) + + CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB" + LEVELDB_TARGET_FLAGS="TARGET_OS=OS_WINDOWS_CROSSCOMPILE" + if test "x$CXXFLAGS_overridden" = "xno"; then + CXXFLAGS="$CXXFLAGS -w" + fi + case $host in + i?86-*) WINDOWS_BITS=32 ;; + x86_64-*) WINDOWS_BITS=64 ;; + *) AC_MSG_ERROR("Could not determine win32/win64 for installer") ;; + esac + AC_SUBST(WINDOWS_BITS) + ;; + *darwin*) + TARGET_OS=darwin + LEVELDB_TARGET_FLAGS="TARGET_OS=Darwin" + if test x$cross_compiling != xyes; then + BUILD_OS=darwin + AC_CHECK_PROG([PORT],port, port) + if test x$PORT = xport; then + dnl add default macports paths + CPPFLAGS="$CPPFLAGS -isystem /opt/local/include -I/opt/local/include/db48" + LIBS="$LIBS -L/opt/local/lib -L/opt/local/lib/db48" + fi + + AC_CHECK_PROG([BREW],brew, brew) + if test x$BREW = xbrew; then + dnl add default homebrew paths + openssl_prefix=`$BREW --prefix openssl` + bdb_prefix=`$BREW --prefix berkeley-db4` + export PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH" + CPPFLAGS="$CPPFLAGS -I$bdb_prefix/include" + LIBS="$LIBS -L$bdb_prefix/lib" + fi + else + case $build_os in + *darwin*) + BUILD_OS=darwin + ;; + *) + AC_PATH_TOOL([INSTALLNAMETOOL], [install_name_tool], install_name_tool) + AC_PATH_TOOL([OTOOL], [otool], otool) + AC_PATH_PROGS([GENISOIMAGE], [genisoimage mkisofs],genisoimage) + ;; + esac + fi + + CPPFLAGS="$CPPFLAGS -DMAC_OSX" + ;; + *) + ;; +esac + ############################################################################### # Checking for needed base libraries @@ -659,6 +735,7 @@ AS_IF([test "x$enable_shared" = "xyes"], AC_SUBST(DEBUGFLAGS) AC_SUBST(PYTHON_INSTALL_PARAMS) AC_SUBST(COMPILETIME_OPTIONS) +AC_SUBST(LEVELDB_TARGET_FLAGS) # Try to guess real svn revision if any, fallback to hardcoded otherwise