|
Packit |
857059 |
#! /bin/bash
|
|
Packit |
857059 |
# A simple wrapper of mpif77 to force it uses RPATH
|
|
Packit |
857059 |
#set -x
|
|
Packit |
857059 |
echo "REAL_MPICC=$REAL_MPICC"
|
|
Packit |
857059 |
# generate compile string and replace 'enable-new-dtags' with 'disable-new-dtags'
|
|
Packit |
857059 |
# to force use RPATH. Given we can have space in quoted string that will cause
|
|
Packit |
857059 |
# wrong word splitting, we split string into arguments by ourselves with ' -'.
|
|
Packit |
857059 |
# To do it, we replace ' -' with '\n-' and then split the string with customized
|
|
Packit |
857059 |
# IFS that is set to new line
|
|
Packit |
857059 |
cmd_str=$($REAL_MPICC -show "$@" | sed -e 's/enable-new-dtags/disable-new-dtags/g' -e 's/[[:space:]]\+-/\n-/g')
|
|
Packit |
857059 |
OLDIFS=$IFS
|
|
Packit |
857059 |
IFS=$'\n'
|
|
Packit |
857059 |
args=()
|
|
Packit |
857059 |
# for each argument that constains '"', we escape special characters in the argument.
|
|
Packit |
857059 |
# Please note that an argument only can contain one quoted string, so it's fine
|
|
Packit |
857059 |
# to do escape in the whole string
|
|
Packit |
857059 |
for arg in ${cmd_str[@]}; do
|
|
Packit |
857059 |
if [[ "$arg" == *\"* ]]; then
|
|
Packit |
857059 |
args+=" $'$arg'"
|
|
Packit |
857059 |
else
|
|
Packit |
857059 |
args+=" $arg"
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
done
|
|
Packit |
857059 |
IFS=$OLDIFS
|
|
Packit |
857059 |
eval "${args[*]}"
|