#! /bin/sh

# $Progeny$

# This program is in the public domain.

# Too bad we don't have something like sysexits.h for POSIX sh...
EX_USAGE=64

usage ()
{
    cat <<EOF
usage: $0 DISTNAME

Where DISTNAME.tar.bz2 contains the DISTNAME directory.
EOF
}

if [ $# -ne 1 ]; then
    usage
    exit ${EX_USAGE}
fi

distdir=$1
distfile=${distdir}.tar.bz2

set -e

bzip2 -dc ${distfile} | tar -xf -

abs_distdir=$(cd ${distdir} && pwd)

mkdir ${distdir}/.buildtest
cd ${distdir}/.buildtest
../configure
make check

make install DESTDIR=${abs_distdir}/.installtest
make uninstall DESTDIR=${abs_distdir}/.installtest

cd ../..
rm -rf ${distdir}

exit 0
