# 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 MY_PN="hexen2" DESCRIPTION="Hexen 2 port - Hammer of Thyrion" HOMEPAGE="http://uhexen2.sourceforge.net/" SRC_URI="mirror://sourceforge/uhexen2/hexen2source-${PV}.tgz" LICENSE="GPL-2" SLOT="0" KEYWORDS="~amd64 ~x86" IUSE="alsa debug demo dynamic lights opengl sdlcd timidity" QA_EXECSTACK="${GAMES_BINDIR:1}/hexen2 ${GAMES_BINDIR:1}/hexen2-demo ${GAMES_BINDIR:1}/hwcl" UIDEPEND=">=media-libs/libsdl-1.2.7 >=media-libs/sdl-mixer-1.2.5 amd64? ( >=app-emulation/emul-linux-x86-sdl-2.1 ) alsa? ( >=media-libs/alsa-lib-1.0.7 ) opengl? ( virtual/opengl ) timidity? ( media-sound/timidity++ ) || ( ( x11-libs/libX11 x11-libs/libXau x11-libs/libXdmcp x11-libs/libXext ) virtual/x11 )" RDEPEND="${UIDEPEND} demo? ( games-fps/hexen2-demodata ) lights? ( games-fps/hexen2-lights )" 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 amd64 ; then if ! has_m32 ; then eerror "Your compiler seems to be unable to compile 32-bit code." eerror "Make sure you compile gcc with:" eerror " USE=multilib FEATURES=-sandbox" die "Cannot produce 32-bit code." fi if has_multilib_profile ; then export ABI=x86 else append-flags -m32 append-ldflags -m32 fi fi if use timidity ; then if ! built_with_use "media-libs/sdl-mixer" timidity ; then eerror "Recompile media-libs/sdl-mixer with the 'timidity' USE flag." die "sdl-mixer without timidity detected." fi fi } src_unpack() { unpack ${A} cd "${S}" local demo use demo && demo="/demo" # Use default basedir sed -i {hexen2,hexenworld/Client}/common.c \ -e "s:strcpy (com_basedir, host_parms.basedir):strcpy (com_basedir, \"${dir}${demo}\"):" \ || die "sed common.c failed" # Change default sndspeed from 11025 to 44100, to improve the quality/reliability. sed -i {hexen2,hexenworld/Client}/snd_dma.c \ -e "s:desired_speed = 11025:desired_speed = 44100:" \ || die "sed snd_dma.c failed" if use demo ; then # Allow lightmaps in demo sed -i hexen2/common.c \ -e "s:!override_pack:0:" \ || die "sed common.c demo failed" fi if ! use x86 ; then sed -i {hexen2,hexenworld/Client}/Makefile \ -e "s:USE_X86_ASM=yes:USE_X86_ASM=no:" \ || die "sed Makefiles 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 use opengl && gl_prefix="gl" && link_gl_libs=$(yesno dynamic) use debug && opts="${opts} DEBUG=1" use demo && opts="${opts} DEMO=1" # Hexen cd "${MY_PN}" emake clean || die "emake clean failed" emake ${opts} \ USE_ALSA=$(yesno alsa) \ USE_MIDI=$(yesno timidity) \ USE_SDLCD=$(yesno sdlcd) \ LINK_GL_LIBS=${link_gl_libs} \ CC="$(tc-getCC)" \ GLH2_BINARY=${MY_PN} \ ${gl_prefix}h2 \ || die "emake failed" # Hexenworld cd "${S}"/hexenworld ./build.sh || die "build.sh failed" } 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" # Hexenworld dogamesbin hexenworld/Server/hwsv \ || die "dogamesbin hwsv failed" dogamesbin hexenworld/Master/hwmaster \ || die "dogamesbin hwmaster failed" newgamesbin "hexenworld/Client/${GL_PREFIX}hwcl" hwcl \ || die "newgamesbin hwcl failed" newicon hexen2/icons/h2_32x32x4.png ${PN}.png make_desktop_entry "${MY_PN}${demo}" "Hexen 2${demo_title}" ${PN}.png use demo || keepdir "${dir}"/{data1,portals} 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" elog 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 ${GAMES_DATADIR}/hexen2/data1 before playing:" elog " hexen.rc pak0.pak pak1.pak progs.dat progs2.dat strings.txt" elog "You may need to patch the data files to version 1.11 using 'update_h2' in:" elog " http://prdownloads.sourceforge.net/uhexen2/hexen2-1.3.0-linux.i586.tgz" elog "Then to play: hexen2" elog elog "For the 'Portal of Praevus' mission pack..." elog "Put the following files into ${GAMES_DATADIR}/hexen2/portals before playing:" elog " default.cfg hexen.rc pak3.pak progs.dat puzzles.txt strings.txt" elog "Then to play: hexen2 -portals" elog elog "Example command-line:" elog " hexen2 -width 1024 -height 768" echo fi }