# Copyright (C) 2012 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

LOCAL_PATH := $(call my-dir)

ifeq ($(TIMA_ENABLED),1)
include $(CLEAR_VARS)

# =============================================================================
# direct access to vendor communication library

include $(CLEAR_VARS)

ifeq ($(TARGET_SOC),exynos5410)
	MOBICORE_PATH := vendor/samsung_slsi/exynos5410/mobicore
else ifeq ($(TARGET_SOC),exynos5420)
	MOBICORE_PATH := vendor/samsung_slsi/exynos5420/mobicore
else ifeq ($(TARGET_SOC),exynos4x12)
	MOBICORE_PATH := vendor/samsung_slsi/exynos4x12/mobicore20
endif

ifeq (exynos,$(findstring exynos,$(TARGET_SOC)))
	EXTRA_CFLAGS := -DUSE_MOBICORE
	VENDOR_PATH := \
	$(MOBICORE_PATH)/daemon/ClientLib/public \
	$(MOBICORE_PATH)/common/MobiCore/inc
	VENDOR_LIB := libMcClient
	LOCAL_SRC_FILES := \
		../tz_platform/vendor/TBASE/tlc/mc_tlc_communication.cpp
else
	EXTRA_CFLAGS := -DUSE_QSEE
	VENDOR_PATH := vendor/qcom/proprietary/securemsm/QSEEComAPI
	VENDOR_LIB := libQSEEComAPI
	LOCAL_SRC_FILES := \
		../tz_platform/vendor/QSEE/tlc/qc_tlc_communication.cpp
endif

LOCAL_MODULE := libtlc_comm
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)

LOCAL_C_INCLUDES := \
	$(VENDOR_PATH) \
	vendor/samsung/common/external/tima/tima3/tlc_tima_common \
	vendor/samsung/common/external/tima/tima3/tz_common/comm \
	vendor/samsung/common/external/tima/tima3/tlc_comm/public \
	vendor/samsung/common/external/tima/tima3/tz_common/public \
	vendor/samsung/common/external/tima/tima3/tlc_tima_pkm/public

LOCAL_CFLAGS := -Wall
ifeq ($(SEC_BUILD_CONF_TIMA_SEANDROID_ENABLED),true)
	LOCAL_CFLAGS +=-DTIMA_ENABLE_SEANDROID_CHECK
endif
LOCAL_SHARED_LIBRARIES := liblog libc libdl $(VENDOR_LIB)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES

include $(BUILD_SHARED_LIBRARY)

# =============================================================================
# indirect access to vendor communication library

include $(CLEAR_VARS)

LOCAL_MODULE := libtlc_server
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)

LOCAL_C_INCLUDES := \
	vendor/samsung/common/external/tima/tima3/tz_common/public \
	vendor/samsung/common/external/tima/tima3/tlc_comm/public \
	vendor/samsung/common/external/tima/tima3/tlc_tima_common \
	vendor/samsung/common/external/tima/tima3/tlc_comm/ClientServerComm/tlc

LOCAL_SRC_FILES := \
        ./ClientServerComm/tlc/client_server_communication.cpp

LOCAL_CFLAGS := -Wall $(EXTRA_CFLAGS)

LOCAL_SHARED_LIBRARIES := liblog libc libcutils libbinder libutils
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES

include $(BUILD_SHARED_LIBRARY)

# =============================================================================
# tlc server executable

include $(CLEAR_VARS)

LOCAL_MODULE := tlc_server
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)

LOCAL_C_INCLUDES := \
	vendor/samsung/common/external/tima/tima3/tz_common/public \
	vendor/samsung/common/external/tima/tima3/tlc_comm/public \
	vendor/samsung/common/external/tima/tima3/tlc_tima_common \
	vendor/samsung/common/external/tima/tima3/tlc_tz_ccm/public \
	vendor/samsung/common/external/tima/tima3/tlc_tz_ccm/public/msgs \
	vendor/samsung/common/external/tima/tima3/tlc_tz_ccm/pkcs11 \
	vendor/samsung/common/external/tima/tima3/tlc_comm/ClientServerComm/tlc

LOCAL_SRC_FILES := \
        ./ClientServerComm/tlc/ccm_server.cpp

LOCAL_CFLAGS := -Wall $(EXTRA_CFLAGS)

LOCAL_SHARED_LIBRARIES := liblog libc libcutils libbinder libutils libtlc_comm
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := EXECUTABLES

include $(BUILD_EXECUTABLE)

endif

