]> Pileus Git - ~andy/sunrise/blob - games-fps/uhexen2-cvs/uhexen2-cvs-20071001.ebuild
games-fps/uhexen2-cvs: Version bump
[~andy/sunrise] / games-fps / uhexen2-cvs / uhexen2-cvs-20071001.ebuild
1 # Copyright 1999-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 inherit eutils flag-o-matic toolchain-funcs versionator games
6
7 DATA_PV="1.19-rc2"
8 HW_PV="0.15"
9 MY_PN="hexen2"
10 DEMO_PV="1.4.1"
11
12 DESCRIPTION="Hexen 2 port - Hammer of Thyrion (CVS snapshot)"
13 HOMEPAGE="http://uhexen2.sourceforge.net/"
14 SRC_URI="http://uhexen2.sourceforge.net/devel/cvs_latest/${P}.tgz
15         mirror://sourceforge/u${MY_PN}/gamedata-all-${DATA_PV}.tgz
16         hexenworld? ( mirror://sourceforge/u${MY_PN}/hexenworld-pakfiles-${HW_PV}.tgz )"
17
18 LICENSE="GPL-2"
19 SLOT="0"
20 KEYWORDS="~amd64 ~ppc ~x86"
21 IUSE="3dfx alsa asm cdaudio debug dedicated demo dynamic hexenworld gtk lights
22 midi opengl optimize-cflags oss sdlaudio sdlcd tools"
23
24 QA_EXECSTACK="${GAMES_BINDIR:1}/hexen2
25         ${GAMES_BINDIR:1}/glhexen2
26         ${GAMES_BINDIR:1}/hexen2-demo
27         ${GAMES_BINDIR:1}/glhexen2-demo
28         ${GAMES_BINDIR:1}/hwcl
29         ${GAMES_BINDIR:1}/glhwcl
30         ${GAMES_BINDIR:1}/hwcl-demo
31         ${GAMES_BINDIR:1}/glhwcl-demo"
32
33 UIDEPEND=">=media-libs/libsdl-1.2.7
34         >=media-libs/sdl-mixer-1.2.5
35         3dfx? ( media-libs/glide-v3 )
36         alsa? ( >=media-libs/alsa-lib-1.0.7 )
37         midi? ( media-sound/timidity++ )
38         opengl? ( virtual/opengl )"
39
40 # Launcher depends from GTK+ libs
41 LNCHDEPEND="gtk? ( =x11-libs/gtk+-2* )"
42
43 # xdelta is needed to manually run the patch script
44 RDEPEND="!games-fps/uhexen2
45         ${UIDEPEND}
46         ${LNCHDEPEND}
47         demo? ( >=games-fps/hexen2-demodata-${DEMO_PV} )
48         lights? ( games-fps/hexen2-lights )
49         >=dev-util/xdelta-1.1.3-r1"
50 DEPEND="${UIDEPEND}
51         ${LNCHDEPEND}
52         x86? ( asm? ( >=dev-lang/nasm-0.98.38 ) )"
53
54 S="${WORKDIR}/uhexen2-cvs-${PV}"
55 dir="${GAMES_DATADIR}/${MY_PN}"
56
57 pkg_setup() {
58         games_pkg_setup
59
60         if use midi ; then
61                 if ! built_with_use "media-libs/sdl-mixer" timidity ; then
62                         eerror "Recompile media-libs/sdl-mixer with 'timidity' USE flag."
63                         die "sdl-mixer without timidity support detected"
64                 fi
65                 use sdlaudio && ewarn "MIDI music does not work with sdlaudio."
66         else
67                 ewarn "MIDI support disabled! MIDI music won't be played at all."
68                 ewarn "If you want to hear it, recompile this package"
69                 ewarn "with \"midi\" USE flag enabled."
70         fi
71
72         use alsa || ewarn "alsa is the recommended sound driver."
73 }
74
75 src_unpack() {
76         unpack ${A}
77         cd "${S}"
78
79         # Clean CVS stuff
80         for x in `find . -name CVS -print`; do rm -fr ${x}; done
81
82         cd hexen2
83         epatch "${S}/00_Patches/external-music-file-support.diff"
84         cd ..
85
86         # Whether to use the demo directory
87         local demo
88         use demo && demo="/demo"
89
90         # Use default basedir - has 2 variations
91         sed -i \
92                 -e "s:parms.basedir = cwd;:parms.basedir = \"${dir}${demo}\";:" \
93                 -e "s:parms.basedir = \".\";:parms.basedir = \"${dir}${demo}\";:" \
94                 {hexen2,hexen2/server,hexenworld/{Client,Server}}/sys_unix.c \
95                 || die "sed sys_unix.c failed"
96
97         # Change default sndspeed from 22050 to 44100,
98         # to improve the quality/reliability.
99         sed -i \
100                 -e "s:desired_speed = 22050:desired_speed = 44100:" \
101                 {hexen2,hexenworld/Client}/snd_dma.c || die "sed snd_dma.c failed"
102
103         # Change patch script to be suitable
104         sed -i \
105                 -e "s:chmod :#chmod :" \
106                 -e 's:"xdelta113":"/usr/bin/xdelta":' \
107                 -e "s:./xdelta113:xdelta": \
108                 "${WORKDIR}"/update_xdelta.sh || die "sed update_xdelta.sh failed"
109
110         # Honour Portage CFLAGS also when debuggins is enabled
111         use debug && append-flags "-g2"
112         for u in `grep -lr '\-g \-Wall' *`; do
113                 sed -i \
114                         -e "s/^CFLAGS \:\= \-g \-Wall/CFLAGS \:\= ${CFLAGS}/" \
115                         ${u} || die "sed ${u} failed"
116         done
117
118         if use demo ; then
119                 # Allow lightmaps in demo
120                 sed -i \
121                         -e "s:!override_pack:0:" \
122                         hexen2/common.c || die "sed common.c demo failed"
123         fi
124
125         if use gtk ; then
126                 # Tweak the default games data dir for graphical launcher
127                 sed -i \
128                         -e "/int basedir_nonstd/s:= 0:= 1:" \
129                         -e "/game_basedir\[0\]/d" \
130                         launcher/config_file.c || die "sed config_file.c failed"
131                 # Tweak the default name for binary executables,if DEMO version is enabled
132                 if use demo ; then
133                         sed -i \
134                                 -e "/BINARY_NAME/s:\"$:-demo\":" \
135                                 launcher/games.h || die "sed games.h failed"
136                 fi
137         fi
138
139         rm -rf docs/{activision,COMPILE,COPYING,LICENSE,README.win32}
140 }
141
142 src_compile() {
143
144         local h2bin="h2" hwbin="hw" link_gl_libs="no" opts
145         local \
146                 h2bin="h2" hwbin="hw" \
147                 USE_ALSA="no" \
148                 USE_CDAUDIO="no" \
149                 LINK_GL_LIBS="no" \
150                 USE_MIDI="no" \
151                 OPT_EXTRA="no" \
152                 USE_OSS="no" \
153                 USE_SDLCD="no" \
154                 X86_ASM="no" \
155                 USE_3DFX="no" \
156                 opts
157
158         if use opengl ; then
159                 h2bin="${h2bin} gl${h2bin}"
160                 hwbin="${hwbin} gl${hwbin}"
161                 use dynamic && LINK_GL_LIBS="yes"
162         fi
163
164         use debug && opts="${opts} DEBUG=1"
165         use demo && opts="${opts} DEMO=1"
166
167         use alsa && USE_ALSA="yes"
168         use cdaudio && USE_CDAUDIO="yes"
169         use optimize-cflags && OPT_EXTRA="yes"
170         use oss && USE_OSS="yes"
171         use sdlcd && USE_SDLCD="yes"
172         use midi && USE_MIDI="yes"
173         use x86 && use asm && X86_ASM="yes"
174         use 3dfx && USE_3DFX="yes"
175
176         if use gtk ; then
177         # Build launcher
178                 cd "${S}/launcher"
179                 einfo "Building graphical launcher"
180                 emake \
181                         AUTOTOOLS=1 \
182                         ${opts} \
183                         CPUFLAGS="${CFLAGS}" \
184                         CC="$(tc-getCC)" \
185                         || die "emake launcher failed"
186         fi
187
188         if use tools ; then
189                 # Build Hexen2 utils
190                 cd "${S}/utils"
191                 einfo "Building utils"
192                 local utils_list="hcc maputils genmodel qfiles dcc jsh2color hcc_old texutils/bsp2wal texutils/lmp2pcx"
193                 for x in ${utils_list}
194                 do
195                         emake -C ${x} \
196                                 ${opts} \
197                                 CPUFLAGS="${CFLAGS}" \
198                                 CC="$(tc-getCC)" \
199                                 || die "emake ${x} failed"
200                 done
201         fi
202
203         if use dedicated ; then
204                 # Dedicated Server
205                 cd "${S}/${MY_PN}"
206                 einfo "Building Dedicated Server"
207                 emake \
208                         ${opts} \
209                         OPT_EXTRA=${OPT_EXTRA} \
210                         CPUFLAGS="${CFLAGS}" \
211                         CC="$(tc-getCC)" \
212                         -f Makefile.sv \
213                         || die "emake Dedicated server failed"
214         fi
215
216         if use hexenworld ; then
217                 if use tools; then
218                         # Hexenworld utils
219                         local hw_utils="hwmquery hwrcon"
220                         einfo "Building Hexenworld utils"
221                         cd "${S}/hw_utils"
222                         for x in ${hw_utils} ; do
223                                 emake \
224                                         ${opts} \
225                                         CPUFLAGS="${CFLAGS}" \
226                                         CC="$(tc-getCC)" \
227                                         -C ${x} \
228                                         || die "emake ${x} failed"
229                         done
230                 fi
231
232                 # Hexenworld
233                 einfo "Building Hexenworld servers"
234                 cd "${S}"/hexenworld
235                 # Hexenworld servers
236                 emake \
237                         ${opts} \
238                         CPUFLAGS="${CFLAGS}" \
239                         CC="$(tc-getCC)" \
240                         -C Server \
241                         || die "emake HexenWorld Server failed"
242                 emake \
243                         ${opts} \
244                         CPUFLAGS="${CFLAGS}" \
245                         CC="$(tc-getCC)" \
246                         -C Master \
247                         || die "emake HexenWorld Master failed"
248
249                 # Hexenworld client
250                 einfo "Building Hexenworld client(s)"
251                 for m in ${hwbin} ; do
252                         emake -C Client clean
253                         emake \
254                                 ${opts} \
255                                 USE_ALSA=${USE_ALSA} \
256                                 USE_OSS=${USE_OSS} \
257                                 USE_CDAUDIO=${USE_CDAUDIO} \
258                                 USE_MIDI=${USE_MIDI} \
259                                 USE_SDLAUDIO=${USE_SDLAUDIO} \
260                                 USE_SDLCD=${USE_SDLCD} \
261                                 USE_X86_ASM=${X86_ASM} \
262                                 OPT_EXTRA=${OPT_EXTRA} \
263                                 LINK_GL_LIBS=${LINK_GL_LIBS} \
264                                 USE_3DFXGAMMA="${USE_3DFX}" \
265                                 CPUFLAGS="${CFLAGS}" \
266                                 CC="$(tc-getCC)" \
267                                 ${m} \
268                                 -C Client \
269                                 || die "emake Hexenworld Client (${m}) failed"
270                 done
271         fi
272
273         # Hexen 2 game executable
274         cd "${S}/${MY_PN}"
275
276         einfo "Building UHexen2 game executable(s)"
277         for m in ${h2bin} ; do
278                 emake clean
279                 emake \
280                         ${opts} \
281                         USE_ALSA=${USE_ALSA} \
282                         USE_OSS=${USE_OSS} \
283                         USE_CDAUDIO=${USE_CDAUDIO} \
284                         USE_MIDI=${USE_MIDI} \
285                         USE_SDLAUDIO=${USE_SDLAUDIO} \
286                         USE_SDLCD=${USE_SDLCD} \
287                         USE_X86_ASM=${X86_ASM} \
288                         OPT_EXTRA=${OPT_EXTRA} \
289                         LINK_GL_LIBS=${LINK_GL_LIBS} \
290                         USE_3DFXGAMMA=${USE_3DFX} \
291                         CPUFLAGS="${CFLAGS}" \
292                         CC="$(tc-getCC)" \
293                         ${m} \
294                         || die "emake Hexen2 (${m}) failed"
295         done
296
297 }
298
299 src_install() {
300         local demo demo_title demo_suffix
301         use demo && demo="-demo" && demo_title=" (Demo)" && demo_suffix="demo"
302
303         newicon hexen2/icons/h2_32x32x4.png ${PN}.png || die
304
305         make_desktop_entry "${MY_PN}${demo}" "Hexen 2${demo_title}" ${PN}.png
306         newgamesbin "${MY_PN}/${MY_PN}" "${MY_PN}${demo}" \
307                 || die "newgamesbin ${MY_PN} failed"
308
309         if use opengl ; then
310                 make_desktop_entry "gl${MY_PN}${demo}" "GLHexen 2${demo_title}" ${PN}.png
311                 newgamesbin "${MY_PN}/gl${MY_PN}" "gl${MY_PN}${demo}" \
312                         || die "newgamesbin gl${MY_PN} failed"
313         fi
314
315         if use dedicated ; then
316                 newgamesbin "${MY_PN}"/h2ded "${MY_PN}${demo}-ded" \
317                         || die "newgamesbin h2ded failed"
318         fi
319
320         if use hexenworld ; then
321                 if use tools; then
322                         # Hexenworld utils
323                         dobin hw_utils/hwmquery/hwmquery || die "dobin hwmquery failed"
324                         dobin hw_utils/hwrcon/{hwrcon,hwterm} || die "dobin hwrcon/hwterm failed"
325
326                         dodoc hw_utils/hwmquery/hwmquery.txt || die "dodoc hwmquery.txt failed"
327                         dodoc hw_utils/hwrcon/{hwrcon,hwterm}.txt \
328                         || die "dodoc hwrcon/hwterm.txt failed"
329                 fi
330
331                 # Hexenworld Servers
332                 newgamesbin hexenworld/Server/hwsv hwsv${demo} \
333                         || die "newgamesbin hwsv failed"
334
335                 newgamesbin hexenworld/Master/hwmaster hwmaster${demo} \
336                         || die "newgamesbin hwmaster failed"
337
338                 # HexenWorld client(s)
339                 newicon hexenworld/icons/hw2_32x32x8.png hwcl.png || die
340
341                 make_desktop_entry \
342                         "hwcl${demo}" "Hexen 2${demo_title} Hexenworld Client" hwcl.png
343                 newgamesbin "hexenworld/Client/hwcl" "hwcl${demo}" \
344                         || die "newgamesbin hwcl failed"
345
346                 if use opengl ; then
347                         make_desktop_entry \
348                                 "glhwcl${demo}" "GLHexen 2${demo_title} Hexenworld Client" hwcl.png
349                         newgamesbin "hexenworld/Client/glhwcl" "glhwcl${demo}" \
350                                 || die "newgamesbin glhwcl failed"
351                 fi
352
353                 insinto "${dir}"/${demo_suffix}
354                 doins -r "${WORKDIR}"/hw || die "doins hexenworld pak failed"
355         fi
356
357         if use gtk ; then
358                 # GTK launcher
359                 local lnch_name="h2launcher"
360                 use demo && lnch_name="h2demo"
361                 newgamesbin launcher/${lnch_name} h2launcher \
362                         || die "newgamesbin h2launcher failed"
363                 make_desktop_entry \
364                         "h2launcher" "Hexen 2${demo_title} Launcher" ${PN}.png
365         fi
366
367         # Forge a new useful document 8)
368         head -22 "00_Patches/external-music-file-support.diff" > \
369         "docs/external_music.README" || die "make readme failed"
370
371         dodoc docs/*
372
373         if ! use demo ; then
374                 # Install updated game data
375                 insinto "${dir}"
376                 doins -r "${WORKDIR}"/{data1,patchdata,portals,siege} || die
377                 # Patching should really be done by a future "hexen2-data" ebuild.
378                 # But this works for now.
379                 doins "${WORKDIR}"/update_xdelta.sh || die
380                 dodoc "${WORKDIR}"/*.txt
381         fi
382
383         if use tools ; then
384                 dobin \
385                         utils/bin/{bsp2wal,bspinfo,dhcc,genmodel,hcc} \
386                         || die "dobin utils part 1 failed"
387                 dobin \
388                         utils/bin/{jsh2colour,light,lmp2pcx,qbsp,qfiles,vis} \
389                         || die "dobin utils part 2 failed"
390                 newbin utils/hcc_old/hcc hcc_old || die "newbin hcc_old failed"
391                 docinto utils
392                 dodoc utils/README || die "dodoc README failed"
393                 newdoc utils/dcc/README README.dcc || die "newdoc dcc failed"
394                 dodoc utils/dcc/dcc.txt || die "dodoc dcc.txt failed"
395                 newdoc utils/hcc/README README.hcc || die "newdoc hcc failed"
396                 newdoc utils/hcc_old/README hcc_old.txt || die "newdoc hcc_old failed"
397                 newdoc utils/jsh2color/README README.jsh2color \
398                         || die "newdoc README.jsh2color failed"
399                 newdoc utils/jsh2color/ChangeLog ChangeLog.jsh2color \
400                         || die "newdoc Changelog.jsh2color failed"
401         fi
402
403         prepgamesdirs
404 }
405
406 pkg_postinst() {
407         games_pkg_postinst
408
409         if use demo ; then
410                 elog "uhexen2 has been compiled specifically to play the demo maps."
411                 elog "Example command-line:"
412                 elog "   hexen2-demo -width 1024 -height 768 -conwidth 640"
413                 echo
414         else
415                 elog "To play the demo, emerge with the 'demo' USE flag."
416                 elog
417                 elog "For the Hexen 2 original game..."
418                 elog "Put the following files into ${dir}/data1 before playing:"
419                 elog "   pak0.pak pak1.pak"
420                 elog "Then to play:  hexen2"
421                 elog
422                 elog "For the 'Portal of Praevus' mission pack..."
423                 elog "Put the following file into ${dir}/portals before playing:"
424                 elog "   pak3.pak"
425                 elog "Then to play:  hexen2 -portals"
426                 elog
427                 elog "To ensure the data files from the CD are patched, run as root:"
428                 elog "   cd ${dir} && sh update_xdelta.sh"
429                 elog
430                 elog "Example command-line:"
431                 elog "   hexen2 -width 1024 -height 768 -conwidth 640"
432                 echo
433         fi
434         if use gtk ; then
435                 elog "You've also installed a nice graphical launcher. Simply run:"
436                 elog
437                 elog "   h2launcher"
438                 elog
439                 elog "to enjoy it :)"
440                 echo
441         fi
442         if use tools ; then
443                 if use hexenworld; then
444                         elog "You've also installed some Hexenworld utility:"
445                         elog
446                         elog " - hwmquery (console app to query HW master servers)"
447                         elog " - hwrcon (remote interface to HW rcon command)"
448                         elog " - hwterm (HW remote console terminal)"
449                         echo
450                 fi
451                 elog "You've also installed some Hexen2 utility"
452                 elog "(useful for mod developing)"
453                 elog
454                 elog " - dhcc (old progs.dat compiler/decompiler)"
455                 elog " - genmodel (3-D model grabber)"
456                 elog " - hcc (HexenC compiler)"
457                 elog " - hcc_old (old version of HexenC compiler)"
458                 elog " - jsh2color (light colouring utility)"
459                 elog " - maputils (Map compiling tools: bspinfo, light, qbsp, vis)"
460                 elog " - qfiles (build pak files and regenerate bsp models)"
461                 elog " - bsp2wal (extract all textures from a bsp file)"
462                 elog " - lmp2pcx (convert hexen2 texture data into pcx and tga)"
463                 elog
464                 elog "See relevant documentation for further informations"
465                 echo
466         fi
467 }