summaryrefslogtreecommitdiff
blob: 0748b73cc530ae3a3829f512e7156338f6ddbb22 (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
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit autotools flag-o-matic pax-utils toolchain-funcs

DESCRIPTION="Argument-driven multi-system emulator utilizing OpenGL and SDL"
HOMEPAGE="https://mednafen.github.io/"
SRC_URI="https://mednafen.github.io/releases/files/${P}.tar.xz"
S="${WORKDIR}/${PN}"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="alsa cpu_flags_ppc_altivec flac jack"

RDEPEND="
	app-arch/zstd:=
	dev-libs/lzo:2
	dev-libs/trio
	media-libs/libsdl2[joystick,opengl,video]
	media-libs/tremor
	media-sound/musepack-tools
	sys-libs/zlib:=[minizip]
	virtual/libintl
	alsa? ( media-libs/alsa-lib )
	flac? ( media-libs/flac:= )
	jack? ( virtual/jack )"
DEPEND="${RDEPEND}"
BDEPEND="
	sys-devel/gettext
	virtual/pkgconfig"

src_prepare() {
	default

	# don't let the build system mess with CFLAGS more than necessary,
	# most are questionable (see README.PORTING/configure.ac comments)
	# -fwrapv: kept for bug #539992
	sed -e '/CC_OPT.*CODEGEN_FLAGS/{/-fwrapv/!d}' \
		-e '/CC_OPT.*NOPICPIE_FLAGS/d' \
		-e '/CC_OPT.*NO_STACK_PROTECTOR_FLAGS/d' \
		-e '/CC_OPT.*OPTIMIZER_FLAGS/c\:' \
		-e '/CC_OPT.*-mtune.*SS_EXTRA_FLAGS/d' \
		-e '/LINK_FLAG.*NOPICPIE_LDFLAGS/d' \
		-i configure.ac || die
	eautoreconf
}

src_configure() {
	# disable unnecessary warnings not to confuse users (see src/types.h)
	append-cppflags -DMDFN_DISABLE_{NO_OPT,PICPIE}_ERRWARN

	local myeconfargs=(
		$(use_enable alsa)
		$(use_enable cpu_flags_ppc_altivec altivec)
		$(use_enable jack)
		$(use_with flac libflac)
		--with-external-{libzstd,lzo,mpcdec,tremor,trio}
	)

	econf "${myeconfargs[@]}"
}

src_compile() {
	emake AR="$(tc-getAR)"
}

src_install() {
	local DOCS=(
		ChangeLog
		Documentation/{cheats.txt,fname_format.txt,modules.def,settings.def}
	)
	local HTML_DOCS=( Documentation/*.{css,html,png} )

	default

	pax-mark m "${ED}"/usr/bin/mednafen
}