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

name                xscreensaver
version             6.14
revision            0
categories          x11
maintainers         nomaintainer
license             X11
description         X11 screen saver
long_description    The xscreensaver program waits until the keyboard and \
                    mouse have been idle for a period, and then runs a graphics \
                    demo chosen at random.

homepage            https://www.jwz.org/xscreensaver
# https://www.jwz.org/blog/2025/12/under-attack-please-stand-by-2/
# fetching distfiles may be broken due to protection against AI bots
# unfortunately this will never be fixed, so let's append a mirror by FreeBSD
master_sites        ${homepage} \
                    freebsd

checksums           rmd160  84face4cda546964d7cc1c13d6fbb68b0294d741 \
                    sha256  07f310eb60ece3a6c57abaa722d7209a2c4f54309a5a7b09b6eed20152d073f2 \
                    size    25206667

depends_build       port:pkgconfig \
                    port:intltool \
                    port:gettext

depends_lib         path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:xorg-libXi \
                    port:xorg-libXt \
                    port:mesa \
                    port:libGLU

depends_run         port:font-bh-ttf

require_active_variants path:lib/pkgconfig/gtk+-3.0.pc:gtk3 x11

# Fix "No GL visuals" when running in fullscreen
patchfiles          patch-driver-subprocs.diff

# Missing 'pthread_attr_set_qos_class_np' on macOS <10.10
if {${os.platform} eq "darwin" && ${os.major} < 14} {
    patchfiles-append   patch-ignore-qos.diff
}

# marbling.c:174:9: error: cannot convert between vector
# values of different size ('v_hi' (vector of 8 'int16_t'
# values) and 'int16_t' (aka 'short')) on macOS <10.13
compiler.blacklist-append \
                    {clang < 1000}

configure.args      --with-app-defaults=${prefix}/share/X11/app-defaults \
                    --with-fontdir=${prefix}/share/fonts/TTF

destroot.destdir    DESTDIR=${destroot}

post-destroot {
    # get it from font-bh-ttf
    delete ${destroot}${prefix}/share/fonts/TTF/luximr.ttf
}

livecheck.type      regex
livecheck.url       https://www.jwz.org/xscreensaver/download.html
livecheck.regex     xscreensaver-(\[0-9\.\]+).tar.gz
