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

PortSystem          1.0

name                irstlm
version             5.80.03
categories          textproc math
maintainers         hum openmaintainer

description         The IRST Language Modeling Toolkit
long_description    ${description} features algorithms and data structures \
                    suitable to estimate, store, and access very large LMs. Our \
                    software has been integrated into a popular open source \
                    Statistical Machine Translation decoder called Moses, and is \
                    compatible with language models created with other tools, \
                    such as the SRILM Tooolkit.

homepage            http://hlt.fbk.eu/en/irstlm
platforms           darwin
license             LGPL

master_sites        http://sourceforge.net/projects/irstlm/files/irstlm/irstlm-5.80/
checksums           rmd160  08b9506e2dc388217e33070ebc1b06d7667d3d5c \
                    sha256  500c64e90cae73c2f06ed34ad078423cc100f4e16e6dd98a9e466b17367d31e7
extract.suffix      .tgz

depends_lib         port:zlib

depends_build       port:autoconf port:automake port:libtool

# binaries and scripts are installed at ${libexec_dir}.
set libexec_dir     ${prefix}/libexec/${name}

# patch-scripts.diff: replace the value of the IRSTLM environmental variable with ${libexec_dir}.
# patch-configure.in.diff: fix for automake 1.13 update; see #37549.
patchfiles          patch-scripts.diff \
                    patch-configure.in.diff

post-patch {
    foreach f {build-lm-qsub.sh build-lm.sh lm-stat.pl split-ngt.sh} {
        reinplace "s|@libexec_dir@|${libexec_dir}|g" ${worksrcpath}/scripts/${f}
    }
}

universal_variant   no

installs_libs       no

pre-configure {
    system -W ${worksrcpath} "sh regenerate-makefiles.sh"
}

# install include files at ${prefix}/include/${name} to avoid conflicts with other builds.
# e.g. mosesdecoder
configure.args      --includedir=${prefix}/include/${name} \
                    --bindir=${libexec_dir} \
                    --enable-caching

# error: variable length array of non-POD element type
compiler.blacklist  *clang*

post-destroot {
    # fix permissions of the binaries and scripts.
    foreach f [glob -directory ${destroot}${libexec_dir} -type f *] {
        file attributes ${f} -permissions 0755
    }
    # install additional documents.
    set doc_dir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${doc_dir}
    xinstall -m 644 -W ${worksrcpath} \
        Copyright README RELEASE \
        ${destroot}${doc_dir}
}

livecheck.type      regex
livecheck.url       http://sourceforge.net/projects/irstlm/
livecheck.regex     ${name}-(\[0-9.\]+)\\.