Forked from
Core Modules / dune-common
7254 commits behind the upstream repository.
-
Christian Engwer authored
[[Imported from SVN: r4735]]
Christian Engwer authored[[Imported from SVN: r4735]]
mpi-config 1.99 KiB
#!/bin/bash
set -e
canonicalname(){
if test $# -ne 1; then
echo Usage: canonicalname path > /dev/stderr
return 1
fi
readlink $1 || echo "$(dirname $1)/$(basename $1)"
}
canonicalpath(){
if test $# -ne 1; then
echo Usage: canonicalpath path > /dev/stderr
return 1
fi
(cd $(dirname $(canonicalname $1)) && pwd)
}
version=0.1
verbose=0
usage()
{
cat <<EOF
Usage: mpi-config [OPTIONS] [LIBRARIES]
Options:
[--mpicc[=COMPILER]]
[--disable-cxx]
[--verbose]
[--version]
[--mpiversion]
[--libs]
[--cflags]
EOF
exit $1
}
if test $# -eq 0 ; then
usage 1 1>&2
fi
while test $# -gt 0 ; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--mpicc=*)
MPICC=$optarg
;;
--version)
echo $version
exit 0
;;
--verbose)
verbose=1
;;
--disable-cxx)
disablecxx=yes
;;
--mpiversion)
tasks="$tasks print_mpiversion"
;;
--cflags)
tasks="$tasks print_cflags"
;;
--libs)
tasks="$tasks print_libs"
;;
*)
usage 1 1>&2
;;
esac
shift
done
if test x$MPICC = x ; then
MPICC=mpicc
fi
#
# LIB
#
# load mpi-config.m4
#
eval "$(
m4 -I$(canonicalpath $0)/../m4/ <<EOF
changequote([, ])
define([AC_DEFUN],[define([\$1],[\$2])])
define([AC_MSG_CHECKING],[
if test $verbose -gt 0; then
echo -n "checking \$@..."
fi
])
define([AC_MSG_RESULT],[
if test $verbose -gt 0; then
echo " \$@"
fi
])
define([AC_MSG_NOTICE],[
if test $verbose -gt 0; then
echo "\$@"
fi
])
define([AC_MSG_ERROR],[
if test $verbose -gt 0; then
echo "Error: \$@"
exit 1
fi
])
include([mpi-config.m4])
MPI_CONFIG_HELPER
EOF
)"
#
# output methods
#
print_mpiversion() {
get_mpiparameters
echo $MPI_VERSION
}
print_cflags() {
get_mpiparameters
if test x$disablecxx = xyes; then
MPI_CPPFLAGS="$MPI_CPPFLAGS $MPI_NOCXXFLAGS"
fi
echo $MPI_CPPFLAGS
}
print_libs() {
get_mpiparameters
echo $MPI_LDFLAGS
}
for task in $tasks; do
eval $task
done