# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils flag-o-matic versionator games MOD_V="20060606" MY_PV=$(replace_version_separator 1 '' ) MY_LIGHTS="fuhquake-lits.rar" MY_ENGINE="${PN}engine${MY_PV}.zip" MY_MOD="${PN}mod${MOD_V}.zip" MY_SKINS="SKINSbmodels-48files-4-23-05.zip" MY_TEXTURES="textures-486files-8-20-05.rar" DESCRIPTION="Enhanced engine for iD Software's Quake 1" HOMEPAGE="http://icculus.org/twilight/darkplaces/" SRC_URI="http://icculus.org/twilight/${PN}/files/${MY_ENGINE} mod? ( http://icculus.org/twilight/${PN}/files/${MY_MOD} ) lights? ( http://www.fuhquake.net/files/extras/${MY_LIGHTS} ) skins? ( http://facelift.quakedev.com/download/${MY_SKINS} ) textures? ( http://facelift.quakedev.com/download/${MY_TEXTURES} )" LICENSE="GPL-2" SLOT="0" KEYWORDS="~amd64 ~x86" IUSE="alsa cdinstall cdsound dedicated lights mod opengl oss sdl skins textures" RESTRICT="primaryuri strip" RDEPEND="sys-libs/glibc alsa? ( media-libs/alsa-lib ) cdinstall? ( games-fps/quake1-data ) opengl? ( virtual/opengl || ( ( x11-libs/libX11 x11-libs/libXau x11-libs/libXdmcp x11-libs/libXext x11-libs/libXxf86dga x11-libs/libXxf86vm ) virtual/x11 ) ) sdl? ( media-libs/libsdl media-libs/sdl-mixer || ( ( x11-libs/libX11 x11-libs/libXau x11-libs/libXdmcp x11-libs/libXext ) virtual/x11 ) )" DEPEND="${RDEPEND} app-arch/unzip" S=${WORKDIR}/${PN} dir=${GAMES_DATADIR}/quake1 pkg_setup() { games_pkg_setup # A gamer should have opengl and/or sdl in the /etc/make.conf USE flags. (use opengl || use sdl || use dedicated) || \ die "At least one of the USE flags 'opengl', 'sdl' and 'dedicated' are required." } src_unpack() { cd "${WORKDIR}" unpack "${MY_ENGINE}" if use mod ; then unpack "${MY_MOD}" fi mkdir maps textures if use lights ; then unpack "${MY_LIGHTS}" mv *.lit maps fi if use skins ; then unpack "${MY_SKINS}" mv *.tga textures mv readme.txt skins.txt fi if use textures ; then unpack "${MY_TEXTURES}" mv *.tga textures fi unpack ./${PN}*.zip find "${WORKDIR}" -name CVS -type d | xargs rm -r cd "${S}" # Make the game automatically look in the correct data directory sed -i fs.c \ -e "s:strcpy(fs_basedir, \"\"):strcpy(fs_basedir, \"${dir}\"):" \ || die "sed fs.c failed" # Only additional CFLAGS optimization is the -march flag local march=$(get-flag -march) sed -i makefile.inc \ -e '/^CC=/d' \ -e "s:-lasound:$(pkg-config --libs alsa):" \ -e "s:CPUOPTIMIZATIONS=:CPUOPTIMIZATIONS=${march}:" \ || die "sed makefile.inc failed" if ! use cdsound ; then sed -i "s:cd_linux.o:\$(OBJ_NOCD):" makefile.inc \ || die "sed cdsound failed" fi # Reduce SDL audio buffer, to fix latency sed -i "s:requested->speed / 20.0:512:" snd_sdl.c \ || die "sed snd_sdl.c failed" # Default sound is alsa. if ! use alsa ; then if use oss ; then sed -i "s:DEFAULT_SNDAPI=ALSA:DEFAULT_SNDAPI=OSS:" makefile \ || die "sed oss failed" else sed -i "s:DEFAULT_SNDAPI=ALSA:DEFAULT_SNDAPI=NULL:" makefile \ || die "sed null failed" fi fi } src_compile() { if use opengl ; then emake cl-release || die "emake cl-release failed" fi if use sdl ; then emake sdl-release || die "emake sdl-release failed" fi if use dedicated ; then emake sv-release || die "emake sv-release failed" fi } src_install() { if use opengl || use sdl ; then newicon darkplaces72x72.png ${PN}.png fi if use opengl ; then dogamesbin ${PN}-glx || die "dogamesbin glx failed" make_desktop_entry ${PN}-glx "Dark Places" ${PN}.png fi if use sdl ; then dogamesbin ${PN}-sdl || die "dogamesbin sdl failed" make_desktop_entry ${PN}-sdl "Dark Places (SDL)" ${PN}.png fi if use dedicated ; then newgamesbin ${PN}-dedicated ${PN}-ded || die "newgamesbin ded failed" fi if use mod ; then insinto "${dir}" doins -r "${WORKDIR}"/dpmod || die "doins dpmod failed" fi if use lights || use skins || use textures ; then insinto "${dir}"/id1 doins -r "${WORKDIR}"/{maps,textures} || die "doins maps textures failed" if use skins ; then dodoc "${WORKDIR}"/skins.txt fi fi dodoc ${PN}.txt ChangeLog todo "${WORKDIR}"/{${PN}-cvschangelog,*.qc} prepgamesdirs } pkg_postinst() { games_pkg_postinst if [[ ! -e "${ROOT}/${dir}"/id1/pak0.pak ]] ; then einfo "Put the *.pak data files into "${ROOT}${dir}"/id1" echo fi if use mod ; then einfo "To use the mod, start the game with:" einfo " darkplaces- -game dpmod" einfo "e.g. darkplaces-glx -game dpmod" echo fi }