aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorThomas Albers Raviola <thomas@thomaslabs.org>2025-02-12 01:27:44 +0100
committerThomas Albers Raviola <thomas@thomaslabs.org>2025-02-12 01:27:44 +0100
commit779b9834e30de1ba0b4f0755388bebd0c45aa1dc (patch)
tree218edb656e329884e4b9cab7e84f4ba4b4af0c4a /Makefile
parent8ac78b9953908d2a4ffece855296fb7597440cce (diff)
Restructure rom image and use dependencies for makefiles
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile68
1 files changed, 19 insertions, 49 deletions
diff --git a/Makefile b/Makefile
index ea09b19..0040ed2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,66 +1,34 @@
-PROJECT=firmware
+export PROJECT_ROOT=$(abspath .)
-AS=sdasz80
-CC=sdcc
-CPP=sdcpp
-
-ASM=crt0.asm\
- isr.asm\
- delay.asm
-SRC=font.c\
- i2c.c\
- input.c\
- main.c\
- tft.c\
- tty.c\
- menu.c
-
-INCLUDE=include
BUILD=build
-OBJ=$(ASM:%.asm=$(BUILD)/%.rel)\
- $(SRC:%.c=$(BUILD)/%.rel)
-
-IHX=$(BUILD)/$(PROJECT).ihx
-TARGET=$(BUILD)/$(PROJECT).hex
+TARGET=$(BUILD)/rom.hex
BOOTLOADER=$(BUILD)/boot/bootloader.hex
+FIRMWARE=$(BUILD)/firmware.hex
-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
+CODE_LOC=0x8100
+DATA_LOC=0xC000
+STACK_LOC=0x0000
+GSINIT_LOC=0x8080
ROM_CHIP=AT28C256
-all : $(TARGET)
-
-$(OBJ): | $(BUILD)
+DIRS=$(addprefix $(BUILD)/,asm src)
-$(BUILD):
- @mkdir -p $(BUILD)
+ASM=$(wildcard asm/*.asm)
+SRC=$(wildcard src/*.c)
-$(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)
+all : $(TARGET)
-$(TARGET) : $(IHX) $(BOOTLOADER)
- @hex2bin.py -l 32768 $< $@
- @dd if=$(BOOTLOADER) of=$@ obs=1024 seek=28 conv=notrunc 2>/dev/null
+$(TARGET) : $(BOOTLOADER) $(FIRMWARE)
+ cat $^ > $@
+ cp $(BOOTLOADER) /tmp/rom.hex
+ dd if=$(FIRMWARE) of=/tmp/rom.hex obs=4096 seek=3 conv=notrunc 2>/dev/null
+ mv /tmp/rom.hex $@
.PHONY : $(BOOTLOADER)
$(BOOTLOADER) :
- @make -C boot
+ make -C boot
.PHONY : flash
flash :
@@ -69,3 +37,5 @@ flash :
.PHONY : clean
clean :
@find $(BUILD) -type f -delete
+
+include include.mk