#Variables
include $(SCT_DAQ_ROOT)/build/Makefile.include
#Commands
include $(SCT_DAQ_ROOT)/build/Makefile.commands

SRCS := $(wildcard *.cpp)
OBJS := $(SRCS:.cpp=.o)
BOOSTTESTLIBDIR := $(BOOSTDIR)/libs/test/build/bin/libboost_unit_test_framework.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/threading-multi/
LDLIBS += -L$(BOOSTTESTLIBDIR) -lboost_unit_test_framework 
LDLIBS += -lSctApi -lDSctApiServer

LDFLAGS += `xml2-config --libs`
CPPFLAGS += `xml2-config --cflags`

LD_LIBRARY_PATH:=$(LD_LIBRARY_PATH):$(BOOSTTESTLIBDIR)

#CPPFLAGS += $(ROOTINCLUDES)
#LDLIBS += $(ROOTLIBS)

.PHONY: all c++ test java install clean distclean

all: c++ execute

c++: TestSuite

java:
install:
clean:
	-rm -f *.o TestSuite

distclean: clean
	-rm -f *.d execute

execute: TestSuite $(LibDir)/libDSctApiServer.so /tmp/$(USER)
	env SCT_PERSISTENT_DIR=/tmp/$(USER) ./TestSuite && touch $@

#/tmp/$(USER):
#	$(MKDIR)

TestSuite: $(OBJS)
	$(BINCMD)

gdb	: TestSuite
	env SCT_PERSISTENT_DIR=/tmp gdb TestSuite

valgrind : TestSuite
	env SCT_PERSISTENT_DIR=/tmp valgrind TestSuite

#Patterns
%.o: %.cpp
	$(CPPCMD)


#dependencies
%.d: %.cpp
	$(DEPENDCMD)

ifeq ($(INCLUDEDEPENDANCIES),)
include $(SRCS:.cpp=.d)
endif

# Do preprocessing only
%.P: %.cpp
	g++ $(CPPFLAGS) $(INCLUDES) -o $@ -E $<
