summaryrefslogtreecommitdiff
path: root/games-emulation/snes9x/snes9x-1.62.3.ebuild
blob: 6f28481e85857871f6719e21a1072c72feefbe1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{10..12} )
inherit autotools cmake flag-o-matic python-any-r1 toolchain-funcs xdg

# TODO: try unbundling, albeit compatibility with (and between) these
# tend to be volatile and it may not be the best idea "yet"
HASH_GLSLANG=6d41bb9c557c5a0eec61ffba1f775dc5f717a8f7
HASH_SPIRV=4e2fdb25671c742a9fbe93a6034eb1542244c7e1
HASH_VULKAN=a3dd2655a3a68c2a67c55a0f8b77dcb8b166ada2

DESCRIPTION="Super Nintendo Entertainment System (SNES) emulator"
HOMEPAGE="https://github.com/snes9xgit/snes9x/"
SRC_URI="
	https://github.com/snes9xgit/snes9x/archive/${PV}.tar.gz -> ${P}.tar.gz
	gui? (
		https://github.com/KhronosGroup/glslang/archive/${HASH_GLSLANG}.tar.gz
			-> glslang-${HASH_GLSLANG}.tar.gz
		https://github.com/KhronosGroup/SPIRV-Cross/archive/${HASH_SPIRV}.tar.gz
			-> spirv-cross-${HASH_SPIRV}.tar.gz
		https://github.com/KhronosGroup/Vulkan-Headers/archive/${HASH_VULKAN}.tar.gz
			-> vulkan-headers-${HASH_VULKAN}.tar.gz
	)"

LICENSE="
	Snes9x GPL-2 GPL-2+ LGPL-2.1 LGPL-2.1+ ISC MIT ZLIB
	gui? ( Apache-2.0 CC0-1.0 BSD )"
SLOT="0"
KEYWORDS="~amd64 ~ppc64 ~x86"
IUSE="alsa debug gui libretro netplay oss portaudio pulseaudio wayland xinerama +xv"
RESTRICT="bindist"

RDEPEND="
	media-libs/libpng:=
	sys-libs/zlib:=[minizip]
	x11-libs/libX11
	x11-libs/libXext
	alsa? ( media-libs/alsa-lib )
	gui? (
		dev-cpp/cairomm:0
		dev-cpp/glibmm:2
		dev-cpp/gtkmm:3.0[wayland?]
		dev-libs/glib:2
		dev-libs/libsigc++:2
		media-libs/libepoxy
		media-libs/libsdl2[joystick]
		x11-libs/cairo
		x11-libs/gdk-pixbuf:2
		x11-libs/gtk+:3[wayland?]
		x11-libs/libXrandr
		portaudio? ( media-libs/portaudio )
		pulseaudio? ( media-libs/libpulse )
		wayland? ( dev-libs/wayland )
	)
	libretro? ( !games-emulation/libretro-snes9x )
	xinerama? ( x11-libs/libXinerama )
	xv? ( x11-libs/libXv )"
DEPEND="
	${RDEPEND}
	x11-base/xorg-proto"
BDEPEND="
	virtual/pkgconfig
	gui? ( ${PYTHON_DEPS} )"

PATCHES=(
	"${FILESDIR}"/${PN}-1.62.1-flags.patch
	"${FILESDIR}"/${PN}-1.62.1-gcc13.patch
	"${FILESDIR}"/${PN}-1.62.1-optional-wayland.patch
)

pkg_setup() {
	# used by bundled glslang
	use gui && python-any-r1_pkg_setup
}

src_prepare() {
	if use gui; then
		rmdir external/{glslang,SPIRV-Cross,vulkan-headers} || die
		mv ../glslang-${HASH_GLSLANG} external/glslang || die
		mv ../SPIRV-Cross-${HASH_SPIRV} external/SPIRV-Cross || die
		mv ../Vulkan-Headers-${HASH_VULKAN} external/vulkan-headers || die
	fi

	if use gui; then
		CMAKE_USE_DIR=${S}/gtk
		cmake_src_prepare
	else
		default
	fi

	pushd unix >/dev/null || die
	eautoreconf
	popd >/dev/null || die

	rm -r unzip || die
}

src_configure() {
	tc-export CC CXX # for libretro

	local econfargs=(
		$(use_enable alsa sound-alsa)
		$(use_enable debug debugger)
		$(use_enable netplay)
		$(use_enable xinerama)
		$(use_enable xv xvideo)
		--enable-gamepad
		--enable-gzip
		--enable-screenshot
		--enable-zip
		--disable-libyuv # unpackaged
		--with-system-zip
	)

	pushd unix >/dev/null || die
	econf "${econfargs[@]}"
	popd >/dev/null || die

	if use gui; then
		# bundled SPIRV-Cross fails with -Werror=odr
		filter-lto

		local mycmakeargs=(
			-DBUILD_SHARED_LIBS=no
			-DDEBUGGER=$(usex debug)
			-DUSE_ALSA=$(usex alsa)
			-DUSE_OSS=$(usex oss)
			-DUSE_PORTAUDIO=$(usex portaudio)
			-DUSE_PULSEAUDIO=$(usex pulseaudio)
			-DUSE_SYSTEMZIP=yes
			-DUSE_WAYLAND=$(usex wayland)
			-DUSE_XV=$(usex xv)

			# this controls both vulkan output and shader support, could be
			# behind a USE but it currently fails to build if disabled and
			# adds no dependencies given they are bundled (for now)
			-DUSE_SLANG=yes

			# gets used for LOCALE/DATADIR too early (installs to /usr//locale)
			-DCMAKE_INSTALL_DATAROOTDIR=share
		)

		cmake_src_configure
	fi
}

src_compile() {
	if use libretro; then
		emake -C libretro LTO=
		# rebuild objects given libretro uses different defines (bug #791475)
		rm *.o || die
	fi

	emake -C unix

	use gui && cmake_src_compile
}

src_test() {
	# currently no tests, but don't run the cmake phase while unconfigured
	use gui && cmake_src_test
}

src_install() {
	if use libretro; then
		exeinto /usr/$(get_libdir)/libretro
		doexe libretro/snes9x_libretro.so
	fi

	dobin unix/snes9x

	local DOCS=(
		README.md
		docs/{changes,control-inputs,controls,snapshots}.txt
		unix/snes9x.conf.default
	)
	einstalldocs

	if use gui; then
		DOCS=( AUTHORS )
		cmake_src_install
	fi
}