summaryrefslogtreecommitdiff
blob: 70216be3471154bfaaa89917a7f3e5d1ac536842 (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
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-libs/mozldap/mozldap-6.0.6-r2.ebuild,v 1.1 2010/09/05 14:53:25 xarthisius Exp $

EAPI="2"

WANT_AUTOCONF="2.1"

inherit eutils multilib versionator autotools

DESCRIPTION="Mozilla LDAP C SDK"
HOMEPAGE="http://wiki.mozilla.org/LDAP_C_SDK"
SRC_URI="ftp://ftp.mozilla.org/pub/mozilla.org/directory/c-sdk/releases/v${PV}/src/${P}.tar.gz"

LICENSE="MPL-1.1 GPL-2 LGPL-2.1"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="ipv6 debug +sasl"

COMMON_DEPEND=">=dev-libs/nss-3.11.4
	>=dev-libs/nspr-4.0.1
	>=dev-libs/svrcore-4.0.0
	sasl? ( dev-libs/cyrus-sasl )"
DEPEND="${COMMON_DEPEND}
	dev-util/pkgconfig"
RDEPEND="${COMMON_DEPEND}"

S="${WORKDIR}"/"${P}"/"mozilla/directory/c-sdk"

src_prepare() {
	epatch "${FILESDIR}"/${PN}-6.0.4-pkgconfig.patch \
		"${FILESDIR}"/configure.in.patch \
		"${FILESDIR}"/nss-m4.patch \
		"${FILESDIR}"/nspr-m4.patch \
		"${FILESDIR}"/${P}-ldflags.patch
	eautoreconf
}

src_configure() {
	local myconf="--libdir=/usr/$(get_libdir)/mozldap"
	econf $(use_enable debug) \
		$(use_enable ipv6) \
		$(use_enable amd64 64bit) \
		$(use_with sasl) \
		--with-svrcore-inc=/usr/include/svrcore \
		--with-svrcore-lib=/usr/$(get_libdir)/svrcore \
		--enable-clu \
		--enable-optimize \
		${myconf} || die "econf failed"
}

src_install () {
	# Their build system is royally fucked, as usual
	cd "${S}"
	sed -e "s,%libdir%,\$\{exec_prefix\}/$(get_libdir)/${PN},g" \
	    -e "s,%prefix%,/usr,g" \
	    -e "s,%major%,$(get_major_version ${PV}),g" \
	    -e "s,%minor%,$(get_version_component_range 2 ${PV}),g" \
	    -e "s,%submin%,$(get_version_component_range 3 ${PV}),g" \
	    -e "s,%libsuffix%,$(get_major_version ${PV})$(get_version_component_range 2 ${PV}),g" \
	    -e "s,%bindir%,\$\{exec_prefix\}/$(get_libdir)/${PN},g" \
	    -e "s,%exec_prefix%,\$\{prefix\},g" \
	    -e "s,%includedir%,\$\{exec_prefix\}/include/${PN},g" \
	    -e "s,%NSPR_VERSION%,$(pkg-config --modversion nspr),g" \
	    -e "s,%NSS_VERSION%,$(pkg-config --modversion nss),g" \
	    -e "s,%SVRCORE_VERSION%,$(pkg-config --modversion svrcore),g" \
	    -e "s,%MOZLDAP_VERSION%,${PV},g" \
	   "${S}"/"${PN}".pc.in > "${S}"/"${PN}".pc || die "sed in install failed"

	emake  install || die "make failed"
	local MY_S="${WORKDIR}"/"${P}"/mozilla/dist/

	rm -rf "${MY_S}/bin/"lib*.so
	rm -rf "${MY_S}/public/ldap-private"

	exeinto /usr/$(get_libdir)/mozldap
	doexe "${MY_S}"/lib/*so*
	doexe "${MY_S}"/lib/*.a
	doexe "${MY_S}"/bin/*

	#create compatibility PATH link

	 for i in ldapcmp ldapcompare ldapdelete ldapmodify \
		 	ldappasswd ldapsearch;do
	 	dosym /usr/$(get_libdir)/mozldap/$i /usr/bin/moz"${i}" || die
	 # compat for 389-project
		dosym /usr/$(get_libdir)/mozldap/$i /usr/bin/389-"${i}" || die
	done

	# move the headers around
	insinto /usr/include/mozldap
	doins "${MY_S}/public/ldap/"*.h

	# add sample config
	insinto /usr/share/mozldap
	doins "${MY_S}"/etc/*.conf

	#and while at it move them to files with versions-ending
	#and link them back :)
	cd "${D}"/usr/$(get_libdir)/mozldap

	#create compatibility Link
	ln -sf libldap$(get_major_version ${PV})$(get_version_component_range 2 ${PV}).so \
		liblber$(get_major_version ${PV})$(get_version_component_range 2 ${PV}).so || die
	#so lets move
	for file in *.so; do
		mv ${file} ${file}.$(get_major_version ${PV}).$(get_version_component_range 2 ${PV}) || die
		ln -sf ${file}.$(get_major_version ${PV}).$(get_version_component_range 2 ${PV}) ${file} || die
		ln -sf ${file}.$(get_major_version ${PV}).$(get_version_component_range 2 ${PV}) \
			${file}.$(get_major_version ${PV}) || die
	done

	# cope with libraries being in /usr/lib/mozldap
	dodir /etc/env.d
	echo "LDPATH=/usr/$(get_libdir)/mozldap" > "${D}"/etc/env.d/08mozldap

	# create pkg-config file
	insinto /usr/$(get_libdir)/pkgconfig/
	doins "${S}"/mozldap.pc
}