# -*- 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
PortGroup           legacysupport 1.1
PortGroup           makefile 1.0

# _faccessat, _clock_gettime
legacysupport.newest_darwin_requires_legacy 15

name                hamclock
version             4.21
revision            0
checksums           rmd160  25fb5309cac75f9fa8a9692176c6aa25c351a69f \
                    sha256  6ad57d5b91a122cb1dfebc0ba30bec901105bc87c3ac89ff2537fcb7e923d9d2 \
                    size    1969275

categories          x11
license             MIT
maintainers         nomaintainer
description         Handy clock with features for amateur radio operators
long_description    HamClock is a kiosk-style application that provides \
                    real time space weather, radio propagation models, \
                    operating events and other information particularly \
                    useful to the radio amateur.

homepage            https://www.clearskyinstitute.com/ham/HamClock
master_sites        ${homepage}/
distname            ESPHamClock-V${version}
extract.suffix      .tgz

worksrcdir          ESPHamClock

post-patch {
    # Respect build environment:
    reinplace "s|CXXFLAGS =|CXXFLAGS +=|" ${worksrcpath}/Makefile
    reinplace "s|LIBS =|LIBS +=|" ${worksrcpath}/Makefile
    reinplace "s|CXX =|CXX ?=|" ${worksrcpath}/ArduinoLib/Makefile
    # Fix X11 paths:
    reinplace "s|/opt/X11|${prefix}|g" ${worksrcpath}/Makefile
}

depends_lib-append  port:xorg-libX11

depends_run-append  port:desktop-file-utils

compiler.cxx_standard   2017

configure.cxxflags-append \
                        -DNO_UPGRADE

default_variants    +1600x960
variant 800x480     description {Window 800x480}   {build.target hamclock-800x480  }
variant 1600x960    description {Window 1600x960}  {build.target hamclock-1600x960 }
variant 2400x1440   description {Window 2400x1440} {build.target hamclock-2400x1440}
variant 3200x1920   description {Window 3200x1920} {build.target hamclock-3200x1920}

if {${os.platform} eq "darwin" && ${os.major} < 16} {
    build.env-append    LIBS=-lMacportsLegacySupport
}

destroot {
    copy ${worksrcpath}/${build.target} ${destroot}${prefix}/bin
    # Make a symlink, so that it can be invoked with ${name}
    ln -s ${build.target} ${destroot}${prefix}/bin/${name}
    xinstall -d ${destroot}${prefix}/share/applications
    xinstall -d ${destroot}${prefix}/share/icons/hicolor/48x48/apps
    copy ${worksrcpath}/${name}.desktop ${destroot}${prefix}/share/applications
    copy ${worksrcpath}/${name}.png ${destroot}${prefix}/share/icons/hicolor/48x48/apps
}

# Only run this for applications, not icons, to avoid GTK dependency:
post-activate {
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
}

livecheck.regex     Version \(\[0-9.\]+\):
