source: rtems/contrib/mingw/build-autotools.sh @ f6cd0db

4.104.114.84.95
Last change on this file since f6cd0db 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 100644
File size: 4.8 KB
Line 
1#! /bin/sh
2
3terminate()
4{
5  echo "error: $*" >&2
6  if [ $? -eq 0 ]; then
7    exit 222
8  fi
9  exit $?
10}
11
12check()
13{
14  if [ $? -ne 0 ]; then
15    terminate $*
16  fi
17}
18
19source=$(dirname $0)
20
21if [ "$source" = "." ]; then
22  source=$(pwd)
23fi
24
25build=none
26clean=no
27prefix=none
28
29while [ $# -gt 0 ];
30do
31  case $1 in
32    -b)
33      shift
34      build=$1
35      ;;
36    -c)
37      shift
38      config=$1
39      ;;
40    -d)
41      set -x
42      ;;
43    -h)
44      usage
45      exit 223
46      ;;
47    -p)
48      shift
49      prefix=$1
50      ;;
51    -s)
52      shift
53      source=$1
54      ;;
55    *)
56      terminate "invalid option (try -h): $1"
57      ;;
58  esac
59  shift
60done
61
62#
63# dirdepth: find the depth of a directory
64#
65# $1 : path
66#
67dirdepth()
68{
69  local depth=0
70  local p=$1
71  p=$(echo $p | sed -e "s/^\///g")
72  p=$(echo $p | sed -e "s/\/$//g")
73  while [ $p != . ];
74  do
75    depth=$(expr $depth + 1)
76    p=$(dirname $p)
77  done
78  echo $depth
79}
80
81#
82# build_package()
83#
84# $1 : package
85# $2 : package source
86# $3 : tar options
87# $4 : patch list
88#
89build_package()
90{
91  local mydir=$(pwd)
92
93  if [ ! -f $source/$2 ]; then
94    terminate "$1 source is not present or not a file: $2"
95  fi
96
97  for p in $4
98  do
99    if [ ! -f $source/$p ]; then
100      terminate "$1 patch is not present or not a file: $p"
101    fi
102  done
103
104  echo "cd $build"
105  cd $build
106  check "changing to $build directory"
107
108  echo "tar $3 $source/$2"
109  tar $3 $source/$2
110  check "extraction of source: $2"
111
112  echo "cd $build/$1"
113  cd $build/$1
114  check "changing to $build/$1 directory"
115
116  for p in $4
117  do
118    echo "patch -p0 < $source/$p"
119    patch -p0 < $source/$p
120    check "patching $autoconf with $p"
121  done
122
123  echo "cd $build"
124  cd $build
125  check "changing to $build directory"
126
127  echo "rm -rf mingw32-$1"
128  rm -rf mingw32-$1
129  check "removing mingw32-$1 build directory"
130
131  echo "mkdir mingw32-$1"
132  mkdir mingw32-$1
133  check "creating mingw32-$1"
134
135  echo "cd $build/mingw32-$1"
136  cd $build/mingw32-$1
137  check "changing to $build/mingw32-$1"
138
139  echo "$build/$1/configure --prefix=$prefix"
140  $build/$1/configure --prefix=$prefix
141  check "configuring $1"
142
143  echo "make"
144  make
145  check "building $1"
146
147  echo "make DESTDIR=$build/install-$1 install"
148  make DESTDIR=$build/install-$1 install
149  check "installing to $build/install-$1"
150
151  echo find $build/install-$1$prefix -type f
152  local files=$(find $build/install-$1$prefix -type f)
153  check "reading $1 file list"
154
155  of=$prefix/Uninstall/$1-files
156  echo "b install-$1$prefix" | sed -e "s/\//\\\\/g" >> $of
157
158  re_path=$(echo $build/install-$1$prefix/ | sed -e 's/\//\\\//g' -e 's/\./\\\./g')
159
160  dirs=
161  for f in $files
162  do
163    if [ $(basename $f) = dir ]; then
164      continue
165    fi
166    f=$(echo $f | sed -e "s/$re_path//g")
167    found=no
168    fd=$(dirname $f)
169    for d in $dirs
170    do
171      if [ $d = $fd ]; then
172        found=yes
173        break;
174      fi
175    done
176    if [ $found = no ]; then
177      echo "d $fd" | sed -e "s/\//\\\\/g" >> $of
178      dirs="$fd $dirs"
179    fi
180    echo "f $f" | sed -e "s/\//\\\\/g" >> $of
181  done
182
183  for d in $dirs
184  do
185    while [ $d != . ]
186    do
187      found=no
188      for rd in $dirs
189      do
190        if [ "$d" = "$rd" ]; then
191          found=yes
192          break
193        fi
194      done
195      if [ $found = no ]; then
196        dirs="$dirs $d"
197      fi
198      d=$(dirname $d)
199    done
200  done
201
202  sorted_dirs=
203  for d in $dirs
204  do
205    depth=$(dirdepth $d)
206    nsp=
207    for sd in $sorted_dirs
208    do
209      if [ ! -z "$d" ]; then
210        spd=$(dirdepth $sd)
211        if [ $depth -ge $spd ]; then
212          sd="$d $sd"
213          d=
214        fi
215      fi
216      nsp="$nsp $sd"
217    done
218    if [ ! -z "$d" ]; then
219      nsp="$nsp $d"
220    fi
221    sorted_dirs=$nsp
222  done
223
224  for d in $sorted_dirs
225  do
226    echo "D $d" | sed -e "s/\//\\\\/g" >> $of
227  done
228
229  echo "cd $mydir"
230  cd $mydir
231  check "changing to $mydir"
232}
233
234munch_path()
235{
236  local p=$1
237  if [ $(echo $p | sed -e "s/[a-zA-Z]:.*/yes/g") = yes ]; then
238    p=$(echo $p | sed -e "s/^[a-zA-Z]:/\/\0/g" -e "s/://g")
239  fi
240  echo $p
241}
242
243if [ $build = none ]; then
244  terminate "no build specified (try -h)"
245fi
246
247if [ $prefix = none ]; then
248  terminate "no prefix specified (try -h)"
249fi
250
251source=$(munch_path $source)
252build=$(munch_path $build)
253prefix=$(munch_path $prefix)
254config=$(munch_path $config)
255
256if [ ! -d $build ]; then
257  terminate "build path is not a directory or does not exist: $build"
258fi
259
260if [ ! -d $prefix ]; then
261  terminate "prefix path is not a directory or does not exist: $prefix"
262fi
263
264if [ ! -f $config ]; then
265  terminate "could find package configuration file: $config"
266fi
267
268. $config
269
270# Need to handle paths carefully as a problem seems to exist
271# with autoconf when it is in the path.
272if [ $(echo $package_name | sed -e "s/autoconf-.*/yes/g") != yes ]; then
273 export PATH=$prefix/bin:$PATH
274fi
275
276build_package $package_name \
277              $package_source \
278              $package_taropts \
279              "$package_patches"
280
281exit $?
Note: See TracBrowser for help on using the repository browser.