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