作者: 谢瑞阳 10225101483 徐翔宇 10225101535
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

202 行
7.3 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. log_test \
  38. memenv_test \
  39. skiplist_test \
  40. table_test \
  41. version_edit_test \
  42. version_set_test \
  43. write_batch_test
  44. PROGRAMS = db_bench leveldbutil $(TESTS)
  45. BENCHMARKS = db_bench_sqlite3 db_bench_tree_db
  46. LIBRARY = libleveldb.a
  47. MEMENVLIBRARY = libmemenv.a
  48. default: all
  49. # Should we build shared libraries?
  50. ifneq ($(PLATFORM_SHARED_EXT),)
  51. ifneq ($(PLATFORM_SHARED_VERSIONED),true)
  52. SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
  53. SHARED2 = $(SHARED1)
  54. SHARED3 = $(SHARED1)
  55. SHARED = $(SHARED1)
  56. else
  57. # Update db.h if you change these.
  58. SHARED_MAJOR = 1
  59. SHARED_MINOR = 9
  60. SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
  61. SHARED2 = $(SHARED1).$(SHARED_MAJOR)
  62. SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR)
  63. SHARED = $(SHARED1) $(SHARED2) $(SHARED3)
  64. $(SHARED1): $(SHARED3)
  65. ln -fs $(SHARED3) $(SHARED1)
  66. $(SHARED2): $(SHARED3)
  67. ln -fs $(SHARED3) $(SHARED2)
  68. endif
  69. $(SHARED3):
  70. $(CXX) $(LDFLAGS) $(PLATFORM_SHARED_LDFLAGS)$(SHARED2) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(SOURCES) -o $(SHARED3) $(LIBS)
  71. endif # PLATFORM_SHARED_EXT
  72. all: $(SHARED) $(LIBRARY)
  73. check: all $(PROGRAMS) $(TESTS)
  74. for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
  75. clean:
  76. -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk
  77. -rm -rf ios-x86/* ios-arm/*
  78. $(LIBRARY): $(LIBOBJECTS)
  79. rm -f $@
  80. $(AR) -rs $@ $(LIBOBJECTS)
  81. db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
  82. $(CXX) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LIBS)
  83. db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL)
  84. $(CXX) $(LDFLAGS) doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lsqlite3 $(LIBS)
  85. db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL)
  86. $(CXX) $(LDFLAGS) doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lkyotocabinet $(LIBS)
  87. leveldbutil: db/leveldb_main.o $(LIBOBJECTS)
  88. $(CXX) $(LDFLAGS) db/leveldb_main.o $(LIBOBJECTS) -o $@ $(LIBS)
  89. arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
  90. $(CXX) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  91. bloom_test: util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS)
  92. $(CXX) $(LDFLAGS) util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  93. c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  94. $(CXX) $(LDFLAGS) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  95. cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
  96. $(CXX) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  97. coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
  98. $(CXX) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  99. corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
  100. $(CXX) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  101. crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  102. $(CXX) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  103. db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
  104. $(CXX) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  105. dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
  106. $(CXX) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  107. env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
  108. $(CXX) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  109. filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
  110. $(CXX) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  111. filter_block_test: table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS)
  112. $(CXX) $(LDFLAGS) table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  113. log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
  114. $(CXX) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  115. table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
  116. $(CXX) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  117. skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
  118. $(CXX) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  119. version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
  120. $(CXX) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  121. version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
  122. $(CXX) $(LDFLAGS) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  123. write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
  124. $(CXX) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  125. $(MEMENVLIBRARY) : $(MEMENVOBJECTS)
  126. rm -f $@
  127. $(AR) -rs $@ $(MEMENVOBJECTS)
  128. memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS)
  129. $(CXX) $(LDFLAGS) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@ $(LIBS)
  130. ifeq ($(PLATFORM), IOS)
  131. # For iOS, create universal object files to be used on both the simulator and
  132. # a device.
  133. PLATFORMSROOT=/Applications/Xcode.app/Contents/Developer/Platforms
  134. SIMULATORROOT=$(PLATFORMSROOT)/iPhoneSimulator.platform/Developer
  135. DEVICEROOT=$(PLATFORMSROOT)/iPhoneOS.platform/Developer
  136. IOSVERSION=$(shell defaults read $(PLATFORMSROOT)/iPhoneOS.platform/version CFBundleShortVersionString)
  137. .cc.o:
  138. mkdir -p ios-x86/$(dir $@)
  139. $(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
  140. mkdir -p ios-arm/$(dir $@)
  141. $(DEVICEROOT)/usr/bin/$(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
  142. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  143. .c.o:
  144. mkdir -p ios-x86/$(dir $@)
  145. $(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
  146. mkdir -p ios-arm/$(dir $@)
  147. $(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
  148. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  149. else
  150. .cc.o:
  151. $(CXX) $(CXXFLAGS) -c $< -o $@
  152. .c.o:
  153. $(CC) $(CFLAGS) -c $< -o $@
  154. endif