as		:= arm-none-eabi-as
ld		:= arm-none-eabi-ld
pt		:= picotool
inc		:= ./include
flags	:= -I$(inc)
ldflags := -M -T memory.ld

.PHONY: clean

all: lightup.uf2

lightup.uf2: lightup.elf
	$(pt) uf2 convert --verbose $< $@

lightup.elf: boot.o lightup.o vectors.o
	$(ld) $(ldflags) $^ -o $@
	chmod 644 $@

vectors.o: vectors.asm
	$(as) $(flags) $< -o $@

boot.o: boot.asm
	$(as) $(flags) $< -o $@

lightup.o: lightup.asm
	$(as) $(flags) $< -o $@

clean:
	rm -f *.o *.elf *.uf2
