# -*- 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
# $Id: Portfile 90542 2012-03-08 16:58:52Z raphael@macports.org $

PortSystem                      1.0
PortGroup                       cmake 1.0
PortGroup                       qt4 1.0

name                            scantailor
version                         0.9.11.1
platforms                       darwin
maintainers                     raphael openmaintainer
license                         GPL-3+
categories                      graphics aqua
description                     An interactive post-processing tool for scanned pages
homepage                        http://${name}.sourceforge.net/
long_description                Scan Tailor is an interactive post-processing tool for scanned \
                                pages. It performs operations such as page splitting, deskewing, \
                                adding/removing borders, and others. You give it raw scans, and \
                                you get pages ready to be printed or assembled into a PDF or \
                                DJVU file. Scanning, optical character recognition, and \
                                assembling multi-page documents are out of scope of this project.

depends_lib-append              port:jpeg \
                                port:zlib \
                                port:libpng \
                                port:tiff \
                                port:boost \
                                port:xrender

master_sites                    sourceforge:project/scantailor/scantailor/${version}

checksums                       rmd160  43958c567bffe17bda2af4873f7beb0b71b77ab4 \
                                sha256  881647a4172c55a067a7b6687965441cf21176d79d93075b22a373ea9accd8d3

post-patch {
    reinplace "s|@VERSION@|${version}|" ${worksrcpath}/packaging/osx/Info.plist.in
}

# scantailor does not build with clang
if {${configure.compiler} == "clang"} {
    configure.compiler llvm-gcc-4.2
}
configure.args-append           ${qt_cmake_defines}

post-destroot {                 # create application bundle
                                set appdir ${destroot}${applications_dir}/ScanTailor.app
                                xinstall -d ${appdir}/Contents/MacOS
                                xinstall -m 644 ${worksrcpath}/packaging/osx/Info.plist.in ${appdir}/Contents/Info.plist
                                move ${destroot}${prefix}/bin/scantailor ${appdir}/Contents/MacOS/ScanTailor
                                xinstall -d ${appdir}/Contents/Resources
                                xinstall -m 644 ${worksrcpath}/packaging/osx/ScanTailor.icns ${appdir}/Contents/Resources/
                                eval move [glob ${destroot}${prefix}/share/scantailor/translations/scantailor_*.qm] \
                                    ${appdir}/Contents/Resources/

                                # install additional documentation files
                                set docdir ${destroot}${prefix}/share/doc/${name}
                                xinstall -d ${docdir}
                                xinstall -m 644 -W ${worksrcpath} \
                                    COPYING \
                                    GPL3.txt \
                                    ${docdir}
}

livecheck.type                  sourceforge
