pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

mesa: initial package for mesa-24.3.4.



Module Name:	pkgsrc-wip
Committed By:	Robert Swindells <rjs%NetBSD.org@localhost>
Pushed By:	rjs
Date:		Fri May 9 15:53:52 2025 +0100
Changeset:	b14c612f06714ab6fb9538ea0e5cae9030eb6f6f

Added Files:
	mesa/DESCR
	mesa/Makefile
	mesa/PLIST
	mesa/buildlink3.mk
	mesa/builtin.mk
	mesa/distinfo
	mesa/features.mk
	mesa/options.mk
	mesa/patches/patch-src_egl_drivers_dri2_platform__drm.c
	mesa/patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c
	mesa/patches/patch-src_gallium_drivers_r600_sfn_sfn__valuefactory.cpp
	mesa/patches/patch-src_glx_glxclient.h
	mesa/patches/patch-src_glx_glxcurrent.c
	mesa/patches/patch-src_util_build__id.c
	mesa/patches/patch-src_util_os__file.c
	mesa/version.mk

Log Message:
mesa: initial package for mesa-24.3.4.

Only added patches for NetBSD.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=b14c612f06714ab6fb9538ea0e5cae9030eb6f6f

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 mesa/DESCR                                         |  10 ++
 mesa/Makefile                                      | 193 +++++++++++++++++++++
 mesa/PLIST                                         | 142 +++++++++++++++
 mesa/buildlink3.mk                                 |  43 +++++
 mesa/builtin.mk                                    |  89 ++++++++++
 mesa/distinfo                                      |  12 ++
 mesa/features.mk                                   |  48 +++++
 mesa/options.mk                                    | 152 ++++++++++++++++
 .../patch-src_egl_drivers_dri2_platform__drm.c     |  16 ++
 ...llium_auxiliary_pipe-loader_pipe__loader__drm.c | 127 ++++++++++++++
 ..._gallium_drivers_r600_sfn_sfn__valuefactory.cpp |  12 ++
 mesa/patches/patch-src_glx_glxclient.h             |  19 ++
 mesa/patches/patch-src_glx_glxcurrent.c            |  19 ++
 mesa/patches/patch-src_util_build__id.c            |  25 +++
 mesa/patches/patch-src_util_os__file.c             |  35 ++++
 mesa/version.mk                                    |  30 ++++
 16 files changed, 972 insertions(+)

diffs:
diff --git a/mesa/DESCR b/mesa/DESCR
new file mode 100644
index 0000000000..8ae75a59fc
--- /dev/null
+++ b/mesa/DESCR
@@ -0,0 +1,10 @@
+The Mesa project began as an open-source implementation of the OpenGL
+specification - a system for rendering interactive 3D graphics.
+
+Over the years the project has grown to implement more graphics APIs,
+including OpenGL ES (versions 1, 2, 3), OpenCL, OpenMAX, VDPAU, VA API,
+XvMC and Vulkan.
+
+A variety of device drivers allows the Mesa libraries to be used in many
+different environments ranging from software emulation to complete hardware
+acceleration for modern GPUs.
diff --git a/mesa/Makefile b/mesa/Makefile
new file mode 100644
index 0000000000..ec488cf8e8
--- /dev/null
+++ b/mesa/Makefile
@@ -0,0 +1,193 @@
+# $NetBSD: $
+
+#DISTNAME=	mesa-25.0.5
+DISTNAME=	mesa-24.3.4
+CATEGORIES=	graphics
+MASTER_SITES=	https://mesa.freedesktop.org/archive/
+EXTRACT_SUFX=	.tar.xz
+
+MAINTAINER=	nia%NetBSD.org@localhost
+HOMEPAGE=	https://www.mesa3d.org/
+COMMENT=	Open source OpenGL implementation
+LICENSE=	mit
+
+USE_TOOLS+=	bison flex pkg-config xgettext
+USE_LANGUAGES=	c c++
+
+FORCE_CXX_STD+=	c++17
+
+USE_FEATURES+=	strnlen
+
+CFLAGS.SunOS+=		-D_POSIX_PTHREAD_SEMANTICS
+CXXFLAGS.SunOS+=	-Drestrict=__restrict__
+LDFLAGS.SunOS+=		-lsocket -lnsl
+
+# Some of these get appended in options.mk.
+DRI_DRIVERS=		#
+GALLIUM_DRIVERS=	softpipe
+VULKAN_DRIVERS=		#
+MESA_PLATFORMS=		#
+
+.include "../../mk/compiler.mk"
+.include "features.mk"
+.include "options.mk"
+
+PLIST_SUBST+=	GLVER="1.2.0"
+PLIST_SUBST+=	MACHINE_ARCH=${MACHINE_ARCH}
+
+# classic DRI drivers
+PLIST_VARS+=		i830 i915 i965 r100 r200 nouveau_dri
+
+# Gallium drivers
+PLIST_VARS+=		r300 svga nouveau iris
+
+# other features
+PLIST_VARS+=		arm kms vaapi xa
+
+.if ${MESALIB_SUPPORTS_DRI} == "yes"
+BUILDLINK_API_DEPENDS.libdrm+=	libdrm>=2.4.100
+.include "../../x11/libdrm/buildlink3.mk"
+.  if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
+.    include "../../sysutils/libpciaccess/buildlink3.mk"
+.  endif
+MESON_ARGS+=		-Degl=enabled
+MESON_ARGS+=		-Dgbm=enabled
+.  if ${_MESALIB_ARCH_SUPPORTS_XA} == "yes"
+# XA state tracker requires at least one of the following gallium drivers:
+# nouveau, freedreno, i915, svga
+MESON_ARGS+=		-Dgallium-xa=enabled
+PLIST.xa=		yes
+.  else
+MESON_ARGS+=		-Dgallium-xa=disabled
+.  endif
+.  if ${X11_TYPE} == "native" && !exists(${X11BASE}/include/xcb/dri3.h)
+MESON_ARGS+=		-Ddri3=false
+.  endif
+PLIST.kms=		yes
+.  if ${MACHINE_ARCH:M*arm*} || \
+      ${MACHINE_CPU} == "aarch64"
+#GALLIUM_DRIVERS+=	freedreno vc4 v3d etnaviv tegra panfrost lima
+GALLIUM_DRIVERS+=	panfrost lima
+PLIST.arm=		yes
+.  endif
+.  if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
+GALLIUM_DRIVERS+=	svga
+DRI_DRIVERS+=		i915 i965
+PLIST.svga=		yes
+PLIST.i830=		yes
+PLIST.i915=		yes
+PLIST.i965=		yes
+.  endif
+# FreeBSD lacks nouveau support (there are official binaries from Nvidia)
+.  if ${OPSYS} != "FreeBSD"
+.    if empty(MACHINE_PLATFORM:MNetBSD-*-powerpc)
+# nouveau not available on this platform
+PLIST.nouveau=		yes
+PLIST.nouveau_dri=	yes
+GALLIUM_DRIVERS+=	nouveau
+DRI_DRIVERS+=		nouveau
+.    endif
+.  endif
+.  if !empty(MACHINE_PLATFORM:MLinux-*-x86_64)
+# qemu Linux guest driver
+# XXX test this
+#GALLIUM_DRIVERS+=	virgl
+#PLIST.virgl=		yes
+.  endif
+# theoretically cross platform PCI drivers
+.  if empty(MACHINE_PLATFORM:MNetBSD-*-*arm*) && \
+      empty(MACHINE_PLATFORM:MNetBSD-*-mipsel)
+DRI_DRIVERS+=		r100 r200
+GALLIUM_DRIVERS+=	r300
+PLIST.r100=		yes
+PLIST.r200=		yes
+PLIST.r300=		yes
+.  endif
+.  include "../../multimedia/libva/available.mk"
+.  if ${VAAPI_AVAILABLE} == "yes" && \
+      !(empty(GALLIUM_DRIVERS:Mr600) && empty(GALLIUM_DRIVERS:Mradeonsi) && \
+        empty(GALLIUM_DRIVERS:Mnouveau))
+MESON_ARGS+=		-Dgallium-va=enabled
+PLIST.vaapi=		yes
+BUILDLINK_API_DEPENDS.libva+=	libva>=2.13.0
+.    include "../../multimedia/libva/buildlink3.mk"
+.  else
+MESON_ARGS+=		-Dgallium-va=disabled
+.  endif
+.else
+MESON_ARGS+=		-Degl=false
+MESON_ARGS+=		-Dgbm=false
+.endif # ${MESALIB_SUPPORTS_DRI} == "yes"
+
+MESON_ARGS+=	-Dgallium-drivers=${GALLIUM_DRIVERS:ts,}
+#MESON_ARGS+=	-Ddri-drivers=${DRI_DRIVERS:ts,}
+MESON_ARGS+=	-Dvulkan-drivers=${VULKAN_DRIVERS:ts,}
+MESON_ARGS+=	-Dplatforms=${MESA_PLATFORMS:ts,}
+
+.if ${MACHINE_ARCH} == "i386"
+MESON_ARGS+=	-Dglx-read-only-text=true
+CXXFLAGS+=	-march=i586
+.endif
+
+MESON_ARGS+=	-Dgles1=enabled
+MESON_ARGS+=	-Dgles2=enabled
+MESON_ARGS+=	-Dopengl=true
+MESON_ARGS+=	-Dosmesa=true
+MESON_ARGS+=	-Dshared-glapi=enabled
+#MESON_ARGS+=	-Dgallium-xvmc=disabled
+
+CPPFLAGS+=	-DHAVE_NOATEXIT
+CPPFLAGS+=	-DSYSCONFDIR=${PKG_SYSCONFDIR}
+
+TOOL_DEPENDS+=	${PYPKGPREFIX}-mako-[0-9]*:../../devel/py-mako
+TOOL_DEPENDS+=	${PYPKGPREFIX}-yaml>=3.0.0:../../textproc/py-yaml
+
+BUILDLINK_TRANSFORM+=		rm:-Werror=incompatible-pointer-types
+
+# https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1854
+BUILDLINK_TRANSFORM+=		rm:-Werror=return-type
+
+# ../src/intel/perf/gen_perf.c:426:7: error: %m is only allowed in syslog(3) like functions
+BUILDLINK_TRANSFORM+=		rm:-Werror=format
+BUILDLINK_TRANSFORM+=		rm:-Wformat-security
+
+# https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1853
+BUILDLINK_TRANSFORM.SunOS+=	rm:-Wl,--build-id=sha1
+
+# Work around Xorg segfaulting in radeon driver due to wrong alloca being used
+CFLAGS.NetBSD+=		-Dalloca=__builtin_alloca
+CXXFLAGS.NetBSD+=	-Dalloca=__builtin_alloca
+
+EGDIR=		${PREFIX}/share/examples/mesa
+
+CONF_FILES+=	${EGDIR}/00-mesa-defaults.conf ${PKG_SYSCONFDIR}/drirc
+
+INSTALLATION_DIRS+=	${EGDIR}
+
+PYTHON_FOR_BUILD_ONLY=		tool
+PYTHON_VERSIONS_INCOMPATIBLE=	27
+
+PKGCONFIG_OVERRIDE_STAGE=	pre-install
+PKGCONFIG_OVERRIDE+=		output/meson-private/glesv1_cm.pc
+PKGCONFIG_OVERRIDE+=		output/meson-private/glesv2.pc
+PKGCONFIG_OVERRIDE+=		output/meson-private/dri.pc
+PKGCONFIG_OVERRIDE+=		output/meson-private/gbm.pc
+PKGCONFIG_OVERRIDE+=		output/meson-private/egl.pc
+PKGCONFIG_OVERRIDE+=		output/meson-private/osmesa.pc
+PKGCONFIG_OVERRIDE+=		output/meson-private/xatracker.pc
+PKGCONFIG_OVERRIDE+=		output/meson-private/gl.pc
+
+post-install:
+	${MV} ${DESTDIR}${PREFIX}/share/drirc.d/00-mesa-defaults.conf ${DESTDIR}${EGDIR}
+.if ${OPSYS} == "Darwin"
+	install_name_tool -id ${PREFIX}/lib/dri/swrast_dri.so \
+	    ${DESTDIR}${PREFIX}/lib/dri/swrast_dri.so
+.endif
+
+.include "../../devel/meson/build.mk"
+.include "../../devel/zlib/buildlink3.mk"
+.include "../../lang/python/batteries-included.mk"
+.include "../../lang/python/tool.mk"
+.include "../../textproc/expat/buildlink3.mk"
+.include "../../mk/atomic64.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/mesa/PLIST b/mesa/PLIST
new file mode 100644
index 0000000000..9e87fc7c38
--- /dev/null
+++ b/mesa/PLIST
@@ -0,0 +1,142 @@
+@comment $NetBSD: PLIST,v 1.49 2022/08/02 20:36:51 tnn Exp $
+${PLIST.kms}include/EGL/egl.h
+${PLIST.kms}include/EGL/eglext.h
+${PLIST.kms}include/EGL/eglext_angle.h
+${PLIST.kms}include/EGL/eglmesaext.h
+${PLIST.kms}include/EGL/eglplatform.h
+include/GL/gl.h
+include/GL/glcorearb.h
+include/GL/glext.h
+${PLIST.glx}include/GL/glx.h
+${PLIST.glx}include/GL/glxext.h
+include/GL/internal/dri_interface.h
+include/GL/osmesa.h
+include/GLES/egl.h
+include/GLES/gl.h
+include/GLES/glext.h
+include/GLES/glplatform.h
+include/GLES2/gl2.h
+include/GLES2/gl2ext.h
+include/GLES2/gl2platform.h
+include/GLES3/gl3.h
+include/GLES3/gl31.h
+include/GLES3/gl32.h
+include/GLES3/gl3ext.h
+include/GLES3/gl3platform.h
+include/KHR/khrplatform.h
+${PLIST.kms}include/gbm.h
+${PLIST.xa}include/xa_composite.h
+${PLIST.xa}include/xa_context.h
+${PLIST.xa}include/xa_tracker.h
+${PLIST.arm}lib/dri/armada-drm_dri.so
+${PLIST.arm}lib/dri/exynos_dri.so
+${PLIST.arm}lib/dri/gm12u320_dri.so
+${PLIST.arm}lib/dri/hdlcd_dri.so
+${PLIST.arm}lib/dri/hx8357d_dri.so
+${PLIST.arm}lib/dri/ili9163_dri.so
+${PLIST.arm}lib/dri/ili9225_dri.so
+${PLIST.arm}lib/dri/ili9341_dri.so
+${PLIST.arm}lib/dri/ili9486_dri.so
+${PLIST.arm}lib/dri/imx-dcss_dri.so
+${PLIST.arm}lib/dri/imx-drm_dri.so
+${PLIST.arm}lib/dri/imx-lcdif_dri.so
+${PLIST.arm}lib/dri/ingenic-drm_dri.so
+${PLIST.iris}lib/dri/iris_dri.so
+${PLIST.arm}lib/dri/kirin_dri.so
+${PLIST.kms}lib/dri/kms_swrast_dri.so
+${PLIST.arm}lib/dri/komeda_dri.so
+lib/dri/libdril_dri.so
+${PLIST.arm}lib/dri/lima_dri.so
+${PLIST.arm}lib/dri/mali-dp_dri.so
+${PLIST.arm}lib/dri/mcde_dri.so
+${PLIST.arm}lib/dri/mediatek_dri.so
+${PLIST.arm}lib/dri/meson_dri.so
+${PLIST.arm}lib/dri/mi0283qt_dri.so
+${PLIST.arm}lib/dri/mxsfb-drm_dri.so
+${PLIST.arm}lib/dri/panel-mipi-dbi_dri.so
+${PLIST.nouveau}lib/dri/nouveau_dri.so
+${PLIST.nouveau}${PLIST.vaapi}lib/dri/nouveau_drv_video.so
+${PLIST.arm}lib/dri/panfrost_dri.so
+${PLIST.arm}lib/dri/panthor_dri.so
+${PLIST.arm}lib/dri/pl111_dri.so
+${PLIST.r300}lib/dri/r300_dri.so
+${PLIST.r600}lib/dri/r600_dri.so
+${PLIST.r600}${PLIST.vaapi}lib/dri/r600_drv_video.so
+${PLIST.radeonsi}lib/dri/radeonsi_dri.so
+${PLIST.r600}${PLIST.vaapi}lib/dri/radeonsi_drv_video.so
+${PLIST.arm}lib/dri/rcar-du_dri.so
+${PLIST.arm}lib/dri/repaper_dri.so
+${PLIST.arm}lib/dri/rockchip_dri.so
+${PLIST.arm}lib/dri/rzg2l-du_dri.so
+${PLIST.arm}lib/dri/ssd130x_dri.so
+${PLIST.arm}lib/dri/st7586_dri.so
+${PLIST.arm}lib/dri/st7735r_dri.so
+${PLIST.arm}lib/dri/sti_dri.so
+${PLIST.arm}lib/dri/stm_dri.so
+${PLIST.arm}lib/dri/sun4i-drm_dri.so
+lib/dri/swrast_dri.so
+${PLIST.arm}lib/dri/udl_dri.so
+${PLIST.arm}lib/dri/vkms_dri.so
+${PLIST.svga}lib/dri/vmwgfx_dri.so
+${PLIST.arm}lib/dri/zynqmp-dpsub_dri.so
+lib/gbm/dri_gbm.so
+${PLIST.kms}lib/libEGL.so
+${PLIST.kms}lib/libEGL.so.1
+${PLIST.kms}lib/libEGL.so.1.0.0
+${PLIST.glx}lib/libGL.so
+${PLIST.glx}lib/libGL.so.1
+${PLIST.glx}lib/libGL.so.${GLVER}
+lib/libGLESv1_CM.so
+lib/libGLESv1_CM.so.1
+lib/libGLESv1_CM.so.1.1.0
+lib/libGLESv2.so
+lib/libGLESv2.so.2
+lib/libGLESv2.so.2.0.0
+lib/libOSMesa.so
+lib/libOSMesa.so.8
+lib/libOSMesa.so.8.0.0
+lib/libgallium-24.3.4.so
+${PLIST.kms}lib/libgbm.so
+${PLIST.kms}lib/libgbm.so.1
+${PLIST.kms}lib/libgbm.so.1.0.0
+lib/libglapi.so
+lib/libglapi.so.0
+lib/libglapi.so.0.0.0
+${PLIST.vulkan}${PLIST.arm}lib/libvulkan_broadcom.so
+${PLIST.vulkan}${PLIST.arm}lib/libvulkan_freedreno.so
+${PLIST.vulkan_intel}lib/libvulkan_intel.so
+${PLIST.vulkan}lib/libvulkan_lvp.so
+${PLIST.vulkan}lib/libvulkan_radeon.so
+${PLIST.xa}lib/libxatracker.so
+${PLIST.xa}lib/libxatracker.so.2
+${PLIST.xa}lib/libxatracker.so.2.5.0
+lib/pkgconfig/dri.pc
+${PLIST.kms}lib/pkgconfig/egl.pc
+${PLIST.kms}lib/pkgconfig/gbm.pc
+${PLIST.glx}lib/pkgconfig/gl.pc
+lib/pkgconfig/glesv1_cm.pc
+lib/pkgconfig/glesv2.pc
+lib/pkgconfig/osmesa.pc
+${PLIST.xa}lib/pkgconfig/xatracker.pc
+${PLIST.nouveau}${PLIST.vdpau}lib/vdpau/libvdpau_nouveau.so
+${PLIST.nouveau}${PLIST.vdpau}lib/vdpau/libvdpau_nouveau.so.1
+${PLIST.nouveau}${PLIST.vdpau}lib/vdpau/libvdpau_nouveau.so.1.0
+${PLIST.nouveau}${PLIST.vdpau}lib/vdpau/libvdpau_nouveau.so.1.0.0
+${PLIST.r300}${PLIST.vdpau}lib/vdpau/libvdpau_r300.so
+${PLIST.r300}${PLIST.vdpau}lib/vdpau/libvdpau_r300.so.1
+${PLIST.r300}${PLIST.vdpau}lib/vdpau/libvdpau_r300.so.1.0
+${PLIST.r300}${PLIST.vdpau}lib/vdpau/libvdpau_r300.so.1.0.0
+${PLIST.r600}${PLIST.vdpau}lib/vdpau/libvdpau_r600.so
+${PLIST.r600}${PLIST.vdpau}lib/vdpau/libvdpau_r600.so.1
+${PLIST.r600}${PLIST.vdpau}lib/vdpau/libvdpau_r600.so.1.0
+${PLIST.r600}${PLIST.vdpau}lib/vdpau/libvdpau_r600.so.1.0.0
+${PLIST.radeonsi}${PLIST.vdpau}lib/vdpau/libvdpau_radeonsi.so
+${PLIST.radeonsi}${PLIST.vdpau}lib/vdpau/libvdpau_radeonsi.so.1
+${PLIST.radeonsi}${PLIST.vdpau}lib/vdpau/libvdpau_radeonsi.so.1.0
+${PLIST.radeonsi}${PLIST.vdpau}lib/vdpau/libvdpau_radeonsi.so.1.0.0
+share/examples/mesa/00-mesa-defaults.conf
+${PLIST.vulkan}${PLIST.arm}share/vulkan/icd.d/broadcom_icd.${MACHINE_ARCH}.json
+${PLIST.vulkan}${PLIST.arm}share/vulkan/icd.d/freedreno_icd.${MACHINE_ARCH}.json
+${PLIST.vulkan_intel}share/vulkan/icd.d/intel_icd.${MACHINE_ARCH}.json
+${PLIST.vulkan}share/vulkan/icd.d/lvp_icd.${MACHINE_ARCH}.json
+${PLIST.vulkan}share/vulkan/icd.d/radeon_icd.${MACHINE_ARCH}.json
diff --git a/mesa/buildlink3.mk b/mesa/buildlink3.mk
new file mode 100644
index 0000000000..79f5628307
--- /dev/null
+++ b/mesa/buildlink3.mk
@@ -0,0 +1,43 @@
+# $NetBSD: buildlink3.mk,v 1.68 2023/08/14 05:24:30 wiz Exp $
+
+BUILDLINK_TREE+=	MesaLib
+
+.if !defined(MESALIB_BUILDLINK3_MK)
+MESALIB_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.MesaLib+=	MesaLib>=3.4.2
+BUILDLINK_ABI_DEPENDS.MesaLib+=	MesaLib>=21.3.9nb3
+BUILDLINK_PKGSRCDIR.MesaLib?=	../../graphics/MesaLib
+
+.include "../../graphics/MesaLib/features.mk"
+
+# See <http://developer.apple.com/qa/qa2007/qa1567.html>.
+.if ${X11_TYPE} == "native" && !empty(MACHINE_PLATFORM:MDarwin-[9].*-*)
+BUILDLINK_LDFLAGS.MesaLib+=	-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
+.endif
+
+pkgbase:= MesaLib
+
+.include "../../mk/pkg-build-options.mk"
+
+.if !empty(PKG_BUILD_OPTIONS.MesaLib:Mx11)
+.  include "../../x11/libX11/buildlink3.mk"
+.  include "../../x11/libXdamage/buildlink3.mk"
+.  include "../../x11/libXext/buildlink3.mk"
+.  include "../../x11/libXfixes/buildlink3.mk"
+.  include "../../x11/libXrandr/buildlink3.mk"
+.  include "../../x11/libXxf86vm/buildlink3.mk"
+.  include "../../x11/libxcb/buildlink3.mk"
+.  include "../../x11/libxshmfence/buildlink3.mk"
+.  include "../../x11/xcb-proto/buildlink3.mk"
+.  include "../../x11/xorgproto/buildlink3.mk"
+.endif
+
+.if ${MESALIB_SUPPORTS_DRI} == "yes"
+.  include "../../x11/libdrm/buildlink3.mk"
+.endif
+
+.include "../../mk/pthread.buildlink3.mk"
+.endif # MESALIB_BUILDLINK3_MK
+
+BUILDLINK_TREE+=	-MesaLib
diff --git a/mesa/builtin.mk b/mesa/builtin.mk
new file mode 100644
index 0000000000..b2c566d8e0
--- /dev/null
+++ b/mesa/builtin.mk
@@ -0,0 +1,89 @@
+# $NetBSD: builtin.mk,v 1.23 2019/08/30 19:06:34 nia Exp $
+
+BUILTIN_PKG:=	MesaLib
+
+BUILTIN_FIND_FILES_VAR:=	H_MESALIB PC_GL
+BUILTIN_FIND_FILES.H_MESALIB=	${X11BASE}/include/GL/glx.h
+BUILTIN_FIND_FILES.PC_GL=	${X11BASE}/lib/pkgconfig/gl.pc
+BUILTIN_FIND_FILES.PC_GL+=	${X11BASE}/lib${LIBABISUFFIX}/pkgconfig/gl.pc
+
+.include "../../mk/buildlink3/bsd.builtin.mk"
+
+###
+### Determine if there is a built-in implementation of the package and
+### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
+###
+.if !defined(IS_BUILTIN.MesaLib)
+.  if empty(PC_GL:M__nonexistent__)
+IS_BUILTIN.MesaLib=	yes
+.  elif empty(H_MESALIB:M__nonexistent__)
+IS_BUILTIN.MesaLib=	yes
+.  else
+IS_BUILTIN.MesaLib=	no
+.  endif
+.endif
+
+MAKEVARS+=	IS_BUILTIN.MesaLib
+
+###
+### If there is a built-in implementation, then set BUILTIN_PKG.<pkg> to
+### a package name to represent the built-in package.
+###
+.if !defined(BUILTIN_PKG.MesaLib) && \
+    !empty(IS_BUILTIN.MesaLib:M[yY][eE][sS])
+.  if empty(PC_GL:M__nonexistent__)
+BUILTIN_VERSION.Mesa!= ${SED} -n -e 's/Version: //p' ${PC_GL}
+.  elif empty(H_MESALIB:M__nonexistent__)
+.    include "version.mk"
+.  else # ?
+BUILTIN_VERSION.Mesa:= 0.something-weird-happened
+.  endif
+BUILTIN_PKG.MesaLib=	MesaLib-${BUILTIN_VERSION.Mesa}
+MAKEVARS+=	BUILTIN_VERSION.Mesa
+.endif
+MAKEVARS+=	BUILTIN_PKG.MesaLib
+
+###
+### Determine whether we should use the built-in implementation if it
+### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
+###
+.if !defined(USE_BUILTIN.MesaLib)
+.  if ${PREFER.MesaLib} == "pkgsrc"
+USE_BUILTIN.MesaLib=	no
+.  else
+USE_BUILTIN.MesaLib=	${IS_BUILTIN.MesaLib}
+.    if defined(BUILTIN_PKG.MesaLib) && \
+        !empty(IS_BUILTIN.MesaLib:M[yY][eE][sS])
+USE_BUILTIN.MesaLib=	yes
+.      for dep in ${BUILDLINK_API_DEPENDS.MesaLib}
+.        if !empty(USE_BUILTIN.MesaLib:M[yY][eE][sS])
+USE_BUILTIN.MesaLib!=							\
+	if ${PKG_ADMIN} pmatch ${dep:Q} ${BUILTIN_PKG.MesaLib}; then \
+		${ECHO} yes;						\
+	else								\
+		${ECHO} no;						\
+	fi
+.        endif
+.      endfor
+.    endif
+.  endif  # PREFER.MesaLib
+.endif
+
+MAKEVARS+=	USE_BUILTIN.MesaLib
+
+###
+### The section below only applies if we are not including this file
+### solely to determine whether a built-in implementation exists.
+###
+CHECK_BUILTIN.MesaLib?=	no
+.if !empty(CHECK_BUILTIN.MesaLib:M[nN][oO])
+
+.  if !empty(USE_BUILTIN.MesaLib:M[nN][oO])
+.    include "../../mk/pthread.buildlink3.mk"
+.    include "../../mk/pthread.builtin.mk"
+BUILTIN_PKG:=	MesaLib
+.  endif
+
+.  include "../../mk/x11.builtin.mk"
+
+.endif	# CHECK_BUILTIN.MesaLib
diff --git a/mesa/distinfo b/mesa/distinfo
new file mode 100644
index 0000000000..17a8e6cac1
--- /dev/null
+++ b/mesa/distinfo
@@ -0,0 +1,12 @@
+$NetBSD: distinfo,v 1.166 2023/07/18 19:33:31 ryoon Exp $
+
+BLAKE2s (mesa-24.3.4.tar.xz) = b20694d859f021fda01b2dbfd3b36b0020d5fd34bcc5037ba4d4ce11eab3d1d3
+SHA512 (mesa-24.3.4.tar.xz) = 9c23cd86fda4cf0289c5a78b08ceea8b01e5b141d86ee3e659fa46e62ff9586ff92a4984d2a340b5bf209c4c7f3414bf99f3ced19feee8fb39ef99fe572dbd55
+Size (mesa-24.3.4.tar.xz) = 30691532 bytes
+SHA1 (patch-src_egl_drivers_dri2_platform__drm.c) = c982acaf2246858a06a52f548b6103800c0d7c45
+SHA1 (patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c) = c6958cf29da9154c673f8c64790ac2bb46ed74bd
+SHA1 (patch-src_gallium_drivers_r600_sfn_sfn__valuefactory.cpp) = 14a0bc9f0cb7d0f4bc7ba8de49cf162af4e27ddf
+SHA1 (patch-src_glx_glxclient.h) = 4812c1b17bfff6cb43192790aa5cfee5c6c3149d
+SHA1 (patch-src_glx_glxcurrent.c) = 38de869a62f3c20b44a0e6cbd3046953f4f2542d
+SHA1 (patch-src_util_build__id.c) = 7a9547bbda9d2fb9f0018ccf27b70b59e497aa2c
+SHA1 (patch-src_util_os__file.c) = 6761051028c97f763075fd7526373e9fa131be08
diff --git a/mesa/features.mk b/mesa/features.mk
new file mode 100644
index 0000000000..e27ce23083
--- /dev/null
+++ b/mesa/features.mk
@@ -0,0 +1,48 @@
+# $NetBSD: features.mk,v 1.2 2023/07/10 03:16:45 pho Exp $
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+.if !defined(MESALIB_SUPPORTS_DRI)
+.  for dri_os in DragonFly FreeBSD NetBSD OpenBSD Linux SunOS
+.    if !empty(OPSYS:M${dri_os})
+MESALIB_SUPPORTS_DRI?=		yes
+.    endif
+.  endfor
+.endif
+
+MESALIB_SUPPORTS_DRI?=		no
+
+_MESALIB_ARCH_SUPPORTS_XA?=	no # Only for graphics/MesaLib/Makefile
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" || \
+    ${MACHINE_ARCH:M*arm*} || ${MACHINE_ARCH} == "aarch64"
+_MESALIB_ARCH_SUPPORTS_XA=	yes
+.endif
+
+.if ${X11_TYPE} == "modular"
+MESALIB_SUPPORTS_OSMESA?=	yes
+MESALIB_SUPPORTS_GLESv2?=	yes
+.  if ${MESALIB_SUPPORTS_DRI} == "yes"
+MESALIB_SUPPORTS_EGL?=		yes
+.    if ${_MESALIB_ARCH_SUPPORTS_XA} == "yes"
+MESALIB_SUPPORTS_XA?=		yes
+.    endif
+.  endif
+.else
+.  if exists(${X11BASE}/include/EGL/egl.h)
+MESALIB_SUPPORTS_EGL?=		yes
+.  endif
+.  if exists(${X11BASE}/lib/libOSMesa.so)
+MESALIB_SUPPORTS_OSMESA?=	yes
+.  endif
+.  if exists(${X11BASE}/include/GLES2/gl2.h)
+MESALIB_SUPPORTS_GLESv2?=	yes
+.  endif
+.  if exists(${X11BASE}/include/xa_tracker.h)
+MESALIB_SUPPORTS_XA?=		yes
+.  endif
+.endif
+
+MESALIB_SUPPORTS_EGL?=		no
+MESALIB_SUPPORTS_GLESv2?=	no
+MESALIB_SUPPORTS_OSMESA?=	no
+MESALIB_SUPPORTS_XA?=		no
diff --git a/mesa/options.mk b/mesa/options.mk
new file mode 100644
index 0000000000..f650b945e8
--- /dev/null
+++ b/mesa/options.mk
@@ -0,0 +1,152 @@
+# $NetBSD: options.mk,v 1.85 2023/07/19 18:32:49 tnn Exp $
+
+PKG_OPTIONS_VAR=		PKG_OPTIONS.MesaLib
+
+.include "features.mk"
+
+PKG_SUPPORTED_OPTIONS+=		llvm vulkan x11
+.if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 109904
+# Thread local storage dispatch not supported here due to ld.elf_so too old.
+.else
+PKG_SUPPORTED_OPTIONS+=		elf-tls
+.endif
+
+.if ${MESALIB_SUPPORTS_DRI} == "yes"
+PKG_SUPPORTED_OPTIONS+=		wayland
+.  include "../../devel/wayland/platform.mk"
+.  if ${PLATFORM_SUPPORTS_WAYLAND} == "yes"
+PKG_SUGGESTED_OPTIONS+=		wayland
+.  endif
+.endif
+
+PKG_SUGGESTED_OPTIONS+=		x11
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+# The LLVM option enables JIT accelerated software rendering and is also
+# required to support the latest RADEON GPUs.
+#
+# Enable it by default on platforms where such GPUs might be encountered or
+# LLVM-accelerated software rendering might be useful.
+.if ${MESALIB_SUPPORTS_DRI} == "yes" && \
+    ${OPSYS} != "SunOS" && \
+      (${MACHINE_ARCH} == "i386" || \
+       ${MACHINE_ARCH} == "x86_64" || \
+       ${MACHINE_ARCH} == "aarch64")
+PKG_SUGGESTED_OPTIONS+=		llvm
+.endif
+
+# ELF TLS is broken in at least the following cases:
+# - NetBSD with SDL2 without X11
+# - FreeBSD - https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3559
+# - Linux with musl libc
+#
+# https://gitlab.freedesktop.org/mesa/mesa/issues/966
+.if ${OPSYS} == "Linux" && !empty(GLIBC_VERSION)
+PKG_SUGGESTED_OPTIONS+=		elf-tls
+.endif
+
+.include "../../mk/bsd.options.mk"
+
+# Gallium drivers requiring LLVM
+PLIST_VARS+=	r600 radeonsi
+
+# Windowing systems
+PLIST_VARS+=	glx
+
+# Misc. features
+PLIST_VARS+=	vdpau
+
+#
+# ELF TLS support
+#
+.if empty(PKG_OPTIONS:Melf-tls)
+BUILDLINK_TRANSFORM+=	rm:-DUSE_ELF_TLS
+.endif
+
+#
+# LLVM support
+#
+.if !empty(PKG_OPTIONS:Mllvm)
+MESON_ARGS+=		-Dllvm=enabled
+.  include "../../devel/libelf/buildlink3.mk"
+.  include "../../lang/llvm/buildlink3.mk"
+.  include "../../wip/libclc/buildlink3.mk"
+.  include "../../wip/spirv-tools/buildlink3.mk"
+.  include "../../lang/libunwind/buildlink3.mk"
+.  include "../../lang/clang/buildlink3.mk"
+
+GALLIUM_DRIVERS+=	llvmpipe
+.  if ${OPSYS} != "Darwin" && ${OPSYS} != "Cygwin"
+# This is the latest libdrm requirement for amdgpu.
+BUILDLINK_API_DEPENDS.libdrm+=	libdrm>=2.4.107
+
+PLIST.r600=		yes
+GALLIUM_DRIVERS+=	r600 iris
+PLIST.radeonsi=		yes
+PLIST.iris=		yes
+GALLIUM_DRIVERS+=	radeonsi
+.  endif
+.else
+MESON_ARGS+=		-Dllvm=disabled
+.endif
+
+#
+# Vulkan support - experimental
+#
+PLIST_VARS+=		 vulkan vulkan_intel
+.if !empty(PKG_OPTIONS:Mvulkan)
+VULKAN_DRIVERS+=	amd
+VULKAN_DRIVERS+=	swrast
+PLIST.vulkan=		yes
+.  if ${MACHINE_ARCH} == "x86_64"
+VULKAN_DRIVERS+=	intel
+PLIST.vulkan_intel=	yes
+.  endif
+.  if ${MACHINE_ARCH} == "aarch64"
+VULKAN_DRIVERS+=	broadcom
+VULKAN_DRIVERS+=	freedreno
+.  endif
+.endif
+
+#
+# X11 support
+#
+.if !empty(PKG_OPTIONS:Mx11)
+MESA_PLATFORMS+=	x11
+PLIST.glx=		yes
+.  if ${MESALIB_SUPPORTS_DRI} == "yes"
+MESON_ARGS+=		-Dglx=dri
+#.    include "../../multimedia/libvdpau/available.mk"
+#.    if ${VDPAU_AVAILABLE} == "yes"
+#MESON_ARGS+=		-Dgallium-vdpau=enabled
+#PLIST.vdpau=		yes
+#.      include "../../multimedia/libvdpau/buildlink3.mk"
+#.    else
+MESON_ARGS+=		-Dgallium-vdpau=disabled
+#.    endif
+.  endif
+.  include "../../x11/libX11/buildlink3.mk"
+.  include "../../x11/libXdamage/buildlink3.mk"
+.  include "../../x11/libXext/buildlink3.mk"
+.  include "../../x11/libXfixes/buildlink3.mk"
+.  include "../../x11/libXrandr/buildlink3.mk"
+.  include "../../x11/libXxf86vm/buildlink3.mk"
+.  include "../../x11/libxcb/buildlink3.mk"
+.  include "../../x11/libxshmfence/buildlink3.mk"
+.  include "../../x11/xcb-proto/buildlink3.mk"
+.  include "../../x11/xorgproto/buildlink3.mk"
+.else
+MESON_ARGS+=		-Dglx=disabled
+MESON_ARGS+=		-Dgallium-vdpau=disabled
+.endif
+
+#
+# Wayland support
+#
+.if !empty(PKG_OPTIONS:Mwayland)
+MESA_PLATFORMS+=	wayland
+.  include "../../devel/wayland/buildlink3.mk"
+.  include "../../devel/wayland-protocols/buildlink3.mk"
+.endif
+
diff --git a/mesa/patches/patch-src_egl_drivers_dri2_platform__drm.c b/mesa/patches/patch-src_egl_drivers_dri2_platform__drm.c
new file mode 100644
index 0000000000..bd8ade0a28
--- /dev/null
+++ b/mesa/patches/patch-src_egl_drivers_dri2_platform__drm.c
@@ -0,0 +1,16 @@
+$NetBSD$
+
+--- src/egl/drivers/dri2/platform_drm.c.orig	2025-05-02 17:22:18.878824432 +0000
++++ src/egl/drivers/dri2/platform_drm.c
+@@ -523,9 +523,8 @@ drm_add_configs_for_visuals(_EGLDisplay 
+ 
+    for (unsigned i = 0; i < ARRAY_SIZE(format_count); i++) {
+       if (!format_count[i]) {
+-         struct gbm_format_name_desc desc;
+-         _eglLog(_EGL_DEBUG, "No DRI config supports native format %s",
+-                 gbm_format_get_name(visuals[i].gbm_format, &desc));
++         _eglLog(_EGL_DEBUG, "No DRI config supports native format 0x%x",
++                 visuals[i].gbm_format);
+       }
+    }
+ }
diff --git a/mesa/patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c b/mesa/patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c
new file mode 100644
index 0000000000..7a4397763f
--- /dev/null
+++ b/mesa/patches/patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c
@@ -0,0 +1,127 @@
+$NetBSD: patch-src_gallium_auxiliary_pipe-loader_pipe__loader__drm.c,v 1.1 2019/08/21 13:35:28 nia Exp $
+
+* From FreeBSD ports / DragonFly dports graphics/mesa-dri
+
+Revert the following commit.
+
+FreeBSD and DragonFly don't have the required render nodes.
+
+-------
+
+From 69a1b9959e59653da262185c4e2cf57d24939b19 Mon Sep 17 00:00:00 2001
+Date: Mon, 29 Jun 2015 12:36:45 +0100
+Subject: pipe-loader: drop support for non-render node devices
+
+Render nodes have been around for quite some time. Removing support via
+the master/primary node allows us to clean up the conditional
+compilation and simplify the build greatly.
+
+For example currently we the pipe-loader, which explicitly links against
+xcb and friends (for X auth) if found at compile-time. That
+would cause problems as one will be forced to use X/xcb, even if it's a
+headless system that is used for opencl.
+
+v2: Clarify the linking topic in the commit message.
+
+* Extended for NetBSD.
+
+--- src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c.orig	2025-01-22 18:12:23.000000000 +0000
++++ src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+@@ -239,6 +239,16 @@ pipe_loader_drm_probe_fd(struct pipe_loa
+    return ret;
+ }
+ 
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__NetBSD__)
++static int
++open_drm_minor(int minor)
++{
++   char path[PATH_MAX];
++   snprintf(path, sizeof(path), DRM_DEV_NAME, DRM_DIR_NAME, minor);
++   return open(path, O_RDWR, 0);
++}
++#endif
++
+ static int
+ open_drm_render_node_minor(int minor)
+ {
+@@ -251,7 +261,19 @@ open_drm_render_node_minor(int minor)
+ static int
+ pipe_loader_drm_probe_internal(struct pipe_loader_device **devs, int ndev, bool zink)
+ {
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__NetBSD__)
++   int i, k, fd, num_render_node_devs;
++   int j = 0;
++
++   struct {
++      unsigned vendor_id;
++      unsigned chip_id;
++   } render_node_devs[DRM_RENDER_NODE_MAX_NODES];
++
++   /* Look for render nodes first */
++#else
+    int i, j, fd;
++#endif
+ 
+    for (i = DRM_RENDER_NODE_MIN_MINOR, j = 0;
+         i <= DRM_RENDER_NODE_MAX_MINOR; i++) {
+@@ -266,6 +288,11 @@ pipe_loader_drm_probe_internal(struct pi
+          continue;
+       }
+ 
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__NetBSD__)
++      render_node_devs[j].vendor_id = dev->u.pci.vendor_id;
++      render_node_devs[j].chip_id = dev->u.pci.chip_id;
++
++#endif
+       if (j < ndev) {
+          devs[j] = dev;
+       } else {
+@@ -275,6 +302,48 @@ pipe_loader_drm_probe_internal(struct pi
+       j++;
+    }
+ 
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__NetBSD__)
++   num_render_node_devs = j;
++
++   /* Next look for drm devices. */
++   for (i = 0; i < DRM_MAX_MINOR; i++) {
++      struct pipe_loader_device *dev;
++      bool duplicate = false;
++      fd = open_drm_minor(i);
++      if (fd < 0)
++         continue;
++
++      if (!pipe_loader_drm_probe_fd(&dev, fd, zink)) {
++         close(fd);
++         continue;
++      }
++
++      /* Check to make sure we aren't already accessing this device via
++       * render nodes.
++       */
++      for (k = 0; k < num_render_node_devs; k++) {
++         if (dev->u.pci.vendor_id == render_node_devs[k].vendor_id &&
++             dev->u.pci.chip_id == render_node_devs[k].chip_id) {
++            close(fd);
++            dev->ops->release(&dev);
++            duplicate = true;
++            break;
++         }
++      }
++
++      if (duplicate)
++         continue;
++
++      if (j < ndev) {
++         devs[j] = dev;
++      } else {
++         dev->ops->release(&dev);
++      }
++
++      j++;
++   }
++
++#endif
+    return j;
+ }
+ 
diff --git a/mesa/patches/patch-src_gallium_drivers_r600_sfn_sfn__valuefactory.cpp b/mesa/patches/patch-src_gallium_drivers_r600_sfn_sfn__valuefactory.cpp
new file mode 100644
index 0000000000..92649817ed
--- /dev/null
+++ b/mesa/patches/patch-src_gallium_drivers_r600_sfn_sfn__valuefactory.cpp
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- src/gallium/drivers/r600/sfn/sfn_valuefactory.cpp.orig	2025-04-30 18:31:25.098356269 +0000
++++ src/gallium/drivers/r600/sfn/sfn_valuefactory.cpp
+@@ -12,6 +12,7 @@
+ 
+ #include <algorithm>
+ #include <iostream>
++#include <limits>
+ #include <queue>
+ #include <sstream>
+ 
diff --git a/mesa/patches/patch-src_glx_glxclient.h b/mesa/patches/patch-src_glx_glxclient.h
new file mode 100644
index 0000000000..086dba550b
--- /dev/null
+++ b/mesa/patches/patch-src_glx_glxclient.h
@@ -0,0 +1,19 @@
+$NetBSD: patch-src_glx_glxclient.h,v 1.3 2022/03/13 15:50:05 tnn Exp $
+
+NetBSD only supports zero-initialized initial-exec tls variables in conjuction
+with dlopen(3) at the moment.
+
+--- src/glx/glxclient.h.orig	2025-01-22 18:12:23.000000000 +0000
++++ src/glx/glxclient.h
+@@ -648,7 +648,11 @@ extern void __glXSetCurrentContext(struc
+ 
+ extern __THREAD_INITIAL_EXEC void *__glX_tls_Context;
+ 
++#if defined(__NetBSD__)
++#  define __glXGetCurrentContext() (likely(__glX_tls_Context) ? __glX_tls_Context : (void*)&dummyContext)
++#else
+ #  define __glXGetCurrentContext() __glX_tls_Context
++#endif
+ 
+ extern void __glXSetCurrentContextNull(void);
+ 
diff --git a/mesa/patches/patch-src_glx_glxcurrent.c b/mesa/patches/patch-src_glx_glxcurrent.c
new file mode 100644
index 0000000000..160100a8bc
--- /dev/null
+++ b/mesa/patches/patch-src_glx_glxcurrent.c
@@ -0,0 +1,19 @@
+$NetBSD: patch-src_glx_glxcurrent.c,v 1.6 2023/07/18 19:33:31 ryoon Exp $
+
+NetBSD only supports zero-initialized initial-exec tls variables in conjuction
+with dlopen(3) at the moment.
+
+--- src/glx/glxcurrent.c.orig	2021-08-04 18:49:29.150474000 +0000
++++ src/glx/glxcurrent.c
+@@ -76,7 +90,11 @@ _X_HIDDEN pthread_mutex_t __glXmutex = P
+  * \b never be \c NULL.  This is important!  Because of this
+  * \c __glXGetCurrentContext can be implemented as trivial macro.
+  */
++#if defined(__NetBSD__)
++__THREAD_INITIAL_EXEC void *__glX_tls_Context = NULL; /* non-zero initializers not supported with dlopen */
++#else
+ __THREAD_INITIAL_EXEC void *__glX_tls_Context = &dummyContext;
++#endif
+ 
+ _X_HIDDEN void
+ __glXSetCurrentContext(struct glx_context * c)
diff --git a/mesa/patches/patch-src_util_build__id.c b/mesa/patches/patch-src_util_build__id.c
new file mode 100644
index 0000000000..647e40d719
--- /dev/null
+++ b/mesa/patches/patch-src_util_build__id.c
@@ -0,0 +1,25 @@
+$NetBSD: patch-src_util_build__id.c,v 1.1 2019/08/21 13:35:28 nia Exp $
+
+Patch taken from FreeBSD ports graphics/mesa-dri mesa 17.1.0.
+
+# Elf_ doesn't exist, use Elf32_ or Elf64_.
+
+--- src/util/build_id.c.orig	2018-09-07 21:18:07.000000000 +0000
++++ src/util/build_id.c
+@@ -35,7 +35,15 @@
+ #endif
+ 
+ #ifndef ElfW
+-#define ElfW(type) Elf_##type
++# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++#  ifdef __LP64__
++#    define ElfW(type) Elf64_##type
++#  else
++#    define ElfW(type) Elf32_##type
++#  endif /* __LP64__ */
++#  else
++#    define ElfW(type) Elf_##type
++#  endif
+ #endif
+ 
+ struct build_id_note {
diff --git a/mesa/patches/patch-src_util_os__file.c b/mesa/patches/patch-src_util_os__file.c
new file mode 100644
index 0000000000..dd63393f0d
--- /dev/null
+++ b/mesa/patches/patch-src_util_os__file.c
@@ -0,0 +1,35 @@
+$NetBSD$
+
+--- src/util/os_file.c.orig	2025-01-22 18:12:23.000000000 +0000
++++ src/util/os_file.c
+@@ -224,6 +224,10 @@ typedef void *kvaddr_t;
+ 
+ #endif /* DETECT_OS_DRAGONFLY || DETECT_OS_FREEBSD */
+ 
++#if DETECT_OS_NETBSD
++#include <sys/stat.h>
++#endif
++
+ int
+ os_same_file_description(int fd1, int fd2)
+ {
+@@ -263,6 +267,19 @@ os_same_file_description(int fd1, int fd
+       return -1;
+ 
+    return (fd1_kfile < fd2_kfile) | ((fd1_kfile > fd2_kfile) << 1);
++#elif DETECT_OS_NETBSD
++   struct stat st1, st2;
++
++   if (fstat(fd1, &st1) != 0)
++      return -1;
++
++   if (fstat(fd2, &st2) != 0)
++      return -1;
++
++   if ((st1.st_dev == st2.st_dev) && (st1.st_ino == st2.st_ino))
++      return 0;
++   else
++      return 3;
+ #else
+    /* Otherwise we can't tell */
+    return -1;
diff --git a/mesa/version.mk b/mesa/version.mk
new file mode 100644
index 0000000000..7f8b9ab5dd
--- /dev/null
+++ b/mesa/version.mk
@@ -0,0 +1,30 @@
+# $NetBSD: version.mk,v 1.1 2019/08/30 19:06:34 nia Exp $
+#
+# This file computes the version number of the Mesa distributed with
+# XFree86 and stores it in ${BUILTIN_VERSION.Mesa}.
+#
+# NOTE: This file should only be used by the Mesa-related builtin.mk files.
+#
+
+BUILTIN_FIND_FILES_VAR:=	H_MESA
+BUILTIN_FIND_FILES.H_MESA=	${X11BASE}/include/GL/gl.h
+.include "../../mk/buildlink3/find-files.mk"
+.include "../../mk/bsd.fast.prefs.mk"
+.if !defined(BUILTIN_VERSION.Mesa) && exists(${H_MESA})
+#
+# According to the Mesa documentation, for stable releases:
+#
+#	Mesa-6.0 implements OpenGL 1.5,
+#	Mesa-5.0 implements OpenGL 1.4,
+#	Mesa-4.0.4 implements OpenGL 1.3,
+#	Mesa-3.4.2 implements OpenGL 1.2.
+#
+BUILTIN_VERSION.Mesa!=							\
+	${AWK} '/\#define[ 	]*GL_VERSION_1_2/ { v = "3.4.2" }	\
+		/\#define[ 	]*GL_VERSION_1_3/ { v = "4.0.4" }	\
+		/\#define[ 	]*GL_VERSION_1_4/ { v = "5.0" }		\
+		/\#define[ 	]*GL_VERSION_1_5/ { v = "6.0" }		\
+		END { printf "%s\n", v }'				\
+		${H_MESA}
+.endif
+MAKEVARS+=	BUILTIN_VERSION.Mesa


Home | Main Index | Thread Index | Old Index