1#!/bin/sh
2
3if [ -f Makefile ]; then
4	make gitclean
5fi
6
7if [ -f aclocal.m4 ]; then
8	rm -fv aclocal.m4
9fi
10
11if [ -d m4 ]; then
12	rm -fv m4/*
13fi
14
15if [ -f configure.ac ]; then
16  if grep "AC_CONFIG_HEADER" configure.ac >/dev/null; then
17      echo "Running autoheader"
18      autoheader || exit 1
19  fi
20  if grep "AM_PROG_LIBTOOL" configure.ac >/dev/null; then
21    echo "Running libtoolize"
22    lver=$(libtoolize --version | grep 1.5)
23    if [ "x${lver}" != "x" ]; then
24	    libtoolize --force --copy || exit 1
25    else    libtoolize --force --copy --install || exit 1
26    fi
27  fi
28  echo "Running aclocal $ACLOCAL_FLAGS"
29  aclocal -I m4 $ACLOCAL_FLAGS || exit 1
30
31  echo "Running autoconf $AUTOCONF_FLAGS"
32  autoconf $AUTOCONF_FLAGS || exit 1
33fi
34
35if [ "${1}" != "--nocfg" ]; then
36	./configure "$@"
37fi
38