1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils flag-o-matic toolchain-funcs versionator games
9 MY_PV=$(replace_version_separator 3 '-')
15 DESCRIPTION="Hexen 2 port - Hammer of Thyrion"
16 HOMEPAGE="http://uhexen2.sourceforge.net/"
17 SRC_URI="mirror://sourceforge/${PN}/${MY_PN}source-${MY_PV}.tgz
18 mirror://sourceforge/u${MY_PN}/gamedata-all-${DATA_PV}.tgz
19 hexenworld? ( mirror://sourceforge/u${MY_PN}/hexenworld-pakfiles-${HW_PV}.tgz )"
23 KEYWORDS="~amd64 ~ppc ~x86"
24 IUSE="3dfx alsa asm cdaudio debug dedicated demo dynamic hexenworld gtk lights
25 midi opengl optimize-cflags oss sdlaudio sdlcd tools"
27 #QA_EXECSTACK="${GAMES_BINDIR:1}/hexen2
28 # ${GAMES_BINDIR:1}/glhexen2
29 # ${GAMES_BINDIR:1}/hexen2-demo
30 # ${GAMES_BINDIR:1}/glhexen2-demo
31 # ${GAMES_BINDIR:1}/hwcl
32 # ${GAMES_BINDIR:1}/glhwcl
33 # ${GAMES_BINDIR:1}/hwcl-demo
34 # ${GAMES_BINDIR:1}/glhwcl-demo"
36 UIDEPEND=">=media-libs/libsdl-1.2.7
37 >=media-libs/sdl-mixer-1.2.5
38 3dfx? ( media-libs/glide-v3 )
39 alsa? ( >=media-libs/alsa-lib-1.0.7 )
40 midi? ( media-sound/timidity++ >=media-libs/sdl-mixer-1.2.5[timidity] )
41 opengl? ( virtual/opengl )"
43 # Launcher depends from GTK+ libs
44 LNCHDEPEND="gtk? ( x11-libs/gtk+:2 )"
46 # xdelta is needed to manually run the patch script
47 RDEPEND="!games-fps/uhexen2-cvs
50 demo? ( >=games-fps/hexen2-demodata-${DEMO_PV} )
51 lights? ( games-fps/hexen2-lights )
52 >=dev-util/xdelta-1.1.3-r1"
55 x86? ( asm? ( >=dev-lang/nasm-0.98.38 ) )"
57 S="${WORKDIR}/hexen2source-${MY_PV}"
58 dir="${GAMES_DATADIR}/${MY_PN}"
68 epatch "${S}/00_Patches/midi_with_sdlaudio-test.diff"
70 epatch "${S}/00_Patches/external-music-file-support.diff"
73 # Whether to use the demo directory
75 use demo && demo="/demo"
77 # Use default basedir - has 2 variations
79 -e "s:parms.basedir = cwd;:parms.basedir = \"${dir}${demo}\";:" \
80 -e "s:parms.basedir = \".\";:parms.basedir = \"${dir}${demo}\";:" \
81 {hexen2,hexen2/server,hexenworld/{Client,Server}}/sys_unix.c \
82 || die "sed sys_unix.c failed"
84 # Change default sndspeed from 22050 to 44100,
85 # to improve the quality/reliability.
87 -e "s:desired_speed = 22050:desired_speed = 44100:" \
88 {hexen2,hexenworld/Client}/snd_dma.c || die "sed snd_dma.c failed"
90 # Change patch script to be suitable
92 -e "s:chmod :#chmod :" \
93 -e 's:"xdelta113":"/usr/bin/xdelta":' \
94 -e "s:./xdelta113:xdelta": \
95 "${WORKDIR}"/update_xdelta.sh || die "sed update_xdelta.sh failed"
97 # Honour Portage CFLAGS also when debuggins is enabled
98 use debug && append-flags "-g2"
99 for u in `grep -lr '\-g \-Wall' *`; do
101 -e "s/^CFLAGS \:\= \-g \-Wall/CFLAGS \:\= ${CFLAGS}/" \
102 ${u} || die "sed ${u} failed"
106 # Allow lightmaps in demo
108 -e "s:!override_pack:0:" \
109 hexen2/common.c || die "sed common.c demo failed"
113 # Tweak the default games data dir for graphical launcher
115 -e "/int basedir_nonstd/s:= 0:= 1:" \
116 -e "/game_basedir\[0\]/d" \
117 launcher/config_file.c || die "sed config_file.c failed"
118 # Tweak the default name for binary executables,if DEMO version is enabled
121 -e "/BINARY_NAME/s:\"$:-demo\":" \
122 launcher/games.h || die "sed games.h failed"
126 rm -rf docs/{activision,COMPILE,COPYING,LICENSE,README.win32}
131 local h2bin="h2" hwbin="hw" link_gl_libs="no" opts
133 h2bin="h2" hwbin="hw" \
146 h2bin="${h2bin} gl${h2bin}"
147 hwbin="${hwbin} gl${hwbin}"
148 use dynamic && LINK_GL_LIBS="yes"
151 use debug && opts="${opts} DEBUG=1"
152 use demo && opts="${opts} DEMO=1"
154 use alsa && USE_ALSA="yes"
155 use cdaudio && USE_CDAUDIO="yes"
156 use optimize-cflags && OPT_EXTRA="yes"
157 use oss && USE_OSS="yes"
158 use sdlcd && USE_SDLCD="yes"
159 use midi && USE_MIDI="yes"
160 use x86 && use asm && X86_ASM="yes"
161 use 3dfx && USE_3DFX="yes"
166 einfo "Building graphical launcher"
170 CPUFLAGS="${CFLAGS}" \
172 || die "emake launcher failed"
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}
184 CPUFLAGS="${CFLAGS}" \
186 || die "emake ${x} failed"
190 if use dedicated ; then
193 einfo "Building Dedicated Server"
196 OPT_EXTRA=${OPT_EXTRA} \
197 CPUFLAGS="${CFLAGS}" \
200 || die "emake Dedicated server failed"
203 if use hexenworld ; then
206 local hw_utils="hwmquery hwrcon"
207 einfo "Building Hexenworld utils"
209 for x in ${hw_utils} ; do
212 CPUFLAGS="${CFLAGS}" \
215 || die "emake ${x} failed"
220 einfo "Building Hexenworld servers"
225 CPUFLAGS="${CFLAGS}" \
228 || die "emake HexenWorld Server failed"
231 CPUFLAGS="${CFLAGS}" \
234 || die "emake HexenWorld Master failed"
237 einfo "Building Hexenworld client(s)"
238 for m in ${hwbin} ; do
239 emake -C Client clean
242 USE_ALSA=${USE_ALSA} \
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="${USE_3DFX}" \
252 CPUFLAGS="${CFLAGS}" \
256 || die "emake Hexenworld Client (${m}) failed"
260 # Hexen 2 game executable
263 einfo "Building UHexen2 game executable(s)"
264 for m in ${h2bin} ; do
268 USE_ALSA=${USE_ALSA} \
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=${USE_3DFX} \
278 CPUFLAGS="${CFLAGS}" \
281 || die "emake Hexen2 (${m}) failed"
287 local demo demo_title demo_suffix
288 use demo && demo="-demo" && demo_title=" (Demo)" && demo_suffix="demo"
290 newicon hexen2/icons/h2_32x32x4.png ${PN}.png || die
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"
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"
302 if use dedicated ; then
303 newgamesbin "${MY_PN}"/h2ded "${MY_PN}${demo}-ded" \
304 || die "newgamesbin h2ded failed"
307 if use hexenworld ; then
310 dobin hw_utils/hwmquery/hwmquery || die "dobin hwmquery failed"
311 dobin hw_utils/hwrcon/{hwrcon,hwterm} || die "dobin hwrcon/hwterm failed"
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"
319 newgamesbin hexenworld/Server/hwsv hwsv${demo} \
320 || die "newgamesbin hwsv failed"
322 newgamesbin hexenworld/Master/hwmaster hwmaster${demo} \
323 || die "newgamesbin hwmaster failed"
325 # HexenWorld client(s)
326 newicon hexenworld/icons/hw2_32x32x8.png hwcl.png || die
329 "hwcl${demo}" "Hexen 2${demo_title} Hexenworld Client" hwcl.png
330 newgamesbin "hexenworld/Client/hwcl" "hwcl${demo}" \
331 || die "newgamesbin hwcl failed"
335 "glhwcl${demo}" "GLHexen 2${demo_title} Hexenworld Client" hwcl.png
336 newgamesbin "hexenworld/Client/glhwcl" "glhwcl${demo}" \
337 || die "newgamesbin glhwcl failed"
340 insinto "${dir}"/${demo_suffix}
341 doins -r "${WORKDIR}"/hw || die "doins hexenworld pak failed"
346 local lnch_name="h2launcher"
347 use demo && lnch_name="h2demo"
348 newgamesbin launcher/${lnch_name} h2launcher \
349 || die "newgamesbin h2launcher failed"
351 "h2launcher" "Hexen 2${demo_title} Launcher" ${PN}.png
354 # Forge some new useful document 8)
355 head -22 "00_Patches/external-music-file-support.diff" > \
356 "docs/external_music.README" || die "make readme failed"
357 head -9 "00_Patches/midi_with_sdlaudio-test.diff" > \
358 "docs/midi_with_sdlaudio.README" || die "make readme failed"
363 # Install updated game data
365 doins -r "${WORKDIR}"/{data1,patchdata,portals,siege} || die
366 # Patching should really be done by a future "hexen2-data" ebuild.
367 # But this works for now.
368 doins "${WORKDIR}"/update_xdelta.sh || die
369 dodoc "${WORKDIR}"/*.txt
374 utils/bin/{bsp2wal,bspinfo,dhcc,genmodel,hcc} \
375 || die "dobin utils part 1 failed"
377 utils/bin/{jsh2colour,light,lmp2pcx,qbsp,qfiles,vis} \
378 || die "dobin utils part 2 failed"
379 newbin utils/hcc_old/hcc hcc_old || die "newbin hcc_old failed"
381 dodoc utils/README || die "dodoc README failed"
382 newdoc utils/dcc/README README.dcc || die "newdoc dcc failed"
383 dodoc utils/dcc/dcc.txt || die "dodoc dcc.txt failed"
384 newdoc utils/hcc/README README.hcc || die "newdoc hcc failed"
385 newdoc utils/hcc_old/README hcc_old.txt || die "newdoc hcc_old failed"
386 newdoc utils/jsh2color/README README.jsh2color \
387 || die "newdoc README.jsh2color failed"
388 newdoc utils/jsh2color/ChangeLog ChangeLog.jsh2color \
389 || die "newdoc Changelog.jsh2color failed"
399 elog "uhexen2 has been compiled specifically to play the demo maps."
400 elog "Example command-line:"
401 elog " hexen2-demo -width 1024 -height 768 -conwidth 640"
404 elog "To play the demo, emerge with the 'demo' USE flag."
406 elog "For the Hexen 2 original game..."
407 elog "Put the following files into "${dir}"/data1 before playing:"
408 elog " pak0.pak pak1.pak"
409 elog "Then to play: hexen2"
411 elog "For the 'Portal of Praevus' mission pack..."
412 elog "Put the following file into "${dir}"/portals before playing:"
414 elog "Then to play: hexen2 -portals"
416 elog "To ensure the data files from the CD are patched, run as root:"
417 elog " cd "${dir}" && sh update_xdelta.sh"
419 elog "Example command-line:"
420 elog " hexen2 -width 1024 -height 768 -conwidth 640"
424 elog "You've also installed a nice graphical launcher. Simply run:"
428 elog "to enjoy it :)"
432 if use hexenworld; then
433 elog "You've also installed some Hexenworld utility:"
435 elog " - hwmquery (console app to query HW master servers)"
436 elog " - hwrcon (remote interface to HW rcon command)"
437 elog " - hwterm (HW remote console terminal)"
440 elog "You've also installed some Hexen2 utility"
441 elog "(useful for mod developing)"
443 elog " - dhcc (old progs.dat compiler/decompiler)"
444 elog " - genmodel (3-D model grabber)"
445 elog " - hcc (HexenC compiler)"
446 elog " - hcc_old (old version of HexenC compiler)"
447 elog " - jsh2color (light colouring utility)"
448 elog " - maputils (Map compiling tools: bspinfo, light, qbsp, vis)"
449 elog " - qfiles (build pak files and regenerate bsp models)"
450 elog " - bsp2wal (extract all textures from a bsp file)"
451 elog " - lmp2pcx (convert hexen2 texture data into pcx and tga)"
453 elog "See relevant documentation for further informations"