1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 inherit eutils multilib versionator linux-mod flag-o-matic nvidia-driver
7 X86_NV_PACKAGE
="NVIDIA-Linux-x86-${PV}"
8 AMD64_NV_PACKAGE
="NVIDIA-Linux-x86_64-${PV}"
9 X86_FBSD_NV_PACKAGE
="NVIDIA-FreeBSD-x86-${PV}"
11 DESCRIPTION
="NVIDIA X11 driver and GLX libraries"
12 HOMEPAGE
="http://www.nvidia.com/"
13 SRC_URI
="x86? ( ftp://download.nvidia.com/XFree86/Linux-x86/${PV}/${X86_NV_PACKAGE}-pkg0.run )
14 amd64? ( ftp://download.nvidia.com/XFree86/Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}-pkg2.run )
15 x86-fbsd? ( ftp://download.nvidia.com/freebsd/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )"
20 IUSE
="acpi custom-cflags gtk multilib kernel_linux"
24 COMMON
=">=x11-base/xorg-server-1.6.1
25 multilib? ( app-emulation/emul-linux-x86-xlibs )
26 kernel_FreeBSD? ( !media-video/nvidia-freebsd )
27 !app-emulation/emul-linux-x86-nvidia
28 !x11-drivers/nvidia-legacy-drivers"
30 kernel_linux? ( virtual/linux-sources )
31 app-admin/eselect-opengl"
33 kernel_linux? ( virtual/modutils )
35 acpi? ( sys-power/acpid )"
36 PDEPEND
="gtk? ( media-video/nvidia-settings )"
38 QA_TEXTRELS_x86
="usr/lib/libXvMCNVIDIA.so.${PV}
39 usr/lib/opengl/nvidia/no-tls/libnvidia-tls.so.${PV}
40 usr/lib/opengl/nvidia/tls/libnvidia-tls.so.${PV}
41 usr/lib/opengl/nvidia/lib/libGL.so.${PV}
42 usr/lib/opengl/nvidia/lib/libnvidia-cfg.so.${PV}
43 usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
44 usr/lib/opengl/nvidia/extensions/libglx.so
45 usr/lib/xorg/modules/drivers/nvidia_drv.so
46 usr/lib/libcuda.so.${PV}
47 usr/lib/libvdpau_nvidia.so.${PV}"
49 QA_TEXTRELS_x86_fbsd
="boot/modules/nvidia.ko
50 usr/lib/opengl/nvidia/lib/libGL.so.1
51 usr/lib/opengl/nvidia/lib/libGLcore.so.1
52 usr/lib/opengl/nvidia/lib/libnvidia-cfg.so.1
53 usr/lib/opengl/nvidia/no-tls/libnvidia-tls.so.1
54 usr/lib/opengl/nvidia/extensions/libglx.so
55 usr/lib/xorg/modules/drivers/nvidia_drv.so"
57 QA_TEXTRELS_amd64
="usr/lib32/opengl/nvidia/tls/libnvidia-tls.so.${PV}
58 usr/lib32/opengl/nvidia/no-tls/libnvidia-tls.so.${PV}
59 usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
60 usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
61 usr/lib32/opengl/nvidia/lib/libnvidia-cfg.so.${PV}
62 usr/lib32/libcuda.so.${PV}
63 usr/lib32/libvdpau_nvidia.so.${PV}"
65 QA_EXECSTACK_x86
="usr/lib/opengl/nvidia/lib/libGL.so.${PV}
66 usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
67 usr/lib/opengl/nvidia/extensions/libglx.so"
69 QA_EXECSTACK_amd64
="usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
70 usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
71 usr/lib64/xorg/modules/drivers/nvidia_drv.so
72 usr/lib64/libnvcompiler.so.${PV}
73 usr/lib64/libXvMCNVIDIA.so.${PV}
74 usr/lib64/opengl/nvidia/tls/libnvidia-tls.so.${PV}
75 usr/lib64/opengl/nvidia/no-tls/libnvidia-tls.so.${PV}
76 usr/lib64/opengl/nvidia/lib/libGLcore.so.${PV}
77 usr/lib64/opengl/nvidia/lib/libGL.so.${PV}
78 usr/lib64/opengl/nvidia/lib/libnvidia-cfg.so.${PV}
79 usr/lib64/opengl/nvidia/extensions/libglx.so
81 usr/bin/nvidia-xconfig
82 usr/lib64/libXvMCNVIDIA.a:NVXVMC.o"
84 QA_WX_LOAD_x86
="usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
85 usr/lib/opengl/nvidia/lib/libGL.so.${PV}
86 usr/lib/opengl/nvidia/extensions/libglx.so
87 usr/lib/libXvMCNVIDIA.a"
89 QA_WX_LOAD_amd64
="usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
90 usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
91 usr/lib64/opengl/nvidia/lib/libGLcore.so.${PV}
92 usr/lib64/opengl/nvidia/lib/libGL.so.${PV}
93 usr/lib64/opengl/nvidia/extensions/libglx.so"
95 QA_SONAME_amd64
="usr/lib64/libnvcompiler.so.${PV}"
97 # we really should have QA_DT_HASH_x86 and QA_DT_HASH_amd64 but Portage
98 # does not support it. bug #271416
100 QA_DT_HASH
="usr/lib32/libvdpau_trace.so.${PV}
101 usr/lib32/libvdpau.so.${PV}
102 usr/lib32/libcuda.so.${PV}
103 usr/lib32/opengl/nvidia/no-tls/libnvidia-tls.so.${PV}
104 usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
105 usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
106 usr/lib32/opengl/nvidia/tls/libnvidia-tls.so.${PV}
107 usr/lib32/libvdpau_nvidia.so.${PV}
108 usr/bin/nvidia-xconfig
109 usr/lib64/libvdpau_trace.so.${PV}
110 usr/lib64/libvdpau.so.${PV}
111 usr/lib64/libcuda.so.${PV}
112 usr/lib64/opengl/nvidia/no-tls/libnvidia-tls.so.${PV}
113 usr/lib64/opengl/nvidia/lib/libnvidia-cfg.so.${PV}
114 usr/lib64/opengl/nvidia/lib/libGLcore.so.${PV}
115 usr/lib64/opengl/nvidia/lib/libGL.so.${PV}
116 usr/lib64/opengl/nvidia/tls/libnvidia-tls.so.${PV}
117 usr/lib64/opengl/nvidia/extensions/libwfb.so
118 usr/lib64/opengl/nvidia/extensions/libglx.so
119 usr/lib64/xorg/modules/drivers/nvidia_drv.so
120 usr/lib64/libXvMCNVIDIA.so.${PV}
121 usr/lib64/libvdpau_nvidia.so.${PV}
123 usr/lib/libvdpau_trace.so.${PV}
124 usr/lib/libvdpau.so.${PV}
125 usr/lib/libcuda.so.${PV}
126 usr/lib/opengl/nvidia/no-tls/libnvidia-tls.so.${PV}
127 usr/lib/opengl/nvidia/lib/libnvidia-cfg.so.${PV}
128 usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
129 usr/lib/opengl/nvidia/lib/libGL.so.${PV}
130 usr/lib/opengl/nvidia/tls/libnvidia-tls.so.${PV}
131 usr/lib/opengl/nvidia/extensions/libwfb.so
132 usr/lib/opengl/nvidia/extensions/libglx.so
133 usr/lib/xorg/modules/drivers/nvidia_drv.so
134 usr/lib/libXvMCNVIDIA.so.${PV}
135 usr/lib/libvdpau_nvidia.so.${PV}"
139 NV_PACKAGE
="${X86_NV_PACKAGE}"
142 NV_PACKAGE
="${AMD64_NV_PACKAGE}"
143 elif use x86-fbsd
; then
145 NV_PACKAGE
="${X86_FBSD_NV_PACKAGE}"
148 S
="${WORKDIR}/${NV_PACKAGE}${PKG_V}"
151 ebegin
"Checking for MTRR support"
152 linux_chkconfig_present MTRR
155 if [[ $?
-ne 0 ]] ; then
156 eerror
"Please enable MTRR support in your kernel config, found at:"
158 eerror
" Processor type and features"
159 eerror
" [*] MTRR (Memory Type Range Register) support"
161 eerror
"and recompile your kernel ..."
162 die
"MTRR support not detected!"
167 if linux_chkconfig_present LOCKDEP
; then
168 eerror
"You've enabled LOCKDEP -- lock tracking -- in the kernel."
169 eerror
"Unfortunately, this option exports the symbol 'lockdep_init_map' as GPL-only"
170 eerror
"which will prevent ${P} from compiling."
171 eerror
"Please make sure the following options have been unset:"
172 eerror
" Kernel hacking --->"
173 eerror
" [ ] Lock debugging: detect incorrect freeing of live locks"
174 eerror
" [ ] Lock debugging: prove locking correctness"
175 eerror
" [ ] Lock usage statistics"
176 eerror
"in 'menuconfig'"
177 die
"LOCKDEP enabled"
182 # try to turn off distcc and ccache for people that have a problem with it
183 export DISTCC_DISABLE
=1
184 export CCACHE_DISABLE
=1
186 if use amd64
&& has_multilib_profile
&& [ "${DEFAULT_ABI}" != "amd64" ]; then
187 eerror
"This ebuild doesn't currently support changing your default abi."
188 die
"Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
191 if use kernel_linux
; then
193 MODULE_NAMES
="nvidia(video:${S}/usr/src/nv)"
194 BUILD_PARAMS
="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
195 SYSOUT=${KV_OUT_DIR} HOST_CC=$(tc-getBUILD_CC)"
200 # On BSD userland it wants real make command
201 use userland_BSD
&& MAKE
="$(get_bmake)"
203 export _POSIX2_VERSION
="199209"
205 # Since Nvidia ships 3 different series of drivers, we need to give the user
206 # some kind of guidance as to what version they should install. This tries
207 # to point the user in the right direction but can't be perfect. check
208 # nvidia-driver.eclass
209 nvidia-driver-check-warning
211 # set variables to where files are in the package structure
212 if use kernel_FreeBSD
; then
216 NV_MAN
="${S}/x11/man"
217 elif use kernel_linux
; then
218 NV_DOC
="${S}/usr/share/doc"
219 NV_EXEC
="${S}/usr/bin"
220 NV_SRC
="${S}/usr/src/nv"
221 NV_MAN
="${S}/usr/share/man/man1"
223 die
"Could not determine proper NVIDIA package"
228 if use kernel_linux
&& kernel_is lt
2 6 7; then
230 ewarn
"Your kernel version is ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
231 ewarn
"This is not officially supported for ${P}. It is likely you"
232 ewarn
"will not be able to compile or use the kernel module."
233 ewarn
"It is recommended that you upgrade your kernel to a version >= 2.6.7"
235 ewarn
"DO NOT file bug reports for kernel versions less than 2.6.7 as they will be ignored."
238 if ! use x86-fbsd
; then
246 # Patches go below here, add brief description
248 use x86-fbsd
&& cd doc
250 # Use the correct defines to make gtkglext build work
251 epatch
"${FILESDIR}"/NVIDIA_glx-defines.
patch
252 # Use some more sensible gl headers and make way for new glext.h
253 epatch
"${FILESDIR}"/NVIDIA_glx-glheader.
patch
255 if use kernel_linux
; then
256 # Quiet down warnings the user does not need to see
258 -e 's:-Wpointer-arith::g' \
259 -e 's:-Wsign-compare::g' \
260 "${NV_SRC}"/Makefile.kbuild
262 # If you set this then it's your own fault when stuff breaks :)
263 use custom-cflags
&& sed -i "s:-O:${CFLAGS}:" "${NV_SRC}"/Makefile.
*
265 # If greater than 2.6.5 use M= instead of SUBDIR=
266 convert_to_m
"${NV_SRC}"/Makefile.kbuild
271 # This is already the default on Linux, as there's no toplevel Makefile, but
272 # on FreeBSD there's one and triggers the kernel module build, as we install
273 # it by itself, pass this.
276 if use x86-fbsd
; then
277 MAKE
="$(get_bmake)" CFLAGS
="-Wno-sign-compare" emake CC
="$(tc-getCC)" \
278 LD
="$(tc-getLD)" LDFLAGS
="$(raw-ldflags)" || die
279 elif use kernel_linux
; then
280 linux-mod_src_compile
285 local MLTEST
=$
(type dyn_unpack
)
289 if use kernel_linux
; then
290 linux-mod_src_install
292 VIDEOGROUP
="$(egetent group video | cut -d ':' -f 3)"
293 if [ -z "$VIDEOGROUP" ]; then
294 eerror
"Failed to determine the video group gid."
295 die
"Failed to determine the video group gid."
299 [ -f "${FILESDIR}/nvidia" ] || die
"nvidia missing in FILESDIR"
300 sed -e 's:PACKAGE:'${PF}':g' \
301 -e 's:VIDEOGID:'${VIDEOGROUP}':' "${FILESDIR}"/nvidia-169.07
> \
303 insinto
/etc
/modprobe.d
304 newins
"${WORKDIR}"/nvidia nvidia.conf || die
305 elif use x86-fbsd
; then
306 insinto
/boot
/modules
307 doins
"${WORKDIR}/${NV_PACKAGE}/src/nvidia.kld" || die
309 exeinto
/boot
/modules
310 doexe
"${WORKDIR}/${NV_PACKAGE}/src/nvidia.ko" || die
313 if has_multilib_profile
; then
315 for ABI
in $
(get_install_abis
) ; do
324 is_final_abi ||
return 0
327 dodoc
"${NV_DOC}"/XF86Config.sample
328 dohtml
"${NV_DOC}"/html
/*
329 if use x86-fbsd
; then
330 dodoc
"${NV_DOC}/README"
333 newdoc
"${NV_DOC}/README.txt" README
334 dodoc
"${NV_DOC}/NVIDIA_Changelog"
337 if use kernel_linux
; then
338 doman
"${NV_MAN}/nvidia-smi.1.gz"
340 doman
"${NV_MAN}/nvidia-xconfig.1.gz"
343 dobin
${NV_EXEC}/nvidia-xconfig || die
344 dobin
${NV_EXEC}/nvidia-bug-report.sh || die
345 if use kernel_linux
; then
346 dobin
${NV_EXEC}/nvidia-smi || die
350 # Install nvidia library:
351 # the first parameter is the place where to install it
352 # the second parameter is the base name of the library
353 # the third parameter is the provided soversion
358 libname
=$
(basename $2)
360 # libnvidia-cfg.so is no longer supplied in lib32; step over it gracefully
361 if [ -e $2.
$3 ] ; then
363 dosym
${libname}.
$3 $1/${libname}
364 [[ $3 != "1" ]] && dosym
${libname}.
$3 $1/${libname}.1
370 local inslibdir
=$
(get_libdir
)
372 if [[ ${#} -eq 2 ]] ; then
375 elif has_multilib_profile
&& [[ ${ABI} == "x86" ]] ; then
379 local usrpkglibdir
=usr
/${pkglibdir}
380 local libdir
=usr
/X11R
6/${pkglibdir}
381 local drvdir
=${libdir}/modules
/drivers
382 local extdir
=${libdir}/modules
/extensions
383 local incdir
=usr
/include
/GL
385 local NV_ROOT
="/usr/${inslibdir}/opengl/nvidia"
386 local NO_TLS_ROOT
="${NV_ROOT}/no-tls"
387 local TLS_ROOT
="${NV_ROOT}/tls"
388 local X11_LIB_DIR
="/usr/${inslibdir}/xorg"
390 if use x86-fbsd
; then
391 # on FreeBSD everything is on obj/
398 # don't ask me why the headers are there.. glxext.h is missing
401 # on FreeBSD it has just .1 suffix
406 donvidia
${NV_ROOT}/lib ${usrpkglibdir}/libGL.so ${sover}
407 donvidia
${NV_ROOT}/lib ${usrpkglibdir}/libGLcore.so ${sover}
409 donvidia
${NV_ROOT}/lib ${usrpkglibdir}/libnvidia-cfg.so ${sover}
412 donvidia
${NO_TLS_ROOT} ${usrpkglibdir}/libnvidia-tls.so ${sover}
414 if ! use x86-fbsd
; then
415 donvidia
${TLS_ROOT} ${usrpkglibdir}/tls/libnvidia-tls.so ${sover}
419 dosym ..
/tls
/libnvidia-tls.so
${NV_ROOT}/lib
420 dosym ..
/tls
/libnvidia-tls.so
.1 ${NV_ROOT}/lib
421 dosym ..
/tls
/libnvidia-tls.so.
${sover} ${NV_ROOT}/lib
423 dosym ..
/no-tls
/libnvidia-tls.so
${NV_ROOT}/lib
424 dosym ..
/no-tls
/libnvidia-tls.so
.1 ${NV_ROOT}/lib
425 dosym ..
/no-tls
/libnvidia-tls.so.
${sover} ${NV_ROOT}/lib
428 if ! use x86-fbsd
; then
429 # Install the .la file for libtool, to prevent e.g. bug #176423
430 [ -f "${FILESDIR}/libGL.la-r2" ] || die
"libGL.la-r2 missing in FILESDIR"
431 local ver1
=$
(get_version_component_range
1)
432 local ver2
=$
(get_version_component_range
2)
433 local ver3
=$
(get_version_component_range
3)
434 sed -e "s:\${PV}:${PV}:" \
435 -e "s:\${ver1}:${ver1}:" \
436 -e "s:\${ver2}:${ver2}:" \
437 -e "s:\${ver3}:${ver3}:" \
438 -e "s:\${libdir}:${inslibdir}:" \
439 "${FILESDIR}"/libGL.la-r2 > "${D}"/${NV_ROOT}/lib/libGL.la
442 exeinto ${X11_LIB_DIR}/modules/drivers
444 [[ -f ${drvdir}/nvidia_drv.so ]] && \
445 doexe ${drvdir}/nvidia_drv.so
447 insinto /usr/${inslibdir}
448 [[ -f ${libdir}/libXvMCNVIDIA.a ]] && \
449 doins ${libdir}/libXvMCNVIDIA.a
450 exeinto /usr/${inslibdir}
452 [[ -f ${libdir}/libXvMCNVIDIA.so.${PV} ]] && \
453 doexe ${libdir}/libXvMCNVIDIA.so.${PV} && \
454 dosym libXvMCNVIDIA.so.${PV} \
455 /usr/${inslibdir}/libXvMCNVIDIA.so
457 exeinto ${NV_ROOT}/extensions
458 [[ -f ${libdir}/modules/libnvidia-wfb.so.${sover} ]] && \
459 newexe ${libdir}/modules/libnvidia-wfb.so.${sover} libwfb.so
460 [[ -f ${extdir}/libglx.so.${sover} ]] && \
461 newexe ${extdir}/libglx.so.${sover} libglx.so
464 insinto ${NV_ROOT}/include
468 if [[ -f usr/include/cuda/cuda.h ]]; then
469 dodir /usr/include/cuda
470 insinto /usr/include/cuda
471 doins usr/include/cuda/*.h
473 if [[ -f usr/${pkglibdir}/libcuda.so.${PV} ]]; then
474 dolib.so usr/${pkglibdir}/libcuda.so.${PV}
475 dosym libcuda.so.${PV} /usr/${inslibdir}/libcuda.so.1
476 dosym libcuda.so.1 /usr/${inslibdir}/libcuda.so
481 if [[ -f usr/include/vdpau/vdpau.h ]]; then
482 dodir /usr/include/vdpau
483 insinto /usr/include/vdpau
484 doins usr/include/vdpau/*.h
486 for vdpaulib in vdpau_nvidia vdpau vdpau_trace; do
487 dolib.so usr/${pkglibdir}/lib${vdpaulib}.so.${PV}
488 dosym lib${vdpaulib}.so.${PV} /usr/${inslibdir}/lib${vdpaulib}.so.1
489 dosym lib${vdpaulib}.so.1 /usr/${inslibdir}/lib${vdpaulib}.so
494 # NOTE: This isn't currently available in the publicly released drivers.
495 if [[ -f usr/${pkglibdir}/libOpenCL.so.1.0.0 ]]; then
496 dodir /usr/include/CL
497 insinto /usr/include/CL
498 doins usr/include/CL/*.h
500 dolib.so usr/${pkglibdir}/libnvcompiler.so.${PV}
501 dosym libnvcompiler.so.${PV} /usr/${inslibdir}/libnvcompiler.so.1
502 dosym libnvcompiler.so.1 /usr/${inslibdir}/libnvcompiler.so
504 dolib.so usr/${pkglibdir}/libOpenCL.so.1.0.0
505 dosym libOpenCL.so.1.0.0 /usr/${inslibdir}/libOpenCL.so.1
506 dosym libOpenCL.so.1 /usr/${inslibdir}/libOpenCL.so
512 # Clean the dynamic libGL stuff's home to ensure
513 # we dont have stale libs floating around
514 if [ -d "${ROOT}"/usr/lib/opengl/nvidia ] ; then
515 rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
517 # Make sure we nuke the old nvidia-glx's env.d file
518 if [ -e "${ROOT}"/etc/env.d/09nvidia ] ; then
519 rm -f "${ROOT}"/etc/env.d/09nvidia
524 if use kernel_linux; then
525 linux-mod_pkg_postinst
528 # Switch to the nvidia implementation
529 eselect opengl set --use-old nvidia
532 elog "You must be
in the video group to use the NVIDIA device
"
533 elog "For
more info
, read the docs
at"
534 elog "http
://www.gentoo.org
/doc
/en
/nvidia-guide.xml
#doc_chap3_sect6"
537 elog
"This ebuild installs a kernel module and X driver. Both must"
538 elog
"match explicitly in their version. This means, if you restart"
539 elog
"X, you most modprobe -r nvidia before starting it back up"
542 elog
"To use the NVIDIA GLX, run \"eselect opengl set nvidia\""
544 elog
"nVidia has requested that any bug reports submitted have the"
545 elog
"output of /usr/bin/nvidia-bug-report.sh included."
547 elog
"To work with compiz, you must enable the AddARGBGLXVisuals option."
549 elog
"If you are having resolution problems, try disabling DynamicTwinView."
554 # For uclibc or anything non glibc, return false
555 has_version sys-libs
/glibc ||
return 1
557 # Old versions of glibc were lt/no-tls only
558 has_version
'<sys-libs/glibc-2.3.2' && return 1
567 # 2.3.5 turned off tls for linuxthreads glibc on i486 and i586
568 if use x86
&& has_version
'>=sys-libs/glibc-2.3.5' ; then
570 i486|i586
) return 1 ;;
574 # These versions built linuxthreads version to support tls, too
575 has_version
'>=sys-libs/glibc-2.3.4.20040619-r2' && return 0
581 if use kernel_linux
; then
584 eselect opengl
set --use-old xorg-x11