summaryrefslogtreecommitdiff
blob: 1d3303d75d2571f5c7772ea3250e50aca7f2cea5 (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit autotools eutils flag-o-matic wxwidgets games

DESCRIPTION="Advanced source port for Doom/Heretic/Hexen/Strife"
HOMEPAGE="http://www.vavoom-engine.com/"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="allegro asm debug dedicated external-glbsp flac mad mikmod models music
openal opengl sdl textures tools wxwindows"

QA_EXECSTACK="${GAMES_BINDIR:1}/${PN}"

# From econf:  "Vavoom requires Allegro or SDL to compile"
# SDL,like Allegro are *software* renderers in this game.
# So, if not selected through proper USEs, the default is SDL,
# without opengl (vavoom can run in software-mode only).
# To enable it, enable proper USE.
# OpenGL is the normally-desired hardware renderer, selected on command-line
# (through "-opengl" switch). This switch is also added to the desktop entry,
# if "opengl" USE flag is enabled

SDLDEPEND=">=media-libs/libsdl-1.2
	media-libs/sdl-mixer"
ALLEGDEPEND=">=media-libs/allegro-4.0"
OPENGLDEPEND="opengl? ( virtual/opengl )
	sdl? ( ${SDLDEPEND} )
	allegro? ( media-libs/allegrogl )
	!sdl? ( !allegro? ( ${SDLDEPEND} ) )"
DEPEND="media-libs/libpng
	media-libs/jpeg
	sdl? ( ${SDLDEPEND} )
	!sdl? ( allegro? ( ${ALLEGDEPEND} ) )
	!sdl? ( !allegro? ( !dedicated? ( ${OPENGLDEPEND} ) ) )
	opengl? ( ${OPENGLDEPEND} )
	music? ( media-libs/libvorbis )
	flac? ( media-libs/flac )
	mad? ( media-libs/libmad )
	mikmod? ( media-libs/libmikmod )
	openal? ( media-libs/openal )
	external-glbsp? ( games-util/glbsp )
	wxwindows? ( =x11-libs/wxGTK-2.6* )"
RDEPEND="${DEPEND}
	allegro? ( media-sound/timidity++ )"
PDEPEND="models? ( >=games-fps/vavoom-models-1.4.2 )
	music? ( games-fps/vavoom-music )
	textures? ( games-fps/vavoom-textures )"

dir=${GAMES_DATADIR}/${PN}

pkg_setup() {
	games_pkg_setup

	# Do some important check ...
	if use sdl && use allegro ; then
		echo
		ewarn "Both 'allegro' and 'sdl' USE flags enabled. Using SDL as default."
	elif ! use sdl && ! use allegro ; then
		echo
		ewarn "Both 'allegro' and 'sdl' USE flags disabled. Using SDL as default."
	fi

	# Base graphic/sound/music support is enabled?
	echo
	einfo "Doing some sanity check..."

	# Graphic/sound/opengl check
	local backend="media-libs/libsdl"

	if ! use sdl && use allegro ; then
		backend="media-libs/allegro"
	fi

	local backendflags="X alsa"

	if use opengl ; then
		[[ "${backend}" == "media-libs/libsdl" ]] && backendflags="${backendflags} opengl"
	else
		ewarn "'opengl' USE flag disabled. OpenGL is recommended, for best graphics."
	fi

	local msg="Please rebuild ${backend} with ${backendflags} USE flag enabled"
	if ! built_with_use ${backend} ${backendflags} ; then
			eerror "${msg}"
			die ${msg}
	fi

	# Music check
	if ! use allegro && ! built_with_use media-libs/sdl-mixer timidity ; then
		echo
		eerror "MIDI Music support is not configured properly!"
		eerror "Please rebuild sdl-mixer with USE 'timidity' enabled!"
		die "music support error"
	fi

	echo
	einfo "All is OK, let's build!"
}

src_unpack() {
	unpack "${A}"
	cd "${S}"

	# Patch Makefiles to get rid of executable wrappers
	epatch "${FILESDIR}/${PN}-makefile_nowrapper.patch"
	# Patch for compiling issue against flac-1.2*
	epatch "${FILESDIR}/${P}_flac-1.2_fix.patch"

	# Set shared directory
	sed -i \
		-e "s:fl_basedir = \".\":fl_basedir = \"${dir}\":" \
		source/files.cpp || die "sed files.cpp failed"

	eautoreconf

	# Set executable filenames
	for m in $(find . -type f -name Makefile.in) ; do
		sed -i \
			-e "s:MAIN_EXE = @MAIN_EXE@:MAIN_EXE=${PN}:" \
			-e "s:SERVER_EXE = @SERVER_EXE@:SERVER_EXE=${PN}-ded:" \
			"${m}" || die "sed ${m} failed"
	done
}

src_compile() {
	local \
		allegro="--without-allegro" \
		sdl="--without-sdl"

	export WX_GTK_VER="2.6"
	need-wxwidgets gtk2

	# Sdl is the default, unless sdl=off & allegro=on
	if ! use sdl && use allegro ; then
		allegro="--with-allegro"
	else
		sdl="--with-sdl"
	fi

	use debug && append-flags -g2

	egamesconf \
		--enable-client \
		${sdl} \
		${allegro} \
		$(use_with opengl) \
		$(use_with openal) \
		$(use_with external-glbsp) \
		$(use_with music vorbis) \
		$(use_with mad libmad) \
		$(use_with mikmod) \
		$(use_with flac) \
		$(use_enable asm) \
		$(use_enable dedicated server) \
		$(use_enable debug) \
		$(use_enable debug zone-debug) \
		$(use_enable wxwindows launcher) \
		--with-wx-config=${WX_CONFIG} \
		--with-iwaddir="${dir}" \
		--disable-dependency-tracking \
		--disable-maintainer-mode \
		|| die "egamesconf failed"

	emake || die "emake failed"
}

src_install() {
	local de_cmd="${PN}"

	emake DESTDIR="${D}" install || die "emake install failed"

	# Remove unneeded icon
	rm -f "${D}/${dir}/${PN}.png"

	# Enable OpenGL in desktop entry, if relevant USE flag is enabled
	use opengl && de_cmd="${PN} -opengl"
	doicon source/${PN}.png || die "doicon ${PN}.png failed"
	make_desktop_entry "${de_cmd}" "Vavoom"

	dodoc docs/${PN}.txt || die "dodoc vavoom.txt failed"

	if use tools ; then
		# The tools are always built
		dobin utils/bin/{acc,fixmd2,vcc,vlumpy} || die "dobin utils failed"
		dodoc utils/vcc/vcc.txt || die "dodoc vcc.txt failed"
	fi

	if use wxwindows ; then
		# Install graphical launcher
		doicon utils/vlaunch/vlaunch.xpm || die "doicon vlaunch.xpm failed"
		dogamesbin utils/bin/vlaunch || die "dogamesbin vlaunch failed"
		make_desktop_entry "vlaunch" "Vavoom Launcher" "vlaunch.xpm"
	fi

	prepgamesdirs
}

pkg_postinst() {
	games_pkg_postinst

	elog "Copy or link wad files into ${dir}"
	elog "(the files must be readable by the 'games' group)."
	elog
	elog "Example setup:"
	elog "ln -sn ${GAMES_DATADIR}/doom-data/doom.wad ${dir}/"
	elog
	elog "Example command-line:"
	elog "   vavoom -doom -opengl"
	elog
	elog "See documentation for further details."

	if use wxwindows ; then
		echo
		elog "You've also installed a nice graphical launcher. Simply run:"
		elog
		elog "   vlaunch"
		elog
		elog "to enjoy it :)"
	fi

	if use tools; then
		echo
		elog "You have also installed some Vavoom-related utilities"
		elog "(useful for mod developing):"
		elog
		elog " - acc (ACS Script Compiler)"
		elog " - fixmd2 (MD2 models utility)"
		elog " - vcc (Vavoom C Compiler)"
		elog " - vlumpy (Vavoom Lump utility)"
		elog
		elog "See the Vavoom Wiki at http://vavoom-engine.com/wiki/ or"
		elog "Vavoom Forum at http://www.vavoom-engine.com/forums/"
		elog "for further help."
	fi
}