summaryrefslogtreecommitdiff
blob: 00187684759dce6f92740f85fff8106464edca81 (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
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=5
inherit eutils cmake-utils gnome2-utils readme.gentoo-r1

DESCRIPTION="Open Source remake of The Settlers II game (needs original game files)"
HOMEPAGE="https://www.siedler25.org/"
# no upstream source tarball yet
# https://bugs.launchpad.net/s25rttr/+bug/1069546
SRC_URI="https://dev.gentoo.org/~hasufell/distfiles/${P}.tar.xz"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="debug"

RDEPEND="
	app-arch/bzip2
	media-libs/libsamplerate
	media-libs/libsdl[X,sound,opengl,video]
	media-libs/libsndfile
	media-libs/sdl-mixer[vorbis]
	net-libs/miniupnpc
	virtual/libiconv
	virtual/opengl
"
DEPEND="${RDEPEND}
	sys-devel/gettext
"

PATCHES=(
	"${FILESDIR}"/${P}-cmake.patch
	"${FILESDIR}"/${P}-soundconverter.patch
	"${FILESDIR}"/${P}-fpic.patch
	"${FILESDIR}"/${P}-format.patch
	"${FILESDIR}"/${P}-miniupnpc-api-14.patch
	"${FILESDIR}"/${P}-cmake-3.patch
	"${FILESDIR}"/${P}-gcc6.patch
)

DOC_CONTENTS="Copy your Settlers2 game files into ~/.${PN}/S2"

src_configure() {
	local arch
	case ${ARCH} in
		amd64)
			arch="x86_64" ;;
		x86)
			arch="i386" ;;
		*) die "Architecture ${ARCH} not yet supported" ;;
	esac

	local mycmakeargs=(
		-DCOMPILEFOR="linux"
		-DCOMPILEARCH="${arch}"
		-DCMAKE_SKIP_RPATH=YES
		-DPREFIX="/usr/"
		-DBINDIR="/usr/bin"
		-DDATADIR="/usr/share"
		-DLIBDIR="/usr/$(get_libdir)/${PN}"
		-DDRIVERDIR="/usr/$(get_libdir)/${PN}"
		-DGAMEDIR="~/.${PN}/S2"
		-DBUILD_GLFW_DRIVER=OFF
	)

	cmake-utils_src_configure
}

src_compile() {
	# work around some relative paths (CMAKE_IN_SOURCE_BUILD not supported)
	ln -s "${CMAKE_USE_DIR}"/RTTR "${CMAKE_BUILD_DIR}"/RTTR || die

	cmake-utils_src_compile

	mv "${CMAKE_USE_DIR}"/RTTR/{sound-convert,s-c_resample} "${T}"/ || die
}

src_install() {
	cd "${CMAKE_BUILD_DIR}" || die

	exeinto /usr/"$(get_libdir)"/${PN}
	doexe "${T}"/{sound-convert,s-c_resample}
	exeinto /usr/"$(get_libdir)"/${PN}/video
	doexe driver/video/SDL/src/libvideoSDL.so
	exeinto /usr/"$(get_libdir)"/${PN}/audio
	doexe driver/audio/SDL/src/libaudioSDL.so

	insinto /usr/share
	doins -r "${CMAKE_USE_DIR}"/RTTR
	dosym ./LSTS/splash.bmp /usr/share/RTTR/splash.bmp

	doicon -s 64 "${CMAKE_USE_DIR}"/debian/${PN}.png
	dobin src/s25client
	make_desktop_entry "s25client" "Settlers RTTR" "${PN}"

	dodoc RTTR/texte/{keyboardlayout.txt,readme.txt}
	readme.gentoo_create_doc
}

pkg_preinst() {
	gnome2_icon_savelist
}

pkg_postinst() {
	gnome2_icon_cache_update
	readme.gentoo_print_elog
}

pkg_postrm() {
	gnome2_icon_cache_update
}