|
Packit |
0848f5 |
#! /bin/sh
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# (C) 2006 by Argonne National Laboratory.
|
|
Packit |
0848f5 |
# See COPYRIGHT in top-level directory.
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# mpif77
|
|
Packit |
0848f5 |
# Simple script to compile and/or link MPI programs.
|
|
Packit |
0848f5 |
# This script knows the default flags and libraries, and can handle
|
|
Packit |
0848f5 |
# alternative C compilers and the associated flags and libraries.
|
|
Packit |
0848f5 |
# The important terms are:
|
|
Packit |
0848f5 |
# includedir, libdir - Directories containing an *installed* mpich
|
|
Packit |
0848f5 |
# prefix, execprefix - Often used to define includedir and libdir
|
|
Packit |
0848f5 |
# F77 - Fortran 77 compiler
|
|
Packit |
0848f5 |
# WRAPPER_FFLAGS - Any special flags needed to compile
|
|
Packit |
0848f5 |
# WRAPPER_LDFLAGS - Any special flags needed to link
|
|
Packit |
0848f5 |
# WRAPPER_LIBS - Any special libraries needed in order to link
|
|
Packit |
0848f5 |
# F77_OTHER_LIBS - Yet more libraries, needed just with F77
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# We assume that (a) the C compiler can both compile and link programs
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# Handling of command-line options:
|
|
Packit |
0848f5 |
# This is a little tricky because some options may contain blanks.
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# Special issues with shared libraries - todo
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# --------------------------------------------------------------------------
|
|
Packit |
0848f5 |
# Set the default values of all variables.
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# Directory locations: Fixed for any MPI implementation.
|
|
Packit |
0848f5 |
# Set from the directory arguments to configure (e.g., --prefix=/usr/local)
|
|
Packit |
0848f5 |
prefix=__PREFIX_TO_BE_FILLED_AT_INSTALL_TIME__
|
|
Packit |
0848f5 |
exec_prefix=__EXEC_PREFIX_TO_BE_FILLED_AT_INSTALL_TIME__
|
|
Packit |
0848f5 |
sysconfdir=__SYSCONFDIR_TO_BE_FILLED_AT_INSTALL_TIME__
|
|
Packit |
0848f5 |
includedir=__INCLUDEDIR_TO_BE_FILLED_AT_INSTALL_TIME__
|
|
Packit |
0848f5 |
libdir=__LIBDIR_TO_BE_FILLED_AT_INSTALL_TIME__
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
# Default settings for compiler, flags, and libraries
|
|
Packit |
0848f5 |
# Determined by a combination of environment variables and tests within
|
|
Packit |
0848f5 |
# configure (e.g., determining whehter -lsocket is needee)
|
|
Packit |
0848f5 |
F77="@F77@"
|
|
Packit |
0848f5 |
F77CPP="@F77CPP@"
|
|
Packit |
0848f5 |
MPICH_VERSION="@MPICH_VERSION@"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
enable_wrapper_rpath="@enable_wrapper_rpath@"
|
|
Packit |
0848f5 |
@f77_shlib_conf@
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
# Internal variables
|
|
Packit |
0848f5 |
# Show is set to echo to cause the compilation command to be echoed instead
|
|
Packit |
0848f5 |
# of executed.
|
|
Packit |
0848f5 |
Show=eval
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# End of initialization of variables
|
|
Packit |
0848f5 |
#---------------------------------------------------------------------
|
|
Packit |
0848f5 |
# Environment Variables.
|
|
Packit |
0848f5 |
# The environment variables MPICH_F77 may be used to override the
|
|
Packit |
0848f5 |
# default choices.
|
|
Packit |
0848f5 |
# In addition, if there is a file $sysconfdir/mpif77-$F77name.conf,
|
|
Packit |
0848f5 |
# where F77name is the name of the compiler with all spaces replaced by hyphens
|
|
Packit |
0848f5 |
# (e.g., "f77 -64" becomes "f77--64", that file is sources, allowing other
|
|
Packit |
0848f5 |
# changes to the compilation environment. See the variables used by the
|
|
Packit |
0848f5 |
# script (defined above)
|
|
Packit |
0848f5 |
# Added MPICH_F77_OLD, MPICH_F77 can be used to prefix F77
|
|
Packit |
0848f5 |
# with external utility, e.g. setenv MPICH_F77 'eval linkcache $MPICH_F77_OLD'
|
|
Packit |
0848f5 |
if [ -n "$MPICH_F77" ] ; then
|
|
Packit |
0848f5 |
MPICH_F77_OLD="$F77"
|
|
Packit |
0848f5 |
F77="$MPICH_F77"
|
|
Packit |
0848f5 |
F77name=`echo $F77 | sed 's/ /-/g'`
|
|
Packit |
0848f5 |
if [ -s $sysconfdir/mpif77-$F77name.conf ] ; then
|
|
Packit |
0848f5 |
. $sysconfdir/mpif77-$F77name.conf
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
# Allow a profiling option to be selected through an environment variable
|
|
Packit |
0848f5 |
if [ -n "$MPIF77_PROFILE" ] ; then
|
|
Packit |
0848f5 |
profConf=$MPIF77_PROFILE
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# ------------------------------------------------------------------------
|
|
Packit |
0848f5 |
# Argument processing.
|
|
Packit |
0848f5 |
# This is somewhat awkward because of the handling of arguments within
|
|
Packit |
0848f5 |
# the shell. We want to handle arguments that include spaces without
|
|
Packit |
0848f5 |
# loosing the spacing (an alternative would be to use a more powerful
|
|
Packit |
0848f5 |
# scripting language that would allow us to retain the array of values,
|
|
Packit |
0848f5 |
# which the basic (rather than enhanced) Bourne shell does not.
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# Look through the arguments for arguments that indicate compile only.
|
|
Packit |
0848f5 |
# If these are *not* found, add the library options
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
linking=yes
|
|
Packit |
0848f5 |
allargs=""
|
|
Packit |
0848f5 |
interlib_deps=yes
|
|
Packit |
0848f5 |
for arg in "$@" ; do
|
|
Packit |
0848f5 |
# Set addarg to no if this arg should be ignored by the C compiler
|
|
Packit |
0848f5 |
addarg=yes
|
|
Packit |
0848f5 |
qarg=$arg
|
|
Packit |
0848f5 |
case $arg in
|
|
Packit |
0848f5 |
# ----------------------------------------------------------------
|
|
Packit |
0848f5 |
# Compiler options that affect whether we are linking or no
|
|
Packit |
0848f5 |
-c|-S|-E|-M|-MM)
|
|
Packit |
0848f5 |
# The compiler links by default
|
|
Packit |
0848f5 |
linking=no
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
# ----------------------------------------------------------------
|
|
Packit |
0848f5 |
# Options that control how we use mpif77 (e.g., -show,
|
|
Packit |
0848f5 |
# -f77=* -config=*
|
|
Packit |
0848f5 |
-static)
|
|
Packit |
0848f5 |
interlib_deps=no
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
-echo)
|
|
Packit |
0848f5 |
addarg=no
|
|
Packit |
0848f5 |
set -x
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
-f77=*)
|
|
Packit |
0848f5 |
F77=`echo A$arg | sed -e 's/A-f77=//g'`
|
|
Packit |
0848f5 |
addarg=no
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
-fc=*)
|
|
Packit |
0848f5 |
F77=`echo A$arg | sed -e 's/A-fc=//g'`
|
|
Packit |
0848f5 |
addarg=no
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
-show)
|
|
Packit |
0848f5 |
addarg=no
|
|
Packit |
0848f5 |
Show=echo
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
-config=*)
|
|
Packit |
0848f5 |
addarg=no
|
|
Packit |
0848f5 |
F77name=`echo A$arg | sed -e 's/A-config=//g'`
|
|
Packit |
0848f5 |
if [ -s "$sysconfdir/mpif77-$F77name.conf" ] ; then
|
|
Packit |
0848f5 |
. "$sysconfdir/mpif77-$F77name.conf"
|
|
Packit |
0848f5 |
else
|
|
Packit |
0848f5 |
echo "Configuration file mpif77-$F77name.conf not found"
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
-compile-info|-compile_info)
|
|
Packit |
0848f5 |
# -compile_info included for backward compatibility
|
|
Packit |
0848f5 |
Show=echo
|
|
Packit |
0848f5 |
addarg=no
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
-link-info|-link_info)
|
|
Packit |
0848f5 |
# -link_info included for backward compatibility
|
|
Packit |
0848f5 |
Show=echo
|
|
Packit |
0848f5 |
addarg=no
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
-v)
|
|
Packit |
0848f5 |
# Pass this argument to the compiler as well.
|
|
Packit |
0848f5 |
echo "mpif77 for MPICH version $MPICH_VERSION"
|
|
Packit |
0848f5 |
# if there is only 1 argument, it must be -v.
|
|
Packit |
0848f5 |
if [ "$#" -eq "1" ] ; then
|
|
Packit |
0848f5 |
linking=no
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
-profile=*)
|
|
Packit |
0848f5 |
# Pass the name of a profiling configuration. As
|
|
Packit |
0848f5 |
# a special case, lib<name>.so or lib<name>.la may be used
|
|
Packit |
0848f5 |
# if the library is in $libdir
|
|
Packit |
0848f5 |
profConf=`echo A$arg | sed -e 's/A-profile=//g'`
|
|
Packit |
0848f5 |
addarg=no
|
|
Packit |
0848f5 |
# Loading the profConf file is handled below
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
-nativelinking)
|
|
Packit |
0848f5 |
# Internal option to use native compiler for linking without MPI libraries
|
|
Packit |
0848f5 |
nativelinking=yes
|
|
Packit |
0848f5 |
addarg=no
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
-help)
|
|
Packit |
0848f5 |
NC=`echo "$F77" | sed 's%\/% %g' | awk '{print $NF}' -`
|
|
Packit |
0848f5 |
if [ -f "$sysconfdir/mpixxx_opts.conf" ] ; then
|
|
Packit |
0848f5 |
. $sysconfdir/mpixxx_opts.conf
|
|
Packit |
0848f5 |
echo " -f77=xxx - Reset the native compiler to xxx."
|
|
Packit |
0848f5 |
echo " -fc=xxx - Reset the native compiler to xxx."
|
|
Packit |
0848f5 |
else
|
|
Packit |
0848f5 |
if [ -f "./mpixxx_opts.conf" ] ; then
|
|
Packit |
0848f5 |
. ./mpixxx_opts.conf
|
|
Packit |
0848f5 |
echo " -f77=xxx - Reset the native compiler to xxx."
|
|
Packit |
0848f5 |
echo " -fc=xxx - Reset the native compiler to xxx."
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
exit 0
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
# -----------------------------------------------------------------
|
|
Packit |
0848f5 |
# Other arguments. We are careful to handle arguments with
|
|
Packit |
0848f5 |
# quotes (we try to quote all arguments in case they include
|
|
Packit |
0848f5 |
# any spaces)
|
|
Packit |
0848f5 |
*\"*)
|
|
Packit |
0848f5 |
qarg="'"$arg"'"
|
|
Packit |
0848f5 |
case $arg in
|
|
Packit |
0848f5 |
-D*)
|
|
Packit |
0848f5 |
cppflags="$cppflags $qarg"
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
esac
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
*\'*)
|
|
Packit |
0848f5 |
qarg='\"'"$arg"'\"'
|
|
Packit |
0848f5 |
case $arg in
|
|
Packit |
0848f5 |
-D*)
|
|
Packit |
0848f5 |
cppflags="$cppflags $qarg"
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
esac
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
# The following are special args used to handle .F files when the
|
|
Packit |
0848f5 |
# Fortran compiler itself does not handle these options
|
|
Packit |
0848f5 |
-I*)
|
|
Packit |
0848f5 |
cppflags="$cppflags $arg"
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
-D*)
|
|
Packit |
0848f5 |
cppflags="$cppflags $arg"
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
*.F|*.F90|*.fpp|*.FPP)
|
|
Packit |
0848f5 |
# If F77CPP is not empty, then we need to do the following:
|
|
Packit |
0848f5 |
# If any input files have the .F or .F90 extension, then
|
|
Packit |
0848f5 |
# If F77CPP = false, then
|
|
Packit |
0848f5 |
# generate an error message and exit
|
|
Packit |
0848f5 |
# Use F77CPP to convert the file from .F to .f, using
|
|
Packit |
0848f5 |
# $TMPDIR/f$$-$count.f as the output file name
|
|
Packit |
0848f5 |
# Replace the input file with this name in the args
|
|
Packit |
0848f5 |
# This is needed only for very broken systems
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
if [ -n "$F77CPP" ] ; then
|
|
Packit |
0848f5 |
if [ "$F77CPP" = "false" ] ; then
|
|
Packit |
0848f5 |
echo "This Fortran compiler does not accept .F or .F90 files"
|
|
Packit |
0848f5 |
exit 1
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
addarg=no
|
|
Packit |
0848f5 |
# Remove and directory names and extension
|
|
Packit |
0848f5 |
$ext=`expr "$arg" : '.*\(\..*\)'`
|
|
Packit |
0848f5 |
bfile=`basename $arg $ext`
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
TMPDIR=${TMPDIR:-/tmp}
|
|
Packit |
0848f5 |
tmpfile=$TMPDIR/f$$-$bfile.f
|
|
Packit |
0848f5 |
if $F77CPP $cppflags $arg > $tmpfile ; then
|
|
Packit |
0848f5 |
# Add this file to the commandline list
|
|
Packit |
0848f5 |
count=`expr $count + 1`
|
|
Packit |
0848f5 |
allargs="$allargs $tmpfile"
|
|
Packit |
0848f5 |
rmfiles="$rmfiles $tmpfile"
|
|
Packit |
0848f5 |
else
|
|
Packit |
0848f5 |
echo "Aborting compilation because of failure in preprocessing step"
|
|
Packit |
0848f5 |
echo "for file $arg ."
|
|
Packit |
0848f5 |
exit 1
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
# Otherwise, just accept the argument
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
# - end of special handling for .F files
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
*)
|
|
Packit |
0848f5 |
qarg="'$arg'"
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
esac
|
|
Packit |
0848f5 |
if [ $addarg = yes ] ; then
|
|
Packit |
0848f5 |
allargs="$allargs $qarg"
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
done
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if [ $# -eq 0 ] ; then
|
|
Packit |
0848f5 |
echo "Error: Command line argument is needed!"
|
|
Packit |
0848f5 |
"$0" -help
|
|
Packit |
0848f5 |
exit 1
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
# -----------------------------------------------------------------------
|
|
Packit |
0848f5 |
# Derived variables. These are assembled from variables set from the
|
|
Packit |
0848f5 |
# default, environment, configuration file (if any) and command-line
|
|
Packit |
0848f5 |
# options (if any)
|
|
Packit |
0848f5 |
f77libs=
|
|
Packit |
0848f5 |
if [ "@MPIFCLIBNAME@" != "@MPILIBNAME@" ] ; then
|
|
Packit |
0848f5 |
f77libs="-l@MPIFCLIBNAME@"
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
PROFILE_FOO=
|
|
Packit |
0848f5 |
# Handle the case of a profile switch
|
|
Packit |
0848f5 |
if [ -n "$profConf" ] ; then
|
|
Packit |
0848f5 |
profConffile=
|
|
Packit |
0848f5 |
if [ -s "$libdir/lib$profConf.a" -o -s "$libdir/lib$profConf.so" ] ; then
|
|
Packit |
0848f5 |
PROFILE_FOO="-l$profConf"
|
|
Packit |
0848f5 |
elif [ -s "$sysconfdir/$profConf.conf" ] ; then
|
|
Packit |
0848f5 |
profConffile="$sysconfdir/$profConf.conf"
|
|
Packit |
0848f5 |
elif [ -s "$profConf.conf" ] ; then
|
|
Packit |
0848f5 |
profConffile="$profConf.conf"
|
|
Packit |
0848f5 |
else
|
|
Packit |
0848f5 |
echo "Profiling configuration file $profConf.conf not found in $sysconfdir"
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
if [ -n "$profConffile" -a -s "$profConffile" ] ; then
|
|
Packit |
0848f5 |
. $profConffile
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
final_fflags="@MPICH_MPIF77_FFLAGS@ @WRAPPER_FFLAGS@"
|
|
Packit |
0848f5 |
final_ldflags="@MPICH_MPIF77_LDFLAGS@ @WRAPPER_LDFLAGS@"
|
|
Packit |
0848f5 |
final_libs="@MPICH_MPIF77_LIBS@"
|
|
Packit |
0848f5 |
if test "@INTERLIB_DEPS@" = "no" -o "${interlib_deps}" = "no" ; then
|
|
Packit |
0848f5 |
final_ldflags="${final_ldflags} @LDFLAGS@"
|
|
Packit |
0848f5 |
final_libs="${final_libs} @LIBS@ @WRAPPER_LIBS@"
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
# A temporary statement to invoke the compiler
|
|
Packit |
0848f5 |
# Place the -L before any args incase there are any mpi libraries in there.
|
|
Packit |
0848f5 |
# Eventually, we'll want to move this after any non-MPI implementation
|
|
Packit |
0848f5 |
# libraries
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
if [ "$linking" = yes ] ; then
|
|
Packit |
0848f5 |
# Attempt to encode rpath info into the executable if the user has not
|
|
Packit |
0848f5 |
# disabled rpath usage and some flavor of rpath makes sense on this
|
|
Packit |
0848f5 |
# platform.
|
|
Packit |
0848f5 |
# TODO configure and config.rpath are computing more sophisticated rpath
|
|
Packit |
0848f5 |
# schemes than this simple one. Consider updating this logic accordingly.
|
|
Packit |
0848f5 |
if test "X$enable_wrapper_rpath" = "Xyes" ; then
|
|
Packit |
0848f5 |
eval rpath_flags=\"${hardcode_libdir_flag_spec}\"
|
|
Packit |
0848f5 |
else
|
|
Packit |
0848f5 |
rpath_flags=""
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if [ "$nativelinking" = yes ] ; then
|
|
Packit |
0848f5 |
$Show $F77 $PROFILE_INCPATHS ${final_fflags} ${final_ldflags} $allargs -I$includedir
|
|
Packit |
0848f5 |
rc=$?
|
|
Packit |
0848f5 |
else
|
|
Packit |
0848f5 |
$Show $F77 $PROFILE_INCPATHS ${final_fflags} ${final_ldflags} $allargs -I$includedir -L$libdir $f77libs $PROFILE_PRELIB $PROFILE_FOO $rpath_flags -l@MPILIBNAME@ @LPMPILIBNAME@ $PROFILE_POSTLIB ${final_libs} @F77_OTHER_LIBS@
|
|
Packit |
0848f5 |
rc=$?
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
else
|
|
Packit |
0848f5 |
$Show $F77 $PROFILE_INCPATHS ${final_fflags} $allargs -I$includedir
|
|
Packit |
0848f5 |
rc=$?
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
if [ -n "$rmfiles" ] ; then
|
|
Packit |
0848f5 |
for file in $rmfiles ; do
|
|
Packit |
0848f5 |
objfile=`basename $file .f`
|
|
Packit |
0848f5 |
if [ -s "${objfile}.o" ] ; then
|
|
Packit |
0848f5 |
# Rename
|
|
Packit |
0848f5 |
destfile=`echo $objfile | sed -e "s/.*$$-//"`
|
|
Packit |
0848f5 |
mv -f ${objfile}.o ${destfile}.o
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
rm -f $file
|
|
Packit |
0848f5 |
done
|
|
Packit |
0848f5 |
rm -f $rmfiles
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
exit $rc
|
|
Packit |
0848f5 |
|