source: rtems-testing/simple-build-script/build_tools @ ef065c7

4.11
Last change on this file since ef065c7 was ef065c7, checked in by Joel Sherrill <joel.sherrill@…>, on May 15, 2012 at 9:07:33 PM

rtems-testing - Remove CVS Ids (manual edits)

  • Property mode set to 100644
File size: 5.6 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#  --Joel Sherrill (28 March 2010)
12#
13
14### EDIT THESE AS NEEDED
15AUTOCONF=autoconf-2.66
16AUTOMAKE=automake-1.11.1
17BINUTILS=binutils-2.20.1
18GDB=gdb-7.1
19GCC=gcc-4.5.0
20NEWLIB=newlib-1.18.0
21LANGUAGES="c,c++"
22### END OF EDIT THESE
23
24
25BASE=`pwd`
26
27#   log an error to stderr
28prerr()
29{
30    echo "$*" >&2
31}
32
33fatal() {
34    prerr "$USAGE"
35    [ "$1" ] && (prerr ; prerr $*);
36    exit 1
37}
38
39check_status()
40{
41  if [ $1 -ne 0 ] ; then
42    shift
43    echo "FAILED: " "$*" >&2
44    exit 1
45  fi
46}
47
48toggle()
49{
50  case $1 in
51    no)  echo "yes" ;;
52    yes) echo "no" ;;
53    *)   fatal "Unknown value to toggle ($1)" ;;
54  esac
55}
56
57usage()
58{
59cat <<EOF
60  -v             verbose
61  -A             toggle building all parts
62  -a             toggle building autoconf
63  -m             toggle building automake
64  -b             toggle building binutils
65  -g             toggle building gcc/newlib
66  -d             toggle building db
67  -i INSTALL     specify install directory (required)
68  -t TARGET      specify target (required)
69
70EOF
71exit 1
72}
73
74do_autoconf=no
75do_automake=no
76do_binutils=no
77do_gdb=no
78do_gcc_newlib=no
79verbose=no
80TARGET=NOT_SET
81INSTALL=NOT_SET
82
83while getopts vAambgdi:t: OPT
84do
85  case "$OPT" in
86    A) do_autoconf=`toggle ${do_autoconf}`
87       do_automake=`toggle ${do_automake}`
88       do_binutils=`toggle ${do_binutils}`
89       do_gdb=`toggle ${do_gdb}`
90       do_gcc_newlib=`toggle ${do_gcc_newlib}`
91       ;;
92    a) do_autoconf=`toggle ${do_autoconf}` ;;
93    m) do_automake=`toggle ${do_automake}` ;;
94    b) do_binutils=`toggle ${do_binutils}` ;;
95    g) do_gcc_newlib=`toggle ${do_gcc_newlib}` ;;
96    d) do_gdb=`toggle ${do_gdb}` ;;
97    i) INSTALL="${OPTARG}" ;;
98    t) TARGET="${OPTARG}" ;;
99    v) verbose=`toggle ${verbose}` ;;
100    *) echo ERROR ; exit 1 ;;
101  esac
102done
103
104if [ ${verbose} = "yes" ] ; then
105  echo "Build autoconf:   " ${do_autoconf}
106  echo "Build automake:   " ${do_automake}
107  echo "Build binutils:   " ${do_binutils}
108  echo "Build gdb:        " ${do_gdb}
109  echo "Build gcc/newlib: " ${do_gcc_newlib}
110  echo "Install point:    " ${INSTALL}
111  echo "Target:           " ${TARGET}
112  echo
113fi
114
115### Validate arguments
116test ${TARGET} != NOT_SET
117check_status $? "TARGET not specified"
118
119test ${INSTALL} != NOT_SET
120check_status $? "INSTALL not specified"
121 
122if [ ! -d ${INSTALL} ] ; then
123  mkdir ${INSTALL}
124  check_status $? "failed to make ${INSTALL}"
125fi
126
127if [ ${do_autoconf} = yes ] ; then
128  test -d ${AUTOCONF}
129  check_status $? "No ${AUTOCONF} - You do not appear to be in src directory"
130  TOBUILD="${TOBUILD} ${AUTOCONF}"
131fi
132
133if [ ${do_automake} = yes ] ; then
134  test -d ${AUTOMAKE}
135  check_status $? "No ${AUTOMAKE} - You do not appear to be in src directory"
136  TOBUILD="${TOBUILD} ${AUTOMAKE}"
137fi
138
139if [ ${do_binutils} = yes ] ; then
140  test -d ${BINUTILS}
141  check_status $? "No ${BINUTILS} - You do not appear to be in src directory"
142  TOBUILD="${TOBUILD} ${BINUTILS}"
143fi
144
145if [ ${do_gdb} = yes ] ; then
146  test -d ${GDB}
147  check_status $? "No ${GDB} - You do not appear to be in src directory"
148  TOBUILD="${TOBUILD} ${GDB}"
149fi
150
151if [ ${do_gcc_newlib} = yes ] ; then
152  test -d ${GCC}
153  check_status $? "No ${GCC} - You do not appear to be in src directory"
154
155  test -d ${NEWLIB}
156  check_status $? "No ${NEWLIB} - You do not appear to be in src directory"
157
158  if [ ! -d ${GCC}/newlib -o ! -d ${GCC}/libgloss ] ; then
159    echo "Please ensure that ${GCC}/newlib and ${GCC}/libgloss are symbolic"
160    echo "links into the newlib tree.  Use commands simiilar to the following:"
161    echo ""
162    echo "ln -s ${BASE}/${NEWLIB}/newlib ${BASE}/${GCC}/newlib"
163    echo "ln -s ${BASE}/${NEWLIB}/libgloss ${BASE}/${GCC}/libgloss"
164    exit 1
165  fi
166
167  TOBUILD="${TOBUILD} ${GCC}"
168fi
169
170export PATH=${INSTALL}/bin:$PATH
171### Build everything
172for pkg in ${TOBUILD}
173do
174  rm -rf b-${pkg}
175  check_status $? "failed to rm b-${pkg}"
176
177  mkdir b-${pkg}
178  check_status $? "failed to make b-${pkg}"
179
180  cd b-${pkg}
181  check_status $? "failed to cd b-${pkg}"
182
183  echo "Configuring ${pkg}..."
184  case $pkg in
185    auto*)                               # autotools are native
186      ../${pkg}/configure --prefix=${INSTALL} >c.log 2>&1
187      check_status $? "failed to configure ${pkg}"
188      ;;
189    binutils*)
190      ../${pkg}/configure --target=${TARGET} \
191        --prefix=${INSTALL} >c.log 2>&1
192      check_status $? "failed to configure ${pkg}"
193      ;;
194    gdb*)
195      ../${pkg}/configure --target=${TARGET} \
196        --prefix=${INSTALL} \
197        --enable-sim --enable-sim-hardware \
198        --enable-timebase --enable-sim-trace
199        >c.log 2>&1
200      check_status $? "failed to configure ${pkg}"
201      ;;
202    gcc*)
203      ../${GCC}/configure \
204       --enable-threads=rtems  --with-gnu-as --enable-multilib \
205       --enable-newlib-mb --enable-newlib-iconv \
206       --with-gnu-ld --with-newlib  --verbose --with-system-zlib --disable-nls \
207        --enable-version-specific-runtime-libs \
208        --enable-languages=${LANGUAGES} --target=${TARGET} --prefix=${INSTALL} \
209      >c.log 2>&1
210      check_status $? "failed to configure ${pkg}"
211      ;;
212    *)
213      prerr "UNKNOWN PACKAGE ${pkg}"
214      exit 1
215      ;;
216  esac
217
218  echo "Building ${pkg}..."
219  make >b.log 2>&1
220  check_status $? "failed to make ${pkg}"
221
222  echo "Installing ${pkg}..."
223  make install >i.log 2>&1
224  check_status $? "failed to install ${pkg}"
225
226  cd ..
227  rm -rf b-${pkg}
228done
229
230exit 0
Note: See TracBrowser for help on using the repository browser.