# -*- 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

PortSystem              1.0
PortGroup               muniversal 1.0

name                    ntl
version                 11.6.0
revision                0
categories              math devel
license                 LGPL-2.1+
maintainers             {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
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                https://libntl.org
master_sites            ${homepage}/

checksums               rmd160  291aa35b9f905be927cf0ce7e63d0535c1d12530 \
                        sha256  bc0ef9aceb075a6a0673ac8d8f47d5f8458c72fe806e4468fbd5d3daff056182 \
                        size    2599487

compiler.cxx_standard   2011

depends_build-append    bin:perl:perl5
depends_lib-append      port:gmp

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

configure.pre_args-replace \
                        --prefix=${prefix} \
                        PREFIX=\"${prefix}\"
# build shared library
# do not try to add -march=native
# look for external libraries (e.g. GMP) in ${prefix}
configure.args-append   SHARED=on \
                        NATIVE=off \
                        DEF_PREFIX=\"${prefix}\"

# respect MacPorts variables
foreach val {CXX CXXFLAGS CPPFLAGS LDFLAGS} {
    configure.args-append ${val}=\"\$${val}\"
}

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

variant tuned description {Build with more optimizations} {
    configure.args-delete  NATIVE=off
    configure.args-append  TUNE=auto
}

test.run                yes
test.target             check

livecheck.url           ${homepage}/download.html
livecheck.regex         "${name}-(\[0-9]+(\\.\[0-9]+)*)\\.tar\\.gz"
