-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompile.sh
executable file
·64 lines (50 loc) · 1.54 KB
/
compile.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
57
58
59
60
61
62
63
64
#! /usr/bin/env bash
set -o errexit -o nounset -o pipefail -o xtrace
: ${PREFIX:="."}
declare -a SRC
SRC=(htable rng utils rows store acc rotate query)
declare -a BIN
BIN=(load dump query rotate ingest merge count)
declare -a TEST
TEST=(index coder store)
CC=${OTHERC:-gcc}
LEAKCHECK_ENABLED=${LEAKCHECK_ENABLED:-}
CFLAGS="-ggdb -O3 -march=native -pipe -std=gnu11 -D_GNU_SOURCE"
CFLAGS="$CFLAGS -I${PREFIX}/src"
CFLAGS="$CFLAGS -Werror -Wall -Wextra"
CFLAGS="$CFLAGS -Wundef"
CFLAGS="$CFLAGS -Wcast-align"
CFLAGS="$CFLAGS -Wwrite-strings"
CFLAGS="$CFLAGS -Wunreachable-code"
CFLAGS="$CFLAGS -Wformat=2"
CFLAGS="$CFLAGS -Wswitch-enum"
CFLAGS="$CFLAGS -Wswitch-default"
CFLAGS="$CFLAGS -Winit-self"
CFLAGS="$CFLAGS -Wno-strict-aliasing"
CFLAGS="$CFLAGS -fno-strict-aliasing"
CFLAGS="$CFLAGS -Wno-implicit-fallthrough"
OBJ=""
for src in "${SRC[@]}"; do
$CC -c -o "$src.o" "${PREFIX}/src/$src.c" $CFLAGS
OBJ="$OBJ $src.o"
done
ar rcs librill.a $OBJ
for bin in "${BIN[@]}"; do
$CC -o "rill_$bin" "${PREFIX}/src/rill_$bin.c" librill.a $CFLAGS
done
for test in "${TEST[@]}"; do
$CC -o "test_$test" "${PREFIX}/test/${test}_test.c" librill.a $CFLAGS
"./test_$test"
done
# this one takes a while so it's usually run manually
$CC -o "test_rotate" "${PREFIX}/test/rotate_test.c" librill.a $CFLAGS
if [ -n "$LEAKCHECK_ENABLED" ]; then
for test in "{TEST[@]}"; do
valgrind \
--leak-check=full \
--track-origins=yes \
--trace-children=yes \
--error-exitcode=1 \
"./test_$test"
done
fi