作者: 谢瑞阳 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.

214 lines
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) $(LDFLAGS) -lsqlite3 doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@
  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) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  113. c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  114. $(CXX) $(LDFLAGS) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  115. cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
  116. $(CXX) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  117. coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
  118. $(CXX) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  119. corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
  120. $(CXX) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  121. crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  122. $(CXX) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  123. db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
  124. $(CXX) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  125. dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
  126. $(CXX) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  127. env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
  128. $(CXX) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  129. filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
  130. $(CXX) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  131. log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
  132. $(CXX) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  133. table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
  134. $(CXX) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  135. skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
  136. $(CXX) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  137. version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
  138. $(CXX) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  139. version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
  140. $(CXX) $(LDFLAGS) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  141. write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
  142. $(CXX) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  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) $(LDFLAGS) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@
  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