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

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

description         FLRIG is a transceiver control program
long_description    FLRIG is a transceiver control program designed to be \
    used either stand alone or as an adjunct to FLDIGI. The supported \
    transceivers all have some degree of CAT. The FLRIG user interface \
    changes to accommodate the degree of CAT support available for the \
    transceiver in use.
homepage            http://www.w1hkj.com
master_sites        http://www.w1hkj.com/files/${name}/

checksums           rmd160  60e9b5c169bb64edc0b623946d4da2c34ca4078c \
                    sha256  0d3aa17998424abba9a24855a86acec01717c10460a0cbf5e9f32310546a6c20 \
                    size    1094239

depends_build-append \
    port:pkgconfig

depends_lib-append \
    path:lib/libfltk.dylib:fltk \
    port:libpng

# build fix: remove -no-stack-check on macOS < 10.10
if {${os.platform} eq "darwin" && ${os.major} <= 13} {
    use_autoreconf yes
    patchfiles-append \
        remove_no-stack-check.patch
}

# We put this into a pre-configure block so it can be evaluated _after_ platform selection.
pre-configure {
    # enable optimization (SSE3) on all Intel hardwares
    if {${build_arch} eq "i386" || ${build_arch} eq "x86_64"} {
        configure.args-append \
            --enable-optimizations=sse3
    }

    # Fix building for older macOS versions via MACOSX_DEPLOYMENT_TARGET
    # from http://www.w1hkj.com/doku/doku.php?id=howto:building_on_os_x
    if {${os.platform} eq "darwin" && [vercmp $macosx_deployment_target 10.12] < 0} {
        configure.args-append \
            --without-clock_gettime
        configure.env-append \
            MACOSX_DEPLOYMENT_TARGET=${macosx_deployment_target}
    }
}

variant bundle description {Enable the macOS bundle} {
    patchfiles-append \
        patch-mkappbundle.sh.diff
    build.target    appbundle
    post-destroot {
        xinstall -d -m 0755 ${destroot}${applications_dir}
        copy ${workpath}/${name}-${version}/src/${name}-${version}/${name}-${version}.app ${destroot}${applications_dir}/${name}.app
    }
}

default_variants-append +bundle

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     ${name}-(\[0-9.\]+)${extract.suffix}