Skip to content

Commit 5bc932a

Browse files
committed
Add support for release build
1 parent b3f59f0 commit 5bc932a

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

Makefile

+26-11
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,52 @@
11
# Compiler
2-
CC := gcc
2+
# CC := gcc
33

44
# Directories
55
SRC_DIR := src
6-
BIN_DIR := bin
6+
BUILD_DIR := build
77

88
# Source files
99
SRCS := $(wildcard $(SRC_DIR)/*.c)
1010

1111
# Object files
12-
OBJS := $(patsubst $(SRC_DIR)/%.c,$(BIN_DIR)/%.o,$(SRCS))
12+
DEBUG_OBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/debug/%.o,$(SRCS))
13+
RELEASE_OBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/release/%.o,$(SRCS))
1314

1415
# Executable file
1516
TARGET := Azzian
1617

1718
# Compiler flags
18-
CFLAGS := -Wall -Wextra -ggdb -std=c99 -Iinclude -Ilib
19+
DEBUG_CFLAGS := -ggdb -DDEBUG -Wall -Wextra -std=c17 -Iinclude -isystemlib
20+
RELEASE_CFLAGS := -Ofast -DNDEBUG -Wall -Wextra -std=c17 -Iinclude -isystemlib
1921

2022
# Linker flags
2123
LDFLAGS := -lraylib -lm
2224

25+
.PHONY: all debug release embed fmt clean
26+
2327
# Build target
24-
$(TARGET): $(OBJS)
25-
$(CC) $^ -o $@ $(LDFLAGS)
28+
all: debug
29+
30+
debug: $(DEBUG_OBJS)
31+
$(CC) $^ -o $(TARGET) $(LDFLAGS)
32+
33+
release: $(RELEASE_OBJS)
34+
$(CC) $^ -o $(TARGET) $(LDFLAGS)
2635

2736
# Compile source files
28-
$(BIN_DIR)/%.o: $(SRC_DIR)/%.c
29-
mkdir -p $(BIN_DIR)
30-
$(CC) $(CFLAGS) -c $< -o $@
37+
$(BUILD_DIR)/debug/%.o: $(SRC_DIR)/%.c
38+
@mkdir -p $(BUILD_DIR)/debug
39+
$(CC) $(DEBUG_CFLAGS) -c $< -o $@
40+
41+
$(BUILD_DIR)/release/%.o: $(SRC_DIR)/%.c
42+
@mkdir -p $(BUILD_DIR)/release
43+
$(CC) $(RELEASE_CFLAGS) -c $< -o $@
44+
45+
embed: embed_assets.py
46+
python $< $(SRC_DIR)/*.c
3147

3248
fmt:
3349
clang-format -i src/*.c include/*.h
3450

3551
clean:
36-
$(RM) -r -- $(BIN_DIR)/*.o $(TARGET)
37-
$(RM) -- Azzian
52+
$(RM) -r -- $(BUILD_DIR) $(TARGET)

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ If you would like to revert back the embedding of assets then either restore to
1616

1717
### Building and execution
1818
```shell
19-
$ make
19+
$ make # Debug build
20+
$ ./Azzian
21+
$ make release # Release build
2022
$ ./Azzian
2123
```
2224

src/main.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ void UpdateDrawFrame(void);
88

99
static bool quitGame = false;
1010

11-
int main() {
12-
InitWindow(1280, 720, "Test Game");
11+
int main(void) {
12+
#ifdef NDEBUG
13+
SetTraceLogLevel(LOG_NONE);
14+
#endif
15+
16+
InitWindow(1280, 720, "Azzian - DEBUG");
1317

1418
// Change it later to Title screen. Player should not go directly to the game screen.
1519
switch (currentScreen) {

0 commit comments

Comments
 (0)