[302b76d] | 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=/usr/src/redhat/SPECS |
---|
| 9 | dst=`pwd` |
---|
| 10 | target=@target@ |
---|
| 11 | rpm_cpu=i386 |
---|
| 12 | |
---|
| 13 | usage() |
---|
| 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" |
---|
[08f224b] | 20 | echo " -C HOST -- build canadian cross for HOST " |
---|
[302b76d] | 21 | echo " -t -- enable test/debug mode" |
---|
| 22 | echo " -cfg <setup.cache>" |
---|
| 23 | echo " -o <rpm-spec-dir>" |
---|
| 24 | exit 1 ; |
---|
| 25 | } |
---|
| 26 | |
---|
[08f224b] | 27 | # |
---|
| 28 | # Checks the status returned by executables and exits if it is non-zero. |
---|
| 29 | # |
---|
| 30 | check_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 | |
---|
[302b76d] | 44 | testing=no |
---|
| 45 | do_binutils=no |
---|
| 46 | do_gccnewlib=no |
---|
| 47 | do_gdb=no |
---|
[08f224b] | 48 | cdn_cross=no |
---|
[302b76d] | 49 | |
---|
| 50 | while 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 | ;; |
---|
[08f224b] | 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 | ;; |
---|
[302b76d] | 80 | -*) |
---|
| 81 | echo "invalid option $1"; |
---|
| 82 | usage |
---|
| 83 | ;; |
---|
| 84 | *) |
---|
| 85 | TARGETS="${TARGETS} $1" |
---|
| 86 | shift |
---|
| 87 | ;; |
---|
| 88 | esac |
---|
| 89 | done |
---|
| 90 | |
---|
| 91 | if 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 |
---|
| 94 | fi |
---|
| 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. |
---|
| 103 | if [ "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" |
---|
| 108 | fi |
---|
| 109 | |
---|
| 110 | . $CFG |
---|
| 111 | |
---|
| 112 | binutils=${binutils_version} |
---|
| 113 | gcc=${gcc_version} |
---|
| 114 | gdb=${gdb_version} |
---|
| 115 | newlib=${newlib_version} |
---|
| 116 | # also use binutils_rpm_release |
---|
| 117 | buildroot=/tmp |
---|
| 118 | |
---|
| 119 | # |
---|
| 120 | # Now get started |
---|
| 121 | # |
---|
| 122 | start=`date` |
---|
| 123 | |
---|
| 124 | echo PATH=$PATH |
---|
| 125 | |
---|
| 126 | if [ ${testing} = yes ] ; then |
---|
| 127 | ECHO=echo |
---|
| 128 | fi |
---|
| 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 |
---|
| 161 | cd ${dst} |
---|
| 162 | test -d log || mkdir log |
---|
| 163 | |
---|
[08f224b] | 164 | if [ "X${rpm_build_root}" = "X" ] ; then |
---|
| 165 | echo rpm_build_root NOT set! |
---|
| 166 | exit 1 |
---|
| 167 | fi |
---|
| 168 | |
---|
| 169 | CWD=`pwd` |
---|
| 170 | test -d tarballs || mkdir tarballs |
---|
| 171 | |
---|
| 172 | OUT=${CWD}/tarballs |
---|
| 173 | |
---|
[302b76d] | 174 | # do all the tools |
---|
| 175 | for target in ${TARGETS} |
---|
| 176 | do |
---|
[08f224b] | 177 | bintarfile=${OUT}/${target}-binutils-${binutils}-${binutils_rpm_release}.tar |
---|
[302b76d] | 178 | if [ ${do_binutils} = yes ] ; then |
---|
[08f224b] | 179 | logfile=${CWD}/log/${target}-binutils |
---|
[302b76d] | 180 | # this part is for tar.bz2 |
---|
[08f224b] | 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 | |
---|
[302b76d] | 206 | cd ${buildroot} |
---|
[08f224b] | 207 | tar cjf ${bintarfile}.bz2 opt |
---|
| 208 | cd ${CWD} |
---|
| 209 | rm -rf b-${target}-bin |
---|
[302b76d] | 210 | ${ECHO} rm -rf ${rpm_build_root}/opt |
---|
[08f224b] | 211 | #rm -rf ${rpm_build_root}/opt |
---|
[302b76d] | 212 | else |
---|
| 213 | echo Skipping binutils for ${target} |
---|
| 214 | fi |
---|
| 215 | |
---|
| 216 | # |
---|
| 217 | # build gcc/newlib |
---|
| 218 | # |
---|
| 219 | |
---|
| 220 | if [ ${do_gccnewlib} = yes ] ; then |
---|
[08f224b] | 221 | logfile=${CWD}/log/${target}-gccnewlib |
---|
[302b76d] | 222 | # now build gcc/newlib |
---|
| 223 | # this part is for tar.bz2 |
---|
[08f224b] | 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 | |
---|
[302b76d] | 260 | cd ${target}/newlib |
---|
[08f224b] | 261 | make prefix=${rpm_build_root}/opt/rtems install-info >>${logfile} 2>&1 |
---|
| 262 | check_fatal $? "newlib make install-info" |
---|
| 263 | |
---|
[302b76d] | 264 | cd ${buildroot} |
---|
[08f224b] | 265 | tar cjf ${gcctarfile}.bz2 opt |
---|
| 266 | cd ${CWD} |
---|
[302b76d] | 267 | rm -rf ${rpm_build_root}/opt |
---|
| 268 | rm -rf ${rpm_build_root}/opt/rtems |
---|
[08f224b] | 269 | rm -rf b-${target}-gccnewlib |
---|
[302b76d] | 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 |
---|
[08f224b] | 280 | gdbtarfile=${OUT}/${target}-gdb-${gdb}-${gdb_rpm_release}.tar |
---|
| 281 | logfile=${CWD}/log/${target}-gdb |
---|
[302b76d] | 282 | |
---|
| 283 | # this part is for tar.bz2 |
---|
| 284 | |
---|
[08f224b] | 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 |
---|
[302b76d] | 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 | ;; |
---|
| 305 | esac |
---|
[08f224b] | 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 | |
---|
[302b76d] | 323 | cd ${buildroot} |
---|
[08f224b] | 324 | tar cjf ${gdbtarfile}.bz2 opt |
---|
| 325 | cd ${CWD} |
---|
[302b76d] | 326 | ${ECHO} rm -rf ${rpm_build_root}/opt |
---|
| 327 | rm -rf ${rpm_build_root}/opt/rtems |
---|
[08f224b] | 328 | rm -rf b-${target}-gdb |
---|
[302b76d] | 329 | else |
---|
| 330 | echo Skipping gdb for ${target} |
---|
| 331 | fi |
---|
| 332 | |
---|
| 333 | done |
---|
| 334 | |
---|
| 335 | # Now we are done |
---|
| 336 | |
---|
| 337 | stop=`date` |
---|
| 338 | |
---|
| 339 | echo |
---|
| 340 | echo "Started: " $start |
---|
| 341 | echo "Finished: " $stop |
---|
| 342 | exit 0 |
---|