This repository has been archived by the owner on Aug 15, 2024. It is now read-only.
forked from Vulcalien/minicraft-gba
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
103 lines (74 loc) · 1.97 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Vulcalien's GBA Makefile
#
# Made for the 'gcc' compiler
# === DETECT OS ===
ifeq ($(OS),Windows_NT)
CURRENT_OS := WINDOWS
else
CURRENT_OS := UNIX
endif
# ========= EDIT HERE =========
OUT_FILENAME := minicraft
SRC_DIR := src
OBJ_DIR := obj
BIN_DIR := bin
SRC_SUBDIRS := scene images entity
ifeq ($(CURRENT_OS),UNIX)
CC := arm-none-eabi-gcc
AS := arm-none-eabi-as
OBJCOPY := arm-none-eabi-objcopy
EMULATOR := mgba-qt
else ifeq ($(CURRENT_OS),WINDOWS)
CC :=
AS :=
OBJCOPY :=
EMULATOR :=
endif
CPPFLAGS := -Iinclude -MMD -MP
CFLAGS := -O3 -fomit-frame-pointer -marm -mcpu=arm7tdmi\
-Wall -pedantic
ASFLAGS := -mcpu=arm7tdmi
LDFLAGS := -Tlnkscript -nostartfiles
LDLIBS :=
# =============================
ifeq ($(CURRENT_OS),UNIX)
MKDIR := mkdir
MKDIRFLAGS := -p
RM := rm
RMFLAGS := -rfv
else ifeq ($(CURRENT_OS),WINDOWS)
MKDIR := mkdir
MKDIRFLAGS :=
RM := rmdir
RMFLAGS := /Q /S
endif
# === OTHER ===
SRC := $(wildcard $(SRC_DIR)/*.c)\
$(foreach DIR,$(SRC_SUBDIRS),$(wildcard $(SRC_DIR)/$(DIR)/*.c))
OBJ := $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
OUT_ELF := $(BIN_DIR)/$(OUT_FILENAME).elf
OUT := $(BIN_DIR)/$(OUT_FILENAME).gba
OBJ_DIRECTORIES := $(OBJ_DIR) $(foreach DIR,$(SRC_SUBDIRS),$(OBJ_DIR)/$(DIR))
# === TARGETS ===
.PHONY: all run build res clean release
all: build
run:
$(EMULATOR) ./$(OUT)
build: $(OUT)
clean:
@$(RM) $(RMFLAGS) $(BIN_DIR) $(OBJ_DIR) src/res
$(OUT): $(OUT_ELF)
$(OBJCOPY) -O binary $^ $@
$(OUT_ELF): $(OBJ_DIR)/crt0.o $(OBJ) | $(BIN_DIR)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(OBJ_DIR)/crt0.o: $(SRC_DIR)/crt0.s | $(OBJ_DIRECTORIES)
$(AS) $(ASFLAGS) -o $@ $<
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIRECTORIES)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(BIN_DIR) $(OBJ_DIRECTORIES) src/res src/res/sounds:
$(MKDIR) $(MKDIRFLAGS) "$@"
res: src/res src/res/sounds
scripts/convert-resources.py res/resources.json
release:
scripts/release.sh "$(OUT)"
-include $(OBJ:.o=.d)