CFLAGS += -Wall -Os -I. -mmcu=attiny26 -std=c99 DEFINES += -DF_CPU=16e6 OBJECTS = gg.o mmc.o #ringbuf_small.o # further optimization: # this removes dead code and does global linker optimization #CFLAGS += -ffunction-sections -Wl,--gc-sections -Wl,--relax #CFLAGS += --param inline-call-cost=2 COMPILE = avr-gcc $(CFLAGS) $(DEFINES) # symbolic targets: all: firmware.hex .c.o: $(COMPILE) -c $< -o $@ .S.o: $(COMPILE) -x assembler-with-cpp -c $< -o $@ # "-x assembler-with-cpp" should not be necessary since this is the default # file type for the .S (with capital S) extension. However, upper case # characters are not always preserved on Windows. To ensure WinAVR # compatibility define the file type manually. .c.s: $(COMPILE) -S $< -o $@ flash: all avrdude -c usbasp -p t26 -U flash:w:firmware.hex fuses: avrdude -c usbasp -p t26 -U lfuse:w:0x61:m # -U hfuse:w:0xf7:m # internal 8Mhz oscillator ## what are the source dependencies %.d: %.c @set -e; rm -f $@; \ $(COMPILE) -MM $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@; # line 1: exits if anything goes wrong # line 2a: gcc -MM outputs dependencies # line 2b: insert the %.d into dependency list #main.c: version.h version.h: .svn/entries export LANG=POSIX; (svn info 2>/dev/null || echo "Revision: unknown") | awk '/^Revision:/ {print "#define SVNVERSION \"" $$2 "\""};' >version.h clean: rm -f *.o *.hex *.obj *.i *.s *.d */*.i */*.s */*.o */*.d version.h # file targets: firmware.bin: $(OBJECTS) $(COMPILE) -o firmware.bin $(OBJECTS) firmware.hex: firmware.bin rm -f firmware.hex firmware.eep.hex avr-objcopy -j .text -j .data -O ihex firmware.bin firmware.hex avr-size firmware.bin # ./checksize firmware.bin 8192 960 # do the checksize script as our last action to allow successful compilation # on Windows with WinAVR where the Unix commands will fail. disasm: firmware.bin avr-objdump -d firmware.bin >disasm functionsize: disasm python avrbuild/functionsize.py countregs: disasm python avrbuild/countregs.py # for depends: -include $(OBJECTS:.o=.d)