File: tau_cc.sh

package info (click to toggle)
tau 2.17.3.1.dfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 20,488 kB
  • ctags: 27,426
  • sloc: java: 94,358; cpp: 51,160; ansic: 48,343; tcl: 15,473; sh: 10,475; fortran: 8,357; python: 5,643; makefile: 3,665; f90: 632; sql: 454; perl: 260; xml: 231; yacc: 117; php: 93; csh: 82; sed: 59; modula3: 29; awk: 19
file content (155 lines) | stat: -rwxr-xr-x 5,053 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

# Define variables 
makefile_specified=no
options_specified=no

# depending on the options, we might invoke the regular compiler, TAU_COMPILER, or both
invoke_without_tau=no
invoke_with_tau=yes

DEFAULT_MAKEFILE=

if [ $# = 0 ] ; then
    cmd=`basename $0`
    echo ""
    echo " $cmd - C compiler wrapper for TAU"
    echo ""
    echo " Usage: $cmd [-tau_makefile=<tau_stub_makefile>]"
    echo "             [-tau_options=<tau_compiler_opts>] <opts> <file>"
    echo ""
    echo " If -tau_makefile option is not used, "
    echo " TAU uses the file specified in the TAU_MAKEFILE environment variable"
    echo " e.g., "
    echo " % $cmd -tau_makefile=/usr/local/tau-2.x/ia64/lib/Makefile.tau-mpi-pdt "
    echo "        -tau_options=-optVerbose -c foo.c"
    echo "    or"
    echo " % setenv TAU_MAKEFILE /usr/local/tau-2.x/include/Makefile"
    echo " % setenv TAU_OPTIONS -optVerbose -optTauSelectFile=select.tau"
    echo " % $cmd -c foo.c"
    echo ""
    echo "TAU_OPTIONS:"
    echo ""
    printf "  -optVerbose\t\t\tTurn on verbose debugging message"
    printf "  -optDetectMemoryLeaks\t\tTrack mallocs/frees using TAU's memory wrapper"
    printf "  -optPdtGnuFortranParser\tSpecify the GNU gfortran PDT parser gfparse instead of f95parse"
    printf "  -optPdtCleanscapeParser\tSpecify the Cleanscape Fortran parser"
    printf "  -optTauSelectFile=\"\"\t\tSpecify selective instrumentation file for tau_instrumentor"
    printf "  -optPreProcess\t\tPreprocess the source code before parsing. Uses /usr/bin/cpp -P by default."
    printf "  -optKeepFiles\t\t\tDoes not remove intermediate .pdb and .inst.* files" 
    printf "  -optShared\t\t\tUse shared library version of TAU."
    printf "  -optCompInst\t\t\tUse compiler-based instrumentation."
    printf "  -optPDTInst\t\t\tUse PDT-based instrumentation."
    echo ""
    exit 1
fi

TAUARGS=
NON_TAUARGS=
EATNEXT=false

for arg in "$@" ; do
  # Thanks to Bernd Mohr for the following that handles quotes and spaces (see configure for explanation)
  modarg=`echo "x$arg" | sed -e 's/^x//' -e 's/"/\\\"/g' -e s,\',%@%\',g -e 's/%@%/\\\/g' -e 's/ /\\\ /g' -e 's#(#\\\(#g' -e 's#)#\\\)#g'`
  if [ $EATNEXT = true ] ; then
      # these arguments should only go to the non-tau invocation
      NON_TAUARGS="$NON_TAUARGS $modarg"
      EATNEXT=false
  else
      case $arg in 
	  -tau_makefile=*)
	      MAKEFILE=`echo $arg | sed -e 's/-tau_makefile=//'`
	      makefile_specified=yes
	      ;;
	  -tau_options=*)
	      TAUCOMPILER_OPTIONS=`echo $arg | sed -e 's/-tau_options=//'`
	      options_specified=yes
	      ;;
	  -show)
	      invoke_without_tau=yes
	      invoke_with_tau=no
	      NON_TAUARGS="$NON_TAUARGS $modarg"
              SHOW=show
	      ;;
	  -E)
	      invoke_without_tau=yes
	      invoke_with_tau=no
	      NON_TAUARGS="$NON_TAUARGS $modarg"
	      ;;
	  -MD | -MMD)
              # if either of these are specified, we invoke the regular compiler
              # and TAU_COMPILER, unless -E or another disabling option is specified
	      invoke_without_tau=yes
	      NON_TAUARGS="$NON_TAUARGS $modarg"
	      ;;
	  -MF | -MT | -MQ)
              # these arguments should only go to the non-tau invocation
	      NON_TAUARGS="$NON_TAUARGS $modarg"
	      # we must eat the next argument as well and use it for the non-tau invocation only
	      EATNEXT=true
	      ;;
	  -MF* | -MT* | -MQ* | -MP | -MG)
              # these arguments should only go to the non-tau invocation
	      NON_TAUARGS="$NON_TAUARGS $modarg"
	      ;;
	  -M | -MM | -V | -v | --version | -print-prog-name=ld | -print-search-dirs | -dumpversion)
              # if any of these are specified, we invoke the regular compiler only
	      invoke_without_tau=yes
	      invoke_with_tau=no
	      NON_TAUARGS="$NON_TAUARGS $modarg"
	      ;;
	  *)
	      TAUARGS="$TAUARGS $modarg"
	      NON_TAUARGS="$NON_TAUARGS $modarg"
	      ;;
      esac
  fi
done

if [ $makefile_specified = no ] ; then
    MAKEFILE=$TAU_MAKEFILE
    if [ "x$MAKEFILE" != "x" ] ; then
	if [ ! -r $MAKEFILE ] ; then
	    echo "ERROR: environment variable TAU_MAKEFILE is set but the file is not readable"
	    exit 1
        fi
    elif [ "x$DEFAULT_MAKEFILE" != "x" ] ; then
	MAKEFILE=$DEFAULT_MAKEFILE
    else
	echo $0: "ERROR: please set the environment variable TAU_MAKEFILE"
	exit 1
    fi
fi

if [ $options_specified = no ] ; then
    TAUCOMPILER_OPTIONS=$TAU_OPTIONS
    if [ "x$TAUCOMPILER_OPTIONS" = "x" ] ; then
	TAUCOMPILER_OPTIONS=-optVerbose 
    fi
fi

tmpmakefile=$( mktemp --tmpdir makefile.tau.$USER.$$-XXXXXX )

if [ $invoke_without_tau = yes ] ; then
cat <<EOF > $tmpmakefile
include $MAKEFILE
all:
	@\$(TAU_RUN_CC) \$(TAU_MPI_INCLUDE) $NON_TAUARGS
show:
	@echo \$(TAU_RUN_CC) \$(TAU_MPI_FLIBS) \$(TAU_LIBS) \$(TAU_LDFLAGS) \$(TAU_CXXLIBS)
EOF
make -s -f $tmpmakefile $SHOW
fi


if [ $invoke_with_tau = yes ] ; then
cat <<EOF > $tmpmakefile
include $MAKEFILE
all:
	@\$(TAU_COMPILER) $TAUCOMPILER_OPTIONS \$(TAU_RUN_CC) $TAUARGS

EOF
make -s -f $tmpmakefile 
fi

/bin/rm -f $tmpmakefile