commit:     5e4b089e913c1b6c5888b0b9e4e1bbcce36577b4
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 21 03:39:29 2022 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Mon Nov 21 04:58:06 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5e4b089e

games-emulation/gngb: EAPI6->8, fix build w/ clang16, C2x, and lto

Also GPL-2 -> GPL-2+, and fixing clang16 issues also fixed lto
ones wrt bug #858641 ... but the real fix here would last rites,
this is a terrible GB emulator by modern standards.

Closes: https://bugs.gentoo.org/858641
Closes: https://bugs.gentoo.org/874999
Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org>

 .../gngb/files/gngb-20060309-clang16.patch         | 100 +++++++++++++++++++++
 .../gngb/files/gngb-20060309-gentoo-zlib.patch     |  12 +++
 ...-20060309-r1.ebuild => gngb-20060309-r2.ebuild} |  23 ++---
 3 files changed, 125 insertions(+), 10 deletions(-)

diff --git a/games-emulation/gngb/files/gngb-20060309-clang16.patch 
b/games-emulation/gngb/files/gngb-20060309-clang16.patch
new file mode 100644
index 000000000000..c365ec049873
--- /dev/null
+++ b/games-emulation/gngb/files/gngb-20060309-clang16.patch
@@ -0,0 +1,100 @@
+gbserial_receive/wait_data() had issues but the functions are
+not used, just "if 0" rather than make sense of them.
+
+https://bugs.gentoo.org/858641
+https://bugs.gentoo.org/874999
+--- a/src/fileio.h
++++ b/src/fileio.h
+@@ -42,4 +42,9 @@
+ int gngb_file_eof(GNGB_FILE *f);
+ 
++#ifdef HAVE_LIBZ
++#include "unzip.h"
++int zip_file_open_next_rom(unzFile file);
++#endif
++
+ #endif
+ 
+--- a/src/memory.c
++++ b/src/memory.c
+@@ -32,4 +32,5 @@
+ #include "serial.h"
+ #include "message.h"
++#include "save.h"
+ #include "sgb.h"
+ 
+@@ -72,5 +73,8 @@
+ Sint16 joy_x_min=0;joy_x_max=0;joy_y_min=0;joy_y_max=0;
+ */
+-Sint16 joy_x_min=-32767;joy_x_max=32767;joy_y_min=-32767;joy_y_max=32767;
++Sint16 joy_x_min=-32767;
++Sint16 joy_x_max=32767;
++Sint16 joy_y_min=-32767;
++Sint16 joy_y_max=32767;
+ 
+ void (*select_rom_page)(Uint16 adr,Uint8 v);
+--- a/src/rom.h
++++ b/src/rom.h
+@@ -55,5 +55,8 @@
+ extern ROM_TIMER *rom_timer;
+ 
++int check_dir(char *dir_name);
+ int open_rom(char *filename);
++void get_ext_nb(char *r,int n);
++void get_bmp_ext_nb(char *r,int n);
+ 
+ #endif
+--- a/src/save.c
++++ b/src/save.c
+@@ -1,2 +1,3 @@
++#include <time.h>
+ #include "emu.h"
+ #include "fileio.h"
+@@ -6,4 +7,5 @@
+ #include "interrupt.h"
+ #include "cpu.h"
++#include "sound.h"
+ 
+ #define FILENAME_LEN 1024
+@@ -646,5 +648,5 @@
+ /* Movie */
+ 
+-GNGB_MOVIE gngb_movie={NULL,0,NULL};
++GNGB_MOVIE gngb_movie={{0},0,NULL};
+ 
+ void begin_save_movie(void) {
+--- a/src/serial.c
++++ b/src/serial.c
+@@ -218,4 +218,5 @@
+ }
+ 
++#if 0
+ Sint8 gbserial_receive(void) {
+ #ifndef WIN32
+@@ -237,4 +238,5 @@
+ #endif
+ }
++#endif
+ 
+ Uint8 gbserial_check2(void) {
+@@ -259,4 +261,5 @@
+ }
+ 
++#if 0
+ Uint8 gbserial_wait_data(void) {
+   Uint8 b;
+@@ -284,4 +287,5 @@
+   return 0;
+ }
++#endif
+ 
+ /* New GbSerial */
+--- a/src/serial.h
++++ b/src/serial.h
+@@ -42,4 +42,6 @@
+ Sint8 gbserial_receive(void);
+ char gbserial_check(void);
++Uint8 gbserial_read(void);
++void gbserial_write(Uint8 b);
+ Uint8 gbserial_wait_data(void);
+ 

diff --git a/games-emulation/gngb/files/gngb-20060309-gentoo-zlib.patch 
b/games-emulation/gngb/files/gngb-20060309-gentoo-zlib.patch
new file mode 100644
index 000000000000..bff6f5d6af9e
--- /dev/null
+++ b/games-emulation/gngb/files/gngb-20060309-gentoo-zlib.patch
@@ -0,0 +1,12 @@
+Gentoo's zlib.h does s/OF/_Z_OF/, so define OF if missing.
+https://bugs.gentoo.org/383179
+--- a/src/unzip.h
++++ b/src/unzip.h
+@@ -59,4 +59,7 @@
+ #endif
+ 
++#ifndef OF
++#define OF(x) x
++#endif
+ 
+ #define UNZ_OK                                  (0)

diff --git a/games-emulation/gngb/gngb-20060309-r1.ebuild 
b/games-emulation/gngb/gngb-20060309-r2.ebuild
similarity index 71%
rename from games-emulation/gngb/gngb-20060309-r1.ebuild
rename to games-emulation/gngb/gngb-20060309-r2.ebuild
index 5644e9baf78a..6ce2b27a4cb1 100644
--- a/games-emulation/gngb/gngb-20060309-r1.ebuild
+++ b/games-emulation/gngb/gngb-20060309-r2.ebuild
@@ -1,24 +1,24 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=6
-inherit autotools
+EAPI=8
+
+inherit autotools flag-o-matic
 
 DESCRIPTION="Gameboy / Gameboy Color emulator"
 HOMEPAGE="http://m.peponas.free.fr/gngb/";
 SRC_URI="http://m.peponas.free.fr/gngb/download/${P}.tar.gz";
 
-LICENSE="GPL-2"
+LICENSE="GPL-2+"
 SLOT="0"
 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos"
 IUSE="opengl"
 
 RDEPEND="
+       app-arch/bzip2:=
        media-libs/libsdl[sound,joystick,video]
-       sys-libs/zlib
-       app-arch/bzip2
-       opengl? ( virtual/opengl )
-"
+       sys-libs/zlib:=
+       opengl? ( media-libs/libglvnd[X] )"
 DEPEND="${RDEPEND}"
 
 PATCHES=(
@@ -32,15 +32,18 @@ PATCHES=(
        "${FILESDIR}"/${P}-qwerty.patch
        # Ours
        "${FILESDIR}"/${P}-gcc10.patch
+       "${FILESDIR}"/${P}-gentoo-zlib.patch
+       "${FILESDIR}"/${P}-clang16.patch
 )
 
 src_prepare() {
        default
-       sed -i -e '70i#define OF(x) x' src/unzip.h || die
-       mv configure.in configure.ac || die
+
        eautoreconf
 }
 
 src_configure() {
+       append-cflags -std=gnu89 # old codebase, incompatible with c2x
+
        econf $(use_enable opengl gl)
 }

Reply via email to