#DEFINES += CFLAGS += -Wall -Os -I. -mmcu=atmega88 # further optimization: #CFLAGS += --param inline-call-cost=2 CFLAGS += -fno-move-loop-invariants # suggestions from from v-usb CFLAGS += -fno-tree-scev-cprop CFLAGS += -fno-inline-small-functions 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 m88 -U flash:w:firmware.hex fuses: avrdude -c usbasp -p m88 -U lfuse:w:0xdf:m -U hfuse:w:0xde:m # external 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 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)