#!/bin/bash
################################################################################
# Filename: ./src/make_helper
# 
# The contents of this file are subject to the Qlusters Public License
# Version 1.1 (the License); you may not use this file except in compliance
# with the License.
# You may obtain a copy of the License at
# http://www.openqrm.org/content/view/33/69/.
# 
# Software distributed under the License is distributed on an AS IS basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
# the specific language governing rights and limitations under the License.
# 
# The Original Code is openQRM.
# 
# The Initial Developer of the Original Code is Qlusters Corporation. Portions
# created by Qlusters Corporation are Copyright (C) 2003-2005. All Rights
# Reserved.
# 
# Contributor(s):
# 
# Description:
# 
# Comments:
################################################################################

QRM_DIR_TMP=`dirname $0`
QRM_BUILD_ROOT=`pushd $QRM_DIR_TMP 1>/dev/null && pwd && popd 1>/dev/null`
export QRM_SERVER_BASE_DIR=$QRM_BUILD_ROOT/base
. $QRM_BUILD_ROOT/base/include/qrm-functions
. $QRM_BUILD_ROOT/base/include/qrm-setup-functions

function do_make() {
	make "$@" 10>&2 2> >(while read LINE; do if [ ! -z "${LINE##+*}" ]; then echo -e '\E[0;31m'$LINE 1>&10; tput sgr0; fi; done)
}

case "$1" in
	build_package)
		build_package $2 $3 $4 $5
		;;
	get_cache_dir)
		echo "$QRM_CACHE_DIR"
		;;
	get_root_dir)
		echo "$QRM_ROOT_DIR"
		;;
	qrm_cache)
		qrm_cache $2 $3 $4 $5
		;;
	qrm_unpack)
		qrm_unpack $2 $3
		;;
	make)
		shift
		do_make "$@"
		;;
	*)
		COMMAND=$1 
		shift
		$COMMAND "$@"
		;;
esac




