blob: ba78a69d30a08812d4e9509641b85a720ce37360 (
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
#! /bin/sh
#
# Generate all the specs and then cycle through building them.
#
RTEMS_DIR=`dirname $0`
CFG=./setup.cache
#dst=/usr/src/redhat/SPECS
dst=`pwd`
target=@target@
rpm_cpu=i386
usage()
{
echo "$0 [options] <target_alias>"
echo " options:"
echo " -b -- build binutils"
echo " -g -- build gcc/newlib"
echo " -d -- build gdb"
echo " -C HOST -- build canadian cross for HOST "
echo " -t -- enable test/debug mode"
echo " -cfg <setup.cache>"
echo " -o <rpm-spec-dir>"
exit 1 ;
}
#
# Checks the status returned by executables and exits if it is non-zero.
#
check_fatal()
{
if [ $1 -ne 0 ] ; then
shift
echo "ERROR: $*" >&2
exit 1
fi
#echo
#echo "End of $*"
#echo -n "Press return to continue> "
#echo
#read line
}
testing=no
do_binutils=no
do_gccnewlib=no
do_gdb=no
cdn_cross=no
while test $# -ge 1; do
case $1 in
-b) do_binutils=yes ; shift;;
-g) do_gccnewlib=yes ; shift;;
-d) do_gdb=yes ; shift;;
-t) do_test=yes ; shift;;
-cfg)
test $# -ge 2 || usage
shift
CFG=$1
shift
;;
-o)
test $# -ge 2 || usage
shift
dst=$1
shift
;;
-C)
test $# -ge 2 || usage
shift
build=$1
shift
if ! test -x ${RTEMS_DIR}/../config.guess ; then
echo "Missing ${RTEMS_DIR}/../config.guess!"
exit 1
fi
CDN_ARGS="--build=`${RTEMS_DIR}/../config.guess` --host=${build}"
cdn_cross=yes
;;
-*)
echo "invalid option $1";
usage
;;
*)
TARGETS="${TARGETS} $1"
shift
;;
esac
done
if test ${do_binutils} = no -a ${do_gccnewlib} = no -a ${do_gdb} = no ; then
echo "You must request building binutils, gcc/newlib, or gdb."
usage
fi
# This is the full list .. some may not build at any given time.
#ALL_TARGETS="i386-rtems m68k-rtems \
# m68k-rtemself mips-rtems \
# powerpc-rtems sh-rtems sh-rtemself sparc-rtems"
# This is the full buildable set.
if [ "X${TARGETS}" = "X" ] ; then
# do not include tic4x as primary targets
# do not include sh-elf or secondary targets
TARGETS="arm-rtems h8300-rtems i386-rtems \
m68k-rtems mips-rtems powerpc-rtems \
sh-rtems sh-rtemself sparc-rtems"
fi
. $CFG
# override the one from $CFG since it likely has a % in it to use the
# .rpmrc setting which we can't use
rpm_build_root=${HOME}/tmp
binutils=${binutils_version}
gcc=${gcc3_version}
gdb=${gdb_version}
newlib=${gcc3newlib_version}
# also use binutils_rpm_release
#
# Now get started
#
start=`date`
echo PATH=$PATH
if [ ${testing} = yes ] ; then
ECHO=echo
fi
#installed_count=`rpm -q -g rtems | wc -l`
#if [ ${installed_count} -ne 0 ] ; then
# echo This script should be run with NO rtems RPMs installed.
# echo It appears that the following rtems RPMs are installed:
# echo
# rpm -qa | grep rtems
# echo
# echo Please remove these and restart this script.
# exit 1
#fi
#echo Copying specs files.
#if [ ${testing} = no ] ; then
# cd ${RTEMS_DIR}
#
# # ./configure || exit 1
# make || exit 1
#
# # Now generate all the specs
# for target in ${TARGETS}
# do
# tspecs=`find . -name "${target}*"`
# if [ "X${tspecs}" = "X" ] ; then
# echo RPM specifications were not generated for ${tspec}.
# exit 1
# fi
# ${ECHO} cp -r ${tspecs} ${dst}
# done
#fi
# clean up a bit before we start
cd ${dst}
test -d log || mkdir log
if [ "X${rpm_build_root}" = "X" ] ; then
echo rpm_build_root NOT set!
exit 1
fi
CWD=`pwd`
test -d tarballs || mkdir tarballs
OUT=${CWD}/tarballs
# do all the tools
for target in ${TARGETS}
do
bintarfile=${OUT}/${target}-binutils-${binutils}-${binutils_rpm_release}.tar
if [ ${do_binutils} = yes ] ; then
logfile=${CWD}/log/${target}-binutils
# this part is for tar.bz2
cd ${CWD}
if [ ! -d binutils-${binutils} ] ; then
echo Could not find binutils-${binutils}!
exit 1
fi
rm -rf b-${target}-bin
mkdir b-${target}-bin
cd b-${target}-bin
echo "Building binutils-${binutils} for ${target}"
../binutils-${binutils}/configure ${CDN_ARGS} --target=${target} \
--verbose --prefix=/opt/rtems >${logfile} 2>&1
check_fatal $? "binutils configure"
make all >>${logfile} 2>&1
check_fatal $? "make all"
make info >>${logfile} 2>&1
check_fatal $? "make info"
make prefix=${rpm_build_root}/opt/rtems install >>${logfile} 2>&1
check_fatal $? "make install"
make prefix=${rpm_build_root}/opt/rtems install-info >>${logfile} 2>&1
check_fatal $? "make install-info"
cd ${rpm_build_root}
tar cjf ${bintarfile}.bz2 opt
cd ${CWD}
rm -rf b-${target}-bin
${ECHO} rm -rf ${rpm_build_root}/opt
rm -rf ${rpm_build_root}/opt
else
echo Skipping binutils for ${target}
fi
#
# build gcc/newlib
#
if [ ${do_gccnewlib} = yes ] ; then
logfile=${CWD}/log/${target}-gccnewlib
# now build gcc/newlib
# this part is for tar.bz2
gcctarfile=${OUT}/${target}-gcc-${gcc}-newlib-${newlib}-${gccnewlib_rpm_release}.tar
if [ ${cdn_cross} = "no" ] ; then
bintarfile=${dst}/binaries/binutils-${binutils}-${binutils_rpm_release}/${target}-binutils-${binutils}-${binutils_rpm_release}.tar
rm -rf ${rpm_build_root}/opt/*
tar xjf ${bintarfile}.bz2
fi
cd ${CWD}
if [ ! -d gcc-${gcc} ] ; then
echo Could not find gcc-${gcc}!
exit 1
fi
if [ ! -d gcc-${gcc}/newlib ] ; then
echo Could not find gcc-${gcc}/newlib!
exit 1
fi
rm -rf b-${target}-gccnewlib
mkdir b-${target}-gccnewlib
cd b-${target}-gccnewlib
echo "Building gcc-${gcc} for ${target}"
../gcc-${gcc}/configure ${CDN_ARGS} --target=${target} \
--with-gnu-as --with-gnu-ld --with-newlib --verbose \
--with-system-zlib --disable-nls \
--enable-version-specific-runtime-libs \
--enable-threads=rtems \
--prefix=/opt/rtems '--enable-languages=c,c++' >${logfile} 2>&1
check_fatal $? "gcc configure"
make all >>${logfile} 2>&1
check_fatal $? "make all"
make info >>${logfile} 2>&1
check_fatal $? "make info"
make prefix=${rpm_build_root}/opt/rtems install >>${logfile} 2>&1
check_fatal $? "make install"
cd ${target}/newlib
make prefix=${rpm_build_root}/opt/rtems install-info >>${logfile} 2>&1
check_fatal $? "newlib make install-info"
cd ${rpm_build_root}
tar cjf ${gcctarfile}.bz2 opt
cd ${CWD}
rm -rf ${rpm_build_root}/opt
rm -rf ${rpm_build_root}/opt/rtems
rm -rf b-${target}-gccnewlib
else
echo Skipping gcc/newlib for ${target}
fi
#
# build gdb
#
if [ ${do_gdb} = yes ] ; then
# now build gdb
gdbtarfile=${OUT}/${target}-gdb-${gdb}-${gdb_rpm_release}.tar
logfile=${CWD}/log/${target}-gdb
# this part is for tar.bz2
if [ ! -d gdb-${gdb} ] ; then
echo Could not find gdb-${gdb}!
exit 1
fi
mkdir b-${target}-gdb
cd b-${target}-gdb
case ${target} in
arm* | d10v* | d30v* | erc32* | fr30* | h8300* | h8500* | \
m32r* | mcore* | mips* | mn10200* | mn10300* | sh* | sparc*| v850* | \
w65* | z8k*)
extra_configure_arguments="--enable-sim"
;;
powerpc*)
extra_configure_arguments="--enable-sim --enable-sim-powerpc --enable-sim-timebase --enable-sim-hardware"
# Enabling this causes the program image to be huge and causes
# some gcc/hosts combinations to run out of memory.
# --enable-sim-inline
;;
*)
;;
esac
echo "Building gdb-${gdb}/configure ${CDN_ARGS} --target=${target}"
../gdb-${gdb}/configure ${CDN_ARGS} --target=${target} \
${extra_configure_arguments} --verbose --prefix=/opt/rtems >${logfile} 2>&1
check_fatal $? "make info"
make all >>${logfile} 2>&1
check_fatal $? "make all"
make info >>${logfile} 2>&1
check_fatal $? "make info"
make prefix=${rpm_build_root}/opt/rtems install >>${logfile} 2>&1
check_fatal $? "make install"
make prefix=${rpm_build_root}/opt/rtems install-info >>${logfile} 2>&1
check_fatal $? "make install-info"
cd ${rpm_build_root}
tar cjf ${gdbtarfile}.bz2 opt
cd ${CWD}
${ECHO} rm -rf ${rpm_build_root}/opt
rm -rf ${rpm_build_root}/opt/rtems
rm -rf b-${target}-gdb
else
echo Skipping gdb for ${target}
fi
done
# Now we are done
stop=`date`
echo
echo "Started: " $start
echo "Finished: " $stop
exit 0
|