From 4145d6bec052608b0b023cb85f2f7f9e51521482 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 31 Dec 2017 17:24:46 +1100 Subject: Update DMBS to the latest version. --- LUFA/Build/DMBS/DMBS/WritingYourOwnModules.md | 6 +-- LUFA/Build/DMBS/DMBS/atprogram.mk | 6 +-- LUFA/Build/DMBS/DMBS/avrdude.md | 47 ++++++++++++++++++++ LUFA/Build/DMBS/DMBS/avrdude.mk | 47 +++++++++++++++++--- LUFA/Build/DMBS/DMBS/core.mk | 7 ++- LUFA/Build/DMBS/DMBS/cppcheck.mk | 6 +-- LUFA/Build/DMBS/DMBS/dfu.mk | 6 +-- LUFA/Build/DMBS/DMBS/doxygen.mk | 8 +--- LUFA/Build/DMBS/DMBS/gcc.md | 4 ++ LUFA/Build/DMBS/DMBS/gcc.mk | 32 ++++++++------ LUFA/Build/DMBS/DMBS/hid.mk | 9 ++-- .../DMBS/Template/lib/TEMPLATE_LIB/TEMPLATE_LIB.mk | 50 ++++++++++++++++++++++ .../lib/TEMPLATE_LIB/include/template_lib.h | 24 +++++++++++ .../Template/lib/TEMPLATE_LIB/src/template_lib.c | 10 +++++ .../lib/TEMPLATE_LIB/src/template_lib_private.h | 14 ++++++ LUFA/Build/DMBS/Template/makefile | 6 ++- 16 files changed, 236 insertions(+), 46 deletions(-) create mode 100644 LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/TEMPLATE_LIB.mk create mode 100644 LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/include/template_lib.h create mode 100644 LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/src/template_lib.c create mode 100644 LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/src/template_lib_private.h diff --git a/LUFA/Build/DMBS/DMBS/WritingYourOwnModules.md b/LUFA/Build/DMBS/DMBS/WritingYourOwnModules.md index 16df7a53b..bb8eb172a 100644 --- a/LUFA/Build/DMBS/DMBS/WritingYourOwnModules.md +++ b/LUFA/Build/DMBS/DMBS/WritingYourOwnModules.md @@ -34,11 +34,9 @@ the dependencies of another module's targets. Next, your module should always import the DMBS `CORE` module, via the following: - # Conditionally import the CORE module of DMBS if it is not already imported + # Import the CORE module of DMBS DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) - ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) - include $(DMBS_MODULE_PATH)/core.mk - endif + include $(DMBS_MODULE_PATH)/core.mk This ensures that the `make help` target is always available. In addition, the `CORE` module exposes some [commonly used macros and variables](core.md) to diff --git a/LUFA/Build/DMBS/DMBS/atprogram.mk b/LUFA/Build/DMBS/DMBS/atprogram.mk index a505275ae..26addd6c6 100644 --- a/LUFA/Build/DMBS/DMBS/atprogram.mk +++ b/LUFA/Build/DMBS/DMBS/atprogram.mk @@ -13,11 +13,9 @@ DMBS_BUILD_OPTIONAL_VARS += ATPROGRAM_PROGRAMMER ATPROGRAM_INTERFACE ATPROGRAM DMBS_BUILD_PROVIDED_VARS += DMBS_BUILD_PROVIDED_MACROS += -# Conditionally import the CORE module of DMBS if it is not already imported +# Import the CORE module of DMBS DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) - include $(DMBS_MODULE_PATH)/core.mk -endif +include $(DMBS_MODULE_PATH)/core.mk # Default values of optionally user-supplied variables ATPROGRAM_PROGRAMMER ?= atmelice diff --git a/LUFA/Build/DMBS/DMBS/avrdude.md b/LUFA/Build/DMBS/DMBS/avrdude.md index d6c71ce6d..9d6a1bbf9 100644 --- a/LUFA/Build/DMBS/DMBS/avrdude.md +++ b/LUFA/Build/DMBS/DMBS/avrdude.md @@ -30,6 +30,26 @@ The following targets are supported by this module: + + + + + + + + + + + + + + + + + + + + @@ -38,6 +58,14 @@ The following targets are supported by this module: + + + + + + + +
avrdude-lfuseProgram the device low fuse. Requires AVRDUDE_LFUSE variable set.
avrdude-hfuseProgram the device high fuse. Requires AVRDUDE_HFUSE variable set.
avrdude-efuseProgram the device extended fuse. Requires AVRDUDE_EFUSE variable set.
avrdude-lockProgram the device lock bits. Requires AVRDUDE_LOCK variable set.
avrdude-fusesProgram the device fuses (lfuse, hfuse, efuse, lock bits).
avrdude Program the device FLASH memory with the application's executable data.avrdude-ee Program the device EEPROM memory with the application's EEPROM data.
avrdude-allSame as avrdude + avrdude-fuses.
avrdude-all-eeSame as avrdude + avrdude-ee + avrdude-fuses.
@@ -83,6 +111,25 @@ be assumed. AVRDUDE_MEMORY Memory space to program when executing the `avrdude` target (e.g. 'application` for an XMEGA device). Default is `flash`. + AVRDUDE_BAUD + Baud rate to use when executing the `avrdude` target (e.g. '115200` for an Optiboot device). Default is empty. + + + AVRDUDE_HFUSE + Fuse setting to use when executing the `avrdude-hfuse` target (format: 0x??). Default is empty. + + + AVRDUDE_EFUSE + Fuse setting to use when executing the `avrdude-efuse` target (format: 0x??). Default is empty. + + + AVRDUDE_LFUSE + Fuse setting to use when executing the `avrdude-lfuse` target (format: 0x??). Default is empty. + + + AVRDUDE_LOCK + Bit bits setting to use when executing the `avrdude-lock` target (format: 0x??). Default is empty. + diff --git a/LUFA/Build/DMBS/DMBS/avrdude.mk b/LUFA/Build/DMBS/DMBS/avrdude.mk index c4bac8fd0..7b5f64ac1 100644 --- a/LUFA/Build/DMBS/DMBS/avrdude.mk +++ b/LUFA/Build/DMBS/DMBS/avrdude.mk @@ -7,23 +7,28 @@ # DMBS_BUILD_MODULES += AVRDUDE -DMBS_BUILD_TARGETS += avrdude avrdude-ee +DMBS_BUILD_TARGETS += avrdude-lfuse avrdude-hfuse avrdude-efuse avrdude-lock avrdude-fuses +DMBS_BUILD_TARGETS += avrdude avrdude-ee avrdude-all avrdude-all-ee DMBS_BUILD_MANDATORY_VARS += MCU TARGET -DMBS_BUILD_OPTIONAL_VARS += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS AVRDUDE_MEMORY +DMBS_BUILD_OPTIONAL_VARS += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS AVRDUDE_MEMORY AVRDUDE_BAUD +DMBS_BUILD_OPTIONAL_VARS += AVRDUDE_LFUSE AVRDUDE_HFUSE AVRDUDE_EUSE AVRDUDE_LOCK DMBS_BUILD_PROVIDED_VARS += DMBS_BUILD_PROVIDED_MACROS += -# Conditionally import the CORE module of DMBS if it is not already imported +# Import the CORE module of DMBS DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) - include $(DMBS_MODULE_PATH)/core.mk -endif +include $(DMBS_MODULE_PATH)/core.mk # Default values of optionally user-supplied variables AVRDUDE_PROGRAMMER ?= jtagicemkii AVRDUDE_PORT ?= usb AVRDUDE_FLAGS ?= AVRDUDE_MEMORY ?= flash +AVRDUDE_LFUSE ?= +AVRDUDE_HFUSE ?= +AVRDUDE_EFUSE ?= +AVRDUDE_LOCK ?= +AVRDUDE_BAUD ?= # Sanity check user supplied values $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) @@ -37,6 +42,9 @@ MSG_AVRDUDE_CMD := ' [AVRDUDE] :' # Construct base avrdude command flags BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +ifneq ($(AVRDUDE_BAUD),) + BASE_AVRDUDE_FLAGS += -b $(AVRDUDE_BAUD) +endif # Programs in the target FLASH memory using AVRDUDE avrdude: $(TARGET).hex $(MAKEFILE_LIST) @@ -48,5 +56,32 @@ avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST) @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\" avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS) +# Programs in the target fuses using AVRDUDE +avrdude-lfuse: $(MAKEFILE_LIST) + @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" low fuse using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\" + $(call ERROR_IF_EMPTY, AVRDUDE_LFUSE) + avrdude $(BASE_AVRDUDE_FLAGS) -Ulfuse:w:$(AVRDUDE_LFUSE):m $(AVRDUDE_FLAGS) + +avrdude-hfuse: $(MAKEFILE_LIST) + @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" high fuse using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\" + $(call ERROR_IF_EMPTY, AVRDUDE_HFUSE) + avrdude $(BASE_AVRDUDE_FLAGS) -Uhfuse:w:$(AVRDUDE_HFUSE):m $(AVRDUDE_FLAGS) + +avrdude-efuse: $(MAKEFILE_LIST) + @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" extended fuse using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\" + $(call ERROR_IF_EMPTY, AVRDUDE_EFUSE) + avrdude $(BASE_AVRDUDE_FLAGS) -Uefuse:w:$(AVRDUDE_EFUSE):m $(AVRDUDE_FLAGS) + +avrdude-lock: $(MAKEFILE_LIST) + @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" lock bits using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\" + $(call ERROR_IF_EMPTY, AVRDUDE_LOCK) + avrdude $(BASE_AVRDUDE_FLAGS) -Ulock:w:$(AVRDUDE_LOCK):m $(AVRDUDE_FLAGS) + +avrdude-fuses: avrdude-lfuse avrdude-hfuse avrdude-efuse avrdude-lock + +avrdude-all: avrdude avrdude-fuses + +avrdude-all-ee: avrdude avrdude-ee avrdude-fuses + # Phony build targets for this module .PHONY: $(DMBS_BUILD_TARGETS) diff --git a/LUFA/Build/DMBS/DMBS/core.mk b/LUFA/Build/DMBS/DMBS/core.mk index 1edbd178c..d18d4ef48 100644 --- a/LUFA/Build/DMBS/DMBS/core.mk +++ b/LUFA/Build/DMBS/DMBS/core.mk @@ -1,3 +1,6 @@ +# Include Guard +ifeq ($(filter CORE, $(DMBS_BUILD_MODULES)),) + # # DMBS Build System # Released into the public domain. @@ -16,7 +19,7 @@ DMBS_BUILD_PROVIDED_MACROS += DMBS_CHECK_VERSION ERROR_IF_UNSET ERROR_IF_EMPTY E SHELL = /bin/sh # Current DMBS release version -DMBS_VERSION := 20170426 +DMBS_VERSION := 20171231 # Macro to check the DMBS version, aborts if the given DMBS version is below the current version DMBS_CHECK_VERSION ?= $(if $(filter-out 0, $(shell test $(DMBS_VERSION) -lt $(1); echo $$?)), , $(error DMBS version $(1) or newer required, current version is $(DMBS_VERSION))) @@ -145,3 +148,5 @@ endif # Phony build targets for this module .PHONY: $(DMBS_BUILD_TARGETS) + +endif diff --git a/LUFA/Build/DMBS/DMBS/cppcheck.mk b/LUFA/Build/DMBS/DMBS/cppcheck.mk index 9b82fc3b0..0c40413f3 100644 --- a/LUFA/Build/DMBS/DMBS/cppcheck.mk +++ b/LUFA/Build/DMBS/DMBS/cppcheck.mk @@ -14,11 +14,9 @@ DMBS_BUILD_OPTIONAL_VARS += CPPCHECK_INCLUDES CPPCHECK_EXCLUDES CPPCHECK_MSG_T DMBS_BUILD_PROVIDED_VARS += DMBS_BUILD_PROVIDED_MACROS += -# Conditionally import the CORE module of DMBS if it is not already imported +# Import the CORE module of DMBS DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) - include $(DMBS_MODULE_PATH)/core.mk -endif +include $(DMBS_MODULE_PATH)/core.mk # Default values of optionally user-supplied variables CPPCHECK_INCLUDES ?= diff --git a/LUFA/Build/DMBS/DMBS/dfu.mk b/LUFA/Build/DMBS/DMBS/dfu.mk index 1eb22b864..ce214ef0d 100644 --- a/LUFA/Build/DMBS/DMBS/dfu.mk +++ b/LUFA/Build/DMBS/DMBS/dfu.mk @@ -13,11 +13,9 @@ DMBS_BUILD_OPTIONAL_VARS += DMBS_BUILD_PROVIDED_VARS += DMBS_BUILD_PROVIDED_MACROS += -# Conditionally import the CORE module of DMBS if it is not already imported +# Import the CORE module of DMBS DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) - include $(DMBS_MODULE_PATH)/core.mk -endif +include $(DMBS_MODULE_PATH)/core.mk # Sanity-check values of mandatory user-supplied variables $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) diff --git a/LUFA/Build/DMBS/DMBS/doxygen.mk b/LUFA/Build/DMBS/DMBS/doxygen.mk index 45639ad15..f37f21506 100644 --- a/LUFA/Build/DMBS/DMBS/doxygen.mk +++ b/LUFA/Build/DMBS/DMBS/doxygen.mk @@ -13,11 +13,9 @@ DMBS_BUILD_OPTIONAL_VARS += DOXYGEN_CONF DOXYGEN_FAIL_ON_WARNING DOXYGEN_OVERR DMBS_BUILD_PROVIDED_VARS += DMBS_BUILD_PROVIDED_MACROS += -# Conditionally import the CORE module of DMBS if it is not already imported +# Import the CORE module of DMBS DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) - include $(DMBS_MODULE_PATH)/core.mk -endif +include $(DMBS_MODULE_PATH)/core.mk # Default values of optionally user-supplied variables DOXYGEN_CONF ?= doxyfile @@ -58,5 +56,3 @@ doxygen-upgrade: $(DOXYGEN_CONF) $(MAKEFILE_LIST) doxygen-create: $(MAKEFILE_LIST) @echo $(MSG_DOXYGEN_CMD) Creating new configuration file \"$(DOXYGEN_CONF)\" with latest template doxygen -g $(DOXYGEN_CONF) > /dev/null - - diff --git a/LUFA/Build/DMBS/DMBS/gcc.md b/LUFA/Build/DMBS/DMBS/gcc.md index d28fd9ae4..f7f3480db 100644 --- a/LUFA/Build/DMBS/DMBS/gcc.md +++ b/LUFA/Build/DMBS/DMBS/gcc.md @@ -151,6 +151,10 @@ be assumed. JUMP_TABLES Boolean, if `Y` jump tables will be enabled to slightly reduce the resulting binary's size - note that this can cause incorrect jumps if the binary is relocated after compilation, such as for a bootloader. Default is `N`. + + LTO + Boolean, if `Y` link time optimization will be enabled to reduce the resulting binary's size. For larger projects you might also want to add `-mcall-prologues` to the `CC_FLAGS`. Default is `N`. + OBJDIR Directory to store the intermediate object files, as they are generated from the source files. Default is `obj`. diff --git a/LUFA/Build/DMBS/DMBS/gcc.mk b/LUFA/Build/DMBS/DMBS/gcc.mk index 6126cf97f..73065dcec 100644 --- a/LUFA/Build/DMBS/DMBS/gcc.mk +++ b/LUFA/Build/DMBS/DMBS/gcc.mk @@ -9,15 +9,15 @@ DMBS_BUILD_MODULES += GCC DMBS_BUILD_TARGETS += size symbol-sizes all lib elf bin hex lss clean mostlyclean DMBS_BUILD_MANDATORY_VARS += TARGET ARCH MCU SRC -DMBS_BUILD_OPTIONAL_VARS += COMPILER_PATH OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS OBJDIR OBJECT_FILES DEBUG_TYPE DEBUG_LEVEL LINKER_RELAXATIONS JUMP_TABLES +DMBS_BUILD_OPTIONAL_VARS += COMPILER_PATH OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS +DMBS_BUILD_OPTIONAL_VARS += CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS OBJDIR OBJECT_FILES DEBUG_TYPE +DMBS_BUILD_OPTIONAL_VARS += DEBUG_LEVEL LINKER_RELAXATIONS JUMP_TABLES LTO DMBS_BUILD_PROVIDED_VARS += DMBS_BUILD_PROVIDED_MACROS += -# Conditionally import the CORE module of DMBS if it is not already imported +# Import the CORE module of DMBS DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) - include $(DMBS_MODULE_PATH)/core.mk -endif +include $(DMBS_MODULE_PATH)/core.mk # Default values of optionally user-supplied variables COMPILER_PATH ?= @@ -35,6 +35,7 @@ DEBUG_FORMAT ?= dwarf-2 DEBUG_LEVEL ?= 2 LINKER_RELAXATIONS ?= Y JUMP_TABLES ?= N +LTO ?= N # Sanity check user supplied values $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) @@ -49,6 +50,7 @@ $(call ERROR_IF_EMPTY, DEBUG_FORMAT) $(call ERROR_IF_EMPTY, DEBUG_LEVEL) $(call ERROR_IF_NONBOOL, LINKER_RELAXATIONS) $(call ERROR_IF_NONBOOL, JUMP_TABLES) +$(call ERROR_IF_NONBOOL, LTO) # Determine the utility prefix to use for the selected architecture ifeq ($(ARCH), AVR8) @@ -108,7 +110,8 @@ DEPENDENCY_FILES := $(OBJECT_FILES:%.o=%.d) # Create a list of common flags to pass to the compiler/linker/assembler BASE_CC_FLAGS := -pipe -g$(DEBUG_FORMAT) -g$(DEBUG_LEVEL) ifneq ($(findstring $(ARCH), AVR8 XMEGA),) - BASE_CC_FLAGS += -mmcu=$(MCU) -fshort-enums -fno-inline-small-functions -fpack-struct + BASE_C_FLAGS += -fpack-struct + BASE_CC_FLAGS += -mmcu=$(MCU) -fshort-enums -fno-inline-small-functions else ifneq ($(findstring $(ARCH), UC3),) BASE_CC_FLAGS += -mpart=$(MCU:at32%=%) -masm-addr-pseudos endif @@ -128,10 +131,15 @@ ifeq ($(JUMP_TABLES), N) # in a pseudo-random jump target. BASE_CC_FLAGS += -fno-jump-tables endif +ifeq ($(LTO), Y) + # Enable link time optimization to reduce overall flash size. + BASE_CC_FLAGS += -flto -fuse-linker-plugin + BASE_LD_FLAGS += -flto -fuse-linker-plugin +endif # Additional language specific compiler flags BASE_C_FLAGS := -x c -O$(OPTIMIZATION) -std=$(C_STANDARD) -Wstrict-prototypes -BASE_CPP_FLAGS := -x c++ -O$(OPTIMIZATION) -std=$(CPP_STANDARD) +BASE_CPP_FLAGS := -x c++ -O$(OPTIMIZATION) -std=$(CPP_STANDARD) -fno-exceptions -fno-threadsafe-statics BASE_ASM_FLAGS := -x assembler-with-cpp # Create a list of flags to pass to the linker @@ -204,27 +212,27 @@ $(SRC): # Compiles an input C source file and generates an assembly listing for it %.s: %.c $(MAKEFILE_LIST) @echo $(MSG_COMPILE_CMD) Generating assembly from C file \"$(notdir $<)\" - $(CROSS)-gcc -S $(BASE_CC_FLAGS) $(BASE_C_FLAGS) $(CC_FLAGS) $(C_FLAGS) $< -o $@ + $(CROSS)-gcc -S $(BASE_CC_FLAGS) $(BASE_C_FLAGS) $(CC_FLAGS) $(C_FLAGS) $($(notdir $<)_FLAGS) $< -o $@ # Compiles an input C++ source file and generates an assembly listing for it %.s: %.cpp $(MAKEFILE_LIST) @echo $(MSG_COMPILE_CMD) Generating assembly from C++ file \"$(notdir $<)\" - $(CROSS)-gcc -S $(BASE_CC_FLAGS) $(BASE_CPP_FLAGS) $(CC_FLAGS) $(CPP_FLAGS) $< -o $@ + $(CROSS)-gcc -S $(BASE_CC_FLAGS) $(BASE_CPP_FLAGS) $(CC_FLAGS) $(CPP_FLAGS) $($(notdir $<)_FLAGS) $< -o $@ # Compiles an input C source file and generates a linkable object file for it $(OBJDIR)/%.o: %.c $(MAKEFILE_LIST) @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) $($(notdir $<)_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@ # Compiles an input C++ source file and generates a linkable object file for it $(OBJDIR)/%.o: %.cpp $(MAKEFILE_LIST) @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) $($(notdir $<)_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@ # Assembles an input ASM source file and generates a linkable object file for it $(OBJDIR)/%.o: %.S $(MAKEFILE_LIST) @echo $(MSG_ASSEMBLE_CMD) Assembling \"$(notdir $<)\" - $(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_ASM_FLAGS) $(CC_FLAGS) $(ASM_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@ + $(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_ASM_FLAGS) $(CC_FLAGS) $(ASM_FLAGS) $($(notdir $<)_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@ # Generates a library archive file from the user application, which can be linked into other applications .PRECIOUS : $(OBJECT_FILES) diff --git a/LUFA/Build/DMBS/DMBS/hid.mk b/LUFA/Build/DMBS/DMBS/hid.mk index 7a0ad9d0e..d3195b2ab 100644 --- a/LUFA/Build/DMBS/DMBS/hid.mk +++ b/LUFA/Build/DMBS/DMBS/hid.mk @@ -13,11 +13,9 @@ DMBS_BUILD_OPTIONAL_VARS += DMBS_BUILD_PROVIDED_VARS += DMBS_BUILD_PROVIDED_MACROS += -# Conditionally import the CORE module of DMBS if it is not already imported +# Import the CORE module of DMBS DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) - include $(DMBS_MODULE_PATH)/core.mk -endif +include $(DMBS_MODULE_PATH)/core.mk # Sanity-check values of mandatory user-supplied variables $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) @@ -29,6 +27,9 @@ MSG_HID_BOOTLOADER_CMD := ' [HID] :' MSG_OBJCPY_CMD := ' [OBJCPY] :' MSG_MAKE_CMD := ' [MAKE] :' +# Set MAKE variable if the environment does not already define it +MAKE ?= make + # Programs in the target FLASH memory using the HID_BOOTLOADER_CLI tool hid: $(TARGET).hex $(MAKEFILE_LIST) @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\" diff --git a/LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/TEMPLATE_LIB.mk b/LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/TEMPLATE_LIB.mk new file mode 100644 index 000000000..57037506f --- /dev/null +++ b/LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/TEMPLATE_LIB.mk @@ -0,0 +1,50 @@ +# +# DMBS Build System +# Released into the public domain. +# +# dean [at] fourwalledcubicle [dot] com +# www.fourwalledcubicle.com +# + +# Include Guard +ifeq ($(filter TEMPLATE_LIB, $(DMBS_BUILD_MODULES)),) + +# Sanity check user supplied DMBS path +ifndef DMBS_PATH +$(error Makefile DMBS_PATH option cannot be blank) +endif + +# Location of the current module +TEMPLATE_LIB_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) + +# Import the CORE module of DMBS +include $(DMBS_PATH)/core.mk + +# This module needs to be included before gcc.mk +ifneq ($(findstring GCC, $(DMBS_BUILD_MODULES)),) +$(error Include this module before gcc.mk) +endif + +# Help settings +DMBS_BUILD_MODULES += TEMPLATE_LIB +DMBS_BUILD_TARGETS += +DMBS_BUILD_MANDATORY_VARS += DMBS_PATH +DMBS_BUILD_OPTIONAL_VARS += +DMBS_BUILD_PROVIDED_VARS += TEMPLATE_LIB_SRC +DMBS_BUILD_PROVIDED_MACROS += + +# Sanity check user supplied values +$(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) + +# TEMPLATE_LIB Library +TEMPLATE_LIB_SRC := $(TEMPLATE_LIB_MODULE_PATH)/src/template_lib.c + +# Compiler flags and sources +SRC += $(TEMPLATE_LIB_SRC) +CC_FLAGS += -DDMBS_MODULE_TEMPLATE_LIB +CC_FLAGS += -I$(TEMPLATE_LIB_MODULE_PATH)/include/ + +# Phony build targets for this module +.PHONY: $(DMBS_BUILD_TARGETS) + +endif diff --git a/LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/include/template_lib.h b/LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/include/template_lib.h new file mode 100644 index 000000000..1baa6357e --- /dev/null +++ b/LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/include/template_lib.h @@ -0,0 +1,24 @@ +/* + DMBS Build System + Released into the public domain. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com + */ + +// Include Guard +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +// Software version +#define TEMPLATE_LIB_VERSION 100 + +#include +#include + +#ifdef __cplusplus +} +#endif diff --git a/LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/src/template_lib.c b/LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/src/template_lib.c new file mode 100644 index 000000000..f7f6945c1 --- /dev/null +++ b/LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/src/template_lib.c @@ -0,0 +1,10 @@ +/* + DMBS Build System + Released into the public domain. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com + */ + +#include "template_lib.h" +#include "template_lib_private.h" diff --git a/LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/src/template_lib_private.h b/LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/src/template_lib_private.h new file mode 100644 index 000000000..714cd3be8 --- /dev/null +++ b/LUFA/Build/DMBS/Template/lib/TEMPLATE_LIB/src/template_lib_private.h @@ -0,0 +1,14 @@ +/* + DMBS Build System + Released into the public domain. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com + */ + +// Include Guard +#pragma once + +#include +#include +#include diff --git a/LUFA/Build/DMBS/Template/makefile b/LUFA/Build/DMBS/Template/makefile index d88292388..817f96fe3 100644 --- a/LUFA/Build/DMBS/Template/makefile +++ b/LUFA/Build/DMBS/Template/makefile @@ -20,8 +20,12 @@ LD_FLAGS = # Default target all: -# Include DMBS build script makefiles +# Include libraries and DMBS build script makefiles DMBS_PATH ?= ../DMBS +LIB_PATH ?= lib + +include $(LIB_PATH)/TEMPLATE_LIB/TEMPLATE_LIB.mk + include $(DMBS_PATH)/core.mk include $(DMBS_PATH)/gcc.mk include $(DMBS_PATH)/cppcheck.mk -- cgit v1.2.3