summaryrefslogtreecommitdiff
blob: dbb04d56495274bf35d82cde60e6062b1529a1c0 (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-4.0.ebuild,v 1.7 2011/09/04 10:08:12 maekke Exp $

EAPI=2

inherit eutils multilib

DESCRIPTION="NVIDIA CUDA Toolkit"
HOMEPAGE="http://developer.nvidia.com/cuda"
RESTRICT="binchecks"

CUDA_V=${PV//_/-}
DIR_V=${CUDA_V//./_}
DIR_V=${DIR_V//beta/Beta}

BASE_URI="http://developer.download.nvidia.com/compute/cuda/${DIR_V}/toolkit"
SRC_URI="amd64? ( ${BASE_URI}/cudatoolkit_${CUDA_V}.17_linux_64_ubuntu10.10.run )
	x86? ( ${BASE_URI}/cudatoolkit_${CUDA_V}.17_linux_32_ubuntu10.10.run )"

LICENSE="NVIDIA"
SLOT="0"
KEYWORDS="amd64 x86"
IUSE="debugger doc profiler"

RDEPEND="${DEPEND}
	>=sys-devel/binutils-2.20
	sys-devel/gcc:4.4
	profiler? ( x86? (
		x11-libs/qt-gui
		x11-libs/qt-core
		x11-libs/qt-assistant[compat]
		x11-libs/qt-sql[sqlite] )
		media-libs/libpng:1.2
	)
	debugger? ( >=sys-libs/libtermcap-compat-2.0.8-r2 )
	!<=x11-drivers/nvidia-drivers-270.41"

S="${WORKDIR}"

#QA_DT_HASH_x86="opt/cuda/.*"
#QA_DT_HASH_amd64="opt/cuda/.*"

src_unpack() {
	for f in ${A} ; do
		if [ "${f//*.run/}" == "" ]; then
			unpack_makeself ${f}
		fi
	done
}

src_install() {
	local DEST=/opt/cuda

	into ${DEST}
	dobin bin/*
	dolib $(get_libdir)/*

	if ! use debugger; then
		rm -f "${D}/${DEST}/bin/cuda-gdb"
	fi

	chmod a-x "${D}/${DEST}/bin/nvcc.profile"

	# TODO: Manuals are missing from this release. Remove the following
	# commented-out lines if they are not restored in the next releases.
	# doman does not respect DESTTREE
	#insinto ${DEST}/man/man1
	#doins man/man1/*
	#insinto ${DEST}/man/man3
	#doins man/man3/*
	#prepman ${DEST}

	insinto ${DEST}/include
	doins -r include/*

	insinto ${DEST}/src
	doins src/*

	if use doc ; then
		insinto ${DEST}/doc
		doins -r doc/*
	fi

	cat > "${T}/env" << EOF
PATH=${DEST}/bin
ROOTPATH=${DEST}/bin
LDPATH=${DEST}/$(get_libdir)
MANPATH=${DEST}/man
EOF
	newenvd "${T}/env" 99cuda

	if use profiler; then
		local target="computeprof"

		into ${DEST}/${target}
		dobin ${target}/bin/${target}

		cat > "${T}/env" << EOF
PATH=${DEST}/${target}/bin
ROOTPATH=${DEST}/${target}/bin
EOF
		if use x86 ; then
			dosym /usr/bin/assistant ${DEST}/${target}/bin

			insinto ${DEST}/${target}/bin
			doins ${target}/bin/cudaapitrace32.so
		else
			dobin ${target}/bin/assistant
			insinto ${DEST}/${target}/bin
			doins ${target}/bin/*.so.?.?.?
			for f in ${target}/bin/*.so.?; do
				dosym $(readlink ${f}) ${DEST}/${f}
			done
			insinto ${DEST}/${target}/bin/sqldrivers
			doins ${target}/bin/sqldrivers/*

			cat >> "${T}/env" << EOF
LDPATH=${DEST}/${target}/bin
EOF
		fi

		newenvd "${T}/env" 99${target}

		if use doc; then
			insinto ${DEST}/${target}
			doins ${target}/*.txt
			insinto ${DEST}/${target}/doc
			doins ${target}/doc/*
			insinto ${DEST}/${target}/projects
			doins ${target}/projects/*
		fi

		make_desktop_entry /opt/cuda/computeprof/bin/computeprof "NVIDIA Compute Visual Profiler"
	fi

	export CONF_LIBDIR_OVERRIDE="lib"
	# HACK: temporary workaround until CONF_LIBDIR_OVERRIDE is respected.
	export LIBDIR_amd64="lib"

	into ${DEST}/open64
	dobin open64/bin/*
	libopts -m0755
	dolib open64/lib/*

	# TODO: ideally, there would be multiple OpenCL implementations available in
	# the tree and an eselect module would allow to switch between them.
	into /
	dosym /opt/cuda/include/CL usr/include/CL
}

pkg_postinst() {
	env-update
	elog "If you want to natively run the code generated by this version of the"
	elog "CUDA toolkit, you will need >=x11-drivers/nvidia-drivers-260.19.21."
	elog ""
	elog "Run '. /etc/profile' before using the CUDA toolkit. "
}