2024-05-04 14:16:34 +02:00
# Copyright 1999-2024 Gentoo Authors
2020-05-16 21:33:10 +02:00
# Distributed under the terms of the GNU General Public License v2
2024-03-31 17:18:18 +02:00
EAPI = 8
2024-04-01 09:52:44 +02:00
inherit flag-o-matic unpacker desktop
2024-03-31 17:18:18 +02:00
# This is the only known version of the engine to work with this mod
ENGINE_PV = "20170829_beta1"
ENGINE_SOURCE = " darkplacesenginesource ${ ENGINE_PV } .tar.gz "
2020-05-16 21:33:10 +02:00
DESCRIPTION = "A mod that makes Quake faster paced, harder, gorier and more violent."
2024-03-31 17:18:18 +02:00
HOMEPAGE = "https://www.moddb.com/mods/quake-15 https://icculus.org/twilight/darkplaces"
GIT_COMMIT = "175af02fa8e6bc5c14ebac952c6925f9328c2348"
2020-05-16 21:33:10 +02:00
SRC_URI = "
2024-03-31 17:18:18 +02:00
https://github.com/DarkPlacesEngine/darkplaces/archive/${ GIT_COMMIT } .tar.gz -> " ${ ENGINE_SOURCE } "
https://archive.org/download/quake15-mirror/Q15_PublicBeta1.7z
https://archive.org/download/quake15-mirror/patch2.7z -> Q15_patch2.7z
https://icculus.org/%7Emarco/sources/lmp2tga.c
2020-05-16 21:33:10 +02:00
"
2024-03-31 17:18:18 +02:00
LICENSE = "GPL-2 UNKNOWN"
2020-05-16 21:33:10 +02:00
SLOT = "0"
2024-03-31 17:18:18 +02:00
# DarkPlaces' PNG is broken on big endian and this mod unfortunately uses PNG a lot. Sorry :(
KEYWORDS = "~amd64 ~arm64 ~x86"
2024-05-04 14:16:34 +02:00
IUSE = "alsa capture cdda cpu_flags_x86_sse cpu_flags_x86_sse2 debug dedicated ipv6 opengl oss sdl textures"
2020-05-16 21:33:10 +02:00
2024-03-31 17:18:18 +02:00
REQUIRED_USE = "
alsa? ( !oss )
oss? ( !alsa )
|| ( alsa oss sdl )
^^ ( opengl sdl )
amd64? (
cpu_flags_x86_sse
cpu_flags_x86_sse2
)
"
GLX_RDEPEND = "
x11-libs/libX11
x11-libs/libXpm
x11-libs/libXext
x11-libs/libXxf86vm
virtual/opengl
alsa? ( media-libs/alsa-lib )
media-libs/libogg
media-libs/libvorbis
capture? ( media-libs/libtheora[ encode] )
!capture? ( media-libs/libtheora )
"
SDL_RDEPEND = "
media-libs/libsdl2[ udev]
x11-libs/libX11
alsa? ( media-libs/alsa-lib )
media-libs/libogg
media-libs/libvorbis
capture? ( media-libs/libtheora[ encode] )
!capture? ( media-libs/libtheora )
"
RDEPEND = "
dev-libs/d0_blind_id
dev-games/ode
net-misc/curl
2024-04-01 09:52:44 +02:00
media-libs/libjpeg-turbo
2024-03-31 17:18:18 +02:00
sys-libs/zlib
media-libs/libpng
textures? ( >= games-fps/quake1-textures-20050820 )
opengl? ( ${ GLX_RDEPEND } )
sdl? ( ${ SDL_RDEPEND } )
"
BDEPEND = "
opengl? (
sys-devel/gcc
media-gfx/imagemagick
app-arch/unzip
)
sdl? (
sys-devel/gcc
media-gfx/imagemagick
app-arch/unzip
)
app-arch/p7zip
app-alternatives/tar
app-alternatives/gzip
sys-apps/coreutils
sys-devel/patch
sys-apps/sed
virtual/pkgconfig
"
2020-05-16 21:33:10 +02:00
S = " ${ WORKDIR } "
2024-03-31 17:18:18 +02:00
WAD_DIR = "/usr/share/quake15"
src_unpack( ) {
mkdir engine
tar -C engine --strip-components 1 -xf " ${ DISTDIR } / ${ ENGINE_SOURCE } "
7z x " ${ DISTDIR } /Q15_PublicBeta1.7z " quake15
7z x -y " ${ DISTDIR } /Q15_patch2.7z " quake15
ln -s /usr/share/quake1/id1/sound quake15/sound
}
src_prepare( ) {
default
cd " ${ S } /engine "
rm mingw_note.txt
strip-flags
patch -p1 -i " ${ FILESDIR } /0010-fix-dpsoftras-alignment.patch "
patch -p1 -i " ${ FILESDIR } /0020-do-not-assume-sse2-is-available-just-because-sse-is-available.patch "
# Only additional CFLAGS optimization is the -march flag
local march = $( get-flag -march)
sed -i \
-e " s:-lasound: $( pkg-config --libs alsa) : " \
-e "/^CPUOPTIMIZATIONS/d" \
-e '/^OPTIM_RELEASE/s/=.*/=$(CFLAGS)/' \
-e '/^OPTIM_DEBUG/s/=.*/=$(CFLAGS)/' \
-e '/^LDFLAGS_DEBUG/s/$/ $(LDFLAGS)/' \
-e '/^LDFLAGS_RELEASE/s/$/ $(LDFLAGS)/' \
-e "s:strip:true:" \
makefile.inc || die
if ! use cdda; then
elog "CD support: disabled"
sed -i \
-e "s:/dev/cdrom:/dev/null:" \
cd_linux.c || die
sed -i \
-e 's:COM_CheckParm("-nocdaudio"):1:' \
cd_shared.c || die
else
elog "CD support: enabled"
fi
if ! use ipv6; then
elog "IPv6 support: disabled"
sed -i 's/^#\(CFLAGS_NET+=-DNOSUPPORTIPV6\)$/\1/' makefile || die
else
elog "IPv6 support: enabled"
fi
patch -p1 -i " ${ FILESDIR } /0030-builddate-template.patch "
sed -i " s/%{PVR}/ ${ ENGINE_PV } / " builddate.c || die
patch -p1 -i " ${ FILESDIR } /0040-enforce-quake15.patch "
}
src_compile( ) {
local video_capture = "disabled"
if use capture; then
elog "Video capture: enabled"
video_capture = "enabled"
else
elog "Video capture: disabled"
fi
local sse_enabled = 0
local sse2_enabled = 0
if use cpu_flags_x86_sse; then
elog "Skeletal animations: uses SSE"
sse_enabled = 1
else
if use amd64; then
elog "Skeletal animations: uses SSE, not disabling on AMD64"
sse_enabled = 1
else
elog "Skeletal animations: uses generic code"
fi
fi
if use cpu_flags_x86_sse2; then
elog "Softrender: uses SSE2"
sse2_enabled = 1
else
if use amd64; then
elog "Softrender: uses SSE2, not disabling on AMD64"
sse2_enabled = 1
else
elog "Softrender: disabled"
fi
fi
local opts = " DP_FS_BASEDIR=\" ${ WAD_DIR } \" \
DP_LINK_JPEG = shared \
DP_LINK_CRYPTO = shared \
DP_LINK_CRYPTO_RIJNDAEL = shared \
DP_LINK_ZLIB = shared \
DP_LINK_ODE = shared \
DP_VIDEO_CAPTURE = ${ video_capture } \
DP_PRELOAD_DEPENDENCIES = 1 \
GENTOO_BUILD = 1 \
DP_SSE = ${ sse_enabled } \
DP_SSE2 = ${ sse2_enabled } \
FORCEGAME = quake15"
# If neither OSS or ALSA are selected, then SDL must be selected.
2024-04-01 09:52:44 +02:00
# However, SDL is a backend for both graphics and sound - so not
# having ALSA or OSS is only an option, if OpenGL is not.
2024-03-31 17:18:18 +02:00
local sound_api = "NULL"
if use oss; then
sound_api = "OSS"
elif use alsa; then
sound_api = "ALSA"
elif ! use sdl; then
die "No sound API has been selected."
fi
opts += " DP_SOUND_API= ${ sound_api } "
local type = "release"
if use debug; then
type = "debug"
fi
ln -s /usr/share/quake1/id1 id1
# Only compile a maximum of 1 client
2024-04-01 09:52:44 +02:00
pushd " ${ WORKDIR } /engine "
2024-03-31 17:18:18 +02:00
local compile_client = false
if use sdl; then
compile_client = true
emake ${ opts } " sdl- ${ type } "
elif use opengl; then
compile_client = true
emake ${ opts } " cl- ${ type } "
fi
if use dedicated; then
emake ${ opts } " sv- ${ type } "
fi
2024-04-01 09:52:44 +02:00
popd
2024-03-31 17:18:18 +02:00
if ${ compile_client } ; then
2024-04-01 09:52:44 +02:00
pushd " ${ WORKDIR } "
2024-03-31 17:18:18 +02:00
unzip -j quake15/q15.pk3 gfx/qplaque.lmp
2024-04-01 09:52:44 +02:00
gcc " ${ DISTDIR } /lmp2tga.c " -o lmp2tga
2024-03-31 17:18:18 +02:00
./lmp2tga qplaque.lmp
2024-04-01 09:52:44 +02:00
convert qplaque.tga -gravity North -chop 0x112 " ${ WORKDIR } /engine/ ${ PN } .png "
popd
2024-03-31 17:18:18 +02:00
fi
}
2020-05-16 21:33:10 +02:00
src_install( ) {
2024-03-31 17:18:18 +02:00
pushd " ${ WORKDIR } /engine "
if use opengl || use sdl ; then
local type = $( use sdl && echo "sdl" || echo "glx" )
newbin " darkplaces- ${ type } " ${ PN }
newicon ${ PN } .png ${ PN } .png
make_desktop_entry ${ PN } "Quake 1.5"
fi
if use dedicated; then
newbin darkplaces-dedicated ${ PN } -ded
fi
dodoc *.txt todo " ${ WORKDIR } " /engine/*.txt
popd
insinto " ${ WAD_DIR } "
doins id1
2020-05-16 21:33:10 +02:00
doins -r quake15
}
pkg_postinst( ) {
2024-05-04 14:16:34 +02:00
elog "Please make sure that the path /usr/share/quake1/id1 exists and place pak0.pak and pak1.pak in /usr/share/quake1/id1"
if use cdda; then
elog "If you wish to have the original soundtrack available without playing from an optical drive, please make sure that the path /usr/share/quake1/id1/sound/cdtracks exists, and that it contains the original soundtrack. The expected filename schema is track%i.%s with a double-digit count, either in WAV RIFF or OGG Vorbis format."
2024-03-31 17:18:18 +02:00
fi
if use sdl && ! use alsa; then
einfo "If audio latency is an issue, consider choosing OpenGL and ALSA USE flags instead of SDL."
fi
2020-05-16 21:33:10 +02:00
}