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

name                limesuite
categories          science comms
platforms           darwin macosx
license             Apache-2
maintainers         {ra1nb0w @ra1nb0w} {michaelld @michaelld} openmaintainer
description         provides drivers and SDR application support for the LMS7002M RFIC
long_description    Lime Suite is a collection of software supporting several hardware \
    platforms including the LimeSDR, drivers for the LMS7002M transceiver RFIC, and other \
    tools for developing with LMS7-based hardware.
homepage            https://myriadrf.org/projects/lime-suite/

subport limesuite-devel {}
if {[string first "-devel" $subport] > 0} {

    github.setup    myriadrf LimeSuite c1b19b2370e42bd896eac2641470c10473992a41
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20220505-[string range ${github.version} 0 7]
    checksums       rmd160  21cb4d9e876da0c668f48f96840d39d4f002f4e4 \
                    sha256  0e53b95763e9f87125eeb3cfeb356beb743234266ae445e10b374db4a6710bd0 \
                    size    5199539
    revision        0

    name            limesuite-devel
    long_description ${long_description} This port is kept up with the LimeSuite \
        GIT 'master' branch, is typically updated weekly to monthly.
    conflicts       limesuite

} else {

    github.setup    myriadrf LimeSuite 22.09.1 v
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    checksums       rmd160  b156ca0e2a16879853a9c0a053eb2d99dcece083 \
                    sha256  d5fe80e1c6695366dd6361e4fa7f363f5d850262b3510bd2a193a112969e9be5 \
                    size    5201126
    revision        0

    conflicts       limesuite-devel
    configure.args-append -DLIME_SUITE_EXTVER=release

}

compiler.cxx_standard 2011

# fix where CMake files are installed; in MacPorts we strive for
# "$PREFIX/share/cmake/$PROJECT_NAME", not "$PREFIX/lib/cmake/$PROJECT_NAME".
patchfiles-append patch-src_CMakeLists.txt.diff

depends_build-append \
    port:pkgconfig

depends_lib-append \
    path:lib/pkgconfig/libusb-1.0.pc:libusb \
    port:sqlite3

configure.args-append \
    -DDOWNLOAD_IMAGES=ON \
    -DENABLE_STREAM=ON \
    -DENABLE_GUI=OFF \
    -DENABLE_NOVENARF7=OFF \
    -DENABLE_SOAPY_LMS7=OFF\
    -DENABLE_OCTAVE=OFF

app.create no

# needs wxWidgets-3.2 to enable dark mode in mojave
variant wxgui description {Enable wxWidgets LimeSuiteGUI} {
    wxWidgets.use           wxWidgets-3.2
    depends_lib-append      port:${wxWidgets.port}
    configure.args-delete   -DENABLE_GUI=OFF
    configure.args-append   -DENABLE_GUI=ON \
        -DwxWidgets_CONFIG_EXECUTABLE=${wxWidgets.wxconfig}
    app.create yes
    app.name LimeSuiteGUI
    app.executable LimeSuiteGUI
    app.icon ${filespath}/limesuitegui.icns
    app.retina yes
}

variant soapy description {Add Soapy support} {
    depends_lib-append      port:SoapySDR
    configure.args-delete   -DENABLE_SOAPY_LMS7=OFF
    configure.args-append   -DENABLE_SOAPY_LMS7=ON
}

variant octave description {Enable Octave support} {
    depends_lib-append      path:bin/octave:octave
    depends_skip_archcheck  octave octave-devel
    configure.args-delete  -DENABLE_OCTAVE=OFF
    configure.args-append  -DENABLE_OCTAVE=ON
}

default_variants +wxgui +soapy
