#!/bin/sh

if test x"$srcdir" != x""; then
    builddir="."	# running from make check, but it does not define that
else
    srcdir=`echo "$0" | sed s,[^/]*$,,`
    test "$srcdir" = "$0" && srcdir=.
    test -z "$srcdir" && srcdir=.
    builddir="$srcdir"	# running manually, have to assume
fi

srcdir=`cd $srcdir;pwd`
builddir=`cd $builddir;pwd`

basedir=".."
cd $srcdir; if [ ! -d $basedir -o ! -f $basedir/src/a52dec.c -o \
    ! -f $basedir/a52dec-*.tar.gz ]; then
    cd ..; if [ ! -d $basedir -o ! -f $basedir/src/a52dec.c -o \
	! -f $basedir/a52dec-*.tar.gz ]; then
	exit 77
    fi
fi
basedir=`cd $basedir;pwd`

cd $builddir
rm -fr compile_test

for compiler in cc gcc gcc272 gcc-2.95 gcc-3.0 gcc-3.1 checkergcc tcc icc \
		i586-mingw32msvc-gcc; do
    compiler_path=`which $compiler`
    if test x"$compiler_path" = x""; then continue; fi

    mkdir compile_test
    cd compile_test; tar xzpf $basedir/a52dec-*.tar.gz; cd a52dec-*
    host=""
    if test x"$compiler" = x"i586-mingw32msvc-gcc"; then
	host="--host=i586-mingw32msvc"
    fi
    error=1
    CC=$compiler ./configure --enable-warnings $host && make && error=0
    if test x"$error" != x"0"; then exit 1; fi
    cd ../..
    rm -fr compile_test
done

exit 0
