summaryrefslogtreecommitdiff
blob: 1c6f42d5306ff94ebd01411e0c368f0375525131 (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# Derived from bug 65084

inherit flag-o-matic eutils games
[ "$PV" == "9999" ] && inherit subversion

ESVN_REPO_URI="https://vegastrike.svn.sourceforge.net/svnroot/vegastrike/trunk"
ESVN_PROJECT="vegastrike"
ESVN_BOOTSTRAP="vegastrike/bootstrap-sh"

DESCRIPTION="A 3D space simulator that allows you to trade and bounty hunt"
HOMEPAGE="http://vegastrike.sourceforge.net/"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~x86"
# FIXME: check configure options
IUSE="stencil-buffer gtk no-sound sdl debug"

# FIXME: check dependencies
RDEPEND="
	virtual/opengl
	media-libs/jpeg
	media-libs/libpng
	dev-libs/expat
	media-libs/openal
	sdl? ( media-libs/libsdl )
	!no-sound? ( media-libs/libvorbis
				 media-libs/libogg
				 sdl? ( media-libs/sdl-mixer ) )
	virtual/glut
	virtual/glu
	gtk? ( x11-libs/gtk+ )
	games-simulation/vegastrike-data"
DEPEND="${RDEPEND}
	>=sys-devel/autoconf-2.58"

S="${WORKDIR}"

pkg_setup() {
	games_pkg_setup
	# FIXME: is this still a problem?
	einfo "If compiling fails for you on gl_globals.h, try to replace your"
	einfo "glext.h (usually found in /usr/include/GL/ with this one"
	einfo "http://oss.sgi.com/projects/ogl-sample/ABI/glext.h"
	einfo "remember to make backup of the original though"
}

src_unpack() {
	cd "${S}"
	local svn=${ESVN_TOP_DIR}

	if [ ! -d "${svn}/vegastrike" ]; then
		ESVN_MODULE="vegastrike"
		ESVN_MODULE_DIR="${ESVN_REPO_URI}/${ESVN_MODULE}"
		subversion_fetch $ESVN_MODULE_DIR $ESVN_MODULE || die "Fetching vegastrike failed"
	fi

	einfo "Copying source to work directory..."
	cp -a "${svn}"/{vegastrike,vssetup} "${S}" >&/dev/null

	# Sort out directory references
	# FIXME: check whether these are still needed
	cd "${S}/${PN}"
	sed -i \
		-e "s!/usr/games/vegastrike!${GAMES_DATADIR}/${PN}!" \
		-e "s!/usr/games/bin!${GAMES_BINDIR}!" \
		launcher/saveinterface.cpp \
		|| die "sed launcher/saveinterface.cpp failed"
	sed -i \
		"s!/usr/local/share/vegastrike!${GAMES_DATADIR}/${PN}!" \
		src/common/common.cpp \
		|| die "sed src/common/common.cpp failed"
	sed -i \
		"s!/usr/share/local/vegastrike!${GAMES_DATADIR}/${PN}!" \
		src/vsfilesystem.cpp \
		|| die "sed src/filesys.cpp failed"
	sed -i \
		-e '/^SUBDIRS =/s:tools::' \
		Makefile.am \
		|| die "sed Makefile.am failed"

	#	FIXME: vssetup doesn't find "readme.txt"
	#	from vegastrike/setup/src/include/display_gtk.cpp +69
	# execlp("less", "less","readme.txt", NULL); //Will this work in Linux?

	#	FIXME: is this still a problem?
	# is not possible here to use built in function subversion_bootstrap: it
	# won't work as expected: ./bootstrap isn't in main compile dir
	./bootstrap-sh
}

src_compile() {
	cd "${S}"/vegastrike
	local conf_opts="${conf_opts} --disable-dependency-tracking"

	# DATA_DIR
	conf_opts="${conf_opts} --with-data-dir=${GAMES_DATADIR}/${PN}/data"

	if use debug; then
		conf_opts="${conf_opts} --enable-debug"
	else
		#	FIXME: This actually enables -O2.
		# -O3 appears to make problems in some cases.
		# Might not be a great idea to mix with user -O flags.
		conf_opts="${conf_opts} --enable-release=2"
	fi

	if ! use gtk; then
		conf_opts="${conf_opts} --disable-gtk"
	fi

	CONFIGURE_OPTIONS="
		$(use_enable stencil-buffer)
		$(use_enable sdl)
		$(use_enable !no-sound sound)
		${conf_opts}"

	egamesconf $CONFIGURE_OPTIONS \
	    || die "egamesconf failed"

	#	FIXME: Is this still a problem?
	#	FIXME: CXXFLAGS can be supplied in a better way.
	# it causes corruptions
	filter-flags -ffast-math
#	# Let's optimize, removing also broken -ffast-math
	sed -i -e "s:-ffast-math:${CXXFLAGS}:g" Makefile \
	    || die "sed of CXXFLAGS failed"

	emake || die "emake failed"
}

src_install() {
	cat << EOF > vsinstall
#!/bin/sh
(
mkdir \${HOME}/.vegastrike 2> /dev/null
cd \${HOME}/.vegastrike
cp "${GAMES_DATADIR}"/vegastrike/data/setup.config .
cp -r "${GAMES_DATADIR}"/vegastrike/data/.vegastrike/* .
cp "${GAMES_DATADIR}"/vegastrike/data/vegastrike.config .
vssetup
)
echo "If you wish to have your own music edit ~/.vegastrike/*.m3u"
echo "Each playlist represents a place or situation in Vega Strike"
exit 0
EOF

	dogamesbin vegastrike/vegastrike \
		|| die "Creation of vegastrike (the binary) failed"
	dogamesbin vsinstall \
		|| die "Creation of vsinstall failed"
	dogamesbin vegastrike/vegaserver \
		|| die "Creation of vegaserver failed"
	dogamesbin vegastrike/mesher \
		|| die "Creation of mesher failed"

	if use gtk; then
		newgamesbin vegastrike/vssetup vssetup || die "newgamesbin failed"
	fi

	make_desktop_entry "vegastrike" "Vegastrike" "${GAMES_DATADIR}/${PN}/data/vegastrike.xpm"

	prepgamesdirs
}

pkg_postinst() {
	games_pkg_postinst
	einfo "First run vsinstall to install your account into ~/.vegastrike,"
	einfo "then run vegastrike to start Vega Strike;"
	einfo "Run vssetup to configure Vega Strike."
	einfo "To start Vega Strike Server run vegaserver."
	einfo "(FIXME: vssetup/vsinstall currently won't find readme.txt."
	einfo " It's in ${GAMES_DATADIR}/${PN}/data/documentation/.)"
}