# Customize for Windows
CC=mips-elf-gcc
CFLAGS = -O2 -Wall

SRCDIR?=./

CONVERT=plasma_convert
BINTOHEX=plasma_bintohex
MLITE=plasma_mlite
LOADER=plasma_loader

.PHONY: all clean run

all: pi2.bin bootldr.bin

run: bootldr.bin pi2.bin
	$(LOADER) - pi2.bin | $(MLITE) bootldr.bin

clean:
	rm -f *.o *.hex *.bin pi2

bootldr: bootldr.o no_os.o
	$(CC) -msoft-float -o $@ $^ -Tplasma-boot.ld

pi2: pi2.o
	$(CC) -msoft-float -o $@ $^ -Tplasma.ld

# target helpers
bootldr.bin: bootldr
	$(CONVERT) $^ $@ 0x0

pi2.bin: pi2
	$(CONVERT) $^ $@ 0x8000

%_0.hex: %.bin
	$(BINTOHEX) $^ $*

%.o: $(SRCDIR)/%.c
	$(CC) $(CFLAGS) -c -msoft-float -mips1 -o $@ $^ 
