summaryrefslogtreecommitdiff
path: root/.circleci/build.sh
blob: 74d98fa380938d8283453af7556ac75ad697435c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
# vim: sw=2 et

set -euo pipefail

fail() {
  echo "ERROR: $*" >&2
  exit 1
}

echo 'BUILD_SPHINX_HTML = NO' > mk/validate.mk
echo 'BUILD_SPHINX_PDF = NO' >> mk/validate.mk

cat > mk/build.mk <<EOF
V=1
HADDOCK_DOCS=YES
LATEX_DOCS=YES
HSCOLOUR_SRCS=YES
BUILD_DOCBOOK_HTML=YES
BeConservative=YES
EOF

export THREADS=8
export SKIP_PERF_TESTS=YES
export VERBOSE=2

function run_build() {
    ./boot
    ./configure "$@"
    make -j$THREADS
    make fasttest
    make binary-dist
}

case "$(uname)" in
  Linux)
    if [[ -n ${TARGET:-} ]]; then
      if [[ $TARGET = FreeBSD ]]; then
        # cross-compiling to FreeBSD
        echo 'HADDOCK_DOCS = NO' >> mk/build.mk
        echo 'WERROR=' >> mk/build.mk
        export PATH=/opt/ghc/bin:$PATH
        run_build --target=x86_64-unknown-freebsd10
      else
        fail "TARGET=$target not supported"
      fi
    else
      run_build
    fi
    ;;
  Darwin)
    if [[ -n ${TARGET:-} ]]; then
      fail "uname=$(uname) not supported for cross-compilation"
    fi
    run_build
    ;;
  *)
    fail "uname=$(uname) not supported"
esac