install.sh 2.16 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
Alexandre Lision's avatar
Alexandre Lision committed
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=''
Alexandre Lision's avatar
Alexandre Lision committed
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}"
    ;;
Alexandre Lision's avatar
Alexandre Lision committed
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 64
DAEMON="$(pwd)"
cd contrib
mkdir -p native
cd native
../bootstrap
65
make
Ciro Santilli's avatar
Ciro Santilli committed
66 67
cd "${DAEMON}"
./autogen.sh
68 69 70 71 72 73

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

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

cd "${TOP}/lrc"
aviau's avatar
aviau committed
83 84
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
Ciro Santilli's avatar
Ciro Santilli committed
85
if $global; then
Alexandre Lision's avatar
Alexandre Lision committed
86
  cmake .. -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH -DCMAKE_BUILD_TYPE=Debug $static
Ciro Santilli's avatar
Ciro Santilli committed
87
else
88 89 90 91
  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
92
fi
93
make -j${proc}
Ciro Santilli's avatar
Ciro Santilli committed
94 95
make_install $global

Alexandre Lision's avatar
Alexandre Lision committed
96
cd "${TOP}/${client}"
aviau's avatar
aviau committed
97 98
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
Ciro Santilli's avatar
Ciro Santilli committed
99
if $global; then
Alexandre Lision's avatar
Alexandre Lision committed
100
  cmake .. -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH $static
Ciro Santilli's avatar
Ciro Santilli committed
101
else
102 103 104 105
  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
106
fi
107
make -j${proc}
Ciro Santilli's avatar
Ciro Santilli committed
108
make_install $global