install.sh 2.06 KB
Newer Older
Ciro Santilli's avatar
Ciro Santilli committed
1 2 3 4 5 6 7
#!/usr/bin/env bash

# Build and install to a local prefix under this repository.

# Flags:

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

set -ex

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

make_install() {
  if $1; then
    sudo make install
Ciro Santilli's avatar
Ciro Santilli committed
41 42 43
    # 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
44 45 46 47 48 49 50 51
  else
    make install
  fi
}

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

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

cd "${TOP}/daemon"
Ciro Santilli's avatar
Ciro Santilli committed
59 60 61 62 63
DAEMON="$(pwd)"
cd contrib
mkdir -p native
cd native
../bootstrap
64
make
Ciro Santilli's avatar
Ciro Santilli committed
65 66 67
cd "${DAEMON}"
./autogen.sh
if $global; then
68
  ./configure --disable-shared $CONFIGURE_FLAGS
Ciro Santilli's avatar
Ciro Santilli committed
69
else
70
  ./configure --disable-shared $CONFIGURE_FLAGS --prefix="${INSTALL}/daemon"
Ciro Santilli's avatar
Ciro Santilli committed
71
fi
Alexandre Lision's avatar
Alexandre Lision committed
72
make -j${proc}
Ciro Santilli's avatar
Ciro Santilli committed
73 74 75
make_install $global

cd "${TOP}/lrc"
aviau's avatar
aviau committed
76 77
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
Ciro Santilli's avatar
Ciro Santilli committed
78
if $global; then
Alexandre Lision's avatar
Alexandre Lision committed
79
  cmake .. -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH -DCMAKE_BUILD_TYPE=Debug $static
Ciro Santilli's avatar
Ciro Santilli committed
80
else
81 82 83 84
  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
85
fi
86
make -j${proc}
Ciro Santilli's avatar
Ciro Santilli committed
87 88
make_install $global

Alexandre Lision's avatar
Alexandre Lision committed
89
cd "${TOP}/${client}"
aviau's avatar
aviau committed
90 91
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
Ciro Santilli's avatar
Ciro Santilli committed
92
if $global; then
Alexandre Lision's avatar
Alexandre Lision committed
93
  cmake .. -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH $static
Ciro Santilli's avatar
Ciro Santilli committed
94
else
95 96 97 98
  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
99
fi
100
make -j${proc}
Ciro Santilli's avatar
Ciro Santilli committed
101
make_install $global