3 # This script helps bootstrap autoconf, when checked out from git.
5 # Copyright (C) 2021-2023 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <https://www.gnu.org/licenses/>.
20 # Autoconf's own configure script is generated using Autoconf. This
21 # script does what running `autoreconf -i` in an Autoconf git checkout
22 # would do, except that it uses autoconf from the source tree we are
23 # preparing, not any version of autoconf that might or might not be
24 # installed already. Note that automake, Perl, and GNU M4 _are_
25 # required to be installed already.
27 # Don't ignore failures.
29 (set -o pipefail
2> /dev
/null
) && set -o pipefail
31 # Avoid problems due to various shell wrinkles.
32 # We assume we have a shell new enough to implement unset correctly.
33 (set -o posix
2> /dev
/null
) && set -o posix
38 unset BASH_ENV CDPATH ENV IFS MAIL MAILPATH POSIXLY_CORRECT
39 unset LANG LANGUAGE LC_ADDRESS LC_COLLATE LC_CTYPE LC_IDENTIFICATION
40 unset LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER
41 unset LC_TELEPHONE LC_TIME
46 # Set program basename.
48 usage
="usage: $me [options]
50 Prepare to build a git checkout of autoconf.
51 Functionally equivalent to \`autoreconf -i\`, but uses autoconf code
52 from the git checkout itself to create \`configure\`.
55 -f, --force consider all files to be obsolete
56 -v, --verbose verbosely report processing (repeat for more detail)
63 while [ $# -gt 0 ]; do
66 if [ -n "$verbose" ]; then
80 printf '%s' "$usage" >&2
88 # Let the user choose which version of aclocal, automake, m4, and perl to use.
90 : ${AUTOMAKE=automake}
93 export ACLOCAL AUTOMAKE M4 PERL
95 # $PERL needs to be an absolute path because we're going to substitute it
101 if [ $# -gt 0 ]; then
105 # Override SHELL. This is required on DJGPP so that Perl's system()
106 # uses bash, not COMMAND.COM which doesn't quote arguments properly.
107 # It's not used otherwise.
108 if test -n "$DJDIR"; then
109 BOOTSTRAP_SHELL
=/dev
/env
/DJDIR
/bin
/bash.exe
111 BOOTSTRAP_SHELL
=/bin
/sh
114 # Determine whether we have a usable version of M4.
115 # This rule is pickier than the rule in autoconf's actual configure script.
116 m4_version
="$($M4 --version | head -1)"
117 case "$m4_version" in
121 |
*\
1.4.
[0123456789] \
124 printf '%s\n' "$me: $M4 ($m4_version) is too old" >&2
129 # Substitutions related to the version of M4 available.
132 m4_help
=$
($M4 --help)
135 M4_DEBUGFILE
=--debugfile ;;
137 M4_DEBUGFILE
=--error-output ;;
144 # Autoconf's version number and identifiers.
145 RELEASE_YEAR
=$
(sed -ne 's/^RELEASE_YEAR=\([0-9][0-9]*\)$/\1/p' configure.ac
)
146 VERSION
=$
(build-aux
/git-version-gen .tarball-version
)
148 # PACKAGE_NAME and PACKAGE_BUGREPORT from the bootstrap autoconf can
149 # get copied into the generated configure script, so we need to get them
150 # right. Caution: there is a hard tab in one of the regexes below.
151 PACKAGE_NAME
=$
(sed -n < configure.ac \
152 -e 's/^m4_define(\[autoconf_PACKAGE_NAME], \[\([^]]*\)])$/\1/p')
153 PACKAGE_BUGREPORT
=$
(sed -n < configure.ac \
154 -e 's/^m4_define(\[autoconf_PACKAGE_BUGREPORT], \[\([^]]*\)])$/\1/p')
156 if [ -z "$RELEASE_YEAR" ]; then
157 echo "$me: error: could not extract RELEASE_YEAR from configure.ac" >&2
160 if [ -z "$VERSION" ]; then
161 echo "$me: error: could not compute VERSION" >&2
164 if [ -z "$PACKAGE_NAME" ]; then
165 echo "$me: error: could not extract PACKAGE_NAME from configure.ac" >&2
168 if [ -z "$PACKAGE_BUGREPORT" ]; then
169 echo "$me: error: could not extract PACKAGE_BUGREPORT from configure.ac" >&2
173 # PACKAGE_TARNAME and PACKAGE_URL from the bootstrap autoconf should not
174 # get copied into the configure script.
175 PACKAGE_URL
='<<not available>>'
176 PACKAGE_TARNAME
='<<not available>>'
178 # Root for temporary partial installation tree.
179 ACBOOTDIR
=$
(mktemp
-d acboot.XXXXXXXXXX
)
181 # dosubst options infile outfile -- performs the substitutions that
182 # config.status would perform on INFILE, creating OUTFILE. INFILE is
183 # relative to the source directory, OUTFILE is relative to $ACBOOTDIR.
184 # If OPTIONS is the letter 'x', OUTFILE is made executable after creation.
189 if [ -n "$verbose" ]; then
190 printf '%s: creating %s\n' "$me" "$out"
193 sed -e "s%@configure_input@%Generated from $in; do not edit by hand.%g" \
195 -e "s%@M4_DEBUGFILE@%$M4_DEBUGFILE%g" \
196 -e "s%@M4_GNU@%$M4_GNU%g" \
197 -e "s%@PACKAGE_BUGREPORT@%$PACKAGE_BUGREPORT%g" \
198 -e "s%@PACKAGE_NAME@%$PACKAGE_NAME%g" \
199 -e "s%@PACKAGE_STRING@%$PACKAGE_NAME $VERSION%g" \
200 -e "s%@PACKAGE_TARNAME@%$PACKAGE_TARNAME%g" \
201 -e "s%@PACKAGE_URL@%$PACKAGE_URL%g" \
202 -e "s%@PACKAGE_VERSION@%$VERSION%g" \
203 -e "s%@PERL@%$PERL%g" \
204 -e "s%@PERL_FLOCK@%0%g" \
205 -e "s%@RELEASE_YEAR@%$RELEASE_YEAR%g" \
206 -e "s%@SHELL@%$BOOTSTRAP_SHELL%g" \
207 -e "s%@VERSION@%$VERSION%g" \
208 -e "s%@pkgdatadir@%$ACBOOTDIR/lib%g" \
210 if [ "$1" = "x" ]; then
215 # Create the bootstrap installation.
216 mkdir
"$ACBOOTDIR"/bin
"$ACBOOTDIR"/lib
"$ACBOOTDIR"/tmp
219 for sub
in Autom4te autoconf m4sugar
; do
220 if [ -n "$verbose" ]; then
221 printf '%s: creating %s\n' "$me" "$ACBOOTDIR/lib/$sub"
223 ln -s ..
/..
/lib
/$sub .
227 # automake invokes autoconf, and autoconf and aclocal both invoke autom4te,
228 # so we need to create both of them.
229 dosubst x bin
/autoconf.
in bin
/autoconf
230 dosubst x bin
/autom4te.
in bin
/autom4te
231 dosubst . lib
/autom4te.
in lib
/autom4te.cfg
232 dosubst . lib
/version.
in lib
/version.
m4
234 AUTOCONF
="$ACBOOTDIR"/bin
/autoconf
235 AUTOM4TE
="$ACBOOTDIR/bin/autom4te -M -C $ACBOOTDIR/tmp/autom4te.cache"
236 export AUTOCONF AUTOM4TE
238 # We can now do what autoreconf would have done.
239 # Order is critical -- first aclocal, then autoconf, then automake.
242 if [ -n "$verbose" ]; then
243 printf '%s: running %s\n' "$me" "$*"
248 run
$ACLOCAL -I m4 -Wall -Werror $subverbose $force
249 run
$AUTOCONF -Wall -Werror $subverbose $force
250 run
$AUTOMAKE --add-missing --copy -Wall -Werror $subverbose $force