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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
--- cflow.sh.orig Sun Feb 19 12:59:18 1995
+++ cflow.sh Wed Jun 3 16:03:01 1998
@@ -1,41 +1,38 @@
-#! @CFLOW_SHELL@
+#!/bin/sh -
# cflow - print a function call hierarchy
# This script is contributed to the public domain by Andrew Moore
# of Talke Studio.
-# exit on errors..
+: ${F2C:=f2c}
+: ${LEX:=flex}
+: ${YACC:="bison -y"}
+: ${CC:=gcc}
+: ${CPP:="$CC -E"}
+: ${PRCC:=/usr/local/bin/prcc}
+: ${PRCG:=/usr/local/bin/prcg}
+: ${RM:=/bin/rm}
-# this values can be overriden by devining them in the
-# enviornment
-F2C=${F2C:=f2c}
-LEX=${LEX:=flex}
-YACC={YACC:="bison -y"}
-CC=${CC:=gcc}
-CPP=${CPP:="$CC -E"}
-PRCC=${PRCC:=@PRCC@}
-PRCG=${PRCG:=@PRCG@}
TMPFILE=/tmp/cflow.$$
-function prcc {
+prcc () {
if [ $verbose ]; then
echo $PRCC $* >/dev/tty
fi
-
- command $PRCC $*
+ $PRCC $*
}
-function prcg {
+prcg () {
if [ $verbose ]; then
echo $PRCG $* >/dev/tty
fi
- command $PRCG $*
+ $PRCG $*
}
-function echo {
- builtin echo -e "$*"
+echo () {
+ printf "$*\n"
}
@@ -50,8 +47,7 @@
progname=$0
-function usage
-{
+usage () {
echo $progname [-AaginPXVvxh] [-d n] [-w n] [-r name] [cpp-opts] files
echo "\t-a\tprint a seperate cal graph for each function"
echo "\t-A\teliminate ansi keywords"
@@ -86,8 +82,7 @@
exclude_directory="$exclude_directory".$$
fi
-function do_mkdir
-{
+do_mkdir () {
for i in $*
do
mkdir -p $i
@@ -98,27 +93,24 @@
done
}
-function remove_exclude_files
-{
+remove_exclude_files () {
if [ -d $exclude_directory ]; then
- rm -rf $exclude_directory
+ $RM -rf $exclude_directory
fi
}
-function remove_tmp_file
-{
+remove_tmp_file () {
if [ "$save_temps" ] ; then
echo temp file in $TMPFILE
else
- rm $TMPFILE
+ $RM $TMPFILE
fi
}
-# call this once when we get are include files
+# call this once when we get our include files
# called only if we want to exclude files
-function exclude
-{
+exclude () {
if [ "$exclude_files" ]; then
do_mkdir $exclude_directory
fi
@@ -136,12 +128,9 @@
done
}
-#builtin -d echo # use gnu echo
# echo command line is $* >& 2
while getopts aghsAPD:I:X:nU:d:ir:Vvw:x c; do
-# echo option is $c
-# echo OPTARG = $OPTARG
case $c in
D)
CPP="$CPP -D$OPTARG"
@@ -202,44 +191,48 @@
esac
done
+shift $(expr $OPTIND - 1)
+
+if [ $# -eq 0 ]; then
+ usage
+fi
+
if [ "$exclude_files" ]; then
exclude
CPP="$CPP -I$exclude_directory"
fi
-
-
-
-let count=$OPTIND-1
-shift $count
-unset count
-
-if [ $# -eq 0 ]; then
- usage
+cat >${TMPFILE}.c <<\EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if ${CPP} ${TMPFILE}.c | egrep yes >/dev/null 2>&1; then
+ CPP="${CPP} -D__attribute__(x)="
fi
+$RM -f ${TMPFILE}.c
-for c in $*
-do
+for c in $*; do
case $c in
*.c|*.cc|*.C)
cname=$c
;;
*.f)
- cname=`basename $c .f`.c
+ cname=$(basename $c .f).c
cat $c | $F2C >$cname
;;
*.F)
- cname=`basename $c .F`.C
+ cname=$(basename $c .F).C
cat $c | $F2C >$cname
;;
*.l)
- cname=`basename $c .l`.c
+ cname=$(basename $c .l).c
$LEX $c
sed '/# line/d' lex.yy.c >$cname
;;
*.y)
- cname=`basename $c .y`.c
+ cname=$(basename $c .y).c
$YACC $c
sed '/# line/d' y.tab.c >$cname
;;
@@ -267,6 +260,7 @@
$CPP $cname >>$TMPFILE
done
+
if [ "$no_prcg" ]; then
PRCG=cat
|