+#!/bin/bash
+
+## Some configuration variables
+number_of_processes="-j4"
+
+## Check input parameters and process inputs (if needed)
+if [ "$#" -eq 1 ]; then
+ valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
+ actual_ext=""
+ for ext in ${valid_extensions[@]}; do
+ if [ `basename $1 $ext` != $1 ]; then
+ actual_ext=$ext
+ fi
+ done
+ if [ "x$actual_ext" == "x" ]; then
+ echo "$0: Invalid file type."
+ exit 1
+ fi
+ canonical_path=`readlink -e $1`
+ source_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`
+ build_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`-build
+ echo -n "Cleaning directories... "
+ rm -rf $source_dir
+ rm -rf $build_dir
+ echo "done."
+ echo -n "Creating directories... "
+ mkdir -p $source_dir
+ mkdir -p $build_dir
+ echo "done."
+ echo -n "Extracting sources... "
+ if [ "$actual_ext" == "zip" ]; then
+ echo unzip $canonical_path
+ elif [ "$actual_ext" == "tar" ]; then
+ tar xf $canonical_path -C $source_dir --strip-components=1
+ elif [ "$actual_ext" == "tar.gz" ]; then
+ tar xzf $canonical_path -C $source_dir --strip-components=1
+ elif [ "$actual_ext" == "tar.bz2" ]; then
+ tar xjf $canonical_path -C $source_dir --strip-components=1
+ else
+ echo "$0: Invalid file type."
+ exit 1
+ fi
+ echo "done!"
+elif [ "$#" -eq 2 ]; then
+ source_dir=`dirname $1`
+ build_dir=`dirname $2`
+else
+ echo "Usage: [cmake_package] or [cmake_source_dir cmake_build_dir]"
+fi
+
+echo "Given source dir : \"$source_dir\""
+echo "Given build dir : \"$build_dir\""
+
+echo "Configuring sources... "
+cd $build_dir
+$source_dir/bootstrap --prefix=${HOME}/local
+echo "Configuring sources... done."
+
+echo "Compiling sources..."
+cd $build_dir
+make $number_of_processes
+echo "Compiling sources... done."
+
+echo "Installing package..."
+cd $build_dir
+make -j install
+echo "Installing package... done."
+
+## eof - $RCSfile$