# -*- 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
PortGroup           boost 1.0

github.setup        moses-smt mosesdecoder f4471692ba51aeec3cf9867fcabe2c4fc7d4cb33
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version             20121007
revision            4
categories          textproc
maintainers         nomaintainer

description         a statistical machine translation system

long_description    Moses is a statistical machine translation system that \
                    allows you to automatically train translation models for \
                    any language pair. All you need is a collection of \
                    translated texts (parallel corpus). An efficient search \
                    algorithm finds quickly the highest probability translation \
                    among the exponential number of choices.

homepage            http://www.statmt.org/moses/
license             LGPL

# stealth update; remove for next version
dist_subdir         ${name}/${version}_1
checksums           rmd160  73cc892cb675c31abcc9693801c701345e010868 \
                    sha256  68fa1878bfe79092cdf115cd1a0a8cdb8e135553211db29f1b7a843bfbe2ab6e \
                    size    6324795

depends_lib         port:zlib

boost.version       1.71

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

# set _EXTERNAL_BINDIR (-external-bin-dir) to ${prefix}/bin.
patchfiles          patch-train-model.perl.diff

post-patch {
    set f ${worksrcpath}/scripts/training/train-model.perl
    reinplace "s|@prefix@|${prefix}|g" ${f}
    reinplace "s|\$SCRIPTS_ROOTDIR/\\.\\./bin/|${libexec_dir}/|g" ${f}
}

use_configure       no

build.cmd           ./bjam
build.target
build.args          --prefix=${prefix} --with-boost=[boost::install_area]

destroot.args       ${build.args} \
                    --bindir=${destroot}${libexec_dir} \
                    --includedir=${destroot}${prefix}/include/${name}
destroot.destdir    --prefix=${destroot}${prefix}

post-destroot {
    # install scripts.
    set scripts_dir ${libexec_dir}/scripts
    set args "${build.args} --install-scripts=${destroot}${scripts_dir}"
    system -W ${worksrcpath}/scripts "../bjam ${args}"
    # link some binaries to bin.
    foreach file {moses moses_chart} {
        ln -s ${libexec_dir}/${file} ${destroot}${prefix}/bin/${file}
    }
}

livecheck.type      none
