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

name            libxslt
version         1.1.45
revision        0
set branch      [join [lrange [split ${version} .] 0 1] .]
categories      textproc
maintainers     {ryandesign @ryandesign} openmaintainer
license         MIT

description     Gnome xslt library and xsltproc
long_description \
    Libxslt is the XSLT C library developed for the Gnome project. \
    XSLT itself is a an XML language to define transformation for XML. \
    Libxslt is based on libxml2 the XML C library developed for the Gnome project. \
    It also implements most of the EXSLT set of processor-portable extensions \
    functions and some of Saxon's evaluate and expressions extensions.

homepage        http://xmlsoft.org/XSLT
master_sites    gnome:sources/${name}/${branch}/
use_xz          yes

checksums       rmd160  1b4310dcbdbe8a2e03d6efdcab714f660d988890 \
                sha256  9acfe68419c4d06a45c550321b3212762d92f41465062ca4ea19e632ee5d216e \
                size    1519992

depends_build   path:bin/pkg-config:pkgconfig

patchfiles      no-doc.patch

configure.args  --disable-silent-rules \
                --without-crypto \
                --without-python

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

    depends_lib-append  port:libxml2

    post-destroot {
        set docdir ${prefix}/share/doc/${name}
        xinstall -d ${destroot}${docdir}
        xinstall -m 0644 -W ${worksrcpath} AUTHORS Copyright FEATURES \
            NEWS README.md TODO ${destroot}${docdir}
    }

    test.run    yes
    test.target check

    pre-test {
        set path {}
        fs-traverse -depth f [list ${worksrcpath}] {
            if {[file isdirectory $f] && [file tail $f] eq ".libs"} {
                lappend path $f
                continue
            }
        }
        test.env    DYLD_LIBRARY_PATH=[join $path :]
    }

    variant doc description {Install extra documentation} {
        patchfiles-delete   no-doc.patch
    }

    variant debug description {Enable debug support} {
        configure.cflags-append -O0 -g
        configure.args-append --with-debugger
    }

    livecheck.type  gnome-with-unstable
} else {
    livecheck.type  none
}

foreach v {2.7 3.10 3.11 3.12} {
    set v_nodot [string map {. {}} $v]
    subport py${v_nodot}-${name} "
        set python.version $v_nodot
        set python.branch $v
    "
}

if {${subport} ne ${name}} {
    epoch                   1
    revision                0
    categories-append       python

    description             Python bindings for libxslt
    long_description        ${description}

    depends_lib-append      port:${name} \
                            port:python${python.version} \
                            port:py${python.version}-libxml2

    set python_prefix       ${frameworks_dir}/Python.framework/Versions/${python.branch}
    configure.args-replace  --without-python --with-python
    configure.args-append   --with-python-sys-prefix
    configure.python        ${prefix}/bin/python${python.branch}
    configure.ldflags-append \
                            -L${python_prefix}/lib -lpython${python.branch}

    destroot.dir            ${worksrcpath}/python

    post-destroot {
        move ${destroot}${prefix}/share/doc/${name}/python \
            ${destroot}${prefix}/share/doc/${subport}
    }
}
