install.sh 1.65 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
Ciro Santilli's avatar
Ciro Santilli committed
10 11 12 13

set -ex

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

make_install() {
  if $1; then
    sudo make install
Ciro Santilli's avatar
Ciro Santilli committed
36 37 38
    # 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
39 40 41 42 43 44 45 46
  else
    make install
  fi
}

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

aviau's avatar
aviau committed
47 48 49 50 51 52 53
if $global; then
    BUILDDIR="build-global"
else
    BUILDDIR="build-local"
fi

cd "${TOP}/daemon"
Ciro Santilli's avatar
Ciro Santilli committed
54 55 56 57 58 59 60 61 62
DAEMON="$(pwd)"
cd contrib
mkdir -p native
cd native
../bootstrap
make -j$(nproc)
cd "${DAEMON}"
./autogen.sh
if $global; then
Alexandre Lision's avatar
Alexandre Lision committed
63
  ./configure $CONFIGURE_FLAGS
Ciro Santilli's avatar
Ciro Santilli committed
64
else
Alexandre Lision's avatar
Alexandre Lision committed
65
  ./configure $CONFIGURE_FLAGS --prefix="${INSTALL}/daemon"
Ciro Santilli's avatar
Ciro Santilli committed
66 67 68 69 70
fi
make -j$(nproc)
make_install $global

cd "${TOP}/lrc"
aviau's avatar
aviau committed
71 72
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
Ciro Santilli's avatar
Ciro Santilli committed
73
if $global; then
74
  cmake .. -DCMAKE_BUILD_TYPE=Debug $static
Ciro Santilli's avatar
Ciro Santilli committed
75
else
76
  cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="${INSTALL}/lrc" -DRING_BUILD_DIR="${DAEMON}/src" $static
Ciro Santilli's avatar
Ciro Santilli committed
77 78 79 80
fi
make
make_install $global

Alexandre Lision's avatar
Alexandre Lision committed
81
cd "${TOP}/${client}"
aviau's avatar
aviau committed
82 83
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
Ciro Santilli's avatar
Ciro Santilli committed
84
if $global; then
85
  cmake .. $static
Ciro Santilli's avatar
Ciro Santilli committed
86
else
Alexandre Lision's avatar
Alexandre Lision committed
87
  cmake .. -DCMAKE_INSTALL_PREFIX="${INSTALL}/${client}" -DLibRingClient_DIR="${INSTALL}/lrc/lib/cmake/LibRingClient" $static
Ciro Santilli's avatar
Ciro Santilli committed
88 89 90
fi
make
make_install $global