10225501448 李度 10225101546 陈胤遒 10215501422 高宇菲
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.

79 lines
2.4 KiB

  1. #!/bin/sh
  2. # Detects OS we're compiling on and generates build_config.mk,
  3. # which in turn gets read while processing Makefile.
  4. # build_config.mk will set the following variables:
  5. # - PORT_CFLAGS will either set:
  6. # -DLEVELDB_PLATFORM_POSIX if cstatomic is present
  7. # -DLEVELDB_PLATFORM_NOATOMIC if it is not
  8. # - PLATFORM_CFLAGS with compiler flags for the platform
  9. # - PLATFORM_LDFLAGS with linker flags for the platform
  10. # Delete existing build_config.mk
  11. rm -f build_config.mk
  12. # Detect OS
  13. case `uname -s` in
  14. Darwin)
  15. PLATFORM=OS_MACOSX
  16. echo "PLATFORM_CFLAGS=-DOS_MACOSX" >> build_config.mk
  17. echo "PLATFORM_LDFLAGS=" >> build_config.mk
  18. ;;
  19. Linux)
  20. PLATFORM=OS_LINUX
  21. echo "PLATFORM_CFLAGS=-pthread -DOS_LINUX" >> build_config.mk
  22. echo "PLATFORM_LDFLAGS=-lpthread" >> build_config.mk
  23. ;;
  24. SunOS)
  25. PLATFORM=OS_SOLARIS
  26. echo "PLATFORM_CFLAGS=-D_REENTRANT -DOS_SOLARIS" >> build_config.mk
  27. echo "PLATFORM_LDFLAGS=-lpthread -lrt" >> build_config.mk
  28. ;;
  29. FreeBSD)
  30. PLATFORM=OS_FREEBSD
  31. echo "PLATFORM_CFLAGS=-D_REENTRANT -DOS_FREEBSD" >> build_config.mk
  32. echo "PLATFORM_LDFLAGS=-lpthread" >> build_config.mk
  33. ;;
  34. GNU/kFreeBSD)
  35. PLATFORM=OS_FREEBSD
  36. echo "PLATFORM_CFLAGS=-pthread -DOS_FREEBSD" >> build_config.mk
  37. echo "PLATFORM_LDFLAGS=-lpthread -lrt" >> build_config.mk
  38. ;;
  39. *)
  40. echo "Unknown platform!"
  41. exit 1
  42. esac
  43. echo "PLATFORM=$PLATFORM" >> build_config.mk
  44. # On GCC, use libc's memcmp, not GCC's memcmp
  45. PORT_CFLAGS="-fno-builtin-memcmp"
  46. # Detect C++0x -- this determines whether we'll use port_noatomic.h
  47. # or port_posix.h by:
  48. # 1. Rrying to compile with -std=c++0x and including <cstdatomic>.
  49. # 2. If g++ returns error code, we know to use port_posix.h
  50. g++ $CFLAGS -std=c++0x -x c++ - -o /dev/null 2>/dev/null <<EOF
  51. #include <cstdatomic>
  52. int main() {}
  53. EOF
  54. if [ "$?" = 0 ]; then
  55. PORT_CFLAGS="$PORT_CFLAGS -DLEVELDB_PLATFORM_POSIX -DLEVELDB_CSTDATOMIC_PRESENT -std=c++0x"
  56. else
  57. PORT_CFLAGS="$PORT_CFLAGS -DLEVELDB_PLATFORM_POSIX"
  58. fi
  59. # Test whether Snappy library is installed
  60. # http://code.google.com/p/snappy/
  61. g++ $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
  62. #include <snappy.h>
  63. int main() {}
  64. EOF
  65. if [ "$?" = 0 ]; then
  66. echo "SNAPPY=1" >> build_config.mk
  67. else
  68. echo "SNAPPY=0" >> build_config.mk
  69. fi
  70. echo "PORT_CFLAGS=$PORT_CFLAGS" >> build_config.mk