summaryrefslogtreecommitdiff
blob: 7502e8bef399e8136522df04b117018bf103787c (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
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/games-fps/cube/cube-20050829.ebuild,v 1.5 2006/01/02 17:02:27 hansmi Exp $

inherit eutils flag-o-matic games

MY_PV=${PV:0:4}_${PV:4:2}_${PV:6:2}
MY_P=${PN}_${MY_PV}
DESCRIPTION="Landscape-style engine that pretends to be an indoor first person shooter engine"
HOMEPAGE="http://www.cubeengine.com/"
SRC_URI="mirror://sourceforge/cube/${MY_P}_unix.tar.gz
	mirror://sourceforge/cube/${MY_P}_src.zip"

LICENSE="ZLIB"
SLOT="0"
KEYWORDS="~amd64 ~hppa ppc x86"
IUSE="dedicated"

RDEPEND="virtual/opengl
	virtual/glu
	media-libs/libsdl
	media-libs/sdl-mixer
	media-libs/sdl-image
	sys-libs/zlib
	media-libs/libpng"
DEPEND="${RDEPEND}
	app-arch/unzip"

S=${WORKDIR}/cube_source
S_BIN=${WORKDIR}/cube
CUBE_DATADIR=${GAMES_DATADIR}/${PN}/

src_unpack() {
	unpack ${A}

	cd "${S}"/src
	epatch "${FILESDIR}"/${P}-gentoo-paths.patch
	echo "#define GAMES_DATADIR \"${CUBE_DATADIR}\"" >> tools.h
	echo "#define GAMES_DATADIR_LEN ${#CUBE_DATADIR}" >> tools.h
	sed -i \
		-e "s:packages/:${CUBE_DATADIR}packages/:" \
		renderextras.cpp rendermd2.cpp sound.cpp worldio.cpp \
		|| die "fixing data path failed"
	# enable parallel make
	sed -i \
		-e 's/make -C/$(MAKE) -C/' \
		Makefile \
		|| die "sed Makefile failed"
	edos2unix *.cpp
	chmod a+x "${S}"/enet/configure
}

src_compile() {
	append-flags -fsigned-char
	cd enet
	egamesconf || die "egamesconf failed"
	emake || die "emake failed"
	cd ../src
	einfo "Compiling in $(pwd)"
	emake CXXOPTFLAGS="-DHAS_SOCKLEN_T=1 -fpermissive ${CXXFLAGS}" \
		|| die "emake failed"
}

src_install() {
	dogamesbin src/cube_client || die "dogamesbin client failed"
	if use dedicated ; then
		dogamesbin src/cube_server "${S_BIN}"/bin_unix/linux_server \
			|| die "dogamesbin server failed"
	fi
	dodoc src/CUBE_TODO.txt

	cd "${S_BIN}"
	insinto "${CUBE_DATADIR}"
	doins -r *.cfg data packages || die "doins failed"
	dohtml -r docs readme.html

	if [[ ${ARCH} == "x86" ]] ; then
		exeinto "${GAMES_LIBDIR}"/${PN}
		newexe bin_unix/linux_client cube_client || die "newexe server failed"
		games_make_wrapper cube_client-bin \
			"${GAMES_LIBDIR}"/${PN}/cube_client "${GAMES_DATADIR}"/${PN} \
			|| die "games_make_wrapper client failed"
		make_desktop_entry cube_client-bin "Cube Client"
	else
		make_desktop_entry cube_client "Cube Client"
	fi

	prepgamesdirs
}

pkg_postinst() {
	games_pkg_postinst
	if [[ ${ARCH} == "x86" ]] ; then
		einfo "You now have 2 clients and 2 servers:"
		einfo "cube_client-bin      prebuilt version (needed to play on public multiplayer servers)"
	else
		einfo "You only have 1 client and 1 server:"
	fi
	einfo "cube_client          custom client built from source"
	use dedicated && \
	einfo "Parallel versions of the server have been installed"
}