aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorThomas Albers Raviola <thomas@thomaslabs.org>2024-11-21 15:55:03 +0100
committerThomas Albers Raviola <thomas@thomaslabs.org>2024-11-21 15:55:03 +0100
commit6d4ad089c5b758ad8af4f68bf385a26ec4e9653a (patch)
tree2fd65006b57d646b53e121aef42bba5ee5852840 /Makefile
Initial commit
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile65
1 files changed, 65 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9311c3e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,65 @@
+PROJECT=firmware
+
+AS=sdasz80
+CC=sdcc
+CPP=sdcpp
+
+ASM=crt0.asm\
+ isr.asm\
+ delay.asm
+SRC=crc16.c\
+ bootloader.c\
+ font.c\
+ i2c.c\
+ input.c\
+ main.c\
+ tft.c\
+ tty.c\
+ menu.c
+
+OBJ=$(ASM:%.asm=build/%.rel)\
+ $(SRC:%.c=build/%.rel)
+
+IHX=build/$(PROJECT).ihx
+TARGET=build/$(PROJECT).hex
+
+INCLUDE=include
+CFLAGS=-mz80 -I$(INCLUDE) --Werror
+LDFLAGS=-mz80 --no-std-crt0\
+ --code-loc 0x0100\
+ --data-loc 0x8010\
+ -Wl-b_ISR_TABLE=0x0070\
+ -Wl-b_GSINIT=0x0080
+
+ROM_CHIP=AT28C256
+
+all : $(TARGET)
+
+$(OBJ): | build
+
+build:
+ @mkdir -p build
+
+build/%.rel : asm/%.asm
+ @echo ' (AS)' $<
+ @$(CPP) -P -I$(INCLUDE) -DASSEMBLY $< > build/$(notdir $<)
+ @$(AS) -g -o $@ build/$(notdir $<)
+
+build/%.rel : src/%.c
+ @echo ' (CC)' $<
+ @$(CC) $(CFLAGS) -c -o $@ $<
+
+$(IHX) : $(OBJ)
+ @echo ' (LD)' $(OBJ)
+ @$(CC) $(LDFLAGS) -o $@ $(OBJ)
+
+$(TARGET) : $(IHX)
+ @hex2bin.py $< $@
+
+.PHONE : flash
+flash :
+ @minipro -y -sp $(ROM_CHIP) -w $(TARGET)
+
+.PHONY : clean
+clean :
+ @find build -type f -delete