SOURCES := $(wildcard *.c)
OBJECTS := $(patsubst %.c,%.o,$(SOURCES))

OPTS := -mmcu=at90s8515
LDOPTS := -nostartfiles

all:
	avr-gcc $(OPTS) -c $(SOURCES)
	avr-gcc $(OPTS) $(LDOPTS) $(OBJECTS)
	avr-objcopy -O ihex a.out output.hex
	avrdude -P /dev/ttyUSB0 -c stk500v2 -p at90s8515 -U flash:w:output.hex -C /usr/local/avr/tools/etc/avrdude.conf -F	

clean:
	rm -rf *.o a.out *.hex *~
