# makefile for attiny2313
#
# written by Steffen from mikrocontrollerspielwiese.de
#
# inspired by Guido Socher's makefile
# http://www.linuxfocus.org/Deutsch/November2004/article352.shtml
#
# license: GPL (http://www.gnu.org/licenses/gpl.txt)
#


MCU=attiny2313
CC=avr-gcc
OBJCOPY=avr-objcopy

#-------------------
#die Programmer der Mikrocontrollerspielwiese zum auswaehlen:
PROGRAMMER = -c dapa
#PROGRAMMER = -c usbasp


# optimize for size:
CFLAGS=-g -mmcu=$(MCU) -Wall -Wstrict-prototypes -Os -mcall-prologues

#-------------------
all: test1.hex

#-------------------
help: 
	clear
	@echo
	@echo "Moegliche Befehle:"
	@echo "		make - compiliert Dein Programm und erzeugt die .hex-Datei"
	@echo "		make all - wie make"
	@echo "		make load - compiliert Dein Programm und schiebt es in den AVR"
	@echo "		make clean - loescht die beim Compilieren erzeugten Dateien"
	@echo
	@echo "		make help - zeigt diesen Hilfetext"
	@echo
	@echo "		make rdfuses - gibt Dir Informationen ueber die gesetzten Fusebits und mehr"
	@echo
	
#-------------------
test1.hex : test1.out 
	$(OBJCOPY) -R .eeprom -O ihex test1.out test1.hex 
test1.out : test1.o 
	$(CC) $(CFLAGS) -o test1.out -Wl,-Map,test1.map test1.o 
test1.o : test1.c 
	$(CC) $(CFLAGS) -Os -c test1.c
	
#------------------
load: test1.hex
	avrdude -p t2313 $(PROGRAMMER) -e -U flash:w:"test1.hex"
	

#-------------------
rdfuses:
	avrdude -p t2313 $(PROGRAMMER) -v -q	
# 
	
	
#-------------------
clean:
	rm -f *.o *.map *.out *.hex
	
#-------------------
