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

Package=AnalysisService

#Lists of source files
HDRS := $(wildcard *.h)
SRCS := $(wildcard *.cpp)
IDLS := $(wildcard *.idl)
IDLFLAGS :=  $(IDLS:.idl=.cppidl)
OBJS := $(SRCS:.cpp=.o)
BINS := AnalysisService

#Flags
CPPFLAGS += $(ROOTINCLUDES)

# note that the rootlibs were removed since they cause problems with exception handling.
LDLIBS += -lSctData -lSct -lSctFitter -lSummaryWriter $(ROOTLIBS) -lboost_thread

#Phony Targets
.PHONY: all c++ java install clean install_bin distclean idls test

all: c++ java
c++: idls compile

idls: $(IDLFLAGS) install_idl 
	$(MAKE) compile

java: install_idl
compile: $(BINS) install
install: $(IncludeDir) install_bin install_idl
distclean: clean
	-rm -f *.cc *.hh *.cppidl *.d
clean:
	-rm -f *.o $(BINS)
#make -C test clean

install_bin: $(BinDir)/AnalysisService
install_idl: $(IncludeDir)/$(Package) $(addprefix $(IncludeDir)/$(Package)/,$(IDLS))

#Real targets
AnalysisService: $(OBJS) AnalysisServiceI-server-stubs.o AnalysisServiceI.o
	$(BINCMD)

test:
	make -C test

AnalysisAlgorithm.o:

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

%.o: %.cc
	$(CPPCMD)

%.cppidl: $(CURDIR)/%.idl
	@echo $^
	$(CPPIDLCMD) && touch $@

$(BinDir)/%: %
	$(CPCMD)

$(IncludeDir)/$(Package)/%: %
	$(CPCMD)

#Pre-requisites
$(IncludeDir)/$(Package):
	$(MKDIR)

#dependencies
$(BINS): $(DEPENDLIBCMD)

%.d: %.cpp
	$(DEPENDCMD)

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

