DEBUG=1

CC = gcc

CXX=g++

ifeq ($(DEBUG), 1) 

OPTS=-O0 -g -DDEBUG

endif


CFLAGS = -fPIC   -I$(COMPILE_DIR) -I$(vesdkdev)  -I$(es_common) -I$(vesdk) -I$(vesdk)/boost-153/include -I$(vesdkproject)

CXXFLAGS=$(CFLAGS)


Target = libServerCfg.so

VPATH = src 

OBJDIR=obj/

DEPDIR=deps/


CXXFLAGS +=$(OPTS)   

CXXFLAGS +=-I../../global_include/  -I$(CrossOnvifLib)/ClientSo/wrapper -I$(CrossOnvifLib)/ClientSo/onvifgen -I$(CrossPlatformLib)/vesdkdev  \

-I$(CrossOnvifLib)/Common/gsoap/share/gsoap/plugin  -I$(CrossOnvifLib)/Common/gsoap/include -I$(CrossPlatformLib)/es_common -I$(CrossPlatformLib)/vesdk \

-I$(CrossPlatformLib)/vesdkdev/utils/mt/


LDFLAGS+=-shared  -lm -pthread


LIBS   = -lOnvifClient -lsqlite3  -lboost_system 


OBJ=  Helper.o  Media.o DevicesMgmt.o Imaging.o PTZ.o DiskTool.o ServerCfg.o


OBJS = $(addprefix $(OBJDIR), $(OBJ))

DEPS = $(addprefix $(DEPDIR), $(OBJ))


all: obj $(Target)


$(Target): $(OBJS)

@echo make $(Target)

$(CXX)  $(CXXFLAGS) $^ -o $@ $(LDFLAGS) $(LIBS)

cp $(Target) /usr/lib


$(OBJDIR)%.o: %.cpp 

$(CC)  $(CXXFLAGS) -c $< -o $@


obj:

mkdir -p obj

deps:

mkdir -p deps

.PHONY: clean


clean:

rm -rf $(OBJS) $(Target)

ifeq ("$(wildcard deps)", "")

     DEP_DIR_DEPS:=deps

endif


include $(DEPS:.o=.d)


$(DEPDIR)%.d: %.cpp $(DEP_DIR_DEPS)

set -e; rm -f $@; \

$(CC) -MM $(CXXFLAGS) $< > $@.$$$$; \

sed 's,\($*\)\.o[ :]*,$(OBJDIR)\1.o $@ : ,g' < $@.$$$$ > $@; \

rm -f $@.$$$$