# -*- Mode: Tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem      1.0
PortGroup       github 1.0
PortGroup       muniversal  1.0

name            mpir
categories      devel math
license         LGPL-3
platforms       darwin
maintainers     {michaelld @michaelld} openmaintainer
description     Multiple Precision Integers and Rationals

long_description \
    MPIR: Multiple Precision Integers and Rationals, is a fork of \
    the GNU Multi Precision \(GMP\) library. MPIR is a library for \
    arbitrary precision arithmetic, operating on signed integers, \
    rational numbers, and floating point numbers. It has a rich set \
    of functions, and the functions have a regular interface. MPIR \
    is designed to be as fast as possible, both for small operands \
    and huge operands.  The speed is achieved by using fullwords as \
    the basic arithmetic type, by using fast algorithms, with \
    carefully optimized assembly code for the most common inner \
    loops for lots of CPUs, and by a general emphasis on speed \
    \(instead of simplicity or elegance\).

subport mpir-devel {}

if {${subport} eq ${name}} {

    # release
    conflicts       mpir-devel
    long_description {*}${long_description} \
        This port is kept up with the MPIR release, which is \
        typically updated a few times a year.

    github.setup    wbhart mpir 3.0.0 mpir-
    revision        2
    checksums       rmd160 62467f99886ae947ed29466880fc885cf5843d63 \
                    sha256 b0a4088134fb25f25725a04243f83039897c51139a0b5f1dcac1395963483c38 \
                    size   3116197

} else {

    # devel
    long_description {*}${long_description} \
        This port is kept up with the MPIR GIT master branch, which \
        is typically updated daily to weekly.

    conflicts       mpir

    github.setup wbhart mpir 077bc69ed91ee7a930f01628c545f17ce3f95a28
    version   20200610-[string range ${github.version} 0 7]
    checksums rmd160 1267de4ba12f16a91c19e0d4c5b1710f36f1525b \
              sha256 b2bcad9691b50083739492d97e3e5222a617a6a640b7b2d4ef053b5e506184d9 \
              size   2546267
    revision  1

}

homepage       http://www.mpir.org/

# universal_variant no

use_autoconf   yes
autoconf.cmd   ./autogen.sh

depends_build  port:autoconf \
               port:automake \
               port:libtool \
               port:yasm

patchfiles-append patch-fix-configure.diff
patch.pre_args -p1

configure.cppflags
compiler.cpath
compiler.library_path

configure.args-append --disable-silent-rules \
                      --enable-cxx

configure.universal_args-delete --disable-dependency-tracking

if {![variant_isset universal]} {
    if {${build_arch} eq "x86_64" || ${build_arch} eq "ppc64"} {
        configure.env-append ABI=64
    } else {
        configure.env-append ABI=32
    }
} else {
    array set merger_configure_env {
        ppc     ABI=mode32
        i386    ABI=32
        ppc64   ABI=mode64
        x86_64  ABI=64
    }
}

test.run       yes
test.target    check
