1 | #! /bin/sh |
---|
2 | # |
---|
3 | # Generate all the specs and then cycle through building them. |
---|
4 | # |
---|
5 | |
---|
6 | RTEMS_DIR=`dirname $0` |
---|
7 | CFG=./setup.cache |
---|
8 | dst=@RPM_SPECSdir@ |
---|
9 | target=@target@ |
---|
10 | rpm_cpu=@RPM_CPU@ |
---|
11 | |
---|
12 | usage() |
---|
13 | { |
---|
14 | echo "$0 [options] <target_alias>" |
---|
15 | echo " options:" |
---|
16 | echo " -b -- build binutils" |
---|
17 | echo " -g -- build gcc/newlib" |
---|
18 | echo " -d -- build gdb" |
---|
19 | echo " -t -- enable test/debug mode" |
---|
20 | echo " -cfg <setup.cache>" |
---|
21 | echo " -o <rpm-spec-dir>" |
---|
22 | exit 1 ; |
---|
23 | } |
---|
24 | |
---|
25 | testing=no |
---|
26 | do_binutils=no |
---|
27 | do_gccnewlib=no |
---|
28 | do_gdb=no |
---|
29 | |
---|
30 | while test $# -ge 1; do |
---|
31 | case $1 in |
---|
32 | -b) do_binutils=yes ; shift;; |
---|
33 | -g) do_gccnewlib=yes ; shift;; |
---|
34 | -d) do_gdb=yes ; shift;; |
---|
35 | -t) do_test=yes ; shift;; |
---|
36 | -cfg) |
---|
37 | test $# -ge 2 || usage |
---|
38 | shift |
---|
39 | CFG=$1 |
---|
40 | shift |
---|
41 | ;; |
---|
42 | -o) |
---|
43 | test $# -ge 2 || usage |
---|
44 | shift |
---|
45 | dst=$1 |
---|
46 | shift |
---|
47 | ;; |
---|
48 | -*) |
---|
49 | echo "invalid option $1"; |
---|
50 | usage |
---|
51 | ;; |
---|
52 | *) |
---|
53 | TARGETS="${TARGETS} $1" |
---|
54 | shift |
---|
55 | ;; |
---|
56 | esac |
---|
57 | done |
---|
58 | |
---|
59 | if test ${do_binutils} = no -a ${do_gccnewlib} = no -a ${do_gdb} = no ; then |
---|
60 | echo "You must request building binutils, gcc/newlib, or gdb." |
---|
61 | usage |
---|
62 | fi |
---|
63 | |
---|
64 | |
---|
65 | # This is the full list .. hppa1.1 does not build now. |
---|
66 | #ALL_TARGETS="hppa1.1-rtems i386-rtems i960-rtems m68k-rtems \ |
---|
67 | # m68k-rtemself mips-rtems mips64orion-rtems \ |
---|
68 | # powerpc-rtems sh-rtems sh-rtemself sparc-rtems" |
---|
69 | |
---|
70 | # This is the full buildable set. |
---|
71 | if [ "X${TARGETS}" = "X" ] ; then |
---|
72 | # do not include c4x or hppa primary targets |
---|
73 | # do not include sh-elf or i960-elf secondary targets |
---|
74 | TARGETS="arm-rtems h8300-rtems i386-rtems i960-rtems m68k-rtems \ |
---|
75 | mips-rtems mips64orion-rtems powerpc-rtems sh-rtems sparc-rtems" |
---|
76 | fi |
---|
77 | |
---|
78 | . $CFG |
---|
79 | |
---|
80 | binutils=${binutils_version} |
---|
81 | gcc=${gcc_version} |
---|
82 | gdb=${gdb_version} |
---|
83 | newlib=${newlib_version} |
---|
84 | # also use binutils_rpm_release |
---|
85 | buildroot=/tmp |
---|
86 | |
---|
87 | # |
---|
88 | # Now get started |
---|
89 | # |
---|
90 | start=`date` |
---|
91 | |
---|
92 | echo PATH=$PATH |
---|
93 | |
---|
94 | if [ ${testing} = yes ] ; then |
---|
95 | ECHO=echo |
---|
96 | fi |
---|
97 | |
---|
98 | installed_count=`rpm -q -g rtems | grep -v "auto" | grep -v "does not contain" | wc -l` |
---|
99 | if [ ${installed_count} -ne 0 ] ; then |
---|
100 | echo This script should be run with NO rtems RPMs installed. |
---|
101 | echo It appears that the following rtems RPMs are installed: |
---|
102 | echo |
---|
103 | rpm -qa | grep rtems |
---|
104 | echo |
---|
105 | echo Please remove these and restart this script. |
---|
106 | exit 1 |
---|
107 | fi |
---|
108 | |
---|
109 | echo Copying specs files. |
---|
110 | if [ ${testing} = no ] ; then |
---|
111 | cd ${RTEMS_DIR} |
---|
112 | |
---|
113 | # ./configure || exit 1 |
---|
114 | make || exit 1 |
---|
115 | |
---|
116 | # Now generate all the specs |
---|
117 | for target in ${TARGETS} |
---|
118 | do |
---|
119 | tspecs=`find . -name "${target}*"` |
---|
120 | if [ "X${tspecs}" = "X" ] ; then |
---|
121 | echo RPM specifications were not generated for ${tspec}. |
---|
122 | exit 1 |
---|
123 | fi |
---|
124 | ${ECHO} cp -r ${tspecs} ${dst} |
---|
125 | done |
---|
126 | fi |
---|
127 | |
---|
128 | # clean up a bit before we start |
---|
129 | cd ${dst} |
---|
130 | test -d log || mkdir log |
---|
131 | |
---|
132 | # do all the tools |
---|
133 | for target in ${TARGETS} |
---|
134 | do |
---|
135 | if [ ${do_binutils} = yes ] ; then |
---|
136 | logfile=log/${target}-binutils |
---|
137 | specfile=${dst}/${target}-binutils-${binutils}.spec |
---|
138 | echo "rpm -ba ${specfile} >${logfile} 2>&1" |
---|
139 | if [ ${testing} = no ] ; then |
---|
140 | rpm -ba ${specfile} >${logfile} 2>&1 |
---|
141 | fi |
---|
142 | ${ECHO} rm -rf ${dst}/../BUILD/${target}-binutils* |
---|
143 | ${ECHO} rm -rf ${buildroot}/opt/rtems |
---|
144 | else |
---|
145 | echo Skipping binutils for ${target} |
---|
146 | fi |
---|
147 | |
---|
148 | # |
---|
149 | # build gcc/newlib |
---|
150 | # |
---|
151 | |
---|
152 | if [ ${do_gccnewlib} = yes ] ; then |
---|
153 | # now build gcc/newlib |
---|
154 | # NOTE: This requires having binutils installed and we immediately |
---|
155 | # remove it once finished. |
---|
156 | base_binutils_rpm=${dst}/../RPMS/${rpm_cpu}/rtems-base-binutils-${binutils}-${binutils_rpm_release}.${rpm_cpu}.rpm |
---|
157 | binutils_rpm=${dst}/../RPMS/${rpm_cpu}/${target}-binutils-${binutils}-${binutils_rpm_release}.${rpm_cpu}.rpm |
---|
158 | if [ ! -f ${binutils_rpm} ] ; then |
---|
159 | echo There is no RPM for binutils for ${target}. |
---|
160 | echo Looked for ${binutils_rpm}. |
---|
161 | fi |
---|
162 | ${ECHO} rpm -i ${base_binutils_rpm} |
---|
163 | ${ECHO} rpm -i ${binutils_rpm} |
---|
164 | |
---|
165 | logfile=log/${target}-gccnewlib |
---|
166 | specfile=${dst}/${target}-gcc-${gcc}-newlib-${newlib}.spec |
---|
167 | echo "rpm -ba ${specfile} >${logfile} 2>&1" |
---|
168 | if [ ${testing} = no ] ; then |
---|
169 | rpm -ba ${specfile} >${logfile} 2>&1 |
---|
170 | fi |
---|
171 | ${ECHO} rm -rf ${dst}/../BUILD/${target}-gcc* |
---|
172 | ${ECHO} rm -rf ${buildroot}/opt/rtems |
---|
173 | |
---|
174 | echo uninstalling binutils for ${target} |
---|
175 | if [ ${testing} = no ] ; then |
---|
176 | rpm -e `rpm -qa | grep rtems` |
---|
177 | rm -rf /opt/rtems/* |
---|
178 | fi |
---|
179 | else |
---|
180 | echo Skipping gcc/newlib for ${target} |
---|
181 | fi |
---|
182 | |
---|
183 | # |
---|
184 | # build gdb |
---|
185 | # |
---|
186 | |
---|
187 | if [ ${do_gdb} = yes ] ; then |
---|
188 | # now build gdb |
---|
189 | logfile=log/${target}-gdb |
---|
190 | specfile=${dst}/${target}-gdb-${gdb}.spec |
---|
191 | echo "rpm -ba ${specfile} >${logfile} 2>&1" |
---|
192 | if [ ${testing} = no ] ; then |
---|
193 | rpm -ba ${specfile} >${logfile} 2>&1 |
---|
194 | fi |
---|
195 | ${ECHO} rm -rf ${dst}/../BUILD/${target}-gdb* |
---|
196 | ${ECHO} rm -rf ${buildroot}/opt/rtems |
---|
197 | else |
---|
198 | echo Skipping gdb for ${target} |
---|
199 | fi |
---|
200 | |
---|
201 | done |
---|
202 | |
---|
203 | # Now we are done |
---|
204 | |
---|
205 | stop=`date` |
---|
206 | |
---|
207 | echo |
---|
208 | echo "Started: " $start |
---|
209 | echo "Finished: " $stop |
---|
210 | exit 0 |
---|