]> Pileus Git - ~andy/sunrise/blob - games-fps/uhexen2/uhexen2-1.4.3.ebuild
x11-libs/libqglviewer: Properly fix qt deps
[~andy/sunrise] / games-fps / uhexen2 / uhexen2-1.4.3.ebuild
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI="2"
6
7 inherit eutils flag-o-matic toolchain-funcs games
8
9 DATA_PV="1.19a"
10 HW_PV="0.15"
11 MY_PN="hexen2"
12 DEMO_PV="1.4.3"
13
14 DESCRIPTION="Hexen 2 port - Hammer of Thyrion"
15 HOMEPAGE="http://uhexen2.sourceforge.net/"
16 SRC_URI="mirror://sourceforge/${PN}/${MY_PN}source-${PV}.tgz
17         mirror://sourceforge/u${MY_PN}/gamedata-all-${DATA_PV}.tgz
18         hexenworld? ( mirror://sourceforge/u${MY_PN}/hexenworld-pakfiles-${HW_PV}.tgz )"
19
20 LICENSE="GPL-2"
21 SLOT="0"
22 KEYWORDS="~amd64 ~ppc ~x86"
23 IUSE="alsa asm cdaudio debug dedicated demo dynamic hexenworld gtk lights
24 midi opengl optimize-cflags oss sdlaudio sdlcd tools"
25
26 QA_EXECSTACK="${GAMES_BINDIR:1}/hexen2
27         ${GAMES_BINDIR:1}/glhexen2
28         ${GAMES_BINDIR:1}/hexen2-demo
29         ${GAMES_BINDIR:1}/glhexen2-demo
30         ${GAMES_BINDIR:1}/hwcl
31         ${GAMES_BINDIR:1}/glhwcl
32         ${GAMES_BINDIR:1}/hwcl-demo
33         ${GAMES_BINDIR:1}/glhwcl-demo"
34
35 UIDEPEND=">=media-libs/libsdl-1.2.7
36         alsa? ( >=media-libs/alsa-lib-1.0.7 )
37         midi? ( >=media-libs/sdl-mixer-1.2.5[timidity] )
38         !midi? ( >=media-libs/sdl-mixer-1.2.5 )
39         opengl? ( virtual/opengl )"
40
41 # Launcher depends from GTK+ libs
42 LNCHDEPEND="gtk? ( x11-libs/gtk+:2 )"
43
44 # xdelta is needed to manually run the patch script
45 RDEPEND="!games-fps/uhexen2-cvs
46         ${UIDEPEND}
47         ${LNCHDEPEND}
48         demo? ( >=games-fps/hexen2-demodata-${DEMO_PV} )
49         lights? ( games-fps/hexen2-lights )
50         >=dev-util/xdelta-1.1.3-r1"
51 DEPEND="${UIDEPEND}
52         ${LNCHDEPEND}
53         x86? ( asm? ( >=dev-lang/nasm-0.98.38 ) )"
54
55 S="${WORKDIR}/hexen2source-${PV}"
56 dir="${GAMES_DATADIR}/${MY_PN}"
57
58 pkg_setup() {
59         games_pkg_setup
60
61         if ! use midi ; then
62                 ewarn "MIDI support disabled! MIDI music won't be played at all."
63                 ewarn "If you want to hear it, recompile this package"
64                 ewarn "with \"midi\" USE flag enabled."
65         fi
66
67         use alsa || ewarn "alsa is the recommended sound driver."
68 }
69
70 src_prepare() {
71         cd hexen2
72         epatch "${S}/00_Patches/external-music-file-support.diff"
73         cd ..
74
75         # Whether to use the demo directory
76         local demo
77         use demo && demo="/demo"
78
79         # Use default basedir - has 2 variations
80         sed -i \
81                 -e "s:parms.basedir = cwd;:parms.basedir = \"${dir}${demo}\";:" \
82                 -e "s:parms.basedir = \".\";:parms.basedir = \"${dir}${demo}\";:" \
83                 {hexen2,hexen2/server,hexenworld/{Client,Server}}/sys_unix.c \
84                 || die "sed sys_unix.c failed"
85
86         # Change default sndspeed from 22050 to 44100,
87         # to improve the quality/reliability.
88         sed -i \
89                 -e "s:desired_speed = 22050:desired_speed = 44100:" \
90                 {hexen2,hexenworld/Client}/snd_dma.c || die "sed snd_dma.c failed"
91
92         # Change patch script to be suitable
93         sed -i \
94                 -e "s:chmod :#chmod :" \
95                 -e 's:"xdelta113":"/usr/bin/xdelta":' \
96                 -e "s:./xdelta113:xdelta": \
97                 "${WORKDIR}"/update_xdelta.sh || die "sed update_xdelta.sh failed"
98
99         # Honour Portage CFLAGS also when debuggins is enabled
100         use debug && append-flags "-g2"
101         for u in `grep -lr '\-g \-Wall' *`; do
102                 sed -i \
103                         -e "s/^CFLAGS \:\= \-g \-Wall/CFLAGS \:\= ${CFLAGS}/" \
104                         ${u} || die "sed ${u} failed"
105         done
106
107         if use demo ; then
108                 # Allow lightmaps in demo
109                 sed -i \
110                         -e "s:!override_pack:0:" \
111                         hexen2/common.c || die "sed common.c demo failed"
112         fi
113
114         if use gtk ; then
115                 # Tweak the default games data dir for graphical launcher
116                 sed -i \
117                         -e "/int basedir_nonstd/s:= 0:= 1:" \
118                         -e "/game_basedir\[0\]/d" \
119                         launcher/config_file.c || die "sed config_file.c failed"
120                 # Tweak the default name for binary executables,if DEMO version is enabled
121                 if use demo ; then
122                         sed -i \
123                                 -e "/BINARY_NAME/s:\"$:-demo\":" \
124                                 launcher/games.h || die "sed games.h failed"
125                 fi
126         fi
127
128         rm -rf docs/{activision,COMPILE,COPYING,LICENSE,README.win32}
129 }
130
131 src_compile() {
132
133         local h2bin="h2" hwbin="hw" link_gl_libs="no" opts
134         local \
135                 h2bin="h2" hwbin="hw" \
136                 USE_ALSA="no" \
137                 USE_CDAUDIO="no" \
138                 LINK_GL_LIBS="no" \
139                 USE_MIDI="no" \
140                 OPT_EXTRA="no" \
141                 USE_OSS="no" \
142                 USE_SDLCD="no" \
143                 X86_ASM="no" \
144                 opts
145
146         if use opengl ; then
147                 h2bin="${h2bin} gl${h2bin}"
148                 hwbin="${hwbin} gl${hwbin}"
149                 use dynamic && LINK_GL_LIBS="yes"
150         fi
151
152         use debug && opts="${opts} DEBUG=1"
153         use demo && opts="${opts} DEMO=1"
154
155         use alsa && USE_ALSA="yes"
156         use cdaudio && USE_CDAUDIO="yes"
157         use optimize-cflags && OPT_EXTRA="yes"
158         use oss && USE_OSS="yes"
159         use sdlcd && USE_SDLCD="yes"
160         use midi && USE_MIDI="yes"
161         use x86 && use asm && X86_ASM="yes"
162
163         if use gtk ; then
164         # Build launcher
165                 cd "${S}/launcher"
166                 einfo "Building graphical launcher"
167                 emake \
168                         AUTOTOOLS=1 \
169                         ${opts} \
170                         CPUFLAGS="${CFLAGS}" \
171                         CC="$(tc-getCC)" \
172                         || die "emake launcher failed"
173         fi
174
175         if use tools ; then
176                 # Build Hexen2 utils
177                 cd "${S}/utils"
178                 einfo "Building utils"
179                 local utils_list="hcc maputils genmodel qfiles dcc jsh2color hcc_old texutils/bsp2wal texutils/lmp2pcx"
180                 for x in ${utils_list}
181                 do
182                         emake -C ${x} \
183                                 ${opts} \
184                                 CPUFLAGS="${CFLAGS}" \
185                                 CC="$(tc-getCC)" \
186                                 || die "emake ${x} failed"
187                 done
188         fi
189
190         if use dedicated ; then
191                 # Dedicated Server
192                 cd "${S}/${MY_PN}"
193                 einfo "Building Dedicated Server"
194                 emake \
195                         ${opts} \
196                         OPT_EXTRA=${OPT_EXTRA} \
197                         CPUFLAGS="${CFLAGS}" \
198                         CC="$(tc-getCC)" \
199                         -f Makefile.sv \
200                         || die "emake Dedicated server failed"
201         fi
202
203         if use hexenworld ; then
204                 if use tools; then
205                         # Hexenworld utils
206                         local hw_utils="hwmquery hwrcon"
207                         einfo "Building Hexenworld utils"
208                         cd "${S}/hw_utils"
209                         for x in ${hw_utils} ; do
210                                 emake \
211                                         ${opts} \
212                                         CPUFLAGS="${CFLAGS}" \
213                                         CC="$(tc-getCC)" \
214                                         -C ${x} \
215                                         || die "emake ${x} failed"
216                         done
217                 fi
218
219                 # Hexenworld
220                 einfo "Building Hexenworld servers"
221                 cd "${S}"/hexenworld
222                 # Hexenworld servers
223                 emake \
224                         ${opts} \
225                         CPUFLAGS="${CFLAGS}" \
226                         CC="$(tc-getCC)" \
227                         -C Server \
228                         || die "emake HexenWorld Server failed"
229                 emake \
230                         ${opts} \
231                         CPUFLAGS="${CFLAGS}" \
232                         CC="$(tc-getCC)" \
233                         -C Master \
234                         || die "emake HexenWorld Master failed"
235
236                 # Hexenworld client
237                 einfo "Building Hexenworld client(s)"
238                 for m in ${hwbin} ; do
239                         emake -C Client clean
240                         emake \
241                                 ${opts} \
242                                 USE_ALSA=${USE_ALSA} \
243                                 USE_OSS=${USE_OSS} \
244                                 USE_CDAUDIO=${USE_CDAUDIO} \
245                                 USE_MIDI=${USE_MIDI} \
246                                 USE_SDLAUDIO=${USE_SDLAUDIO} \
247                                 USE_SDLCD=${USE_SDLCD} \
248                                 USE_X86_ASM=${X86_ASM} \
249                                 OPT_EXTRA=${OPT_EXTRA} \
250                                 LINK_GL_LIBS=${LINK_GL_LIBS} \
251                                 USE_3DFXGAMMA=no \
252                                 CPUFLAGS="${CFLAGS}" \
253                                 CC="$(tc-getCC)" \
254                                 ${m} \
255                                 -C Client \
256                                 || die "emake Hexenworld Client (${m}) failed"
257                 done
258         fi
259
260         # Hexen 2 game executable
261         cd "${S}/${MY_PN}"
262
263         einfo "Building UHexen2 game executable(s)"
264         for m in ${h2bin} ; do
265                 emake clean
266                 emake \
267                         ${opts} \
268                         USE_ALSA=${USE_ALSA} \
269                         USE_OSS=${USE_OSS} \
270                         USE_CDAUDIO=${USE_CDAUDIO} \
271                         USE_MIDI=${USE_MIDI} \
272                         USE_SDLAUDIO=${USE_SDLAUDIO} \
273                         USE_SDLCD=${USE_SDLCD} \
274                         USE_X86_ASM=${X86_ASM} \
275                         OPT_EXTRA=${OPT_EXTRA} \
276                         LINK_GL_LIBS=${LINK_GL_LIBS} \
277                         USE_3DFXGAMMA=no \
278                         CPUFLAGS="${CFLAGS}" \
279                         CC="$(tc-getCC)" \
280                         ${m} \
281                         || die "emake Hexen2 (${m}) failed"
282         done
283
284 }
285
286 src_install() {
287         local demo demo_title demo_suffix
288         use demo && demo="-demo" && demo_title=" (Demo)" && demo_suffix="demo"
289
290         newicon hexen2/icons/h2_32x32x4.png ${PN}.png || die
291
292         make_desktop_entry "${MY_PN}${demo}" "Hexen 2${demo_title}" ${PN}.png
293         newgamesbin "${MY_PN}/${MY_PN}" "${MY_PN}${demo}" \
294                 || die "newgamesbin ${MY_PN} failed"
295
296         if use opengl ; then
297                 make_desktop_entry "gl${MY_PN}${demo}" "GLHexen 2${demo_title}" ${PN}.png
298                 newgamesbin "${MY_PN}/gl${MY_PN}" "gl${MY_PN}${demo}" \
299                         || die "newgamesbin gl${MY_PN} failed"
300         fi
301
302         if use dedicated ; then
303                 newgamesbin "${MY_PN}"/h2ded "${MY_PN}${demo}-ded" \
304                         || die "newgamesbin h2ded failed"
305         fi
306
307         if use hexenworld ; then
308                 if use tools; then
309                         # Hexenworld utils
310                         dobin hw_utils/hwmquery/hwmquery || die "dobin hwmquery failed"
311                         dobin hw_utils/hwrcon/{hwrcon,hwterm} || die "dobin hwrcon/hwterm failed"
312
313                         dodoc hw_utils/hwmquery/hwmquery.txt || die "dodoc hwmquery.txt failed"
314                         dodoc hw_utils/hwrcon/{hwrcon,hwterm}.txt \
315                         || die "dodoc hwrcon/hwterm.txt failed"
316                 fi
317
318                 # Hexenworld Servers
319                 newgamesbin hexenworld/Server/hwsv hwsv${demo} \
320                         || die "newgamesbin hwsv failed"
321
322                 newgamesbin hexenworld/Master/hwmaster hwmaster${demo} \
323                         || die "newgamesbin hwmaster failed"
324
325                 # HexenWorld client(s)
326                 newicon hexenworld/icons/hw2_32x32x8.png hwcl.png || die
327
328                 make_desktop_entry \
329                         "hwcl${demo}" "Hexen 2${demo_title} Hexenworld Client" hwcl.png
330                 newgamesbin "hexenworld/Client/hwcl" "hwcl${demo}" \
331                         || die "newgamesbin hwcl failed"
332
333                 if use opengl ; then
334                         make_desktop_entry \
335                                 "glhwcl${demo}" "GLHexen 2${demo_title} Hexenworld Client" hwcl.png
336                         newgamesbin "hexenworld/Client/glhwcl" "glhwcl${demo}" \
337                                 || die "newgamesbin glhwcl failed"
338                 fi
339
340                 insinto "${dir}"/${demo_suffix}
341                 doins -r "${WORKDIR}"/hw || die "doins hexenworld pak failed"
342         fi
343
344         if use gtk ; then
345                 # GTK launcher
346                 local lnch_name="h2launcher"
347                 use demo && lnch_name="h2demo"
348                 newgamesbin launcher/${lnch_name} h2launcher \
349                         || die "newgamesbin h2launcher failed"
350                 make_desktop_entry \
351                         "h2launcher" "Hexen 2${demo_title} Launcher" ${PN}.png
352         fi
353
354         # Forge a new useful document 8)
355         head -22 "00_Patches/external-music-file-support.diff" > \
356         "docs/external_music.README" || die "make readme failed"
357
358         dodoc docs/* || die "dodoc failed"
359
360         if ! use demo ; then
361                 # Install updated game data
362                 insinto "${dir}"
363                 doins -r "${WORKDIR}"/{data1,patchdata,portals,siege} || die
364                 # Patching should really be done by a future "hexen2-data" ebuild.
365                 # But this works for now.
366                 doins "${WORKDIR}"/update_xdelta.sh || die
367                 dodoc "${WORKDIR}"/*.txt || die
368         fi
369
370         if use tools ; then
371                 dobin \
372                         utils/bin/{bsp2wal,bspinfo,dhcc,genmodel,hcc} \
373                         || die "dobin utils part 1 failed"
374                 dobin \
375                         utils/bin/{jsh2colour,light,lmp2pcx,qbsp,qfiles,vis} \
376                         || die "dobin utils part 2 failed"
377                 newbin utils/hcc_old/hcc hcc_old || die "newbin hcc_old failed"
378                 docinto utils
379                 dodoc utils/README || die "dodoc README failed"
380                 newdoc utils/dcc/README README.dcc || die "newdoc dcc failed"
381                 dodoc utils/dcc/dcc.txt || die "dodoc dcc.txt failed"
382                 newdoc utils/hcc/README README.hcc || die "newdoc hcc failed"
383                 newdoc utils/hcc_old/README hcc_old.txt || die "newdoc hcc_old failed"
384                 newdoc utils/jsh2color/README README.jsh2color \
385                         || die "newdoc README.jsh2color failed"
386                 newdoc utils/jsh2color/ChangeLog ChangeLog.jsh2color \
387                         || die "newdoc Changelog.jsh2color failed"
388         fi
389
390         prepgamesdirs
391 }
392
393 pkg_postinst() {
394         games_pkg_postinst
395
396         if use demo ; then
397                 einfo "uhexen2 has been compiled specifically to play the demo maps."
398                 einfo "Example command-line:"
399                 einfo "   hexen2-demo -width 1024 -height 768 -conwidth 640"
400                 einfo
401         else
402                 elog "To play the demo, emerge with the 'demo' USE flag."
403                 elog
404                 elog "For the Hexen 2 original game..."
405                 elog "Put the following files into "${dir}"/data1 before playing:"
406                 elog "   pak0.pak pak1.pak"
407                 elog "Then to play:  hexen2"
408                 elog
409                 elog "For the 'Portal of Praevus' mission pack..."
410                 elog "Put the following file into "${dir}"/portals before playing:"
411                 elog "   pak3.pak"
412                 elog "Then to play:  hexen2 -portals"
413                 elog
414                 elog "To ensure the data files from the CD are patched, run as root:"
415                 elog "   cd "${dir}" && sh update_xdelta.sh"
416                 elog
417                 elog "Example command-line:"
418                 elog "   hexen2 -width 1024 -height 768 -conwidth 640"
419                 einfo
420         fi
421         if use gtk ; then
422                 einfo "You've also installed a nice graphical launcher. Simply run:"
423                 einfo
424                 einfo "   h2launcher"
425                 einfo
426                 einfo "to enjoy it :)"
427                 einfo
428         fi
429         if use tools ; then
430                 if use hexenworld; then
431                         einfo "You've also installed some Hexenworld utility:"
432                         einfo
433                         einfo " - hwmquery (console app to query HW master servers)"
434                         einfo " - hwrcon (remote interface to HW rcon command)"
435                         einfo " - hwterm (HW remote console terminal)"
436                         einfo
437                 fi
438                 einfo "You've also installed some Hexen2 utility"
439                 einfo "(useful for mod developing)"
440                 einfo
441                 einfo " - dhcc (old progs.dat compiler/decompiler)"
442                 einfo " - genmodel (3-D model grabber)"
443                 einfo " - hcc (HexenC compiler)"
444                 einfo " - hcc_old (old version of HexenC compiler)"
445                 einfo " - jsh2color (light colouring utility)"
446                 einfo " - maputils (Map compiling tools: bspinfo, light, qbsp, vis)"
447                 einfo " - qfiles (build pak files and regenerate bsp models)"
448                 einfo " - bsp2wal (extract all textures from a bsp file)"
449                 einfo " - lmp2pcx (convert hexen2 texture data into pcx and tga)"
450                 einfo
451                 einfo "See relevant documentation for further informations"
452                 einfo
453         fi
454 }