aboutsummaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..95ea230
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+cd ${0%/*} # go to project root
+
+FLAGS="-Wall -Wextra -g -pedantic"
+FLAGS_DISPLAY="-lraylib -lm -lpthread -lGL -ldl -lrt -lX11"
+SRC="src"
+BIN="bin"
+OBJ="obj"
+RUN=0
+VALGRIND=""
+
+function __run__ {
+ RUN=1
+}
+
+function __valgrind__ {
+ VALGRIND=valgrind
+ RUN=1
+}
+
+function __clean__ {
+ rm -rf $BIN
+ rm -rf $OBJ
+ kill $( ps -q $$ -o pgid= ) # exit
+}
+
+set -xe
+
+if ! { [[ $# -eq 0 ]]; } 2> /dev/null
+then
+ __$1__
+fi
+
+
+mkdir -p $BIN
+mkdir -p $OBJ
+
+gcc -c -o $OBJ/main.o $SRC/main.c
+gcc -c -o $OBJ/display.o $SRC/display.c
+gcc -o $BIN/main $OBJ/main.o $OBJ/display.o $FLAGS $FLAGS_DISPLAY
+
+if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null
+then
+ $BIN/main
+fi