##### User configurable options #####
# This is an example Makefile.in (or Makefile configured with mpireconfig)
# for the programs cpi, pi3, and cpilog.  

ARCH        = @ARCH@
COMM        = @COMM@
INSTALL_DIR = @MPIR_HOME@
CC          = @CC@
F77         = @F77@
CLINKER     = @CLINKER@
FLINKER     = @FLINKER@
OPTFLAGS    = @OPTFLAGS@
#
LIB_PATH    = @LIB_PATH@
FLIB_PATH   = @FLIB_PATH@
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)
EXECS = pi3 cpi cpilog cpilog2

default: cpi pi3

all: $(EXECS)

cpi: cpi.o $(INSTALL_DIR)/include/mpi.h
	$(CLINKER) $(OPTFLAGS) -o cpi cpi.o \
	$(LIB_PATH) $(LIB_LIST) -lm

cpilog: cpilog.o $(INSTALL_DIR)/include/mpi.h $(INSTALL_DIR)/include/mpe.h
	$(CLINKER) $(OPTFLAGS) -o cpilog cpilog.o \
	$(LIB_PATH) -lmpe $(LIB_LIST) -lm

pi3: pi3.o $(INSTALL_DIR)/include/mpif.h
	$(FLINKER) $(OPTFLAGS) -o pi3 pi3.o $(FLIBS)

alternate:
	@echo "Use mpif77 and mpicc to build the programs"
	@echo "Note the use of an explicit path for the mpif77 and mpicc"
	@echo "commands; this allows multiple versions/devices to"
	@echo "coexist."
	$(INSTALL_DIR)/lib/$(ARCH)/$(COMM)/mpif77 -o pi3 pi3.f
	$(INSTALL_DIR)/lib/$(ARCH)/$(COMM)/mpicc -o cpi cpi.c -lm 
	$(INSTALL_DIR)/lib/$(ARCH)/$(COMM)/mpicc -o cpilog2 -mpitrace cpi.c -lm


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

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

