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

github.setup        chokkan simstring 6209ea86d84f7043f8e19029d83299f458665ec5
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version             20140723
categories          textproc math
maintainers         nomaintainer

description         A fast and simple algorithm for approximate string matching/retrieval
long_description    SimString is a simple library for fast approximate string \
                    retrieval. Approximate string retrieval finds strings in a \
                    database whose similarity with a query string is no smaller \
                    than a threshold. Finding not only identical but similar \
                    strings, approximate string retrieval has various \
                    applications including spelling correction, flexible \
                    dictionary matching, duplicate detection, and record linkage.

homepage            http://www.chokkan.org/software/simstring/
license             BSD

checksums           rmd160  b583d69175504f70b7d761d9365b8a274628431a \
                    sha256  298e292c597f21fd4d3e7a4e6478f9b73f46d04372b78c6ea0a901ecfeb52d2d

if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} == "libc++"} {
    # https://github.com/chokkan/simstring/issues/16
    patchfiles      patch-libc++.diff
    notes "UTF16/32 not supported because of libc++ incompatibility"
}

use_autoconf        yes
autoconf.cmd        ./autogen.sh

depends_build       port:autoconf \
                    port:automake \
                    port:libtool

# Python port
subport py27-simstring {
    PortGroup           python 1.0
    name                py-simstring
    python.versions     27
    categories-append   textproc math
    description         SimString Python module
    long_description    {*}${description}
    set python_dir      ${worksrcpath}/swig/python

    depends_build-append  port:swig-python

    use_configure       yes
    build.dir           ${python_dir}
    pre-build {
        system -W ${python_dir} "./prepare.sh --swig"
    }
    build.target        build_ext
    destroot.dir        ${python_dir}
    post-destroot {
        set exdir ${prefix}/share/examples/${subport}
        xinstall -m 755 -d ${destroot}${exdir}
        foreach py {sample.py sample_unicode.py} {
            xinstall -m 755 ${python_dir}/${py} ${destroot}${exdir}
            reinplace "s|#!/usr/bin/env python|#!${python.bin}|" ${destroot}${exdir}/${py}
        }
    }
}
