# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0
PortGroup           boost 1.0
PortGroup           cmake 1.1
PortGroup           qt5 1.0
PortGroup           app 1.0

name                gqrx
maintainers         {michaelld @michaelld} {ra1nb0w @ra1nb0w} openmaintainer
categories          science comms
license             GPL-3 BSD
platforms           darwin macosx
description         Gqrx is a software defined radio (SDR) receiver using \
    GNU Radio, OSMOSDR, and Qt5.
long_description    Gqrx is a software defined radio receiver for Funcube \
    Dongle (FCD), RTL2832U-based DVB-T devices (RTL-SDR), Universal \
    Software Radio Peripherals (USRP) and Osmo SDR devices.  Gqrx is \
    powered by GNU Radio and the Qt5 GUI toolkit.  Gqrx is free and open \
    source software and anyone is invited to hack the source code to suit \
    their needs.

homepage            https://gqrx.dk

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

    github.setup    gqrx-sdr gqrx 2.16 v
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    checksums       rmd160  a68883414b7480d9d7410df2e492018998e7cb23 \
                    sha256  68ecd4c3e81afe44f0b234edf02d31d24baa4033158bacefe735d73503a0aeeb \
                    size    3608334
    epoch           1

    # repo moved, so treat like a stealth update
    # remove this with next release
    dist_subdir   ${name}/${version}_1

    compiler.c_standard   2011
    compiler.cxx_standard 2011

    qt5.depends_component qtsvg

    depends_lib-append \
        port:gr-osmosdr \
        path:lib/libgnuradio-audio.dylib:gnuradio \
        port:portaudio \
        path:lib/libvolk.dylib:volk

    # we force portaudio for the moment
    # otherwise choose "Gr-audio"
    configure.args-append \
        -DOSX_AUDIO_BACKEND=Portaudio

    if {${os.platform} eq "darwin" && ${os.major} > 22} {
        configure.cppflags-append \
            -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
    }

    variant iqbal description "Enable automatic I/Q phase and gain correction with gr-iqbal" {
        depends_lib-append \
            port:gr-iqbalance
    }

    variant experimental description "add experimental features to ${name}" {
        patchfiles-append \
            experimental.patch
        
        notes {
            The experimental variant enable the following features:
            - improved noise blankers (derived from wdsp)
        }
    }

    app.create yes
    app.name Gqrx
    app.executable gqrx
    app.icon resources/icons/gqrx.icns
    app.retina yes

}
