dev-python/pip: arm64 stable (bug #719946)
[gentoo.git] / games-fps / yamagi-quake2 / yamagi-quake2-7.42.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit desktop eutils
7
8 CTF_V="1.06"
9 ROGUE_V="2.06"
10 XATRIX_V="2.07"
11
12 DESCRIPTION="Quake 2 engine focused on single player"
13 HOMEPAGE="https://www.yamagi.org/quake2/"
14 SRC_URI="https://deponie.yamagi.org/quake2/quake2-${PV}.tar.xz
15         ctf? ( https://deponie.yamagi.org/quake2/quake2-ctf-${CTF_V}.tar.xz )
16         rogue? ( https://deponie.yamagi.org/quake2/quake2-rogue-${ROGUE_V}.tar.xz )
17         xatrix? ( https://deponie.yamagi.org/quake2/quake2-xatrix-${XATRIX_V}.tar.xz )"
18
19 LICENSE="GPL-2"
20 SLOT="0"
21 KEYWORDS="~amd64 ~x86"
22 IUSE="+client ctf dedicated openal +opengl rogue softrender xatrix"
23 REQUIRED_USE="
24         || ( client dedicated )
25         client? ( || ( opengl softrender ) )
26 "
27
28 COMMON_DEPEND="
29         client? (
30                 media-libs/libsdl2[video]
31                 !openal? ( media-libs/libsdl2[sound] )
32                 opengl? (
33                         media-libs/libsdl2[opengl]
34                         virtual/opengl
35                 )
36         )
37 "
38 RDEPEND="${COMMON_DEPEND}
39         client? ( openal? ( media-libs/openal ) )
40 "
41 DEPEND="${COMMON_DEPEND}"
42
43 S="${WORKDIR}/quake2-${PV}"
44
45 PATCHES=(
46         "${FILESDIR}"/${PN}-respect-flags.patch
47         "${FILESDIR}"/${PN}-7.42-fno-common.patch
48 )
49 DOCS=( CHANGELOG README.md doc/. )
50
51 mymake() {
52         emake \
53                 VERBOSE=1 \
54                 WITH_SYSTEMWIDE=yes \
55                 WITH_SYSTEMDIR="${EPREFIX}"/usr/share/games/quake2 \
56                 WITH_OPENAL=$(usex openal) \
57                 "$@"
58 }
59
60 src_prepare() {
61         local addon
62         for addon in ctf rogue xatrix; do
63                 use ${addon} || continue
64
65                 pushd "${WORKDIR}"/quake2-${addon}-* >/dev/null || die
66                 if [[ ${addon} = ctf ]]; then
67                         eapply -l -- "${FILESDIR}"/${PN}-addon-respect-flags-r2.patch
68                 else
69                         eapply -l -- "${FILESDIR}"/${PN}-addon-respect-flags-r3.patch
70                 fi
71                 popd >/dev/null || die
72         done
73
74         default
75 }
76
77 src_compile() {
78         local targets=( game )
79         if use client; then
80                 targets+=( client )
81                 use opengl && targets+=( ref_gl1 ref_gl3 )
82                 use softrender && targets+=( ref_soft )
83         fi
84         use dedicated && targets+=( server )
85
86         mymake config
87         mymake "${targets[@]}"
88
89         local addon
90         for addon in ctf rogue xatrix; do
91                 use ${addon} || continue
92                 emake -C "${WORKDIR}"/quake2-${addon}-* VERBOSE=1
93         done
94 }
95
96 src_install() {
97         insinto /usr/lib/yamagi-quake2
98         # Yamagi Quake II expects all binaries to be in the same directory
99         # See stuff/packaging.md for more info
100         exeinto /usr/lib/yamagi-quake2
101         doins -r release/.
102
103         if use client; then
104                 doexe release/quake2
105                 dosym ../lib/yamagi-quake2/quake2 /usr/bin/yquake2
106
107                 newicon stuff/icon/Quake2.svg "yamagi-quake2.svg"
108                 make_desktop_entry "yquake2" "Yamagi Quake II"
109         fi
110
111         if use dedicated; then
112                 doexe release/q2ded
113                 dosym ../lib/yamagi-quake2/q2ded /usr/bin/yq2ded
114         fi
115
116         insinto /usr/lib/yamagi-quake2/baseq2
117         doins stuff/yq2.cfg
118
119         local addon
120         for addon in ctf rogue xatrix; do
121                 use ${addon} || continue
122
123                 insinto /usr/lib/yamagi-quake2/${addon}
124                 doins "${WORKDIR}"/quake2-${addon}-*/release/game.so
125
126                 if use client; then
127                         local addon_name
128                         case ${addon} in
129                                 ctf)    addon_name="CTF" ;;
130                                 rogue)  addon_name="Ground Zero" ;;
131                                 xatrix) addon_name="The Reckoning" ;;
132                         esac
133
134                         make_wrapper "yquake2-${addon}" "yquake2 +set game ${addon}"
135                         make_desktop_entry "yquake2-${addon}" "Yamagi Quake II: ${addon_name}"
136                 fi
137         done
138
139         einstalldocs
140         if use client; then
141                 docinto examples
142                 dodoc stuff/cdripper.sh
143         fi
144 }
145
146 pkg_postinst() {
147         if [[ -z ${REPLACING_VERSIONS} ]]; then
148                 elog
149                 elog "In order to play, you must at least install:"
150                 elog "games-fps/quake2-data or games-fps/quake2-demodata or copy game"
151                 elog "data files to ~/.yq2/ or ${EPREFIX}/usr/share/games/quake2/ manually."
152                 elog "Read ${EPREFIX}/usr/share/doc/${PF}/README.md* for more information."
153                 elog
154         fi
155 }