File: bootstrap.std

package info (click to toggle)
complexity 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,200 kB
  • sloc: ansic: 16,003; sh: 5,127; makefile: 76
file content (212 lines) | stat: -rwxr-xr-x 5,874 bytes parent folder | download
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
# -*- Mode: shell-script -*-

#  This file is part of gnu-pw-mgr.
#
#  Copyright (C) 2013-2018 Bruce Korb - all rights reserved
#
#  gnu-pw-mgr 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.
#
#  gnu-pw-mgr 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/>.

prog=`basename "$0" .sh`
program=`basename "$0"`
progdir=`cd \`dirname "$0"\` >/dev/null && pwd -P`
progpid=$$
readonly prog program progdir progpid

# death rattle
#
die()
{ 
    echo "${prog} error:  $*"
    backtrace
    kill -TERM ${progpid}
    exit 1
} >&2

# append_all_gnulib_includes
# ---------------------------------------------
# Append all gnulib mandated header files to the end of the first
# AC_CONFIG_HEADER{,S} file from $configure_ac.
append_all_gnulib_includes ()
{
    $debug_cmd

    func_extract_trace AC_CONFIG_HEADERS
    test -n "$func_extract_trace_result" \
        || func_extract_trace AC_CONFIG_HEADER

    test -n "$func_extract_trace_result" || return

    $require_all_gnulib_includes

    test -n "$all_gnulib_includes" || return

    set -- $func_extract_trace_result
    header=$1

    # Take care to honor config.h:config-h.in specifications.
    case $header in
    *:*) header=`echo $header |sed 's|^.*:||'` ;;
    *)   header=$header.in ;;
    esac

    guard=$(basename $(pwd))_$header
    guard=$(echo $guard | \
        tr '[a-z]' '[A-Z]' | \
        sed 's/[^A-Z0-9]/_/g')
    func_verbose "appending gnulib includes to '$header'"
    {
        printf '#ifndef %s\n#define %s 1\n' $guard $guard
        cat $header
        echo "$all_gnulib_includes"
        printf '#endif /* %s*/\n' $guard
    } > ZZTEMP-$$
    mv ZZTEMP-$$ $header
}
func_add_hook func_fini append_all_gnulib_includes

# require_all_gnulib_includes
# ---------------------------
# Ensure `$all_gnulib_includes' contains a sorted uniquified list of
# every gnulib mandated header file.
#
func_require_all_gnulib_includes ()
{
    $debug_cmd

    $require_gnulib_tool
    require_all_gnulib_includes=:

    test true = "$gnulib_tool" && return

    $require_all_gnulib_modules
    $require_gnulib_tool_base_options

    gnulib_mode=--extract-include-directive
    gnulib_tool_all_options="$gnulib_mode $gnulib_tool_base_options"
    all_gnulib_includes=$(
        $gnulib_tool $gnulib_tool_all_options $all_gnulib_modules | \
            sed '/^$/d' | \
            sort -u)

    # put <> includes before "" includes
    all_gnulib_includes=$(
        echo "$all_gnulib_includes" | grep -v '"'
        echo "$all_gnulib_includes" | grep '"' )

    test -n "all_gnulib_includes" || \
        func_verbose "found no gnulib includes"
}
require_all_gnulib_includes=func_require_all_gnulib_includes


# require_all_gnulib_modules
# --------------------------
# Ensure `$all_gnulib_modules' contains the fully expanded list of
# gnulib modules with dependencies expanded.
func_require_all_gnulib_modules ()
{
    $debug_cmd

    $require_gnulib_tool

    test true = "$gnulib_tool" || {
        $require_gnulib_tool_base_options

        all_gnulib_modules=$gnulib_modules
        gnulib_mode=--extract-dependencies
        gnulib_tool_all_options="$gnulib_mode $gnulib_tool_base_options"
        while :; do
            my_add_modules=false
            for module in $gnulib_modules; do
                for depend in $(
                    $gnulib_tool $gnulib_tool_all_options $module)
                do
                    case " "`echo $my_full_module_list`" " in
                    *" $depend "*) ;;
                    *) my_add_modules=:
                        my_full_module_list="$my_full_module_list
				$depend"
                        ;;
                    esac
                done
            done
            $my_add_modules || break
        done
    }

    test "$all_gnulib_modules" = "$gnulib_modules" || \
        func_verbose 'recursively expanding $gnulib_modules list'

    require_all_gnulib_modules=:
}

require_all_gnulib_modules=func_require_all_gnulib_modules
require_gnulib_merge_changelog=: # it requires gnulib's option processing
require_gnulib_git_submodules=: # no submodules
require_bootstrap_uptodate=: # we don't use gnulib's bootstrap

# Leave here for anemic shells
#
test "$BASH_VERSION" = "" && {
    backtrace() { : ; }
    unset xtrace
    return
}

bashopts=' '$(exec 2>/dev/null ; echo $(shopt))' '

# Specifically test for xtrace being set
#
case ":$SHELLOPTS:" in
*:xtrace:* ) dashx=-x ;;
* ) dashx= ;;
esac

# See if extdebug is supported
#
case "$bashopts" in
*' extdebug '* )
    shopt -s extdebug
    backtrace() {
        set +x
        local ct=${#FUNCNAME[@]} fn ln sf ix width=0 fmt
        for fn in ${FUNCNAME[*]}
        do
            (( width < ${#fn} )) && width=${#fn}
        done

        fmt="%-${width}s  from line and file"
        printf "Call stack:\n$fmt\n" 'function'
        fmt="%-${width}s %5d    %s\n"

        for ((ix = 2 ; ix < ct ; ix++))
        do
            fn=${FUNCNAME[$((ix - 1))]}
            if (( ix == 2 )) && $TRAPPED
            then
                sf=$sfile
                ln=$sline
            else
                sf=$(basename ${BASH_SOURCE[$ix]})
                ln=${BASH_LINENO[$((ix - 1))]}
            fi
            printf "$fmt" $fn $ln "$sf"
        done
        test ${#dashx} -gt 0 && set -x
    }
    ;;

* ) backtrace() { for f in ${FUNCNAME[*]} ; do echo $f ; done ; }
    ;;
esac