1#!/bin/bash
2
3die() {
4  echo "$@" 1>&2
5  exit 1
6}
7
8clean() {
9  echo $1 | sed -e 's/\\//g'
10}
11
12### NOTE: ############################################################
13### These variables specify the tool versions we want to use.
14### Periods should be escaped with backslash for use by grep.
15###
16### If you update these, please also update docs/GettingStarted.rst
17want_autoconf_version='2\.60'
18want_autoheader_version=$want_autoconf_version
19want_aclocal_version='1\.9\.6'
20### END NOTE #########################################################
21
22outfile=configure
23configfile=configure.ac
24
25want_autoconf_version_clean=$(clean $want_autoconf_version)
26want_autoheader_version_clean=$(clean $want_autoheader_version)
27want_aclocal_version_clean=$(clean $want_aclocal_version)
28
29test -d autoconf && test -f autoconf/$configfile && cd autoconf
30test -f $configfile || die "Can't find 'autoconf' dir; please cd into it first"
31autoconf --version | grep $want_autoconf_version > /dev/null
32test $? -eq 0 || die "Your autoconf was not detected as being $want_autoconf_version_clean"
33aclocal --version | grep '^aclocal.*'$want_aclocal_version > /dev/null
34test $? -eq 0 || die "Your aclocal was not detected as being $want_aclocal_version_clean"
35autoheader --version | grep '^autoheader.*'$want_autoheader_version > /dev/null
36test $? -eq 0 || die "Your autoheader was not detected as being $want_autoheader_version_clean"
37echo ""
38echo "### NOTE: ############################################################"
39echo "### If you get *any* warnings from autoconf below you MUST fix the"
40echo "### scripts in the m4 directory because there are future forward"
41echo "### compatibility or platform support issues at risk. Please do NOT"
42echo "### commit any configure script that was generated with warnings"
43echo "### present. You should get just three 'Regenerating..' lines."
44echo "######################################################################"
45echo ""
46echo "Regenerating aclocal.m4 with aclocal $want_aclocal_version_clean"
47cwd=`pwd`
48aclocal --force -I $cwd/m4 || die "aclocal failed"
49echo "Regenerating configure with autoconf $want_autoconf_version_clean"
50autoconf --force --warnings=all -o ../$outfile $configfile || die "autoconf failed"
51cd ..
52echo "Regenerating config.h.in with autoheader $want_autoheader_version_clean"
53autoheader --warnings=all -I autoconf -I autoconf/m4 autoconf/$configfile || die "autoheader failed"
54exit 0
55