ALL: oned twod onedsync onedsandr onednb onedpair
##### User configurable options #####

ARCH        = @ARCH@
COMM        = @COMM@
BOPT        = @BOPT@
P4_DIR      = @P4_DIR@
TOOLS_DIR   = @TOOLS_DIR@
MPIR_HOME   = @MPIR_HOME@
CC          = @CC@
CLINKER     = @CLINKER@
CCC         = @CPP_COMPILER@
CCLINKER    = $(CCC)
F77         = @F77@
FLINKER     = @FLINKER@
AR          = @AR@
RANLIB      = @RANLIB@
PROFILING   = $(PMPILIB)
OPTFLAGS    = @OPTFLAGS@
LIB_PATH    = @LIB_PATH@
FLIB_PATH   = @FLIB_PATH@
LIB_LIST    = @LIB_LIST@
#
INCLUDE_DIR = @USER_INCLUDE_PATH@ -I$(MPIR_HOME)/include 
DEVICE      = @DEVICE@

### End User configurable options ###

CFLAGS  = @USER_CFLAGS@ $(OPTFLAGS) $(INCLUDE_DIR) -DMPI_$(ARCH)
CCFLAGS = $(CFLAGS)
FFLAGS = @FFLAGS@ $(OPTFLAGS)
MPILIB = $(MPIR_HOME)/lib/$(ARCH)/$(COMM)/libmpi.a 
MPIPPLIB = $(MPIR_HOME)/lib/$(ARCH)/$(COMM)/libmpi++.a
LIBS = $(LIB_PATH) $(LIB_LIST)
FLIBS = $(FLIB_PATH) $(LIB_LIST)
LIBSPP = $(MPIPPLIB) $(LIBS)
EXECS = oned onedsync onedsandr onedpair onednb twod \
	onedpr onedsyncpr onedsandrpr onedpairpr onednbpr twodpr
        
PROFLIBS = $(LIBDIR)/mpe_proff.o $(LIBDIR)/mpe_prof.o $(LIBDIR)/libmpe.a \
	   $(LIBDIR)/libmpi.a \
	   $(LIBDIR)/libpmpi.a $(LIBDIR)/libmpi.a $(DEVICE_LIB)

default: oned twod

oned: oned.o sweep.o exchng1.o diff.o onedbase.o decomp.o
	$(FLINKER) $(FFLAGS) -o oned  $(DEVICE_MAINF) \
		oned.o sweep.o exchng1.o \
		diff.o onedbase.o decomp.o $(LIBS)
	if [ ! -x oned ] ; then /bin/rm -f oned ; fi
onedsync: oned.o sweep.o exsync1d.o diff.o onedbase.o decomp.o
	$(FLINKER) $(FFLAGS) -o onedsync  $(DEVICE_MAINF) \
		oned.o sweep.o exsync1d.o \
		diff.o onedbase.o decomp.o $(LIBS)
	if [ ! -x onedsync ] ; then /bin/rm -f onedsync ; fi
onedsandr: oned.o sweep.o exsandr1d.o diff.o onedbase.o decomp.o
	$(FLINKER) $(FFLAGS) -o onedsandr  $(DEVICE_MAINF) oned.o sweep.o \
		exsandr1d.o diff.o onedbase.o decomp.o $(LIBS)
	if [ ! -x onedsandr ] ; then /bin/rm -f onedsandr ; fi
onedpair: oned.o sweep.o expair1d.o diff.o onedbase.o decomp.o
	$(FLINKER) $(FFLAGS) -o onedpair  $(DEVICE_MAINF) \
		oned.o sweep.o expair1d.o \
		diff.o onedbase.o decomp.o $(LIBS)
	if [ ! -x onedpair ] ; then /bin/rm -f onedpair ; fi
onednb: oned.o sweep.o exchng1nb.o diff.o onedbase.o decomp.o
	$(FLINKER) $(FFLAGS) -o onednb  $(DEVICE_MAINF) \
		oned.o sweep.o exchng1nb.o \
		diff.o onedbase.o decomp.o $(LIBS)
	if [ ! -x onednb ] ; then /bin/rm -f onednb ; fi
onedovlp: onednb.o nbsweep.o nbexchng.o diff.o onedbase.o decomp.o
	$(FLINKER) $(FFLAGS) -o onedovlp  $(DEVICE_MAINF) \
		onednb.o nbsweep.o nbexchng.o \
		diff.o onedbase.o decomp.o $(LIBS)
	if [ ! -x onedovlp ] ; then /bin/rm -f onedovlp ; fi
twod: twod.o sweep2.o exchng2.o diff2d.o twodbase.o decomp.o fndnbr2d.o
	$(FLINKER) $(FFLAGS) -o twod  $(DEVICE_MAINF) \
		twod.o sweep2.o exchng2.o \
		diff2d.o twodbase.o decomp.o fndnbr2d.o $(LIBS)
	if [ ! -x twod ] ; then /bin/rm -f oned ; fi

# Profiling versions
onedpr: oned.o sweep.o exchng1.o diff.o onedbase.o decomp.o
	$(FLINKER) -o onedpr  $(DEVICE_MAINF) \
		oned.o sweep.o exchng1.o \
		diff.o onedbase.o decomp.o $(PROFLIBS)
	if [ ! -x onedpr ] ; then /bin/rm -f onedpr ; fi
onedsyncpr: oned.o sweep.o exsync1d.o diff.o onedbase.o decomp.o
	$(FLINKER) -o onedsyncpr  $(DEVICE_MAINF) \
		oned.o sweep.o exsync1d.o \
		diff.o onedbase.o decomp.o $(PROFLIBS)
	if [ ! -x onedsyncpr ] ; then /bin/rm -f onedsyncpr ; fi
onedsandrpr: oned.o sweep.o exsandr1d.o diff.o onedbase.o decomp.o
	$(FLINKER) -o onedsandrpr  $(DEVICE_MAINF) oned.o sweep.o \
		exsandr1d.o diff.o onedbase.o decomp.o $(PROFLIBS)
	if [ ! -x onedsandrpr ] ; then /bin/rm -f onedsandrpr ; fi
onedpairpr: oned.o sweep.o expair1d.o diff.o onedbase.o decomp.o
	$(FLINKER) -o onedpairpr  $(DEVICE_MAINF) \
		oned.o sweep.o expair1d.o \
		diff.o onedbase.o decomp.o $(PROFLIBS)
	if [ ! -x onedpairpr ] ; then /bin/rm -f onedpairpr ; fi
onednbpr: onednb.o nbsweep.o nbexchng.o diff.o onedbase.o decomp.o
	$(FLINKER) $(FFLAGS) -o onednbpr  $(DEVICE_MAINF) \
		onednb.o nbsweep.o nbexchng.o \
		diff.o onedbase.o decomp.o $(LIBS)
	if [ ! -x onednbpr ] ; then /bin/rm -f onednbpr ; fi
onednbpr: oned.o sweep.o exchng1nb.o diff.o onedbase.o decomp.o
	$(FLINKER) $(FFLAGS) -o onednbpr  $(DEVICE_MAINF) \
		oned.o sweep.o exchng1nb.o \
		diff.o onedbase.o decomp.o $(LIBS)
	if [ ! -x onednbpr ] ; then /bin/rm -f onednbpr ; fi
onedovlppr: onednb.o nbsweep.o nbexchng.o diff.o onedbase.o decomp.o
	$(FLINKER) $(FFLAGS) -o onedovlppr  $(DEVICE_MAINF) \
		onednb.o nbsweep.o nbexchng.o \
		diff.o onedbase.o decomp.o $(LIBS)
	if [ ! -x onedovlppr ] ; then /bin/rm -f onedovlppr ; fi
twodpr: twod.o sweep2.o exchng2.o diff2d.o twodbase.o decomp.o fndnbr2d.o
	$(FLINKER) -o twodpr  $(DEVICE_MAINF) \
		twod.o sweep2.o exchng2.o \
		diff2d.o twodbase.o decomp.o fndnbr2d.o $(PROFLIBS)
	if [ ! -x twodpr ] ; then /bin/rm -f twodpr ; fi

.c.o:
	$(CC) $(CFLAGS) -c $*.c

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

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