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