小组成员: 曹可心-10223903406 朴祉燕-10224602413
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.

69 lines
2.1 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. *)
  30. echo "Unknown platform!"
  31. exit 1
  32. esac
  33. echo "PLATFORM=$PLATFORM" >> build_config.mk
  34. # On GCC, use libc's memcmp, not GCC's memcmp
  35. PORT_CFLAGS="-fno-builtin-memcmp"
  36. # Detect C++0x -- this determines whether we'll use port_noatomic.h
  37. # or port_posix.h by:
  38. # 1. Rrying to compile with -std=c++0x and including <cstdatomic>.
  39. # 2. If g++ returns error code, we know to use port_posix.h
  40. g++ $CFLAGS -std=c++0x -x c++ - -o /dev/null 2>/dev/null <<EOF
  41. #include <cstdatomic>
  42. int main() {}
  43. EOF
  44. if [ "$?" = 0 ]; then
  45. PORT_CFLAGS="$PORT_CFLAGS -DLEVELDB_PLATFORM_POSIX -DLEVELDB_CSTDATOMIC_PRESENT -std=c++0x"
  46. else
  47. PORT_CFLAGS="$PORT_CFLAGS -DLEVELDB_PLATFORM_POSIX"
  48. fi
  49. # Test whether Snappy library is installed
  50. # http://code.google.com/p/snappy/
  51. g++ $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
  52. #include <snappy.h>
  53. int main() {}
  54. EOF
  55. if [ "$?" = 0 ]; then
  56. echo "SNAPPY=1" >> build_config.mk
  57. else
  58. echo "SNAPPY=0" >> build_config.mk
  59. fi
  60. echo "PORT_CFLAGS=$PORT_CFLAGS" >> build_config.mk