#!/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://dl.sourceforge.net/sourceforge/wxwindows/wxGTK-2.4.2.tar.bz2
install http://dl.sourceforge.net/sourceforge/xmule/xmule-1.7.1.tar.bz2 --with-wx-prefix=$PREFIX
# message
cat <<EOF

to start open a new console, then: xmule
EOF

