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

name                cpp-world-clock
github.setup        kburchfiel cpp_world_clock_2025 45811a8e80c59ebf14091cda47ac66174dab71a5
version             2.4.0
revision            0
categories          sysutils
license             MIT
maintainers         nomaintainer
description         Simple C++-based world clock viewer
long_description    {*}${description}
checksums           rmd160  9df6a95c5bbaad78888b76ecce154232e1f3ff99 \
                    sha256  8cf1dc553c7dfc777132289dc80750601d26eddb217fc9d110ca26dd1f2a5b9d \
                    size    4249605
github.tarball_from archive

set tzdir           ${prefix}/share/${name}

patchfiles          patch-fix-tzdir.diff \
                    patch-tz.diff

post-extract {
    copy ${filespath}/tz_list_custom.csv ${worksrcpath}/config
}

post-patch {
    reinplace "s|@TZDIR@|${tzdir}|" ${worksrcpath}/cpp_world_clock.cpp
}

compiler.blacklist-append \
                    *gcc-4.* {clang}
# Requires the new ABI: https://github.com/kburchfiel/cpp_world_clock_2025/issues/1
# compiler.cxx_standard   2023

# This assumes powerpc always uses libstdc++ (which is normally the case):
if {${os.platform} eq "darwin" && ${configure.build_arch} ni [list ppc ppc64]} {
    configure.cxx_stdlib    libstdc++
    compiler.whitelist      macports-gcc-15 macports-gcc-14
}

destroot {
    copy ${cmake.build_dir}/cwc25 ${destroot}${prefix}/bin/cwc
    xinstall -d ${destroot}${tzdir}
    copy ${worksrcpath}/config ${destroot}${tzdir}/
}

notes "
    Desired time-zones can be adjusted in config files in ${tzdir}/config
"
