提供基本的ttl测试用例
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
5.1 KiB

  1. #!/bin/sh
  2. #
  3. # Detects OS we're compiling on and outputs a file specified by the first
  4. # argument, which in turn gets read while processing Makefile.
  5. #
  6. # The output will set the following variables:
  7. # PLATFORM_LDFLAGS Linker flags
  8. # PLATFORM_SHARED_EXT Extension for shared libraries
  9. # PLATFORM_SHARED_LDFLAGS Flags for building shared library
  10. # PLATFORM_SHARED_CFLAGS Flags for compiling objects for shared library
  11. # PLATFORM_CCFLAGS C compiler flags
  12. # PLATFORM_CXXFLAGS C++ compiler flags. Will contain:
  13. # -DLEVELDB_PLATFORM_POSIX if cstdatomic is present
  14. # -DLEVELDB_PLATFORM_NOATOMIC if it is not
  15. OUTPUT=$1
  16. if test -z "$OUTPUT"; then
  17. echo "usage: $0 <output-filename>"
  18. exit 1
  19. fi
  20. # Delete existing output, if it exists
  21. rm -f $OUTPUT
  22. touch $OUTPUT
  23. if test -z "$CXX"; then
  24. CXX=g++
  25. fi
  26. # Detect OS
  27. if test -z "$TARGET_OS"; then
  28. TARGET_OS=`uname -s`
  29. fi
  30. COMMON_FLAGS=
  31. PLATFORM_CCFLAGS=
  32. PLATFORM_CXXFLAGS=
  33. PLATFORM_LDFLAGS=
  34. PLATFORM_SHARED_EXT="so"
  35. PLATFORM_SHARED_LDFLAGS="-shared -Wl,-soname -Wl,"
  36. PLATFORM_SHARED_CFLAGS="-fPIC"
  37. # On GCC, we pick libc's memcmp over GCC's memcmp via -fno-builtin-memcmp
  38. case "$TARGET_OS" in
  39. Darwin)
  40. PLATFORM=OS_MACOSX
  41. COMMON_FLAGS="-fno-builtin-memcmp -DOS_MACOSX"
  42. PLATFORM_SHARED_EXT=dylib
  43. PLATFORM_SHARED_LDFLAGS="-dynamiclib -install_name "
  44. PORT_FILE=port/port_posix.cc
  45. ;;
  46. Linux)
  47. PLATFORM=OS_LINUX
  48. COMMON_FLAGS="-fno-builtin-memcmp -pthread -DOS_LINUX"
  49. PLATFORM_LDFLAGS="-pthread"
  50. PORT_FILE=port/port_posix.cc
  51. ;;
  52. SunOS)
  53. PLATFORM=OS_SOLARIS
  54. COMMON_FLAGS="-fno-builtin-memcmp -D_REENTRANT -DOS_SOLARIS"
  55. PLATFORM_LDFLAGS="-lpthread -lrt"
  56. PORT_FILE=port/port_posix.cc
  57. ;;
  58. FreeBSD)
  59. PLATFORM=OS_FREEBSD
  60. COMMON_FLAGS="-fno-builtin-memcmp -D_REENTRANT -DOS_FREEBSD"
  61. PLATFORM_LDFLAGS="-lpthread"
  62. PORT_FILE=port/port_posix.cc
  63. ;;
  64. NetBSD)
  65. PLATFORM=OS_NETBSD
  66. COMMON_FLAGS="-fno-builtin-memcmp -D_REENTRANT -DOS_NETBSD"
  67. PLATFORM_LDFLAGS="-lpthread -lgcc_s"
  68. PORT_FILE=port/port_posix.cc
  69. ;;
  70. OpenBSD)
  71. PLATFORM=OS_OPENBSD
  72. COMMON_FLAGS="-fno-builtin-memcmp -D_REENTRANT -DOS_OPENBSD"
  73. PLATFORM_LDFLAGS="-pthread"
  74. PORT_FILE=port/port_posix.cc
  75. ;;
  76. DragonFly)
  77. PLATFORM=OS_DRAGONFLYBSD
  78. COMMON_FLAGS="-fno-builtin-memcmp -D_REENTRANT -DOS_DRAGONFLYBSD"
  79. PLATFORM_LDFLAGS="-lpthread"
  80. PORT_FILE=port/port_posix.cc
  81. ;;
  82. OS_ANDROID_CROSSCOMPILE)
  83. PLATFORM="$TARGET_OS"
  84. COMMON_FLAGS=""
  85. PLATFORM_LDFLAGS=""
  86. PORT_FILE=port/port_android.cc
  87. ;;
  88. *)
  89. echo "Unknown platform!"
  90. exit 1
  91. esac
  92. # We want to make a list of all cc files within util, db, table, and helpers
  93. # except for the test and benchmark files. By default, find will output a list
  94. # of all files matching either rule, so we need to append -print to make the
  95. # prune take effect.
  96. DIRS="util db table"
  97. set -f # temporarily disable globbing so that our patterns aren't expanded
  98. PRUNE_TEST="-name *test*.cc -prune"
  99. PRUNE_BENCH="-name *_bench.cc -prune"
  100. PORTABLE_FILES=`find $DIRS $PRUNE_TEST -o $PRUNE_BENCH -o -name '*.cc' -print | sort | tr "\n" " "`
  101. set +f # re-enable globbing
  102. # The sources consist of the portable files, plus the platform-specific port
  103. # file.
  104. echo "SOURCES=$PORTABLE_FILES $PORT_FILE" >> $OUTPUT
  105. echo "MEMENV_SOURCES=helpers/memenv/memenv.cc" >> $OUTPUT
  106. if [ "$PLATFORM" = "OS_ANDROID_CROSSCOMPILE" ]; then
  107. # Cross-compiling; do not try any compilation tests.
  108. true
  109. else
  110. # If -std=c++0x works, use <cstdatomic>. Otherwise use port_posix.h.
  111. $CXX $CFLAGS -std=c++0x -x c++ - -o /dev/null 2>/dev/null <<EOF
  112. #include <cstdatomic>
  113. int main() {}
  114. EOF
  115. if [ "$?" = 0 ]; then
  116. COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX -DLEVELDB_CSTDATOMIC_PRESENT"
  117. PLATFORM_CXXFLAGS="-std=c++0x"
  118. else
  119. COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX"
  120. fi
  121. # Test whether Snappy library is installed
  122. # http://code.google.com/p/snappy/
  123. $CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
  124. #include <snappy.h>
  125. int main() {}
  126. EOF
  127. if [ "$?" = 0 ]; then
  128. COMMON_FLAGS="$COMMON_FLAGS -DSNAPPY"
  129. PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lsnappy"
  130. fi
  131. # Test whether tcmalloc is available
  132. $CXX $CFLAGS -x c++ - -o /dev/null -ltcmalloc 2>/dev/null <<EOF
  133. int main() {}
  134. EOF
  135. if [ "$?" = 0 ]; then
  136. PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -ltcmalloc"
  137. fi
  138. fi
  139. PLATFORM_CCFLAGS="$PLATFORM_CCFLAGS $COMMON_FLAGS"
  140. PLATFORM_CXXFLAGS="$PLATFORM_CXXFLAGS $COMMON_FLAGS"
  141. echo "PLATFORM=$PLATFORM" >> $OUTPUT
  142. echo "PLATFORM_LDFLAGS=$PLATFORM_LDFLAGS" >> $OUTPUT
  143. echo "PLATFORM_CCFLAGS=$PLATFORM_CCFLAGS" >> $OUTPUT
  144. echo "PLATFORM_CXXFLAGS=$PLATFORM_CXXFLAGS" >> $OUTPUT
  145. echo "PLATFORM_SHARED_CFLAGS=$PLATFORM_SHARED_CFLAGS" >> $OUTPUT
  146. echo "PLATFORM_SHARED_EXT=$PLATFORM_SHARED_EXT" >> $OUTPUT
  147. echo "PLATFORM_SHARED_LDFLAGS=$PLATFORM_SHARED_LDFLAGS" >> $OUTPUT