Browse Source

Making...

master
Ognjen Milan Robovic 4 months ago
parent
commit
95aecd2be9
2 changed files with 77 additions and 0 deletions
  1. +44
    -0
      make.sh
  2. +33
    -0
      makefile

+ 44
- 0
make.sh 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
- 0
makefile 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}

Loading…
Cancel
Save