# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils toolchain-funcs versionator games MY_PV=$(delete_all_version_separators) MY_PN="quake2" FILE_STEM="KMQuake2_${MY_PV}_src_unix" DATA_STEM="KMQuake2_data-${PV}" DESCRIPTION="Enhanced Quake 2 engine with Lazarus mod support" HOMEPAGE="http://qexpo2005.quakedev.com/booths.php?tag=knightmare http://qudos.quakedev.com/" SRC_URI="http://qudos.quakedev.com/linux/quake2/engines/KMQuake2/${FILE_STEM}.tar.bz2 http://qudos.quakedev.com/linux/quake2/engines/KMQuake2/${DATA_STEM}.tar" LICENSE="GPL-2" SLOT="0" KEYWORDS="~amd64 ~x86" IUSE="cdinstall debug dedicated demo maps mods opengl sdl textures" QA_EXECSTACK="${GAMES_BINDIR:1}/${PN}" UIRDEPEND="media-libs/alsa-lib media-libs/openal media-libs/jpeg media-libs/libogg media-libs/libpng media-libs/libvorbis virtual/opengl virtual/glu sdl? ( media-libs/libsdl ) x11-libs/libX11 x11-libs/libXext x11-libs/libXxf86dga x11-libs/libXxf86vm" UIDEPEND="${UIRDEPEND} x11-proto/xf86dgaproto x11-proto/xf86vidmodeproto x11-proto/xproto" RDEPEND="opengl? ( ${UIRDEPEND} ) !opengl? ( sdl? ( ${UIRDEPEND} ) ) !opengl? ( !sdl? ( !dedicated? ( ${UIRDEPEND} ) ) ) cdinstall? ( games-fps/quake2-data ) demo? ( games-fps/quake2-demodata ) maps? ( games-fps/kmquake2-shanmaps ) mods? ( games-fps/kmquake2-mods ) textures? ( games-fps/quake2-textures )" DEPEND="opengl? ( ${UIDEPEND} ) !opengl? ( sdl? ( ${UIDEPEND} ) ) !opengl? ( !sdl? ( !dedicated? ( ${UIDEPEND} ) ) ) app-arch/unzip" S=${WORKDIR}/${FILE_STEM} dir=${GAMES_DATADIR}/${MY_PN} libdir=${GAMES_LIBDIR}/${PN} build_client() { if use opengl || use sdl || ! use dedicated ; then # Build default client return 0 fi return 1 } src_unpack() { unpack ${A} cd "${S}" # Fix link to header sed -i \ -e "s:altypes\.h:al\.h:" \ client/snd_loc.h || die "sed snd_loc.h failed" # Fix directory search for the game API sed -i \ -e 's:"%s/%s/%s", curpath, path, gamename:"%s/%s", path, gamename:' \ unix/sys_unix.c || die "sed sys_unix.c failed" rm gnu.txt mv "${WORKDIR}/${DATA_STEM}/${PN}.png" "${WORKDIR}" } src_compile() { yesno() { useq $1 && echo YES || echo NO ; } local client="YES" build_client || client="NO" local target="release" use debug && target="debug" local opengl="NO" sdl="NO" if build_client ; then if use sdl ; then sdl="YES" else opengl="YES" fi fi emake \ BUILD_DEDICATED=$(yesno dedicated) \ BUILD_KMQUAKE2=${opengl} \ BUILD_KMQUAKE2_SDL=${sdl} \ DATADIR="${dir}" \ LIBDIR="${libdir}" \ LOCALBASE="/usr" \ CC="$(tc-getCC)" \ BUILD_DATADIR=YES \ BUILD_LIBDIR=YES \ "${target}" \ || die "emake failed" } src_install() { local icon=${PN}.png insinto "${libdir}" doins -r "${WORKDIR}/${DATA_STEM}"/* \ || die "doins ${DATA_STEM} failed" doins -r quake2/baseq2 \ || die "doins quake2/baseq2 failed" doicon "${WORKDIR}/${icon}" || die "doicon failed" if build_client ; then if use sdl ; then newgamesbin ${MY_PN}/${PN}-sdl ${PN} \ || die "newgamesbin ${PN}-sdl failed" else dogamesbin ${MY_PN}/${PN} \ || die "dogamesbin ${PN} failed" fi if use demo ; then games_make_wrapper ${PN}-demo "${PN} +set game demo" make_desktop_entry ${PN}-demo "KM Quake 2 (Demo)" "${icon}" else make_desktop_entry ${PN} "KM Quake 2" "${icon}" fi fi if use dedicated ; then newgamesbin ${MY_PN}/${PN}_netserver ${PN}-ded \ || die "newgamesbin ${PN}_netserver failed" fi dodoc *.{txt,unix} prepgamesdirs }