1 | #!KSHELL -p |
---|
2 | # |
---|
3 | # size_rtems |
---|
4 | # |
---|
5 | # This script gathers information related to the size of RTEMS |
---|
6 | # using the GNU "size" command. |
---|
7 | # |
---|
8 | # This script operates by summing up the sizes of the various |
---|
9 | # object files which constitute a particular configuration of |
---|
10 | # RTEMS. This size information is gathered for placement in the |
---|
11 | # brochure flyers and supplement manuals. |
---|
12 | # |
---|
13 | # NOTE: The concept of the minimum executive size is buried in this script. |
---|
14 | # |
---|
15 | # COPYRIGHT (c) 1989-1998. |
---|
16 | # On-Line Applications Research Corporation (OAR). |
---|
17 | # Copyright assigned to U.S. Government, 1994. |
---|
18 | # |
---|
19 | # The license and distribution terms for this file may be |
---|
20 | # found in the file LICENSE in this distribution or at |
---|
21 | # http://www.OARcorp.com/rtems/license.html. |
---|
22 | # |
---|
23 | # $Id$ |
---|
24 | # |
---|
25 | |
---|
26 | target=@target@ |
---|
27 | program_prefix=@program_prefix@ |
---|
28 | |
---|
29 | gnusize=${program_prefix}size |
---|
30 | |
---|
31 | # check usage |
---|
32 | if [ $# -ne 2 ] ; then |
---|
33 | echo usage ${0}: bsp object_directory |
---|
34 | exit 1 |
---|
35 | fi |
---|
36 | |
---|
37 | bsp=$1 |
---|
38 | board=$1 |
---|
39 | ARCH=$2 |
---|
40 | |
---|
41 | cpu=`echo $target | sed -e 's/-.*//'` |
---|
42 | |
---|
43 | case $target in |
---|
44 | sparc-sun-solaris*) |
---|
45 | rtems_cpu=unix |
---|
46 | bsp=solaris2 |
---|
47 | echo Not supported on unix port. |
---|
48 | exit 0 |
---|
49 | ;; |
---|
50 | i[3456]86-pc-linux-gnu) |
---|
51 | echo linux |
---|
52 | rtems_cpu=unix |
---|
53 | bsp=linux1 |
---|
54 | echo Not supported on unix port. |
---|
55 | exit 0 |
---|
56 | ;; |
---|
57 | *-rtems*) |
---|
58 | cpu=`echo $target | sed -e 's/-.*//'` |
---|
59 | case $cpu in |
---|
60 | hppa1.1) rtems_cpu=hppa1_1 ;; |
---|
61 | powerpc) rtems_cpu=ppc ;; |
---|
62 | *) rtems_cpu=$cpu ;; |
---|
63 | esac |
---|
64 | ;; |
---|
65 | *) |
---|
66 | echo unknown target $target |
---|
67 | exit 1 |
---|
68 | ;; |
---|
69 | esac |
---|
70 | |
---|
71 | case $ARCH in |
---|
72 | *debug*) VARIANT=debug ;; |
---|
73 | *profile*) VARIANT=profile ;; |
---|
74 | *) VARIANT=optimized;; |
---|
75 | esac |
---|
76 | |
---|
77 | echo |
---|
78 | echo Size Information for the Following Configuration: |
---|
79 | echo CPU: ${cpu} |
---|
80 | echo BSP: ${board} |
---|
81 | echo VARIANT: ${VARIANT} |
---|
82 | echo |
---|
83 | |
---|
84 | |
---|
85 | # |
---|
86 | # KLUDGE to figure out at runtime how to echo a line without a |
---|
87 | # newline. |
---|
88 | # |
---|
89 | count=`echo "\\c" | wc -c` |
---|
90 | if [ ${count} -ne 0 ] ; then |
---|
91 | EARG="-n" |
---|
92 | EOL="" |
---|
93 | else |
---|
94 | EARG="" |
---|
95 | EOL="\\c" |
---|
96 | fi |
---|
97 | |
---|
98 | if [ ! -d ${board} ] ; then |
---|
99 | echo "${board} does not exist ... is the current directory the build directory?" |
---|
100 | exit 1 |
---|
101 | fi |
---|
102 | |
---|
103 | #DIRLIST -- so greps for DIRLIST will find this file |
---|
104 | CPUOBJ=c/src/exec/score/cpu/${rtems_cpu}/${ARCH} |
---|
105 | COREOBJ=c/src/exec/score/src/${ARCH} |
---|
106 | RTEMSOBJ=c/src/exec/rtems/src/${ARCH} |
---|
107 | SAPIOBJ=c/src/exec/sapi/src/${ARCH} |
---|
108 | OPTOBJ=c/src/exec/rtems/optman/${ARCH} |
---|
109 | |
---|
110 | MANLIST=" \ |
---|
111 | ${RTEMSOBJ}/clock.o \ |
---|
112 | ${RTEMSOBJ}/dpmem.o \ |
---|
113 | ${RTEMSOBJ}/event.o \ |
---|
114 | ${RTEMSOBJ}/intr.o \ |
---|
115 | ${RTEMSOBJ}/msg.o \ |
---|
116 | ${RTEMSOBJ}/part.o \ |
---|
117 | ${RTEMSOBJ}/ratemon.o \ |
---|
118 | ${RTEMSOBJ}/region.o \ |
---|
119 | ${RTEMSOBJ}/sem.o \ |
---|
120 | ${RTEMSOBJ}/signal.o \ |
---|
121 | ${RTEMSOBJ}/tasks.o \ |
---|
122 | ${RTEMSOBJ}/timer.o \ |
---|
123 | ${SAPIOBJ}/debug.o \ |
---|
124 | ${SAPIOBJ}/extension.o \ |
---|
125 | ${SAPIOBJ}/fatal.o \ |
---|
126 | ${SAPIOBJ}/exinit.o \ |
---|
127 | ${SAPIOBJ}/io.o \ |
---|
128 | ${SAPIOBJ}/rtemsapi.o \ |
---|
129 | " |
---|
130 | MPLIST="\ |
---|
131 | ${RTEMSOBJ}/mp.o ${RTEMSOBJ}/eventmp.o \ |
---|
132 | ${COREOBJ}/mpci.o ${RTEMSOBJ}/msgmp.o ${COREOBJ}/objectmp.o \ |
---|
133 | ${RTEMSOBJ}/partmp.o ${RTEMSOBJ}/regionmp.o ${RTEMSOBJ}/semmp.o \ |
---|
134 | ${RTEMSOBJ}/signalmp.o ${RTEMSOBJ}/taskmp.o ${COREOBJ}/threadmp.o \ |
---|
135 | " |
---|
136 | |
---|
137 | OPTMANLIST="\ |
---|
138 | ${OPTOBJ}/no-dpmem.rel \ |
---|
139 | ${OPTOBJ}/no-event.rel \ |
---|
140 | ${OPTOBJ}/no-mp.rel \ |
---|
141 | ${OPTOBJ}/no-msg.rel \ |
---|
142 | ${OPTOBJ}/no-part.rel \ |
---|
143 | ${OPTOBJ}/no-region.rel \ |
---|
144 | ${OPTOBJ}/no-rtmon.rel \ |
---|
145 | ${OPTOBJ}/no-sem.rel \ |
---|
146 | ${OPTOBJ}/no-signal.rel \ |
---|
147 | ${OPTOBJ}/no-timer.rel \ |
---|
148 | " |
---|
149 | REQMANLIST="\ |
---|
150 | ${SAPIOBJ}/exinit.o \ |
---|
151 | ${RTEMSOBJ}/tasks.o \ |
---|
152 | ${RTEMSOBJ}/intr.o \ |
---|
153 | ${SAPIOBJ}/fatal.o \ |
---|
154 | " |
---|
155 | CORELIST=" \ |
---|
156 | ${COREOBJ}/apiext.o ${COREOBJ}/chain.o \ |
---|
157 | ${COREOBJ}/coremsg.o ${COREOBJ}/coremutex.o ${COREOBJ}/coresem.o \ |
---|
158 | ${COREOBJ}/heap.o ${COREOBJ}/interr.o \ |
---|
159 | ${COREOBJ}/isr.o \ |
---|
160 | ${COREOBJ}/object.o \ |
---|
161 | ${SAPIOBJ}/rtemsapi.o \ |
---|
162 | ${COREOBJ}/thread.o ${COREOBJ}/threadq.o ${COREOBJ}/tod.o \ |
---|
163 | ${COREOBJ}/userext.o \ |
---|
164 | ${COREOBJ}/watchdog.o ${COREOBJ}/wkspace.o \ |
---|
165 | " |
---|
166 | |
---|
167 | CPULIST="\ |
---|
168 | ${CPUOBJ}/rtems-cpu.rel \ |
---|
169 | " |
---|
170 | |
---|
171 | # check directories |
---|
172 | for i in ${EXECOBJ} ${CPUOBJ} ${OPTOBJ} |
---|
173 | do |
---|
174 | if [ ! -d ${i} ] ; then |
---|
175 | echo "${i} does not exist ... is RTEMS compiled and installed?" |
---|
176 | exit 1 |
---|
177 | fi |
---|
178 | done |
---|
179 | |
---|
180 | for i in ${MANLIST} ${MPLIST} ${OPTMANLIST} ${REQMANLIST} ${CORELIST} ${CPULIST} |
---|
181 | do |
---|
182 | if [ ! -r ${i} ] ; then |
---|
183 | echo ${i} does not exist ... is RTEMS compiled and installed? |
---|
184 | exit 1 |
---|
185 | fi |
---|
186 | done |
---|
187 | |
---|
188 | # "rips" a line of gsize's output and prints size, data, bss |
---|
189 | parse_size() |
---|
190 | { |
---|
191 | echo $1 $2 $3 |
---|
192 | } |
---|
193 | |
---|
194 | # prepares a list of code, data, bss sizes for a directory |
---|
195 | sizedir() |
---|
196 | { |
---|
197 | ${gnusize} $* | sed -e '1,1d' | |
---|
198 | while read line |
---|
199 | do |
---|
200 | parse_size ${line} |
---|
201 | done |
---|
202 | } |
---|
203 | |
---|
204 | # adds a column from the output of sizedir |
---|
205 | addsizes() |
---|
206 | { |
---|
207 | cut -d' ' -f${1} | sed -e '2,$s/$/ + /' -e '$,$s/$/ p/' | dc |
---|
208 | } |
---|
209 | |
---|
210 | # calculates total size of a directory and prints report line |
---|
211 | size_files() |
---|
212 | { |
---|
213 | trap "rm -f /tmp/size.$$ ; exit 1" 2 3 |
---|
214 | |
---|
215 | for file in $* |
---|
216 | do |
---|
217 | parse_size `${gnusize} $file | sed -e '/text/d'` |
---|
218 | done >/tmp/size.$$ |
---|
219 | |
---|
220 | code=`cat /tmp/size.$$ | addsizes 1` |
---|
221 | data=`cat /tmp/size.$$ | addsizes 2` |
---|
222 | bss=` cat /tmp/size.$$ | addsizes 3` |
---|
223 | echo "${code} ${data} ${bss}" |
---|
224 | rm /tmp/size.$$ |
---|
225 | } |
---|
226 | |
---|
227 | echo |
---|
228 | echo " RTEMS SIZE REPORT" |
---|
229 | echo |
---|
230 | echo " CODE DATA BSS" |
---|
231 | echo " ==================" |
---|
232 | echo ${EARG} "MANAGERS: " ${EOL} ; size_files $MANLIST $MPLIST |
---|
233 | echo ${EARG} "CORE : " ${EOL} ; size_files $CORELIST $CPULIST |
---|
234 | echo ${EARG} "CPU : " ${EOL} ; size_files $CPULIST |
---|
235 | echo ${EARG} "OVERALL : " ${EOL} ; size_files $CPULIST $CORELIST $MANLIST \ |
---|
236 | $MPLIST |
---|
237 | echo ${EARG} "MINIMUM : " ${EOL} ; size_files $CPULIST $CORELIST \ |
---|
238 | $OPTMANLIST $REQMANLIST |
---|
239 | echo |
---|
240 | |
---|
241 | for file in $MANLIST |
---|
242 | do |
---|
243 | base=`basename ${file}` |
---|
244 | echo ${EARG} ""${base} : " ${EOL} " ; size_files ${file} |
---|
245 | done |
---|
246 | |
---|
247 | echo ${EARG} "MP : " ${EOL} ; size_files $MPLIST |
---|
248 | |
---|
249 | echo |
---|
250 | for file in $OPTMANLIST |
---|
251 | do |
---|
252 | base=`basename ${file}` |
---|
253 | echo ${EARG} "${base} : " ${EOL} ; size_files ${file} |
---|
254 | done |
---|
255 | |
---|
256 | echo |
---|
257 | exit 0 |
---|