5d4d630bcb2c08f5fc90bab64954fadfd73ea1ae
[ghc.git] / .circleci / prepare-system.sh
1 #!/usr/bin/env bash
2 # vim: sw=2 et
3 set -euo pipefail
4
5 fail() {
6 echo "ERROR: $*" >&2
7 exit 1
8 }
9
10 case "$(uname)" in
11 Linux)
12 if [[ -n ${TARGET:-} ]]; then
13 if [[ $TARGET = FreeBSD ]]; then
14 # cross-compiling to FreeBSD
15 add-apt-repository -y ppa:hvr/ghc
16 apt-get update -qq
17 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
18 cabal update
19 cabal install --reinstall hscolour
20 ln -s $HOME/.cabal/bin/HsColour /usr/local/bin/HsColour
21 else
22 fail "TARGET=$target not supported"
23 fi
24 else
25 # assuming Ubuntu
26 apt-get update -qq
27 apt-get install -qy git openssh-client make automake autoconf gcc perl python3 texinfo xz-utils
28 cabal update
29 cabal install --reinstall hscolour
30 fi
31 ;;
32 Darwin)
33 if [[ -n ${TARGET:-} ]]; then
34 fail "uname=$(uname) not supported for cross-compilation"
35 fi
36 brew install ghc cabal-install python3 ncurses
37 cabal update
38 cabal install --reinstall alex happy haddock hscolour
39 # put them on the $PATH, don't fail if already installed
40 ln -s $HOME/.cabal/bin/alex /usr/local/bin/alex || true
41 ln -s $HOME/.cabal/bin/happy /usr/local/bin/happy || true
42 ln -s $HOME/.cabal/bin/hscolour /usr/local/bin/hscolour || true
43 ;;
44 *)
45 fail "uname=$(uname) not supported"
46 esac