# $Id: Portfile 114325 2013-12-05 09:20:31Z ryandesign@macports.org $

PortSystem          1.0
PortGroup           xcode 1.0

name                Platypus
version             4.7
license             GPL-2
categories          aqua devel
maintainers         me.com:tsupplis openmaintainer
conflicts           Platypus44
description         Program for creating application wrappers around scripts.

long_description    Platypus is a program for creating application \
    wrappers around scripts, i.e. creating Mac OS X applications that execute a \
    script they are bundled with. Scripts can thus be run transparently from \
    the graphical window environment without having to resort to using the \
    command line interface. It supports drag and drop on created apps, running \
    as root using Authentication Manager and more.

homepage            http://www.sveinbjorn.org/platypus/
master_sites        http://www.sveinbjorn.org/files/software/platypus/
distname            platypus${version}.src
use_zip             yes

checksums           md5     a2a24f6d4cd3da850bbfc54175e3332e \
                    sha1    87b959b96df9221caacccba3e843558d6800ebec \
                    rmd160  54dc72eb2af47523561d5140d0cbad842bcfd38c


supported_archs     i386 x86_64

build.target        platypus ScriptExec Platypus
destroot.target     Platypus

if {${os.platform} eq "darwin" && ${os.major} >= 10} {
    universal_variant   no
}

set extracted_dir   "${name} ${version} Source Code"
set target_dir      [string map {" " _} "$extracted_dir"]
worksrcdir          $target_dir

post-extract {
    file rename ${workpath}/${extracted_dir} ${workpath}/${target_dir}
}


post-patch {
    reinplace "s|/usr/local|${prefix}|" ${worksrcpath}/CommandLineTool/platypus.1 ${worksrcpath}/Common.h
    reinplace "s|build/Platypus/Build/Products/Development|build/Deployment|" ${worksrcpath}/Platypus.xcodeproj/project.pbxproj
}

post-destroot {
    reinplace "s|/usr/local|${destroot}${prefix}|g" ${worksrcpath}/Scripts/InstallCommandLineTool.sh

    # there is no English.lproj when building on Tiger and Leopard but there is one on SL
    if {${os.platform} eq "darwin" && 10 > ${os.major}} {
        reinplace "s|English.lproj/||g" ${worksrcpath}/Scripts/InstallCommandLineTool.sh
    }

    system -W ${worksrcpath}/Scripts "./InstallCommandLineTool.sh ${destroot}${applications_dir}/Platypus.app/Contents/Resources"
}

livecheck.type  regex
livecheck.url   ${homepage}
livecheck.regex "${name} (\\d+(?:\\.\\d+)*)"

