MPICXX=mpicxx
CXX=$(MPICXX)

LIBPGT_CFLAGS=-I/home/timos/Work/libpgt -DHAVE_PGT
LIBPGT_LIBS=-L/home/timos/Work/libpgt -lpgt -lpapi


CFLAGS=-O0 -g3 -DTRAN_MPI -I. #$(LIBPGT_CFLAGS)
CXXFLAGS=-O0 -g3 -DTRAN_MPI -I.# $(LIBPGT_CFLAGS)
LIBS=$(LIBPGT_LIBS)

#CFLAGS=-DTRAN_OF
#LIBS=../of/.libs/libof.a ../libdict/.libs/libdict.a -libverbs 

all: libcDAG.a ring

libcDAG.tgz: libcDAG.a ring
	mkdir libcDAG
	cp Makefile cDAG.cpp *hpp cDAG_Scheduler.cpp ring.cpp cDAG_Graph.cpp collective_detection.cpp Matcher.cpp Matcher.hpp HtorSets.hpp DataFlow.cpp DataFlow.hpp DetectCollectives.cpp fortran_wrappers.cpp libcDAG
	tar czf libcDAG.tgz libcDAG
	
libcDAG.a: cDAG_Graph.o cDAG_Scheduler.o cDAG.o Matcher.o collective_detection.o DataFlow.o DetectCollectives.o fortran_wrappers.o
	 ar r $@ cDAG_Graph.o cDAG_Scheduler.o cDAG.o Matcher.o collective_detection.o DataFlow.o DetectCollectives.o fortran_wrappers.o
	 ranlib $@

cDAG_Graph.o: cDAG_Graph.cpp *hpp
	$(MPICXX) $(CFLAGS) -c $< -o $@

cDAG.o: cDAG.cpp *hpp
	$(MPICXX) $(CFLAGS) -c $< -o $@

ng_sync.o: ng_sync.c ng_sync.h
	$(MPICXX) $(CFLAGS) -c $< -o $@

cDAG_Scheduler.o: cDAG_Scheduler.cpp *hpp
	$(MPICXX) $(CFLAGS) -c $< -o $@

collective_detection.o: collective_detection.cpp *hpp
	$(MPICXX) $(CFLAGS) -c $< -o $@

Matcher.o: Matcher.cpp *hpp
	$(MPICXX) $(CFLAGS) -c $< -o $@

DataFlow.o: DataFlow.cpp *hpp
	$(MPICXX) $(CFLAGS) -c $< -o $@

DetectCollectives.o: DetectCollectives.cpp *hpp
	$(MPICXX) $(CFLAGS) -c $< -o $@

fortran_wrappers.o: fortran_wrappers.cpp *hpp
	$(MPICXX) $(CFLAGS) -c $< -o $@

ring: ring.cpp libcDAG.a 
	$(MPICXX) $(CFLAGS) $< -o $@ -L. -lcDAG $(LIBS)

../of/.libs/libof.a: 
	 make -C ../of .libs/libof.a

../of/.libs/libdict.a: 
	make -C ../libdict

clean:
	rm -f libcDAG.a ring binomial *.o

realclean:
	make clean
	rm -f stamp-h1
	rm -f missing
	rm -f config.h
	rm -f configure
	rm -f aclocal.m4
	rm -f config.log
	rm -f config.sub
	rm -f install-sh
	rm -f config.h.in
	rm -f config.guess
	rm -f autoscan.log
	rm -f config.status
	rm -rf autom4te.cache

