summaryrefslogtreecommitdiff
blob: 72bf8df8241879cac4a0819dbf6b32a6f1c70eb8 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=6 # compiles broken unlinked binaries on EAPI=7??

inherit cmake-utils desktop

MY_COMMIT="10af17" # check tags: https://osdn.net/projects/zandronum/scm/hg/zandronum-stable/tags
##MY_COMMIT_UTC_TIMESTAMP="1504266050"

DESCRIPTION="OpenGL ZDoom port with Client/Server multiplayer"
HOMEPAGE="https://zandronum.com/"
SRC_URI="https://osdn.dl.osdn.net/scmarchive/g/${PN}/hg/${PN}-stable/${MY_COMMIT:0:2}/${MY_COMMIT:2}/${PN}-stable-${MY_COMMIT}.tar.gz"

LICENSE="Sleepycat"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="cpu_flags_x86_mmx dedicated +gtk +opengl timidity"

REQUIRED_USE="|| ( dedicated opengl )
	gtk? ( opengl )
	timidity? ( opengl )"

RDEPEND="gtk? ( x11-libs/gtk+:2 )
	timidity? ( media-sound/timidity++ )
	opengl? ( media-libs/fmod:1
		media-libs/game-music-emu
		media-libs/libsdl[opengl]
		virtual/glu
		virtual/jpeg
		virtual/opengl
	)
	app-arch/bzip2
	dev-db/sqlite
	dev-libs/openssl:0
	media-sound/fluidsynth
	sys-libs/zlib"

DEPEND="${RDEPEND}
	cpu_flags_x86_mmx? ( || ( dev-lang/nasm dev-lang/yasm ) )"

S="${WORKDIR}/${PN}-stable-${MY_COMMIT}"

src_prepare() {
	# Normally Mercurial would generate gitinfo.h for NETGAMEVERSION
	# let's do it without Mercurial
	# NOTE: not currently used for 3.0.1 as compatibility with 3.0 is hardcoded
##	echo "#define HG_REVISION_NUMBER ${MY_COMMIT_UTC_TIMESTAMP}" > src/gitinfo.h
##	echo "#define HG_REVISION_HASH_STRING \"0\"" >> src/gitinfo.h
##	echo "#define HG_TIME \"\"" >> src/gitinfo.h

	# Use system libs
	sed -i -e "/add_subdirectory( sqlite )/d" CMakeLists.txt

	# Use default data path
	sed -i -e "s:/usr/local/share/:/usr/share/doom/:" src/sdl/i_system.h

	# Fix building with gcc-5
	sed -i -e 's/ restrict/ _restrict/g' dumb/include/dumb.h dumb/src/it/*.c

	cmake-utils_src_prepare
}

src_configure() {
	mycmakeargs=(
		-DFMOD_INCLUDE_DIR=/opt/fmodex/api/inc/
		-DFMOD_LIBRARY=/opt/fmodex/api/lib/libfmodex.so
		-DFORCE_INTERNAL_GME="OFF"
		-DNO_ASM="$(usex cpu_flags_x86_mmx OFF ON)"
		-DNO_GTK="$(usex gtk OFF ON)"
	)

	# Can't build both client and server at once... so separate them
	if use opengl; then
		BUILD_DIR="${WORKDIR}/${P}_client"
		cmake-utils_src_configure
	fi
	if use dedicated; then
		BUILD_DIR="${WORKDIR}/${P}_server"
		mycmakeargs+=(-DSERVERONLY=1)
		cmake-utils_src_configure
	fi
}

src_compile() {
	if use opengl; then
		BUILD_DIR="${WORKDIR}/${P}_client"
		cmake-utils_src_make
	fi
	if use dedicated; then
		BUILD_DIR="${WORKDIR}/${P}_server"
		cmake-utils_src_make
	fi
}

src_install() {
	dodoc docs/{commands,zandronum*}.txt docs/console.{css,html}

	cd "${BUILD_DIR}"
	insinto "/usr/share/doom"
	doins *.pk3

	if use opengl; then
		dobin "${WORKDIR}/${P}_client/${PN}"
		doicon "${S}/src/win32/zandronum.ico"
		make_desktop_entry "${PN}" "Zandronum" "${PN}.ico" "Game;ActionGame;"
	fi
	if use dedicated; then
		dobin "${WORKDIR}/${P}_server/${PN}-server"
	fi

        # don't install this now
        rm "${D}/usr/share/doom/brightmaps.pk3"
}
pkg_postinst() {
	# install here to avoid collisions with games-fps/gzdoom
	# hacky, i know. should've listened to juippis :) please don't hit me.
	# note: brightmaps.pk3 NEEDS TO KEEP ITS NAME to not break online play
	# on servers that mistakenly add it as a required pwad.
	cp -n "${BUILD_DIR}/brightmaps.pk3" "${EPREFIX}/usr/share/doom/" || die

        ewarn "For parity with the gzdoom ebuild, the data path has been changed yet again!"
        ewarn "It is ${EPREFIX}/usr/share/doom - copy/link wad files there or in \$HOME/.config/zandronum"
        ewarn "If after an upgrade the game complains about not finding zandronum.pk3,"
        ewarn "edit the [*Search.Directories] sections in \$HOME/.config/zandronum/zandronum.ini."

	if use opengl; then
		elog
		elog "To play online, install games-util/doomseeker"
	fi
}