# -*- 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.1

github.setup        rjhogan Adept-2 16df3ddfbc82605073c0e139916971a045adc36e
name                adept2
version             2024.02.22
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  d1d51537fbb87bedbec874d045c99ebf28c9ff77 \
                    sha256  5dd21bb098423fd2f5f5a398c25b8d40c137e3d3ebefa21602043e415e5db6d2 \
                    size    333366
github.tarball_from archive

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
