Use https by default
[gentoo.git] / dev-util / nvidia-cuda-toolkit / nvidia-cuda-toolkit-7.0.28.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 inherit check-reqs cuda unpacker versionator
8
9 MYD=$(get_version_component_range 1)_$(get_version_component_range 2)
10
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"
14
15 SLOT="0/${PV}"
16 LICENSE="NVIDIA-CUDA"
17 KEYWORDS="-* ~amd64 ~amd64-linux"
18 IUSE="debugger doc eclipse profiler"
19
20 DEPEND=""
21 RDEPEND="${DEPEND}
22         >=sys-devel/gcc-4.7[cxx]
23         >=x11-drivers/nvidia-drivers-346.35[uvm]
24         debugger? (
25                 sys-libs/libtermcap-compat
26                 sys-libs/ncurses[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="1500M"
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_unpack() {
43         unpacker
44         unpacker run_files/cuda-linux*.run
45 }
46
47 src_prepare() {
48         local cuda_supported_gcc
49
50         cuda_supported_gcc="4.7 4.8 4.9"
51
52         sed \
53                 -e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \
54                 "${FILESDIR}"/cuda-config.in > "${T}"/cuda-config || die
55 }
56
57 src_install() {
58         local i j
59         local remove="doc jre run_files install-linux.pl "
60         local cudadir=/opt/cuda
61         local ecudadir="${EPREFIX}"${cudadir}
62
63         # dodoc doc/*txt
64         if use doc; then
65                 dodoc doc/pdf/*
66                 dohtml -r doc/html/*
67         fi
68
69         mv doc/man/man3/{,cuda-}deprecated.3 || die
70         doman doc/man/man*/*
71
72         use debugger || remove+=" bin/cuda-gdb extras/Debugger"
73         ( use profiler || use eclipse ) || remove+=" libnsight"
74         remove+=" cuda-installer.pl"
75
76         if use profiler; then
77                 # hack found in install-linux.pl
78                 for j in nvvp nsight; do
79                         cat > bin/${j} <<- EOF
80                                 #!${EPREFIX}/bin/sh
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
84                         EOF
85                         chmod a+x bin/${j}
86                 done
87         else
88                 use eclipse || remove+=" libnvvp"
89                 remove+=" extras/CUPTI"
90         fi
91
92         for i in ${remove}; do
93         ebegin "Cleaning ${i}..."
94                 if [[ -e ${i} ]]; then
95                         find ${i} -delete || die
96                         eend
97                 else
98                         eend $1
99                 fi
100         done
101
102         ln -sf lib lib32 || die
103
104         dodir ${cudadir}
105         mv * "${ED}"${cudadir} || die
106
107         cat > "${T}"/99cuda <<- EOF
108                 PATH=${ecudadir}/bin$(use profiler && echo ":${ecudadir}/libnvvp")
109                 ROOTPATH=${ecudadir}/bin
110                 LDPATH=${ecudadir}/lib64:${ecudadir}/lib
111         EOF
112         doenvd "${T}"/99cuda
113
114         use profiler && \
115                 make_wrapper nvprof "${EPREFIX}"${cudadir}/bin/nvprof "." ${ecudadir}/lib64:${ecudadir}/lib
116
117         dobin "${T}"/cuda-config
118 }
119
120 pkg_postinst_check() {
121         local a b
122         a="$(version_sort $(cuda-config -s))"; a=( $a )
123         # greatest supported version
124         b=${a[${#a[@]}-1]}
125
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
129                         echo
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"
135                         echo
136         fi
137 }
138
139 pkg_postinst() {
140         if [[ ${MERGE_TYPE} != binary ]]; then
141                 pkg_postinst_check
142         fi
143 }