小组成员:姚凯文(kevinyao0901),姜嘉琪
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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