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

#Lists of source files
HDRS := $(wildcard *.h)
IOHDRS :=  $(wildcard IO/*.h)
SRCS := $(wildcard *.cpp)
IOSRCS := $(wildcard IO/*.cpp)
OBJS := $(SRCS:.cpp=.o)
IOOBJS := $(IOSRCS:.cpp=.o)

#Flags

CPPFLAGS += $(ROOTINCLUDES)
LDLIBS += $(ROOTLIBS) -lboost_date_time -lboost_thread -lSct

#Phony Targets
.PHONY: all c++ java install clean install_lib install_headers distclean IO

all: c++

c++: $(OBJS) IO libSctData.so install

#Do nothing
java:

IO:
	$(MAKE) -C IO

install: install_lib install_headers

distclean: clean
	-rm -f *.d

clean:
	$(MAKE) -C IO $(MAKECMDGOALS)
	-rm -f *.o libSctData.so

install_lib: $(LibDir)/libSctData.so

install_headers: $(IncludeDir)/SctData $(addprefix $(IncludeDir)/SctData/,$(HDRS))

#Real targets
libSctData.so: $(OBJS) $(IOOBJS)
	$(LIBCMD)

$(LibDir)/libSctData.so: libSctData.so
	$(CPCMD)

$(IncludeDir)/SctData/%.h: %.h
	$(CPCMD)

$(IncludeDir)/SctData:
	$(MKDIR)	

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


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

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

