sys-block/zram-init: bump to 9.1 and fix push.sh reference
[gentoo.git] / dev-util / nvidia-cuda-toolkit / nvidia-cuda-toolkit-10.1.243-r2.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit check-reqs cuda toolchain-funcs unpacker
7
8 MYD=$(ver_cut 1-2 ${PV})
9 DRIVER_PV="418.87.00"
10
11 DESCRIPTION="NVIDIA CUDA Toolkit (compiler and friends)"
12 HOMEPAGE="https://developer.nvidia.com/cuda-zone"
13 SRC_URI="https://developer.download.nvidia.com/compute/cuda/${MYD}/Prod/local_installers/cuda_${PV}_${DRIVER_PV}_linux.run"
14
15 LICENSE="NVIDIA-CUDA"
16 SLOT="0/${PV}"
17 KEYWORDS="-* ~amd64 ~amd64-linux"
18 IUSE="debugger doc eclipse profiler"
19 RESTRICT="bindist mirror"
20
21 BDEPEND=""
22 RDEPEND="
23         <sys-devel/gcc-9[cxx]
24         !prefix? ( >=x11-drivers/nvidia-drivers-${DRIVER_PV}[X,uvm] )
25         debugger? (
26                 dev-libs/openssl-compat:1.0.0
27                 sys-libs/libtermcap-compat
28                 sys-libs/ncurses-compat:5[tinfo]
29         )
30         eclipse? (
31                 dev-libs/openssl-compat:1.0.0
32                 >=virtual/jre-1.6
33         )
34         profiler? (
35                 dev-libs/openssl-compat:1.0.0
36                 >=virtual/jre-1.6
37         )"
38
39 S="${WORKDIR}"
40
41 QA_PREBUILT="opt/cuda/*"
42
43 CHECKREQS_DISK_BUILD="6800M"
44
45 pkg_setup() {
46         # We don't like to run cuda_pkg_setup as it depends on us
47         check-reqs_pkg_setup
48 }
49
50 src_prepare() {
51         local cuda_supported_gcc
52
53         cuda_supported_gcc="4.7 4.8 4.9 5.3 5.4 6.3 6.4 7.2 7.3 8.2 8.3"
54
55         sed \
56                 -e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \
57                 "${FILESDIR}"/cuda-config.in > "${T}"/cuda-config || die
58
59         default
60 }
61
62 src_install() {
63         local i remove=( doc )
64         local cudadir=/opt/cuda
65         local ecudadir="${EPREFIX}${cudadir}"
66
67         cd builds/cuda-toolkit
68         if use doc; then
69                 DOCS+=( doc/pdf/. )
70                 HTML_DOCS+=( doc/html/. )
71         fi
72         einstalldocs
73
74         mv doc/man/man3/{,cuda-}deprecated.3 || die
75         doman doc/man/man*/*
76
77         use debugger || remove+=( bin/cuda-gdb bin/cuda-gdbserver extras/Debugger share/gdb extras/cuda-gdb-${PV}.src.tar.gz )
78
79         if use profiler; then
80                 # hack found in install-linux.pl
81                 for i in nvvp nsight; do
82                         cat > bin/${i} <<- EOF || die
83                                 #!/usr/bin/env sh
84                                 LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:${ecudadir}/lib:${ecudadir}/lib64 \
85                                         UBUNTU_MENUPROXY=0 LIBOVERLAY_SCROLLBAR=0 \
86                                         ${ecudadir}/lib${i}/${i} -vm ${EPREFIX}/usr/bin/java
87                         EOF
88                         chmod a+x bin/${i} || die
89                 done
90         else
91                 use eclipse || remove+=( libnvvp libnsight nsightee_plugins nsight-compute-2019.4.0 nsight-systems-2019.3.7.5 bin/nsight bin/nsight_ee_plugins_manage.sh bin/nvvp bin/computeprof )
92                 remove+=( extras/CUPTI bin/nvprof )
93         fi
94
95         for i in "${remove[@]}"; do
96                 ebegin "Cleaning ${i}..."
97                 rm -r "${i}" || die
98                 eend
99         done
100
101         dodir ${cudadir}
102         into ${cudadir}
103
104         # Install binaries separately to make sure the X permission is set
105         local bindirs=( bin nvvm/bin extras/demo_suite $(usex profiler "libnsight/nsight") )
106         for i in $(find "${bindirs[@]}" -maxdepth 1 -type f); do
107                 exeinto ${cudadir}/${i%/*}
108                 doexe ${i}
109                 rm ${i} || die
110         done
111         exeinto ${cudadir}/bin
112         doexe "${T}"/cuda-config
113
114         # Install the rest
115         insinto ${cudadir}
116         doins -r *
117
118         cat > "${T}"/99cuda <<- EOF || die
119                 PATH=${ecudadir}/bin$(usex profiler ":${ecudadir}/libnvvp" "")
120                 ROOTPATH=${ecudadir}/bin
121                 LDPATH=${ecudadir}/lib64:${ecudadir}/lib:${ecudadir}/nvvm/lib64
122         EOF
123         doenvd "${T}"/99cuda
124
125         #Cuda prepackages libraries, don't revdep-build on them
126         echo "SEARCH_DIRS_MASK=\"${ecudadir}\"" > "${T}/80${PN}" || die
127         insinto "/etc/revdep-rebuild"
128         doins "${T}/80${PN}"
129 }
130
131 pkg_postinst_check() {
132         local a b
133         a="$(${EROOT}/opt/cuda/bin/cuda-config -s)"
134         b="0.0"
135         for v in $a; do
136                 if ver_test "${v}" -gt "${b}"; then
137                         b="${v}"
138                 fi
139         done
140
141         # if gcc and if not gcc-version is at least greatest supported
142         if tc-is-gcc && \
143                 ver_test $(gcc-version) -gt ${b}; then
144                         ewarn ""
145                         ewarn "gcc > ${b} will not work with CUDA"
146                         ewarn "Make sure you set an earlier version of gcc with gcc-config"
147                         ewarn "or append --compiler-bindir= pointing to a gcc bindir like"
148                         ewarn "--compiler-bindir=${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/gcc${b}"
149                         ewarn "to the nvcc compiler flags"
150                         ewarn ""
151         fi
152 }
153
154 pkg_postinst() {
155         if [[ ${MERGE_TYPE} != binary ]]; then
156                 pkg_postinst_check
157         fi
158
159         if use prefix; then
160                 ewarn "Gentoo Prefix does not manage kernel modules.  You need to make certain"
161                 ewarn "the function counterpart to >=x11-drivers/nvidia-drivers-${DRIVER_PV}[X,uvm]"
162                 ewarn "is available from the host"
163         fi
164 }