# $Id: Portfile 67394 2010-05-07 10:46:15Z jeremyhu@macports.org $

PortSystem	1.0
PortGroup       muniversal 1.0

name		nspr
version		4.8.4
categories	devel
maintainers	jeremyhu openmaintainer
platforms	darwin
description	A platform-neutral API for system level and libc like functions.

long_description ${description}

homepage	http://www.mozilla.org/projects/nspr
master_sites	http://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v${version}/src/ \
		ftp://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v${version}/src/

checksums           md5     a85bdbe1eb646aa32c785a37d8e3a2f5 \
                    sha1    c4af8c2956674ff0f17b4247516716e92db40cf6 \
                    rmd160  654b86f773130f74a19df3a06e40917a4cef9eb7

worksrcdir	${worksrcdir}/mozilla/nsprpub

post-patch {
    reinplace "s:@LDFLAGS@:${configure.ldflags}:" \
        ${worksrcpath}/config/nspr-config.in
	reinplace "s|@executable_path|${prefix}/lib/nspr|g" \
		${worksrcpath}/configure
}

configure.args \
	--disable-debug \
	--enable-optimize='-O2' \
	--enable-strip \
	--libdir=${prefix}/lib/nspr

set merger_configure_args(ppc64)  "--enable-64bit"
set merger_configure_args(x86_64) "--enable-64bit"

variant debug description "build with debugging symbols" {
    configure.args-delete   --disable-debug \
                            --enable-optimize='-O2' \
                            --enable-strip

    configure.args-append   --enable-debug='-ggdb3' \
                            --disable-optimize \
                            --disable-strip

    configure.cflags ""
}

post-destroot {
	file mkdir ${destroot}${prefix}/lib/pkgconfig
	copy ${filespath}/nspr.pc ${destroot}${prefix}/lib/pkgconfig
	reinplace "s|@@prefix@@|${prefix}|" ${destroot}${prefix}/lib/pkgconfig/nspr.pc
	set mylibs [exec ${destroot}${prefix}/bin/nspr-config --libs]
	set mycflags [exec ${destroot}${prefix}/bin/nspr-config --cflags]
	set myversion [exec ${destroot}${prefix}/bin/nspr-config --version]
	reinplace "s|@@FULL_NSPR_LIBS@@|${mylibs}|" ${destroot}${prefix}/lib/pkgconfig/nspr.pc
	reinplace "s|@@FULL_NSPR_CFLAGS@@|${mycflags}|" ${destroot}${prefix}/lib/pkgconfig/nspr.pc
	reinplace "s|@@NSPR_VERSION@@|${myversion}|" ${destroot}${prefix}/lib/pkgconfig/nspr.pc
}

livecheck.type  regex
livecheck.url   ${homepage}/release-notes/
livecheck.regex {NSPR (\d+(?:\.\d+)*)<}
