summaryrefslogtreecommitdiff
path: root/.circleci/prepare-system.sh
blob: 5d4d630bcb2c08f5fc90bab64954fadfd73ea1ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
# vim: sw=2 et
set -euo pipefail

fail() {
  echo "ERROR: $*" >&2
  exit 1
}

case "$(uname)" in
  Linux)
    if [[ -n ${TARGET:-} ]]; then
      if [[ $TARGET = FreeBSD ]]; then
        # cross-compiling to FreeBSD
        add-apt-repository -y ppa:hvr/ghc
        apt-get update -qq
        apt-get install -qy ghc-8.0.2 cabal-install  alex happy ncurses-dev git openssh-client make automake autoconf gcc perl python3 texinfo xz-utils
        cabal update
        cabal install --reinstall hscolour
        ln -s $HOME/.cabal/bin/HsColour /usr/local/bin/HsColour
      else
        fail "TARGET=$target not supported"
      fi
    else
      # assuming Ubuntu
      apt-get update -qq
      apt-get install -qy git openssh-client make automake autoconf gcc perl python3 texinfo xz-utils
      cabal update
      cabal install --reinstall hscolour
    fi
    ;;
  Darwin)
    if [[ -n ${TARGET:-} ]]; then
      fail "uname=$(uname) not supported for cross-compilation"
    fi
    brew install ghc cabal-install python3 ncurses
    cabal update
    cabal install --reinstall alex happy haddock hscolour
    # put them on the $PATH, don't fail if already installed
    ln -s $HOME/.cabal/bin/alex /usr/local/bin/alex || true
    ln -s $HOME/.cabal/bin/happy /usr/local/bin/happy || true
    ln -s $HOME/.cabal/bin/hscolour /usr/local/bin/hscolour || true
    ;;
  *)
    fail "uname=$(uname) not supported"
esac