ALL: default

##### User configurable options #####
# This is an example Makefile.in (or Makefile configured with mpireconfig)

ARCH        = @ARCH@
COMM        = @COMM@
INSTALL_DIR = @MPIR_HOME@
CC          = @CC@
F77         = @F77@
CLINKER     = @CLINKER@
FLINKER     = @FLINKER@
OPTFLAGS    = @OPTFLAGS@
#
LIB_PATH    = -L$(INSTALL_DIR)/lib/$(ARCH)/$(COMM)
FLIB_PATH   = @FLIB_PATH_LEADER@$(INSTALL_DIR)/lib/$(ARCH)/$(COMM)
LIB_LIST    = @LIB_LIST@
#
INCLUDE_DIR = @INCLUDE_PATH@ -I$(INSTALL_DIR)/include

### End User configurable options ###

CFLAGS  = @CFLAGS@ $(OPTFLAGS) $(INCLUDE_DIR) -DMPI_$(ARCH)
FFLAGS = @FFLAGS@ $(INCLUDE_DIR) $(OPTFLAGS)
LIBS = $(LIB_PATH) $(LIB_LIST)
FLIBS = $(FLIB_PATH) $(LIB_LIST)

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

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

EXECS =  badbuf bsend bsend_free buffer cancel cancel2 cancel3 free getcount interf iprobe isend probe rsend rsend2 sendrecv sendrecv_rep seq ssend start startall test1 test2 test3 testall testany testsome waitall waitany waitnull waitsome wildcard
default: $(EXECS)

badbuf: badbuf.o
	$(CLINKER) $(OPTFLAGS) -o badbuf badbuf.o \
	$(LIB_PATH) $(LIB_LIST) -lm
bsend: bsend.o
	$(CLINKER) $(OPTFLAGS) -o bsend bsend.o \
	$(LIB_PATH) $(LIB_LIST) -lm
bsend_free: bsend_free.o
	$(CLINKER) $(OPTFLAGS) -o bsend_free bsend_free.o \
	$(LIB_PATH) $(LIB_LIST) -lm
buffer: buffer.o
	$(CLINKER) $(OPTFLAGS) -o buffer buffer.o \
	$(LIB_PATH) $(LIB_LIST) -lm
cancel: cancel.o
	$(CLINKER) $(OPTFLAGS) -o cancel cancel.o \
	$(LIB_PATH) $(LIB_LIST) -lm
cancel2: cancel2.o
	$(CLINKER) $(OPTFLAGS) -o cancel2 cancel2.o \
	$(LIB_PATH) $(LIB_LIST) -lm
cancel3: cancel3.o
	$(CLINKER) $(OPTFLAGS) -o cancel3 cancel3.o \
	$(LIB_PATH) $(LIB_LIST) -lm
free: free.o
	$(CLINKER) $(OPTFLAGS) -o free free.o \
	$(LIB_PATH) $(LIB_LIST) -lm
getcount: getcount.o
	$(CLINKER) $(OPTFLAGS) -o getcount getcount.o \
	$(LIB_PATH) $(LIB_LIST) -lm
interf: interf.o
	$(CLINKER) $(OPTFLAGS) -o interf interf.o \
	$(LIB_PATH) $(LIB_LIST) -lm
iprobe: iprobe.o
	$(CLINKER) $(OPTFLAGS) -o iprobe iprobe.o \
	$(LIB_PATH) $(LIB_LIST) -lm
isend: isend.o
	$(CLINKER) $(OPTFLAGS) -o isend isend.o \
	$(LIB_PATH) $(LIB_LIST) -lm
probe: probe.o
	$(CLINKER) $(OPTFLAGS) -o probe probe.o \
	$(LIB_PATH) $(LIB_LIST) -lm
rsend: rsend.o
	$(CLINKER) $(OPTFLAGS) -o rsend rsend.o \
	$(LIB_PATH) $(LIB_LIST) -lm
rsend2: rsend2.o
	$(CLINKER) $(OPTFLAGS) -o rsend2 rsend2.o \
	$(LIB_PATH) $(LIB_LIST) -lm
sendrecv: sendrecv.o
	$(CLINKER) $(OPTFLAGS) -o sendrecv sendrecv.o \
	$(LIB_PATH) $(LIB_LIST) -lm
sendrecv_rep: sendrecv_rep.o
	$(CLINKER) $(OPTFLAGS) -o sendrecv_rep sendrecv_rep.o \
	$(LIB_PATH) $(LIB_LIST) -lm
seq: seq.o
	$(CLINKER) $(OPTFLAGS) -o seq seq.o \
	$(LIB_PATH) $(LIB_LIST) -lm
ssend: ssend.o
	$(CLINKER) $(OPTFLAGS) -o ssend ssend.o \
	$(LIB_PATH) $(LIB_LIST) -lm
start: start.o
	$(CLINKER) $(OPTFLAGS) -o start start.o \
	$(LIB_PATH) $(LIB_LIST) -lm
startall: startall.o
	$(CLINKER) $(OPTFLAGS) -o startall startall.o \
	$(LIB_PATH) $(LIB_LIST) -lm
test1: test1.o
	$(CLINKER) $(OPTFLAGS) -o test1 test1.o \
	$(LIB_PATH) $(LIB_LIST) -lm
test2: test2.o
	$(CLINKER) $(OPTFLAGS) -o test2 test2.o \
	$(LIB_PATH) $(LIB_LIST) -lm
test3: test3.o
	$(CLINKER) $(OPTFLAGS) -o test3 test3.o \
	$(LIB_PATH) $(LIB_LIST) -lm
testall: testall.o
	$(CLINKER) $(OPTFLAGS) -o testall testall.o \
	$(LIB_PATH) $(LIB_LIST) -lm
testany: testany.o
	$(CLINKER) $(OPTFLAGS) -o testany testany.o \
	$(LIB_PATH) $(LIB_LIST) -lm
testsome: testsome.o
	$(CLINKER) $(OPTFLAGS) -o testsome testsome.o \
	$(LIB_PATH) $(LIB_LIST) -lm
waitall: waitall.o
	$(CLINKER) $(OPTFLAGS) -o waitall waitall.o \
	$(LIB_PATH) $(LIB_LIST) -lm
waitany: waitany.o
	$(CLINKER) $(OPTFLAGS) -o waitany waitany.o \
	$(LIB_PATH) $(LIB_LIST) -lm
waitnull: waitnull.o
	$(CLINKER) $(OPTFLAGS) -o waitnull waitnull.o \
	$(LIB_PATH) $(LIB_LIST) -lm
waitsome: waitsome.o
	$(CLINKER) $(OPTFLAGS) -o waitsome waitsome.o \
	$(LIB_PATH) $(LIB_LIST) -lm
wildcard: wildcard.o
	$(CLINKER) $(OPTFLAGS) -o wildcard wildcard.o \
	$(LIB_PATH) $(LIB_LIST) -lm
testing: $(EXECS)
	mpirun -np 2 badbuf
	mpirun -np 2 bsend
	mpirun -np 2 bsend_free
# The buffer test assumes a certain behavior (not mandated by the standard)
# when the buffer space is exhausted.
#	mpirun -np 2 buffer
	mpirun -np 2 cancel
	mpirun -np 2 cancel2
	mpirun -np 2 cancel3
	mpirun -np 2 free
	mpirun -np 2 getcount
	mpirun -np 2 interf
	mpirun -np 2 iprobe
	mpirun -np 2 isend
	mpirun -np 2 probe
	mpirun -np 2 rsend
	mpirun -np 2 rsend2
	mpirun -np 2 sendrecv
	mpirun -np 2 sendrecv_rep
	mpirun -np 2 seq
	mpirun -np 2 ssend
	mpirun -np 2 start
	mpirun -np 2 startall
	mpirun -np 2 test1
	mpirun -np 2 test2
	mpirun -np 2 test3
	mpirun -np 2 testall
	mpirun -np 2 testany
	mpirun -np 2 testsome
	mpirun -np 2 waitall
	mpirun -np 2 waitany
	mpirun -np 2 waitnull
	mpirun -np 2 waitsome
	mpirun -np 2 wildcard
