Gentoo Archives: gentoo-commits

From: Jeroen Roovers <jer@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: x11-drivers/nvidia-drivers/
Date: Mon, 29 May 2017 09:55:45
Message-Id: 1496051741.b7738dc018a6f1fbf6b8f2ad7323f2f31e7aed39.jer@gentoo
1 commit: b7738dc018a6f1fbf6b8f2ad7323f2f31e7aed39
2 Author: Jeroen Roovers <jer <AT> gentoo <DOT> org>
3 AuthorDate: Mon May 29 09:55:02 2017 +0000
4 Commit: Jeroen Roovers <jer <AT> gentoo <DOT> org>
5 CommitDate: Mon May 29 09:55:41 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b7738dc0
7
8 x11-drivers/nvidia-drivers: Decompress manpage files (bug #619976).
9
10 Package-Manager: Portage-2.3.6, Repoman-2.3.2
11
12 .../nvidia-drivers-304.135-r1.ebuild | 498 ++++++++++++++++++
13 .../nvidia-drivers-340.102-r1.ebuild | 529 +++++++++++++++++++
14 .../nvidia-drivers/nvidia-drivers-375.66-r1.ebuild | 569 ++++++++++++++++++++
15 .../nvidia-drivers/nvidia-drivers-378.13-r1.ebuild | 572 ++++++++++++++++++++
16 .../nvidia-drivers/nvidia-drivers-381.22-r1.ebuild | 573 +++++++++++++++++++++
17 5 files changed, 2741 insertions(+)
18
19 diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-304.135-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-304.135-r1.ebuild
20 new file mode 100644
21 index 00000000000..28804d50042
22 --- /dev/null
23 +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-304.135-r1.ebuild
24 @@ -0,0 +1,498 @@
25 +# Copyright 1999-2017 Gentoo Foundation
26 +# Distributed under the terms of the GNU General Public License v2
27 +
28 +EAPI=6
29 +inherit eutils flag-o-matic linux-info linux-mod multilib-minimal nvidia-driver \
30 + portability toolchain-funcs unpacker user versionator udev
31 +
32 +NV_URI="http://http.download.nvidia.com/XFree86/"
33 +X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}"
34 +AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}"
35 +X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}"
36 +AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}"
37 +
38 +DESCRIPTION="NVIDIA Accelerated Graphics Driver"
39 +HOMEPAGE="http://www.nvidia.com/ http://www.nvidia.com/Download/Find.aspx"
40 +SRC_URI="
41 + amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz )
42 + amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )
43 + x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )
44 + x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run )
45 + tools? ( ${NV_URI}nvidia-settings/nvidia-settings-${PV}.tar.bz2 )
46 +"
47 +
48 +LICENSE="GPL-2 NVIDIA-r1"
49 +SLOT="0/${PV%.*}"
50 +KEYWORDS="-* ~amd64 ~x86 ~amd64-fbsd ~x86-fbsd"
51 +IUSE="acpi multilib kernel_FreeBSD kernel_linux pax_kernel static-libs +tools +X"
52 +RESTRICT="bindist mirror"
53 +EMULTILIB_PKG="true"
54 +
55 +COMMON="
56 + app-eselect/eselect-opencl
57 + kernel_linux? ( >=sys-libs/glibc-2.6.1 )
58 + tools? (
59 + dev-libs/atk
60 + dev-libs/glib:2
61 + x11-libs/gdk-pixbuf[X]
62 + x11-libs/gtk+:2
63 + x11-libs/libX11
64 + x11-libs/libXext
65 + x11-libs/pango[X]
66 + x11-libs/pangox-compat
67 + )
68 + X? (
69 + >=app-eselect/eselect-opengl-1.0.9
70 + )
71 +"
72 +DEPEND="${COMMON}
73 + kernel_linux? (
74 + virtual/linux-sources
75 + virtual/pkgconfig
76 + )"
77 +RDEPEND="${COMMON}
78 + acpi? ( sys-power/acpid )
79 + tools? ( !media-video/nvidia-settings )
80 + X? (
81 + <x11-base/xorg-server-1.19.99:=
82 + >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
83 + >=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}]
84 + sys-libs/zlib[${MULTILIB_USEDEP}]
85 + x11-libs/libXvMC[${MULTILIB_USEDEP}]
86 + )
87 +"
88 +PDEPEND="X? ( >=x11-libs/libvdpau-0.3-r1[${MULTILIB_USEDEP}] )"
89 +
90 +REQUIRED_USE="
91 + tools? ( X )
92 + static-libs? ( tools )
93 +"
94 +
95 +QA_PREBUILT="opt/* usr/lib*"
96 +
97 +S=${WORKDIR}/
98 +
99 +nvidia_drivers_versions_check() {
100 + if use amd64 && has_multilib_profile && \
101 + [ "${DEFAULT_ABI}" != "amd64" ]; then
102 + eerror "This ebuild doesn't currently support changing your default ABI"
103 + die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
104 + fi
105 +
106 + if use kernel_linux && kernel_is ge 4 10; then
107 + ewarn "Gentoo supports kernels which are supported by NVIDIA"
108 + ewarn "which are limited to the following kernels:"
109 + ewarn "<sys-kernel/gentoo-sources-4.10"
110 + ewarn "<sys-kernel/vanilla-sources-4.10"
111 + ewarn ""
112 + ewarn "You are free to utilize eapply_user to provide whatever"
113 + ewarn "support you feel is appropriate, but will not receive"
114 + ewarn "support as a result of those changes."
115 + ewarn ""
116 + ewarn "Do not file a bug report about this."
117 + ewarn ""
118 + fi
119 +
120 + # Since Nvidia ships many different series of drivers, we need to give the user
121 + # some kind of guidance as to what version they should install. This tries
122 + # to point the user in the right direction but can't be perfect. check
123 + # nvidia-driver.eclass
124 + nvidia-driver-check-warning
125 +
126 + # Kernel features/options to check for
127 + CONFIG_CHECK="~ZONE_DMA ~MTRR ~SYSVIPC ~!LOCKDEP"
128 + use x86 && CONFIG_CHECK+=" ~HIGHMEM"
129 +
130 + # Now do the above checks
131 + use kernel_linux && check_extra_config
132 +}
133 +
134 +pkg_pretend() {
135 + nvidia_drivers_versions_check
136 +}
137 +
138 +pkg_setup() {
139 + nvidia_drivers_versions_check
140 +
141 + # try to turn off distcc and ccache for people that have a problem with it
142 + export DISTCC_DISABLE=1
143 + export CCACHE_DISABLE=1
144 +
145 + if use kernel_linux; then
146 + linux-mod_pkg_setup
147 + MODULE_NAMES="nvidia(video:${S}/kernel)"
148 + BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
149 + SYSOUT=${KV_OUT_DIR} CC=$(tc-getBUILD_CC)"
150 + # linux-mod_src_compile calls set_arch_to_kernel, which
151 + # sets the ARCH to x86 but NVIDIA's wrapping Makefile
152 + # expects x86_64 or i386 and then converts it to x86
153 + # later on in the build process
154 + BUILD_FIXES="ARCH=$(uname -m | sed -e 's/i.86/i386/')"
155 + fi
156 +
157 + # set variables to where files are in the package structure
158 + if use kernel_FreeBSD; then
159 + use x86-fbsd && S="${WORKDIR}/${X86_FBSD_NV_PACKAGE}"
160 + use amd64-fbsd && S="${WORKDIR}/${AMD64_FBSD_NV_PACKAGE}"
161 + NV_DOC="${S}/doc"
162 + NV_OBJ="${S}/obj"
163 + NV_SRC="${S}/src"
164 + NV_MAN="${S}/x11/man"
165 + NV_X11="${S}/obj"
166 + NV_SOVER=1
167 + elif use kernel_linux; then
168 + NV_DOC="${S}"
169 + NV_OBJ="${S}"
170 + NV_SRC="${S}/kernel"
171 + NV_MAN="${S}"
172 + NV_X11="${S}"
173 + NV_SOVER=${PV}
174 + else
175 + die "Could not determine proper NVIDIA package"
176 + fi
177 +}
178 +
179 +src_prepare() {
180 + # Please add a brief description for every added patch
181 +
182 + if use kernel_linux; then
183 + eapply "${FILESDIR}"/${P}-endif.patch
184 +
185 + if kernel_is lt 2 6 9 ; then
186 + eerror "You must build this against 2.6.9 or higher kernels."
187 + fi
188 +
189 + # If greater than 2.6.5 use M= instead of SUBDIR=
190 + convert_to_m "${NV_SRC}"/Makefile.kbuild
191 + fi
192 +
193 + if use pax_kernel; then
194 + ewarn "Using PAX patches is not supported. You will be asked to"
195 + ewarn "use a standard kernel should you have issues. Should you"
196 + ewarn "need support with these patches, contact the PaX team."
197 + eapply "${FILESDIR}"/${PN}-pax-const.patch
198 + eapply "${FILESDIR}"/${PN}-pax-usercopy.patch
199 + fi
200 +
201 + cat <<- EOF > "${S}"/nvidia.icd
202 + /usr/$(get_libdir)/libnvidia-opencl.so
203 + EOF
204 +
205 + local man_file
206 + for man_file in "${NV_MAN}"/*1.gz; do
207 + gunzip $man_file || die
208 + done
209 +
210 + # Allow user patches so they can support RC kernels and whatever else
211 + eapply_user
212 +}
213 +
214 +src_compile() {
215 + # This is already the default on Linux, as there's no toplevel Makefile, but
216 + # on FreeBSD there's one and triggers the kernel module build, as we install
217 + # it by itself, pass this.
218 +
219 + cd "${NV_SRC}"
220 + if use kernel_FreeBSD; then
221 + MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
222 + LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
223 + elif use kernel_linux; then
224 + MAKEOPTS=-j1 linux-mod_src_compile
225 + fi
226 +
227 + if use tools; then
228 + emake -C "${S}"/nvidia-settings-${PV}/src/libXNVCtrl clean
229 + emake -C "${S}"/nvidia-settings-${PV}/src/libXNVCtrl \
230 + AR="$(tc-getAR)" \
231 + CC="$(tc-getCC)" \
232 + RANLIB="$(tc-getRANLIB)" \
233 + libXNVCtrl.a
234 + emake -C "${S}"/nvidia-settings-${PV}/src \
235 + AR="$(tc-getAR)" \
236 + CC="$(tc-getCC)" \
237 + LD="$(tc-getCC)" \
238 + LIBDIR="$(get_libdir)" \
239 + NVML_ENABLED=0 \
240 + NV_USE_BUNDLED_LIBJANSSON=0 \
241 + NV_VERBOSE=1 \
242 + RANLIB="$(tc-getRANLIB)" \
243 + STRIP_CMD=true
244 + fi
245 +}
246 +
247 +# Install nvidia library:
248 +# the first parameter is the library to install
249 +# the second parameter is the provided soversion
250 +# the third parameter is the target directory if its not /usr/lib
251 +donvidia() {
252 + # Full path to library minus SOVER
253 + MY_LIB="$1"
254 +
255 + # SOVER to use
256 + MY_SOVER="$2"
257 +
258 + # Where to install
259 + MY_DEST="$3"
260 +
261 + if [[ -z "${MY_DEST}" ]]; then
262 + MY_DEST="/usr/$(get_libdir)"
263 + action="dolib.so"
264 + else
265 + exeinto ${MY_DEST}
266 + action="doexe"
267 + fi
268 +
269 + # Get just the library name
270 + libname=$(basename $1)
271 +
272 + # Install the library with the correct SOVER
273 + ${action} ${MY_LIB}.${MY_SOVER} || \
274 + die "failed to install ${libname}"
275 +
276 + # If SOVER wasn't 1, then we need to create a .1 symlink
277 + if [[ "${MY_SOVER}" != "1" ]]; then
278 + dosym ${libname}.${MY_SOVER} \
279 + ${MY_DEST}/${libname}.1 || \
280 + die "failed to create ${libname} symlink"
281 + fi
282 +
283 + # Always create the symlink from the raw lib to the .1
284 + dosym ${libname}.1 \
285 + ${MY_DEST}/${libname} || \
286 + die "failed to create ${libname} symlink"
287 +}
288 +
289 +src_install() {
290 + if use kernel_linux; then
291 + linux-mod_src_install
292 +
293 + # Add the aliases
294 + # This file is tweaked with the appropriate video group in
295 + # pkg_preinst, see bug #491414
296 + insinto /etc/modprobe.d
297 + newins "${FILESDIR}"/nvidia-169.07 nvidia.conf
298 +
299 + # Ensures that our device nodes are created when not using X
300 + exeinto "$(get_udevdir)"
301 + newexe "${FILESDIR}"/nvidia-udev.sh-r1 nvidia-udev.sh
302 + udev_newrules "${FILESDIR}"/nvidia.udev-rule 99-nvidia.rules
303 + elif use kernel_FreeBSD; then
304 + if use x86-fbsd; then
305 + insinto /boot/modules
306 + doins "${S}/src/nvidia.kld"
307 + fi
308 +
309 + exeinto /boot/modules
310 + doexe "${S}/src/nvidia.ko"
311 + fi
312 +
313 + # NVIDIA kernel <-> userspace driver config lib
314 + donvidia "${NV_OBJ}"/libnvidia-cfg.so ${NV_SOVER}
315 +
316 + if use kernel_linux; then
317 + # NVIDIA video decode <-> CUDA
318 + donvidia "${NV_OBJ}"/libnvcuvid.so ${NV_SOVER}
319 + fi
320 +
321 + if use X; then
322 + # Xorg DDX driver
323 + insinto /usr/$(get_libdir)/xorg/modules/drivers
324 + doins "${NV_X11}"/nvidia_drv.so
325 +
326 + # Xorg GLX driver
327 + donvidia "${NV_X11}"/libglx.so ${NV_SOVER} \
328 + /usr/$(get_libdir)/opengl/nvidia/extensions
329 +
330 + # XvMC driver
331 + dolib.a "${NV_X11}"/libXvMCNVIDIA.a || \
332 + die "failed to install libXvMCNVIDIA.so"
333 + donvidia "${NV_X11}"/libXvMCNVIDIA.so ${NV_SOVER}
334 + dosym libXvMCNVIDIA.so.${NV_SOVER} \
335 + /usr/$(get_libdir)/libXvMCNVIDIA_dynamic.so.1 || \
336 + die "failed to create libXvMCNVIDIA_dynamic.so symlink"
337 + fi
338 +
339 + # OpenCL ICD for NVIDIA
340 + if use kernel_linux; then
341 + insinto /etc/OpenCL/vendors
342 + doins nvidia.icd
343 + donvidia "${NV_OBJ}"/libnvidia-opencl.so ${NV_SOVER}
344 + fi
345 +
346 + # Documentation
347 + dodoc -r "${NV_DOC}"/html
348 + if use kernel_FreeBSD; then
349 + dodoc "${NV_DOC}"/README
350 + use X && doman "${NV_MAN}"/nvidia-xconfig.1
351 + use tools && doman "${NV_MAN}"/nvidia-settings.1
352 + else
353 + # Docs
354 + newdoc "${NV_DOC}"/README.txt README
355 + dodoc "${NV_DOC}"/NVIDIA_Changelog
356 + doman "${NV_MAN}"/nvidia-smi.1
357 + use X && doman "${NV_MAN}"/nvidia-xconfig.1
358 + use tools && doman "${NV_MAN}"/nvidia-settings.1
359 + doman "${NV_MAN}"/nvidia-cuda-proxy-control.1
360 + fi
361 +
362 + # Helper Apps
363 + exeinto /opt/bin/
364 +
365 + if use X; then
366 + doexe "${NV_OBJ}"/nvidia-xconfig
367 + fi
368 +
369 + if use kernel_linux ; then
370 + doexe "${NV_OBJ}"/nvidia-debugdump
371 + doexe "${NV_OBJ}"/nvidia-cuda-proxy-control
372 + doexe "${NV_OBJ}"/nvidia-cuda-proxy-server
373 + doexe "${NV_OBJ}"/nvidia-smi
374 + newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi
375 + fi
376 +
377 + dobin "${NV_OBJ}"/nvidia-bug-report.sh
378 +
379 + # Desktop entries for nvidia-settings
380 + if use tools ; then
381 + emake -C "${S}"/nvidia-settings-${PV}/src/ \
382 + DESTDIR="${D}" \
383 + LIBDIR="${D}/usr/$(get_libdir)" \
384 + PREFIX=/usr \
385 + NV_USE_BUNDLED_LIBJANSSON=0 \
386 + install
387 +
388 + if use static-libs; then
389 + dolib.a "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/libXNVCtrl.a
390 +
391 + insinto /usr/include/NVCtrl
392 + doins "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/*.h
393 + fi
394 +
395 + # There is no icon in the FreeBSD tarball.
396 + use kernel_FreeBSD || \
397 + doicon "${NV_OBJ}"/nvidia-settings.png
398 +
399 + domenu "${FILESDIR}"/nvidia-settings.desktop
400 +
401 + exeinto /etc/X11/xinit/xinitrc.d
402 + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings
403 + fi
404 +
405 + #doenvd "${FILESDIR}"/50nvidia-prelink-blacklist
406 +
407 + if has_multilib_profile && use multilib ; then
408 + local OABI=${ABI}
409 + for ABI in $(get_install_abis) ; do
410 + src_install-libs
411 + done
412 + ABI=${OABI}
413 + unset OABI
414 + else
415 + src_install-libs
416 + fi
417 +
418 + is_final_abi || die "failed to iterate through all ABIs"
419 +
420 + readme.gentoo_create_doc
421 +}
422 +
423 +src_install-libs() {
424 + local inslibdir=$(get_libdir)
425 + local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib"
426 + local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia"
427 + local nv_libdir="${NV_OBJ}"
428 +
429 + if use kernel_linux && has_multilib_profile && \
430 + [[ ${ABI} == "x86" ]] ; then
431 + nv_libdir="${NV_OBJ}"/32
432 + fi
433 +
434 + if use X; then
435 + # The GLX libraries
436 + donvidia "${nv_libdir}"/libGL.so ${NV_SOVER} ${GL_ROOT}
437 + donvidia "${nv_libdir}"/libnvidia-glcore.so ${NV_SOVER}
438 + if use kernel_FreeBSD; then
439 + donvidia "${nv_libdir}"/libnvidia-tls.so ${NV_SOVER} ${GL_ROOT}
440 + else
441 + donvidia "${nv_libdir}"/tls/libnvidia-tls.so ${NV_SOVER} ${GL_ROOT}
442 + fi
443 +
444 + # VDPAU
445 + donvidia "${nv_libdir}"/libvdpau_nvidia.so ${NV_SOVER}
446 + fi
447 +
448 + # NVIDIA monitoring library
449 + if use kernel_linux ; then
450 + donvidia "${nv_libdir}"/libnvidia-ml.so ${NV_SOVER}
451 + fi
452 +
453 + # CUDA & OpenCL
454 + if use kernel_linux; then
455 + donvidia "${nv_libdir}"/libcuda.so ${NV_SOVER}
456 + donvidia "${nv_libdir}"/libnvidia-compiler.so ${NV_SOVER}
457 + donvidia "${nv_libdir}"/libOpenCL.so 1.0.0 ${CL_ROOT}
458 + fi
459 +}
460 +
461 +pkg_preinst() {
462 + if use kernel_linux; then
463 + linux-mod_pkg_preinst
464 +
465 + local videogroup="$(egetent group video | cut -d ':' -f 3)"
466 + if [ -z "${videogroup}" ]; then
467 + eerror "Failed to determine the video group gid"
468 + die "Failed to determine the video group gid"
469 + else
470 + sed -i \
471 + -e "s:PACKAGE:${PF}:g" \
472 + -e "s:VIDEOGID:${videogroup}:" \
473 + "${D}"/etc/modprobe.d/nvidia.conf || die
474 + fi
475 + fi
476 +
477 + # Clean the dynamic libGL stuff's home to ensure
478 + # we dont have stale libs floating around
479 + if [ -d "${ROOT}"/usr/lib/opengl/nvidia ] ; then
480 + rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
481 + fi
482 + # Make sure we nuke the old nvidia-glx's env.d file
483 + if [ -e "${ROOT}"/etc/env.d/09nvidia ] ; then
484 + rm -f "${ROOT}"/etc/env.d/09nvidia
485 + fi
486 +}
487 +
488 +pkg_postinst() {
489 + use kernel_linux && linux-mod_pkg_postinst
490 +
491 + # Switch to the nvidia implementation
492 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia
493 + "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia
494 +
495 + readme.gentoo_print_elog
496 +
497 + if ! use X; then
498 + elog "You have elected to not install the X.org driver. Along with"
499 + elog "this the OpenGL libraries, XvMC, and VDPAU libraries were not"
500 + elog "installed. Additionally, once the driver is loaded your card"
501 + elog "and fan will run at max speed which may not be desirable."
502 + elog "Use the 'nvidia-smi' init script to have your card and fan"
503 + elog "speed scale appropriately."
504 + elog
505 + fi
506 + if ! use tools; then
507 + elog "USE=tools controls whether the nvidia-settings application"
508 + elog "is installed. If you would like to use it, enable that"
509 + elog "flag and re-emerge this ebuild. Optionally you can install"
510 + elog "media-video/nvidia-settings"
511 + elog
512 + fi
513 +}
514 +
515 +pkg_prerm() {
516 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
517 +}
518 +
519 +pkg_postrm() {
520 + use kernel_linux && linux-mod_pkg_postrm
521 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
522 +}
523
524 diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-340.102-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-340.102-r1.ebuild
525 new file mode 100644
526 index 00000000000..39187a30aba
527 --- /dev/null
528 +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-340.102-r1.ebuild
529 @@ -0,0 +1,529 @@
530 +# Copyright 1999-2017 Gentoo Foundation
531 +# Distributed under the terms of the GNU General Public License v2
532 +
533 +EAPI=6
534 +inherit eutils flag-o-matic linux-info linux-mod multilib-minimal nvidia-driver \
535 + portability toolchain-funcs unpacker user udev
536 +
537 +NV_URI="http://http.download.nvidia.com/XFree86/"
538 +X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}"
539 +AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}"
540 +X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}"
541 +AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}"
542 +
543 +DESCRIPTION="NVIDIA Accelerated Graphics Driver"
544 +HOMEPAGE="http://www.nvidia.com/ http://www.nvidia.com/Download/Find.aspx"
545 +SRC_URI="
546 + amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz )
547 + amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )
548 + x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )
549 + x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run )
550 + tools? ( ${NV_URI}nvidia-settings/nvidia-settings-${PV}.tar.bz2 )
551 +"
552 +
553 +LICENSE="GPL-2 NVIDIA-r2"
554 +SLOT="0/${PV%.*}"
555 +KEYWORDS="-* ~amd64 ~x86 ~amd64-fbsd ~x86-fbsd"
556 +IUSE="acpi multilib kernel_FreeBSD kernel_linux pax_kernel static-libs +tools +X uvm"
557 +RESTRICT="bindist mirror"
558 +EMULTILIB_PKG="true"
559 +
560 +COMMON="
561 + app-eselect/eselect-opencl
562 + kernel_linux? ( >=sys-libs/glibc-2.6.1 )
563 + tools? (
564 + dev-libs/atk
565 + dev-libs/glib:2
566 + dev-libs/jansson
567 + x11-libs/gdk-pixbuf[X]
568 + >=x11-libs/gtk+-2.4:2
569 + x11-libs/libX11
570 + x11-libs/libXext
571 + x11-libs/pango[X]
572 + )
573 + X? (
574 + >=app-eselect/eselect-opengl-1.0.9
575 + )
576 +"
577 +DEPEND="
578 + ${COMMON}
579 + app-arch/xz-utils
580 + kernel_linux? ( virtual/linux-sources )
581 +"
582 +RDEPEND="
583 + ${COMMON}
584 + acpi? ( sys-power/acpid )
585 + tools? ( !media-video/nvidia-settings )
586 + X? (
587 + <x11-base/xorg-server-1.19.99:=
588 + >=x11-libs/libvdpau-0.3-r1
589 + sys-libs/zlib[${MULTILIB_USEDEP}]
590 + multilib? (
591 + >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
592 + >=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}]
593 + )
594 + )
595 +"
596 +
597 +REQUIRED_USE="tools? ( X )"
598 +
599 +QA_PREBUILT="opt/* usr/lib*"
600 +
601 +S=${WORKDIR}/
602 +
603 +nvidia_drivers_versions_check() {
604 + if use amd64 && has_multilib_profile && \
605 + [ "${DEFAULT_ABI}" != "amd64" ]; then
606 + eerror "This ebuild doesn't currently support changing your default ABI"
607 + die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
608 + fi
609 +
610 + if use kernel_linux && kernel_is ge 4 10; then
611 + ewarn "Gentoo supports kernels which are supported by NVIDIA"
612 + ewarn "which are limited to the following kernels:"
613 + ewarn "<sys-kernel/gentoo-sources-4.10"
614 + ewarn "<sys-kernel/vanilla-sources-4.10"
615 + ewarn ""
616 + ewarn "You are free to utilize eapply_user to provide whatever"
617 + ewarn "support you feel is appropriate, but will not receive"
618 + ewarn "support as a result of those changes."
619 + ewarn ""
620 + ewarn "Do not file a bug report about this."
621 + ewarn ""
622 + fi
623 +
624 + # Since Nvidia ships many different series of drivers, we need to give the user
625 + # some kind of guidance as to what version they should install. This tries
626 + # to point the user in the right direction but can't be perfect. check
627 + # nvidia-driver.eclass
628 + nvidia-driver-check-warning
629 +
630 + # Kernel features/options to check for
631 + CONFIG_CHECK="~ZONE_DMA ~MTRR ~SYSVIPC ~!LOCKDEP"
632 + use x86 && CONFIG_CHECK+=" ~HIGHMEM"
633 +
634 + # Now do the above checks
635 + use kernel_linux && check_extra_config
636 +}
637 +
638 +pkg_pretend() {
639 + nvidia_drivers_versions_check
640 +}
641 +
642 +pkg_setup() {
643 + nvidia_drivers_versions_check
644 +
645 + # try to turn off distcc and ccache for people that have a problem with it
646 + export DISTCC_DISABLE=1
647 + export CCACHE_DISABLE=1
648 +
649 + if use kernel_linux; then
650 + MODULE_NAMES="nvidia(video:${S}/kernel)"
651 + use uvm && MODULE_NAMES+=" nvidia-uvm(video:${S}/kernel/uvm)"
652 +
653 + # This needs to run after MODULE_NAMES (so that the eclass checks
654 + # whether the kernel supports loadable modules) but before BUILD_PARAMS
655 + # is set (so that KV_DIR is populated).
656 + linux-mod_pkg_setup
657 +
658 + BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
659 + SYSOUT=${KV_OUT_DIR} CC=$(tc-getBUILD_CC)"
660 +
661 + # linux-mod_src_compile calls set_arch_to_kernel, which
662 + # sets the ARCH to x86 but NVIDIA's wrapping Makefile
663 + # expects x86_64 or i386 and then converts it to x86
664 + # later on in the build process
665 + BUILD_FIXES="ARCH=$(uname -m | sed -e 's/i.86/i386/')"
666 + fi
667 +
668 + # set variables to where files are in the package structure
669 + if use kernel_FreeBSD; then
670 + use x86-fbsd && S="${WORKDIR}/${X86_FBSD_NV_PACKAGE}"
671 + use amd64-fbsd && S="${WORKDIR}/${AMD64_FBSD_NV_PACKAGE}"
672 + NV_DOC="${S}/doc"
673 + NV_OBJ="${S}/obj"
674 + NV_SRC="${S}/src"
675 + NV_MAN="${S}/x11/man"
676 + NV_X11="${S}/obj"
677 + NV_SOVER=1
678 + elif use kernel_linux; then
679 + NV_DOC="${S}"
680 + NV_OBJ="${S}"
681 + NV_SRC="${S}/kernel"
682 + NV_MAN="${S}"
683 + NV_X11="${S}"
684 + NV_SOVER=${PV}
685 + else
686 + die "Could not determine proper NVIDIA package"
687 + fi
688 +}
689 +
690 +src_prepare() {
691 + # Please add a brief description for every added patch
692 +
693 + if use kernel_linux; then
694 + if kernel_is lt 2 6 9 ; then
695 + eerror "You must build this against 2.6.9 or higher kernels."
696 + fi
697 +
698 + # If greater than 2.6.5 use M= instead of SUBDIR=
699 +# convert_to_m "${NV_SRC}"/Makefile.kbuild
700 + fi
701 +
702 + if use pax_kernel; then
703 + ewarn "Using PAX patches is not supported. You will be asked to"
704 + ewarn "use a standard kernel should you have issues. Should you"
705 + ewarn "need support with these patches, contact the PaX team."
706 + eapply "${FILESDIR}"/${PN}-331.13-pax-usercopy.patch
707 + eapply "${FILESDIR}"/${PN}-337.12-pax-constify.patch
708 + fi
709 +
710 + local man_file
711 + for man_file in "${NV_MAN}"/*1.gz; do
712 + gunzip $man_file || die
713 + done
714 +
715 + # Allow user patches so they can support RC kernels and whatever else
716 + eapply_user
717 +}
718 +
719 +src_compile() {
720 + # This is already the default on Linux, as there's no toplevel Makefile, but
721 + # on FreeBSD there's one and triggers the kernel module build, as we install
722 + # it by itself, pass this.
723 +
724 + cd "${NV_SRC}"
725 + if use kernel_FreeBSD; then
726 + MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
727 + LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
728 + elif use kernel_linux; then
729 + use uvm && MAKEOPTS=-j1
730 + linux-mod_src_compile
731 + fi
732 +
733 + if use tools; then
734 + emake -C "${S}"/nvidia-settings-${PV}/src/libXNVCtrl clean
735 + emake -C "${S}"/nvidia-settings-${PV}/src/libXNVCtrl \
736 + AR="$(tc-getAR)" \
737 + CC="$(tc-getCC)" \
738 + RANLIB="$(tc-getRANLIB)" \
739 + libXNVCtrl.a
740 + emake -C "${S}"/nvidia-settings-${PV}/src \
741 + AR="$(tc-getAR)" \
742 + CC="$(tc-getCC)" \
743 + LD="$(tc-getCC)" \
744 + LIBDIR="$(get_libdir)" \
745 + NVML_ENABLED=0 \
746 + NV_USE_BUNDLED_LIBJANSSON=0 \
747 + NV_VERBOSE=1 \
748 + RANLIB="$(tc-getRANLIB)" \
749 + STRIP_CMD=true
750 + fi
751 +}
752 +
753 +# Install nvidia library:
754 +# the first parameter is the library to install
755 +# the second parameter is the provided soversion
756 +# the third parameter is the target directory if its not /usr/lib
757 +donvidia() {
758 + # Full path to library minus SOVER
759 + MY_LIB="$1"
760 +
761 + # SOVER to use
762 + MY_SOVER="$2"
763 +
764 + # Where to install
765 + MY_DEST="$3"
766 +
767 + if [[ -z "${MY_DEST}" ]]; then
768 + MY_DEST="/usr/$(get_libdir)"
769 + action="dolib.so"
770 + else
771 + exeinto ${MY_DEST}
772 + action="doexe"
773 + fi
774 +
775 + # Get just the library name
776 + libname=$(basename $1)
777 +
778 + # Install the library with the correct SOVER
779 + ${action} ${MY_LIB}.${MY_SOVER} || \
780 + die "failed to install ${libname}"
781 +
782 + # If SOVER wasn't 1, then we need to create a .1 symlink
783 + if [[ "${MY_SOVER}" != "1" ]]; then
784 + dosym ${libname}.${MY_SOVER} \
785 + ${MY_DEST}/${libname}.1 || \
786 + die "failed to create ${libname} symlink"
787 + fi
788 +
789 + # Always create the symlink from the raw lib to the .1
790 + dosym ${libname}.1 \
791 + ${MY_DEST}/${libname} || \
792 + die "failed to create ${libname} symlink"
793 +}
794 +
795 +src_install() {
796 + if use kernel_linux; then
797 + linux-mod_src_install
798 +
799 + # Add the aliases
800 + # This file is tweaked with the appropriate video group in
801 + # pkg_preinst, see bug #491414
802 + insinto /etc/modprobe.d
803 + newins "${FILESDIR}"/nvidia-169.07 nvidia.conf
804 + use uvm && doins "${FILESDIR}"/nvidia-uvm.conf
805 +
806 + # Ensures that our device nodes are created when not using X
807 + exeinto "$(get_udevdir)"
808 + newexe "${FILESDIR}"/nvidia-udev.sh-r1 nvidia-udev.sh
809 + udev_newrules "${FILESDIR}"/nvidia.udev-rule 99-nvidia.rules
810 + elif use kernel_FreeBSD; then
811 + if use x86-fbsd; then
812 + insinto /boot/modules
813 + doins "${S}/src/nvidia.kld"
814 + fi
815 +
816 + exeinto /boot/modules
817 + doexe "${S}/src/nvidia.ko"
818 + fi
819 +
820 + # NVIDIA kernel <-> userspace driver config lib
821 + donvidia "${NV_OBJ}"/libnvidia-cfg.so ${NV_SOVER}
822 +
823 + # NVIDIA framebuffer capture library
824 + donvidia "${NV_OBJ}"/libnvidia-fbc.so ${NV_SOVER}
825 +
826 + # NVIDIA video encode/decode <-> CUDA
827 + if use kernel_linux; then
828 + donvidia "${NV_OBJ}"/libnvcuvid.so ${NV_SOVER}
829 + donvidia "${NV_OBJ}"/libnvidia-encode.so ${NV_SOVER}
830 + fi
831 +
832 + if use X; then
833 + # Xorg DDX driver
834 + insinto /usr/$(get_libdir)/xorg/modules/drivers
835 + doins "${NV_X11}"/nvidia_drv.so
836 +
837 + # Xorg GLX driver
838 + donvidia "${NV_X11}"/libglx.so ${NV_SOVER} \
839 + /usr/$(get_libdir)/opengl/nvidia/extensions
840 + fi
841 +
842 + # OpenCL ICD for NVIDIA
843 + if use kernel_linux; then
844 + insinto /etc/OpenCL/vendors
845 + doins "${NV_OBJ}"/nvidia.icd
846 + fi
847 +
848 + # Documentation
849 + if use kernel_FreeBSD; then
850 + dodoc "${NV_DOC}"/README
851 + use X && doman "${NV_MAN}"/nvidia-xconfig.1
852 + use tools && doman "${NV_MAN}"/nvidia-settings.1
853 + else
854 + # Docs
855 + newdoc "${NV_DOC}"/README.txt README
856 + dodoc "${NV_DOC}"/NVIDIA_Changelog
857 + doman "${NV_MAN}"/nvidia-smi.1
858 + use X && doman "${NV_MAN}"/nvidia-xconfig.1
859 + use tools && doman "${NV_MAN}"/nvidia-settings.1
860 + doman "${NV_MAN}"/nvidia-cuda-mps-control.1
861 + fi
862 +
863 + docinto html
864 + dodoc -r "${NV_DOC}"/html/*
865 +
866 + # Helper Apps
867 + exeinto /opt/bin/
868 +
869 + if use X; then
870 + doexe "${NV_OBJ}"/nvidia-xconfig
871 + fi
872 +
873 + if use kernel_linux ; then
874 + doexe "${NV_OBJ}"/nvidia-cuda-mps-control
875 + doexe "${NV_OBJ}"/nvidia-cuda-mps-server
876 + doexe "${NV_OBJ}"/nvidia-debugdump
877 + doexe "${NV_OBJ}"/nvidia-persistenced
878 + doexe "${NV_OBJ}"/nvidia-smi
879 +
880 + # install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092)
881 + doexe "${NV_OBJ}"/nvidia-modprobe
882 + fowners root:video /opt/bin/nvidia-modprobe
883 + fperms 4710 /opt/bin/nvidia-modprobe
884 + dosym /{opt,usr}/bin/nvidia-modprobe
885 +
886 + doman nvidia-cuda-mps-control.1
887 + doman nvidia-modprobe.1
888 + doman nvidia-persistenced.1
889 + newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi
890 + newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced
891 + newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced
892 + fi
893 +
894 + if use tools; then
895 + emake -C "${S}"/nvidia-settings-${PV}/src/ \
896 + DESTDIR="${D}" \
897 + LIBDIR="${D}/usr/$(get_libdir)" \
898 + PREFIX=/usr \
899 + NV_USE_BUNDLED_LIBJANSSON=0 \
900 + install
901 +
902 + if use static-libs; then
903 + dolib.a "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/libXNVCtrl.a
904 +
905 + insinto /usr/include/NVCtrl
906 + doins "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/*.h
907 + fi
908 +
909 + insinto /usr/share/nvidia/
910 + doins nvidia-application-profiles-${PV}-key-documentation
911 +
912 + insinto /etc/nvidia
913 + newins \
914 + nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc
915 +
916 + # There is no icon in the FreeBSD tarball.
917 + use kernel_FreeBSD || \
918 + doicon "${NV_OBJ}"/nvidia-settings.png
919 +
920 + domenu "${FILESDIR}"/nvidia-settings.desktop
921 +
922 + exeinto /etc/X11/xinit/xinitrc.d
923 + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings
924 +
925 + fi
926 +
927 + dobin "${NV_OBJ}"/nvidia-bug-report.sh
928 +
929 + #doenvd "${FILESDIR}"/50nvidia-prelink-blacklist
930 +
931 + if has_multilib_profile && use multilib ; then
932 + local OABI=${ABI}
933 + for ABI in $(get_install_abis) ; do
934 + src_install-libs
935 + done
936 + ABI=${OABI}
937 + unset OABI
938 + else
939 + src_install-libs
940 + fi
941 +
942 + is_final_abi || die "failed to iterate through all ABIs"
943 +
944 + readme.gentoo_create_doc
945 +}
946 +
947 +src_install-libs() {
948 + local inslibdir=$(get_libdir)
949 + local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib"
950 + local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia"
951 + local nv_libdir="${NV_OBJ}"
952 +
953 + if use kernel_linux && has_multilib_profile && \
954 + [[ ${ABI} == "x86" ]] ; then
955 + nv_libdir="${NV_OBJ}"/32
956 + fi
957 +
958 + if use X; then
959 + # The GLX libraries
960 + donvidia "${nv_libdir}"/libEGL.so ${NV_SOVER} ${GL_ROOT}
961 + donvidia "${nv_libdir}"/libGL.so ${NV_SOVER} ${GL_ROOT}
962 + donvidia "${nv_libdir}"/libGLESv1_CM.so ${NV_SOVER} ${GL_ROOT}
963 + donvidia "${nv_libdir}"/libnvidia-eglcore.so ${NV_SOVER}
964 + donvidia "${nv_libdir}"/libnvidia-glcore.so ${NV_SOVER}
965 + donvidia "${nv_libdir}"/libnvidia-glsi.so ${NV_SOVER}
966 + donvidia "${nv_libdir}"/libnvidia-ifr.so ${NV_SOVER}
967 + if use kernel_FreeBSD; then
968 + donvidia "${nv_libdir}"/libnvidia-tls.so ${NV_SOVER}
969 + else
970 + donvidia "${nv_libdir}"/tls/libnvidia-tls.so ${NV_SOVER}
971 + fi
972 +
973 + # VDPAU
974 + donvidia "${nv_libdir}"/libvdpau_nvidia.so ${NV_SOVER}
975 +
976 + # GLES v2 libraries
977 + insinto ${GL_ROOT}
978 + doexe "${nv_libdir}"/libGLESv2.so.${PV}
979 + dosym libGLESv2.so.${PV} ${GL_ROOT}/libGLESv2.so.2
980 + dosym libGLESv2.so.2 ${GL_ROOT}/libGLESv2.so
981 + fi
982 +
983 + # NVIDIA monitoring library
984 + if use kernel_linux ; then
985 + donvidia "${nv_libdir}"/libnvidia-ml.so ${NV_SOVER}
986 + fi
987 +
988 + # CUDA & OpenCL
989 + if use kernel_linux; then
990 + donvidia "${nv_libdir}"/libcuda.so ${NV_SOVER}
991 + donvidia "${nv_libdir}"/libnvidia-compiler.so ${NV_SOVER}
992 + donvidia "${nv_libdir}"/libOpenCL.so 1.0.0 ${CL_ROOT}
993 + donvidia "${nv_libdir}"/libnvidia-opencl.so ${NV_SOVER}
994 + fi
995 +}
996 +
997 +pkg_preinst() {
998 + if use kernel_linux; then
999 + linux-mod_pkg_preinst
1000 +
1001 + local videogroup="$(egetent group video | cut -d ':' -f 3)"
1002 + if [ -z "${videogroup}" ]; then
1003 + eerror "Failed to determine the video group gid"
1004 + die "Failed to determine the video group gid"
1005 + else
1006 + sed -i \
1007 + -e "s:PACKAGE:${PF}:g" \
1008 + -e "s:VIDEOGID:${videogroup}:" \
1009 + "${D}"/etc/modprobe.d/nvidia.conf || die
1010 + fi
1011 + fi
1012 +
1013 + # Clean the dynamic libGL stuff's home to ensure
1014 + # we dont have stale libs floating around
1015 + if [ -d "${ROOT}"/usr/lib/opengl/nvidia ] ; then
1016 + rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
1017 + fi
1018 + # Make sure we nuke the old nvidia-glx's env.d file
1019 + if [ -e "${ROOT}"/etc/env.d/09nvidia ] ; then
1020 + rm -f "${ROOT}"/etc/env.d/09nvidia
1021 + fi
1022 +}
1023 +
1024 +pkg_postinst() {
1025 + use kernel_linux && linux-mod_pkg_postinst
1026 +
1027 + # Switch to the nvidia implementation
1028 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia
1029 + "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia
1030 +
1031 + readme.gentoo_print_elog
1032 +
1033 + if ! use X; then
1034 + elog "You have elected to not install the X.org driver. Along with"
1035 + elog "this the OpenGL libraries and VDPAU libraries were not"
1036 + elog "installed. Additionally, once the driver is loaded your card"
1037 + elog "and fan will run at max speed which may not be desirable."
1038 + elog "Use the 'nvidia-smi' init script to have your card and fan"
1039 + elog "speed scale appropriately."
1040 + elog
1041 + fi
1042 + if ! use tools; then
1043 + elog "USE=tools controls whether the nvidia-settings application"
1044 + elog "is installed. If you would like to use it, enable that"
1045 + elog "flag and re-emerge this ebuild. Optionally you can install"
1046 + elog "media-video/nvidia-settings"
1047 + elog
1048 + fi
1049 +}
1050 +
1051 +pkg_prerm() {
1052 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
1053 +}
1054 +
1055 +pkg_postrm() {
1056 + use kernel_linux && linux-mod_pkg_postrm
1057 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
1058 +}
1059
1060 diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-375.66-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-375.66-r1.ebuild
1061 new file mode 100644
1062 index 00000000000..59ee6f6b715
1063 --- /dev/null
1064 +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-375.66-r1.ebuild
1065 @@ -0,0 +1,569 @@
1066 +# Copyright 1999-2017 Gentoo Foundation
1067 +# Distributed under the terms of the GNU General Public License v2
1068 +
1069 +EAPI=6
1070 +inherit eutils flag-o-matic linux-info linux-mod multilib-minimal nvidia-driver \
1071 + portability toolchain-funcs unpacker user udev
1072 +
1073 +NV_URI="http://http.download.nvidia.com/XFree86/"
1074 +X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}"
1075 +AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}"
1076 +ARM_NV_PACKAGE="NVIDIA-Linux-armv7l-gnueabihf-${PV}"
1077 +X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}"
1078 +AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}"
1079 +
1080 +DESCRIPTION="NVIDIA Accelerated Graphics Driver"
1081 +HOMEPAGE="http://www.nvidia.com/ http://www.nvidia.com/Download/Find.aspx"
1082 +SRC_URI="
1083 + amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz )
1084 + amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )
1085 + arm? ( ${NV_URI}Linux-32bit-ARM/${PV}/${ARM_NV_PACKAGE}.run )
1086 + x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )
1087 + x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run )
1088 + tools? (
1089 + https://github.com/NVIDIA/nvidia-settings/archive/${PV}.tar.gz -> nvidia-settings-${PV}.tar.gz
1090 + )
1091 +"
1092 +
1093 +LICENSE="GPL-2 NVIDIA-r2"
1094 +SLOT="0/${PV%.*}"
1095 +KEYWORDS="-* ~amd64 ~x86 ~amd64-fbsd ~x86-fbsd"
1096 +RESTRICT="bindist mirror"
1097 +EMULTILIB_PKG="true"
1098 +
1099 +IUSE="acpi compat +driver gtk3 kernel_FreeBSD kernel_linux +kms multilib pax_kernel static-libs +tools uvm wayland +X"
1100 +REQUIRED_USE="
1101 + tools? ( X )
1102 + static-libs? ( tools )
1103 +"
1104 +
1105 +COMMON="
1106 + app-eselect/eselect-opencl
1107 + kernel_linux? ( >=sys-libs/glibc-2.6.1 )
1108 + tools? (
1109 + dev-libs/atk
1110 + dev-libs/glib:2
1111 + dev-libs/jansson
1112 + gtk3? (
1113 + x11-libs/gtk+:3
1114 + )
1115 + x11-libs/cairo
1116 + x11-libs/gdk-pixbuf[X]
1117 + x11-libs/gtk+:2
1118 + x11-libs/libX11
1119 + x11-libs/libXext
1120 + x11-libs/libXrandr
1121 + x11-libs/libXv
1122 + x11-libs/libXxf86vm
1123 + x11-libs/pango[X]
1124 + )
1125 + X? (
1126 + >=app-eselect/eselect-opengl-1.0.9
1127 + app-misc/pax-utils
1128 + )
1129 +"
1130 +DEPEND="
1131 + ${COMMON}
1132 + kernel_linux? ( virtual/linux-sources )
1133 +"
1134 +RDEPEND="
1135 + ${COMMON}
1136 + acpi? ( sys-power/acpid )
1137 + tools? ( !media-video/nvidia-settings )
1138 + wayland? ( dev-libs/wayland[${MULTILIB_USEDEP}] )
1139 + X? (
1140 + <x11-base/xorg-server-1.19.99:=
1141 + >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
1142 + >=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}]
1143 + >=x11-libs/libvdpau-1.0[${MULTILIB_USEDEP}]
1144 + sys-libs/zlib[${MULTILIB_USEDEP}]
1145 + )
1146 +"
1147 +
1148 +QA_PREBUILT="opt/* usr/lib*"
1149 +
1150 +S=${WORKDIR}/
1151 +
1152 +nvidia_drivers_versions_check() {
1153 + if use amd64 && has_multilib_profile && \
1154 + [ "${DEFAULT_ABI}" != "amd64" ]; then
1155 + eerror "This ebuild doesn't currently support changing your default ABI"
1156 + die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
1157 + fi
1158 +
1159 + if use kernel_linux && kernel_is ge 4 12; then
1160 + ewarn "Gentoo supports kernels which are supported by NVIDIA"
1161 + ewarn "which are limited to the following kernels:"
1162 + ewarn "<sys-kernel/gentoo-sources-4.12"
1163 + ewarn "<sys-kernel/vanilla-sources-4.12"
1164 + ewarn ""
1165 + ewarn "You are free to utilize epatch_user to provide whatever"
1166 + ewarn "support you feel is appropriate, but will not receive"
1167 + ewarn "support as a result of those changes."
1168 + ewarn ""
1169 + ewarn "Do not file a bug report about this."
1170 + ewarn ""
1171 + fi
1172 +
1173 + # Since Nvidia ships many different series of drivers, we need to give the user
1174 + # some kind of guidance as to what version they should install. This tries
1175 + # to point the user in the right direction but can't be perfect. check
1176 + # nvidia-driver.eclass
1177 + nvidia-driver-check-warning
1178 +
1179 + # Kernel features/options to check for
1180 + CONFIG_CHECK="~ZONE_DMA ~MTRR ~SYSVIPC ~!LOCKDEP"
1181 + use x86 && CONFIG_CHECK+=" ~HIGHMEM"
1182 +
1183 + # Now do the above checks
1184 + use kernel_linux && check_extra_config
1185 +}
1186 +
1187 +pkg_pretend() {
1188 + nvidia_drivers_versions_check
1189 +}
1190 +
1191 +pkg_setup() {
1192 + nvidia_drivers_versions_check
1193 +
1194 + # try to turn off distcc and ccache for people that have a problem with it
1195 + export DISTCC_DISABLE=1
1196 + export CCACHE_DISABLE=1
1197 +
1198 + if use driver && use kernel_linux; then
1199 + MODULE_NAMES="nvidia(video:${S}/kernel)"
1200 + use uvm && MODULE_NAMES+=" nvidia-uvm(video:${S}/kernel)"
1201 + use kms && MODULE_NAMES+=" nvidia-modeset(video:${S}/kernel) nvidia-drm(video:${S}/kernel)"
1202 +
1203 + # This needs to run after MODULE_NAMES (so that the eclass checks
1204 + # whether the kernel supports loadable modules) but before BUILD_PARAMS
1205 + # is set (so that KV_DIR is populated).
1206 + linux-mod_pkg_setup
1207 +
1208 + BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
1209 + SYSOUT=${KV_OUT_DIR} CC=$(tc-getBUILD_CC) NV_VERBOSE=1"
1210 +
1211 + # linux-mod_src_compile calls set_arch_to_kernel, which
1212 + # sets the ARCH to x86 but NVIDIA's wrapping Makefile
1213 + # expects x86_64 or i386 and then converts it to x86
1214 + # later on in the build process
1215 + BUILD_FIXES="ARCH=$(uname -m | sed -e 's/i.86/i386/')"
1216 + fi
1217 +
1218 + if use kernel_linux && kernel_is lt 2 6 9; then
1219 + eerror "You must build this against 2.6.9 or higher kernels."
1220 + fi
1221 +
1222 + # set variables to where files are in the package structure
1223 + if use kernel_FreeBSD; then
1224 + use x86-fbsd && S="${WORKDIR}/${X86_FBSD_NV_PACKAGE}"
1225 + use amd64-fbsd && S="${WORKDIR}/${AMD64_FBSD_NV_PACKAGE}"
1226 + NV_DOC="${S}/doc"
1227 + NV_OBJ="${S}/obj"
1228 + NV_SRC="${S}/src"
1229 + NV_MAN="${S}/x11/man"
1230 + NV_X11="${S}/obj"
1231 + NV_SOVER=1
1232 + elif use kernel_linux; then
1233 + NV_DOC="${S}"
1234 + NV_OBJ="${S}"
1235 + NV_SRC="${S}/kernel"
1236 + NV_MAN="${S}"
1237 + NV_X11="${S}"
1238 + NV_SOVER=${PV}
1239 + else
1240 + die "Could not determine proper NVIDIA package"
1241 + fi
1242 +}
1243 +
1244 +src_prepare() {
1245 + eapply "${FILESDIR}"/${P}-profiles-rc.patch
1246 +
1247 + if use pax_kernel; then
1248 + ewarn "Using PAX patches is not supported. You will be asked to"
1249 + ewarn "use a standard kernel should you have issues. Should you"
1250 + ewarn "need support with these patches, contact the PaX team."
1251 + eapply "${FILESDIR}"/${PN}-375.20-pax.patch
1252 + fi
1253 +
1254 + local man_file
1255 + for man_file in "${NV_MAN}"/*1.gz; do
1256 + gunzip $man_file || die
1257 + done
1258 +
1259 + # Allow user patches so they can support RC kernels and whatever else
1260 + eapply_user
1261 +}
1262 +
1263 +src_compile() {
1264 + # This is already the default on Linux, as there's no toplevel Makefile, but
1265 + # on FreeBSD there's one and triggers the kernel module build, as we install
1266 + # it by itself, pass this.
1267 +
1268 + cd "${NV_SRC}"
1269 + if use kernel_FreeBSD; then
1270 + MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
1271 + LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
1272 + elif use driver && use kernel_linux; then
1273 + MAKEOPTS=-j1 linux-mod_src_compile
1274 + fi
1275 +
1276 + if use tools; then
1277 + emake -C "${S}"/nvidia-settings-${PV}/src \
1278 + AR="$(tc-getAR)" \
1279 + CC="$(tc-getCC)" \
1280 + LIBDIR="$(get_libdir)" \
1281 + NV_VERBOSE=1 \
1282 + RANLIB="$(tc-getRANLIB)" \
1283 + DO_STRIP= \
1284 + build-xnvctrl
1285 +
1286 + emake -C "${S}"/nvidia-settings-${PV}/src \
1287 + CC="$(tc-getCC)" \
1288 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
1289 + LD="$(tc-getCC)" \
1290 + LIBDIR="$(get_libdir)" \
1291 + NVML_ENABLED=0 \
1292 + NV_USE_BUNDLED_LIBJANSSON=0 \
1293 + NV_VERBOSE=1 \
1294 + DO_STRIP=
1295 + fi
1296 +}
1297 +
1298 +# Install nvidia library:
1299 +# the first parameter is the library to install
1300 +# the second parameter is the provided soversion
1301 +# the third parameter is the target directory if it is not /usr/lib
1302 +donvidia() {
1303 + # Full path to library
1304 + nv_LIB="${1}"
1305 +
1306 + # SOVER to use
1307 + nv_SOVER="$(scanelf -qF'%S#F' ${nv_LIB})"
1308 +
1309 + # Where to install
1310 + nv_DEST="${2}"
1311 +
1312 + # Get just the library name
1313 + nv_LIBNAME=$(basename "${nv_LIB}")
1314 +
1315 + if [[ "${nv_DEST}" ]]; then
1316 + exeinto ${nv_DEST}
1317 + action="doexe"
1318 + else
1319 + nv_DEST="/usr/$(get_libdir)"
1320 + action="dolib.so"
1321 + fi
1322 +
1323 + # Install the library
1324 + ${action} ${nv_LIB} || die "failed to install ${nv_LIBNAME}"
1325 +
1326 + # If the library has a SONAME and SONAME does not match the library name,
1327 + # then we need to create a symlink
1328 + if [[ ${nv_SOVER} ]] && ! [[ "${nv_SOVER}" = "${nv_LIBNAME}" ]]; then
1329 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_SOVER} \
1330 + || die "failed to create ${nv_DEST}/${nv_SOVER} symlink"
1331 + fi
1332 +
1333 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_LIBNAME/.so*/.so} \
1334 + || die "failed to create ${nv_LIBNAME/.so*/.so} symlink"
1335 +}
1336 +
1337 +src_install() {
1338 + if use driver && use kernel_linux; then
1339 + linux-mod_src_install
1340 +
1341 + # Add the aliases
1342 + # This file is tweaked with the appropriate video group in
1343 + # pkg_preinst, see bug #491414
1344 + insinto /etc/modprobe.d
1345 + newins "${FILESDIR}"/nvidia-169.07 nvidia.conf
1346 + doins "${FILESDIR}"/nvidia-rmmod.conf
1347 +
1348 + # Ensures that our device nodes are created when not using X
1349 + exeinto "$(get_udevdir)"
1350 + newexe "${FILESDIR}"/nvidia-udev.sh-r1 nvidia-udev.sh
1351 + udev_newrules "${FILESDIR}"/nvidia.udev-rule 99-nvidia.rules
1352 + elif use kernel_FreeBSD; then
1353 + if use x86-fbsd; then
1354 + insinto /boot/modules
1355 + doins "${S}/src/nvidia.kld"
1356 + fi
1357 +
1358 + exeinto /boot/modules
1359 + doexe "${S}/src/nvidia.ko"
1360 + fi
1361 +
1362 + # NVIDIA kernel <-> userspace driver config lib
1363 + donvidia "${NV_OBJ}"/libnvidia-cfg.so.${NV_SOVER}
1364 +
1365 + # NVIDIA framebuffer capture library
1366 + donvidia "${NV_OBJ}"/libnvidia-fbc.so.${NV_SOVER}
1367 +
1368 + # NVIDIA video encode/decode <-> CUDA
1369 + if use kernel_linux; then
1370 + donvidia "${NV_OBJ}"/libnvcuvid.so.${NV_SOVER}
1371 + donvidia "${NV_OBJ}"/libnvidia-encode.so.${NV_SOVER}
1372 + fi
1373 +
1374 + if use X; then
1375 + # Xorg DDX driver
1376 + insinto /usr/$(get_libdir)/xorg/modules/drivers
1377 + doins "${NV_X11}"/nvidia_drv.so
1378 +
1379 + # Xorg GLX driver
1380 + donvidia "${NV_X11}"/libglx.so.${NV_SOVER} \
1381 + /usr/$(get_libdir)/opengl/nvidia/extensions
1382 +
1383 + # Xorg nvidia.conf
1384 + if has_version '>=x11-base/xorg-server-1.16'; then
1385 + insinto /usr/share/X11/xorg.conf.d
1386 + newins {,50-}nvidia-drm-outputclass.conf
1387 + fi
1388 +
1389 + insinto /usr/share/glvnd/egl_vendor.d
1390 + doins "${NV_X11}"/10_nvidia.json
1391 + fi
1392 +
1393 + # OpenCL ICD for NVIDIA
1394 + if use kernel_linux; then
1395 + insinto /etc/OpenCL/vendors
1396 + doins "${NV_OBJ}"/nvidia.icd
1397 + fi
1398 +
1399 + # Documentation
1400 + if use kernel_FreeBSD; then
1401 + dodoc "${NV_DOC}"/README
1402 + use X && doman "${NV_MAN}"/nvidia-xconfig.1
1403 + use tools && doman "${NV_MAN}"/nvidia-settings.1
1404 + else
1405 + # Docs
1406 + newdoc "${NV_DOC}"/README.txt README
1407 + dodoc "${NV_DOC}"/NVIDIA_Changelog
1408 + doman "${NV_MAN}"/nvidia-smi.1
1409 + use X && doman "${NV_MAN}"/nvidia-xconfig.1
1410 + use tools && doman "${NV_MAN}"/nvidia-settings.1
1411 + doman "${NV_MAN}"/nvidia-cuda-mps-control.1
1412 + fi
1413 +
1414 + docinto html
1415 + dodoc -r "${NV_DOC}"/html/*
1416 +
1417 + # Helper Apps
1418 + exeinto /opt/bin/
1419 +
1420 + if use X; then
1421 + doexe "${NV_OBJ}"/nvidia-xconfig
1422 +
1423 + insinto /etc/vulkan/icd.d
1424 + doins nvidia_icd.json
1425 + fi
1426 +
1427 + if use kernel_linux; then
1428 + doexe "${NV_OBJ}"/nvidia-cuda-mps-control
1429 + doexe "${NV_OBJ}"/nvidia-cuda-mps-server
1430 + doexe "${NV_OBJ}"/nvidia-debugdump
1431 + doexe "${NV_OBJ}"/nvidia-persistenced
1432 + doexe "${NV_OBJ}"/nvidia-smi
1433 +
1434 + # install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092)
1435 + doexe "${NV_OBJ}"/nvidia-modprobe
1436 + fowners root:video /opt/bin/nvidia-modprobe
1437 + fperms 4710 /opt/bin/nvidia-modprobe
1438 + dosym /{opt,usr}/bin/nvidia-modprobe
1439 +
1440 + doman nvidia-cuda-mps-control.1
1441 + doman nvidia-modprobe.1
1442 + doman nvidia-persistenced.1
1443 + newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi
1444 + newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced
1445 + newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced
1446 + fi
1447 +
1448 + if use tools; then
1449 + emake -C "${S}"/nvidia-settings-${PV}/src/ \
1450 + DESTDIR="${D}" \
1451 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
1452 + LIBDIR="${D}/usr/$(get_libdir)" \
1453 + NV_USE_BUNDLED_LIBJANSSON=0 \
1454 + NV_VERBOSE=1 \
1455 + PREFIX=/usr \
1456 + DO_STRIP= \
1457 + install
1458 +
1459 + if use static-libs; then
1460 + dolib.a "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/libXNVCtrl.a
1461 +
1462 + insinto /usr/include/NVCtrl
1463 + doins "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/*.h
1464 + fi
1465 +
1466 + insinto /usr/share/nvidia/
1467 + doins nvidia-application-profiles-${PV}-key-documentation
1468 +
1469 + insinto /etc/nvidia
1470 + newins \
1471 + nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc
1472 +
1473 + # There is no icon in the FreeBSD tarball.
1474 + use kernel_FreeBSD || \
1475 + doicon "${NV_OBJ}"/nvidia-settings.png
1476 +
1477 + domenu "${FILESDIR}"/nvidia-settings.desktop
1478 +
1479 + exeinto /etc/X11/xinit/xinitrc.d
1480 + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings
1481 + fi
1482 +
1483 + dobin "${NV_OBJ}"/nvidia-bug-report.sh
1484 +
1485 + if has_multilib_profile && use multilib; then
1486 + local OABI=${ABI}
1487 + for ABI in $(get_install_abis); do
1488 + src_install-libs
1489 + done
1490 + ABI=${OABI}
1491 + unset OABI
1492 + else
1493 + src_install-libs
1494 + fi
1495 +
1496 + is_final_abi || die "failed to iterate through all ABIs"
1497 +
1498 + readme.gentoo_create_doc
1499 +}
1500 +
1501 +src_install-libs() {
1502 + local inslibdir=$(get_libdir)
1503 + local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib"
1504 + local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia"
1505 + local nv_libdir="${NV_OBJ}"
1506 +
1507 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "x86" ]]; then
1508 + nv_libdir="${NV_OBJ}"/32
1509 + fi
1510 +
1511 + if use X; then
1512 + NV_GLX_LIBRARIES=(
1513 + "libEGL.so.$(usex compat ${NV_SOVER} 1) ${GL_ROOT}"
1514 + "libEGL_nvidia.so.${NV_SOVER} ${GL_ROOT}"
1515 + "libGL.so.$(usex compat ${NV_SOVER} 1.0.0) ${GL_ROOT}"
1516 + "libGLESv1_CM.so.1 ${GL_ROOT}"
1517 + "libGLESv1_CM_nvidia.so.${NV_SOVER} ${GL_ROOT}"
1518 + "libGLESv2.so.2 ${GL_ROOT}"
1519 + "libGLESv2_nvidia.so.${NV_SOVER} ${GL_ROOT}"
1520 + "libGLX.so.0 ${GL_ROOT}"
1521 + "libGLX_nvidia.so.${NV_SOVER} ${GL_ROOT}"
1522 + "libGLdispatch.so.0 ${GL_ROOT}"
1523 + "libOpenCL.so.1.0.0 ${CL_ROOT}"
1524 + "libOpenGL.so.0 ${GL_ROOT}"
1525 + "libcuda.so.${NV_SOVER}"
1526 + "libnvcuvid.so.${NV_SOVER}"
1527 + "libnvidia-compiler.so.${NV_SOVER}"
1528 + "libnvidia-eglcore.so.${NV_SOVER}"
1529 + "libnvidia-encode.so.${NV_SOVER}"
1530 + "libnvidia-fatbinaryloader.so.${NV_SOVER}"
1531 + "libnvidia-fbc.so.${NV_SOVER}"
1532 + "libnvidia-glcore.so.${NV_SOVER}"
1533 + "libnvidia-glsi.so.${NV_SOVER}"
1534 + "libnvidia-ifr.so.${NV_SOVER}"
1535 + "libnvidia-opencl.so.${NV_SOVER}"
1536 + "libnvidia-ptxjitcompiler.so.${NV_SOVER}"
1537 + "libvdpau_nvidia.so.${NV_SOVER}"
1538 + )
1539 +
1540 + if use wayland && has_multilib_profile && [[ ${ABI} == "amd64" ]];
1541 + then
1542 + NV_GLX_LIBRARIES+=(
1543 + "libnvidia-egl-wayland.so.${NV_SOVER}"
1544 + )
1545 + fi
1546 +
1547 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "amd64" ]];
1548 + then
1549 + NV_GLX_LIBRARIES+=(
1550 + "libnvidia-wfb.so.${NV_SOVER}"
1551 + )
1552 + fi
1553 +
1554 + if use kernel_FreeBSD; then
1555 + NV_GLX_LIBRARIES+=(
1556 + "libnvidia-tls.so.${NV_SOVER}"
1557 + )
1558 + fi
1559 +
1560 + if use kernel_linux; then
1561 + NV_GLX_LIBRARIES+=(
1562 + "libnvidia-ml.so.${NV_SOVER}"
1563 + "tls/libnvidia-tls.so.${NV_SOVER}"
1564 + )
1565 + fi
1566 +
1567 + for NV_LIB in "${NV_GLX_LIBRARIES[@]}"; do
1568 + donvidia "${nv_libdir}"/${NV_LIB}
1569 + done
1570 + fi
1571 +}
1572 +
1573 +pkg_preinst() {
1574 + if use driver && use kernel_linux; then
1575 + linux-mod_pkg_preinst
1576 +
1577 + local videogroup="$(egetent group video | cut -d ':' -f 3)"
1578 + if [ -z "${videogroup}" ]; then
1579 + eerror "Failed to determine the video group gid"
1580 + die "Failed to determine the video group gid"
1581 + else
1582 + sed -i \
1583 + -e "s:PACKAGE:${PF}:g" \
1584 + -e "s:VIDEOGID:${videogroup}:" \
1585 + "${D}"/etc/modprobe.d/nvidia.conf || die
1586 + fi
1587 + fi
1588 +
1589 + # Clean the dynamic libGL stuff's home to ensure
1590 + # we dont have stale libs floating around
1591 + if [ -d "${ROOT}"/usr/lib/opengl/nvidia ]; then
1592 + rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
1593 + fi
1594 + # Make sure we nuke the old nvidia-glx's env.d file
1595 + if [ -e "${ROOT}"/etc/env.d/09nvidia ]; then
1596 + rm -f "${ROOT}"/etc/env.d/09nvidia
1597 + fi
1598 +}
1599 +
1600 +pkg_postinst() {
1601 + use driver && use kernel_linux && linux-mod_pkg_postinst
1602 +
1603 + # Switch to the nvidia implementation
1604 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia
1605 + "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia
1606 +
1607 + readme.gentoo_print_elog
1608 +
1609 + if ! use X; then
1610 + elog "You have elected to not install the X.org driver. Along with"
1611 + elog "this the OpenGL libraries and VDPAU libraries were not"
1612 + elog "installed. Additionally, once the driver is loaded your card"
1613 + elog "and fan will run at max speed which may not be desirable."
1614 + elog "Use the 'nvidia-smi' init script to have your card and fan"
1615 + elog "speed scale appropriately."
1616 + elog
1617 + fi
1618 + if ! use tools; then
1619 + elog "USE=tools controls whether the nvidia-settings application"
1620 + elog "is installed. If you would like to use it, enable that"
1621 + elog "flag and re-emerge this ebuild. Optionally you can install"
1622 + elog "media-video/nvidia-settings"
1623 + elog
1624 + fi
1625 +}
1626 +
1627 +pkg_prerm() {
1628 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
1629 +}
1630 +
1631 +pkg_postrm() {
1632 + use driver && use kernel_linux && linux-mod_pkg_postrm
1633 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
1634 +}
1635
1636 diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-378.13-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-378.13-r1.ebuild
1637 new file mode 100644
1638 index 00000000000..1bf233cbbfd
1639 --- /dev/null
1640 +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-378.13-r1.ebuild
1641 @@ -0,0 +1,572 @@
1642 +# Copyright 1999-2017 Gentoo Foundation
1643 +# Distributed under the terms of the GNU General Public License v2
1644 +
1645 +EAPI=6
1646 +inherit eutils flag-o-matic linux-info linux-mod multilib-minimal nvidia-driver \
1647 + portability toolchain-funcs unpacker user udev
1648 +
1649 +NV_URI="http://http.download.nvidia.com/XFree86/"
1650 +X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}"
1651 +AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}"
1652 +ARM_NV_PACKAGE="NVIDIA-Linux-armv7l-gnueabihf-${PV}"
1653 +X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}"
1654 +AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}"
1655 +
1656 +DESCRIPTION="NVIDIA Accelerated Graphics Driver"
1657 +HOMEPAGE="http://www.nvidia.com/ http://www.nvidia.com/Download/Find.aspx"
1658 +SRC_URI="
1659 + amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz )
1660 + amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )
1661 + arm? ( ${NV_URI}Linux-32bit-ARM/${PV}/${ARM_NV_PACKAGE}.run )
1662 + x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )
1663 + x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run )
1664 + tools? (
1665 + https://github.com/NVIDIA/nvidia-settings/archive/${PV}.tar.gz -> nvidia-settings-${PV}.tar.gz
1666 + )
1667 +"
1668 +
1669 +LICENSE="GPL-2 NVIDIA-r2"
1670 +SLOT="0/${PV%.*}"
1671 +KEYWORDS="-* ~amd64 ~x86 ~amd64-fbsd ~x86-fbsd"
1672 +RESTRICT="bindist mirror"
1673 +EMULTILIB_PKG="true"
1674 +
1675 +IUSE="acpi compat +driver gtk3 kernel_FreeBSD kernel_linux +kms multilib pax_kernel static-libs +tools uvm wayland +X"
1676 +REQUIRED_USE="
1677 + tools? ( X )
1678 + static-libs? ( tools )
1679 +"
1680 +
1681 +COMMON="
1682 + app-eselect/eselect-opencl
1683 + kernel_linux? ( >=sys-libs/glibc-2.6.1 )
1684 + tools? (
1685 + dev-libs/atk
1686 + dev-libs/glib:2
1687 + dev-libs/jansson
1688 + gtk3? (
1689 + x11-libs/gtk+:3
1690 + )
1691 + x11-libs/cairo
1692 + x11-libs/gdk-pixbuf[X]
1693 + x11-libs/gtk+:2
1694 + x11-libs/libX11
1695 + x11-libs/libXext
1696 + x11-libs/libXrandr
1697 + x11-libs/libXv
1698 + x11-libs/libXxf86vm
1699 + x11-libs/pango[X]
1700 + )
1701 + X? (
1702 + >=app-eselect/eselect-opengl-1.0.9
1703 + app-misc/pax-utils
1704 + )
1705 +"
1706 +DEPEND="
1707 + ${COMMON}
1708 + kernel_linux? ( virtual/linux-sources )
1709 +"
1710 +RDEPEND="
1711 + ${COMMON}
1712 + acpi? ( sys-power/acpid )
1713 + tools? ( !media-video/nvidia-settings )
1714 + wayland? ( dev-libs/wayland[${MULTILIB_USEDEP}] )
1715 + X? (
1716 + <x11-base/xorg-server-1.19.99:=
1717 + >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
1718 + >=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}]
1719 + >=x11-libs/libvdpau-1.0[${MULTILIB_USEDEP}]
1720 + sys-libs/zlib[${MULTILIB_USEDEP}]
1721 + )
1722 +"
1723 +
1724 +QA_PREBUILT="opt/* usr/lib*"
1725 +
1726 +S=${WORKDIR}/
1727 +
1728 +nvidia_drivers_versions_check() {
1729 + if use amd64 && has_multilib_profile && \
1730 + [ "${DEFAULT_ABI}" != "amd64" ]; then
1731 + eerror "This ebuild doesn't currently support changing your default ABI"
1732 + die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
1733 + fi
1734 +
1735 + if use kernel_linux && kernel_is ge 4 10; then
1736 + ewarn "Gentoo supports kernels which are supported by NVIDIA"
1737 + ewarn "which are limited to the following kernels:"
1738 + ewarn "<sys-kernel/gentoo-sources-4.10"
1739 + ewarn "<sys-kernel/vanilla-sources-4.10"
1740 + ewarn ""
1741 + ewarn "You are free to utilize epatch_user to provide whatever"
1742 + ewarn "support you feel is appropriate, but will not receive"
1743 + ewarn "support as a result of those changes."
1744 + ewarn ""
1745 + ewarn "Do not file a bug report about this."
1746 + ewarn ""
1747 + fi
1748 +
1749 + # Since Nvidia ships many different series of drivers, we need to give the user
1750 + # some kind of guidance as to what version they should install. This tries
1751 + # to point the user in the right direction but can't be perfect. check
1752 + # nvidia-driver.eclass
1753 + nvidia-driver-check-warning
1754 +
1755 + # Kernel features/options to check for
1756 + CONFIG_CHECK="~ZONE_DMA ~MTRR ~SYSVIPC ~!LOCKDEP"
1757 + use x86 && CONFIG_CHECK+=" ~HIGHMEM"
1758 +
1759 + # Now do the above checks
1760 + use kernel_linux && check_extra_config
1761 +}
1762 +
1763 +pkg_pretend() {
1764 + nvidia_drivers_versions_check
1765 +}
1766 +
1767 +pkg_setup() {
1768 + nvidia_drivers_versions_check
1769 +
1770 + # try to turn off distcc and ccache for people that have a problem with it
1771 + export DISTCC_DISABLE=1
1772 + export CCACHE_DISABLE=1
1773 +
1774 + if use driver && use kernel_linux; then
1775 + MODULE_NAMES="nvidia(video:${S}/kernel)"
1776 + use uvm && MODULE_NAMES+=" nvidia-uvm(video:${S}/kernel)"
1777 + use kms && MODULE_NAMES+=" nvidia-modeset(video:${S}/kernel) nvidia-drm(video:${S}/kernel)"
1778 +
1779 + # This needs to run after MODULE_NAMES (so that the eclass checks
1780 + # whether the kernel supports loadable modules) but before BUILD_PARAMS
1781 + # is set (so that KV_DIR is populated).
1782 + linux-mod_pkg_setup
1783 +
1784 + BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
1785 + SYSOUT=${KV_OUT_DIR} CC=$(tc-getBUILD_CC) NV_VERBOSE=1"
1786 +
1787 + # linux-mod_src_compile calls set_arch_to_kernel, which
1788 + # sets the ARCH to x86 but NVIDIA's wrapping Makefile
1789 + # expects x86_64 or i386 and then converts it to x86
1790 + # later on in the build process
1791 + BUILD_FIXES="ARCH=$(uname -m | sed -e 's/i.86/i386/')"
1792 + fi
1793 +
1794 + if use kernel_linux && kernel_is lt 2 6 9; then
1795 + eerror "You must build this against 2.6.9 or higher kernels."
1796 + fi
1797 +
1798 + # set variables to where files are in the package structure
1799 + if use kernel_FreeBSD; then
1800 + use x86-fbsd && S="${WORKDIR}/${X86_FBSD_NV_PACKAGE}"
1801 + use amd64-fbsd && S="${WORKDIR}/${AMD64_FBSD_NV_PACKAGE}"
1802 + NV_DOC="${S}/doc"
1803 + NV_OBJ="${S}/obj"
1804 + NV_SRC="${S}/src"
1805 + NV_MAN="${S}/x11/man"
1806 + NV_X11="${S}/obj"
1807 + NV_SOVER=1
1808 + elif use kernel_linux; then
1809 + NV_DOC="${S}"
1810 + NV_OBJ="${S}"
1811 + NV_SRC="${S}/kernel"
1812 + NV_MAN="${S}"
1813 + NV_X11="${S}"
1814 + NV_SOVER=${PV}
1815 + else
1816 + die "Could not determine proper NVIDIA package"
1817 + fi
1818 +}
1819 +
1820 +src_prepare() {
1821 + if use pax_kernel; then
1822 + ewarn "Using PAX patches is not supported. You will be asked to"
1823 + ewarn "use a standard kernel should you have issues. Should you"
1824 + ewarn "need support with these patches, contact the PaX team."
1825 + eapply "${FILESDIR}"/${PN}-375.20-pax.patch
1826 + fi
1827 +
1828 + local man_file
1829 + for man_file in "${NV_MAN}"/*1.gz; do
1830 + gunzip $man_file || die
1831 + done
1832 +
1833 + # Allow user patches so they can support RC kernels and whatever else
1834 + eapply_user
1835 +}
1836 +
1837 +src_compile() {
1838 + # This is already the default on Linux, as there's no toplevel Makefile, but
1839 + # on FreeBSD there's one and triggers the kernel module build, as we install
1840 + # it by itself, pass this.
1841 +
1842 + cd "${NV_SRC}"
1843 + if use kernel_FreeBSD; then
1844 + MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
1845 + LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
1846 + elif use driver && use kernel_linux; then
1847 + MAKEOPTS=-j1 linux-mod_src_compile
1848 + fi
1849 +
1850 + if use tools; then
1851 + emake -C "${S}"/nvidia-settings-${PV}/src \
1852 + AR="$(tc-getAR)" \
1853 + CC="$(tc-getCC)" \
1854 + LIBDIR="$(get_libdir)" \
1855 + NV_VERBOSE=1 \
1856 + RANLIB="$(tc-getRANLIB)" \
1857 + DO_STRIP= \
1858 + build-xnvctrl
1859 +
1860 + emake -C "${S}"/nvidia-settings-${PV}/src \
1861 + CC="$(tc-getCC)" \
1862 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
1863 + LD="$(tc-getCC)" \
1864 + LIBDIR="$(get_libdir)" \
1865 + NVML_ENABLED=0 \
1866 + NV_USE_BUNDLED_LIBJANSSON=0 \
1867 + NV_VERBOSE=1 \
1868 + DO_STRIP=
1869 + fi
1870 +}
1871 +
1872 +# Install nvidia library:
1873 +# the first parameter is the library to install
1874 +# the second parameter is the provided soversion
1875 +# the third parameter is the target directory if it is not /usr/lib
1876 +donvidia() {
1877 + # Full path to library
1878 + nv_LIB="${1}"
1879 +
1880 + # SOVER to use
1881 + nv_SOVER="$(scanelf -qF'%S#F' ${nv_LIB})"
1882 +
1883 + # Where to install
1884 + nv_DEST="${2}"
1885 +
1886 + # Get just the library name
1887 + nv_LIBNAME=$(basename "${nv_LIB}")
1888 +
1889 + if [[ "${nv_DEST}" ]]; then
1890 + exeinto ${nv_DEST}
1891 + action="doexe"
1892 + else
1893 + nv_DEST="/usr/$(get_libdir)"
1894 + action="dolib.so"
1895 + fi
1896 +
1897 + # Install the library
1898 + ${action} ${nv_LIB} || die "failed to install ${nv_LIBNAME}"
1899 +
1900 + # If the library has a SONAME and SONAME does not match the library name,
1901 + # then we need to create a symlink
1902 + if [[ ${nv_SOVER} ]] && ! [[ "${nv_SOVER}" = "${nv_LIBNAME}" ]]; then
1903 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_SOVER} \
1904 + || die "failed to create ${nv_DEST}/${nv_SOVER} symlink"
1905 + fi
1906 +
1907 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_LIBNAME/.so*/.so} \
1908 + || die "failed to create ${nv_LIBNAME/.so*/.so} symlink"
1909 +}
1910 +
1911 +src_install() {
1912 + if use driver && use kernel_linux; then
1913 + linux-mod_src_install
1914 +
1915 + # Add the aliases
1916 + # This file is tweaked with the appropriate video group in
1917 + # pkg_preinst, see bug #491414
1918 + insinto /etc/modprobe.d
1919 + newins "${FILESDIR}"/nvidia-169.07 nvidia.conf
1920 + doins "${FILESDIR}"/nvidia-rmmod.conf
1921 +
1922 + # Ensures that our device nodes are created when not using X
1923 + exeinto "$(get_udevdir)"
1924 + newexe "${FILESDIR}"/nvidia-udev.sh-r1 nvidia-udev.sh
1925 + udev_newrules "${FILESDIR}"/nvidia.udev-rule 99-nvidia.rules
1926 + elif use kernel_FreeBSD; then
1927 + if use x86-fbsd; then
1928 + insinto /boot/modules
1929 + doins "${S}/src/nvidia.kld"
1930 + fi
1931 +
1932 + exeinto /boot/modules
1933 + doexe "${S}/src/nvidia.ko"
1934 + fi
1935 +
1936 + # NVIDIA kernel <-> userspace driver config lib
1937 + donvidia ${NV_OBJ}/libnvidia-cfg.so.${NV_SOVER}
1938 +
1939 + # NVIDIA framebuffer capture library
1940 + donvidia ${NV_OBJ}/libnvidia-fbc.so.${NV_SOVER}
1941 +
1942 + # NVIDIA video encode/decode <-> CUDA
1943 + if use kernel_linux; then
1944 + donvidia ${NV_OBJ}/libnvcuvid.so.${NV_SOVER}
1945 + donvidia ${NV_OBJ}/libnvidia-encode.so.${NV_SOVER}
1946 + fi
1947 +
1948 + if use X; then
1949 + # Xorg DDX driver
1950 + insinto /usr/$(get_libdir)/xorg/modules/drivers
1951 + doins ${NV_X11}/nvidia_drv.so
1952 +
1953 + # Xorg GLX driver
1954 + donvidia ${NV_X11}/libglx.so.${NV_SOVER} \
1955 + /usr/$(get_libdir)/opengl/nvidia/extensions
1956 +
1957 + # Xorg nvidia.conf
1958 + if has_version '>=x11-base/xorg-server-1.16'; then
1959 + insinto /usr/share/X11/xorg.conf.d
1960 + newins {,50-}nvidia-drm-outputclass.conf
1961 + fi
1962 +
1963 + insinto /usr/share/glvnd/egl_vendor.d
1964 + doins ${NV_X11}/10_nvidia.json
1965 + fi
1966 +
1967 + if use wayland; then
1968 + insinto /usr/share/egl/egl_external_platform.d
1969 + doins ${NV_X11}/10_nvidia_wayland.json
1970 + fi
1971 +
1972 + # OpenCL ICD for NVIDIA
1973 + if use kernel_linux; then
1974 + insinto /etc/OpenCL/vendors
1975 + doins ${NV_OBJ}/nvidia.icd
1976 + fi
1977 +
1978 + # Documentation
1979 + if use kernel_FreeBSD; then
1980 + dodoc "${NV_DOC}/README"
1981 + use X && doman "${NV_MAN}/nvidia-xconfig.1"
1982 + use tools && doman "${NV_MAN}/nvidia-settings.1"
1983 + else
1984 + # Docs
1985 + newdoc "${NV_DOC}/README.txt" README
1986 + dodoc "${NV_DOC}/NVIDIA_Changelog"
1987 + doman "${NV_MAN}"/nvidia-smi.1
1988 + use X && doman "${NV_MAN}"/nvidia-xconfig.1
1989 + use tools && doman "${NV_MAN}"/nvidia-settings.1
1990 + doman "${NV_MAN}"/nvidia-cuda-mps-control.1
1991 + fi
1992 +
1993 + docinto html
1994 + dodoc -r ${NV_DOC}/html/*
1995 +
1996 + # Helper Apps
1997 + exeinto /opt/bin/
1998 +
1999 + if use X; then
2000 + doexe ${NV_OBJ}/nvidia-xconfig
2001 +
2002 + insinto /etc/vulkan/icd.d
2003 + doins nvidia_icd.json
2004 + fi
2005 +
2006 + if use kernel_linux; then
2007 + doexe ${NV_OBJ}/nvidia-cuda-mps-control
2008 + doexe ${NV_OBJ}/nvidia-cuda-mps-server
2009 + doexe ${NV_OBJ}/nvidia-debugdump
2010 + doexe ${NV_OBJ}/nvidia-persistenced
2011 + doexe ${NV_OBJ}/nvidia-smi
2012 +
2013 + # install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092)
2014 + doexe ${NV_OBJ}/nvidia-modprobe
2015 + fowners root:video /opt/bin/nvidia-modprobe
2016 + fperms 4710 /opt/bin/nvidia-modprobe
2017 + dosym /{opt,usr}/bin/nvidia-modprobe
2018 +
2019 + doman nvidia-cuda-mps-control.1
2020 + doman nvidia-modprobe.1
2021 + doman nvidia-persistenced.1
2022 + newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi
2023 + newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced
2024 + newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced
2025 + fi
2026 +
2027 + if use tools; then
2028 + emake -C "${S}"/nvidia-settings-${PV}/src/ \
2029 + DESTDIR="${D}" \
2030 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
2031 + LIBDIR="${D}/usr/$(get_libdir)" \
2032 + NV_USE_BUNDLED_LIBJANSSON=0 \
2033 + NV_VERBOSE=1 \
2034 + PREFIX=/usr \
2035 + DO_STRIP= \
2036 + install
2037 +
2038 + if use static-libs; then
2039 + dolib.a "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/libXNVCtrl.a
2040 +
2041 + insinto /usr/include/NVCtrl
2042 + doins "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/*.h
2043 + fi
2044 +
2045 + insinto /usr/share/nvidia/
2046 + doins nvidia-application-profiles-${PV}-key-documentation
2047 +
2048 + insinto /etc/nvidia
2049 + newins \
2050 + nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc
2051 +
2052 + # There is no icon in the FreeBSD tarball.
2053 + use kernel_FreeBSD || \
2054 + doicon ${NV_OBJ}/nvidia-settings.png
2055 +
2056 + domenu "${FILESDIR}"/nvidia-settings.desktop
2057 +
2058 + exeinto /etc/X11/xinit/xinitrc.d
2059 + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings
2060 + fi
2061 +
2062 + dobin ${NV_OBJ}/nvidia-bug-report.sh
2063 +
2064 + if has_multilib_profile && use multilib; then
2065 + local OABI=${ABI}
2066 + for ABI in $(get_install_abis); do
2067 + src_install-libs
2068 + done
2069 + ABI=${OABI}
2070 + unset OABI
2071 + else
2072 + src_install-libs
2073 + fi
2074 +
2075 + is_final_abi || die "failed to iterate through all ABIs"
2076 +
2077 + readme.gentoo_create_doc
2078 +}
2079 +
2080 +src_install-libs() {
2081 + local inslibdir=$(get_libdir)
2082 + local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib"
2083 + local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia"
2084 + local nv_libdir="${NV_OBJ}"
2085 +
2086 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "x86" ]]; then
2087 + nv_libdir="${NV_OBJ}"/32
2088 + fi
2089 +
2090 + if use X; then
2091 + NV_GLX_LIBRARIES=(
2092 + "libEGL.so.$(usex compat ${NV_SOVER} 1) ${GL_ROOT}"
2093 + "libEGL_nvidia.so.${NV_SOVER} ${GL_ROOT}"
2094 + "libGL.so.$(usex compat ${NV_SOVER} 1.0.0) ${GL_ROOT}"
2095 + "libGLESv1_CM.so.1 ${GL_ROOT}"
2096 + "libGLESv1_CM_nvidia.so.${NV_SOVER} ${GL_ROOT}"
2097 + "libGLESv2.so.2 ${GL_ROOT}"
2098 + "libGLESv2_nvidia.so.${NV_SOVER} ${GL_ROOT}"
2099 + "libGLX.so.0 ${GL_ROOT}"
2100 + "libGLX_nvidia.so.${NV_SOVER} ${GL_ROOT}"
2101 + "libGLdispatch.so.0 ${GL_ROOT}"
2102 + "libOpenCL.so.1.0.0 ${CL_ROOT}"
2103 + "libOpenGL.so.0 ${GL_ROOT}"
2104 + "libcuda.so.${NV_SOVER}"
2105 + "libnvcuvid.so.${NV_SOVER}"
2106 + "libnvidia-compiler.so.${NV_SOVER}"
2107 + "libnvidia-eglcore.so.${NV_SOVER}"
2108 + "libnvidia-encode.so.${NV_SOVER}"
2109 + "libnvidia-fatbinaryloader.so.${NV_SOVER}"
2110 + "libnvidia-fbc.so.${NV_SOVER}"
2111 + "libnvidia-glcore.so.${NV_SOVER}"
2112 + "libnvidia-glsi.so.${NV_SOVER}"
2113 + "libnvidia-ifr.so.${NV_SOVER}"
2114 + "libnvidia-opencl.so.${NV_SOVER}"
2115 + "libnvidia-ptxjitcompiler.so.${NV_SOVER}"
2116 + "libvdpau_nvidia.so.${NV_SOVER}"
2117 + )
2118 +
2119 + if use wayland && has_multilib_profile && [[ ${ABI} == "amd64" ]];
2120 + then
2121 + NV_GLX_LIBRARIES+=(
2122 + "libnvidia-egl-wayland.so.1.0.1"
2123 + )
2124 + fi
2125 +
2126 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "amd64" ]];
2127 + then
2128 + NV_GLX_LIBRARIES+=(
2129 + "libnvidia-wfb.so.${NV_SOVER}"
2130 + )
2131 + fi
2132 +
2133 + if use kernel_FreeBSD; then
2134 + NV_GLX_LIBRARIES+=(
2135 + "libnvidia-tls.so.${NV_SOVER}"
2136 + )
2137 + fi
2138 +
2139 + if use kernel_linux; then
2140 + NV_GLX_LIBRARIES+=(
2141 + "libnvidia-ml.so.${NV_SOVER}"
2142 + "tls/libnvidia-tls.so.${NV_SOVER}"
2143 + )
2144 + fi
2145 +
2146 + for NV_LIB in "${NV_GLX_LIBRARIES[@]}"; do
2147 + donvidia "${nv_libdir}"/${NV_LIB}
2148 + done
2149 + fi
2150 +}
2151 +
2152 +pkg_preinst() {
2153 + if use driver && use kernel_linux; then
2154 + linux-mod_pkg_preinst
2155 +
2156 + local videogroup="$(egetent group video | cut -d ':' -f 3)"
2157 + if [ -z "${videogroup}" ]; then
2158 + eerror "Failed to determine the video group gid"
2159 + die "Failed to determine the video group gid"
2160 + else
2161 + sed -i \
2162 + -e "s:PACKAGE:${PF}:g" \
2163 + -e "s:VIDEOGID:${videogroup}:" \
2164 + "${D}"/etc/modprobe.d/nvidia.conf || die
2165 + fi
2166 + fi
2167 +
2168 + # Clean the dynamic libGL stuff's home to ensure
2169 + # we dont have stale libs floating around
2170 + if [ -d "${ROOT}"/usr/lib/opengl/nvidia ]; then
2171 + rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
2172 + fi
2173 + # Make sure we nuke the old nvidia-glx's env.d file
2174 + if [ -e "${ROOT}"/etc/env.d/09nvidia ]; then
2175 + rm -f "${ROOT}"/etc/env.d/09nvidia
2176 + fi
2177 +}
2178 +
2179 +pkg_postinst() {
2180 + use driver && use kernel_linux && linux-mod_pkg_postinst
2181 +
2182 + # Switch to the nvidia implementation
2183 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia
2184 + "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia
2185 +
2186 + readme.gentoo_print_elog
2187 +
2188 + if ! use X; then
2189 + elog "You have elected to not install the X.org driver. Along with"
2190 + elog "this the OpenGL libraries and VDPAU libraries were not"
2191 + elog "installed. Additionally, once the driver is loaded your card"
2192 + elog "and fan will run at max speed which may not be desirable."
2193 + elog "Use the 'nvidia-smi' init script to have your card and fan"
2194 + elog "speed scale appropriately."
2195 + elog
2196 + fi
2197 + if ! use tools; then
2198 + elog "USE=tools controls whether the nvidia-settings application"
2199 + elog "is installed. If you would like to use it, enable that"
2200 + elog "flag and re-emerge this ebuild. Optionally you can install"
2201 + elog "media-video/nvidia-settings"
2202 + elog
2203 + fi
2204 +}
2205 +
2206 +pkg_prerm() {
2207 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
2208 +}
2209 +
2210 +pkg_postrm() {
2211 + use driver && use kernel_linux && linux-mod_pkg_postrm
2212 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
2213 +}
2214
2215 diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-381.22-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-381.22-r1.ebuild
2216 new file mode 100644
2217 index 00000000000..15dd5379175
2218 --- /dev/null
2219 +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-381.22-r1.ebuild
2220 @@ -0,0 +1,573 @@
2221 +# Copyright 1999-2017 Gentoo Foundation
2222 +# Distributed under the terms of the GNU General Public License v2
2223 +
2224 +EAPI=6
2225 +inherit eutils flag-o-matic linux-info linux-mod multilib-minimal nvidia-driver \
2226 + portability toolchain-funcs unpacker user udev
2227 +
2228 +NV_URI="http://http.download.nvidia.com/XFree86/"
2229 +X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}"
2230 +AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}"
2231 +ARM_NV_PACKAGE="NVIDIA-Linux-armv7l-gnueabihf-${PV}"
2232 +X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}"
2233 +AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}"
2234 +
2235 +DESCRIPTION="NVIDIA Accelerated Graphics Driver"
2236 +HOMEPAGE="http://www.nvidia.com/ http://www.nvidia.com/Download/Find.aspx"
2237 +SRC_URI="
2238 + amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz )
2239 + amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )
2240 + arm? ( ${NV_URI}Linux-32bit-ARM/${PV}/${ARM_NV_PACKAGE}.run )
2241 + x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )
2242 + x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run )
2243 + tools? (
2244 + https://github.com/NVIDIA/nvidia-settings/archive/${PV}.tar.gz -> nvidia-settings-${PV}.tar.gz
2245 + )
2246 +"
2247 +
2248 +LICENSE="GPL-2 NVIDIA-r2"
2249 +SLOT="0/${PV%.*}"
2250 +KEYWORDS="-* ~amd64 ~x86 ~amd64-fbsd ~x86-fbsd"
2251 +RESTRICT="bindist mirror"
2252 +EMULTILIB_PKG="true"
2253 +
2254 +IUSE="acpi compat +driver gtk3 kernel_FreeBSD kernel_linux +kms multilib pax_kernel static-libs +tools uvm wayland +X"
2255 +REQUIRED_USE="
2256 + tools? ( X )
2257 + static-libs? ( tools )
2258 +"
2259 +
2260 +COMMON="
2261 + app-eselect/eselect-opencl
2262 + kernel_linux? ( >=sys-libs/glibc-2.6.1 )
2263 + tools? (
2264 + dev-libs/atk
2265 + dev-libs/glib:2
2266 + dev-libs/jansson
2267 + gtk3? (
2268 + x11-libs/gtk+:3
2269 + )
2270 + x11-libs/cairo
2271 + x11-libs/gdk-pixbuf[X]
2272 + x11-libs/gtk+:2
2273 + x11-libs/libX11
2274 + x11-libs/libXext
2275 + x11-libs/libXrandr
2276 + x11-libs/libXv
2277 + x11-libs/libXxf86vm
2278 + x11-libs/pango[X]
2279 + )
2280 + X? (
2281 + >=app-eselect/eselect-opengl-1.0.9
2282 + app-misc/pax-utils
2283 + )
2284 +"
2285 +DEPEND="
2286 + ${COMMON}
2287 + kernel_linux? ( virtual/linux-sources )
2288 + tools? ( sys-apps/dbus )
2289 +"
2290 +RDEPEND="
2291 + ${COMMON}
2292 + acpi? ( sys-power/acpid )
2293 + tools? ( !media-video/nvidia-settings )
2294 + wayland? ( dev-libs/wayland[${MULTILIB_USEDEP}] )
2295 + X? (
2296 + <x11-base/xorg-server-1.19.99:=
2297 + >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
2298 + >=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}]
2299 + >=x11-libs/libvdpau-1.0[${MULTILIB_USEDEP}]
2300 + sys-libs/zlib[${MULTILIB_USEDEP}]
2301 + )
2302 +"
2303 +
2304 +QA_PREBUILT="opt/* usr/lib*"
2305 +
2306 +S=${WORKDIR}/
2307 +
2308 +nvidia_drivers_versions_check() {
2309 + if use amd64 && has_multilib_profile && \
2310 + [ "${DEFAULT_ABI}" != "amd64" ]; then
2311 + eerror "This ebuild doesn't currently support changing your default ABI"
2312 + die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
2313 + fi
2314 +
2315 + if use kernel_linux && kernel_is ge 4 12; then
2316 + ewarn "Gentoo supports kernels which are supported by NVIDIA"
2317 + ewarn "which are limited to the following kernels:"
2318 + ewarn "<sys-kernel/gentoo-sources-4.12"
2319 + ewarn "<sys-kernel/vanilla-sources-4.12"
2320 + ewarn ""
2321 + ewarn "You are free to utilize epatch_user to provide whatever"
2322 + ewarn "support you feel is appropriate, but will not receive"
2323 + ewarn "support as a result of those changes."
2324 + ewarn ""
2325 + ewarn "Do not file a bug report about this."
2326 + ewarn ""
2327 + fi
2328 +
2329 + # Since Nvidia ships many different series of drivers, we need to give the user
2330 + # some kind of guidance as to what version they should install. This tries
2331 + # to point the user in the right direction but can't be perfect. check
2332 + # nvidia-driver.eclass
2333 + nvidia-driver-check-warning
2334 +
2335 + # Kernel features/options to check for
2336 + CONFIG_CHECK="~ZONE_DMA ~MTRR ~SYSVIPC ~!LOCKDEP"
2337 + use x86 && CONFIG_CHECK+=" ~HIGHMEM"
2338 +
2339 + # Now do the above checks
2340 + use kernel_linux && check_extra_config
2341 +}
2342 +
2343 +pkg_pretend() {
2344 + nvidia_drivers_versions_check
2345 +}
2346 +
2347 +pkg_setup() {
2348 + nvidia_drivers_versions_check
2349 +
2350 + # try to turn off distcc and ccache for people that have a problem with it
2351 + export DISTCC_DISABLE=1
2352 + export CCACHE_DISABLE=1
2353 +
2354 + if use driver && use kernel_linux; then
2355 + MODULE_NAMES="nvidia(video:${S}/kernel)"
2356 + use uvm && MODULE_NAMES+=" nvidia-uvm(video:${S}/kernel)"
2357 + use kms && MODULE_NAMES+=" nvidia-modeset(video:${S}/kernel) nvidia-drm(video:${S}/kernel)"
2358 +
2359 + # This needs to run after MODULE_NAMES (so that the eclass checks
2360 + # whether the kernel supports loadable modules) but before BUILD_PARAMS
2361 + # is set (so that KV_DIR is populated).
2362 + linux-mod_pkg_setup
2363 +
2364 + BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
2365 + SYSOUT=${KV_OUT_DIR} CC=$(tc-getBUILD_CC) NV_VERBOSE=1"
2366 +
2367 + # linux-mod_src_compile calls set_arch_to_kernel, which
2368 + # sets the ARCH to x86 but NVIDIA's wrapping Makefile
2369 + # expects x86_64 or i386 and then converts it to x86
2370 + # later on in the build process
2371 + BUILD_FIXES="ARCH=$(uname -m | sed -e 's/i.86/i386/')"
2372 + fi
2373 +
2374 + if use kernel_linux && kernel_is lt 2 6 9; then
2375 + eerror "You must build this against 2.6.9 or higher kernels."
2376 + fi
2377 +
2378 + # set variables to where files are in the package structure
2379 + if use kernel_FreeBSD; then
2380 + use x86-fbsd && S="${WORKDIR}/${X86_FBSD_NV_PACKAGE}"
2381 + use amd64-fbsd && S="${WORKDIR}/${AMD64_FBSD_NV_PACKAGE}"
2382 + NV_DOC="${S}/doc"
2383 + NV_OBJ="${S}/obj"
2384 + NV_SRC="${S}/src"
2385 + NV_MAN="${S}/x11/man"
2386 + NV_X11="${S}/obj"
2387 + NV_SOVER=1
2388 + elif use kernel_linux; then
2389 + NV_DOC="${S}"
2390 + NV_OBJ="${S}"
2391 + NV_SRC="${S}/kernel"
2392 + NV_MAN="${S}"
2393 + NV_X11="${S}"
2394 + NV_SOVER=${PV}
2395 + else
2396 + die "Could not determine proper NVIDIA package"
2397 + fi
2398 +}
2399 +
2400 +src_prepare() {
2401 + if use pax_kernel; then
2402 + ewarn "Using PAX patches is not supported. You will be asked to"
2403 + ewarn "use a standard kernel should you have issues. Should you"
2404 + ewarn "need support with these patches, contact the PaX team."
2405 + eapply "${FILESDIR}"/${PN}-375.20-pax.patch
2406 + fi
2407 +
2408 + local man_file
2409 + for man_file in "${NV_MAN}"/*1.gz; do
2410 + gunzip $man_file || die
2411 + done
2412 +
2413 + # Allow user patches so they can support RC kernels and whatever else
2414 + eapply_user
2415 +}
2416 +
2417 +src_compile() {
2418 + # This is already the default on Linux, as there's no toplevel Makefile, but
2419 + # on FreeBSD there's one and triggers the kernel module build, as we install
2420 + # it by itself, pass this.
2421 +
2422 + cd "${NV_SRC}"
2423 + if use kernel_FreeBSD; then
2424 + MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
2425 + LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
2426 + elif use driver && use kernel_linux; then
2427 + MAKEOPTS=-j1 linux-mod_src_compile
2428 + fi
2429 +
2430 + if use tools; then
2431 + emake -C "${S}"/nvidia-settings-${PV}/src \
2432 + AR="$(tc-getAR)" \
2433 + CC="$(tc-getCC)" \
2434 + LIBDIR="$(get_libdir)" \
2435 + NV_VERBOSE=1 \
2436 + RANLIB="$(tc-getRANLIB)" \
2437 + DO_STRIP= \
2438 + build-xnvctrl
2439 +
2440 + emake -C "${S}"/nvidia-settings-${PV}/src \
2441 + CC="$(tc-getCC)" \
2442 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
2443 + LD="$(tc-getCC)" \
2444 + LIBDIR="$(get_libdir)" \
2445 + NVML_ENABLED=0 \
2446 + NV_USE_BUNDLED_LIBJANSSON=0 \
2447 + NV_VERBOSE=1 \
2448 + DO_STRIP=
2449 + fi
2450 +}
2451 +
2452 +# Install nvidia library:
2453 +# the first parameter is the library to install
2454 +# the second parameter is the provided soversion
2455 +# the third parameter is the target directory if it is not /usr/lib
2456 +donvidia() {
2457 + # Full path to library
2458 + nv_LIB="${1}"
2459 +
2460 + # SOVER to use
2461 + nv_SOVER="$(scanelf -qF'%S#F' ${nv_LIB})"
2462 +
2463 + # Where to install
2464 + nv_DEST="${2}"
2465 +
2466 + # Get just the library name
2467 + nv_LIBNAME=$(basename "${nv_LIB}")
2468 +
2469 + if [[ "${nv_DEST}" ]]; then
2470 + exeinto ${nv_DEST}
2471 + action="doexe"
2472 + else
2473 + nv_DEST="/usr/$(get_libdir)"
2474 + action="dolib.so"
2475 + fi
2476 +
2477 + # Install the library
2478 + ${action} ${nv_LIB} || die "failed to install ${nv_LIBNAME}"
2479 +
2480 + # If the library has a SONAME and SONAME does not match the library name,
2481 + # then we need to create a symlink
2482 + if [[ ${nv_SOVER} ]] && ! [[ "${nv_SOVER}" = "${nv_LIBNAME}" ]]; then
2483 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_SOVER} \
2484 + || die "failed to create ${nv_DEST}/${nv_SOVER} symlink"
2485 + fi
2486 +
2487 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_LIBNAME/.so*/.so} \
2488 + || die "failed to create ${nv_LIBNAME/.so*/.so} symlink"
2489 +}
2490 +
2491 +src_install() {
2492 + if use driver && use kernel_linux; then
2493 + linux-mod_src_install
2494 +
2495 + # Add the aliases
2496 + # This file is tweaked with the appropriate video group in
2497 + # pkg_preinst, see bug #491414
2498 + insinto /etc/modprobe.d
2499 + newins "${FILESDIR}"/nvidia-169.07 nvidia.conf
2500 + doins "${FILESDIR}"/nvidia-rmmod.conf
2501 +
2502 + # Ensures that our device nodes are created when not using X
2503 + exeinto "$(get_udevdir)"
2504 + newexe "${FILESDIR}"/nvidia-udev.sh-r1 nvidia-udev.sh
2505 + udev_newrules "${FILESDIR}"/nvidia.udev-rule 99-nvidia.rules
2506 + elif use kernel_FreeBSD; then
2507 + if use x86-fbsd; then
2508 + insinto /boot/modules
2509 + doins "${S}/src/nvidia.kld"
2510 + fi
2511 +
2512 + exeinto /boot/modules
2513 + doexe "${S}/src/nvidia.ko"
2514 + fi
2515 +
2516 + # NVIDIA kernel <-> userspace driver config lib
2517 + donvidia ${NV_OBJ}/libnvidia-cfg.so.${NV_SOVER}
2518 +
2519 + # NVIDIA framebuffer capture library
2520 + donvidia ${NV_OBJ}/libnvidia-fbc.so.${NV_SOVER}
2521 +
2522 + # NVIDIA video encode/decode <-> CUDA
2523 + if use kernel_linux; then
2524 + donvidia ${NV_OBJ}/libnvcuvid.so.${NV_SOVER}
2525 + donvidia ${NV_OBJ}/libnvidia-encode.so.${NV_SOVER}
2526 + fi
2527 +
2528 + if use X; then
2529 + # Xorg DDX driver
2530 + insinto /usr/$(get_libdir)/xorg/modules/drivers
2531 + doins ${NV_X11}/nvidia_drv.so
2532 +
2533 + # Xorg GLX driver
2534 + donvidia ${NV_X11}/libglx.so.${NV_SOVER} \
2535 + /usr/$(get_libdir)/opengl/nvidia/extensions
2536 +
2537 + # Xorg nvidia.conf
2538 + if has_version '>=x11-base/xorg-server-1.16'; then
2539 + insinto /usr/share/X11/xorg.conf.d
2540 + newins {,50-}nvidia-drm-outputclass.conf
2541 + fi
2542 +
2543 + insinto /usr/share/glvnd/egl_vendor.d
2544 + doins ${NV_X11}/10_nvidia.json
2545 + fi
2546 +
2547 + if use wayland; then
2548 + insinto /usr/share/egl/egl_external_platform.d
2549 + doins ${NV_X11}/10_nvidia_wayland.json
2550 + fi
2551 +
2552 + # OpenCL ICD for NVIDIA
2553 + if use kernel_linux; then
2554 + insinto /etc/OpenCL/vendors
2555 + doins ${NV_OBJ}/nvidia.icd
2556 + fi
2557 +
2558 + # Documentation
2559 + if use kernel_FreeBSD; then
2560 + dodoc "${NV_DOC}/README"
2561 + use X && doman "${NV_MAN}"/nvidia-xconfig.1
2562 + use tools && doman "${NV_MAN}"/nvidia-settings.1
2563 + else
2564 + # Docs
2565 + newdoc "${NV_DOC}/README.txt" README
2566 + dodoc "${NV_DOC}/NVIDIA_Changelog"
2567 + doman "${NV_MAN}"/nvidia-smi.1
2568 + use X && doman "${NV_MAN}"/nvidia-xconfig.1
2569 + use tools && doman "${NV_MAN}"/nvidia-settings.1
2570 + doman "${NV_MAN}"/nvidia-cuda-mps-control.1
2571 + fi
2572 +
2573 + docinto html
2574 + dodoc -r ${NV_DOC}/html/*
2575 +
2576 + # Helper Apps
2577 + exeinto /opt/bin/
2578 +
2579 + if use X; then
2580 + doexe ${NV_OBJ}/nvidia-xconfig
2581 +
2582 + insinto /etc/vulkan/icd.d
2583 + doins nvidia_icd.json
2584 + fi
2585 +
2586 + if use kernel_linux; then
2587 + doexe ${NV_OBJ}/nvidia-cuda-mps-control
2588 + doexe ${NV_OBJ}/nvidia-cuda-mps-server
2589 + doexe ${NV_OBJ}/nvidia-debugdump
2590 + doexe ${NV_OBJ}/nvidia-persistenced
2591 + doexe ${NV_OBJ}/nvidia-smi
2592 +
2593 + # install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092)
2594 + doexe ${NV_OBJ}/nvidia-modprobe
2595 + fowners root:video /opt/bin/nvidia-modprobe
2596 + fperms 4710 /opt/bin/nvidia-modprobe
2597 + dosym /{opt,usr}/bin/nvidia-modprobe
2598 +
2599 + doman nvidia-cuda-mps-control.1
2600 + doman nvidia-modprobe.1
2601 + doman nvidia-persistenced.1
2602 + newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi
2603 + newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced
2604 + newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced
2605 + fi
2606 +
2607 + if use tools; then
2608 + emake -C "${S}"/nvidia-settings-${PV}/src/ \
2609 + DESTDIR="${D}" \
2610 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
2611 + LIBDIR="${D}/usr/$(get_libdir)" \
2612 + NV_USE_BUNDLED_LIBJANSSON=0 \
2613 + NV_VERBOSE=1 \
2614 + PREFIX=/usr \
2615 + DO_STRIP= \
2616 + install
2617 +
2618 + if use static-libs; then
2619 + dolib.a "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/libXNVCtrl.a
2620 +
2621 + insinto /usr/include/NVCtrl
2622 + doins "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/*.h
2623 + fi
2624 +
2625 + insinto /usr/share/nvidia/
2626 + doins nvidia-application-profiles-${PV}-key-documentation
2627 +
2628 + insinto /etc/nvidia
2629 + newins \
2630 + nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc
2631 +
2632 + # There is no icon in the FreeBSD tarball.
2633 + use kernel_FreeBSD || \
2634 + doicon ${NV_OBJ}/nvidia-settings.png
2635 +
2636 + domenu "${FILESDIR}"/nvidia-settings.desktop
2637 +
2638 + exeinto /etc/X11/xinit/xinitrc.d
2639 + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings
2640 + fi
2641 +
2642 + dobin ${NV_OBJ}/nvidia-bug-report.sh
2643 +
2644 + if has_multilib_profile && use multilib; then
2645 + local OABI=${ABI}
2646 + for ABI in $(get_install_abis); do
2647 + src_install-libs
2648 + done
2649 + ABI=${OABI}
2650 + unset OABI
2651 + else
2652 + src_install-libs
2653 + fi
2654 +
2655 + is_final_abi || die "failed to iterate through all ABIs"
2656 +
2657 + readme.gentoo_create_doc
2658 +}
2659 +
2660 +src_install-libs() {
2661 + local inslibdir=$(get_libdir)
2662 + local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib"
2663 + local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia"
2664 + local nv_libdir="${NV_OBJ}"
2665 +
2666 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "x86" ]]; then
2667 + nv_libdir="${NV_OBJ}"/32
2668 + fi
2669 +
2670 + if use X; then
2671 + NV_GLX_LIBRARIES=(
2672 + "libEGL.so.$(usex compat ${NV_SOVER} 1) ${GL_ROOT}"
2673 + "libEGL_nvidia.so.${NV_SOVER} ${GL_ROOT}"
2674 + "libGL.so.$(usex compat ${NV_SOVER} 1.0.0) ${GL_ROOT}"
2675 + "libGLESv1_CM.so.1 ${GL_ROOT}"
2676 + "libGLESv1_CM_nvidia.so.${NV_SOVER} ${GL_ROOT}"
2677 + "libGLESv2.so.2 ${GL_ROOT}"
2678 + "libGLESv2_nvidia.so.${NV_SOVER} ${GL_ROOT}"
2679 + "libGLX.so.0 ${GL_ROOT}"
2680 + "libGLX_nvidia.so.${NV_SOVER} ${GL_ROOT}"
2681 + "libGLdispatch.so.0 ${GL_ROOT}"
2682 + "libOpenCL.so.1.0.0 ${CL_ROOT}"
2683 + "libOpenGL.so.0 ${GL_ROOT}"
2684 + "libcuda.so.${NV_SOVER}"
2685 + "libnvcuvid.so.${NV_SOVER}"
2686 + "libnvidia-compiler.so.${NV_SOVER}"
2687 + "libnvidia-eglcore.so.${NV_SOVER}"
2688 + "libnvidia-encode.so.${NV_SOVER}"
2689 + "libnvidia-fatbinaryloader.so.${NV_SOVER}"
2690 + "libnvidia-fbc.so.${NV_SOVER}"
2691 + "libnvidia-glcore.so.${NV_SOVER}"
2692 + "libnvidia-glsi.so.${NV_SOVER}"
2693 + "libnvidia-ifr.so.${NV_SOVER}"
2694 + "libnvidia-opencl.so.${NV_SOVER}"
2695 + "libnvidia-ptxjitcompiler.so.${NV_SOVER}"
2696 + "libvdpau_nvidia.so.${NV_SOVER}"
2697 + )
2698 +
2699 + if use wayland && has_multilib_profile && [[ ${ABI} == "amd64" ]];
2700 + then
2701 + NV_GLX_LIBRARIES+=(
2702 + "libnvidia-egl-wayland.so.1.0.1"
2703 + )
2704 + fi
2705 +
2706 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "amd64" ]];
2707 + then
2708 + NV_GLX_LIBRARIES+=(
2709 + "libnvidia-wfb.so.${NV_SOVER}"
2710 + )
2711 + fi
2712 +
2713 + if use kernel_FreeBSD; then
2714 + NV_GLX_LIBRARIES+=(
2715 + "libnvidia-tls.so.${NV_SOVER}"
2716 + )
2717 + fi
2718 +
2719 + if use kernel_linux; then
2720 + NV_GLX_LIBRARIES+=(
2721 + "libnvidia-ml.so.${NV_SOVER}"
2722 + "tls/libnvidia-tls.so.${NV_SOVER}"
2723 + )
2724 + fi
2725 +
2726 + for NV_LIB in "${NV_GLX_LIBRARIES[@]}"; do
2727 + donvidia "${nv_libdir}"/${NV_LIB}
2728 + done
2729 + fi
2730 +}
2731 +
2732 +pkg_preinst() {
2733 + if use driver && use kernel_linux; then
2734 + linux-mod_pkg_preinst
2735 +
2736 + local videogroup="$(egetent group video | cut -d ':' -f 3)"
2737 + if [ -z "${videogroup}" ]; then
2738 + eerror "Failed to determine the video group gid"
2739 + die "Failed to determine the video group gid"
2740 + else
2741 + sed -i \
2742 + -e "s:PACKAGE:${PF}:g" \
2743 + -e "s:VIDEOGID:${videogroup}:" \
2744 + "${D}"/etc/modprobe.d/nvidia.conf || die
2745 + fi
2746 + fi
2747 +
2748 + # Clean the dynamic libGL stuff's home to ensure
2749 + # we dont have stale libs floating around
2750 + if [ -d "${ROOT}"/usr/lib/opengl/nvidia ]; then
2751 + rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
2752 + fi
2753 + # Make sure we nuke the old nvidia-glx's env.d file
2754 + if [ -e "${ROOT}"/etc/env.d/09nvidia ]; then
2755 + rm -f "${ROOT}"/etc/env.d/09nvidia
2756 + fi
2757 +}
2758 +
2759 +pkg_postinst() {
2760 + use driver && use kernel_linux && linux-mod_pkg_postinst
2761 +
2762 + # Switch to the nvidia implementation
2763 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia
2764 + "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia
2765 +
2766 + readme.gentoo_print_elog
2767 +
2768 + if ! use X; then
2769 + elog "You have elected to not install the X.org driver. Along with"
2770 + elog "this the OpenGL libraries and VDPAU libraries were not"
2771 + elog "installed. Additionally, once the driver is loaded your card"
2772 + elog "and fan will run at max speed which may not be desirable."
2773 + elog "Use the 'nvidia-smi' init script to have your card and fan"
2774 + elog "speed scale appropriately."
2775 + elog
2776 + fi
2777 + if ! use tools; then
2778 + elog "USE=tools controls whether the nvidia-settings application"
2779 + elog "is installed. If you would like to use it, enable that"
2780 + elog "flag and re-emerge this ebuild. Optionally you can install"
2781 + elog "media-video/nvidia-settings"
2782 + elog
2783 + fi
2784 +}
2785 +
2786 +pkg_prerm() {
2787 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
2788 +}
2789 +
2790 +pkg_postrm() {
2791 + use driver && use kernel_linux && linux-mod_pkg_postrm
2792 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
2793 +}