# Set these paths to match your compiler setup
TARGET=arm-elf
DCBASE=/usr/local
CC=$(DCBASE)/bin/$(TARGET)-gcc -mcpu=arm7 -Wall
LD=$(DCBASE)/bin/$(TARGET)-ld
AS=$(DCBASE)/bin/$(TARGET)-as -marm7
AR=$(DCBASE)/bin/$(TARGET)-ar
OBJCOPY=$(DCBASE)/bin/$(TARGET)-objcopy

all: aica_fw.h

aica_fw.h: sound.bin
	../../utils/bin2c sound.bin aica_fw.h.tmp
	echo 'unsigned char NDC_sound[] = {' > aica_fw.h
	cat aica_fw.h.tmp >> aica_fw.h
	echo '};' >> aica_fw.h
	-rm aica_fw.h.tmp

sound.bin: sound.elf
	$(OBJCOPY) -O binary sound.elf sound.bin

sound.elf: crt0.o main.o aica.o
	$(CC) -Wl,-Ttext,0x00000000 -nostartfiles -nostdlib -e reset -o sound.elf crt0.o main.o aica.o -lgcc

%.o: %.c
	$(CC) -O0 $(INCS) -c $< -o $@

%.o: %.s
	$(AS) $< -o $@

clean:
	-rm -f *.o *.srec *.elf 1ST_READ.BIN sound.bin *.bck


