aboutsummaryrefslogtreecommitdiff
path: root/build.sh
blob: 5ca2ea664a35ea2f5888e08f0af8813a06bcb517 (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
#!/bin/sh

set -e

this_script_path=$(readlink -f "$0")
this_script_dir=$(dirname "$this_script_path")
source_files=$(readlink -f $(find "$this_script_dir/src" -name "*.c"))

if [ -z "$CC" ]; then
    CC=cc
fi

CFLAGS=""
LIBS=""
if [ ! -z "$SANITIZE_ADDRESS" ]; then
    CFLAGS+="-fsanitize=address "
    LIBS+="-lasan "
fi

CFLAGS+="-Wall -Wextra -Werror -g -O0 -DDEBUG -std=c89 -pedantic -D_GNU_SOURCE"
LIBS+="-pthread"

set -x
time "$CC" $source_files $CFLAGS $LIBS -shared -fpic -o libamalgam.so
set +x
if [ -z "$NO_TEST" ]; then
    source_files_tests=$(readlink -f $(find "$this_script_dir/tests" -name "*.c"))
    set -x
    time "$CC" $source_files_tests $CFLAGS $LIBS -o test "$this_script_dir/libamalgam.so"
fi