# -*- 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                latex2man
version             1.23
categories          textproc
conflicts           texlive-bin-extra
platforms           any
license             LPPL
maintainers         nomaintainer

supported_archs     noarch

description         Translator program intended to translate a LaTeX \
                    document into man
long_description    Latex2man is a tool to translate UNIX manual \
                    pages written with LaTeX into a format understood \
                    by the UNIX man(1)-command. Alternatively HTML, \
                    TexInfo, or LaTeX code can be produced too.
homepage            http://www.informatik-vollmer.de/software/latex2man.php

master_sites        http://www.informatik-vollmer.de/software
checksums           md5     3507109dcaabaabe81dc427811a29eb9 \
                    sha1    e9b10025255510e4e8af066777c959b599131098 \
                    rmd160  75090f62f12a0a14166514c4854a21567320ae50

depends_lib         bin:tex:texlive \
                    path:bin/perl:perl5

worksrcdir          ${name}

patchfiles          patch-Makefile.diff

configure {
    reinplace -locale en_US.ISO8859-1 \
        "s|\$(HOME)/man|${destroot}${prefix}/share/man|g" \
        ${worksrcpath}/Makefile
    reinplace -locale en_US.ISO8859-1 \
        "s|\$(HOME)/info|${destroot}${prefix}/share/info|g" \
        ${worksrcpath}/Makefile
    reinplace -locale en_US.ISO8859-1 \
        "s|\$(HOME)/public_html|${destroot}${prefix}/share/doc/latex2man|g" \
        ${worksrcpath}/Makefile
    reinplace -locale en_US.ISO8859-1 \
        "s|\$(HOME)/tex/inputs|${destroot}${prefix}/share/texmf-local/tex/latex/latex2man|g" \
        ${worksrcpath}/Makefile
    reinplace -locale en_US.ISO8859-1 \
        "s|\$(HOME)|${destroot}${prefix}|g" \
        ${worksrcpath}/Makefile
    reinplace -locale en_US.ISO8859-1 \
        "s|/usr/bin/env perl|${prefix}/bin/perl|" \
        ${worksrcpath}/latex2man
}

# 'make install' first cleans, so no point in doing any build
build {}

pre-destroot {
    file mkdir ${destroot}${prefix}/share/doc/latex2man
    file mkdir ${destroot}${prefix}/share/texmf-local/tex/latex/latex2man
}
destroot.env    LANG=C

post-activate {
    system "\
        texhash && \
        fmtutil-sys --enablefmt latex2man && \
        fmtutil-sys --missing && \
        fmtutil-sys --all"

    # These are required so that local additions are picked
    # up if teTeX is updated:
    system "mktexlsr"
    system "updmap-sys"
}

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     ${name}-(\\d+(?:\\.\\d+)*)
