1 # Copyright 1999-2009 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-r2.ebuild,v 1.2 2009/10/31 20:18:19 cardoe Exp $
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 )"
22 IUSE
="acpi custom-cflags gtk multilib kernel_linux"
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 )"
30 kernel_linux? ( virtual/linux-sources )
31 app-admin/eselect-opengl"
33 kernel_linux? ( virtual/modutils )
34 !>=media-libs/mesa-7.6
35 acpi? ( sys-power/acpid )"
36 PDEPEND
="x11-libs/libvdpau
37 gtk? ( media-video/nvidia-settings )"
39 QA_TEXTRELS_x86
="usr/lib/libXvMCNVIDIA.so.${PV}
40 usr/lib/opengl/nvidia/lib/libnvidia-tls.so.${PV}
41 usr/lib/opengl/nvidia/lib/libGL.so.${PV}
42 usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
43 usr/lib/opengl/nvidia/extensions/libglx.so.${PV}
44 usr/lib/xorg/modules/drivers/nvidia_drv.so
45 usr/lib/libcuda.so.${PV}
46 usr/lib/libnvidia-cfg.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/libnvidia-cfg.so.1
53 usr/lib/opengl/nvidia/extensions/libglx.so.1
54 usr/lib/xorg/modules/drivers/nvidia_drv.so"
56 QA_TEXTRELS_amd64
="usr/lib32/opengl/nvidia/lib/libnvidia-tls.so.${PV}
57 usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
58 usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
59 usr/lib32/libcuda.so.${PV}
60 usr/lib32/libvdpau_nvidia.so.${PV}"
62 QA_EXECSTACK_x86
="usr/lib/opengl/nvidia/lib/libGL.so.${PV}
63 usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
64 usr/lib/opengl/nvidia/extensions/libglx.so.${PV}
65 usr/lib/libXvMCNVIDIA.a:NVXVMC.o"
67 QA_EXECSTACK_amd64
="usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
68 usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
69 usr/lib64/libnvcompiler.so.${PV}
70 usr/lib64/libXvMCNVIDIA.so.${PV}
71 usr/lib64/libXvMCNVIDIA.a:NVXVMC.o
72 usr/lib64/libnvidia-cfg.so.${PV}
73 usr/lib64/opengl/nvidia/lib/libnvidia-tls.so.${PV}
74 usr/lib64/opengl/nvidia/lib/libGL.so.${PV}
75 usr/lib64/opengl/nvidia/lib/libGLcore.so.${PV}
76 usr/lib64/opengl/nvidia/extensions/libglx.so.${PV}
78 usr/bin/nvidia-xconfig"
80 QA_WX_LOAD_x86
="usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
81 usr/lib/opengl/nvidia/lib/libGL.so.${PV}
82 usr/lib/opengl/nvidia/extensions/libglx.so.${PV}
83 usr/lib/libXvMCNVIDIA.a"
85 QA_WX_LOAD_amd64
="usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
86 usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
87 usr/lib64/opengl/nvidia/lib/libGL.so.${PV}
88 usr/lib64/opengl/nvidia/lib/libGLcore.so.${PV}
89 usr/lib64/opengl/nvidia/extensions/libglx.so.${PV}"
91 QA_SONAME_amd64
="usr/lib64/libnvcompiler.so.${PV}"
93 QA_DT_HASH_amd64
="usr/lib32/libcuda.so.${PV}
94 usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
95 usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
96 usr/lib32/opengl/nvidia/lib/libnvidia-tls.so.${PV}
97 usr/lib32/libvdpau_nvidia.so.${PV}
98 usr/lib64/libXvMCNVIDIA.so.${PV}
99 usr/lib64/libcuda.so.${PV}
100 usr/lib64/libnvidia-cfg.so.${PV}
101 usr/lib64/opengl/nvidia/lib/libGLcore.so.${PV}
102 usr/lib64/opengl/nvidia/lib/libGL.so.${PV}
103 usr/lib64/opengl/nvidia/lib/libnvidia-tls.so.${PV}
104 usr/lib64/opengl/nvidia/extensions/libglx.so.${PV}
105 usr/lib64/xorg/modules/drivers/nvidia_drv.so
106 usr/lib64/libvdpau_nvidia.so.${PV}
108 usr/bin/nvidia-xconfig"
110 QA_DT_HASH_x86
="usr/lib/libcuda.so.${PV}
111 usr/lib/opengl/nvidia/lib/libnvidia-cfg.so.${PV}
112 usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
113 usr/lib/opengl/nvidia/lib/libGL.so.${PV}
114 usr/lib/opengl/nvidia/lib/libnvidia-tls.so.${PV}
115 usr/lib/opengl/nvidia/extensions/libwfb.so
116 usr/lib/opengl/nvidia/extensions/libglx.so
117 usr/lib/xorg/modules/drivers/nvidia_drv.so
118 usr/lib/libXvMCNVIDIA.so.${PV}
119 usr/lib/libvdpau_nvidia.so.${PV}
121 usr/bin/nvidia-xconfig"
125 NV_PACKAGE
="${X86_NV_PACKAGE}"
128 NV_PACKAGE
="${AMD64_NV_PACKAGE}"
129 elif use x86-fbsd
; then
131 NV_PACKAGE
="${X86_FBSD_NV_PACKAGE}"
134 S
="${WORKDIR}/${NV_PACKAGE}${PKG_V}"
137 ebegin
"Checking for MTRR support"
138 linux_chkconfig_present MTRR
141 if [[ $?
-ne 0 ]] ; then
142 eerror
"Please enable MTRR support in your kernel config, found at:"
144 eerror
" Processor type and features"
145 eerror
" [*] MTRR (Memory Type Range Register) support"
147 eerror
"and recompile your kernel ..."
148 die
"MTRR support not detected!"
153 if linux_chkconfig_present LOCKDEP
; then
154 eerror
"You've enabled LOCKDEP -- lock tracking -- in the kernel."
155 eerror
"Unfortunately, this option exports the symbol 'lockdep_init_map' as GPL-only"
156 eerror
"which will prevent ${P} from compiling."
157 eerror
"Please make sure the following options have been unset:"
158 eerror
" Kernel hacking --->"
159 eerror
" [ ] Lock debugging: detect incorrect freeing of live locks"
160 eerror
" [ ] Lock debugging: prove locking correctness"
161 eerror
" [ ] Lock usage statistics"
162 eerror
"in 'menuconfig'"
163 die
"LOCKDEP enabled"
168 # try to turn off distcc and ccache for people that have a problem with it
169 export DISTCC_DISABLE
=1
170 export CCACHE_DISABLE
=1
172 if use amd64
&& has_multilib_profile
&& [ "${DEFAULT_ABI}" != "amd64" ]; then
173 eerror
"This ebuild doesn't currently support changing your default abi."
174 die
"Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
177 if use kernel_linux
; then
179 MODULE_NAMES
="nvidia(video:${S}/usr/src/nv)"
180 BUILD_PARAMS
="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
181 SYSOUT=${KV_OUT_DIR} HOST_CC=$(tc-getBUILD_CC)"
186 # On BSD userland it wants real make command
187 use userland_BSD
&& MAKE
="$(get_bmake)"
189 export _POSIX2_VERSION
="199209"
191 # Since Nvidia ships 3 different series of drivers, we need to give the user
192 # some kind of guidance as to what version they should install. This tries
193 # to point the user in the right direction but can't be perfect. check
194 # nvidia-driver.eclass
195 nvidia-driver-check-warning
197 # set variables to where files are in the package structure
198 if use kernel_FreeBSD
; then
203 NV_MAN
="${S}/x11/man"
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"
215 die
"Could not determine proper NVIDIA package"
220 if use kernel_linux
&& kernel_is lt
2 6 7; then
222 ewarn
"Your kernel version is ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
223 ewarn
"This is not officially supported for ${P}. It is likely you"
224 ewarn
"will not be able to compile or use the kernel module."
225 ewarn
"It is recommended that you upgrade your kernel to a version >= 2.6.7"
227 ewarn
"DO NOT file bug reports for kernel versions less than 2.6.7 as they will be ignored."
230 if ! use x86-fbsd
; then
240 # Please add a brief description for every added patch
241 use x86-fbsd
&& cd doc
243 # Use the correct defines to make gtkglext build work
244 epatch
"${FILESDIR}"/NVIDIA_glx-defines.
patch
245 # Use some more sensible gl headers and make way for new glext.h
246 epatch
"${FILESDIR}"/NVIDIA_glx-glheader.
patch
248 if use kernel_linux
; then
249 # Quiet down warnings the user does not need to see
251 -e 's:-Wpointer-arith::g' \
252 -e 's:-Wsign-compare::g' \
253 "${NV_SRC}"/Makefile.kbuild
255 # If you set this then it's your own fault when stuff breaks :)
256 use custom-cflags
&& sed -i "s:-O:${CFLAGS}:" "${NV_SRC}"/Makefile.
*
258 # If greater than 2.6.5 use M= instead of SUBDIR=
259 convert_to_m
"${NV_SRC}"/Makefile.kbuild
264 # This is already the default on Linux, as there's no toplevel Makefile, but
265 # on FreeBSD there's one and triggers the kernel module build, as we install
266 # it by itself, pass this.
269 if use x86-fbsd
; then
270 MAKE
="$(get_bmake)" CFLAGS
="-Wno-sign-compare" emake CC
="$(tc-getCC)" \
271 LD
="$(tc-getLD)" LDFLAGS
="$(raw-ldflags)" || die
272 elif use kernel_linux
; then
273 linux-mod_src_compile
278 if use kernel_linux
; then
279 linux-mod_src_install
281 VIDEOGROUP
="$(egetent group video | cut -d ':' -f 3)"
282 if [ -z "$VIDEOGROUP" ]; then
283 eerror
"Failed to determine the video group gid."
284 die
"Failed to determine the video group gid."
288 [ -f "${FILESDIR}/nvidia-169.07" ] || die
"nvidia missing in FILESDIR"
289 sed -e 's:PACKAGE:'${PF}':g' \
290 -e 's:VIDEOGID:'${VIDEOGROUP}':' "${FILESDIR}"/nvidia-169.07
> \
292 insinto
/etc
/modprobe.d
293 newins
"${WORKDIR}"/nvidia nvidia.conf || die
294 elif use x86-fbsd
; then
295 insinto
/boot
/modules
296 doins
"${WORKDIR}/${NV_PACKAGE}/src/nvidia.kld" || die
298 exeinto
/boot
/modules
299 doexe
"${WORKDIR}/${NV_PACKAGE}/src/nvidia.ko" || die
302 # NVIDIA kernel <-> userspace driver config lib
303 dolib.so
${NV_LIB}/libnvidia-cfg.so.
${NV_SOVER} || \
304 die
"failed to install libnvidia-cfg"
307 insinto
/usr
/$
(get_libdir
)/xorg
/modules
/drivers
308 doins
${NV_X11}/modules
/drivers
/nvidia_drv.so || die
"failed to install nvidia_drv.so"
311 insinto
/usr
/$
(get_libdir
)/opengl
/nvidia
/extensions
312 doins
${NV_X11}/modules
/extensions
/libglx.so.
${NV_SOVER} || \
313 die
"failed to install libglx.so"
314 dosym
/usr
/$
(get_libdir
)/opengl
/nvidia
/extensions
/libglx.so.
${NV_SOVER} \
315 /usr
/$
(get_libdir
)/opengl
/nvidia
/extensions
/libglx.so || \
316 die
"failed to create libglx.so symlink"
319 dolib.a
${NV_X11}/libXvMCNVIDIA.a || \
320 die
"failed to install libXvMCNVIDIA.so"
321 dolib.so
${NV_X11}/libXvMCNVIDIA.so.
${NV_SOVER} || \
322 die
"failed to install libXvMCNVIDIA.so"
323 dosym libXvMCNVIDIA.so.
${NV_SOVER} /usr
/$
(get_libdir
)/libXvMCNVIDIA.so || \
324 die
"failed to create libXvMCNVIDIA.so symlink"
326 # CUDA headers (driver to come)
327 if use kernel_linux
; then
328 dodir
/usr
/include
/cuda
329 insinto
/usr
/include
/cuda
330 doins usr
/include
/cuda
/*.h || die
"failed to install cuda headers"
333 # OpenCL headers (driver to come)
334 if [[ -d ${S}/usr
/include
/CL
]]; then
335 dodir
/usr
/include
/CL
336 insinto
/usr
/include
/CL
337 doins usr
/include
/CL
/*.h || die
"failed to install OpenCL headers"
341 dodoc
${NV_DOC}/XF86Config.sample
342 dohtml
${NV_DOC}/html
/*
343 if use x86-fbsd
; then
344 dodoc
"${NV_DOC}/README"
345 doman
"${NV_MAN}/nvidia-xconfig.1"
348 newdoc
"${NV_DOC}/README.txt" README
349 dodoc
"${NV_DOC}/NVIDIA_Changelog"
350 doman
"${NV_MAN}/nvidia-smi.1.gz"
351 doman
"${NV_MAN}/nvidia-xconfig.1.gz"
355 dobin
${NV_EXEC}/nvidia-xconfig || die
356 dobin
${NV_EXEC}/nvidia-bug-report.sh || die
357 if use kernel_linux
; then
358 dobin
${NV_EXEC}/nvidia-smi || die
361 if has_multilib_profile
; then
363 for ABI
in $
(get_install_abis
) ; do
372 is_final_abi || die
"failed to iterate through all ABIs"
375 # Install nvidia library:
376 # the first parameter is the place where to install it
377 # the second parameter is the base name of the library
378 # the third parameter is the provided soversion
383 libname
=$
(basename $2)
385 doexe
$2.
$3 || die
"failed to install $2"
386 dosym
${libname}.
$3 $1/${libname} || die
"failed to symlink $2"
387 [[ $3 != "1" ]] && dosym
${libname}.
$3 $1/${libname}.1
392 local inslibdir
=$
(get_libdir
)
394 if has_multilib_profile
&& [[ ${ABI} == "x86" ]] ; then
398 local NV_ROOT
="/usr/${inslibdir}/opengl/nvidia"
402 if use kernel_linux
; then
403 libdir
=usr
/${pkglibdir}
407 # on FreeBSD it has just .1 suffix
412 donvidia
${NV_ROOT}/lib ${libdir}/libGL.so ${sover}
413 donvidia
${NV_ROOT}/lib ${libdir}/libGLcore.so ${sover}
414 donvidia
${NV_ROOT}/lib ${libdir}/tls/libnvidia-tls.so ${sover}
416 if ! use x86-fbsd
; then
417 # Install the .la file for libtool, to prevent e.g. bug #176423
418 [ -f "${FILESDIR}/libGL.la-r2" ] || die
"libGL.la-r2 missing in FILESDIR"
419 local ver1
=$
(get_version_component_range
1)
420 local ver2
=$
(get_version_component_range
2)
421 local ver3
=$
(get_version_component_range
3)
422 sed -e "s:\${PV}:${PV}:" \
423 -e "s:\${ver1}:${ver1}:" \
424 -e "s:\${ver2}:${ver2}:" \
425 -e "s:\${ver3}:${ver3}:" \
426 -e "s:\${libdir}:${inslibdir}:" \
427 "${FILESDIR}"/libGL.la-r2 > "${D}"/${NV_ROOT}/lib/libGL.la
431 if [[ -f usr/${pkglibdir}/libcuda.so.${PV} ]]; then
432 dolib.so usr/${pkglibdir}/libcuda.so.${PV}
433 dosym libcuda.so.${PV} /usr/${inslibdir}/libcuda.so.1
434 dosym libcuda.so.1 /usr/${inslibdir}/libcuda.so
438 if [[ -f usr/${pkglibdir}/libvdpau_nvidia.so.${PV} ]]; then
439 dolib.so usr/${pkglibdir}/libvdpau_nvidia.so.${PV}
440 dosym libvdpau_nvidia.so.${PV} /usr/${inslibdir}/libvdpau_nvidia.so
444 # NOTE: This isn't currently available in the publicly released drivers.
445 if [[ -f usr/${pkglibdir}/libOpenCL.so.1.0.0 ]]; then
447 dolib.so usr/${pkglibdir}/libnvcompiler.so.${PV}
448 dosym libnvcompiler.so.${PV} /usr/${inslibdir}/libnvcompiler.so.1
449 dosym libnvcompiler.so.1 /usr/${inslibdir}/libnvcompiler.so
451 dolib.so usr/${pkglibdir}/libOpenCL.so.1.0.0
452 dosym libOpenCL.so.1.0.0 /usr/${inslibdir}/libOpenCL.so.1
453 dosym libOpenCL.so.1 /usr/${inslibdir}/libOpenCL.so
459 # Clean the dynamic libGL stuff's home to ensure
460 # we dont have stale libs floating around
461 if [ -d "${ROOT}"/usr/lib/opengl/nvidia ] ; then
462 rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
464 # Make sure we nuke the old nvidia-glx's env.d file
465 if [ -e "${ROOT}"/etc/env.d/09nvidia ] ; then
466 rm -f "${ROOT}"/etc/env.d/09nvidia
471 if use kernel_linux; then
472 linux-mod_pkg_postinst
475 # Switch to the nvidia implementation
476 eselect opengl set --use-old nvidia
479 elog "You must be
in the video group to use the NVIDIA device
"
480 elog "For
more info
, read the docs
at"
481 elog "http
://www.gentoo.org
/doc
/en
/nvidia-guide.xml
#doc_chap3_sect6"
484 elog
"This ebuild installs a kernel module and X driver. Both must"
485 elog
"match explicitly in their version. This means, if you restart"
486 elog
"X, you most modprobe -r nvidia before starting it back up"
489 elog
"To use the NVIDIA GLX, run \"eselect opengl set nvidia\""
491 elog
"NVIDIA has requested that any bug reports submitted have the"
492 elog
"output of /usr/bin/nvidia-bug-report.sh included."
494 elog
"To work with compiz, you must enable the AddARGBGLXVisuals option."
496 elog
"If you are having resolution problems, try disabling DynamicTwinView."
501 if use kernel_linux
; then
504 eselect opengl
set --use-old xorg-x11