Making...

This commit is contained in:
Ognjen Milan Robovic 2023-12-29 07:41:35 -05:00
parent 0aa8ec2987
commit 95aecd2be9
2 changed files with 77 additions and 0 deletions

44
make.sh Normal file
View File

@ -0,0 +1,44 @@
#!/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

33
makefile Normal file
View File

@ -0,0 +1,33 @@
.PHONY: all debug release clean
CFLAGS := -std=gnu17 -pedantic -Wall -Wextra ${CFLAGS}
LDLIBS :=
sources := source/engine.c \
source/game.c \
source/main.c \
source/menu.c \
source/render.c \
source/source.c \
source/system.c
obj = ${sources:.c=.o}
dep = ${sources:.c=.d}
.c.o:
$(CC) -MD -MP $(CFLAGS) -c $< -o $@
all: debug
debug: CFLAGS += -g
release: CFLAGS += -O3
debug release: umorna
umorna: $(obj)
$(CC) $(LDLIBS) $< -o $@
clean:
rm -f umorna ${obj} ${dep}
-include ${dep}