1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit check-reqs cuda toolchain-funcs unpacker
8 MYD=$(ver_cut 1-2 ${PV})
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"
17 KEYWORDS="-* ~amd64 ~amd64-linux"
18 IUSE="debugger doc eclipse profiler"
23 >=x11-drivers/nvidia-drivers-396.24[X,uvm]
25 sys-libs/libtermcap-compat
26 sys-libs/ncurses-compat:5[tinfo]
28 eclipse? ( >=virtual/jre-1.6 )
29 profiler? ( >=virtual/jre-1.6 )"
33 QA_PREBUILT="opt/cuda/*"
35 CHECKREQS_DISK_BUILD="6100M"
38 # We don't like to run cuda_pkg_setup as it depends on us
43 local cuda_supported_gcc
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"
48 -e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \
49 "${FILESDIR}"/cuda-config.in > "${T}"/cuda-config || die
55 local i remove=( doc jre run_files install-linux.pl cuda-installer.pl )
56 local cudadir=/opt/cuda
57 local ecudadir="${EPREFIX}${cudadir}"
59 cd builds/cuda-toolkit
62 HTML_DOCS+=( doc/html/. )
66 mv doc/man/man3/{,cuda-}deprecated.3 || die
69 use debugger || remove+=( bin/cuda-gdb bin/cuda-gdbserver extras/Debugger share/gdb extras/cuda-gdb-${PV}.src.tar.gz )
72 # hack found in install-linux.pl
73 for i in nvvp nsight; do
74 cat > bin/${i} <<- EOF || die
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
80 chmod a+x bin/${i} || die
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 )
87 for i in "${remove[@]}"; do
88 ebegin "Cleaning ${i}..."
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%/*}
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
116 make_wrapper nvprof "${ecudadir}/bin/nvprof" "." "${ecudadir}/lib64:${ecudadir}/lib"
118 dobin "${T}"/cuda-config
121 pkg_postinst_check() {
123 a="$(${EROOT}/opt/cuda/bin/cuda-config -s)"
126 if ver_test "${v}" -gt "${b}"; then
131 # if gcc and if not gcc-version is at least greatest supported
133 ver_test $(gcc-version) -gt ${b}; then
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"
145 if [[ ${MERGE_TYPE} != binary ]]; then