1- # /*******************************************************************************
2- # * Copyright (C) 2022 Maxim Integrated Products, Inc., All Rights Reserved.
3- # *
4- # * Permission is hereby granted, free of charge, to any person obtaining a
5- # * copy of this software and associated documentation files (the "Software"),
6- # * to deal in the Software without restriction, including without limitation
7- # * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8- # * and/or sell copies of the Software, and to permit persons to whom the
9- # * Software is furnished to do so, subject to the following conditions:
10- # *
11- # * The above copyright notice and this permission notice shall be included
12- # * in all copies or substantial portions of the Software.
13- # *
14- # * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15- # * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16- # * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17- # * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
18- # * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19- # * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20- # * OTHER DEALINGS IN THE SOFTWARE.
21- # *
22- # * Except as contained in this notice, the name of Maxim Integrated
23- # * Products, Inc. shall not be used except as stated in the Maxim Integrated
24- # * Products, Inc. Branding Policy.
25- # *
26- # * The mere transfer of this software does not imply any licenses
27- # * of trade secrets, proprietary technology, copyrights, patents,
28- # * trademarks, maskwork rights, or any other form of intellectual
29- # * property whatsoever. Maxim Integrated Products, Inc. retains all
30- # * ownership rights.
31- # *******************************************************************************
32- # */
1+ # ###############################################################################
2+ # Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved.
3+ #
4+ # Permission is hereby granted, free of charge, to any person obtaining a
5+ # copy of this software and associated documentation files (the "Software"),
6+ # to deal in the Software without restriction, including without limitation
7+ # the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+ # and/or sell copies of the Software, and to permit persons to whom the
9+ # Software is furnished to do so, subject to the following conditions:
10+ #
11+ # The above copyright notice and this permission notice shall be included
12+ # in all copies or substantial portions of the Software.
13+ #
14+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17+ # IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
18+ # OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+ # OTHER DEALINGS IN THE SOFTWARE.
21+ #
22+ # Except as contained in this notice, the name of Maxim Integrated
23+ # Products, Inc. shall not be used except as stated in the Maxim Integrated
24+ # Products, Inc. Branding Policy.
25+ #
26+ # The mere transfer of this software does not imply any licenses
27+ # of trade secrets, proprietary technology, copyrights, patents,
28+ # trademarks, maskwork rights, or any other form of intellectual
29+ # property whatsoever. Maxim Integrated Products, Inc. retains all
30+ # ownership rights.
31+ #
32+ # ##############################################################################
3333
3434# ** Readme! **
3535# Don't edit this file! This is the core Makefile for a MaximSDK
3636# project. The available configuration options can be overridden
3737# in "project.mk", on the command-line, or with system environment
3838# variables.
3939
40- # See https://github.com/Analog-Devices-MSDK/VSCode-Maxim/tree/develop #build-configuration
40+ # See https://analog-devices-msdk. github.io/msdk/USERGUIDE/ #build-system
4141# for more detailed instructions on how to use this system.
4242
4343# The detailed instructions mentioned above are easier to read than
5959
6060
6161ifeq "$(TARGET ) " ""
62- # Default target microcontroller
63- TARGET := MAX78000
64- TARGET_UC := MAX78000
65- TARGET_LC := max78000
62+ $(error TARGET must be specified!)
6663else
6764# "TARGET" has been overridden in the environment or on the command-line.
6865# 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))))
7168TARGET_LC := $(subst M,m,$(subst A,a,$(subst X,x,$(TARGET ) ) ) )
7269endif
7370
74- # Default board.
75- BOARD ?= EvKit_V1
71+ ifeq "$(BOARD ) " ""
72+ $(error BOARD must be specified!)
73+ endif
7674
7775# *******************************************************************************
7876# Locate the MaximSDK
@@ -198,6 +196,8 @@ PROJECT ?= $(TARGET_LC)
198196# Compiler options
199197
200198# Configuration Variables:
199+ # - DEBUG : Set DEBUG=1 to build explicitly for debugging. This adds some additional
200+ # symbols and sets -Og as the default optimization level.
201201# - MXC_OPTIMIZE_CFLAGS : Override the default compiler optimization level.
202202# Ex: MXC_OPTIMIZE_CFLAGS = -O2
203203# - PROJ_CFLAGS : Add additional compiler flags to the build.
@@ -208,7 +208,10 @@ PROJECT ?= $(TARGET_LC)
208208# Ex: MFLOAT_ABI = hard
209209# - LINKERFILE : Override the default linkerfile.
210210# Ex: LINKERFILE = customlinkerfile.ld
211-
211+ # - LINKERPATH : Override the default search location for $(LINKERFILE)
212+ # The default search location is $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/GCC
213+ # If $(LINKERFILE) cannot be found at this path, then the root project
214+ # directory will be used as a fallback.
212215
213216# Select 'GCC' or 'IAR' compiler
214217ifeq "$(COMPILER ) " ""
@@ -223,17 +226,14 @@ DEBUG = 0
223226endif
224227
225228ifeq ($(DEBUG ) ,1)
226- # Default optimization level for debug builds (make DEBUG=1 ...)
227- # gcc.mk checks for this flag to add some additional debug
228- # info to the build, and should be used when you really need to
229- # debug.
229+ # Optimizes for debugging as recommended
230+ # by GNU for code-edit-debug cycles
231+ # https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options
230232MXC_OPTIMIZE_CFLAGS := -Og
231233endif
232234
233- # Fallback default optimizes for debugging as recommended
234- # by GNU for code-edit-debug cycles
235- # https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options
236- MXC_OPTIMIZE_CFLAGS ?= -Og
235+ # Default level if not building for release or explicitly for debug
236+ MXC_OPTIMIZE_CFLAGS ?= -O2
237237
238238# Set compiler flags
239239PROJ_CFLAGS += -Wall # Enable warnings
@@ -245,21 +245,23 @@ PROJ_CFLAGS += -DMXC_ASSERT_ENABLE
245245# - soft
246246# - softfp (default if MFLOAT_ABI is not set)
247247MFLOAT_ABI ?= softfp
248- # MFLOAT_ABI must be exported to other Makefiles, who check this too
248+ # MFLOAT_ABI must be exported to other Makefiles
249249export MFLOAT_ABI
250250
251- # Set the default linkerfile. Since the core Makefiles later add the location of Maxim's
252- # linkerfiles to VPATH, and the local project directory has also been added to VPATH, Make
253- # will search both locations for the specified linkerfile if it can't find it by its path alone.
254- # The result is that overriding LINKERFILE with the filename of one of Maxim's alternate linkerfiles
255- # (ex: LINKERFILE=max78000_arm.ld) will work just the same as LINKERFILE=mycustom.ld
256- # even if mycustom.ld lives locally to this project.
257-
258251ifeq "$(RISCV_CORE ) " ""
259252# Default linkerfile is only specified for standard Arm-core projects.
260253# Otherwise, gcc_riscv.mk sets the appropriate riscv linkerfile.
261- LINKER = $(TARGET_LC ) .ld
262- LINKERFILE ?= $(CMSIS_ROOT ) /Device/Maxim/$(TARGET_UC ) /Source/GCC/$(LINKER )
254+ LINKERFILE ?= $(TARGET_LC ) .ld
255+ LINKERPATH ?= $(CMSIS_ROOT ) /Device/Maxim/$(TARGET_UC ) /Source/GCC
256+
257+ # Check if linkerfile exists
258+ ifeq ("$(wildcard $(LINKERPATH ) /$(LINKERFILE ) ) ","")
259+ # Doesn't exists, attempt to use root project folder.
260+ LINKERPATH: =.
261+ endif
262+
263+ # Form full path to linkerfile. Works around MSYS2 edge case from (see MSDK-903).
264+ LINKERFILE: =$(LINKERPATH ) /$(LINKERFILE )
263265endif
264266
265267# This path contains system-level intialization files for the target micro. Add to the build.
@@ -327,6 +329,16 @@ ifeq "$(MAKECMDGOALS)" ""
327329MAKECMDGOALS: =$(.DEFAULT_GOAL )
328330endif
329331
332+ # Enable colors when --sync-output is used.
333+ # See https://www.gnu.org/software/make/manual/make.html#Terminal-Output (section 13.2)
334+ ifneq ($(MAKE_TERMOUT ) ,)
335+ PROJ_CFLAGS += -fdiagnostics-color=always
336+ endif
337+
338+ ifneq ($(FORCE_COLOR ) ,)
339+ PROJ_CFLAGS += -fdiagnostics-color=always
340+ endif
341+
330342# *******************************************************************************
331343# Include SBT config. We need to do this here because it needs to know
332344# the current MAKECMDGOAL.
0 commit comments