|
Packit |
0848f5 |
#! @BASH_SHELL@
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# (C) 2006 by Argonne National Laboratory.
|
|
Packit |
0848f5 |
# See COPYRIGHT in top-level directory.
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# mpicc
|
|
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 |
# CC - C compiler
|
|
Packit |
0848f5 |
# WRAPPER_CFLAGS - 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 |
#
|
|
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 |
CC="@CC@"
|
|
Packit |
0848f5 |
MPICH_VERSION="@MPICH_VERSION@"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
enable_wrapper_rpath="@enable_wrapper_rpath@"
|
|
Packit |
0848f5 |
@cc_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=
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# End of initialization of variables
|
|
Packit |
0848f5 |
#---------------------------------------------------------------------
|
|
Packit |
0848f5 |
# Environment Variables.
|
|
Packit |
0848f5 |
# The environment variables MPICH_CC may be used to override the
|
|
Packit |
0848f5 |
# default choices.
|
|
Packit |
0848f5 |
# In addition, if there is a file $sysconfdir/mpicc-$CCname.conf,
|
|
Packit |
0848f5 |
# where CCname is the name of the compiler with all spaces replaced by hyphens
|
|
Packit |
0848f5 |
# (e.g., "cc -64" becomes "cc--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_CC_OLD, MPICH_CC can be used to prefix CC with external utility,
|
|
Packit |
0848f5 |
# e.g. setenv MPICH_CC 'eval linkcache $MPICH_CC_OLD'
|
|
Packit |
0848f5 |
if [ -n "$MPICH_CC" ] ; then
|
|
Packit |
0848f5 |
MPICH_CC_OLD="$CC"
|
|
Packit |
0848f5 |
CC="$MPICH_CC"
|
|
Packit |
0848f5 |
CCname=`echo $CC | sed 's/ /-/g'`
|
|
Packit |
0848f5 |
if [ -s $sysconfdir/mpicc-$CCname.conf ] ; then
|
|
Packit |
0848f5 |
. $sysconfdir/mpicc-$CCname.conf
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
# Allow a profiling option to be selected through an environment variable
|
|
Packit |
0848f5 |
if [ -n "$MPICC_PROFILE" ] ; then
|
|
Packit |
0848f5 |
profConf=$MPICC_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 |
argno=0
|
|
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 |
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 mpicc (e.g., -show,
|
|
Packit |
0848f5 |
# -cc=* -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 |
-cc=*)
|
|
Packit |
0848f5 |
CC=`echo A$arg | sed -e 's/A-cc=//g'`
|
|
Packit |
0848f5 |
addarg=no
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
-show)
|
|
Packit |
0848f5 |
addarg=no
|
|
Packit |
0848f5 |
Show=echo
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
-config=*)
|
|
Packit |
0848f5 |
addarg=no
|
|
Packit |
0848f5 |
CCname=`echo A$arg | sed -e 's/A-config=//g'`
|
|
Packit |
0848f5 |
if [ -s "$sysconfdir/mpicc-$CCname.conf" ] ; then
|
|
Packit |
0848f5 |
. "$sysconfdir/mpicc-$CCname.conf"
|
|
Packit |
0848f5 |
else
|
|
Packit |
0848f5 |
echo "Configuration file mpicc-$CCname.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 "mpicc 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 "$CC" | sed 's%\/% %g' | awk '{print $NF}' -`
|
|
Packit |
0848f5 |
if [ -f "$sysconfdir/mpixxx_opts.conf" ] ; then
|
|
Packit |
0848f5 |
. $sysconfdir/mpixxx_opts.conf
|
|
Packit |
0848f5 |
echo " -cc=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 " -cc=xxx - Reset the native compiler to xxx."
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
exit 0
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
*)
|
|
Packit |
0848f5 |
;;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
esac
|
|
Packit |
0848f5 |
if [ $addarg = no ] ; then
|
|
Packit |
0848f5 |
unset allargs[$argno]
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
# Some versions of bash do not accept ((argno++))
|
|
Packit |
0848f5 |
argno=`expr $argno + 1`
|
|
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 |
|
|
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_cflags="@MPICH_MPICC_CFLAGS@ @WRAPPER_CFLAGS@"
|
|
Packit |
0848f5 |
final_cppflags="@MPICH_MPICC_CPPFLAGS@ @WRAPPER_CPPFLAGS@"
|
|
Packit |
0848f5 |
final_ldflags="@MPICH_MPICC_LDFLAGS@ @WRAPPER_LDFLAGS@"
|
|
Packit |
0848f5 |
final_libs="@MPICH_MPICC_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 |
# -----------------------------------------------------------------------
|
|
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 |
# We use a single invocation of the compiler. This will be adequate until
|
|
Packit |
0848f5 |
# we run into a system that uses a separate linking command. With any luck,
|
|
Packit |
0848f5 |
# such archaic systems are no longer with us. This also lets us
|
|
Packit |
0848f5 |
# accept any argument; we don't need to know if we've seen a source
|
|
Packit |
0848f5 |
# file or an object file. Instead, we just check for an option that
|
|
Packit |
0848f5 |
# suppressing linking, such as -c or -M.
|
|
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 $CC ${final_cppflags} $PROFILE_INCPATHS ${final_cflags} ${final_ldflags} "${allargs[@]}" -I$includedir
|
|
Packit |
0848f5 |
rc=$?
|
|
Packit |
0848f5 |
else
|
|
Packit |
0848f5 |
$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 |
0848f5 |
rc=$?
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
else
|
|
Packit |
0848f5 |
$Show $CC ${final_cppflags} $PROFILE_INCPATHS ${final_cflags} "${allargs[@]}" -I$includedir
|
|
Packit |
0848f5 |
rc=$?
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
exit $rc
|