# target name, the target name must have the same name of c source file
TARGET_NAME=libredismq

# target 
# for linux module driver: KO
# for application: EXE
# for dynamic library: DLL
TARGET_TYPE = DLL
 
# target object
# for application: APP
# for device driver: DRV
TARGET_OBJ  = APP

# custom install dir
TARGET_BOX = 

#debug mode or release mode
DEBUG 			= TRUE

PLAT_LINUX		?= TRUE
PLAT_ARM64		?= TRUE

VPATH = ../user/redismq/

# source code

# set the source file, don't used .o because of ...

COMMON_SRCS = redis_publisher.c redis_subscriber.c thpool.c

# MRS Board Source Files
PLAT_LINUX_SRCS = $(COMMON_SRCS)
PLAT_ARM64_SRCS = $(COMMON_SRCS)

# gcc CFLAGS
PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common/redismq -I../thirdparty/arm64/usr/local/include
PLAT_LINUX_CFLAGS := -fPIC -I../../Common -I../common/redismq -I../thirdparty/x86_64/usr/local/include


PLAT_ARM64_LDFLAGS  := -fPIC -shared -lpthread
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)


#gcc libs
ARM64_LIBS		:=  ../thirdparty/arm64/usr/local/lib/libhiredis.so ../thirdparty/arm64/usr/local/lib/libjemalloc.so  
LINUX_LIBS		:=  ../thirdparty/x86_64/usr/local/lib/libhiredis.so ../thirdparty/x86_64/usr/local/lib/libjemalloc.so 

ifeq	($(PLAT_ARM64), TRUE)
DEPEND_LIB			+= ../thirdparty/arm64/usr/local/lib/libhiredis.so ../thirdparty/arm64/usr/local/lib/libjemalloc.so
USER_CLEAN_ITEMS	+= 
endif

ifeq	($(PLAT_LINUX), TRUE)
DEPEND_LIB			+= ../thirdparty/x86_64/usr/local/lib/libhiredis.so ../thirdparty/x86_64/usr/local/lib/libjemalloc.so 
USER_CLEAN_ITEMS	+= 
endif

# this line must be at below of thus, because of...	
include ../../Common/common.Makefile

ifneq ($(MAKECMDGOALS), clean)
ifneq ($(MAKECMDGOALS), cleanall)
ifneq ($(notdir $(DEPEND_LIB)), $(wildcard $(DEPEND_LIB)))
$(shell $(CP) $(DEPEND_LIB) ./)
endif
endif
endif

ifeq ($(MAKECMDGOALS), )
$(shell find ./ -name "$(TARGET)-*.ko" -delete)
else
ifeq ($(MAKECMDGOALS), all)
$(shell find ./ -name "$(TARGET)-*.ko" -delete)
endif
endif