Commit 85579e12 authored by Dean Camera's avatar Dean Camera
Browse files

Clean up BUILD build system module - seperate architecture utility prefix code...

Clean up BUILD build system module - seperate architecture utility prefix code and sanity check from the CC_FLAGS construction code. Add target to print GCC version.
parent 719a0e7f
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# #
LUFA_BUILD_MODULES += BUILD LUFA_BUILD_MODULES += BUILD
LUFA_BUILD_TARGETS += size checksource all elf hex clean LUFA_BUILD_TARGETS += size checksource all elf hex lss gcc_version clean
LUFA_BUILD_MANDATORY_VARS += TARGET ARCH MCU SRC F_USB LUFA_PATH LUFA_BUILD_MANDATORY_VARS += TARGET ARCH MCU SRC F_USB LUFA_PATH
LUFA_BUILD_OPTIONAL_VARS += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS LUFA_BUILD_OPTIONAL_VARS += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS
...@@ -25,6 +25,8 @@ LUFA_BUILD_OPTIONAL_VARS += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_ ...@@ -25,6 +25,8 @@ LUFA_BUILD_OPTIONAL_VARS += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_
# all - Build application and list size # all - Build application and list size
# elf - Build application ELF debug object file # elf - Build application ELF debug object file
# hex - Build application HEX object files # hex - Build application HEX object files
# lss - Build application LSS assembly listing file
# gcc_version - Print version of GCC used
# clean - Remove output files # clean - Remove output files
# #
# MANDATORY PARAMETERS: # MANDATORY PARAMETERS:
...@@ -72,6 +74,17 @@ CPP_FLAGS ?= ...@@ -72,6 +74,17 @@ CPP_FLAGS ?=
ASM_FLAGS ?= ASM_FLAGS ?=
CC_FLAGS ?= CC_FLAGS ?=
# Determine the utility prefix to use for the selected architecture
ifeq ($(ARCH), AVR8)
CROSS = avr-
else ifeq ($(ARCH), XMEGA)
CROSS = avr-
else ifeq ($(ARCH), UC3)
CROSS = avr32-
else
$(error Unsupported architecture.)
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)\".
...@@ -94,15 +107,10 @@ DEPENDENCY_FILES = $(OBJECT_FILES:%=%.d) ...@@ -94,15 +107,10 @@ DEPENDENCY_FILES = $(OBJECT_FILES:%=%.d)
# Create a list of flags to pass to the compiler # Create a list of flags to pass to the compiler
ifeq ($(ARCH), AVR8) ifeq ($(ARCH), AVR8)
CC_FLAGS += -mmcu=$(MCU) -gdwarf-2 -fshort-enums -fno-inline-small-functions -fpack-struct CC_FLAGS += -mmcu=$(MCU) -gdwarf-2 -fshort-enums -fno-inline-small-functions -fpack-struct
CROSS = avr-
else ifeq ($(ARCH), XMEGA) else ifeq ($(ARCH), XMEGA)
CC_FLAGS += -mmcu=$(MCU) -gdwarf-2 -fshort-enums -fno-inline-small-functions -fpack-struct CC_FLAGS += -mmcu=$(MCU) -gdwarf-2 -fshort-enums -fno-inline-small-functions -fpack-struct
CROSS = avr-
else ifeq ($(ARCH), UC3) else ifeq ($(ARCH), UC3)
CC_FLAGS += -mpart=$(MCU) -g3 -masm-addr-pseudos CC_FLAGS += -mpart=$(MCU) -g3 -masm-addr-pseudos
CROSS = avr32-
else
$(error Unsupported architecture.)
endif endif
CC_FLAGS += -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections CC_FLAGS += -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections
CC_FLAGS += -I. -I$(patsubst %/,%,$(LUFA_PATH))/.. CC_FLAGS += -I. -I$(patsubst %/,%,$(LUFA_PATH))/..
...@@ -118,7 +126,7 @@ CPP_FLAGS += -O$(OPTIMIZATION) -std=$(CPP_STANDARD) -MMD -MP -MF $@.d ...@@ -118,7 +126,7 @@ CPP_FLAGS += -O$(OPTIMIZATION) -std=$(CPP_STANDARD) -MMD -MP -MF $@.d
# Create a list of flags to pass to the linker # Create a list of flags to pass to the linker
LD_FLAGS += -lm -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections LD_FLAGS += -lm -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections
ifeq ($(ARCH), UC3) ifeq ($(ARCH), UC3)
LD_FLAGS += --rodata-writable -Wl,--direct-data LD_FLAGS += --rodata-writable --direct-data
else else
LD_FLAGS += -Wl,--relax LD_FLAGS += -Wl,--relax
endif endif
...@@ -137,11 +145,16 @@ SIZE_FORMAT_FLAG = $(shell $(CROSS)size --help | grep -- --format=.*avr > /dev/n ...@@ -137,11 +145,16 @@ SIZE_FORMAT_FLAG = $(shell $(CROSS)size --help | grep -- --format=.*avr > /dev/n
begin: begin:
@echo "" @echo ""
@echo $(MSG_BUILD_BEGIN) @echo $(MSG_BUILD_BEGIN)
@echo ""
end: end:
@echo ""
@echo $(MSG_BUILD_END) @echo $(MSG_BUILD_END)
@echo "" @echo ""
gcc_version:
@$(CROSS)gcc --version
checksource: checksource:
@for f in $(SRC) $(CPPSRC) $(ASRC); do \ @for f in $(SRC) $(CPPSRC) $(ASRC); do \
if [ -f $$f ]; then \ if [ -f $$f ]; then \
...@@ -157,8 +170,8 @@ size: ...@@ -157,8 +170,8 @@ size:
$(CROSS)size $(SIZE_MCU_FLAG) $(SIZE_FORMAT_FLAG) $(TARGET).elf ; 2>/dev/null; \ $(CROSS)size $(SIZE_MCU_FLAG) $(SIZE_FORMAT_FLAG) $(TARGET).elf ; 2>/dev/null; \
fi fi
.PHONY: begin elf hex lss size end .PHONY: begin gcc_version elf hex lss size end
all: begin elf hex lss size end all: begin gcc_version elf hex lss size end
elf: $(TARGET).elf elf: $(TARGET).elf
hex: $(TARGET).hex $(TARGET).eep hex: $(TARGET).hex $(TARGET).eep
......
Markdown is supported
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