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

github.setup            rrthomas pdfjam 4.3.1 v
categories              textproc pdf
maintainers             {gmail.com:jjstickel @jjstickel} openmaintainer
license                 GPL-2
platforms               any
supported_archs         noarch
use_configure           no

description             pdfjam is a shell-script front end to the LaTeX 'pdfpages' package

long_description \
    The pdfjam package makes available the pdfjam shell script that provides a simple interface to much of the \
    functionality of the excellent pdfpages package (by Andreas Matthias) for LaTeX. \
    The pdfjam script takes one or more PDF files (and/or JPG/PNG graphics files) as input, \
    and produces one or more PDF files as output. \
    It is useful for joining files together, selecting pages, reducing several source pages onto one output page, etc.

github.tarball_from     releases

checksums               rmd160  218bfd3455ff368adfad4de5a3ae1fa08d1ca81f \
                        sha256  4423745a9708335afdbc68fb27b9eec3d177ccbb755fb74e37ecc0c77e88fd09 \
                        size    256312

depends_run \
    bin:pdflatex:texlive-latex \
    path:share/texmf-dist/tex/latex/pdfpages/pdfpages.sty:texlive-latex-recommended

post-patch {
    reinplace "s|/usr/local|${prefix}|g" \
        ${worksrcpath}/bin/pdfjam \
        ${worksrcpath}/man/pdfjam.1
}

build {}

test.run    yes
test.cmd    bin/pdfjam
test.target
test.args   --version

destroot {
    xinstall -m 755 ${worksrcpath}/bin/pdfjam ${destroot}${prefix}/bin/pdfjam
    xinstall -m 644 ${worksrcpath}/man/pdfjam.1 ${destroot}${prefix}/share/man/man1/pdfjam.1
    xinstall -m 644 ${worksrcpath}/pdfjam.conf ${destroot}${prefix}/etc/pdfjam.conf.sample

    xinstall -m 755 -d ${destroot}${prefix}/share/zsh/site-functions
    xinstall -m 644 ${worksrcpath}/shell-completion/zsh/_pdfjam ${destroot}${prefix}/share/zsh/site-functions/_pdfjam

    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} pdfjam.pdf COPYING README.md VERSION-${version} \
       ${destroot}${prefix}/share/doc/${name}
}

notes "
If you use the zsh shell, you can add shell completion for ${name} by adding this line to ~/.zshrc:

    source ${prefix}/share/zsh/site-functions/_pdfjam
"
