## Makefile -- a makefile for GCC-AVR (AVR-GCC) Atmel AVR test program ## test.c -- does something with input PORTD onto output PORTB ## implemented and tested on an AT90S8515 & STK500 ## Copyleft (!C) 2003 S. Mann and C. Manders, ## (http://www.gnu.org/copyleft/gpl.html); ## based on the Makefile that came with Stephen Lacy's "mirror.c" ## "make" to compile the program; ## "make program" to compile it and program it into the AVR ## (also strips symbol tables and outputs ascii hexdump to stk500) CC=avr-gcc OBJCOPY=avr-objcopy STRIP=avr-strip UISP=uisp OBJDUMP=avr-objdump ##MCU=at90s2313 MCU=at90s8515 PROG_METHOD=stk500 PORT=/dev/ttyS0 SRECS=\ test.srec \ $(NULL) default: $(SRECS) test: test.o PROGRAMS=$(SRECS:.srec=) OBJFILES=$(SRECS:.srec=.o) ASSEMBLY=$(SRECS:.srec=.asm) clean: rm -f $(SRECS) $(PROGRAMS) $(OBJFILES) $(ASSEMBLY) %.o: %.c $(CC) -g -O -mmcu=$(MCU) -c $^ -o $@ %: %.o $(CC) -g -O -mmcu=$(MCU) $^ -o $@ %.asm: % $(OBJDUMP) -S -d $^ > $@ %-stripped: % $(STRIP) $^ -o $@ %.srec: %-stripped $(OBJCOPY) -O srec $^ $@ %.hex: %-stripped $(OBJCOPY) -O ihex $^ $@ ##program-%: %.srec programwithwousyfooting: test.srec $(UISP) -dprog=$(PROG_METHOD) --segment=flash -dserial=$(PORT) -dpart=$(MCU) --erase sleep 1 $(UISP) -dprog=$(PROG_METHOD) --segment=flash -dserial=$(PORT) -dpart=$(MCU) --upload if=$^ sleep 1 $(UISP) -dprog=$(PROG_METHOD) --segment=flash -dserial=$(PORT) -dpart=$(MCU) --verify if=$^ sleep 1 program: test.srec $(UISP) -dprog=$(PROG_METHOD) --segment=flash -dserial=$(PORT) -dpart=$(MCU) --erase sleep 1 $(UISP) -dprog=$(PROG_METHOD) --segment=flash -dserial=$(PORT) -dpart=$(MCU) --upload if=$^