CFLAGS = -Wall -g -O -fPIC -DYOCTO_LINUX

INCLUDE_DIRS = \
    -I./include \
    -I../omx_plugin/include \
    -I../omx_plugin/include/openmax_ext \
    -I../omx_plugin/include/utils \
    -I../../Common/omx_plugin/include \
    -I$(SYS_ROOT)/usr/include/gstreamer1.0-omx/omx/openmax \
    -I../../Common/omx_plugin/include/utils \
    -I$(SYS_ROOT)/usr/include/memion \


ifeq ($(strip $(TARGET_PLATFORM_ARCH)),arm)
CFLAGS += -DPLATFORM_32BIT
else ifeq ($(strip $(TARGET_PLATFORM_ARCH)),aarch64)
CFLAGS += -DPLATFORM_64BIT
endif

ifeq ($(strip $(TARGET_BOARD_PLATFORM)),sp9863a)
INCLUDE_DIRS += -I../../Yocto/omx_core/SharkL3
else ifeq ($(strip $(TARGET_BOARD_PLATFORM)),ums312)
INCLUDE_DIRS += -I../../Yocto/omx_core/SharkL5
else ifeq ($(strip $(TARGET_BOARD_PLATFORM)),ud710)
INCLUDE_DIRS += -I../../Yocto/omx_core/ROC1
else ifeq ($(strip $(TARGET_BOARD_PLATFORM)),sp9832e)
INCLUDE_DIRS += -I../../Yocto/omx_core/SharkLE
else ifeq ($(strip $(TARGET_BOARD_PLATFORM)),ums512)
INCLUDE_DIRS += -I../../Yocto/omx_core/SharkL5Pro
endif

OBJ_DIR ?= .

TARGET = $(OBJ_DIR)/libsprd_omx_core.so

LIBS = -ldl

SRCS = $(wildcard *.cpp) \
    ../../Common/omx_core/sprd_omx_core.cpp \
    ../../Common/omx_plugin/SprdOMXComponent.cpp \


OBJS = $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(notdir $(SRCS)))

all:$(OBJS)
	$(CXX) -shared -fPIC -o $(TARGET) $(OBJS) $(LIBS)

$(OBJS):$(SRCS)
	$(foreach var,$^,\
		$(CXX) $(CFLAGS) $(INCLUDE_DIRS) -c $(var) -o $(OBJ_DIR)/$(basename $(notdir $(var))).o ;\
	)

install:
	cp $(TARGET) $(INSTALL_MOD_PATH)/usr/lib

clean:
	rm -f $(OBJS)
	rm -f $(TARGET)