# -*- 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                    pdftk
version                 2.02
revision                1
categories              textproc graphics pdf
maintainers             nomaintainer
platforms               darwin
license                 GPL-2+
homepage                https://www.pdflabs.com/tools/pdftk-server/
master_sites            https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/
use_zip                 yes
use_configure           no
universal_variant       no
use_parallel_build      no

description \
    pdftk - PDF Toolkit, for various operations on PDF files

long_description \
    pdftk is a simple tool for doing everyday things with PDF documents: \
    Merge PDF Documents \
    Split PDF Pages into a New Document \
    Decrypt Input as Necessary (Password Required) \
    Encrypt Output as Desired \
    Fill PDF Forms with FDF Data and/or Flatten Forms \
    Apply a Background Watermark \
    Report on PDF Metrics such as Metadata, Bookmarks, and Page Labels \
    Update PDF Metadata \
    Attach Files to PDF Pages or the PDF Document \
    Unpack PDF Attachments \
    Burst a PDF Document into Single Pages \
    Uncompress and Re-Compress Page Streams \
    Repair Corrupted PDF (Where Possible)

conflicts               pdftk-java

checksums               rmd160  4d9e75abc4a966041bd0be7b1db13bb73819d2ae \
                        sha256  118f6a25fd3acaafb58824dce6f97cdc07e56050e666b90e4c4ef426ea37b8c1 \
                        size    2239008

# builds and links against libstdc++/macports-libstdc++
configure.cxx_stdlib    libstdc++

distname                ${name}-${version}-src
worksrcdir              ${name}-${version}-dist

depends_lib             port:libiconv \
                        port:zlib

build.dir               ${worksrcpath}/${name}

patchfiles              patch-Makefile.OSX-10.6.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${build.dir}/Makefile.OSX-10.6
}

set versuff ""

pre-build {
    build.args-append   VERSUFF=${versuff}
}

build.args-append       -f Makefile.OSX-10.6

destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 755 -W ${destroot.dir} pdftk ${destroot}${prefix}/bin
    xinstall -m 644 -W ${worksrcpath} changelog.html changelog.txt pdftk.1.html pdftk.1.txt \
        ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} pdftk.1 \
        ${destroot}${prefix}/share/man/man1
}

variant gcc45 conflicts gcc47 gcc5 description {Build using gcc45} {
    configure.compiler  macports-gcc-4.5
    set versuff         -mp-4.5
}

variant gcc47 conflicts gcc45 gcc5 description {Build using gcc47} {
    configure.compiler  macports-gcc-4.7
    set versuff         -mp-4.7
}

variant gcc5 conflicts gcc45 gcc47 description {Build using gcc5} {
    configure.compiler  macports-gcc-5
    depends_run-append  port:gcc5
    set versuff         -mp-5
}

if {![variant_isset gcc45] && ![variant_isset gcc47] && ![variant_isset gcc5]} {
    default_variants    +gcc5 
}

livecheck.type          regex
livecheck.url           https://www.pdflabs.com/docs/install-pdftk-on-redhat-or-centos/
livecheck.regex         ${name}-(\[0-9.\]+)-src${extract.suffix}
