summaryrefslogtreecommitdiff
blob: 644f48fe4be5c58f0833e85451c59ddd40ddb71b (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
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/libpq/libpq-7.3.21.ebuild,v 1.3 2008/01/14 01:14:51 ranger Exp $

inherit eutils gnuconfig flag-o-matic toolchain-funcs

KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ppc64 ~s390 ~sh ~sparc x86"

DESCRIPTION="PostgreSQL libraries."
HOMEPAGE="http://www.postgresql.org/"
SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
LICENSE="POSTGRESQL"
SLOT="3"
IUSE="kerberos nls pam pg-intdatetime readline ssl zlib"

RDEPEND="!<=dev-db/postgresql-7.3.15-r1
		kerberos? ( virtual/krb5 )
		pam? ( virtual/pam )
		readline? ( >=sys-libs/readline-4.1 )
		ssl? ( >=dev-libs/openssl-0.9.6-r1 )
		zlib? ( >=sys-libs/zlib-1.1.3 )"
DEPEND="${RDEPEND}
		sys-devel/autoconf
		>=sys-devel/bison-1.875
		nls? ( sys-devel/gettext )"

S="${WORKDIR}/postgresql-${PV}"

pkg_preinst() {
	# Removing wrong symlink created by previous ebuild
	if [[ -L "${ROOT}/usr/include/libpq" ]] ; then
		rm -f "${ROOT}/usr/include/libpq"
	fi
}

src_unpack() {
	unpack ${A}
	cd "${S}"

	epatch "${FILESDIR}/${P}-gentoo.patch"
}

src_compile() {
	filter-flags -ffast-math -feliminate-dwarf2-dups

	# Detect mips systems properly
	gnuconfig_update

	cd "${S}"

	./configure --prefix=/usr \
		--includedir=/usr/include/postgresql/libpq-${SLOT} \
		--sysconfdir=/etc/postgresql \
		--mandir=/usr/share/man \
		--host=${CHOST} \
		--docdir=/usr/share/doc/${PF} \
		--libdir=/usr/$(get_libdir) \
		--enable-depend \
		$(use_with kerberos krb5) \
		$(use_enable nls ) \
		$(use_with pam) \
		--without-perl \
		$(use_enable pg-intdatetime integer-datetimes ) \
		--without-python \
		$(use_with readline) \
		$(use_with ssl openssl) \
		--without-tcl \
		--without-tk \
		$(use_with zlib) \
		|| die "configure failed"

	cd "${S}/src/interfaces/libpq"
	emake -j1 LD="$(tc-getLD) $(get_abi_LDFLAGS)" || die "emake libpq failed"

	cd "${S}/src/bin/pg_config"
	emake -j1 LD="$(tc-getLD) $(get_abi_LDFLAGS)" || die "emake pg_config failed"
}

src_install() {
	cd "${S}/src/interfaces/libpq"
	emake DESTDIR="${D}" LIBDIR="${D}/usr/$(get_libdir)" install || die "emake install libpq failed"

	cd "${S}/src/include"
	emake DESTDIR="${D}" install-all-headers || die "emake install headers failed"

	cd "${S}/src/bin/pg_config"
	emake DESTDIR="${D}" install || die "emake install pg_config failed"

	cd "${S}"
	dodoc README HISTORY

	dosym libpq-${SLOT}.a /usr/$(get_libdir)/libpq.a

	for f in $(ls -1 "${D}"/usr/include/postgresql/libpq-${SLOT}/*.h) ; do
		dosym postgresql/libpq-${SLOT}/$(basename ${f}) /usr/include/
	done

	dodir /usr/include/libpq
	for f in $(ls -1 "${D}"/usr/include/postgresql/libpq-${SLOT}/libpq/*.h) ; do
		dosym ../postgresql/libpq-${SLOT}/libpq/$(basename ${f}) /usr/include/libpq/
	done

	cd "${D}/usr/include/postgresql/libpq-${SLOT}"
	for f in $(find * -name '*.h' -print) ; do
		destdir=$(dirname ${f})
		if [[ ! -d "${D}/usr/include/postgresql/${destdir}" ]] ; then
			dodir "/usr/include/postgresql/${destdir}"
		fi
		dosym /usr/include/postgresql/libpq-${SLOT}/${f} "/usr/include/postgresql/${destdir}/"
	done
}

src_test() {
	einfo "No tests available for libpq."
}