45 lines
725 B
Bash
45 lines
725 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
set -xe
|
||
|
|
||
|
CC=clang
|
||
|
CFLAGS="-std=gnu17 -Weverything -Werror"
|
||
|
LDLIBS="-lraylib"
|
||
|
|
||
|
TARGET=umorna
|
||
|
|
||
|
build_type="$1"
|
||
|
|
||
|
if [ -z "$build_type" ] || \
|
||
|
[ "$build_type" = debug ]; then
|
||
|
CFLAGS+=" -O0 -g"
|
||
|
elif [ "$build_type" = "release" ]; then
|
||
|
CFLAGS+=" -O3 -flto"
|
||
|
fi
|
||
|
|
||
|
sources=(
|
||
|
"source/engine.c"
|
||
|
"source/render.c"
|
||
|
"source/game.c"
|
||
|
"source/menu.c"
|
||
|
"source/main.c"
|
||
|
)
|
||
|
|
||
|
objects=()
|
||
|
|
||
|
updated=""
|
||
|
|
||
|
for source in "${sources[@]}"; do
|
||
|
obj="${source%.*}.o"
|
||
|
objects+=("$obj")
|
||
|
|
||
|
if [ "$source" -nt "$obj" ]; then
|
||
|
"$CC" $CFLAGS -c "$source" -o "$obj"
|
||
|
updated="y"
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
if [ ! -f "$TARGET" ] || [ -n "$updated" ]; then
|
||
|
"$CC" $CFLAGS $LDLIBS "${objects[@]}" -o "$TARGET"
|
||
|
fi
|