summaryrefslogtreecommitdiff
blob: 06b2bdd37c2a8404077470d799c9b0b51d5ada21 (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
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sci-libs/geos/geos-2.2.3.ebuild,v 1.7 2008/07/02 16:51:29 bicatali Exp $

USE_RUBY="ruby18"
RUBY_OPTIONAL="yes"

inherit eutils distutils ruby toolchain-funcs

DESCRIPTION="Geometry engine library for Geographic Information Systems"
HOMEPAGE="http://geos.refractions.net"
SRC_URI="http://geos.refractions.net/${P}.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~ppc ppc64 ~sparc x86"
IUSE="doc python ruby"

RDEPEND="ruby? ( virtual/ruby )
	python? ( virtual/python )"
DEPEND="${RDEPEND}
	doc? ( app-doc/doxygen )\
	ruby?  ( >=dev-lang/swig-1.3.29 )
	python? ( >=dev-lang/swig-1.3.29 )"

src_unpack() {
	unpack ${A}
	cd "${S}"
	epatch "${FILESDIR}/${P}-swig.patch"
	epatch "${FILESDIR}/${P}-python-shared.patch"
	epatch "${FILESDIR}/${P}-gcc43.patch"
}

src_compile() {
	econf || die "econf failed"
	emake || die "emake failed"

	if use python; then
		einfo "Compilling PyGEOS"
		cd "${S}/swig/python"
		cp "${FILESDIR}/python.i" "${S}/swig/python/"
		rm -f geos_wrap.cxx
		swig -c++ -python -modern -o geos_wrap.cxx ../geos.i
		distutils_src_compile
	fi
	if use ruby; then
		einfo "Compilling Ruby bindings"
		cd "${S}"/swig/ruby
		swig -c++ -ruby -autorename -o geos_wrap.cxx ../geos.i
		local CXX=$(tc-getCXX)
		local RUBY_ARCHDIR="$(ruby -r rbconfig -e 'print Config::CONFIG["archdir"]')"
		${CXX} ${CXXFLAGS} -I../../source/headers -I${RUBY_ARCHDIR} \
			-fPIC -c geos_wrap.cxx
		${CXX} ${CXXFLAGS} -shared -L"${S}"/source/geom/.libs -lgeos \
			-lruby geos_wrap.o -o geos.so
	fi
}

src_test() {
	emake check || die "Trying make check without success."
	# I think this test must be made after the PyGEOS installation
	#export PYTHONPATH=${S}/swig/python
	if use python; then
		cd "${S}"/swig/python
		python tests/runtests.py -v
	fi
}

src_install(){
	emake install DESTDIR="${D}" || die "emake install failed"

	if use python; then
		einfo "Installing PyGEOS"
		cd "${S}"/swig/python
		distutils_src_install
		insinto /usr/share/doc/${PF}/python
		doins README.txt tests/*.py || die
		insinto /usr/share/doc/${PF}/python/cases
		doins tests/cases/* || die
	fi
	if use ruby; then
		local RUBY_SITEARCHDIR="$(ruby -r rbconfig -e 'print Config::CONFIG["sitearchdir"]')"
		einfo "Installing Ruby bindings in ${RUBY_SITEARCHDIR}/${PN}"
		cd "${S}"/swig/ruby
		insinto ${RUBY_SITEARCHDIR}/${PN}
		doins geos.so || die
		insinto /usr/share/doc/${PF}/ruby
		doins README.txt test/*.rb || die
		if use doc; then
			erubydoc
		fi
	fi
	if use doc; then
		cd "${S}"/doc
		emake doxygen-html || die "make doxygen docs failed"
		dohtml -r doxygen_docs/html/*  || die
	fi
	cd "${S}"
	dodoc AUTHORS NEWS README TODO || die
}

pkg_postinst() {
	if use python; then
		python_version
		python_mod_optimize /usr/bin
	fi
}

pkg_postrm() {
	if use python; then
		python_mod_cleanup
	fi
}