summaryrefslogtreecommitdiff
path: root/config/bootstrap
blob: 2675a56b3cb360dab8815c074c42e0cf3eb23285 (plain)
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
#! /bin/bash
#  -*- Mode: Shell-script -*-
#
# bootstrap --- maintainer's bootstrap script
#
# Time-stamp:      "2012-04-14 08:11:20 bkorb"
##
##  This file is part of AutoGen.
##  AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
##
##  AutoGen is free software: you can redistribute it and/or modify it
##  under the terms of the GNU General Public License as published by the
##  Free Software Foundation, either version 3 of the License, or
##  (at your option) any later version.
##
##  AutoGen is distributed in the hope that it will be useful, but
##  WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
##  See the GNU General Public License for more details.
##
##  You should have received a copy of the GNU General Public License along
##  with this program.  If not, see <http://www.gnu.org/licenses/>.

# This script is designed to find any directories which contain a
# configure.ac 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.

PS4='>bsl-${FUNCNAME}> '
top_srcdir=$(
    cd $(dirname $0)/.. >/dev/null
    pwd )
top_builddir=${top_srcdir}

. config/bootstrap.shlib
PS4='>bs-${FUNCNAME}> '

config_tools()
{
    top_srcdir=$(pwd)
    top_builddir=${top_srcdir}
    srcdir=${top_srcdir}
    config_file=configure.ac
    conf_dir=${top_srcdir}/config
    test -f "${srcdir}/${config_file}" || die "${config_file} not in ${srcdir}"

    #  This missing function is used in many places
    #
    MISSING="${conf_dir}/missing"
    export config_file srcdir top_srcdir top_builddir MISSING
    chmod +x ${MISSING} || exit 1

    #  Check for AutoGen version 5.
    #
    AGexe=$(command -v autogen)
    case "${AGexe}" in
    ( /* )
        v=$($AGexe --version || :)
        case "$(echo $v | sed 's/.* //')" in
        5.* ) : ;;
        * ) die "OUT OF DATE AutoGen: $v" ;;
        esac
        ;;

    ( * )
        die "AutoGen requires autogen to bootstrap"
        ;;
    esac

    GDexe=$(command -v getdefs)
    CLexe=$(command -v columns)
    test -x "${GDexe}" -a -x "${CLexe}" || \
        die "autogen support programs are missing"
    export AGexe GDexe CLexe

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

    tools="autoconf autoheader aclocal automake libtoolize"
    for f in $tools
    do
        tool=$(command -v ${f}) > /dev/null || die "No $f found"
        eval ${f}_reqver=$(
            set -- $(${tool} --version | sed 1q)
            eval echo \${$#})
        eval $(echo $f | tr a-z A-Z)=${tool}
    done

    char_mapper=$(command -v char-mapper) 2>/dev/null
    test -x "${char_mapper}" || {
        char_mapper=$(
            cd add-on/char-mapper >&2
            make char-mapper >&2 || die "cannot make char-mapper"
            echo ${PWD}/char-mapper)
    }
    export char_mapper

    echo bootstrapping in ${PWD}
    set +e
}

# 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.
#
pre_local()
{
    BOOTSTRAP=pre
    export BOOTSTRAP

    local PS4='>pbs-${FUNCNAME}> '
    . ${conf_dir}/bootstrap.local ${1+"$@"} || \
        die FAILED: ${conf_dir}/bootstrap.local

    cd autoopts
    PS4='>aobs-${FUNCNAME}> '
    . ./bootstrap.dir aoconf
}

post_local()
{
    for f in $(find . -name bootstrap.dir)
    do  (
        ${setx}
        cd $(dirname $f)
        srcdir=`pwd`
        echo running POST-bootstrap.dir in ${srcdir}
        PS4='>Abs-${FUNCNAME}> '
        . ./bootstrap.dir recursive || :
        )
    done

    local BOOTSTRAP=post
    local PS4='>Abs-${FUNCNAME}> '
    . ${conf_dir}/bootstrap.local ${1+"$@"}
}

run_autotools()
{
    # remove any stale config.cache
    doit rm -f config.cache

    test -n "$auxdir" || auxdir=${srcdir}
    test -d $auxdir || auxdir=.

    doit $LIBTOOLIZE    --force
    doit $ACLOCAL       -I config
    doit $AUTOHEADER
    doit $AUTOMAKE      --gnu --add-missing
    doit $AUTOCONF
}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#    M A I N
#
config_tools
( pre_local )
run_autotools
post_local

trap '' 0
( exit 0 ) ; exit

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

# bootstrap ends here