source: rtems-testing/simple-build-script/build_tools @ 8da8788

4.11
Last change on this file since 8da8788 was 8da8788, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 10, 2013 at 12:54:56 AM

simple-build-scripts: Significant update

This script can now build RTEMS and non-RTEMS targets.
It can be used to test non-RTEMS no-OS targets.

  • Property mode set to 100755
File size: 9.1 KB
Line 
1#! /bin/sh
2#
3#  This script is a simple script to build and install rtems toolset
4#  for the target you specify on the command line.  It should be of
5#  the form <CPU>-rtems<VERSION>.  For example, sparc-rtems4.11
6#
7#  This can be used to build versions from CVS/SVN or released versions.
8#  Please be sure to apply appropriate patches from
9#  rtems/contrib/crossrpms/patches.
10#
11#  Currently only testing of non-RTEMS targets is supported.
12#
13
14### EDIT THESE AS NEEDED
15AUTOCONF=autoconf-2.69
16AUTOMAKE=automake-1.12.6
17BINUTILS=binutils-cvs/src
18GDB=gdb-cvs/src
19GCC=gcc-svn
20NEWLIB=newlib-cvs/src
21LANGUAGES="c,c++"
22### END OF EDIT THESE
23
24BASE=`pwd`
25
26#   log an error to stderr
27prerr()
28{
29    echo "$*" >&2
30}
31
32fatal() {
33    prerr "$USAGE"
34    [ "$1" ] && (prerr ; prerr $*);
35    exit 1
36}
37
38check_status()
39{
40  if [ $1 -ne 0 ] ; then
41    shift
42    echo "FAILED: " "$*" >&2
43    exit 1
44  fi
45}
46
47toggle()
48{
49  case $1 in
50    no)  echo "yes" ;;
51    yes) echo "no" ;;
52    *)   fatal "Unknown value to toggle ($1)" ;;
53  esac
54}
55
56usage()
57{
58cat <<EOF
59  -v             verbose (default=no)
60  -c             clean after building if OK (default=yes)
61  -A             toggle building binutils, gcc, newlib, and gdb
62  -a             toggle building autoconf (default=no)
63  -m             toggle building automake (default=no)
64  -b             toggle building binutils (default=no)
65  -g             toggle building gcc/newlib (default=no)
66  -d             toggle building gdb (default=no)
67  -i INSTALL     specify install directory (required)
68  -t TARGET      specify target (required)
69  -B DIRECTORY   specify directory for build tree (default=pwd)
70  -T             toggle running test (default=no)
71  -M             toggle sending test results email (default=no)
72
73EOF
74exit 1
75}
76
77sourcedir=`pwd`
78buildroot=`pwd`
79do_clean=yes
80do_autoconf=no
81do_automake=no
82do_binutils=no
83do_gdb=no
84do_gcc_newlib=no
85verbose=no
86TARGET=NOT_SET
87INSTALL=NOT_SET
88jobs=NOT_SET
89do_tests=no
90do_mail=no
91
92while getopts cj:B:vTMAambgdi:t: OPT
93do
94  case "$OPT" in
95    A) do_binutils=`toggle ${do_binutils}`
96       do_gdb=`toggle ${do_gdb}`
97       do_gcc_newlib=`toggle ${do_gcc_newlib}`
98       ;;
99    a) do_autoconf=`toggle ${do_autoconf}` ;;
100    m) do_automake=`toggle ${do_automake}` ;;
101    b) do_binutils=`toggle ${do_binutils}` ;;
102    g) do_gcc_newlib=`toggle ${do_gcc_newlib}` ;;
103    d) do_gdb=`toggle ${do_gdb}` ;;
104    i) INSTALL="${OPTARG}" ;;
105    t) TARGET="${OPTARG}" ;;
106    j) jobs="${OPTARG}" ;;
107    B) buildroot="${OPTARG}" ;;
108    c) do_clean=`toggle ${do_clean}` ;;
109    T) do_tests=`toggle ${do_tests}` ;;
110    M) do_mail=`toggle ${do_mail}` ;;
111    v) verbose=`toggle ${verbose}` ;;
112    *) echo "Error ${OPT} is not a valid option" ; usage ; exit 1 ;;
113  esac
114done
115
116# Specify the desired parallelism
117if [ ${jobs} != "NOT_SET" ] ; then
118  case ${jobs} in
119    NOT_SET)
120      JOBS=""
121      ;;
122    ''|*[!0-9]*)
123      check_fatal 1 "Number of jobs (${jobs}) specified is not a number"
124      ;;
125    *)
126      JOBS="-j ${jobs}"
127      ;;
128  esac
129fi
130
131if [ ${verbose} = "yes" ] ; then
132  echo "Build autoconf:    " ${do_autoconf}
133  echo "Build automake:    " ${do_automake}
134  echo "Build binutils:    " ${do_binutils}
135  echo "Build gdb:         " ${do_gdb}
136  echo "Build gcc/newlib:  " ${do_gcc_newlib}
137  echo "Clean as building: " ${do_clean}
138  echo "Running Tests:     " ${do_tests}
139  echo "  Mailing Results: " ${do_mail}
140  echo "Parallel Jobs:     " ${jobs}
141  echo "Install point:     " ${INSTALL}
142  echo "Build root:        " ${buildroot}
143  echo "Target:            " ${TARGET}
144  echo
145fi
146
147### Validate arguments
148test ${TARGET} != NOT_SET
149check_status $? "TARGET not specified"
150
151test ${INSTALL} != NOT_SET
152check_status $? "INSTALL not specified"
153 
154if [ ! -d ${INSTALL} ] ; then
155  mkdir ${INSTALL}
156  check_status $? "failed to make ${INSTALL}"
157fi
158
159if [ ${do_autoconf} = yes ] ; then
160  test -d ${AUTOCONF}
161  check_status $? "No ${AUTOCONF} - You do not appear to be in src directory"
162  TOBUILD="${TOBUILD} ${AUTOCONF}"
163fi
164
165if [ ${do_automake} = yes ] ; then
166  test -d ${AUTOMAKE}
167  check_status $? "No ${AUTOMAKE} - You do not appear to be in src directory"
168  TOBUILD="${TOBUILD} ${AUTOMAKE}"
169fi
170
171if [ ${do_binutils} = yes ] ; then
172  test -d ${BINUTILS}
173  check_status $? "No ${BINUTILS} - You do not appear to be in src directory"
174  TOBUILD="${TOBUILD} ${BINUTILS}"
175fi
176
177if [ ${do_gdb} = yes ] ; then
178  test -d ${GDB}
179  check_status $? "No ${GDB} - You do not appear to be in src directory"
180  TOBUILD="${TOBUILD} ${GDB}"
181fi
182
183if [ ${do_gcc_newlib} = yes ] ; then
184  test -d ${GCC}
185  check_status $? "No ${GCC} - You do not appear to be in src directory"
186
187  test -d ${NEWLIB}
188  check_status $? "No ${NEWLIB} - You do not appear to be in src directory"
189
190  if [ ! -d ${GCC}/newlib -o ! -d ${GCC}/libgloss ] ; then
191    echo "Please ensure that ${GCC}/newlib and ${GCC}/libgloss are symbolic"
192    echo "links into the newlib tree.  Use commands simiilar to the following:"
193    echo ""
194    echo "ln -s ${BASE}/${NEWLIB}/newlib ${BASE}/${GCC}/newlib"
195    echo "ln -s ${BASE}/${NEWLIB}/libgloss ${BASE}/${GCC}/libgloss"
196    exit 1
197  fi
198
199  TOBUILD="${TOBUILD} ${GCC}"
200fi
201
202test -d ${buildroot}
203check_status $? "${buildroot} does not exist"
204
205export PATH=${INSTALL}/bin:$PATH
206### Build everything
207for pkg in ${TOBUILD}
208do
209  cd ${buildroot}
210  check_status $? "failed to cd ${buildroot}"
211
212  BUILDDIR=`echo b-${TARGET}-${pkg} | sed -e 's/\//-/g'`
213
214  rm -rf ${BUILDDIR}
215  check_status $? "failed to rm ${BUILDDIR}"
216
217  mkdir ${BUILDDIR}
218  check_status $? "failed to make ${BUILDDIR}"
219
220  cd ${BUILDDIR}
221  check_status $? "failed to cd ${BUILDDIR}"
222
223  echo "Configuring ${pkg} in ${BUILDDIR}..."
224  case $pkg in
225    auto*)                               # autotools are native
226      ${sourcedir}/${pkg}/configure --prefix=${INSTALL} >c.log 2>&1
227      check_status $? "failed to configure ${pkg}"
228      ;;
229    binutils*)
230      ${sourcedir}/${pkg}/configure --target=${TARGET} \
231        --prefix=${INSTALL} >c.log 2>&1
232      check_status $? "failed to configure ${pkg}"
233      ;;
234    gdb*)
235      ${sourcedir}/${pkg}/configure --target=${TARGET} \
236        --prefix=${INSTALL} \
237        --enable-sim --enable-sim-hardware \
238        --enable-timebase --enable-sim-trace >c.log 2>&1
239      check_status $? "failed to configure ${pkg}"
240      ;;
241    gcc*)
242      ${sourcedir}/${GCC}/configure \
243       --enable-threads=rtems  --with-gnu-as --enable-multilib \
244       --enable-newlib-mb --enable-newlib-iconv \
245       --with-gnu-ld --with-newlib  --verbose --with-system-zlib --disable-nls \
246        --enable-version-specific-runtime-libs \
247        --enable-languages=${LANGUAGES} --target=${TARGET} --prefix=${INSTALL} \
248      >c.log 2>&1
249      check_status $? "failed to configure ${pkg}"
250      ;;
251    *)
252      prerr "UNKNOWN PACKAGE ${pkg}"
253      exit 1
254      ;;
255  esac
256
257  echo "Building ${pkg}..."
258  make ${JOBS} >b.log 2>&1
259  check_status $? "failed to make ${pkg}"
260
261  echo "Installing ${pkg}..."
262  make install >i.log 2>&1
263  check_status $? "failed to install ${pkg}"
264
265  # If testing the package, fall into this if
266  if [ ${do_tests} = "yes" ] ; then
267    echo "Testing ${pkg}..."
268    case $pkg in
269      auto*)
270        # currently do not run test suite on autoconf and automake
271        ;;
272      binutils*)
273        echo "Testing binutils for ${TARGET}"
274        make check >check.log 2>&1
275        ;;
276      gdb*)
277        # currently do not run test suite on gdb
278        ;;
279      gcc*)
280        baseboard=NOT_SET
281        case ${TARGET} in
282          *-rtems*)
283            echo "*** Currently do not support testing GCC with this script"
284            ;;
285          *-elf*|*-eabi*)
286            cpu=`echo ${TARGET} | cut -d'-' -f1`
287            case ${cpu} in
288              arc*|arm*|basic*|cris*|d10v*|d30v*|fr30*|frv*|h8300*|i960*|iq2000*|jmr3904|\
289              m32r*|m68hc11*|mcore*|mips*|mips64*|mips64vr4100*|mmixware*|mn10200|\
290              mn10300*|powerpc*|powerpcle*|sh*|sparc*|sparc64*|sparclite*|tic80*|tx39|\
291              v850*|vr4100*|vr4111*|vr4300*|xtensa*)
292                baseboard=${cpu}-sim
293                ;;
294              *)
295                ;;
296            esac
297            ;;
298          *)
299            ;;
300         
301        esac
302
303        # now see if we found a configuration to test with
304        if [ ${baseboard} = "NOT_SET" ] ; then
305          echo "*** Do not know how to test gcc on ${target}"
306          continue
307        fi
308
309        echo "Testing gcc for ${TARGET} on ${baseboard}"
310        make check RUNTESTFLAGS="--target_board=${baseboard}" >check.log 2>&1
311
312        if [ ${do_mail} = "yes" ] ; then
313          echo "Sending ${language} test results to GCC community.."
314          ${sourcedir}/${GCC}/contrib/test_summary -m gcc-testresults@gcc.gnu.org | sh
315          check_status $? "Failed to email ${language} Test Results to GCC Community .. bailing"
316
317          echo "Sending ${language} test results to RTEMS community.."
318          ${sourcedir}/${GCC}/contrib/test_summary -o -m rtems-tooltestresults@rtems.org | sh
319          check_status $? "Failed to email ${language} Test Results to RTEMS Community .. bailing"
320        fi
321        ;;
322      *)
323        prerr "UNKNOWN PACKAGE ${pkg}"
324        exit 1
325        ;;
326    esac
327
328  fi
329  # END of if testing the package
330
331  cd ..
332  if [ ${do_clean} = "yes" ] ; then
333    rm -rf ${BUILD}
334  fi
335done
336
337exit 0
Note: See TracBrowser for help on using the repository browser.