# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 85360 2011-10-13 02:17:56Z rmstonecipher@macports.org $

PortSystem	1.0
PortGroup       muniversal 1.0

name		nspr
version		4.8.9
categories	devel
maintainers	jeremyhu openmaintainer
license             {MPL-1.1 GPL-2+ LGPL-2.1+}
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     60770d45dc08c0f181b22cdfce5be3e8 \
                    sha1    509785e68f52542778c770445329cc4db15c749b \
                    rmd160  6c7089a9d798367b8d559e5dea8e732e73b47df2

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   [lindex ${master_sites} 0]
livecheck.url	http://ftp.mozilla.org/pub/mozilla.org/nspr/releases/
livecheck.regex "v(\\d+(?:\\.\\d+)*)"
