# $Id: Portfile 103191 2013-02-18 09:14:15Z raimue@macports.org $

PortSystem      1.0

name            poedit
version         1.5.5
categories      devel aqua
platforms       darwin
license         MIT
maintainers     raimue \
                openmaintainer

description     Poedit is a cross-platform gettext catalogs (.po files) editor.
long_description \
    Poedit is a cross-platform gettext catalogs (.po files) editor. It aims to \
    provide more convenient approach to editing catalogs than editing the file by \
    hand. This port installs Poedit.app.

homepage        http://www.poedit.net/
master_sites    sourceforge:poedit

checksums       md5     da86cb73cee9d006a42f9574811d13ab \
                sha1    822a72afab0c936c00291e21c8f23ff4cf8a3009 \
                rmd160  cfc402f9eb0f000f068d98364870ac3860c20f57 \
                sha256  3c94c9825c11a2d1ce10e083ad246e8625469f358da4a5a2f6210170b970f949

depends_build   bin:grep:grep \
                port:pkgconfig \
                port:boost
depends_lib     port:wxWidgets \
                port:gettext

depends_skip_archcheck grep pkgconfig boost

variant wxwidgets_devel description {Uses wxWidgets-devel (allows 64-bit build)} {
    depends_lib-delete        port:wxWidgets
    depends_lib-append        port:wxWidgets-devel
}

platform darwin 11 {
    # According to comments in wxWidgets Portfile
    if {[vercmp $xcodeversion 4.4] >= 0} {
        default_variants +wxwidgets_devel
    }
}

platform darwin 12 {
    depends_lib-replace    port:wxWidgets port:wxWidgets30
}

if {![variant_isset wxwidgets_devel]} {
    # wxWidgets 2.8 is not universal and is 32-bit only
    universal_variant       no
    supported_archs         i386 ppc
}

# remove some additional features, especially sparkle because macports handles updates
configure.args  --disable-transmem --disable-spellchecking --without-sparkle

build.dir           ${build.dir}/src
build.target        bundle
build.env-append    GETTEXT_PREFIX=${prefix}

destroot {
    # the gettext binaries are copied into Poedit.app during build,
    # but we rather delete and symlink them to get updates to gettext automatically
    foreach extra { msgfmt msgmerge msgunfmt xgettext } {
        file delete ${worksrcpath}/src/Poedit.app/Contents/MacOS/${extra}
        ln -s ${prefix}/bin/${extra} ${worksrcpath}/src/Poedit.app/Contents/MacOS/${extra}
    }
    file delete ${worksrcpath}/src/Poedit.app/Contents/MacOS/gnu_gettext.COPYING

    file copy ${worksrcpath}/src/Poedit.app ${destroot}${applications_dir}/Poedit.app
}

variant transmem description {Enables translation memory for often used phrases} {
    depends_lib-append      port:db44
    configure.args-delete   --disable-transmem
    configure.args-append   --enable-transmem
}

variant spellcheck description {Enables spellchecking} {
    depends_lib-append      port:gtkspell2
    configure.args-delete   --disable-spellchecking
    configure.args-append   --enable-spellchecking
}

livecheck.type  regex
livecheck.url   http://www.poedit.net/download.php
livecheck.regex {Latest stable version is <b>(\d+(?:.\d+)+)</b>}
