Skip to content

Commit 351abf9

Browse files
committed
Merge #7911: leveldb: integrate leveldb into our buildsystem
a4625ac leveldb: integrate leveldb into our buildsystem (Cory Fields)
2 parents 90653bc + a4625ac commit 351abf9

File tree

3 files changed

+106
-19
lines changed

3 files changed

+106
-19
lines changed

configure.ac

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ case $host in
267267
fi
268268

269269
CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB"
270-
LEVELDB_TARGET_FLAGS="TARGET_OS=OS_WINDOWS_CROSSCOMPILE"
270+
LEVELDB_TARGET_FLAGS="-DOS_WINDOWS"
271271
if test "x$CXXFLAGS_overridden" = "xno"; then
272272
CXXFLAGS="$CXXFLAGS -w"
273273
fi
@@ -289,7 +289,7 @@ case $host in
289289
;;
290290
*darwin*)
291291
TARGET_OS=darwin
292-
LEVELDB_TARGET_FLAGS="TARGET_OS=Darwin"
292+
LEVELDB_TARGET_FLAGS="-DOS_MACOSX"
293293
if test x$cross_compiling != xyes; then
294294
BUILD_OS=darwin
295295
AC_CHECK_PROG([PORT],port, port)
@@ -354,9 +354,11 @@ case $host in
354354
OBJCXXFLAGS="$CXXFLAGS"
355355
;;
356356
*linux*)
357-
TARGET_OS=linux
357+
LEVELDB_TARGET_FLAGS="-DOS_LINUX"
358358
;;
359359
*)
360+
OTHER_OS=`echo ${host_os} | awk '{print toupper($0)}'`
361+
LEVELDB_TARGET_FLAGS="-DOS_${OTHER_OS}"
360362
;;
361363
esac
362364

@@ -541,6 +543,18 @@ if test x$use_reduce_exports = xyes; then
541543
[AC_MSG_ERROR([Cannot set default symbol visibility. Use --disable-reduce-exports.])])
542544
fi
543545

546+
dnl This can go away when we require c++11
547+
TEMP_CXXFLAGS="$CXXFLAGS"
548+
CXXFLAGS="$CXXFLAGS -std=c++0x"
549+
AC_MSG_CHECKING(for c++11 atomics)
550+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
551+
#include <atomic>
552+
]],[[]])],
553+
[ AC_MSG_RESULT(yes); LEVELDB_ATOMIC_CPPFLAGS="-DLEVELDB_ATOMIC_PRESENT"; LEVELDB_ATOMIC_CXXFLAGS="-std=c++0x"],
554+
[ AC_MSG_RESULT(no)]
555+
)
556+
CXXFLAGS="$TEMP_CXXFLAGS"
557+
544558
LEVELDB_CPPFLAGS=
545559
LIBLEVELDB=
546560
LIBMEMENV=
@@ -1043,6 +1057,8 @@ AC_SUBST(TESTDEFS)
10431057
AC_SUBST(LEVELDB_TARGET_FLAGS)
10441058
AC_SUBST(MINIUPNPC_CPPFLAGS)
10451059
AC_SUBST(MINIUPNPC_LIBS)
1060+
AC_SUBST(LEVELDB_ATOMIC_CPPFLAGS)
1061+
AC_SUBST(LEVELDB_ATOMIC_CXXFLAGS)
10461062
AC_CONFIG_FILES([Makefile src/Makefile share/setup.nsi share/qt/Info.plist src/test/buildenv.py])
10471063
AC_CONFIG_FILES([qa/pull-tester/run-bitcoind-for-test.sh],[chmod +x qa/pull-tester/run-bitcoind-for-test.sh])
10481064
AC_CONFIG_FILES([qa/pull-tester/tests_config.py],[chmod +x qa/pull-tester/tests_config.py])

src/Makefile.am

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ DIST_SUBDIRS = secp256k1 univalue
33
AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS)
44
AM_CXXFLAGS = $(HARDENED_CXXFLAGS)
55
AM_CPPFLAGS = $(HARDENED_CPPFLAGS)
6+
EXTRA_LIBRARIES =
67

78
if EMBEDDED_UNIVALUE
89
LIBUNIVALUE = univalue/libunivalue.la
@@ -13,21 +14,6 @@ else
1314
LIBUNIVALUE = $(UNIVALUE_LIBS)
1415
endif
1516

16-
if EMBEDDED_LEVELDB
17-
LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/include
18-
LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/helpers/memenv
19-
LIBLEVELDB += $(builddir)/leveldb/libleveldb.a
20-
LIBMEMENV += $(builddir)/leveldb/libmemenv.a
21-
22-
# 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
23-
$(LIBLEVELDB): $(LIBMEMENV)
24-
25-
$(LIBLEVELDB) $(LIBMEMENV):
26-
@echo "Building LevelDB ..." && $(MAKE) -C $(@D) $(@F) CXX="$(CXX)" \
27-
CC="$(CC)" PLATFORM=$(TARGET_OS) AR="$(AR)" $(LEVELDB_TARGET_FLAGS) \
28-
OPT="$(AM_CXXFLAGS) $(PIE_FLAGS) $(CXXFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -D__STDC_LIMIT_MACROS"
29-
endif
30-
3117
BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config
3218
BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS)
3319

@@ -49,7 +35,7 @@ $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*)
4935

5036
# Make is not made aware of per-object dependencies to avoid limiting building parallelization
5137
# But to build the less dependent modules first, we manually select their order here:
52-
EXTRA_LIBRARIES = \
38+
EXTRA_LIBRARIES += \
5339
crypto/libbitcoin_crypto.a \
5440
libbitcoin_util.a \
5541
libbitcoin_common.a \
@@ -482,6 +468,10 @@ endif
482468
@test -f $(PROTOC)
483469
$(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(<D) $<
484470

471+
if EMBEDDED_LEVELDB
472+
include Makefile.leveldb.include
473+
endif
474+
485475
if ENABLE_TESTS
486476
include Makefile.test.include
487477
endif

src/Makefile.leveldb.include

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
LIBLEVELDB_INT = leveldb/libleveldb.a
2+
LIBMEMENV_INT = leveldb/libmemenv.a
3+
4+
EXTRA_LIBRARIES += $(LIBLEVELDB_INT)
5+
EXTRA_LIBRARIES += $(LIBMEMENV_INT)
6+
7+
LIBLEVELDB += $(LIBLEVELDB_INT)
8+
LIBMEMENV += $(LIBMEMENV_INT)
9+
10+
LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/include
11+
LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/helpers/memenv
12+
13+
LEVELDB_CPPFLAGS_INT =
14+
LEVELDB_CPPFLAGS_INT += -I$(srcdir)/leveldb
15+
LEVELDB_CPPFLAGS_INT += $(LEVELDB_TARGET_FLAGS)
16+
LEVELDB_CPPFLAGS_INT += $(LEVELDB_ATOMIC_CPPFLAGS)
17+
LEVELDB_CPPFLAGS_INT += -D__STDC_LIMIT_MACROS
18+
19+
if TARGET_WINDOWS
20+
LEVELDB_CPPFLAGS_INT += -DLEVELDB_PLATFORM_WINDOWS -DWINVER=0x0500 -D__USE_MINGW_ANSI_STDIO=1
21+
else
22+
LEVELDB_CPPFLAGS_INT += -DLEVELDB_PLATFORM_POSIX
23+
endif
24+
25+
LEVELDB_CXXFLAGS_INT =
26+
LEVELDB_CXXFLAGS_INT += $(LEVELDB_ATOMIC_CXXFLAGS)
27+
28+
leveldb_libleveldb_a_CPPFLAGS = $(AM_CPPFLAGS) $(LEVELDB_CPPFLAGS_INT) $(LEVELDB_CPPFLAGS)
29+
leveldb_libleveldb_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) $(LEVELDB_CXXFLAGS_INT)
30+
31+
leveldb_libleveldb_a_SOURCES=
32+
leveldb_libleveldb_a_SOURCES += leveldb/db/builder.cc
33+
leveldb_libleveldb_a_SOURCES += leveldb/db/c.cc
34+
leveldb_libleveldb_a_SOURCES += leveldb/db/dbformat.cc
35+
leveldb_libleveldb_a_SOURCES += leveldb/db/db_impl.cc
36+
leveldb_libleveldb_a_SOURCES += leveldb/db/db_iter.cc
37+
leveldb_libleveldb_a_SOURCES += leveldb/db/dumpfile.cc
38+
leveldb_libleveldb_a_SOURCES += leveldb/db/filename.cc
39+
leveldb_libleveldb_a_SOURCES += leveldb/db/log_reader.cc
40+
leveldb_libleveldb_a_SOURCES += leveldb/db/log_writer.cc
41+
leveldb_libleveldb_a_SOURCES += leveldb/db/memtable.cc
42+
leveldb_libleveldb_a_SOURCES += leveldb/db/repair.cc
43+
leveldb_libleveldb_a_SOURCES += leveldb/db/table_cache.cc
44+
leveldb_libleveldb_a_SOURCES += leveldb/db/version_edit.cc
45+
leveldb_libleveldb_a_SOURCES += leveldb/db/version_set.cc
46+
leveldb_libleveldb_a_SOURCES += leveldb/db/write_batch.cc
47+
leveldb_libleveldb_a_SOURCES += leveldb/table/block_builder.cc
48+
leveldb_libleveldb_a_SOURCES += leveldb/table/block.cc
49+
leveldb_libleveldb_a_SOURCES += leveldb/table/filter_block.cc
50+
leveldb_libleveldb_a_SOURCES += leveldb/table/format.cc
51+
leveldb_libleveldb_a_SOURCES += leveldb/table/iterator.cc
52+
leveldb_libleveldb_a_SOURCES += leveldb/table/merger.cc
53+
leveldb_libleveldb_a_SOURCES += leveldb/table/table_builder.cc
54+
leveldb_libleveldb_a_SOURCES += leveldb/table/table.cc
55+
leveldb_libleveldb_a_SOURCES += leveldb/table/two_level_iterator.cc
56+
leveldb_libleveldb_a_SOURCES += leveldb/util/arena.cc
57+
leveldb_libleveldb_a_SOURCES += leveldb/util/bloom.cc
58+
leveldb_libleveldb_a_SOURCES += leveldb/util/cache.cc
59+
leveldb_libleveldb_a_SOURCES += leveldb/util/coding.cc
60+
leveldb_libleveldb_a_SOURCES += leveldb/util/comparator.cc
61+
leveldb_libleveldb_a_SOURCES += leveldb/util/crc32c.cc
62+
leveldb_libleveldb_a_SOURCES += leveldb/util/env.cc
63+
leveldb_libleveldb_a_SOURCES += leveldb/util/env_posix.cc
64+
leveldb_libleveldb_a_SOURCES += leveldb/util/env_win.cc
65+
leveldb_libleveldb_a_SOURCES += leveldb/util/filter_policy.cc
66+
leveldb_libleveldb_a_SOURCES += leveldb/util/hash.cc
67+
leveldb_libleveldb_a_SOURCES += leveldb/util/histogram.cc
68+
leveldb_libleveldb_a_SOURCES += leveldb/util/logging.cc
69+
leveldb_libleveldb_a_SOURCES += leveldb/util/options.cc
70+
leveldb_libleveldb_a_SOURCES += leveldb/util/status.cc
71+
72+
if TARGET_WINDOWS
73+
leveldb_libleveldb_a_SOURCES += leveldb/util/env_win.cc
74+
leveldb_libleveldb_a_SOURCES += leveldb/port/port_win.cc
75+
else
76+
leveldb_libleveldb_a_SOURCES += leveldb/port/port_posix.cc
77+
endif
78+
79+
leveldb_libmemenv_a_CPPFLAGS = $(leveldb_libleveldb_a_CPPFLAGS)
80+
leveldb_libmemenv_a_CXXFLAGS = $(leveldb_libleveldb_a_CXXFLAGS)
81+
leveldb_libmemenv_a_SOURCES = leveldb/helpers/memenv/memenv.cc

0 commit comments

Comments
 (0)