47 lines
1.8 KiB
Makefile
47 lines
1.8 KiB
Makefile
TOOL_PREFIX ?= /opt/homebrew/bin/arm-none-eabi-
|
|
PYTHON ?= /usr/bin/python3
|
|
CC := $(TOOL_PREFIX)gcc
|
|
OBJCOPY := $(TOOL_PREFIX)objcopy
|
|
CFLAGS := -mcpu=arm7tdmi -marm -O2 -g -Wall -Wextra -Werror -ffreestanding -fno-builtin -fno-common -Wa,--noexecstack
|
|
GAME_SOURCES := source/main.c source/video.c source/scenery.c source/world.c \
|
|
source/actors.c source/battle.c source/story.c source/hud.c source/audio.c source/beach.c source/menu.c source/save.c
|
|
GAME_OBJECTS := $(GAME_SOURCES:source/%.c=build/%.o)
|
|
TEST_SOURCES := tests/test_game.c tests/test_support.c tests/test_maps.c \
|
|
tests/test_story.c tests/test_battle.c tests/test_rendering.c tests/test_movement.c tests/test_audio.c \
|
|
tests/test_catching.c tests/test_menu.c tests/test_progress.c tests/test_location.c
|
|
|
|
.PHONY: all play check check-host
|
|
all: game.gba
|
|
|
|
build:
|
|
mkdir -p build
|
|
|
|
build/start.o: source/start.s | build
|
|
$(CC) -mcpu=arm7tdmi -marm -c $< -o $@
|
|
|
|
build/%.o: source/%.c source/game.h | build
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
build/actors.o: source/wild_creatures.h
|
|
build/audio.o build/main.o: source/audio.h
|
|
|
|
# The bare-metal .data segment intentionally contains startup-relocated EWRAM code.
|
|
build/game.elf: build/start.o $(GAME_OBJECTS) gba.ld Makefile
|
|
$(CC) -mcpu=arm7tdmi -marm -nostdlib -T gba.ld -Wl,-z,noexecstack -Wl,--no-warn-rwx-segments -Wl,-Map,build/game.map build/start.o $(GAME_OBJECTS) -lgcc -o $@
|
|
|
|
game.gba: build/game.elf tools/rom_header.py
|
|
$(OBJCOPY) -O binary $< $@
|
|
$(PYTHON) tools/rom_header.py $@
|
|
|
|
check: game.gba
|
|
$(PYTHON) tools/rom_header.py --check game.gba
|
|
$(PYTHON) -m unittest discover -s tests -v
|
|
$(MAKE) check-host
|
|
|
|
check-host: | build
|
|
/usr/bin/clang -Wall -Wextra -Werror -DGAME_TEST $(TEST_SOURCES) $(GAME_SOURCES) -o build/test_game
|
|
./build/test_game
|
|
|
|
play: game.gba
|
|
open -a mGBA game.gba
|