作者: 谢瑞阳 10225101483 徐翔宇 10225101535
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

189 строки
6.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. CC = g++
  5. #-----------------------------------------------
  6. # Uncomment exactly one of the lines labelled (A), (B), and (C) below
  7. # to switch between compilation modes.
  8. OPT = -O2 -DNDEBUG # (A) Production use (optimized mode)
  9. # OPT = -g2 # (B) Debug mode, w/ full line-level debugging symbols
  10. # OPT = -O2 -g2 -DNDEBUG # (C) Profiling mode: opt, but w/debugging symbols
  11. #-----------------------------------------------
  12. # detect what platform we're building on
  13. $(shell sh ./build_detect_platform)
  14. # this file is generated by build_detect_platform to set build flags
  15. include build_config.mk
  16. # If Snappy is installed, add compilation and linker flags
  17. # (see http://code.google.com/p/snappy/)
  18. ifeq ($(SNAPPY), 1)
  19. SNAPPY_CFLAGS=-DSNAPPY
  20. SNAPPY_LDFLAGS=-lsnappy
  21. else
  22. SNAPPY_CFLAGS=
  23. SNAPPY_LDFLAGS=
  24. endif
  25. # If Google Perf Tools are installed, add compilation and linker flags
  26. # (see http://code.google.com/p/google-perftools/)
  27. ifeq ($(GOOGLE_PERFTOOLS), 1)
  28. GOOGLE_PERFTOOLS_LDFLAGS=-ltcmalloc
  29. else
  30. GOOGLE_PERFTOOLS_LDFLAGS=
  31. endif
  32. CFLAGS = -c -I. -I./include $(PORT_CFLAGS) $(PLATFORM_CFLAGS) $(OPT) $(SNAPPY_CFLAGS)
  33. LDFLAGS=$(PLATFORM_LDFLAGS) $(SNAPPY_LDFLAGS) $(GOOGLE_PERFTOOLS_LDFLAGS)
  34. LIBOBJECTS = \
  35. ./db/builder.o \
  36. ./db/db_impl.o \
  37. ./db/db_iter.o \
  38. ./db/filename.o \
  39. ./db/dbformat.o \
  40. ./db/log_reader.o \
  41. ./db/log_writer.o \
  42. ./db/memtable.o \
  43. ./db/repair.o \
  44. ./db/table_cache.o \
  45. ./db/version_edit.o \
  46. ./db/version_set.o \
  47. ./db/write_batch.o \
  48. ./port/port_posix.o \
  49. ./table/block.o \
  50. ./table/block_builder.o \
  51. ./table/format.o \
  52. ./table/iterator.o \
  53. ./table/merger.o \
  54. ./table/table.o \
  55. ./table/table_builder.o \
  56. ./table/two_level_iterator.o \
  57. ./util/arena.o \
  58. ./util/cache.o \
  59. ./util/coding.o \
  60. ./util/comparator.o \
  61. ./util/crc32c.o \
  62. ./util/env.o \
  63. ./util/env_posix.o \
  64. ./util/hash.o \
  65. ./util/histogram.o \
  66. ./util/logging.o \
  67. ./util/options.o \
  68. ./util/status.o
  69. TESTUTIL = ./util/testutil.o
  70. TESTHARNESS = ./util/testharness.o $(TESTUTIL)
  71. TESTS = \
  72. arena_test \
  73. cache_test \
  74. coding_test \
  75. corruption_test \
  76. crc32c_test \
  77. db_test \
  78. dbformat_test \
  79. env_test \
  80. filename_test \
  81. log_test \
  82. skiplist_test \
  83. table_test \
  84. version_edit_test \
  85. version_set_test \
  86. write_batch_test
  87. PROGRAMS = db_bench $(TESTS)
  88. BENCHMARKS = db_bench_sqlite3 db_bench_tree_db
  89. LIBRARY = libleveldb.a
  90. all: $(LIBRARY)
  91. check: $(PROGRAMS) $(TESTS)
  92. for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
  93. clean:
  94. -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o
  95. -rm -rf ios-x86/* ios-arm/*
  96. -rm build_config.mk
  97. $(LIBRARY): $(LIBOBJECTS)
  98. rm -f $@
  99. $(AR) -rs $@ $(LIBOBJECTS)
  100. db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
  101. $(CC) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@
  102. db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL)
  103. $(CC) $(LDFLAGS) -lsqlite3 doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@
  104. db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL)
  105. $(CC) $(LDFLAGS) -lkyotocabinet doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@
  106. arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
  107. $(CC) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  108. cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
  109. $(CC) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  110. coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
  111. $(CC) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  112. corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
  113. $(CC) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  114. crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  115. $(CC) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  116. db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
  117. $(CC) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  118. dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
  119. $(CC) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  120. env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
  121. $(CC) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  122. filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
  123. $(CC) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  124. log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
  125. $(CC) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  126. table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
  127. $(CC) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  128. skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
  129. $(CC) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  130. version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
  131. $(CC) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  132. version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
  133. $(CC) $(LDFLAGS) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  134. write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
  135. $(CC) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  136. ifeq ($(PLATFORM), IOS)
  137. # For iOS, create universal object files to be used on both the simulator and
  138. # a device.
  139. SIMULATORROOT=/Developer/Platforms/iPhoneSimulator.platform/Developer
  140. DEVICEROOT=/Developer/Platforms/iPhoneOS.platform/Developer
  141. IOSVERSION=$(shell defaults read /Developer/Platforms/iPhoneOS.platform/version CFBundleShortVersionString)
  142. .cc.o:
  143. mkdir -p ios-x86/$(dir $@)
  144. $(SIMULATORROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 $< -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 $< -o ios-arm/$@
  147. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  148. else
  149. .cc.o:
  150. $(CC) $(CFLAGS) $< -o $@
  151. endif