1#!/bin/sh
2die () {
3	echo "$@" 1>&2
4	exit 1
5}
6test -d autoconf && test -f autoconf/configure.ac && cd autoconf
7test -f configure.ac || die "Can't find 'autoconf' dir; please cd into it first"
8autoconf --version | egrep '2\.[56][0-9]' > /dev/null
9if test $? -ne 0 ; then
10  die "Your autoconf was not detected as being 2.5x or 2.6x"
11fi
12cwd=`pwd`
13if test -d ../../../autoconf/m4 ; then
14  cd ../../../autoconf/m4
15  llvm_src_root=../..
16  llvm_obj_root=../..
17  cd $cwd
18elif test -d ../../llvm/autoconf/m4 ; then
19  cd ../../llvm/autoconf/m4
20  llvm_src_root=../..
21  llvm_obj_root=../..
22  cd $cwd
23else
24  while true ; do
25    echo "LLVM source root not found." 
26    read -p "Enter full path to LLVM source:" REPLY
27    if test -d "$REPLY/autoconf/m4" ; then
28      llvm_src_root="$REPLY"
29      read -p "Enter full path to LLVM objects (empty for same as source):" REPLY
30      if test -d "$REPLY" ; then
31        llvm_obj_root="$REPLY"
32      else
33        llvm_obj_root="$llvm_src_root"
34      fi
35      break
36    fi
37  done
38fi
39echo "Regenerating aclocal.m4 with aclocal"
40rm -f aclocal.m4
41aclocal -I $cwd/m4 || die "aclocal failed"
42echo "Regenerating configure with autoconf"
43autoconf --warnings=all -o ../configure configure.ac || die "autoconf failed"
44cd ..
45exit 0
46