# -*- 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 111353 2013-09-19 07:21:56Z ryandesign@macports.org $

PortSystem 1.0

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

name                mpfr
set base_version    3.1.1
set patch_level     2
version             ${base_version}-p${patch_level}
#version             ${base_version}
categories          devel math
platforms           darwin
license             LGPL-3+
maintainers         nomaintainer

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.

distname            ${name}-${base_version}
homepage            http://www.mpfr.org/
master_sites        http://www.mpfr.org/${distname}/

use_xz              yes

checksums           patch01 \
                    rmd160  85434fe0b6e038cfc442192644924923ee0b646b \
                    sha256  81ba90e0ad8f13f5392626b3b06f9145071dbbfc2b21099f562bf7f51a5228a3 \
                    patch02 \
                    rmd160  47646390186d9d76bad7b1f799c2dfa94501627e \
                    sha256  40d152b1e94ee2accb17a8d6b870378f7774739f6348c6205c4d6c5dccdb12cf \
                    ${distname}${extract.suffix} \
                    rmd160  de61952998c5fe3e0467ed420d0aa5f1963e4a98 \
                    sha256  49d5acc32dbeec30a8e26af9c19845763d63feacb8bf97b12876008419f5a17a

use_parallel_build  yes

depends_lib     port:gmp

dist_subdir     ${name}/${base_version}

patch_sites     ${master_sites}
patch.args      -p1

for {set i 1} {${i} <= ${patch_level}} {incr i} {
    patchfiles-append patch[format %02d ${i}]
}

# 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.
configure.args  --disable-thread-safe

test.run        yes
test.target     check

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