#! /bin/sh
cp -f version cfg/autoconf/VERSION
cd cfg/autoconf
if [ ! -f ./configure -o "x$1" = "x--regenerate" -o ./configure.in -nt ./configure ] ; then
    echo "Running autoconf..."
    autoconf
    test "x$1" = "x--regenerate" && shift
fi
if ./configure "$@" ; then
    if [ "$1" = "--help" ]
    then
        echo
        echo "Use --regenerate as first parameter regenerate configure script"
    else
        cp Makefile.cfg ../Makefile.cfg
        chmod a+rw ../Makefile.cfg
        rm Makefile.cfg
        mv -f config.h ../config.h
        chmod a+rw ../config.h
    fi
fi
