小组成员:谢瑞阳、徐翔宇
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

210 rindas
7.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. #-----------------------------------------------
  5. # Uncomment exactly one of the lines labelled (A), (B), and (C) below
  6. # to switch between compilation modes.
  7. OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode)
  8. # OPT ?= -g2 # (B) Debug mode, w/ full line-level debugging symbols
  9. # OPT ?= -O2 -g2 -DNDEBUG # (C) Profiling mode: opt, but w/debugging symbols
  10. #-----------------------------------------------
  11. # detect what platform we're building on
  12. $(shell CC="$(CC)" CXX="$(CXX)" TARGET_OS="$(TARGET_OS)" \
  13. ./build_detect_platform build_config.mk ./)
  14. # this file is generated by the previous line to set build flags and sources
  15. include build_config.mk
  16. CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
  17. CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
  18. LDFLAGS += $(PLATFORM_LDFLAGS)
  19. LIBS += $(PLATFORM_LIBS)
  20. LIBOBJECTS = $(SOURCES:.cc=.o)
  21. MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)
  22. TESTUTIL = ./util/testutil.o
  23. TESTHARNESS = ./util/testharness.o $(TESTUTIL)
  24. TESTS = \
  25. arena_test \
  26. autocompact_test \
  27. bloom_test \
  28. c_test \
  29. cache_test \
  30. coding_test \
  31. corruption_test \
  32. crc32c_test \
  33. db_test \
  34. dbformat_test \
  35. env_test \
  36. filename_test \
  37. filter_block_test \
  38. issue178_test \
  39. log_test \
  40. memenv_test \
  41. skiplist_test \
  42. table_test \
  43. version_edit_test \
  44. version_set_test \
  45. write_batch_test
  46. PROGRAMS = db_bench leveldbutil $(TESTS)
  47. BENCHMARKS = db_bench_sqlite3 db_bench_tree_db
  48. LIBRARY = libleveldb.a
  49. MEMENVLIBRARY = libmemenv.a
  50. default: all
  51. # Should we build shared libraries?
  52. ifneq ($(PLATFORM_SHARED_EXT),)
  53. ifneq ($(PLATFORM_SHARED_VERSIONED),true)
  54. SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
  55. SHARED2 = $(SHARED1)
  56. SHARED3 = $(SHARED1)
  57. SHARED = $(SHARED1)
  58. else
  59. # Update db.h if you change these.
  60. SHARED_MAJOR = 1
  61. SHARED_MINOR = 13
  62. SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
  63. SHARED2 = $(SHARED1).$(SHARED_MAJOR)
  64. SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR)
  65. SHARED = $(SHARED1) $(SHARED2) $(SHARED3)
  66. $(SHARED1): $(SHARED3)
  67. ln -fs $(SHARED3) $(SHARED1)
  68. $(SHARED2): $(SHARED3)
  69. ln -fs $(SHARED3) $(SHARED2)
  70. endif
  71. $(SHARED3):
  72. $(CXX) $(LDFLAGS) $(PLATFORM_SHARED_LDFLAGS)$(SHARED2) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(SOURCES) -o $(SHARED3) $(LIBS)
  73. endif # PLATFORM_SHARED_EXT
  74. all: $(SHARED) $(LIBRARY)
  75. check: all $(PROGRAMS) $(TESTS)
  76. for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
  77. clean:
  78. -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk
  79. -rm -rf ios-x86/* ios-arm/*
  80. $(LIBRARY): $(LIBOBJECTS)
  81. rm -f $@
  82. $(AR) -rs $@ $(LIBOBJECTS)
  83. db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
  84. $(CXX) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LIBS)
  85. db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL)
  86. $(CXX) $(LDFLAGS) doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lsqlite3 $(LIBS)
  87. db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL)
  88. $(CXX) $(LDFLAGS) doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lkyotocabinet $(LIBS)
  89. leveldbutil: db/leveldb_main.o $(LIBOBJECTS)
  90. $(CXX) $(LDFLAGS) db/leveldb_main.o $(LIBOBJECTS) -o $@ $(LIBS)
  91. arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
  92. $(CXX) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  93. autocompact_test: db/autocompact_test.o $(LIBOBJECTS) $(TESTHARNESS)
  94. $(CXX) $(LDFLAGS) db/autocompact_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  95. bloom_test: util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS)
  96. $(CXX) $(LDFLAGS) util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  97. c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  98. $(CXX) $(LDFLAGS) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  99. cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
  100. $(CXX) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  101. coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
  102. $(CXX) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  103. corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
  104. $(CXX) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  105. crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
  106. $(CXX) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  107. db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
  108. $(CXX) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  109. dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
  110. $(CXX) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  111. env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
  112. $(CXX) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  113. filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
  114. $(CXX) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  115. filter_block_test: table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS)
  116. $(CXX) $(LDFLAGS) table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  117. issue178_test: issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS)
  118. $(CXX) $(LDFLAGS) issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  119. log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
  120. $(CXX) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  121. table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
  122. $(CXX) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  123. skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
  124. $(CXX) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  125. version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
  126. $(CXX) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  127. version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
  128. $(CXX) $(LDFLAGS) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  129. write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
  130. $(CXX) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
  131. $(MEMENVLIBRARY) : $(MEMENVOBJECTS)
  132. rm -f $@
  133. $(AR) -rs $@ $(MEMENVOBJECTS)
  134. memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS)
  135. $(CXX) $(LDFLAGS) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@ $(LIBS)
  136. ifeq ($(PLATFORM), IOS)
  137. # For iOS, create universal object files to be used on both the simulator and
  138. # a device.
  139. PLATFORMSROOT=/Applications/Xcode.app/Contents/Developer/Platforms
  140. SIMULATORROOT=$(PLATFORMSROOT)/iPhoneSimulator.platform/Developer
  141. DEVICEROOT=$(PLATFORMSROOT)/iPhoneOS.platform/Developer
  142. IOSVERSION=$(shell defaults read $(PLATFORMSROOT)/iPhoneOS.platform/version CFBundleShortVersionString)
  143. .cc.o:
  144. mkdir -p ios-x86/$(dir $@)
  145. $(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
  146. mkdir -p ios-arm/$(dir $@)
  147. $(DEVICEROOT)/usr/bin/$(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
  148. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  149. .c.o:
  150. mkdir -p ios-x86/$(dir $@)
  151. $(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
  152. mkdir -p ios-arm/$(dir $@)
  153. $(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
  154. lipo ios-x86/$@ ios-arm/$@ -create -output $@
  155. else
  156. .cc.o:
  157. $(CXX) $(CXXFLAGS) -c $< -o $@
  158. .c.o:
  159. $(CC) $(CFLAGS) -c $< -o $@
  160. endif