# $Id: Portfile 92858 2012-05-09 05:50:29Z jmr@macports.org $

PortSystem 1.0

name            latex2man
version         1.23
categories      textproc
platforms       darwin
maintainers     nomaintainer

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_run     bin:tex:texlive path:bin/perl:perl5

worksrcdir      ${name}

patchfiles      patch-Makefile.diff

configure       {
                reinplace "s|\$(HOME)/man|${destroot}${prefix}/share/man|g" ${worksrcpath}/Makefile
                reinplace "s|\$(HOME)/info|${destroot}${prefix}/share/info|g" ${worksrcpath}/Makefile
                reinplace "s|\$(HOME)/public_html|${destroot}${prefix}/share/doc/latex2man|g" ${worksrcpath}/Makefile
                reinplace "s|\$(HOME)/tex/inputs|${destroot}${prefix}/share/texmf-local/tex/latex/latex2man|g" ${worksrcpath}/Makefile
                reinplace "s|\$(HOME)|${destroot}${prefix}|g" ${worksrcpath}/Makefile
                reinplace "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"
}
