summaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2023-04-09 02:02:51 +0300
committerkartofen <mladenovnasko0@gmail.com>2023-04-09 02:02:51 +0300
commitfc027f7d214028086178a7328926c9b14ead464d (patch)
treed2972055a06565f26a19626ac3fb26ead84e0766 /build.sh
map loading done
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh57
1 files changed, 57 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..6ddf9a4
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+cd ${0%/*} # go to project root
+
+NAME="main"
+
+DEBUG_FLAGS="-std=c99 -Wall -Wextra -g -pedantic -DDEBUG"
+# PROD_FLAGS="-std=c99 ???"
+SDL_FLAGS="`sdl2-config --cflags --libs`"
+FLAGS="$DEBUG_FLAGS $SDL_FLAGS"
+
+SRC="src"
+OBJ="obj"
+BIN="bin"
+FILES="files"
+RUN=0
+
+function __run__ {
+ RUN=1
+}
+
+function __leak__ {
+ VALGRND="valgrind --leak-check=full --show-leak-kinds=all -s"
+ RUN=1
+}
+
+function __prod__ {
+ FLAGS="$PROD_FLAGS $SDL_FLAGS"
+}
+
+function __clean__ {
+ rm -rf $BIN
+ rm -rf $OBJ
+ exit 0
+}
+
+set -xe
+
+mkdir -p $BIN
+mkdir -p $OBJ
+mkdir -p $FILES
+
+if ! { [[ $# -eq 0 ]]; } 2> /dev/null
+then
+ __$1__
+fi
+
+gcc -o $OBJ/main.o -c $SRC/main.c $FLAGS
+gcc -o $OBJ/player.o -c $SRC/player.c $FLAGS
+gcc -o $OBJ/sector.o -c $SRC/sector.c $FLAGS
+
+gcc -o $BIN/$NAME $OBJ/*.o $FLAGS
+
+if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null
+then
+ $VALGRND $BIN/$NAME
+fi