# -*- 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           cmake 1.1
PortGroup           github 1.0
PortGroup           linear_algebra 1.0
PortGroup           mpi 1.0

github.setup        william-dawson NTPoly 3.1.0 ntpoly-v _bigdft
revision            1
categories          math
license             MIT
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         Library for computing the functions of sparse matrices
long_description    NTPoly is a massively parallel library for computing the functions of sparse, \
                    Hermitian matrices based on polynomial expansions. For sufficiently sparse matrices, \
                    most of the matrix functions in NTPoly can be computed in linear time.
homepage            https://william-dawson.github.io/NTPoly
checksums           rmd160  548ec88eb7028416478cbd67f4c7c987de3bc2d8 \
                    sha256  33b2dfd281ce46c9bb52b9505c54d6e77c5a882b9d94ceb3dc72fee2055b458d \
                    size    306359
github.tarball_from archive

set_default_variants    no

if {![variant_isset accelerate] && ![variant_isset atlas] && ![variant_isset blis] \
    && ![variant_isset flexiblas] && ![variant_isset openblas]} {
        default_variants-append +openblas
}

if {${os.platform} eq "darwin" && ${os.arch} eq "powerpc"} {
    mpi.setup       require require_fortran \
                    -gcc44 -gcc45 -gcc46 -gcc47 -gcc48 -gcc49 -gcc5 -gcc6 \
                    -clang -fortran
} else {
    mpi.setup       require require_fortran \
                    -gcc44 -gcc45 -gcc46 -gcc47 -gcc48 -gcc49 -gcc5 -gcc6
}

# https://github.com/william-dawson/NTPoly/issues/192
compiler.blacklist-append \
                    {clang < 500}

pre-configure {
    # Otherwise configure may pick a random BLAS implementation, like FlexiBLAS.
    # Notice that +blis does not build atm: https://github.com/william-dawson/NTPoly/issues/228
    if [variant_isset openblas] {
        configure.args-append  \
                    -DBLAS_LIBRARIES=${prefix}/lib/libopenblas.dylib \
                    -DLAPACK_LIBRARIES=${prefix}/lib/libopenblas.dylib
    }
}

configure.args-append \
                    -DBUILD_SHARED_LIBS=on \
                    -DNOSWIG=yes

# Error: Type mismatch between actual argument at (1) and actual argument at (2)
compilers.allow_arguments_mismatch yes
