summaryrefslogtreecommitdiffstats
path: root/scripts/buildall
blob: c91d6e9a2c8fcc95dc9aded13fc929e3eec0bda9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#! /bin/sh
#
#  Generate all the specs and then cycle through building them.
#

RTEMS_DIR=`dirname $0`

# This is the full list .. hppa1.1 does not build now.
#ALL_TARGETS="hppa1.1-rtems i386-rtems i960-rtems m68k-rtems \
#  m68k-rtemself mips64orion-rtems \
#  powerpc-rtems sh-rtems sh-rtemself sparc-rtems"

# This is the full buildable set.
ALL_TARGETS="i386-rtems i960-rtems m68k-rtems \
  m68k-rtemself mips64orion-rtems \
  powerpc-rtems sh-rtems sh-rtemself sparc-rtems"

# This is what we are building this time
#TARGETS=${ALL_TARGETS}
TARGETS="sh-rtems"

binutils=990901
gcc=2.95.1
gdb=4.18
newlib=1.8.2
buildroot=/opt/tmp

testing=yes
do_binutils=yes
do_gdb=yes
do_gccnewlib=yes
staging_dir=/usr3/rtems_cds/test_cd/linux

#
#  Now get started
#
start=`date`

echo PATH=$PATH

if [ ${testing} = yes ] ; then
  ECHO=echo
fi

installed_count=`rpm -qa | grep rtems | wc -l`
if [ ${installed_count} -ne 0 ] ; then
  echo This script should be run with NO rtems RPMs installed.
  echo It appears that the following rtems RPMs are installed:
  echo
  rpm -qa | grep rtems
  echo
  echo Please remove these and restart this script.
  exit 1
fi

# Some linux distributions use /usr/src/packages
# redhat uses /usr/src/redhat
# others might use /usr/src
if test -d /usr/src/packages/SPECS;
then
dst=/usr/src/packages/SPECS;
elif test -d /usr/src/redhat/SPECS;
 then
dst=/usr/src/redhat/SPECS;
elif test -d /usr/src/SPECS/;
then
dst=/usr/src/SPECS;
fi

if [ ${testing} = no ] ; then
  cd ${RTEMS_DIR}/scripts
  ./configure || exit 1
  make        || exit 1
fi

#  Now generate all the specs
for target in ${TARGETS}
do
  tspecs=`find . -name "${target}*"`
  ${ECHO} cp -r ${tspecs} ${dst}
done

# clean up a bit before we start
cd ${dst}
test -d log || mkdir log

#  do all the tools
for target in ${TARGETS}
do
  if [ ${do_binutils} = yes ] ; then
    logfile=log/${target}-binutils
    specfile=${dst}/${target}-binutils-${binutils}.spec
    echo "rpm -ba --buildroot=${buildroot} ${specfile} >${logfile} 2>&1"
    if [ ${testing} = no ] ; then
      rpm -ba --buildroot=${buildroot} ${specfile} >${logfile} 2>&1
    fi
    ${ECHO} rm -rf ${dst}/../BUILD/${target}-binutils*
    ${ECHO} rm -rf ${buildroot}/opt
  else
    echo Skipping binutils for ${target}
  fi

  if [ ${do_gdb} = yes ] ; then
    # now build gdb
    logfile=log/${target}-gdb
    specfile=${dst}/${target}-gdb-${gdb}.spec
    echo "rpm -ba --buildroot=${buildroot} ${specfile} >${logfile} 2>&1"
    if [ ${testing} = no ] ; then
      rpm -ba --buildroot=${buildroot} ${specfile} >${logfile} 2>&1
    fi
    ${ECHO} rm -rf ${dst}/../BUILD/${target}-gdb*
    ${ECHO} rm -rf ${buildroot}/opt
  else
    echo Skipping gdb for ${target}
  fi

  if [ ${do_gccnewlib} = yes ] ; then
    # now build gcc/newlib
    #    NOTE: This requires having binutils installed and we immediately
    #          remove it once finished.
    binutils_rpm=${dst}/../RPMS/i386/${target}-binutils-${binutils}-0.i386.rpm
    if [ ! -f ${binutils_rpm} ] ; then
      echo There is no RPM for binutils for ${target}.
      echo Looked for ${binutils_rpm}.
    fi
    ${ECHO} rpm -i ${binutils_rpm}

    logfile=log/${target}-gccnewlib
    specfile=${dst}/${target}-gcc-${gcc}-newlib-${newlib}.spec
    echo "rpm -ba --buildroot=${buildroot} ${specfile} >${logfile} 2>&1"
    if [ ${testing} = no ] ; then
      rpm -ba --buildroot=${buildroot} ${specfile} >${logfile} 2>&1
    fi
    ${ECHO} rm -rf ${dst}/../BUILD/${target}-gcc*
    ${ECHO} rm -rf ${buildroot}/opt

    echo uninstalling binutils for ${target} 
    if [ ${testing} = no ] ; then
      rpm -e `rpm -qa | grep rtems`
    fi
  else
    echo Skipping gcc/newlib for ${target}
  fi
done

if [ X${staging_dir} != X ] ; then
  echo "Moving files to a staging directory for distribution."
  echo "Plus it saves space in /usr. :)"
  echo
  echo Making staging directory..
  ${ECHO} mkdir ${staging_dir}
  ${ECHO} mkdir ${staging_dir}/RPMS
  ${ECHO} mkdir ${staging_dir}/SRPMS

  echo Moving RPMs to CD staging directory
  for file in `ls -1 ${dst}/../RPMS/i386/*.rpm 2>/dev/null`
  do
    echo Moving ${file}
    ${ECHO} mv ${file} ${staging_dir}/RPMS
  done

  echo Moving SRPMs to CD staging directory
  for file in `ls -1 ${dst}/../SRPMS/*.rpm 2>/dev/null`
  do
    echo Moving ${file}
    ${ECHO} mv ${file} ${staging_dir}/SRPMS
  done
fi

# Now we are done

stop=`date`

echo
echo "Started:  " $start
echo "Finished: " $stop
exit 0