# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-

PortSystem              1.0
PortGroup               cmake 1.1
PortGroup               github 1.0
PortGroup               legacysupport 1.1

# std::locale::ctype
legacysupport.use_mp_libcxx                 yes
legacysupport.newest_darwin_requires_legacy 12

github.setup            apertium lttoolbox 3.8.2 v
github.tarball_from     releases
use_bzip2               yes
revision                0

categories              textproc
license                 GPL-2+
maintainers             nomaintainer

description             toolbox for lexical processing, morphological analysis \
                        and generation

long_description        lttoolbox is a toolbox from the Apertium platform \
                        used for lexical processing, morphological analysis \
                        and generation of words. Analysis involves finding \
                        the lemma and grammatical information (e.g. noun, \
                        plural) of a surface form. Generation is the opposite \
                        process. The package is split into three programs, \
                        lt-comp (compiler), lt-proc (processor), and \
                        lt-expand (generates all possible mappings between \
                        surface forms and lexical forms).

homepage                http://wiki.apertium.org/wiki/Lttoolbox

checksums               rmd160  81acb8547ecebd9a1ca335ae4cd949bd76e8df8c \
                        sha256  7028dbbcda6c49467378d47784092ef8aba9a59d53e78102742d1edb7c5ff21b \
                        size    157342

# Fixed upstream.  Remove when fixed after version 3.8.2.
# https://github.com/apertium/lttoolbox/issues/206
patchfiles-append       patch-ustring_h.diff

compiler.cxx_standard   2017

# Cannot be compiled on macOS 10.7-10.8 with the newer versions of LLVM
# Enforcing the _DARWIN_C_SOURCE flag fixes this issue
# https://trac.macports.org/ticket/60885
# https://github.com/macports/macports-ports/pull/30356
if {${os.platform} eq "darwin" && ${os.major} < 13 && ${os.major} > 10} {
        # lt_locale.cc:32:78: error: 'ctype' is
        # unavailable: introduced in macOS 10.9
        # std::locale::ctype is missing in the libc++ system
        # library, and Clang reports this error even with
        # macports-libcxx (except for <Lion), so pass this flag.
        if {[string match *clang* ${configure.compiler}]} {
                configure.cxxflags-append \
                        -D_LIBCPP_DISABLE_AVAILABILITY
        }
        if {${configure.cxx_stdlib} eq "libc++"} {
                configure.cxxflags-append \
                        -D_DARWIN_C_SOURCE
        }
}

set python_version      313

depends_build-append    path:bin/pkg-config:pkgconfig \
                        port:python${python_version} \
                        port:utfcpp

depends_lib-append      port:libxml2 \
                        port:icu
