Blah Blah Blah. Stick with -r1 for 173 for the moment.
[gentoo-diskmaster-overlay.git] / x11-drivers / nvidia-drivers / nvidia-drivers-173.14.12-r2.broken
blobb12246a4c9d96b2a88cb391e95aae2f370377e1e
1 # Copyright 1999-2008 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/x11-drivers/nvidia-drivers/nvidia-drivers-173.14.12.ebuild,v 1.1 2008/07/31 13:30:39 chainsaw 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}"
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? ( http://us.download.nvidia.com/XFree86/Linux-x86/${PV}/${X86_NV_PACKAGE}-pkg0.run )
14          amd64? ( http://us.download.nvidia.com/XFree86/Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}-pkg2.run )
15          x86-fbsd? ( http://us.download.nvidia.com/freebsd/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )"
17 LICENSE="NVIDIA"
18 SLOT="0"
19 KEYWORDS="-* ~amd64 ~x86 ~x86-fbsd"
20 IUSE="acpi custom-cflags gtk multilib kernel_linux"
21 RESTRICT="strip"
22 EMULTILIB_PKG="true"
24 COMMON="x11-base/xorg-server
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"
29 DEPEND="${COMMON}
30         kernel_linux? ( virtual/linux-sources )
31         app-admin/eselect-opengl"
32 RDEPEND="${COMMON}
33         kernel_linux? ( virtual/modutils )
34         media-libs/mesa
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}"
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/opengl/nvidia/lib/libnvidia-cfg.so.1
52         usr/lib/opengl/nvidia/no-tls/libnvidia-tls.so.1
53         usr/lib/opengl/nvidia/extensions/libglx.so
54         usr/lib/xorg/modules/drivers/nvidia_drv.so"
56 QA_TEXTRELS_amd64="usr/lib32/opengl/nvidia/tls/libnvidia-tls.so.${PV}
57         usr/lib32/opengl/nvidia/no-tls/libnvidia-tls.so.${PV}
58         usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
59         usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
60         usr/lib32/opengl/nvidia/lib/libnvidia-cfg.so.${PV}
61         usr/lib32/libcuda.so.${PV}"
63 QA_EXECSTACK_x86="usr/lib/opengl/nvidia/lib/libGL.so.${PV}
64         usr/lib/opengl/nvidia/lib/libGLcore.so.${PV}
65         usr/lib/opengl/nvidia/extensions/libglx.so"
67 QA_EXECSTACK_amd64="usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
68         usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
69         usr/lib64/xorg/modules/drivers/nvidia_drv.so
70         usr/lib64/libXvMCNVIDIA.so.${PV}
71         usr/lib64/opengl/nvidia/tls/libnvidia-tls.so.${PV}
72         usr/lib64/opengl/nvidia/no-tls/libnvidia-tls.so.${PV}
73         usr/lib64/opengl/nvidia/lib/libGLcore.so.${PV}
74         usr/lib64/opengl/nvidia/lib/libGL.so.${PV}
75         usr/lib64/opengl/nvidia/lib/libnvidia-cfg.so.${PV}
76         usr/lib64/opengl/nvidia/extensions/libglx.so
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"
83 QA_WX_LOAD_amd64="usr/lib32/opengl/nvidia/lib/libGLcore.so.${PV}
84         usr/lib32/opengl/nvidia/lib/libGL.so.${PV}
85         usr/lib64/opengl/nvidia/lib/libGLcore.so.${PV}
86         usr/lib64/opengl/nvidia/lib/libGL.so.${PV}
87         usr/lib64/opengl/nvidia/extensions/libglx.so"
89 if use x86; then
90         PKG_V="-pkg0"
91         NV_PACKAGE="${X86_NV_PACKAGE}"
92 elif use amd64; then
93         PKG_V="-pkg2"
94         NV_PACKAGE="${AMD64_NV_PACKAGE}"
95 elif use x86-fbsd; then
96         PKG_V=""
97         NV_PACKAGE="${X86_FBSD_NV_PACKAGE}"
100 S="${WORKDIR}/${NV_PACKAGE}${PKG_V}"
102 mtrr_check() {
103         ebegin "Checking for MTRR support"
104         linux_chkconfig_present MTRR
105         eend $?
107         if [[ $? -ne 0 ]] ; then
108                 eerror "Please enable MTRR support in your kernel config, found at:"
109                 eerror
110                 eerror "  Processor type and features"
111                 eerror "    [*] MTRR (Memory Type Range Register) support"
112                 eerror
113                 eerror "and recompile your kernel ..."
114                 die "MTRR support not detected!"
115         fi
118 sysvipc_check() {
119         ebegin "Checking for SYSVIPC support"
120         linux_chkconfig_present SYSVIPC
121         eend $?
123         if [[ $? -ne 0 ]] ; then
124                 eerror "Please enable SYSVIPC support in your kernel config, found at:"
125                 eerror
126                 eerror "  General setup"
127                 eerror "    [*] System V IPC"
128                 eerror
129                 eerror "and recompile your kernel ..."
130                 die "SYSVIPC support not detected!"
131         fi
134 pkg_setup() {
135         # try to turn off distcc and ccache for people that have a problem with it
136         export DISTCC_DISABLE=1
137         export CCACHE_DISABLE=1
139         if use amd64 && has_multilib_profile && [ "${DEFAULT_ABI}" != "amd64" ]; then
140                 eerror "This ebuild doesn't currently support changing your default abi."
141                 die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
142         fi
144         if use kernel_linux; then
145                 linux-mod_pkg_setup
146                 MODULE_NAMES="nvidia(video:${S}/usr/src/nv)"
147                 BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
148                 SYSOUT=${KV_OUT_DIR} HOST_CC=$(tc-getBUILD_CC)"
149                 mtrr_check
150                 sysvipc_check
151         fi
153         # On BSD userland it wants real make command
154         use userland_BSD && MAKE="$(get_bmake)"
156         export _POSIX2_VERSION="199209"
158         # Since Nvidia ships 3 different series of drivers, we need to give the user
159         # some kind of guidance as to what version they should install. This tries
160         # to point the user in the right direction but can't be perfect. check
161         # nvidia-driver.eclass
162         nvidia-driver-check-warning
164         # set variables to where files are in the package structure
165         if use kernel_FreeBSD; then
166                 NV_DOC="${S}/doc"
167                 NV_EXEC="${S}/obj"
168                 NV_SRC="${S}/src"
169         elif use kernel_linux; then
170                 NV_DOC="${S}/usr/share/doc"
171                 NV_EXEC="${S}/usr/bin"
172                 NV_SRC="${S}/usr/src/nv"
173         else
174                 die "Could not determine proper NVIDIA package"
175         fi
178 src_unpack() {
179         if use kernel_linux && kernel_is lt 2 6 7; then
180                 echo
181                 ewarn "Your kernel version is ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
182                 ewarn "This is not officially supported for ${P}. It is likely you"
183                 ewarn "will not be able to compile or use the kernel module."
184                 ewarn "It is recommended that you upgrade your kernel to a version >= 2.6.7"
185                 echo
186                 ewarn "DO NOT file bug reports for kernel versions less than 2.6.7 as they will be ignored."
187         fi
189         if ! use x86-fbsd; then
190                 cd "${WORKDIR}"
191                 bash "${DISTDIR}"/${NV_PACKAGE}${PKG_V}.run --extract-only
192         else
193                 unpack ${A}
194         fi
196         # Patches go below here, add brief description
197         cd "${S}"
198         use x86-fbsd && cd doc
200         # Use the correct defines to make gtkglext build work
201         epatch "${FILESDIR}"/NVIDIA_glx-defines.patch
202         # Use some more sensible gl headers and make way for new glext.h
203         epatch "${FILESDIR}"/NVIDIA_glx-glheader.patch
205         # allow on board sensors to work with lm_sensors
206         if use kernel_linux; then
207                 epatch "${FILESDIR}"/NVIDIA_i2c-hwmon.patch
208         fi
210         if use kernel_linux; then
211                 # Quiet down warnings the user does not need to see
212                 sed -i \
213                         -e 's:-Wpointer-arith::g' \
214                         -e 's:-Wsign-compare::g' \
215                         "${NV_SRC}"/Makefile.kbuild
217                 # If you set this then it's your own fault when stuff breaks :)
218                 use custom-cflags \
219                     && einfo "Patching ${NV_SRC}/Makefile* to respect custom cflags" \
220                     && sed -i "s:-O:${CFLAGS}:" "${NV_SRC}"/Makefile.*
222                 # If greater than 2.6.5 use M= instead of SUBDIR=
223                 convert_to_m "${NV_SRC}"/Makefile.kbuild
224         fi
225         cd ${S}/usr/src/nv
226         epatch "${FILESDIR}"/mm-fix.patch
227         epatch "${FILESDIR}"/nv-173-post-2.6.26-update.patch
228         #epatch "${FILESDIR}"/nv-initmmfix.patch - Pointless.
229         #epatch "${FILESDIR}"/NV-177.13-new.patch - Baroque?
232 src_compile() {
233         # This is already the default on Linux, as there's no toplevel Makefile, but
234         # on FreeBSD there's one and triggers the kernel module build, as we install
235         # it by itself, pass this.
237         cd "${NV_SRC}"
238         if use x86-fbsd; then
239                 MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
240                         LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
241         elif use kernel_linux; then
242                 linux-mod_src_compile
243         fi
246 src_install() {
247         local MLTEST=$(type dyn_unpack)
249         cd "${S}"
251         if use kernel_linux; then
252                 linux-mod_src_install
254                 VIDEOGROUP="$(egetent group video | cut -d ':' -f 3)"
255                 if [ -z "$VIDEOGROUP" ]; then
256                         eerror "Failed to determine the video group gid."
257                         die "Failed to determine the video group gid."
258                 fi
260                 # Add the aliases
261                 [ -f "${FILESDIR}/nvidia" ] || die "nvidia missing in FILESDIR"
262                 sed -e 's:PACKAGE:'${PF}':g' \
263                         -e 's:VIDEOGID:'${VIDEOGROUP}':' "${FILESDIR}"/nvidia-169.07 > \
264                         "${WORKDIR}"/nvidia
265                 insinto /etc/modprobe.d
266                 doins "${WORKDIR}"/nvidia || die
267         elif use x86-fbsd; then
268                 insinto /boot/modules
269                 doins "${WORKDIR}/${NV_PACKAGE}/src/nvidia.kld" || die
271                 exeinto /boot/modules
272                 doexe "${WORKDIR}/${NV_PACKAGE}/src/nvidia.ko" || die
273         fi
275         if has_multilib_profile ; then
276                 local OABI=${ABI}
277                 for ABI in $(get_install_abis) ; do
278                         src_install-libs
279                 done
280                 ABI=${OABI}
281                 unset OABI
282         elif use amd64 ; then
283                 src_install-libs lib32 $(get_multilibdir)
284                 src_install-libs lib $(get_libdir)
286                 rm -rf "${D}"/usr/$(get_multilibdir)/opengl/nvidia/include
287                 rm -rf "${D}"/usr/$(get_multilibdir)/opengl/nvidia/extensions
288         else
289                 src_install-libs
290         fi
292         is_final_abi || return 0
294         # Documentation
295         dodoc "${NV_DOC}"/{XF86Config.sample,Copyrights}
296         dohtml "${NV_DOC}"/html/*
297         if use x86-fbsd; then
298                 dodoc "${NV_DOC}/README"
299         else
300                 # Docs
301                 newdoc "${NV_DOC}/README.txt" README
302                 dodoc "${NV_DOC}/NVIDIA_Changelog"
303         fi
305         # Helper Apps
306         dobin ${NV_EXEC}/nvidia-xconfig || die
307         dobin ${NV_EXEC}/nvidia-bug-report.sh || die
310 # Install nvidia library:
311 # the first parameter is the place where to install it
312 # the second parameter is the base name of the library
313 # the third parameter is the provided soversion
314 donvidia() {
315         dodir $1
316         exeinto $1
318         libname=$(basename $2)
320         # libnvidia-cfg.so is no longer supplied in lib32; step over it gracefully
321         if [ -e $2.$3 ] ; then
322                 doexe $2.$3
323                 dosym ${libname}.$3 $1/${libname}
324                 [[ $3 != "1" ]] && dosym ${libname}.$3 $1/${libname}.1
325         fi
328 src_install-libs() {
329         local pkglibdir=lib
330         local inslibdir=$(get_libdir)
332         if [[ ${#} -eq 2 ]] ; then
333                 pkglibdir=${1}
334                 inslibdir=${2}
335         elif has_multilib_profile && [[ ${ABI} == "x86" ]] ; then
336                 pkglibdir=lib32
337         fi
339         local usrpkglibdir=usr/${pkglibdir}
340         local libdir=usr/X11R6/${pkglibdir}
341         local drvdir=${libdir}/modules/drivers
342         local extdir=${libdir}/modules/extensions
343         local incdir=usr/include/GL
344         local sover=${PV}
345         local NV_ROOT="/usr/${inslibdir}/opengl/nvidia"
346         local NO_TLS_ROOT="${NV_ROOT}/no-tls"
347         local TLS_ROOT="${NV_ROOT}/tls"
348         local X11_LIB_DIR="/usr/${inslibdir}/xorg"
350         if use x86-fbsd; then
351                 # on FreeBSD everything is on obj/
352                 pkglibdir=obj
353                 usrpkglibdir=obj
354                 x11pkglibdir=obj
355                 drvdir=obj
356                 extdir=obj
358                 # don't ask me why the headers are there.. glxext.h is missing
359                 incdir=doc
361                 # on FreeBSD it has just .1 suffix
362                 sover=1
363         fi
365         # The GLX libraries
366         donvidia ${NV_ROOT}/lib ${usrpkglibdir}/libGL.so ${sover}
367         donvidia ${NV_ROOT}/lib ${usrpkglibdir}/libGLcore.so ${sover}
369         donvidia ${NV_ROOT}/lib ${usrpkglibdir}/libnvidia-cfg.so ${sover}
371         dodir ${NO_TLS_ROOT}
372         donvidia ${NO_TLS_ROOT} ${usrpkglibdir}/libnvidia-tls.so ${sover}
374         if ! use x86-fbsd; then
375                 donvidia ${TLS_ROOT} ${usrpkglibdir}/tls/libnvidia-tls.so ${sover}
376         fi
378         if want_tls ; then
379                 dosym ../tls/libnvidia-tls.so ${NV_ROOT}/lib
380                 dosym ../tls/libnvidia-tls.so.1 ${NV_ROOT}/lib
381                 dosym ../tls/libnvidia-tls.so.${sover} ${NV_ROOT}/lib
382         else
383                 dosym ../no-tls/libnvidia-tls.so ${NV_ROOT}/lib
384                 dosym ../no-tls/libnvidia-tls.so.1 ${NV_ROOT}/lib
385                 dosym ../no-tls/libnvidia-tls.so.${sover} ${NV_ROOT}/lib
386         fi
388         if ! use x86-fbsd; then
389                 # Install the .la file for libtool, to prevent e.g. bug #176423
390                 [ -f "${FILESDIR}/libGL.la-r2" ] || die "libGL.la-r2 missing in FILESDIR"
391                 local ver1=$(get_version_component_range 1)
392                 local ver2=$(get_version_component_range 2)
393                 local ver3=$(get_version_component_range 3)
394                 sed -e "s:\${PV}:${PV}:"     \
395                         -e "s:\${ver1}:${ver1}:" \
396                         -e "s:\${ver2}:${ver2}:" \
397                         -e "s:\${ver3}:${ver3}:" \
398                         -e "s:\${libdir}:${inslibdir}:" \
399                         "${FILESDIR}"/libGL.la-r2 > "${D}"/${NV_ROOT}/lib/libGL.la
400         fi
402         exeinto ${X11_LIB_DIR}/modules/drivers
404         [[ -f ${drvdir}/nvidia_drv.so ]] && \
405                 doexe ${drvdir}/nvidia_drv.so
407         insinto /usr/${inslibdir}
408         [[ -f ${libdir}/libXvMCNVIDIA.a ]] && \
409                 doins ${libdir}/libXvMCNVIDIA.a
410         exeinto /usr/${inslibdir}
411         # fix Bug 131315
412         [[ -f ${libdir}/libXvMCNVIDIA.so.${PV} ]] && \
413                 doexe ${libdir}/libXvMCNVIDIA.so.${PV} && \
414                 dosym libXvMCNVIDIA.so.${PV} \
415                         /usr/${inslibdir}/libXvMCNVIDIA.so
417         exeinto ${NV_ROOT}/extensions
418         [[ -f ${libdir}/modules/libnvidia-wfb.so.${sover} ]] && \
419                 newexe ${libdir}/modules/libnvidia-wfb.so.${sover} libwfb.so
420         [[ -f ${extdir}/libglx.so.${sover} ]] && \
421                 newexe ${extdir}/libglx.so.${sover} libglx.so
423         # Includes
424         insinto ${NV_ROOT}/include
425         doins ${incdir}/*.h
427         #cuda
428         if [[ -f usr/include/cuda/cuda.h ]]; then
429                 dodir /usr/include/cuda
430                 insinto /usr/include/cuda
431                 doins usr/include/cuda/*.h
433                 if [[ -f usr/${pkglibdir}/libcuda.so.${PV} ]]; then
434                         dolib.so usr/${pkglibdir}/libcuda.so.${PV}
435                         dosym libcuda.so.${PV} /usr/${inslibdir}/libcuda.so.1
436                         dosym libcuda.so.1 /usr/${inslibdir}/libcuda.so
437                 fi
438         fi
441 pkg_preinst() {
443         # Clean the dynamic libGL stuff's home to ensure
444         # we dont have stale libs floating around
445         if [ -d "${ROOT}"/usr/lib/opengl/nvidia ] ; then
446                 rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
447         fi
448         # Make sure we nuke the old nvidia-glx's env.d file
449         if [ -e "${ROOT}"/etc/env.d/09nvidia ] ; then
450                 rm -f "${ROOT}"/etc/env.d/09nvidia
451         fi
454 pkg_postinst() {
455         if use kernel_linux; then
456                 linux-mod_pkg_postinst
457         fi
459         # Switch to the nvidia implementation
460         eselect opengl set --use-old nvidia
462         echo
463         elog "You must be in the video group to use the NVIDIA device"
464         elog "For more info, read the docs at"
465         elog "http://www.gentoo.org/doc/en/nvidia-guide.xml#doc_chap3_sect6"
466         elog
468         elog "This ebuild installs a kernel module and X driver. Both must"
469         elog "match explicitly in their version. This means, if you restart"
470         elog "X, you most modprobe -r nvidia before starting it back up"
471         elog
473         elog "To use the NVIDIA GLX, run \"eselect opengl set nvidia\""
474         elog
475         elog "nVidia has requested that any bug reports submitted have the"
476         elog "output of /usr/bin/nvidia-bug-report.sh included."
477         elog
478         elog "To work with compiz, you must enable the AddARGBGLXVisuals option."
479         elog
480         elog "If you are having resolution problems, try disabling DynamicTwinView."
481         echo
484 want_tls() {
485         # For uclibc or anything non glibc, return false
486         has_version sys-libs/glibc || return 1
488         # Old versions of glibc were lt/no-tls only
489         has_version '<sys-libs/glibc-2.3.2' && return 1
491         if use x86 ; then
492                 case ${CHOST/-*} in
493                         i486|i586|i686) ;;
494                         *) return 1 ;;
495                 esac
496         fi
498         # If we've got nptl, we've got tls
499         built_with_use --missing true sys-libs/glibc nptl && return 0
501         # 2.3.5 turned off tls for linuxthreads glibc on i486 and i586
502         if use x86 && has_version '>=sys-libs/glibc-2.3.5' ; then
503                 case ${CHOST/-*} in
504                         i486|i586) return 1 ;;
505                 esac
506         fi
508         # These versions built linuxthreads version to support tls, too
509         has_version '>=sys-libs/glibc-2.3.4.20040619-r2' && return 0
511         return 1
514 pkg_postrm() {
515         if use kernel_linux; then
516                 linux-mod_pkg_postrm
517         fi
518         eselect opengl set --use-old xorg-x11