#!/bin/sh

export GIT_AUTHOR_NAME="Ludovic Courtès"
export GIT_COMMITTER_NAME="Ludovic Courtès"
export GUILE_BRANCH="branch_release-1-8"

cd $HOME/guile
git-reset --hard
git-checkout "$GUILE_BRANCH"

if ! git-pull origin "$GUILE_BRANCH"
then
    echo "git-pull failed"
    exit 1
fi

make distclean

# Use Autobuild's macro.
if [ ! -f autobuild.m4 ]
then
    echo "file \`autobuild.m4' not found"
    exit 1
else
    cat autobuild.m4 >> acinclude.m4
fi

ed configure.in <<EOF
/^AH_TOP
i

AB_INIT

.
wq
EOF

AUTOMAKE=automake-1.10 ACLOCAL=aclocal-1.10 autoreconf2.50 -vfi -I.
if [ $? -ne 0 ]
then
    echo "autoreconf failed"
    exit 1
fi

export PATH="$HOME/soft/bin:$PATH"
export LD_LIBRARY_PATH="$HOME/soft/lib:$LD_LIBRARY_PATH"

echo "building branch \`$GUILE_BRANCH'..."

( CPPFLAGS="-I$HOME/soft/include" LDFLAGS="-L$HOME/soft/lib" \
  ./configure --enable-maintainer-mode && make check $MAKEFLAGS ) 2>&1 | \
mail guile@autobuild.josefsson.org
