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