# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

inherit eutils

MY_P=${PN}-${PV/_}
DESCRIPTION="Support for the Griffin PowerMate USB Dial that includes an 
XMMS/BMP visualization Plugin"
HOMEPAGE="http://powermated.sourceforge.net"
SRC_URI="http://www.nano-editor.org/dist/v1.3/${MY_P}.tar.gz"
SRC_URI="http://osdn.dl.sourceforge.net/sourceforge/powermated/${MY_P}.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~ppc-macos 
~s390 ~sh ~sparc x86"
IUSE="xmms beep xosd"

DEPEND="x11
	xmms? ( media-sound/xmms )
	beep? ( media-sound/beep-media-player )
	xosd? ( x11-libs/xosd )"

S=${WORKDIR}/${MY_P}

src_unpack() {
	unpack ${A}
	cd ${S}
}

src_compile() {
	local myconf=""
	use build && myconf="${myconf}"

	econf \
		$(use_enable xmms) \
		$(use_enable beep) \
		$(use_enable xosd) \
		${myconf} \
		|| die "configure failed"
	emake || die
}

src_install() {
	make DESTDIR="${D}" install || die

	if use build ; then
		rm -rf "${D}"/usr/share
	else
		cat ${FILESDIR}/config/powermated.conf >> doc/powermated.conf.sample
		dodoc ChangeLog README config/powermated.conf AUTHORS BUGS NEWS TODO
		insinto /etc
		newins doc/powermated.conf.sample powermated.conf
	fi
}

pkg_postinst() {
	einfo "For details on how to get Linux to recognize the PowerMate see:"
	einfo "http://powermated.sourceforge.net/instructions.html"
}