summaryrefslogtreecommitdiff
path: root/games-rpg/openglad/openglad-0.98_p20200907.ebuild
blob: 111e08b4cc6c6a5f80f5baaa9fd281bc8d76b64f (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
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit desktop flag-o-matic toolchain-funcs

MY_COMMIT="80e33b15cfa6d7d288b4b3db4dcca0349f13691f"

DESCRIPTION="SDL clone of Gladiator, a classic RPG game"
HOMEPAGE="https://snowstorm.sourceforge.net/"
SRC_URI="
	https://github.com/openglad/openglad/archive/${MY_COMMIT}.tar.gz -> ${P}.tar.gz
	mirror://gentoo/${PN}.png"
S="${WORKDIR}/${PN}-${MY_COMMIT}"

LICENSE="Boost-1.0 GPL-2+ ZLIB"
SLOT="0"
KEYWORDS="~amd64 ~x86"

RDEPEND="
	dev-libs/libyaml
	dev-libs/libzip:=
	media-libs/libpng:=
	media-libs/libsdl2[joystick,opengl,sound,video]
	media-libs/sdl2-mixer"
DEPEND="${RDEPEND}"
BDEPEND="
	dev-util/premake:5
	virtual/pkgconfig"

PATCHES=(
	"${FILESDIR}"/${P}-clang.patch
)

src_prepare() {
	default

	# game uses the binary's location for assets even with a wrapper
	sed -e '/^std::string get_asset_path/!b;n' \
		-e "a\\return \"${EPREFIX}/usr/share/${PN}/\";" \
		-i src/io.cpp || die

	# unbundle (delete + add to pkg-config below is enough)
	# physfs: need missing physfsrwops.h matching system's to unbundle
	rm -r src/external/{libyaml,libzip} || die

	# cleanup not to install
	rm sound/Makefile.am || die
}

src_configure() {
	# premake4.lua assumes a lot (e.g. no SDL2 include path), check ourselves
	local pkgs=( SDL2_mixer libpng libzip sdl2 yaml-0.1 )
	append-cppflags $($(tc-getPKG_CONFIG) --cflags "${pkgs[@]}" || die)
	append-libs $($(tc-getPKG_CONFIG) --libs "${pkgs[@]}" || die)

	premake5 gmake || die
}

src_compile() {
	local emakeargs=(
		config=release
		verbose=y
		ARCH= # build assumes this is -m64 and tries to pass it to the compiler
		CC="$(tc-getCC)"
		CXX="$(tc-getCXX)"
		LIBS="${LIBS}"
		ALL_LDFLAGS="${LDFLAGS}" # only used to override -s
	)

	emake "${emakeargs[@]}"
}

src_install() {
	dobin bin/Release/${PN}

	insinto /usr/share/${PN}
	doins -r builtin cfg extra_campaigns pix sound
	# note: extra_campaigns not directly used, but users may want them

	dodoc {cheats,classes,scen}.txt
	einstalldocs

	doicon "${DISTDIR}"/${PN}.png
	make_desktop_entry ${PN} ${PN^}
}