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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Mon Nov 19 21:21:51 2012 UTC (21 months, 1 week ago) by cardoe
Branch: MAIN
Changes since 1.1: +2 -2 lines
Fix bad directory reference

(Portage version: 2.2.0_alpha142/cvs/Linux x86_64, unsigned Manifest commit)

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

  ViewVC Help
Powered by ViewVC 1.1.20