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

name                armadillo
version             15.2.6
revision            0

categories          science math
maintainers         {mps @Schamschula} openmaintainer
license             Apache-2

description         Armadillo C++ linear algebra library
long_description    Armadillo is a C++ linear algebra library (matrix maths) \
                    aiming towards a good balance between speed and ease of use. \
                    Integer, floating point and complex numbers are supported, \
                    as well as a subset of trigonometric and statistics functions. \
                    Various matrix decompositions are provided through optional \
                    integration with LAPACK or high-performance LAPACK-compatible \
                    libraries.

homepage            http://arma.sf.net
master_sites        sourceforge:project/arma

use_xz              yes

checksums           rmd160  fe75179c425d15e346d644931f98a1ce83f13d81 \
                    sha256  97cb8ef708541f632e861d005a462dd0367240f81ff96f8e63ebbdd75c8ce55f \
                    size    7100608

depends_build-append \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:hdf5

mpi.setup
mpi.enforce_variant hdf5
 
configure.args-append \
                    -DALLOW_BLAS_LAPACK_MACOS=OFF \
                    -DALLOW_OPENBLAS_MACOS=OFF \
                    -DARPACK_LIBRARY=

variant accelerate description "Compile with Accelerate support" {
    configure.args-replace  -DALLOW_BLAS_LAPACK_MACOS=OFF -DALLOW_BLAS_LAPACK_MACOS=ON
}

variant arpack description "Compile with ARPACK support" {
    depends_lib-append      port:arpack
    configure.args-delete   -DARPACK_LIBRARY=
}

variant openblas description "Compile with OpenBLAS support" {
    depends_lib-append      path:lib/libopenblas.dylib:OpenBLAS
    configure.args-replace  -DALLOW_OPENBLAS_MACOS=OFF -DALLOW_OPENBLAS_MACOS=ON
    configure.args-append   -DOPENBLAS_PROVIDES_LAPACK=ON
}

variant superlu description "Compile with SuperLU support" {
    depends_lib-append      port:superlu
    configure.args-append   -DARMA_USE_SUPERLU=ON
}

if {${os.platform} eq "darwin" && ${os.major} < 11} {
    # Without OpenBLAS the build fails on Leopard and Rosetta with undefined symbols.
    # https://trac.macports.org/ticket/65292
    # -DALLOW_OPENBLAS_MACOS=ON is necessary.
    default_variants-append +openblas
} else {
    # This port allows simultaneous usage of Accelerate and OpenBLAS, somehow.
    default_variants-append +accelerate
}

# Fix https://trac.macports.org/ticket/59173,
# also see https://trac.macports.org/ticket/56554
if {[variant_isset gcc44] || [variant_isset gcc45] || [variant_isset gcc46] || \
    [variant_isset gcc47] || [variant_isset gcc48] || [variant_isset gcc49] || \
    [variant_isset gcc5] || [variant_isset gcc6] || [variant_isset gcc7] || \
    [variant_isset gcc8] || [variant_isset gcc9]} {
    configure.cxx_stdlib    libstdc++
}

compiler.cxx_standard \
                    2011
compiler.thread_local_storage \
                    yes

livecheck.type      regex
livecheck.url       ${homepage}download.html
livecheck.regex     /${name}-(\[0-9.\]+)${extract.suffix}
