summaryrefslogtreecommitdiff
blob: 146429cb7d88cae73945eab7bd1e9bbf4fed469a (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
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/games-fps/duke3d/duke3d-20030817-r1.ebuild,v 1.14 2004/04/20 10:28:40 mr_bones_ Exp $

ECVS_PASS="anonymous"
ECVS_SERVER="icculus.org:/cvs/cvsroot"
ECVS_MODULE="duke3d"
inherit eutils flag-o-matic games
#inherit cvs

DESCRIPTION="port of the original DukeNukem 3D"
HOMEPAGE="http://icculus.org/projects/duke3d/"
SRC_URI="mirror://gentoo/${P}.tbz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="x86 ppc"
IUSE="perl opengl" # nophysfs"

RDEPEND="virtual/x11
	media-libs/libsdl
	media-libs/sdl-mixer
	media-sound/timidity++
	media-sound/timidity-eawpatches
	opengl? ( virtual/opengl )"
DEPEND="${RDEPEND}
	x86? ( dev-lang/nasm )
	>=sys-apps/sed-4"

S="${WORKDIR}/${ECVS_MODULE}"

use_tf() { use ${1} > /dev/null && echo "true" || echo "false"; }
use_ft() { use ${1} > /dev/null && echo "false" || echo "true"; }

src_unpack() {
	local fromcvs=0
	if [ ${fromcvs} -eq 1 ] ; then
		cvs_src_unpack
		cd duke3d/source
		ECVS_MODULE="buildengine"
		cvs_src_unpack
	else
		unpack ${A}
	fi

	# configure buildengine
	cd ${S}/source/buildengine
	sed -i \
		-e "/^useperl := / s:=.*:= $(use_tf perl):" \
		-e "/^useopengl := / s:=.*:= $(use_tf opengl):" \
		-e "/^usephysfs := / s:=.*:= false:" Makefile \
			|| die "sed Makefile failed"
	if use x86 ; then
		sed -i \
			-e 's:^#USE_ASM:USE_ASM:' Makefile \
				|| die "sed Makefile failed (x86)"
	fi
	epatch "${FILESDIR}/${PV}-buildengine-makefile-cflags.patch"
	sed -i \
		-e 's:/usr/lib/perl5/i386-linux/CORE/libperl.a::' Makefile \
			|| die "sed Makefile failed (libperl)"

	# configure duke3d
	cd ${S}/source
	epatch "${FILESDIR}/${PV}-credits.patch"
	epatch "${FILESDIR}/${PV}-duke3d-makefile-opts.patch"
	if use x86 ; then
		sed -i \
			-e '/^#use_asm/s:#::' Makefile \
				|| die "sed Makefile failed"
	fi
	if use opengl ; then
		sed -i \
			-e '/^#use_opengl/s:#::' Makefile \
				|| die "sed Makefile failed"
	fi
}

src_compile() {
	# -O3 fails on athlon with gcc 3.2.3, maybe others.
	replace-flags "-O3" "-O2"
	cd source/buildengine
	emake OPTFLAGS="${CFLAGS}" || die "buildengine failed"
	cd ..
	emake OPTIMIZE="${CFLAGS}" || die "duke3d failed"
}

src_install() {
	games_make_wrapper duke3d "${GAMES_BINDIR}/duke3d.bin" "${GAMES_DATADIR}/${PN}"
	newgamesbin source/duke3d duke3d.bin || die "newgamesbin failed"

	dodoc readme.txt

	cd testdata
	insinto "${GAMES_DATADIR}/${PN}"
	newins defs.con DEFS.CON
	newins game.con GAME.CON
	newins user.con USER.CON
	doins "${FILESDIR}/network.cfg"
	insinto "${GAMES_SYSCONFDIR}"
	doins "${FILESDIR}/duke3d.cfg"
	dosym "${GAMES_SYSCONFDIR}/duke3d.cfg" "${GAMES_DATADIR}/${PN}/DUKE3D.CFG"

	prepgamesdirs
}

pkg_postinst() {
	games_pkg_postinst
	einfo "Just put the data files in ${GAMES_DATADIR}/${PN}"
	einfo "before playing !"
}