# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils flag-o-matic multilib toolchain-funcs versionator games DATA_PV="1.19-pre3" HW_PV="0.15" MY_PN="hexen2" MY_PV=$(replace_version_separator 3 '-') DEMO_PV="1.4.1" DESCRIPTION="Hexen 2 port - Hammer of Thyrion" HOMEPAGE="http://uhexen2.sourceforge.net/" SRC_URI="mirror://sourceforge/${PN}/${MY_PN}source-${MY_PV}.tgz mirror://sourceforge/${PN}/gamedata-all-${DATA_PV}.tgz hexenworld? ( mirror://sourceforge/${PN}/hexenworld-pakfiles-${HW_PV}.tgz )" LICENSE="GPL-2" SLOT="0" KEYWORDS="~amd64 ~x86" IUSE="32bit alsa cdaudio debug dedicated demo dynamic hexenworld gtk gtk2 lights \ opengl optimize-cflags oss sdlaudio sdlcd timidity tools" QA_EXECSTACK="${GAMES_BINDIR:1}/hexen2 ${GAMES_BINDIR:1}/hexen2-demo ${GAMES_BINDIR:1}/hwcl ${GAMES_BINDIR:1}/hwcl-demo" # amd64 needs opengl - software rendering does not compile. UIDEPEND=">=media-libs/libsdl-1.2.7 >=media-libs/sdl-mixer-1.2.5 alsa? ( >=media-libs/alsa-lib-1.0.7 ) opengl? ( virtual/opengl ) timidity? ( media-sound/timidity++ ) amd64? ( virtual/opengl ) 32bit? ( amd64? ( app-emulation/emul-linux-x86-sdl ) )" # Launcher depends from GTK+ libs LNCHDEPEND="gtk? ( =x11-libs/gtk+-1* ) gtk2? ( =x11-libs/gtk+-2* )" # xdelta is needed to manually run the patch script RDEPEND="${UIDEPEND} ${LNCHDEPEND} demo? ( >=games-fps/hexen2-demodata-${DEMO_PV} ) lights? ( games-fps/hexen2-lights ) >=dev-util/xdelta-1.1.3-r1" DEPEND="${UIDEPEND} ${LNCHDEPEND} x86? ( >=dev-lang/nasm-0.98.38 )" S=${WORKDIR}/hexen2source-${MY_PV} dir=${GAMES_DATADIR}/${MY_PN} pkg_setup() { games_pkg_setup if use timidity ; then if ! built_with_use "media-libs/sdl-mixer" timidity ; then eerror "Recompile media-libs/sdl-mixer with 'timidity' USE flag." die "sdl-mixer without timidity support detected" fi if use sdlaudio ; then ewarn "timidity (midi music) does not work with sdlaudio." fi else ewarn "timidity is needed if midi music is desired." fi if ! use alsa ; then ewarn "alsa is the recommended sound driver." fi } src_unpack() { unpack ${A} cd "${S}" # Whether to use the demo directory local demo use demo && demo="/demo" # Use default basedir - has 2 variations sed -i \ -e "s:parms.basedir = cwd;:parms.basedir = \"${dir}${demo}\";:" \ -e "s:parms.basedir = \".\";:parms.basedir = \"${dir}${demo}\";:" \ {hexen2,hexen2/server,hexenworld/{Client,Server}}/sys_unix.c \ || die "sed sys_unix.c failed" # Change default sndspeed from 11025 to 44100, # to improve the quality/reliability. sed -i \ -e "s:desired_speed = 11025:desired_speed = 44100:" \ {hexen2,hexenworld/Client}/snd_dma.c || die "sed snd_dma.c failed" # Change patch script to be suitable sed -i \ -e "s:chmod :#chmod :" \ -e 's:"xdelta113":"/usr/bin/xdelta":' \ -e "s:./xdelta113:xdelta": \ "${WORKDIR}"/update_xdelta.sh || die "sed update_xdelta.sh failed" if use demo ; then # Allow lightmaps in demo sed -i \ -e "s:!override_pack:0:" \ hexen2/common.c || die "sed common.c demo failed" fi if use gtk || use gtk2 ; then local demo use demo && demo="-demo" #Build the launcher, so fix the binary paths sed -i \ -e "/H2_BINARY_NAME/s:hexen2:${GAMES_BINDIR}/hexen2${demo}:" \ -e "/HW_BINARY_NAME/s:hwcl:${GAMES_BINDIR}/hwcl${demo}:" \ launcher/launcher_defs.h || die "sed launcher_defs.h failed" sed -i \ -e 's:"gl":"":' \ launcher/launch_bin.c || die "sed launch_bin.c failed" fi rm -rf docs/{activision,COMPILE,COPYING,LICENSE,README.win32} } src_compile() { yesno() { useq $1 && echo yes || echo no ; } local gl_prefix link_gl_libs="no" opts # Prefix to make OpenGL instead of software-rendered binaries if use opengl || use amd64 ; then gl_prefix="gl" link_gl_libs=$(yesno dynamic) fi use debug && opts="${opts} DEBUG=1" use demo && opts="${opts} DEMO=1" if use gtk || use gtk2 ; then local gtk_used # Build launcher cd ${S}/launcher || die einfo "Compiling launcher" # Prefer GTK2 over GTK1 if use gtk && ! use gtk2 ; then gtk_used="GTK1=$(yesno gtk)" fi emake clean || die "emake clean failed" emake \ ${opts} \ ${gtk_used} \ CPUFLAGS="${CFLAGS}" \ CC="$(tc-getCC)" \ || die "emake launcher failed" fi if use tools ; then # Build Hexen2 utils cd "${S}/utils" || die einfo "Compiling utils" ./build.sh clean local utils_list="hcc maputils genmodel qfiles dcc jsh2color hcc_old" for x in ${utils_list} do make -C ${x} \ ${opts} \ CPUFLAGS="${CFLAGS}" \ CC="$(tc-getCC)" \ || die "emake ${x} failed" done fi if use dedicated ; then # Dedicated Server cd "${S}/${MY_PN}" || die einfo "Compiling Dedicated Server" emake clean || die "emake clean failed" emake \ ${opts} \ OPT_EXTRA=$(yesno optimize-cflags) \ CPUFLAGS="${CFLAGS}" \ CC="$(tc-getCC)" \ -f Makefile.sv \ || die "emake dedicated failed" fi if use hexenworld ; then if use tools; then # Hexenworld utils local hw_utils="hwmquery hwrcon" einfo "Compiling Hexenworld utils" cd "${S}"/hw_utils || die for x in ${hw_utils} do emake \ ${opts} \ CPUFLAGS="${CFLAGS}" \ CC="$(tc-getCC)" \ -C ${x} \ || die "emake ${x} failed" done fi # Hexenworld einfo "Compiling Hexenworld" cd "${S}"/hexenworld || die # Hexenworld servers emake \ ${opts} \ CPUFLAGS="${CFLAGS}" \ CC="$(tc-getCC)" \ -C Server \ || die "emake Server failed" emake \ ${opts} \ CPUFLAGS="${CFLAGS}" \ CC="$(tc-getCC)" \ -C Master \ || die "emake Master failed" # if "32bit" enabled and on amd64, we need to link against a 32-bit SDL use 32bit && use amd64 && multilib_toolchain_setup x86 # Hexenworld client emake \ ${opts} \ USE_ALSA=$(yesno alsa) \ USE_OSS=$(yesno oss) \ USE_CDAUDIO=$(yesno cdaudio) \ USE_MIDI=$(yesno timidity) \ USE_SDLAUDIO=$(yesno sdlaudio) \ USE_SDLCD=$(yesno sdlcd) \ USE_X86_ASM=$(yesno x86) \ OPT_EXTRA=$(yesno optimize-cflags) \ LINK_GL_LIBS=${link_gl_libs} \ COMPILE_32BITS=$(yesno 32bit) \ CPUFLAGS="${CFLAGS}" \ CC="$(tc-getCC)" \ HW_BINARY=hwcl \ GLHW_BINARY=hwcl \ ${gl_prefix}hw \ -C Client \ || die "emake Client failed" fi # Hexen cd "${S}/${MY_PN}" || die # if "32bit" enabled and on amd64, we need to link against a 32-bit SDL use 32bit && use amd64 && multilib_toolchain_setup x86 einfo "Compiling main program" emake clean || die "emake clean failed" emake \ ${opts} \ USE_ALSA=$(yesno alsa) \ USE_OSS=$(yesno oss) \ USE_CDAUDIO=$(yesno cdaudio) \ USE_MIDI=$(yesno timidity) \ USE_SDLAUDIO=$(yesno sdlaudio) \ USE_SDLCD=$(yesno sdlcd) \ USE_X86_ASM=$(yesno x86) \ OPT_EXTRA=$(yesno optimize-cflags) \ LINK_GL_LIBS=${link_gl_libs} \ COMPILE_32BITS=$(yesno 32bit) \ CPUFLAGS="${CFLAGS}" \ CC="$(tc-getCC)" \ GLH2_BINARY=${MY_PN} \ ${gl_prefix}h2 \ || die "emake hexen2 failed" } src_install() { local demo demo_title demo_suffix use demo && demo="-demo" && demo_title=" (Demo)" && demo_suffix="demo" newgamesbin "${MY_PN}/${MY_PN}" "${MY_PN}${demo}" \ || die "newgamesbin ${MY_PN} failed" newicon hexen2/icons/h2_32x32x4.png ${PN}.png || die make_desktop_entry "${MY_PN}${demo}" "Hexen 2${demo_title}" ${PN}.png if use dedicated ; then newgamesbin "${MY_PN}"/h2ded "${MY_PN}${demo}-ded" \ || die "newgamesbin h2ded failed" fi if use hexenworld ; then if use tools; then # Hexenworld utils dobin hw_utils/hwmquery/hwmquery || die "dobin hwmquery failed" dobin hw_utils/hwrcon/{hwrcon,hwterm} || die "dobin hwrcon/hwterm failed" dodoc hw_utils/hwmquery/hwmquery.txt || die "dodoc hwmquery.txt failed" dodoc hw_utils/hwrcon/{hwrcon,hwterm}.txt \ || die "dodoc hwrcon/hwterm.txt failed" fi # Hexenworld newgamesbin hexenworld/Server/hwsv hwsv${demo} \ || die "newgamesbin hwsv failed" newgamesbin hexenworld/Master/hwmaster hwmaster${demo} \ || die "newgamesbin hwmaster failed" newgamesbin hexenworld/Client/hwcl hwcl${demo} \ || die "newgamesbin hwcl failed" newicon hexenworld/icons/hw2_32x32x8.png hwcl.png || die make_desktop_entry \ "hwcl${demo}" "Hexen 2${demo_title} Hexenworld Client" hwcl.png insinto "${dir}"/${demo_suffix} doins -r "${WORKDIR}"/hw || die "doins hexenworld pak failed" fi if use gtk || use gtk2 ; then local lnch_prfx lnch_name="h2launcher" ! use gtk2 && use gtk && lnch_prfx=".gtk1" use demo && lnch_name="h2demo" newgamesbin launcher/${lnch_name}${lnch_prfx} h2launcher \ || die "dogamesbin h2launcher failed" make_desktop_entry \ "h2launcher" "Hexen 2${demo_title} Launcher" ${PN}.png fi dodoc docs/* if ! use demo ; then # Install updated game data insinto "${dir}" doins -r "${WORKDIR}"/{data1,patchdata,portals,siege} || die # Patching should really be done by a future "hexen2-data" ebuild. # But this works for now. doins "${WORKDIR}"/update_xdelta.sh || die dodoc "${WORKDIR}"/*.txt fi if use tools ; then dobin \ utils/bin/{bspinfo,dhcc,genmodel,hcc,jsh2colour,light,qbsp,qfiles,vis} \ || die "dobin utils failed" newbin utils/hcc_old/hcc hcc_old || die "newbin hcc_old failed" docinto utils dodoc utils/README || die "dodoc README failed" dodoc utils/bin/hcc.txt || die "dodoc hcc.txt failed" newdoc utils/dcc/README README.dcc || die "newdoc dcc.txt failed" dodoc utils/dcc/dcc.txt || die "dodoc dcc.txt failed" newdoc utils/hcc_old/README hcc_old.txt || die "newdoc hcc_old failed" newdoc utils/jsh2color/README README.jsh2color \ || die "newdoc README.jsh2color failed" newdoc utils/jsh2color/ChangeLog ChangeLog.jsh2color \ || die "newdoc Changelog.jsh2color failed" fi prepgamesdirs } pkg_postinst() { games_pkg_postinst if ! use timidity ; then elog "MIDI music requires the 'timidity' USE flag." elog fi if use demo ; then elog "uhexen2 has been compiled specifically to play the demo maps." elog "Example command-line:" elog " hexen2-demo -width 1024 -height 768 -conwidth 640" echo else elog "To play the demo, emerge with the 'demo' USE flag." elog elog "For the Hexen 2 original game..." elog "Put the following files into ${dir}/data1 before playing:" elog " pak0.pak pak1.pak" elog "Then to play: hexen2" elog elog "For the 'Portal of Praevus' mission pack..." elog "Put the following file into ${dir}/portals before playing:" elog " pak3.pak" elog "Then to play: hexen2 -portals" elog elog "To ensure the data files from the CD are patched, run as root:" elog " cd ${dir} && sh update_xdelta.sh" elog elog "Example command-line:" elog " hexen2 -width 1024 -height 768 -conwidth 640" echo fi if use tools; then if use hexenworld; then elog elog "You've also installed some Hexenworld utility:" elog elog " - hwmquery (console app to query HW master servers)" elog " - hwrcon (remote interface to HW rcon command)" elog " - hwterm (HW remote console terminal)" fi elog elog "You've also installed some Hexen2 utility" elog "(useful for mod developing)" elog elog " - dhcc (old progs.dat compiler/decompiler" elog " - genmodel (3-D model grabber" elog " - hcc (HexenC compiler)" elog " - hcc_old (old version of HexenC compiler)" elog " - jsh2color (light colouring utility)" elog " - maputils (Map compiling tools: bspinfo, light, qbsp, vis)" elog " - qfiles (build pak files and regenerate bsp models)" elog elog "See relevant documentation for further informations" fi }