OUTPUT := example.bin
TARGET_CPU := 65c02

# Tool list
CC65 := cc65
CA65 := ca65
LD65 := ld65
CL65 := cl65

# Searches directly under src and one level under. If a file is under 2 folders
#such as src/math/float/types.s, either one more level needs to be added, or
#switch these to a shell find $(shell find src -name '*.s')
C_SOURCES := $(wildcard src/*.c) $(wildcard src/*/*.s)
ASM_SOURCES := $(wildcard src/*.s) $(wildcard src/*/*.s)
OBJECTS := $(ASM_SOURCES:.s=.o)

.PHONY: all clean

all: $(OUTPUT)

$(OUTPUT): $(C_SOURCES) $(ASM_SOURCES)
	@mkdir -p $(dir $@)
	$(CL65) -t none --cpu $(TARGET_CPU) -C computer.cfg -O -o $@ $^

clean:
	rm -f $(OBJECTS)
	rm -f $(OUTPUT)