forked from stedolan/ocaml-afl-persistent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·56 lines (44 loc) · 1.25 KB
/
build.sh
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
#!/bin/sh
set -e
set -x
cd `dirname $0`
rm -rf _build/; rm -f afl-persistent.config
mkdir _build; cd _build
ocamlc='ocamlc -g -bin-annot'
ocamlopt='ocamlopt -g -bin-annot'
echo 'print_string "hello"' > afl_check.ml
if ocamlopt -dcmm -c afl_check.ml 2>&1 | grep -q caml_afl; then
afl_always=true
else
afl_always=false
fi
if [ "$(ocamlopt -afl-instrument afl_check.ml -o test 2>/dev/null && ./test)" = "hello" ]; then
ocamlopt="$ocamlopt -afl-inst-ratio 0"
afl_available=true
elif [ "$(ocamlopt -version)" = 4.04.0+afl ]; then
# hack for the backported 4.04+afl branch
export AFL_INST_RATIO=0
afl_available=true
else
afl_available=false
fi
cat > ../afl-persistent.config <<EOF
opam-version: "1.2"
afl-available: $afl_available
afl-always: $afl_always
EOF
cp ../aflPersistent.mli .
if [ $afl_available = true ]; then
cp ../aflPersistent.ml .
else
cp ../aflPersistent-stub.ml aflPersistent.ml
fi
$ocamlc -c aflPersistent.mli
$ocamlc -c aflPersistent.ml
$ocamlc -a aflPersistent.cmo -o afl-persistent.cma
$ocamlopt -c aflPersistent.ml
$ocamlopt -a aflPersistent.cmx -o afl-persistent.cmxa
# test
cp ../test.ml .
ocamlc unix.cma afl-persistent.cma test.ml -o test && ./test
ocamlopt unix.cmxa afl-persistent.cmxa test.ml -o test && ./test