summaryrefslogtreecommitdiff
path: root/autoopts/bootstrap.dir
blob: d86a9aad0210c3c71630552641d2aa80c5af8ca9 (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
224
225
226
227
228
229
230
231
232
#! /bin/echo This_file_must_be_sourced,_not_executed
# Time-stamp:      "2012-04-14 14:12:20 bkorb"
#
##  This file is part of AutoOpts, a companion to AutoGen.
##  AutoOpts is free software.
##  AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
##
##  AutoOpts is available under any one of two licenses.  The license
##  in use must be one of these two and the choice is under the control
##  of the user of the license.
##
##   The GNU Lesser General Public License, version 3 or later
##      See the files "COPYING.lgplv3" and "COPYING.gplv3"
##
##   The Modified Berkeley Software Distribution License
##      See the file "COPYING.mbsd"
##
##  These files have the following md5sums:
##
##  43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3
##  06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3
##  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd

burn_aover() {
    agvars=$(egrep '^A[GO]_' ../VERSION)
    eval "${agvars}"
    vers_curr=$(expr '(' $AO_CURRENT   '*' 4096 ')' + $AO_REVISION)

    cd tpl
    for f in *.sh *.pl
    do  g=${f%.sh} ; g=${g%.pl}
        cat $f > $g
        chmod +x $g
    done
    cd -
}

add_files_to_mf() {
    #  Regenerate the "genshell.h" 'cuz we just altered the template to
    #  contain the header version number.
    #
    ${AGexe} -Tagman3.tpl funcs.def || \
        die "FAILED: ${AGexe} -Tagman3.tpl funcs.def"

    local tmpl=$(
        ndst=""
        sfil=''

        for f in man mdoc texi
        do
            for g in man mdoc texi
            do
                sfil=${sfil}tpl/${f}2${g}${nl}
                test -f tpl/${f}2${g}.sh || \
                    ndst=${ndst}tpl/${f}2${g}${nl}
            done
        done

        pdta="autoopts.m4${nl}tpl/usage.tlib${nl}"
        edta="bootstrap.dir${nl}autoopts-config.in${nl}autogen.map${nl}"
        edta="${edta}mk-tpl-config.sh${nl}mk-autoopts-pc.in${nl}"
        edta="${edta}install-hook.sh${nl}po${nl}tpl/usage-txt.tpl${nl}"

        for f in tpl/*.*
        do
            case $f in
            ( *.in | *.pl | *.sh )
                g=$(echo $f | sed 's/\...$//;s/-tlib$/.tlib/')
                ndst=${ndst}${g}${nl}    # installed file
                edta=${edta}${f}${nl}    # distributed file
                ;;

            ( *tpl-config.tlib | *tpl/usage* ) : ;;

            ( *.tlib | *.tpl | *.def | *.lic )
                pdta=${pdta}${f}${nl} ;; # installed & distributed file
            esac
        done

        echo "local ndst='${ndst%${nl}}'"
        echo "local pdta='${pdta%${nl}}'"
        echo "local edta='${edta%${nl}}'"
        echo "local sfil='${sfil%${nl}}'"
    )

    eval "$tmpl"

    {
        ls -1 *.3 | \
            sed '/^pathfind.3$/d' | \
            columns -I4 --spread=1 --line=' \'

        printf '\nnodist_pkgdata_DATA = $(libsrc) \\\n'
        echo "${ndst}" | sort -u | columns -I4 --spread=1 --line=' \'

        printf '\npkgdata_DATA    = \\\n'
        echo "${pdta}" | sort -u | columns -I4 --spread=1 --line=' \'

        printf '\nEXTRA_DATA      = $(pkgdata_DATA) \\\n'
        echo "${edta}" | sort -u | columns -I4 --spread=1 --line=' \'

        printf '\nGENSCRIPTS      = $(srcdir)/funcs.def \\\n'
        echo "${sfil}" | columns -I4 --spread=1 --line=' \'
        echo

        sed -n '/^## begin/,/^## end/{
		s/^##.*//
		/^$/d
		p
	    }' gnulib.mk

    } > Makefile.lists

    sed '/^GENMAN /r Makefile.lists' Makefile.am > Makefile.tmp
    mv -f Makefile.tmp Makefile.am

    rm -f Makefile.lists gnulib.mk *.3
}

make_funcs_def()
{
    $noag && exit 1
    s2enum=`which mk-str2enum` 2>/dev/null || :
    test -x "${s2enum}" || \
        s2enum="bash ${top_srcdir}/add-on/char-mapper/mk-str2enum.sh"

    ${char_mapper:-char-mapper} autogen.map || die "FAILED: char-mapper"
    ${AGexe} ao-strs.def || die "cannot make strings - exited $?"

    ${s2enum} --base-name=xat-attribute -n \
        type words members cooked uncooked keep || \
        die "FAILED: ${s2enum} --base-name=xat-attribute"

    ${s2enum} --base-name=value-type --prefix=vtp -n string integer \
        boolean bool keyword set set-membership nested hierarchy || \
        die "FAILED: ${s2enum} --base-name=value-type"
    burn_aover

    test -d autoopts || mkdir autoopts
    test -d po       || mkdir po
    ${AGexe} genshell.def  || \
        die "FAILED: ${AGexe} genshell.def"
    ${AGexe} usage-txt.def || \
        die "FAILED: ${AGexe} usage-txt.def"
    mv usage-txt.h   autoopts/.
    mv usage-txt.pot po/.

    files=$(sed -n '/^CSRC/,/\.c$/p' Makefile.am | \
        sed '/^CSRC/d;s/[=\\]//'
        echo  ../compat/pathfind.c)
    getdefs linenum srcfile template=options_h output=funcs.def $files
    chmod u+w funcs.def
    vers_min=$( expr '(' $AO_CURRENT - $AO_AGE ')' '*' 4096)
    cat >> funcs.def <<-  _END_VERS_INFO_
	vers-curr       = "${vers_curr}";
	vers-min        = "${vers_min}";
	vers-min-str    = "$(expr $AO_CURRENT - $AO_AGE):0:0";
	vers-sovers     = "${AO_SOVERS}";
	library         = opts;

	/*
	 *  THIS FILE IS DISTRIBUTED
	 *
	 *  This file is used to construct options.h + doc files.  Because it is
	 *  such a nuisance to get the build ordering correct, we distribute
	 *  this.  It should be constructed after all binaries are built.
	 */
	_END_VERS_INFO_
    ${AGexe} funcs.def || die "FAILED: ${AGexe} funcs.def"
    test -f options.h || die "options.h not created"
    mv options.h autoopts/.
    cp project.h autoopts/.
    add_files_to_mf
    make_proto

    ${AGexe} aoconf.def || die "FAILED: ${AGexe} aoconf.def"
}

test "X${mainpid}" = X && {
    \cd ${top_srcdir-..}
    top_srcdir=`pwd`
    . config/bootstrap.shlib
    cd autoopts
    free_trap=true
} || {
    free_trap=false
}

export AGexe=${AGexe-autogen}\ -L${top_srcdir}/autoopts/tpl
noag=`${AGexe} -v > /dev/null 2>&1 && echo false || echo true`
nl=$'\n'

case "$1" in
*genshell.c )
    if ${noag}
    then
        test -f ${top_srcdir}/autoopts/genshell.c || \
            die "No autogen for building genshell.c"
    else
        ${AGexe} genshell.def || \
            die "FAILED: ${AGexe} genshell.def"
    fi
    ;;

*libopts.texi )
    if ${noag}
    then
        test -f ${top_srcdir}/autoopts/libopts.texi || \
            die "No autogen for building libopts.texi"
    else
        agopts='-Taginfo3.tpl -DLEVEL=subsection -blibopts funcs.def'
        ${AGexe} ${agopts} || \
            die "FAILED: ${AGexe} ${agopts}"
    fi
    ;;

aoconf )
    make_funcs_def
    ;;
esac

${free_trap} && trap '' 0
true

# Local Variables:
# mode:shell-script
# sh-indentation:4
# sh-basic-offset:4
# indent-tabs-mode: nil
# End:

# bootstrap.dir ends here