CC= avr-gcc
cflags=-g -DF_CPU=$(avrFreq) -Wall -Os -Werror -Wextra
baud=19200
avrFreq=1000000
programmerDev=/dev/ttyACM0
programmerType=arduino
src=example
avrType=atmega16

object:
	$(CC) $(cflags) -mmcu=$(avrType) -Wa,-ahlmns=${src}.lst -c -o $(src).o $(src).c

elf : object 
	$(CC) $(cflags) -mmcu=$(avrType) -o $(src).elf $(src).o

hex : elf
	avr-objcopy -j .text -j .data -O ihex $(src).elf $(src).flash.hex

flash: hex
	avrdude -p${avrType} -c${programmerType} -P${programmerDev} -b${baud} -v -U flash:w:${src}.flash.hex
