TRUSTLET_DIR := $(KINIBI_TA_BUILD_ROOT)/kinibi_source/tima_atn/Locals/Code
TIMA_ATN_COMMON := $(KINIBI_TA_BUILD_ROOT)/kinibi_source
ICCC_CONFIG := $(KINIBI_TA_BUILD_ROOT)/kinibi_source/tz_iccc_common

# output binary name without path or extension
OUTPUT_NAME := tl_tima_atn

### Mobiconvert parameters
## For more information about the different parameters, see the "MobiConvert User Manual"

## mandatory parameters

# the uuid( also used as output base file name)
TRUSTLET_UUID := ffffffff00000000000000000000000f
# --servicetype <num>
TRUSTLET_SERVICE_TYPE := 3 # 2: service provider trustlet; 3: system trustlet

## optional parameters
# --flags
TRUSTLET_FLAGS := 0 # 0: no flag; 1: permanent; 2: service has no WSM control interface; 3: both (permanent and service has not WSM control interface); 4: debuggable
# ---numberofinstances <num>
TRUSTLET_INSTANCES := 1 # min: 1; max: 16
# --numberofthreads <num>
TRUSTLET_NO_OF_THREADS := 1 # has to be 1 for Trustlets
# --memtype <type>
TRUSTLET_MEMTYPE := 2 # 0: internal memory prefered; 1: internal memory used; 2: external memory used

TRUSTLET_OPTS += -D__DEBUG__

#-------------------------------------------------------------------------------
# Files and include paths - Add your files here
#-------------------------------------------------------------------------------

### Add include path here
INCLUDE_DIRS += \
    $(TRUSTLET_DIR)/inc \
    $(TIMA_ATN_COMMON)/tima_atn_common/Locals/Code/inc

### Add source code files for C++ compiler here
SRC_CPP += \
    $(TRUSTLET_DIR)/src/tl_tima_attestation.c \
    $(TIMA_ATN_COMMON)/tima_atn_common/Locals/Code/src/TBASE_TZ_Vendor.c \
    $(TIMA_ATN_COMMON)/tima_atn_common/Locals/Code/src/buffer_utils.c \
    $(TIMA_ATN_COMMON)/tima_atn_common/Locals/Code/src/process_msr.c \

### Add source code files for C compiler here
SRC_C += # nothing

### Add source code files for assembler here
SRC_S += # nothing

include $(ICCC_CONFIG)/iccc_config.mk

ARMCC_COMPILATION_FLAGS += -DUSE_MOBICORE
ARMCC_COMPILATION_FLAGS += --diag_error=C167,C152,C185,C513,C1254,C1293,C546,C550,C61,C47,C191,C144,C188,C231,C111,C225 #,C223,C1461,C177
ARMCC_COMPILATION_FLAGS += --protect_stack --protect_stack_all
ARMCC_COMPILATION_FLAGS += -W

MODE := Debug

ifeq ($(findstring exynos,$(TA_TARGET_SOC)), exynos)
PLATFORM = EXYNOS_$(strip $(subst exynos, ,$(TA_TARGET_SOC)))_STD
ARMCC_COMPILATION_FLAGS += -DCONFIG_SMDK$(strip $(subst exynos, ,$(TA_TARGET_SOC)))
ifeq ($(TA_TARGET_SOC), exynos7885)
RUNTYPE := gd_mobicore400_trustlet
TRUSTLET_SIGN_CONF := "-s 3 -n 1 -i 1 -m 2 -f 0"
SRC_CPP += \
    $(TIMA_ATN_COMMON)/tima_atn_common/Locals/Code/src/tz_ta_stack_protection.c
else ifeq ($(TA_TARGET_SOC), exynos9810)
RUNTYPE := gd_mobicore400_trustlet
TRUSTLET_SIGN_CONF := "-s 3 -n 1 -i 2 -m 2 -f 8"
TBASE_API_LEVEL := 8
ENABLE_STACK_PROTECTION := true
ARMCC_COMPILATION_FLAGS += -DENABLE_STACK_PROTECTION
endif
endif

ifeq ($(findstring mt,$(TA_TARGET_SOC)), mt)
ARMCC_COMPILATION_FLAGS += -DCONFIG_MT$(strip $(subst mt, ,$(TA_TARGET_SOC)))
ifeq ($(TA_TARGET_SOC), mt6768)
RUNTYPE := gd_mobicore410_trustlet
TRUSTLET_SIGN_CONF := "-s 3 -n 1 -i 2 -m 2 -f 8"
TBASE_API_LEVEL := 11
endif
endif

$(info [Attestation] Build Conf KINIBI_VERSION : $(KINIBI_VERSION))
$(info [Attestation] Build Conf TRUSTLET_SIGN_CONF : $(TRUSTLET_SIGN_CONF))
$(info [Attestation] Build Conf RUNTYPE : $(RUNTYPE))
$(info [Attestation] Build Conf TBASE_API_LEVEL : $(TBASE_API_LEVEL))

# use generic make file
include $(TLSDK_DIR_SRC)/trustlet.mk
