commit:     484cf796cfa38577842783be53a79346b65a8dcf
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 22 10:53:17 2021 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Wed Dec 22 18:12:26 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=484cf796

games-emulation/zsnes: add 2.0.9 (fork) with new dumbed down ebuild

zsnes is very fragile, and supporting many configurations/flags
doesn't seem worth it anymore. So this uses current upstream
defaults for safety (no libao+debugger, and enable sdl+png+opengl).

May possibly have some new issues / regressions to iron out, notably
given doesn't use autoconf anymore which shifted many things around.

Unsure if this fork will be maintained on the long term, if not
then this package may be better off last-rited.

bug 817395: fork uses FORTIFY_SOURCE=0 which combined with -U should
            ensure it's unused even if our gcc enables it by default
(issue does exist still, was able to reproduce if letting it use it)
bug 829785: cause is unknown but can't reproduce when using the fork

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

 games-emulation/zsnes/Manifest                     |  1 +
 .../zsnes/files/zsnes-2.0.9-cc-quotes.patch        |  8 +++
 .../zsnes/files/zsnes-2.0.9-gentoo-zlib.patch      | 12 +++++
 games-emulation/zsnes/zsnes-2.0.9.ebuild           | 62 ++++++++++++++++++++++
 4 files changed, 83 insertions(+)

diff --git a/games-emulation/zsnes/Manifest b/games-emulation/zsnes/Manifest
index 23bb4c0f0963..84c9a0519a79 100644
--- a/games-emulation/zsnes/Manifest
+++ b/games-emulation/zsnes/Manifest
@@ -1 +1,2 @@
 DIST zsnes-1.51-20071031.tar.bz2 1072340 BLAKE2B 
d67c92e382ca130d4138d21fbb2effc06539d1c7e3aabf0339c9b7e773521daf2d3cb0bcef75991e1a4453fcc86903d3dead48d90806489c8b4bf7677f8ebf3b
 SHA512 
b10373cf81b201a33dc60c728431d4f69d36de31fcf6f137b623ea206a2998f722dcd6132daec1d0bf14a05ae52f3ee9ecee4334517039be554db85c9f7b8274
+DIST zsnes-2.0.9.tar.gz 935183 BLAKE2B 
a9b72ed15b2ed6d9e4631b4f12b2291ddca76a7236da008eba0f8b3ee27c94b98f00ff16a4929929adf484bc16554474b942b9f8306f46ab713e8a40e1f64624
 SHA512 
ea9244e98a175db9bceddf14e8212b3474ddaba1f508d698d8cfc43270fa3dabf51dca43dd30255272aba3cd061bf450bef04e005ce8087d550400e66faea565

diff --git a/games-emulation/zsnes/files/zsnes-2.0.9-cc-quotes.patch 
b/games-emulation/zsnes/files/zsnes-2.0.9-cc-quotes.patch
new file mode 100644
index 000000000000..d2615149601b
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-2.0.9-cc-quotes.patch
@@ -0,0 +1,8 @@
+Does not expect CC may have arguments rather than being in CFLAGS, e.g. -m32
+--- a/Makefile
++++ b/Makefile
+@@ -355,3 +355,3 @@
+       @echo '===> PSR $@'
+-      $(Q)./$(PSR) $(CFGDEFS) -gcc $(CC_TARGET) -compile -flags '$(CFLAGS)' 
-cheader $@ -fname $(*F) $(@:.h=.o) $<
++      $(Q)./$(PSR) $(CFGDEFS) -gcc '$(CC_TARGET)' -compile -flags '$(CFLAGS)' 
-cheader $@ -fname $(*F) $(@:.h=.o) $<
+ 

diff --git a/games-emulation/zsnes/files/zsnes-2.0.9-gentoo-zlib.patch 
b/games-emulation/zsnes/files/zsnes-2.0.9-gentoo-zlib.patch
new file mode 100644
index 000000000000..a5b5f584e177
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-2.0.9-gentoo-zlib.patch
@@ -0,0 +1,12 @@
+Gentoo-specific workaround due to https://bugs.gentoo.org/383179
+--- a/zip/zunzip.h
++++ b/zip/zunzip.h
+@@ -48,4 +48,8 @@
+ #include <zlib.h>
+ 
++#ifndef OF
++#define OF _Z_OF
++#endif
++
+ #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
+ /* like the STRICT of WIN32, we define a pointer that cannot be converted

diff --git a/games-emulation/zsnes/zsnes-2.0.9.ebuild 
b/games-emulation/zsnes/zsnes-2.0.9.ebuild
new file mode 100644
index 000000000000..a948fb8c0346
--- /dev/null
+++ b/games-emulation/zsnes/zsnes-2.0.9.ebuild
@@ -0,0 +1,62 @@
+# Copyright 2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit desktop flag-o-matic multilib toolchain-funcs
+
+DESCRIPTION="Fork of the classic Super Nintendo emulator"
+HOMEPAGE="https://github.com/xyproto/zsnes/ https://www.zsnes.com/";
+SRC_URI="https://github.com/xyproto/zsnes/archive/${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="-* ~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="custom-cflags"
+
+RDEPEND="
+       media-libs/libpng:=[abi_x86_32(-)]
+       media-libs/libsdl[abi_x86_32(-),joystick,opengl,sound,video]
+       sys-libs/zlib:=[abi_x86_32(-)]
+       virtual/opengl[abi_x86_32(-)]
+       x11-libs/libX11[abi_x86_32(-)]"
+DEPEND="
+       ${RDEPEND}
+       x11-base/xorg-proto"
+BDEPEND="
+       dev-lang/nasm
+       sys-libs/zlib
+       virtual/pkgconfig"
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-2.0.9-cc-quotes.patch
+       "${FILESDIR}"/${PN}-2.0.9-gentoo-zlib.patch
+)
+
+src_compile() {
+       # config.linux forces many CFLAGS that are questionable, but zsnes'
+       # ancient x86 asm is very fragile, not pic safe (bug #427104), broken
+       # by FORTIFY_SOURCE (bug #257963), and can be affected by -march=* and
+       # similar. Stick to upstream's choices, this is non-portable either way.
+       use custom-cflags || strip-flags
+       append-cppflags -U_FORTIFY_SOURCE
+
+       # used to build and run parsegen at build time (uses zlib wrt BDEPEND)
+       local buildcxx="$(tc-getBUILD_CXX) ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}"
+
+       use amd64 && multilib_toolchain_setup x86
+       tc-export CC CXX
+       append-cflags "${CPPFLAGS}"
+       append-cxxflags "${CPPFLAGS}"
+
+       emake CXX_HOST="${buildcxx}"
+}
+
+src_install() {
+       emake DESTDIR="${D}" PREFIX="${EPREFIX}"/usr install
+
+       dodoc README.md TODO.md
+
+       newicon icons/64x64x32.png ${PN}.png
+       make_desktop_entry ${PN} ${PN^^}
+}

Reply via email to