summaryrefslogtreecommitdiff
path: root/dht/p
blob: 357606adf9631ff803ed74f540e8d555729b99d9 (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
#!/bin/bash

rootname=$(cat /etc/debian_chroot 2>/dev/null)
echo $PATH | grep '\.stack' >/dev/null && rootname="stack"
BUILDB=
for b in build/b/Presence/monitortty.o .stack-work/dist/x86_64-linux/Cabal-*/build/Presence/monitortty.o; do
	if [ -f $b ]; then
		BUILDB=$(dirname $(dirname $b))
		break
	fi
done
[ -z "$BUILDB" ] && { echo "Where is monitortty.o?"; exit 1; }

opts="-rtsopts -hisuf p_hi -osuf p_o -prof -fprof-auto -fprof-auto-exported"
warn="-freverse-errors -fwarn-unused-imports -Wmissing-signatures -fdefer-typed-holes"
exts="-XOverloadedStrings -XRecordWildCards"
defs="-DBENCODE_AESON -DTHREAD_DEBUG"
hidden="crypto-random crypto-api crypto-numbers cryptohash prettyclass"
[ "$rootname" == "stack" ] && hidden=""
hide=""
for h in $hidden;do
	# too slow.
	# ghc-pkg latest $h && hide="$hide -hide-package $h"
	hide="$hide -hide-package $h"
done

if [ "$rootname" == "stretch" ]
    then
        echo "Building with cryptonite backport. (chroot = $rootname)"
        defs="$defs -DCRYPTONITE_BACKPORT -icryptonite-backport"
        warn="$BUILDB/cbits/cryptonite_salsa.o $BUILDB/cbits/cryptonite_xsalsa.o $warn"
    fi

root=${0%/*}
cd "$root"

me=${0##*/}
me=${me%.*}
set -x
ghc -threaded                        \
    $opts                            \
    $hide                            \
    $exts                            \
    $defs                            \
    -hidir build/$me$rootname -odir build/$me$rootname \
    -iPresence                       \
    -iArchive                        \
    -isrc                            \
    $BUILDB/Presence/monitortty.o    \
    $warn                            \
    "$@"