Commit 4145d6be authored by Dean Camera's avatar Dean Camera
Browse files

Update DMBS to the latest version.

parent b5c251a7
...@@ -34,11 +34,9 @@ the dependencies of another module's targets. ...@@ -34,11 +34,9 @@ the dependencies of another module's targets.
Next, your module should always import the DMBS `CORE` module, via the Next, your module should always import the DMBS `CORE` module, via the
following: 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)))) DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) include $(DMBS_MODULE_PATH)/core.mk
include $(DMBS_MODULE_PATH)/core.mk
endif
This ensures that the `make help` target is always available. In addition, the 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 `CORE` module exposes some [commonly used macros and variables](core.md) to
......
...@@ -13,11 +13,9 @@ DMBS_BUILD_OPTIONAL_VARS += ATPROGRAM_PROGRAMMER ATPROGRAM_INTERFACE ATPROGRAM ...@@ -13,11 +13,9 @@ DMBS_BUILD_OPTIONAL_VARS += ATPROGRAM_PROGRAMMER ATPROGRAM_INTERFACE ATPROGRAM
DMBS_BUILD_PROVIDED_VARS += DMBS_BUILD_PROVIDED_VARS +=
DMBS_BUILD_PROVIDED_MACROS += 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)))) DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) include $(DMBS_MODULE_PATH)/core.mk
include $(DMBS_MODULE_PATH)/core.mk
endif
# Default values of optionally user-supplied variables # Default values of optionally user-supplied variables
ATPROGRAM_PROGRAMMER ?= atmelice ATPROGRAM_PROGRAMMER ?= atmelice
......
...@@ -30,6 +30,26 @@ The following targets are supported by this module: ...@@ -30,6 +30,26 @@ The following targets are supported by this module:
<table> <table>
<tbody> <tbody>
<tr>
<td>avrdude-lfuse</td>
<td>Program the device low fuse. Requires AVRDUDE_LFUSE variable set.</td>
</tr>
<tr>
<td>avrdude-hfuse</td>
<td>Program the device high fuse. Requires AVRDUDE_HFUSE variable set.</td>
</tr>
<tr>
<td>avrdude-efuse</td>
<td>Program the device extended fuse. Requires AVRDUDE_EFUSE variable set.</td>
</tr>
<tr>
<td>avrdude-lock</td>
<td>Program the device lock bits. Requires AVRDUDE_LOCK variable set.</td>
</tr>
<tr>
<td>avrdude-fuses</td>
<td>Program the device fuses (lfuse, hfuse, efuse, lock bits).</td>
</tr>
<tr> <tr>
<td>avrdude</td> <td>avrdude</td>
<td>Program the device FLASH memory with the application's executable data.</td> <td>Program the device FLASH memory with the application's executable data.</td>
...@@ -38,6 +58,14 @@ The following targets are supported by this module: ...@@ -38,6 +58,14 @@ The following targets are supported by this module:
<td>avrdude-ee</td> <td>avrdude-ee</td>
<td>Program the device EEPROM memory with the application's EEPROM data.</td> <td>Program the device EEPROM memory with the application's EEPROM data.</td>
</tr> </tr>
<tr>
<td>avrdude-all</td>
<td>Same as avrdude + avrdude-fuses.</td>
</tr>
<tr>
<td>avrdude-all-ee</td>
<td>Same as avrdude + avrdude-ee + avrdude-fuses.</td>
</tr>
</tbody> </tbody>
</table> </table>
...@@ -83,6 +111,25 @@ be assumed. ...@@ -83,6 +111,25 @@ be assumed.
<td>AVRDUDE_MEMORY</td> <td>AVRDUDE_MEMORY</td>
<td>Memory space to program when executing the `avrdude` target (e.g. 'application` for an XMEGA device). Default is `flash`.</td> <td>Memory space to program when executing the `avrdude` target (e.g. 'application` for an XMEGA device). Default is `flash`.</td>
</tr> </tr>
<td>AVRDUDE_BAUD</td>
<td>Baud rate to use when executing the `avrdude` target (e.g. '115200` for an Optiboot device). Default is empty.</td>
</tr>
</tr>
<td>AVRDUDE_HFUSE</td>
<td>Fuse setting to use when executing the `avrdude-hfuse` target (format: 0x??). Default is empty.</td>
</tr>
</tr>
<td>AVRDUDE_EFUSE</td>
<td>Fuse setting to use when executing the `avrdude-efuse` target (format: 0x??). Default is empty.</td>
</tr>
</tr>
<td>AVRDUDE_LFUSE</td>
<td>Fuse setting to use when executing the `avrdude-lfuse` target (format: 0x??). Default is empty.</td>
</tr>
</tr>
<td>AVRDUDE_LOCK</td>
<td>Bit bits setting to use when executing the `avrdude-lock` target (format: 0x??). Default is empty.</td>
</tr>
</tbody> </tbody>
</table> </table>
......
...@@ -7,23 +7,28 @@ ...@@ -7,23 +7,28 @@
# #
DMBS_BUILD_MODULES += AVRDUDE 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_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_VARS +=
DMBS_BUILD_PROVIDED_MACROS += 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)))) DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) include $(DMBS_MODULE_PATH)/core.mk
include $(DMBS_MODULE_PATH)/core.mk
endif
# Default values of optionally user-supplied variables # Default values of optionally user-supplied variables
AVRDUDE_PROGRAMMER ?= jtagicemkii AVRDUDE_PROGRAMMER ?= jtagicemkii
AVRDUDE_PORT ?= usb AVRDUDE_PORT ?= usb
AVRDUDE_FLAGS ?= AVRDUDE_FLAGS ?=
AVRDUDE_MEMORY ?= flash AVRDUDE_MEMORY ?= flash
AVRDUDE_LFUSE ?=
AVRDUDE_HFUSE ?=
AVRDUDE_EFUSE ?=
AVRDUDE_LOCK ?=
AVRDUDE_BAUD ?=
# Sanity check user supplied values # Sanity check user supplied values
$(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
...@@ -37,6 +42,9 @@ MSG_AVRDUDE_CMD := ' [AVRDUDE] :' ...@@ -37,6 +42,9 @@ MSG_AVRDUDE_CMD := ' [AVRDUDE] :'
# Construct base avrdude command flags # Construct base avrdude command flags
BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) 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 # Programs in the target FLASH memory using AVRDUDE
avrdude: $(TARGET).hex $(MAKEFILE_LIST) avrdude: $(TARGET).hex $(MAKEFILE_LIST)
...@@ -48,5 +56,32 @@ avrdude-ee: $(TARGET).eep $(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)\" @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS) 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 build targets for this module
.PHONY: $(DMBS_BUILD_TARGETS) .PHONY: $(DMBS_BUILD_TARGETS)
# Include Guard
ifeq ($(filter CORE, $(DMBS_BUILD_MODULES)),)
# #
# DMBS Build System # DMBS Build System
# Released into the public domain. # Released into the public domain.
...@@ -16,7 +19,7 @@ DMBS_BUILD_PROVIDED_MACROS += DMBS_CHECK_VERSION ERROR_IF_UNSET ERROR_IF_EMPTY E ...@@ -16,7 +19,7 @@ DMBS_BUILD_PROVIDED_MACROS += DMBS_CHECK_VERSION ERROR_IF_UNSET ERROR_IF_EMPTY E
SHELL = /bin/sh SHELL = /bin/sh
# Current DMBS release version # 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 # 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))) 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 ...@@ -145,3 +148,5 @@ endif
# Phony build targets for this module # Phony build targets for this module
.PHONY: $(DMBS_BUILD_TARGETS) .PHONY: $(DMBS_BUILD_TARGETS)
endif
...@@ -14,11 +14,9 @@ DMBS_BUILD_OPTIONAL_VARS += CPPCHECK_INCLUDES CPPCHECK_EXCLUDES CPPCHECK_MSG_T ...@@ -14,11 +14,9 @@ DMBS_BUILD_OPTIONAL_VARS += CPPCHECK_INCLUDES CPPCHECK_EXCLUDES CPPCHECK_MSG_T
DMBS_BUILD_PROVIDED_VARS += DMBS_BUILD_PROVIDED_VARS +=
DMBS_BUILD_PROVIDED_MACROS += 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)))) DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) include $(DMBS_MODULE_PATH)/core.mk
include $(DMBS_MODULE_PATH)/core.mk
endif
# Default values of optionally user-supplied variables # Default values of optionally user-supplied variables
CPPCHECK_INCLUDES ?= CPPCHECK_INCLUDES ?=
......
...@@ -13,11 +13,9 @@ DMBS_BUILD_OPTIONAL_VARS += ...@@ -13,11 +13,9 @@ DMBS_BUILD_OPTIONAL_VARS +=
DMBS_BUILD_PROVIDED_VARS += DMBS_BUILD_PROVIDED_VARS +=
DMBS_BUILD_PROVIDED_MACROS += 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)))) DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) include $(DMBS_MODULE_PATH)/core.mk
include $(DMBS_MODULE_PATH)/core.mk
endif
# Sanity-check values of mandatory user-supplied variables # Sanity-check values of mandatory user-supplied variables
$(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
......
...@@ -13,11 +13,9 @@ DMBS_BUILD_OPTIONAL_VARS += DOXYGEN_CONF DOXYGEN_FAIL_ON_WARNING DOXYGEN_OVERR ...@@ -13,11 +13,9 @@ DMBS_BUILD_OPTIONAL_VARS += DOXYGEN_CONF DOXYGEN_FAIL_ON_WARNING DOXYGEN_OVERR
DMBS_BUILD_PROVIDED_VARS += DMBS_BUILD_PROVIDED_VARS +=
DMBS_BUILD_PROVIDED_MACROS += 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)))) DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) include $(DMBS_MODULE_PATH)/core.mk
include $(DMBS_MODULE_PATH)/core.mk
endif
# Default values of optionally user-supplied variables # Default values of optionally user-supplied variables
DOXYGEN_CONF ?= doxyfile DOXYGEN_CONF ?= doxyfile
...@@ -58,5 +56,3 @@ doxygen-upgrade: $(DOXYGEN_CONF) $(MAKEFILE_LIST) ...@@ -58,5 +56,3 @@ doxygen-upgrade: $(DOXYGEN_CONF) $(MAKEFILE_LIST)
doxygen-create: $(MAKEFILE_LIST) doxygen-create: $(MAKEFILE_LIST)
@echo $(MSG_DOXYGEN_CMD) Creating new configuration file \"$(DOXYGEN_CONF)\" with latest template @echo $(MSG_DOXYGEN_CMD) Creating new configuration file \"$(DOXYGEN_CONF)\" with latest template
doxygen -g $(DOXYGEN_CONF) > /dev/null doxygen -g $(DOXYGEN_CONF) > /dev/null
...@@ -151,6 +151,10 @@ be assumed. ...@@ -151,6 +151,10 @@ be assumed.
<td>JUMP_TABLES</td> <td>JUMP_TABLES</td>
<td>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`.</td> <td>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`.</td>
</tr> </tr>
<tr>
<td>LTO</td>
<td>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`.</td>
</tr>
<tr> <tr>
<td>OBJDIR</td> <td>OBJDIR</td>
<td>Directory to store the intermediate object files, as they are generated from the source files. Default is `obj`.</td> <td>Directory to store the intermediate object files, as they are generated from the source files. Default is `obj`.</td>
......
...@@ -9,15 +9,15 @@ ...@@ -9,15 +9,15 @@
DMBS_BUILD_MODULES += GCC DMBS_BUILD_MODULES += GCC
DMBS_BUILD_TARGETS += size symbol-sizes all lib elf bin hex lss clean mostlyclean DMBS_BUILD_TARGETS += size symbol-sizes all lib elf bin hex lss clean mostlyclean
DMBS_BUILD_MANDATORY_VARS += TARGET ARCH MCU SRC 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_VARS +=
DMBS_BUILD_PROVIDED_MACROS += 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)))) DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) include $(DMBS_MODULE_PATH)/core.mk
include $(DMBS_MODULE_PATH)/core.mk
endif
# Default values of optionally user-supplied variables # Default values of optionally user-supplied variables
COMPILER_PATH ?= COMPILER_PATH ?=
...@@ -35,6 +35,7 @@ DEBUG_FORMAT ?= dwarf-2 ...@@ -35,6 +35,7 @@ DEBUG_FORMAT ?= dwarf-2
DEBUG_LEVEL ?= 2 DEBUG_LEVEL ?= 2
LINKER_RELAXATIONS ?= Y LINKER_RELAXATIONS ?= Y
JUMP_TABLES ?= N JUMP_TABLES ?= N
LTO ?= N
# Sanity check user supplied values # Sanity check user supplied values
$(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
...@@ -49,6 +50,7 @@ $(call ERROR_IF_EMPTY, DEBUG_FORMAT) ...@@ -49,6 +50,7 @@ $(call ERROR_IF_EMPTY, DEBUG_FORMAT)
$(call ERROR_IF_EMPTY, DEBUG_LEVEL) $(call ERROR_IF_EMPTY, DEBUG_LEVEL)
$(call ERROR_IF_NONBOOL, LINKER_RELAXATIONS) $(call ERROR_IF_NONBOOL, LINKER_RELAXATIONS)
$(call ERROR_IF_NONBOOL, JUMP_TABLES) $(call ERROR_IF_NONBOOL, JUMP_TABLES)
$(call ERROR_IF_NONBOOL, LTO)
# 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)
...@@ -108,7 +110,8 @@ DEPENDENCY_FILES := $(OBJECT_FILES:%.o=%.d) ...@@ -108,7 +110,8 @@ DEPENDENCY_FILES := $(OBJECT_FILES:%.o=%.d)
# Create a list of common flags to pass to the compiler/linker/assembler # Create a list of common flags to pass to the compiler/linker/assembler
BASE_CC_FLAGS := -pipe -g$(DEBUG_FORMAT) -g$(DEBUG_LEVEL) BASE_CC_FLAGS := -pipe -g$(DEBUG_FORMAT) -g$(DEBUG_LEVEL)
ifneq ($(findstring $(ARCH), AVR8 XMEGA),) 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),) else ifneq ($(findstring $(ARCH), UC3),)
BASE_CC_FLAGS += -mpart=$(MCU:at32%=%) -masm-addr-pseudos BASE_CC_FLAGS += -mpart=$(MCU:at32%=%) -masm-addr-pseudos
endif endif
...@@ -128,10 +131,15 @@ ifeq ($(JUMP_TABLES), N) ...@@ -128,10 +131,15 @@ ifeq ($(JUMP_TABLES), N)
# in a pseudo-random jump target. # in a pseudo-random jump target.
BASE_CC_FLAGS += -fno-jump-tables BASE_CC_FLAGS += -fno-jump-tables
endif 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 # Additional language specific compiler flags
BASE_C_FLAGS := -x c -O$(OPTIMIZATION) -std=$(C_STANDARD) -Wstrict-prototypes 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 BASE_ASM_FLAGS := -x assembler-with-cpp
# Create a list of flags to pass to the linker # Create a list of flags to pass to the linker
...@@ -204,27 +212,27 @@ $(SRC): ...@@ -204,27 +212,27 @@ $(SRC):
# Compiles an input C source file and generates an assembly listing for it # Compiles an input C source file and generates an assembly listing for it
%.s: %.c $(MAKEFILE_LIST) %.s: %.c $(MAKEFILE_LIST)
@echo $(MSG_COMPILE_CMD) Generating assembly from C file \"$(notdir $<)\" @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 # Compiles an input C++ source file and generates an assembly listing for it
%.s: %.cpp $(MAKEFILE_LIST) %.s: %.cpp $(MAKEFILE_LIST)
@echo $(MSG_COMPILE_CMD) Generating assembly from C++ file \"$(notdir $<)\" @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 # Compiles an input C source file and generates a linkable object file for it
$(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) $($(notdir $<)_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@
# Compiles an input C++ source file and generates a linkable object file for it # Compiles an input C++ source file and generates a linkable object file for it
$(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) $($(notdir $<)_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@
# Assembles an input ASM source file and generates a linkable object file for it # Assembles an input ASM source file and generates a linkable object file for it
$(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) -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 # Generates a library archive file from the user application, which can be linked into other applications
.PRECIOUS : $(OBJECT_FILES) .PRECIOUS : $(OBJECT_FILES)
......
...@@ -13,11 +13,9 @@ DMBS_BUILD_OPTIONAL_VARS += ...@@ -13,11 +13,9 @@ DMBS_BUILD_OPTIONAL_VARS +=
DMBS_BUILD_PROVIDED_VARS += DMBS_BUILD_PROVIDED_VARS +=
DMBS_BUILD_PROVIDED_MACROS += 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)))) DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),) include $(DMBS_MODULE_PATH)/core.mk
include $(DMBS_MODULE_PATH)/core.mk
endif
# Sanity-check values of mandatory user-supplied variables # Sanity-check values of mandatory user-supplied variables
$(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
...@@ -29,6 +27,9 @@ MSG_HID_BOOTLOADER_CMD := ' [HID] :' ...@@ -29,6 +27,9 @@ MSG_HID_BOOTLOADER_CMD := ' [HID] :'
MSG_OBJCPY_CMD := ' [OBJCPY] :' MSG_OBJCPY_CMD := ' [OBJCPY] :'
MSG_MAKE_CMD := ' [MAKE] :' 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 # Programs in the target FLASH memory using the HID_BOOTLOADER_CLI tool
hid: $(TARGET).hex $(MAKEFILE_LIST) hid: $(TARGET).hex $(MAKEFILE_LIST)
@echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\" @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"
......
#
# 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
/*
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 <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
}
#endif
/*
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"
/*
DMBS Build System
Released into the public domain.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
// Include Guard
#pragma once
#include <stdint.h>
#include <stddef.h>
#include <avr/io.h>
...@@ -20,8 +20,12 @@ LD_FLAGS = ...@@ -20,8 +20,12 @@ LD_FLAGS =
# Default target