1 # Copyright 1999-2008 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-177.80.ebuild,v 1.1 2008/10/13 00:35:38 ricmm Exp $
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}"
10 DESCRIPTION="NVIDIA X11 driver and GLX libraries"
11 HOMEPAGE="http://www.nvidia.com/"
12 SRC_URI="x86? ( http://download.nvidia.com/XFree86/Linux-x86/${PV}/${X86_NV_PACKAGE}-pkg0.run )
13 amd64? ( http://download.nvidia.com/XFree86/Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}-pkg2.run )"
17 KEYWORDS="-* ~amd64 ~x86"
18 IUSE="acpi custom-cflags gtk multilib kernel_linux"
22 COMMON="x11-base/xorg-server
23 multilib? ( app-emulation/emul-linux-x86-xlibs )
24 kernel_FreeBSD? ( !media-video/nvidia-freebsd )
25 !app-emulation/emul-linux-x86-nvidia
26 !x11-drivers/nvidia-legacy-drivers"
28 kernel_linux? ( virtual/linux-sources )
29 app-admin/eselect-opengl"
31 kernel_linux? ( virtual/modutils )
33 acpi? ( sys-power/acpid )"
34 PDEPEND="gtk? ( media-video/nvidia-settings )"
36 QA_TEXTRELS_x86="usr/lib/libXvMCNVIDIA.so.${PV}
37 usr/lib/opengl/nvidia/no-tls/libnvidia-tls.so.${PV}
38 usr/lib/opengl/nvidia/tls/libnvidia-tls.so.${PV}
39 usr/lib/opengl/nvidia/lib/libGL.so.${PV}
40 usr/lib/opengl/nvidia/lib/libnvidia-cfg.so.${PV}
41 usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
42 usr/lib/opengl/nvidia/extensions/libglx.so
43 usr/lib/xorg/modules/drivers/nvidia_drv.so
44 usr/lib/libcuda.so.${PV}"
46 QA_TEXTRELS_x86_fbsd="boot/modules/nvidia.ko
47 usr/lib/opengl/nvidia/lib/libGL.so.1
48 usr/lib/opengl/nvidia/lib/libGLcore.so.1
49 usr/lib/opengl/nvidia/lib/libnvidia-cfg.so.1
50 usr/lib/opengl/nvidia/no-tls/libnvidia-tls.so.1
51 usr/lib/opengl/nvidia/extensions/libglx.so
52 usr/lib/xorg/modules/drivers/nvidia_drv.so"
54 QA_TEXTRELS_amd64="usr/lib32/opengl/nvidia/tls/libnvidia-tls.so.${PV}
55 usr/lib32/opengl/nvidia/no-tls/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/opengl/nvidia/lib/libnvidia-cfg.so.${PV}
59 usr/lib32/libcuda.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"
65 QA_EXECSTACK_amd64="usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
66 usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
67 usr/lib64/xorg/modules/drivers/nvidia_drv.so
68 usr/lib64/libXvMCNVIDIA.so.${PV}
69 usr/lib64/opengl/nvidia/tls/libnvidia-tls.so.${PV}
70 usr/lib64/opengl/nvidia/no-tls/libnvidia-tls.so.${PV}
71 usr/lib64/opengl/nvidia/lib/libGLcore.so.${PV}
72 usr/lib64/opengl/nvidia/lib/libGL.so.${PV}
73 usr/lib64/opengl/nvidia/lib/libnvidia-cfg.so.${PV}
74 usr/lib64/opengl/nvidia/extensions/libglx.so
75 usr/bin/nvidia-xconfig"
77 QA_WX_LOAD_x86="usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
78 usr/lib/opengl/nvidia/lib/libGL.so.${PV}
79 usr/lib/opengl/nvidia/extensions/libglx.so"
81 QA_WX_LOAD_amd64="usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
82 usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
83 usr/lib64/opengl/nvidia/lib/libGLcore.so.${PV}
84 usr/lib64/opengl/nvidia/lib/libGL.so.${PV}
85 usr/lib64/opengl/nvidia/extensions/libglx.so"
89 NV_PACKAGE="${X86_NV_PACKAGE}"
92 NV_PACKAGE="${AMD64_NV_PACKAGE}"
93 elif use x86-fbsd; then
95 NV_PACKAGE="${X86_FBSD_NV_PACKAGE}"
98 S="${WORKDIR}/${NV_PACKAGE}${PKG_V}"
101 ebegin "Checking for MTRR support"
102 linux_chkconfig_present MTRR
105 if [[ $? -ne 0 ]] ; then
106 eerror "Please enable MTRR support in your kernel config, found at:"
108 eerror " Processor type and features"
109 eerror " [*] MTRR (Memory Type Range Register) support"
111 eerror "and recompile your kernel ..."
112 die "MTRR support not detected!"
117 ebegin "Checking for Paravirtualized guest support"
118 linux_chkconfig_present PARAVIRT
120 if [[ $? -eq 0 ]]; then
121 eerror "Please disable PARAVIRT in your kernel config, found at:"
123 eerror " Processor type and features"
124 eerror " [*] Paravirtualized guest support"
126 eerror "or XEN support"
128 eerror "and recompile your kernel .."
129 die "PARAVIRT support detected!"
134 # try to turn off distcc and ccache for people that have a problem with it
135 export DISTCC_DISABLE=1
136 export CCACHE_DISABLE=1
138 if use amd64 && has_multilib_profile && [ "${DEFAULT_ABI}" != "amd64" ]; then
139 eerror "This ebuild doesn't currently support changing your default abi."
140 die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
143 if use kernel_linux; then
145 MODULE_NAMES="nvidia(video:${S}/usr/src/nv)"
146 BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
147 SYSOUT=${KV_OUT_DIR} HOST_CC=$(tc-getBUILD_CC)"
152 # On BSD userland it wants real make command
153 use userland_BSD && MAKE="$(get_bmake)"
155 export _POSIX2_VERSION="199209"
157 # Since Nvidia ships 3 different series of drivers, we need to give the user
158 # some kind of guidance as to what version they should install. This tries
159 # to point the user in the right direction but can't be perfect. check
160 # nvidia-driver.eclass
161 nvidia-driver-check-warning
163 # set variables to where files are in the package structure
164 if use kernel_FreeBSD; then
168 elif use kernel_linux; then
169 NV_DOC="${S}/usr/share/doc"
170 NV_EXEC="${S}/usr/bin"
171 NV_SRC="${S}/usr/src/nv"
173 die "Could not determine proper NVIDIA package"
178 if use kernel_linux && kernel_is lt 2 6 7; then
180 ewarn "Your kernel version is ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
181 ewarn "This is not officially supported for ${P}. It is likely you"
182 ewarn "will not be able to compile or use the kernel module."
183 ewarn "It is recommended that you upgrade your kernel to a version >= 2.6.7"
185 ewarn "DO NOT file bug reports for kernel versions less than 2.6.7 as they will be ignored."
188 if ! use x86-fbsd; then
190 bash "${DISTDIR}"/${NV_PACKAGE}${PKG_V}.run --extract-only
195 # Patches go below here, add brief description
197 use x86-fbsd && cd doc
199 # Use the correct defines to make gtkglext build work
200 epatch "${FILESDIR}"/NVIDIA_glx-defines.patch
201 # Use some more sensible gl headers and make way for new glext.h
202 epatch "${FILESDIR}"/NVIDIA_glx-glheader.patch
204 # allow on board sensors to work with lm_sensors
205 if use kernel_linux; then
206 epatch "${FILESDIR}"/NVIDIA_i2c-hwmon.patch
209 if use kernel_linux; then
210 # Quiet down warnings the user does not need to see
212 -e 's:-Wpointer-arith::g' \
213 -e 's:-Wsign-compare::g' \
214 "${NV_SRC}"/Makefile.kbuild
216 # If you set this then it's your own fault when stuff breaks :)
217 use custom-cflags && sed -i "s:-O:${CFLAGS}:" Makefile.*
219 # If greater than 2.6.5 use M= instead of SUBDIR=
220 convert_to_m "${NV_SRC}"/Makefile.kbuild
225 # This is already the default on Linux, as there's no toplevel Makefile, but
226 # on FreeBSD there's one and triggers the kernel module build, as we install
227 # it by itself, pass this.
230 if use x86-fbsd; then
231 MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
232 LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
233 elif use kernel_linux; then
234 linux-mod_src_compile
239 local MLTEST=$(type dyn_unpack)
243 if use kernel_linux; then
244 linux-mod_src_install
246 VIDEOGROUP="$(egetent group video | cut -d ':' -f 3)"
247 if [ -z "$VIDEOGROUP" ]; then
248 eerror "Failed to determine the video group gid."
249 die "Failed to determine the video group gid."
253 [ -f "${FILESDIR}/nvidia" ] || die "nvidia missing in FILESDIR"
254 sed -e 's:PACKAGE:'${PF}':g' \
255 -e 's:VIDEOGID:'${VIDEOGROUP}':' "${FILESDIR}"/nvidia-169.07 > \
257 insinto /etc/modprobe.d
258 doins "${WORKDIR}"/nvidia || die
259 elif use x86-fbsd; then
260 insinto /boot/modules
261 doins "${WORKDIR}/${NV_PACKAGE}/src/nvidia.kld" || die
263 exeinto /boot/modules
264 doexe "${WORKDIR}/${NV_PACKAGE}/src/nvidia.ko" || die
267 if has_multilib_profile ; then
269 for ABI in $(get_install_abis) ; do
274 elif use amd64 ; then
275 src_install-libs lib32 $(get_multilibdir)
276 src_install-libs lib $(get_libdir)
278 rm -rf "${D}"/usr/$(get_multilibdir)/opengl/nvidia/include
279 rm -rf "${D}"/usr/$(get_multilibdir)/opengl/nvidia/extensions
284 is_final_abi || return 0
287 dodoc "${NV_DOC}"/{XF86Config.sample,Copyrights}
288 dohtml "${NV_DOC}"/html/*
289 if use x86-fbsd; then
290 dodoc "${NV_DOC}/README"
293 newdoc "${NV_DOC}/README.txt" README
294 dodoc "${NV_DOC}/NVIDIA_Changelog"
298 dobin ${NV_EXEC}/nvidia-xconfig || die
299 dobin ${NV_EXEC}/nvidia-bug-report.sh || die
302 # Install nvidia library:
303 # the first parameter is the place where to install it
304 # the second parameter is the base name of the library
305 # the third parameter is the provided soversion
310 libname=$(basename $2)
312 # libnvidia-cfg.so is no longer supplied in lib32; step over it gracefully
313 if [ -e $2.$3 ] ; then
315 dosym ${libname}.$3 $1/${libname}
316 [[ $3 != "1" ]] && dosym ${libname}.$3 $1/${libname}.1
322 local inslibdir=$(get_libdir)
324 if [[ ${#} -eq 2 ]] ; then
327 elif has_multilib_profile && [[ ${ABI} == "x86" ]] ; then
331 local usrpkglibdir=usr/${pkglibdir}
332 local libdir=usr/X11R6/${pkglibdir}
333 local drvdir=${libdir}/modules/drivers
334 local extdir=${libdir}/modules/extensions
335 local incdir=usr/include/GL
337 local NV_ROOT="/usr/${inslibdir}/opengl/nvidia"
338 local NO_TLS_ROOT="${NV_ROOT}/no-tls"
339 local TLS_ROOT="${NV_ROOT}/tls"
340 local X11_LIB_DIR="/usr/${inslibdir}/xorg"
342 if use x86-fbsd; then
343 # on FreeBSD everything is on obj/
350 # don't ask me why the headers are there.. glxext.h is missing
353 # on FreeBSD it has just .1 suffix
358 donvidia ${NV_ROOT}/lib ${usrpkglibdir}/libGL.so ${sover}
359 donvidia ${NV_ROOT}/lib ${usrpkglibdir}/libGLcore.so ${sover}
361 donvidia ${NV_ROOT}/lib ${usrpkglibdir}/libnvidia-cfg.so ${sover}
364 donvidia ${NO_TLS_ROOT} ${usrpkglibdir}/libnvidia-tls.so ${sover}
366 if ! use x86-fbsd; then
367 donvidia ${TLS_ROOT} ${usrpkglibdir}/tls/libnvidia-tls.so ${sover}
371 dosym ../tls/libnvidia-tls.so ${NV_ROOT}/lib
372 dosym ../tls/libnvidia-tls.so.1 ${NV_ROOT}/lib
373 dosym ../tls/libnvidia-tls.so.${sover} ${NV_ROOT}/lib
375 dosym ../no-tls/libnvidia-tls.so ${NV_ROOT}/lib
376 dosym ../no-tls/libnvidia-tls.so.1 ${NV_ROOT}/lib
377 dosym ../no-tls/libnvidia-tls.so.${sover} ${NV_ROOT}/lib
380 if ! use x86-fbsd; then
381 # Install the .la file for libtool, to prevent e.g. bug #176423
382 [ -f "${FILESDIR}/libGL.la-r2" ] || die "libGL.la-r2 missing in FILESDIR"
383 local ver1=$(get_version_component_range 1)
384 local ver2=$(get_version_component_range 2)
385 local ver3=$(get_version_component_range 3)
386 sed -e "s:\${PV}:${PV}:" \
387 -e "s:\${ver1}:${ver1}:" \
388 -e "s:\${ver2}:${ver2}:" \
389 -e "s:\${ver3}:${ver3}:" \
390 -e "s:\${libdir}:${inslibdir}:" \
391 "${FILESDIR}"/libGL.la-r2 > "${D}"/${NV_ROOT}/lib/libGL.la
394 exeinto ${X11_LIB_DIR}/modules/drivers
396 [[ -f ${drvdir}/nvidia_drv.so ]] && \
397 doexe ${drvdir}/nvidia_drv.so
399 insinto /usr/${inslibdir}
400 [[ -f ${libdir}/libXvMCNVIDIA.a ]] && \
401 doins ${libdir}/libXvMCNVIDIA.a
402 exeinto /usr/${inslibdir}
404 [[ -f ${libdir}/libXvMCNVIDIA.so.${PV} ]] && \
405 doexe ${libdir}/libXvMCNVIDIA.so.${PV} && \
406 dosym libXvMCNVIDIA.so.${PV} \
407 /usr/${inslibdir}/libXvMCNVIDIA.so
409 exeinto ${NV_ROOT}/extensions
410 [[ -f ${libdir}/modules/libnvidia-wfb.so.${sover} ]] && \
411 newexe ${libdir}/modules/libnvidia-wfb.so.${sover} libwfb.so
412 [[ -f ${extdir}/libglx.so.${sover} ]] && \
413 newexe ${extdir}/libglx.so.${sover} libglx.so
416 insinto ${NV_ROOT}/include
420 if [[ -f usr/include/cuda/cuda.h ]]; then
421 dodir /usr/include/cuda
422 insinto /usr/include/cuda
423 doins usr/include/cuda/*.h
425 if [[ -f usr/${pkglibdir}/libcuda.so.${PV} ]]; then
426 dolib.so usr/${pkglibdir}/libcuda.so.${PV}
427 dosym libcuda.so.${PV} /usr/${inslibdir}/libcuda.so.1
428 dosym libcuda.so.1 /usr/${inslibdir}/libcuda.so
433 if [[ -f usr/include/vdpau/vdpau.h ]]; then
434 dodir /usr/include/vdpau
435 insinto /usr/include/vdpau
436 doins usr/include/vdpau/*.h
438 for vdpau_lib in libvdpau_nvidia.so libvdpau.so libvdpau_trace.so; do
439 if [[ -f usr/${pkglibdir}/${vdpau_lib}.${PV} ]]; then
440 dolib.so usr/${pkglibdir}/${vdpau_lib}.${PV}
441 dosym ${vdpau_lib}.${PV} /usr/${inslibdir}/${vdpau_lib}.1
442 dosym ${vdpau_lib}.1 /usr/${inslibdir}/${vdpau_lib}
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 most 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 # For uclibc or anything non glibc, return false
493 has_version sys-libs/glibc || return 1
495 # Old versions of glibc were lt/no-tls only
496 has_version '<sys-libs/glibc-2.3.2' && return 1
505 # If we've got nptl, we've got tls
506 built_with_use --missing true sys-libs/glibc nptl && return 0
508 # 2.3.5 turned off tls for linuxthreads glibc on i486 and i586
509 if use x86 && has_version '>=sys-libs/glibc-2.3.5' ; then
511 i486|i586) return 1 ;;
515 # These versions built linuxthreads version to support tls, too
516 has_version '>=sys-libs/glibc-2.3.4.20040619-r2' && return 0
522 if use kernel_linux; then
525 eselect opengl set --use-old xorg-x11