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.download.nvidia.com/compute/cuda/${MYD}/Prod/local_installers/cuda_${PV}_${DRIVER_PV}_linux.run"
17 KEYWORDS="-* ~amd64 ~amd64-linux"
18 IUSE="debugger doc eclipse profiler"
19 RESTRICT="bindist mirror"
24 !prefix? ( >=x11-drivers/nvidia-drivers-${DRIVER_PV}[X,uvm] )
26 dev-libs/openssl-compat:1.0.0
27 sys-libs/libtermcap-compat
28 sys-libs/ncurses-compat:5[tinfo]
31 dev-libs/openssl-compat:1.0.0
35 dev-libs/openssl-compat:1.0.0
41 QA_PREBUILT="opt/cuda/*"
43 CHECKREQS_DISK_BUILD="6800M"
46 # We don't like to run cuda_pkg_setup as it depends on us
51 local cuda_supported_gcc
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"
56 -e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \
57 "${FILESDIR}"/cuda-config.in > "${T}"/cuda-config || die
63 local i remove=( doc )
64 local cudadir=/opt/cuda
65 local ecudadir="${EPREFIX}${cudadir}"
67 cd builds/cuda-toolkit
70 HTML_DOCS+=( doc/html/. )
74 mv doc/man/man3/{,cuda-}deprecated.3 || die
77 use debugger || remove+=( bin/cuda-gdb bin/cuda-gdbserver extras/Debugger share/gdb extras/cuda-gdb-${PV}.src.tar.gz )
80 # hack found in install-linux.pl
81 for i in nvvp nsight; do
82 cat > bin/${i} <<- EOF || die
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
88 chmod a+x bin/${i} || die
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 )
95 for i in "${remove[@]}"; do
96 ebegin "Cleaning ${i}..."
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%/*}
111 exeinto ${cudadir}/bin
112 doexe "${T}"/cuda-config
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
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"
131 pkg_postinst_check() {
133 a="$(${EROOT}/opt/cuda/bin/cuda-config -s)"
136 if ver_test "${v}" -gt "${b}"; then
141 # if gcc and if not gcc-version is at least greatest supported
143 ver_test $(gcc-version) -gt ${b}; then
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"
155 if [[ ${MERGE_TYPE} != binary ]]; 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"