From 63eecaf6c614c98f57f47fe68e4edb1e801c4b2e Mon Sep 17 00:00:00 2001 From: Jake Carter Date: Mon, 27 Mar 2023 18:51:33 -0500 Subject: [PATCH] Update Makefiles to latest MSDKGen template --- MaximSDK/Inject/Makefile | 110 ++++++++++++++------------- MaximSDK/New_Project/Makefile | 128 +++++++++++++++++--------------- MaximSDK/New_Project/project.mk | 5 +- 3 files changed, 131 insertions(+), 112 deletions(-) diff --git a/MaximSDK/Inject/Makefile b/MaximSDK/Inject/Makefile index fb43f37..5f3c4de 100644 --- a/MaximSDK/Inject/Makefile +++ b/MaximSDK/Inject/Makefile @@ -1,35 +1,35 @@ -# /******************************************************************************* -# * Copyright (C) 2022 Maxim Integrated Products, Inc., All Rights Reserved. -# * -# * Permission is hereby granted, free of charge, to any person obtaining a -# * copy of this software and associated documentation files (the "Software"), -# * to deal in the Software without restriction, including without limitation -# * the rights to use, copy, modify, merge, publish, distribute, sublicense, -# * and/or sell copies of the Software, and to permit persons to whom the -# * Software is furnished to do so, subject to the following conditions: -# * -# * The above copyright notice and this permission notice shall be included -# * in all copies or substantial portions of the Software. -# * -# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES -# * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -# * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -# * OTHER DEALINGS IN THE SOFTWARE. -# * -# * Except as contained in this notice, the name of Maxim Integrated -# * Products, Inc. shall not be used except as stated in the Maxim Integrated -# * Products, Inc. Branding Policy. -# * -# * The mere transfer of this software does not imply any licenses -# * of trade secrets, proprietary technology, copyrights, patents, -# * trademarks, maskwork rights, or any other form of intellectual -# * property whatsoever. Maxim Integrated Products, Inc. retains all -# * ownership rights. -# ******************************************************************************* -# */ +################################################################################ + # Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved. + # + # Permission is hereby granted, free of charge, to any person obtaining a + # copy of this software and associated documentation files (the "Software"), + # to deal in the Software without restriction, including without limitation + # the rights to use, copy, modify, merge, publish, distribute, sublicense, + # and/or sell copies of the Software, and to permit persons to whom the + # Software is furnished to do so, subject to the following conditions: + # + # The above copyright notice and this permission notice shall be included + # in all copies or substantial portions of the Software. + # + # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + # IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + # OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + # OTHER DEALINGS IN THE SOFTWARE. + # + # Except as contained in this notice, the name of Maxim Integrated + # Products, Inc. shall not be used except as stated in the Maxim Integrated + # Products, Inc. Branding Policy. + # + # The mere transfer of this software does not imply any licenses + # of trade secrets, proprietary technology, copyrights, patents, + # trademarks, maskwork rights, or any other form of intellectual + # property whatsoever. Maxim Integrated Products, Inc. retains all + # ownership rights. + # +############################################################################### # ** Readme! ** # Don't edit this file! This is the core Makefile for a MaximSDK @@ -59,10 +59,7 @@ ifeq "$(TARGET)" "" -# Default target microcontroller -TARGET := ##__TARGET__## -TARGET_UC := ##__TARGET_UC__## -TARGET_LC := ##__TARGET_LC__## +$(error TARGET must be specified!) else # "TARGET" has been overridden in the environment or on the command-line. # We need to calculate an upper and lowercase version of the part number, @@ -71,8 +68,9 @@ TARGET_UC := $(subst m,M,$(subst a,A,$(subst x,X,$(TARGET)))) TARGET_LC := $(subst M,m,$(subst A,a,$(subst X,x,$(TARGET)))) endif -# Default board. -BOARD ?= ##__BOARD__## +ifeq "$(BOARD)" "" +$(error BOARD must be specified!) +endif # ******************************************************************************* # Locate the MaximSDK @@ -111,7 +109,7 @@ $(info Loaded project.mk) ifeq "$(MAXIM_PATH)" "" # MAXIM_PATH is still not defined... -DEPTH := ##__DEPTH__## +DEPTH := ../../../ MAXIM_PATH := $(abspath $(DEPTH)) $(warning Warning: MAXIM_PATH is not set! Set MAXIM_PATH in your environment or in project.mk to clear this warning.) $(warning Warning: Attempting to use $(MAXIM_PATH) calculated from relative path) @@ -166,14 +164,16 @@ export CMSIS_ROOT # Where to find source files for this project. -##__VPATHS__## +VPATH += . +VPATH += src VPATH := $(VPATH) # Where to find header files for this project -##__IPATHS__## +IPATH += . +IPATH += include IPATH := $(IPATH) -AUTOSEARCH ?= ##__AUTOSEARCH__## +AUTOSEARCH ?= 1 ifeq ($(AUTOSEARCH), 1) # Auto-detect all C source files on VPATH SRCS += $(wildcard $(addsuffix /*.c, $(VPATH))) @@ -215,13 +215,13 @@ PROJECT ?= $(TARGET_LC) # Select 'GCC' or 'IAR' compiler ifeq "$(COMPILER)" "" -COMPILER := ##__COMPILER__## +COMPILER := GCC endif # Set default compiler optimization levels ifeq "$(MAKECMDGOALS)" "release" # Default optimization level for "release" builds (make release) -MXC_OPTIMIZE_CFLAGS ?= -O##__OLEVEL_RELEASE__## +MXC_OPTIMIZE_CFLAGS ?= -O2 DEBUG = 0 endif @@ -229,22 +229,22 @@ ifeq ($(DEBUG),1) # Optimizes for debugging as recommended # by GNU for code-edit-debug cycles # https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options -MXC_OPTIMIZE_CFLAGS := -O##__OLEVEL_DEBUG__## +MXC_OPTIMIZE_CFLAGS := -Og endif # Default level if not building for release or explicitly for debug -MXC_OPTIMIZE_CFLAGS ?= -O##__OLEVEL_DEFAULT__## +MXC_OPTIMIZE_CFLAGS ?= -O2 # Set compiler flags PROJ_CFLAGS += -Wall # Enable warnings -##__DEFINES__## +PROJ_CFLAGS += -DMXC_ASSERT_ENABLE # Set hardware floating point acceleration. # Options are: # - hard # - soft # - softfp (default if MFLOAT_ABI is not set) -MFLOAT_ABI ?= ##__FLOAT_ABI__## +MFLOAT_ABI ?= softfp # MFLOAT_ABI must be exported to other Makefiles export MFLOAT_ABI @@ -288,7 +288,7 @@ VPATH += $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source # However, if there are multiple secure part #s for the target # microcontroller this variable may need to be changed. -SBT ?= ##__SBT__## +SBT ?= 0 ifeq ($(SBT), 1) MAXIM_SBT_DIR ?= $(MAXIM_PATH)/Tools/SBT MAXIM_SBT_DIR := $(subst \,/,$(MAXIM_SBT_DIR)) @@ -316,7 +316,7 @@ ifeq "$(.DEFAULT_GOAL)" "" ifeq ($(SBT),1) override .DEFAULT_GOAL := sla else -override .DEFAULT_GOAL := ##__DEFAULT_GOAL__## +override .DEFAULT_GOAL := all endif endif @@ -329,6 +329,16 @@ ifeq "$(MAKECMDGOALS)" "" MAKECMDGOALS:=$(.DEFAULT_GOAL) endif +# Enable colors when --sync-output is used. +# See https://www.gnu.org/software/make/manual/make.html#Terminal-Output (section 13.2) +ifneq ($(MAKE_TERMOUT),) +PROJ_CFLAGS += -fdiagnostics-color=always +endif + +ifneq ($(FORCE_COLOR),) +PROJ_CFLAGS += -fdiagnostics-color=always +endif + # ******************************************************************************* # Include SBT config. We need to do this here because it needs to know # the current MAKECMDGOAL. diff --git a/MaximSDK/New_Project/Makefile b/MaximSDK/New_Project/Makefile index f16fc0e..5f3c4de 100644 --- a/MaximSDK/New_Project/Makefile +++ b/MaximSDK/New_Project/Makefile @@ -1,35 +1,35 @@ -# /******************************************************************************* -# * Copyright (C) 2022 Maxim Integrated Products, Inc., All Rights Reserved. -# * -# * Permission is hereby granted, free of charge, to any person obtaining a -# * copy of this software and associated documentation files (the "Software"), -# * to deal in the Software without restriction, including without limitation -# * the rights to use, copy, modify, merge, publish, distribute, sublicense, -# * and/or sell copies of the Software, and to permit persons to whom the -# * Software is furnished to do so, subject to the following conditions: -# * -# * The above copyright notice and this permission notice shall be included -# * in all copies or substantial portions of the Software. -# * -# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES -# * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -# * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -# * OTHER DEALINGS IN THE SOFTWARE. -# * -# * Except as contained in this notice, the name of Maxim Integrated -# * Products, Inc. shall not be used except as stated in the Maxim Integrated -# * Products, Inc. Branding Policy. -# * -# * The mere transfer of this software does not imply any licenses -# * of trade secrets, proprietary technology, copyrights, patents, -# * trademarks, maskwork rights, or any other form of intellectual -# * property whatsoever. Maxim Integrated Products, Inc. retains all -# * ownership rights. -# ******************************************************************************* -# */ +################################################################################ + # Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved. + # + # Permission is hereby granted, free of charge, to any person obtaining a + # copy of this software and associated documentation files (the "Software"), + # to deal in the Software without restriction, including without limitation + # the rights to use, copy, modify, merge, publish, distribute, sublicense, + # and/or sell copies of the Software, and to permit persons to whom the + # Software is furnished to do so, subject to the following conditions: + # + # The above copyright notice and this permission notice shall be included + # in all copies or substantial portions of the Software. + # + # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + # IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + # OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + # OTHER DEALINGS IN THE SOFTWARE. + # + # Except as contained in this notice, the name of Maxim Integrated + # Products, Inc. shall not be used except as stated in the Maxim Integrated + # Products, Inc. Branding Policy. + # + # The mere transfer of this software does not imply any licenses + # of trade secrets, proprietary technology, copyrights, patents, + # trademarks, maskwork rights, or any other form of intellectual + # property whatsoever. Maxim Integrated Products, Inc. retains all + # ownership rights. + # +############################################################################### # ** Readme! ** # Don't edit this file! This is the core Makefile for a MaximSDK @@ -37,7 +37,7 @@ # in "project.mk", on the command-line, or with system environment # variables. -# See https://github.com/Analog-Devices-MSDK/VSCode-Maxim/tree/develop#build-configuration +# See https://analog-devices-msdk.github.io/msdk/USERGUIDE/#build-system # for more detailed instructions on how to use this system. # The detailed instructions mentioned above are easier to read than @@ -59,10 +59,7 @@ ifeq "$(TARGET)" "" -# Default target microcontroller -TARGET := MAX78000 -TARGET_UC := MAX78000 -TARGET_LC := max78000 +$(error TARGET must be specified!) else # "TARGET" has been overridden in the environment or on the command-line. # We need to calculate an upper and lowercase version of the part number, @@ -71,8 +68,9 @@ TARGET_UC := $(subst m,M,$(subst a,A,$(subst x,X,$(TARGET)))) TARGET_LC := $(subst M,m,$(subst A,a,$(subst X,x,$(TARGET)))) endif -# Default board. -BOARD ?= EvKit_V1 +ifeq "$(BOARD)" "" +$(error BOARD must be specified!) +endif # ******************************************************************************* # Locate the MaximSDK @@ -198,6 +196,8 @@ PROJECT ?= $(TARGET_LC) # Compiler options # Configuration Variables: +# - DEBUG : Set DEBUG=1 to build explicitly for debugging. This adds some additional +# symbols and sets -Og as the default optimization level. # - MXC_OPTIMIZE_CFLAGS : Override the default compiler optimization level. # Ex: MXC_OPTIMIZE_CFLAGS = -O2 # - PROJ_CFLAGS : Add additional compiler flags to the build. @@ -208,7 +208,10 @@ PROJECT ?= $(TARGET_LC) # Ex: MFLOAT_ABI = hard # - LINKERFILE : Override the default linkerfile. # Ex: LINKERFILE = customlinkerfile.ld - +# - LINKERPATH : Override the default search location for $(LINKERFILE) +# The default search location is $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/GCC +# If $(LINKERFILE) cannot be found at this path, then the root project +# directory will be used as a fallback. # Select 'GCC' or 'IAR' compiler ifeq "$(COMPILER)" "" @@ -223,17 +226,14 @@ DEBUG = 0 endif ifeq ($(DEBUG),1) -# Default optimization level for debug builds (make DEBUG=1 ...) -# gcc.mk checks for this flag to add some additional debug -# info to the build, and should be used when you really need to -# debug. +# Optimizes for debugging as recommended +# by GNU for code-edit-debug cycles +# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options MXC_OPTIMIZE_CFLAGS := -Og endif -# Fallback default optimizes for debugging as recommended -# by GNU for code-edit-debug cycles -# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options -MXC_OPTIMIZE_CFLAGS ?= -Og +# Default level if not building for release or explicitly for debug +MXC_OPTIMIZE_CFLAGS ?= -O2 # Set compiler flags PROJ_CFLAGS += -Wall # Enable warnings @@ -245,21 +245,23 @@ PROJ_CFLAGS += -DMXC_ASSERT_ENABLE # - soft # - softfp (default if MFLOAT_ABI is not set) MFLOAT_ABI ?= softfp -# MFLOAT_ABI must be exported to other Makefiles, who check this too +# MFLOAT_ABI must be exported to other Makefiles export MFLOAT_ABI -# Set the default linkerfile. Since the core Makefiles later add the location of Maxim's -# linkerfiles to VPATH, and the local project directory has also been added to VPATH, Make -# will search both locations for the specified linkerfile if it can't find it by its path alone. -# The result is that overriding LINKERFILE with the filename of one of Maxim's alternate linkerfiles -# (ex: LINKERFILE=max78000_arm.ld) will work just the same as LINKERFILE=mycustom.ld -# even if mycustom.ld lives locally to this project. - ifeq "$(RISCV_CORE)" "" # Default linkerfile is only specified for standard Arm-core projects. # Otherwise, gcc_riscv.mk sets the appropriate riscv linkerfile. -LINKER = $(TARGET_LC).ld -LINKERFILE ?= $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/GCC/$(LINKER) +LINKERFILE ?= $(TARGET_LC).ld +LINKERPATH ?= $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/GCC + +# Check if linkerfile exists +ifeq ("$(wildcard $(LINKERPATH)/$(LINKERFILE))","") +# Doesn't exists, attempt to use root project folder. +LINKERPATH:=. +endif + +# Form full path to linkerfile. Works around MSYS2 edge case from (see MSDK-903). +LINKERFILE:=$(LINKERPATH)/$(LINKERFILE) endif # This path contains system-level intialization files for the target micro. Add to the build. @@ -327,6 +329,16 @@ ifeq "$(MAKECMDGOALS)" "" MAKECMDGOALS:=$(.DEFAULT_GOAL) endif +# Enable colors when --sync-output is used. +# See https://www.gnu.org/software/make/manual/make.html#Terminal-Output (section 13.2) +ifneq ($(MAKE_TERMOUT),) +PROJ_CFLAGS += -fdiagnostics-color=always +endif + +ifneq ($(FORCE_COLOR),) +PROJ_CFLAGS += -fdiagnostics-color=always +endif + # ******************************************************************************* # Include SBT config. We need to do this here because it needs to know # the current MAKECMDGOAL. diff --git a/MaximSDK/New_Project/project.mk b/MaximSDK/New_Project/project.mk index 250f70c..f068448 100644 --- a/MaximSDK/New_Project/project.mk +++ b/MaximSDK/New_Project/project.mk @@ -3,11 +3,8 @@ # "Makefile" that is located next to this one. # For instructions on how to use this system, see -# https://github.com/Analog-Devices-MSDK/VSCode-Maxim/tree/develop#build-configuration +# https://analog-devices-msdk.github.io/msdk/USERGUIDE/#build-system # ********************************************************** # Add your config here! - - -