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