LOCAL_PATH := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))

include $(_sdk_dir)/../source/gp-api/crypto.mk
 
LOCAL_NAME := $(LOCAL_UUID)_emulator_gp_tee
_gpapi_include_dirs := ../../include/gp-api protocol ../../include/gp-mb filesystem persistent_object log_utils $(CRYPTO_INCLUDE_DIRS)
LOCAL_SRC_C := tee/emulator/tl_main.c \
               tee/emulator/tee_sys.c \
               tee/emulator/tee_time.c \
               tee/emulator/tees_mem.c \
               tee/emulator/tees_log.c \
               tee/emulator/tees_secure_object.c \
               tee/emulator/persistent_object.c \
               tee/emulator/init_subsystems.c \
               tee/emulator/tees_rpmb.c \
               protocol/tee_param_utils.c \
               protocol/socket_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/emulator/tee_cancel.c \
               crypto/init_crypto_host.c \
               crypto/kdf/tees_kdf_emulator.c \
               $(CRYPTO_SRC)

LOCAL_CFLAGS += -DMB_PO_ROOT_DIR=\"./mb_po\" -Wall -Werror -fPIC $(CRYPTO_CFLAGS)

#RPMB FLAGS which is were set for debug.
LOCAL_CFLAGS += -DRPMB_BLOCK_SIZE=256
LOCAL_CFLAGS += -DRPMB_PART_NUM=1
LOCAL_CFLAGS += -DRPMB_MIN_PARTITION_ID=1
LOCAL_CFLAGS += -DRPMB_MAX_PARTITION_ID=1
LOCAL_CFLAGS += -DRPMB_MAX_BLOCK_NUM=1
LOCAL_CFLAGS += -DRPMB_MAX_ADDRESS_NUM=512

# 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_CFLAGS += -std=c99 -D_POSIX_C_SOURCE=199309
include $(_sdk_dir)/uuid-utils.mk
TA_UUID_STRUCT = $(strip $(call get-local-uuid-as-struct,$(LOCAL_UUID)))
TA_GROUP_ID = $(LOCAL_GROUP_ID)
LOCAL_CFLAGS += -DYOUR_TA_UUID='$(TA_UUID_STRUCT)' -DYOUR_GROUP_ID=\"$(TA_GROUP_ID)\" -DTA_UUID=\"$(LOCAL_UUID)\"

ifeq ($(LOCAL_FIPS_CRYPTO),y)
    LOCAL_CFLAGS += -DBORING_SSL
else
    LOCAL_CFLAGS += -DHOST_OPENSSL
endif

_import_include_dirs := $(LOCAL_INCLUDE_DIRS)
LOCAL_INCLUDE_DIRS := $(_gpapi_include_dirs) $(_import_include_dirs)

include $(BUILD_HOST_LIBRARY)
