LOCAL_PATH := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
include $(_sdk_dir)/uuid-utils.mk

include $(_sdk_dir)/../source/gp-api/crypto.mk

LOCAL_QSEE_UUID := $(strip $(call get-qsee-uuid,$(LOCAL_UUID)))
TA_UUID_STRUCT := $(strip $(call get-local-uuid-as-struct,$(LOCAL_UUID)))
TA_GROUP_ID := $(LOCAL_GROUP_ID)

LOCAL_NAME := $(LOCAL_QSEE_UUID)_qsee_gp_tee
_gpapi_include_dirs := ../../include/gp-api protocol ../../include/gp-mb uuid_utils persistent_object tee/session_manager client log_utils $(CRYPTO_INCLUDE_DIRS)
LOCAL_SRC_C := \
               tee/qsee/tee_sys.c \
               tee/qsee/tee_time.c \
               tee/qsee/tees_mem.c \
               tee/qsee/tees_log.c \
               tee/qsee/persistent_object.c \
               tee/session_manager/session_manager.c \
               tee/qsee/tees_secure_object.c \
               tee/qsee/tees_rpmb.c \
               uuid_utils/uuid_utils.c \
               protocol/tee_param_utils.c \
               persistent_object/persistent_object_api.c \
               persistent_object/serialise_attr.c \
               persistent_time/tee_persistent_time.c \
               log_utils/log_utils.c \
               cancellation_func/tee_cancel.c \
               tee/qsee/tee_cancel.c \
               crypto/kdf/tees_kdf_qsee.c \
               $(CRYPTO_SRC)

LOCAL_CFLAGS += -DNO_INLINE -DMB_QSEE -DNO_ASSERT \
                -DQSEE_APP_NAME=\"$(LOCAL_QSEE_UUID)\" \
                -DYOUR_TA_UUID='$(TA_UUID_STRUCT)' \
                -DYOUR_GROUP_ID=\"$(TA_GROUP_ID)\" \
                $(CRYPTO_CFLAGS)

# RPMB API FLAG which is were found by empirical way for msm8998 and sdm845 chip.
ifneq ($(filter msm8998 sdm845,$(LOCAL_CHIP)),)
        LOCAL_CFLAGS += -DHAS_RPMB_PARTITION_REMOVE
endif

ifeq ($(LOCAL_FIPS_CRYPTO),y)
    ifeq ($(LOCAL_CHIP),msm8996)
        LOCAL_CFLAGS += -DSCRYPTO_INIT
    endif
    LOCAL_CFLAGS += -DBORING_SSL
else
    _gpapi_include_dirs += ../../prebuilt/arm/cryptocore/include
endif

LOCAL_LINK_GP_TEE := n

# gp-api properties
_gpapi_include_dirs += prop/src \
                       prop/tee \
                       prop/inc \
                       prop/tee/non-blowfish-include \
                       ../../include/gp-ext

LOCAL_SRC_C += prop/src/property.c \
               prop/src/tee_string.c \
               prop/src/uuid.c
LOCAL_BSP_DEFINES += -Wno-gnu-folding-constant -Wno-strncat-size
ARMCC_LOCAL_CFLAGS += --gnu --c99 --no_vla \
                      --diag_suppress 223 \
                      --diag_suppress 188 \
                      --diag_suppress 40 \
                      --diag_suppress 1202 \
                      --diag_suppress 1296 \
                      --diag_suppress 177
ifeq ($(LOCAL_BUILD_TOOL),arm)
  LOCAL_CFLAGS += $(ARMCC_LOCAL_CFLAGS) --diag_error=warning
else
  LOCAL_CFLAGS += -Wall -Werror -Wno-gnu-folding-constant -Wno-strncat-size -Wincompatible-pointer-types
endif

_import_include_dirs := $(LOCAL_INCLUDE_DIRS)
LOCAL_INCLUDE_DIRS := $(_gpapi_include_dirs) $(_import_include_dirs)

include $(BUILD_QSEE_LIBRARY)
