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

name                DiffPDF
version             2.1.3
categories          graphics
platforms           darwin
license             GPL-2+
maintainers         {gmail.com:davide.liessi @dliessi} openmaintainer
description         Compare two PDF files textually or visually
long_description    ${name} can compare two PDF files. \
                    It offers three comparison modes: \
                    Words, Characters, and Appearance.
homepage            http://www.qtrac.eu/diffpdf-foss.html
master_sites        http://www.qtrac.eu/

distname            [string tolower ${name}-${version}]

checksums           sha1    663ecb7666a4b7d6fbd1a37327fd1f895fae69b8 \
                    rmd160  12a5f6921b8a53d98d9786af25e408e27611f56f \
                    sha256  c6142ee038a78108397f45b0c456dca7a4fe1d75250f21a514a134101d322433 \
                    size    91856

depends_lib-append  port:poppler-qt4-mac
configure.pkg_config_path-append \
                    ${prefix}/libexec/poppler-qt4-mac/lib/pkgconfig

depends_build-append    port:makeicns

patchfiles          patch-include-poppler-qt4.diff

post-patch {
    reinplace s|@@PREFIX@@|${prefix}| ${worksrcpath}/[string tolower ${name}].pro
    reinplace s|@@ICON@@|${worksrcpath}/images/icon.icns| ${worksrcpath}/[string tolower ${name}].pro
}

pre-configure {
    system -W ${worksrcpath} "${qt_lrelease_cmd} [string tolower ${name}].pro"
}

pre-build {
    if {[catch {system -W ${worksrcpath}/images "${prefix}/bin/makeicns -in icon.png 2>&1"}]} {
        return -code error "icon.png could not be converted to icon.icns: $::errorInfo"
    }
}

post-build {
    move ${worksrcpath}/[string tolower ${name}].app ${worksrcpath}/${name}.app
    system -W ${worksrcpath} "${qt_bins_dir}/macdeployqt ${name}.app"
}

destroot {
    copy ${worksrcpath}/${name}.app ${destroot}${applications_dir}
}

livecheck.type      regex
livecheck.regex     [string tolower ${name}]-(\\d+(?:\\.\\d+)*)
