summaryrefslogtreecommitdiff
path: root/games-roguelike/cataclysm-dda/cataclysm-dda-0h-r1.ebuild
blob: 9dfc019bf862f64c079ee493a233b24448f1e9c3 (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
187
# Copyright 2024-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit xdg toolchain-funcs

SP_VER="2024-10-27"

DESCRIPTION="A turn-based survival game set in a post-apocalyptic world"
HOMEPAGE="https://cataclysmdda.org
	https://github.com/CleverRaven/Cataclysm-DDA"
if [[ ${PV} == 9999 ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/CleverRaven/Cataclysm-DDA.git"
	SLOT="${PV}"
else
	v2="$(ver_cut 2)"
	MY_PV="$(ver_cut 1).${v2^^}"
	unset v2
	SRC_URI="
		https://github.com/CleverRaven/Cataclysm-DDA/archive/${MY_PV}-RELEASE.tar.gz -> ${P}.tar.gz
		soundpack? (
			https://github.com/Fris0uman/CDDA-Soundpacks/releases/download/${SP_VER}/CC-Sounds.zip -> ${P}-soundpack.zip
		)
	"
	SLOT="${MY_PV}"
	S="${WORKDIR}/Cataclysm-DDA-${MY_PV}-RELEASE"
	KEYWORDS="~amd64"
fi

# NOTE: Add BSD license on bump
LICENSE="CC-BY-SA-3.0 Apache-2.0 soundpack? ( CC-BY-SA-4.0 ) MIT OFL-1.1 Unicode-3.0"
IUSE="debug doc ncurses nls +sound +soundpack test +tiles"
REQUIRED_USE="soundpack? ( sound ) sound? ( tiles ) \
	|| ( tiles ncurses )"
RESTRICT="!test? ( test )"

RDEPEND="
	virtual/zlib:=
	ncurses? ( sys-libs/ncurses )
	tiles? (
		media-libs/libsdl2[video]
		media-libs/sdl2-image[png]
		media-libs/sdl2-ttf[harfbuzz]
		sound? (
			   media-libs/libsdl2[sound]
			   media-libs/sdl2-mixer[vorbis]
		)
	)"
DEPEND="${RDEPEND}"
BDEPEND="
	doc? ( app-text/doxygen[dot] )
	nls? ( sys-devel/gettext )
	"

[[ ${PV} != 9999 ]] && BDEPEND+=" soundpack? ( app-arch/unzip )"

PATCHES=(
	"${FILESDIR}/${PN}-respect-flags.patch"
	"${FILESDIR}/${P}-fix-gcc15.patch"
)

src_unpack() {
	if [[ ${PV} == 9999 ]]; then
		git-r3_src_unpack

		if use soundpack; then
			git-r3_fetch https://github.com/Fris0uman/CDDA-Soundpacks
			git-r3_checkout https://github.com/Fris0uman/CDDA-Soundpacks "${WORKDIR}/CDDA-Soundpacks"

			mv "${WORKDIR}/CDDA-Soundpacks/sound/CC-Sounds" "${WORKDIR}/CC-Sounds" || die
		fi
	else
		default
	fi
}

src_prepare() {
	sed -i \
		-e "s/-Werror //" \
		-e "s/TARGET_NAME = cataclysm/TARGET_NAME = cataclysm-${SLOT}/" \
		-e "s/\$(TARGET_NAME)-tiles/cataclysm-tiles-${SLOT}/" \
		-e "s/CataclysmDDA/CataclysmDDA-${SLOT}/" \
		-e "s/${PN}/${PN}-${SLOT}/" \
		"Makefile" || die

	find "${S}" -name "Makefile" -print | \
		xargs sed -i \
		-e "s/cataclysm.a/cataclysm-${SLOT}.a/g" \
		-e "s/\$(BUILD_PREFIX)//g" || die # BUILD_PREFIX is also used by portage

	sed -i -e "s/${PN}/${PN}-${SLOT}/" \
		"lang/Makefile" \
		"src/path_info.cpp" \
		"src/translation_manager_impl.cpp" \
		"tests/translation_system_test.cpp" || die

	sed -i "s#data#${EPREFIX}/usr/share/${PN}-${SLOT}#" \
		"data/fontdata.json" || die

	local f="org.cataclysmdda.CataclysmDDA"

	sed -i \
		-e "s/cataclysm-tiles/cataclysm-tiles-${SLOT}/g" \
		-e "s/${f}/${f}-${SLOT}/g" \
		"data/xdg/${f}.desktop" || die

	mv "data/xdg/${f}.desktop" "data/xdg/${f}-${SLOT}.desktop" || die
	mv "data/xdg/${f}.svg" "data/xdg/${f}-${SLOT}.svg" || die
	mv "data/xdg/${f}.appdata.xml" "data/xdg/${f}-${SLOT}.appdata.xml" || die

	default
}

src_compile() {
	myemakeargs=(
		BACKTRACE=$(usex debug 1 0)
		CXX="$(tc-getCXX)"
		LINTJSON=0
		PCH=0
		PREFIX="${EPREFIX}/usr"
		USE_XDG_DIR=1
	)

	use nls && export LANGUAGES="all"

	if use doc; then
		doxygen doxygen_doc/doxygen_conf.txt || die "Failed to generate docs"
	fi

	if use ncurses; then
		# don't build tests twice
		if ! use tiles; then
			emake "${myemakeargs[@]}" "RUNTESTS=$(usex test 1 0)" "TESTS=$(usex test 1 0)"
		else
			emake "${myemakeargs[@]}" "TESTS=0" "RUNTESTS=0"
		fi
		# move it when building both variants
		use tiles && { mv "cataclysm-${SLOT}" "${WORKDIR}"/cataclysm-${SLOT} || die ;}
	fi

	if use tiles; then
		emake clean
		emake "${myemakeargs[@]}" \
			"RUNTESTS=$(usex test 1 0)" \
			"SOUND=$(usex sound 1 0)" \
			"TESTS=$(usex test 1 0)" \
			"TILES=$(usex tiles 1 0)"
	fi
}

src_install() {
	emake \
		"TILES=$(usex tiles 1 0)" \
		"SOUND=$(usex sound 1 0)" \
		"${myemakeargs[@]}" \
		DESTDIR="${D}" \
		install

	[[ -e "${WORKDIR}/cataclysm-${SLOT}" ]] && dobin "${WORKDIR}/cataclysm-${SLOT}"

	use doc && dodoc -r doxygen_doc/html

	use tiles && newman "doc/cataclysm-tiles.6" "cataclysm-tiles-${SLOT}.6"
	use ncurses && newman "doc/cataclysm.6" "cataclysm-${SLOT}.6"

	if use soundpack; then
		insinto "/usr/share/${PN}-${SLOT}/sound"
		doins -r "${WORKDIR}/CC-Sounds"
	fi
}

pkg_postinst() {
	xdg_pkg_postinst

	elog "cataclysm is a slotted install that supports having"
	elog "multiple versions installed.  The binary has the"
	elog "slot appended, e.g. 'cataclysm-"${SLOT}"'."

	if use tiles && use ncurses; then
		elog
		elog "Since you have enabled both tiles and ncurses frontends"
		elog "the ncurses binary is called 'cataclysm-${SLOT}' and the"
		elog "tiles binary is called 'cataclysm-tiles-${SLOT}'."
	fi
}