小组成员:10215300402-朱维清 & 10222140408 谷杰
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

182 行
5.6 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. LIBRARY = libleveldb.a
  89. all: $(LIBRARY)
  90. check: $(PROGRAMS) $(TESTS)
  91. for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
  92. clean:
  93. -rm -f $(PROGRAMS) $(LIBRARY) */*.o ios-x86/*/*.o ios-arm/*/*.o
  94. -rm -rf ios-x86/* ios-arm/*
  95. -rm build_config.mk
  96. $(LIBRARY): $(LIBOBJECTS)
  97. rm -f $@
  98. $(AR) -rs $@ $(LIBOBJECTS)
  99. db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
  100. $(CC) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@
  101. arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
  102. $(CC) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  103. cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
  104. $(CC) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  105. coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
  106. $(CC) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  107. corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
  108. $(CC) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  109. crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  110. $(CC) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  111. db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
  112. $(CC) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  113. dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
  114. $(CC) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  115. env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
  116. $(CC) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  117. filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
  118. $(CC) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  119. log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
  120. $(CC) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  121. table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
  122. $(CC) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  123. skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
  124. $(CC) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  125. version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
  126. $(CC) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  127. version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
  128. $(CC) $(LDFLAGS) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  129. write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
  130. $(CC) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
  131. ifeq ($(PLATFORM), IOS)
  132. # For iOS, create universal object files to be used on both the simulator and
  133. # a device.
  134. SIMULATORROOT=/Developer/Platforms/iPhoneSimulator.platform/Developer
  135. DEVICEROOT=/Developer/Platforms/iPhoneOS.platform/Developer
  136. IOSVERSION=$(shell defaults read /Developer/Platforms/iPhoneOS.platform/version CFBundleShortVersionString)
  137. .cc.o:
  138. mkdir -p ios-x86/$(dir $@)
  139. $(SIMULATORROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 $< -o ios-x86/$@
  140. mkdir -p ios-arm/$(dir $@)
  141. $(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 $< -o ios-arm/$@
  142. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  143. else
  144. .cc.o:
  145. $(CC) $(CFLAGS) $< -o $@
  146. endif