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

name                gr-specest
maintainers         {michaelld @michaelld} openmaintainer
description         Provides spectral estimation blocks for GNU Radio.
long_description    {*}${description}
license             GPL-3

# Claims to use c++11 but actually needs constexpr constants 
compiler.cxx_standard 2017
configure.cxxflags-append -std=c++17
compiler.blacklist    {clang < 1103}

if {${subport} eq ${name}} {

    github.setup    kit-cel gr-specest fe599836c38e2a858c1ae0703ebd006a2fe9edae
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20191014-[string range ${github.version} 0 7]
    checksums       rmd160  9b44d1d1b49a1d7624115ae76bbc539b91a96783 \
                    sha256  63b75c426f14b9d0b817cdfbc58724e8c44c4d590217943792a6d30a12cf8e34 \
                    size    568696
    revision        6

    conflicts gr37-specest

    depends_lib-append \
        port:gr-osmosdr

}

subport gr37-specest {

    name            gr37-specest

    github.setup    kit-cel gr-specest 91a27336b19a65125483fe0424b16f31822e7c85
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20180115
    revision        4
    checksums       rmd160 5b9614203006aa5ef497caccaa86dab2b40324b4 \
                    sha256 3cdd50bc68a002509bb14d4ab0565736409c171b7fb443694dc2fbcecd6d4227 \
                    size   562474

    conflicts       gr-specest

    patchfiles-append \
        patch-fix_build.37.diff

    depends_lib-append \
        port:gr37-osmosdr

}

# require a fortran compiler
#compilers.choose    f77 f90
compilers.setup     require_fortran

depends_lib-append \
    port:libxml2 \
    port:armadillo

variant accelerate conflicts atlas openblas description {Use Apple Accelerate Libraries for BLAS} {
    configure.env-append BLA_VENDOR=Apple
}

variant atlas conflicts accelerate openblas description {Use MacPorts ATLAS Libraries} {
    depends_lib-append port:atlas
    configure.env-append BLA_VENDOR=ATLAS
}

variant openblas conflicts atlas accelerate description {Use MacPorts OpenBLAS Libraries} {
    depends_lib-append path:lib/libopenblas.dylib:OpenBLAS
    configure.env-append BLA_VENDOR=OpenBLAS
}

if {![variant_isset accelerate] &&
    ![variant_isset atlas] &&
    ![variant_isset openblas]} {
    default_variants +accelerate
}

if {![variant_isset accelerate] &&
    ![variant_isset atlas] &&
    ![variant_isset openblas]} {
    ui_msg "\nError: '${name} -accelerate' is an invalid option; please select one of the variants +accelerate, +atlas, or +openblas.\n"
    return -code error "Invalid variant selection"
}
