COMBBLAS = ../../
COMBBLAS_INC = $(COMBBLAS)/include/CombBLAS
COMBBLAS_SRC = $(COMBBLAS)/src
INCADD = -I$(COMBBLAS)/include/ -I$(COMBBLAS)/psort-1.0/include/ -I$(COMBBLAS)/usort/include/ -I$(COMBBLAS)/graph500-1.2/generator/include/ 

OPT = -O2 -DMPICH_IGNORE_CXX_SEEK -DGRAPH_GENERATOR_SEQ -Wreturn-type #-DNDEBUG (disables important assertions)
DEB = -g -O0 -fno-inline -DMPICH_IGNORE_CXX_SEEK -DGRAPH_GENERATOR_SEQ -Wreturn-type -DDEBUG 
PROF = -pg -O2 -fno-inline -DMPICH_IGNORE_CXX_SEEK -DGRAPH_GENERATOR_SEQ -Wreturn-type
CXXCOMP = mpicxx -cxx=clang++
CXXFLAG = -std=c++11 -std=c++14 -DTHREADED -fopenmp  -fpermissive  
CCOMP = mpicc -cc=clang
FLAGS = $(DEB) -fsanitize=address #$(OPT) -Wall -Wno-maybe-uninitialized #-DGNU_PARALLEL -DTIMING #-DCOMBBLAS_DEBUG 


hash.o:	$(COMBBLAS_SRC)/hash.cpp $(COMBBLAS_INC)/hash.hpp
	$(CXXCOMP) $(CXXFLAG) $(FLAGS) $(INCADD) -c -o hash.o $(COMBBLAS_SRC)/hash.cpp

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

MPIType.o:	$(COMBBLAS_SRC)/MPIType.cpp $(COMBBLAS_INC)/MPIType.h
	$(CXXCOMP) $(CXXFLAG) $(INCADD) $(FLAGS) -c -o MPIType.o $(COMBBLAS_SRC)/MPIType.cpp 

CommGrid.o:	$(COMBBLAS_SRC)/CommGrid.cpp $(COMBBLAS_INC)/CommGrid.h
	$(CXXCOMP) $(CXXFLAG) $(INCADD) $(FLAGS) -c -o CommGrid.o $(COMBBLAS_SRC)/CommGrid.cpp 

MemoryPool.o:	$(COMBBLAS_SRC)/MemoryPool.cpp $(COMBBLAS_INC)/SpDefs.h
	$(CXXCOMP) $(CXXFLAG) $(INCADD) $(FLAGS) -c -o MemoryPool.o $(COMBBLAS_SRC)/MemoryPool.cpp 

SpGEMM3D.o:  SpGEMM3D.cpp $(COMBBLAS_INC)/SpDCCols.cpp $(COMBBLAS_INC)/dcsc.cpp $(COMBBLAS_INC)/SpHelper.h $(COMBBLAS_INC)/SpParMat.h $(COMBBLAS_INC)/ParFriends.h $(COMBBLAS_INC)/SpParMat.cpp $(COMBBLAS_INC)/SpDefs.h $(COMBBLAS_INC)/SpTuples.cpp $(COMBBLAS_INC)/CommGrid3D.h $(COMBBLAS_INC)/SpParMat3D.h $(COMBBLAS_INC)/SpParMat3D.cpp
	$(CXXCOMP) $(CXXFLAG) $(INCADD) $(FLAGS) -c -o SpGEMM3D.o SpGEMM3D.cpp

SpGEMM3D:	SpGEMM3D.o MemoryPool.o CommGrid.o MPIType.o mmio.o hash.o 
	$(CXXCOMP) $(CXXFLAG) $(INCADD) $(FLAGS) -o SpGEMM3D SpGEMM3D.o MemoryPool.o mmio.o CommGrid.o MPIType.o hash.o


SegTest.o:  SegTest.cpp $(COMBBLAS_INC)/SpDCCols.cpp $(COMBBLAS_INC)/dcsc.cpp $(COMBBLAS_INC)/SpHelper.h $(COMBBLAS_INC)/SpParMat.h $(COMBBLAS_INC)/ParFriends.h $(COMBBLAS_INC)/SpParMat.cpp $(COMBBLAS_INC)/SpDefs.h $(COMBBLAS_INC)/SpTuples.cpp
	$(CXXCOMP) $(CXXFLAG) $(INCADD) $(FLAGS) -c -o SegTest.o SegTest.cpp

segtest:	CommGrid.o MPIType.o SegTest.o
	$(CXXCOMP) $(CXXFLAG) $(INCADD) $(FLAGS)  -o segtest SegTest.o CommGrid.o MPIType.o


clean:
	rm -f segtest
	rm -f *.o
	rm -f $(COMBBLAS)/graph500-1.2/generator/*.o
	rm -f $(COMBBLAS)/graph500-1.2/generator/libgraph_generator_seq.a
	rm -f SpGEMM3D
