#!/bin/bash
# install function
function install ()
{
 NAME=`basename "$1"`
 echo installing... "$NAME"
 if ! test -e "$NAME"; then wget "$1"; fi
 case "$NAME" in
  *.tar.gz) tar zxf "$NAME"; SHORTNAME=`echo "$NAME"|sed s/.tar.gz//` ;;
  *.tar.bz2) tar jxf "$NAME"; SHORTNAME=`echo "$NAME"|sed s/.tar.bz2//` ;;
 esac
 cd "$SHORTNAME"
 shift
 ./configure --prefix=$PREFIX $*
 make
 make install
 cd -
 rm -rf "$SHORTNAME"
}
# make $HOME/dist
PREFIX=$HOME/dist
mkdir -p $PREFIX/src
cd $PREFIX/src
GREP_RESULT=`grep $PREFIX/bin $HOME/.bashrc`
if test -z "$GREP_RESULT"; then
 echo "export PATH=$PREFIX/bin:$PATH" >> $HOME/.bashrc
fi
GREP_RESULT=`grep $PREFIX/lib $HOME/.bashrc`
if test -z "$GREP_RESULT"; then
 echo "export LD_LIBRARY_PATH=$PREFIX/lib" >> $HOME/.bashrc
fi
# install files
install http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz
install ftp://xmlsoft.org/libxml2-2.5.6.tar.gz
install http://www.dtek.chalmers.se/groups/dvd/dist/libdvdread-0.9.4.tar.gz
install http://developers.videolan.org/pub/videolan/libdvdcss/1.2.6/libdvdcss-1.2.6.tar.bz2
install http://www.dtek.chalmers.se/groups/dvd/dist/ogle-0.9.1.tar.gz --with-xml-prefix=$PREFIX
# message
cat <<EOF

to start open a new console, then: ogle -u cli /dev/dvd
EOF
