blob: c681c679eea713bc57545d47086ac366144cacd0 [file] [log] [blame]
H. Peter Anvin (Intel)dea90382019-08-07 17:43:20 -07001#!/bin/sh -x
H. Peter Anvin2030bd22007-04-12 16:25:58 +00002#
H. Peter Anvinb0121dc2018-12-22 18:17:16 -08003# Run this script to regenerate autoconf files
H. Peter Anvin2030bd22007-04-12 16:25:58 +00004#
H. Peter Anvin54d50782018-12-22 18:51:59 -08005recheck=false
6if [ x"$1" = x--recheck ]; then
7 recheck=true
8 config=$(sh config.status --config 2>/dev/null)
9fi
10
H. Peter Anvin (Intel)dea90382019-08-07 17:43:20 -070011# This allows for overriding the default autoconf programs
12AUTOCONF="${AUTOCONF:-${AUTOTOOLS_PREFIX}autoconf}"
13AUTOMAKE="${AUTOMAKE:-${AUTOTOOLS_PREFIX}automake}"
14ACLOCAL="${ACLOCAL:-${AUTOTOOLS_PREFIX}aclocal}"
15AUTOHEADER="${AUTOHEADER:-${AUTOTOOLS_PREFIX}autoheader}"
16
H. Peter Anvin0bddd0f2019-02-22 01:13:52 -080017mkdir -p autoconf autoconf/helpers config
H. Peter Anvin (Intel)dea90382019-08-07 17:43:20 -070018autolib="`"$AUTOMAKE" --print-libdir`"
19if test ! x"$autolib" = x; then
20 for prg in install-sh compile config.guess config.sub; do
H. Peter Anvin (Intel)01a67a12019-09-24 11:13:43 -070021 # Update autoconf helpers if and only if newer ones are available
22 if test -f "$autolib"/"$prg" && \
23 ( test -f "$autolib"/"$prg" && \
24 sed -n -r -e \
25 's/^(scriptver(|sion)|timestamp)=['\''"]?([^'\''"]+).*$/\3/p' \
26 "$autolib"/"$prg" autoconf/helpers/"$prg" | \
27 sort --check=quiet; test $? -ne 0 )
28 then
H. Peter Anvin (Intel)dea90382019-08-07 17:43:20 -070029 cp -f "$autolib"/"$prg" autoconf/helpers
30 fi
31 done
32fi
33mv -f autoconf/aclocal.m4 autoconf/aclocal.m4.old
H. Peter Anvinb0121dc2018-12-22 18:17:16 -080034mkdir -p autoconf/m4.old autoconf/m4
35mv -f autoconf/m4/*.m4 autoconf/m4.old/ 2>/dev/null || true
36ACLOCAL_PATH="${ACLOCAL_PATH}${ACLOCAL_PATH:+:}`pwd`/autoconf/m4.old"
37export ACLOCAL_PATH
H. Peter Anvin (Intel)dea90382019-08-07 17:43:20 -070038"$ACLOCAL" --install --output=autoconf/aclocal.m4 -I autoconf/m4
39if test ! -f autoconf/aclocal.m4; then
40 # aclocal failed, revert to previous files
41 mv -f autoconf/m4.old/*.m4 autoconf/m4/
42 mv -f autoconf/aclocal.m4.old autoconf/aclocal.m4
43fi
44rm -rf autoconf/*m4.old
45"$AUTOHEADER" -B autoconf
H. Peter Anvin97ea4ad2019-10-03 21:32:08 -070046if [ config/config.h.in -nt config/unconfig.h ]; then
47 # Create a file corresponding to a completely empty configure
48 # instance, commenting out the #undef directives from the template
49 # just like configure would do.
50 perl -np < config/config.h.in > config/unconfig.h \
51 -e 's:^(\#\s*undef\s.*)$:/* $1 */:;' \
52 -e 's:config/config.h.in:config/unconfig.h:;' \
53 -e 's:autoheader:autogen.sh:;'
54fi
H. Peter Anvin (Intel)dea90382019-08-07 17:43:20 -070055"$AUTOCONF" -B autoconf
H. Peter Anvinb0121dc2018-12-22 18:17:16 -080056rm -rf autom4te.cache config.log config.status config/config.h Makefile
H. Peter Anvin54d50782018-12-22 18:51:59 -080057
58if $recheck; then
59 # This bizarre statement has to do with how config.status quotes its output
60 echo exec sh configure $config | sh -
61fi