File: bootstrap

package info (click to toggle)
autogen 5.3.5-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,216 kB
  • ctags: 2,706
  • sloc: ansic: 17,527; sh: 11,794; awk: 629; makefile: 556; lisp: 164; yacc: 50
file content (264 lines) | stat: -rwxr-xr-x 7,868 bytes parent folder | download | duplicates (2)
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#! /bin/sh
#  -*- Mode: Shell-script -*- 
# ----------------------------------------------------------------------
# bootstrap --- maintainer's bootstrap script
#
# Author:            Gary V. Vaughan <gary@oranda.demon.co.uk>
# Maintainer:        Gary V. Vaughan <gary@oranda.demon.co.uk>
# Created:           Thu Apr  9 00:40:23 1998
# Last Modified:     $Date: 2002/01/12 16:27:02 $
#            by:     Gary V. Vaughan <gary@gnu.org>
# ----------------------------------------------------------------------
# @(#) $Id: bootstrap,v 1.39 2002/01/12 16:27:02 bkorb Exp $
# ----------------------------------------------------------------------

# This script is designed to find any directories which contain a
# configure.in in script, and to run the autotools programs from each
# of those directories to make sure they are in a state ready to
# 'configure; make; make install'
#
# Often this process involves more than `libtoolize; automake; autoconf',
# so supplementary actions can be placed in a bootstrap.local script
# in the same directory as this script, and anywhere in the source tree
# in bootstrap.dir files.  The bootstrap.local script will be sourced
# twice; first with BOOTSTRAP=pre before the main part is run, and then
# again with BOOTSTRAP=post after the main part has finished.  This makes
# it possible to set up any links or temporary files required for this
# script to work before it has executed, and then remove them when it
# has finished.  The bootstrap.dir files are also sourced, in a random
# order, as they are found in the tree just before the BOOTSTRAP=post
# phase.  This allows a developer to put any peculiar bootstrap actions
# required by individual directories where they can be seen (and not
# forgotten!).
#
# In an ideal world, running this bootstrap script (including any extra
# scripts it executes) should leave a freshly checked out CVS source tree
# in the same state as a freshly unrolled tarball.  In this way, one
# no longer has to maintain generated files under source control, they
# can be generated after checkout using this bootstrap procedure.

# Code:
set -e

# Figure out the absolute path to the working directory.
#
wd=`echo $0|sed 's,/[^/]*$,,'`
test -z "$wd" && wd=.
wd=`cd $wd ; pwd`

# Search for a configure.in
#
for srcdir in $wd $wd/.. .. .; do
    test -f $srcdir/configure.ac && break
    test -f $srcdir/configure.in && break
done

if test -f $srcdir/configure.ac
then config_file=configure.ac
else config_file=configure.in
fi
export config_file srcdir

#  This missing function is used in many places
#
MISSING="`cd ${srcdir}/config ; pwd`/missing"
export MISSING

#  Check for AutoGen version 5.
#
AUTOGEN=`type autogen 2>/dev/null`
case "${AUTOGEN}" in
  *" is /"* )
     AUTOGEN=`echo $AUTOGEN|sed 's,autogen is [^/]*/,/,'`
     case "`$AUTOGEN --version`" in
       *"Ver. 5."* )
           export AUTOGEN ;;
       * ) echo OUT OF DATE AutoGen: `$AUTOGEN --version` >&2
           unset AUTOGEN ;;
     esac
     ;;

  * )
     unset AUTOGEN
     ;;
esac

# Source any local scripts which add to the bootstrap procedure.
# The bootstrap.local script should test the value of the BOOTSTRAP
# environment variable to see whether it should run the sections
# to be called before the main script, or afterwards.
#
BOOTSTRAP=pre
export BOOTSTRAP
test -f $wd/bootstrap.local && sh $wd/bootstrap.local $@

# ----------------------------------------------------------------------
# Make sure all of the maintainer tools required for bootstrap are
# available on the host machine.
# ----------------------------------------------------------------------

tools="autoconf autoheader aclocal automake libtoolize"
autoconf_reqver=2.50
autoheader_reqver=2.50
aclocal_reqver=1.4-p4
automake_reqver=1.4-p4
libtoolize_reqver=1.4

#  A version is out-of-date if it does not compare equal to the correct
#  version and then one of its component numbers compares less
#
out_of_date()
{
    if test "X${1}" = "X${2}"
    then return 1 ; fi

    tv=`IFS=" .";set -- ${1};echo $@`
    bv=`IFS=" .";set -- ${2};echo $@`

    #  FOREVER...(as long as we have version number components)
    #
    while :
    do
        #  Extract the next component.  If they are not equal,
        #  then it is time to return 0 or 1.
        #
        x=`set -- $tv;echo $1`
        y=`set -- $bv;echo $1`
        if test "X$x" = "X$y" ; then :
        else
            set -- `(echo $x return 0; echo $y return 1) | sort -n | sed 1q`
            shift
            eval $@
        fi

        #  Shift off the first component of each.  If the base version is done
        #  then the test version is more recent, otherwise the other way
        #
        tv=`set -- $tv;shift;echo $@`
        bv=`set -- $bv;shift;echo $@`
        [ -z "$bv" ] && return 1
        [ -z "$tv" ] && return 0
    done
}

# Rather than give up at the first failure, set this variable to
# "exit 1", so that all the checks are performed before exiting.
DIE=:

for f in $tools
do
  v=`$f --version`
  if test $? -ne 0
  then
    ${MISSING} ${f}
    DIE="exit 1"
  else
    v=`echo "$v"|sed 1q |sed 's/.* \([0-9]\)/\1/'`
    eval reqver=\$${f}_reqver

    if out_of_date "${v}" "${reqver}"
    then
      ${MISSING} old ${f}
      DIE="exit 1"
    fi
  fi

  eval `echo $f | tr a-z A-Z`=$f
done

# If any of the above tests failed, abort at this point.
#
${DIE}

doit ()
{
  if test "x$1" != x: ; then 
    echo "RUN:  $@"
    eval "$@"
  fi
}

# Run through all of the required autogeneration tools in
# each directory which contains a ${config_file} file...
for i in `find $srcdir -name ${config_file} -print|grep -v CVS/`
do
  # Find the top directory with respect to the current ${config_file}.
  top=`echo $i|sed 's,/[^/]*$,,'`
  case $i in
    /* | [A-Za-z]:\\*) ;;
    *) top=`(cd $top && pwd)` ;;
  esac

  # A brief check to make sure we are not running in the wrong
  # directory.
  initfile=`fgrep AC_CONFIG_SRCDIR $top/${config_file} | sed 's,^.*(,,;s,).*$,,'`
  if test -z "$initfile" || test ! -f $top/$initfile; then
    cat <<- _EOF_
        \$initfile is \`$initfile'
        **Error**: Directory \`$top' does not look like a valid
        top-level directory.
_EOF_
    exit 1
  fi

  # Execute this in a sub-shell so we don't lose our start location.
  (
    cd $top
    echo bootstrapping in `pwd`

    # remove any stale config.cache
    doit rm -f config.cache

    # Use auxdir if set in ${config_file}.
    auxdir=${auxdir-`fgrep CONFIG_AUX_DIR ${config_file} | \
        sed 's,^.*(,,;s,).*$,,'`}
    test -n "$auxdir" || auxdir=$srcdir
    test -d $auxdir || auxdir=.

    if sed 's,#.*$,,;s,dnl[ \t].*$,,' ${config_file} \
      | egrep 'A[CM]_PROG_LIBTOOL' > /dev/null ; then
    doit $LIBTOOLIZE    --force
    fi

    if sed 's,#.*$,,;s,dnl[ \t].*$,,' ${config_file} \
      | egrep 'A(C|M)_INIT_AUTOMAKE' > /dev/null ; then
    doit $ACLOCAL       -I $auxdir
    fi

    doit $AUTOHEADER

    if sed 's,#.*$,,;s,dnl[ \t].*$,,' ${config_file} \
      | egrep 'A(C|M)_INIT_AUTOMAKE' > /dev/null ; then
    doit $AUTOMAKE      --gnu --add-missing
    fi

    doit $AUTOCONF
  ) || exit 1
done

# Execute (NOTE: not source!) any bootstrap.dir scripts we find in
# the source tree.

find . -name bootstrap.dir |
egrep -v '/CVS/'       | (
while read f
do
  (cd `dirname $f` ; srcdir=.
   echo running bootstrap.dir in `pwd`
   sh ./bootstrap.dir recursive ) || exit 1
done ) || exit 1

# Source any local scripts which add to the bootstrap procedure.
# The bootstrap.local script should test the value of the BOOTSTRAP
# environment variable to see whether it should run the sections
# to be called before the main script, or afterwards.
BOOTSTRAP=post
test -f $wd/bootstrap.local && . $wd/bootstrap.local $@

# Local Variables:
# mode: shell-script
# sh-indentation: 2
# indent-tabs-mode: nil
# End:

# bootstrap ends here