[d35e532b] | 1 | #! /bin/sh |
---|
| 2 | # |
---|
| 3 | # Generate all the specs and then cycle through building them. |
---|
| 4 | # |
---|
| 5 | |
---|
| 6 | RTEMS_DIR=`dirname $0` |
---|
[43e7d103] | 7 | CFG=./setup.cache |
---|
[d35e532b] | 8 | dst=@RPM_SPECSdir@ |
---|
[df49c60] | 9 | target=@target@ |
---|
| 10 | rpm_cpu=@RPM_CPU@ |
---|
[d35e532b] | 11 | |
---|
| 12 | usage() |
---|
| 13 | { |
---|
| 14 | echo "$0 [options] <target_alias>" |
---|
| 15 | echo " options:" |
---|
[df49c60] | 16 | echo " -b -- build binutils" |
---|
| 17 | echo " -g -- build gcc/newlib" |
---|
| 18 | echo " -d -- build gdb" |
---|
| 19 | echo " -t -- enable test/debug mode" |
---|
[43e7d103] | 20 | echo " -cfg <setup.cache>" |
---|
[d35e532b] | 21 | echo " -o <rpm-spec-dir>" |
---|
| 22 | exit 1 ; |
---|
| 23 | } |
---|
| 24 | |
---|
[df49c60] | 25 | testing=no |
---|
| 26 | do_binutils=no |
---|
| 27 | do_gccnewlib=no |
---|
| 28 | do_gdb=no |
---|
| 29 | |
---|
[d35e532b] | 30 | while test $# -ge 1; do |
---|
| 31 | case $1 in |
---|
[df49c60] | 32 | -b) do_binutils=yes ; shift;; |
---|
| 33 | -g) do_gccnewlib=yes ; shift;; |
---|
| 34 | -d) do_gdb=yes ; shift;; |
---|
| 35 | -t) do_test=yes ; shift;; |
---|
[d35e532b] | 36 | -cfg) |
---|
| 37 | test $# -ge 2 || usage |
---|
| 38 | shift |
---|
| 39 | CFG=$1 |
---|
| 40 | shift |
---|
| 41 | ;; |
---|
| 42 | -o) |
---|
| 43 | test $# -ge 2 || usage |
---|
| 44 | shift |
---|
| 45 | dst=$1 |
---|
| 46 | shift |
---|
| 47 | ;; |
---|
| 48 | -*) |
---|
| 49 | echo "invalid option $1"; |
---|
| 50 | usage |
---|
| 51 | ;; |
---|
| 52 | *) |
---|
| 53 | TARGETS="${TARGETS} $1" |
---|
| 54 | shift |
---|
| 55 | ;; |
---|
| 56 | esac |
---|
| 57 | done |
---|
| 58 | |
---|
[df49c60] | 59 | if test ${do_binutils} = no -a ${do_gccnewlib} = no -a ${do_gdb} = no ; then |
---|
| 60 | echo "You must request building binutils, gcc/newlib, or gdb." |
---|
| 61 | usage |
---|
| 62 | fi |
---|
| 63 | |
---|
| 64 | |
---|
[d35e532b] | 65 | # This is the full list .. hppa1.1 does not build now. |
---|
| 66 | #ALL_TARGETS="hppa1.1-rtems i386-rtems i960-rtems m68k-rtems \ |
---|
[06f2f75] | 67 | # m68k-rtemself mips-rtems mips64orion-rtems \ |
---|
[d35e532b] | 68 | # powerpc-rtems sh-rtems sh-rtemself sparc-rtems" |
---|
| 69 | |
---|
| 70 | # This is the full buildable set. |
---|
| 71 | if [ "X${TARGETS}" = "X" ] ; then |
---|
[08330bf] | 72 | # do not include c4x or hppa primary targets |
---|
| 73 | # do not include sh-elf or i960-elf secondary targets |
---|
| 74 | TARGETS="arm-rtems h8300-rtems i386-rtems i960-rtems m68k-rtems \ |
---|
[06f2f75] | 75 | mips-rtems mips64orion-rtems powerpc-rtems sh-rtems sparc-rtems" |
---|
[d35e532b] | 76 | fi |
---|
| 77 | |
---|
[98e6eb8] | 78 | . $CFG |
---|
[d35e532b] | 79 | |
---|
| 80 | binutils=${binutils_version} |
---|
| 81 | gcc=${gcc_version} |
---|
| 82 | gdb=${gdb_version} |
---|
| 83 | newlib=${newlib_version} |
---|
| 84 | # also use binutils_rpm_release |
---|
[43e7d103] | 85 | buildroot=/tmp |
---|
[d35e532b] | 86 | |
---|
| 87 | # |
---|
| 88 | # Now get started |
---|
| 89 | # |
---|
| 90 | start=`date` |
---|
| 91 | |
---|
| 92 | echo PATH=$PATH |
---|
| 93 | |
---|
| 94 | if [ ${testing} = yes ] ; then |
---|
| 95 | ECHO=echo |
---|
| 96 | fi |
---|
| 97 | |
---|
[349a01cc] | 98 | installed_count=`rpm -q -g rtems | grep -v "auto" | grep -v "does not contain" | wc -l` |
---|
[d35e532b] | 99 | if [ ${installed_count} -ne 0 ] ; then |
---|
| 100 | echo This script should be run with NO rtems RPMs installed. |
---|
| 101 | echo It appears that the following rtems RPMs are installed: |
---|
| 102 | echo |
---|
| 103 | rpm -qa | grep rtems |
---|
| 104 | echo |
---|
| 105 | echo Please remove these and restart this script. |
---|
| 106 | exit 1 |
---|
| 107 | fi |
---|
| 108 | |
---|
[98e6eb8] | 109 | echo Copying specs files. |
---|
[d35e532b] | 110 | if [ ${testing} = no ] ; then |
---|
| 111 | cd ${RTEMS_DIR} |
---|
[98e6eb8] | 112 | |
---|
| 113 | # ./configure || exit 1 |
---|
[d35e532b] | 114 | make || exit 1 |
---|
| 115 | |
---|
| 116 | # Now generate all the specs |
---|
| 117 | for target in ${TARGETS} |
---|
| 118 | do |
---|
| 119 | tspecs=`find . -name "${target}*"` |
---|
[43e7d103] | 120 | if [ "X${tspecs}" = "X" ] ; then |
---|
| 121 | echo RPM specifications were not generated for ${tspec}. |
---|
| 122 | exit 1 |
---|
| 123 | fi |
---|
[d35e532b] | 124 | ${ECHO} cp -r ${tspecs} ${dst} |
---|
| 125 | done |
---|
| 126 | fi |
---|
| 127 | |
---|
| 128 | # clean up a bit before we start |
---|
| 129 | cd ${dst} |
---|
| 130 | test -d log || mkdir log |
---|
| 131 | |
---|
| 132 | # do all the tools |
---|
| 133 | for target in ${TARGETS} |
---|
| 134 | do |
---|
| 135 | if [ ${do_binutils} = yes ] ; then |
---|
| 136 | logfile=log/${target}-binutils |
---|
| 137 | specfile=${dst}/${target}-binutils-${binutils}.spec |
---|
| 138 | echo "rpm -ba ${specfile} >${logfile} 2>&1" |
---|
| 139 | if [ ${testing} = no ] ; then |
---|
| 140 | rpm -ba ${specfile} >${logfile} 2>&1 |
---|
| 141 | fi |
---|
| 142 | ${ECHO} rm -rf ${dst}/../BUILD/${target}-binutils* |
---|
[43e7d103] | 143 | ${ECHO} rm -rf ${buildroot}/opt/rtems |
---|
[d35e532b] | 144 | else |
---|
| 145 | echo Skipping binutils for ${target} |
---|
| 146 | fi |
---|
| 147 | |
---|
[2f23359] | 148 | # |
---|
| 149 | # build gcc/newlib |
---|
| 150 | # |
---|
[d35e532b] | 151 | |
---|
| 152 | if [ ${do_gccnewlib} = yes ] ; then |
---|
| 153 | # now build gcc/newlib |
---|
| 154 | # NOTE: This requires having binutils installed and we immediately |
---|
| 155 | # remove it once finished. |
---|
[df49c60] | 156 | base_binutils_rpm=${dst}/../RPMS/${rpm_cpu}/rtems-base-binutils-${binutils}-${binutils_rpm_release}.${rpm_cpu}.rpm |
---|
| 157 | binutils_rpm=${dst}/../RPMS/${rpm_cpu}/${target}-binutils-${binutils}-${binutils_rpm_release}.${rpm_cpu}.rpm |
---|
[d35e532b] | 158 | if [ ! -f ${binutils_rpm} ] ; then |
---|
| 159 | echo There is no RPM for binutils for ${target}. |
---|
| 160 | echo Looked for ${binutils_rpm}. |
---|
| 161 | fi |
---|
[5eac93c7] | 162 | ${ECHO} rpm -i ${base_binutils_rpm} |
---|
[d35e532b] | 163 | ${ECHO} rpm -i ${binutils_rpm} |
---|
| 164 | |
---|
| 165 | logfile=log/${target}-gccnewlib |
---|
| 166 | specfile=${dst}/${target}-gcc-${gcc}-newlib-${newlib}.spec |
---|
| 167 | echo "rpm -ba ${specfile} >${logfile} 2>&1" |
---|
| 168 | if [ ${testing} = no ] ; then |
---|
| 169 | rpm -ba ${specfile} >${logfile} 2>&1 |
---|
| 170 | fi |
---|
| 171 | ${ECHO} rm -rf ${dst}/../BUILD/${target}-gcc* |
---|
[43e7d103] | 172 | ${ECHO} rm -rf ${buildroot}/opt/rtems |
---|
[d35e532b] | 173 | |
---|
| 174 | echo uninstalling binutils for ${target} |
---|
| 175 | if [ ${testing} = no ] ; then |
---|
| 176 | rpm -e `rpm -qa | grep rtems` |
---|
[ee9d8d52] | 177 | rm -rf /opt/rtems/* |
---|
[d35e532b] | 178 | fi |
---|
| 179 | else |
---|
| 180 | echo Skipping gcc/newlib for ${target} |
---|
| 181 | fi |
---|
[2f23359] | 182 | |
---|
| 183 | # |
---|
| 184 | # build gdb |
---|
| 185 | # |
---|
| 186 | |
---|
| 187 | if [ ${do_gdb} = yes ] ; then |
---|
| 188 | # now build gdb |
---|
| 189 | logfile=log/${target}-gdb |
---|
| 190 | specfile=${dst}/${target}-gdb-${gdb}.spec |
---|
| 191 | echo "rpm -ba ${specfile} >${logfile} 2>&1" |
---|
| 192 | if [ ${testing} = no ] ; then |
---|
| 193 | rpm -ba ${specfile} >${logfile} 2>&1 |
---|
| 194 | fi |
---|
| 195 | ${ECHO} rm -rf ${dst}/../BUILD/${target}-gdb* |
---|
[43e7d103] | 196 | ${ECHO} rm -rf ${buildroot}/opt/rtems |
---|
[2f23359] | 197 | else |
---|
| 198 | echo Skipping gdb for ${target} |
---|
| 199 | fi |
---|
| 200 | |
---|
[d35e532b] | 201 | done |
---|
| 202 | |
---|
| 203 | # Now we are done |
---|
| 204 | |
---|
| 205 | stop=`date` |
---|
| 206 | |
---|
| 207 | echo |
---|
| 208 | echo "Started: " $start |
---|
| 209 | echo "Finished: " $stop |
---|
| 210 | exit 0 |
---|