ALL: default
##### User configurable options #####

MPIR_HOME   = @MPIR_HOME@
CC          = @MPICC@
CLINKER     = @MPICC@
CCC         = @MPICPLUSPLUS@
CCLINKER    = $(CCC)
F77         = @MPIF77@
FLINKER     = @MPIF77@
OPTFLAGS    = @OPTFLAGS@
MAKE        = @MAKE@

### End User configurable options ###

SHELL = /bin/sh

PROFLIB =
CFLAGS  = $(OPTFLAGS) 
CCFLAGS = $(CFLAGS)
FFLAGS = $(OPTFLAGS)
# Use LIBS to add any special libraries for C programs
LIBS = 
# Use FLIBS to add any special libraries for Fortran programs
FLIBS = 
TESTDIRS = pt2pt coll topol env context profile
SUBDIRS = pt2pt coll topol env context profile

default: subdirs
	@echo "Type \"make testing\" to compile and run tests"

subdirs:
	@for dir in $(SUBDIRS) ;\
		do \
			echo " " ;\
			echo Making in directory $$dir ;\
			(cd $$dir; $(MAKE)) ;\
		done

linktest:
	@for dir in $(SUBDIRS) ;\
		do \
			echo " " ;\
			echo Making linktest in directory $$dir ;\
			(cd $$dir; $(MAKE) linktest) ;\
		done

#
# This also cleans the files after the testing to keep the
# total size down.  You can use TESTARGS to pass arguments to the
# test program; for example, 
# make TESTARGS="-small"
# to run in "small" mode (build executable, run, remove executable)
testing: $(MPIR_HOME)/util/mpirun
	@-for dir in $(TESTDIRS) ;\
		do \
			echo " " ;\
			echo Making testing in directory $$dir ;\
			(cd $$dir; $(MAKE) testing TESTARGS="$(TESTARGS)" ; \
	                 $(MAKE) clean ) ;\
		done

#
# This is a version of testing, but it saves the "diff" files in the top 
# level directory
testing_save: $(MPIR_HOME)/util/mpirun
	@-for dir in $(TESTDIRS) ;\
		do \
			echo " " ;\
			echo Making testing in directory $$dir ;\
			(cd $$dir; $(MAKE) testing TESTARGS="$(TESTARGS)" ; \
	                 if [ -s $$dir.diff ] ; then cp $$dir.diff .. ; fi ; \
	    		 $(MAKE) clean ) ;\
		done

clean:
	/bin/rm -f test.log *.diff sendchar.sun4 sendchar.freebsd \
		sendshort.sun4 sendshort.freebsd *.o \
		sendvector.sun4 sendvector.freebsd \
		sendstruct.sun4 sendstruct.freebsd \
	        sendchar sendshort sendvector sendstruct
	@for dir in $(SUBDIRS) ;\
		do \
			echo " " ;\
			echo Making clean in directory $$dir ;\
			(cd $$dir; $(MAKE) clean) ;\
		done

# MPICH specific
#$(MPIR_HOME)/util/mpirun:
#	(cd $(MPIR_HOME) ; $(MAKE) mpirun )
