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.105-r1.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.39"
10
11 DESCRIPTION="NVIDIA CUDA Toolkit (compiler and friends)"
12 HOMEPAGE="https://developer.nvidia.com/cuda-zone"
13 SRC_URI="https://developer.nvidia.com/compute/cuda/${MYD}/Prod/local_installers/cuda_${PV}_${DRIVER_PV}_linux.run -> 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
20 DEPEND=""
21 RDEPEND="${DEPEND}
22         <sys-devel/gcc-9[cxx]
23         >=x11-drivers/nvidia-drivers-396.24[X,uvm]
24         debugger? (
25                 sys-libs/libtermcap-compat
26                 sys-libs/ncurses-compat:5[tinfo]
27                 )
28         eclipse? ( >=virtual/jre-1.6 )
29         profiler? ( >=virtual/jre-1.6 )"
30
31 S="${WORKDIR}"
32
33 QA_PREBUILT="opt/cuda/*"
34
35 CHECKREQS_DISK_BUILD="6100M"
36
37 pkg_setup() {
38         # We don't like to run cuda_pkg_setup as it depends on us
39         check-reqs_pkg_setup
40 }
41
42 src_prepare() {
43         local cuda_supported_gcc
44
45         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"
46
47         sed \
48                 -e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \
49                 "${FILESDIR}"/cuda-config.in > "${T}"/cuda-config || die
50
51         default
52 }
53
54 src_install() {
55         local i remove=( doc jre run_files install-linux.pl cuda-installer.pl )
56         local cudadir=/opt/cuda
57         local ecudadir="${EPREFIX}${cudadir}"
58
59         cd builds/cuda-toolkit
60         if use doc; then
61                 DOCS+=( doc/pdf/. )
62                 HTML_DOCS+=( doc/html/. )
63         fi
64         einstalldocs
65
66         mv doc/man/man3/{,cuda-}deprecated.3 || die
67         doman doc/man/man*/*
68
69         use debugger || remove+=( bin/cuda-gdb bin/cuda-gdbserver extras/Debugger share/gdb extras/cuda-gdb-${PV}.src.tar.gz )
70
71         if use profiler; then
72                 # hack found in install-linux.pl
73                 for i in nvvp nsight; do
74                         cat > bin/${i} <<- EOF || die
75                                 #!/usr/bin/env sh
76                                 LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:${ecudadir}/lib:${ecudadir}/lib64 \
77                                         UBUNTU_MENUPROXY=0 LIBOVERLAY_SCROLLBAR=0 \
78                                         ${ecudadir}/lib${i}/${i} -vm ${EPREFIX}/usr/bin/java
79                         EOF
80                         chmod a+x bin/${i} || die
81                 done
82         else
83                 use eclipse || remove+=( libnvvp libnsight nsightee_plugins NsightCompute-2019.1 NsightSystems-2018.3 bin/nsight bin/nsight_ee_plugins_manage.sh bin/nvvp bin/computeprof )
84                 remove+=( extras/CUPTI bin/nvprof )
85         fi
86
87         for i in "${remove[@]}"; do
88                 ebegin "Cleaning ${i}..."
89                 rm -rf "${i}" || die
90                 eend
91         done
92
93         dodir ${cudadir}
94         into ${cudadir}
95
96         # Install binaries separately to make sure the X permission is set
97         local bindirs=( bin nvvm/bin extras/demo_suite )
98         for i in $(find "${bindirs[@]}" -maxdepth 1 -type f); do
99                 exeinto ${cudadir}/${i%/*}
100                 doexe ${i}
101                 rm ${i} || die
102         done
103
104         # Install the rest
105         insinto ${cudadir}
106         doins -r *
107
108         cat > "${T}"/99cuda <<- EOF || die
109                 PATH=${ecudadir}/bin$(usex profiler ":${ecudadir}/libnvvp" "")
110                 ROOTPATH=${ecudadir}/bin
111                 LDPATH=${ecudadir}/lib64:${ecudadir}/lib:${ecudadir}/nvvm/lib64
112         EOF
113         doenvd "${T}"/99cuda
114
115         use profiler && \
116                 make_wrapper nvprof "${ecudadir}/bin/nvprof" "." "${ecudadir}/lib64:${ecudadir}/lib"
117
118         dobin "${T}"/cuda-config
119 }
120
121 pkg_postinst_check() {
122         local a b
123         a="$(${EROOT}/opt/cuda/bin/cuda-config -s)"
124         b="0.0"
125         for v in $a; do
126                 if ver_test "${v}" -gt "${b}"; then
127                         b="${v}"
128                 fi
129         done
130
131         # if gcc and if not gcc-version is at least greatest supported
132         if tc-is-gcc && \
133                 ver_test $(gcc-version) -gt ${b}; then
134                         ewarn ""
135                         ewarn "gcc >= ${b} will not work with CUDA"
136                         ewarn "Make sure you set an earlier version of gcc with gcc-config"
137                         ewarn "or append --compiler-bindir= pointing to a gcc bindir like"
138                         ewarn "--compiler-bindir=${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/gcc${b}"
139                         ewarn "to the nvcc compiler flags"
140                         ewarn ""
141         fi
142 }
143
144 pkg_postinst() {
145         if [[ ${MERGE_TYPE} != binary ]]; then
146                 pkg_postinst_check
147         fi
148 }