# -*- 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 67309 2010-05-05 07:11:27Z jmr@macports.org $

PortSystem 1.0
PortGroup  xcode 1.0

name            gimp-app
version         2.6.0
revision        1
maintainers     nomaintainer
description     Gimp.app application bundle
long_description ${description}

categories      aqua graphics
homepage        http://gimp-app.sourceforge.net/

depends_run     bin:gimp:gimp2

master_sites    sourceforge
distfiles       ScriptExec.tar.gz \
                gimp.app.skel.tar.gz
checksums       ScriptExec.tar.gz md5 fc444a1e18cf2664f29af6ca6ca335ef \
                gimp.app.skel.tar.gz md5 66ad4912a3c71056c479c8eeef11fd43
worksrcdir      ScriptExec

patchfiles      patch-main.c.diff

pre-patch {
    foreach f {Info.plist PkgInfo} {
        delete ${workpath}/Gimp.app/Contents/$f
        xinstall -m 644 ${filespath}/$f ${workpath}/Gimp.app/Contents
    }
    delete ${workpath}/Gimp.app/Contents/Resources/script
    xinstall -m 755 ${filespath}/script ${workpath}/Gimp.app/Contents/Resources
    reinplace "s|__VERSION__|${version}|g" ${workpath}/Gimp.app/Contents/Info.plist
}

post-patch {
    reinplace "s|`dirname \\\\\"\$0\\\\\"`|${prefix}|g" \
        ${workpath}/Gimp.app/Contents/Resources/openDoc \
        ${workpath}/Gimp.app/Contents/Resources/script
}

pre-build {
    # clean up old precompiled headers just in case
    system "cd ${worksrcpath} && ${xcodebuildcmd} clean"
}

destroot {
    xinstall -m 755 \
        ${workpath}/Gimp.app/Contents/Resources/bin/getdisplay.sh \
        ${destroot}${prefix}/bin
}
post-destroot {
    foreach f {Gimp.icns bin etc lib share} {
        delete ${workpath}/Gimp.app/Contents/Resources/$f
    }
    xinstall -m 644 -W ${filespath} Gimp.icns xcf.icns \
        ${workpath}/Gimp.app/Contents/Resources

    xinstall -m 755 \
        ${worksrcpath}/build/Deployment/ScriptExec.app/Contents/MacOS/ScriptExec \
        ${workpath}/Gimp.app/Contents/MacOS/Gimp

    xinstall -d ${destroot}${applications_dir}
    copy ${workpath}/Gimp.app ${destroot}${applications_dir}
}

notes "
If you are having problems viewing the help files when using Gimp.app,
    1- Make sure you have the user manual installed (port gimp-user-manual)
    2- Add the following line to ~/.gimp-2.6/gimprc :
        (help-locales \"LANG\")
       where LANG is your two-letters locale (fr, en, jp, ...)
"

variant quartz {
    destroot {
        foreach f {openDoc script} {
            delete ${workpath}/Gimp.app/Contents/Resources/$f
            ln -s ${prefix}/bin/gimp \
                ${workpath}/Gimp.app/Contents/Resources/$f
        }
    }
}

livecheck.regex <title>${name} (\[0-9.\]+).* released.*</title>
