[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" |
---|
| 20 | echo " -t -- enable test/debug mode" |
---|
| 21 | echo " -cfg <setup.cache>" |
---|
| 22 | echo " -o <rpm-spec-dir>" |
---|
| 23 | exit 1 ; |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | testing=no |
---|
| 27 | do_binutils=no |
---|
| 28 | do_gccnewlib=no |
---|
| 29 | do_gdb=no |
---|
| 30 | |
---|
| 31 | while test $# -ge 1; do |
---|
| 32 | case $1 in |
---|
| 33 | -b) do_binutils=yes ; shift;; |
---|
| 34 | -g) do_gccnewlib=yes ; shift;; |
---|
| 35 | -d) do_gdb=yes ; shift;; |
---|
| 36 | -t) do_test=yes ; shift;; |
---|
| 37 | -cfg) |
---|
| 38 | test $# -ge 2 || usage |
---|
| 39 | shift |
---|
| 40 | CFG=$1 |
---|
| 41 | shift |
---|
| 42 | ;; |
---|
| 43 | -o) |
---|
| 44 | test $# -ge 2 || usage |
---|
| 45 | shift |
---|
| 46 | dst=$1 |
---|
| 47 | shift |
---|
| 48 | ;; |
---|
| 49 | -*) |
---|
| 50 | echo "invalid option $1"; |
---|
| 51 | usage |
---|
| 52 | ;; |
---|
| 53 | *) |
---|
| 54 | TARGETS="${TARGETS} $1" |
---|
| 55 | shift |
---|
| 56 | ;; |
---|
| 57 | esac |
---|
| 58 | done |
---|
| 59 | |
---|
| 60 | if test ${do_binutils} = no -a ${do_gccnewlib} = no -a ${do_gdb} = no ; then |
---|
| 61 | echo "You must request building binutils, gcc/newlib, or gdb." |
---|
| 62 | usage |
---|
| 63 | fi |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | # This is the full list .. hppa1.1 does not build now. |
---|
| 67 | #ALL_TARGETS="hppa1.1-rtems i386-rtems i960-rtems m68k-rtems \ |
---|
| 68 | # m68k-rtemself mips-rtems mips64orion-rtems \ |
---|
| 69 | # powerpc-rtems sh-rtems sh-rtemself sparc-rtems" |
---|
| 70 | |
---|
| 71 | # This is the full buildable set. |
---|
| 72 | if [ "X${TARGETS}" = "X" ] ; then |
---|
| 73 | # do not include c4x or hppa primary targets |
---|
| 74 | # do not include sh-elf or i960-elf secondary targets |
---|
| 75 | TARGETS="arm-rtems h8300-rtems i386-rtems i960-rtems m68k-rtems \ |
---|
| 76 | mips-rtems mips64orion-rtems powerpc-rtems sh-rtems sparc-rtems" |
---|
| 77 | fi |
---|
| 78 | |
---|
| 79 | . $CFG |
---|
| 80 | |
---|
| 81 | binutils=${binutils_version} |
---|
| 82 | gcc=${gcc_version} |
---|
| 83 | gdb=${gdb_version} |
---|
| 84 | newlib=${newlib_version} |
---|
| 85 | # also use binutils_rpm_release |
---|
| 86 | buildroot=/tmp |
---|
| 87 | |
---|
| 88 | # |
---|
| 89 | # Now get started |
---|
| 90 | # |
---|
| 91 | start=`date` |
---|
| 92 | |
---|
| 93 | echo PATH=$PATH |
---|
| 94 | |
---|
| 95 | if [ ${testing} = yes ] ; then |
---|
| 96 | ECHO=echo |
---|
| 97 | fi |
---|
| 98 | |
---|
| 99 | #installed_count=`rpm -q -g rtems | wc -l` |
---|
| 100 | #if [ ${installed_count} -ne 0 ] ; then |
---|
| 101 | # echo This script should be run with NO rtems RPMs installed. |
---|
| 102 | # echo It appears that the following rtems RPMs are installed: |
---|
| 103 | # echo |
---|
| 104 | # rpm -qa | grep rtems |
---|
| 105 | # echo |
---|
| 106 | # echo Please remove these and restart this script. |
---|
| 107 | # exit 1 |
---|
| 108 | #fi |
---|
| 109 | |
---|
| 110 | #echo Copying specs files. |
---|
| 111 | #if [ ${testing} = no ] ; then |
---|
| 112 | # cd ${RTEMS_DIR} |
---|
| 113 | # |
---|
| 114 | # # ./configure || exit 1 |
---|
| 115 | # make || exit 1 |
---|
| 116 | # |
---|
| 117 | # # Now generate all the specs |
---|
| 118 | # for target in ${TARGETS} |
---|
| 119 | # do |
---|
| 120 | # tspecs=`find . -name "${target}*"` |
---|
| 121 | # if [ "X${tspecs}" = "X" ] ; then |
---|
| 122 | # echo RPM specifications were not generated for ${tspec}. |
---|
| 123 | # exit 1 |
---|
| 124 | # fi |
---|
| 125 | # ${ECHO} cp -r ${tspecs} ${dst} |
---|
| 126 | # done |
---|
| 127 | #fi |
---|
| 128 | |
---|
| 129 | # clean up a bit before we start |
---|
| 130 | cd ${dst} |
---|
| 131 | test -d log || mkdir log |
---|
| 132 | |
---|
| 133 | # do all the tools |
---|
| 134 | for target in ${TARGETS} |
---|
| 135 | do |
---|
| 136 | bintarfile=${PWD}/${target}-binutils-${binutils}-${binutils_rpm_release}.tar |
---|
| 137 | if [ ${do_binutils} = yes ] ; then |
---|
| 138 | # this part is for RPMS |
---|
| 139 | logfile=log/${target}-binutils |
---|
| 140 | #specfile=${dst}/${target}-binutils-${binutils}.spec |
---|
| 141 | #echo "rpm -ba ${specfile} >${logfile} 2>&1" |
---|
| 142 | #if [ ${testing} = no ] ; then |
---|
| 143 | # rpm -ba ${specfile} >${logfile} 2>&1 |
---|
| 144 | #fi |
---|
| 145 | #${ECHO} rm -rf ${dst}/../BUILD/${target}-binutils* |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | # this part is for tar.bz2 |
---|
| 149 | PWD=`pwd` |
---|
| 150 | mkdir b-${target} |
---|
| 151 | cd b-${target} |
---|
| 152 | ../binutils-${binutils}/configure --target=${target} \ |
---|
| 153 | --verbose --prefix=/opt/rtems |
---|
| 154 | make all |
---|
| 155 | make info |
---|
| 156 | make prefix=${rpm_build_root}/opt/rtems install |
---|
| 157 | make prefix=${rpm_build_root}/opt/rtems install-info |
---|
| 158 | cd ${buildroot} |
---|
| 159 | tar cf ${PWD}/${target}-binutils-${binutils}-${binutils_rpm_release}.tar opt |
---|
| 160 | cd ${PWD} |
---|
| 161 | bzip2 -9 ${target}-binutils-${binutils}.tar |
---|
| 162 | ${ECHO} rm -rf ${rpm_build_root}/opt |
---|
| 163 | rm -rf ${rpm_build_root}/opt/rtems |
---|
| 164 | rm -rf b-${target} |
---|
| 165 | else |
---|
| 166 | echo Skipping binutils for ${target} |
---|
| 167 | fi |
---|
| 168 | |
---|
| 169 | # |
---|
| 170 | # build gcc/newlib |
---|
| 171 | # |
---|
| 172 | |
---|
| 173 | if [ ${do_gccnewlib} = yes ] ; then |
---|
| 174 | # now build gcc/newlib |
---|
| 175 | # NOTE: This requires having binutils installed and we immediately |
---|
| 176 | # remove it once finished. |
---|
| 177 | #base_binutils_rpm=${dst}/../RPMS/${rpm_cpu}/rtems-base-binutils-${binutils}-${binutils_rpm_release}.${rpm_cpu}.rpm |
---|
| 178 | #binutils_rpm=${dst}/../RPMS/${rpm_cpu}/${target}-binutils-${binutils}-${binutils_rpm_release}.${rpm_cpu}.rpm |
---|
| 179 | #if [ ! -f ${binutils_rpm} ] ; then |
---|
| 180 | # echo There is no RPM for binutils for ${target}. |
---|
| 181 | # echo Looked for ${binutils_rpm}. |
---|
| 182 | #fi |
---|
| 183 | #${ECHO} rpm -i ${base_binutils_rpm} |
---|
| 184 | #${ECHO} rpm -i ${binutils_rpm} |
---|
| 185 | |
---|
| 186 | #logfile=log/${target}-gccnewlib |
---|
| 187 | #specfile=${dst}/${target}-gcc-${gcc}-newlib-${newlib}.spec |
---|
| 188 | #echo "rpm -ba ${specfile} >${logfile} 2>&1" |
---|
| 189 | #if [ ${testing} = no ] ; then |
---|
| 190 | # rpm -ba ${specfile} >${logfile} 2>&1 |
---|
| 191 | #fi |
---|
| 192 | #${ECHO} rm -rf ${dst}/../BUILD/${target}-gcc* |
---|
| 193 | #${ECHO} rm -rf ${buildroot}/opt/rtems |
---|
| 194 | |
---|
| 195 | #echo uninstalling binutils for ${target} |
---|
| 196 | #if [ ${testing} = no ] ; then |
---|
| 197 | # rpm -e `rpm -qa | grep rtems` |
---|
| 198 | # rm -rf /opt/rtems/* |
---|
| 199 | #fi |
---|
| 200 | |
---|
| 201 | # this part is for tar.bz2 |
---|
| 202 | PWD=`pwd` |
---|
| 203 | |
---|
| 204 | gcctarfile=${PWD}/${target}-gcc-${gcc}-newlib-${newlib}-${gccnewlib_rpm_release}.tar |
---|
| 205 | bintarfile=${dst}/binaries/binutils-${binutils}-${binutils_rpm_release}/${target}-binutils-${binutils}-${binutils_rpm_release}.tar |
---|
| 206 | cd / |
---|
| 207 | rm -rf /opt/* |
---|
| 208 | bzcat ${bintarfile}.bz2 | tar xf - |
---|
| 209 | |
---|
| 210 | cd ${PWD} |
---|
| 211 | rm -rf b-${target} |
---|
| 212 | mkdir b-${target} |
---|
| 213 | cd b-${target} |
---|
| 214 | ../gcc-${gcc}/configure --target=${target} \ |
---|
| 215 | --with-gnu-as --with-gnu-ld --with-newlib --verbose \ |
---|
| 216 | --enable-threads --prefix=/opt/rtems '--enable-languages=c,c++' |
---|
| 217 | make all |
---|
| 218 | make info |
---|
| 219 | make prefix=${rpm_build_root}/opt/rtems install |
---|
| 220 | make prefix=${rpm_build_root}/opt/rtems install-info |
---|
| 221 | cd ${target}/newlib |
---|
| 222 | make prefix=${rpm_build_root}/opt/rtems install-info |
---|
| 223 | cd ${buildroot} |
---|
| 224 | tar cf ${gcctarfile} opt |
---|
| 225 | cd ${PWD} |
---|
| 226 | bzip2 -9 ${gcctarfile} |
---|
| 227 | rm -rf ${rpm_build_root}/opt |
---|
| 228 | rm -rf ${rpm_build_root}/opt/rtems |
---|
| 229 | rm -rf b-${target} |
---|
| 230 | else |
---|
| 231 | echo Skipping gcc/newlib for ${target} |
---|
| 232 | fi |
---|
| 233 | |
---|
| 234 | # |
---|
| 235 | # build gdb |
---|
| 236 | # |
---|
| 237 | |
---|
| 238 | if [ ${do_gdb} = yes ] ; then |
---|
| 239 | # now build gdb |
---|
| 240 | #logfile=log/${target}-gdb |
---|
| 241 | #specfile=${dst}/${target}-gdb-${gdb}.spec |
---|
| 242 | #echo "rpm -ba ${specfile} >${logfile} 2>&1" |
---|
| 243 | #if [ ${testing} = no ] ; then |
---|
| 244 | # rpm -ba ${specfile} >${logfile} 2>&1 |
---|
| 245 | #fi |
---|
| 246 | #${ECHO} rm -rf ${dst}/../BUILD/${target}-gdb* |
---|
| 247 | #${ECHO} rm -rf ${buildroot}/opt/rtems |
---|
| 248 | |
---|
| 249 | # this part is for tar.bz2 |
---|
| 250 | |
---|
| 251 | PWD=`pwd` |
---|
| 252 | mkdir b-${target} |
---|
| 253 | cd b-${target} |
---|
| 254 | case ${target} in |
---|
| 255 | arm* | d10v* | d30v* | erc32* | fr30* | h8300* | h8500* | i960* | \ |
---|
| 256 | m32r* | mcore* | mips* | mn10200* | mn10300* | sh* | sparc*| v850* | \ |
---|
| 257 | w65* | z8k*) |
---|
| 258 | extra_configure_arguments="--enable-sim" |
---|
| 259 | ;; |
---|
| 260 | powerpc*) |
---|
| 261 | extra_configure_arguments="--enable-sim --enable-sim-powerpc --enable-sim-timebase --enable-sim-hardware" |
---|
| 262 | # Enabling this causes the program image to be huge and causes |
---|
| 263 | # some gcc/hosts combinations to run out of memory. |
---|
| 264 | # --enable-sim-inline |
---|
| 265 | ;; |
---|
| 266 | *) |
---|
| 267 | ;; |
---|
| 268 | esac |
---|
| 269 | ../gdb-${gdb}/configure --target=${target} \ |
---|
| 270 | ${extra_configure_arguments} --verbose --prefix=/opt/rtems |
---|
| 271 | make all |
---|
| 272 | make info |
---|
| 273 | make prefix=${rpm_build_root}/opt/rtems install |
---|
| 274 | make prefix=${rpm_build_root}/opt/rtems install-info |
---|
| 275 | cd ${buildroot} |
---|
| 276 | tar cf ${PWD}/${target}-gdb-${gdb}-${gdb_rpm_release}.tar opt |
---|
| 277 | cd ${PWD} |
---|
| 278 | bzip2 -9 ${target}-gdb-${gdb}.tar |
---|
| 279 | ${ECHO} rm -rf ${rpm_build_root}/opt |
---|
| 280 | rm -rf ${rpm_build_root}/opt/rtems |
---|
| 281 | rm -rf b-${target} |
---|
| 282 | else |
---|
| 283 | echo Skipping gdb for ${target} |
---|
| 284 | fi |
---|
| 285 | |
---|
| 286 | done |
---|
| 287 | |
---|
| 288 | # Now we are done |
---|
| 289 | |
---|
| 290 | stop=`date` |
---|
| 291 | |
---|
| 292 | echo |
---|
| 293 | echo "Started: " $start |
---|
| 294 | echo "Finished: " $stop |
---|
| 295 | exit 0 |
---|