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

# Although mpfr builds without a custom universal variant,
# it is not the same as building the archs differently
# due to the variable HAVE_LDOUBLE_IEEE_EXT_LITTLE.
PortGroup           muniversal 1.0
PortGroup           xcode_workaround 1.0

platforms           darwin
categories          devel math

name                mpfr
version             4.2.2
revision            0

checksums           rmd160  ee9f8e95d43c9deb993b017967c2b905af35b322 \
                    sha256  b67ba0383ef7e8a8563734e2e889ef5ec3c3b898a01d00fa0a6869ad81c6ce01 \
                    size    1505596

homepage            https://www.mpfr.org/
master_sites        ${homepage}/${distname}
license             LGPL-3+
maintainers         {larryv @larryv} openmaintainer

description         C library for multiple-precision floating-point \
                    computations
long_description    MPFR is a portable C library for arbitrary-precision \
                    binary floating-point computation with correct \
                    rounding, based on the GMP multiple-precision \
                    library. The computation is both efficient and \
                    has a well-defined semantics. It copies the good \
                    ideas from the ANSI/IEEE-754 standard for \
                    fixed-precision floating-point arithmetic.

use_xz              yes

depends_lib-append  port:gmp

# see https://trac.macports.org/ticket/60091
xcode_workaround.fixed_xcode_version 11.2

# Due to radr://10291355 (llvm.org PR11111), the new tls support enabled in clang with Xcode 4.2
# miscompiles mpfr. While this was fixed in Xcode 4.2.1, as the ttls support was never used prior to
# Xcode 4.2, the generic fix is to pass --disable-thread-safe to configure, however this will break
# any project that requires a thread-safe mpfr library, therefore the Xcode 4.2 compiler is
# blacklisted here
compiler.blacklist-append  {clang == 211.10.1}

if {${os.platform} eq "darwin" && ${os.major} < 11} {
    # the OS toolchains on these systems do not support TLS.
    # macports-clang-N also does not presently build this correctly on these systems
    # A multithreaded mpfr is possible on these systems by building with a
    # current gcc version but that involves a cyclical dep at present
    configure.args-append --disable-thread-safe
}

test.run            yes
test.target         check

livecheck.url       http://www.mpfr.org/mpfr-current/
livecheck.regex     "mpfr-(\\d+(?:\\.\\d+)*)${extract.suffix}"
