summaryrefslogtreecommitdiffstats
path: root/doc/posix_users/gen_size_report
blob: 06b9bb5054e9448f19979bcbb288c9858444402b (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
#
#  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

objdir=/usr1/rtems/build/build-${cpu}-rtems/${cpu}-rtems/c/${bsp}/
libc=/opt/rtems/${cpu}-rtems/lib/libc.a
srcdir=$r/src
docdir=$d
nm=${cpu}-rtems-nm
size=${cpu}-rtems-size
ar=${cpu}-rtems-ar

check_objs()
{
  for i in *.o
  do
    ${nm} $i | grep "T ${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

# 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
for i in *.t
do
  per_manager $i exec/rtems/src exec/sapi/src lib/libc
done

# Grab the size of the Classic 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 *.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 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