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

name                hunspell-en
version             2018.04.16
distname            scowl-${version}
categories          textproc
license             permissive
maintainers         nomaintainer
description         SCOWL based hunspell english dictionaries.
long_description    ${description}
platforms           darwin
homepage            http://wordlist.aspell.net/dicts/
master_sites        sourceforge:wordlist
supported_archs     noarch

checksums           rmd160  b002ca9f5e3a558d33d0229571175108b29c46b8 \
                    sha256  3a97d5a92a8705a35611ac21a61ed72ad9a19baa64168273deb5b8cca1cd9386

use_configure       no

depends_build       port:aspell \
                    port:perl5 \
                    port:dos2unix

depends_lib         port:hunspell

build.dir           ${worksrcpath}/speller
build.cmd           ./make-hunspell-dict
build.target        -all
use_parallel_build  no

set installdir "${destroot}${prefix}/share/hunspell/"

pre-destroot {
    xinstall -d -m 755 $installdir
}

subport hunspell-en {
    long_description    ${description}
    pre-configure {
        ui_error "Please choose one of the subports: \
        hunspell-en_AU, hunspell-en_AU_large, \
        hunspell-en_CA, hunspell-en_CA_large, \
        hunspell-en_GB_ise, hunspell-en_GB_ize, hunspell-en_GB_large, \
        hunspell-en_US or hunspell-en_US_large."
        return -code error
    }
}

# use MacPorts perl https://trac.macports.org/ticket/55116
pre-configure {
    reinplace -locale C -W ${worksrcpath} "s|/usr/bin/perl|${prefix}/bin/perl|g" mk-list
    reinplace -locale C -W ${worksrcpath}/speller "s|/usr/bin/perl|${prefix}/bin/perl|g" \
        add-no-suggest munch-list
    reinplace -locale C -W ${worksrcpath}/src "s|/usr/bin/perl|${prefix}/bin/perl|g" \
        add-accents add-affixes add-other-forms add-other-spellings clean-alan-list \
        cmp-final count find-ss get-level make-README proc-alt12dicts proc-census \
        proc-neol proc-uk-freq-class rand-sample.pl rand-samples remove-plurals
}

subport hunspell-en_AU {
    long_description    ${description}: AU English dictionary

    destroot {
        xinstall -m 644 ${worksrcpath}/speller/en_AU.aff $installdir
        xinstall -m 644 ${worksrcpath}/speller/en_AU.dic $installdir
    }
}

subport hunspell-en_AU_large {
    long_description    ${description}: large AU English dictionary

    destroot {
        xinstall -m 644 ${worksrcpath}/speller/en_AU-large.aff $installdir
        xinstall -m 644 ${worksrcpath}/speller/en_AU-large.dic $installdir
    }
}

subport hunspell-en_CA {
    long_description    ${description}: CA English dictionary

    destroot {
        xinstall -m 644 ${worksrcpath}/speller/en_CA.aff $installdir
        xinstall -m 644 ${worksrcpath}/speller/en_CA.dic $installdir
    }
}

subport hunspell-en_CA_large {
    long_description    ${description}: large CA English dictionary

    destroot {
        xinstall -m 644 ${worksrcpath}/speller/en_CA-large.aff $installdir
        xinstall -m 644 ${worksrcpath}/speller/en_CA-large.dic $installdir
    }
}

subport hunspell-en_GB_ise {
    long_description    ${description}: GB English dictionary (-ise version)

    destroot {
        xinstall -m 644 ${worksrcpath}/speller/en_GB-ise.aff $installdir
        xinstall -m 644 ${worksrcpath}/speller/en_GB-ise.dic $installdir
    }
}

subport hunspell-en_GB_ize {
    long_description    ${description}: GB English dictionary (-ize version)

    destroot {
        xinstall -m 644 ${worksrcpath}/speller/en_GB-ize.aff $installdir
        xinstall -m 644 ${worksrcpath}/speller/en_GB-ize.dic $installdir
    }
}

subport hunspell-en_GB_large {
    long_description    ${description}: large GB English dictionary

    destroot {
        xinstall -m 644 ${worksrcpath}/speller/en_GB-large.aff $installdir
        xinstall -m 644 ${worksrcpath}/speller/en_GB-large.dic $installdir
    }
}

subport hunspell-en_US {
    long_description    ${description}: US English dictionary

    destroot {
        xinstall -m 644 ${worksrcpath}/speller/en_US.aff $installdir
        xinstall -m 644 ${worksrcpath}/speller/en_US.dic $installdir
    }
}

subport hunspell-en_US_large {
    long_description    ${description}: large US English dictionary

    destroot {
        xinstall -m 644 ${worksrcpath}/speller/en_US-large.aff $installdir
        xinstall -m 644 ${worksrcpath}/speller/en_US-large.dic $installdir
    }
}

livecheck.type      regex
livecheck.url       https://sourceforge.net/projects/wordlist/files/speller/
livecheck.regex     "(\\d{4}\\.\\d{2}\\.\\d{2})"