summaryrefslogtreecommitdiffstats
path: root/doc/posix_users/gen_size_report
blob: da4d303343e6b7c18d8805565b747f9f21f95d04 (plain) (blame)
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#
#  Hack of a script to generate a very long list which contains
#  the size information for every service listed in this manual
#
#  This script must be modified by the user to tailor it for their
#  environment.  This is VERY ugly and could be replaced by something
#  nicer in the future if this report style is useful.
#
#  $Id$
# 

#cpu=sparc
#bsp=erc32

#cpu=powerpc
#bsp=mcp750

cpu=v850
bsp=bare
symprefix=_

#objdir=/usr1/rtems/build/build-${cpu}-rtems/${cpu}-rtems/c/${bsp}/
#libc=/opt/rtems/${cpu}-rtems/lib/libc.a
#libm=/opt/rtems/${cpu}-rtems/lib/libm.a
objdir=/usr1/rtems/work/tools-v850/b-rtems/${cpu}-rtems/c/${bsp}/
libc=/usr2/test-v850/${cpu}-rtems/lib/libc.a
libm=/usr2/test-v850/${cpu}-rtems/lib/libm.a
srcdir=$r/src
docdir=$d
nm=${cpu}-rtems-nm
size=${cpu}-rtems-size
ar=${cpu}-rtems-ar

#
#  All customization should be above this point
#

check_objs()
{
  for i in *.o
  do
    ${nm} $i | grep "T ${symprefix}${1}$" >/dev/null
    if [ $? -eq  0 ] ; then
      echo $i
      return 0
    fi
  done
  return 1
}
per_manager()
{
  docfile=$1
  shift
  subdirs=$*
  grep ^@item ${docfile} | grep "@code.* - " | \
    grep -v "@item E" | \
    grep -v "@code{CONFIGURE" | \
    grep -v "@value{RPREFIX" | \
    sed -e 's/@value{DIRPREFIX}/rtems_/' | \
    cut -d'{' -f2 | sed -e 's/}//' | cut -d'-' -f1 >/tmp/XXX.size

  if [ `wc -c </tmp/XXX.size` -eq 1 ]  ; then
    return
  fi
  echo "====> `grep ^@chapter ${docfile} | sed -e 's/@chapter //'`"
  cat /tmp/XXX.size | while read line
  do
    # echo $line
    found=no
    for subd in ${subdirs}
    do
      if [ ${found} = "no" ] ; then
        cd ${objdir}/${subd}/o-optimize/
        objfile=`check_objs $line`
        if [ $? -eq 0 ] ; then
           found=yes
           #echo ${objfile}
           objcode=`${size} ${objfile} | tail -1 | cut -f1`
           objdata=`${size} ${objfile} | tail -1 | cut -f2`
           objbss=`${size} ${objfile} | tail -1 | cut -f3`
           objcode=`echo ${objcode}`
           objdata=`echo ${objdata}`
           objbss=`echo ${objbss}`
           echo "${line} - ${objcode}, ${objdata}, ${objbss}"
        fi
      fi
    done
    if [ ${found} = "no" ] ; then
      echo "$line - macro or not implemented"
    fi
   
  done
}


# extract libc
if [ ! -d ${objdir}/newlib_extract/o-optimize ] ; then
  mkdir -p ${objdir}/newlib_extract/o-optimize
  cd ${objdir}/newlib_extract/o-optimize
  list=`${ar} t ${libc}`
  for i in $list
  do
    ${ar} x ${libc} ${i}
  done
fi

# extract libm
if [ ! -d ${objdir}/libm_extract/o-optimize ] ; then
  mkdir -p ${objdir}/libm_extract/o-optimize
  cd ${objdir}/libm_extract/o-optimize
  list=`${ar} t ${libm}`
  for i in $list
  do
    ${ar} x ${libm} ${i}
  done
fi

# grab the size of the Classic API
#
#  NOTE: This API is always configured.
#
cd ${docdir}/user
echo
echo "=============================================================="
echo "=============================================================="
echo "====                                                      ===="
echo "====            CLASSIC API SIZE INFORMATION              ===="
echo "====                                                      ===="
echo "=============================================================="
echo "=============================================================="
echo
if [ -r ${objdir}/../../../${bsp}/lib/librtems.a ] ; then
  for i in *.t
  do
    per_manager $i exec/rtems/src exec/sapi/src lib/libc
  done
else
  echo "RTEMS Classic API not configured."
fi

# Grab the size of the POSIX API
cd ${docdir}/posix_users
echo
echo "=============================================================="
echo "=============================================================="
echo "====                                                      ===="
echo "====         POSIX 1003.1b API SIZE INFORMATION           ===="
echo "====                                                      ===="
echo "=============================================================="
echo "=============================================================="
echo
if [ -r ${objdir}/../../../${bsp}/lib/libposix.a ] ; then
  for i in `ls -1 *.t | grep -v libc.t | grep -v libm.t`
  do
    per_manager $i exec/posix/src lib/libc newlib_extract
  done
else
  echo "POSIX API not configured."
fi

# Grab the size of the POSIX routines provided by the C Library
cd ${docdir}/posix_users
echo
echo "=============================================================="
echo "=============================================================="
echo "====                                                      ===="
echo "====             LIBC API SIZE INFORMATION                ===="
echo "====                                                      ===="
echo "=============================================================="
echo "=============================================================="
echo
for i in libc.t
do
  per_manager $i exec/posix/src lib/libc newlib_extract
done

# Grab the size of the libm routines
cd ${docdir}/posix_users
echo
echo "=============================================================="
echo "=============================================================="
echo "====                                                      ===="
echo "====             LIBM API SIZE INFORMATION                ===="
echo "====                                                      ===="
echo "=============================================================="
echo "=============================================================="
echo
for i in libm.t
do
  per_manager $i exec/posix/src lib/libc libm_extract
done

# Grab the size of the ITRON API
cd ${docdir}/itron3.0
echo
echo "=============================================================="
echo "=============================================================="
echo "====                                                      ===="
echo "====           ITRON 3.0 API SIZE INFORMATION             ===="
echo "====                                                      ===="
echo "=============================================================="
echo "=============================================================="
echo
if [ -r ${objdir}/../../../${bsp}/lib/libitron.a ] ; then
  for i in *.t
  do
    per_manager $i exec/itron/src
  done
else
  echo "ITRON API not configured."
fi