# -*- 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.09
revision            1
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        sourceforge:project/fldigi/${name}

checksums           rmd160  bd0de612205e7986413b02952f2af01c9260e87f \
                    sha256  76f521ecf1062af276d5ac3804504b283a2c138455b593d66fd5d51c9464f59d \
                    size    1137698

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}
