#!/bin/sh
#
# Configure script for MPY (Message Passing Yorick)
# Assumes Yorick has already been configured in ../Yorick
#
# You need to do part of the work here yourself:
#
#     MPI implementations usually come with a substitute for the
#     cc and f77 compilers.  These invoke the underlying cc and f77
#     compilers with the appropriate -I, -L, and -l options so the
#     MPI headers and libraries can be found.  If your MPI does not
#     come with these substitutes, you will need to write scripts
#     to do it yourself.  The mpicc-sh script in this directory
#     is an example for the LAM implementation of MPI (LAM's hcc
#     script supplies the necessary -I options, but not the -L or
#     -l options).
#     You don't need to set MPI_F77 correctly unless you plan to use
#     Fortran in your own codes; MPY itself doesn't use any.  Be sure
#     that you've set up the FC line in ../Yorick/Maketmpl correctly
#     if you do care about MPI_F77.

MPI_CC=mpicc
MPI_F77=mpif77

# Now type this:
#     ./configure
# Which constructs the Make-mpy template.  Then you can type:
#     make
# to build MPY itself.  See the README for more details.

# substitute mpicc for the name of the C compiler
set `grep "^CC = " ../Yorick/Maketmpl`
shift 3
csubst="s/^CC = .*/CC = ${MPI_CC} $*/"

# substitute mpif77 for the name of the Fortran compiler
set `grep "^FC = " ../Yorick/Maketmpl`
if test $# -gt 2; then
shift 3
else
shift 2
fi
fsubst="s/^FC = .*/FC = ${MPI_F77} $*/"

sed -e "${csubst}" -e "${fsubst}" ../Yorick/Maketmpl >Make-mpy
