all repos — 3ByteBadVM @ 081b72c6ea4b2b09b15b073845d676f3d72669cb

3ByteBadVM

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
# 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

CC           = gcc
CFLAGS      ?= -Wall -Wpedantic -Wextra -std=c99 
DEBUG        = -g -ggdb
ROM          = rom.bin
TRACE_SUFFIX =
TARGET       = hard

all: $(TARGET)

debug: CFLAGS += $(DEBUG)
debug: $(TARGET)

trace: CFLAGS += $(DEBUG) -DTRACE -lreadline
trace: TRACE_SUFFIX = -trace
trace: $(TARGET)


disass: CFLAGS += -DTRACE -lreadline
disass: bin/disass.o bin/vm.o
	$(CC) $(CFLAGS) -o bin/$@ $^

bin/%.o: src/%.c
	$(CC) $(CFLAGS) -o $@ -c $^

bin/emcalls.o:
bin/vm.o:
bin/main.o:
bin/disass.o:

# needs to be run separately
rom: rom.bin
	xxd -i src/$^ > src/$@.h

rom.bin: src/rom.asm src/zeropage.incbin
	./ass.sh src/rom.asm src/zeropage.incbin

$(TARGET): bin/main.o bin/vm.o bin/emcalls.o
	$(CC) $(CFLAGS) -o bin/$@$(TRACE_SUFFIX) $^

clean:
	rm -f bin/*
cleano:
	rm -f bin/*.o

.PHONY: all debug trace clean cleano