# -*- 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           cmake 1.1
PortGroup           app 1.0

name                SDRPlusPlus
platforms           darwin macosx
categories          science
license             GPL-3
maintainers         {ra1nb0w @ra1nb0w} openmaintainer

description         SDR++ is a cross-platform and open source SDR software with \
    the aim of being bloat free and simple to use.
long_description    ${description}

# the latest version doesn't have OPT_OVERRIDE_STD_FILESYSTEM
# neede for macOS =< 10.14
github.setup        AlexandreRouma SDRPlusPlus 1.0.4
checksums           rmd160  9aa72b5f7c0c751bc9795161bb8e901b76b0773c \
                    sha256  0acff4557806c79afbea6e69620541701c4d3405a94716e651ec1bc9c0349c01 \
                    size    3700910
revision            2

epoch               1

compiler.c_standard   2011
compiler.cxx_standard 2017

patchfiles-append \
    cmakelists.patch

depends_build-append \
    port:pkgconfig

depends_lib-append \
    port:fftw-3-single \
    port:glew \
    path:lib/pkgconfig/glfw3.pc:glfw \
    port:volk \
    port:portaudio \
    path:lib/pkgconfig/libusb-1.0.pc:libusb \
    port:codec2 \
    path:lib/libhamlib.dylib:hamlib

configure.args-append \
    -DINSTALL_PREFIX=${prefix} \
    -DOPT_OVERRIDE_STD_FILESYSTEM=OFF \
    -DOPT_BUILD_AIRSPY_SOURCE=OFF \
    -DOPT_BUILD_AIRSPYHF_SOURCE=OFF \
    -DOPT_BUILD_SPYSERVER_SOURCE=OFF \
    -DOPT_BUILD_BLADERF_SOURCE=OFF \
    -DOPT_BUILD_HACKRF_SOURCE=OFF \
    -DOPT_BUILD_LIMESDR_SOURCE=OFF \
    -DOPT_BUILD_RTL_SDR_SOURCE=OFF \
    -DOPT_BUILD_RTL_TCP_SOURCE=OFF \
    -DOPT_BUILD_SDRPLAY_SOURCE=OFF \
    -DOPT_BUILD_SOAPY_SOURCE=OFF \
    -DOPT_BUILD_PLUTOSDR_SOURCE=OFF \
    -DOPT_BUILD_AUDIO_SINK=OFF \
    -DOPT_BUILD_PORTAUDIO_SINK=ON \
    -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON \
    -DOPT_BUILD_M17_DECODER=ON \
    -DOPT_BUILD_WEATHER_SAT_DECODER=ON \
    -DOPT_BUILD_METEOR_DEMODULATOR=ON \
    -DOPT_BUILD_SCANNER=ON \
    -DOPT_BUILD_SCHEDULER=ON

if {${os.platform} eq "darwin" && ${os.major} <= 18} {
    configure.args-replace -DOPT_OVERRIDE_STD_FILESYSTEM=OFF -DOPT_OVERRIDE_STD_FILESYSTEM=ON
}

variant debug description {Enable debug messages} {
    configure.args-append   \
        -DCMAKE_BUILD_TYPE=Debug \
        -DDEBUG_OUTPUT=ON
}

variant gui description {Enable Gui} {
    app.create yes
    app.name SDRPlusPlus
    app.executable sdrpp
    app.icon root/res/icons/sdrpp.png
    app.retina yes
}

variant airspy description {Enable Airspy hardware} {
    depends_lib-append      port:airspy
    configure.args-replace  -DOPT_BUILD_AIRSPY_SOURCE=OFF -DOPT_BUILD_AIRSPY_SOURCE=ON
    configure.args-replace  -DOPT_BUILD_SPYSERVER_SOURCE=OFF -DOPT_BUILD_SPYSERVER_SOURCE=ON
}

variant airspyhf description {Enable AirspyHF hardware} {
    depends_lib-append      port:airspyhf
    configure.args-replace  -DOPT_BUILD_AIRSPYHF_SOURCE=OFF  -DOPT_BUILD_AIRSPYHF_SOURCE=ON
    configure.args-replace  -DOPT_BUILD_SPYSERVER_SOURCE=OFF -DOPT_BUILD_SPYSERVER_SOURCE=ON
}

variant bladerf description {Enable bladeRF hardware} {
    depends_lib-append      port:bladeRF
    configure.args-replace  -DOPT_BUILD_BLADERF_SOURCE=OFF -DOPT_BUILD_BLADERF_SOURCE=ON
}

variant hackrf description {Enable HackRF hardware} {
    depends_lib-append      path:lib/libhackrf.dylib:hackrf
    configure.args-replace  -DOPT_BUILD_HACKRF_SOURCE=OFF -DOPT_BUILD_HACKRF_SOURCE=ON
}

variant libiio description {Enable libiio support, like PlutoSDR hardware} {
    depends_lib-append      port:libiio
    configure.args-replace  -DOPT_BUILD_PLUTOSDR_SOURCE=OFF -DOPT_BUILD_PLUTOSDR_SOURCE=ON
}

variant limesuite description {Enable limesuite hardware} {
    depends_lib-append      path:lib/libLimeSuite.dylib:limesuite
    configure.args-replace  -DOPT_BUILD_LIMESDR_SOURCE=OFF -DOPT_BUILD_LIMESDR_SOURCE=ON
}

variant rtlsdr description {Enable rtl-sdr hardware} {
    depends_lib-append      port:rtl-sdr
    configure.args-replace  -DOPT_BUILD_RTL_SDR_SOURCE=OFF -DOPT_BUILD_RTL_SDR_SOURCE=ON
    configure.args-replace  -DOPT_BUILD_RTL_TCP_SOURCE=OFF -DOPT_BUILD_RTL_TCP_SOURCE=ON
}

variant soapysdr description {Enable SoapySDR support} {
    depends_lib-append      port:SoapySDR
    configure.args-replace  -DOPT_BUILD_SOAPY_SOURCE=OFF -DOPT_BUILD_SOAPY_SOURCE=ON
}

variant sdrplay description {Enable SDRplay support} {
    depends_lib-append      port:SDRplay3
    configure.args-replace  -DOPT_BUILD_SDRPLAY_SOURCE=OFF -DOPT_BUILD_SDRPLAY_SOURCE=ON
}

default_variants +gui +airspy +airspyhf +hackrf +limesuite +rtlsdr
