Ensure timestamp on saved contents of configure.ac is not changed.
[oota-llvm.git] / autoconf / AutoRegen.sh
1 #!/bin/sh
2 die () {
3         echo "$@" 1>&2
4         exit 1
5 }
6 if test "$1" = --with-automake ; then
7   outfile=configure_am
8   configfile=configure.am
9   with_automake=1
10 elif test -z "$1" ; then
11   outfile=configure
12   configfile=configure.ac
13   with_automake=0
14 else
15   die "Invalid option: $1"
16 fi
17 test -d autoconf && test -f autoconf/$configfile && cd autoconf
18 test -f $configfile || die "Can't find 'autoconf' dir; please cd into it first"
19 autoconf --version | egrep '2\.59' > /dev/null
20 if test $? -ne 0 ; then
21   die "Your autoconf was not detected as being 2.59"
22 fi
23 aclocal --version | egrep '1\.9\.2' > /dev/null
24 if test $? -ne 0 ; then
25   die "Your aclocal was not detected as being 1.9.1"
26 fi
27 autoheader --version | egrep '2\.59' > /dev/null
28 if test $? -ne 0 ; then
29   die "Your autoheader was not detected as being 2.59"
30 fi
31 libtool --version | grep '1.5.10' > /dev/null
32 if test $? -ne 0 ; then
33   die "Your libtool was not detected as being 1.5.10"
34 fi
35 if test $with_automake -eq 1 ; then
36   automake --version | grep 'automake.*1.9.2' > /dev/null
37   if test $? -ne 0 ; then
38     die "Your automake was not detected as being 1.9.2"
39   fi
40 fi
41 echo ""
42 echo "### NOTE: ############################################################"
43 echo "### If you get *any* warnings from autoconf below you MUST fix the"
44 echo "### scripts in the m4 directory because there are future forward"
45 echo "### compatibility or platform support issues at risk. Please do NOT"
46 echo "### commit any configure script that was generated with warnings"
47 echo "### present. You should get just three 'Regenerating..' lines."
48 echo "######################################################################"
49 echo ""
50 echo "Regenerating aclocal.m4 with aclocal"
51 cwd=`pwd`
52 if test $with_automake -eq 1 ; then
53   mv configure.ac .configure.ac.save
54   cp configure.am configure.ac
55   cp configure.am ../configure.ac
56 fi
57 aclocal --force -I $cwd/m4 || die "aclocal failed"
58 echo "Regenerating configure with autoconf 2.59"
59 autoconf --force --warnings=all -o ../$outfile $configfile || die "autoconf failed"
60 cd ..
61 echo "Regenerating config.h.in with autoheader 2.59"
62 autoheader -I autoconf -I autoconf/m4 autoconf/$configfile || die "autoheader failed"
63 if test $with_automake -eq 1 ; then
64   echo "Regenerating makefiles with automake 1.9.2"
65   cp autoconf/aclocal.m4 .
66   automake --gnu --add-missing --copy --force-missing
67   cd $cwd
68   mv .configure.ac.save configure.ac
69 fi
70 exit 0