CC=gcc
LDFLAGS=-lm
CFLAGS=-std=c99 -D_GNU_SOURCE

all:		flash.hex

flash.hex:	flash.o
		avr-ld --oformat ihex -o $@ $^

song.i:		script encode
		./encode <$< >$@

flash.o:	play.S song.i
		avr-gcc -nostdlib -Xlinker -M -Os -B/usr/avr/lib -Wall -mmcu=avr1 -o $@ $< >mapfile
		avr-size $@

clean:
		rm -f flash.hex song.i flash.o mapfile encode
