blob: 7dbca5876aa58c4c5dfe47e9b3039abae5cd8fbf [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "A free implementation of the OpenGL API"
2DESCRIPTION = "Mesa is an open-source implementation of the OpenGL specification - \
3a system for rendering interactive 3D graphics. \
4A variety of device drivers allows Mesa to be used in many different environments \
5ranging from software emulation to complete hardware acceleration for modern GPUs. \
6Mesa is used as part of the overall Direct Rendering Infrastructure and X.org \
7environment."
8
9HOMEPAGE = "http://mesa3d.org"
10BUGTRACKER = "https://bugs.freedesktop.org"
11SECTION = "x11"
12LICENSE = "MIT"
Andrew Geissler87f5cff2022-09-30 13:13:31 -050013LIC_FILES_CHKSUM = "file://docs/license.rst;md5=63779ec98d78d823a9dc533a0735ef10"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014
15PE = "2"
16
Andrew Geissler4ed12e12020-06-05 18:00:41 -050017SRC_URI = "https://mesa.freedesktop.org/archive/mesa-${PV}.tar.xz \
18 file://0001-meson.build-check-for-all-linux-host_os-combinations.patch \
Andrew Geissler4ed12e12020-06-05 18:00:41 -050019 file://0001-meson-misdetects-64bit-atomics-on-mips-clang.patch \
Andrew Geissler4c19ea12020-10-27 13:52:24 -050020 file://0001-futex.h-Define-__NR_futex-if-it-does-not-exist.patch \
Andrew Geissler595f6302022-01-24 19:11:47 +000021 file://0001-util-format-Check-for-NEON-before-using-it.patch \
Patrick Williams2390b1b2022-11-03 13:47:49 -050022 ${NATIVE_PATCHES} \
Andrew Geissler4ed12e12020-06-05 18:00:41 -050023 "
Patrick Williams2390b1b2022-11-03 13:47:49 -050024NATIVE_PATCHES ?= ""
25# required by mesa-native on Ubuntu 18.04 with gcc 7.5 when DEBUG_BUILD enabled
26NATIVE_PATCHES:class-native = "file://0001-nir-nir_opt_move-fix-ALWAYS_INLINE-compiler-error.patch"
Andrew Geissler4ed12e12020-06-05 18:00:41 -050027
Patrick Williams2390b1b2022-11-03 13:47:49 -050028SRC_URI[sha256sum] = "2de11fb74fc5cc671b818e49fe203cea0cd1d8b69756e97cdb06a2f4e78948f9"
Andrew Geissler4ed12e12020-06-05 18:00:41 -050029
30UPSTREAM_CHECK_GITTAGREGEX = "mesa-(?P<pver>\d+(\.\d+)+)"
31
32#because we cannot rely on the fact that all apps will use pkgconfig,
33#make eglplatform.h independent of MESA_EGL_NO_X11_HEADER
Patrick Williams213cb262021-08-07 19:21:33 -050034do_install:append() {
Andrew Geissler4ed12e12020-06-05 18:00:41 -050035 if ${@bb.utils.contains('PACKAGECONFIG', 'egl', 'true', 'false', d)}; then
36 sed -i -e 's/^#elif defined(__unix__) && defined(EGL_NO_X11)$/#elif defined(__unix__) \&\& defined(EGL_NO_X11) || ${@bb.utils.contains('PACKAGECONFIG', 'x11', '0', '1', d)}/' ${D}${includedir}/EGL/eglplatform.h
37 fi
38}
39
Brad Bishop393846f2019-05-20 12:24:11 -040040DEPENDS = "expat makedepend-native flex-native bison-native libxml2-native zlib chrpath-replacement-native python3-mako-native gettext-native"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050041EXTRANATIVEPATH += "chrpath-native"
Brad Bishop316dfdd2018-06-25 12:45:53 -040042PROVIDES = " \
43 ${@bb.utils.contains('PACKAGECONFIG', 'opengl', 'virtual/libgl', '', d)} \
Andrew Geissler595f6302022-01-24 19:11:47 +000044 ${@bb.utils.contains('PACKAGECONFIG', 'gles', 'virtual/libgles1 virtual/libgles2 virtual/libgles3', '', d)} \
Brad Bishop316dfdd2018-06-25 12:45:53 -040045 ${@bb.utils.contains('PACKAGECONFIG', 'egl', 'virtual/egl', '', d)} \
46 ${@bb.utils.contains('PACKAGECONFIG', 'gbm', 'virtual/libgbm', '', d)} \
47 virtual/mesa \
48 "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049
Brad Bishop6dbb3162019-11-25 09:41:34 -050050inherit meson pkgconfig python3native gettext features_check
Patrick Williamsc124f4f2015-09-15 14:41:29 -050051
Brad Bishop19323692019-04-05 15:28:33 -040052BBCLASSEXTEND = "native nativesdk"
53
Patrick Williams213cb262021-08-07 19:21:33 -050054ANY_OF_DISTRO_FEATURES:class-target = "opengl vulkan"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055
Andrew Geisslerd1e89492021-02-12 15:35:20 -060056PLATFORMS ??= "${@bb.utils.filter('PACKAGECONFIG', 'x11 wayland', d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050057
Patrick Williams92b42cb2022-09-03 06:53:57 -050058# By placing llvm-config in the target sysroot bindir, it will then map values
59# to the target libdir magically. We can safely add to path as there are no other binaries
60# there.
61PATH:prepend = "${STAGING_BINDIR_CROSS}:${STAGING_BINDIR}:"
Brad Bishop08902b02019-08-20 09:16:51 -040062MESA_LLVM_RELEASE ?= "${LLVMVERSION}"
Patrick Williams92b42cb2022-09-03 06:53:57 -050063do_configure:prepend () {
64 if [ -e ${STAGING_BINDIR_NATIVE}/llvm-config${MESA_LLVM_RELEASE} ]; then
65 cp ${STAGING_BINDIR_NATIVE}/llvm-config${MESA_LLVM_RELEASE} ${STAGING_BINDIR}
66 cp ${STAGING_BINDIR_NATIVE}/llvm-config ${STAGING_BINDIR}
67 fi
68}
Brad Bishop393846f2019-05-20 12:24:11 -040069
Andrew Geissler82c905d2020-04-13 13:39:40 -050070# set the MESA_BUILD_TYPE to either 'release' (default) or 'debug'
71# by default the upstream mesa sources build a debug release
72# here we assume the user will want a release build by default
73MESA_BUILD_TYPE ?= "release"
74def check_buildtype(d):
75 _buildtype = d.getVar('MESA_BUILD_TYPE')
76 if _buildtype not in ['release', 'debug']:
77 bb.fatal("unknown build type (%s), please set MESA_BUILD_TYPE to either 'release' or 'debug'" % _buildtype)
78 if _buildtype == 'debug':
79 return 'debugoptimized'
80 return 'plain'
81MESON_BUILDTYPE = "${@check_buildtype(d)}"
82
Brad Bishop393846f2019-05-20 12:24:11 -040083EXTRA_OEMESON = " \
Andrew Geisslerd1e89492021-02-12 15:35:20 -060084 -Dshared-glapi=enabled \
Brad Bishop393846f2019-05-20 12:24:11 -040085 -Dglx-read-only-text=true \
86 -Dplatforms='${@",".join("${PLATFORMS}".split())}' \
Brad Bishop19323692019-04-05 15:28:33 -040087"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050088
Andrew Geissler6ce62a22020-11-30 19:58:47 -060089def strip_comma(s):
90 return s.strip(',')
91
Andrew Geissler9aee5002022-03-30 16:27:02 +000092PACKAGECONFIG = " \
93 gallium \
94 ${@bb.utils.filter('DISTRO_FEATURES', 'x11 vulkan wayland', d)} \
95 ${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'opengl egl gles gbm virgl', '', d)} \
96 ${@bb.utils.contains('DISTRO_FEATURES', 'x11 opengl', 'dri3', '', d)} \
97 ${@bb.utils.contains('DISTRO_FEATURES', 'x11 vulkan', 'dri3', '', d)} \
Andrew Geissler87f5cff2022-09-30 13:13:31 -050098 ${@bb.utils.contains('DISTRO_FEATURES', 'vulkan', 'zink', '', d)} \
Andrew Geissler9aee5002022-03-30 16:27:02 +000099"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500100
Andrew Geissler9aee5002022-03-30 16:27:02 +0000101# "gbm" requires "opengl"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600102PACKAGECONFIG[gbm] = "-Dgbm=enabled,-Dgbm=disabled"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600103
Brad Bishop19323692019-04-05 15:28:33 -0400104X11_DEPS = "xorgproto virtual/libx11 libxext libxxf86vm libxdamage libxfixes xrandr"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500105# "x11" requires "opengl"
Brad Bishop393846f2019-05-20 12:24:11 -0400106PACKAGECONFIG[x11] = ",-Dglx=disabled,${X11_DEPS}"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600107PACKAGECONFIG[xvmc] = "-Dgallium-xvmc=enabled,-Dgallium-xvmc=disabled,libxvmc"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400108PACKAGECONFIG[wayland] = ",,wayland-native wayland libdrm wayland-protocols"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500109
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600110PACKAGECONFIG[dri3] = "-Ddri3=enabled, -Ddri3=disabled, xorgproto libxshmfence"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500111
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500112# Vulkan drivers need dri3 enabled
Andrew Geissler6ce62a22020-11-30 19:58:47 -0600113# amd could be enabled as well but requires gallium-llvm with llvm >= 3.9
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500114VULKAN_DRIVERS = ""
Patrick Williams213cb262021-08-07 19:21:33 -0500115VULKAN_DRIVERS:append:x86:class-target = ",intel"
116VULKAN_DRIVERS:append:x86-64:class-target = ",intel"
117VULKAN_DRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'freedreno', ',freedreno', '', d)}"
Andrew Geissler595f6302022-01-24 19:11:47 +0000118VULKAN_DRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'broadcom', ',broadcom', '', d)}"
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500119PACKAGECONFIG[vulkan] = "-Dvulkan-drivers=${@strip_comma('${VULKAN_DRIVERS}')}, -Dvulkan-drivers='',glslang-native vulkan-loader vulkan-headers"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500120
Brad Bishop393846f2019-05-20 12:24:11 -0400121PACKAGECONFIG[opengl] = "-Dopengl=true, -Dopengl=false"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500122
123# "gles" requires "opengl"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600124PACKAGECONFIG[gles] = "-Dgles1=enabled -Dgles2=enabled, -Dgles1=disabled -Dgles2=disabled"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500125
Andrew Geissler9aee5002022-03-30 16:27:02 +0000126# "egl" requires "opengl"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600127PACKAGECONFIG[egl] = "-Degl=enabled, -Degl=disabled"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500128
Andrew Geissler9aee5002022-03-30 16:27:02 +0000129# "opencl" requires libclc from meta-clang and spirv-tools from OE-Core
Patrick Williams92b42cb2022-09-03 06:53:57 -0500130OPENCL_NATIVE = "${@bb.utils.contains('PACKAGECONFIG', 'freedreno', '-Dopencl-native=true', '', d)}"
131PACKAGECONFIG[opencl] = "-Dgallium-opencl=icd -Dopencl-spirv=true ${OPENCL_NATIVE},-Dgallium-opencl=disabled -Dopencl-spirv=false,libclc spirv-tools"
Andrew Geissler9aee5002022-03-30 16:27:02 +0000132
Andrew Geissler595f6302022-01-24 19:11:47 +0000133PACKAGECONFIG[broadcom] = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500134PACKAGECONFIG[etnaviv] = ""
Brad Bishop00e122a2019-10-05 11:10:57 -0400135PACKAGECONFIG[freedreno] = ""
Brad Bishop393846f2019-05-20 12:24:11 -0400136PACKAGECONFIG[kmsro] = ""
Brad Bishopc68388fc2019-08-26 01:33:31 -0400137PACKAGECONFIG[vc4] = ""
138PACKAGECONFIG[v3d] = ""
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500139PACKAGECONFIG[zink] = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500140
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500141GALLIUMDRIVERS = "swrast"
Brad Bishop79641f22019-09-10 07:20:22 -0400142# gallium swrast was found to crash Xorg on startup in x32 qemu
Patrick Williams213cb262021-08-07 19:21:33 -0500143GALLIUMDRIVERS:x86-x32 = ""
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500144GALLIUMDRIVERS:append:x86:class-target = ",i915,iris,crocus"
145GALLIUMDRIVERS:append:x86-64:class-target = ",i915,iris,crocus"
Brad Bishop79641f22019-09-10 07:20:22 -0400146
Patrick Williams213cb262021-08-07 19:21:33 -0500147GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'etnaviv', ',etnaviv', '', d)}"
148GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'freedreno', ',freedreno', '', d)}"
149GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'kmsro', ',kmsro', '', d)}"
150GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'vc4', ',vc4', '', d)}"
151GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'v3d', ',v3d', '', d)}"
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500152GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'zink', ',zink', '', d)}"
Brad Bishop19323692019-04-05 15:28:33 -0400153
154# radeonsi requires LLVM
Andrew Geissler6ce62a22020-11-30 19:58:47 -0600155GALLIUMDRIVERS_RADEONSI = "${@bb.utils.contains('PACKAGECONFIG', 'r600', ',radeonsi', '', d)}"
Andrew Geisslereff27472021-10-29 15:35:00 -0500156GALLIUMDRIVERS_LLVM = "r300,nouveau${GALLIUMDRIVERS_RADEONSI}"
157GALLIUMDRIVERS_LLVM:append:x86:class-target = ",svga"
158GALLIUMDRIVERS_LLVM:append:x86-64:class-target = ",svga"
Brad Bishop19323692019-04-05 15:28:33 -0400159
160PACKAGECONFIG[r600] = ""
Andrew Geissler82c905d2020-04-13 13:39:40 -0500161PACKAGECONFIG[virgl] = ""
Brad Bishop19323692019-04-05 15:28:33 -0400162
Patrick Williams213cb262021-08-07 19:21:33 -0500163GALLIUMDRIVERS:append = "${@bb.utils.contains('PACKAGECONFIG', 'gallium-llvm', ',${GALLIUMDRIVERS_LLVM}', '', d)}"
164GALLIUMDRIVERS:append = "${@bb.utils.contains('PACKAGECONFIG', 'r600', ',r600', '', d)}"
165GALLIUMDRIVERS:append = "${@bb.utils.contains('PACKAGECONFIG', 'virgl', ',virgl', '', d)}"
Brad Bishop19323692019-04-05 15:28:33 -0400166
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500167PACKAGECONFIG[gallium] = "-Dgallium-drivers=${@strip_comma('${GALLIUMDRIVERS}')}, -Dgallium-drivers='', libdrm"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600168PACKAGECONFIG[gallium-llvm] = "-Dllvm=enabled -Dshared-llvm=enabled, -Dllvm=disabled, llvm${MESA_LLVM_RELEASE} llvm-native \
Andrew Geissler6ce62a22020-11-30 19:58:47 -0600169 elfutils"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600170PACKAGECONFIG[xa] = "-Dgallium-xa=enabled, -Dgallium-xa=disabled"
171PACKAGECONFIG[va] = "-Dgallium-va=enabled,-Dgallium-va=disabled,libva-initial"
Andrew Geisslerc182c622020-05-15 14:13:32 -0500172
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600173PACKAGECONFIG[vdpau] = "-Dgallium-vdpau=enabled,-Dgallium-vdpau=disabled,libvdpau"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500174
Brad Bishop96ff1982019-08-19 13:50:42 -0400175PACKAGECONFIG[lima] = ""
Patrick Williams213cb262021-08-07 19:21:33 -0500176GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'lima', ',lima', '', d)}"
Brad Bishop96ff1982019-08-19 13:50:42 -0400177
Brad Bishop79641f22019-09-10 07:20:22 -0400178PACKAGECONFIG[panfrost] = ""
Patrick Williams213cb262021-08-07 19:21:33 -0500179GALLIUMDRIVERS:append ="${@bb.utils.contains('PACKAGECONFIG', 'panfrost', ',panfrost', '', d)}"
Brad Bishop79641f22019-09-10 07:20:22 -0400180
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500181PACKAGECONFIG[vulkan-beta] = "-Dvulkan-beta=true,-Dvulkan-beta=false"
182
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500183PACKAGECONFIG[osmesa] = "-Dosmesa=true,-Dosmesa=false"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500184
Patrick Williams2390b1b2022-11-03 13:47:49 -0500185PACKAGECONFIG[perfetto] = "-Dperfetto=true,-Dperfetto=false,libperfetto"
186
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600187PACKAGECONFIG[unwind] = "-Dlibunwind=enabled,-Dlibunwind=disabled,libunwind"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800188
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700189PACKAGECONFIG[lmsensors] = "-Dlmsensors=enabled,-Dlmsensors=disabled,lmsensors"
190
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500191# llvmpipe is slow if compiled with -fomit-frame-pointer (e.g. -O2)
Patrick Williams213cb262021-08-07 19:21:33 -0500192FULL_OPTIMIZATION:append = " -fno-omit-frame-pointer"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500193
Patrick Williams213cb262021-08-07 19:21:33 -0500194CFLAGS:append:armv5 = " -DMISSING_64BIT_ATOMICS"
195CFLAGS:append:armv6 = " -DMISSING_64BIT_ATOMICS"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500196
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500197# Remove the mesa dependency on mesa-dev, as mesa is empty
Andrew Geissler615f2f12022-07-15 14:00:58 -0500198DEV_PKG_DEPENDENCY = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500199
Andrew Geissler595f6302022-01-24 19:11:47 +0000200# Khronos documentation says that include/GLES2/gl2ext.h can be used for
201# OpenGL ES 3 specification as well as for OpenGL ES 2.
202# There can be applications including GLES2/gl2ext.h instead of GLES3/gl3ext.h
203# meaning we should probably bring in GLES2/gl2ext.h if someone asks for
204# development package of libgles3.
205RDEPENDS:libgles3-mesa-dev += "libgles2-mesa-dev"
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500206
Andrew Geissler9aee5002022-03-30 16:27:02 +0000207RDEPENDS:libopencl-mesa += "${@bb.utils.contains('PACKAGECONFIG', 'opencl', 'libclc spirv-tools', '', d)}"
208
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500209PACKAGES =+ "libegl-mesa libegl-mesa-dev \
210 libosmesa libosmesa-dev \
211 libgl-mesa libgl-mesa-dev \
212 libglapi libglapi-dev \
213 libgbm libgbm-dev \
214 libgles1-mesa libgles1-mesa-dev \
215 libgles2-mesa libgles2-mesa-dev \
216 libgles3-mesa libgles3-mesa-dev \
Andrew Geissler9aee5002022-03-30 16:27:02 +0000217 libopencl-mesa libopencl-mesa-dev \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500218 libxatracker libxatracker-dev \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500219 mesa-megadriver mesa-vulkan-drivers \
Andrew Geisslerc182c622020-05-15 14:13:32 -0500220 mesa-vdpau-drivers \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500221 "
222
Patrick Williams213cb262021-08-07 19:21:33 -0500223do_install:append () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500224 # Drivers never need libtool .la files
225 rm -f ${D}${libdir}/dri/*.la
226 rm -f ${D}${libdir}/egl/*.la
227 rm -f ${D}${libdir}/gallium-pipe/*.la
228 rm -f ${D}${libdir}/gbm/*.la
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500229
Brad Bishop19323692019-04-05 15:28:33 -0400230 # it was packaged in libdricore9.1.3-1 and preventing upgrades when debian.bbclass was used
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500231 chrpath --delete ${D}${libdir}/dri/*_dri.so || true
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800232
233 # libwayland-egl has been moved to wayland 1.15+
234 rm -f ${D}${libdir}/libwayland-egl*
235 rm -f ${D}${libdir}/pkgconfig/wayland-egl.pc
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500236}
237
238# For the packages that make up the OpenGL interfaces, inject variables so that
239# they don't get Debian-renamed (which would remove the -mesa suffix), and
240# RPROVIDEs/RCONFLICTs on the generic libgl name.
241python __anonymous() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500242 pkgconfig = (d.getVar('PACKAGECONFIG') or "").split()
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600243 suffix = ""
244 if "-native" in d.getVar("PN"):
245 suffix = "-native"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500246 for p in (("egl", "libegl", "libegl1"),
Andrew Geissler9aee5002022-03-30 16:27:02 +0000247 ("opengl", "libgl", "libgl1"),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500248 ("gles", "libgles1", "libglesv1-cm1"),
249 ("gles", "libgles2", "libglesv2-2"),
Andrew Geissler9aee5002022-03-30 16:27:02 +0000250 ("gles", "libgles3",),
251 ("opencl", "libopencl",)):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500252 if not p[0] in pkgconfig:
253 continue
Andrew Geissler1e34c2d2020-05-29 16:02:59 -0500254 mlprefix = d.getVar("MLPREFIX")
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600255 fullp = mlprefix + p[1] + "-mesa" + suffix
Andrew Geissler1e34c2d2020-05-29 16:02:59 -0500256 mlprefix = d.getVar("MLPREFIX")
Patrick Williams213cb262021-08-07 19:21:33 -0500257 pkgs = " " + " ".join(mlprefix + x + suffix for x in p[1:])
258 d.setVar("DEBIAN_NOAUTONAME:" + fullp, "1")
259 d.appendVar("RREPLACES:" + fullp, pkgs)
260 d.appendVar("RPROVIDES:" + fullp, pkgs)
261 d.appendVar("RCONFLICTS:" + fullp, pkgs)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500262
Patrick Williams213cb262021-08-07 19:21:33 -0500263 d.appendVar("RRECOMMENDS:" + fullp, " ${MLPREFIX}mesa-megadriver" + suffix)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500264
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500265 # For -dev, the first element is both the Debian and original name
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600266 fullp = mlprefix + p[1] + "-mesa-dev" + suffix
Patrick Williams213cb262021-08-07 19:21:33 -0500267 pkgs = " " + mlprefix + p[1] + "-dev" + suffix
268 d.setVar("DEBIAN_NOAUTONAME:" + fullp, "1")
269 d.appendVar("RREPLACES:" + fullp, pkgs)
270 d.appendVar("RPROVIDES:" + fullp, pkgs)
271 d.appendVar("RCONFLICTS:" + fullp, pkgs)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500272}
273
274python mesa_populate_packages() {
275 pkgs = ['mesa', 'mesa-dev', 'mesa-dbg']
276 for pkg in pkgs:
Patrick Williams213cb262021-08-07 19:21:33 -0500277 d.setVar("RPROVIDES:%s" % pkg, pkg.replace("mesa", "mesa-dri", 1))
278 d.setVar("RCONFLICTS:%s" % pkg, pkg.replace("mesa", "mesa-dri", 1))
279 d.setVar("RREPLACES:%s" % pkg, pkg.replace("mesa", "mesa-dri", 1))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500280
281 import re
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500282 dri_drivers_root = oe.path.join(d.getVar('PKGD'), d.getVar('libdir'), "dri")
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600283 if os.path.isdir(dri_drivers_root):
Patrick Williams93c203f2021-10-06 16:15:23 -0500284 dri_pkgs = sorted(os.listdir(dri_drivers_root))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600285 lib_name = d.expand("${MLPREFIX}mesa-megadriver")
286 for p in dri_pkgs:
Brad Bishop19323692019-04-05 15:28:33 -0400287 m = re.match(r'^(.*)_dri\.so$', p)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600288 if m:
289 pkg_name = " ${MLPREFIX}mesa-driver-%s" % legitimize_package_name(m.group(1))
Patrick Williams213cb262021-08-07 19:21:33 -0500290 d.appendVar("RPROVIDES:%s" % lib_name, pkg_name)
291 d.appendVar("RCONFLICTS:%s" % lib_name, pkg_name)
292 d.appendVar("RREPLACES:%s" % lib_name, pkg_name)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500293
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500294 pipe_drivers_root = os.path.join(d.getVar('libdir'), "gallium-pipe")
Brad Bishop19323692019-04-05 15:28:33 -0400295 do_split_packages(d, pipe_drivers_root, r'^pipe_(.*)\.so$', 'mesa-driver-pipe-%s', 'Mesa %s pipe driver', extra_depends='')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500296}
297
Patrick Williams213cb262021-08-07 19:21:33 -0500298PACKAGESPLITFUNCS:prepend = "mesa_populate_packages "
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500299
300PACKAGES_DYNAMIC += "^mesa-driver-.*"
Patrick Williams213cb262021-08-07 19:21:33 -0500301PACKAGES_DYNAMIC:class-native = "^mesa-driver-.*-native"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500302
Andrew Geisslerd5838332022-05-27 11:33:10 -0500303FILES:mesa-megadriver = "${libdir}/dri/* ${datadir}/drirc.d"
Patrick Williams213cb262021-08-07 19:21:33 -0500304FILES:mesa-vulkan-drivers = "${libdir}/libvulkan_*.so ${datadir}/vulkan"
305FILES:${PN}-vdpau-drivers = "${libdir}/vdpau/*.so.*"
306FILES:libegl-mesa = "${libdir}/libEGL.so.*"
307FILES:libgbm = "${libdir}/libgbm.so.*"
308FILES:libgles1-mesa = "${libdir}/libGLESv1*.so.*"
309FILES:libgles2-mesa = "${libdir}/libGLESv2.so.*"
310FILES:libgl-mesa = "${libdir}/libGL.so.*"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500311FILES:libopencl-mesa = "${libdir}/libMesaOpenCL.so.* ${libdir}/gallium-pipe/*.so ${sysconfdir}/OpenCL/vendors/mesa.icd"
Patrick Williams213cb262021-08-07 19:21:33 -0500312FILES:libglapi = "${libdir}/libglapi.so.*"
313FILES:libosmesa = "${libdir}/libOSMesa.so.*"
314FILES:libxatracker = "${libdir}/libxatracker.so.*"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500315
Patrick Williams213cb262021-08-07 19:21:33 -0500316FILES:${PN}-dev = "${libdir}/pkgconfig/dri.pc ${includedir}/vulkan ${libdir}/vdpau/*.so"
317FILES:libegl-mesa-dev = "${libdir}/libEGL.* ${includedir}/EGL ${includedir}/KHR ${libdir}/pkgconfig/egl.pc"
318FILES:libgbm-dev = "${libdir}/libgbm.* ${libdir}/pkgconfig/gbm.pc ${includedir}/gbm.h"
319FILES:libgl-mesa-dev = "${libdir}/libGL.* ${includedir}/GL ${libdir}/pkgconfig/gl.pc"
320FILES:libglapi-dev = "${libdir}/libglapi.*"
321FILES:libgles1-mesa-dev = "${libdir}/libGLESv1*.* ${includedir}/GLES ${libdir}/pkgconfig/glesv1*.pc"
322FILES:libgles2-mesa-dev = "${libdir}/libGLESv2.* ${includedir}/GLES2 ${libdir}/pkgconfig/glesv2.pc"
323FILES:libgles3-mesa-dev = "${includedir}/GLES3"
Andrew Geissler9aee5002022-03-30 16:27:02 +0000324FILES:libopencl-mesa-dev = "${libdir}/libMesaOpenCL.so"
Patrick Williams213cb262021-08-07 19:21:33 -0500325FILES:libosmesa-dev = "${libdir}/libOSMesa.* ${includedir}/GL/osmesa.h ${libdir}/pkgconfig/osmesa.pc"
326FILES:libxatracker-dev = "${libdir}/libxatracker.so ${libdir}/libxatracker.la \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500327 ${includedir}/xa_tracker.h ${includedir}/xa_composite.h ${includedir}/xa_context.h \
328 ${libdir}/pkgconfig/xatracker.pc"
Brad Bishop19323692019-04-05 15:28:33 -0400329
330# Fix upgrade path from mesa to mesa-megadriver
Patrick Williams213cb262021-08-07 19:21:33 -0500331RREPLACES:mesa-megadriver = "mesa"
332RCONFLICTS:mesa-megadriver = "mesa"
333RPROVIDES:mesa-megadriver = "mesa"