# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem      1.0
PortGroup       muniversal 1.0

name            findutils
conflicts       findutils-devel
set my_name     findutils

version         4.10.0
revision        0

categories      sysutils
license         GPL-3+
maintainers     {mascguy @mascguy} openmaintainer

description     findutils contains GNU find, xargs, and locate
long_description \
                {*}${description}
homepage        https://www.gnu.org/software/${my_name}/

master_sites    gnu:${my_name}
distname        ${my_name}-${version}
dist_subdir     ${my_name}
use_xz          yes

installs_libs   no

checksums       rmd160  623fffe9e2331a2a11b52bd212790480d3c7a8c4 \
                sha256  1387e0b67ff247d2abde998f90dfbf70c1491391a59ddfecb8ae698789f0a4f5 \
                size    2240712

depends_build-append \
                port:gettext

depends_lib-append \
                port:gettext-runtime \
                port:libiconv

# Fix issues with older Clang releases
compiler.blacklist-append \
                {clang < 900}

configure.env-append \
                SORT=/usr/bin/sort

configure.args-append \
                --disable-silent-rules \
                --program-prefix=g

test.run        yes
test.target     check

if {${universal_possible} && [variant_isset universal]} {
    set merger_configure_args(i386) { TIME_T_32_BIT_OK=yes --disable-year2038 }
    set merger_configure_args(ppc) { TIME_T_32_BIT_OK=yes --disable-year2038 }
} else {
    switch -- ${configure.build_arch} {
        x86_64 {}
        i386 { configure.args-append TIME_T_32_BIT_OK=yes --disable-year2038 }
        ppc { configure.args-append TIME_T_32_BIT_OK=yes --disable-year2038 }
        ppc64 {}
    }
}

post-destroot {
    move ${destroot}${prefix}/share/info/find.info ${destroot}${prefix}/share/info/gfind.info
    delete ${destroot}${prefix}/lib/charset.alias

    set docdir ${prefix}/share/doc/${name}-${version}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} AUTHORS COPYING ChangeLog NEWS README \
        THANKS TODO ${destroot}${docdir}

    xinstall -m 755 -d ${destroot}${prefix}/libexec/gnubin
    foreach binary [glob -tails -directory ${destroot}${prefix}/bin g*] {
        ln -s ${prefix}/bin/${binary} ${destroot}${prefix}/libexec/gnubin/[string range $binary 1 end]
    }
    xinstall -m 755 -d ${destroot}${prefix}/libexec/gnubin/man/man1
    foreach manpage [glob -tails -directory ${destroot}${prefix}/share/man/man1 g*] {
        ln -s ${prefix}/share/man/man1/${manpage}.gz ${destroot}${prefix}/libexec/gnubin/man/man1/[string range $manpage 1 end].gz
    }
}

livecheck.name  ${my_name}
