74d5ea70d56d4d768d78b751fc71b98f355dcf2a
[ghc.git] / .circleci / build.sh
1 #!/usr/bin/env bash
2 # vim: sw=2 et
3
4 set -euo pipefail
5
6 fail() {
7 echo "ERROR: $*" >&2
8 exit 1
9 }
10
11 echo 'BUILD_SPHINX_HTML = NO' > mk/validate.mk
12 echo 'BUILD_SPHINX_PDF = NO' >> mk/validate.mk
13
14 cat > mk/build.mk <<EOF
15 V=1
16 HADDOCK_DOCS=YES
17 LATEX_DOCS=YES
18 HSCOLOUR_SRCS=YES
19 BUILD_DOCBOOK_HTML=YES
20 BeConservative=YES
21 EOF
22
23 export THREADS=8
24 export SKIP_PERF_TESTS=YES
25 export VERBOSE=2
26
27 function run_build() {
28 ./boot
29 ./configure "$@"
30 make -j$THREADS
31 make test
32 make binary-dist
33 }
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 export PATH=/opt/ghc/bin:$PATH
43 run_build --target=x86_64-unknown-freebsd10
44 else
45 fail "TARGET=$target not supported"
46 fi
47 else
48 run_build
49 fi
50 ;;
51 Darwin)
52 if [[ -n ${TARGET:-} ]]; then
53 fail "uname=$(uname) not supported for cross-compilation"
54 fi
55 run_build
56 ;;
57 *)
58 fail "uname=$(uname) not supported"
59 esac