summaryrefslogtreecommitdiff
blob: 78c22bdce005a07dff828d8c0c89b3e7e84a3085 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

# FIXME: Patch neo/SConstruct to Python3
PYTHON_COMPAT=( python2_7 )
inherit desktop git-r3 python-any-r1 scons-utils toolchain-funcs

DESCRIPTION="3rd installment of the classic iD 3D first-person shooter"
HOMEPAGE="https://github.com/TTimo/doom3.gpl"
EGIT_REPO_URI="https://github.com/TTimo/doom3.gpl.git"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="debug dedicated opengl"

REQUIRED_USE="|| ( dedicated opengl )"

RDEPEND="sys-libs/glibc
	amd64? ( sys-libs/glibc[multilib] )
	opengl? ( >=virtual/opengl-7.0-r1[abi_x86_32(-)]
		  >=x11-libs/libX11-1.6.2[abi_x86_32(-)]
		  >=x11-libs/libXext-1.3.2[abi_x86_32(-)]
		  >=media-libs/alsa-lib-1.0.27.2[abi_x86_32(-)]
	)"
DEPEND="${RDEPEND}
	sys-devel/m4"

src_prepare() {
	# do we really need Wall spam?
	sed -i -e "/BASECPPFLAGS.append( '-Wall' )/d" neo/SConstruct

	# we supply our own CFLAGS instead of what the release build uses:
	# -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer
	sed -i -e "/OPTCPPFLAGS = \[ '-O3'/d" neo/SConstruct
	sed -i -e "s/BASEFLAGS = ''/BASEFLAGS = \[ '${CXXFLAGS//[${IFS}]/', '}' \]/" neo/SConstruct
	sed -i -e "s/BASELINKFLAGS = \[ \]/BASELINKFLAGS = \[ '${LDFLAGS//[${IFS}]/', '}' \]/" neo/SConstruct

	# fix compilation errors on modern systems
	sed -i -e "s/m_speed - PRIMARYFREQ/(double)(m_speed - PRIMARYFREQ)/" neo/sys/linux/sound.cpp
	sed -i -e "s/HUGE/100000000/" neo/tools/compilers/roqvq/codec.cpp

	eapply "${FILESDIR}/d3_carmacksreverse.patch"
	eapply "${FILESDIR}/d3_nokeycheck.patch"

	eapply_user
}

src_configure() {
	S="${WORKDIR}/${P}/neo"

	# FIXME: disabled curl due to needing 32-bit libz.a
	MYSCONS=(
		CC="$(tc-getCC)"
		CXX="$(tc-getCXX)"
		BUILD="$(usex debug debug release)"
		NOCURL="1"
	)

	if use dedicated; then
		if use opengl; then
			MYSCONS+=( DEDICATED="2" )
		else
			MYSCONS+=( DEDICATED="1" )
		fi
	else
		MYSCONS+=( DEDICATED="0" )
	fi
}

src_compile() {
	escons "${MYSCONS[@]}"
}

src_install() {
	exeinto "/usr/share/doom3"
	newexe gamex86-base.so gamex86.so
	doexe gamex86-d3xp.so

	if use opengl; then
		doexe doom.x86
		doexe sys/linux/setup/image/openurl.sh
		dosym /usr/share/doom3/doom.x86 /usr/bin/doom3
		doicon sys/linux/setup/image/doom3.png
		make_desktop_entry doom3 "Doom III" "doom3" "Game;ActionGame"
	fi

	if use dedicated; then
		doexe doomded.x86
		dosym /usr/share/doom3/doomded.x86 /usr/bin/doom3-dedicated
	fi

	dodoc ../README.txt sys/linux/setup/image/README
}

pkg_postinst() {
	elog "You need to copy the 'base' directory of a fully patched game to"
	elog "/usr/share/doom3/ before running the game."
}