作者: 谢瑞阳 10225101483 徐翔宇 10225101535
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.

201 lines
7.0 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. # Inherit some settings from environment variables, if available
  5. INSTALL_PATH ?= $(CURDIR)
  6. #-----------------------------------------------
  7. # Uncomment exactly one of the lines labelled (A), (B), and (C) below
  8. # to switch between compilation modes.
  9. OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode)
  10. # OPT ?= -g2 # (B) Debug mode, w/ full line-level debugging symbols
  11. # OPT ?= -O2 -g2 -DNDEBUG # (C) Profiling mode: opt, but w/debugging symbols
  12. #-----------------------------------------------
  13. # detect what platform we're building on
  14. $(shell CC=$(CC) CXX=$(CXX) TARGET_OS=$(TARGET_OS) \
  15. ./build_detect_platform build_config.mk ./)
  16. # this file is generated by the previous line to set build flags and sources
  17. include build_config.mk
  18. CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
  19. CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
  20. LDFLAGS += $(PLATFORM_LDFLAGS)
  21. LIBOBJECTS = $(SOURCES:.cc=.o)
  22. MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)
  23. TESTUTIL = ./util/testutil.o
  24. TESTHARNESS = ./util/testharness.o $(TESTUTIL)
  25. TESTS = \
  26. arena_test \
  27. bloom_test \
  28. c_test \
  29. cache_test \
  30. coding_test \
  31. corruption_test \
  32. crc32c_test \
  33. db_test \
  34. dbformat_test \
  35. env_test \
  36. filename_test \
  37. filter_block_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 $(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 = 6
  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) $(SOURCES) $(LDFLAGS) $(PLATFORM_SHARED_LDFLAGS)$(INSTALL_PATH)$(SHARED2) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) -o $(SHARED3)
  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) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LDFLAGS)
  84. db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL)
  85. $(CXX) doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LDFLAGS) -lsqlite3
  86. db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL)
  87. $(CXX) doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LDFLAGS) -lkyotocabinet
  88. arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
  89. $(CXX) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  90. bloom_test: util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS)
  91. $(CXX) util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  92. c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  93. $(CXX) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  94. cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
  95. $(CXX) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  96. coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
  97. $(CXX) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  98. corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
  99. $(CXX) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  100. crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  101. $(CXX) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  102. db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
  103. $(CXX) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  104. dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
  105. $(CXX) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  106. env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
  107. $(CXX) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  108. filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
  109. $(CXX) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  110. filter_block_test: table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS)
  111. $(CXX) table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  112. log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
  113. $(CXX) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  114. table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
  115. $(CXX) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  116. skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
  117. $(CXX) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  118. version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
  119. $(CXX) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  120. version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
  121. $(CXX) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  122. write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
  123. $(CXX) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  124. $(MEMENVLIBRARY) : $(MEMENVOBJECTS)
  125. rm -f $@
  126. $(AR) -rs $@ $(MEMENVOBJECTS)
  127. memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS)
  128. $(CXX) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@ $(LDFLAGS)
  129. ifeq ($(PLATFORM), IOS)
  130. # For iOS, create universal object files to be used on both the simulator and
  131. # a device.
  132. PLATFORMSROOT=/Applications/Xcode.app/Contents/Developer/Platforms
  133. SIMULATORROOT=$(PLATFORMSROOT)/iPhoneSimulator.platform/Developer
  134. DEVICEROOT=$(PLATFORMSROOT)/iPhoneOS.platform/Developer
  135. IOSVERSION=$(shell defaults read $(PLATFORMSROOT)/iPhoneOS.platform/version CFBundleShortVersionString)
  136. .cc.o:
  137. mkdir -p ios-x86/$(dir $@)
  138. $(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
  139. mkdir -p ios-arm/$(dir $@)
  140. $(DEVICEROOT)/usr/bin/$(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
  141. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  142. .c.o:
  143. mkdir -p ios-x86/$(dir $@)
  144. $(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
  145. mkdir -p ios-arm/$(dir $@)
  146. $(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
  147. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  148. else
  149. .cc.o:
  150. $(CXX) $(CXXFLAGS) -c $< -o $@
  151. .c.o:
  152. $(CC) $(CFLAGS) -c $< -o $@
  153. endif