Commit c128d878 authored by Dean Camera's avatar Dean Camera
Browse files

Minor build system improvements - move out AVRDUDE base flags into a makefile...

Minor build system improvements - move out AVRDUDE base flags into a makefile variable, clean up BUILD module.
parent 75180645
...@@ -67,13 +67,16 @@ $(call ERROR_IF_EMPTY, AVRDUDE_PORT) ...@@ -67,13 +67,16 @@ $(call ERROR_IF_EMPTY, AVRDUDE_PORT)
# Output Messages # Output Messages
MSG_AVRDUDE_CMD := ' [AVRDUDE] :' MSG_AVRDUDE_CMD := ' [AVRDUDE] :'
# Construct base avrdude command flags
BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
avrdude: $(TARGET).hex $(MAKEFILE_LIST) avrdude: $(TARGET).hex $(MAKEFILE_LIST)
@echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH with settings \"$(AVRDUDE_FLASH_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\" @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH with settings \"$(AVRDUDE_FLASH_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
avrdude -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -U flash:w:$< $(AVRDUDE_FLAGS) avrdude $(BASE_AVRDUDE_FLAGS) -U flash:w:$< $(AVRDUDE_FLAGS)
avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST) avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST)
@echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM with settings \"$(AVRDUDE_EEP_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\" @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM with settings \"$(AVRDUDE_EEP_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
avrdude -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -U eeprom:w:$< $(AVRDUDE_FLAGS) avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS)
# Phony build targets for this module # Phony build targets for this module
.PHONY: avrdude avrdude-ee .PHONY: avrdude avrdude-ee
...@@ -99,12 +99,12 @@ $(call ERROR_IF_EMPTY, OBJDIR) ...@@ -99,12 +99,12 @@ $(call ERROR_IF_EMPTY, OBJDIR)
# Determine the utility prefix to use for the selected architecture # Determine the utility prefix to use for the selected architecture
ifeq ($(ARCH), AVR8) ifeq ($(ARCH), AVR8)
CROSS := avr- CROSS := avr
else ifeq ($(ARCH), XMEGA) else ifeq ($(ARCH), XMEGA)
CROSS := avr- CROSS := avr
$(warning The XMEGA device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.) $(warning The XMEGA device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.)
else ifeq ($(ARCH), UC3) else ifeq ($(ARCH), UC3)
CROSS := avr32- CROSS := avr32
$(warning The UC3 device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.) $(warning The UC3 device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.)
else else
$(error Unsupported architecture "$(ARCH)") $(error Unsupported architecture "$(ARCH)")
...@@ -113,8 +113,8 @@ endif ...@@ -113,8 +113,8 @@ endif
# Output Messages # Output Messages
MSG_BUILD_BEGIN := Begin compilation of project \"$(TARGET)\"... MSG_BUILD_BEGIN := Begin compilation of project \"$(TARGET)\"...
MSG_BUILD_END := Finished building project \"$(TARGET)\". MSG_BUILD_END := Finished building project \"$(TARGET)\".
MSG_COMPILE_CMD := ' [CC] :' MSG_COMPILE_CMD := ' [GCC] :'
MSG_ASSEMBLE_CMD := ' [AS] :' MSG_ASSEMBLE_CMD := ' [GAS] :'
MSG_NM_CMD := ' [NM] :' MSG_NM_CMD := ' [NM] :'
MSG_REMOVE_CMD := ' [RM] :' MSG_REMOVE_CMD := ' [RM] :'
MSG_LINKER_CMD := ' [LNK] :' MSG_LINKER_CMD := ' [LNK] :'
...@@ -174,8 +174,8 @@ else ...@@ -174,8 +174,8 @@ else
endif endif
# Determine flags to pass to the size utility based on its reported features # Determine flags to pass to the size utility based on its reported features
SIZE_MCU_FLAG := $(shell $(CROSS)size --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) SIZE_MCU_FLAG := $(shell $(CROSS)-size --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
SIZE_FORMAT_FLAG := $(shell $(CROSS)size --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) SIZE_FORMAT_FLAG := $(shell $(CROSS)-size --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
build_begin: build_begin:
...@@ -188,7 +188,7 @@ build_end: ...@@ -188,7 +188,7 @@ build_end:
@echo "" @echo ""
gcc_version: gcc_version:
@$(CROSS)gcc --version @$(CROSS)-gcc --version
check_source: check_source:
@for f in $(SRC); do \ @for f in $(SRC); do \
...@@ -201,7 +201,7 @@ check_source: ...@@ -201,7 +201,7 @@ check_source:
size: $(TARGET).elf size: $(TARGET).elf
@echo $(MSG_SIZE_CMD) Determining size of \"$<\" @echo $(MSG_SIZE_CMD) Determining size of \"$<\"
@echo "" @echo ""
$(CROSS)size $(SIZE_MCU_FLAG) $(SIZE_FORMAT_FLAG) $< ; 2>/dev/null; $(CROSS)-size $(SIZE_MCU_FLAG) $(SIZE_FORMAT_FLAG) $< ; 2>/dev/null;
symbol-sizes: $(TARGET).elf symbol-sizes: $(TARGET).elf
@echo $(MSG_NM_CMD) Extracting \"$<\" symbols with decimal byte sizes @echo $(MSG_NM_CMD) Extracting \"$<\" symbols with decimal byte sizes
...@@ -224,37 +224,37 @@ sym: $(TARGET).sym ...@@ -224,37 +224,37 @@ sym: $(TARGET).sym
$(OBJDIR)/%.o: %.c $(MAKEFILE_LIST) $(OBJDIR)/%.o: %.c $(MAKEFILE_LIST)
@echo $(MSG_COMPILE_CMD) Compiling C file \"$(notdir $<)\" @echo $(MSG_COMPILE_CMD) Compiling C file \"$(notdir $<)\"
$(CROSS)gcc -c $(BASE_CC_FLAGS) $(BASE_C_FLAGS) $(CC_FLAGS) $(C_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@ $(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_C_FLAGS) $(CC_FLAGS) $(C_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@
$(OBJDIR)/%.o: %.cpp $(MAKEFILE_LIST) $(OBJDIR)/%.o: %.cpp $(MAKEFILE_LIST)
@echo $(MSG_COMPILE_CMD) Compiling C++ file \"$(notdir $<)\" @echo $(MSG_COMPILE_CMD) Compiling C++ file \"$(notdir $<)\"
$(CROSS)gcc -c $(BASE_CC_FLAGS) $(BASE_CPP_FLAGS) $(CC_FLAGS) $(CPP_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@ $(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_CPP_FLAGS) $(CC_FLAGS) $(CPP_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@
$(OBJDIR)/%.o: %.S $(MAKEFILE_LIST) $(OBJDIR)/%.o: %.S $(MAKEFILE_LIST)
@echo $(MSG_ASSEMBLE_CMD) Assembling \"$(notdir $<)\" @echo $(MSG_ASSEMBLE_CMD) Assembling \"$(notdir $<)\"
$(CROSS)gcc -c $(BASE_CC_FLAGS) $(BASE_ASM_FLAGS) $(CC_FLAGS) $(ASM_FLAGS) $< -o $@ $(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_ASM_FLAGS) $(CC_FLAGS) $(ASM_FLAGS) $< -o $@
.PRECIOUS : $(OBJECT_FILES) .PRECIOUS : $(OBJECT_FILES)
.SECONDARY : %.elf .SECONDARY : %.elf
%.elf: $(OBJECT_FILES) %.elf: $(OBJECT_FILES)
@echo $(MSG_LINKER_CMD) Linking object files into \"$@\" @echo $(MSG_LINKER_CMD) Linking object files into \"$@\"
$(CROSS)gcc $(BASE_CC_FLAGS) $(BASE_LD_FLAGS) $(CC_FLAGS) $(LD_FLAGS) $^ -o $@ $(CROSS)-gcc $(BASE_CC_FLAGS) $(BASE_LD_FLAGS) $(CC_FLAGS) $(LD_FLAGS) $^ -o $@
%.hex: %.elf %.hex: %.elf
@echo $(MSG_OBJCPY_CMD) Extracting HEX file data from \"$<\" @echo $(MSG_OBJCPY_CMD) Extracting HEX file data from \"$<\"
$(CROSS)objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@ $(CROSS)-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@
%.eep: %.elf %.eep: %.elf
@echo $(MSG_OBJCPY_CMD) Extracting EEP file data from \"$<\" @echo $(MSG_OBJCPY_CMD) Extracting EEP file data from \"$<\"
$(CROSS)objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex $< $@ || exit 0 $(CROSS)-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex $< $@ || exit 0
%.lss: %.elf %.lss: %.elf
@echo $(MSG_OBJDMP_CMD) Extracting LSS file data from \"$<\" @echo $(MSG_OBJDMP_CMD) Extracting LSS file data from \"$<\"
$(CROSS)objdump -h -S -z $< > $@ $(CROSS)-objdump -h -S -z $< > $@
%.sym: %.elf %.sym: %.elf
@echo $(MSG_NM_CMD) Extracting SYM file data from \"$<\" @echo $(MSG_NM_CMD) Extracting SYM file data from \"$<\"
$(CROSS)nm -n $< > $@ $(CROSS)-nm -n $< > $@
# Include build dependency files # Include build dependency files
-include $(DEPENDENCY_FILES) -include $(DEPENDENCY_FILES)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment