d08481f40290b8e0bb2bd2e395263cb5014ea72c
[otih-overlay.git] / x11-drivers / nvidia-drivers / nvidia-drivers-195.30.ebuild
blobd08481f40290b8e0bb2bd2e395263cb5014ea72c
1 # Copyright 1999-2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/x11-drivers/nvidia-drivers/nvidia-drivers-190.42-r3.ebuild,v 1.4 2009/11/12 19:12:29 cardoe Exp $
5 EAPI="2"
7 inherit eutils multilib versionator linux-mod flag-o-matic nvidia-driver
9 X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}"
10 AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}"
11 X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}"
13 DESCRIPTION="NVIDIA X11 driver and GLX libraries"
14 HOMEPAGE="http://www.nvidia.com/"
15 SRC_URI="x86? ( ftp://download.nvidia.com/XFree86/Linux-x86/${PV}/${X86_NV_PACKAGE}-pkg0.run )
16 amd64? ( ftp://download.nvidia.com/XFree86/Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}-pkg2.run )
17 x86-fbsd? ( ftp://download.nvidia.com/freebsd/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )"
19 LICENSE="NVIDIA"
20 SLOT="0"
21 KEYWORDS=""
22 IUSE="acpi custom-cflags gtk multilib kernel_linux"
23 RESTRICT="strip"
24 EMULTILIB_PKG="true"
26 COMMON="<x11-base/xorg-server-1.7.99
27 kernel_linux? ( >=sys-libs/glibc-2.6.1 )
28 multilib? ( app-emulation/emul-linux-x86-xlibs )
29 >=app-admin/eselect-opengl-1.0.9"
30 DEPEND="${COMMON}
31 kernel_linux? ( virtual/linux-sources )"
32 RDEPEND="${COMMON}
33 kernel_linux? ( virtual/modutils )
34 acpi? ( sys-power/acpid )"
35 PDEPEND=">=x11-libs/libvdpau-0.3-r1
36 gtk? ( media-video/nvidia-settings )"
38 QA_TEXTRELS_x86="usr/lib/opengl/nvidia/lib/libnvidia-tls.so.${PV}
39 usr/lib/opengl/nvidia/lib/libGL.so.${PV}
40 usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
41 usr/lib/opengl/nvidia/extensions/libglx.so.${PV}
42 usr/lib/xorg/modules/drivers/nvidia_drv.so
43 usr/lib/libcuda.so.${PV}
44 usr/lib/libnvidia-cfg.so.${PV}
45 usr/lib/libvdpau_nvidia.so.${PV}
46 usr/lib/libXvMCNVIDIA.so.${PV}"
48 QA_TEXTRELS_x86_fbsd="boot/modules/nvidia.ko
49 usr/lib/opengl/nvidia/lib/libGL.so.1
50 usr/lib/opengl/nvidia/lib/libGLcore.so.1
51 usr/lib/libnvidia-cfg.so.1
52 usr/lib/opengl/nvidia/extensions/libglx.so.1
53 usr/lib/xorg/modules/drivers/nvidia_drv.so"
55 QA_TEXTRELS_amd64="usr/lib32/opengl/nvidia/lib/libnvidia-tls.so.${PV}
56 usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
57 usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
58 usr/lib32/libcuda.so.${PV}
59 usr/lib32/libvdpau_nvidia.so.${PV}"
61 QA_EXECSTACK_x86="usr/lib/opengl/nvidia/lib/libGL.so.${PV}
62 usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
63 usr/lib/opengl/nvidia/extensions/libglx.so.${PV}
64 usr/lib/libXvMCNVIDIA.a:NVXVMC.o"
66 QA_EXECSTACK_amd64="usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
67 usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
68 usr/lib64/libnvcompiler.so.${PV}
69 usr/lib64/libXvMCNVIDIA.so.${PV}
70 usr/lib64/libXvMCNVIDIA.a:NVXVMC.o
71 usr/lib64/libnvidia-cfg.so.${PV}
72 usr/lib64/opengl/nvidia/lib/libnvidia-tls.so.${PV}
73 usr/lib64/opengl/nvidia/lib/libGL.so.${PV}
74 usr/lib64/opengl/nvidia/lib/libGLcore.so.${PV}
75 usr/lib64/opengl/nvidia/extensions/libglx.so.${PV}
76 usr/bin/nvidia-smi
77 usr/bin/nvidia-xconfig"
79 QA_WX_LOAD_x86="usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
80 usr/lib/opengl/nvidia/lib/libGL.so.${PV}
81 usr/lib/opengl/nvidia/extensions/libglx.so.${PV}
82 usr/lib/libXvMCNVIDIA.a"
84 QA_WX_LOAD_amd64="usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
85 usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
86 usr/lib64/opengl/nvidia/lib/libGL.so.${PV}
87 usr/lib64/opengl/nvidia/lib/libGLcore.so.${PV}
88 usr/lib64/opengl/nvidia/extensions/libglx.so.${PV}"
90 QA_SONAME_amd64="usr/lib64/libnvcompiler.so.${PV}"
92 QA_DT_HASH_amd64="usr/lib32/libcuda.so.${PV}
93 usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
94 usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
95 usr/lib32/opengl/nvidia/lib/libnvidia-tls.so.${PV}
96 usr/lib32/libvdpau_nvidia.so.${PV}
97 usr/lib64/libXvMCNVIDIA.so.${PV}
98 usr/lib64/libcuda.so.${PV}
99 usr/lib64/libnvidia-cfg.so.${PV}
100 usr/lib64/opengl/nvidia/lib/libGLcore.so.${PV}
101 usr/lib64/opengl/nvidia/lib/libGL.so.${PV}
102 usr/lib64/opengl/nvidia/lib/libnvidia-tls.so.${PV}
103 usr/lib64/opengl/nvidia/extensions/libglx.so.${PV}
104 usr/lib64/xorg/modules/drivers/nvidia_drv.so
105 usr/lib64/libvdpau_nvidia.so.${PV}
106 usr/bin/nvidia-smi
107 usr/bin/nvidia-xconfig"
109 QA_DT_HASH_x86="usr/lib/libcuda.so.${PV}
110 usr/lib/libnvidia-cfg.so.${PV}
111 usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
112 usr/lib/opengl/nvidia/lib/libGL.so.${PV}
113 usr/lib/opengl/nvidia/lib/libnvidia-tls.so.${PV}
114 usr/lib/opengl/nvidia/extensions/libglx.so.${PV}
115 usr/lib/xorg/modules/drivers/nvidia_drv.so
116 usr/lib/libXvMCNVIDIA.so.${PV}
117 usr/lib/libvdpau_nvidia.so.${PV}
118 usr/bin/nvidia-smi
119 usr/bin/nvidia-xconfig"
121 if use x86; then
122 PKG_V="-pkg0"
123 NV_PACKAGE="${X86_NV_PACKAGE}"
124 elif use amd64; then
125 PKG_V="-pkg2"
126 NV_PACKAGE="${AMD64_NV_PACKAGE}"
127 elif use x86-fbsd; then
128 PKG_V=""
129 NV_PACKAGE="${X86_FBSD_NV_PACKAGE}"
130 fi
132 S="${WORKDIR}/${NV_PACKAGE}${PKG_V}"
134 mtrr_check() {
135 ebegin "Checking for MTRR support"
136 linux_chkconfig_present MTRR
137 eend $?
139 if [[ $? -ne 0 ]] ; then
140 eerror "Please enable MTRR support in your kernel config, found at:"
141 eerror
142 eerror " Processor type and features"
143 eerror " [*] MTRR (Memory Type Range Register) support"
144 eerror
145 eerror "and recompile your kernel ..."
146 die "MTRR support not detected!"
147 fi
150 lockdep_check() {
151 if linux_chkconfig_present LOCKDEP; then
152 eerror "You've enabled LOCKDEP -- lock tracking -- in the kernel."
153 eerror "Unfortunately, this option exports the symbol 'lockdep_init_map' as GPL-only"
154 eerror "which will prevent ${P} from compiling."
155 eerror "Please make sure the following options have been unset:"
156 eerror " Kernel hacking --->"
157 eerror " [ ] Lock debugging: detect incorrect freeing of live locks"
158 eerror " [ ] Lock debugging: prove locking correctness"
159 eerror " [ ] Lock usage statistics"
160 eerror "in 'menuconfig'"
161 die "LOCKDEP enabled"
162 fi
165 pkg_setup() {
166 # try to turn off distcc and ccache for people that have a problem with it
167 export DISTCC_DISABLE=1
168 export CCACHE_DISABLE=1
170 if use amd64 && has_multilib_profile && [ "${DEFAULT_ABI}" != "amd64" ]; then
171 eerror "This ebuild doesn't currently support changing your default abi."
172 die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
173 fi
175 if use kernel_linux; then
176 linux-mod_pkg_setup
177 MODULE_NAMES="nvidia(video:${S}/usr/src/nv)"
178 BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
179 SYSOUT=${KV_OUT_DIR} HOST_CC=$(tc-getBUILD_CC)"
180 mtrr_check
181 lockdep_check
182 fi
184 # On BSD userland it wants real make command
185 use userland_BSD && MAKE="$(get_bmake)"
187 export _POSIX2_VERSION="199209"
189 # Since Nvidia ships 3 different series of drivers, we need to give the user
190 # some kind of guidance as to what version they should install. This tries
191 # to point the user in the right direction but can't be perfect. check
192 # nvidia-driver.eclass
193 nvidia-driver-check-warning
195 # set variables to where files are in the package structure
196 if use kernel_FreeBSD; then
197 NV_DOC="${S}/doc"
198 NV_EXEC="${S}/obj"
199 NV_LIB="${S}/obj"
200 NV_SRC="${S}/src"
201 NV_MAN="${S}/x11/man"
202 NV_X11="${S}/obj"
203 NV_X11_DRV="${NV_X11}"
204 NV_X11_EXT="${NV_X11}"
205 NV_SOVER=1
206 elif use kernel_linux; then
207 NV_DOC="${S}/usr/share/doc"
208 NV_EXEC="${S}/usr/bin"
209 NV_LIB="${S}/usr/lib"
210 NV_SRC="${S}/usr/src/nv"
211 NV_MAN="${S}/usr/share/man/man1"
212 NV_X11="${S}/usr/X11R6/lib"
213 NV_X11_DRV="${NV_X11}/modules/drivers"
214 NV_X11_EXT="${NV_X11}/modules/extensions"
215 NV_SOVER=${PV}
216 else
217 die "Could not determine proper NVIDIA package"
218 fi
221 src_unpack() {
222 if use kernel_linux && kernel_is lt 2 6 7; then
223 echo
224 ewarn "Your kernel version is ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
225 ewarn "This is not officially supported for ${P}. It is likely you"
226 ewarn "will not be able to compile or use the kernel module."
227 ewarn "It is recommended that you upgrade your kernel to a version >= 2.6.7"
228 echo
229 ewarn "DO NOT file bug reports for kernel versions less than 2.6.7 as they will be ignored."
230 fi
232 if ! use x86-fbsd; then
233 mkdir "${S}"
234 cd "${S}"
235 unpack_makeself
236 else
237 unpack ${A}
238 fi
241 src_prepare() {
242 # Please add a brief description for every added patch
243 use x86-fbsd && cd doc
245 # Use the correct defines to make gtkglext build work
246 epatch "${FILESDIR}"/NVIDIA_glx-defines.patch
247 # Use some more sensible gl headers and make way for new glext.h
248 epatch "${FILESDIR}"/NVIDIA_glx-glheader.patch
250 if use kernel_linux; then
251 # Quiet down warnings the user does not need to see
252 sed -i \
253 -e 's:-Wpointer-arith::g' \
254 -e 's:-Wsign-compare::g' \
255 "${NV_SRC}"/Makefile.kbuild
257 # If you set this then it's your own fault when stuff breaks :)
258 use custom-cflags && sed -i "s:-O:${CFLAGS}:" "${NV_SRC}"/Makefile.*
260 # If greater than 2.6.5 use M= instead of SUBDIR=
261 convert_to_m "${NV_SRC}"/Makefile.kbuild
262 fi
265 src_compile() {
266 # This is already the default on Linux, as there's no toplevel Makefile, but
267 # on FreeBSD there's one and triggers the kernel module build, as we install
268 # it by itself, pass this.
270 cd "${NV_SRC}"
271 if use x86-fbsd; then
272 MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
273 LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
274 elif use kernel_linux; then
275 linux-mod_src_compile
276 fi
279 src_install() {
280 if use kernel_linux; then
281 linux-mod_src_install
283 VIDEOGROUP="$(egetent group video | cut -d ':' -f 3)"
284 if [ -z "$VIDEOGROUP" ]; then
285 eerror "Failed to determine the video group gid."
286 die "Failed to determine the video group gid."
287 fi
289 # Add the aliases
290 [ -f "${FILESDIR}/nvidia-169.07" ] || die "nvidia missing in FILESDIR"
291 sed -e 's:PACKAGE:'${PF}':g' \
292 -e 's:VIDEOGID:'${VIDEOGROUP}':' "${FILESDIR}"/nvidia-169.07 > \
293 "${WORKDIR}"/nvidia
294 insinto /etc/modprobe.d
295 newins "${WORKDIR}"/nvidia nvidia.conf || die
296 elif use x86-fbsd; then
297 insinto /boot/modules
298 doins "${WORKDIR}/${NV_PACKAGE}/src/nvidia.kld" || die
300 exeinto /boot/modules
301 doexe "${WORKDIR}/${NV_PACKAGE}/src/nvidia.ko" || die
302 fi
304 # NVIDIA kernel <-> userspace driver config lib
305 dolib.so ${NV_LIB}/libnvidia-cfg.so.${NV_SOVER} || \
306 die "failed to install libnvidia-cfg"
308 # Xorg DDX driver
309 insinto /usr/$(get_libdir)/xorg/modules/drivers
310 doins ${NV_X11_DRV}/nvidia_drv.so || die "failed to install nvidia_drv.so"
312 # Xorg GLX driver
313 insinto /usr/$(get_libdir)/opengl/nvidia/extensions
314 doins ${NV_X11_EXT}/libglx.so.${NV_SOVER} || \
315 die "failed to install libglx.so"
316 dosym /usr/$(get_libdir)/opengl/nvidia/extensions/libglx.so.${NV_SOVER} \
317 /usr/$(get_libdir)/opengl/nvidia/extensions/libglx.so || \
318 die "failed to create libglx.so symlink"
320 # XvMC driver
321 dolib.a ${NV_X11}/libXvMCNVIDIA.a || \
322 die "failed to install libXvMCNVIDIA.so"
323 dolib.so ${NV_X11}/libXvMCNVIDIA.so.${NV_SOVER} || \
324 die "failed to install libXvMCNVIDIA.so"
325 dosym libXvMCNVIDIA.so.${NV_SOVER} /usr/$(get_libdir)/libXvMCNVIDIA.so || \
326 die "failed to create libXvMCNVIDIA.so symlink"
328 # CUDA headers (driver to come)
329 if use kernel_linux; then
330 dodir /usr/include/cuda
331 insinto /usr/include/cuda
332 doins usr/include/cuda/*.h || die "failed to install cuda headers"
333 fi
335 # OpenCL headers (driver to come)
336 if [[ -d ${S}/usr/include/CL ]]; then
337 dodir /usr/include/CL
338 insinto /usr/include/CL
339 doins usr/include/CL/*.h || die "failed to install OpenCL headers"
340 fi
342 # Documentation
343 dodoc ${NV_DOC}/XF86Config.sample
344 dohtml ${NV_DOC}/html/*
345 if use x86-fbsd; then
346 dodoc "${NV_DOC}/README"
347 doman "${NV_MAN}/nvidia-xconfig.1"
348 else
349 # Docs
350 newdoc "${NV_DOC}/README.txt" README
351 dodoc "${NV_DOC}/NVIDIA_Changelog"
352 doman "${NV_MAN}/nvidia-smi.1.gz"
353 doman "${NV_MAN}/nvidia-xconfig.1.gz"
354 fi
356 # Helper Apps
357 dobin ${NV_EXEC}/nvidia-xconfig || die
358 dobin ${NV_EXEC}/nvidia-bug-report.sh || die
359 if use kernel_linux; then
360 dobin ${NV_EXEC}/nvidia-smi || die
361 fi
363 if has_multilib_profile ; then
364 local OABI=${ABI}
365 for ABI in $(get_install_abis) ; do
366 src_install-libs
367 done
368 ABI=${OABI}
369 unset OABI
370 else
371 src_install-libs
372 fi
374 is_final_abi || die "failed to iterate through all ABIs"
377 # Install nvidia library:
378 # the first parameter is the place where to install it
379 # the second parameter is the base name of the library
380 # the third parameter is the provided soversion
381 donvidia() {
382 dodir $1
383 exeinto $1
385 libname=$(basename $2)
387 doexe $2.$3 || die "failed to install $2"
388 dosym ${libname}.$3 $1/${libname} || die "failed to symlink $2"
389 [[ $3 != "1" ]] && dosym ${libname}.$3 $1/${libname}.1
392 src_install-libs() {
393 local inslibdir=$(get_libdir)
394 local NV_ROOT="/usr/${inslibdir}/opengl/nvidia"
395 local libdir= sover=
397 if use kernel_linux; then
398 if has_multilib_profile && [[ ${ABI} == "x86" ]] ; then
399 libdir=usr/lib32
400 else
401 libdir=usr/lib
402 fi
403 sover=${PV}
404 else
405 libdir=obj
406 # on FreeBSD it has just .1 suffix
407 sover=1
408 fi
410 # The GLX libraries
411 donvidia ${NV_ROOT}/lib ${libdir}/libGL.so ${sover}
412 donvidia ${NV_ROOT}/lib ${libdir}/libGLcore.so ${sover}
413 if use x86-fbsd; then
414 donvidia ${NV_ROOT}/lib ${libdir}/libnvidia-tls.so ${sover}
415 else
416 donvidia ${NV_ROOT}/lib ${libdir}/tls/libnvidia-tls.so ${sover}
417 fi
419 #cuda
420 if [[ -f ${libdir}/libcuda.so.${sover} ]]; then
421 dolib.so ${libdir}/libcuda.so.${sover}
422 [[ "${sover}" != "1" ]] && dosym libcuda.so.${sover} /usr/${inslibdir}/libcuda.so.1
423 dosym libcuda.so.1 /usr/${inslibdir}/libcuda.so
424 fi
426 #vdpau
427 if [[ -f ${libdir}/vdpau/libvdpau_nvidia.so.${sover} ]]; then
428 insinto /usr/${inslibdir}/vdpau
429 dolib.so ${libdir}/vdpau/libvdpau_nvidia.so.${sover}
430 dosym libvdpau_nvidia.so.${sover} /usr/${inslibdir}/libvdpau_nvidia.so.1
431 fi
433 # OpenCL
434 # NOTE: This isn't currently available in the publicly released drivers.
435 if [[ -f ${libdir}/libOpenCL.so.1.0.0 ]]; then
437 dolib.so ${libdir}/libnvcompiler.so.${sover}
438 [[ "${sover}" != "1" ]] && dosym libnvcompiler.so.${sover} /usr/${inslibdir}/libnvcompiler.so.1
439 dosym libnvcompiler.so.1 /usr/${inslibdir}/libnvcompiler.so
441 dolib.so ${libdir}/libOpenCL.so.1.0.0
442 dosym libOpenCL.so.1.0.0 /usr/${inslibdir}/libOpenCL.so.1
443 dosym libOpenCL.so.1 /usr/${inslibdir}/libOpenCL.so
444 fi
447 pkg_preinst() {
448 if use kernel_linux; then
449 linux-mod_pkg_postinst
450 fi
452 # Clean the dynamic libGL stuff's home to ensure
453 # we dont have stale libs floating around
454 if [ -d "${ROOT}"/usr/lib/opengl/nvidia ] ; then
455 rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
456 fi
457 # Make sure we nuke the old nvidia-glx's env.d file
458 if [ -e "${ROOT}"/etc/env.d/09nvidia ] ; then
459 rm -f "${ROOT}"/etc/env.d/09nvidia
460 fi
463 pkg_postinst() {
464 if use kernel_linux; then
465 linux-mod_pkg_postinst
466 fi
468 # Switch to the nvidia implementation
469 eselect opengl set --use-old nvidia
471 echo
472 elog "You must be in the video group to use the NVIDIA device"
473 elog "For more info, read the docs at"
474 elog "http://www.gentoo.org/doc/en/nvidia-guide.xml#doc_chap3_sect6"
475 elog
477 elog "This ebuild installs a kernel module and X driver. Both must"
478 elog "match explicitly in their version. This means, if you restart"
479 elog "X, you must modprobe -r nvidia before starting it back up"
480 elog
482 elog "To use the NVIDIA GLX, run \"eselect opengl set nvidia\""
483 elog
484 elog "NVIDIA has requested that any bug reports submitted have the"
485 elog "output of /usr/bin/nvidia-bug-report.sh included."
486 elog
487 elog "To work with compiz, you must enable the AddARGBGLXVisuals option."
488 elog
489 elog "If you are having resolution problems, try disabling DynamicTwinView."
490 echo
493 pkg_postrm() {
494 if use kernel_linux; then
495 linux-mod_pkg_postrm
496 fi
497 eselect opengl set --use-old xorg-x11