########################################################################################################################
# File Name  : Makefile
# Description: Local main project Makefile
# Project    : Vector Basic Runtime System
# Module     : BrsHw for platform ArmCommon
#              and Compiler LlvmTexasInstruments,
#              using Vector PES MakeSupport 4.1
# Template   : This Makefile is reviewed according to Brs_Template@MakeSupport[1.02.01]
#
#-----------------------------------------------------------------------------------------------------------------------
# COPYRIGHT
#-----------------------------------------------------------------------------------------------------------------------
# Copyright (c) 2025 by Vector Informatik GmbH.                                                  All rights reserved.
#
#-----------------------------------------------------------------------------------------------------------------------
# REVISION HISTORY
#-----------------------------------------------------------------------------------------------------------------------
# Version   Date        Author  Change Id      Description
# ----------------------------------------------------------------------------------------------------------------------
# 01.00.00  2021-09-29  vishci                 Initial creation
# 01.00.01  2021-12-17  visbwa                 Update to Brs_Template 1.01.01, changed default compiler path to fit with chocolatey,
#                                              removed unused code fragments, switched assembler binary to proper tiarmclang and
#                                              adapted the default assembler options, fixed version options
# 01.00.02  2022-01-24  visbwa                 Added -march attribute value for Cortex-M3/M4
# 01.00.03  2022-03-24  vismaa                 Removed Xlinker --scan_libraries
# 01.00.04  2022-05-16  visrgm                 Added CPU Switch for Cortex-M4F
# 01.01.00  2022-07-25  visbwa                 Changed linker option -e from brsStartupEntry to intvect_CoreExceptions, as this
#                                              proper entry is always available since Brs_Template 1.03 and references brsStartupEntry
# 01.01.01  2022-07-26  visjhr                 Added EXCEPTION_TABLE_LDFLAGS
# 01.01.02  2022-07-27  visjhr                 Fixed EXCEPTION_TABLE_LDFLAGS
# 01.01.03  2022-08-09  visjhr                 Added ADDITIONAL_INCLUDES += LlvmTi
# 01.01.04  2022-08-10  visjhr                 Removed all ADDITIONAL_INCLUDES
# 01.01.05  2022-09-05  visdri                 Add ADDITIONAL_CFLAGS_FROM_VBRS to CFLAGS_VECTOR_OPTIONS
# 01.01.06  2022-09-23  visjhr                 Added usage of BRS_FIRST_EXECUTION_INSTANCE for selection of entry/startup label
# 01.01.07  2023-01-11  visqli                 Moved PROJECT_NAME to Makefile.static and included Makefile.static forwards,
#                                              enabled generation of PROJECT_NAME and LINKER_COMMAND_FILE
# 01.01.08  2023-03-13  vishci                 Added -mcpu and -march value for Cortex-M0/M0plus
# 01.01.09  2023-03-14  visjhr                 Use BRS_CPU_CORE_x_USED variables to prevent optimization of exception tables
#                                              (HALBE-8500 Generate additional core specific variables in Makefile.config.generated)
# 01.01.10  2023-03-15  vishci                 Added core specific mfloat-abi option
# 01.01.11  2023-03-20  visbwa                 Added --memwidth=8 to HexFlags, after user feedback
# 01.01.12  2023-07-06  visdri                 Compile ARMBrsHwIntTb_CortexR.c / ARMStartup_CortexR.c in ARM state even when
#                                              Thumb state is configured for the project
# 01.01.13  2023-07-14  visbwa                 Added keep for FBL exception table in RAM (intvect_CoreExceptions_Ram)
# 01.01.14  2023-11-16  visbwa                 LDFLAG -u=intvect_CoreExceptions_Ram only for FBL UseCase
# 01.01.15  2024-03-05  virrlu                 Changed ARFLAGS to -r after user feedback
# 01.01.16  2024-03-28  vishci  BASEENV-11520  Added forced ARM state to compiling ARMBrsHwIntTb_CortexR.c / ARMStartup_CortexR.c to
#                                              all CORTEX_R based cores, Brs_Template 1.01.05 (Change Id)
# 01.01.17  2024-06-24  kal     BASEENV-12084  Added comment clarifying default C language standard (GNU11)
# 01.02.00  2024-08-01  vishci  BASEENV-12178  Unify naming of intvect_CoreExceptions_Ram_Vectortable for FBL usecase and added keep flag
# 01.02.01  2024-08-27  vishci                 Bugfix for intvect_CoreExceptions_Ram_Vectortable flag in Cortex M Cores
# 01.03.00  2025-06-12  visbwa  BASEENV-13804  Replaced include of Makefile.config.generated and Makefile.project.part.defines in Makefile.static
#                                              by new Makefile.wrapper; added usage of new parameter TEMPDATA_DIR for LINKER_COMMAND_FILE;
#                                              review to Brs_Template 1.02.00; fixed LNK_SUFFIX
# 01.03.01  2025-07-31  visbwa  TAR-93253      Added LDFLAGS_RESPONSE_FILE value in Makefile.static
# 01.03.02  2025-07-31  visbwa  TAR-93253      Introduced RESPONSE_FILE_MULTILINE in Makefile.static and set to '1';
#                                              feature was introduced with zBrs_MakeSupport@Implementation[4.01.65]
# 01.04.00  2025-09-02  kal     BASEENV-14399  Added support for Cortex-R52 (TI Arm Clang Compiler Tools >= 4.03.00 LTS)
# 01.04.01  2025-10-16  visbwa                 Set 4.0.3.LTS as default compiler for Cortex-R52
########################################################################################################################

########################################################################################################################
# EXAMPLE CODE ONLY
#-----------------------------------------------------------------------------------------------------------------------
# This Example Code is only intended for illustrating an example of a possible BSW integration and BSW configuration.
# The Example Code has not passed any quality control measures and may be incomplete. The Example Code is neither
# intended nor qualified for use in series production. The Example Code as well as any of its modifications and/or
# implementations must be tested with diligent care and must comply with all quality requirements which are necessary
# according to the state of the art before their use.
########################################################################################################################

#------------------------------------------------------------------------------
# Static settings placed inside separate file
#------------------------------------------------------------------------------
include Makefile.static

#------------------------------------------------------------------------------
# Name of linker file
#
# If BRS_LINKER_COMMAND_FILE_POSTFIX (derived from referenced vLinGen variant
# vBRS/vBRSGeneral/vBRSVariantUsageOfvLinkGen) was generated into
# Makefile.config.generated (by vBRS Cfg5 generator), use that file.
#------------------------------------------------------------------------------
ifeq ($(BRS_LINKER_COMMAND_FILE_POSTFIX),)
LINKER_COMMAND_FILE = $(TEMPDATA_DIR)/vLinkGen_Template.$(LNK_SUFFIX)
else
LINKER_COMMAND_FILE = $(TEMPDATA_DIR)/vLinkGen_Template_$(BRS_LINKER_COMMAND_FILE_POSTFIX).$(LNK_SUFFIX)
endif

#------------------------------------------------------------------------------
# Define Compiler path, e.g.
#   COMPILER_BASE_WIN = D:\uti\%vendor%\%platform%\%version% (\ can be used)
#   COMPILER_BASE    := $(subst \,/,$(COMPILER_BASE_WIN)) (\ is converted to /)
#   COMPILER_BIN      = $(COMPILER_BASE)/bin
#   COMPILER_INC      = $(COMPILER_BASE)/inc
#   COMPILER_LIB      = $(COMPILER_BASE)/lib
#
# If BRS_COMPILER_PATH (vBRS/vBRSHwConfig/vBRSCompilerPath) was generated into
# Makefile.config.generated (by vBRS Cfg5 generator), use that path.
#------------------------------------------------------------------------------
ifeq ($(BRS_COMPILER_PATH),)
 ifeq ($(CPU_CORE),CORTEX_R52)
  #TI Arm Clang Compiler Tools 4.0.3 LTS now offers basic support for R52
  COMPILER_BASE_WIN = D:\uti\TI\LLVMARM\ccs\tools\compiler\ti-cgt-armllvm_4.0.3.LTS
 else
  COMPILER_BASE_WIN = D:\uti\TI\LLVMARM\ccs\tools\compiler\ti-cgt-armllvm_1.3.0.LTS
 endif
else
COMPILER_BASE_WIN = $(BRS_COMPILER_PATH)
endif
COMPILER_BASE    := $(subst \,/,$(COMPILER_BASE_WIN))
COMPILER_BIN      = $(COMPILER_BASE)/bin
COMPILER_INC      = $(COMPILER_BASE)/include
COMPILER_LIB      = $(COMPILER_BASE)/lib

#------------------------------------------------------------------------------
# Build Options Selection: VECTOR / CUSTOMER
#------------------------------------------------------------------------------
ASFLAGS_SELECTOR  = VECTOR
CFLAGS_SELECTOR   = VECTOR
LDFLAGS_SELECTOR  = VECTOR

#------------------------------------------------------------------------------
# Define Emulator path
# E.g.: EMU_PATH = C:/UTI/HITOPWIN/P6811
#
# This parameter is not mandatory. It is used for some platforms, to provide
# e.g. debug connect scripts (e.g. multi within RH850).
#------------------------------------------------------------------------------
EMU_PATH =

#------------------------------------------------------------------------------
# Set $(NANT_USED) to '1', to enable the usage of NAnt support within
# Global Makefile. If this is enabled, the MakeSupport will include the
# NAnt support from an internal link and the NAnt build targets can be used.
#------------------------------------------------------------------------------
#NANT_USED = 1

#------------------------------------------------------------------------------
# Set MKVERBOSE to a various value, to enable enhanced debug output from
# MakeSupport. To disable this afterwards, set MKVERBOSE to nothing
# (comment out this line and type "set MKVERBOSE=" in command window)
#------------------------------------------------------------------------------
#MKVERBOSE = 1

#------------------------------------------------------------------------------
# Set $(BRSVINFO_USED) to 1 to enable the generation of BrsVInfo.h within the
# GenData folder by the MakeSupport.
# The BrsVInfo.h will contain e.g. kBrsCompilerVersion, to use this
# information within the embedded code.
#------------------------------------------------------------------------------
#BRSVINFO_USED = 1

#------------------------------------------------------------------------------
# Set $(USE_RESPONSE_FILE_FOR_LINKAGE) to '1' to pass object files in a response file
# to the linker instead of using the command line.
#
# Use it if you hit the limit of maximum length command line length under Windows.
#
# See e.g. the following link regarding some information on response files:
# https://gcc.gnu.org/wiki/Response_Files
#
# If you enable 'USE_RESPONSE_FILE_FOR_LINKAGE', you also need to define
# 'LDFLAGS_RESPONSE_FILE' in Makefile.static.
#------------------------------------------------------------------------------
#USE_RESPONSE_FILE_FOR_LINKAGE=1

#------------------------------------------------------------------------------
# Functions used within Assembler/Compiler/Linker options.
#
# Common functionality is encapsulated in the following functions:
# - obj2err
# - obj2lst
#
# Example:
# --list-file=$(call obj2lst,$@)
# --error-file=$(call obj2err,$@)
#
# Please have a look at Makefile_functions.mk for further detailed information.
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Extra dependency defines
# The DEPEND tool which is normally a preprocessor
# is called with $(EXTRA_DEPENDFLAGS) and $(CPPFLAGS).
#
# The cross compiler adds its own defines which DEPEND
# doesn't know.
#
# Add cross options set by compiler and other options
# for the preprocessor here.
# e.g.: EXTRA_DEPENDFLAGS += -D__CTC__
#
# For normal build defines use $(CPPFLAGS_VECTOR_MAKESUPPORT).
#------------------------------------------------------------------------------
EXTRA_DEPENDFLAGS +=

#--------------------------------------
# CPU-core-specific CFLAGS option list
#--------------------------------------
CPU_SWITCH_CORTEX_M0     = Cortex-M0
CPU_SWITCH_CORTEX_M0PLUS = Cortex-M0plus
CPU_SWITCH_CORTEX_M3     = Cortex-M3
CPU_SWITCH_CORTEX_M4     = Cortex-M4
CPU_SWITCH_CORTEX_M4F    = Cortex-M4
CPU_SWITCH_CORTEX_R5F    = Cortex-R5
CPU_SWITCH_CORTEX_R52    = Cortex-R52

ifeq ($(CPU_SWITCH_$(CPU_CORE)),)
  $(error COMPILERFLAGERROR: The compiler option (-mcpu=<value>) is not defined!)
endif

#--------------------------------------------------
# CPU-core-architecture specific CFLAGS option list
#--------------------------------------------------
ARCHITECTURE_SWITCH_CORTEX_M0     = armv6-m
ARCHITECTURE_SWITCH_CORTEX_M0PLUS = armv6-m
ARCHITECTURE_SWITCH_CORTEX_M3     = armv7-m
ARCHITECTURE_SWITCH_CORTEX_M4     = armv7-m
ARCHITECTURE_SWITCH_CORTEX_M4F    = armv7-m
ARCHITECTURE_SWITCH_CORTEX_R5F    = armv7-r

ifeq ($(ARCHITECTURE_SWITCH_$(CPU_CORE)),)
  # -march=armv8-r not (yet) supported in tiarmclang 4.0.3 LTS
  ifneq ($(CPU_CORE),CORTEX_R52)
    $(error COMPILERFLAGERROR: The compiler option (-march=<value>) is not defined!)
  endif
endif


#------------------------------------------------------------------------------
#    CPU-core-specific FPU option list
#------------------------------------------------------------------------------
ifeq ($(FPU_USED),1)
  CFLAGS_FPU_CORTEX_R5F = vfpv3-d16 -mfloat-abi=hard
  CFLAGS_FPU_CORTEX_M4F = fpv4-sp-d16 -mfloat-abi=hard
  # CFLAGS_FPU_CORTEX_R52: neon-fp-armv8 FPU is enabled by default
else
  CFLAGS_FPU_$(CPU_CORE) = none -mfloat-abi=soft
endif

ifeq ($(CFLAGS_FPU_$(CPU_CORE)),)
  $(error COMPILERFLAGERROR: The compiler option (-mfpu=<value>) is not defined!)
endif

#------------------------------------------------------------------------------
# $(AS_ENV) is the environment necessary to run the assembler
# $(AS) defines the path to the assembler
# $(ASFLAGS_VECTOR_MAKESUPPORT) defines all assembler switches, mandatory for
#                               the Vector build environment (MakeSupport/BrsHw)
# $(ASFLAGS_VECTOR_OPTIONS) defines the Vector default assembler switches
# $(ASFLAGS_CUSTOMER_OPTIONS) defines the customer requested assembler switches
# Depending of ASFLAGS_SELECTOR, ASFLAGS_VECTOR_OPTIONS or ASFLAGS_CUSTOMER_OPTIONS
# are used together with $(ASFLAGS_VECTOR_MAKESUPPORT) for build.
#------------------------------------------------------------------------------
AS_ENV = 
AS     = $(COMPILER_BIN)/tiarmclang

#------------------------------------------------------------------------------
# Please add only absolutely mandatory options below
#------------------------------------------------------------------------------
ASFLAGS_VECTOR_MAKESUPPORT = -c \
                             -o $@

#------------------------------------------------------------------------------
# $(ASFLAGS_VECTOR_PREPROCESS) defines the options in preprocessing
# just before assembler starts. This flag is used only if
# AS_VECTOR_PREPROCESS (located in Makefile.static) is enabled.
#
# $(CPPFLAGS_CORE) can be added here.
#------------------------------------------------------------------------------
ASFLAGS_VECTOR_PREPROCESS = $(CPPFLAGS_CORE)

#------------------------------------------------------------------------------
# Please add any other option below (Vector default options)
#
# Use $(ASFLAGS_VECTOR_OPTIONS) if assembler supports preprocessing by default.
# In case of assembler does not support preprocessing and preprocessing is
# enabled by $(ASFLAGS_VECTOR_PREPROCESS) in a prestep
# $(CPPFLAGS_CORE) must be set in $(ASFLAGS_VECTOR_PREPROCESS)
#------------------------------------------------------------------------------
ASFLAGS_VECTOR_OPTIONS = $(CFLAGS_VECTOR_OPTIONS)

#------------------------------------------------------------------------------
# Please enter all customer options below
#------------------------------------------------------------------------------
ASFLAGS_CUSTOMER_OPTIONS =

#------------------------------------------------------------------------------
# $(ASVERSION) defines the assembler switch for version report.
# E.g.: ASVERSION = -V
#------------------------------------------------------------------------------
ASVERSION = --version

#------------------------------------------------------------------------------
# $(AS_LC) defines the number of lines used for assembler version information.
# $(AS_OFF) defines the offset of lines used for assembler version information
# in BrsVinfo.h and Deliverydescription (default is 5).
#------------------------------------------------------------------------------
AS_OFF = 
AS_LC  = 1

#------------------------------------------------------------------------------
#------------------------- MUST be filled out ---------------------------------
# $(CC_ENV) is the environment necessary to run the compiler
# $(CC) defines the path to the C-Compiler
# $(CFLAGS_VECTOR_MAKESUPPORT) defines all compiler switches, mandatory for
#                              the Vector build environment (Makesupport/BrsHw)
# $(CFLAGS_VECTOR_OPTIONS) defines the Vector default compiler switches
# $(CFLAGS_CUSTOMER_OPTIONS) defines the customer requested compiler switches
# Depending $(CFLAGS_SELECTOR), $(CFLAGS_VECTOR_OPTIONS) or
# $(CFLAGS_CUSTOMER_OPTIONS) is used together with $(CFLAGS_VECTOR_MAKESUPPORT)
# for build.
#
#  Avoid $(OBJ_SUFFIX) to filter use $(basename $@) because
#  ECO has a preprocess using CFLAGS_xx and the target is of type source.
#------------------------------------------------------------------------------
CC_ENV = 
CC     = $(COMPILER_BIN)/tiarmclang

#------------------------------------------------------------------------------
# Please add only absolutely mandatory options below
#
#  BRS values:
#    -DBRS_COMP_$(COMPILER_MANUFACTURER)
#    -DBRS_PLATFORM_$(PLATFORM)
#
#  Avoid $(OBJ_SUFFIX) to filter. Use $(basename $@) because
#  ECO has a preprocess using CFLAGS_xx and the target is of type source.
#------------------------------------------------------------------------------
CPPFLAGS_VECTOR_MAKESUPPORT = -DBRS_PLATFORM_$(PLATFORM) \
                              -DBRS_COMP_$(COMPILER_MANUFACTURER)

CFLAGS_VECTOR_MAKESUPPORT = -c \
                            -o $@

CFLAGS_ARM   = -marm
CFLAGS_THUMB = -mthumb

ifeq ($(CFLAGS_$(INSTRUCTION_SET)),)
  $(error COMPILERFLAGERROR: The compiler option for the instruction set is not defined!)
endif

#------------------------------------------------------------------------------
# Add depend options here.
# It is separated because of the option to overwrite
# $(COMPILER_SUPPORTS_DEPEND) or have different compile without
# path length problem in command line.
#
# Pay attention below if $(MAKESUPPORT_POST_COMPILE_CMD) is
# used in context of depend file creation.
#
# Example:
#   CFLAGS_VECTOR_MAKESUPPORT    += -MMD -MF $(@:.o=.dt)
#   MAKESUPPORT_POST_COMPILE_CMD += $(SED) -Ef $(MAKESUPPORT_DIR_U)/util/fix_dos_dep_file.sed < $(@:.o=.dt) > $(@:.o=.d);
#   MAKESUPPORT_POST_COMPILE_CMD += $(RM) $(@:.o=.dt);
#------------------------------------------------------------------------------
ifeq ($(COMPILER_SUPPORTS_DEPEND),1)
  CFLAGS_VECTOR_MAKESUPPORT    += -MD
  MAKESUPPORT_POST_COMPILE_CMD +=

  #-----------------------------------------------------------------------------
  # If $(CC) shall create dependency file as well, fill the following variables.
  # Otherwise, 'clang' does the task without using a floating license.
  #-----------------------------------------------------------------------------
  #DEPEND = $(CC_ENV) $(CC)
  #DEPENDFLAGS =
endif

#------------------------------------------------------------------------------
# $(REUSE_CPP_DEPEND) is set because compiler has a path length problem
#------------------------------------------------------------------------------
#REUSE_CPP_DEPEND = 1
ifeq ($(COMPILER_SUPPORTS_DEPEND)+$(REUSE_CPP_DEPEND),1+1)
  $(error Can not set both: COMPILER_SUPPORTS_DEPEND and REUSE_CPP_DEPEND)
endif

#------------------------------------------------------------------------------
# Post compile command to cleanup anything during compilation process
#
# Calling convention:
#   $(call MAKESUPPORT_POST_COMPILE_CMD,$@,$<)
#------------------------------------------------------------------------------
MAKESUPPORT_POST_COMPILE_CMD +=

#------------------------------------------------------------------------------
# Please add any other option below (Vector default options)
#  Avoid $(OBJ_SUFFIX) to filter use $(basename $@) because
#  ECO has a preprocess using CFLAGS_xx and the target is of type source.
#------------------------------------------------------------------------------
# If no -std option is specified when compiling a C source file, gnu11 is assumed by default.
CFLAGS_VECTOR_OPTIONS = -Wall                                     \
                        -mcpu=$(CPU_SWITCH_$(CPU_CORE))           \
                        -mfpu=$(CFLAGS_FPU_$(CPU_CORE))           \
                        -mlittle-endian                           \
                        -O1                                       \
                        -g                                        \
                        $(CFLAGS_$(INSTRUCTION_SET))              \
                        $(ADDITIONAL_CFLAGS_FROM_VBRS)            \
                        $(CPU_MARCH_FLAGS)

# Only set -march if CPU_CORE is not R52
ifeq ($(CPU_CORE),CORTEX_R52)
CPU_MARCH_FLAGS =
else
CPU_MARCH_FLAGS = -march=$(ARCHITECTURE_SWITCH_$(CPU_CORE))
endif

#------------------------------------------------------------------------------
# Please enter all customer options below
#  Avoid $(OBJ_SUFFIX) to filter use $(basename $@) because
#  ECO has a preprocess using CFLAGS_xx and the target is of type source.
#------------------------------------------------------------------------------
CFLAGS_CUSTOMER_OPTIONS =

#------------------------------------------------------------------------------
# $(CVERSION) defines the compiler switch for version report
# E.g.: CVERSION = -V
#------------------------------------------------------------------------------
CVERSION = --version

#------------------------------------------------------------------------------
# $(CC_LC) defines the number of lines used for compiler version information
# $(CC_OFF) defines the offset of lines used for compiler version information
# in BrsVinfo.h and Deliverydescription (default is 5)
#------------------------------------------------------------------------------
CC_OFF =
CC_LC  = 1

#------------------------------------------------------------------------------
# Filter out section
# Add flags which must be filtered out for specific files
#
# Examples:
#   FILTER_Os=-g              # no debug option for file Os.c
#   FILTER_COMPONENT_Det=-g   # no debug option for component Det
#------------------------------------------------------------------------------
#FILTER_<file_without_extension> =
#FILTER_COMPONENT_<module_name>  =

# Note:
# The exception table and the init of exc table using the backup exc table are
# implmented in ARM mode => (ARMBrsHwIntTb_CortexR.c, ARMStartup_CortexR.c)
# must be compiled in ARM mode even when Thumb mode instruction set is configured.
ifeq ($(CPU_CORE), $(filter $(CPU_CORE), CORTEX_R4 CORTEX_R4F CORTEX_R5 CORTEX_R5F CORTEX_R52 CORTEX_R7))
  ifeq ($(INSTRUCTION_SET),THUMB)
    FILTER_ARMBrsHwIntTb_CortexR = $(CFLAGS_THUMB)
    CFLAGS_ARMBrsHwIntTb_CortexR = $(CFLAGS_ARM)
    FILTER_ARMStartup_CortexR    = $(CFLAGS_THUMB)
    CFLAGS_ARMStartup_CortexR    = $(CFLAGS_ARM)
  endif
endif

#------------------------------------------------------------------------------
# Additional file specific compiler options
#------------------------------------------------------------------------------
#CFLAGS_<file_without_extension>   =
#CFLAGS_COMPONENT_<module_name>    =

#------------------------------------------------------------------------------
#------------------------- MUST be filled out ---------------------------------
# $(LD_ENV) is the environment necessary to run the linker
# $(LD) defines the path to the linker
# $(LDFLAGS_VECTOR_MAKESUPPORT) defines all linker switches, mandatory for the
#                               Vector build environment (MakeSupport/BrsHw)
# $(LDFLAGS_VECTOR_OPTIONS) defines the Vector default linker switches
# $(LDFLAGS_CUSTOMER_OPTIONS) defines the customer requested linker switches
# Depending on $(LDFLAGS_SELECTOR), $(LDFLAGS_VECTOR_OPTIONS) or
# $(LDFLAGS_CUSTOMER_OPTIONS)is used together with $(LDFLAGS_VECTOR_MAKESUPPORT)
# for build.
#------------------------------------------------------------------------------
LD_ENV = 
LD     = $(COMPILER_BIN)/tiarmclang

ifeq ($(BRS_FIRST_EXECUTION_INSTANCE),1)
  ifeq ($(CPU_CORE),$(filter $(CPU_CORE),CORTEX_M0 CORTEX_M0PLUS CORTEX_M3 CORTEX_M33 CORTEX_M4 CORTEX_M4F CORTEX_M7))
    LDFLAGS_ENTRY = brsStartupEntry
  else
    LDFLAGS_ENTRY = intvect_CoreExceptions
  endif
else
  LDFLAGS_ENTRY = Brs_ApplicationEntry
endif

#------------------------------------------------------------------------------
# Please add only absolutely mandatory options below
#
#  Please use $(PROJECT_NAME).$(BINARY_SUFFIX) or $(TARGET) instead of $@ and
#  $(PROJECT_NAME) instead of $* because flags
#  are used in delivery description.
#
#  Linker script file name : $(LINKER_COMMAND_FILE)
#------------------------------------------------------------------------------
LDFLAGS_VECTOR_MAKESUPPORT = -Xlinker -c                    \
                             -Xlinker -e=$(LDFLAGS_ENTRY)   \
                             -Xlinker -m$(PROJECT_NAME).map \
                             -o $(TARGET)

#------------------------------------------------------------------------------
# Set $(PREPROCESS_LINKER_COMMAND_FILE) to 1 to preprocess
# linker command file. $(USER_LINKER_COMMAND_FILE) can be set manually
# but is $(PROJECT_NAME).$(LNK_SUFFIX) by default.
#------------------------------------------------------------------------------
#PREPROCESS_LINKER_COMMAND_FILE = 1

#------------------------------------------------------------------------------
# Post link command to cleanup anything during linking process
#
# Calling convention:
#   $(call MAKESUPPORT_POST_LINK_CMD,$@,$<)
#------------------------------------------------------------------------------
MAKESUPPORT_POST_LINK_CMD +=

#------------------------------------------------------------------------------
# Please add any other option below (Vector default options)
#
#  Please use $(PROJECT_NAME).$(BINARY_SUFFIX) or $(TARGET) instead of
#  $@ and $(PROJECT_NAME) instead of $* because flags
#  are used in delivery description.
#
#  Linker script file name : $(LINKER_COMMAND_FILE)
#------------------------------------------------------------------------------
# --diag_suppress=10063-D is to suppress linker warning for
#   "entry-point symbol other than "_c_int00" specified: "intvect_CoreExceptions""
#
# --diag_suppress=10068-D is to suppress linker warning for
#   "no matching section"
#
# --diag_suppress=10247-D is to suppress linker warning for
#   "creating output section ".cinit" without a SECTIONS specification"
#------------------------------------------------------------------------------
ifeq ($(CPU_CORE),CORTEX_R5F)
  EXCEPTION_TABLE_LDFLAGS = -Xlinker -u=intvect_CoreExceptions_vectortable \
                            -Xlinker -u=intvect_CoreExceptions_vectortable_backup

  ifeq ($(BRS_CPU_CORE_1_USED),1)
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core1Exceptions_vectortable
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core1Exceptions_vectortable_backup
  endif
  ifeq ($(BRS_CPU_CORE_2_USED),1)
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core2Exceptions_vectortable
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core2Exceptions_vectortable_backup
  endif
  ifeq ($(BRS_CPU_CORE_3_USED),1)
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core3Exceptions_vectortable
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core3Exceptions_vectortable_backup
  endif
  ifeq ($(BRS_CPU_CORE_4_USED),1)
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core4Exceptions_vectortable
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core4Exceptions_vectortable_backup
  endif
  ifeq ($(BRS_CPU_CORE_5_USED),1)
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core5Exceptions_vectortable
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core5Exceptions_vectortable_backup
  endif
  ifeq ($(BRS_CPU_CORE_6_USED),1)
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core6Exceptions_vectortable
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core6Exceptions_vectortable_backup
  endif
  ifeq ($(BRS_CPU_CORE_7_USED),1)
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core7Exceptions_vectortable
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_Core7Exceptions_vectortable_backup
  endif
  ifeq ($(BRS_FBL_EXCEPTIONTABLE_IN_RAM),1)
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_CoreExceptions_Ram
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_CoreExceptions_Ram_Vectortable
  endif
endif

ifeq ($(BRS_ENABLE_FBL_SUPPORT),1)
 ifeq ($(CPU_CORE),$(filter $(CPU_CORE),CORTEX_R4 CORTEX_R4F CORTEX_R5 CORTEX_R5F CORTEX_R52 CORTEX_R7))
  ifeq ($(BRS_FBL_EXCEPTIONTABLE_IN_RAM),1)
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_CoreExceptions_Ram
    EXCEPTION_TABLE_LDFLAGS += -Xlinker -u=intvect_CoreExceptions_Ram_Vectortable
  endif
 endif
endif

LDFLAGS_VECTOR_OPTIONS = -Xlinker -q                              \
                         -Xlinker --warn_sections                 \
                         -Xlinker --unused_section_elimination=on \
                         -Xlinker --compress_dwarf=on             \
                         -Xlinker --copy_compression=rle          \
                         -Xlinker --reread_libs                   \
                         -Xlinker --display_error_number          \
                         -Xlinker --priority                      \
                         $(ADDITIONAL_LDFLAGS_FROM_VBRS)          \
                         -Xlinker $(LINKER_COMMAND_FILE)          \
                         -Xlinker --diag_suppress=10063-D         \
                         -Xlinker --diag_suppress=10068-D         \
                         -Xlinker --diag_suppress=10247-D         \
                         $(EXCEPTION_TABLE_LDFLAGS)

#------------------------------------------------------------------------------
# Please enter all customer options below
#
#  Please use $(PROJECT_NAME).$(BINARY_SUFFIX) instead of $@ and
#  $(PROJECT_NAME) instead of $*, because flags
#  are used in delivery description.
#------------------------------------------------------------------------------
LDFLAGS_CUSTOMER_OPTIONS =

#------------------------------------------------------------------------------
# Please add additional system libraries below
#
#  For some compilers, it is necessary to add additional system libraries.
#  E.g. the ARM GCC Gnu compiler may need libc for memcpy or libgcc for modulo
#
#  To add additional libraries use:
#  -lgcc  (libgcc: e.g. support for modulo operation)
#  -lc    (libc:   e.g. support for memcpy function)
#------------------------------------------------------------------------------
SYSLIBS +=

#------------------------------------------------------------------------------
# $(LDVERSION) defines the linker switch for version report
# E.g.: LDVERSION = -v
#------------------------------------------------------------------------------
LDVERSION = --version

#------------------------------------------------------------------------------
# $(LD_LC) defines the number of lines used for linker version information
# $(LD_OFF) defines the offset of lines used for linker version information
# in BrsVinfo.h and Delivery Description (default is 5)
#------------------------------------------------------------------------------
LD_OFF =
LD_LC  = 1

#------------------------------------------------------------------------------
#------------------------- MUST be filled out if used -------------------------
# $(HEX_ENV) is the environment necessary to run the hexfile generator
# $(HEX) defines the path to the hex converter, e.g. $(COMPILER_BIN)/gsrec
# $(HEXFLAGS) contains options for HEX tool, e.g. -nos5 -skip .tdata $< -o $@
#------------------------------------------------------------------------------
HEX_ENV  = $(CC_ENV)
HEX      = $(COMPILER_BIN)/tiarmhex

HEXFLAGS = --intel $(PROJECT_NAME).$(BINARY_SUFFIX) --memwidth=8 --outfile=$(PROJECT_NAME).hex

#------------------------------------------------------------------------------
#------------------------- MUST be filled out if used -------------------------
# $(AR_ENV) is the environment necessary to run the librarian
# $(AR) defines the path to the C-librarian
# $(ARFLAGS) defines all librarian switches
#
# Don't add $@. It is added in rule because AR rule is dynamically generated.
#------------------------------------------------------------------------------
AR_ENV =
AR     = $(COMPILER_BIN)/tiarmar

ARFLAGS = -r

#------------------------------------------------------------------------------
# $(ARVERSION) defines the archiver switch for version report
# E.g.: ARVERSION = -v
#------------------------------------------------------------------------------
ARVERSION = --version

#------------------------------------------------------------------------------
# $(AR_LC) defines the number of lines used for librarian version information
# $(AR_OFF) defines the offset of lines used for archiver version information
# in BrsVinfo.h
#------------------------------------------------------------------------------
AR_OFF =
AR_LC  = 1

#------------------------------------------------------------------------------
# Additional includes essentially for compilation
#------------------------------------------------------------------------------
ADDITIONAL_INCLUDES +=

#------------------------------------------------------------------------------
# Additional objects essentially for linking
# E.g.: ADDITIONAL_OBJECTS = $(OBJ_PATH)/myobject.$(OBJ_SUFFIX)
#------------------------------------------------------------------------------
ADDITIONAL_OBJECTS +=

#------------------------------------------------------------------------------
# Additional libraries essentially for linking
# E.g.: ADDITIONAL_LIBRARIES = $(LIB_PATH)/mylib.$(LIB_SUFFIX)
#------------------------------------------------------------------------------
ADDITIONAL_LIBRARIES +=

#------------------------------------------------------------------------------
# List of assembler source files
# E.g.: ASM_SOURCES = source/startup.$(ASM_SUFFIX)
#------------------------------------------------------------------------------
ASM_SOURCES +=

#------------------------------------------------------------------------------
# Add Startup code to application source list
# E.g.: APP_SOURCE_LST += source/startup.c
#------------------------------------------------------------------------------
APP_SOURCE_LST +=

#------------------------------------------------------------------------------
# Check if all necessary variables are set
# (Checks that are not possible to be performed within Makefile.static)
#------------------------------------------------------------------------------

###############################################################################
######### DO NOT remove these lines from the end of the Makefile!!! ###########
###############################################################################

#------------------------------------------------------------------------------
# Include the main makefile where all the targets are defined
#------------------------------------------------------------------------------
include $(MAKESUPPORT_DIR)/Global.Makefile.target.$(VERSION).mk

# End of Makefile
