summaryrefslogtreecommitdiff
path: root/config/bootstrap.local
blob: 2375ce7bcb62995f06913c3dec93c84f8c74fa30 (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
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
#! /bin/echo This_file_must_be_sourced,_not_executed
#
# config/bootstrap.local --- maintainer's bootstrap script
#
# Author:            Bruce Korb <bkorb@gnu.org>
# Time-stamp:        "2012-08-11 08:38:04 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/>.

locate_exe()
{
    if [ -x "$1" ]
    then
        echo "$1"
        return 0
    fi

    case "${1}" in
    */* )
        echo "Cannot find ${1}" >&2
        return 1
        ;;
    "" )
        echo "USAGE:  locate_exe <exe-name>" >&2
        exit 1
        ;;
    * )
        name="${1}"
        ;;
    esac

    SV="${IFS}"
    IFS=" :"
    set -- ${PATH}
    for f
    do
        if [ -x ${f}/${name} ]
        then
            echo ${f}/${name}
            return 0
        fi
    done
    return 1
}

config_configurables()
{
    local tops=$(ls -d [a-rt-z]* snprintfv/Makefile.am Makefile.am)
    local inf=$(find ${tops} -type f -name '*.in')
    local in_list

    {
        for f in $inf
        do
            case "$f" in
            *-tpl.in )  g=${f%-tpl.in}.tpl ;;
            *-tlib.in ) g=${f%-tlib.in}.tlib ;;
            *.in )      in_list=${in_list}${f%.in}$'\n' ; continue ;;
            esac
            printf 'AC_CONFIG_FILES([%s:%s])\n' $g $f
        done
        {
            echo "$in_list"
            find ${tops} -name 'Makefile.am' | sed 's/\.am$//'
        } | columns --first='AC_CONFIG_FILES([' --end='])' -I4
    } > configure.files

    sedcmd="
	s/^AC_INIT(.*/AC_INIT([${PACKAGE}],[${AG_VERSION}],[${EADDR}])/
	/dnl Local Variables:/,\$d
	/==ADD_CONFIG_FILES==/{
	    s/.*//
	    r configure.files
	}"

    sed "$sedcmd" ${config_file} > configure.tmp
    mv  -f configure.tmp ${config_file}
    rm  -f configure.files
}

config_versions()
{
    set -a
    eval "$(egrep '^[A-Z][A-Z0-9_]+=' VERSION)"
    set +a
    unset LANG || LANG=''

    grep '==ADD_CONFIG_FILES==' ${config_file} >/dev/null 2>&1
    test $? -eq 0 && config_configurables

    for f in $(egrep -l 'eaddr +=' */*opts.def)
    do sed "/eaddr  *=/s/= .*/= '${EADDR}';/" $f > X ; mv -f X $f
    done

    if grep '__CURRENT_VERSION__' NEWS > /dev/null
    then
      sed "1s/__CURRENT_VERSION__.*/${AG_VERSION} - $(date '+%B %Y')/" NEWS > X
      mv -f X NEWS
    fi

    cd ${srcdir}/config
    ${AGexe} -L. libopts.def || exit 1
    ${AGexe} -L. misc.def    || exit 1
    cd ..
    cp snprintfv/snprintfv.m4 config/.

    marker='=== Component Todo:'
    rm -f TODO
    {
        sed "/${marker}/,\$d" TODO-top
        for f in */TODO
        do
            test -s $f || continue
            echo ; echo ${marker} ${f} '==='
            cat ${f}
        done
    } > TODO

    cd ${srcdir}

    glopts='--local-dir=tmp --source-base=autoopts --lib=do_not_make_me
	--import
	--makefile-name=gnulib.mk
	--libtool
	--no-changelog
	--symlink
	--m4-base=config
        --lgpl=2'
    glmods='parse-duration gendocs gettext-h'

    GNULIBTOOL=${GNULIBDIR:-~gnu/proj/gnulib}/gnulib-tool
    ${GNULIBTOOL} $glopts $glmods
    sed -i 's/do_not_make_me_.*_SOURCES/EXTRA_DIST/;/do_not_make_me/d' \
        autoopts/gnulib.mk
}

check_tools()
{
    local t e
    for t in AG GD CL
    do
        eval e=\${${t}exe}
        test -x "$e" || die "Not executable: \$${t}exe == '$e'"
        $e --version || die "$e does not work"
    done
}

tweak_Makefile_am()
{
    #  IF the source dir is not known,
    #  THEN it is the directory above the directory of this file.
    #
    test -z "${srcdir}" && \
        srcdir=$(\cd $(dirname $0) ; \cd .. ; pwd)
    cd ${srcdir}

    {
        sed '/^EXTRA_DIST /{
            s/.*/misc_extra     = \\/
            q
        }' Makefile.am
        find VERSION NOTES config/bootstrap* config/*.m4 \
               autoopts/parse-duration.[ch] doc/gendocs* \
            -type f | \
            columns --spread=1 -I4 --line=' \'

        sed -n '/^EXTRA_DIST /,$p' Makefile.am
    } > XXX$$
    mv -f XXX$$ Makefile.am

    cd pkg
    {
        sed '/^LIBOPTS_FILES  *=/{
            s/=.*/= \\/
            q
        }' Makefile.am

        find libopts -type f -name '[a-zA-Z]*' | \
            columns --spread=1 -I4 --line=' \'
        echo

        sed '1,/LIBOPTS_FILES *=/d' Makefile.am
    } > XXX$$
    mv -f XXX$$ Makefile.am
    cd ${srcdir}
}

case "${BOOTSTRAP}" in
( pre )
    dummy_texi=${srcdir}/doc/autogen.texi
    echo '@setfilename autogen.info' > ${dummy_texi}
    test -f ${srcdir}/configure && rm -f ${srcdir}/configure
    check_tools >/dev/null
    config_versions
    tweak_Makefile_am
    ;;

( post )
    test ${#dummy_texi} -gt 0 && rm -f ${dummy_texi}
    ;;
esac

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

# config/bootstrap.local ends here