1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
#! /bin/sh
DoLink=1
DoCompile=0
MPILOG=
Show=eval
allargs=
compileargs=
linkargs=
linkobjs=
gettinglinkarg=0
HasDashC=0
UsesPmpi=0
for arg in "$@" ; do
# echo procssing arg $arg
# Special processing for -o name
if [ $gettinglinkarg = 1 ] ; then
linkargs="$linkargs $arg"
gettinglinkarg=0
continue
fi
case "$arg" in
-c)
# If -c is NOT specified, then we need to perform a link step.
allargs="$allargs $arg"
compileargs="$compileargs $arg"
DoLink=0
HasDashC=1
;;
-o)
# Need to link
allargs="$allargs $arg"
if [ $HasDashC = 1 ] ; then
# Some BUT NOT ALL compilers support -o with -c. Allow
# the user to make use of the feature, IF IT EXISTS.
compileargs="$compileargs $arg"
else
linkargs="$linkargs $arg"
compileargs="$compileargs -c"
# Still need to add the target of the -o
gettinglinkarg=1
DoLink=1
fi
;;
-l*)
# This SHOULD be the -l<lib> argument. Only for the linker
linkargs="$linkargs $arg"
allargs="$allargs $arg"
;;
-mpilog)
if [ $UsesPmpi = 1 ] ; then
echo "Only one of -mpilog, -mpitrace, or -mpianim may be used."
exit 1
else
UsesPmpi=1
fi
if [ -n "@MPE_LIBS@" ] ; then
MPILOG=-llmpi
else
echo "-mpilog requires the MPE libraries"
fi
;;
-mpitrace)
if [ $UsesPmpi = 1 ] ; then
echo "Only one of -mpilog, -mpitrace, or -mpianim may be used."
exit 1
else
UsesPmpi=1
fi
if [ -n "@MPE_LIBS@" ] ; then
MPILOG=-ltmpi
else
echo "-mpitrace requires the MPE libraries"
fi
;;
-mpianim)
if [ $UsesPmpi = 1 ] ; then
echo "Only one of -mpilog, -mpitrace, or -mpianim may be used."
exit 1
else
UsesPmpi=1
fi
if [ -n "@MPE_LIBS@" ] ; then
MPILOG="-lampi @MPE_LIBS@ @X_LIB@"
else
echo "-mpianim requires the MPE libraries"
fi
;;
-echo)
set -x
;;
-show)
Show=echo
;;
-help)
echo "This is a program to compile or link MPI programs"
echo "In addition, the following special options are supported"
echo " -mpilog - Build version that generate MPE log files"
echo " -mpitrace - Build version that generates traces"
echo " -mpianim - Build version that generates real-time"
echo " animation"
echo " -show - Show the commands that would be used without"
echo " runnning them"
echo " -help - Give this help"
echo " -echo - Show exactly what this program is doing."
echo " This option should normally not be used."
echo "This should be used just like the usual C compiler"
echo "For example,"
echo " $0 -c foo.c "
echo "and"
echo " $0 -o foo foo.o"
echo "Combining compilation and linking in a single command"
echo " $0 -o foo foo.c"
echo "may not work on some systems, and is not recommended."
exit 1
;;
*\"*)
allargs="$allargs `echo $arg | sed 's/\"/\\\"/g'`"
compileargs="$compileargs `echo $arg | sed 's/\"/\\\"/g'`"
linkargs="$linkargs `echo $arg | sed 's/\"/\\\"/g'`"
;;
*) allargs="$allargs $arg"
if [ -s "$arg" ] ; then
ext=`expr "$arg" : '.*\(\..*\)'`
if [ "$ext" = ".c" ] ; then
DoCompile=1
compileargs="$compileargs $arg"
fname=`basename $arg .c`
linkobjs="$linkobjs $fname.o"
elif [ "$ext" = ".o" ] ; then
if [ $HasDashC = 1 ] ; then
compileargs="$compileargs $arg"
else
DoLink=1
linkobjs="$linkobjs $arg"
fi
else
compileargs="$compileargs $arg"
linkargs="$linkargs $arg"
fi
else
compileargs="$compileargs $arg"
linkargs="$linkargs $arg"
fi
;;
esac
done
#
status=0
if [ $DoCompile = 1 ] ; then
if [ $HasDashC != 1 ] ; then
compileargs="-c $compileargs"
fi
$Show @CC@ @CFLAGS@ -DMPI_@ARCH@ -I@MPIR_HOME@/include \
-I@MPIR_HOME@/lib/@ARCH@/@COMM@ $compileargs
status=$?
if [ $status != 0 ] ; then
exit $status
fi
fi
if [ $DoLink = 1 ] ; then
if [ -n "$MPILOG" ] ; then
$Show @CLINKER@ @LIB_PATH@ $linkobjs $MPILOG $linkargs -lp@MPILIBNAME@ @LIB_LIST@
else
# linkargs needs to be after linkobjs for things like "-lm"
$Show @CLINKER@ @LIB_PATH@ $linkobjs $linkargs @LIB_LIST@
fi
status=$?
fi
exit $status
|