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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Tue Feb 12 04:40:01 2013 UTC (16 months, 4 weeks ago) by vapier
Branch: MAIN
Changes since 1.2: +4 -1 lines
Fix building with kernels that split obj & src dirs.  Fix building against linux-3.7+ #447566 by Martin Väth.

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

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

  ViewVC Help
Powered by ViewVC 1.1.20