7d8cac60a29cf6abff7d004bbd503f7a5d8369a3
[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 hackage_index_state="@1522046735"
11
12 if [[ -z ${BUILD_SPHINX_HTML:-} ]]; then BUILD_SPHINX_HTML=YES; fi
13 if [[ -z ${BUILD_SPHINX_PDF:-} ]]; then BUILD_SPHINX_PDF=YES; fi
14
15 cat > mk/build.mk <<EOF
16 V=1
17 HADDOCK_DOCS=YES
18 LATEX_DOCS=YES
19 HSCOLOUR_SRCS=YES
20 BUILD_SPHINX_HTML=$BUILD_SPHINX_HTML
21 BUILD_SPHINX_PDF=$BUILD_SPHINX_PDF
22 BeConservative=YES
23 EOF
24
25 case "$(uname)" in
26 Linux)
27 if [[ -n ${TARGET:-} ]]; then
28 if [[ $TARGET = FreeBSD ]]; then
29 # cross-compiling to FreeBSD
30 add-apt-repository -y ppa:hvr/ghc
31 apt-get update -qq
32 apt-get install -qy ghc-8.0.2 cabal-install-1.24 alex happy \
33 ncurses-dev git make automake autoconf gcc perl \
34 python3 texinfo xz-utils lbzip2 patch
35 cabal update
36 cabal install --reinstall hscolour --index-state=$hackage_index_state
37 ln -s $HOME/.cabal/bin/HsColour /usr/local/bin/HsColour
38
39 echo 'HADDOCK_DOCS = NO' >> mk/build.mk
40 echo 'WERROR=' >> mk/build.mk
41 # https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables
42 echo 'export PATH=/opt/ghc/bin:$PATH' >> $BASH_ENV
43 else
44 fail "TARGET=$target not supported"
45 fi
46 else
47 cabal update -v
48 cabal install --reinstall hscolour
49 sudo ln -s /home/ghc/.cabal/bin/HsColour /usr/local/bin/HsColour || true
50 fi
51 ;;
52
53 Darwin)
54 if [[ -n ${TARGET:-} ]]; then
55 fail "uname=$(uname) not supported for cross-compilation"
56 fi
57 # It looks like we already have python2 here and just installing python3
58 # does not work.
59 brew upgrade python
60 brew install ghc cabal-install ncurses gmp
61
62 pip3 install sphinx
63 # PDF documentation disabled as MacTeX apparently doesn't include xelatex.
64 #brew cask install mactex
65
66 cabal update
67 cabal install --reinstall alex happy haddock hscolour --index-state=$hackage_index_state
68 # put them on the $PATH, don't fail if already installed
69 ln -s $HOME/.cabal/bin/alex /usr/local/bin/alex || true
70 ln -s $HOME/.cabal/bin/happy /usr/local/bin/happy || true
71 ln -s $HOME/.cabal/bin/HsColour /usr/local/bin/HsColour || true
72 echo "libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp" >> mk/build.mk
73 ;;
74 *)
75 fail "uname=$(uname) not supported"
76 esac
77
78 echo "================================================="
79 echo "Build.mk:"
80 echo ""
81 cat mk/build.mk
82 echo "================================================="