1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
|
# Copyright 2008 Alexander Færøy <eroyf@eroyf.org>
# Copyright 2008-2011 Ingmar Vanhassel <ingmar@exherbo.org>
# Copyright 2013 Saleem Abdulrasool <compnerd@compnerd.org>
# Distributed under the terms of the GNU General Public License v2
# Based in part upon 'mesa-7.0.3.ebuild' which is:
# Copyright 1999-2008 Gentoo Foundation
if ever is_scm ; then
SCM_REPOSITORY="https://anongit.freedesktop.org/git/${PN}/${PN}.git"
require scm-git
else
MY_PV=${PV%%-rc*}
DOWNLOADS="
https://mesa.freedesktop.org/archive/${MY_PV}/${PNV}.tar.xz
https://mesa.freedesktop.org/archive/${PNV}.tar.xz
"
UPSTREAM_RELEASE_NOTES="https://www.mesa3d.org/relnotes/${PV}.html"
fi
require alternatives toolchain-funcs
require flag-o-matic
require autotools [ supported_autoconf=[ 2.5 ] supported_automake=[ 1.16 1.15 ] ]
export_exlib_phases src_configure src_install pkg_postinst
OPENGL_DIR="xorg-x11"
SUMMARY="Mesa's OpenGL library"
HOMEPAGE="https://www.mesa3d.org"
# Licences for parts we don't install:
# GLUT: Mark Kilgard's copyright
LICENCES="MIT"
SLOT="0"
MYOPTIONS="
llvm [[ description = [ Using LLVM as the shader backend for Gallium ] ]]
llvm-static [[ description = [ Link to LLVM statically ] requires = [ llvm ] ]]
opencl [[ description = [ Enable the OpenCL Gallium state tracker ] requires = [ llvm ] ]]
texture-float [[ description = [ Enable floating-point textures and renderbuffers. SGI claims to hold patents on this code. ] ]]
va [[ description = [ Enable the VA-API state tracker ] ]]
wayland
X [[ description = [ Enable GLX ] presumed = true ]]
xa [[ description = [ Enable the X Acceleration API (xatracker) ] ]]
xvmc [[ description = [ Enable support for XvMC hardware accelerated video decoding ] ]]
(
platform:
amd64
x86
video_drivers:
(
i915 [[ description = [ Gallium driver for i915 based Intel GPUs ] ]]
intel [[ description = [ Driver for i915, i965 and newer ] ]]
) [[ number-selected = at-most-one ]]
gallium-swrast [[ description = [ Gallium based software driver ] ]]
(
nouveau [[ description = [ (Gallium) Generally for newer Nvidia cards ] ]]
nouveau-legacy [[ description = [ Generally for older Nvidia cards ] ]]
) [[ number-selected = at-most-one ]]
(
r300 [[ description = [ (Gallium) Driver for Radeon cards from 9500 (r300) to X1950 (r500) ] ]]
radeon [[ description = [ (Gallium) Driver for the Radeon HD-2000 (r600) and newer ] ]]
) [[ requires = [ llvm video_drivers: gallium-swrast ] ]]
radeon-legacy [[ description = [ Classic driver for cards older than the Radeon 9500 (r300) ] ]]
virtio-gpu [[ description = [ Gallium driver for guest systems on hypervisors with VirtIO-GPU ] ]]
vmware [[ description = [ Gallium driver for VMware's SVGA virtual GPU ] ]]
)
(
platform:
armv7
video_drivers:
(
vc4 [[ description = [ Gallium driver for Raspberry Pi Videocore graphics ] ]]
)
)
llvm? (
( video_drivers: gallium-swrast i915 nouveau r300 radeon ) [[ number-selected = at-least-one ]]
)
opencl? (
( video_drivers: nouveau radeon ) [[ number-selected = at-least-one ]]
)
vdpau? ( ( video_drivers: nouveau radeon ) [[ number-selected = at-least-one ]] )
xa? ( ( video_drivers: i915 nouveau vmware radeon ) [[ number-selected = at-least-one ]] )
xvmc? ( ( video_drivers: nouveau radeon ) [[ number-selected = at-least-one ]] )
"
if ever at_least 17.1.3; then
MYOPTIONS+="
vdpau [[ description = [ Enable support for VDPAU hardware accelerated video decoding ] requires = [ X ] ]]
va? (
( X wayland ) [[ number-selected = at-least-one ]]
)
"
else
MYOPTIONS+="
vdpau [[ description = [ Enable support for VDPAU hardware accelerated video decoding ] ]]
"
fi
if ever at_least 13.0.0; then
MYOPTIONS+="
sensors [[ description = [ Gallium extra HUD and sensors support ] ]]
sensors? ( ( video_drivers: nouveau radeon ) [[ number-selected = at-least-one ]] )
"
else
MYOPTIONS+="
( providers: eudev systemd ) [[ number-selected = exactly-one ]]
"
fi
if ever at_least 12.0.0-rc1; then
MYOPTIONS+="
gl-vendor [[
description = [ Install a glvnd (gl vendor) file to allow for parallel install of multiple GL implementations ]
]]
valgrind [[ description = [ Support valgrind intrinsics to suppress false warnings ] ]]
"
fi
if ! ever at_least 17.1.3; then
MYOPTIONS+="
( providers: gcrypt libressl nettle openssl ) [[ number-selected = exactly-one ]]
"
fi
# these high versions are not required for every package but as long as we don't need to deal with different versions use the latest
if ever at_least 17.3.7; then
LIBDRM_REQUIRED='[>=2.4.91]'
elif ever at_least 17.2.0; then
LIBDRM_REQUIRED='[>=2.4.82]'
elif ever at_least 17.1.3; then
LIBDRM_REQUIRED='[>=2.4.80]'
else
LIBDRM_REQUIRED='[>=2.4.69]'
fi
DEPENDENCIES="
build:
dev-lang/python:2.7
sys-devel/bison
sys-devel/flex
virtual/pkg-config[>=0.9.0]
!x11-dri/eclectic-opengl
llvm? (
!llvm-static? ( dev-lang/llvm[>=3.7][-static] )
llvm-static? ( dev-lang/llvm[>=3.7][static] )
)
opencl? (
dev-lang/clang[>=3.4]
)
video_drivers:radeon? ( dev-lang/llvm[>=3.6.0] )
X? ( x11-proto/xorgproto )
build+run:
dev-libs/expat
x11-dri/libdrm${LIBDRM_REQUIRED}
opencl? ( dev-libs/libclc )
va? (
x11-libs/libX11
x11-libs/libva[>=1.6.0]
x11-libs/libxcb${XCBDRI2_REQUIRED}
)
vdpau? (
x11-libs/libX11
x11-libs/libvdpau[>=1.1]
x11-libs/libxcb${XCBDRI2_REQUIRED}
)
video_drivers:i915? ( x11-dri/libdrm[video_drivers:intel(+)] )
video_drivers:intel? ( x11-dri/libdrm[video_drivers:intel(+)] )
video_drivers:nouveau? ( x11-dri/libdrm[video_drivers:nouveau(-)] )
video_drivers:nouveau-legacy? ( x11-dri/libdrm[video_drivers:nouveau(-)] )
video_drivers:r300? ( x11-dri/libdrm[video_drivers:radeon(-)] )
video_drivers:radeon? (
dev-util/elfutils
x11-dri/libdrm[video_drivers:radeon(-)]
)
video_drivers:radeon-legacy? ( x11-dri/libdrm[video_drivers:radeon(-)] )
video_drivers:vc4? ( x11-dri/libdrm[video_drivers:vc4(-)] )
video_drivers:vmware? ( x11-dri/libdrm[video_drivers:vmware(-)] )
wayland? ( sys-libs/wayland[>=1.2.0] )
X? (
x11-libs/libICE
x11-libs/libX11[xcb(+)]
x11-libs/libXau
x11-libs/libxcb[>=1.9.3]
x11-libs/libXdamage[>=1.1.1]
x11-libs/libXdmcp
x11-libs/libXext
x11-libs/libXfixes
x11-libs/libxshmfence[>=1.1]
x11-libs/libXxf86vm
)
xvmc? (
x11-libs/libX11
x11-libs/libXvMC[>=1.0.6]
x11-libs/libxcb${XCBDRI2_REQUIRED}
)
run:
llvm? (
!llvm-static? ( dev-lang/llvm[>=3.7][-static] )
)
opencl? (
dev-libs/ocl-icd
)
suggestion:
x11-dri/mesa-demos
"
if ever at_least 13.0.0; then
DEPENDENCIES+="
build+run:
sensors? (
sys-apps/lm_sensors[>=3.4.0]
[[ note = [ lm_sensors version in configure.ac is bogus ] ]]
)
"
else
DEPENDENCIES+="
build:
providers:eudev? ( sys-apps/eudev )
providers:systemd? ( sys-apps/systemd[>=151] )
"
fi
if ever at_least 12.0.0-rc1; then
DEPENDENCIES+="
build:
gl-vendor? ( dev-libs/libglvnd )
valgrind? ( dev-util/valgrind )
"
fi
if ! ever at_least 17.1.3; then
DEPENDENCIES+="
build+run:
providers:gcrypt? ( dev-libs/libgcrypt )
providers:libressl? ( dev-libs/libressl:= )
providers:nettle? ( dev-libs/nettle )
providers:openssl? ( dev-libs/openssl )
"
fi
if ever at_least 17.1.3; then
DEPENDENCIES+="
build:
dev-libs/libpthread-stubs[>=0.4]
gl-vendor? ( dev-libs/libglvnd[>=0.2.0] )
video_drivers:radeon? ( dev-lang/llvm[>=3.9.0] )
build+run:
sys-libs/zlib[>=1.2.3]
wayland? ( sys-libs/wayland[>=1.11] )
"
fi
if ever at_least 17.2.0; then
DEPENDENCIES+="
build:
dev-libs/libpthread-stubs[>=0.4]
gl-vendor? ( dev-libs/libglvnd[>=0.2.0] )
video_drivers:radeon? ( dev-lang/llvm[>=3.9.0] )
build+run:
sys-libs/zlib[>=1.2.3]
wayland? (
sys-libs/wayland[>=1.11]
sys-libs/wayland-protocols[>=1.8.0]
)
"
fi
if ever at_least 17.3.3; then
DEPENDENCIES+="
build:
opencl? ( dev-lang/llvm[>=3.9.0] )
build+run:
!media-libs/libtxc_dxtn [[
description = [ mesa now bundles libtxc_dxtn ]
resolution = uninstall-blocked-after
]]
"
fi
if ever at_least 13.0.0; then
DEPENDENCIES+="
build:
dev-python/Mako[>=0.8.0][python_abis:2.7]
"
else
DEPENDENCIES+="
build:
dev-python/Mako[>=0.3.4][python_abis:2.7]
"
fi
if ever is_scm; then
DEPENDENCIES+="
build+run:
x11-apps/xrandr
"
fi
DEFAULT_SRC_TEST_PARAMS=( PTHREAD_LIBS="-lpthread" )
AT_M4DIR=( m4 )
mesa_src_configure() {
DRI_DRIVERS=( )
EGL_PLATFORMS=( )
GALLIUM_DRIVERS_NOSW=( )
GALLIUM_DRIVERS=( )
VULKAN_DRIVERS=( )
option !video_drivers:gallium-swrast && DRI_DRIVERS+=( swrast )
option video_drivers:intel && DRI_DRIVERS+=( i915 i965 )
option video_drivers:nouveau-legacy && DRI_DRIVERS+=( nouveau )
option video_drivers:radeon-legacy && DRI_DRIVERS+=( radeon r200 )
# TODO: noop, swr, vc5, etnaviv, imx, pl111
option video_drivers:i915 && GALLIUM_DRIVERS_NOSW+=( i915 )
option video_drivers:nouveau && GALLIUM_DRIVERS_NOSW+=( nouveau )
option video_drivers:r300 && GALLIUM_DRIVERS_NOSW+=( r300 )
option video_drivers:radeon && GALLIUM_DRIVERS_NOSW+=( r600 radeonsi )
option video_drivers:vc4 && GALLIUM_DRIVERS_NOSW+=( vc4 )
option video_drivers:virtio-gpu && GALLIUM_DRIVERS_NOSW+=( virgl )
option video_drivers:vmware && GALLIUM_DRIVERS_NOSW+=( svga )
# TODO: gallium-swr
GALLIUM_DRIVERS=( "${GALLIUM_DRIVERS_NOSW[@]}" )
option video_drivers:gallium-swrast && GALLIUM_DRIVERS+=( swrast )
option X && EGL_PLATFORMS+=( x11 )
option wayland && EGL_PLATFORMS+=( wayland )
EGL_PLATFORMS+=( drm surfaceless )
option video_drivers:intel && VULKAN_DRIVERS+=( intel )
option video_drivers:radeon && VULKAN_DRIVERS+=( radeon )
local MESA_SRC_CONFIGURE_PARAMS
# NOTE(compnerd) disable the assembly dispatching. The code is absolutely horrid, fragile, and
# is disabled by other distributions as well (including Fedora and RHEL). It is also broken
# with LTO, and is not intended to be fixed. https://bugs.freedesktop.org/show_bug.cgi?id=55080
MESA_SRC_CONFIGURE_PARAMS+=(
$(option llvm && echo --with-llvm-prefix=/usr/$(exhost --target))
$($(option platform:x86 || option platform:amd64) && echo --disable-asm)
--enable-osmesa # off-screen mesa
)
if [[ ${#DRI_DRIVERS[@]} -gt 0 ]]; then
MESA_SRC_CONFIGURE_PARAMS+=( --with-dri-drivers=$(IFS=, ; echo "${DRI_DRIVERS[*]}") )
else
MESA_SRC_CONFIGURE_PARAMS+=( --without-dri-drivers )
fi
if [[ ${#GALLIUM_DRIVERS[*]} -gt 0 ]] ; then
MESA_SRC_CONFIGURE_PARAMS+=( --with-gallium-drivers=$(IFS=, ; echo "${GALLIUM_DRIVERS[*]}") )
else
MESA_SRC_CONFIGURE_PARAMS+=( --without-gallium-drivers )
fi
if [[ ${#GALLIUM_DRIVERS_NOSW[*]} -gt 0 ]] ; then
MESA_SRC_CONFIGURE_PARAMS+=( $(option video_drivers:gallium-swrast && echo "--enable-nine") )
fi
if ever at_least 12.0.0-rc1; then
if [[ ${#VULKAN_DRIVERS[@]} -gt 0 ]]; then
MESA_SRC_CONFIGURE_PARAMS+=( --with-vulkan-drivers=$(IFS=, ; echo "${VULKAN_DRIVERS[*]}") )
else
MESA_SRC_CONFIGURE_PARAMS+=( --without-vulkan-drivers )
fi
MESA_SRC_CONFIGURE_PARAMS+=( $(option_enable gl-vendor libglvnd) )
fi
# TODO gallium_tests
# TODO state trackers: OpenMAX(omx), requires additional new dependency libomxil-bellagio
MESA_SRC_CONFIGURE_PARAMS+=(
--with-pic
--enable-dri
--enable-egl
--enable-gbm
--enable-gles1
--enable-gles2
--enable-shared-glapi
--disable-glx-read-only-text
$(option_enable !llvm-static llvm-shared-libs)
$(option_enable opencl)
$(option_enable opencl opencl-icd)
$(option_enable texture-float)
$(option_enable va)
$(option_enable vdpau)
$(option_enable X dri3)
$(option_enable X glx)
$(option_enable X glx-tls)
$(option_enable xa)
$(option_enable xvmc)
)
if ever at_least 17.3.4; then
MESA_SRC_CONFIGURE_PARAMS+=(
--enable-driglx-direct
--disable-omx-bellagio
)
else
MESA_SRC_CONFIGURE_PARAMS+=(
--disable-omx
)
fi
if ever at_least 12.0.0-rc1; then
MESA_SRC_CONFIGURE_PARAMS+=( $(option_enable valgrind) )
fi
if ! ever at_least 12.0.2; then
MESA_SRC_CONFIGURE_PARAMS+=(
$(option_enable video_drivers:radeon r600-llvm-compiler)
)
fi
if ever at_least 13.0.0; then
MESA_SRC_CONFIGURE_PARAMS+=(
$(option_enable sensors lmsensors)
$(option_enable sensors gallium_extra_hud)
)
else
MESA_SRC_CONFIGURE_PARASM+=(
--disable-sysfs
)
fi
if ever at_least 17.1.3; then
MESA_SRC_CONFIGURE_PARAMS+=(
--disable-libunwind
--with-platforms=$(IFS=, ; echo "${EGL_PLATFORMS[*]}")
--with-wayland-scanner-path=/usr/$(exhost --build)/bin/wayland-scanner
$(option_enable llvm)
)
else
MESA_SRC_CONFIGURE_PARAMS+=(
--enable-shader-cache
--with-egl-platforms=$(IFS=, ; echo "${EGL_PLATFORMS[*]}")
$(option_enable llvm gallium-llvm)
)
if option providers:libressl || option providers:openssl; then
MESA_SRC_CONFIGURE_PARAMS+=(
--with-sha1=libcrypto
)
elif option providers:gcrypt; then
MESA_SRC_CONFIGURE_PARAMS+=(
--with-sha1=libgcrypt
)
elif option providers:nettle; then
MESA_SRC_CONFIGURE_PARAMS+=(
--with-sha1=libnettle
)
fi
fi
# Fix using the 32bit python while it isn't needed.
# TODO: Something with python.exlib to require the neccessary modules to be built for the
# selected python.
#PYTHON2=/usr/bin/python2 \
# TODO: check if something similar to the above might be necessary when cross-compiling
# mesa. Obviously the path doesn't work on cross. (heirecka)
econf "${MESA_SRC_CONFIGURE_PARAMS[@]}"
}
mesa_src_install() {
dodir /usr
local host=$(exhost --target)
local X_alternatives=()
default
# alternatives
local libs=(libEGL libGLESv1_CM libGLESv2)
option X && libs+=(libGL)
edo mkdir "${IMAGE}"/usr/${host}/lib/opengl/
local lib path_old path_new soname
for lib in "${libs[@]}"; do
path_new=/usr/${host}/lib/opengl/${lib}-xorg.so
path_old=$(readlink -f "${IMAGE}"/usr/${host}/lib/${lib}.so)
edo mv \
"${path_old}" \
"${IMAGE}"/${path_new}
local objdump=$(exhost --tool-prefix)objdump
soname=$(edo ${objdump} -p "${IMAGE}"/${path_new} | sed -n 's/^ *SONAME *//p')
# clean up the leftover symlinks
edo rm "${IMAGE}"/usr/${host}/lib/{${lib}.so,${soname}}
X_alternatives+=(
/usr/${host}/lib/${lib}.so ${path_new}
/usr/${host}/lib/${soname} ${path_new}
)
done
alternatives_for opengl X.org 10 ${X_alternatives[@]}
edo rm -rf "${IMAGE}"/usr/${host}/include/GL/{glew,glxew,wglew}.h
}
mesa_pkg_postinst() {
# Clean up after old eclectic-opengl module
if [[ -f ${ROOT}/etc/env.d/03opengl ]] ; then
rm "${ROOT}/etc/env.d/03opengl" || ewarn "Remove /etc/env.d/03opengl manually"
fi
alternatives_pkg_postinst
}
|