
ifeq ($(OPENMACRO),)
CROSS   = arm-hisiv100nptl-linux-
endif

ifeq ($(OPENMACRO),V300)
CROSS   = arm-hisiv300-linux-
endif

ifeq ($(OPENMACRO),V500)
CROSS   = arm-hisiv500-linux-
endif

ifeq ($(OPENMACRO),LINUX)
CROSS   =
endif

ifeq ($(OPENMACRO),LINUX64)
CROSS   =
endif

CC	= @echo " GCC	$@"; $(CROSS)gcc
CPP	= @echo " G++	$@"; $(CROSS)g++
LD	= @echo " LD	$@"; $(CROSS)ld
AR	= @echo " AR	$@"; $(CROSS)ar
RM	= @echo " RM	$@"; rm -f
STRIP 	= @echo " STRIP $@"; $(CROSS)strip

TOPDIR = ../
SRCDIR = ./

ifeq ($(OPENMACRO),)
LIBDIR = $(TOPDIR)/lib/HI3531
LDFLAGS += -L$(TOPDIR)/lib
endif

ifeq ($(OPENMACRO),V300)
LIBDIR = $(TOPDIR)/lib/HI3531A
LDFLAGS += -L$(TOPDIR)/lib
endif

ifeq ($(OPENMACRO),V500)
LIBDIR = $(TOPDIR)/lib/HISV500
LDFLAGS += -L$(TOPDIR)/lib
endif

ifeq ($(OPENMACRO),LINUX)
LIBDIR = $(TOPDIR)/lib/LINUX
LDFLAGS += -L$(TOPDIR)/lib
endif

ifeq ($(OPENMACRO),LINUX64)
LIBDIR = $(TOPDIR)/lib/LINUX64
LDFLAGS += -L$(TOPDIR)/lib
CFLAGS  += -DFACE_DETECT
endif

CFLAGS	+= -I$(TOPDIR)/inc/API
CFLAGS  += -Wall -O2 -Os
CFLAGS  += -D_GNU_SOURCE -DLINUX
CFLAGS  += -fomit-frame-pointer
CFLAGS  += -Wstrict-prototypes
AFLAGS	+= -rv

EXTLIBS = $(LIBDIR)/libNetSDK.a	\
		  $(LIBDIR)/libBasic.a	\
		  $(LIBDIR)/libTPLayer.a	\
		  $(LIBDIR)/libStreamParaser.a	\

TEST_OBJS = SDKDemo.o

TEST_TARGET = Test

TARGET	= $(TEST_TARGET)

all: $(TARGET)
	
$(TEST_TARGET): $(TEST_OBJS) $(EXTLIBS)
ifeq ($(OPENMACRO),LINUX)
	$(CPP)  -o $@ $^ -Xlinker "-(" $(EXTLIBS) -lpthread -lc -Xlinker "-)" $(LDFLAGS) -v;
else ifeq ($(OPENMACRO),LINUX64)
	$(CPP)  -o $@ $^ -Xlinker "-(" $(EXTLIBS) -lpthread -lc -Xlinker "-)" $(LDFLAGS) -v;
else
	$(CPP) -static -o $@ $^ $(LDFLAGS) -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lc 	
endif
	$(STRIP)  $(TEST_TARGET)
.c.o:
	$(CC) -c $(CFLAGS) $^ -o $@

.cpp.o:
	$(CPP) -c $(CFLAGS) $^ -o $@

clean:
	$(RM) $(TARGET) $(LIB_OBJS) $(TEST_OBJS);

