# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/rox-base/rox/rox-2.7.ebuild,v 1.4 2008/02/29 20:32:30 carlo Exp $

inherit eutils multilib

MY_P="rox-filer-${PV}"
S="${WORKDIR}/${MY_P}"

DESCRIPTION="ROX is a desktop environment and filer based on RISC OS."
HOMEPAGE="http://rox.sourceforge.net/"
SRC_URI="mirror://sourceforge/rox/${MY_P}.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~ppc ~sparc ~x86"
IUSE="svg"

RDEPEND=">=x11-libs/gtk+-2.4
	>=dev-libs/glib-2.2
	>=dev-libs/libxml2-2.4.23
	>=x11-misc/shared-mime-info-0.14
	svg? ( gnome-base/librsvg )"

DEPEND="${RDEPEND}
	>=dev-util/pkgconfig-0.20"

APPNAME="ROX-Filer"
APPDIR="/usr/$(get_libdir)/rox"
LIBDIR="/usr/$(get_libdir)/"
WRAPPERNAME="rox"
MIMEDIR="/usr/share/mime"
MIMECONFDIR="/etc/xdg/rox.sourceforge.net"

src_unpack() {
	unpack ${A}
	cd "${S}"
	epatch "${FILESDIR}"/${P}-nostrip.patch
	epatch "${FILESDIR}"/${P}-text_plain.patch
}

src_compile() {

	cd ${APPNAME}

	# Most rox self-compiles have a 'read' call to wait for the user to
	# press return if the compile fails.
	# Find and remove this:
	sed -i.bak -e 's/\/#read/' AppRun

	./AppRun --compile || die "make failed"
	(cd src; make clean) > /dev/null
	# don't need these directories anymore
	if [ -n "${KEEP_SRC}" ]; then
		(cd src; make clean) > /dev/null
	else
		rm -rf src
	fi
	rm -fr build

	# Restore the original AppRun
	mv AppRun.bak AppRun
}

# new streamlined install

src_install() {
	doman rox.1

	dodir ${APPDIR}
	cp -r ${APPNAME}/ "${D}/${APPDIR}"

	# add documentation to be proper
	( cd ${APPNAME}/Help
	dodoc Changes README README-es TODO
	)

	# install shell script
	dodir /usr/bin

	cat >"${D}/usr/bin/${WRAPPERNAME}" <"${D}/usr/bin/${WRAPPERNAME}uri" <