CC=avr-gcc
AA=avr-as
#A=avra

# Hier den Typ eintragen:
M=atmega8

C=avr-gcc -c -mmcu=$M -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=test.lst  -std=gnu99 -DF_OSC=3686400 -MD -MP -MF .dep/test.o.d
L=avr-gcc -mmcu=$M -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=test.o  -std=gnu99 -DF_OSC=3686400 -MD -MP -MF .dep/test.elf.d  -Wl,-Map=test.map,--cref    -lm
A=avr-gcc -c -mmcu=$M -I. -x assembler-with-cpp -Wa,-adhlns=unterprog.lst,-gstabs  -DF_OSC=3686400

# ausprobieren der Musterprogramme:
# > ln -s name.c test.c
# > make
# > make install

all: interrrupt

test.hex: test.o
	$L test.o -o test.elf
	avr-objcopy -O ihex -R .eeprom test.elf test.hex
	avr-objdump -h -S test.elf > test.lss

test.eep: test.elf
	avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
        --change-section-lma .eeprom=0 -O ihex test.elf test.eep

test.o: test.c
	$C test.c -o test.o

unterprog.o: unterprog.S
	$A unterprog.S -o unterprog.o

start: start.c
	rm -f test.c
	ln -s start.c test.c
	make test.hex

interrrupt: interrupt.c
	rm -f test.c
	ln -s interrupt.c test.c
	make test.hex

clean:
	rm -f *~ *.o *.lst *.lss *.elf *.map
clean_all:
	rm -f *~ *.o *.lst *.lss *.elf *.map *.hex *.eep

install: test.hex
	avrdude -p m8 -c avr910 -P /dev/ttyUSB0 -U flash:w:test.hex:i
eepinstall: test.eep
	avrdude -p m8 -c avr910 -P /dev/ttyUSB0 -U eeprom:w:test.eep:i
