# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils flag-o-matic toolchain-funcs games DATA_PV="1.16" HW_PV="0.15" MY_PN="hexen2" DESCRIPTION="Hexen 2 port - Hammer of Thyrion" HOMEPAGE="http://uhexen2.sourceforge.net/" SRC_URI="mirror://sourceforge/${PN}/hexen2source-${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="alsa cdaudio debug dedicated demo dynamic hexenworld lights opengl optimize-cflags sdlaudio sdlcd timidity" QA_EXECSTACK="${GAMES_BINDIR:1}/hexen2 ${GAMES_BINDIR:1}/hexen2-demo ${GAMES_BINDIR:1}/hwcl" # 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 ) amd64? ( virtual/opengl ) opengl? ( virtual/opengl ) timidity? ( media-sound/timidity++ )" # xdelta is needed to manually run the patch script RDEPEND="${UIDEPEND} demo? ( >=games-fps/hexen2-demodata-${PV} ) lights? ( games-fps/hexen2-lights ) >=dev-util/xdelta-1.1.3-r1" DEPEND="${UIDEPEND} x86? ( >=dev-lang/nasm-0.98.38 )" S=${WORKDIR}/${MY_PN}source-${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 die "Recompile media-libs/sdl-mixer with 'timidity' USE flag." 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 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" # Hexen cd "${MY_PN}" || die einfo "Compiling Hexen client" emake clean || die "emake clean failed" emake \ ${opts} \ USE_ALSA=$(yesno alsa) \ 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} \ CPUFLAGS="${CFLAGS}" \ CC="$(tc-getCC)" \ GLH2_BINARY=${MY_PN} \ ${gl_prefix}h2 \ || die "emake hexen failed" if use dedicated ; then 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 # Hexenworld einfo "Compiling hexenworld" cd "${S}"/hexenworld || die if use dedicated ; then # 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" fi # Hexenworld client emake \ ${opts} \ USE_ALSA=$(yesno alsa) \ 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} \ CPUFLAGS="${CFLAGS}" \ CC="$(tc-getCC)" \ HW_BINARY=hwcl \ GLHW_BINARY=hwcl \ ${gl_prefix}hw \ -C Client \ || die "emake Client failed" fi } src_install() { local demo demo_title use demo && demo="-demo" && demo_title=" (Demo)" newgamesbin "${MY_PN}/${MY_PN}" "${MY_PN}${demo}" \ || die "newgamesbin ${MY_PN} failed" if use dedicated ; then newgamesbin "${MY_PN}"/h2ded "${MY_PN}${demo}-ded" \ || die "newgamesbin h2ded failed" fi if use hexenworld ; then # Hexenworld if use dedicated ; then newgamesbin hexenworld/Server/hwsv hwsv${demo} \ || die "newgamesbin hwsv failed" newgamesbin hexenworld/Master/hwmaster hwmaster${demo} \ || die "newgamesbin hwmaster failed" fi newgamesbin hexenworld/Client/hwcl hwcl${demo} \ || die "newgamesbin hwcl failed" fi newicon hexen2/icons/h2_32x32x4.png ${PN}.png || die make_desktop_entry "${MY_PN}${demo}" "Hexen 2${demo_title}" ${PN}.png if ! use demo ; then # Install updated game data insinto "${dir}" doins -r "${WORKDIR}"/{data1,hw,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 dodoc docs/* prepgamesdirs } pkg_postinst() { games_pkg_postinst if ! use timidity ; then elog "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 }