ALL: default

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

ARCH        = @ARCH@
COMM        = @COMM@
#INSTALL_DIR = @INSTALL_DIR@
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 =  allgather allreduce alltoall barrier bcast bcast_struct gather op reduce reduce_scatter scan scatter struct_gatherv
default: $(EXECS)

allgather: allgather.o
	$(CLINKER) $(OPTFLAGS) -o allgather allgather.o \
	$(LIB_PATH) $(LIB_LIST) -lm
allreduce: allreduce.o
	$(CLINKER) $(OPTFLAGS) -o allreduce allreduce.o \
	$(LIB_PATH) $(LIB_LIST) -lm
alltoall: alltoall.o
	$(CLINKER) $(OPTFLAGS) -o alltoall alltoall.o \
	$(LIB_PATH) $(LIB_LIST) -lm
barrier: barrier.o
	$(CLINKER) $(OPTFLAGS) -o barrier barrier.o \
	$(LIB_PATH) $(LIB_LIST) -lm
bcast: bcast.o
	$(CLINKER) $(OPTFLAGS) -o bcast bcast.o \
	$(LIB_PATH) $(LIB_LIST) -lm
bcast_struct: bcast_struct.o
	$(CLINKER) $(OPTFLAGS) -o bcast_struct bcast_struct.o \
	$(LIB_PATH) $(LIB_LIST) -lm
gather: gather.o
	$(CLINKER) $(OPTFLAGS) -o gather gather.o \
	$(LIB_PATH) $(LIB_LIST) -lm
op: op.o
	$(CLINKER) $(OPTFLAGS) -o op op.o \
	$(LIB_PATH) $(LIB_LIST) -lm
reduce: reduce.o
	$(CLINKER) $(OPTFLAGS) -o reduce reduce.o \
	$(LIB_PATH) $(LIB_LIST) -lm
reduce_scatter: reduce_scatter.o
	$(CLINKER) $(OPTFLAGS) -o reduce_scatter reduce_scatter.o \
	$(LIB_PATH) $(LIB_LIST) -lm
scan: scan.o
	$(CLINKER) $(OPTFLAGS) -o scan scan.o \
	$(LIB_PATH) $(LIB_LIST) -lm
scatter: scatter.o
	$(CLINKER) $(OPTFLAGS) -o scatter scatter.o \
	$(LIB_PATH) $(LIB_LIST) -lm
struct_gatherv: struct_gatherv.o
	$(CLINKER) $(OPTFLAGS) -o struct_gatherv struct_gatherv.o \
	$(LIB_PATH) $(LIB_LIST) -lm
testing: $(EXECS)
	mpirun -np 2 allgather
	mpirun -np 2 allreduce
	mpirun -np 2 alltoall
	mpirun -np 2 barrier
	mpirun -np 2 bcast
	mpirun -np 2 bcast_struct
	mpirun -np 2 gather
	mpirun -np 2 op
	mpirun -np 2 reduce
	mpirun -np 2 reduce_scatter
	mpirun -np 2 scan
	mpirun -np 2 scatter
	mpirun -np 2 struct_gatherv
