summaryrefslogtreecommitdiff
blob: 1a0fedaef047d87f1ae09bb1a5a4200b5dd28ccf (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-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=4

inherit eutils toolchain-funcs

MY_PN=AMD-APP-SDK
MY_PV=v${PV}
MY_P=${MY_PN}-${MY_PV}

DESCRIPTION="AMD Accelerated Parallel Processing (APP) SDK (formerly ATI Stream)"
HOMEPAGE="http://developer.amd.com/sdks/amdappsdk/pages/default.aspx"

SRC_URI="amd64? ( http://developer.amd.com/Downloads/${MY_P}-lnx64.tgz )
	x86? ( http://developer.amd.com/Downloads/${MY_P}-lnx32.tgz )"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64"
IUSE="examples"

DEPEND="examples? ( app-admin/eselect-opengl
		sys-devel/llvm
		media-libs/mesa
		|| ( dev-util/opencl-headers dev-util/nvidia-cuda-toolkit )
		media-libs/glew
		media-libs/freeglut )"
RDEPEND="${DEPEND}"

S=${WORKDIR}

RESTRICT="mirror"
QA_PREBUILT="opt/AMDAPP/lib/*
	opt/AMDAPP/bin/clinfo"

pkg_setup() {
	if [[ $(tc-arch) == 'x86' ]] ; then
		bitness=32
		_arch=x86
	else
		bitness=64
		_arch=x86_64
	fi
	export bitness
	export _arch
	export MY_S=${MY_P}-RC3-lnx${bitness}
}

src_unpack() {
	default_src_unpack
	unpack ./${MY_S}.tgz ./icd-registration.tgz
}

src_prepare() {
	local _ddir=/opt/AMDAPP
	cat <<-EOF > 99${PN}
		PATH=${_ddir}/bin
		LDPATH=${_ddir}/lib
	EOF

	if use examples ; then
		pushd ${MY_S} &> /dev/null
		epatch "${FILESDIR}"/${P}-x11.patch
		sed -i make/openclsdkdefs.mk \
			-e "s/g++/$(tc-getCXX)/" \
			-e "/C_DEBUG_FLAG/d" || die
		popd &> /dev/null
	fi
}

src_compile() {
	use examples || return
	emake -C ${MY_S}
}

src_install() {
	doenvd 99${PN}
	doins -r etc

	#Install SDK
	pushd ${MY_S} &> /dev/null
	insinto /opt/AMDAPP
	doins -r {glut_notice.txt,docs,include}

	insinto /opt/AMDAPP/bin
	doins bin/${_arch}/clinfo

	insinto /opt/AMDAPP/lib
	doins lib/*.so lib/${_arch}/*

	# fix perms
	fperms 755 /opt/AMDAPP/bin/clinfo

	#TODO: install examples

	#Env vars
	#mkdir -p ${D}/etc/profile.d
	#cd ${D}/etc/profile.d
	#echo "#!/bin/sh" > amdstream.sh
	#echo "export AMDAPPSDKROOT=${_installdir}" >> amdstream.sh
	#echo "export AMDAPPSDKSAMPLESROOT=${_installdir}" >> amdstream.sh

	##More docs and export
	#echo "AMDSTREAMSDKROOT=${_installdir}/" >> ${D}/etc/env.d/99amdstream
	#echo "AMDSTREAMSDKSAMPLEROOT=${_installdir}/" >> ${D}/etc/env.d/99amdstream
	#echo "LIBRARY_PATH=${_installdir}/lib/x86_64" >> ${D}/etc/env.d/99amdstream
}