DIRS = usingmpi life C++ nuclei mandel-pvm


# Here is what we need to run programs in this directory

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

all: $(EXECS)

### End User configurable options ###
SHELL	= /bin/sh
CFLAGS  = @USER_CFLAGS@ $(OPTFLAGS) $(INCLUDE_DIR) -DMPI_$(ARCH)
CCFLAGS = $(CFLAGS)
#FFLAGS = '-qdpc=e' 
FFLAGS = @FFLAGS@ $(OPTFLAGS)
MPILIB = $(MPIR_HOME)/lib/$(ARCH)/$(COMM)/lib@MPILIBNAME@.a 
MPIPPLIB = $(MPIR_HOME)/lib/$(ARCH)/$(COMM)/lib@MPILIBNAME@++.a
LIBS = $(LIB_PATH) $(LIB_LIST)
LIBSPP = $(MPIPPLIB) $(LIBS)
EXECS  = dcmplx isendtst dbltest names particles topologies
OBJS   = dcmplx.o isendtst.o names.o particles.o topologies.o

dcmplx: mpif.h dcmplx.o $(MPILIB)
	$(FLINKER) $(OPTFLAGS) -o dcmplx dcmplx.o $(LIBS)

dbltest: mpif.h dbltest.o $(MPILIB)
	$(FLINKER) $(OPTFLAGS) -o dbltest dbltest.o $(LIBS)

isendtst: isendtst.o $(MPILIB)
	$(CLINKER) $(OPTFLAGS) -o isendtst isendtst.o $(LIBS)

structtest: structtest.o $(MPILIB)
	$(CLINKER) $(OPTFLAGS) -o structtest structtest.o $(LIBS)

names: names.o $(MPILIB)
	$(CLINKER) $(OPTFLAGS) -o names names.o $(LIBS)

particles: particles.o $(MPILIB)
	$(CLINKER) $(OPTFLAGS) -o particles particles.o $(LIBS) -lm

topologies: topologies.o $(MPILIB)
	$(CLINKER) $(OPTFLAGS) -o topologies topologies.o $(LIBS)

#
# Some systems have no test for a symbolic link and return false for
# a link that exists
mpif.h: $(MPIR_HOME)/include/mpif.h
	if test \! -f mpif.h ; then \
	    /bin/rm -f mpif.h ; \
	    ln -s $(MPIR_HOME)/include/mpif.h . ; \
	fi

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

clean:
	/bin/rm -f $(EXECS) $(OBJS)
	for dir in $(DIRS) ; do \
	if [ -s $$dir ] ; then ( cd $$dir ; $(MAKE) clean ) ; fi ; done
