summaryrefslogtreecommitdiff
blob: 8cc88d0ab14fa6a63627a782d86c3e4442307619 (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
# 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"
QA_DT_HASH="/opt/ati-stream-sdk/lib/x86/libGLEW.so
	/opt/ati-stream-sdk/lib/x86_64/libGLEW.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 SUBDIR=

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

	if use amd64; then
		SUBDIR=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
		SUBDIR=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/${SUBDIR}
EOF
	doenvd "${T}/99${PN}" || die
	#Fix binary location issues that are only present in 2.1.
	#This location appears to be compiled into the library. Chaning
	#it does not appear to be feasable.
	dosym ${DEST}/bin ${DEST}/bin/${SUBDIR} || 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."
}