Line 0
Link Here
|
|
|
1 |
# Copyright 1999-2016 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Id$ |
4 |
|
5 |
EAPI=5 |
6 |
|
7 |
EGIT_REPO_URI="git://anongit.freedesktop.org/mesa/mesa" |
8 |
|
9 |
if [[ ${PV} = 9999 ]]; then |
10 |
GIT_ECLASS="git-r3" |
11 |
EXPERIMENTAL="true" |
12 |
fi |
13 |
|
14 |
PYTHON_COMPAT=( python2_7 ) |
15 |
|
16 |
inherit autotools multilib-minimal python-any-r1 pax-utils ${GIT_ECLASS} |
17 |
|
18 |
OPENGL_DIR="xorg-x11" |
19 |
|
20 |
MY_P="${P/_/-}" |
21 |
FOLDER="${PV/_rc*/}" |
22 |
|
23 |
DESCRIPTION="OpenGL-like graphic library for Linux" |
24 |
HOMEPAGE="http://mesa3d.sourceforge.net/" |
25 |
|
26 |
if [[ $PV == 9999 ]]; then |
27 |
SRC_URI="" |
28 |
KEYWORDS="" |
29 |
else |
30 |
SRC_URI="ftp://ftp.freedesktop.org/pub/mesa/${FOLDER}/${MY_P}.tar.xz" |
31 |
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~x86-freebsd ~amd64-linux ~arm-linux ~ia64-linux ~x86-linux ~sparc-solaris ~x64-solaris ~x86-solaris" |
32 |
fi |
33 |
|
34 |
LICENSE="MIT" |
35 |
SLOT="0" |
36 |
RESTRICT="!bindist? ( bindist )" |
37 |
|
38 |
INTEL_CARDS="i915 i965 ilo intel" |
39 |
RADEON_CARDS="r100 r200 r300 r600 radeon radeonsi" |
40 |
VIDEO_CARDS="${INTEL_CARDS} ${RADEON_CARDS} freedreno nouveau vmware" |
41 |
for card in ${VIDEO_CARDS}; do |
42 |
IUSE_VIDEO_CARDS+=" video_cards_${card}" |
43 |
done |
44 |
|
45 |
IUSE="${IUSE_VIDEO_CARDS} |
46 |
bindist +classic d3d9 debug +dri3 +egl +gallium +gbm gles1 gles2 +llvm |
47 |
+nptl opencl osmesa pax_kernel openmax pic selinux +udev vaapi vdpau |
48 |
wayland xvmc xa kernel_FreeBSD" |
49 |
|
50 |
REQUIRED_USE=" |
51 |
d3d9? ( dri3 gallium ) |
52 |
llvm? ( gallium ) |
53 |
opencl? ( gallium llvm ) |
54 |
openmax? ( gallium ) |
55 |
gles1? ( egl ) |
56 |
gles2? ( egl ) |
57 |
vaapi? ( gallium ) |
58 |
vdpau? ( gallium ) |
59 |
wayland? ( egl gbm ) |
60 |
xa? ( gallium ) |
61 |
video_cards_freedreno? ( gallium ) |
62 |
video_cards_intel? ( classic ) |
63 |
video_cards_i915? ( || ( classic gallium ) ) |
64 |
video_cards_i965? ( classic ) |
65 |
video_cards_ilo? ( gallium ) |
66 |
video_cards_nouveau? ( || ( classic gallium ) ) |
67 |
video_cards_radeon? ( || ( classic gallium ) |
68 |
gallium? ( x86? ( llvm ) amd64? ( llvm ) ) ) |
69 |
video_cards_r100? ( classic ) |
70 |
video_cards_r200? ( classic ) |
71 |
video_cards_r300? ( gallium x86? ( llvm ) amd64? ( llvm ) ) |
72 |
video_cards_r600? ( gallium ) |
73 |
video_cards_radeonsi? ( gallium llvm ) |
74 |
video_cards_vmware? ( gallium ) |
75 |
${PYTHON_REQUIRED_USE} |
76 |
" |
77 |
|
78 |
LIBDRM_DEPSTRING=">=x11-libs/libdrm-2.4.67" |
79 |
# keep correct libdrm and dri2proto dep |
80 |
# keep blocks in rdepend for binpkg |
81 |
RDEPEND=" |
82 |
!<x11-base/xorg-server-1.7 |
83 |
!<=x11-proto/xf86driproto-2.0.3 |
84 |
abi_x86_32? ( !app-emulation/emul-linux-x86-opengl[-abi_x86_32(-)] ) |
85 |
classic? ( app-eselect/eselect-mesa ) |
86 |
gallium? ( app-eselect/eselect-mesa ) |
87 |
>=app-eselect/eselect-opengl-1.3.0 |
88 |
udev? ( kernel_linux? ( >=virtual/libudev-215:=[${MULTILIB_USEDEP}] ) ) |
89 |
>=dev-libs/expat-2.1.0-r3:=[${MULTILIB_USEDEP}] |
90 |
>=x11-libs/libX11-1.6.2:=[${MULTILIB_USEDEP}] |
91 |
>=x11-libs/libxshmfence-1.1:=[${MULTILIB_USEDEP}] |
92 |
>=x11-libs/libXdamage-1.1.4-r1:=[${MULTILIB_USEDEP}] |
93 |
>=x11-libs/libXext-1.3.2:=[${MULTILIB_USEDEP}] |
94 |
>=x11-libs/libXxf86vm-1.1.3:=[${MULTILIB_USEDEP}] |
95 |
>=x11-libs/libxcb-1.9.3:=[${MULTILIB_USEDEP}] |
96 |
x11-libs/libXfixes:=[${MULTILIB_USEDEP}] |
97 |
llvm? ( !kernel_FreeBSD? ( |
98 |
video_cards_radeonsi? ( || ( |
99 |
>=dev-libs/elfutils-0.155-r1:=[${MULTILIB_USEDEP}] |
100 |
>=dev-libs/libelf-0.8.13-r2:=[${MULTILIB_USEDEP}] |
101 |
) ) |
102 |
!video_cards_r600? ( |
103 |
video_cards_radeon? ( || ( |
104 |
>=dev-libs/elfutils-0.155-r1:=[${MULTILIB_USEDEP}] |
105 |
>=dev-libs/libelf-0.8.13-r2:=[${MULTILIB_USEDEP}] |
106 |
) ) |
107 |
) ) |
108 |
>=sys-devel/llvm-3.6.0:=[${MULTILIB_USEDEP}] |
109 |
) |
110 |
opencl? ( |
111 |
app-eselect/eselect-opencl |
112 |
dev-libs/libclc |
113 |
!kernel_FreeBSD? ( || ( |
114 |
>=dev-libs/elfutils-0.155-r1:=[${MULTILIB_USEDEP}] |
115 |
>=dev-libs/libelf-0.8.13-r2:=[${MULTILIB_USEDEP}] |
116 |
) ) |
117 |
) |
118 |
openmax? ( >=media-libs/libomxil-bellagio-0.9.3:=[${MULTILIB_USEDEP}] ) |
119 |
vaapi? ( >=x11-libs/libva-1.6.0:=[${MULTILIB_USEDEP}] ) |
120 |
vdpau? ( >=x11-libs/libvdpau-1.1:=[${MULTILIB_USEDEP}] ) |
121 |
wayland? ( >=dev-libs/wayland-1.2.0:=[${MULTILIB_USEDEP}] ) |
122 |
xvmc? ( >=x11-libs/libXvMC-1.0.8:=[${MULTILIB_USEDEP}] ) |
123 |
${LIBDRM_DEPSTRING}[video_cards_freedreno?,video_cards_nouveau?,video_cards_vmware?,${MULTILIB_USEDEP}] |
124 |
" |
125 |
for card in ${INTEL_CARDS}; do |
126 |
RDEPEND="${RDEPEND} |
127 |
video_cards_${card}? ( ${LIBDRM_DEPSTRING}[video_cards_intel] ) |
128 |
" |
129 |
done |
130 |
|
131 |
for card in ${RADEON_CARDS}; do |
132 |
RDEPEND="${RDEPEND} |
133 |
video_cards_${card}? ( ${LIBDRM_DEPSTRING}[video_cards_radeon] ) |
134 |
" |
135 |
done |
136 |
RDEPEND="${RDEPEND} |
137 |
video_cards_radeonsi? ( ${LIBDRM_DEPSTRING}[video_cards_amdgpu] ) |
138 |
" |
139 |
|
140 |
DEPEND="${RDEPEND} |
141 |
llvm? ( |
142 |
video_cards_radeonsi? ( sys-devel/llvm[video_cards_radeon] ) |
143 |
) |
144 |
opencl? ( |
145 |
>=sys-devel/llvm-3.4.2:=[${MULTILIB_USEDEP}] |
146 |
>=sys-devel/clang-3.4.2:=[${MULTILIB_USEDEP}] |
147 |
>=sys-devel/gcc-4.6 |
148 |
) |
149 |
sys-devel/gettext |
150 |
virtual/pkgconfig |
151 |
>=x11-proto/dri2proto-2.8-r1:=[${MULTILIB_USEDEP}] |
152 |
dri3? ( |
153 |
>=x11-proto/dri3proto-1.0:=[${MULTILIB_USEDEP}] |
154 |
>=x11-proto/presentproto-1.0:=[${MULTILIB_USEDEP}] |
155 |
) |
156 |
>=x11-proto/glproto-1.4.17-r1:=[${MULTILIB_USEDEP}] |
157 |
>=x11-proto/xextproto-7.2.1-r1:=[${MULTILIB_USEDEP}] |
158 |
>=x11-proto/xf86driproto-2.1.1-r1:=[${MULTILIB_USEDEP}] |
159 |
>=x11-proto/xf86vidmodeproto-2.3.1-r1:=[${MULTILIB_USEDEP}] |
160 |
" |
161 |
[[ ${PV} == 9999 ]] && DEPEND+=" |
162 |
sys-devel/bison |
163 |
sys-devel/flex |
164 |
${PYTHON_DEPS} |
165 |
$(python_gen_any_dep ">=dev-python/mako-0.7.3[\${PYTHON_USEDEP}]") |
166 |
" |
167 |
|
168 |
S="${WORKDIR}/${MY_P}" |
169 |
EGIT_CHECKOUT_DIR=${S} |
170 |
|
171 |
QA_WX_LOAD=" |
172 |
x86? ( |
173 |
!pic? ( |
174 |
usr/lib*/libglapi.so.0.0.0 |
175 |
usr/lib*/libGLESv1_CM.so.1.1.0 |
176 |
usr/lib*/libGLESv2.so.2.0.0 |
177 |
usr/lib*/libGL.so.1.2.0 |
178 |
usr/lib*/libOSMesa.so.8.0.0 |
179 |
) |
180 |
)" |
181 |
|
182 |
pkg_setup() { |
183 |
# warning message for bug 459306 |
184 |
if use llvm && has_version sys-devel/llvm[!debug=]; then |
185 |
ewarn "Mismatch between debug USE flags in media-libs/mesa and sys-devel/llvm" |
186 |
ewarn "detected! This can cause problems. For details, see bug 459306." |
187 |
fi |
188 |
|
189 |
python-any-r1_pkg_setup |
190 |
} |
191 |
|
192 |
src_prepare() { |
193 |
[[ ${PV} == 9999 ]] && eautoreconf |
194 |
} |
195 |
|
196 |
multilib_src_configure() { |
197 |
local myconf |
198 |
|
199 |
if use classic; then |
200 |
# Configurable DRI drivers |
201 |
driver_enable swrast |
202 |
|
203 |
# Intel code |
204 |
driver_enable video_cards_i915 i915 |
205 |
driver_enable video_cards_i965 i965 |
206 |
if ! use video_cards_i915 && \ |
207 |
! use video_cards_i965; then |
208 |
driver_enable video_cards_intel i915 i965 |
209 |
fi |
210 |
|
211 |
# Nouveau code |
212 |
driver_enable video_cards_nouveau nouveau |
213 |
|
214 |
# ATI code |
215 |
driver_enable video_cards_r100 radeon |
216 |
driver_enable video_cards_r200 r200 |
217 |
if ! use video_cards_r100 && \ |
218 |
! use video_cards_r200; then |
219 |
driver_enable video_cards_radeon radeon r200 |
220 |
fi |
221 |
fi |
222 |
|
223 |
if use egl; then |
224 |
myconf+=" --with-egl-platforms=x11$(use wayland && echo ",wayland")$(use gbm && echo ",drm")" |
225 |
fi |
226 |
|
227 |
if use gallium; then |
228 |
myconf+=" |
229 |
$(use_enable d3d9 nine) |
230 |
$(use_enable llvm gallium-llvm) |
231 |
$(use_enable openmax omx) |
232 |
$(use_enable vaapi va) |
233 |
$(use_enable vdpau) |
234 |
$(use_enable xa) |
235 |
$(use_enable xvmc) |
236 |
" |
237 |
use vaapi && myconf+=" --with-va-libdir=/usr/$(get_libdir)/va/drivers" |
238 |
|
239 |
gallium_enable swrast |
240 |
gallium_enable video_cards_vmware svga |
241 |
gallium_enable video_cards_nouveau nouveau |
242 |
gallium_enable video_cards_i915 i915 |
243 |
gallium_enable video_cards_ilo ilo |
244 |
if ! use video_cards_i915 && \ |
245 |
! use video_cards_i965; then |
246 |
gallium_enable video_cards_intel i915 |
247 |
fi |
248 |
|
249 |
gallium_enable video_cards_r300 r300 |
250 |
gallium_enable video_cards_r600 r600 |
251 |
gallium_enable video_cards_radeonsi radeonsi |
252 |
if ! use video_cards_r300 && \ |
253 |
! use video_cards_r600; then |
254 |
gallium_enable video_cards_radeon r300 r600 |
255 |
fi |
256 |
|
257 |
gallium_enable video_cards_freedreno freedreno |
258 |
# opencl stuff |
259 |
if use opencl; then |
260 |
myconf+=" |
261 |
$(use_enable opencl) |
262 |
--with-clang-libdir="${EPREFIX}/usr/lib" |
263 |
" |
264 |
fi |
265 |
fi |
266 |
|
267 |
# x86 hardened pax_kernel needs glx-rts, bug 240956 |
268 |
if [[ ${ABI} == x86 ]]; then |
269 |
myconf+=" $(use_enable pax_kernel glx-read-only-text)" |
270 |
fi |
271 |
|
272 |
# on abi_x86_32 hardened we need to have asm disable |
273 |
if [[ ${ABI} == x86* ]] && use pic; then |
274 |
myconf+=" --disable-asm" |
275 |
fi |
276 |
|
277 |
if use gallium; then |
278 |
myconf+=" $(use_enable osmesa gallium-osmesa)" |
279 |
else |
280 |
myconf+=" $(use_enable osmesa)" |
281 |
fi |
282 |
|
283 |
# build fails with BSD indent, bug #428112 |
284 |
use userland_GNU || export INDENT=cat |
285 |
|
286 |
ECONF_SOURCE="${S}" \ |
287 |
econf \ |
288 |
--enable-dri \ |
289 |
--enable-glx \ |
290 |
--enable-shared-glapi \ |
291 |
--disable-shader-cache \ |
292 |
$(use_enable !bindist texture-float) \ |
293 |
$(use_enable d3d9 nine) \ |
294 |
$(use_enable debug) \ |
295 |
$(use_enable dri3) \ |
296 |
$(use_enable egl) \ |
297 |
$(use_enable gbm) \ |
298 |
$(use_enable gles1) \ |
299 |
$(use_enable gles2) \ |
300 |
$(use_enable nptl glx-tls) \ |
301 |
$(use_enable !udev sysfs) \ |
302 |
--enable-llvm-shared-libs \ |
303 |
--with-dri-drivers=${DRI_DRIVERS} \ |
304 |
--with-gallium-drivers=${GALLIUM_DRIVERS} \ |
305 |
PYTHON2="${PYTHON}" \ |
306 |
${myconf} |
307 |
} |
308 |
|
309 |
multilib_src_install() { |
310 |
emake install DESTDIR="${D}" |
311 |
|
312 |
if use classic || use gallium; then |
313 |
ebegin "Moving DRI/Gallium drivers for dynamic switching" |
314 |
local gallium_drivers=( i915_dri.so i965_dri.so r300_dri.so r600_dri.so swrast_dri.so ) |
315 |
keepdir /usr/$(get_libdir)/dri |
316 |
dodir /usr/$(get_libdir)/mesa |
317 |
for x in ${gallium_drivers[@]}; do |
318 |
if [ -f "$(get_libdir)/gallium/${x}" ]; then |
319 |
mv -f "${ED}/usr/$(get_libdir)/dri/${x}" "${ED}/usr/$(get_libdir)/dri/${x/_dri.so/g_dri.so}" \ |
320 |
|| die "Failed to move ${x}" |
321 |
fi |
322 |
done |
323 |
if use classic; then |
324 |
emake -C "${BUILD_DIR}/src/mesa/drivers/dri" DESTDIR="${D}" install |
325 |
fi |
326 |
for x in "${ED}"/usr/$(get_libdir)/dri/*.so; do |
327 |
if [ -f ${x} -o -L ${x} ]; then |
328 |
mv -f "${x}" "${x/dri/mesa}" \ |
329 |
|| die "Failed to move ${x}" |
330 |
fi |
331 |
done |
332 |
pushd "${ED}"/usr/$(get_libdir)/dri || die "pushd failed" |
333 |
ln -s ../mesa/*.so . || die "Creating symlink failed" |
334 |
# remove symlinks to drivers known to eselect |
335 |
for x in ${gallium_drivers[@]}; do |
336 |
if [ -f ${x} -o -L ${x} ]; then |
337 |
rm "${x}" || die "Failed to remove ${x}" |
338 |
fi |
339 |
done |
340 |
popd |
341 |
eend $? |
342 |
fi |
343 |
if use opencl; then |
344 |
ebegin "Moving Gallium/Clover OpenCL implementation for dynamic switching" |
345 |
local cl_dir="/usr/$(get_libdir)/OpenCL/vendors/mesa" |
346 |
dodir ${cl_dir}/{lib,include} |
347 |
if [ -f "${ED}/usr/$(get_libdir)/libOpenCL.so" ]; then |
348 |
mv -f "${ED}"/usr/$(get_libdir)/libOpenCL.so* \ |
349 |
"${ED}"${cl_dir} |
350 |
fi |
351 |
if [ -f "${ED}/usr/include/CL/opencl.h" ]; then |
352 |
mv -f "${ED}"/usr/include/CL \ |
353 |
"${ED}"${cl_dir}/include |
354 |
fi |
355 |
eend $? |
356 |
fi |
357 |
|
358 |
if use openmax; then |
359 |
echo "XDG_DATA_DIRS=\"${EPREFIX}/usr/share/mesa/xdg\"" > "${T}/99mesaxdgomx" |
360 |
doenvd "${T}"/99mesaxdgomx |
361 |
keepdir /usr/share/mesa/xdg |
362 |
fi |
363 |
} |
364 |
|
365 |
multilib_src_install_all() { |
366 |
prune_libtool_files --all |
367 |
einstalldocs |
368 |
|
369 |
if use !bindist; then |
370 |
dodoc docs/patents.txt |
371 |
fi |
372 |
|
373 |
# Install config file for eselect mesa |
374 |
insinto /usr/share/mesa |
375 |
newins "${FILESDIR}/eselect-mesa.conf.9.2" eselect-mesa.conf |
376 |
} |
377 |
|
378 |
multilib_src_test() { |
379 |
if use llvm; then |
380 |
local llvm_tests='lp_test_arit lp_test_arit lp_test_blend lp_test_blend lp_test_conv lp_test_conv lp_test_format lp_test_format lp_test_printf lp_test_printf' |
381 |
pushd src/gallium/drivers/llvmpipe >/dev/null || die |
382 |
emake ${llvm_tests} |
383 |
pax-mark m ${llvm_tests} |
384 |
popd >/dev/null || die |
385 |
fi |
386 |
emake check |
387 |
} |
388 |
|
389 |
pkg_postinst() { |
390 |
# Switch to the xorg implementation. |
391 |
echo |
392 |
eselect opengl set --use-old ${OPENGL_DIR} |
393 |
|
394 |
# Select classic/gallium drivers |
395 |
if use classic || use gallium; then |
396 |
eselect mesa set --auto |
397 |
fi |
398 |
|
399 |
# Switch to mesa opencl |
400 |
if use opencl; then |
401 |
eselect opencl set --use-old ${PN} |
402 |
fi |
403 |
|
404 |
# run omxregister-bellagio to make the OpenMAX drivers known system-wide |
405 |
if use openmax; then |
406 |
ebegin "Registering OpenMAX drivers" |
407 |
BELLAGIO_SEARCH_PATH="${EPREFIX}/usr/$(get_libdir)/libomxil-bellagio0" \ |
408 |
OMX_BELLAGIO_REGISTRY=${EPREFIX}/usr/share/mesa/xdg/.omxregister \ |
409 |
omxregister-bellagio |
410 |
eend $? |
411 |
fi |
412 |
|
413 |
# warn about patent encumbered texture-float |
414 |
if use !bindist; then |
415 |
elog "USE=\"bindist\" was not set. Potentially patent encumbered code was" |
416 |
elog "enabled. Please see patents.txt for an explanation." |
417 |
fi |
418 |
|
419 |
if ! has_version media-libs/libtxc_dxtn; then |
420 |
elog "Note that in order to have full S3TC support, it is necessary to install" |
421 |
elog "media-libs/libtxc_dxtn as well. This may be necessary to get nice" |
422 |
elog "textures in some apps, and some others even require this to run." |
423 |
fi |
424 |
} |
425 |
|
426 |
pkg_prerm() { |
427 |
if use openmax; then |
428 |
rm "${EPREFIX}"/usr/share/mesa/xdg/.omxregister |
429 |
fi |
430 |
} |
431 |
|
432 |
# $1 - VIDEO_CARDS flag |
433 |
# other args - names of DRI drivers to enable |
434 |
# TODO: avoid code duplication for a more elegant implementation |
435 |
driver_enable() { |
436 |
case $# in |
437 |
# for enabling unconditionally |
438 |
1) |
439 |
DRI_DRIVERS+=",$1" |
440 |
;; |
441 |
*) |
442 |
if use $1; then |
443 |
shift |
444 |
for i in $@; do |
445 |
DRI_DRIVERS+=",${i}" |
446 |
done |
447 |
fi |
448 |
;; |
449 |
esac |
450 |
} |
451 |
|
452 |
gallium_enable() { |
453 |
case $# in |
454 |
# for enabling unconditionally |
455 |
1) |
456 |
GALLIUM_DRIVERS+=",$1" |
457 |
;; |
458 |
*) |
459 |
if use $1; then |
460 |
shift |
461 |
for i in $@; do |
462 |
GALLIUM_DRIVERS+=",${i}" |
463 |
done |
464 |
fi |
465 |
;; |
466 |
esac |
467 |
} |