?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{FILE START}

library

?curdirlinks? - Rev 6

?prevdifflink? - Blame - ?getfile?

#----------------------------------------------------------------------------------
# ARM-GCC standard Makefile
# This makefile is to be used by including it from a project-specific makefile
# which defines the source files and compiler/linker options
#
# Written by Pascal Stang
# Based on Volker Oth's AVR makefiles of jan.2000
# ---------------------------------------------------------------------------------

###### BLOCK 1) define some variables based on the AVR base path in $(AVR) #######

        CC      = avr-gcc
        AS      = avr-gcc -x assembler-with-cpp 
        RM      = rm -f
        RN      = mv
        CP      = cp
        OBJCOPY = avr-objcopy
        SIZE    = avr-size
        INCDIR  = .


###### BLOCK 2) output format can be srec, ihex (avrobj and bin are always created) #######

        FORMAT = ihex   

###### BLOCK 3) define all project specific object files ######

        SRC     += $(addprefix $(AVRLIB)/,$(AVRLIB_SRC))
        OBJ     = $(ASRC:.s=.o) $(SRC:.c=.o) 
        CPFLAGS += -mmcu=$(MCU)
        ASFLAGS += -mmcu=$(MCU)
        LDFLAGS += -mmcu=$(MCU)

###### BLOCK 4) this defines the aims of the make process ######

all:    $(TRG).elf $(TRG).cof $(TRG).bin $(TRG).hex $(TRG).eep $(TRG).ok


###### BLOCK 5) compile: instructions to create assembler and/or object files from C source ######

%.o : %.c 
        $(CC) -c $(CPFLAGS) -I$(INCDIR) $< -o $@

%.s : %.c
        $(CC) -S $(CPFLAGS) -I$(INCDIR) $< -o $@


###### BLOCK 6) assemble: instructions to create object file from assembler files ######

%.o : %.s
        $(AS) -c $(ASFLAGS) -I$(INCDIR) $< -o $@


###### BLOCK 7)  link: instructions to create elf output file from object files ######
%.elf: $(OBJ)
        $(CC) $(OBJ) $(LIB) $(LDFLAGS) -o $@

###### BLOCK 8) create avrobj file from elf output file ######

#%.obj: %.elf
#       $(OBJCOPY) -O avrobj -R .eeprom $< $@


###### BLOCK 9) create bin (.hex, .bin, and .eep) files from elf output file ######

%.bin: %.elf
        $(OBJCOPY) -O binary -R .eeprom $< $@

%.hex: %.elf
        $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@

%.eep: %.elf
        $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O $(FORMAT) $< $@

%.cof: %.elf
        $(OBJCOPY) --debugging -O coff-ext-avr \
                --change-section-address   .data-0x800000 \
                --change-section-address    .bss-0x800000 \
                --change-section-address .noinit-0x800000 \
                --change-section-address .eeprom-0x810000 \
                $< $@


###### BLOCK 10) If all other steps compile ok then echo "Errors: none" ######

%ok:
        $(SIZE) $(TRG).elf
        @echo "Errors: none" 


###### BLOCK 11)  make instruction to delete created files ######

clean:
        $(RM) $(OBJ)
        $(RM) $(SRC:.c=.s)
        $(RM) $(SRC:.c=.lst)
        $(RM) $(TRG).map
        $(RM) $(TRG).elf
        $(RM) $(TRG).cof
        $(RM) $(TRG).obj
        $(RM) $(TRG).a90
        $(RM) $(TRG).sym
        $(RM) $(TRG).eep
        $(RM) $(TRG).hex
        $(RM) $(TRG).bin
        @echo "Errors: none"
        
size:
        $(SIZE) $(TRG).elf

{FILE END}
{FOOTER START}

Powered by WebSVN v2.8.3