# -*- 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 e043f37205ffbde5627ff299ad25cd532f2956f0
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
set man_commit      1a7c9e1585dd3ae14b03226e359d434c10066bfb
version             20231127
revision            0
checksums           ${name}-${man_commit}.1 \
                    rmd160  4b0c9cdf0094d757d3b9cbe819803a103dab5eee \
                    sha256  92a6745a74f28c75946312440af18628b7f1767b2b8a129b24bca6d8f86e43ed \
                    size    3850 \
                    ${name}-${git.branch}.c \
                    rmd160  358f404218818c713cb2f2fac811d84ebc005606 \
                    sha256  43a39a18c9a9ae7c26c0a5f8fdc975050c9f385bb53ca9ceb3acf512ea76c96b \
                    size    5017

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

# 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]+)"}
