# $Id: Portfile 60245 2009-11-07 08:25:38Z jmr@macports.org $

PortSystem 1.0

name            ntl
version         5.4.2
categories      math
platforms       darwin
maintainers     fimaluka.org:ralf
description     NTL: A Library for doing Number Theory
long_description NTL is a high-performance, portable C++ library providing\
                 data structures and algorithms for arbitrary length\
                 integers\; for vectors, matrices, and polynomials over the\
                 integers and over finite fields\; and for arbitrary\
                 precision floating point arithmetic.

homepage		http://shoup.net/ntl/
master_sites    ${homepage}
checksums       md5 0aac5c680eee09a19732e1601b237a0b \
                sha1 0250461a5e205663f7e446211c9571b6aad249e9 \
                rmd160 5657f4f3b18281787b85f561b184c757254f656f

depends_build   path:bin/perl:perl5

test.run        no

configure.pre_args      PREFIX=\"${prefix}\" DOCDIR=\"${prefix}/share/doc\"
configure.args          NTL_STD_CXX=on \
                        CC=\"\$CC\" CXX=\"\$CXX\" CFLAGS=\"\$CFLAGS\" CXXFLAGS=\"\$CXXFLAGS\"

worksrcdir      ${name}-${version}/src

destroot.destdir PREFIX=\"${destroot}${prefix}\" DOCDIR=\"${destroot}${prefix}/share/doc\"

post-patch {
        # Ensure that the correct perl is used
        reinplace "s|perl DoConfig|${prefix}/bin/perl DoConfig|g" ${worksrcpath}/configure
}

variant gmp {
        depends_lib-append      port:gmp
        configure.args-append   NTL_GMP_LIP=on GMP_PREFIX=\"${prefix}\"
}

post-destroot {
        system "cd ${destroot}${prefix}/share/doc && mv NTL tmp && mv tmp ntl"
        xinstall -m 0644 ${worksrcpath}/../README \
                         ${destroot}${prefix}/share/doc/${name}
        xinstall -m 0644 ${worksrcpath}/../doc/copying.txt \
                         ${destroot}${prefix}/share/doc/${name}/LICENSE
}

livecheck.url    http://shoup.net/ntl/download.html
livecheck.regex  "Download NTL (\\d(?:\\.\\d+)*)"
