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

EAPI="4"

inherit versionator unpacker eutils

MY_P="${PN}_$(delete_version_separator 2)"

DESCRIPTION="Virtual webcam that can mix several video sources together"
HOMEPAGE="http://www.ws4gl.org/"
SRC_URI="http://webcamstudio.googlecode.com/files/${MY_P}_all.deb"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64"
IUSE="pulseaudio"

DEPEND=""
RDEPEND="dev-java/jna
	~media-video/${PN}-module-${PV}
	virtual/jre
	pulseaudio? ( media-sound/pulseaudio )"

S="${WORKDIR}"

src_prepare() {
	epatch "${FILESDIR}/${PN}-gentooify.patch"

	rm -rf ./usr/share/${PN}/${PN}-src || die # handled in webcamstudio-module
	rm ./usr/bin/webcamstudioConsole || die
	if ! use pulseaudio; then
		rm ./usr/bin/ws4gl-pulseaudio-get{apps,sources}.sh || die
	fi
}

src_install() {
	dodir usr
	cp -R "${S}/usr" "${D}/" || die "Install failed!"
	dosym /usr/share/jna/lib/jna.jar /usr/lib/webcamstudio/lib/jna.jar
}