# $Id: Portfile 79385 2011-06-12 07:59:29Z jmr@macports.org $

PortSystem              1.0

name                    pdfjam
version                 2.06
revision                1
categories              textproc pdf
maintainers             vcn.com:jjstickel
license                 GPLv2
platforms               darwin
homepage                http://go.warwick.ac.uk/pdfjam
master_sites            ${homepage}
extract.suffix          .tgz
distname                ${name}_[join [split ${version} .] {}]
worksrcdir              ${name}
supported_archs         noarch
use_configure           no

description             A few PDF manipulation tools.

long_description \
    PDFjam is a small collection of shell scripts which provide a  \
    simple interface to some of the functionality of the excellent \
    pdfpages package (by Andreas Matthias) for pdfLaTeX.

checksums               md5     8113cae5d43359708be9e7e9d6df999d \
                        sha1    4bc7afe3c3d8a45877d2c4ff76e3ca31900b2840 \
                        rmd160  01e1add0e1b58bfda06efdedb230c7d721c51e62
		    
depends_run \
    bin:pdflatex:texlive-basic \
    path:share/texmf-dist/tex/latex/pdfpages/pdfpages.sty:texlive-latex-recommended

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

build {}

destroot {
    delete ${destroot}${prefix}/bin ${destroot}${prefix}/share/man/man1
    copy ${worksrcpath}/bin ${destroot}${prefix}/bin
    copy ${worksrcpath}/man1 ${destroot}${prefix}/share/man/man1

    xinstall -m 644 ${worksrcpath}/pdfjam.conf ${destroot}${prefix}/etc/pdfjam.conf.sample

    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} COPYING PDFjam-README.html VERSION \
       ${destroot}${prefix}/share/doc/${name}
}

pre-activate {
    # texlive-bin-extra used to contain pdfjam, but doesn't
    # anymore. If the old version is installed, deactivate it to avoid
    # a conflict.
    if {[file exists $prefix/bin/pdfjam] 
        && ![catch {set vers [lindex [registry_active texlive-bin-extra] 0]}]
        && [rpm-vercomp [lindex $vers 1] 19536] < 0} {
        set deactivate_proc registry_deactivate_composite
        if {[info commands registry_deactivate_composite] == {}} {
            set deactivate_proc registry_deactivate
        }
        $deactivate_proc texlive-bin-extra "" [list ports_nodepcheck 1]
    }
}
