1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit check-reqs cuda unpacker versionator
9 MYD=$(get_version_component_range 1)_$(get_version_component_range 2)
11 DESCRIPTION="NVIDIA CUDA Toolkit (compiler and friends)"
12 HOMEPAGE="http://developer.nvidia.com/cuda"
13 SRC_URI="http://developer.download.nvidia.com/compute/cuda/${MYD}/Prod/local_installers/cuda_${PV}_linux.run"
17 KEYWORDS="-* ~amd64 ~amd64-linux"
18 IUSE="debugger doc eclipse profiler"
22 >=sys-devel/gcc-4.7[cxx]
23 >=x11-drivers/nvidia-drivers-346.35[uvm]
25 sys-libs/libtermcap-compat
26 sys-libs/ncurses[tinfo]
28 eclipse? ( >=virtual/jre-1.6 )
29 profiler? ( >=virtual/jre-1.6 )"
33 QA_PREBUILT="opt/cuda/*"
35 CHECKREQS_DISK_BUILD="1500M"
38 # We don't like to run cuda_pkg_setup as it depends on us
44 unpacker run_files/cuda-linux*.run
48 local cuda_supported_gcc
50 cuda_supported_gcc="4.7 4.8 4.9"
53 -e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \
54 "${FILESDIR}"/cuda-config.in > "${T}"/cuda-config || die
59 local remove="doc jre run_files install-linux.pl "
60 local cudadir=/opt/cuda
61 local ecudadir="${EPREFIX}"${cudadir}
69 mv doc/man/man3/{,cuda-}deprecated.3 || die
72 use debugger || remove+=" bin/cuda-gdb extras/Debugger"
73 ( use profiler || use eclipse ) || remove+=" libnsight"
74 remove+=" cuda-installer.pl"
77 # hack found in install-linux.pl
78 for j in nvvp nsight; do
79 cat > bin/${j} <<- EOF
81 LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:${ecudadir}/lib:${ecudadir}/lib64 \
82 UBUNTU_MENUPROXY=0 LIBOVERLAY_SCROLLBAR=0 \
83 ${ecudadir}/lib${j}/${j} -vm ${EPREFIX}/usr/bin/java
88 use eclipse || remove+=" libnvvp"
89 remove+=" extras/CUPTI"
92 for i in ${remove}; do
93 ebegin "Cleaning ${i}..."
94 if [[ -e ${i} ]]; then
95 find ${i} -delete || die
102 ln -sf lib lib32 || die
105 mv * "${ED}"${cudadir} || die
107 cat > "${T}"/99cuda <<- EOF
108 PATH=${ecudadir}/bin$(use profiler && echo ":${ecudadir}/libnvvp")
109 ROOTPATH=${ecudadir}/bin
110 LDPATH=${ecudadir}/lib64:${ecudadir}/lib
115 make_wrapper nvprof "${EPREFIX}"${cudadir}/bin/nvprof "." ${ecudadir}/lib64:${ecudadir}/lib
117 dobin "${T}"/cuda-config
120 pkg_postinst_check() {
122 a="$(version_sort $(cuda-config -s))"; a=( $a )
123 # greatest supported version
126 # if gcc and if not gcc-version is at least greatesst supported
127 if [[ $(tc-getCC) == *gcc* ]] && \
128 ! version_is_at_least $(gcc-version) ${b}; then
130 ewarn "gcc >= ${b} will not work with CUDA"
131 ewarn "Make sure you set an earlier version of gcc with gcc-config"
132 ewarn "or append --compiler-bindir= pointing to a gcc bindir like"
133 ewarn "--compiler-bindir=${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/gcc${b}"
134 ewarn "to the nvcc compiler flags"
140 if [[ ${MERGE_TYPE} != binary ]]; then