#
# $Id: Makefile,v 1.1 2002/12/18 22:35:38 joerg_wunsch Exp $
#
CC= avr-gcc
#MCU=atmega8
#MCU=atmega16
#MCU=atmega32
#MCU=atmega163
#MCU=atmega323
MCU=atmega8

#CFLAGS=  -O -g -Wall -ffreestanding -gstabs -mmcu=$(MCU)
CFLAGS=  -Wall -g -O2 -mmcu=$(MCU) 
LDLIBS= -lm
#-mcall-prologues
#CFLAGS=  -Wall -O8 -mmcu=$(MCU) 

.SUFFIXES: .s .bin .out .hex .srec

.c.s:
	$(CC) $(CFLAGS) -S $<

.S.o:
	$(CC) $(ASFLAGS) -g -c $<

.o.out:
	$(CC) $(CFLAGS) -o $@ $<

.out.bin:
	avr-objcopy -O binary $< $@

.out.hex:
	avr-objcopy -O ihex $< $@

.out.srec:
	avr-objcopy -O srec $< $@

showsize:
	avr-size video.out
	avr-objdump video.out -S  > video.S2
	#avr-objdump myfloat.out -S  > mylfo.S2

all:	clean video.bin video.hex gen.s showsize

OBJS=gen.o
video.out: $(OBJS)
	$(CC) -o video.out $(CFLAGS) $(LDFLAGS) $(OBJS) $(LDLIBS)	

#avr-strip video.out

clean:
	rm -f *~ *.out *.bin *.hex *.srec *.o *.pdf *core *.S2

program:
	uisp  -dprog=avr910 -dserial=/dev/ttyS1 -dpart=auto --erase
	uisp  -dprog=avr910 -dserial=/dev/ttyS1 -dpart=auto --upload if=video.hex

simul:
	simulavr -g -d atmega8 video.bin
