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

epoch               1
github.setup        moses-smt giza-pp 1.0.7 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            1
categories          textproc
maintainers         nomaintainer

description         a statistical machine translation toolkit
long_description    GIZA++ is a statistical machine translation toolkit that is \
                    used to train IBM Models 1-5 and an HMM word alignment model. \
                    This package also contains the source for the mkcls tool \
                    which generates the word classes necessary for training some \
                    of the alignment models.

license             GPL-2

installs_libs       no

master_sites        macports_distfiles
checksums           rmd160  aa1a7b9e5cc5c9bb56250b8a8707ed150d56b078 \
                    sha256  302b45d6ca22bc0a1495a2b09dcc9cc965815e1e3d56c78d053c8743d96369f0 \
                    size    163217

conflicts           mgizapp

distname            ${name}-v${version}
worksrcdir          ${name}

depends_build       bin:iconv:libiconv

patchfiles          tr1.patch

post-patch {
    system -W ${worksrcpath} "iconv -f ISO-8859-1 -t UTF-8 mkcls-v2/mkcls.cpp > x"
    move -force ${worksrcpath}/x ${worksrcpath}/mkcls-v2/mkcls.cpp
}

use_configure       no

variant universal {}

if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} ne ""} {
    configure.cxxflags-append -stdlib=${configure.cxx_stdlib}
}

build.args          CXX=${configure.cxx} CFLAGS="${configure.cxxflags} [get_canonical_archflags cxx]"

destroot {
    xinstall -m 0755 -W ${worksrcpath}/GIZA++-v2 GIZA++ \
        snt2plain.out plain2snt.out snt2cooc.out ${destroot}${prefix}/bin
    xinstall -m 0755 ${worksrcpath}/mkcls-v2/mkcls ${destroot}${prefix}/bin
    set doc ${destroot}${prefix}/share/doc/${name}
    file mkdir ${doc}
    xinstall -m 0644 ${worksrcpath}/GIZA++-v2/README ${doc}/README.GIZA++
    xinstall -m 0644 ${worksrcpath}/mkcls-v2/README ${doc}/README.mkcls
}
