10225501448 李度 10225101546 陈胤遒 10215501422 高宇菲
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

214 lignes
6.9 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. CXX ?= g++
  5. CC ?= gcc
  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 sh ./build_detect_platform)
  15. # this file is generated by build_detect_platform to set build flags
  16. include build_config.mk
  17. # If Snappy is installed, add compilation and linker flags
  18. # (see http://code.google.com/p/snappy/)
  19. ifeq ($(SNAPPY), 1)
  20. SNAPPY_CFLAGS=-DSNAPPY
  21. SNAPPY_LDFLAGS=-lsnappy
  22. else
  23. SNAPPY_CFLAGS=
  24. SNAPPY_LDFLAGS=
  25. endif
  26. # If Google Perf Tools are installed, add compilation and linker flags
  27. # (see http://code.google.com/p/google-perftools/)
  28. ifeq ($(GOOGLE_PERFTOOLS), 1)
  29. GOOGLE_PERFTOOLS_LDFLAGS=-ltcmalloc
  30. else
  31. GOOGLE_PERFTOOLS_LDFLAGS=
  32. endif
  33. CFLAGS = -c -I. -I./include $(PORT_CFLAGS) $(PLATFORM_CFLAGS) $(OPT) $(SNAPPY_CFLAGS)
  34. LDFLAGS += $(PLATFORM_LDFLAGS) $(SNAPPY_LDFLAGS) $(GOOGLE_PERFTOOLS_LDFLAGS)
  35. LIBOBJECTS = \
  36. ./db/builder.o \
  37. ./db/c.o \
  38. ./db/db_impl.o \
  39. ./db/db_iter.o \
  40. ./db/filename.o \
  41. ./db/dbformat.o \
  42. ./db/log_reader.o \
  43. ./db/log_writer.o \
  44. ./db/memtable.o \
  45. ./db/repair.o \
  46. ./db/table_cache.o \
  47. ./db/version_edit.o \
  48. ./db/version_set.o \
  49. ./db/write_batch.o \
  50. ./port/port_posix.o \
  51. ./table/block.o \
  52. ./table/block_builder.o \
  53. ./table/format.o \
  54. ./table/iterator.o \
  55. ./table/merger.o \
  56. ./table/table.o \
  57. ./table/table_builder.o \
  58. ./table/two_level_iterator.o \
  59. ./util/arena.o \
  60. ./util/cache.o \
  61. ./util/coding.o \
  62. ./util/comparator.o \
  63. ./util/crc32c.o \
  64. ./util/env.o \
  65. ./util/env_posix.o \
  66. ./util/hash.o \
  67. ./util/histogram.o \
  68. ./util/logging.o \
  69. ./util/options.o \
  70. ./util/status.o
  71. TESTUTIL = ./util/testutil.o
  72. TESTHARNESS = ./util/testharness.o $(TESTUTIL)
  73. TESTS = \
  74. arena_test \
  75. c_test \
  76. cache_test \
  77. coding_test \
  78. corruption_test \
  79. crc32c_test \
  80. db_test \
  81. dbformat_test \
  82. env_test \
  83. filename_test \
  84. log_test \
  85. memenv_test \
  86. skiplist_test \
  87. table_test \
  88. version_edit_test \
  89. version_set_test \
  90. write_batch_test
  91. PROGRAMS = db_bench $(TESTS)
  92. BENCHMARKS = db_bench_sqlite3 db_bench_tree_db
  93. LIBRARY = libleveldb.a
  94. MEMENVLIBRARY = libmemenv.a
  95. all: $(LIBRARY)
  96. check: $(PROGRAMS) $(TESTS)
  97. for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
  98. clean:
  99. -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(MEMENVLIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o
  100. -rm -rf ios-x86/* ios-arm/*
  101. -rm build_config.mk
  102. $(LIBRARY): $(LIBOBJECTS)
  103. rm -f $@
  104. $(AR) -rs $@ $(LIBOBJECTS)
  105. db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
  106. $(CXX) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@
  107. db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL)
  108. $(CXX) -lsqlite3 doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LDFLAGS
  109. db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL)
  110. $(CXX) $(LDFLAGS) -lkyotocabinet doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@
  111. arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
  112. $(CXX) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  113. c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  114. $(CXX) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  115. cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
  116. $(CXX) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  117. coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
  118. $(CXX) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  119. corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
  120. $(CXX) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  121. crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  122. $(CXX) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  123. db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
  124. $(CXX) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  125. dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
  126. $(CXX) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  127. env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
  128. $(CXX) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  129. filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
  130. $(CXX) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  131. log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
  132. $(CXX) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  133. table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
  134. $(CXX) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  135. skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
  136. $(CXX) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  137. version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
  138. $(CXX) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  139. version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
  140. $(CXX) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  141. write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
  142. $(CXX) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
  143. $(MEMENVLIBRARY) : helpers/memenv/memenv.o
  144. rm -f $@
  145. $(AR) -rs $@ helpers/memenv/memenv.o
  146. memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS)
  147. $(CXX) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@ $(LDFLAGS)
  148. ifeq ($(PLATFORM), IOS)
  149. # For iOS, create universal object files to be used on both the simulator and
  150. # a device.
  151. SIMULATORROOT=/Developer/Platforms/iPhoneSimulator.platform/Developer
  152. DEVICEROOT=/Developer/Platforms/iPhoneOS.platform/Developer
  153. IOSVERSION=$(shell defaults read /Developer/Platforms/iPhoneOS.platform/version CFBundleShortVersionString)
  154. .cc.o:
  155. mkdir -p ios-x86/$(dir $@)
  156. $(SIMULATORROOT)/usr/bin/$(CXX) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 $< -o ios-x86/$@
  157. mkdir -p ios-arm/$(dir $@)
  158. $(DEVICEROOT)/usr/bin/$(CXX) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 $< -o ios-arm/$@
  159. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  160. .c.o:
  161. mkdir -p ios-x86/$(dir $@)
  162. $(SIMULATORROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 $< -o ios-x86/$@
  163. mkdir -p ios-arm/$(dir $@)
  164. $(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 $< -o ios-arm/$@
  165. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  166. else
  167. .cc.o:
  168. $(CXX) $(CFLAGS) $< -o $@
  169. .c.o:
  170. $(CC) $(CFLAGS) $< -o $@
  171. endif