# First to include the conf info depending on the compilers we need etc
# i.e. all options starting with IC_

include ../../../conf/system/makeopts-SNIPE_LITE

# For any arch type options
# i.e. anything else like, IMA_ARCH, system call flags etc

include ../../../conf/system/makeopts-$(HARNESS_ARCH)

#
# The rest should now be a little puddie kat.
#

# Final build options conf file.
# Yep, how many do we need :)

include ../../../conf/makeopts-HARNESS


MPI_OPTS =-I$(HARNESS_ROOT)/include
COMPILE_OPT = $(INTER_OPTS) $(BUILD_OPTS) $(MPI_OPTS) 


###########################################################################
#			C++ tests
###########################################################################

exes = 	$(bindir)/hello_world \
	$(bindir)/pi \
	$(bindir)/topology \
	$(bindir)/user_bcast \
	$(bindir)/chapter_10_mpi2

###########################################################################

# Now for the compilation directories

include ../../../conf/system/makeopts-dirs

###########################################################################

default: $(objdir) $(bindir) $(libdir)\
	$(exes) $(fexes)

all: $(objdir) $(bindir) $(libdir)\
	$(exes) $(fexes)

###########################################################################

LIBS = $(SL_LIBS) -lm

###########################################################################

HDRS = ../../../include/mpi.h ../../../include/mpi++.h 
FHDRS = ../../../include/mpif.h 


###########################################################################

$(objdir) : 
	mkdir $(objdir)

$(bindir) : 
	mkdir $(bindir)

$(libdir) : 
	mkdir $(libdir)

###########################################################################

###########################################################################
#		C++ tests
###########################################################################

$(bindir)/hello_world : hello_world.cc $(libdir)/libftmpi.a $(libdir)/libftmpi++.a $(HDRS)
	$(CCC) $(CCFLAGS) $(COMPILE_OPT) hello_world.cc -o $(objdir)/hello_world  -L$(libdir) \
	-lftmpi++ -lftmpi $(LIBS) 
	mv $(objdir)/hello_world  $(bindir)


$(bindir)/pi : pi.cc $(libdir)/libftmpi.a $(libdir)/libftmpi++.a $(HDRS)
	$(CCC) $(CCFLAGS) $(COMPILE_OPT) pi.cc -o $(objdir)/pi  -L$(libdir) \
	-lftmpi++ -lftmpi $(LIBS) 
	mv $(objdir)/pi  $(bindir)

$(bindir)/topology : topology.cc $(libdir)/libftmpi.a $(libdir)/libftmpi++.a $(HDRS)
	$(CCC) $(CCFLAGS) $(COMPILE_OPT) topology.cc -o $(objdir)/topology  -L$(libdir) \
	-lftmpi++ -lftmpi $(LIBS) 
	mv $(objdir)/topology  $(bindir)

$(bindir)/user_bcast : user_bcast.cc $(libdir)/libftmpi.a $(libdir)/libftmpi++.a $(HDRS)
	$(CCC) $(CCFLAGS) $(COMPILE_OPT) user_bcast.cc -o $(objdir)/user_bcast  -L$(libdir) \
	-lftmpi++ -lftmpi $(LIBS) 
	mv $(objdir)/user_bcast  $(bindir)

$(bindir)/chapter_10_mpi2 : chapter_10_mpi2.cc $(libdir)/libftmpi.a $(libdir)/libftmpi++.a $(HDRS)
	$(CCC) $(CCFLAGS) $(COMPILE_OPT) chapter_10_mpi2.cc -o $(objdir)/chapter_10_mpi2  -L$(libdir) \
	-lftmpi++ -lftmpi $(LIBS) 
	mv $(objdir)/chapter_10_mpi2  $(bindir)

###########################################################################
#		Misc	
###########################################################################

clean :
	rm -f $(objdir)/*
	rm -f $(bindir)/pi $(bindir)/hello_world $(bindir)/topology
	rm -f $(bindir)/user_bcast $(bindir)/chapter_10_mpi2
