x11-drivers/nvidia-drivers-195.30: fixes
[otih-overlay.git] / x11-drivers / nvidia-drivers / nvidia-drivers-195.30.ebuild
blobd3c8091a54c894c1ad337379b861151ee8aade5a
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 # 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
255 sed -i \
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
265 fi
268 src_compile() {
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.
273 cd "${NV_SRC}"
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
279 fi
282 src_install() {
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."
290 fi
292 # Add the aliases
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 > \
296 "${WORKDIR}"/nvidia
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
305 fi
307 # NVIDIA kernel <-> userspace driver config lib
308 dolib.so ${NV_LIB}/libnvidia-cfg.so.${NV_SOVER} || \
309 die "failed to install libnvidia-cfg"
311 # Xorg DDX driver
312 insinto /usr/$(get_libdir)/xorg/modules/drivers
313 doins ${NV_X11_DRV}/nvidia_drv.so || die "failed to install nvidia_drv.so"
315 # Xorg GLX driver
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"
323 # XvMC driver
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"
336 fi
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"
343 fi
345 # Documentation
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"
351 else
352 # Docs
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"
357 fi
359 # Helper Apps
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
364 fi
366 if has_multilib_profile ; then
367 local OABI=${ABI}
368 for ABI in $(get_install_abis) ; do
369 src_install-libs
370 done
371 ABI=${OABI}
372 unset OABI
373 else
374 src_install-libs
375 fi
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
384 donvidia() {
385 dodir $1
386 exeinto $1
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
395 src_install-libs() {
396 local inslibdir=$(get_libdir)
397 local NV_ROOT="/usr/${inslibdir}/opengl/nvidia"
398 local libdir= sover=
400 if use kernel_linux; then
401 if has_multilib_profile && [[ ${ABI} == "x86" ]] ; then
402 libdir=usr/lib32
403 else
404 libdir=usr/lib
405 fi
406 sover=${PV}
407 else
408 libdir=obj
409 # on FreeBSD it has just .1 suffix
410 sover=1
411 fi
413 # The GLX libraries
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}
418 else
419 donvidia ${NV_ROOT}/lib ${libdir}/tls/libnvidia-tls.so ${sover}
420 fi
422 #cuda
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
427 fi
429 #vdpau
430 if [[ -f ${libdir}/vdpau/libvdpau_nvidia.so.${sover} ]]; then
431 insinto /usr/${inslibdir}/vdpau
432 dolib.so ${libdir}/vdpau/libvdpau_nvidia.so.${sover}
433 dosym libvdpau_nvidia.so.${sover} /usr/${inslibdir}/libvdpau_nvidia.so.1
434 fi
436 # OpenCL
437 # NOTE: This isn't currently available in the publicly released drivers.
438 if [[ -f ${libdir}/libOpenCL.so.1.0.0 ]]; then
440 dolib.so ${libdir}/libnvcompiler.so.${sover}
441 [[ "${sover}" != "1" ]] && dosym libnvcompiler.so.${sover} /usr/${inslibdir}/libnvcompiler.so.1
442 dosym libnvcompiler.so.1 /usr/${inslibdir}/libnvcompiler.so
444 dolib.so ${libdir}/libOpenCL.so.1.0.0
445 dosym libOpenCL.so.1.0.0 /usr/${inslibdir}/libOpenCL.so.1
446 dosym libOpenCL.so.1 /usr/${inslibdir}/libOpenCL.so
447 fi
450 pkg_preinst() {
451 if use kernel_linux; then
452 linux-mod_pkg_postinst
453 fi
455 # Clean the dynamic libGL stuff's home to ensure
456 # we dont have stale libs floating around
457 if [ -d "${ROOT}"/usr/lib/opengl/nvidia ] ; then
458 rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
459 fi
460 # Make sure we nuke the old nvidia-glx's env.d file
461 if [ -e "${ROOT}"/etc/env.d/09nvidia ] ; then
462 rm -f "${ROOT}"/etc/env.d/09nvidia
463 fi
466 pkg_postinst() {
467 if use kernel_linux; then
468 linux-mod_pkg_postinst
469 fi
471 # Switch to the nvidia implementation
472 eselect opengl set --use-old nvidia
474 echo
475 elog "You must be in the video group to use the NVIDIA device"
476 elog "For more info, read the docs at"
477 elog "http://www.gentoo.org/doc/en/nvidia-guide.xml#doc_chap3_sect6"
478 elog
480 elog "This ebuild installs a kernel module and X driver. Both must"
481 elog "match explicitly in their version. This means, if you restart"
482 elog "X, you must modprobe -r nvidia before starting it back up"
483 elog
485 elog "To use the NVIDIA GLX, run \"eselect opengl set nvidia\""
486 elog
487 elog "NVIDIA has requested that any bug reports submitted have the"
488 elog "output of /usr/bin/nvidia-bug-report.sh included."
489 elog
490 elog "To work with compiz, you must enable the AddARGBGLXVisuals option."
491 elog
492 elog "If you are having resolution problems, try disabling DynamicTwinView."
493 echo
496 pkg_postrm() {
497 if use kernel_linux; then
498 linux-mod_pkg_postrm
499 fi
500 eselect opengl set --use-old xorg-x11