|
Packit Service |
c5cf8c |
#! @BASH_SHELL@
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# (C) 2006 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
# See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# mpicc
|
|
Packit Service |
c5cf8c |
# Simple script to compile and/or link MPI programs.
|
|
Packit Service |
c5cf8c |
# This script knows the default flags and libraries, and can handle
|
|
Packit Service |
c5cf8c |
# alternative C compilers and the associated flags and libraries.
|
|
Packit Service |
c5cf8c |
# The important terms are:
|
|
Packit Service |
c5cf8c |
# includedir, libdir - Directories containing an *installed* mpich
|
|
Packit Service |
c5cf8c |
# prefix, execprefix - Often used to define includedir and libdir
|
|
Packit Service |
c5cf8c |
# CC - C compiler
|
|
Packit Service |
c5cf8c |
# WRAPPER_CFLAGS - Any special flags needed to compile
|
|
Packit Service |
c5cf8c |
# WRAPPER_LDFLAGS - Any special flags needed to link
|
|
Packit Service |
c5cf8c |
# WRAPPER_LIBS - Any special libraries needed in order to link
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# We assume that (a) the C compiler can both compile and link programs
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# Handling of command-line options:
|
|
Packit Service |
c5cf8c |
# This is a little tricky because some options may contain blanks.
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# Special issues with shared libraries - todo
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# --------------------------------------------------------------------------
|
|
Packit Service |
c5cf8c |
# Set the default values of all variables.
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# Directory locations: Fixed for any MPI implementation.
|
|
Packit Service |
c5cf8c |
# Set from the directory arguments to configure (e.g., --prefix=/usr/local)
|
|
Packit Service |
c5cf8c |
prefix=__PREFIX_TO_BE_FILLED_AT_INSTALL_TIME__
|
|
Packit Service |
c5cf8c |
exec_prefix=__EXEC_PREFIX_TO_BE_FILLED_AT_INSTALL_TIME__
|
|
Packit Service |
c5cf8c |
sysconfdir=__SYSCONFDIR_TO_BE_FILLED_AT_INSTALL_TIME__
|
|
Packit Service |
c5cf8c |
includedir=__INCLUDEDIR_TO_BE_FILLED_AT_INSTALL_TIME__
|
|
Packit Service |
c5cf8c |
libdir=__LIBDIR_TO_BE_FILLED_AT_INSTALL_TIME__
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Default settings for compiler, flags, and libraries.
|
|
Packit Service |
c5cf8c |
# Determined by a combination of environment variables and tests within
|
|
Packit Service |
c5cf8c |
# configure (e.g., determining whehter -lsocket is needee)
|
|
Packit Service |
c5cf8c |
CC="@CC@"
|
|
Packit Service |
c5cf8c |
MPICH_VERSION="@MPICH_VERSION@"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
enable_wrapper_rpath="@enable_wrapper_rpath@"
|
|
Packit Service |
c5cf8c |
@cc_shlib_conf@
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Internal variables
|
|
Packit Service |
c5cf8c |
# Show is set to echo to cause the compilation command to be echoed instead
|
|
Packit Service |
c5cf8c |
# of executed.
|
|
Packit Service |
c5cf8c |
Show=
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# End of initialization of variables
|
|
Packit Service |
c5cf8c |
#---------------------------------------------------------------------
|
|
Packit Service |
c5cf8c |
# Environment Variables.
|
|
Packit Service |
c5cf8c |
# The environment variables MPICH_CC may be used to override the
|
|
Packit Service |
c5cf8c |
# default choices.
|
|
Packit Service |
c5cf8c |
# In addition, if there is a file $sysconfdir/mpicc-$CCname.conf,
|
|
Packit Service |
c5cf8c |
# where CCname is the name of the compiler with all spaces replaced by hyphens
|
|
Packit Service |
c5cf8c |
# (e.g., "cc -64" becomes "cc--64", that file is sources, allowing other
|
|
Packit Service |
c5cf8c |
# changes to the compilation environment. See the variables used by the
|
|
Packit Service |
c5cf8c |
# script (defined above)
|
|
Packit Service |
c5cf8c |
# Added MPICH_CC_OLD, MPICH_CC can be used to prefix CC with external utility,
|
|
Packit Service |
c5cf8c |
# e.g. setenv MPICH_CC 'eval linkcache $MPICH_CC_OLD'
|
|
Packit Service |
c5cf8c |
if [ -n "$MPICH_CC" ] ; then
|
|
Packit Service |
c5cf8c |
MPICH_CC_OLD="$CC"
|
|
Packit Service |
c5cf8c |
CC="$MPICH_CC"
|
|
Packit Service |
c5cf8c |
CCname=`echo $CC | sed 's/ /-/g'`
|
|
Packit Service |
c5cf8c |
if [ -s $sysconfdir/mpicc-$CCname.conf ] ; then
|
|
Packit Service |
c5cf8c |
. $sysconfdir/mpicc-$CCname.conf
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
# Allow a profiling option to be selected through an environment variable
|
|
Packit Service |
c5cf8c |
if [ -n "$MPICC_PROFILE" ] ; then
|
|
Packit Service |
c5cf8c |
profConf=$MPICC_PROFILE
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# ------------------------------------------------------------------------
|
|
Packit Service |
c5cf8c |
# Argument processing.
|
|
Packit Service |
c5cf8c |
# This is somewhat awkward because of the handling of arguments within
|
|
Packit Service |
c5cf8c |
# the shell. We want to handle arguments that include spaces without
|
|
Packit Service |
c5cf8c |
# loosing the spacing (an alternative would be to use a more powerful
|
|
Packit Service |
c5cf8c |
# scripting language that would allow us to retain the array of values,
|
|
Packit Service |
c5cf8c |
# which the basic (rather than enhanced) Bourne shell does not.
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# Look through the arguments for arguments that indicate compile only.
|
|
Packit Service |
c5cf8c |
# If these are *not* found, add the library options
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
linking=yes
|
|
Packit Service |
c5cf8c |
allargs=("$@")
|
|
Packit Service |
c5cf8c |
argno=0
|
|
Packit Service |
c5cf8c |
interlib_deps=yes
|
|
Packit Service |
c5cf8c |
static_mpi=no
|
|
Packit Service |
c5cf8c |
for arg in "$@" ; do
|
|
Packit Service |
c5cf8c |
# Set addarg to no if this arg should be ignored by the C compiler
|
|
Packit Service |
c5cf8c |
addarg=yes
|
|
Packit Service |
c5cf8c |
case "$arg" in
|
|
Packit Service |
c5cf8c |
# ----------------------------------------------------------------
|
|
Packit Service |
c5cf8c |
# Compiler options that affect whether we are linking or no
|
|
Packit Service |
c5cf8c |
-c|-S|-E|-M|-MM)
|
|
Packit Service |
c5cf8c |
# The compiler links by default
|
|
Packit Service |
c5cf8c |
linking=no
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
# ----------------------------------------------------------------
|
|
Packit Service |
c5cf8c |
# Options that control how we use mpicc (e.g., -show,
|
|
Packit Service |
c5cf8c |
# -cc=* -config=*
|
|
Packit Service |
c5cf8c |
-static)
|
|
Packit Service |
c5cf8c |
interlib_deps=no
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
-static-mpi)
|
|
Packit Service |
c5cf8c |
interlib_deps=no
|
|
Packit Service |
c5cf8c |
static_mpi=yes
|
|
Packit Service |
c5cf8c |
addarg=no
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
-echo)
|
|
Packit Service |
c5cf8c |
addarg=no
|
|
Packit Service |
c5cf8c |
set -x
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
-cc=*)
|
|
Packit Service |
c5cf8c |
CC=`echo A$arg | sed -e 's/A-cc=//g'`
|
|
Packit Service |
c5cf8c |
addarg=no
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
-show)
|
|
Packit Service |
c5cf8c |
addarg=no
|
|
Packit Service |
c5cf8c |
Show=echo
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
-config=*)
|
|
Packit Service |
c5cf8c |
addarg=no
|
|
Packit Service |
c5cf8c |
CCname=`echo A$arg | sed -e 's/A-config=//g'`
|
|
Packit Service |
c5cf8c |
if [ -s "$sysconfdir/mpicc-$CCname.conf" ] ; then
|
|
Packit Service |
c5cf8c |
. "$sysconfdir/mpicc-$CCname.conf"
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
echo "Configuration file mpicc-$CCname.conf not found"
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
-compile-info|-compile_info)
|
|
Packit Service |
c5cf8c |
# -compile_info included for backward compatibility
|
|
Packit Service |
c5cf8c |
Show=echo
|
|
Packit Service |
c5cf8c |
addarg=no
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
-link-info|-link_info)
|
|
Packit Service |
c5cf8c |
# -link_info included for backward compatibility
|
|
Packit Service |
c5cf8c |
Show=echo
|
|
Packit Service |
c5cf8c |
addarg=no
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
-v)
|
|
Packit Service |
c5cf8c |
# Pass this argument to the compiler as well.
|
|
Packit Service |
c5cf8c |
echo "mpicc for MPICH version $MPICH_VERSION"
|
|
Packit Service |
c5cf8c |
# if there is only 1 argument, it must be -v.
|
|
Packit Service |
c5cf8c |
if [ "$#" -eq "1" ] ; then
|
|
Packit Service |
c5cf8c |
linking=no
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
-profile=*)
|
|
Packit Service |
c5cf8c |
# Pass the name of a profiling configuration. As
|
|
Packit Service |
c5cf8c |
# a special case, lib<name>.so or lib<name>.la may be used
|
|
Packit Service |
c5cf8c |
# if the library is in $libdir
|
|
Packit Service |
c5cf8c |
profConf=`echo A$arg | sed -e 's/A-profile=//g'`
|
|
Packit Service |
c5cf8c |
addarg=no
|
|
Packit Service |
c5cf8c |
# Loading the profConf file is handled below
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
-nativelinking)
|
|
Packit Service |
c5cf8c |
# Internal option to use native compiler for linking without MPI libraries
|
|
Packit Service |
c5cf8c |
nativelinking=yes
|
|
Packit Service |
c5cf8c |
addarg=no
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
-help)
|
|
Packit Service |
c5cf8c |
NC=`echo "$CC" | sed 's%\/% %g' | awk '{print $NF}' -`
|
|
Packit Service |
c5cf8c |
if [ -f "$sysconfdir/mpixxx_opts.conf" ] ; then
|
|
Packit Service |
c5cf8c |
. $sysconfdir/mpixxx_opts.conf
|
|
Packit Service |
c5cf8c |
echo " -cc=xxx - Reset the native compiler to xxx."
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
if [ -f "./mpixxx_opts.conf" ] ; then
|
|
Packit Service |
c5cf8c |
. ./mpixxx_opts.conf
|
|
Packit Service |
c5cf8c |
echo " -cc=xxx - Reset the native compiler to xxx."
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
exit 0
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
*)
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
esac
|
|
Packit Service |
c5cf8c |
if [ $addarg = no ] ; then
|
|
Packit Service |
c5cf8c |
unset allargs[$argno]
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
# Some versions of bash do not accept ((argno++))
|
|
Packit Service |
c5cf8c |
argno=`expr $argno + 1`
|
|
Packit Service |
c5cf8c |
done
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if [ $# -eq 0 ] ; then
|
|
Packit Service |
c5cf8c |
echo "Error: Command line argument is needed!"
|
|
Packit Service |
c5cf8c |
"$0" -help
|
|
Packit Service |
c5cf8c |
exit 1
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# -----------------------------------------------------------------------
|
|
Packit Service |
c5cf8c |
# Derived variables. These are assembled from variables set from the
|
|
Packit Service |
c5cf8c |
# default, environment, configuration file (if any) and command-line
|
|
Packit Service |
c5cf8c |
# options (if any)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
PROFILE_FOO=
|
|
Packit Service |
c5cf8c |
# Handle the case of a profile switch
|
|
Packit Service |
c5cf8c |
if [ -n "$profConf" ] ; then
|
|
Packit Service |
c5cf8c |
profConffile=
|
|
Packit Service |
c5cf8c |
if [ -s "$libdir/lib$profConf.a" -o -s "$libdir/lib$profConf.so" ] ; then
|
|
Packit Service |
c5cf8c |
PROFILE_FOO="-l$profConf"
|
|
Packit Service |
c5cf8c |
elif [ -s "$sysconfdir/$profConf.conf" ] ; then
|
|
Packit Service |
c5cf8c |
profConffile="$sysconfdir/$profConf.conf"
|
|
Packit Service |
c5cf8c |
elif [ -s "$profConf.conf" ] ; then
|
|
Packit Service |
c5cf8c |
profConffile="$profConf.conf"
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
echo "Profiling configuration file $profConf.conf not found in $sysconfdir"
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
if [ -n "$profConffile" -a -s "$profConffile" ] ; then
|
|
Packit Service |
c5cf8c |
. $profConffile
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
3f36f5 |
final_cflags="@MPICH_MPICC_CFLAGS@ "
|
|
Packit Service |
3f36f5 |
final_cppflags="@MPICH_MPICC_CPPFLAGS@ "
|
|
Packit Service |
3f36f5 |
final_ldflags="@MPICH_MPICC_LDFLAGS@ "
|
|
Packit Service |
c5cf8c |
final_libs="@MPICH_MPICC_LIBS@"
|
|
Packit Service |
c5cf8c |
if test "@INTERLIB_DEPS@" = "no" -o "${interlib_deps}" = "no" ; then
|
|
Packit Service |
c5cf8c |
final_ldflags="${final_ldflags} @LDFLAGS@"
|
|
Packit Service |
3f36f5 |
final_libs="${final_libs} @LIBS@ "
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# -----------------------------------------------------------------------
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# A temporary statement to invoke the compiler
|
|
Packit Service |
c5cf8c |
# Place the -L before any args incase there are any mpi libraries in there.
|
|
Packit Service |
c5cf8c |
# Eventually, we'll want to move this after any non-MPI implementation
|
|
Packit Service |
c5cf8c |
# libraries.
|
|
Packit Service |
c5cf8c |
# We use a single invocation of the compiler. This will be adequate until
|
|
Packit Service |
c5cf8c |
# we run into a system that uses a separate linking command. With any luck,
|
|
Packit Service |
c5cf8c |
# such archaic systems are no longer with us. This also lets us
|
|
Packit Service |
c5cf8c |
# accept any argument; we don't need to know if we've seen a source
|
|
Packit Service |
c5cf8c |
# file or an object file. Instead, we just check for an option that
|
|
Packit Service |
c5cf8c |
# suppressing linking, such as -c or -M.
|
|
Packit Service |
c5cf8c |
if [ "$linking" = yes ] ; then
|
|
Packit Service |
c5cf8c |
# Attempt to encode rpath info into the executable if the user has not
|
|
Packit Service |
c5cf8c |
# disabled rpath usage and some flavor of rpath makes sense on this
|
|
Packit Service |
c5cf8c |
# platform.
|
|
Packit Service |
c5cf8c |
# TODO configure and config.rpath are computing more sophisticated rpath
|
|
Packit Service |
c5cf8c |
# schemes than this simple one. Consider updating this logic accordingly.
|
|
Packit Service |
c5cf8c |
if test "X$enable_wrapper_rpath" = "Xyes" ; then
|
|
Packit Service |
c5cf8c |
eval rpath_flags=\"${hardcode_libdir_flag_spec}\"
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
rpath_flags=""
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if [ "$nativelinking" = yes ] ; then
|
|
Packit Service |
c5cf8c |
$Show $CC ${final_cppflags} $PROFILE_INCPATHS ${final_cflags} ${final_ldflags} "${allargs[@]}" -I$includedir
|
|
Packit Service |
c5cf8c |
rc=$?
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
if [ "$static_mpi" = no ] ; then
|
|
Packit Service |
c5cf8c |
$Show $CC ${final_cppflags} $PROFILE_INCPATHS ${final_cflags} ${final_ldflags} "${allargs[@]}" -I$includedir -L$libdir $PROFILE_PRELIB $PROFILE_FOO $rpath_flags -l@MPILIBNAME@ @LPMPILIBNAME@ $PROFILE_POSTLIB ${final_libs}
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
fabric_dep=""
|
|
Packit Service |
c5cf8c |
if [ "@ofi_embedded@" = yes ] ; then
|
|
Packit Service |
c5cf8c |
fabric_dep=`pkg-config --static --libs $libdir/pkgconfig/libfabric.pc`
|
|
Packit Service |
c5cf8c |
fabric_dep=`echo $fabric_dep | sed 's/-lfabric//'`
|
|
Packit Service |
c5cf8c |
elif [ -f @with_libfabric@/lib/pkgconfig/libfabric.pc ] ; then
|
|
Packit Service |
c5cf8c |
fabric_dep=`pkg-config --static --libs @with_libfabric@/lib/pkgconfig/libfabric.pc`
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
fabric_dep=`pkg-config --static --libs libfabric`
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
$Show $CC ${final_cppflags} $PROFILE_INCPATHS ${final_cflags} ${final_ldflags} "${allargs[@]}" -I$includedir -L$libdir $PROFILE_PRELIB $PROFILE_FOO $rpath_flags $libdir/libmpi.a @LPMPILIBNAME@ $PROFILE_POSTLIB ${final_libs} ${fabric_dep}
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
rc=$?
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
$Show $CC ${final_cppflags} $PROFILE_INCPATHS ${final_cflags} "${allargs[@]}" -I$includedir
|
|
Packit Service |
c5cf8c |
rc=$?
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
exit $rc
|