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

github.setup            latex2html latex2html 2021 v
github.tarball_from     archive
revision                1

categories              print
maintainers             nomaintainer
license                 GPL-2
supported_archs         noarch
platforms               any

description             Convert LaTeX into HTML.

long_description        LATEX2HTML is a convertor written in Perl that \
                        converts LATEX documents to HTML.

homepage                https://www.ctan.org/pkg/${name}

checksums               rmd160  d8661c4571eb15134b58a9d8c0118a86a7bdd5b8 \
                        sha256  872fe7a53f91ababaafc964847639e3644f2b9fab3282ea059788e4e18cbba47 \
                        size    1130224

depends_lib             bin:latex:texlive-latex \
                        port:dvipng \
                        port:ghostscript \
                        port:netpbm \
                        path:lib/pkgconfig/poppler.pc:poppler

patchfiles              patch-config-config.pl.diff

# respect DESTDIR value
patchfiles-append       patch-destdir.diff

# latex2html can not depend on perl5 since it puts the full perl name in the scripts
#    (#! ${prefix}/bin/perl5.x)
perl5.conflict_variants yes
perl5.branches          5.28 5.30 5.32 5.34
perl5.default_branch    5.34
perl5.create_variants   ${perl5.branches}

configure.perl          ${perl5.bin}

# Perl 5.26 no longer includes "." in the standard search locations (@INC)
# latex2html relies on this behavior
configure.env-append    PERL5LIB=${worksrcpath}
build.env-append        PERL5LIB=${worksrcpath}
destroot.env-append     PERL5LIB=${worksrcpath}

set texmfdir ${texlive_texmfports}/tex/latex/html
configure.args          --without-mktexlsr \
                        --with-texpath=${texmfdir}

post-destroot {
    set docdir ${destroot}${prefix}/share/doc/${name}
    xinstall -d ${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        BUGS \
        Changes \
        FAQ \
        LICENSE \
        README.md \
        TODO \
        ${docdir}

    xinstall -d -m 755 ${destroot}${texmfdir}
    foreach file [ glob ${worksrcpath}/texinputs/* ] {
        file copy -force ${file} ${destroot}${texmfdir}
    }

    # Newer versions of these files are already installed by
    # texlive. Because ${texlive_texmfports} is earlier in the search
    # path, the files installed by this port would shadow them. To
    # prevent this, don't install the old versions.
    delete ${destroot}${texmfdir}/url.sty
    delete ${destroot}${texmfdir}/latin9.def
}

texlive.use_mktexlsr yes
