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

github.setup        rjhogan Adept-2 9ac1eaa0b3ae95d230504f11d52b9cc4b43ef112
name                adept2
version             2024.01.24
revision            0
categories          math
license             Apache-2
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         Fast automatic differentiation library in C++
long_description    Combined array and automatic differentiation library in C++.
homepage            https://www.met.reading.ac.uk/clouds/adept
checksums           rmd160  eb7b29f03b31d26c9361b333002198493cf93f42 \
                    sha256  82c62d658ceb2654b313a709a13a3beeb318701bc50abf20c5891d42ecaa6abb \
                    size    333335
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
}

use_autoreconf      yes

compilers.choose    fc f90 f77
compilers.setup     require_fortran

compiler.thread_local_storage yes

if [variant_isset openblas] {
    post-patch {
        reinplace "s|include <cblas.h>|include <cblas_openblas.h>|" ${worksrcpath}/configure.ac
        reinplace "s|cblas.h|cblas_openblas.h|" ${worksrcpath}/adept/settings.cpp
    }
}

pre-configure {
    configure.args-append \
                    --with-blas="-L${prefix}/lib ${linalglib}"
}

depends_test-append port:gsl

test.run            yes
test.target         check
