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-r3.ebuild,v 1.4 2009/11/12 19:12:29 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 )
29 >=app-admin/eselect-opengl-1.0.9"
31 kernel_linux? ( virtual/linux-sources )"
33 kernel_linux? ( virtual/modutils )
34 acpi? ( sys-power/acpid )"
35 PDEPEND
="x11-libs/libvdpau
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}
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}
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}
119 usr/bin/nvidia-xconfig"
123 NV_PACKAGE
="${X86_NV_PACKAGE}"
126 NV_PACKAGE
="${AMD64_NV_PACKAGE}"
127 elif use x86-fbsd
; then
129 NV_PACKAGE
="${X86_FBSD_NV_PACKAGE}"
132 S
="${WORKDIR}/${NV_PACKAGE}${PKG_V}"
135 ebegin
"Checking for MTRR support"
136 linux_chkconfig_present MTRR
139 if [[ $?
-ne 0 ]] ; then
140 eerror
"Please enable MTRR support in your kernel config, found at:"
142 eerror
" Processor type and features"
143 eerror
" [*] MTRR (Memory Type Range Register) support"
145 eerror
"and recompile your kernel ..."
146 die
"MTRR support not detected!"
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"
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}"
175 if use kernel_linux
; then
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)"
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
201 NV_MAN
="${S}/x11/man"
203 NV_X11_DRV
="${NV_X11}"
204 NV_X11_EXT
="${NV_X11}"
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"
217 die
"Could not determine proper NVIDIA package"
222 if use kernel_linux
&& kernel_is lt
2 6 7; then
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"
229 ewarn
"DO NOT file bug reports for kernel versions less than 2.6.7 as they will be ignored."
232 if ! use x86-fbsd
; then
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 # Adjust detection of linux kernel
251 epatch
"${FILESDIR}"/NVIDIA_arch.
patch
253 if use kernel_linux
; then
254 # Quiet down warnings the user does not need to see
256 -e 's:-Wpointer-arith::g' \
257 -e 's:-Wsign-compare::g' \
258 "${NV_SRC}"/Makefile.kbuild
260 # If you set this then it's your own fault when stuff breaks :)
261 use custom-cflags
&& sed -i "s:-O:${CFLAGS}:" "${NV_SRC}"/Makefile.
*
263 # If greater than 2.6.5 use M= instead of SUBDIR=
264 convert_to_m
"${NV_SRC}"/Makefile.kbuild
269 # This is already the default on Linux, as there's no toplevel Makefile, but
270 # on FreeBSD there's one and triggers the kernel module build, as we install
271 # it by itself, pass this.
274 if use x86-fbsd
; then
275 MAKE
="$(get_bmake)" CFLAGS
="-Wno-sign-compare" emake CC
="$(tc-getCC)" \
276 LD
="$(tc-getLD)" LDFLAGS
="$(raw-ldflags)" || die
277 elif use kernel_linux
; then
278 linux-mod_src_compile
283 if use kernel_linux
; then
284 linux-mod_src_install
286 VIDEOGROUP
="$(egetent group video | cut -d ':' -f 3)"
287 if [ -z "$VIDEOGROUP" ]; then
288 eerror
"Failed to determine the video group gid."
289 die
"Failed to determine the video group gid."
293 [ -f "${FILESDIR}/nvidia-169.07" ] || die
"nvidia missing in FILESDIR"
294 sed -e 's:PACKAGE:'${PF}':g' \
295 -e 's:VIDEOGID:'${VIDEOGROUP}':' "${FILESDIR}"/nvidia-169.07
> \
297 insinto
/etc
/modprobe.d
298 newins
"${WORKDIR}"/nvidia nvidia.conf || die
299 elif use x86-fbsd
; then
300 insinto
/boot
/modules
301 doins
"${WORKDIR}/${NV_PACKAGE}/src/nvidia.kld" || die
303 exeinto
/boot
/modules
304 doexe
"${WORKDIR}/${NV_PACKAGE}/src/nvidia.ko" || die
307 # NVIDIA kernel <-> userspace driver config lib
308 dolib.so
${NV_LIB}/libnvidia-cfg.so.
${NV_SOVER} || \
309 die
"failed to install libnvidia-cfg"
312 insinto
/usr
/$
(get_libdir
)/xorg
/modules
/drivers
313 doins
${NV_X11_DRV}/nvidia_drv.so || die
"failed to install nvidia_drv.so"
316 insinto
/usr
/$
(get_libdir
)/opengl
/nvidia
/extensions
317 doins
${NV_X11_EXT}/libglx.so.
${NV_SOVER} || \
318 die
"failed to install libglx.so"
319 dosym
/usr
/$
(get_libdir
)/opengl
/nvidia
/extensions
/libglx.so.
${NV_SOVER} \
320 /usr
/$
(get_libdir
)/opengl
/nvidia
/extensions
/libglx.so || \
321 die
"failed to create libglx.so symlink"
324 dolib.a
${NV_X11}/libXvMCNVIDIA.a || \
325 die
"failed to install libXvMCNVIDIA.so"
326 dolib.so
${NV_X11}/libXvMCNVIDIA.so.
${NV_SOVER} || \
327 die
"failed to install libXvMCNVIDIA.so"
328 dosym libXvMCNVIDIA.so.
${NV_SOVER} /usr
/$
(get_libdir
)/libXvMCNVIDIA.so || \
329 die
"failed to create libXvMCNVIDIA.so symlink"
331 # CUDA headers (driver to come)
332 if use kernel_linux
; then
333 dodir
/usr
/include
/cuda
334 insinto
/usr
/include
/cuda
335 doins usr
/include
/cuda
/*.h || die
"failed to install cuda headers"
338 # OpenCL headers (driver to come)
339 if [[ -d ${S}/usr
/include
/CL
]]; then
340 dodir
/usr
/include
/CL
341 insinto
/usr
/include
/CL
342 doins usr
/include
/CL
/*.h || die
"failed to install OpenCL headers"
346 dodoc
${NV_DOC}/XF86Config.sample
347 dohtml
${NV_DOC}/html
/*
348 if use x86-fbsd
; then
349 dodoc
"${NV_DOC}/README"
350 doman
"${NV_MAN}/nvidia-xconfig.1"
353 newdoc
"${NV_DOC}/README.txt" README
354 dodoc
"${NV_DOC}/NVIDIA_Changelog"
355 doman
"${NV_MAN}/nvidia-smi.1.gz"
356 doman
"${NV_MAN}/nvidia-xconfig.1.gz"
360 dobin
${NV_EXEC}/nvidia-xconfig || die
361 dobin
${NV_EXEC}/nvidia-bug-report.sh || die
362 if use kernel_linux
; then
363 dobin
${NV_EXEC}/nvidia-smi || die
366 if has_multilib_profile
; then
368 for ABI
in $
(get_install_abis
) ; do
377 is_final_abi || die
"failed to iterate through all ABIs"
380 # Install nvidia library:
381 # the first parameter is the place where to install it
382 # the second parameter is the base name of the library
383 # the third parameter is the provided soversion
388 libname
=$
(basename $2)
390 doexe
$2.
$3 || die
"failed to install $2"
391 dosym
${libname}.
$3 $1/${libname} || die
"failed to symlink $2"
392 [[ $3 != "1" ]] && dosym
${libname}.
$3 $1/${libname}.1
396 local inslibdir
=$
(get_libdir
)
397 local NV_ROOT
="/usr/${inslibdir}/opengl/nvidia"
400 if use kernel_linux
; then
401 if has_multilib_profile
&& [[ ${ABI} == "x86" ]] ; then
409 # on FreeBSD it has just .1 suffix
414 donvidia
${NV_ROOT}/lib ${libdir}/libGL.so ${sover}
415 donvidia
${NV_ROOT}/lib ${libdir}/libGLcore.so ${sover}
416 if use x86-fbsd
; then
417 donvidia
${NV_ROOT}/lib ${libdir}/libnvidia-tls.so ${sover}
419 donvidia
${NV_ROOT}/lib ${libdir}/tls/libnvidia-tls.so ${sover}
423 if [[ -f ${libdir}/libcuda.so.
${sover} ]]; then
424 dolib.so
${libdir}/libcuda.so.
${sover}
425 [[ "${sover}" != "1" ]] && dosym libcuda.so.${sover} /usr/${inslibdir}/libcuda.so.1
426 dosym libcuda.so.1 /usr/${inslibdir}/libcuda.so
430 if [[ -f ${libdir}/vdpau/libvdpau_nvidia.so.${sover} ]]; then
431 dolib.so ${libdir}/vdpau/libvdpau_nvidia.so.${sover}
432 dosym libvdpau_nvidia.so.${sover} /usr/${inslibdir}/libvdpau_nvidia.so
436 # NOTE: This isn't currently available in the publicly released drivers.
437 if [[ -f ${libdir}/libOpenCL.so.1.0.0 ]]; then
439 dolib.so ${libdir}/libOpenCL.so.1.0.0
440 dosym libOpenCL.so.1.0.0 /usr/${inslibdir}/libOpenCL.so.1
441 dosym libOpenCL.so.1 /usr/${inslibdir}/libOpenCL.so
446 if use kernel_linux; then
447 linux-mod_pkg_postinst
450 # Clean the dynamic libGL stuff's home to ensure
451 # we dont have stale libs floating around
452 if [ -d "${ROOT}"/usr/lib/opengl/nvidia ] ; then
453 rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
455 # Make sure we nuke the old nvidia-glx's env.d file
456 if [ -e "${ROOT}"/etc/env.d/09nvidia ] ; then
457 rm -f "${ROOT}"/etc/env.d/09nvidia
462 if use kernel_linux; then
463 linux-mod_pkg_postinst
466 # Switch to the nvidia implementation
467 eselect opengl set --use-old nvidia
470 elog "You must be
in the video group to use the NVIDIA device
"
471 elog "For
more info
, read the docs
at"
472 elog "http
://www.gentoo.org
/doc
/en
/nvidia-guide.xml
#doc_chap3_sect6"
475 elog
"This ebuild installs a kernel module and X driver. Both must"
476 elog
"match explicitly in their version. This means, if you restart"
477 elog
"X, you must modprobe -r nvidia before starting it back up"
480 elog
"To use the NVIDIA GLX, run \"eselect opengl set nvidia\""
482 elog
"NVIDIA has requested that any bug reports submitted have the"
483 elog
"output of /usr/bin/nvidia-bug-report.sh included."
485 elog
"To work with compiz, you must enable the AddARGBGLXVisuals option."
487 elog
"If you are having resolution problems, try disabling DynamicTwinView."
492 if use kernel_linux
; then
495 eselect opengl
set --use-old xorg-x11