summaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh42
1 files changed, 20 insertions, 22 deletions
diff --git a/build.sh b/build.sh
index 80f3d5a..e602edb 100755
--- a/build.sh
+++ b/build.sh
@@ -1,31 +1,29 @@
1#!/bin/sh 1#!/bin/sh
2set -eu 2set -eu
3 3
4# Toolchain 4script_dir="$(dirname "$(readlink -f "$0")")"
5CC=clang 5cd "$script_dir"
6 6
7# Files 7build_dir="build"
8SRC=main.c 8mkdir -p "$build_dir"
9OUT=main
10 9
11# Include paths 10compile()
12INCLUDES="-I." 11{
12 source="$1"
13 out="$2"
14 flags="${3:-}"
13 15
14# Compiler flags 16 common_flags="-I. -Wall -Wextra -Wno-unused-function -Wno-unused-variable"
15CFLAGS=" 17 linker_flags="-lX11 -lm"
16-g
17-O0
18"
19 18
20# Linker flags 19 flags="$common_flags $flags $linker_flags"
21LDFLAGS="
22-lX11
23-I.
24-lm
25"
26 20
27echo "==> Building $OUT" 21 gcc $flags "$(readlink -f "$source")" -o "$build_dir"/"$out"
28$CC $CFLAGS $INCLUDES "$SRC" -o "$OUT" $LDFLAGS 22}
23
24# Build core shared lib
25compile "source/core/core.h" "libcore.so" "-fPIC -shared -DCORE_UNITY"
26
27# Build app
28compile "source/core/core.c" "app" "-L$build_dir -lcore"
29 29
30echo "==> Running $OUT"
31./"$OUT"