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
104
105
106
107
108
|
RM = rm -f
TARGET = main
# platform is ds (desktop) or stm (stm32)
PLATFORM = ds
# if your editor uses compile_commands.json for autocomplete, you should run `make compile_commands.json` again
HOST=$(strip $(shell uname -o))
ifeq ($(PLATFORM),stm)
STM = true
include stm32.mk
endif
ifeq ($(PLATFORM),ds)
DESKTOP = true
include ds.mk
endif
SHARED_FLAGS += -g
SHARED_FLAGS += -Wall
SHARED_FLAGS += -Wextra
SHARED_FLAGS += -I.
# SHARED_FLAGS += -O1
LFLAGS += -lm
# LFLAGS += -lc
CFLAGS += $(if $(STM), -DHH_TARGET_STM32, )
CFLAGS += $(if $(DESKTOP), -DHH_TARGET_DESKTOP, )
LOCAL_SRCS += main.c \
ppu/internals.c \
ppu/ppu.c \
demo.c \
engine/engine.c \
engine/sprite_controller.c \
engine/player_controller.c \
engine/draw_screen.c \
engine/camera.c \
engine/maths.c \
engine/entity.c \
engine/bullet.c \
engine/title_screen.c \
engine/level_const.c \
engine/enemy.c \
engine/enemy_ai.c \
engine/animator.c \
game_loop/shop.c \
game_loop/gameplay.c \
game_loop/game_over.c \
game_loop/starting_screen.c
CFLAGS += $(SHARED_FLAGS)
LFLAGS += $(SHARED_FLAGS)
AFLAGS += $(SHARED_FLAGS)
SRCS += $(LOCAL_SRCS)
SRCS += $(if $(STM), $(STM_SRCS), )
SRCS += $(if $(DESKTOP), $(DESKTOP_SRCS), )
ifeq ($(PLATFORM),stm)
OBJS := $(patsubst %.c,%-stm.o, $(patsubst %.s,%-stm.o, $(SRCS)))
all: $(TARGET).bin
endif
ifeq ($(PLATFORM),ds)
OBJS := $(patsubst %.c,%-ds.o, $(SRCS))
all: $(TARGET)
endif
%-stm.o: %.s
$(CC) -c $(AFLAGS) $< -o $@
lib/%-stm.o: lib/%.c
$(CC) -c $(CFLAGS) -w $< -o $@
%-stm.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
$(TARGET).elf: $(OBJS)
$(LD) $^ $(LFLAGS) -o $@
$(TARGET).bin: $(TARGET).elf
$(OC) -O binary $< $@
$(OS) $<
PHONY += flash
flash: $(TARGET).bin
st-flash --reset write $(TARGET).bin 0x08000000
%-ds.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
$(TARGET): $(OBJS)
$(LD) $^ $(LFLAGS) -o $@
compile_commands.json: makefile stm32.mk ds.mk
compiledb make -Bn
../scripts/compiledb-full-path-mingw.sh compile_commands.json
PHONY += format
format:
clang-format -i $(LOCAL_SRCS) $(DESKTOP_SRCS)
clang-tidy --fix-errors $(LOCAL_SRCS) $(DESKTOP_SRCS)
PHONY += clean
clean:
$(RM) $(TARGET).bin $(TARGET).elf $(OBJS)
.PHONY: $(PHONY)
|