1 # Copyright 1999-2008 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 inherit eutils flag-o-matic toolchain-funcs versionator games
12 DESCRIPTION="Hexen 2 port - Hammer of Thyrion (CVS snapshot)"
13 HOMEPAGE="http://uhexen2.sourceforge.net/"
14 SRC_URI="http://uhexen2.sourceforge.net/devel/cvs_latest/${P}.tgz
15 mirror://sourceforge/u${MY_PN}/gamedata-all-${DATA_PV}.tgz
16 hexenworld? ( mirror://sourceforge/u${MY_PN}/hexenworld-pakfiles-${HW_PV}.tgz )"
20 KEYWORDS="~amd64 ~ppc ~x86"
21 IUSE="3dfx alsa asm cdaudio debug dedicated demo dynamic hexenworld gtk lights
22 midi opengl optimize-cflags oss sdlaudio sdlcd tools"
24 QA_EXECSTACK="${GAMES_BINDIR:1}/hexen2
25 ${GAMES_BINDIR:1}/glhexen2
26 ${GAMES_BINDIR:1}/hexen2-demo
27 ${GAMES_BINDIR:1}/glhexen2-demo
28 ${GAMES_BINDIR:1}/hwcl
29 ${GAMES_BINDIR:1}/glhwcl
30 ${GAMES_BINDIR:1}/hwcl-demo
31 ${GAMES_BINDIR:1}/glhwcl-demo"
33 UIDEPEND=">=media-libs/libsdl-1.2.7
34 >=media-libs/sdl-mixer-1.2.5
35 3dfx? ( media-libs/glide-v3 )
36 alsa? ( >=media-libs/alsa-lib-1.0.7 )
37 midi? ( media-sound/timidity++ )
38 opengl? ( virtual/opengl )"
40 # Launcher depends from GTK+ libs
41 LNCHDEPEND="gtk? ( =x11-libs/gtk+-2* )"
43 # xdelta is needed to manually run the patch script
44 RDEPEND="!games-fps/uhexen2
47 demo? ( >=games-fps/hexen2-demodata-${DEMO_PV} )
48 lights? ( games-fps/hexen2-lights )
49 >=dev-util/xdelta-1.1.3-r1"
52 x86? ( asm? ( >=dev-lang/nasm-0.98.38 ) )"
54 S="${WORKDIR}/uhexen2-cvs-${PV}"
55 dir="${GAMES_DATADIR}/${MY_PN}"
61 if ! built_with_use "media-libs/sdl-mixer" timidity ; then
62 eerror "Recompile media-libs/sdl-mixer with 'timidity' USE flag."
63 die "sdl-mixer without timidity support detected"
65 use sdlaudio && ewarn "MIDI music does not work with sdlaudio."
67 ewarn "MIDI support disabled! MIDI music won't be played at all."
68 ewarn "If you want to hear it, recompile this package"
69 ewarn "with \"midi\" USE flag enabled."
72 use alsa || ewarn "alsa is the recommended sound driver."
80 for x in `find . -name CVS -print`; do rm -fr ${x}; done
83 epatch "${S}/00_Patches/external-music-file-support.diff"
86 # Whether to use the demo directory
88 use demo && demo="/demo"
90 # Use default basedir - has 2 variations
92 -e "s:parms.basedir = cwd;:parms.basedir = \"${dir}${demo}\";:" \
93 -e "s:parms.basedir = \".\";:parms.basedir = \"${dir}${demo}\";:" \
94 {hexen2,hexen2/server,hexenworld/{Client,Server}}/sys_unix.c \
95 || die "sed sys_unix.c failed"
97 # Change default sndspeed from 22050 to 44100,
98 # to improve the quality/reliability.
100 -e "s:desired_speed = 22050:desired_speed = 44100:" \
101 {hexen2,hexenworld/Client}/snd_dma.c || die "sed snd_dma.c failed"
103 # Change patch script to be suitable
105 -e "s:chmod :#chmod :" \
106 -e 's:"xdelta113":"/usr/bin/xdelta":' \
107 -e "s:./xdelta113:xdelta": \
108 "${WORKDIR}"/update_xdelta.sh || die "sed update_xdelta.sh failed"
110 # Honour Portage CFLAGS also when debuggins is enabled
111 use debug && append-flags "-g2"
112 for u in `grep -lr '\-g \-Wall' *`; do
114 -e "s/^CFLAGS \:\= \-g \-Wall/CFLAGS \:\= ${CFLAGS}/" \
115 ${u} || die "sed ${u} failed"
119 # Allow lightmaps in demo
121 -e "s:!override_pack:0:" \
122 hexen2/common.c || die "sed common.c demo failed"
126 # Tweak the default games data dir for graphical launcher
128 -e "/int basedir_nonstd/s:= 0:= 1:" \
129 -e "/game_basedir\[0\]/d" \
130 launcher/config_file.c || die "sed config_file.c failed"
131 # Tweak the default name for binary executables,if DEMO version is enabled
134 -e "/BINARY_NAME/s:\"$:-demo\":" \
135 launcher/games.h || die "sed games.h failed"
139 rm -rf docs/{activision,COMPILE,COPYING,LICENSE,README.win32}
144 local h2bin="h2" hwbin="hw" link_gl_libs="no" opts
146 h2bin="h2" hwbin="hw" \
159 h2bin="${h2bin} gl${h2bin}"
160 hwbin="${hwbin} gl${hwbin}"
161 use dynamic && LINK_GL_LIBS="yes"
164 use debug && opts="${opts} DEBUG=1"
165 use demo && opts="${opts} DEMO=1"
167 use alsa && USE_ALSA="yes"
168 use cdaudio && USE_CDAUDIO="yes"
169 use optimize-cflags && OPT_EXTRA="yes"
170 use oss && USE_OSS="yes"
171 use sdlcd && USE_SDLCD="yes"
172 use midi && USE_MIDI="yes"
173 use x86 && use asm && X86_ASM="yes"
174 use 3dfx && USE_3DFX="yes"
179 einfo "Building graphical launcher"
183 CPUFLAGS="${CFLAGS}" \
185 || die "emake launcher failed"
191 einfo "Building utils"
192 local utils_list="hcc maputils genmodel qfiles dcc jsh2color hcc_old texutils/bsp2wal texutils/lmp2pcx"
193 for x in ${utils_list}
197 CPUFLAGS="${CFLAGS}" \
199 || die "emake ${x} failed"
203 if use dedicated ; then
206 einfo "Building Dedicated Server"
209 OPT_EXTRA=${OPT_EXTRA} \
210 CPUFLAGS="${CFLAGS}" \
213 || die "emake Dedicated server failed"
216 if use hexenworld ; then
219 local hw_utils="hwmquery hwrcon"
220 einfo "Building Hexenworld utils"
222 for x in ${hw_utils} ; do
225 CPUFLAGS="${CFLAGS}" \
228 || die "emake ${x} failed"
233 einfo "Building Hexenworld servers"
238 CPUFLAGS="${CFLAGS}" \
241 || die "emake HexenWorld Server failed"
244 CPUFLAGS="${CFLAGS}" \
247 || die "emake HexenWorld Master failed"
250 einfo "Building Hexenworld client(s)"
251 for m in ${hwbin} ; do
252 emake -C Client clean
255 USE_ALSA=${USE_ALSA} \
257 USE_CDAUDIO=${USE_CDAUDIO} \
258 USE_MIDI=${USE_MIDI} \
259 USE_SDLAUDIO=${USE_SDLAUDIO} \
260 USE_SDLCD=${USE_SDLCD} \
261 USE_X86_ASM=${X86_ASM} \
262 OPT_EXTRA=${OPT_EXTRA} \
263 LINK_GL_LIBS=${LINK_GL_LIBS} \
264 USE_3DFXGAMMA="${USE_3DFX}" \
265 CPUFLAGS="${CFLAGS}" \
269 || die "emake Hexenworld Client (${m}) failed"
273 # Hexen 2 game executable
276 einfo "Building UHexen2 game executable(s)"
277 for m in ${h2bin} ; do
281 USE_ALSA=${USE_ALSA} \
283 USE_CDAUDIO=${USE_CDAUDIO} \
284 USE_MIDI=${USE_MIDI} \
285 USE_SDLAUDIO=${USE_SDLAUDIO} \
286 USE_SDLCD=${USE_SDLCD} \
287 USE_X86_ASM=${X86_ASM} \
288 OPT_EXTRA=${OPT_EXTRA} \
289 LINK_GL_LIBS=${LINK_GL_LIBS} \
290 USE_3DFXGAMMA=${USE_3DFX} \
291 CPUFLAGS="${CFLAGS}" \
294 || die "emake Hexen2 (${m}) failed"
300 local demo demo_title demo_suffix
301 use demo && demo="-demo" && demo_title=" (Demo)" && demo_suffix="demo"
303 newicon hexen2/icons/h2_32x32x4.png ${PN}.png || die
305 make_desktop_entry "${MY_PN}${demo}" "Hexen 2${demo_title}" ${PN}.png
306 newgamesbin "${MY_PN}/${MY_PN}" "${MY_PN}${demo}" \
307 || die "newgamesbin ${MY_PN} failed"
310 make_desktop_entry "gl${MY_PN}${demo}" "GLHexen 2${demo_title}" ${PN}.png
311 newgamesbin "${MY_PN}/gl${MY_PN}" "gl${MY_PN}${demo}" \
312 || die "newgamesbin gl${MY_PN} failed"
315 if use dedicated ; then
316 newgamesbin "${MY_PN}"/h2ded "${MY_PN}${demo}-ded" \
317 || die "newgamesbin h2ded failed"
320 if use hexenworld ; then
323 dobin hw_utils/hwmquery/hwmquery || die "dobin hwmquery failed"
324 dobin hw_utils/hwrcon/{hwrcon,hwterm} || die "dobin hwrcon/hwterm failed"
326 dodoc hw_utils/hwmquery/hwmquery.txt || die "dodoc hwmquery.txt failed"
327 dodoc hw_utils/hwrcon/{hwrcon,hwterm}.txt \
328 || die "dodoc hwrcon/hwterm.txt failed"
332 newgamesbin hexenworld/Server/hwsv hwsv${demo} \
333 || die "newgamesbin hwsv failed"
335 newgamesbin hexenworld/Master/hwmaster hwmaster${demo} \
336 || die "newgamesbin hwmaster failed"
338 # HexenWorld client(s)
339 newicon hexenworld/icons/hw2_32x32x8.png hwcl.png || die
342 "hwcl${demo}" "Hexen 2${demo_title} Hexenworld Client" hwcl.png
343 newgamesbin "hexenworld/Client/hwcl" "hwcl${demo}" \
344 || die "newgamesbin hwcl failed"
348 "glhwcl${demo}" "GLHexen 2${demo_title} Hexenworld Client" hwcl.png
349 newgamesbin "hexenworld/Client/glhwcl" "glhwcl${demo}" \
350 || die "newgamesbin glhwcl failed"
353 insinto "${dir}"/${demo_suffix}
354 doins -r "${WORKDIR}"/hw || die "doins hexenworld pak failed"
359 local lnch_name="h2launcher"
360 use demo && lnch_name="h2demo"
361 newgamesbin launcher/${lnch_name} h2launcher \
362 || die "newgamesbin h2launcher failed"
364 "h2launcher" "Hexen 2${demo_title} Launcher" ${PN}.png
367 # Forge a new useful document 8)
368 head -22 "00_Patches/external-music-file-support.diff" > \
369 "docs/external_music.README" || die "make readme failed"
374 # Install updated game data
376 doins -r "${WORKDIR}"/{data1,patchdata,portals,siege} || die
377 # Patching should really be done by a future "hexen2-data" ebuild.
378 # But this works for now.
379 doins "${WORKDIR}"/update_xdelta.sh || die
380 dodoc "${WORKDIR}"/*.txt
385 utils/bin/{bsp2wal,bspinfo,dhcc,genmodel,hcc} \
386 || die "dobin utils part 1 failed"
388 utils/bin/{jsh2colour,light,lmp2pcx,qbsp,qfiles,vis} \
389 || die "dobin utils part 2 failed"
390 newbin utils/hcc_old/hcc hcc_old || die "newbin hcc_old failed"
392 dodoc utils/README || die "dodoc README failed"
393 newdoc utils/dcc/README README.dcc || die "newdoc dcc failed"
394 dodoc utils/dcc/dcc.txt || die "dodoc dcc.txt failed"
395 newdoc utils/hcc/README README.hcc || die "newdoc hcc failed"
396 newdoc utils/hcc_old/README hcc_old.txt || die "newdoc hcc_old failed"
397 newdoc utils/jsh2color/README README.jsh2color \
398 || die "newdoc README.jsh2color failed"
399 newdoc utils/jsh2color/ChangeLog ChangeLog.jsh2color \
400 || die "newdoc Changelog.jsh2color failed"
410 elog "uhexen2 has been compiled specifically to play the demo maps."
411 elog "Example command-line:"
412 elog " hexen2-demo -width 1024 -height 768 -conwidth 640"
415 elog "To play the demo, emerge with the 'demo' USE flag."
417 elog "For the Hexen 2 original game..."
418 elog "Put the following files into ${dir}/data1 before playing:"
419 elog " pak0.pak pak1.pak"
420 elog "Then to play: hexen2"
422 elog "For the 'Portal of Praevus' mission pack..."
423 elog "Put the following file into ${dir}/portals before playing:"
425 elog "Then to play: hexen2 -portals"
427 elog "To ensure the data files from the CD are patched, run as root:"
428 elog " cd ${dir} && sh update_xdelta.sh"
430 elog "Example command-line:"
431 elog " hexen2 -width 1024 -height 768 -conwidth 640"
435 elog "You've also installed a nice graphical launcher. Simply run:"
439 elog "to enjoy it :)"
443 if use hexenworld; then
444 elog "You've also installed some Hexenworld utility:"
446 elog " - hwmquery (console app to query HW master servers)"
447 elog " - hwrcon (remote interface to HW rcon command)"
448 elog " - hwterm (HW remote console terminal)"
451 elog "You've also installed some Hexen2 utility"
452 elog "(useful for mod developing)"
454 elog " - dhcc (old progs.dat compiler/decompiler)"
455 elog " - genmodel (3-D model grabber)"
456 elog " - hcc (HexenC compiler)"
457 elog " - hcc_old (old version of HexenC compiler)"
458 elog " - jsh2color (light colouring utility)"
459 elog " - maputils (Map compiling tools: bspinfo, light, qbsp, vis)"
460 elog " - qfiles (build pak files and regenerate bsp models)"
461 elog " - bsp2wal (extract all textures from a bsp file)"
462 elog " - lmp2pcx (convert hexen2 texture data into pcx and tga)"
464 elog "See relevant documentation for further informations"