PageRenderTime 24ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/buildtools/build.sh

http://github.com/mozy/mordor
Shell | 72 lines | 58 code | 8 blank | 6 comment | 8 complexity | af569a03493787c96b3c998d265d38d4 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. #!/bin/bash
  2. #Trigger builds on linux or mac
  3. #By default autoconf and xcode projects are used.
  4. set -e -u
  5. CONFIG=release
  6. USE_CMAKE=0
  7. while [[ $# -gt 0 ]] ; do
  8. key="$1"
  9. case "$1" in
  10. release|debug|coverage|valgrind)
  11. CONFIG=$1
  12. ;;
  13. cmake)
  14. USE_CMAKE=1
  15. ;;
  16. --)
  17. #Arguments after -- are forwarded to configure
  18. shift
  19. break
  20. ;;
  21. *)
  22. echo "Unknown option $1"
  23. ;;
  24. esac
  25. shift
  26. done
  27. if [ "${USE_CMAKE}" = "1" ] ; then
  28. . buildtools/build-cmake.sh $CONFIG
  29. elif [ `uname` = 'Darwin' ] ; then
  30. #To be phased out when building osx exclusively with cmake
  31. . buildtools/build-xcode.sh $CONFIG
  32. else
  33. #Linux autotools base build
  34. if [ ! -x configure ]; then
  35. autoreconf -i
  36. fi
  37. CXXFLAGS=
  38. VALGRINDFLAGS=
  39. ASSERTFLAGS=
  40. POSTGRESFLAGS=
  41. if [ ! -f Makefile ]; then
  42. if [ "${CONFIG}" = "debug" ]; then
  43. CXXFLAGS+=' -g -O0'
  44. elif [ "${CONFIG}" = "coverage" ]; then
  45. CXXFLAGS+=' -g -O0 -fprofile-arcs -ftest-coverage'
  46. elif [ "${CONFIG}" = "valgrind" ]; then
  47. CXXFLAGS+=' -g -O0'
  48. VALGRINDFLAGS=--enable-valgrind=yes
  49. else
  50. ASSERTFLAGS=--disable-assert
  51. fi
  52. if [[ -n "$CXXFLAGS" ]] ; then
  53. export CXXFLAGS
  54. fi
  55. which pg_config >/dev/null || POSTGRESFLAGS=--without-postgresql
  56. ./configure --disable-shared $ASSERTFLAGS $POSTGRESFLAGS $VALGRINDFLAGS "$@"
  57. fi
  58. if [ $(uname) = 'Linux' ]; then
  59. j=$(grep processor /proc/cpuinfo | wc -l)
  60. else
  61. j=2
  62. fi
  63. make check -j$j
  64. fi