小组成员:姚凯文(kevinyao0901),姜嘉琪
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 line
7.4 KiB

  1. # Copyright (c) 2011 The LevelDB Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file. See the AUTHORS file for names of contributors.
  4. #-----------------------------------------------
  5. # Uncomment exactly one of the lines labelled (A), (B), and (C) below
  6. # to switch between compilation modes.
  7. OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode)
  8. # OPT ?= -g2 # (B) Debug mode, w/ full line-level debugging symbols
  9. # OPT ?= -O2 -g2 -DNDEBUG # (C) Profiling mode: opt, but w/debugging symbols
  10. #-----------------------------------------------
  11. # detect what platform we're building on
  12. $(shell CC="$(CC)" CXX="$(CXX)" TARGET_OS="$(TARGET_OS)" \
  13. ./build_detect_platform build_config.mk ./)
  14. # this file is generated by the previous line to set build flags and sources
  15. include build_config.mk
  16. CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
  17. CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
  18. LDFLAGS += $(PLATFORM_LDFLAGS)
  19. LIBS += $(PLATFORM_LIBS)
  20. LIBOBJECTS = $(SOURCES:.cc=.o)
  21. MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)
  22. TESTUTIL = ./util/testutil.o
  23. TESTHARNESS = ./util/testharness.o $(TESTUTIL)
  24. TESTS = \
  25. arena_test \
  26. bloom_test \
  27. c_test \
  28. cache_test \
  29. coding_test \
  30. corruption_test \
  31. crc32c_test \
  32. db_test \
  33. dbformat_test \
  34. env_test \
  35. filename_test \
  36. filter_block_test \
  37. issue178_test \
  38. log_test \
  39. memenv_test \
  40. skiplist_test \
  41. table_test \
  42. version_edit_test \
  43. version_set_test \
  44. write_batch_test
  45. PROGRAMS = db_bench leveldbutil $(TESTS)
  46. BENCHMARKS = db_bench_sqlite3 db_bench_tree_db
  47. LIBRARY = libleveldb.a
  48. MEMENVLIBRARY = libmemenv.a
  49. default: all
  50. # Should we build shared libraries?
  51. ifneq ($(PLATFORM_SHARED_EXT),)
  52. ifneq ($(PLATFORM_SHARED_VERSIONED),true)
  53. SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
  54. SHARED2 = $(SHARED1)
  55. SHARED3 = $(SHARED1)
  56. SHARED = $(SHARED1)
  57. else
  58. # Update db.h if you change these.
  59. SHARED_MAJOR = 1
  60. SHARED_MINOR = 11
  61. SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
  62. SHARED2 = $(SHARED1).$(SHARED_MAJOR)
  63. SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR)
  64. SHARED = $(SHARED1) $(SHARED2) $(SHARED3)
  65. $(SHARED1): $(SHARED3)
  66. ln -fs $(SHARED3) $(SHARED1)
  67. $(SHARED2): $(SHARED3)
  68. ln -fs $(SHARED3) $(SHARED2)
  69. endif
  70. $(SHARED3):
  71. $(CXX) $(LDFLAGS) $(PLATFORM_SHARED_LDFLAGS)$(SHARED2) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(SOURCES) -o $(SHARED3) $(LIBS)
  72. endif # PLATFORM_SHARED_EXT
  73. all: $(SHARED) $(LIBRARY)
  74. check: all $(PROGRAMS) $(TESTS)
  75. for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
  76. clean:
  77. -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk
  78. -rm -rf ios-x86/* ios-arm/*
  79. $(LIBRARY): $(LIBOBJECTS)
  80. rm -f $@
  81. $(AR) -rs $@ $(LIBOBJECTS)
  82. db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
  83. $(CXX) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LIBS)
  84. db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL)
  85. $(CXX) $(LDFLAGS) doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lsqlite3 $(LIBS)
  86. db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL)
  87. $(CXX) $(LDFLAGS) doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lkyotocabinet $(LIBS)
  88. leveldbutil: db/leveldb_main.o $(LIBOBJECTS)
  89. $(CXX) $(LDFLAGS) db/leveldb_main.o $(LIBOBJECTS) -o $@ $(LIBS)
  90. arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
  91. $(CXX) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  92. bloom_test: util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS)
  93. $(CXX) $(LDFLAGS) util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  94. c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  95. $(CXX) $(LDFLAGS) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  96. cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
  97. $(CXX) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  98. coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
  99. $(CXX) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  100. corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
  101. $(CXX) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  102. crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  103. $(CXX) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  104. db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
  105. $(CXX) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  106. dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
  107. $(CXX) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  108. env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
  109. $(CXX) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  110. filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
  111. $(CXX) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  112. filter_block_test: table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS)
  113. $(CXX) $(LDFLAGS) table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  114. issue178_test: issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS)
  115. $(CXX) $(LDFLAGS) issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  116. log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
  117. $(CXX) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  118. table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
  119. $(CXX) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  120. skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
  121. $(CXX) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  122. version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
  123. $(CXX) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  124. version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
  125. $(CXX) $(LDFLAGS) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  126. write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
  127. $(CXX) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  128. $(MEMENVLIBRARY) : $(MEMENVOBJECTS)
  129. rm -f $@
  130. $(AR) -rs $@ $(MEMENVOBJECTS)
  131. memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS)
  132. $(CXX) $(LDFLAGS) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@ $(LIBS)
  133. ifeq ($(PLATFORM), IOS)
  134. # For iOS, create universal object files to be used on both the simulator and
  135. # a device.
  136. PLATFORMSROOT=/Applications/Xcode.app/Contents/Developer/Platforms
  137. SIMULATORROOT=$(PLATFORMSROOT)/iPhoneSimulator.platform/Developer
  138. DEVICEROOT=$(PLATFORMSROOT)/iPhoneOS.platform/Developer
  139. IOSVERSION=$(shell defaults read $(PLATFORMSROOT)/iPhoneOS.platform/version CFBundleShortVersionString)
  140. .cc.o:
  141. mkdir -p ios-x86/$(dir $@)
  142. $(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
  143. mkdir -p ios-arm/$(dir $@)
  144. $(DEVICEROOT)/usr/bin/$(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
  145. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  146. .c.o:
  147. mkdir -p ios-x86/$(dir $@)
  148. $(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
  149. mkdir -p ios-arm/$(dir $@)
  150. $(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
  151. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  152. else
  153. .cc.o:
  154. $(CXX) $(CXXFLAGS) -c $< -o $@
  155. .c.o:
  156. $(CC) $(CFLAGS) -c $< -o $@
  157. endif