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

epoch           1
github.setup    tukaani-project xz 5.8.4 v
checksums       rmd160  789671e64b025c561d121b9242ecf7de581b161f \
                sha256  3340ae48f88665abc78d71dc43446fb3f7e70b48fd59844ac0e14958cef6e00b \
                size    2061621

categories      archivers
# some executables are GPL, libs and everything else are public domain
license         {public-domain GPL-2+}
maintainers     {ryandesign @ryandesign} openmaintainer

description     XZ Utils

long_description \
XZ utils consist of a few relatively separate submodules: \
\n* LZMA/XZ encoder/decoder command line tool similar to gzip/bzip2 \
\n* Scripts to ease grepping, diffing and viewing (lz*grep, lzdiff/lzcmp, lzmore/lzless)

homepage        https://tukaani.org/xz/
master_sites-append \
                sourceforge:project/lzmautils

use_bzip2       yes

if {${subport} eq ${name}} {
    revision    0

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

    # document that we always need legacy symlinks now that "lzmautils" refers here
    configure.args-append --enable-lzma-links

    github.livecheck.regex  {([0-9.]+)}
} else {
    livecheck.type  none
}

# This port is used by clang-3.4 to bootstrap libcxx
subport ${name}-bootstrap {
    revision                1

    # Avoid macports-clang dep (doesn't use C++ anyway)
    configure.cxx_stdlib
    compiler.whitelist      clang gcc-4.2 apple-gcc-4.2
    # Hangs extracting archives when built with Xcode 3.2.6 clang
    compiler.blacklist      {clang < 100}

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

    configure.ccache        no
    configure.distcc        no

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

    prefix                  ${prefix}/libexec/xz-bootstrap
    configure.args          --disable-doc \
                            --disable-lzma-links \
                            --disable-lzmadec \
                            --disable-lzmainfo \
                            --disable-nls \
                            --disable-scripts \
                            --disable-static \
                            --disable-xzdec \
                            --without-libiconv-prefix \
                            --without-libintl-prefix

    # Don't install manpages
    destroot.args           dist_man_MANS=

}
if {${os.platform} eq "darwin" && ${os.major} < 11 && ${cxx_stdlib} eq "libc++"} {
    # This port is in the dependency chain for clang 3.7 and later
    clang_dependency.extra_versions 3.7
}

# the internal "check.h" header conflicts with port check's <check.h>
configure.cppflags -I${worksrcpath}/src/liblzma/check -I${prefix}/include

configure.checks.implicit_function_declaration.whitelist-append \
                        alignof \
                        strchr
