CC = avr-gcc
OBJCOPY = avr-objcopy
DUDE = avrdude

CFLAGS = -Os -mmcu=attiny45
OBJFLAGS = -j .text -j .data -O ihex
DUDEFLAGS = -p attiny45 -c usbtiny -q


all: main.flash

# Housekeeping if you want it
clean:
	$(RM) *.o *.hex *.elf usbdrv/*.o

%.flash: %.hex
	$(DUDE) $(DUDEFLAGS) -U flash:w:$*.hex

# Main.elf requires additional objects to the firmware, not just main.o
main.elf: $(OBJECTS)
	$(CC) $(CFLAGS) $(OBJECTS) -o $@

%.hex: %.elf
	$(OBJCOPY) $(OBJFLAGS) $< $@

%.elf: %.o
	$(CC) $(CFLAGS) $< -o $@
