summaryrefslogtreecommitdiff
blob: 7a8c6ca52d4abd1497f8f938d8326882238dd5a6 (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
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="2"
inherit eutils multilib

MY_P="${PN}-v${PV}"

DESCRIPTION="Enable compiling code and loading it on ATI/AMD GPU"
HOMEPAGE="http://developer.amd.com/GPU/ATISTREAMSDK/Pages/default.aspx"
SRC_URI=" \
	amd64? ( http://download2-developer.amd.com/amd/Stream20GA/${MY_P}-lnx64.tgz ) \
	x86? ( http://download2-developer.amd.com/amd/Stream20GA/${MY_P}-lnx32.tgz )"

LICENSE="AMD-OCL"
SLOT="0"
KEYWORDS=""
IUSE="examples doc multilib"
RESTRICT="strip fetch"
RDEPEND="media-libs/freeglut
	examples? ( media-libs/glew )
	x11-drivers/ati-drivers
	!dev-util/nvidia-cuda-sdk
	!dev-util/nvidia-cuda-toolkit"

QA_EXECSTACK="opt/${PN}/lib*/libatiocl??.so"

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

pkg_nofetch(){
	ewarn "Proprietary software. Download at"
	ewarn "http://developer.amd.com/gpu/AMDAPPSDK/downloads/Pages/default.aspx"
	ewarn "and move it to distfiles"
}

src_unpack(){
	default_src_unpack

	mv ${MY_P}-lnx* ${MY_P} || die
	cp "${FILESDIR}"/Makefile ${MY_P}/ || die
}

src_prepare(){
	if use examples; then
		sed -i -e 's/samples/examples/g'  make/openclsdkrules.mk make/openclsdkdefs.mk\
			|| die "Sed failed"
	fi
}

src_compile(){ true; }

src_install(){
	local DEST=/opt/${PN}
	local LIBDIR=

	rm include/GL/{glext.h,glut.h} || die

	if use amd64; then
		LIBDIR=x86_64
		emake DESTDIR="${D}" ARCH="amd64" install || die "Install failed";
		if use multilib; then
			emake DESTDIR="${D}" ARCH="x86" install-lib \
				|| die "Multilib install failed"
		fi
		insinto /etc/OpenCL/vendors
		doins "${FILESDIR}"/atiocl64.icd || die
	else
		LIBDIR=x86
		emake DESTDIR="${D}" ARCH="x86" install || die "Install failed";
		insinto /etc/OpenCL/vendors
		doins "${FILESDIR}"/atiocl32.icd || die
	fi

	cat > "${T}/99${PN}" << EOF
PATH=${DEST}/bin
ROOTPATH=${DEST}/bin
LDPATH=${DEST}/lib/${LIBDIR}
EOF
	doenvd "${T}/99${PN}" || die

	if use examples; then
		insinto ${DEST}/examples
		doins -r samples/* || die
		insinto ${DEST}
		doins -r make || die
	fi

	if use doc; then
		dodoc docs/opencl/* || die
	fi
}

pkg_postinst(){
	elog "If you want to be able to compile without passing"
	elog "-I /opt/ati-stream-sdk/include to gcc, please set"
	elog "C_INCLUDE_PATH and CPLUS_INCLUDE_PATH to that directory"
	elog
	elog "Also, if you do not want to pass -L /opt/ati-stream-sdk/lib/x86(_64)"
	elog "to gcc for every use of -lOpenCL, add that directory to"
	elog "LD_LIBRARY_PATH."
}