summaryrefslogtreecommitdiff
blob: ae5060f06c1c81228c24471eb31c806a69a1f085 (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
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sci-astronomy/celestia/celestia-1.5.1.ebuild,v 1.9 2009/03/02 19:34:35 ranger Exp $

inherit eutils flag-o-matic gnome2 kde-functions autotools

EAPI="1"

DESCRIPTION="OpenGL 3D space simulator"
HOMEPAGE="http://www.shatters.net/celestia/"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz
		mirror://gentoo/${P}-acinclude.patch.bz2
		mirror://gentoo/${P}-gcc43.patch.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 ppc ppc64 sparc x86"
IUSE="arts cairo gnome gtk kde lua nls pch theora threads unicode"

RDEPEND="virtual/glu
	media-libs/jpeg
	media-libs/libpng
	gtk? ( !gnome? ( !kde? (
		>=x11-libs/gtk+-2.6
		>=x11-libs/gtkglext-1.0
	) ) )
	gnome? ( !kde? (
		>=x11-libs/gtk+-2.6
		>=x11-libs/gtkglext-1.0
		>=gnome-base/libgnomeui-2.0
	) )
	kde?  ( !gnome? ( kde-base/kdelibs:3.5 ) )
	!gtk? ( !gnome? ( !kde? ( virtual/glut ) ) )
	arts? ( kde-base/arts )
	lua? ( >=dev-lang/lua-5.0 )
	cairo? ( x11-libs/cairo )
	theora? ( media-libs/libtheora )"

DEPEND="${RDEPEND}
	dev-util/pkgconfig"

pkg_setup() {
	# Check for one for the following use flags to be set.

	if ! use gnome && use kde; then
		einfo "USE=\"kde\" detected."
		CELESTIA_GUI="kde"
	elif ! use kde && use gnome; then
		einfo "USE=\"gnome\" detected."
		USE_DESTDIR="1"
		CELESTIA_GUI="gnome"
	elif ! use kde && ! use gnome && use gtk; then
		einfo "USE=\"gtk\" detected."
		CELESTIA_GUI="gtk"
	elif use kde && use gnome; then
		einfo "Both gnome and kde support requested. Defaulting to kde"
		CELESTIA_GUI="kde"
	else
		ewarn "If you want to use the full gui, set USE=\"{kde/gnome/gtk}\""
		ewarn "Defaulting to glut support (no GUI)."
		CELESTIA_GUI="glut"
	fi
}

src_unpack() {

	unpack ${A}
	cd "${S}"
	# make better desktop files
	epatch "${FILESDIR}"/${PN}-1.5.0-desktop.patch

	# add a ~/.celestia for extra directories
	epatch "${FILESDIR}"/${PN}-1.4.1-cfg.patch

	# fix for as-needed (bug #130091)
	epatch "${FILESDIR}"/${PN}-1.4.1-as-needed.patch

	# fix for as-needed (bug #217758)
	epatch "${DISTDIR}"/${P}-gcc43.patch.bz2

	# fix for libtool-2.2 (bug #228865 and #218982)
	epatch "${DISTDIR}"/${P}-acinclude.patch.bz2

	# needed for kde GUI
	epatch "${FILESDIR}"/${P}-arts.patch

	# needed for proper detection of kde-3.5 in the presence
	# of kde4
	epatch "${FILESDIR}"/${P}-kde-3.5.patch

	# remove flags to let the user decide
	for cf in -O2 -ffast-math \
		-fexpensive-optimizations \
		-fomit-frame-pointer; do
		sed -i \
			-e "s/${cf}//g" \
			configure.in || die "sed failed"
	done

	# remove an unused gconf macro killing autoconf when no gnome
	# (not needed without eautoreconf)
	if ! use gnome; then
		sed -i \
			-e '/AM_GCONF_SOURCE_2/d' \
			configure.in || die "sed failed"
	fi
	if use unicode; then
		pushd locale > /dev/null
		for i in guide_{de,es,fr,it,nl,sv}.cel start_de.cel demo_nl.cel; do
			iconv -f iso-8859-1 ${i} -t utf8 > ${i}.utf8
			mv ${i}.utf8 ${i}
		done
		popd > /dev/null
	fi

	eautoreconf
}

src_compile() {

	if [[ ${CELESTIA_GUI} == kde ]]; then
		REALHOME="${HOME}"
		mkdir -p "${T}"/fakehome/.kde
		mkdir -p "${T}"/fakehome/.qt
		export HOME="${T}"/fakehome
		[[ -d ${REALHOME}/.ccache ]] && ln -sf "${REALHOME}/.ccache" "${HOME}/"
		set-kdedir 3
		export kde_widgetdir="${KDEDIR}/lib/kde3/plugins/designer"
	fi

	filter-flags "-funroll-loops -frerun-loop-opt"

	econf \
		--with-${CELESTIA_GUI} \
		$(use_with arts) \
		$(use_with lua) \
		$(use_enable cairo) \
		$(use_enable threads threading) \
		$(use_enable nls) \
		$(use_enable pch) \
		$(use_enable theora) \
		|| die "econf failed"

	emake || die "emake failed"
}

src_install() {
	if [[ ${CELESTIA_GUI} == gnome ]]; then
		gnome2_src_install
	else
		emake DESTDIR="${D}" install || die "emake install failed"
		for size in 16 22 32 48 ; do
			insinto /usr/share/icons/hicolor/${size}x${size}/apps
			newins "${S}"/src/celestia/kde/data/hi${size}-app-${PN}.png ${PN}.png
		done
	fi
	[[ ${CELESTIA_GUI} == glut ]] && domenu celestia.desktop
	dodoc AUTHORS README TODO TRANSLATORS *.txt || die
}