# -*- 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        flexpaper pdf2json 0.69 v
categories          textproc pdf
platforms           darwin
maintainers         {@flexpaper devaldi.com:pdf2json}
license             GPL-2

description         PDF to JSON conversion utility

long_description    PDF2JSON is a conversion library based on XPDF (3.02) \
                    which can be used for high performance PDF page by page \
                    conversion to JSON and XML format.

github.tarball_from releases

checksums           rmd160  f86436c47973bbd1c7c297f8047019c385602b08 \
                    sha256  69394ef5d5d5504f7106e8b55e15bf491c48d906d611e6bc2e5952005a85b593 \
                    size    1156853

extract.mkdir       yes

post-extract {
    # DOS to UNIX line endings so we can patch
    reinplace "s|\r||g" ${worksrcpath}/Makefile.in
}

patchfiles          patch-Makefiles.diff

post-patch {
    reinplace "s|/usr/local|${prefix}|g" \
        ${worksrcpath}/doc/sample-xpdfrc \
        ${worksrcpath}/xpdf/GlobalParams.cc
}

# remove files already provided by poppler and xpdf
post-destroot {
    file delete -force -- ${destroot}${prefix}/share
    file delete -force -- ${destroot}${prefix}/etc
    foreach f {pdfinfo pdftotext pdfimages pdffonts pdftops} {
        file delete ${destroot}${prefix}/bin/$f
    }
}
