34 lines
1012 B
Makefile
34 lines
1012 B
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
|
|
|
|
.PHONY: all play check
|
|
all: game.gba
|
|
|
|
build:
|
|
mkdir -p build
|
|
|
|
build/start.o: source/start.s | build
|
|
$(CC) -mcpu=arm7tdmi -marm -c $< -o $@
|
|
|
|
build/main.o: source/main.c source/wild_creatures.h | build
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
build/game.elf: build/start.o build/main.o gba.ld
|
|
$(CC) -mcpu=arm7tdmi -marm -nostdlib -T gba.ld -Wl,-z,noexecstack -Wl,-Map,build/game.map build/start.o build/main.o -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
|
|
/usr/bin/clang -Wall -Wextra -Werror tests/test_game.c -o build/test_game
|
|
./build/test_game
|
|
|
|
play: game.gba
|
|
open -a mGBA game.gba
|