#INCADD = -I/global/homes/a/abuluc \
# 	-I/opt/cray/pmi/1.0-1.0000.7901.22.1.ss/include \
# 	-I/opt/cray/mpt/5.1.0/xt/seastar/mpich2-gnu/include \
# 	-I/opt/cray/mpt/5.1.0/xt/seastar/sma/include \
# 	-I/opt/xt-libsci/10.4.8/gnu/include \
# 	-I/usr/include/alps \
#	-I/opt/gcc/4.5.1/snos/include/g++ -I/opt/gcc/4.5.1/snos/include/g++/x86_64-suse-linux -I/opt/gcc/4.5.1/snos/include/g++/backward \
# 	-I/usr/local/include \
# 	-I/opt/gcc/4.5.1/snos/include \
# 	-I/opt/gcc/4.5.1/snos/lib/gcc/x86_64-suse-linux/4.5.1/include \
# 	-I/opt/gcc/4.5.1/snos/lib/gcc/x86_64-suse-linux/4.5.1/include-fixed \
# 	-I/usr/include

# LIBADD = -L/opt/gcc/4.5.1/snos/lib/gcc/x86_64-suse-linux/4.5.1/../../../

BOOST = $(BOOST_DIR)
INCADD = -I$(BOOST)/include 
# notes for configure:

# -fno-exceptions does not work with MPICH2
# -fno-rtti does not work with tr1:tuples


GCCOPT = -O2 -DMPICH_IGNORE_CXX_SEEK -DGRAPH_GENERATOR_SEQ #-DNDEBUG (disables important assertions)
GCCDEB = -g -fno-inline -DMPICH_IGNORE_CXX_SEEK -DGRAPH_GENERATOR_SEQ #-DDEBUG
OPTPGI = -fast -Mipa=fast,inline -Msmartalloc --zc_eh -DMPICH_IGNORE_CXX_SEEK -DGRAPH_GENERATOR_SEQ 
COMPILER = CC 
GCCFLAGS = $(GCCOPT) -DTIMING 
PGIFLAGS = $(INCADD) $(OPTPGI) -DCOMBBLAS_BOOST
CRAYFLAGS = $(INCADD) -DCOMBBLAS_BOOST -DCRAYCOMP -h msglevel_4
FLAGS = $(GCCFLAGS) -std=c++11 -std=gnu++14 -DTHREADED -fopenmp #-DCOMBBLAS_DEBUG #-DKSELECTLIMIT=40 
COMBBLAS = ..

#
# build Graph500 generator
#
$(COMBBLAS)/graph500-1.2/generator/libgraph_generator_seq.a:
	$(MAKE) -C $(COMBBLAS)/graph500-1.2/generator

mmio.o: ../mmio.c
	cc $(INCADD) $(FLAGS) -c -o mmio.o ../mmio.c

CommGrid.o:	../CommGrid.cpp ../CommGrid.h
	$(COMPILER) $(FLAGS) -c -o CommGrid.o ../CommGrid.cpp 

MPIType.o:	../MPIType.cpp ../MPIType.h
	$(COMPILER) $(FLAGS) -c -o MPIType.o ../MPIType.cpp 

MemoryPool.o:	../MemoryPool.cpp ../SpDefs.h
	$(COMPILER) $(FLAGS) -c -o MemoryPool.o ../MemoryPool.cpp 

hash.o:	../hash.cpp ../hash.hpp
	$(COMPILER) $(FLAGS) $(INCADD) -c -o hash.o ../hash.cpp

BetwCent.o: BetwCent.cpp ../SpDCCols.cpp ../dcsc.cpp ../SpHelper.h ../SpParMat.h ../ParFriends.h ../SpParMat.cpp ../SpDefs.h ../SpTuples.cpp
	$(COMPILER) $(FLAGS) -c -o BetwCent.o BetwCent.cpp

MCL.o:  MCL.cpp CC.h WriteMCLClusters.h ../SpDCCols.cpp ../dcsc.cpp ../SpHelper.h ../SpParMat.h ../ParFriends.h ../SpParMat.cpp ../SpDefs.h ../SpTuples.cpp
	$(COMPILER) $(FLAGS) -c -o MCL.o MCL.cpp

CC.o:  CC.cpp CC.h ../SpDCCols.cpp ../dcsc.cpp ../SpHelper.h ../SpParMat.h ../ParFriends.h ../SpParMat.cpp ../SpDefs.h ../SpTuples.cpp 
	$(COMPILER) $(INCADD) $(FLAGS) -c -o CC.o CC.cpp 

APowers.o:  APowers.cpp ../SpDCCols.cpp ../dcsc.cpp ../SpHelper.h ../SpParMat.h ../ParFriends.h ../SpParMat.cpp ../SpDefs.h ../SpTuples.cpp
	$(COMPILER) $(FLAGS) -c -o APowers.o APowers.cpp

TopDownBFS.o:  TopDownBFS.cpp ../SpDCCols.cpp ../dcsc.cpp ../SpHelper.h ../SpParMat.h ../ParFriends.h ../SpParMat.cpp ../SpDefs.h ../SpTuples.cpp ../SpImpl.h
	$(COMPILER) $(INCADD) $(FLAGS) -c -o TopDownBFS.o TopDownBFS.cpp 

DirOptBFS.o:  DirOptBFS.cpp ../SpDCCols.cpp ../dcsc.cpp ../SpHelper.h ../SpParMat.h ../ParFriends.h ../SpParMat.cpp ../SpDefs.h ../SpTuples.cpp ../SpImpl.h
	$(COMPILER) $(INCADD) $(FLAGS) -c -o DirOptBFS.o DirOptBFS.cpp 

FilteredBFS.o:  FilteredBFS.cpp ../SpDCCols.cpp ../dcsc.cpp ../SpHelper.h ../SpParMat.h ../ParFriends.h ../SpParMat.cpp ../SpDefs.h ../SpTuples.cpp ../SpImpl.h ../SpParHelper.cpp ../Friends.h TwitterEdge.h ../MPIType.h
	$(COMPILER) $(INCADD) $(FLAGS) -c -o FilteredBFS.o FilteredBFS.cpp 

FilteredMIS.o:  FilteredMIS.cpp ../SpDCCols.cpp ../dcsc.cpp ../SpHelper.h ../SpParMat.h ../ParFriends.h ../SpParMat.cpp ../SpDefs.h ../SpTuples.cpp ../SpImpl.h ../SpParHelper.cpp ../Friends.h TwitterEdge.h ../MPIType.h ../FullyDistVec.cpp

	$(COMPILER) $(INCADD) $(FLAGS) -c -o FilteredMIS.o FilteredMIS.cpp

nqp.o:  nqp.cpp ../SpDCCols.cpp ../dcsc.cpp ../SpHelper.h ../SpParMat.h ../ParFriends.h ../SpParMat.cpp ../SpDefs.h ../SpTuples.cpp 
	$(COMPILER) $(FLAGS) -c -o nqp.o nqp.cpp

mcl:	CommGrid.o MPIType.o MCL.o mmio.o hash.o
	$(COMPILER) $(FLAGS) -o mcl MCL.o mmio.o CommGrid.o MPIType.o hash.o

cc:	MemoryPool.o CommGrid.o MPIType.o CC.o mmio.o hash.o
	$(COMPILER) $(FLAGS) -o cc CC.o mmio.o CommGrid.o MPIType.o hash.o

nqp:	CommGrid.o MPIType.o nqp.o
	$(COMPILER) $(FLAGS) -o nqp nqp.o CommGrid.o MPIType.o

apowers:	CommGrid.o MPIType.o APowers.o
	$(COMPILER) $(FLAGS) -o apowers APowers.o CommGrid.o MPIType.o

tdbfs:	CommGrid.o MPIType.o TopDownBFS.o $(COMBBLAS)/graph500-1.2/generator/libgraph_generator_seq.a
	$(COMPILER) $(INCADD) $(FLAGS) -o tdbfs TopDownBFS.o CommGrid.o MPIType.o -L$(COMBBLAS)/graph500-1.2/generator -lgraph_generator_seq 

dobfs:	CommGrid.o MPIType.o DirOptBFS.o $(COMBBLAS)/graph500-1.2/generator/libgraph_generator_seq.a
	$(COMPILER) $(INCADD) $(FLAGS) -o dobfs DirOptBFS.o CommGrid.o MPIType.o -L$(COMBBLAS)/graph500-1.2/generator -lgraph_generator_seq 

betwcent: CommGrid.o MPIType.o BetwCent.o
	$(COMPILER) $(INCADD) $(FLAGS) -o betwcent BetwCent.o CommGrid.o MPIType.o 

fbfs:	CommGrid.o MPIType.o FilteredBFS.o $(COMBBLAS)/graph500-1.2/generator/libgraph_generator_seq.a
	$(COMPILER) $(INCADD) $(FLAGS) -o fbfs FilteredBFS.o CommGrid.o MPIType.o -L$(COMBBLAS)/graph500-1.2/generator -lgraph_generator_seq

fmis:	CommGrid.o MPIType.o FilteredMIS.o $(COMBBLAS)/graph500-1.2/generator/libgraph_generator_seq.a
	$(COMPILER) $(INCADD) $(FLAGS) -o fmis FilteredMIS.o CommGrid.o MPIType.o -L$(COMBBLAS)/graph500-1.2/generator -lgraph_generator_seq


BPMaximalMatching.o:  BPMaximalMatching.cpp ../SpDCCols.cpp ../dcsc.cpp ../SpHelper.h ../SpParMat.h ../ParFriends.h ../SpParMat.cpp ../SpDefs.h ../SpTuples.cpp ../SpImpl.h
	$(COMPILER) $(FLAGS) -c -o BPMaximalMatching.o BPMaximalMatching.cpp 


BPMaximalMatching: CommGrid.o MPIType.o BPMaximalMatching.o $(COMBBLAS)/graph500-1.2/generator/libgraph_generator_seq.a
	$(COMPILER) $(FLAGS) -o BPMaximalMatching BPMaximalMatching.o CommGrid.o MPIType.o -L$(COMBBLAS)/graph500-1.2/generator -lgraph_generator_seq


BPMaximumMatching.o:  BPMaximumMatching.cpp BPMaximalMatching.h ../SpDCCols.cpp ../dcsc.cpp ../SpHelper.h ../SpParMat.h ../ParFriends.h ../SpParMat.cpp ../SpDefs.h ../SpTuples.cpp ../SpImpl.h
	$(COMPILER) $(INCADD) $(FLAGS) -c -o BPMaximumMatching.o BPMaximumMatching.cpp 


bpmm:	CommGrid.o MPIType.o BPMaximumMatching.o mmio.o $(COMBBLAS)/graph500-1.2/generator/libgraph_generator_seq.a
	$(COMPILER) $(INCADD) $(FLAGS) -o bpmm BPMaximumMatching.o CommGrid.o mmio.o MPIType.o -L$(COMBBLAS)/graph500-1.2/generator -lgraph_generator_seq 

clean:
	rm -f betwcent
	rm -f driver
	rm -f mcl
	rm -f fbfs
	rm -f fmis
	rm -f apowers
	rm -f dobfs
	rm -f tdbfs
	rm -f BPMaximumMatching
	rm -f *.o
	rm -f ../graph500-1.2/generator/*.o
	rm -f ../graph500-1.2/generator/libgraph_generator_seq.a

cleanout:
	rm out.*
	rm err.*
