summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0f348ca02bddf66c1cf9945b4490c71b843d20d2 (plain)
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
# Maintainer: Denis Benato <benato.denis96 [at] gmail dot com>
# Maintainer: Chris Lane <aur at chrislane dot com>
# Contributor: Reza Jahanbakhshi <reza.jahanbakhshi at gmail dot com
# Contributor: Lone_Wolf <lone_wolf@klaas-de-kat.nl>
# Contributor: Armin K. <krejzi at email dot com>
# Contributor: Kristian Klausen <klausenbusk@hotmail.com>
# Contributor: Egon Ashrafinia <e.ashrafinia@gmail.com>
# Contributor: Tavian Barnes <tavianator@gmail.com>
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: Andreas Radke <andyrtr@archlinux.org>
# Contributor: Thomas Dziedzic < gostrc at gmail >
# Contributor: Antti "Tera" Oja <antti.bofh@gmail.com>
# Contributor: Diego Jose <diegoxter1006@gmail.com>

pkgbase=lib32-mesa-amdonly-gaming-git
pkgver=24.2.0_devel.191030.0e220cd45a4.d41d8cd98f00b204e9800998ecf8427e
options=(!lto) # LTO is bad for mesa, makes random applications crash on my system

pkgname=(
  'lib32-amdonly-gaming-vulkan-mesa-layers-git'
  'lib32-amdonly-gaming-opencl-clover-mesa-git'
  'lib32-amdonly-gaming-opencl-rusticl-mesa-git'
  'lib32-amdonly-gaming-vulkan-radeon-git'
  'lib32-amdonly-gaming-vulkan-swrast-git'
  'lib32-amdonly-gaming-libva-mesa-driver-git'
  'lib32-amdonly-gaming-mesa-vdpau-git'
  'lib32-amdonly-gaming-mesa-git'
)
pkgrel=1
pkgdesc="An open-source implementation of the OpenGL specification (32-bit)"
url="https://www.mesa3d.org/"
arch=('x86_64')
license=('custom:mesa')
makedepends=(
  'lib32-clang'
  'lib32-expat'
  'lib32-libdrm'
  'lib32-libelf'
  'lib32-libglvnd'
  'lib32-libva'
  'lib32-libvdpau'
  'lib32-libx11'
  'lib32-libxdamage'
  'lib32-libxml2'
  'lib32-libxrandr'
  'lib32-libxshmfence'
  'lib32-libxxf86vm'
  'lib32-llvm'
  'lib32-lm_sensors'
  'lib32-rust-libs'
  'lib32-spirv-llvm-translator'
  'lib32-spirv-tools'
  'lib32-systemd'
  'lib32-vulkan-icd-loader'
  'lib32-wayland'
  'lib32-zstd'

  # shared between mesa and lib32-mesa
  'git'
  'clang'
  'cmake'
  'elfutils'
  'glslang'
  'libclc'
  'meson>=1.3.0'
  'python-mako'
  'python-ply'
  'rust-bindgen'
  'wayland-protocols'
  'xorgproto'

)
source=(
  'mesa::git+https://gitlab.freedesktop.org/mesa/mesa.git#branch=main'
  'LICENSE'
)
b2sums=('SKIP'
        'cc60238726b35133b5b729fb4ed1e76e04136588533615d84b4a54656d5b41727d5e7ff06ef4de3eb102eed6669d6c5c5cb8ac9fbdf6fc25aa477877c5c3ba87')
validpgpkeys=('8703B6700E7EE06D7A39B8D6EDAE37B02CEB490D'  # Emil Velikov <emil.l.velikov@gmail.com>
              '946D09B5E4C9845E63075FF1D961C596A7203456'  # Andres Gomez <tanty@igalia.com>
              'E3E8F480C52ADD73B278EE78E1ECBE07D7D70895'  # Juan Antonio Suárez Romero (Igalia, S.L.) <jasuarez@igalia.com>
              'A5CC9FEC93F2F837CB044912336909B6B25FADFA'  # Juan A. Suarez Romero <jasuarez@igalia.com>
              '71C4B75620BC75708B4BDB254C95FAAB3EB073EC'  # Dylan Baker <dylan@pnwbakers.com>
              '57551DE15B968F6341C248F68D8E31AFC32428A6') # Eric Engestrom <eric@engestrom.ch>


# NINJAFLAGS is an env var used to pass commandline options to ninja
# NOTE: It's your responbility to validate the value of $NINJAFLAGS. If unsure, don't set it.

pkgver() {
    cd mesa
    local _ver
    read -r _ver <VERSION

    local _patchver
    local _patchfile
    for _patchfile in "${source[@]}"; do
        _patchfile="${_patchfile%%::*}"
        _patchfile="${_patchfile##*/}"
        [[ $_patchfile = *.patch ]] || continue
        _patchver="${_patchver}$(md5sum ${srcdir}/${_patchfile} | cut -c1-32)"
    done
    _patchver="$(echo -n $_patchver | md5sum | cut -c1-32)"

    echo ${_ver/-/_}.$(git rev-list --count HEAD).$(git rev-parse --short HEAD).${_patchver}
}

prepare() {
  # although removing _build folder in build() function feels more natural,
  # that interferes with the spirit of makepkg --noextract
  if [  -d _build ]; then
    rm -rf _build
  fi

  # Ugly hack to allow recompilation using gamescope.path
  if [ -f "mesa/src/egl/wayland/wayland-drm/gamescope-commit-queue-v1.xml" ]; then
    rm -rf "mesa/src/egl/wayland/wayland-drm/gamescope-commit-queue-v1.xml"
  fi

  # Include package release in version string so Chromium invalidates
  # its GPU cache; otherwise it can cause pages to render incorrectly.
  # https://bugs.launchpad.net/ubuntu/+source/chromium-browser/+bug/2020604
  echo "$pkgver-$pkgrel" >VERSION

  local _patchfile
  for _patchfile in "${source[@]}"; do
      _patchfile="${_patchfile%%::*}"
      _patchfile="${_patchfile##*/}"
      [[ $_patchfile = *.patch ]] || continue
      echo "Applying patch $_patchfile..."
      patch --directory=mesa --forward --strip=1 --input="${srcdir}/${_patchfile}"
  done
}

build() {
  local meson_options=(
    --cross-file lib32
    -D android-libbacktrace=disabled
    -D b_ndebug=true
    -D b_lto=false
    -D dri3=enabled
    -D egl=enabled
    -D gallium-drivers=radeonsi,swrast,zink
    -D gallium-extra-hud=true
    -D gallium-nine=true
    -D gallium-omx=disabled
    -D gallium-opencl=icd
    -D gallium-rusticl=true
    -D gallium-va=enabled
    -D gallium-vdpau=enabled
    -D gallium-xa=disabled
    -D gbm=enabled
    -D gles1=disabled
    -D gles2=enabled
    -D glvnd=true
    -D glx=dri
    -D intel-rt=disabled
    -D libunwind=disabled
    -D llvm=enabled
    -D lmsensors=enabled
    -D microsoft-clc=disabled
    -D osmesa=true
    -D platforms=x11,wayland
    -D rust_std=2021
    -D shared-glapi=enabled
    -D opencl-spirv=true
    -D valgrind=disabled
    -D video-codecs=all
    -D vulkan-drivers=amd,swrast
    -D vulkan-layers=device-select,overlay
    -D vulkan-beta=true
    --wrap-mode=nofallback
  )

  # Build only minimal debug info to reduce size
  #CFLAGS+=' -g1'
  #CXXFLAGS+=' -g1'

  export BINDGEN_EXTRA_CLANG_ARGS="-m32"

  arch-meson mesa build "${meson_options[@]}"
  meson configure build --no-pager # Print config

  #if [ ! -f "build/build.ninja.bak" ]; then
  #  cp build/build.ninja build/build.ninja.back
  #fi

  # Evil: Hack build to make proc-macro crate native
  # Should become unnecessary with Meson 1.3
  #sed -e '/^rule rust_COMPILER$/irule rust_HACK\n command = rustc -C linker=gcc $ARGS $in\n deps = gcc\n depfile = $targetdep\n description = Compiling native Rust source $in\n' \
  #    -e '/^build src\/gallium\/frontends\/rusticl\/librusticl_proc_macros\.so:/s/rust_COMPILER/rust_HACK/' \
  #    -e '/^ LINK_ARGS =/s/ src\/gallium\/frontends\/rusticl\/librusticl_proc_macros\.so//' \
  #    -i build/build.ninja

  meson compile $NINJAFLAGS -C build

  # fake installation to be seperated into packages
  # outside of fakeroot but mesa doesn't need to chown/mod
  DESTDIR="${srcdir}/fakeinstall" meson install -C build
}

_install() {
  local src f dir
  for src; do
    f="${src#fakeinstall/}"
    dir="${pkgdir}/${f%/*}"
    install -m755 -d "${dir}"
    mv -v "${src}" "${dir}/"
  done
}

_libdir=usr/lib32

package_lib32-amdonly-gaming-vulkan-mesa-layers-git() {
  pkgdesc="Mesa's Vulkan layers (32-bit)"
  depends=(
    'lib32-libdrm'
    'lib32-libxcb'
    'lib32-wayland'

    'amdonly-gaming-vulkan-mesa-layers-git'
  )
  conflicts=(
    'lib32-vulkan-mesa-layers'
    'lib32-vulkan-mesa-layer'
  )
  provides=(
    'lib32-vulkan-mesa-layers'
  )

  rm -rv fakeinstall/usr/share/vulkan/explicit_layer.d
  rm -rv fakeinstall/usr/share/vulkan/implicit_layer.d
  _install fakeinstall/$_libdir/libVkLayer_*.so
  rm -v fakeinstall/usr/bin/mesa-overlay-control.py

  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
}

package_lib32-amdonly-gaming-opencl-clover-mesa-git() {
  pkgdesc="OpenCL support with clover for mesa drivers (32-bit)"
  depends=(
    'lib32-clang'
    'lib32-expat'
    'lib32-libdrm'
    'lib32-libelf'
    'lib32-spirv-llvm-translator'
    'lib32-zstd'

    'libclc'
    'amdonly-gaming-opencl-clover-mesa-git'
  )
  optdepends=('opencl-headers: headers necessary for OpenCL development')
  provides=(
    'lib32-opencl-driver'
    'lib32-opencl-clover-mesa'
  )
  conflicts=(
    'lib32-opencl-mesa'
    'lib32-opencl-clover-mesa'
  )

  rm -v fakeinstall/etc/OpenCL/vendors/mesa.icd
  _install fakeinstall/$_libdir/libMesaOpenCL*
  _install fakeinstall/$_libdir/gallium-pipe

  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
}

package_lib32-amdonly-gaming-opencl-rusticl-mesa-git() {
  pkgdesc="OpenCL support with rusticl for mesa drivers (32-bit)"
  depends=(
    'lib32-clang'
    'lib32-expat'
    'lib32-libdrm'
    'lib32-libelf'
    'lib32-lm_sensors'
    'lib32-spirv-llvm-translator'
    'lib32-zstd'

    'libclc'
    'amdonly-gaming-opencl-rusticl-mesa-git'
  )
  optdepends=('opencl-headers: headers necessary for OpenCL development')
  provides=(
    'lib32-opencl-rusticl-mesa'
    'lib32-opencl-driver'
  )
  conflicts=(
    'lib32-opencl-rusticl-mesa'
    'lib32-opencl-mesa'
  )

  rm -v fakeinstall/etc/OpenCL/vendors/rusticl.icd
  _install fakeinstall/$_libdir/libRusticlOpenCL*

  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
}

package_lib32-amdonly-gaming-vulkan-radeon-git() {
  pkgdesc="Radeon's Vulkan mesa driver (32-bit)"
  depends=(
    'lib32-libdrm'
    'lib32-libelf'
    'lib32-libx11'
    'lib32-libxshmfence'
    'lib32-llvm-libs'
    'lib32-systemd'
    'lib32-wayland'
    'lib32-xcb-util-keysyms'
    'lib32-zstd'

    'amdonly-gaming-vulkan-radeon-git'
  )
  optdepends=('lib32-vulkan-mesa-layers: additional vulkan layers')
  provides=(
    'lib32-vulkan-driver'
    'lib32-vulkan-radeon'
  )
  conflicts=('lib32-vulkan-radeon')

  rm -v fakeinstall/usr/share/drirc.d/00-radv-defaults.conf
  _install fakeinstall/usr/share/vulkan/icd.d/radeon_icd*.json
  _install fakeinstall/$_libdir/libvulkan_radeon.so

  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
}

package_lib32-amdonly-gaming-vulkan-swrast-git() {
  pkgdesc="Vulkan software rasteriser driver (32-bit)"
  depends=(
    'lib32-libdrm'
    'lib32-libx11'
    'lib32-libxshmfence'
    'lib32-llvm-libs'
    'lib32-systemd'
    'lib32-wayland'
    'lib32-xcb-util-keysyms'
    'lib32-zstd'
  )
  optdepends=('lib32-vulkan-mesa-layers: additional vulkan layers')
  conflicts=(
    'lib32-vulkan-mesa'
    'lib32-vulkan-swrast'
  )
  provides=(
    'lib32-vulkan-driver'
    'lib32-vulkan-swrast'
  )

  _install fakeinstall/usr/share/vulkan/icd.d/lvp_icd*.json
  _install fakeinstall/$_libdir/libvulkan_lvp.so

  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
}

package_lib32-amdonly-gaming-libva-mesa-driver-git() {
  pkgdesc="VA-API drivers (32-bit)"
  depends=(
    'lib32-expat'
    'lib32-libdrm'
    'lib32-libelf'
    'lib32-libx11'
    'lib32-libxshmfence'
    'lib32-llvm-libs'
    'lib32-zstd'
  )
  provides=('lib32-libva-driver')
  conflicts=('lib32-libva-mesa-driver')

  _install fakeinstall/$_libdir/dri/*_drv_video.so

  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
}

package_lib32-amdonly-gaming-mesa-vdpau-git() {
  pkgdesc="VDPAU drivers (32-bit)"
  depends=(
    'lib32-expat'
    'lib32-libdrm'
    'lib32-libelf'
    'lib32-libx11'
    'lib32-libxshmfence'
    'lib32-llvm-libs'
    'lib32-zstd'
  )
  provides=(
    'lib32-vdpau-driver'
    'lib32-mesa-vdpau'
  )
  conflicts=('lib32-mesa-vdpau')

  _install fakeinstall/$_libdir/vdpau

  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
}

package_lib32-amdonly-gaming-mesa-git() {
  depends=(
    'lib32-libdrm'
    'lib32-libelf'
    'lib32-libglvnd'
    'lib32-libxdamage'
    'lib32-libxshmfence'
    'lib32-libxxf86vm'
    'lib32-llvm-libs'
    'lib32-lm_sensors'
    'lib32-vulkan-icd-loader'
    'lib32-wayland'
    'lib32-zstd'

    'amdonly-gaming-mesa-git'
  )
  optdepends=(
    'opengl-man-pages: for the OpenGL API man pages'
  )
  provides=(
    'lib32-mesa'
    'lib32-mesa-libgl'
    'lib32-opengl-driver'
  )
  conflicts=(
    'lib32-mesa'
    'lib32-mesa-libgl'
  )

  rm -v fakeinstall/usr/share/drirc.d/00-mesa-defaults.conf
  rm -v fakeinstall/usr/share/glvnd/egl_vendor.d/50_mesa.json

  # ati-dri, nouveau-dri, intel-dri, svga-dri, swrast, swr
  _install fakeinstall/$_libdir/dri/*_dri.so

  _install fakeinstall/$_libdir/d3d
  _install fakeinstall/$_libdir/lib{gbm,glapi}.so*
  _install fakeinstall/$_libdir/libOSMesa.so*

  # only needed when gallium-xa is enabled
  #_install fakeinstall/$_libdir/libxatracker.so*

  rm -rv fakeinstall/usr/include
  _install fakeinstall/$_libdir/pkgconfig

  # libglvnd support
  _install fakeinstall/$_libdir/libGLX_mesa.so*
  _install fakeinstall/$_libdir/libEGL_mesa.so*

  # indirect rendering
  ln -sr "$pkgdir"/$_libdir/libGLX_{mesa,indirect}.so.0

  # make sure there are no files left to install
  find fakeinstall -depth -print0 | xargs -0 rmdir

  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
}