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

name                diffutils-for-muniversal
version             3.8
revision            0
platforms           {darwin >= 22}

# we will not use the use_xz mechanism, as we don't want to pull in MP xz port and deps
dist_subdir         diffutils
distname            diffutils-${version}
extract.suffix      .tar.xz

categories          sysutils
license             GPL-3+

maintainers         nomaintainer

description         GNU diff utilities sequestered for muniversal PG
long_description \
    diffutils contains the GNU diff, diff3, sdiff, and cmp utilities. \
    Sequestered for muniversal to use.

homepage            https://www.gnu.org/software/diffutils/

master_sites        gnu:diffutils

checksums           rmd160  30b1050d0a5334becdc6141dcd52a4b584f0dbc4 \
                    sha256  a6bdd7d1b31266d11c4f4de6c1b748d4607ab0231af5188fc2533d0ae2438fec \
                    size    1585120

# boilerplate extract phase override
extract {
    foreach f ${distfiles} {
        set f [lindex [split ${f} :] 0]
        ui_debug "Extracting: ${f}"
        if {[string match "*bz2*" ${f}]} {
            system -W ${workpath} "/usr/bin/tar xjf [shellescape ${distpath}/${f}]"
        }
        if {[string match "*gz*" ${f}]}  {
            system -W ${workpath} "/usr/bin/tar xzf [shellescape ${distpath}/${f}]"
        }
        if {[string match "*xz*" ${f}]}  {
            system -W ${workpath} "/usr/bin/tar xJf [shellescape ${distpath}/${f}]"
        }
    }
}

# sterilize MacPorts build environment; we want nothing picked up from MP prefix
compiler.cpath
compiler.library_path

configure.cxx_stdlib

configure.cflags
configure.cxxflags
configure.cppflags
configure.optflags
configure.ldflags

configure.universal_cflags
configure.universal_cxxflags
configure.universal_cppflags
configure.universal_ldflags
configure.universal_args

configure.ccache    no
configure.distcc    no

configure.checks.implicit_function_declaration.whitelist-append strchr

# sterilize PATH
configure.env-append    PATH=/usr/bin:/bin:/usr/sbin:/sbin
build.env-append        PATH=/usr/bin:/bin:/usr/sbin:/sbin

universal_variant       no
installs_libs           no

configure.pre_args      --prefix=${prefix}/libexec/diffutils


test.run        yes
test.target     check

livecheck.type  none
