summaryrefslogtreecommitdiff
blob: 53e475af225e92de1e6858c7f0666fa56c2843a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="4"
PYTHON_DEPEND="python? 2:2.6"

inherit cmake-utils multilib python

DESCRIPTION="Drivers and libraries for the Xbox Kinect device"
HOMEPAGE="https://github.com/OpenKinect/libfreenect"
SRC_URI="https://github.com/OpenKinect/${PN}/tarball/v${PV} -> ${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="c_sync examples fakenect opencv python"
REQUIRED_USE="opencv? ( c_sync )
	python? ( c_sync )"

RDEPEND="dev-libs/libusb:1
	examples? (
		media-libs/freeglut
		virtual/opengl
	)
	opencv? ( media-libs/opencv )
	python? ( dev-python/numpy )"
DEPEND="${RDEPEND}
	dev-util/pkgconfig"

src_unpack() {
	unpack ${A}
	mv OpenKinect-${PN}-* ${P} || die
}

pkg_setup() {
	if use python; then
		python_set_active_version 2
		python_pkg_setup
	fi
}

src_configure() {
	local mycmakeargs=(
		$(cmake-utils_use_build c_sync)
		$(cmake-utils_use_build examples)
		$(cmake-utils_use_build examples CPP)
		$(cmake-utils_use_build fakenect)
		$(cmake-utils_use_build opencv CV)
		$(cmake-utils_use_build python)
	)
	if use python; then
		#Add numpy core include path in python CMakeList.txt to allow compilation
		sed -i -e "s|../c_sync/|$(python_get_sitedir)/numpy/core/include/ ../c_sync/|" "wrappers/python/CMakeLists.txt" || die
	fi
	cmake-utils_src_configure
}

src_install() {
	cmake-utils_src_install
	# Rename record example so it does not collide with xawtv
	if use examples && use fakenect; then
		mv "${D}"/usr/bin/record "${D}"/usr/bin/frecord || die
	fi
	# Remove cvdemo if examples is not enabled
	if use opencv && ! use examples; then
		rm -f "${D}"/usr/bin/cvdemo || die
	fi
	insinto /$(get_libdir)/udev/rules.d/
	doins "${FILESDIR}/51-kinect.rules"
}

pkg_postinst() {
	elog "Make sure your user is in the 'video' group"
	elog "Just run 'gpasswd -a <USER> video', then have <USER> re-login."
}