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

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

### 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 = 
EXECS = attrtest attrt ictest ictest2 ictest3 grouptest

default: $(EXECS)

fortran_tests: attrtest

#
# Note that runtests builds the executables as required
testing: 
	-./runtests $(TESTARGS)

linktest: default clean

all: testing

attrtest: mpif.h attrtest.o
	$(FLINKER) $(OPTFLAGS) -o attrtest attrtest.o $(FLIBS)

attrt: attrt.o test.o
	$(CLINKER) $(OPTFLAGS) -o attrt attrt.o test.o $(LIBS)

ictest: ictest.o
	$(CLINKER) $(OPTFLAGS) -o ictest ictest.o $(LIBS)
ictest2: ictest2.o
	$(CLINKER) $(OPTFLAGS) -o ictest2 ictest2.o $(LIBS)
ictest3: ictest3.o
	$(CLINKER) $(OPTFLAGS) -o ictest3 ictest3.o $(LIBS)
grouptest: grouptest.o
	$(CLINKER) $(OPTFLAGS) -o grouptest grouptest.o $(LIBS)

mpif.h: $(MPIR_HOME)/include/mpif.h
	if test \! -f mpif.h ; then \
	    /bin/rm -f mpif.h ; \
	    ln -s $(MPIR_HOME)/include/mpif.h . ; \
	fi

clean:
	/bin/rm -f *.o *~ PI* $(EXECS) core *.out context.diff

.c.o:
	$(CC) $(CFLAGS) -c $*.c
.f.o:
	$(F77) $(FFLAGS) -c $*.f
