# -*- 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.0

name                rw
version             1.0
categories          sysutils
platforms           darwin
maintainers         {raimue @raimue} \
                    openmaintainer
license             ISC

description         a simple replacement for dd(1)

long_description \
    Sortix rw is a program that reads blocks from the standard input and copies \
    them to the standard output until the end of the standard input. rw(1) is \
    designed to be a replacement for dd(1), providing only the the core \
    blockwise I/O. It has a standard command line interface with dashed \
    options, useful and efficient defaults.

homepage            https://sortix.org/rw/
master_sites        https://sortix.org/rw/release/
distname            rw-portable-${version}

checksums           rmd160  271db6bea10b0ef28ec3d0d4b99167709c8f31a5 \
                    sha256  50009730e36991dfe579716f91f4f616f5ba05ffb7bf69c03d41bf305ed93b6d \
                    size    12993

pre-fetch {
    # rw requires clock_gettime(), available as of macOS 10.12
    if {${os.subplatform} eq "macosx" && [vercmp ${macosx_version} 10.12] < 0} {
        ui_error "${name} requires macOS 10.12 Sierra or greater."
        return -code error "incompatible macOS version"
    }
}

use_configure no
build.env           "CC=${configure.cc} [get_canonical_archflags cc]" \
                    CPPFLAGS=${configure.cppflags} \
                    CFLAGS=${configure.cflags} \
                    LDFLAGS=${configure.ldflags}

destroot.args       PREFIX=${prefix}

post-destroot {
    xinstall -d ${destroot}${prefix}/share/doc/rw
    xinstall -m 0644 -W ${worksrcpath} README LICENSE ${destroot}${prefix}/share/doc/rw
}

livecheck.type      regex
livecheck.regex     {rw-portable-(\d+(?:\.\d+)*)\.tar}
