# C++ compiler
CXX := mpicxx
CXXFLAGS := -std=c++11 -O2 -DNDEBUG -fopenmp #-DDEBUG 

# C compiler
CC := mpicc
CFLAGS := -O2

COMBBLAS = ..

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

%.o : %.c 
	$(CC) $(CFLAGS) -o $@ -c $<

%.o : %.cpp 
	$(CXX) $(CXXFLAGS) -o $@ -c $<

%.o : %.cxx 
	$(CXX) $(CXXFLAGS) -o $@ -c $<


all: mpipspgemm test_mpipspgemm RestrictionOp

clean:
	rm -rf mpipspgemm
	rm -f *.o
	rm -rf ../*.o
	rm -f ../graph500-1.2/generator/*.o
	rm -f ../graph500-1.2/generator/libgraph_generator_seq.a

SUMMALayer.o: SUMMALayer.cpp mtSpGEMM.o
	$(CXX) $(CXXFLAGS) -o $@ -c $<

mpipspgemm: mpipspgemm.o SplitMatDist.h Reductions.h  SUMMALayer.h $(COMBBLAS)/MPIType.o $(COMBBLAS)/graph500-1.2/generator/libgraph_generator_seq.a $(COMBBLAS)/CommGrid.o $(COMBBLAS)/mmio.o 
	$(CXX) $(CXXFLAGS) -o $@ $^ -L$(COMBBLAS)/graph500-1.2/generator -lgraph_generator_seq


test_mpipspgemm: test_mpipspgemm.o SplitMatDist.h Reductions.h SUMMALayer.h $(COMBBLAS)/MPIType.o $(COMBBLAS)/graph500-1.2/generator/libgraph_generator_seq.a $(COMBBLAS)/CommGrid.o $(COMBBLAS)/mmio.o
	$(CXX) $(CXXFLAGS) -o $@ $^ -L$(COMBBLAS)/graph500-1.2/generator -lgraph_generator_seq

RestrictionOp: RestrictionOp.o SplitMatDist.h Reductions.h SUMMALayer.h $(COMBBLAS)/MPIType.o $(COMBBLAS)/graph500-1.2/generator/libgraph_generator_seq.a $(COMBBLAS)/CommGrid.o $(COMBBLAS)/mmio.o 
	$(CXX) $(CXXFLAGS) -o $@ $^ -L$(COMBBLAS)/graph500-1.2/generator -lgraph_generator_seq 
