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

EAPI=5

inherit cmake-utils versionator

MY_PV="$(replace_version_separator 3 '-' )"
MY_PN="${PN}-project"
MY_P="${MY_PN}-${MY_PV}"

DESCRIPTION="Wiimotedev Project consists of wiimotedev daemon and Qt frontend for use with Wii remotes"
HOMEPAGE="http://code.google.com/p/wiimotedev/"
SRC_URI="http://wiimotedev.googlecode.com/files/${MY_P}.tar.xz"

LICENSE="LGPL-2.1"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="examples"

RDEPEND="x11-libs/qt-gui:4
	x11-libs/qt-dbus:4
	x11-libs/qt-opengl:4
	net-wireless/bluez
	>=app-misc/cwiid-20110107-r1"
DEPEND="${RDEPEND}"

S="${WORKDIR}/${MY_PN}"

DOCS=( CHANGELOG README )

src_prepare() {
	sed -i -e "s@opts@extra_started_commands@" init.d/gentoo/wiimotedev-daemon || die 'sed on init.d/gentoo/wiimotedev-daemon failed'
}

src_configure() {
	local mycmakeargs=(
		-DDISTRO=gentoo \
		-DUSE_STATIC_CWIID=OFF \
		$(cmake-utils_use_build examples EXAMPLES)
	)
	cmake-utils_src_configure
}

pkg_postinst() {
	elog "Please see"
	elog "http://code.google.com/p/clementine-player/wiki/WiiRemotes"
	elog "about instructions for use with media-sound/clementine"
}