summaryrefslogtreecommitdiff
path: root/Makefile
blob: 8f7312cd31a9b16cecc4a901f90d9c771a529c93 (plain)
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
ASM=crt0.asm
SRC=crc16.c zbootloader.c

OBJ=$(ASM:%.asm=build/%.rel) $(SRC:%.c=build/%.rel)
IHX=build/bootloader.ihx
TARGET=bootloader.hex

CFLAGS=-mz80 -I. --Werror
LDFLAGS=-mz80 --no-std-crt0 --code-loc 0x100 --data-loc 0x8000 -Wl-b_GSINIT=0x80

ROM_CHIP=SST39SF040

all : $(TARGET)

build/%.rel : %.asm
	@echo '  (AS)' $<
	@sdcpp -P -I. -DASSEMBLY $< > build/$<
	@sdasz80 -g -o $@ build/$<

build/%.rel : %.c
	@echo '  (CC)' $<
	@sdcc $(CFLAGS) -c -o $@ $<

$(IHX) : $(OBJ)
	@echo '  (LD)' $(OBJ)
	@sdcc $(LDFLAGS) -o $@ $(OBJ)

$(TARGET) : $(IHX)
	@hex2bin.py $< $@

.PHONY : upload
upload :
	z80up $(TARGET) -p /dev/ttyUSB0

.PHONE : flash
flash :
	minipro -y -sp $(ROM_CHIP) -w $(TARGET)

.PHONY : clean
clean :
	@rm -rf build/* $(TARGET)