9a16c0128475beae69dd4c797c4c04495b080b2f
[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 echo 'HADDOCK_DOCS = NO' >> mk/build.mk
31 echo 'WERROR=' >> mk/build.mk
32 # https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables
33 echo 'export PATH=/opt/ghc/bin:$PATH' >> $BASH_ENV
34 else
35 fail "TARGET=$target not supported"
36 fi
37 fi
38 ;;
39
40 Darwin)
41 if [[ -n ${TARGET:-} ]]; then
42 fail "uname=$(uname) not supported for cross-compilation"
43 fi
44 # It looks like we already have python2 here and just installing python3
45 # does not work.
46 brew upgrade python
47 brew install ghc cabal-install ncurses gmp
48
49 pip3 install sphinx
50 # PDF documentation disabled as MacTeX apparently doesn't include xelatex.
51 #brew cask install mactex
52
53 cabal update
54 cabal install --reinstall alex happy haddock hscolour --index-state=$hackage_index_state
55 # put them on the $PATH, don't fail if already installed
56 ln -s $HOME/.cabal/bin/alex /usr/local/bin/alex || true
57 ln -s $HOME/.cabal/bin/happy /usr/local/bin/happy || true
58 ln -s $HOME/.cabal/bin/HsColour /usr/local/bin/HsColour || true
59 echo "libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp" >> mk/build.mk
60 ;;
61 *)
62 fail "uname=$(uname) not supported"
63 esac
64
65 echo "================================================="
66 echo "Build.mk:"
67 echo ""
68 cat mk/build.mk
69 echo "================================================="