CXX 	= g++
ROOTCFLAGS = $(shell root-config --cflags)
ROOTLIBS   = $(shell root-config --libs)
ROOTGLIBS  = $(shell root-config --glibs)
#CXXFLAGS = $(shell root-config --cflags) -Wall -O3
CXXFLAGS += -I $(INC) $(ROOTCFLAGS) -D NEW_HEADER_FORMAT
LIBS	= $(ROOTGLIBS) -lm -L/usr/X11R6 -L/usr/lib -L./ 
#LIBS	 = -lm -L/usr/X11R6 -L/usr/lib -L./

INC	= ../include
BINDIR	= ../bin

TARGET 	= run
OBJS	= common.o SiTCP.o comm.o svxconfig.o analyze.o logger.o daq.o util.o main.o

all: ${TARGET}

${TARGET}: ${OBJS}
	@echo "Now make : $@"
	${CXX} ${CXXFLAGS} ${LDFLAGS} -Wall -v -o $@ ${OBJS} ${LIBS}
	@echo "... Compile done! "

.SUFFIXES: .cpp .o

.cpp.o:
	@echo "Start Compiling : $<"
	${CXX} ${CXXFLAGS} -Wall -c $<
	@echo "... Compiling Object Files $< -->done"
	@echo ""

.PHONY: clean

clean:
	@echo "-- Now Clean Up --"
	rm -f *.o *~ $(TARGET)

install:
	@echo "-- Now Installing... --"
	install -m 755 *.o $(BINDIR)/
	install -m 755 run $(BINDIR)/run

main.o:	 $(INC)/svxcommon.h $(INC)/SiTCP.h $(INC)/comm.h $(INC)/svxconfig.h $(INC)/analyze.h $(INC)/logger.h $(INC)/daq.h $(INC)/util.h
common.o:$(INC)/svxcommon.h
util.o:	 $(INC)/svxcommon.h $(INC)/svxconfig.h $(INC)/util.h
SiTCP.o: $(INC)/SiTCP.h
comm.o:	 $(INC)/SiTCP.h $(INC)/comm.h
svxconfig.o:$(INC)/svxcommon.h $(INC)/SiTCP.h $(INC)/comm.h $(INC)/svxconfig.h
analyze.o:$(INC)/svxcommon.h $(INC)/SiTCP.h $(INC)/comm.h $(INC)/svxconfig.h $(INC)/analyze.h
logger.o:$(INC)/svxcommon.h $(INC)/logger.h
daq.o:   $(INC)/svxcommon.h $(INC)/SiTCP.h $(INC)/comm.h $(INC)/svxconfig.h $(INC)/daq.h
