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

SHELL       = /bin/sh
ARCH        = @ARCH@
COMM        = @COMM@
MPIR_HOME   = @MPIR_HOME@
CC          = @MPIR_HOME@/lib/@ARCH@/@COMM@/mpicc
CLINKER     = $(CC)
F77         = @MPIR_HOME@/lib/@ARCH@/@COMM@/mpif77
FLINKER     = $(F77)
CCC         = @MPIR_HOME@/lib/@ARCH@/@COMM@/mpiCC
CCLINKER    = $(CCC)
AR          = @AR@
RANLIB      = @RANLIB@
PROFILING   = $(PMPILIB)
OPTFLAGS    = @OPTFLAGS@
MPE_LIBS    = @MPE_LIBS@
MPE_DIR     = @MPE_DIR@
MPE_GRAPH   = @MPE_GRAPHICS@
#

### End User configurable options ###

CFLAGS	  = $(OPTFLAGS) 
CFLAGSMPE = $(CFLAGS) -I$(MPE_DIR) $(MPE_GRAPH)
CCFLAGS	  = $(CFLAGS)
#FFLAGS	  = '-qdpc=e' 
FFLAGS	  = $(OPTFLAGS)
EXECS	  = cpi systest fpi cpilog srtest

default: $(EXECS)

all: default

fpi: fpi.o $(MPIR_HOME)/include/mpif.h
	$(FLINKER) $(OPTFLAGS) -o fpi fpi.o

cpi: cpi.o $(MPIR_HOME)/include/mpir.h
	$(CLINKER) $(OPTFLAGS) -o cpi cpi.o -lm

cpilog: cpilog.o $(MPIR_HOME)/include/mpir.h
	$(CLINKER) $(OPTFLAGS) -o cpilog cpilog.o -lmpe -lpmpi -lm

srtest: srtest.o $(MPIR_HOME)/include/mpir.h
	$(CLINKER) $(OPTFLAGS) -o srtest srtest.o -lm

systest: systest.o $(MPIR_HOME)/include/mpir.h
	$(CLINKER) $(OPTFLAGS) -o systest systest.o -lm

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

cpilog.o: cpilog.c
	@if test -z "$(MPE_DIR)" ; then \
	    echo "Can only build cpilog if MPE libraries built" ; \
	    echo "Use -mpe to configure to have the MPE libraries built" ; \
	    exit 1 ; \
	fi
	$(CC) $(CFLAGSMPE) -c cpilog.c
.c.o:
	$(CC) $(CFLAGS) -c $*.c
.f.o:
	$(F77) $(FFLAGS) -c $*.f

