C=avr-gcc -Wall -Os -c
A=avr-as
L=avr-gcc -Os

all: start.hex mischen.hex test.hex

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

start-install: start.hex
	avrdude -p m8 -c avr910 -P /dev/ttyUSB0 -U flash:w:start.hex:i

mischen.hex: mischen.o unterprog.o
	$L mischen.o unterprog.o -o mischen.elf
	avr-objcopy -O ihex -R .eeprom mischen.elf mischen.hex
	avr-objdump -h -S mischen.elf > mischen.lss
mischen.o: mischen.c
	$C mischen.c
unterprog.o: unterprog.S
	$A unterprog.S -o unterprog.o

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

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

clean:
	rm -f *~ *.o *.elf *.lss test.hex
clean_all:
	rm -f *~ *.o *.elf *.lss *.hex

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