summaryrefslogtreecommitdiff
blob: 335a45779c55e918b7b854b203e9ad8fe682b73d (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
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/games-strategy/ufo-ai/ufo-ai-2.2.1.ebuild,v 1.5 2010/01/19 14:42:14 ssuominen Exp $

EAPI=2
inherit eutils games

MY_P="${P/o-a/oa}"

DESCRIPTION="UFO: Alien Invasion - X-COM inspired strategy game"
HOMEPAGE="http://ufoai.sourceforge.net/"
SRC_URI="mirror://sourceforge/ufoai/${MY_P}-source.tar.bz2
	mirror://sourceforge/ufoai/${MY_P}-data.tar"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~x86"
IUSE="dedicated doc editor mmx"

# Dependencies and more instructions can be found here:
# http://ufoai.ninex.info/wiki/index.php/Compile_for_Linux
RDEPEND="!dedicated? (
		virtual/opengl
		virtual/glu
		media-libs/libsdl
		media-libs/sdl-ttf
		media-libs/sdl-mixer
		media-libs/jpeg
		media-libs/libpng
		media-libs/libogg
		media-libs/libvorbis
		x11-proto/xf86vidmodeproto
	)
	editor? ( media-libs/jpeg )
	net-misc/curl
	sys-devel/gettext"

DEPEND="${RDEPEND}
	doc? ( virtual/latex-base )"

S=${WORKDIR}/${MY_P}-source

src_prepare() {
	# move data from packages to source dir
	mv "${WORKDIR}/base" "${S}" || die

	# Set basedir & fixes bug in finding text files - it should use fs_basedir
	epatch "${FILESDIR}"/${P}-gentoo.patch

	sed -i \
		-e "s:@GENTOO_DATADIR@:${GAMES_DATADIR}/${PN}:" \
		src/common/files.c \
		src/tools/gtkradiant/games/ufoai.game \
		src/client/cl_main.c \
		src/client/cl_language.c \
		|| die "sed failed"

	sed -i \
		-e "s:jpeg_mem_src:_&:" \
		src/{renderer/r_image,tools/ufo2map/common/imagelib}.c || die
}

src_configure() {
	egamesconf \
		$(use_enable mmx) \
		--enable-release \
		$(use_enable editor ufo2map) \
		--enable-dedicated \
		$(use_enable !dedicated client) \
		--with-shaders
}

src_compile() {
	emake lang || die "emake langs failed"

	if use doc ; then
		emake pdf-manual || die "emake pdf-manual failed (USE=doc)"
	fi

	emake || die "emake failed"
}

src_install() {
	# server
	dogamesbin ufoded || die "Failed installing server"
	newicon src/ports/linux/installer/data/ufo.xpm ${PN}.xpm \
		|| die "Failed installing icon"
	make_desktop_entry ${PN}-ded "UFO: Alien Invasion Server" ${PN}.xpm
	if ! use dedicated ; then
		# client
		newgamesbin ufo ${PN} || die "Failed installing client"
		make_desktop_entry ${PN} "UFO: Alien Invasion" ${PN}.xpm
	fi

	if use editor ; then
		dogamesbin ufo2map || die "Failed installing editor"
	fi

	insinto "${GAMES_DATADIR}"/${PN}
	doins -r base || die "doins -r failed"
	if use doc ; then
		dodoc src/docs/tex/ufo-manual_EN.pdf || die "Failed installing manual"
	fi

	prepgamesdirs
}