git: 762073ef1e09 - main - games/libretro-desmume: new port

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

URL: https://cgit.FreeBSD.org/ports/commit/?id=762073ef1e09c923950a79265d30e22880f011cf

commit 762073ef1e09c923950a79265d30e22880f011cf
Author:     Stephane D'Alu <sdalu@sdalu.com>
AuthorDate: 2023-10-27 09:12:13 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-11-07 00:16:55 +0000

    games/libretro-desmume: new port
    
    PR:             274647
---
 games/Makefile                                     |  1 +
 games/libretro-desmume/Makefile                    | 39 ++++++++++++++++++++++
 games/libretro-desmume/distinfo                    |  3 ++
 ...me_src_libretro-common_features_features__cpu.c | 11 ++++++
 ...desmume_src_libretro-common_rthreads_rthreads.c | 11 ++++++
 games/libretro-desmume/pkg-descr                   |  1 +
 6 files changed, 66 insertions(+)

diff --git a/games/Makefile b/games/Makefile
index b7a55a4b5538..3b7339247ff8 100644
--- a/games/Makefile
+++ b/games/Makefile
@@ -513,6 +513,7 @@
     SUBDIR += libretro-boom3
     SUBDIR += libretro-cap32
     SUBDIR += libretro-core-info
+    SUBDIR += libretro-desmume
     SUBDIR += libretro-desmume2015
     SUBDIR += libretro-dosbox
     SUBDIR += libretro-emux
diff --git a/games/libretro-desmume/Makefile b/games/libretro-desmume/Makefile
new file mode 100644
index 000000000000..2f59797b8846
--- /dev/null
+++ b/games/libretro-desmume/Makefile
@@ -0,0 +1,39 @@
+PORTNAME=	libretro-desmume
+DISTVERSION=	0.20231006
+CATEGORIES=	games
+
+MAINTAINER=	sdalu@sdalu.com
+COMMENT=	Port of Desmume to libretro
+WWW=		https://github.com/libretro/desmume
+
+LICENSE=	GPLv2
+LICENSE_FILE=	${WRKSRC}/license.txt
+
+ONLY_FOR_ARCHS= amd64 i386
+ONLY_FOR_ARCHS_REASON= fails to compile: invokes x86 assembler
+
+USES=		gmake gl localbase:ldflags
+USE_LDCONFIG=	yes
+USE_GL=		gl
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	libretro
+GH_PROJECT=	desmume
+GH_TAGNAME=	4ee1bb1d6a6c9695baea49d0c2dff34c10187502
+
+PLIST_FILES=	lib/libretro/desmume_libretro.so
+
+MAKEFILE=	Makefile.libretro
+BUILD_WRKSRC=	${WRKSRC}/desmume/src/frontend/libretro
+
+.include <bsd.port.options.mk>
+
+.if ${ARCH} != aarch64 && ${ARCH} != amd64 && !${ARCH:Marmv*} && ${ARCH} != i386
+MAKE_ENV+=	DESMUME_JIT=0
+.endif
+
+do-install:
+	${MKDIR} ${STAGEDIR}/${PREFIX}/lib/libretro
+	${INSTALL_LIB} ${WRKSRC}/desmume/src/frontend/libretro/desmume_libretro.so ${STAGEDIR}/${PREFIX}/lib/libretro
+
+.include <bsd.port.mk>
diff --git a/games/libretro-desmume/distinfo b/games/libretro-desmume/distinfo
new file mode 100644
index 000000000000..52b825233ed5
--- /dev/null
+++ b/games/libretro-desmume/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1698314795
+SHA256 (libretro-desmume-0.20231006-4ee1bb1d6a6c9695baea49d0c2dff34c10187502_GH0.tar.gz) = 2cc19bb94521bcc717f25fec2c6fc26af7660748573bcfc78d3fbe6e3216ded9
+SIZE (libretro-desmume-0.20231006-4ee1bb1d6a6c9695baea49d0c2dff34c10187502_GH0.tar.gz) = 11415777
diff --git a/games/libretro-desmume/files/patch-desmume_src_libretro-common_features_features__cpu.c b/games/libretro-desmume/files/patch-desmume_src_libretro-common_features_features__cpu.c
new file mode 100644
index 000000000000..288dbb0b252d
--- /dev/null
+++ b/games/libretro-desmume/files/patch-desmume_src_libretro-common_features_features__cpu.c
@@ -0,0 +1,11 @@
+--- desmume/src/libretro-common/features/features_cpu.c.orig	2021-02-16 18:16:47 UTC
++++ desmume/src/libretro-common/features/features_cpu.c
+@@ -144,7 +144,7 @@ retro_perf_tick_t cpu_features_get_perf_counter(void)
+    tv_sec     = (long)((ularge.QuadPart - epoch) / 10000000L);
+    tv_usec    = (long)(system_time.wMilliseconds * 1000);
+    time_ticks = (1000000 * tv_sec + tv_usec);
+-#elif defined(__linux__) || defined(__QNX__) || defined(__MACH__)
++#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(__QNX__) || defined(ANDROID) || defined(__MACH__) || defined(__PSL1GHT__)
+    struct timespec tv = {0};
+    if (ra_clock_gettime(CLOCK_MONOTONIC, &tv) == 0)
+       time_ticks = (retro_perf_tick_t)tv.tv_sec * 1000000000 +
diff --git a/games/libretro-desmume/files/patch-desmume_src_libretro-common_rthreads_rthreads.c b/games/libretro-desmume/files/patch-desmume_src_libretro-common_rthreads_rthreads.c
new file mode 100644
index 000000000000..431f8e3a08bb
--- /dev/null
+++ b/games/libretro-desmume/files/patch-desmume_src_libretro-common_rthreads_rthreads.c
@@ -0,0 +1,11 @@
+--- desmume/src/libretro-common/rthreads/rthreads.c.orig	2023-10-06 13:44:56 UTC
++++ desmume/src/libretro-common/rthreads/rthreads.c
+@@ -55,7 +55,7 @@
+ #include <time.h>
+ #endif
+ 
+-#if defined(VITA) || defined(BSD) || defined(ORBIS)
++#if defined(VITA) || defined(BSD) || defined(ORBIS) || (__FreeBSD__ <= 12)
+ #include <sys/time.h>
+ #endif
+ 
diff --git a/games/libretro-desmume/pkg-descr b/games/libretro-desmume/pkg-descr
new file mode 100644
index 000000000000..fb10fa0338b7
--- /dev/null
+++ b/games/libretro-desmume/pkg-descr
@@ -0,0 +1 @@
+Port of Desmume to libretro.