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.

78 rindas
2.3 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. if test -z "$CXX"; then
  13. CXX=g++
  14. fi
  15. # Detect OS
  16. case `uname -s` in
  17. Darwin)
  18. PLATFORM=OS_MACOSX
  19. echo "PLATFORM_CFLAGS=-DOS_MACOSX" >> build_config.mk
  20. echo "PLATFORM_LDFLAGS=" >> build_config.mk
  21. ;;
  22. Linux)
  23. PLATFORM=OS_LINUX
  24. echo "PLATFORM_CFLAGS=-pthread -DOS_LINUX" >> build_config.mk
  25. echo "PLATFORM_LDFLAGS=-lpthread" >> build_config.mk
  26. ;;
  27. SunOS)
  28. PLATFORM=OS_SOLARIS
  29. echo "PLATFORM_CFLAGS=-D_REENTRANT -DOS_SOLARIS" >> build_config.mk
  30. echo "PLATFORM_LDFLAGS=-lpthread -lrt" >> build_config.mk
  31. ;;
  32. FreeBSD)
  33. PLATFORM=OS_FREEBSD
  34. echo "PLATFORM_CFLAGS=-D_REENTRANT -DOS_FREEBSD" >> build_config.mk
  35. echo "PLATFORM_LDFLAGS=-lpthread" >> build_config.mk
  36. ;;
  37. *)
  38. echo "Unknown platform!"
  39. exit 1
  40. esac
  41. echo "PLATFORM=$PLATFORM" >> build_config.mk
  42. # On GCC, use libc's memcmp, not GCC's memcmp
  43. PORT_CFLAGS="-fno-builtin-memcmp"
  44. # Detect C++0x -- this determines whether we'll use port_noatomic.h
  45. # or port_posix.h by:
  46. # 1. Rrying to compile with -std=c++0x and including <cstdatomic>.
  47. # 2. If $CXX returns error code, we know to use port_posix.h
  48. $CXX $CFLAGS -std=c++0x -x c++ - -o /dev/null 2>/dev/null <<EOF
  49. #include <cstdatomic>
  50. int main() {}
  51. EOF
  52. if [ "$?" = 0 ]; then
  53. PORT_CFLAGS="$PORT_CFLAGS -DLEVELDB_PLATFORM_POSIX -DLEVELDB_CSTDATOMIC_PRESENT -std=c++0x"
  54. else
  55. PORT_CFLAGS="$PORT_CFLAGS -DLEVELDB_PLATFORM_POSIX"
  56. fi
  57. # Test whether Snappy library is installed
  58. # http://code.google.com/p/snappy/
  59. $CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
  60. #include <snappy.h>
  61. int main() {}
  62. EOF
  63. if [ "$?" = 0 ]; then
  64. echo "SNAPPY=1" >> build_config.mk
  65. else
  66. echo "SNAPPY=0" >> build_config.mk
  67. fi
  68. echo "PORT_CFLAGS=$PORT_CFLAGS" >> build_config.mk