# -*- 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                xmlstarlet
version             1.6.1
revision            4
checksums           rmd160  16ca33aa94cd9cb45ef0635526ed07243c4819db \
                    sha256  15d838c4f3375332fd95554619179b69e4ec91418a3a5296e7c631b7ed19e7ca \
                    size    420923

categories          textproc
maintainers         nomaintainer
license             MIT

description         xml command line utilities
long_description    XMLStarlet is a set of command line utilities (tools) to \
                    transform, query, validate, and edit XML documents and \
                    files using simple set of shell commands in similar way it \
                    is done for text files with UNIX grep, sed, awk, diff, \
                    patch, join, etc utilities.

homepage            https://xmlstar.sourceforge.net
master_sites        sourceforge:project/xmlstar/xmlstarlet/${version}

depends_lib         port:libxml2 port:libxslt port:libiconv

patchfiles          libxml2.patch

configure.args      --disable-silent-rules \
                    --with-libxml-prefix=${prefix} \
                    --with-libxslt-prefix=${prefix} \
                    --with-libiconv-prefix=${prefix} \
                    --mandir=${prefix}/share/man \
                    --disable-build_docs \
                    --program-transform-name=s/xml$/${name}/

build.target        clean-doc all
# Avoid the error below by setting environment variables
# sed: RE error: illegal byte sequence
# http://stackoverflow.com/questions/19242275/re-error-illegal-byte-sequence-on-mac-os-x
build.env-append    LC_CTYPE=C LANG=C

post-destroot {
    set docdir ${destroot}${prefix}/share/doc/${name}
    xinstall -d ${docdir}
    xinstall -m 0644 -W ${worksrcpath} \
        AUTHORS \
        COPYING \
        NEWS \
        README \
        TODO \
        ${docdir}
    xinstall -d ${destroot}${prefix}/share/${name}
    file copy ${worksrcpath}/examples ${destroot}${prefix}/share/${name}
}

variant docs description {Enable documentation} {
    depends_build-append    port:docbook-xsl-ns \
                            port:fop \
                            port:ghostscript

    configure.args-delete --disable-build_docs
    configure.args-append --enable-build_docs
}

notes "
Some ${name} documentation files refer to the program name as \"xml\" but\
in MacPorts the program is installed as \"${name}\".
"

livecheck.regex     /${name}-(\[0-9.\]+)${extract.suffix}
