Skip to content

Commit

Permalink
Update Makefiles to latest MSDKGen template
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Carter committed Mar 27, 2023
1 parent 7f68625 commit 63eecaf
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 112 deletions.
110 changes: 60 additions & 50 deletions MaximSDK/Inject/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -215,36 +215,36 @@ 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

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

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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

Expand All @@ -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.
Expand Down
128 changes: 70 additions & 58 deletions MaximSDK/New_Project/Makefile
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
# /*******************************************************************************
# * 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
# project. The available configuration options can be overridden
# 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
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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)" ""
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 63eecaf

Please sign in to comment.