git: 30a12533e7c4 - main - games/retroarch: fix build on all versions and enable on non-x86

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Tue, 07 Nov 2023 00:22:06 UTC
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=30a12533e7c488b57fa176d3b0bd53903db28520

commit 30a12533e7c488b57fa176d3b0bd53903db28520
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2023-11-06 19:22:04 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-11-07 00:17:29 +0000

    games/retroarch: fix build on all versions and enable on non-x86
    
    Do not depend on svgalib where svgalib is not supported.
    Do not enable code using memfd_create() where that is not supported.
    
    PR:             274647
---
 games/retroarch/Makefile                             |  9 +++++++--
 .../files/patch-gfx_common_wayland__common.c         | 11 +++++++++++
 games/retroarch/files/patch-input_input__keymaps.c   | 20 ++++++++++++++++++++
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/games/retroarch/Makefile b/games/retroarch/Makefile
index b60cd355702f..18d06bac680d 100644
--- a/games/retroarch/Makefile
+++ b/games/retroarch/Makefile
@@ -35,8 +35,13 @@ LDFLAGS_i386=	-Wl,-znotext
 DOCSDIR=	${PREFIX}/share/doc/${PORTNAME:tl}
 SUB_FILES=	pkg-message
 
-OPTIONS_DEFINE=	CACA FFMPEG OSS JACK PULSEAUDIO ALSA SDL OPENGL OPENAL V4L FREETYPE WAYLAND UDEV QT X11 DOCS
-OPTIONS_DEFAULT=FFMPEG OSS SDL OPENGL OPENAL V4L FREETYPE WAYLAND UDEV QT X11
+OPTIONS_DEFINE=	CACA FFMPEG OSS JACK PULSEAUDIO ALSA SDL OPENGL OPENAL V4L FREETYPE UDEV QT X11 DOCS
+OPTIONS_DEFINE_amd64=	WAYLAND	# svgalib is x86 only
+OPTIONS_DEFINE_i386=	WAYLAND
+OPTIONS_DEFAULT=FFMPEG OSS SDL OPENGL OPENAL V4L FREETYPE UDEV QT X11
+OPTIONS_DEFAULT_amd64=	WAYLAND
+OPTIONS_DEFAULT_i386=	WAYLAND
+OPTIONS_EXCLUDE_FreeBSD_12=	WAYLAND	# requires memfd_create()
 FFMPEG_DESC=	On-the-fly recording of gameplay with libavcodec
 WAYLAND_DESC=	Wayland display support
 UDEV_DESC=	udev device hotplug support
diff --git a/games/retroarch/files/patch-gfx_common_wayland__common.c b/games/retroarch/files/patch-gfx_common_wayland__common.c
new file mode 100644
index 000000000000..c964aead462b
--- /dev/null
+++ b/games/retroarch/files/patch-gfx_common_wayland__common.c
@@ -0,0 +1,11 @@
+--- gfx/common/wayland_common.c.orig	2023-11-06 19:16:56 UTC
++++ gfx/common/wayland_common.c
+@@ -419,7 +419,7 @@ bool gfx_ctx_wl_get_metrics_common(void *data,
+ static int create_shm_file(off_t size)
+ {
+    int fd, ret;
+-   if ((fd = syscall(SYS_memfd_create, SPLASH_SHM_NAME,
++   if ((fd = memfd_create(SPLASH_SHM_NAME,
+                MFD_CLOEXEC | MFD_ALLOW_SEALING)) >= 0)
+    {
+       fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK);
diff --git a/games/retroarch/files/patch-input_input__keymaps.c b/games/retroarch/files/patch-input_input__keymaps.c
new file mode 100644
index 000000000000..dae7278b7f58
--- /dev/null
+++ b/games/retroarch/files/patch-input_input__keymaps.c
@@ -0,0 +1,20 @@
+--- input/input_keymaps.c.orig	2023-11-06 19:58:13 UTC
++++ input/input_keymaps.c
+@@ -54,7 +54,7 @@
+ #include "SDL.h"
+ #endif
+ 
+-#if defined(__linux__) || defined(HAVE_WAYLAND)
++#if defined(__linux__) || defined(HAVE_WAYLAND) || defined(__FreeBSD__)
+ #if defined(__linux__)
+ #include <linux/input.h>
+ #include <linux/kd.h>
+@@ -1130,7 +1130,7 @@ const struct rarch_key_map rarch_key_map_x11[] = {
+ };
+ #endif
+ 
+-#if defined(__linux__) || defined(HAVE_WAYLAND)
++#if defined(__linux__) || defined(HAVE_WAYLAND) || defined(__FreeBSD__)
+ /* Note: Only one input can be mapped to each
+  * RETROK_* key. If several physical inputs
+  * correspond to the same key, these inputs