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

# PortGroup         github 1.0
# github.setup      ftilmann latexdiff 1.1.1
name                latexdiff
version             1.2.1
revision            1
categories          tex
maintainers         nomaintainer
license             GPL-3+
platforms           darwin
supported_archs     noarch
description         determine and mark up significant differences between latex files
long_description    \
    latexdiff is a Perl script, which compares two latex files and marks up \
    significant differences between them (i.e. a diff for latex files). Various \
    options are available for visual markup using standard latex packages such \
    as \"color.sty\". Changes not directly affecting visible text, for example in \
    formatting commands, are still marked in the latex source.

homepage            http://www.ctan.org/pkg/latexdiff
master_sites        https://github.com/ftilmann/${name}/releases/download/${version}/

checksums           rmd160  4ce4afc970029e4eff2b26c5dbf93838e74a4f6b \
                    sha256  12634c8ec5c68b173d3906679bb09330e724491c6a64e675989217cf4790604e

perl5.branches      5.26

depends_run         port:perl${perl5.major} \
                    port:p${perl5.major}-algorithm-diff

post-patch {
    reinplace -W ${worksrcpath} "s|/usr/bin/env perl|${perl5.bin}|g" \
        latexdiff latexdiff-fast latexdiff-so latexdiff-vc latexrevise
}

use_configure       no

build               {}

destroot.destdir    INSTALLPATH=${destroot}${prefix} \
                    INSTALLMANPATH=${destroot}${prefix}/share/man

destroot {
    # install scripts
    xinstall -m 755 -W ${worksrcpath} latexdiff latexdiff-fast latexdiff-so latexdiff-vc latexrevise ${destroot}${prefix}/bin

    # install man pages
    xinstall -m 644 -W ${worksrcpath} latexdiff.1 latexdiff-vc.1 latexrevise.1 ${destroot}${prefix}/share/man/man1

    # install docs
    set docdir ${prefix}/share/doc/${name}
    xinstall -m 755 -d ${destroot}${docdir}/examples
    xinstall -m 644 -W ${worksrcpath} COPYING README doc/example-diff.tex doc/latexdiff-man.pdf doc/latexdiff-man.tex ${destroot}${docdir}

    # install examples
    xinstall -m 644 -W ${worksrcpath}/example example-draft.tex example-rev.tex ${destroot}${docdir}/examples
}

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     "<td>(\\d+(\\.\\d+)*) ?</td>"