FLASHPORT=/dev/ttyS0 FLASHDEVTYPE=ponyser OFORMAT = ihex override CFLAGS += -I../lib -g -funsigned-char -funsigned-bitfields -fpack-struct \ -fshort-enums -Wall -Wstrict-prototypes -Wa,-ahlms=$(<:.c=.lst) # Optional assembler flags. ASFLAGS = -Wa,-ahlms=$(<:.s=.lst), -gstabs # Optional linker flags. override LDFLAGS += -Wl,-Map=$(TARGET).map,--cref # Additional library flags (-lm = math library). LIBFLAGS = -lm # Define programs and commands. SHELL = sh CC = avr-gcc OBJCOPY = avr-objcopy OBJDUMP = avr-objdump REMOVE = rm -f COPY = cp ELFCOFF = objtool HEXSIZE = @avr-size --target=$(OFORMAT) $(TARGET).hex ELFSIZE = @avr-size $(TARGET).elf # Define all listing files. LST = $(ASRC:.s=.lst) $(SRC:.c=.lst) # Combine all necessary flags and optional flags. Add target processor to flags. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) ALL_LDFLAGS = -mmcu=$(MCU) $(LDFLAGS) # Default target. all: $(TARGET).elf $(TARGET).hex $(TARGET).bin $(TARGET).eep $(TARGET).lss # Display size of file. sizebefore: @echo Size before: -$(HEXSIZE) sizeafter: @echo Size after: $(HEXSIZE) # Display compiler version information. gccversion : $(CC) --version # Target: Convert ELF to COFF for use in debugging / simulating in AVR Studio. coff: $(TARGET).cof end %.cof: %.elf $(ELFCOFF) loadelf $< mapfile $*.map writecof $@ # Create final output files (.hex, .eep) from ELF output file. %.hex: %.elf $(OBJCOPY) -O $(OFORMAT) -R .eeprom $< $@ %.bin: %.elf $(OBJCOPY) -O binary -R .eeprom $< $@ %.eep: %.elf -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O $(OFORMAT) $< $@ # Create extended listing file from ELF output file. %.lss: %.elf $(OBJDUMP) -h -S $< > $@ # Link: create ELF output file from object files. %.elf: $(SRC) $(CC) $(ALL_LDFLAGS) $(ALL_CFLAGS) -combine $^ $(LIBFLAGS) --output $@ # Target: clean project. clean: clean_list clean_list : $(REMOVE) $(TARGET).hex $(REMOVE) $(TARGET).eep $(REMOVE) $(TARGET).obj $(REMOVE) $(TARGET).cof $(REMOVE) $(TARGET).elf $(REMOVE) $(TARGET).bin $(REMOVE) $(TARGET).map $(REMOVE) $(TARGET).obj $(REMOVE) $(TARGET).a90 $(REMOVE) $(TARGET).sym $(REMOVE) $(TARGET).lnk $(REMOVE) $(TARGET).lss $(REMOVE) $(LST) # Remove the '-' if you want to see the dependency files generated. -include $(SRC:.c=.d) # Listing of phony targets. .PHONY : all begin finish end sizebefore sizeafter gccversion coff clean clean_list