# $Id: Portfile,v 1.13 2005/09/14 17:06:54 landonf Exp $

PortSystem 1.0
name            openldap
version         2.2.28
categories      databases
maintainers     landonf@opendarwin.org bchesneau@mac.com
description     OpenLDAP Software 
long_description	OpenLDAP Software is an open source implementation \
			of the Lightweight Directory Access Protocol.  

platforms       darwin freebsd
master_sites    ftp://ftp.OpenLDAP.org/pub/OpenLDAP/openldap-release/ \
		http://www.PlanetMirror.com/pub/openldap/openldap-release/ 
distfiles	${name}-${version}.tgz
checksums	md5 b51db7328430b9cbe527696da726f1fb

depends_lib	port:db4 \
		port:perl5.8 \
		port:cyrus-sasl2 \
		port:openssl

depends_run 	path:/Library/StartupItems/DarwinPortsStartup:DarwinPortsStartup

patchfiles	patch-ltmain

configure.env   LDFLAGS="-L${prefix}/lib" \
		CPPFLAGS="-I${prefix}/include -I${prefix}/include/db4 -I/usr/include/openssl -DBIND_8_COMPAT" \
		LANG=C

configure.args	--mandir=${prefix}/share/man \
		--localstatedir=${prefix}/var/run \
		--with-cyrus-sasl \
		--with-tls \
		--enable-wrappers

platform darwin 6 {
        depends_lib-append      lib:libdl:dlcompat
}

variant ipv6 {
	configure.args-append --enable-ipv6
}

pre-configure {
	if { ![variant_isset ipv6]} {
		configure.args-append --disable-ipv6
	}
}

pre-build {
	system "cd ${workpath}/${worksrcdir} && \
			make depend"
}

pre-destroot {
	# should be in pre-deploy....
	addgroup ldap
	set gid [existsgroup ldap]
	adduser ldap gid=${gid}
}

post-destroot {
	xinstall -d -g ldap -m 700 -o ldap \
		"${destroot}${prefix}/var/run/openldap-data"
	#since post-deploy doesn't exist
	xinstall -d -m 755 -o root "${destroot}${prefix}/etc/rc.d"
	xinstall -m 755 -o root "${portpath}/files/slapd.sh" \
		"${destroot}${prefix}/etc/rc.d"
	reinplace "s|__PREFIX|${prefix}|g" \
		${destroot}${prefix}/etc/rc.d/slapd.sh
}
