Move Hadrian executable to /hadrian.
[ghc.git] / build.sh
1 #!/usr/bin/env bash
2
3 set -euo pipefail
4
5 # readlink on os x, doesn't support -f, to prevent the
6 # need of installing coreutils (e.g. through brew, just
7 # for readlink, we use the follownig substitute.
8 #
9 # source: http://stackoverflow.com/a/1116890
10 function rl {
11 TARGET_FILE="$1"
12
13 cd "$(dirname "$TARGET_FILE")"
14 TARGET_FILE="$(basename "$TARGET_FILE")"
15
16 # Iterate down a (possible) chain of symlinks
17 while [ -L "$TARGET_FILE" ]
18 do
19 TARGET_FILE="$(readlink "$TARGET_FILE")"
20 cd "$(dirname "$TARGET_FILE")"
21 TARGET_FILE="$(basename "$TARGET_FILE")"
22 done
23
24 # Compute the canonicalized name by finding the physical path
25 # for the directory we're in and appending the target file.
26 PHYS_DIR="$(pwd -P)"
27 RESULT="$PHYS_DIR/$TARGET_FILE"
28 echo "$RESULT"
29 }
30
31 root="$(dirname "$(rl "$0")")"
32
33 mkdir -p "$root/../_build/hadrian"
34
35 ghc \
36 "$root/src/Main.hs" \
37 -Wall \
38 -fno-warn-name-shadowing \
39 -XRecordWildCards \
40 -i"$root/src" \
41 -rtsopts \
42 -with-rtsopts=-I0 \
43 -threaded \
44 -outputdir="$root/../_build/hadrian" \
45 -j -O \
46 -o "$root/hadrian"
47
48 "$root/hadrian" \
49 --lint \
50 --directory "$root/.." \
51 --colour \
52 "$@"