/[gentoo-x86]/x11-drivers/nvidia-drivers/nvidia-drivers-304.60.ebuild
Gentoo

Contents of /x11-drivers/nvidia-drivers/nvidia-drivers-304.60.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Wed Dec 19 16:52:01 2012 UTC (22 months ago) by tetromino
Branch: MAIN
Changes since 1.4: +2 -1 lines
Depend on pangox-compat if using pango-1.32.

(Portage version: 2.2.0_alpha149/cvs/Linux x86_64, signed Manifest commit with key CF0ADD61)

1 # Copyright 1999-2012 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-304.60.ebuild,v 1.4 2012/12/11 15:20:56 ssuominen Exp $
4
5 EAPI=4
6
7 inherit eutils flag-o-matic linux-info linux-mod multilib nvidia-driver \
8 portability toolchain-funcs unpacker user versionator udev
9
10 X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}"
11 AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}"
12 X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}"
13 AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}"
14
15 DESCRIPTION="NVIDIA X11 driver and GLX libraries"
16 HOMEPAGE="http://www.nvidia.com/"
17 SRC_URI="x86? ( ftp://download.nvidia.com/XFree86/Linux-x86/${PV}/${X86_NV_PACKAGE}.run )
18 amd64? ( ftp://download.nvidia.com/XFree86/Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )
19 amd64-fbsd? ( ftp://download.nvidia.com/XFree86/FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz )
20 x86-fbsd? ( ftp://download.nvidia.com/XFree86/FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )"
21
22 LICENSE="NVIDIA"
23 SLOT="0"
24 KEYWORDS="-* amd64 x86 ~amd64-fbsd ~x86-fbsd"
25 IUSE="acpi multilib kernel_FreeBSD kernel_linux pax_kernel +tools +X"
26 RESTRICT="strip"
27 EMULTILIB_PKG="true"
28
29 COMMON="app-admin/eselect-opencl
30 kernel_linux? ( >=sys-libs/glibc-2.6.1 )
31 multilib? ( app-emulation/emul-linux-x86-xlibs )
32 X? (
33 <x11-base/xorg-server-1.13.99
34 >=app-admin/eselect-opengl-1.0.9
35 )"
36 DEPEND="${COMMON}
37 kernel_linux? (
38 virtual/linux-sources
39 virtual/pkgconfig
40 )"
41 RDEPEND="${COMMON}
42 acpi? ( sys-power/acpid )
43 tools? (
44 dev-libs/atk
45 dev-libs/glib
46 x11-libs/gdk-pixbuf
47 x11-libs/gtk+:2
48 x11-libs/libX11
49 x11-libs/libXext
50 x11-libs/pango[X]
51 || ( x11-libs/pangox-compat <x11-libs/pango-1.31[X] )
52 )
53 X? ( x11-libs/libXvMC )"
54 PDEPEND="X? ( >=x11-libs/libvdpau-0.3-r1 )"
55
56 REQUIRED_USE="tools? ( X )"
57
58 QA_PREBUILT="opt/* usr/lib*"
59
60 S=${WORKDIR}/
61
62 pkg_pretend() {
63
64 if use amd64 && has_multilib_profile && \
65 [ "${DEFAULT_ABI}" != "amd64" ]; then
66 eerror "This ebuild doesn't currently support changing your default ABI"
67 die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
68 fi
69
70 # Kernel features/options to check for
71 CONFIG_CHECK="~ZONE_DMA ~MTRR ~SYSVIPC ~!LOCKDEP"
72 use x86 && CONFIG_CHECK+=" ~HIGHMEM"
73
74 # Now do the above checks
75 use kernel_linux && check_extra_config
76 }
77
78 pkg_setup() {
79 # try to turn off distcc and ccache for people that have a problem with it
80 export DISTCC_DISABLE=1
81 export CCACHE_DISABLE=1
82
83 if use kernel_linux; then
84 linux-mod_pkg_setup
85 MODULE_NAMES="nvidia(video:${S}/kernel)"
86 BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
87 SYSOUT=${KV_OUT_DIR} CC=$(tc-getBUILD_CC)"
88 # linux-mod_src_compile calls set_arch_to_kernel, which
89 # sets the ARCH to x86 but NVIDIA's wrapping Makefile
90 # expects x86_64 or i386 and then converts it to x86
91 # later on in the build process
92 BUILD_FIXES="ARCH=$(uname -m | sed -e 's/i.86/i386/')"
93 fi
94
95 # Since Nvidia ships 3 different series of drivers, we need to give the user
96 # some kind of guidance as to what version they should install. This tries
97 # to point the user in the right direction but can't be perfect. check
98 # nvidia-driver.eclass
99 nvidia-driver-check-warning
100
101 # set variables to where files are in the package structure
102 if use kernel_FreeBSD; then
103 use x86-fbsd && S="${WORKDIR}/${X86_FBSD_NV_PACKAGE}"
104 use amd64-fbsd && S="${WORKDIR}/${AMD64_FBSD_NV_PACKAGE}"
105 NV_DOC="${S}/doc"
106 NV_OBJ="${S}/obj"
107 NV_SRC="${S}/src"
108 NV_MAN="${S}/x11/man"
109 NV_X11="${S}/obj"
110 NV_SOVER=1
111 elif use kernel_linux; then
112 NV_DOC="${S}"
113 NV_OBJ="${S}"
114 NV_SRC="${S}/kernel"
115 NV_MAN="${S}"
116 NV_X11="${S}"
117 NV_SOVER=${PV}
118 else
119 die "Could not determine proper NVIDIA package"
120 fi
121 }
122
123 src_unpack() {
124 if ! use kernel_FreeBSD; then
125 cd "${S}"
126 unpack_makeself
127 else
128 unpack ${A}
129 fi
130 }
131
132 src_prepare() {
133 # Please add a brief description for every added patch
134
135 if use kernel_linux; then
136 if kernel_is lt 2 6 9 ; then
137 eerror "You must build this against 2.6.9 or higher kernels."
138 fi
139
140 # If greater than 2.6.5 use M= instead of SUBDIR=
141 convert_to_m "${NV_SRC}"/Makefile.kbuild
142 fi
143
144 if use pax_kernel; then
145 ewarn "Using PAX patches is not supported. You will be asked to"
146 ewarn "use a standard kernel should you have issues. Should you"
147 ewarn "need support with these patches, contact the PaX team."
148 epatch "${FILESDIR}"/nvidia-drivers-pax-const.patch
149 epatch "${FILESDIR}"/nvidia-drivers-pax-usercopy.patch
150 fi
151
152 cat <<- EOF > "${S}"/nvidia.icd
153 /usr/$(get_libdir)/libnvidia-opencl.so
154 EOF
155
156 # Allow user patches so they can support RC kernels and whatever else
157 epatch_user
158 }
159
160 src_compile() {
161 # This is already the default on Linux, as there's no toplevel Makefile, but
162 # on FreeBSD there's one and triggers the kernel module build, as we install
163 # it by itself, pass this.
164
165 cd "${NV_SRC}"
166 if use kernel_FreeBSD; then
167 MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
168 LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
169 elif use kernel_linux; then
170 linux-mod_src_compile
171 fi
172 }
173
174 # Install nvidia library:
175 # the first parameter is the library to install
176 # the second parameter is the provided soversion
177 # the third parameter is the target directory if its not /usr/lib
178 donvidia() {
179 # Full path to library minus SOVER
180 MY_LIB="$1"
181
182 # SOVER to use
183 MY_SOVER="$2"
184
185 # Where to install
186 MY_DEST="$3"
187
188 if [[ -z "${MY_DEST}" ]]; then
189 MY_DEST="/usr/$(get_libdir)"
190 action="dolib.so"
191 else
192 exeinto ${MY_DEST}
193 action="doexe"
194 fi
195
196 # Get just the library name
197 libname=$(basename $1)
198
199 # Install the library with the correct SOVER
200 ${action} ${MY_LIB}.${MY_SOVER} || \
201 die "failed to install ${libname}"
202
203 # If SOVER wasn't 1, then we need to create a .1 symlink
204 if [[ "${MY_SOVER}" != "1" ]]; then
205 dosym ${libname}.${MY_SOVER} \
206 ${MY_DEST}/${libname}.1 || \
207 die "failed to create ${libname} symlink"
208 fi
209
210 # Always create the symlink from the raw lib to the .1
211 dosym ${libname}.1 \
212 ${MY_DEST}/${libname} || \
213 die "failed to create ${libname} symlink"
214 }
215
216 src_install() {
217 if use kernel_linux; then
218 linux-mod_src_install
219
220 VIDEOGROUP="$(egetent group video | cut -d ':' -f 3)"
221 if [ -z "$VIDEOGROUP" ]; then
222 eerror "Failed to determine the video group gid."
223 die "Failed to determine the video group gid."
224 fi
225
226 # Add the aliases
227 [ -f "${FILESDIR}/nvidia-169.07" ] || die "nvidia missing in FILESDIR"
228 sed -e 's:PACKAGE:'${PF}':g' \
229 -e 's:VIDEOGID:'${VIDEOGROUP}':' "${FILESDIR}"/nvidia-169.07 > \
230 "${WORKDIR}"/nvidia
231 insinto /etc/modprobe.d
232 newins "${WORKDIR}"/nvidia nvidia.conf || die
233
234 # Ensures that our device nodes are created when not using X
235 exeinto "$(udev_get_udevdir)"
236 doexe "${FILESDIR}"/nvidia-udev.sh
237 udev_newrules "${FILESDIR}"/nvidia.udev-rule 99-nvidia.rules
238
239 elif use kernel_FreeBSD; then
240 if use x86-fbsd; then
241 insinto /boot/modules
242 doins "${S}/src/nvidia.kld" || die
243 fi
244
245 exeinto /boot/modules
246 doexe "${S}/src/nvidia.ko" || die
247 fi
248
249 # NVIDIA kernel <-> userspace driver config lib
250 donvidia ${NV_OBJ}/libnvidia-cfg.so ${NV_SOVER}
251
252 if use kernel_linux; then
253 # NVIDIA video decode <-> CUDA
254 donvidia ${NV_OBJ}/libnvcuvid.so ${NV_SOVER}
255 fi
256
257 if use X; then
258 # Xorg DDX driver
259 insinto /usr/$(get_libdir)/xorg/modules/drivers
260 doins ${NV_X11}/nvidia_drv.so || die "failed to install nvidia_drv.so"
261
262 # Xorg GLX driver
263 donvidia ${NV_X11}/libglx.so ${NV_SOVER} \
264 /usr/$(get_libdir)/opengl/nvidia/extensions
265
266 # XvMC driver
267 dolib.a ${NV_X11}/libXvMCNVIDIA.a || \
268 die "failed to install libXvMCNVIDIA.so"
269 donvidia ${NV_X11}/libXvMCNVIDIA.so ${NV_SOVER}
270 dosym libXvMCNVIDIA.so.${NV_SOVER} \
271 /usr/$(get_libdir)/libXvMCNVIDIA_dynamic.so.1 || \
272 die "failed to create libXvMCNVIDIA_dynamic.so symlink"
273 fi
274
275 # OpenCL ICD for NVIDIA
276 if use kernel_linux; then
277 insinto /etc/OpenCL/vendors
278 doins nvidia.icd
279 donvidia ${NV_OBJ}/libnvidia-opencl.so ${NV_SOVER}
280 fi
281
282 # Documentation
283 dohtml ${NV_DOC}/html/*
284 if use kernel_FreeBSD; then
285 dodoc "${NV_DOC}/README"
286 use X && doman "${NV_MAN}/nvidia-xconfig.1"
287 use tools && doman "${NV_MAN}/nvidia-settings.1"
288 else
289 # Docs
290 newdoc "${NV_DOC}/README.txt" README
291 dodoc "${NV_DOC}/NVIDIA_Changelog"
292 doman "${NV_MAN}/nvidia-smi.1.gz"
293 use X && doman "${NV_MAN}/nvidia-xconfig.1.gz"
294 use tools && doman "${NV_MAN}/nvidia-settings.1.gz"
295 doman "${NV_MAN}/nvidia-cuda-proxy-control.1.gz"
296 fi
297
298 # Helper Apps
299 exeinto /opt/bin/
300
301 if use X; then
302 doexe ${NV_OBJ}/nvidia-xconfig || die
303 fi
304
305 if use kernel_linux ; then
306 doexe ${NV_OBJ}/nvidia-debugdump || die
307 doexe ${NV_OBJ}/nvidia-cuda-proxy-control || die
308 doexe ${NV_OBJ}/nvidia-cuda-proxy-server || die
309 doexe ${NV_OBJ}/nvidia-smi || die
310 newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi
311 fi
312
313 if use tools; then
314 doexe ${NV_OBJ}/nvidia-settings || die
315 fi
316
317 exeinto /usr/bin/
318 doexe ${NV_OBJ}/nvidia-bug-report.sh || die
319
320 # Desktop entries for nvidia-settings
321 if use tools ; then
322 # There is no icon in the FreeBSD tarball.
323 use kernel_FreeBSD || newicon ${NV_OBJ}/nvidia-settings.png nvidia-drivers-settings.png
324 domenu "${FILESDIR}"/nvidia-drivers-settings.desktop
325 exeinto /etc/X11/xinit/xinitrc.d
326 doexe "${FILESDIR}"/95-nvidia-settings
327 fi
328
329 #doenvd "${FILESDIR}"/50nvidia-prelink-blacklist
330
331 if has_multilib_profile && use multilib ; then
332 local OABI=${ABI}
333 for ABI in $(get_install_abis) ; do
334 src_install-libs
335 done
336 ABI=${OABI}
337 unset OABI
338 else
339 src_install-libs
340 fi
341
342 is_final_abi || die "failed to iterate through all ABIs"
343 }
344
345 src_install-libs() {
346 local inslibdir=$(get_libdir)
347 local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib"
348 local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia"
349 local libdir=${NV_OBJ}
350
351 if use kernel_linux && has_multilib_profile && \
352 [[ ${ABI} == "x86" ]] ; then
353 libdir=${NV_OBJ}/32
354 fi
355
356 if use X; then
357 # The GLX libraries
358 donvidia ${libdir}/libGL.so ${NV_SOVER} ${GL_ROOT}
359 donvidia ${libdir}/libnvidia-glcore.so ${NV_SOVER}
360 if use kernel_FreeBSD; then
361 donvidia ${libdir}/libnvidia-tls.so ${NV_SOVER} ${GL_ROOT}
362 else
363 donvidia ${libdir}/tls/libnvidia-tls.so ${NV_SOVER} ${GL_ROOT}
364 fi
365
366 # VDPAU
367 donvidia ${libdir}/libvdpau_nvidia.so ${NV_SOVER}
368 fi
369
370 # NVIDIA monitoring library
371 if use kernel_linux ; then
372 donvidia ${libdir}/libnvidia-ml.so ${NV_SOVER}
373 fi
374
375 # CUDA & OpenCL
376 if use kernel_linux; then
377 donvidia ${libdir}/libcuda.so ${NV_SOVER}
378 donvidia ${libdir}/libnvidia-compiler.so ${NV_SOVER}
379 donvidia ${libdir}/libOpenCL.so 1.0.0 ${CL_ROOT}
380 fi
381 }
382
383 pkg_preinst() {
384 use kernel_linux && linux-mod_pkg_preinst
385
386 # Clean the dynamic libGL stuff's home to ensure
387 # we dont have stale libs floating around
388 if [ -d "${ROOT}"/usr/lib/opengl/nvidia ] ; then
389 rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
390 fi
391 # Make sure we nuke the old nvidia-glx's env.d file
392 if [ -e "${ROOT}"/etc/env.d/09nvidia ] ; then
393 rm -f "${ROOT}"/etc/env.d/09nvidia
394 fi
395 }
396
397 pkg_postinst() {
398 use kernel_linux && linux-mod_pkg_postinst
399
400 # Switch to the nvidia implementation
401 use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia
402 "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia
403
404 elog "You must be in the video group to use the NVIDIA device"
405 elog "For more info, read the docs at"
406 elog "http://www.gentoo.org/doc/en/nvidia-guide.xml#doc_chap3_sect6"
407 elog
408 elog "This ebuild installs a kernel module and X driver. Both must"
409 elog "match explicitly in their version. This means, if you restart"
410 elog "X, you must modprobe -r nvidia before starting it back up"
411 elog
412 elog "To use the NVIDIA GLX, run \"eselect opengl set nvidia\""
413 elog
414 elog "To use the NVIDIA CUDA/OpenCL, run \"eselect opencl set nvidia\""
415 elog
416 elog "NVIDIA has requested that any bug reports submitted have the"
417 elog "output of /opt/bin/nvidia-bug-report.sh included."
418 elog
419 if ! use X; then
420 elog "You have elected to not install the X.org driver. Along with"
421 elog "this the OpenGL libraries, XvMC, and VDPAU libraries were not"
422 elog "installed. Additionally, once the driver is loaded your card"
423 elog "and fan will run at max speed which may not be desirable."
424 elog "Use the 'nvidia-smi' init script to have your card and fan"
425 elog "speed scale appropriately."
426 elog
427 fi
428 if ! use tools; then
429 elog "USE=tools controls whether the nvidia-settings application"
430 elog "is installed. If you would like to use it, enable that"
431 elog "flag and re-emerge this ebuild. Optionally you can install"
432 elog "media-video/nvidia-settings"
433 elog
434 fi
435 }
436
437 pkg_prerm() {
438 use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
439 }
440
441 pkg_postrm() {
442 use kernel_linux && linux-mod_pkg_postrm
443 use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
444 }

  ViewVC Help
Powered by ViewVC 1.1.20