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

name                gr-baz
license             GPL-3
maintainers         {michaelld @michaelld} openmaintainer
description         Provides augmented functionality (blocks, GRC definitions, apps, etc) for GNU Radio.
long_description    {*}${description}
homepage            https://wiki.spench.net/wiki/Gr-baz

github.setup        balint256 gr-baz 937834ce3520b730277328d8e0cdebb3f2b1aafc
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version             20200409-[string range ${github.version} 0 7]
checksums           rmd160  62c7e8c1c62000b3bf8f7dee8b4ee0bbde7bc1b8 \
                    sha256  6cfb84fc38046f2429e679a9429bec8b404deb955f4cceecb33f17dc4d73110a \
                    size    516543
revision            7

# use C++11
compiler.cxx_standard 2011

if {${subport} eq ${name}} {
    # fix gnuradio version
    patchfiles-append \
        cmakelists-3.8.txt.patch

    conflicts gr37-baz

    pre-configure {
        file copy -force ${worksrcpath}/CMakeLists-3.8.txt ${worksrcpath}/CMakeLists.txt
    }
}

subport gr37-baz {
    name gr37-baz

    conflicts gr-baz

    pre-configure {
        file copy -force ${worksrcpath}/CMakeLists-3.7.txt ${worksrcpath}/CMakeLists.txt
    }
}

configure.args-append \
       -DUHD_INCLUDE_DIRS= \
       -DUHD_LIBRARIES= \
       -DLIBUSB_INCLUDE_DIR= \
       -DLIBUSB_LIBRARIES= \
       -DARMADILLO_INCLUDE_DIR= \
       -DARMADILLO_LIBRARY=

variant uhd description "Install ${name} with support for UHD" {
    depends_lib-append \
        path:lib/libuhd.dylib:uhd

    configure.args-replace \
        -DUHD_INCLUDE_DIRS= \
        -DUHD_INCLUDE_DIRS=${prefix}/include \

   configure.args-replace \
        -DUHD_LIBRARIES= \
        -DUHD_LIBRARIES=${prefix}/lib/libuhd.dylib
}


variant rtl description "Install ${name} with support for RTL SDR hardware (via libusb)" {
    depends_lib-append path:lib/pkgconfig/libusb-1.0.pc:libusb

    configure.args-replace \
        -DLIBUSB_INCLUDE_DIR= \
        -DLIBUSB_INCLUDE_DIR=${prefix}/include/libusb-1.0

    configure.args-replace \
        -DLIBUSB_LIBRARIES= \
        -DLIBUSB_LIBRARIES=${prefix}/lib/libusb-1.0.dylib
}

variant armadillo description "Install ${name} with support for MUSIC DOA estimator block (via armadillo)" {
    depends_lib-append port:armadillo

    configure.args-replace \
        -DARMADILLO_INCLUDE_DIR= \
        -DARMADILLO_INCLUDE_DIR=${prefix}/include

    configure.args-replace \
        -DARMADILLO_LIBRARY= \
        -DARMADILLO_LIBRARY=${prefix}/lib/libarmadillo.dylib
}

# enable all variants except +debug and +universal
default_variants +uhd +rtl +armadillo
