# -*- 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            libxslt
version         1.1.45
revision        0

checksums       rmd160  1b4310dcbdbe8a2e03d6efdcab714f660d988890 \
                sha256  9acfe68419c4d06a45c550321b3212762d92f41465062ca4ea19e632ee5d216e \
                size    1519992

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

depends_build   path:bin/pkg-config:pkgconfig

patchfiles      no-doc.patch

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

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

    depends_lib-append  port:libxml2

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 :]
}

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}
}

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 {3.10 3.11 3.12 3.13 3.14} {
    set v_nodot [string map {. {}} $v]
    subport py${v_nodot}-${name} "
        set python.version $v_nodot
        set python.branch $v
    "
}

if {${name} ne ${subport}} {
    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}
    }
}
