summaryrefslogtreecommitdiff
blob: 5bb6e7d9d2620b3a6641547f5590bbb4dcf1086a (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# Copyright 2008-2012 Funtoo Technologies
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=4

inherit base eutils python

DESCRIPTION="A 3D game engine and framework for Python and C++."
HOMEPAGE="http://www.panda3d.org"
SRC_URI="http://www.panda3d.org/download/${P}/${P}.tar.gz"

LICENSE="Panda3D"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="artoolkit bullet doc eigen ffmpeg fftw fmod jpeg openal opencv png python ssl tiff truetype zlib"

DEPEND="
	artoolkit? ( media-libs/artoolkit )
	bullet? ( sci-physics/bullet )
	doc? ( dev-python/epydoc )
	eigen? ( dev-cpp/eigen:3 )
	ffmpeg? ( media-video/ffmpeg )
	fftw? ( sci-libs/fftw:2.1 )
	fmod? ( media-libs/fmod )
	jpeg? ( virtual/jpeg )
	openal? ( media-libs/openal )
	opencv? ( media-libs/opencv )
	png? ( media-libs/libpng )
	python? ( dev-lang/python )
	ssl? ( dev-libs/openssl )
	tiff? ( media-libs/tiff )
	truetype? ( media-libs/freetype )
	zlib? ( sys-libs/zlib )
	virtual/opengl"
RDEPEND="${DEPEND}"

PATCHES=(
    "${FILESDIR}/${P}-pkgconfig.patch"
)

use_no() {
	local UWORD="$2"
	if [ -z "${UWORD}" ]; then
		UWORD="$1"
	fi

	if use $1 ; then
		echo "--use-${UWORD}"
	else
		echo "--no-${UWORD}"
	fi
}

src_compile() {
	./makepanda/makepanda.py \
		$(use_no artoolkit) \
		$(use_no bullet) \
		$(use_no eigen) \
		$(use_no ffmpeg) \
		$(use_no fftw) \
		$(use_no fmod) \
		$(use_no jpeg) \
		$(use_no png) \
		$(use_no openal) \
		$(use_no opencv) \
		$(use_no python) \
		$(use_no ssl openssl) \
		$(use_no tiff) \
		$(use_no truetype freetype) \
		$(use_no zlib) \
		--no-fcollada \
		--no-gles \
		--no-gles2 \
		--no-osmesa \
		--no-ode \
		--no-rocket \
		--no-squish \
		--no-vrpn \
		|| die "build failed"
}

src_install() {
	dodir /opt/panda3d

	doenvd "${FILESDIR}"/50panda3d
	sed -i -e "s:lib:$(get_libdir):g" \
		"${D}"/etc/env.d/50panda3d \
		|| die "libdir patching failed"

	if use doc; then
		cp -R "${S}"/samples "${S}"/built
		cp -R "${S}"/direct/src "${S}"/built/direct/src
		cd "${S}"/built
	fi

	if use python ; then
		# python installation
		dodir $(python_get_sitedir)
		cat <<- EOF > "${D}"$(python_get_sitedir)/panda3d.pth
		# This document sets up paths for python to access the
		# panda3d modules
		/opt/panda3d
		/opt/panda3d/lib
		/opt/panda3d/direct
		/opt/panda3d/pandac
		/opt/panda3d/built
		/opt/panda3d/built/$(get_libdir)
		EOF
	fi

	cp -R "${S}"/direct/src "${S}"/built/direct/
	cp -R "${S}"/built/* "${D}"/opt/panda3d
}

pkg_postinst()
{
	elog "Panda3D is installed in /opt/panda3d"
	elog
	if use doc ; then
		elog "Documentation is installed in /opt/panda3d/doc"
		elog "Samples are installed in /opt/panda3d/samples"
	fi
	elog "For C++ compiling, include directory must be set:"
	elog "g++ -I/opt/panda3d/include [other flags]"
	elog
	elog "Tutorials available at http://panda3d.org"
}