-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.sh
executable file
·49 lines (37 loc) · 1.13 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
#! /usr/bin/env bash
set -o errexit -o nounset -o pipefail -o xtrace
: ${PREFIX:="."}
declare -a SRC
SRC=(htable mem prof pmem)
declare -a TEST
TEST=(basics)
CC=${OTHERC:-gcc}
CFLAGS="-ggdb -O3 -march=native -pipe -std=gnu11 -D_GNU_SOURCE"
CFLAGS="$CFLAGS -I${PREFIX}/src"
CFLAGS="$CFLAGS -fPIC"
CFLAGS="$CFLAGS -fvisibility=hidden"
CFLAGS="$CFLAGS -fno-strict-aliasing"
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 -Wno-implicit-fallthrough"
# Feels a bit dirty but oh well
grep -q '^#define PMEM_LIBUNWIND$' "${PREFIX}/config.h" && \
CFLAGS="$CFLAGS -lunwind"
OBJ=""
for src in "${SRC[@]}"; do
$CC -c -o "$src.o" "${PREFIX}/src/$src.c" $CFLAGS
OBJ="$OBJ $src.o"
done
$CC -o libpmem.so -shared $OBJ
for test in "${TEST[@]}"; do
$CC -o "test_$test" "${PREFIX}/test/$test.c" $CFLAGS
LD_PRELOAD=./libpmem.so "./test_$test"
done