# -*- 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             2020.12.07
revision            0
distname            scowl-${version}
categories          textproc
license             permissive
maintainers         nomaintainer
description         SCOWL based hunspell english dictionaries.
platforms           any
homepage            http://wordlist.aspell.net/dicts/
master_sites        sourceforge:wordlist
supported_archs     noarch

checksums           rmd160  cac39f67d422ee0ca99daa51b17e32c36661a469 \
                    sha256  5587667caa20c4891390c2d42dbb4d5c4c3f41bee77af1457ece3ba23fb859cc \
                    size    2569810

use_configure       no

if {$subport eq $name} {
    notes "The $name port is just a stub. Please install 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."
    long_description    {*}${description} {*}${notes}
    distfiles
    build {}
    destroot {
        xinstall -d ${destroot}${prefix}/share/doc/${name}
        system "echo [join $notes] > ${destroot}${prefix}/share/doc/${name}/ReadMe.txt"
    }
} else {
    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
    # Tell MacPorts base not to add a -j1 arg which make-hunspell-dict doesn't understand.
    build.jobs          0

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

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

    # 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/SCOWL/
livecheck.regex     "(\\d{4}\\.\\d{2}\\.\\d{2})"
