From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1066997-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 44526138334
	for <garchives@archives.gentoo.org>; Tue, 15 Jan 2019 17:40:41 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 368BFE09A7;
	Tue, 15 Jan 2019 17:40:40 +0000 (UTC)
Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id E5AF8E09A7
	for <gentoo-commits@lists.gentoo.org>; Tue, 15 Jan 2019 17:40:39 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id EDA97335C5D
	for <gentoo-commits@lists.gentoo.org>; Tue, 15 Jan 2019 17:40:37 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 297BE50A
	for <gentoo-commits@lists.gentoo.org>; Tue, 15 Jan 2019 17:40:36 +0000 (UTC)
From: "Jeroen Roovers" <jer@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Jeroen Roovers" <jer@gentoo.org>
Message-ID: <1547574033.e6849a08559de4479b4a0120193a13bbe20052dc.jer@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: x11-drivers/nvidia-drivers/
X-VCS-Repository: repo/gentoo
X-VCS-Files: x11-drivers/nvidia-drivers/Manifest x11-drivers/nvidia-drivers/nvidia-drivers-415.27.ebuild
X-VCS-Directories: x11-drivers/nvidia-drivers/
X-VCS-Committer: jer
X-VCS-Committer-Name: Jeroen Roovers
X-VCS-Revision: e6849a08559de4479b4a0120193a13bbe20052dc
X-VCS-Branch: master
Date: Tue, 15 Jan 2019 17:40:36 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 3b18f4fd-2da2-42f1-8b5e-a0a53d8053c4
X-Archives-Hash: 8fa1c05699e1305864ac3d25d91c9937

commit:     e6849a08559de4479b4a0120193a13bbe20052dc
Author:     Jeroen Roovers <jer <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 15 17:39:55 2019 +0000
Commit:     Jeroen Roovers <jer <AT> gentoo <DOT> org>
CommitDate: Tue Jan 15 17:40:33 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e6849a08

x11-drivers/nvidia-drivers: Version 415.27

Package-Manager: Portage-2.3.56, Repoman-2.3.12
Signed-off-by: Jeroen Roovers <jer <AT> gentoo.org>

 x11-drivers/nvidia-drivers/Manifest                |   3 +
 .../nvidia-drivers/nvidia-drivers-415.27.ebuild    | 592 +++++++++++++++++++++
 2 files changed, 595 insertions(+)

diff --git a/x11-drivers/nvidia-drivers/Manifest b/x11-drivers/nvidia-drivers/Manifest
index e168b660eda..ec2365e5dd6 100644
--- a/x11-drivers/nvidia-drivers/Manifest
+++ b/x11-drivers/nvidia-drivers/Manifest
@@ -18,6 +18,7 @@ DIST NVIDIA-FreeBSD-x86_64-396.54.tar.gz 60938322 BLAKE2B a23488b625a15703b0c40b
 DIST NVIDIA-FreeBSD-x86_64-410.78.tar.gz 61935486 BLAKE2B 3bc85aacd0775b600c37cd285de49fe3d35bba04fd8d3db1ec75f1fdfbd93a9d5b3d34b67e6fd82b5056bff875ccbc44cd2f06fed9b66703b26057c85f750867 SHA512 30488f9e5e6a377a478c49f13d648fba77ac910f43c3e561ce7715380480ac8b3860fecfb5b745beefadb6abe0b4c4135684c468a69c5b71b56cd463698b931a
 DIST NVIDIA-FreeBSD-x86_64-410.93.tar.gz 61977979 BLAKE2B a662fa13866cfb36ef61a0b9dd459519e26ea93a6ad6ae7bf34075fae8e7622a91707d88cec8de0660513cb959c3596e8b6169357891c83e847870ecffd72928 SHA512 ecdd5270f9d5f32117d83cd3e3cf0376f0b37c748fe164e702c4230d225c6b28bdbbea4334555b6928d05f1a7cfaf87caf20dd2e7e06e1259c526f6bd50e4d0e
 DIST NVIDIA-FreeBSD-x86_64-415.25.tar.gz 62373961 BLAKE2B 4c1ce36ad31933efdb7b9b3a5a530439cadb50c6ee29c0689a521308fbc213266a761765998c44643fd8511159ae96387a3a278accc4a0d00322b06b9b327232 SHA512 792f0cfafb1d6b2137db62c3a5a7e76217d89c3b18cee92ec8317d6c583fdc9676aa46efd55bc795aeaaf1532501f7b40d1d9609d782ffe63e55bb37d0d6db14
+DIST NVIDIA-FreeBSD-x86_64-415.27.tar.gz 62389955 BLAKE2B 39ac5970ef1a6ffbb03abe8b758a6f5d7eaca787231845fa4b4bff5f26aa770fb7c695bbd5585d919c934c65b9ed0cfe42f9674bcaabd796c9bd8b89cea87ee6 SHA512 857d1523bad2fca21c75b45c29066be0f530afa8ca124806bcaa36509ac5135df1c4037e6b09e5718c701f085b3608925e2b1fea45d0681e69a99ef709c307d0
 DIST NVIDIA-Linux-armv7l-gnueabihf-375.82.run 26650801 BLAKE2B 31446667065c56b48f6a3e737afe29a4517459d3462138136bffe383bc6fe514d6e80b49c391c27edc96b8abc3da3dd4d6ee3f3dca17f3c9a0f1cdf0e72cf099 SHA512 28554f1c24fe63c9257c0de3e84e4e739a45bf1c20ec7a53bc2c1b69b4e2355675061491ef5b03f3ae489cf623e553cfa68442f5536f137837327036d1c53d63
 DIST NVIDIA-Linux-armv7l-gnueabihf-378.13.run 26514235 BLAKE2B 2b3c540704496a290be7ae3f1ff378487c75af2298c12488da8b3a1814446e5df02a1ed99afd8ee7fc459d950aab472155359eae0bf56ac83389711d70638152 SHA512 253786a821df85fa926ae842114321b3c70502f887ea7c2b6790dfe3836039ee5d390e6722ca8785904ec6487e465916923d3042dc6191b3b4522c3161b80cb0
 DIST NVIDIA-Linux-armv7l-gnueabihf-381.22.run 26815484 BLAKE2B e5f0241b07d1e54edea2025dd30061d1018c68cc2c7136c507eb894bbad5be3d0724494e2b9f33d1f8f60da4904999bbb964e6f2e78d045d7cd86bcd46b7f6d0 SHA512 934cda37c7aed26243b5b661122e1c060de5b4df890aaf2295b6650dddea37cb4f0e3f0bebddb00b5d687b66ab5e028a203195c4d4ad3379593babda42febe77
@@ -44,6 +45,7 @@ DIST NVIDIA-Linux-x86_64-396.54.run 86946680 BLAKE2B 9b3ab39c9d09c663238d0fac634
 DIST NVIDIA-Linux-x86_64-410.78.run 107944209 BLAKE2B f493efb4b61716ae1f7ac760d57b330e0160e8cd7a90e80dd00744c2277d0c8024f6704eac3a9f95ff13d66f362bf9eecdc8176edb429ea7e45c4622b52beca7 SHA512 0bd7ed61dcfd4d7634ba450b106d7648fc274c256e7e4c4e51e544bd7779d68ffa08cba709ace5333679eeea1dbe4afa0c267361887eaa784d6f1369b717677d
 DIST NVIDIA-Linux-x86_64-410.93.run 107257681 BLAKE2B 56e9b6a17ab4d2fe2f18d90b4e209fe048c53dc43846ee9c8bd0960999a06ef9d9b6ba7e4c242f77cc35cfc5b9a0e2ae24aa5f07f68cb7662bd5010de41a9b36 SHA512 1132884210e447d20768c4ae84ff572c9f6886fb9a082da4d229a03c13932a5c6ccc518cad3311a9302b6a0d9e9675e3a53199e7183e07c81282d46883d26105
 DIST NVIDIA-Linux-x86_64-415.25.run 108599932 BLAKE2B 958a345f03157ebd8f8a84da91af78143ada75be4bf1d5abbbec9bc8b0ca11549891efb2f78c3ae89ed86fa94a4bf179834d1b229b2dc7d3587a138235a8ce7f SHA512 d289a37344916f5d17425f17d0530a7838b264c49866a0148665c9b87dcb7c23e868abae866a2568abac425701149d9075da540dd0f45f3d18f67b57102c0857
+DIST NVIDIA-Linux-x86_64-415.27.run 108399659 BLAKE2B 05fb81a4ab8626d0170a30b70ed114c639ba7f0e5ac260d2f38cb5042a4d6052e40ada51cf2feff6bae0f394781d77cb70014f390873a715b7d9495b86918bf1 SHA512 5919333136042a227ff36c850d0c57898fb428a77d88633d205a269db4b844356a87f5b1e5c3042f40feaf083d4f82d32df5366820375b601f9d69d98cada0b6
 DIST nvidia-settings-304.137.tar.bz2 1481361 BLAKE2B cf52a55a34eeb03a685a683487af6a198ba467dd8ba9983cc75624a37a226373cd931d98e8448b7b8ed430c54be2118c7b240ed2a9100b19bec5e832e2f6cdad SHA512 676d1f70c9a78ee234f5f1a283412430a386fa604de211afba02806a45906c5e246a002989b724d74752178d28c92a268de1c98d4c87876797d991253f16b0cc
 DIST nvidia-settings-340.107.tar.bz2 1549413 BLAKE2B 127442ee2c35ceec47ab4f103bdd2d0278c621fcb9be47051111f6f8728ef5699bdc95fe33a3812a807c38c4868b04c2176e2ed218a422171d2a88ac0c00de96 SHA512 593e7e83aa350a3a7beaaa32aca8660d7e203f6f2e460a6e6eabcdc092087f9917ee4e6d141e37ad4e3b0a1b9908c085e4a71d2f579e481a03bbd1c6f75ca776
 DIST nvidia-settings-375.82.tar.bz2 1620463 BLAKE2B 0c100ee95c91bb53c2192da8ddd1042ce4e0dec7defcf4793a1745020f65d538c4b0d09f690f00034bb02f7ec219048a0539e81031c8b3eb12006f2a0d566d2e SHA512 abc650089cad57ae95a3e3456deb16d2e3c116e148aed83ab40ca5e381445561cdf4c3c0d8676930fb4c73dd5f3282dd1cc1a62d876b7ed07146569ccfb38488
@@ -56,3 +58,4 @@ DIST nvidia-settings-396.54.tar.bz2 1116371 BLAKE2B 114b88f393b0909c8d84a56a2808
 DIST nvidia-settings-410.78.tar.bz2 1115872 BLAKE2B 68471e3c3700c68c1082bd7ca349a791a8b7c9524f71882d78791a11ac4ecaa28d40cdd32baea20354732b4ee8e47767ae8c12d534f95a96494da5787869b4c1 SHA512 28aae1cbec6004d4f532aac2a728d66384440525c3f35f1bf5b7221c4722ccd02be119d44b261204c0f0c116d5455eca7555d10cab3f6d4184a39255750ccf97
 DIST nvidia-settings-410.93.tar.bz2 1115704 BLAKE2B 1119181feb2704711593c19a43dce5feb58778d0251cb2dcb8647de7bfb1abe3a7f374bddd62e4c983b07a207bca7c1d99a7ac51cba3ae41f78fb97c4d1e9666 SHA512 4e5a5babae382dbe9f6899e51d3b1081fd7123f9ba5e147f7d5cc1899904892ea8d953983e43643ea4355d06348db40005755a02c7c0ff6ba104eac4a9d450f2
 DIST nvidia-settings-415.25.tar.bz2 1121689 BLAKE2B acd9dd12b4d9a3d76e08d1498fe2373327308d0764791c7e14c6471cf98e79f635a1073dfacdaa4fa60dd148c15803a18061b185cdea24676d851b3a1b695184 SHA512 8646e4eb8d491cbd20205766833fa9f0629a2567797fbb7ca085e07946f4698645cc134615bc20a42090d4f4fe826df48ab4be717b227ee59c17941d185e0b0b
+DIST nvidia-settings-415.27.tar.bz2 1128013 BLAKE2B 36513252ff3d5f2036c80250e012d79bebfc14daff56fdaabb032856f5f78ce77cf4ce32d6eaee5fe4c1a18db63d5c69d6848517f025c711f133e28b3e509396 SHA512 5ac3b673c41194a1952ec10cd3c961aefd281bb044ecae5c9d11cb55d4555fed44e6056b5a2e97b5b87687743cd7f702f33ce7e0f841f04c8175d63693a24594

diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-415.27.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-415.27.ebuild
new file mode 100644
index 00000000000..93bdc175c38
--- /dev/null
+++ b/x11-drivers/nvidia-drivers/nvidia-drivers-415.27.ebuild
@@ -0,0 +1,592 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+inherit eutils flag-o-matic linux-info linux-mod multilib-minimal nvidia-driver \
+	portability toolchain-funcs unpacker user udev
+
+DESCRIPTION="NVIDIA Accelerated Graphics Driver"
+HOMEPAGE="http://www.nvidia.com/ http://www.nvidia.com/Download/Find.aspx"
+
+AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}"
+AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}"
+ARM_NV_PACKAGE="NVIDIA-Linux-armv7l-gnueabihf-${PV}"
+
+NV_URI="https://us.download.nvidia.com/XFree86/"
+SRC_URI="
+	amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz )
+	amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )
+	tools? (
+		https://download.nvidia.com/XFree86/nvidia-settings/nvidia-settings-${PV}.tar.bz2
+	)
+"
+
+LICENSE="GPL-2 NVIDIA-r2"
+SLOT="0/${PV%.*}"
+KEYWORDS="-* ~amd64 ~amd64-fbsd"
+RESTRICT="bindist mirror"
+EMULTILIB_PKG="true"
+
+IUSE="acpi compat +driver gtk3 kernel_FreeBSD kernel_linux +kms multilib pax_kernel static-libs +tools uvm wayland +X"
+REQUIRED_USE="
+	tools? ( X )
+	static-libs? ( tools )
+"
+
+COMMON="
+	app-eselect/eselect-opencl
+	kernel_linux? ( >=sys-libs/glibc-2.6.1 )
+	tools? (
+		dev-libs/atk
+		dev-libs/glib:2
+		dev-libs/jansson
+		gtk3? (
+			x11-libs/gtk+:3
+		)
+		x11-libs/cairo
+		x11-libs/gdk-pixbuf[X]
+		x11-libs/gtk+:2
+		x11-libs/libX11
+		x11-libs/libXext
+		x11-libs/libXrandr
+		x11-libs/libXv
+		x11-libs/libXxf86vm
+		x11-libs/pango[X]
+	)
+	X? (
+		>=app-eselect/eselect-opengl-1.0.9
+		app-misc/pax-utils
+	)
+"
+DEPEND="
+	${COMMON}
+	kernel_linux? ( virtual/linux-sources )
+	tools? ( sys-apps/dbus )
+"
+RDEPEND="
+	${COMMON}
+	acpi? ( sys-power/acpid )
+	tools? ( !media-video/nvidia-settings )
+	wayland? ( dev-libs/wayland[${MULTILIB_USEDEP}] )
+	X? (
+		<x11-base/xorg-server-1.20.99:=
+		>=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
+		>=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}]
+		>=x11-libs/libvdpau-1.0[${MULTILIB_USEDEP}]
+		sys-libs/zlib[${MULTILIB_USEDEP}]
+	)
+"
+QA_PREBUILT="opt/* usr/lib*"
+S=${WORKDIR}/
+
+nvidia_drivers_versions_check() {
+	if use amd64 && has_multilib_profile && \
+		[ "${DEFAULT_ABI}" != "amd64" ]; then
+		eerror "This ebuild doesn't currently support changing your default ABI"
+		die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
+	fi
+
+	if use kernel_linux && kernel_is ge 4 21; then
+		ewarn "Gentoo supports kernels which are supported by NVIDIA"
+		ewarn "which are limited to the following kernels:"
+		ewarn "<sys-kernel/gentoo-sources-4.21"
+		ewarn "<sys-kernel/vanilla-sources-4.21"
+		ewarn ""
+		ewarn "You are free to utilize epatch_user to provide whatever"
+		ewarn "support you feel is appropriate, but will not receive"
+		ewarn "support as a result of those changes."
+		ewarn ""
+		ewarn "Do not file a bug report about this."
+		ewarn ""
+	fi
+
+	# Since Nvidia ships many different series of drivers, we need to give the user
+	# some kind of guidance as to what version they should install. This tries
+	# to point the user in the right direction but can't be perfect. check
+	# nvidia-driver.eclass
+	nvidia-driver-check-warning
+
+	# Kernel features/options to check for
+	CONFIG_CHECK="!DEBUG_MUTEXES !I2C_NVIDIA_GPU ~!LOCKDEP ~MTRR ~SYSVIPC ~ZONE_DMA"
+
+	# Now do the above checks
+	use kernel_linux && check_extra_config
+}
+
+pkg_pretend() {
+	nvidia_drivers_versions_check
+}
+
+pkg_setup() {
+	nvidia_drivers_versions_check
+
+	# try to turn off distcc and ccache for people that have a problem with it
+	export DISTCC_DISABLE=1
+	export CCACHE_DISABLE=1
+
+	if use driver && use kernel_linux; then
+		MODULE_NAMES="nvidia(video:${S}/kernel)"
+		use uvm && MODULE_NAMES+=" nvidia-uvm(video:${S}/kernel)"
+		use kms && MODULE_NAMES+=" nvidia-modeset(video:${S}/kernel) nvidia-drm(video:${S}/kernel)"
+
+		# This needs to run after MODULE_NAMES (so that the eclass checks
+		# whether the kernel supports loadable modules) but before BUILD_PARAMS
+		# is set (so that KV_DIR is populated).
+		linux-mod_pkg_setup
+
+		BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
+		SYSOUT=${KV_OUT_DIR} CC=$(tc-getBUILD_CC) NV_VERBOSE=1"
+
+		# linux-mod_src_compile calls set_arch_to_kernel, which
+		# sets the ARCH to x86 but NVIDIA's wrapping Makefile
+		# expects x86_64 or i386 and then converts it to x86
+		# later on in the build process
+		BUILD_FIXES="ARCH=$(uname -m | sed -e 's/i.86/i386/')"
+	fi
+
+	if use kernel_linux && kernel_is lt 2 6 9; then
+		eerror "You must build this against 2.6.9 or higher kernels."
+	fi
+
+	# set variables to where files are in the package structure
+	if use kernel_FreeBSD; then
+		use amd64-fbsd && S="${WORKDIR}/${AMD64_FBSD_NV_PACKAGE}"
+		NV_DOC="${S}/doc"
+		NV_OBJ="${S}/obj"
+		NV_SRC="${S}/src"
+		NV_MAN="${S}/x11/man"
+		NV_X11="${S}/obj"
+		NV_SOVER=1
+	elif use kernel_linux; then
+		NV_DOC="${S}"
+		NV_OBJ="${S}"
+		NV_SRC="${S}/kernel"
+		NV_MAN="${S}"
+		NV_X11="${S}"
+		NV_SOVER=${PV}
+	else
+		die "Could not determine proper NVIDIA package"
+	fi
+}
+
+src_prepare() {
+	if use pax_kernel; then
+		ewarn "Using PAX patches is not supported. You will be asked to"
+		ewarn "use a standard kernel should you have issues. Should you"
+		ewarn "need support with these patches, contact the PaX team."
+		eapply "${FILESDIR}"/${PN}-375.20-pax.patch
+	fi
+
+	local man_file
+	for man_file in "${NV_MAN}"/*1.gz; do
+		gunzip $man_file || die
+	done
+
+	if use tools; then
+		cp "${FILESDIR}"/nvidia-settings-linker.patch "${WORKDIR}" || die
+		sed -i \
+			-e "s:@PV@:${PV}:g" \
+			"${WORKDIR}"/nvidia-settings-linker.patch || die
+		eapply "${WORKDIR}"/nvidia-settings-linker.patch
+	fi
+
+	default
+
+	if ! [ -f nvidia_icd.json ]; then
+		cp nvidia_icd.json.template nvidia_icd.json || die
+		sed -i -e 's:__NV_VK_ICD__:libGLX_nvidia.so.0:g' nvidia_icd.json || die
+	fi
+}
+
+src_compile() {
+	# This is already the default on Linux, as there's no toplevel Makefile, but
+	# on FreeBSD there's one and triggers the kernel module build, as we install
+	# it by itself, pass this.
+
+	cd "${NV_SRC}"
+	if use kernel_FreeBSD; then
+		MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
+			LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
+	elif use driver && use kernel_linux; then
+		BUILD_TARGETS=module linux-mod_src_compile \
+			KERNELRELEASE="${KV_FULL}" \
+			src="${KERNEL_DIR}"
+	fi
+
+	if use tools; then
+		emake -C "${S}"/nvidia-settings-${PV}/src \
+			AR="$(tc-getAR)" \
+			CC="$(tc-getCC)" \
+			DO_STRIP= \
+			LD="$(tc-getCC)" \
+			LIBDIR="$(get_libdir)" \
+			NVLD="$(tc-getLD)" \
+			NV_VERBOSE=1 \
+			RANLIB="$(tc-getRANLIB)" \
+			build-xnvctrl
+
+		emake -C "${S}"/nvidia-settings-${PV}/src \
+			CC="$(tc-getCC)" \
+			DO_STRIP= \
+			GTK3_AVAILABLE=$(usex gtk3 1 0) \
+			LD="$(tc-getCC)" \
+			LIBDIR="$(get_libdir)" \
+			NVLD="$(tc-getLD)" \
+			NVML_ENABLED=0 \
+			NV_USE_BUNDLED_LIBJANSSON=0 \
+			NV_VERBOSE=1
+	fi
+}
+
+# Install nvidia library:
+# the first parameter is the library to install
+# the second parameter is the provided soversion
+# the third parameter is the target directory if it is not /usr/lib
+donvidia() {
+	# Full path to library
+	nv_LIB="${1}"
+
+	# SOVER to use
+	nv_SOVER="$(scanelf -qF'%S#F' ${nv_LIB})"
+
+	# Where to install
+	nv_DEST="${2}"
+
+	# Get just the library name
+	nv_LIBNAME=$(basename "${nv_LIB}")
+
+	if [[ "${nv_DEST}" ]]; then
+		exeinto ${nv_DEST}
+		action="doexe"
+	else
+		nv_DEST="/usr/$(get_libdir)"
+		action="dolib.so"
+	fi
+
+	# Install the library
+	${action} ${nv_LIB} || die "failed to install ${nv_LIBNAME}"
+
+	# If the library has a SONAME and SONAME does not match the library name,
+	# then we need to create a symlink
+	if [[ ${nv_SOVER} ]] && ! [[ "${nv_SOVER}" = "${nv_LIBNAME}" ]]; then
+		dosym ${nv_LIBNAME} ${nv_DEST}/${nv_SOVER} \
+			|| die "failed to create ${nv_DEST}/${nv_SOVER} symlink"
+	fi
+
+	dosym ${nv_LIBNAME} ${nv_DEST}/${nv_LIBNAME/.so*/.so} \
+		|| die "failed to create ${nv_LIBNAME/.so*/.so} symlink"
+}
+
+src_install() {
+	if use driver && use kernel_linux; then
+		linux-mod_src_install
+
+		# Add the aliases
+		# This file is tweaked with the appropriate video group in
+		# pkg_preinst, see bug #491414
+		insinto /etc/modprobe.d
+		newins "${FILESDIR}"/nvidia-169.07 nvidia.conf
+		doins "${FILESDIR}"/nvidia-rmmod.conf
+
+		# Ensures that our device nodes are created when not using X
+		exeinto "$(get_udevdir)"
+		newexe "${FILESDIR}"/nvidia-udev.sh-r1 nvidia-udev.sh
+		udev_newrules "${FILESDIR}"/nvidia.udev-rule 99-nvidia.rules
+	elif use kernel_FreeBSD; then
+		if use x86-fbsd; then
+			insinto /boot/modules
+			doins "${S}/src/nvidia.kld"
+		fi
+
+		exeinto /boot/modules
+		doexe "${S}/src/nvidia.ko"
+	fi
+
+	# NVIDIA kernel <-> userspace driver config lib
+	donvidia ${NV_OBJ}/libnvidia-cfg.so.${NV_SOVER}
+
+	# NVIDIA framebuffer capture library
+	donvidia ${NV_OBJ}/libnvidia-fbc.so.${NV_SOVER}
+
+	# NVIDIA video encode/decode <-> CUDA
+	if use kernel_linux; then
+		donvidia ${NV_OBJ}/libnvcuvid.so.${NV_SOVER}
+		donvidia ${NV_OBJ}/libnvidia-encode.so.${NV_SOVER}
+	fi
+
+	if use X; then
+		# Xorg DDX driver
+		insinto /usr/$(get_libdir)/xorg/modules/drivers
+		doins ${NV_X11}/nvidia_drv.so
+
+		# Xorg GLX driver
+		donvidia ${NV_X11}/libglxserver_nvidia.so.${NV_SOVER} \
+			/usr/$(get_libdir)/xorg/modules/extensions
+
+		# Xorg nvidia.conf
+		if has_version '>=x11-base/xorg-server-1.16'; then
+			insinto /usr/share/X11/xorg.conf.d
+			newins {,50-}nvidia-drm-outputclass.conf
+		fi
+
+		insinto /usr/share/glvnd/egl_vendor.d
+		doins ${NV_X11}/10_nvidia.json
+	fi
+
+	if use wayland; then
+		insinto /usr/share/egl/egl_external_platform.d
+		doins ${NV_X11}/10_nvidia_wayland.json
+	fi
+
+	# OpenCL ICD for NVIDIA
+	if use kernel_linux; then
+		insinto /etc/OpenCL/vendors
+		doins ${NV_OBJ}/nvidia.icd
+	fi
+
+	# Documentation
+	if use kernel_FreeBSD; then
+		dodoc "${NV_DOC}/README"
+		use X && doman "${NV_MAN}"/nvidia-xconfig.1
+		use tools && doman "${NV_MAN}"/nvidia-settings.1
+	else
+		# Docs
+		newdoc "${NV_DOC}/README.txt" README
+		dodoc "${NV_DOC}/NVIDIA_Changelog"
+		doman "${NV_MAN}"/nvidia-smi.1
+		use X && doman "${NV_MAN}"/nvidia-xconfig.1
+		use tools && doman "${NV_MAN}"/nvidia-settings.1
+		doman "${NV_MAN}"/nvidia-cuda-mps-control.1
+	fi
+
+	docinto html
+	dodoc -r ${NV_DOC}/html/*
+
+	# Helper Apps
+	exeinto /opt/bin/
+
+	if use X; then
+		doexe ${NV_OBJ}/nvidia-xconfig
+
+		insinto /etc/vulkan/icd.d
+		doins nvidia_icd.json
+	fi
+
+	if use kernel_linux; then
+		doexe ${NV_OBJ}/nvidia-cuda-mps-control
+		doexe ${NV_OBJ}/nvidia-cuda-mps-server
+		doexe ${NV_OBJ}/nvidia-debugdump
+		doexe ${NV_OBJ}/nvidia-persistenced
+		doexe ${NV_OBJ}/nvidia-smi
+
+		# install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092)
+		doexe ${NV_OBJ}/nvidia-modprobe
+		fowners root:video /opt/bin/nvidia-modprobe
+		fperms 4710 /opt/bin/nvidia-modprobe
+		dosym /{opt,usr}/bin/nvidia-modprobe
+
+		doman nvidia-cuda-mps-control.1
+		doman nvidia-modprobe.1
+		doman nvidia-persistenced.1
+		newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi
+		newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced
+		newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced
+	fi
+
+	if use tools; then
+		emake -C "${S}"/nvidia-settings-${PV}/src/ \
+			DESTDIR="${D}" \
+			GTK3_AVAILABLE=$(usex gtk3 1 0) \
+			LIBDIR="${D}/usr/$(get_libdir)" \
+			NV_USE_BUNDLED_LIBJANSSON=0 \
+			NV_VERBOSE=1 \
+			PREFIX=/usr \
+			DO_STRIP= \
+			install
+
+		if use static-libs; then
+			dolib.a "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/libXNVCtrl.a
+
+			insinto /usr/include/NVCtrl
+			doins "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/*.h
+		fi
+
+		insinto /usr/share/nvidia/
+		doins nvidia-application-profiles-${PV}-key-documentation
+
+		insinto /etc/nvidia
+		newins \
+			nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc
+
+		# There is no icon in the FreeBSD tarball.
+		use kernel_FreeBSD || \
+			doicon ${NV_OBJ}/nvidia-settings.png
+
+		domenu "${FILESDIR}"/nvidia-settings.desktop
+
+		exeinto /etc/X11/xinit/xinitrc.d
+		newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings
+	fi
+
+	dobin ${NV_OBJ}/nvidia-bug-report.sh
+
+	if has_multilib_profile && use multilib; then
+		local OABI=${ABI}
+		for ABI in $(get_install_abis); do
+			src_install-libs
+		done
+		ABI=${OABI}
+		unset OABI
+	else
+		src_install-libs
+	fi
+
+	is_final_abi || die "failed to iterate through all ABIs"
+
+	readme.gentoo_create_doc
+}
+
+src_install-libs() {
+	local inslibdir=$(get_libdir)
+	local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib"
+	local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia"
+	local nv_libdir="${NV_OBJ}"
+
+	if use kernel_linux && has_multilib_profile && [[ ${ABI} == "x86" ]]; then
+		nv_libdir="${NV_OBJ}"/32
+	fi
+
+	if use X; then
+		NV_GLX_LIBRARIES=(
+			"libEGL.so.$(usex compat ${NV_SOVER} 1.1.0) ${GL_ROOT}"
+			"libEGL_nvidia.so.${NV_SOVER} ${GL_ROOT}"
+			"libGL.so.$(usex compat ${NV_SOVER} 1.7.0) ${GL_ROOT}"
+			"libGLESv1_CM.so.1.2.0 ${GL_ROOT}"
+			"libGLESv1_CM_nvidia.so.${NV_SOVER} ${GL_ROOT}"
+			"libGLESv2.so.2.1.0 ${GL_ROOT}"
+			"libGLESv2_nvidia.so.${NV_SOVER} ${GL_ROOT}"
+			"libGLX.so.0 ${GL_ROOT}"
+			"libGLX_nvidia.so.${NV_SOVER} ${GL_ROOT}"
+			"libGLdispatch.so.0 ${GL_ROOT}"
+			"libOpenCL.so.1.0.0 ${CL_ROOT}"
+			"libOpenGL.so.0 ${GL_ROOT}"
+			"libcuda.so.${NV_SOVER}"
+			"libnvcuvid.so.${NV_SOVER}"
+			"libnvidia-compiler.so.${NV_SOVER}"
+			"libnvidia-eglcore.so.${NV_SOVER}"
+			"libnvidia-encode.so.${NV_SOVER}"
+			"libnvidia-fatbinaryloader.so.${NV_SOVER}"
+			"libnvidia-fbc.so.${NV_SOVER}"
+			"libnvidia-glcore.so.${NV_SOVER}"
+			"libnvidia-glsi.so.${NV_SOVER}"
+			"libnvidia-glvkspirv.so.${NV_SOVER}"
+			"libnvidia-ifr.so.${NV_SOVER}"
+			"libnvidia-opencl.so.${NV_SOVER}"
+			"libnvidia-ptxjitcompiler.so.${NV_SOVER}"
+			"libvdpau_nvidia.so.${NV_SOVER}"
+		)
+
+		if use wayland && has_multilib_profile && [[ ${ABI} == "amd64" ]];
+		then
+			NV_GLX_LIBRARIES+=(
+				"libnvidia-egl-wayland.so.1.1.0"
+			)
+		fi
+
+		if use kernel_linux && has_multilib_profile && [[ ${ABI} == "amd64" ]];
+		then
+			NV_GLX_LIBRARIES+=(
+				"libnvidia-wfb.so.${NV_SOVER}"
+			)
+		fi
+
+		if use kernel_FreeBSD; then
+			NV_GLX_LIBRARIES+=(
+				"libnvidia-tls.so.${NV_SOVER}"
+			)
+		fi
+
+		if use kernel_linux; then
+			NV_GLX_LIBRARIES+=(
+				"libnvidia-ml.so.${NV_SOVER}"
+				"libnvidia-tls.so.${NV_SOVER}"
+			)
+		fi
+
+		if use kernel_linux && has_multilib_profile && [[ ${ABI} == "amd64" ]];
+		then
+			NV_GLX_LIBRARIES+=(
+				"libnvidia-cbl.so.${NV_SOVER}"
+				"libnvidia-rtcore.so.${NV_SOVER}"
+				"libnvoptix.so.${NV_SOVER}"
+			)
+		fi
+
+		for NV_LIB in "${NV_GLX_LIBRARIES[@]}"; do
+			donvidia "${nv_libdir}"/${NV_LIB}
+		done
+	fi
+}
+
+pkg_preinst() {
+	if use driver && use kernel_linux; then
+		linux-mod_pkg_preinst
+
+		local videogroup="$(egetent group video | cut -d ':' -f 3)"
+		if [ -z "${videogroup}" ]; then
+			eerror "Failed to determine the video group gid"
+			die "Failed to determine the video group gid"
+		else
+			sed -i \
+				-e "s:PACKAGE:${PF}:g" \
+				-e "s:VIDEOGID:${videogroup}:" \
+				"${D}"/etc/modprobe.d/nvidia.conf || die
+		fi
+	fi
+
+	# Clean the dynamic libGL stuff's home to ensure
+	# we dont have stale libs floating around
+	if [ -d "${ROOT}"/usr/lib/opengl/nvidia ]; then
+		rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
+	fi
+	# Make sure we nuke the old nvidia-glx's env.d file
+	if [ -e "${ROOT}"/etc/env.d/09nvidia ]; then
+		rm -f "${ROOT}"/etc/env.d/09nvidia
+	fi
+}
+
+pkg_postinst() {
+	use driver && use kernel_linux && linux-mod_pkg_postinst
+
+	# Switch to the nvidia implementation
+	use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia
+	"${ROOT}"/usr/bin/eselect opencl set --use-old nvidia
+
+	readme.gentoo_print_elog
+
+	if ! use X; then
+		elog "You have elected to not install the X.org driver. Along with"
+		elog "this the OpenGL libraries and VDPAU libraries were not"
+		elog "installed. Additionally, once the driver is loaded your card"
+		elog "and fan will run at max speed which may not be desirable."
+		elog "Use the 'nvidia-smi' init script to have your card and fan"
+		elog "speed scale appropriately."
+		elog
+	fi
+	if ! use tools; then
+		elog "USE=tools controls whether the nvidia-settings application"
+		elog "is installed. If you would like to use it, enable that"
+		elog "flag and re-emerge this ebuild. Optionally you can install"
+		elog "media-video/nvidia-settings"
+		elog
+	fi
+}
+
+pkg_prerm() {
+	use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
+}
+
+pkg_postrm() {
+	use driver && use kernel_linux && linux-mod_pkg_postrm
+	use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
+}