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

name                pwait
github.setup        freebsd freebsd-src 3aac05f56620712744cb57d71a0ef42f8d8e3b52
set man_commit      1a7c9e1585dd3ae14b03226e359d434c10066bfb
version             20250923
revision            0
checksums           ${name}-${man_commit}.1 \
                    rmd160  4b0c9cdf0094d757d3b9cbe819803a103dab5eee \
                    sha256  92a6745a74f28c75946312440af18628b7f1767b2b8a129b24bca6d8f86e43ed \
                    size    3850 \
                    ${name}-${git.branch}.c \
                    rmd160  e4bc5853120bcd2c9e1b747cd00bf6838c77204b \
                    sha256  56511ba60055c32509b7f7e3c91f200dcb3cb58e055a89a8e6c4d47496a55390 \
                    size    5163

categories          sysutils
maintainers         {ryandesign @ryandesign} openmaintainer
license             BSD

description         waits for processes to exit

long_description    The ${name} utility will wait until each of the \
                    given processes has terminated.

set repo_path       bin/${name}
github.livecheck.branch main
homepage            ${github.homepage}/tree/${github.livecheck.branch}/${repo_path}
master_sites        ${github.raw}/${git.branch}/${repo_path}/${name}.c?dummy=:code \
                    ${github.raw}/${man_commit}/${repo_path}/${name}.1?dummy=:man
distfiles           ${name}-${git.branch}.c:code \
                    ${name}-${man_commit}.1:man

worksrcdir          ${name}
extract.mkdir       yes
extract.only

post-extract {
    copy ${distpath}/${name}-${git.branch}.c ${worksrcpath}/${name}.c
    copy ${distpath}/${name}-${man_commit}.1 ${worksrcpath}/${name}.1
}

use_configure       no

# Includes <stdbool.h> as of 20250923.
compiler.c_standard 1999
configure.cflags-append -std=c99

# Some old versions of sys/cdefs.h don't have __FBSDID
configure.cflags-append -D__FBSDID\\(s\\)=

variant universal {}

build.cmd           ${configure.cc}
build.target
build.args          -o pwait \
                    {*}[get_canonical_archflags] \
                    {*}${configure.cflags} \
                    {*}${configure.ldflags} \
                    ${name}.c

destroot {
    xinstall -m 0755 ${worksrcpath}/pwait ${destroot}${prefix}/bin/
    xinstall -m 0444 ${worksrcpath}/${name}.1 ${destroot}${prefix}/share/man/man1/
}

livecheck.version   ${git.branch}
livecheck.url       https://api.github.com/repos/${github.author}/${github.project}/commits?path=${repo_path}/${name}.c&page=1&per_page=1
livecheck.type      regexm
livecheck.regex     {^\[\s*\{\s*"sha":\s*"([0-9a-f]+)"}
