1#! /bin/sh 2# 3# mpecc : Script to compile and/or link MPI programs with MPE libraries. 4# 5MPE_ETCDIR=@etcbuild_dir@ 6 7MPI_CC="@MPI_CC@" 8MPI_CLINKER=$MPI_CC 9 10MPI_CFLAGS="@MPI_CFLAGS@" 11MPI_LIBS="@MPI_LIBS@" 12CFLAGS="@CFLAGS@" 13 14LDFLAGS="@LDFLAGS@" 15MPE_BUILD_FORTRAN2C=@MPE_BUILD_FORTRAN2C@ 16 17# Internal variables 18# Show is set to echo to cause the compilation command to be echoed instead 19# of executed. 20Show=eval 21 22# ------------------------------------------------------------------------ 23# Argument processing. 24# Look through the arguments for arguments that indicate compile only. 25# If these are *not* found, add the library options 26 27linking=yes 28allargs="" 29for arg in "$@" ; do 30 # Set addarg to no if this arg should be ignored by the C compiler 31 addarg=yes 32 qarg=$arg 33 case $arg in 34 # ---------------------------------------------------------------- 35 # Compiler options that affect whether we are linking or no 36 -c|-S|-E|-M|-MM) 37 # The compiler links by default 38 linking=no 39 ;; 40 # ---------------------------------------------------------------- 41 # Options that control how we use mpicc (e.g., -show, 42 # -cc=* -config=* 43 -echo) 44 addarg=no 45 set -x 46 ;; 47 -mpicc=*) 48 MPI_CC=`echo A$arg | sed -e 's/A-mpicc=//g'` 49 MPI_CLINKER=$MPI_CC 50 addarg=no 51 ;; 52 -show) 53 addarg=no 54 Show=echo 55 ;; 56 -mpilog|-mpitrace|-mpianim|-mpicheck|-graphics|-log|-nolog) 57 profConf=`echo A$arg | sed -e 's/A-//g'` 58 profConf="mpe_$profConf" 59 addarg=no 60 # Loading the profConf file is handled below 61 ;; 62 -h|-help) 63cat <<EOF 64mpecc : To compile or link C MPI programs with MPE profiling libraries. 65 In addition, the following special options are supported. 66 -h|-help : Display this help message. 67 -echo : Do set -x. 68 -show : Show the command that would be used without executing it. 69 -mpicc : Reset the MPI_CC used in this script. 70EOF 71 if [ -f $MPE_ETCDIR/mpe_help.conf ] ; then 72 . $MPE_ETCDIR/mpe_help.conf 73 fi 74 exit 1 75 ;; 76 # ----------------------------------------------------------------- 77 # Other arguments. We are careful to handle arguments with 78 # quotes (we try to quote all arguments in case they include 79 # any spaces) 80 *\"*) 81 qarg="'"$arg"'" 82 ;; 83 *\'*) 84 qarg='\"'"$arg"'\"' 85 ;; 86 *) 87 ;; 88 89 esac 90 if [ $addarg = yes ] ; then 91 allargs="$allargs $qarg" 92 fi 93done 94 95# Handle the case of a profile switch 96if [ -n "$profConf" ] ; then 97 if [ -s "$MPE_ETCDIR/$profConf.conf" ] ; then 98 . $MPE_ETCDIR/$profConf.conf 99 else 100 echo "mpecc: **** No profiling configuration file $profConf.conf is found in $MPE_ETCDIR" 101 exit 1; 102 fi 103else 104 echo "mpecc: **** No profiling option is specifed!" 105fi 106 107# MPE include path, x_INCS, goes in front of MPI include path, MPI_xFLAGS, 108# in case MPI include path is in MPI_xFLAGS containing old MPE include path. 109C_INCS="$PROFILE_INCPATHS $MPI_CFLAGS" 110MPICC_FLAGS="$C_INCS $MPE_COPTS" 111MPICC_LDFLAGS="$LDFLAGS $C_INCS $MPE_LDOPTS" 112 113if [ "$linking" = yes ] ; then 114 $Show $MPI_CLINKER $MPICC_LDFLAGS $allargs $PROFILE_PRELIB $MPI_LIBS $PROFILE_POSTLIB 115 rc=$? 116else 117 $Show $MPI_CC $MPICC_FLAGS $allargs 118 rc=$? 119fi 120 121exit $rc 122