Merge commit '5229c43ccf77bcbffeced01dccb27398d017fa34'
[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 echo 'BUILD_SPHINX_HTML = NO' > mk/validate.mk
11 echo 'BUILD_SPHINX_PDF = NO' >> mk/validate.mk
12
13 cat > mk/build.mk <<EOF
14 V=1
15 HADDOCK_DOCS=YES
16 LATEX_DOCS=YES
17 HSCOLOUR_SRCS=YES
18 BUILD_DOCBOOK_HTML=YES
19 BeConservative=YES
20 EOF
21
22 case "$(uname)" in
23 Linux)
24 if [[ -n ${TARGET:-} ]]; then
25 if [[ $TARGET = FreeBSD ]]; then
26 # cross-compiling to FreeBSD
27 add-apt-repository -y ppa:hvr/ghc
28 apt-get update -qq
29 apt-get install -qy ghc-8.0.2 cabal-install-1.24 alex happy \
30 ncurses-dev git make automake autoconf gcc perl \
31 python3 texinfo xz-utils
32 cabal update
33 cabal install --reinstall hscolour
34 ln -s $HOME/.cabal/bin/HsColour /usr/local/bin/HsColour
35
36 echo 'HADDOCK_DOCS = NO' >> mk/build.mk
37 echo 'WERROR=' >> mk/build.mk
38 # https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables
39 echo 'export PATH=/opt/ghc/bin:$PATH' >> $BASH_ENV
40 else
41 fail "TARGET=$target not supported"
42 fi
43 else
44 # assuming Ubuntu
45 apt-get install -qy git make automake autoconf gcc perl python3 texinfo xz-utils
46 cabal update
47 cabal install --reinstall hscolour
48 fi
49 ;;
50 Darwin)
51 if [[ -n ${TARGET:-} ]]; then
52 fail "uname=$(uname) not supported for cross-compilation"
53 fi
54 brew install ghc cabal-install python3 ncurses
55 cabal update
56 cabal install --reinstall alex happy haddock hscolour
57 # put them on the $PATH, don't fail if already installed
58 ln -s $HOME/.cabal/bin/alex /usr/local/bin/alex || true
59 ln -s $HOME/.cabal/bin/happy /usr/local/bin/happy || true
60 ln -s $HOME/.cabal/bin/hscolour /usr/local/bin/hscolour || true
61 ;;
62 *)
63 fail "uname=$(uname) not supported"
64 esac