summaryrefslogtreecommitdiff
blob: 2fed6ceaa21aabd6c8119a9afc42cbaa42771412 (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
# 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 GPL-1 as-is"
SLOT="0"
KEYWORDS=""
IUSE="examples doc multilib"
RESTRICT="strip fetch"
RDEPEND="media-libs/freeglut
	x11-drivers/ati-drivers
	examples? ( media-libs/glew )"

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"
#		sed -i \
#			-e "/OPENCL_LIBDIRS/{s|lib/\$(CPU_ARCH)|$(get_libdir)|}" \
#			-e "s|\$(DEPTH)/lib/\$(CPU_ARCH)|\$(DEPTH)/$(get_libdir)|" \
#			-e "/CAL_LIBDIRS/{s|lib|$(get_libdir)|}" \
#			make/openclsdkdefs.mk || die "Sed failed"
	fi
}

src_compile() { true; }

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

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

	if use amd64; then
		#emake DESTDIR="${D}" ARCH="amd64" LIBDIR='$(PREFIX)/'$(get_libdir) install || die "Install failed";
		emake DESTDIR="${D}" ARCH="amd64" install || die "Install failed";
		#if use multilib; then
		#	emake DESTDIR="${D}" ARCH="x86" LIBDIR='$(PREFIX)/lib32' \
		#		install-lib || die "Install multilib failed"
		#fi
	else
		emake DESTDIR="${D}" ARCH="x86" LIBDIR='$(PREFIX)/'$(get_libdir) install || die "Install failed";
	fi

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

	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/*
	fi
}