forked from uucidl/uu.spdr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_examples_posix.sh
executable file
·73 lines (56 loc) · 1.88 KB
/
build_examples_posix.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
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
##
# NOTE(nicolas): SPDR does not need to be built outside of your
# project.
#
# You only need two things to use SPDR:
# - import the `./include` directory
# - add one of its `_unit.c` source files to your project
# - include "spdr/spdr.h" (C) or "spdr/spdr.hh" (C++)
set -u
RELH="$(dirname "${0}")"
HERE="$(cd "${RELH}" && pwd)"
OUTPUT="${HERE}"/output
CXX=${CXX:-$(which "c++")}
CC=${CC:-$(which "cc")}
CFLAGS=${CFLAGS:-}
cflags=(${CFLAGS} -Wall -Wextra)
cflags=(${cflags[@]})
[ -d "${OUTPUT}" ] || mkdir -p "${OUTPUT}"
printf "INFO building into %s\n" "${OUTPUT}"
# just to print the timing information about builds
origin="$(date "+%s")"
printf "%s\n" "${origin}"
PS4='T $(($(date "+%s") - ${origin}))\011'
set -x
## <BUILD EXAMPLES..
set -o errexit
EXAMPLES="${HERE}"/examples
# here is all you need:
SPDR=(-I"${HERE}"/include "${HERE}"/src/spdr_posix_unit.c -lrt)
D="${OUTPUT}"/test
"${CC}" "${cflags[@]}" -DTRACING_ENABLED=1 -ansi "${EXAMPLES}"/test.c -lm "${SPDR[@]}" \
-o "${D}"
printf "PROGRAM\t%s\n" "${D}"
D="${OUTPUT}"/test-scope
"${CC}" "${cflags[@]}" -DTRACING_ENABLED=1 "${EXAMPLES}"/test-scope.c -lm "${SPDR[@]}" \
-o "${D}"
printf "PROGRAM\t%s\n" "${D}"
D="${OUTPUT}"/test-mt
"${CC}" "${cflags[@]}" -DTRACING_ENABLED=1 -ansi "${EXAMPLES}"/test-mt.c -lpthread -lm "${SPDR[@]}" \
-o "${D}"
printf "PROGRAM\t%s\n" "${D}"
D="${OUTPUT}"/test-full
"${CC}" "${cflags[@]}" -DTRACING_ENABLED=1 -ansi "${EXAMPLES}"/test-full.c -lm "${SPDR[@]}" \
-o "${D}"
printf "PROGRAM\t%s\n" "${D}"
D="${OUTPUT}"/test-cxx
"${CXX}" "${cflags[@]}" -DTRACING_ENABLED=1 "${EXAMPLES}"/test-cxx.cc -lm "${SPDR[@]}" \
-o "${D}"
printf "PROGRAM\t%s\n" "${D}"
D="${OUTPUT}"/perf-test
"${CC}" "${cflags[@]}" -DTRACING_ENABLED=1 "${EXAMPLES}"/perf-test.c -lm -lpthread "${SPDR[@]}" \
-o "${D}"
printf "PROGRAM\t%s\n" "${D}"
## ..BUILD EXAMPLES>
set +x