#!/bin/sh

set -e

ARCH=$1


./autogen.sh

# Run configure for arm-linux build
if [ ! "x$ARCH" = "x" ]; then
  if [ "$ARCH" = "arm-linux" ] ; then
    CC=arm-linux-gcc CC_FOR_BUILD=gcc ./configure --prefix=$PWD/usr/local --build=i386-linux --host=arm-linux
  fi
fi

# Edit Makefile
sed s/"1:0:2"/"1:0:1"/ Makefile >> tmp.txt
cp tmp.txt Makefile
rm tmp.txt

# Make/Install
if [ ! "x$ARCH" = "x" ]; then
  if [ "$ARCH" = "arm-linux" ] ; then
    make install
  else
    make DESTDIR=$PWD install
  fi
fi

# make install should really do this
cd usr/local
mkdir -p include
cd include
cp ../../../config_types.h .
cp ../../../ivorbiscodec.h .
cp ../../../ivorbisfile.h .
cp ../../../ogg.h .
cp ../../../os_types.h .





