2011-03-19 06:37:00 +08:00
|
|
|
# Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
|
2011-06-02 08:00:37 +08:00
|
|
|
#-----------------------------------------------
|
|
|
|
# Uncomment exactly one of the lines labelled (A), (B), and (C) below
|
|
|
|
# to switch between compilation modes.
|
|
|
|
|
2014-09-17 05:19:52 +08:00
|
|
|
# (A) Production use (optimized mode)
|
|
|
|
OPT ?= -O2 -DNDEBUG
|
|
|
|
# (B) Debug mode, w/ full line-level debugging symbols
|
|
|
|
# OPT ?= -g2
|
|
|
|
# (C) Profiling mode: opt, but w/debugging symbols
|
|
|
|
# OPT ?= -O2 -g2 -DNDEBUG
|
2011-06-02 08:00:37 +08:00
|
|
|
#-----------------------------------------------
|
|
|
|
|
2011-06-29 08:30:50 +08:00
|
|
|
# detect what platform we're building on
|
2013-05-15 07:52:56 +08:00
|
|
|
$(shell CC="$(CC)" CXX="$(CXX)" TARGET_OS="$(TARGET_OS)" \
|
2012-10-13 02:53:12 +08:00
|
|
|
./build_detect_platform build_config.mk ./)
|
2012-04-17 23:36:46 +08:00
|
|
|
# this file is generated by the previous line to set build flags and sources
|
2011-06-29 08:30:50 +08:00
|
|
|
include build_config.mk
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2012-03-31 04:15:49 +08:00
|
|
|
CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
|
|
|
|
CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
|
2011-06-29 08:30:50 +08:00
|
|
|
|
2012-03-22 01:28:03 +08:00
|
|
|
LDFLAGS += $(PLATFORM_LDFLAGS)
|
2012-10-17 07:17:53 +08:00
|
|
|
LIBS += $(PLATFORM_LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2012-03-22 01:28:03 +08:00
|
|
|
LIBOBJECTS = $(SOURCES:.cc=.o)
|
|
|
|
MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
TESTUTIL = ./util/testutil.o
|
|
|
|
TESTHARNESS = ./util/testharness.o $(TESTUTIL)
|
|
|
|
|
2014-09-17 05:19:52 +08:00
|
|
|
# Note: iOS should probably be using libtool, not ar.
|
|
|
|
ifeq ($(PLATFORM), IOS)
|
|
|
|
AR=xcrun ar
|
|
|
|
endif
|
|
|
|
|
2011-03-19 06:37:00 +08:00
|
|
|
TESTS = \
|
|
|
|
arena_test \
|
2013-08-22 02:12:47 +08:00
|
|
|
autocompact_test \
|
2012-04-17 23:36:46 +08:00
|
|
|
bloom_test \
|
2011-08-06 04:40:49 +08:00
|
|
|
c_test \
|
2011-03-19 06:37:00 +08:00
|
|
|
cache_test \
|
|
|
|
coding_test \
|
|
|
|
corruption_test \
|
|
|
|
crc32c_test \
|
|
|
|
db_test \
|
|
|
|
dbformat_test \
|
|
|
|
env_test \
|
2014-12-11 23:59:38 +08:00
|
|
|
fault_injection_test \
|
2011-03-19 06:37:00 +08:00
|
|
|
filename_test \
|
2012-04-17 23:36:46 +08:00
|
|
|
filter_block_test \
|
2014-09-17 05:19:52 +08:00
|
|
|
hash_test \
|
2013-06-14 07:14:06 +08:00
|
|
|
issue178_test \
|
2013-09-20 04:42:22 +08:00
|
|
|
issue200_test \
|
2011-03-19 06:37:00 +08:00
|
|
|
log_test \
|
2011-09-12 17:21:10 +08:00
|
|
|
memenv_test \
|
2014-12-12 00:13:18 +08:00
|
|
|
recovery_test \
|
2011-03-19 06:37:00 +08:00
|
|
|
skiplist_test \
|
|
|
|
table_test \
|
|
|
|
version_edit_test \
|
2011-06-22 10:36:45 +08:00
|
|
|
version_set_test \
|
2011-03-19 06:37:00 +08:00
|
|
|
write_batch_test
|
|
|
|
|
2012-12-28 02:38:48 +08:00
|
|
|
PROGRAMS = db_bench leveldbutil $(TESTS)
|
2011-07-27 09:46:25 +08:00
|
|
|
BENCHMARKS = db_bench_sqlite3 db_bench_tree_db
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2011-05-28 08:53:58 +08:00
|
|
|
LIBRARY = libleveldb.a
|
2011-09-12 17:21:10 +08:00
|
|
|
MEMENVLIBRARY = libmemenv.a
|
2011-05-28 08:53:58 +08:00
|
|
|
|
2012-03-31 04:15:49 +08:00
|
|
|
default: all
|
|
|
|
|
|
|
|
# Should we build shared libraries?
|
|
|
|
ifneq ($(PLATFORM_SHARED_EXT),)
|
2012-05-31 00:45:46 +08:00
|
|
|
|
|
|
|
ifneq ($(PLATFORM_SHARED_VERSIONED),true)
|
|
|
|
SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
|
|
|
|
SHARED2 = $(SHARED1)
|
|
|
|
SHARED3 = $(SHARED1)
|
|
|
|
SHARED = $(SHARED1)
|
|
|
|
else
|
2012-03-31 04:15:49 +08:00
|
|
|
# Update db.h if you change these.
|
|
|
|
SHARED_MAJOR = 1
|
2014-09-17 05:19:52 +08:00
|
|
|
SHARED_MINOR = 18
|
2012-03-31 04:15:49 +08:00
|
|
|
SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
|
|
|
|
SHARED2 = $(SHARED1).$(SHARED_MAJOR)
|
|
|
|
SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR)
|
|
|
|
SHARED = $(SHARED1) $(SHARED2) $(SHARED3)
|
|
|
|
$(SHARED1): $(SHARED3)
|
|
|
|
ln -fs $(SHARED3) $(SHARED1)
|
2012-05-31 00:45:46 +08:00
|
|
|
$(SHARED2): $(SHARED3)
|
|
|
|
ln -fs $(SHARED3) $(SHARED2)
|
2012-03-31 04:15:49 +08:00
|
|
|
endif
|
|
|
|
|
2012-05-31 00:45:46 +08:00
|
|
|
$(SHARED3):
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) $(PLATFORM_SHARED_LDFLAGS)$(SHARED2) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(SOURCES) -o $(SHARED3) $(LIBS)
|
2012-05-31 00:45:46 +08:00
|
|
|
|
|
|
|
endif # PLATFORM_SHARED_EXT
|
|
|
|
|
2012-03-31 04:15:49 +08:00
|
|
|
all: $(SHARED) $(LIBRARY)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2012-03-31 04:15:49 +08:00
|
|
|
check: all $(PROGRAMS) $(TESTS)
|
2011-03-19 06:37:00 +08:00
|
|
|
for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
|
|
|
|
|
|
|
|
clean:
|
2012-03-31 04:15:49 +08:00
|
|
|
-rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk
|
2011-06-29 08:30:50 +08:00
|
|
|
-rm -rf ios-x86/* ios-arm/*
|
2011-05-28 08:53:58 +08:00
|
|
|
|
|
|
|
$(LIBRARY): $(LIBOBJECTS)
|
|
|
|
rm -f $@
|
|
|
|
$(AR) -rs $@ $(LIBOBJECTS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2011-07-27 09:46:25 +08:00
|
|
|
db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lsqlite3 $(LIBS)
|
2011-07-27 09:46:25 +08:00
|
|
|
|
|
|
|
db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lkyotocabinet $(LIBS)
|
2011-07-27 09:46:25 +08:00
|
|
|
|
2012-12-28 02:38:48 +08:00
|
|
|
leveldbutil: db/leveldb_main.o $(LIBOBJECTS)
|
|
|
|
$(CXX) $(LDFLAGS) db/leveldb_main.o $(LIBOBJECTS) -o $@ $(LIBS)
|
|
|
|
|
2011-03-19 06:37:00 +08:00
|
|
|
arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2013-08-22 02:12:47 +08:00
|
|
|
|
|
|
|
autocompact_test: db/autocompact_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
|
|
|
$(CXX) $(LDFLAGS) db/autocompact_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2012-04-17 23:36:46 +08:00
|
|
|
bloom_test: util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2012-04-17 23:36:46 +08:00
|
|
|
|
2011-08-06 04:40:49 +08:00
|
|
|
c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-08-06 04:40:49 +08:00
|
|
|
|
2011-03-19 06:37:00 +08:00
|
|
|
cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2014-12-11 23:59:38 +08:00
|
|
|
fault_injection_test: db/fault_injection_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
|
|
|
$(CXX) $(LDFLAGS) db/fault_injection_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
|
|
|
|
2011-03-19 06:37:00 +08:00
|
|
|
filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2012-04-17 23:36:46 +08:00
|
|
|
filter_block_test: table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2012-04-17 23:36:46 +08:00
|
|
|
|
2014-09-17 05:19:52 +08:00
|
|
|
hash_test: util/hash_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
|
|
|
$(CXX) $(LDFLAGS) util/hash_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
|
|
|
|
2013-06-14 07:14:06 +08:00
|
|
|
issue178_test: issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
|
|
|
$(CXX) $(LDFLAGS) issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
|
|
|
|
2013-09-20 04:42:22 +08:00
|
|
|
issue200_test: issues/issue200_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
|
|
|
$(CXX) $(LDFLAGS) issues/issue200_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
|
|
|
|
2011-03-19 06:37:00 +08:00
|
|
|
log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2014-12-12 00:13:18 +08:00
|
|
|
recovery_test: db/recovery_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
|
|
|
$(CXX) $(LDFLAGS) db/recovery_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
|
|
|
|
2011-03-19 06:37:00 +08:00
|
|
|
table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2011-06-22 10:36:45 +08:00
|
|
|
version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-06-22 10:36:45 +08:00
|
|
|
|
2011-03-19 06:37:00 +08:00
|
|
|
write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2012-03-22 01:28:03 +08:00
|
|
|
$(MEMENVLIBRARY) : $(MEMENVOBJECTS)
|
2011-09-12 17:21:10 +08:00
|
|
|
rm -f $@
|
2012-03-22 01:28:03 +08:00
|
|
|
$(AR) -rs $@ $(MEMENVOBJECTS)
|
2011-09-12 17:21:10 +08:00
|
|
|
|
|
|
|
memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS)
|
2012-10-17 07:17:53 +08:00
|
|
|
$(CXX) $(LDFLAGS) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@ $(LIBS)
|
2011-09-12 17:21:10 +08:00
|
|
|
|
2011-05-28 08:53:58 +08:00
|
|
|
ifeq ($(PLATFORM), IOS)
|
|
|
|
# For iOS, create universal object files to be used on both the simulator and
|
|
|
|
# a device.
|
2015-10-07 22:21:59 +08:00
|
|
|
SIMULATORSDK=$(shell xcrun -sdk iphonesimulator --show-sdk-path)
|
|
|
|
DEVICESDK=$(shell xcrun -sdk iphoneos --show-sdk-path)
|
2014-05-02 04:43:12 +08:00
|
|
|
IOSARCH=-arch armv6 -arch armv7 -arch armv7s -arch arm64
|
2011-06-30 06:53:17 +08:00
|
|
|
|
2011-05-28 08:53:58 +08:00
|
|
|
.cc.o:
|
|
|
|
mkdir -p ios-x86/$(dir $@)
|
2015-10-07 22:21:59 +08:00
|
|
|
xcrun -sdk iphonesimulator $(CXX) $(CXXFLAGS) -isysroot "$(SIMULATORSDK)" -arch i686 -arch x86_64 -c $< -o ios-x86/$@
|
2011-05-28 08:53:58 +08:00
|
|
|
mkdir -p ios-arm/$(dir $@)
|
2015-10-07 22:21:59 +08:00
|
|
|
xcrun -sdk iphoneos $(CXX) $(CXXFLAGS) -isysroot "$(DEVICESDK)" $(IOSARCH) -c $< -o ios-arm/$@
|
2014-09-17 05:19:52 +08:00
|
|
|
xcrun lipo ios-x86/$@ ios-arm/$@ -create -output $@
|
2011-08-06 04:40:49 +08:00
|
|
|
|
|
|
|
.c.o:
|
|
|
|
mkdir -p ios-x86/$(dir $@)
|
2015-10-07 22:21:59 +08:00
|
|
|
xcrun -sdk iphonesimulator $(CC) $(CFLAGS) -isysroot "$(SIMULATORSDK)" -arch i686 -arch x86_64 -c $< -o ios-x86/$@
|
2011-08-06 04:40:49 +08:00
|
|
|
mkdir -p ios-arm/$(dir $@)
|
2015-10-07 22:21:59 +08:00
|
|
|
xcrun -sdk iphoneos $(CC) $(CFLAGS) -isysroot "$(DEVICESDK)" $(IOSARCH) -c $< -o ios-arm/$@
|
2014-09-17 05:19:52 +08:00
|
|
|
xcrun lipo ios-x86/$@ ios-arm/$@ -create -output $@
|
2011-08-06 04:40:49 +08:00
|
|
|
|
2011-05-28 08:53:58 +08:00
|
|
|
else
|
2011-03-19 06:37:00 +08:00
|
|
|
.cc.o:
|
2012-03-31 04:15:49 +08:00
|
|
|
$(CXX) $(CXXFLAGS) -c $< -o $@
|
2011-08-06 04:40:49 +08:00
|
|
|
|
|
|
|
.c.o:
|
2012-03-31 04:15:49 +08:00
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
2011-05-28 08:53:58 +08:00
|
|
|
endif
|