2021-04-21 04:08:19 +00:00
|
|
|
# TODO: enforce c99
|
|
|
|
# eventually add -Wextra
|
|
|
|
|
|
|
|
# Personal makefile notes:
|
|
|
|
# '$@' gets replaced with the target name
|
|
|
|
# '$^' gets replaced with the target's dependencies (to right of target name)
|
|
|
|
# For more, check out https://youtu.be/G5dNorAoeCM
|
|
|
|
|
|
|
|
# Note: I understand this makefile is not as optimal as it could/should be
|
|
|
|
|
2021-04-30 01:15:13 +00:00
|
|
|
CC = gcc
|
|
|
|
CFLAGS ?= -Wall -Wpedantic -Wextra -std=c99
|
|
|
|
DEBUG = -g -ggdb
|
|
|
|
ROM = rom.bin
|
2021-04-27 06:20:19 +00:00
|
|
|
TRACE_SUFFIX =
|
2021-04-30 01:15:13 +00:00
|
|
|
TARGET = hard
|
2021-04-27 06:20:19 +00:00
|
|
|
|
2021-04-30 01:15:13 +00:00
|
|
|
all: $(TARGET)
|
2021-04-27 06:20:19 +00:00
|
|
|
|
2021-04-30 01:15:13 +00:00
|
|
|
debug: CFLAGS += $(DEBUG)
|
|
|
|
debug: $(TARGET)
|
|
|
|
|
|
|
|
trace: CFLAGS += $(DEBUG) -DTRACE -lreadline
|
2021-04-27 06:20:19 +00:00
|
|
|
trace: TRACE_SUFFIX = -trace
|
2021-04-30 01:15:13 +00:00
|
|
|
trace: $(TARGET)
|
2021-04-27 06:20:19 +00:00
|
|
|
|
2021-04-27 06:47:04 +00:00
|
|
|
|
|
|
|
disass: CFLAGS += -DTRACE -lreadline
|
2021-05-17 07:44:06 +00:00
|
|
|
disass: bin/disass.o bin/vm.o bin/emcalls.o
|
2021-04-27 06:47:04 +00:00
|
|
|
$(CC) $(CFLAGS) -o bin/$@ $^
|
|
|
|
|
2021-04-27 06:20:19 +00:00
|
|
|
bin/%.o: src/%.c
|
|
|
|
$(CC) $(CFLAGS) -o $@ -c $^
|
|
|
|
|
2021-05-03 13:35:00 +00:00
|
|
|
bin/emcalls.o:
|
2021-04-27 06:20:19 +00:00
|
|
|
bin/vm.o:
|
|
|
|
bin/main.o:
|
2021-04-27 06:47:04 +00:00
|
|
|
bin/disass.o:
|
2021-04-27 06:20:19 +00:00
|
|
|
|
2021-05-03 13:35:00 +00:00
|
|
|
# needs to be run separately
|
2021-04-27 07:16:20 +00:00
|
|
|
rom: rom.bin
|
|
|
|
xxd -i src/$^ > src/$@.h
|
|
|
|
|
|
|
|
rom.bin: src/rom.asm src/zeropage.incbin
|
|
|
|
./ass.sh src/rom.asm src/zeropage.incbin
|
|
|
|
|
2021-05-03 13:35:00 +00:00
|
|
|
$(TARGET): bin/main.o bin/vm.o bin/emcalls.o
|
2021-04-27 06:20:19 +00:00
|
|
|
$(CC) $(CFLAGS) -o bin/$@$(TRACE_SUFFIX) $^
|
|
|
|
|
2021-04-27 06:47:04 +00:00
|
|
|
clean:
|
|
|
|
rm -f bin/*
|
2021-04-27 06:20:19 +00:00
|
|
|
cleano:
|
2021-04-27 06:47:04 +00:00
|
|
|
rm -f bin/*.o
|
2021-04-27 06:20:19 +00:00
|
|
|
|
2021-04-30 01:15:13 +00:00
|
|
|
.PHONY: all debug trace clean cleano
|
2021-04-21 04:08:19 +00:00
|
|
|
|