summaryrefslogtreecommitdiff
blob: 7115cc950cb43c9eb0e98008c170e65f8f19755a (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
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/postgis/postgis-1.1.1.ebuild,v 1.1 2006/03/20 08:04:01 nakano Exp $

inherit autotools eutils

DESCRIPTION="Geographic Objects for PostgreSQL"
HOMEPAGE="http://postgis.refractions.net"
SRC_URI="http://www.postgis.org/download/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"
IUSE="geos proj"

DEPEND=">=dev-db/postgresql-7.2
	app-text/docbook-xsl-stylesheets
	geos? ( sci-libs/geos )
	proj? ( sci-libs/proj )
	sys-devel/autoconf"
RDEPEND=">=dev-db/postgresql-7.2
	geos? ( sci-libs/geos )
	proj? ( sci-libs/proj )"

src_unpack(){
	unpack "${P}.tar.gz"
	cd "${S}"
	# Remove redundant installation of README.postgis from docs-install
	epatch "${FILESDIR}"/${P}_doc.patch
}

src_compile(){
	local myconf

	cd "${S}"
	local xslv="$(portageq match / app-text/docbook-xsl-stylesheets |\
		cut -d'/' -f2 | sed s/"docbook-"//)"
	einfo "doc will be build with ${xslv}"
	if [ ! -z "$(echo ${xslv} | grep '\-r')" ]; then
		xslv="$(echo ${xslv} | cut -d'-' -f1 )-$(echo ${xslv} | cut -d'-' -f2 )-$(echo ${xslv} | cut -d'-' -f3)"
	fi
	sed s/"xsl-stylesheets"/"${xslv}"/ -i configure.in
	myconf="${myconf} --with-docdir=/usr/share/doc/${PF}/html/"

	eautoconf
	myconf="${myconf} --enable-autoconf \
		--libdir=/usr/$(get_libdir)/postgresql/\
		--datadir=/usr/share/postgresql/contrib/"
	econf ${myconf} \
		$(use_with geos) \
		$(use_with proj)\
		|| die "Error: econf failed"

	emake || die "Error: emake failed"

	make docs || die "Unable to build documentation"
	cd topology/
	emake || die "Unable to build topology sql file"
}

src_install(){
	into /usr
	cd ${S}
	dodir /usr/$(get_libdir)/postgresql /usr/share/postgresql/contrib/
	make DESTDIR="${D}" install || die "einstall failed"
	cd "${S}"/topology/
	make DESTDIR="${D}" install

	cd "${S}"
	dodoc CHANGES COPYING CREDITS README.postgis TODO loader/README.*\
		doc/*txt || die "Unable to install doc"

	docinto topology
	dodoc topology/{TODO,README}

	cd "${S}"
	make DESTDIR="${D}" docs-install || die "Unable to install documentation"

	# postgis_proc_upgrade.pl is not needed cause it was used during
	# the compilation process and create the file
	# /usr/share/postgresql/contrib/lwpostgis_upgrade.sql (used to upgrade all
	# functions defined into the new lwpostgis.sql, simply done with command :
	# 'create or replace function'). So I decided to install only
	# postgis_restore.pl for a hard upgrade (cf.
	# http://postgis.refractions.net/docs/ch02.html#upgrading)
	bininto "${D}"/usr/bin/
	dobin ./utils/postgis_restore.pl
}

pkg_postinst() {
	einfo "To create your first postgis database do the followings commands :"
	einfo " # su postgres"
	einfo " # createdb test"
	einfo " # createlang plpgsql test"
	einfo " # psql -d test -f /usr/share/postgresql/contrib/lwpostgis.sql"
	einfo " # psql -d test -f /usr/share/postgresql/contrib/spatial_ref_sys.sql"
	einfo "For more informations see : http://postgis.refractions.net/documentation.php"
	einfo "(For french user only see http://techer.pascal.free.fr/postgis)"
}