1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils flag-o-matic toolchain-funcs games
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 )"
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"
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"
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 )"
41 # Launcher depends from GTK+ libs
42 LNCHDEPEND="gtk? ( x11-libs/gtk+:2 )"
44 # xdelta is needed to manually run the patch script
45 RDEPEND="!games-fps/uhexen2-cvs
48 demo? ( >=games-fps/hexen2-demodata-${DEMO_PV} )
49 lights? ( games-fps/hexen2-lights )
50 >=dev-util/xdelta-1.1.3-r1"
53 x86? ( asm? ( >=dev-lang/nasm-0.98.38 ) )"
55 S="${WORKDIR}/hexen2source-${PV}"
56 dir="${GAMES_DATADIR}/${MY_PN}"
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."
67 use alsa || ewarn "alsa is the recommended sound driver."
72 epatch "${S}/00_Patches/external-music-file-support.diff"
75 # Whether to use the demo directory
77 use demo && demo="/demo"
79 # Use default basedir - has 2 variations
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"
86 # Change default sndspeed from 22050 to 44100,
87 # to improve the quality/reliability.
89 -e "s:desired_speed = 22050:desired_speed = 44100:" \
90 {hexen2,hexenworld/Client}/snd_dma.c || die "sed snd_dma.c failed"
92 # Change patch script to be suitable
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"
99 # Honour Portage CFLAGS also when debuggins is enabled
100 use debug && append-flags "-g2"
101 for u in `grep -lr '\-g \-Wall' *`; do
103 -e "s/^CFLAGS \:\= \-g \-Wall/CFLAGS \:\= ${CFLAGS}/" \
104 ${u} || die "sed ${u} failed"
108 # Allow lightmaps in demo
110 -e "s:!override_pack:0:" \
111 hexen2/common.c || die "sed common.c demo failed"
115 # Tweak the default games data dir for graphical launcher
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
123 -e "/BINARY_NAME/s:\"$:-demo\":" \
124 launcher/games.h || die "sed games.h failed"
128 rm -rf docs/{activision,COMPILE,COPYING,LICENSE,README.win32}
133 local h2bin="h2" hwbin="hw" link_gl_libs="no" opts
135 h2bin="h2" hwbin="hw" \
147 h2bin="${h2bin} gl${h2bin}"
148 hwbin="${hwbin} gl${hwbin}"
149 use dynamic && LINK_GL_LIBS="yes"
152 use debug && opts="${opts} DEBUG=1"
153 use demo && opts="${opts} DEMO=1"
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"
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} \
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} \
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 a new useful document 8)
355 head -22 "00_Patches/external-music-file-support.diff" > \
356 "docs/external_music.README" || die "make readme failed"
358 dodoc docs/* || die "dodoc failed"
361 # Install updated game data
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
372 utils/bin/{bsp2wal,bspinfo,dhcc,genmodel,hcc} \
373 || die "dobin utils part 1 failed"
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"
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"
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"
402 elog "To play the demo, emerge with the 'demo' USE flag."
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"
409 elog "For the 'Portal of Praevus' mission pack..."
410 elog "Put the following file into "${dir}"/portals before playing:"
412 elog "Then to play: hexen2 -portals"
414 elog "To ensure the data files from the CD are patched, run as root:"
415 elog " cd "${dir}" && sh update_xdelta.sh"
417 elog "Example command-line:"
418 elog " hexen2 -width 1024 -height 768 -conwidth 640"
422 einfo "You've also installed a nice graphical launcher. Simply run:"
426 einfo "to enjoy it :)"
430 if use hexenworld; then
431 einfo "You've also installed some Hexenworld utility:"
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)"
438 einfo "You've also installed some Hexen2 utility"
439 einfo "(useful for mod developing)"
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)"
451 einfo "See relevant documentation for further informations"