Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 1 | ################################################################################ |
| 2 | # \file toolchains.mk |
| 3 | # \version 1.0 |
| 4 | # |
| 5 | # \brief |
| 6 | # Makefile to describe supported toolchains for Cypress MCUBoot based applications. |
| 7 | # |
| 8 | ################################################################################ |
| 9 | # \copyright |
| 10 | # Copyright 2018-2019 Cypress Semiconductor Corporation |
| 11 | # SPDX-License-Identifier: Apache-2.0 |
| 12 | # |
| 13 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 14 | # you may not use this file except in compliance with the License. |
| 15 | # You may obtain a copy of the License at |
| 16 | # |
| 17 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 18 | # |
| 19 | # Unless required by applicable law or agreed to in writing, software |
| 20 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 21 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 22 | # See the License for the specific language governing permissions and |
| 23 | # limitations under the License. |
| 24 | ################################################################################ |
| 25 | |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 26 | include common_libs.mk |
| 27 | |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 28 | # Compilers |
| 29 | GCC_ARM := 1 |
| 30 | IAR := 2 |
| 31 | ARM := 3 |
| 32 | OTHER := 4 |
| 33 | |
| 34 | ifeq ($(MAKEINFO), 1) |
| 35 | $(info $(COMPILER)) |
| 36 | endif |
| 37 | # Detect host OS to make resolving compiler pathes easier |
| 38 | UNAME_S := $(shell uname -s) |
| 39 | ifeq ($(UNAME_S), Darwin) |
| 40 | HOST_OS = osx |
| 41 | else |
| 42 | ifeq ($(UNAME_S), Linux) |
| 43 | HOST_OS = linux |
| 44 | else |
| 45 | HOST_OS = win |
| 46 | endif |
| 47 | endif |
| 48 | |
| 49 | # Path to the compiler installation |
| 50 | # NOTE: Absolute pathes for now for the sake of development |
| 51 | ifeq ($(HOST_OS), win) |
| 52 | ifeq ($(COMPILER), GCC_ARM) |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 53 | TOOLCHAIN_PATH ?= c:/Users/$(USERNAME)/ModusToolbox/tools_2.2/gcc |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 54 | MY_TOOLCHAIN_PATH:=$(subst \,/,$(TOOLCHAIN_PATH)) |
| 55 | TOOLCHAIN_PATH := $(MY_TOOLCHAIN_PATH) |
| 56 | GCC_PATH := $(TOOLCHAIN_PATH) |
| 57 | # executables |
| 58 | CC := "$(GCC_PATH)/bin/arm-none-eabi-gcc" |
| 59 | LD := $(CC) |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 60 | endif |
| 61 | |
| 62 | else ifeq ($(HOST_OS), osx) |
| 63 | TOOLCHAIN_PATH ?= /opt/gcc-arm-none-eabi |
| 64 | GCC_PATH := $(TOOLCHAIN_PATH) |
| 65 | |
| 66 | CC := "$(GCC_PATH)/bin/arm-none-eabi-gcc" |
| 67 | LD := $(CC) |
| 68 | |
| 69 | else ifeq ($(HOST_OS), linux) |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 70 | TOOLCHAIN_PATH ?= /opt/gcc-arm-none-eabi |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 71 | GCC_PATH := $(TOOLCHAIN_PATH) |
| 72 | # executables |
| 73 | CC := "$(GCC_PATH)/bin/arm-none-eabi-gcc" |
| 74 | LD := $(CC) |
| 75 | endif |
| 76 | |
| 77 | PDL_ELFTOOL := "hal/tools/$(HOST_OS)/elf/cymcuelftool" |
| 78 | |
| 79 | OBJDUMP := "$(GCC_PATH)/bin/arm-none-eabi-objdump" |
| 80 | OBJCOPY := "$(GCC_PATH)/bin/arm-none-eabi-objcopy" |
| 81 | |
| 82 | # Set flags for toolchain executables |
| 83 | ifeq ($(COMPILER), GCC_ARM) |
| 84 | # set build-in compiler flags |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 85 | CFLAGS_COMMON := -mcpu=cortex-$(CORE_SIFFX) -mthumb -mfloat-abi=soft -fno-stack-protector -ffunction-sections -fdata-sections -ffat-lto-objects -fstrict-aliasing -g -Wall -Wextra |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 86 | ifeq ($(BUILDCFG), Debug) |
| 87 | CFLAGS_COMMON += -Og -g3 |
| 88 | else ifeq ($(BUILDCFG), Release) |
| 89 | CFLAGS_COMMON += -Os -g |
| 90 | else |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 91 | $(error BUILDCFG : '$(BUILDCFG)' is not supported) |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 92 | endif |
| 93 | # add defines and includes |
| 94 | CFLAGS := $(CFLAGS_COMMON) $(INCLUDES) |
| 95 | CC_DEPEND = -MD -MP -MF |
| 96 | |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 97 | LDFLAGS_COMMON := -mcpu=cortex-$(CORE_SIFFX) -mthumb -specs=nano.specs -ffunction-sections -fdata-sections -Wl,--gc-sections -L "$(GCC_PATH)/lib/gcc/arm-none-eabi/7.2.1/thumb/v6-m" -ffat-lto-objects -g --enable-objc-gc |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 98 | ifeq ($(BUILDCFG), Debug) |
| 99 | LDFLAGS_COMMON += -Og |
| 100 | else ifeq ($(BUILDCFG), Release) |
| 101 | LDFLAGS_COMMON += -Os |
| 102 | else |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 103 | $(error BUILDCFG : '$(BUILDCFG)' is not supported) |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 104 | endif |
| 105 | LDFLAGS_NANO := -L "$(GCC_PATH)/arm-none-eabi/lib/thumb/v6-m" |
| 106 | LDFLAGS := $(LDFLAGS_COMMON) $(LDFLAGS_NANO) |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 107 | endif |