作者: 韩晨旭 10225101440 李畅 10225102463
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

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