# -*- 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.43
revision        0

checksums       rmd160  b646f6620803c608edb564b61a06c397712ad5e9 \
                sha256  5a3d6b383ca5afc235b171118e90f5ff6aa27e9fea3303065231a6d403f0183a \
                size    1518364

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 {2.7 3.9 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 {${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}
    }
}
