From 7655205aac2ae8aca89bcd4e3e056bb20a33414c Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sat, 2 Jun 2012 21:45:51 +0000 Subject: [PATCH] Clean up CORE build system module, use simple rather than recursive make variables for internal constants and $(shell) derived values. --- Bootloaders/CDC/makefile | 8 ++++---- Bootloaders/DFU/makefile | 8 ++++---- Bootloaders/HID/makefile | 8 ++++---- LUFA/Build/lufa.avrdude.in | 2 +- LUFA/Build/lufa.build.in | 26 +++++++++++++------------- LUFA/Build/lufa.core.in | 38 ++++++++++++++++++++------------------ LUFA/Build/lufa.dfu.in | 6 +++--- LUFA/Build/lufa.doxygen.in | 2 +- LUFA/makefile | 5 +++-- 9 files changed, 53 insertions(+), 50 deletions(-) diff --git a/Bootloaders/CDC/makefile b/Bootloaders/CDC/makefile index 64d7928582..822a411b99 100644 --- a/Bootloaders/CDC/makefile +++ b/Bootloaders/CDC/makefile @@ -14,14 +14,14 @@ # # Note that the bootloader size and start address given in AVRStudio is in words and not # bytes, and so will need to be doubled to obtain the byte address needed by AVR-GCC. -FLASH_SIZE_KB = 128 -BOOT_SECTION_SIZE_KB = 8 +FLASH_SIZE_KB := 128 +BOOT_SECTION_SIZE_KB := 8 # Formulas used to calculate the starting address of the Bootloader section, and the User Application # API jump table (for more information on the latter, see the bootloader documentation). These formulas # should not need to be altered - modify the FLASH_SIZE_KB and BOOT_SECTION_KB values above instead. -BOOT_START = 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc) -BOOT_API_TABLESTART = 0x$(shell echo "obase=16; (($(FLASH_SIZE_KB) * 1024) - 96)" | bc) +BOOT_START := 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc) +BOOT_API_TABLESTART := 0x$(shell echo "obase=16; (($(FLASH_SIZE_KB) * 1024) - 96)" | bc) MCU = at90usb1287 ARCH = AVR8 diff --git a/Bootloaders/DFU/makefile b/Bootloaders/DFU/makefile index 22ae1d67e2..d6d1bb313f 100644 --- a/Bootloaders/DFU/makefile +++ b/Bootloaders/DFU/makefile @@ -14,14 +14,14 @@ # # Note that the bootloader size and start address given in AVRStudio is in words and not # bytes, and so will need to be doubled to obtain the byte address needed by AVR-GCC. -FLASH_SIZE_KB = 128 -BOOT_SECTION_SIZE_KB = 8 +FLASH_SIZE_KB := 128 +BOOT_SECTION_SIZE_KB := 8 # Formulas used to calculate the starting address of the Bootloader section, and the User Application # API jump table (for more information on the latter, see the bootloader documentation). These formulas # should not need to be altered - modify the FLASH_SIZE_KB and BOOT_SECTION_KB values above instead. -BOOT_START = 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc) -BOOT_API_TABLESTART = 0x$(shell echo "obase=16; (($(FLASH_SIZE_KB) * 1024) - 96)" | bc) +BOOT_START := 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc) +BOOT_API_TABLESTART := 0x$(shell echo "obase=16; (($(FLASH_SIZE_KB) * 1024) - 96)" | bc) MCU = at90usb1287 ARCH = AVR8 diff --git a/Bootloaders/HID/makefile b/Bootloaders/HID/makefile index 9e33f7bfe5..667bfd96ba 100644 --- a/Bootloaders/HID/makefile +++ b/Bootloaders/HID/makefile @@ -14,14 +14,14 @@ # # Note that the bootloader size and start address given in AVRStudio is in words and not # bytes, and so will need to be doubled to obtain the byte address needed by AVR-GCC. -FLASH_SIZE_KB = 128 -BOOT_SECTION_SIZE_KB = 8 +FLASH_SIZE_KB := 128 +BOOT_SECTION_SIZE_KB := 8 # Formulas used to calculate the starting address of the Bootloader section, and the User Application # API jump table (for more information on the latter, see the bootloader documentation). These formulas # should not need to be altered - modify the FLASH_SIZE_KB and BOOT_SECTION_KB values above instead. -BOOT_START = 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc) -BOOT_API_TABLESTART = 0x$(shell echo "obase=16; (($(FLASH_SIZE_KB) * 1024) - 96)" | bc) +BOOT_START := 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc) +BOOT_API_TABLESTART := 0x$(shell echo "obase=16; (($(FLASH_SIZE_KB) * 1024) - 96)" | bc) MCU = at90usb1287 ARCH = AVR8 diff --git a/LUFA/Build/lufa.avrdude.in b/LUFA/Build/lufa.avrdude.in index dcffe84f5e..0148504538 100644 --- a/LUFA/Build/lufa.avrdude.in +++ b/LUFA/Build/lufa.avrdude.in @@ -48,7 +48,7 @@ AVRDUDE_PORT ?= usb AVRDUDE_FLAGS ?= # Output Messages -MSG_AVRDUDE_CMD = ' [AVRDUDE] :' +MSG_AVRDUDE_CMD := ' [AVRDUDE] :' AVRDUDE_FLASH_FLAGS = -U flash:w:$< $(AVRDUDE_FLAGS) AVRDUDE_EEP_FLAGS = -U eeprom:w:$< $(AVRDUDE_FLAGS) diff --git a/LUFA/Build/lufa.build.in b/LUFA/Build/lufa.build.in index a4b5c363e9..3b28db9ee7 100644 --- a/LUFA/Build/lufa.build.in +++ b/LUFA/Build/lufa.build.in @@ -76,24 +76,24 @@ CC_FLAGS ?= # Determine the utility prefix to use for the selected architecture ifeq ($(ARCH), AVR8) - CROSS = avr- + CROSS := avr- else ifeq ($(ARCH), XMEGA) - CROSS = avr- + CROSS := avr- else ifeq ($(ARCH), UC3) - CROSS = avr32- + CROSS := avr32- else $(error Unsupported architecture.) endif # Output Messages -MSG_BUILD_BEGIN = Begin compilation of project \"$(TARGET)\"... -MSG_BUILD_END = Finished building project \"$(TARGET)\". -MSG_COMPILE_CMD = ' [CC] :' -MSG_REMOVE_CMD = ' [RM] :' -MSG_LINKER_CMD = ' [LNK] :' -MSG_SIZE_CMD = ' [SIZE] :' -MSG_OBJCPY_CMD = ' [OBJCPY] :' -MSG_OBJDMP_CMD = ' [OBJDMP] :' +MSG_BUILD_BEGIN := Begin compilation of project \"$(TARGET)\"... +MSG_BUILD_END := Finished building project \"$(TARGET)\". +MSG_COMPILE_CMD := ' [CC] :' +MSG_REMOVE_CMD := ' [RM] :' +MSG_LINKER_CMD := ' [LNK] :' +MSG_SIZE_CMD := ' [SIZE] :' +MSG_OBJCPY_CMD := ' [OBJCPY] :' +MSG_OBJDMP_CMD := ' [OBJDMP] :' # Convert input source file list to differentiate them by type C_SOURCE = $(filter %.c, $(SRC)) @@ -138,8 +138,8 @@ ifneq ($(UNKNOWN_SOURCE),) endif # 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_FORMAT_FLAG = $(shell $(CROSS)size --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) +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 ) begin: diff --git a/LUFA/Build/lufa.core.in b/LUFA/Build/lufa.core.in index bc07a940ac..f403b9edb5 100644 --- a/LUFA/Build/lufa.core.in +++ b/LUFA/Build/lufa.core.in @@ -7,7 +7,7 @@ # LUFA_BUILD_MODULES += CORE -LUFA_BUILD_TARGETS += info help list_targets list_modules list_mandatory list_optional +LUFA_BUILD_TARGETS += help list_targets list_modules list_mandatory list_optional LUFA_BUILD_MANDATORY_VARS += LUFA_BUILD_OPTIONAL_VARS += @@ -19,7 +19,6 @@ LUFA_BUILD_OPTIONAL_VARS += # ----------------------------------------------------------------------------- # TARGETS: # -# info - Build system information # help - Build system help # list_targets - List all build targets # list_modules - List all build modules @@ -38,14 +37,17 @@ LUFA_BUILD_OPTIONAL_VARS += # # ----------------------------------------------------------------------------- -info: +# Build sorted and filtered lists of the included build module data +SORTED_LUFA_BUILD_MODULES = $(sort $(LUFA_BUILD_MODULES)) +SORTED_LUFA_BUILD_TARGETS = $(sort $(LUFA_BUILD_TARGETS)) +SORTED_LUFA_MANDATORY_VARS = $(sort $(LUFA_BUILD_MANDATORY_VARS)) +SORTED_LUFA_OPTIONAL_VARS = $(filter-out $(SORTED_LUFA_MANDATORY_VARS), $(sort $(LUFA_BUILD_OPTIONAL_VARS))) + +help: @echo "===================================================================" - @echo " LUFA Build System 2.0 " - @echo " (C) Dean Camera { dean @ fourwalledcubicle . com } " + @echo " LUFA Build System 2.0 " + @echo " (C) Dean Camera, 2012 { dean @ fourwalledcubicle . com } " @echo "===================================================================" - -.PHONY: info -help: info @echo "DESCRIPTION: " @echo " This build system is a set of makefile modules for (GNU) Make, to " @echo " provide a simple system for building LUFA powered applications. " @@ -61,35 +63,35 @@ help: info @echo "===================================================================" @echo " Currently used modules in this application: " @echo " " - @echo " [" $(sort $(LUFA_BUILD_MODULES)) "]" + @echo " [" $(SORTED_LUFA_BUILD_MODULES) "]" @echo " " @echo " " @echo " Currently available build targets in this application: " @echo " " - @echo " [" $(sort $(LUFA_BUILD_TARGETS)) "]" + @echo " [" $(SORTED_LUFA_BUILD_TARGETS) "]" @echo " " @echo " " @echo " Mandatory variables required by the selected build Modules: " @echo " " - @echo " [" $(sort $(LUFA_BUILD_MANDATORY_VARS)) "]" + @echo " [" $(SORTED_LUFA_MANDATORY_VARS) "]" @echo " " @echo " " @echo " Optional variables required by the selected build Modules: " @echo " " - @echo " [" $(filter-out $(LUFA_BUILD_MANDATORY_VARS), $(sort $(LUFA_BUILD_OPTIONAL_VARS))) "]" + @echo " [" $(SORTED_LUFA_OPTIONAL_VARS) "]" @echo " " @echo "===================================================================" @echo " The LUFA BuildSystem 2.0 - Powered By Unicorns (tm) " @echo "===================================================================" -list_targets: - @echo Currently Available Build Targets: $(sort $(LUFA_BUILD_TARGETS)) - list_modules: - @echo Currently Build Modules: $(sort $(LUFA_BUILD_MODULES)) + @echo Currently Build Modules: $(SORTED_LUFA_BUILD_MODULES) + +list_targets: + @echo Currently Available Build Targets: $(SORTED_LUFA_BUILD_TARGETS) list_mandatory: - @echo Mandatory Variables for Included Modules: $(sort $(LUFA_BUILD_MANDATORY_VARS)) + @echo Mandatory Variables for Included Modules: $(SORTED_LUFA_MANDATORY_VARS) list_optional: - @echo Optional Variables for Included Modules: $(filter-out $(LUFA_BUILD_MANDATORY_VARS), $(sort $(LUFA_BUILD_OPTIONAL_VARS))) + @echo Optional Variables for Included Modules: $(SORTED_LUFA_OPTIONAL_VARS) diff --git a/LUFA/Build/lufa.dfu.in b/LUFA/Build/lufa.dfu.in index c3a102be82..f855bf7b03 100644 --- a/LUFA/Build/lufa.dfu.in +++ b/LUFA/Build/lufa.dfu.in @@ -41,9 +41,9 @@ MCU ?= $(error Makefile MCU value not set.) TARGET ?= $(error Makefile TARGET value not set.) # Output Messages -MSG_COPY_CMD = ' [CP] :' -MSG_REMOVE_CMD = ' [RM] :' -MSG_DFU_CMD = ' [DFU] :' +MSG_COPY_CMD := ' [CP] :' +MSG_REMOVE_CMD := ' [RM] :' +MSG_DFU_CMD := ' [DFU] :' flip: $(TARGET).hex @echo $(MSG_DFU_CMD) Programming FLASH with batchisp using \"$(TARGET).hex\" diff --git a/LUFA/Build/lufa.doxygen.in b/LUFA/Build/lufa.doxygen.in index f1b9a9d6ea..7d4f8ae319 100644 --- a/LUFA/Build/lufa.doxygen.in +++ b/LUFA/Build/lufa.doxygen.in @@ -44,7 +44,7 @@ DOXYGEN_FAIL_ON_WARNING ?= Y DOXYGEN_OVERRIDE_PARAMS ?= QUIET=YES HTML_STYLESHEET=$(patsubst %/,%,$(LUFA_PATH))/DoxygenPages/Style/Style.css # Output Messages -MSG_DOXYGEN_CMD = ' [DOXYGEN] :' +MSG_DOXYGEN_CMD := ' [DOXYGEN] :' # Determine Doxygen invocation command BASE_DOXYGEN_CMD = ( cat Doxygen.conf $(DOXYGEN_OVERRIDE_PARAMS:%=; echo "%") ) | doxygen - diff --git a/LUFA/makefile b/LUFA/makefile index 5b186937cb..31c06b32f9 100644 --- a/LUFA/makefile +++ b/LUFA/makefile @@ -9,8 +9,9 @@ # Makefile for the LUFA library itself. # --------------------------------------- -LUFA_VERSION_NUM = $(shell grep LUFA_VERSION_STRING Version.h | cut -d'"' -f2) -EXCLUDE_FROM_EXPORT = Documentation DoxygenPages CodeTemplates Build *.conf *.tar *.o *.lss *.lst *.hex *.elf *.bin +LUFA_VERSION_NUM := $(shell grep LUFA_VERSION_STRING Version.h | cut -d'"' -f2) +EXCLUDE_FROM_EXPORT := Documentation DoxygenPages CodeTemplates Build *.conf *.tar *.o *.lss *.lst *.hex *.elf *.bin + DOXYGEN_OVERRIDE_PARAMS = PROJECT_NUMBER=$(LUFA_VERSION_NUM) all: