作者: 韩晨旭@ArcueidType(Arcueid) 10225101440 李畅@wesley 10225102463 设计文档为PLAN.md,md版本报告为README.md,pdf版本报告为Report.pdf
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.

166 lines
4.7 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. # Uncomment one of the following to switch between debug and opt mode
  6. #OPT = -O2 -DNDEBUG
  7. OPT = -g2
  8. UNAME := $(shell uname)
  9. ifeq ($(UNAME), Darwin)
  10. # To build for iOS, set PLATFORM=IOS.
  11. ifndef PLATFORM
  12. PLATFORM=OSX
  13. endif # PLATFORM
  14. PLATFORM_CFLAGS = -DLEVELDB_PLATFORM_OSX
  15. PORT_MODULE = port_osx.o
  16. else # UNAME
  17. PLATFORM_CFLAGS = -DLEVELDB_PLATFORM_POSIX -std=c++0x
  18. PORT_MODULE = port_posix.o
  19. endif # UNAME
  20. CFLAGS = -c -I. -I./include $(PLATFORM_CFLAGS) $(OPT)
  21. LDFLAGS=-lpthread
  22. LIBOBJECTS = \
  23. ./db/builder.o \
  24. ./db/db_impl.o \
  25. ./db/db_iter.o \
  26. ./db/filename.o \
  27. ./db/dbformat.o \
  28. ./db/log_reader.o \
  29. ./db/log_writer.o \
  30. ./db/memtable.o \
  31. ./db/repair.o \
  32. ./db/table_cache.o \
  33. ./db/version_edit.o \
  34. ./db/version_set.o \
  35. ./db/write_batch.o \
  36. ./port/$(PORT_MODULE) \
  37. ./table/block.o \
  38. ./table/block_builder.o \
  39. ./table/format.o \
  40. ./table/iterator.o \
  41. ./table/merger.o \
  42. ./table/table.o \
  43. ./table/table_builder.o \
  44. ./table/two_level_iterator.o \
  45. ./util/arena.o \
  46. ./util/cache.o \
  47. ./util/coding.o \
  48. ./util/comparator.o \
  49. ./util/crc32c.o \
  50. ./util/env.o \
  51. ./util/env_posix.o \
  52. ./util/hash.o \
  53. ./util/histogram.o \
  54. ./util/logging.o \
  55. ./util/options.o \
  56. ./util/status.o
  57. TESTUTIL = ./util/testutil.o
  58. TESTHARNESS = ./util/testharness.o $(TESTUTIL)
  59. TESTS = \
  60. arena_test \
  61. cache_test \
  62. coding_test \
  63. corruption_test \
  64. crc32c_test \
  65. db_test \
  66. dbformat_test \
  67. env_test \
  68. filename_test \
  69. log_test \
  70. skiplist_test \
  71. table_test \
  72. version_edit_test \
  73. write_batch_test
  74. PROGRAMS = db_bench $(TESTS)
  75. LIBRARY = libleveldb.a
  76. ifeq ($(PLATFORM), IOS)
  77. # Only XCode can build executable applications for iOS.
  78. all: $(LIBRARY)
  79. else
  80. all: $(PROGRAMS) $(LIBRARY)
  81. endif
  82. check: $(TESTS)
  83. for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
  84. clean:
  85. -rm -f $(PROGRAMS) $(LIBRARY) */*.o ios-x86/*/*.o ios-arm/*/*.o
  86. -rmdir -p ios-x86/* ios-arm/*
  87. $(LIBRARY): $(LIBOBJECTS)
  88. rm -f $@
  89. $(AR) -rs $@ $(LIBOBJECTS)
  90. db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
  91. $(CC) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@
  92. arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
  93. $(CC) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  94. cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
  95. $(CC) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  96. coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
  97. $(CC) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  98. corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
  99. $(CC) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  100. crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  101. $(CC) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  102. db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
  103. $(CC) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  104. dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
  105. $(CC) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  106. env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
  107. $(CC) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  108. filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
  109. $(CC) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  110. log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
  111. $(CC) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  112. table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
  113. $(CC) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  114. skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
  115. $(CC) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  116. version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
  117. $(CC) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  118. write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
  119. $(CC) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  120. ifeq ($(PLATFORM), IOS)
  121. # For iOS, create universal object files to be used on both the simulator and
  122. # a device.
  123. .cc.o:
  124. mkdir -p ios-x86/$(dir $@)
  125. $(CC) $(CFLAGS) -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -arch i686 $< -o ios-x86/$@
  126. mkdir -p ios-arm/$(dir $@)
  127. $(CC) $(CFLAGS) -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -arch armv6 -arch armv7 $< -o ios-arm/$@
  128. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  129. else
  130. .cc.o:
  131. $(CC) $(CFLAGS) $< -o $@
  132. endif
  133. # TODO(gabor): dependencies for .o files
  134. # TODO(gabor): Build library