source: rtems/contrib/mingw/build-rpms.sh @ 0e6d50c

4.104.114.95
Last change on this file since 0e6d50c was f6cd0db, checked in by Chris Johns <chrisj@…>, on 07/28/07 at 08:31:57

2007-07-28 Chris Johns <chisj@…>

  • README, build-rpms.sh, rtems.ini, build-exes.sh, rtems-tools.nsi: Updated to the new 4.8 build plus a new installer.
  • autoconf.def, automake.def, ba-wrap.sh, build-autotools.sh, msys-path.nsi, rtems-autotools.nsi, target-section-text, upload.sh, version: New to version 4.8. Autotools is built when installing.
  • Property mode set to 100755
File size: 8.3 KB
Line 
1#! /bin/sh
2#
3# $Id$
4#
5# RTEMS Build RPM script.
6#
7# This script builds the RTEMS tools into RPM packages on a Linux Fedora host,
8# and supports Canadian cross builds to other hosts. It is light sugar around
9# the fine work of Ralf Corsepius thats actually builds the RPM files.
10#
11# We build all the targets for a given host.
12#
13# Note: This file should be placed in crossrpms.
14#
15
16source=$(dirname $0)
17
18terminate()
19{
20  echo "error: $*" >&2
21  exit 1
22}
23
24check()
25{
26 if [ $? -ne 0 ]; then
27  terminate
28 fi
29}
30
31processor=$(uname -p)
32
33. $source/version
34
35base_tool_list="binutils gcc"
36
37target_list=$(cat $source/targets)
38host_list="cygwin freebsd5.2 freebsd6.0 freebsd6.1 mingw32"
39
40rtems_tool_list="autoconf automake $base_tool_list gdb"
41linux_tool_list="autoconf automake $base_tool_list"
42cygwin_tool_list="w32api libs autoconf automake $base_tool_list"
43freebsd_tool_list="libs autoconf automake $base_tool_list"
44mingw32_tool_list="w32api libs autoconf automake $base_tool_list"
45
46cygwin_cc_name="pc"
47freebsd_cc_name="pc"
48mingw32_cc_name="pc"
49
50linux_cpu_list="$processor"
51cygwin_cpu_list="i686"
52freebsd_cpu_list="i586"
53mingw32_cpu_list="i686"
54
55rpm_topdir=$(rpm --eval "%{_topdir}")
56
57prefix=/opt/rtems-$version
58hosts=$host_list
59build=$processor-linux-gnu
60infos=
61targets=$target_list
62run_prefix=
63rpm_prefix=custom-
64rpm_prefix_arg=
65local_rpm_database=yes
66clean=yes
67
68while [ $# -gt 0 ];
69do
70 case $1 in
71  -c)
72   clean=no
73   ;;
74  -d)
75   set -x
76   ;;
77  -h)
78   shift
79   hosts=$1
80   ;;
81  -i)
82   infos="--enable-infos"
83   ;;
84  -l)
85   shift
86   rpm_prefix=$1-
87   rpm_prefix_arg="--enable-rpmprefix=$rpm_label"
88   ;;
89  -n)
90   run_prefix="echo "
91   ;;
92  -p)
93   shift
94   prefix=$1
95   ;;
96  -R)
97   local_rpm_database=no
98   ;;
99  -s)
100   shift
101   source=$1
102   ;;
103  -t)
104   shift
105   targets=$1
106   ;;
107  -v)
108   shift
109   version=$1
110   ;;
111  --help)
112   echo "$0 -cdinr -o <output> -h <hosts>" \
113        "-l <rpm prefix> -p <prefix> -s <source> -t <targets> -v <version>"
114   exit 2
115   ;;
116  *)
117   terminate "error: invalid option (try --help): $1"
118   ;;
119 esac
120 shift
121done
122
123for t in $targets;
124do
125 if [ -z "$(echo $target_list | grep $t)" ]; then
126  terminate "error: invalid target: $t"
127 fi
128done
129
130cd=${run_prefix}cd
131configure=${run_prefix}${source}/configure
132cp=${run_prefix}cp
133make=${run_prefix}make
134mkdir=${run_prefix}mkdir
135rm=${run_prefix}rm
136rpmbuild=${run_prefix}rpmbuild
137rpm=${run_prefix}rpm
138
139if [ $local_rpm_database = yes ]; then
140  rpm_database="--dbpath $prefix/var/lib/rpm"
141else
142  rpm_database=
143fi
144
145echo " Source: $source"
146echo " Prefix: $prefix"
147echo "  Hosts: $hosts"
148echo "Targets: $targets"
149
150if [ ! -f $source/configure ]; then
151 terminate "$source/configure not found under: $source"
152fi
153
154if [ x$prefix != x ]; then
155 if [ -e $prefix ]; then
156  if [ ! -d $prefix ]; then
157   terminate "$prefix is not a directory"
158  fi
159 else
160  echo "Creating $(pwd)"
161  $mkdir -p $prefix
162  check "making the prefix directory: $prefix"
163 fi
164fi
165
166$cd $prefix
167check "cannot change to the prefix directory: $prefix"
168
169if [ $clean = yes ]; then
170 echo "Cleaning: $(pwd)"
171 $rm -rf *
172fi
173
174#
175# Using a local RPM database means we do not need to be root to
176# perform the build.
177#
178if [ $local_rpm_database = yes ]; then
179 echo "Creating private RPM database: $(pwd)/var/lib/rpm"
180 if [ ! -d /var/lib/rpm ]; then
181  terminate "no RPM database found on this host"
182  exit 1
183 fi
184 if [ ! -d var/lib ]; then
185  $mkdir -p var/lib
186  check "making the local RPM database directory: var/lib"
187 fi
188 if [ $clean = yes -o ! -e var/lib/rpmPackages ]; then
189  echo "Copying RPM database to a local RPM database"
190  $cp -r /var/lib/rpm var/lib/rpm
191  check "copying the RPM database to the local database"
192 fi
193fi
194
195#
196# Set the path to the new directory.
197#
198export PATH=$prefix/bin:$PATH
199
200#
201# Install the RPM.
202#
203
204rpm_installer()
205{
206 local rpm_common=
207 local rpm_libs=
208 local rpm_tools=
209 local r
210
211 local rpm_database=$1
212 shift
213 local rpm_arch=$1
214 shift
215 local rpm_path=$1
216 shift
217
218 #
219 # Get the names of the rpm files that have been built. This means we
220 # do not have maintain version info.
221 #
222 rpm_names=$(rpmbuild $rpm_database $* --nobuild 2> /dev/null | \
223             grep -v "debuginfo" | grep "Process" | sed 's/Process.*\: //')
224 #
225 # If we have a base place that one first then libs then the tools.
226 #
227 for r in $rpm_names
228 do
229  if [ $(echo $r | sed 's/.*common.*/yes/') = yes ]; then
230   rpm_common="$rpm_common $r"
231  elif [ $(echo $r | sed 's/.*lib.*/yes/') = yes ]; then
232   rpm_libs="$rpm_libs $r"
233  elif [ $(echo $r | sed 's/.*sys\-root.*/yes/') = yes ]; then
234   rpm_libs="$rpm_libs $r"
235  else
236   rpm_tools="$rpm_tools $r"
237  fi
238 done
239
240 for r in $rpm_common $rpm_libs $rpm_tools
241 do
242  echo "rpm $rpm_database --force" \
243           "-i $rpm_path/$rpm_arch/$r.$rpm_arch.rpm"
244  $rpm $rpm_database --force -i $rpm_path/$rpm_arch/$r.$rpm_arch.rpm
245  check "installing the $r.$rpm_arch.rpm rpm failed"
246 done
247}
248
249#
250# Select the type of arch we have.
251#
252
253rpm_arch()
254{
255 if [ $(echo $1 | sed 's/.*api.*/yes/') = yes ]; then
256  echo "noarch"
257 elif [ $(echo $1 | sed 's/.*lib.*/yes/') = yes ]; then
258  echo "noarch"
259 elif [ $(echo $1 | sed 's/.*auto.*/yes/') = yes ]; then
260  echo "noarch"
261 else
262  echo $2
263 fi
264}
265
266#
267# We always build tools for the build host. We need them to
268# build the libraries for the target processor.
269#
270hosts="linux $hosts"
271
272echo "Configuring target: all"
273echo "configure --prefix=$prefix $rpm_prefix_arg " \
274     " --target=all $infos"
275$configure --prefix=$prefix $rpm_prefix_arg \
276           --target=all \
277           $infos
278check "configuring the crossrpms failed"
279echo "make"
280$make
281check "building the rpm spec files failed"
282echo "make -C autotools"
283$make -C autotools
284check "building the rpm spec files failed"
285
286for h in $hosts;
287do
288 #
289 # Need to translate the build host to an RTEMS host. Create a
290 # target host (th) and specs directory (sd) variable to handle
291 # the use of RTEMS.
292 #
293 if [ $h = "linux" ]; then
294  th="linux-gnu"
295  sd=rtems$version
296  canadian_cross=no
297 else
298  th=$h
299  sd=$h
300  canadian_cross=yes
301 fi
302
303 #
304 # Associate the host to its tool list to get the packages to build.
305 #
306 tl=${h}_tool_list
307 pl=${h}_cpu_list
308
309 echo "Native Host Tools: ${!tl} for ${!pl}"
310 echo "Canadian Cross: $canadian_cross ($t $h)"
311
312 for p in ${!pl}
313 do
314  pth="$p-pc-$th"
315
316  if [ $canadian_cross = yes ]; then
317   echo "make -C $sd/$p"
318   $make -C $sd/$p
319   check "building the rpm spec files failed: $sd/$p"
320
321   for s in ${!tl}
322   do
323    case $s in
324     autoconf|automake)
325      # Hack around the prefix in the spec files for autotools.
326      ba="-ba $prefix/autotools/$rpm_prefix$s.spec"
327      ;;
328     *)
329      ba="-ba $prefix/$sd/$p/$rpm_prefix$pth-$s.spec"
330    esac
331
332    rpmbuild_cmd="$ba --target=$build"
333
334    echo "rpmbuild --define '_defaultdocdir $prefix/share/doc' $rpm_database $rpmbuild_cmd"
335    $rpmbuild --define "_defaultdocdir $prefix/share/doc" $rpm_database $rpmbuild_cmd
336    check "building the $sd/$p/$rpm_prefix$pth-$s rpm failed"
337
338    rpm_installer "$rpm_database" \
339                  $(rpm_arch $rpm_prefix$pth-$s $processor) \
340                  $rpm_topdir/linux/RPMS \
341                  $rpmbuild_cmd
342   done
343  fi
344 done
345
346 for t in $targets;
347 do
348  for s in ${rtems_tool_list}
349  do
350   case $s in
351    autoconf|automake)
352     # Hack around the prefix in the spec files for autotools.
353     ba="-ba $prefix/autotools/$rpm_prefix$s.spec"
354     ;;
355    *)
356     ba="-ba $prefix/rtems$version/$t/$rpm_prefix$t-rtems$version-$s.spec"
357   esac
358
359   rpmbuild_cmd="$ba --target=$pth"
360
361   if [ $canadian_cross = yes ]; then
362    ccl=${h}_cc_name
363    echo "rpmbuild --define '_build $processor-redhat-linux' " \
364         "--define '_host $pth' " \
365         "--define '_defaultdocdir $prefix/share/doc' " \
366         "$rpm_database $rpmbuild_cmd "
367    $rpmbuild --define "_build $processor-redhat-linux" \
368              --define "_host $pth" \
369              --define "_defaultdocdir $prefix/share/doc" \
370              --define "__cc $p-${!ccl}-$h-gcc" \
371              $rpm_database $rpmbuild_cmd
372    check "building host cross target: $rpm_prefix$t-rtems$version-$s"
373   else
374    echo "rpmbuild --define '_defaultdocdir $prefix/share/doc' "\
375         "$rpm_database $rpmbuild_cmd"
376    $rpmbuild --define "_defaultdocdir $prefix/share/doc" \
377              $rpm_database $rpmbuild_cmd
378    check "building host cross target: $rpm_prefix$t-rtems$version-$s"
379   fi
380
381   if [ $canadian_cross != yes ]; then
382    rpm_installer "$rpm_database" \
383                  $(rpm_arch $rpm_prefix$t-rtems$version-$s $p) \
384                  $rpm_topdir/$h/RPMS \
385                  $rpmbuild_cmd
386   fi
387  done
388 done
389done
Note: See TracBrowser for help on using the repository browser.