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

name                sparskit
# note, this is the "version 2" updated in 2019, not the earlier one from 2015 or before
version             2-20210601
revision            0
checksums           rmd160  235a973af274442edd26726011b306e490d54ef8 \
                    sha256  a9bf3f595b733a4f5db211664aa775108b5078f280d58eb4e32dbc3a40a77a72 \
                    size    1176828
categories          science
maintainers         {dstrubbe @dstrubbe}
license             LGPL-2.1+

description         A basic tool-kit for sparse matrix computations

long_description    A basic tool-kit for sparse matrix computations: programs \
                    for converting data structures, printing simple \
                    statistics on a matrix, plotting a matrix profile, \
                    performing basic linear algebra operations with sparse \
                    matrices and so on.

homepage            https://www-users.cs.umn.edu/~saad/software/SPARSKIT
master_sites        ${homepage}
distname            SPARSKIT2

# This line should be removed when the next proper version of the software is released.
dist_subdir         ${name}/${version}

use_configure       no

patchfiles          patch-makefile.diff \
                    patch-INOUT-makefile.diff \
                    patch-MATGEN-FEM-makefile.diff

compilers.choose    fc
compilers.setup     require_fortran
compilers.allow_arguments_mismatch yes

depends_build-append port:cctools

configure.optflags  -O3

build.args          OPT="-c ${configure.fcflags}"

use_parallel_build  yes

test.run            yes
test.args           FFLAGS="${configure.fcflags}"
# test requires FC, FFLAGS set because test makefiles lack explicit rule for .f -> .o and these are in the implicit rule
# One test may fail currently: /bin/sh: line 1: 11978 Segmentation fault: 11  ./info1.ex < saylr1

pre-build {
    build.args-append  F77=${configure.fc} FFLAGS="${configure.fcflags}"
}

pre-test {
    test.args-append   F77=${configure.fc} FC=${configure.fc}
}

destroot {
    xinstall ${worksrcpath}/libskit.a ${destroot}${prefix}/lib/
}

post-test {
    ui_notice "Examine log file for test results."
}

livecheck.type      regex
livecheck.url       [lindex ${master_sites} 0]
livecheck.regex     SPARSKIT(\[0-9.\]+)[quotemeta ${extract.suffix}]
