166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#!/bin/bash
266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumandie() {
466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  echo "$@" 1>&2
566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  exit 1
666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman}
766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanclean() {
966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  echo $1 | sed -e 's/\\//g'
1066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman}
1166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
1266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman### NOTE: ############################################################
1366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman### These variables specify the tool versions we want to use.
1466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman### Periods should be escaped with backslash for use by grep.
1566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman###
1666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman### If you update these, please also update docs/GettingStarted.html
1766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanwant_autoconf_version='2\.61'
1866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanwant_autoheader_version=$want_autoconf_version
1966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanwant_aclocal_version='1\.10'
2066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanwant_libtool_version='1\.5\.22'
2166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman### END NOTE #########################################################
2266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
2366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanoutfile=configure
2466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanconfigfile=configure.ac
2566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
2666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanwant_autoconf_version_clean=$(clean $want_autoconf_version)
2766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanwant_autoheader_version_clean=$(clean $want_autoheader_version)
2866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanwant_aclocal_version_clean=$(clean $want_aclocal_version)
2966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanwant_libtool_version_clean=$(clean $want_libtool_version)
3066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
3166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumantest -d autoconf && test -f autoconf/$configfile && cd autoconf
3266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumantest -f $configfile || die "Can't find 'autoconf' dir; please cd into it first"
3366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanautoconf --version | grep $want_autoconf_version > /dev/null
3466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumantest $? -eq 0 || die "Your autoconf was not detected as being $want_autoconf_version_clean"
3566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanaclocal --version | grep '^aclocal.*'$want_aclocal_version > /dev/null
3666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumantest $? -eq 0 || die "Your aclocal was not detected as being $want_aclocal_version_clean"
3766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanautoheader --version | grep '^autoheader.*'$want_autoheader_version > /dev/null
3866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumantest $? -eq 0 || die "Your autoheader was not detected as being $want_autoheader_version_clean"
3966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanlibtool --version | grep $want_libtool_version > /dev/null
4066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumantest $? -eq 0 || die "Your libtool was not detected as being $want_libtool_version_clean"
4166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanecho ""
4266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanecho "### NOTE: ############################################################"
4366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanecho "### If you get *any* warnings from autoconf below you MUST fix the"
4466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanecho "### scripts in the m4 directory because there are future forward"
4566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanecho "### compatibility or platform support issues at risk. Please do NOT"
4666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanecho "### commit any configure script that was generated with warnings"
4766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanecho "### present. You should get just three 'Regenerating..' lines."
4866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanecho "######################################################################"
4966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanecho ""
5066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanecho "Regenerating aclocal.m4 with aclocal $want_aclocal_version_clean"
5166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumancwd=`pwd`
5266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanaclocal --force -I $cwd/m4 || die "aclocal failed"
5366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanecho "Regenerating configure with autoconf $want_autoconf_version_clean"
5466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanautoconf --force --warnings=all -o ../$outfile $configfile || die "autoconf failed"
5566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumancd ..
5666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanecho "Regenerating config.h.in with autoheader $want_autoheader_version_clean"
5766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanautoheader --warnings=all -I autoconf -I autoconf/m4 autoconf/$configfile || die "autoheader failed"
5866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanexit 0
59