# Makefile for sample - AVR Sample code # Each rule is in the form: # target: dependency1 dependency2 # command to make target from dependencies # make looks at all dependencies for a target before making it: # 1) If there is a rule to make dependency, then do that rule # 2) If there is no rule, and the dependency file exists, then: # a) if target file exists and is newer than dependency file, # then look at next dependency # b) if dependency file is newer than target (or target doesn't # exist), then run command to make target. # default target when "make" is run w/o arguments all: sample.rom # compile timer.c into timer.o timer.o: timer.c sample.h avr-gcc -c -g -O3 -Wall -mmcu=at90s8535 -I. timer.c -o timer.o # compile sample.c into sample.o sample.o: sample.c sample.h avr-gcc -c -g -O3 -Wall -mmcu=at90s8535 -I. sample.c -o sample.o # link up sample.o and timer.o into sample.elf sample.elf: timer.o sample.o avr-gcc timer.o sample.o -Wl,-Map=sample.map,--cref -mmcu=at90s8535 -o sample.elf # copy ROM (FLASH) object out of sample.elf into sample.rom sample.rom: sample.elf avr-objcopy -O ihex sample.elf sample.rom # command to program chip (optional) (invoked by running "make install") install: avr-prog -p 4 sample.rom # command to clean up junk (no source files) (invoked by "make clean") clean: rm -f *.o *.rom *.elf *.map *~