install.sh 2.25 KB
Newer Older
Ciro Santilli's avatar
Ciro Santilli committed
1 2 3
#!/usr/bin/env bash

# Build and install to a local prefix under this repository.
4
export OSTYPE
Ciro Santilli's avatar
Ciro Santilli committed
5 6 7 8

# Flags:

  # -g: install globally instead for all users
9
  # -s: link everything statically, no D-Bus communication. More likely to work!
Alexandre Lision's avatar
Alexandre Lision committed
10
  # -c: client to build
11
  # -p: number of processors to use
Ciro Santilli's avatar
Ciro Santilli committed
12 13 14 15

set -ex

global=false
16
static=''
Alexandre Lision's avatar
Alexandre Lision committed
17
client=''
18 19
proc=''
while getopts gsc:p: OPT; do
Ciro Santilli's avatar
Ciro Santilli committed
20 21 22 23
  case "$OPT" in
    g)
      global='true'
    ;;
24 25 26
    s)
      static='-DENABLE_STATIC=true'
    ;;
Alexandre Lision's avatar
Alexandre Lision committed
27 28 29
    c)
      client="${OPTARG}"
    ;;
30 31 32
    p)
      proc="${OPTARG}"
    ;;
Ciro Santilli's avatar
Ciro Santilli committed
33 34 35 36 37 38 39 40 41
    \?)
      exit 1
    ;;
  esac
done

make_install() {
  if $1; then
    sudo make install
Ciro Santilli's avatar
Ciro Santilli committed
42 43 44
    # Or else the next non-sudo install will fail, because this generates some
    # root owned files like install_manifest.txt under the build directory.
    sudo chown -R "$USER" .
Ciro Santilli's avatar
Ciro Santilli committed
45 46 47 48 49 50 51 52
  else
    make install
  fi
}

TOP="$(pwd)"
INSTALL="${TOP}/install"

aviau's avatar
aviau committed
53 54 55 56 57 58 59
if $global; then
    BUILDDIR="build-global"
else
    BUILDDIR="build-local"
fi

cd "${TOP}/daemon"
Ciro Santilli's avatar
Ciro Santilli committed
60 61 62 63
DAEMON="$(pwd)"
cd contrib
mkdir -p native
cd native
64 65 66 67
if [[ "$OSTYPE" == "darwin"* ]]; then
    enableRestbed="--enable-restbed"
fi
../bootstrap $enableRestbed
68
make
Ciro Santilli's avatar
Ciro Santilli committed
69 70
cd "${DAEMON}"
./autogen.sh
71 72 73 74 75 76

#keep shared Lib on MAC OSX
if [[ "$OSTYPE" != "darwin"* ]]; then
    sharedLib="--disable-shared"
fi

Ciro Santilli's avatar
Ciro Santilli committed
77
if $global; then
78
  ./configure $sharedLib $CONFIGURE_FLAGS
Ciro Santilli's avatar
Ciro Santilli committed
79
else
80
  ./configure $sharedLib $CONFIGURE_FLAGS --prefix="${INSTALL}/daemon"
Ciro Santilli's avatar
Ciro Santilli committed
81
fi
82
make -j${proc}
Ciro Santilli's avatar
Ciro Santilli committed
83 84 85
make_install $global

cd "${TOP}/lrc"
aviau's avatar
aviau committed
86 87
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
Ciro Santilli's avatar
Ciro Santilli committed
88
if $global; then
Alexandre Lision's avatar
Alexandre Lision committed
89
  cmake .. -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH -DCMAKE_BUILD_TYPE=Debug $static
Ciro Santilli's avatar
Ciro Santilli committed
90
else
91 92 93 94
  cmake ..  -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \
            -DCMAKE_BUILD_TYPE=Debug \
            -DCMAKE_INSTALL_PREFIX="${INSTALL}/lrc" \
            -DRING_BUILD_DIR="${DAEMON}/src" $static
Ciro Santilli's avatar
Ciro Santilli committed
95
fi
96
make -j${proc}
Ciro Santilli's avatar
Ciro Santilli committed
97 98
make_install $global

Alexandre Lision's avatar
Alexandre Lision committed
99
cd "${TOP}/${client}"
aviau's avatar
aviau committed
100 101
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
Ciro Santilli's avatar
Ciro Santilli committed
102
if $global; then
Alexandre Lision's avatar
Alexandre Lision committed
103
  cmake .. -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH $static
Ciro Santilli's avatar
Ciro Santilli committed
104
else
105 106 107 108
  cmake ..  -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \
            -DCMAKE_INSTALL_PREFIX="${INSTALL}/${client}" \
            -DRINGTONE_DIR="${INSTALL}/daemon/share/ring/ringtones" \
            -DLibRingClient_DIR="${INSTALL}/lrc/lib/cmake/LibRingClient" $static
Ciro Santilli's avatar
Ciro Santilli committed
109
fi
110
make -j${proc}
Ciro Santilli's avatar
Ciro Santilli committed
111
make_install $global