dev-util/nvidia-cuda-toolkit: x86 stable wrt bug #600036
[gentoo.git] / dev-util / nvidia-cuda-toolkit / nvidia-cuda-toolkit-6.5.14.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 inherit check-reqs cuda unpacker versionator
8
9 MYD=$(get_version_component_range 1)_$(get_version_component_range 2)
10
11 DESCRIPTION="NVIDIA CUDA Toolkit (compiler and friends)"
12 HOMEPAGE="http://developer.nvidia.com/cuda"
13 CURI="http://developer.download.nvidia.com/compute/cuda/${MYD}/rel/installers"
14 SRC_URI="
15         amd64? ( ${CURI}/cuda_${PV}_linux_64.run )
16         x86? ( ${CURI}/cuda_${PV}_linux_32.run )"
17
18 SLOT="0/${PV}"
19 LICENSE="NVIDIA-CUDA"
20 KEYWORDS="-* amd64 x86 ~amd64-linux ~x86-linux"
21 IUSE="debugger doc eclipse profiler"
22
23 DEPEND=""
24 RDEPEND="${DEPEND}
25         <sys-devel/gcc-4.9[cxx]
26         debugger? (
27                 sys-libs/libtermcap-compat
28                 sys-libs/ncurses[tinfo]
29                 )
30         eclipse? ( >=virtual/jre-1.6 )
31         profiler? ( >=virtual/jre-1.6 )
32         amd64? ( >=x11-drivers/nvidia-drivers-340.32[uvm] )
33         x86? ( <x11-drivers/nvidia-drivers-346.35[uvm] )
34         "
35
36 S="${WORKDIR}"
37
38 QA_PREBUILT="opt/cuda/*"
39
40 CHECKREQS_DISK_BUILD="1500M"
41
42 pkg_setup() {
43         # We don't like to run cuda_pkg_setup as it depends on us
44         check-reqs_pkg_setup
45
46         if use x86; then
47                 ewarn "Starting with version 6.5 NVIDIA dropped more and more"
48                 ewarn "the support for 32bit linux."
49                 ewarn "Be aware that bugfixes and new features may not be available."
50                 ewarn "https://dev.gentoo.org/~jlec/distfiles/CUDA_Toolkit_Release_Notes.pdf"
51         fi
52 }
53
54 src_unpack() {
55         unpacker
56         unpacker run_files/cuda-linux*.run
57 }
58
59 src_prepare() {
60         local cuda_supported_gcc
61
62         cuda_supported_gcc="4.7 4.8"
63
64         sed \
65                 -e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \
66                 "${FILESDIR}"/cuda-config.in > "${T}"/cuda-config || die
67 }
68
69 src_install() {
70         local i j
71         local remove="doc jre run_files install-linux.pl "
72         local cudadir=/opt/cuda
73         local ecudadir="${EPREFIX}"${cudadir}
74
75         # dodoc doc/*txt
76         if use doc; then
77                 dodoc doc/pdf/*
78                 dohtml -r doc/html/*
79         fi
80
81         if use amd64; then
82                 mv doc/man/man3/{,cuda-}deprecated.3 || die
83                 doman doc/man/man*/*
84         fi
85
86         use debugger || remove+=" bin/cuda-gdb extras/Debugger"
87         ( use profiler || use eclipse ) || remove+=" libnsight"
88         use amd64 || remove+=" cuda-installer.pl"
89
90         if use profiler; then
91                 # hack found in install-linux.pl
92                 for j in nvvp nsight; do
93                         cat > bin/${j} <<- EOF
94                                 #!${EPREFIX}/bin/sh
95                                 LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:${ecudadir}/lib:${ecudadir}/lib64 \
96                                         UBUNTU_MENUPROXY=0 LIBOVERLAY_SCROLLBAR=0 \
97                                         ${ecudadir}/lib${j}/${j} -vm ${EPREFIX}/usr/bin/java
98                         EOF
99                         chmod a+x bin/${j}
100                 done
101         else
102                 use eclipse || remove+=" libnvvp"
103                 remove+=" extras/CUPTI"
104         fi
105
106         for i in ${remove}; do
107         ebegin "Cleaning ${i}..."
108                 if [[ -e ${i} ]]; then
109                         find ${i} -delete || die
110                         eend
111                 else
112                         eend $1
113                 fi
114         done
115
116         dodir ${cudadir}
117         mv * "${ED}"${cudadir} || die
118
119         cat > "${T}"/99cuda <<- EOF
120                 PATH=${ecudadir}/bin$(use profiler && echo ":${ecudadir}/libnvvp")
121                 ROOTPATH=${ecudadir}/bin
122                 LDPATH=${ecudadir}/lib$(use amd64 && echo "64:${ecudadir}/lib")
123         EOF
124         doenvd "${T}"/99cuda
125
126         use profiler && \
127                 make_wrapper nvprof "${EPREFIX}"${cudadir}/bin/nvprof "." ${ecudadir}/lib$(use amd64 && echo "64:${ecudadir}/lib")
128
129         dobin "${T}"/cuda-config
130 }
131
132 pkg_postinst_check() {
133         local a b
134         a="$(version_sort $(cuda-config -s))"; a=( $a )
135         # greatest supported version
136         b=${a[${#a[@]}-1]}
137
138         # if gcc and if not gcc-version is at least greatesst supported
139         if [[ $(tc-getCC) == *gcc* ]] && \
140                 ! version_is_at_least $(gcc-version) ${b}; then
141                         echo
142                         ewarn "gcc >= ${b} will not work with CUDA"
143                         ewarn "Make sure you set an earlier version of gcc with gcc-config"
144                         ewarn "or append --compiler-bindir= pointing to a gcc bindir like"
145                         ewarn "--compiler-bindir=${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/gcc${b}"
146                         ewarn "to the nvcc compiler flags"
147                         echo
148         fi
149 }
150
151 pkg_postinst() {
152         if [[ ${MERGE_TYPE} != binary ]]; then
153                 pkg_postinst_check
154         fi
155 }