LOCAL_PATH := $(call my-dir)

MESON_HAS_TFLITE := @MESON_HAS_TFLITE@

ifeq ($(MESON_HAS_TFLITE),1)

include $(CLEAR_VARS)

LOCAL_MODULE := tensorflow-lite
LIB_ := arm64

ifeq ($(APP_ABI), armeabi-v7a)
  LIB_ := armv7
endif

LOCAL_SRC_FILES := @MESON_TFLITE_ROOT@/lib/$(LIB_)/libtensorflow-lite.a
LOCAL_EXPORT_C_INCLUDES := @MESON_TFLITE_ROOT@/include
LOCAL_EXPORT_LDLIBS := -lEGL -lGLESv2
include $(PREBUILT_STATIC_LIBRARY)

endif # MESON_HAS_TFLITE

include $(CLEAR_VARS)

LOCAL_MODULE := openblas

LOCAL_SRC_FILES := @MESON_BLAS_ROOT@/lib/libopenblas.a
LOCAL_EXPORT_C_INCLUDES := @MESON_BLAS_ROOT@/include
LOCAL_EXPORT_CFLAGS += -DUSE_BLAS=1

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := ml-api-inference

LOCAL_SRC_FILES := @MESON_ML_API_COMMON_ROOT@/lib/arm64-v8a/libnnstreamer-native.so
LOCAL_EXPORT_C_INCLUDES := @MESON_ML_API_COMMON_ROOT@/include

include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE        := iniparser
LOCAL_MODULE_TAGS   := optional

LOCAL_SRC_FILES     := @MESON_INIPARSER_ROOT@/src/iniparser.c \
											 @MESON_INIPARSER_ROOT@/src/dictionary.c
LOCAL_C_INCLUDES    := @MESON_INIPARSER_ROOT@/src
LOCAL_EXPORT_C_INCLUDES  := $(LOCAL_C_INCLUDES)

include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE        := nntrainer
LOCAL_SRC_FILES     := @MESON_NNTRAINER_SRCS@
# @todo ML_API_COMMON_ROOT should be included by exporting ml-api-common lib later
LOCAL_C_INCLUDES    := @MESON_NNTRAINER_INCS@ @MESON_ML_API_COMMON_ROOT@/include
LOCAL_EXPORT_C_INCLUDES  := $(LOCAL_C_INCLUDES)

LOCAL_ARM_NEON      := true
LOCAL_CFLAGS        += -pthread -fexceptions -fopenmp -static-openmp @MESON_CFLAGS@ -DML_API_COMMON=1
LOCAL_CXXFLAGS      += -std=c++17 -frtti -fexceptions -DML_API_COMMON=1
LOCAL_MODULE_TAGS   := optional

LOCAL_LDLIBS        := -llog -landroid -fopenmp -static-openmp

LOCAL_STATIC_LIBRARIES += iniparser openblas

ifeq ($(MESON_HAS_TFLITE), 1)
  LOCAL_STATIC_LIBRARIES += tensorflow-lite
endif # MESON_HAS_TFLITE

include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE        := ccapi-nntrainer
LOCAL_SRC_FILES     := @MESON_CCAPI_NNTRAINER_SRCS@
LOCAL_C_INCLUDES    := @MESON_CCAPI_NNTRAINER_INCS@ @MESON_ML_API_COMMON_ROOT@/include
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)

LOCAL_ARM_NEON      := true
LOCAL_CFLAGS        += -pthread -fexceptions -fopenmp -static-openmp @MESON_CFLAGS@ -DML_API_COMMON=1
LOCAL_CXXFLAGS      += -std=c++17 -frtti -fexceptions -DML_API_COMMON=1
LOCAL_MODULE_TAGS   := optional

LOCAL_LDLIBS        := -llog -landroid -fopenmp -static-openmp

LOCAL_SHARED_LIBRARIES += nntrainer

include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE        := capi-nntrainer
LOCAL_SRC_FILES     := @MESON_CAPI_NNTRAINER_SRCS@
LOCAL_C_INCLUDES    := @MESON_CAPI_NNTRAINER_INCS@
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)

LOCAL_ARM_NEON      := true
LOCAL_CFLAGS        += -pthread -fexceptions -fopenmp -static-openmp @MESON_CFLAGS@ -DML_API_COMMON=1
LOCAL_CXXFLAGS      += -std=c++17 -frtti -fexceptions -DML_API_COMMON=1
LOCAL_MODULE_TAGS   := optional

LOCAL_LDLIBS        := -llog -landroid -fopenmp -static-openmp

LOCAL_SHARED_LIBRARIES += ccapi-nntrainer nntrainer ml-api-inference

include $(BUILD_SHARED_LIBRARY)






