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

github.setup        AbiWord enchant 2.2.3 v
name                enchant2
categories          textproc devel
platforms           darwin
license             LGPL-2.1+
maintainers         nomaintainer

description         Generic spell checking library
long_description    Enchant aims to provide a simple but comprehensive abstraction for dealing \
                    with different spell checking libraries in a consistent way. Installs in \
                    parallel with legacy Enchant 1.x versions without conflict.

github.tarball_from releases

# Remove dist_subdir when updating to the next version.
dist_subdir         ${name}/${version}_1

checksums           rmd160  87ac76b00ed54d47d246b0938d493d2a82180de6 \
                    sha256  abd8e915675cff54c0d4da5029d95c528362266557c61c7149d53fa069b8076d \
                    size    957451

depends_lib         path:lib/pkgconfig/glib-2.0.pc:glib2

depends_build       port:pkgconfig

configure.args      --without-hunspell \
                    --without-applespell \
                    --without-aspell \
                    --without-voikko \
                    --without-hspell \
                    --without-zemberek \
                    --disable-silent-rules \
                    --disable-gcc-warnings

# to allow parallel install with enchant 1.x
build.cmd-append    pkgdatadir=${prefix}/share/enchant-2

# https://trac.macports.org/ticket/51287
# https://trac.macports.org/ticket/56222
if {${os.platform} eq "darwin" &&  ${os.major} >= 15} {
    # users most likely have AppleSpell already set up for their language
    default_variants    +applespell
} else {
    default_variants    +aspell
}

variant aspell description {Enable aspell backend} {
    configure.args-replace --without-aspell --with-aspell
    configure.args-append  --with-aspell-dir=${prefix}/share/aspell
    depends_lib-append  port:aspell
    depends_run         port:aspell-dict-en
}

variant hunspell description {Enable hunspell backend} {
    configure.args-replace --without-hunspell --with-hunspell
    configure.args-append  --with-hunspell-dir=${prefix}/share/hunspell
    depends_lib-append  port:hunspell
    depends_run-append  port:hunspell-en_US
}

variant applespell description {Enable AppleSpell backend, using system-wide OS X spell checker} {
    configure.args-replace --without-applespell --with-applespell
}

if {[variant_isset aspell] || [variant_isset hunspell]} {
    notes {
        enchant2 will use the first backend that provides a dictionary for the
        requested language. If you prefer a specific backend, please see the
        man page how you can change the lookup order. By default, the backend
        order is hunspell, aspell, AppleSpell from highest to lowest
        preference.

        $ man enchant-2
    }
}