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

205 lines
6.5 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/c.o \
  37. ./db/db_impl.o \
  38. ./db/db_iter.o \
  39. ./db/filename.o \
  40. ./db/dbformat.o \
  41. ./db/log_reader.o \
  42. ./db/log_writer.o \
  43. ./db/memtable.o \
  44. ./db/repair.o \
  45. ./db/table_cache.o \
  46. ./db/version_edit.o \
  47. ./db/version_set.o \
  48. ./db/write_batch.o \
  49. ./port/port_posix.o \
  50. ./table/block.o \
  51. ./table/block_builder.o \
  52. ./table/format.o \
  53. ./table/iterator.o \
  54. ./table/merger.o \
  55. ./table/table.o \
  56. ./table/table_builder.o \
  57. ./table/two_level_iterator.o \
  58. ./util/arena.o \
  59. ./util/cache.o \
  60. ./util/coding.o \
  61. ./util/comparator.o \
  62. ./util/crc32c.o \
  63. ./util/env.o \
  64. ./util/env_posix.o \
  65. ./util/hash.o \
  66. ./util/histogram.o \
  67. ./util/logging.o \
  68. ./util/options.o \
  69. ./util/status.o
  70. TESTUTIL = ./util/testutil.o
  71. TESTHARNESS = ./util/testharness.o $(TESTUTIL)
  72. TESTS = \
  73. arena_test \
  74. c_test \
  75. cache_test \
  76. coding_test \
  77. corruption_test \
  78. crc32c_test \
  79. db_test \
  80. dbformat_test \
  81. env_test \
  82. filename_test \
  83. log_test \
  84. skiplist_test \
  85. table_test \
  86. version_edit_test \
  87. version_set_test \
  88. write_batch_test
  89. PROGRAMS = db_bench $(TESTS)
  90. BENCHMARKS = db_bench_sqlite3 db_bench_tree_db
  91. LIBRARY = libleveldb.a
  92. all: $(LIBRARY)
  93. check: $(PROGRAMS) $(TESTS)
  94. for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
  95. clean:
  96. -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o
  97. -rm -rf ios-x86/* ios-arm/*
  98. -rm build_config.mk
  99. $(LIBRARY): $(LIBOBJECTS)
  100. rm -f $@
  101. $(AR) -rs $@ $(LIBOBJECTS)
  102. db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
  103. $(CC) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@
  104. db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL)
  105. $(CC) $(LDFLAGS) -lsqlite3 doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@
  106. db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL)
  107. $(CC) $(LDFLAGS) -lkyotocabinet doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@
  108. arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
  109. $(CC) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  110. c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  111. $(CC) $(LDFLAGS) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  112. cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
  113. $(CC) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  114. coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
  115. $(CC) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  116. corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
  117. $(CC) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  118. crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  119. $(CC) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  120. db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
  121. $(CC) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  122. dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
  123. $(CC) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  124. env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
  125. $(CC) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  126. filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
  127. $(CC) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  128. log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
  129. $(CC) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  130. table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
  131. $(CC) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  132. skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
  133. $(CC) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  134. version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
  135. $(CC) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  136. version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
  137. $(CC) $(LDFLAGS) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  138. write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
  139. $(CC) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  140. ifeq ($(PLATFORM), IOS)
  141. # For iOS, create universal object files to be used on both the simulator and
  142. # a device.
  143. SIMULATORROOT=/Developer/Platforms/iPhoneSimulator.platform/Developer
  144. DEVICEROOT=/Developer/Platforms/iPhoneOS.platform/Developer
  145. IOSVERSION=$(shell defaults read /Developer/Platforms/iPhoneOS.platform/version CFBundleShortVersionString)
  146. .cc.o:
  147. mkdir -p ios-x86/$(dir $@)
  148. $(SIMULATORROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 $< -o ios-x86/$@
  149. mkdir -p ios-arm/$(dir $@)
  150. $(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 $< -o ios-arm/$@
  151. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  152. .c.o:
  153. mkdir -p ios-x86/$(dir $@)
  154. $(SIMULATORROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 $< -o ios-x86/$@
  155. mkdir -p ios-arm/$(dir $@)
  156. $(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 $< -o ios-arm/$@
  157. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  158. else
  159. .cc.o:
  160. $(CC) $(CFLAGS) $< -o $@
  161. .c.o:
  162. $(CC) $(CFLAGS) $< -o $@
  163. endif