# -*- 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-lora
maintainers         {michaelld @michaelld} openmaintainer
description         Provides an open-source implementation of the LoRa CSS PHY.
long_description    {*}${description}
license             GPL-3

if {${subport} eq ${name}} {
    version         20180131
    revision        2
    replaced_by     gr-lora-rpp0
    PortGroup       obsolete 1.0
}

subport gr37-lora-BastilleResearch {

    name            gr37-lora-BastilleResearch

    github.setup    BastilleResearch gr-lora d587169a9676ad0f9ebf85e6a840f3955b3976d7
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20170713
    checksums       rmd160 99f82eb4e57eb59c863598b6a5e58f3632edc769 \
                    sha256 e1958cfe15e5ff3542e4df3dc7e626751321957cd2ff0122723d6a86d845cf6c
    revision        3

    conflicts \
        gr37-lora-rpp0 \
        gr-lora-rpp0

}

subport gr37-lora-rpp0 {

    name            gr37-lora-rpp0

    github.setup    rpp0 gr-lora b1d38fab9032a52eaf31bf33a145df45fce7512f
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    git.branch      gr3.7
    version         20180919
    checksums       rmd160 f5fbd363efebe98a1bdbbd0259c6294ad7ea62e1 \
                    sha256 37caf0b2550608a31e71dc0f4f605aa2c57fa2cbeaac82984910f5d874efcc6a \
                    size   519697
    revision        3

    patchfiles-append \
        patch-build-fixes.diff
    patch.pre_args-replace  -p0 -p1

    conflicts \
        gr37-lora-BastilleResearch \
        gr-lora-rpp0
}

subport gr-lora-rpp0 {

    name            gr-lora-rpp0

    github.setup    rpp0 gr-lora 91fb5e4930379e03797b860ff8d2fb934f474e8a
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20200323-[string range ${github.version} 0 7]
    checksums       rmd160  c18dbf6cd87643e66277a06c8f8cdce42b4eadde \
                    sha256  63ca9b40c3ff69a3b18d145e5a58e65023d386c1dec1591b9dc57ffa748a1a20 \
                    size    505793
    revision        4

    conflicts \
        gr37-lora-BastilleResearch \
        gr37-lora-rpp0

}

if {[string first "-lora-rpp0" $subport] > 0} {

    depends_lib-append \
        port:liquid-dsp \
        path:lib/libwireshark.dylib:wireshark3

    configure.args-append \
        -DHAS_MONGODB=FALSE

    variant mongodb description "Include support for storing data to MongoDB" {
       configure.args-replace \
            -DHAS_MONGODB=FALSE \
            -DHAS_MONGODB=TRUE

       depends_lib-append \
            port:py${active_python_version_no_dot}-pymongo
    }

    default_variants +mongodb
}
