source: rtems/scripts/buildalltar.in @ 17a11842

4.104.114.84.95
Last change on this file since 17a11842 was 08f224b, checked in by Joel Sherrill <joel.sherrill@…>, on 01/22/02 at 15:38:43

2001-01-22 Joel Sherrill <joel@…>

  • buildalltar.in: Modified to support Canadian cross builds. It was testing using a RedHat? 7.2 host to build *-rtems tools that run on an i386-cygwin host.
  • Property mode set to 100644
File size: 8.2 KB
Line 
1#! /bin/sh
2#
3#  Generate all the specs and then cycle through building them.
4#
5
6RTEMS_DIR=`dirname $0`
7CFG=./setup.cache
8#dst=/usr/src/redhat/SPECS
9dst=`pwd`
10target=@target@
11rpm_cpu=i386
12
13usage()
14{
15  echo "$0 [options] <target_alias>"
16  echo "  options:"
17  echo "    -b                  -- build binutils"
18  echo "    -g                  -- build gcc/newlib"
19  echo "    -d                  -- build gdb"
20  echo "    -C HOST             -- build canadian cross for HOST "
21  echo "    -t                  -- enable test/debug mode"
22  echo "    -cfg <setup.cache>"
23  echo "    -o <rpm-spec-dir>"
24  exit 1 ;
25}
26
27#   
28#  Checks the status returned by executables and exits if it is non-zero.
29#
30check_fatal()
31{
32  if [ $1 -ne 0 ] ; then
33    shift
34    echo "ERROR: $*" >&2
35    exit 1
36  fi
37  #echo
38  #echo "End of $*"
39  #echo -n "Press return to continue> "
40  #echo
41  #read line
42}
43
44testing=no
45do_binutils=no
46do_gccnewlib=no
47do_gdb=no
48cdn_cross=no
49
50while test $# -ge 1; do
51  case $1 in
52    -b) do_binutils=yes  ; shift;;
53    -g) do_gccnewlib=yes ; shift;;
54    -d) do_gdb=yes       ; shift;;
55    -t) do_test=yes      ; shift;;
56    -cfg)
57      test $# -ge 2 || usage
58      shift
59      CFG=$1
60      shift
61      ;;
62    -o)
63      test $# -ge 2 || usage
64      shift
65      dst=$1
66      shift
67      ;;
68    -C)
69      test $# -ge 2 || usage
70      shift
71      build=$1
72      shift
73      if ! test -x ${RTEMS_DIR}/../config.guess ; then
74        echo "Missing ${RTEMS_DIR}/../config.guess!"
75        exit 1
76      fi
77      CDN_ARGS="--build=`${RTEMS_DIR}/../config.guess` --host=${build}"
78      cdn_cross=yes
79      ;;
80    -*)
81      echo "invalid option $1";
82      usage
83      ;;
84    *)
85      TARGETS="${TARGETS} $1"
86      shift
87      ;;
88  esac
89done
90
91if test ${do_binutils} = no -a ${do_gccnewlib} = no -a ${do_gdb} = no ; then
92  echo "You must request building binutils, gcc/newlib, or gdb."
93  usage
94fi
95
96
97# This is the full list .. hppa1.1 does not build now.
98#ALL_TARGETS="hppa1.1-rtems i386-rtems i960-rtems m68k-rtems \
99#  m68k-rtemself mips-rtems mips64orion-rtems \
100#  powerpc-rtems sh-rtems sh-rtemself sparc-rtems"
101
102# This is the full buildable set.
103if [ "X${TARGETS}" = "X" ] ; then
104  # do not include c4x or hppa primary targets
105  # do not include sh-elf or i960-elf secondary targets
106  TARGETS="arm-rtems h8300-rtems i386-rtems i960-rtems m68k-rtems \
107    mips-rtems mips64orion-rtems powerpc-rtems sh-rtems sparc-rtems"
108fi
109
110. $CFG
111
112binutils=${binutils_version}
113gcc=${gcc_version}
114gdb=${gdb_version}
115newlib=${newlib_version}
116# also use binutils_rpm_release
117buildroot=/tmp
118
119#
120#  Now get started
121#
122start=`date`
123
124echo PATH=$PATH
125
126if [ ${testing} = yes ] ; then
127  ECHO=echo
128fi
129
130#installed_count=`rpm -q -g rtems | wc -l`
131#if [ ${installed_count} -ne 0 ] ; then
132#  echo This script should be run with NO rtems RPMs installed.
133#  echo It appears that the following rtems RPMs are installed:
134#  echo
135#  rpm -qa | grep rtems
136#  echo
137#  echo Please remove these and restart this script.
138#  exit 1
139#fi
140
141#echo Copying specs files.
142#if [ ${testing} = no ] ; then
143#  cd ${RTEMS_DIR}
144
145#  # ./configure || exit 1
146#  make        || exit 1
147#
148#  #  Now generate all the specs
149#  for target in ${TARGETS}
150#  do
151#    tspecs=`find . -name "${target}*"`
152#    if [ "X${tspecs}" = "X" ] ; then
153#      echo RPM specifications were not generated for ${tspec}.
154#      exit 1
155#    fi
156#    ${ECHO} cp -r ${tspecs} ${dst}
157#  done
158#fi
159
160# clean up a bit before we start
161cd ${dst}
162test -d log || mkdir log
163
164if [ "X${rpm_build_root}" = "X" ] ; then
165  echo rpm_build_root NOT set!
166  exit 1
167fi
168
169CWD=`pwd`
170test -d tarballs || mkdir tarballs
171
172OUT=${CWD}/tarballs
173
174#  do all the tools
175for target in ${TARGETS}
176do
177  bintarfile=${OUT}/${target}-binutils-${binutils}-${binutils_rpm_release}.tar
178  if [ ${do_binutils} = yes ] ; then
179    logfile=${CWD}/log/${target}-binutils
180    # this part is for tar.bz2
181    cd ${CWD}
182    if [ ! -d binutils-${binutils} ] ; then
183      echo Could not find binutils-${binutils}!
184      exit 1
185    fi
186    rm -rf b-${target}-bin
187    mkdir b-${target}-bin
188    cd b-${target}-bin
189    echo "Building binutils-${binutils} for ${target}"
190    ../binutils-${binutils}/configure ${CDN_ARGS} --target=${target} \
191      --verbose --prefix=/opt/rtems   >${logfile} 2>&1
192    check_fatal $? "binutils configure"
193
194    make all >>${logfile} 2>&1
195    check_fatal $? "make all"
196
197    make info >>${logfile} 2>&1
198    check_fatal $? "make info"
199
200    make prefix=${rpm_build_root}/opt/rtems install >>${logfile} 2>&1
201    check_fatal $? "make install"
202
203    make prefix=${rpm_build_root}/opt/rtems install-info >>${logfile} 2>&1
204    check_fatal $? "make install-info"
205
206    cd ${buildroot}
207    tar cjf ${bintarfile}.bz2 opt
208    cd ${CWD}
209    rm -rf b-${target}-bin
210    ${ECHO} rm -rf ${rpm_build_root}/opt
211    #rm -rf ${rpm_build_root}/opt
212  else
213    echo Skipping binutils for ${target}
214  fi
215
216  #
217  #  build gcc/newlib
218  #
219
220  if [ ${do_gccnewlib} = yes ] ; then
221    logfile=${CWD}/log/${target}-gccnewlib
222    # now build gcc/newlib
223    # this part is for tar.bz2
224
225    gcctarfile=${OUT}/${target}-gcc-${gcc}-newlib-${newlib}-${gccnewlib_rpm_release}.tar
226    if [ ${cdn_cross} = "no" ] ; then
227      bintarfile=${dst}/binaries/binutils-${binutils}-${binutils_rpm_release}/${target}-binutils-${binutils}-${binutils_rpm_release}.tar
228      cd /
229      rm -rf /opt/*
230      tar xjf ${bintarfile}.bz2
231    fi
232
233    cd ${CWD}
234    if [ ! -d gcc-${gcc} ] ; then
235      echo Could not find gcc-${gcc}!
236      exit 1
237    fi
238    if [ ! -d gcc-${gcc}/newlib ] ; then
239      echo Could not find gcc-${gcc}/newlib!
240      exit 1
241    fi
242    rm -rf b-${target}-gccnewlib
243    mkdir b-${target}-gccnewlib
244    cd b-${target}-gccnewlib
245    echo "Building gcc-${gcc} for ${target}"
246    ../gcc-${gcc}/configure ${CDN_ARGS} --target=${target} \
247      --with-gnu-as --with-gnu-ld --with-newlib --verbose --enable-threads \
248      --prefix=/opt/rtems '--enable-languages=c,c++' >${logfile} 2>&1
249    check_fatal $? "gcc configure"
250
251    make all >>${logfile} 2>&1
252    check_fatal $? "make all"
253
254    make info >>${logfile} 2>&1
255    check_fatal $? "make info"
256
257    make prefix=${rpm_build_root}/opt/rtems install >>${logfile} 2>&1
258    check_fatal $? "make install"
259
260    cd ${target}/newlib
261    make prefix=${rpm_build_root}/opt/rtems install-info  >>${logfile} 2>&1
262    check_fatal $? "newlib make install-info"
263
264    cd ${buildroot}
265    tar cjf ${gcctarfile}.bz2 opt
266    cd ${CWD}
267    rm -rf ${rpm_build_root}/opt
268    rm -rf ${rpm_build_root}/opt/rtems
269    rm -rf b-${target}-gccnewlib
270  else
271    echo Skipping gcc/newlib for ${target}
272  fi
273
274  #
275  # build gdb
276  #
277
278  if [ ${do_gdb} = yes ] ; then
279    # now build gdb
280    gdbtarfile=${OUT}/${target}-gdb-${gdb}-${gdb_rpm_release}.tar
281    logfile=${CWD}/log/${target}-gdb
282
283    # this part is for tar.bz2
284   
285    if [ ! -d gdb-${gdb} ] ; then
286      echo Could not find gdb-${gdb}!
287      exit 1
288    fi
289    mkdir b-${target}-gdb
290    cd b-${target}-gdb
291    case ${target} in
292      arm* | d10v* | d30v* | erc32* | fr30* | h8300* | h8500* | i960* | \
293      m32r* | mcore* | mips* | mn10200* | mn10300* | sh* | sparc*| v850* | \
294      w65* | z8k*)
295        extra_configure_arguments="--enable-sim"
296        ;;
297     powerpc*)
298        extra_configure_arguments="--enable-sim --enable-sim-powerpc --enable-sim-timebase --enable-sim-hardware"
299        #  Enabling this causes the program image to be huge and causes
300        #  some gcc/hosts combinations to run out of memory.
301        #          --enable-sim-inline
302        ;;
303      *)
304        ;;
305esac
306    echo "Building gdb-${gdb}/configure ${CDN_ARGS} --target=${target}"
307    ../gdb-${gdb}/configure ${CDN_ARGS} --target=${target} \
308      ${extra_configure_arguments} --verbose --prefix=/opt/rtems >${logfile} 2>&1
309    check_fatal $? "make info"
310
311    make all >>${logfile} 2>&1
312    check_fatal $? "make all"
313
314    make info >>${logfile} 2>&1
315    check_fatal $? "make info"
316
317    make prefix=${rpm_build_root}/opt/rtems install >>${logfile} 2>&1
318    check_fatal $? "make install"
319
320    make prefix=${rpm_build_root}/opt/rtems install-info >>${logfile} 2>&1
321    check_fatal $? "make install-info"
322
323    cd ${buildroot}
324    tar cjf ${gdbtarfile}.bz2 opt
325    cd ${CWD}
326    ${ECHO} rm -rf ${rpm_build_root}/opt
327    rm -rf ${rpm_build_root}/opt/rtems
328    rm -rf b-${target}-gdb
329  else
330    echo Skipping gdb for ${target}
331  fi
332
333done
334
335# Now we are done
336
337stop=`date`
338
339echo
340echo "Started:  " $start
341echo "Finished: " $stop
342exit 0
Note: See TracBrowser for help on using the repository browser.