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

set -ex

global=false
13 14
static=''
while getopts gs OPT; do
Ciro Santilli's avatar
Ciro Santilli committed
15 16 17 18
  case "$OPT" in
    g)
      global='true'
    ;;
19 20 21
    s)
      static='-DENABLE_STATIC=true'
    ;;
Ciro Santilli's avatar
Ciro Santilli committed
22 23 24 25 26 27 28 29 30
    \?)
      exit 1
    ;;
  esac
done

make_install() {
  if $1; then
    sudo make install
Ciro Santilli's avatar
Ciro Santilli committed
31 32 33
    # 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
34 35 36 37 38 39 40 41
  else
    make install
  fi
}

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

aviau's avatar
aviau committed
42 43 44 45 46 47 48
if $global; then
    BUILDDIR="build-global"
else
    BUILDDIR="build-local"
fi

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

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

cd "${TOP}/client-gnome"
aviau's avatar
aviau committed
77 78
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
Ciro Santilli's avatar
Ciro Santilli committed
79
if $global; then
80
  cmake .. $static
Ciro Santilli's avatar
Ciro Santilli committed
81
else
82
  cmake .. -DCMAKE_INSTALL_PREFIX="${INSTALL}/client-gnome" -DLibRingClient_DIR="${INSTALL}/lrc/lib/cmake/LibRingClient" $static
Ciro Santilli's avatar
Ciro Santilli committed
83 84 85
fi
make
make_install $global