# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=3

DESCRIPTION="C Implementation of FAST protocol"
HOMEPAGE="http://code.google.com/p/quickfast/"
SRC_URI="http://quickfast.googlecode.com/files/quickfast_lnx_src_1_2.tar.gz"

LICENSE="New BSD License"
SLOT="0"
KEYWORDS="~amd64"
IUSE=""

DEPEND="dev-libs/boost dev-libs/xerces-c"
RDEPEND="${DEPEND}"

src_unpack() {

#MPC is required to prepare Makefile
wget http://quickfast.googlecode.com/files/quickfast_lnx_src_1_2.tar.gz
wget http://downloads.ociweb.com/MPC/MPC_3_8_0.tar.gz
tar xvf quickfast_lnx_src_1_2.tar.gz
tar xvf MPC_3_8_0.tar.gz

export MPC_ROOT=$WORKDIR/MPC
export QUICKFAST_ROOT=$WORKDIR/quickfast_lnx_src_1_2
export BOOST_ROOT=/usr/include/boost
export BOOST_ROOT_LIB=/usr/lib
export XERCES_ROOT=/usr/include/xerces
export XERCES_LIBPATH=/usr/lib
export XERCES_INCLUDE=/usr/include
export XERCES_LIBNAME=xerces-c
export PATH=$QUICKFAST_ROOT/bin:$MPC_ROOT:$PATH
export LD_LIBRARY_PATH=$XERCES_LIBPATH:$QUICKFAST_ROOT/lib:$BOOST_ROOT_LIB:$LD_LIBRARY_PATH:$QUICKFAST_ROOT/src
export CPATH=$QUICKFAST_ROOT/src
export CPLUS_INCLUDE_PATH=$CPATH
cd $QUICKFAST_ROOT
$MPC_ROOT/mwc.pl -type make $QUICKFAST_ROOT/QuickFAST.mwc
}

src_compile() {
cd $QUICKFAST_ROOT
emake || die "Make failed"
}

src_install() {
cd $QUICKFAST_ROOT
dolib lib/libQuickFAST.so
dobin bin/InterpretApplication || die "Installation failed"
}