#!/bin/sh

set -e
set -x

version=0.4.5
topdir=`pwd`
tmpdir=${topdir}/tmp

test -f orc-${version}.tar.gz || \
test -f orc-${version}.tar.xz || \
  wget http://gstreamer.freedesktop.org/src/orc/orc-${version}.tar.gz || \
  wget http://gstreamer.freedesktop.org/src/orc/orc-${version}.tar.xz

rm -rf ${tmpdir}
mkdir -p ${tmpdir}

# FIXME: no test.orc ..
libtool --mode=execute ../../tools/orcc -o ${tmpdir}/out.c --implementation test.orc

if test -f orc-${version}.tar.gz; then
  tar -xzf orc-${version}.tar.gz --directory ${tmpdir}
elif test -f orc-${version}.tar.xz; then
  tar -xzf orc-${version}.tar.xz --directory ${tmpdir}
fi
cd ${tmpdir}

cd orc-${version}
./configure --prefix=${tmpdir}/_inst
make
make install

cd ${tmpdir}
gcc -Wall -Werror -I${tmpdir}/_inst/include/orc-0.4/ -c -o out.o out.c


