3 # This script helps bootstrap autoconf, when checked out from git.
5 # Copyright (C) 2021-2024 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 # Allow 'ln -s' to be overridden by the user.
99 # $PERL needs to be an absolute path because we're going to substitute it
103 PERL
=$
(command -v $1)
105 if [ $# -gt 0 ]; then
109 # Override SHELL. This is required on DJGPP so that Perl's system()
110 # uses bash, not COMMAND.COM which doesn't quote arguments properly.
111 # It's not used otherwise.
112 if test -n "$DJDIR"; then
113 BOOTSTRAP_SHELL
=/dev
/env
/DJDIR
/bin
/bash.exe
115 BOOTSTRAP_SHELL
=/bin
/sh
118 # Determine whether we have a usable version of M4.
119 # This rule is pickier than the rule in autoconf's actual configure script.
120 m4_version
="$($M4 --version | head -1)"
121 case "$m4_version" in
125 |
*\
1.4.
[0123456789] \
128 printf '%s\n' "$me: $M4 ($m4_version) is too old" >&2
133 # Substitutions related to the version of M4 available.
136 m4_help
=$
($M4 --help)
139 M4_DEBUGFILE
=--debugfile ;;
141 M4_DEBUGFILE
=--error-output ;;
148 # Autoconf's version number and identifiers.
149 RELEASE_YEAR
=$
(sed -ne 's/^RELEASE_YEAR=\([0-9][0-9]*\)$/\1/p' configure.ac
)
150 VERSION
=$
(build-aux
/git-version-gen .tarball-version
)
152 # PACKAGE_NAME and PACKAGE_BUGREPORT from the bootstrap autoconf can
153 # get copied into the generated configure script, so we need to get them
154 # right. Caution: there is a hard tab in one of the regexes below.
155 PACKAGE_NAME
=$
(sed -n < configure.ac \
156 -e 's/^m4_define(\[autoconf_PACKAGE_NAME], \[\([^]]*\)])$/\1/p')
157 PACKAGE_BUGREPORT
=$
(sed -n < configure.ac \
158 -e 's/^m4_define(\[autoconf_PACKAGE_BUGREPORT], \[\([^]]*\)])$/\1/p')
160 if [ -z "$RELEASE_YEAR" ]; then
161 echo "$me: error: could not extract RELEASE_YEAR from configure.ac" >&2
164 if [ -z "$VERSION" ]; then
165 echo "$me: error: could not compute VERSION" >&2
168 if [ -z "$PACKAGE_NAME" ]; then
169 echo "$me: error: could not extract PACKAGE_NAME from configure.ac" >&2
172 if [ -z "$PACKAGE_BUGREPORT" ]; then
173 echo "$me: error: could not extract PACKAGE_BUGREPORT from configure.ac" >&2
177 # PACKAGE_TARNAME and PACKAGE_URL from the bootstrap autoconf should not
178 # get copied into the configure script.
179 PACKAGE_URL
='<<not available>>'
180 PACKAGE_TARNAME
='<<not available>>'
182 # Root for temporary partial installation tree.
183 ACBOOTDIR
=$
(mktemp
-d acboot.XXXXXXXXXX
)
184 ACBOOTDIR
=$
(realpath
$ACBOOTDIR)
186 # dosubst options infile outfile -- performs the substitutions that
187 # config.status would perform on INFILE, creating OUTFILE. INFILE is
188 # relative to the source directory, OUTFILE is relative to $ACBOOTDIR.
189 # If OPTIONS is the letter 'x', OUTFILE is made executable after creation.
194 if [ -n "$verbose" ]; then
195 printf '%s: creating %s\n' "$me" "$out"
198 sed -e "s%@configure_input@%Generated from $in; do not edit by hand.%g" \
200 -e "s%@M4_DEBUGFILE@%$M4_DEBUGFILE%g" \
201 -e "s%@M4_GNU@%$M4_GNU%g" \
202 -e "s%@PACKAGE_BUGREPORT@%$PACKAGE_BUGREPORT%g" \
203 -e "s%@PACKAGE_NAME@%$PACKAGE_NAME%g" \
204 -e "s%@PACKAGE_STRING@%$PACKAGE_NAME $VERSION%g" \
205 -e "s%@PACKAGE_TARNAME@%$PACKAGE_TARNAME%g" \
206 -e "s%@PACKAGE_URL@%$PACKAGE_URL%g" \
207 -e "s%@PACKAGE_VERSION@%$VERSION%g" \
208 -e "s%@PERL@%$PERL%g" \
209 -e "s%@PERL_FLOCK@%0%g" \
210 -e "s%@RELEASE_YEAR@%$RELEASE_YEAR%g" \
211 -e "s%@SHELL@%$BOOTSTRAP_SHELL%g" \
212 -e "s%@VERSION@%$VERSION%g" \
213 -e "s%@pkgdatadir@%$ACBOOTDIR/lib%g" \
215 if [ "$1" = "x" ]; then
220 # Create the bootstrap installation.
221 mkdir
"$ACBOOTDIR"/bin
"$ACBOOTDIR"/lib
"$ACBOOTDIR"/tmp
224 for sub
in Autom4te autoconf m4sugar
; do
225 if [ -n "$verbose" ]; then
226 printf '%s: creating %s\n' "$me" "$ACBOOTDIR/lib/$sub"
228 $LN_S ..
/..
/lib
/$sub .
232 # automake invokes autoconf, and autoconf and aclocal both invoke autom4te,
233 # so we need to create both of them.
234 dosubst x bin
/autoconf.
in bin
/autoconf
235 dosubst x bin
/autom4te.
in bin
/autom4te
236 dosubst . lib
/autom4te.
in lib
/autom4te.cfg
237 dosubst . lib
/version.
in lib
/version.
m4
239 AUTOCONF
="$ACBOOTDIR"/bin
/autoconf
240 AUTOM4TE
="$ACBOOTDIR/bin/autom4te -M -C $ACBOOTDIR/tmp/autom4te.cache"
241 export AUTOCONF AUTOM4TE
243 # We can now do what autoreconf would have done.
244 # Order is critical -- first aclocal, then autoconf, then automake.
247 if [ -n "$verbose" ]; then
248 printf '%s: running %s\n' "$me" "$*"
253 run
$ACLOCAL -I m4 -Wall -Werror $subverbose $force
254 run
$AUTOCONF -Wall -Werror $subverbose $force
255 run
$AUTOMAKE --add-missing --copy -Wall -Werror $subverbose $force