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

name                libANN
version             1.1.2
revision            1
maintainers         nomaintainer

categories          science devel
description         A Library for Approximate Nearest Neighbor Searching
long_description    ANN is a library written in C++, which supports data structures and \
                    algorithms for both exact and approximate nearest neighbor searching \
                    in arbitrarily high dimensions.

platforms           darwin
license             LGPL

homepage            http://www.cs.umd.edu/~mount/ANN/
master_sites        ${homepage}Files/${version}/
distname            ann_${version}

checksums           rmd160  1b76b2f5c25c83c6d52a1a1e19e5b058ccf929d0 \
                    sha256  eea03f2e224b66813226d775053316675375dcec45bd263674c052d9324a49a5 \
                    size    590517

patchfiles          patch-Make-config.diff \
                    patch-ann2fig-ann2fig.cpp.diff \
                    patch-dynamic_library.diff \
                    CFLAGS.patch

post-patch {
    # Yes, libANN gives CFLAGS to the C++ compiler.
    reinplace "s|@CFLAGS@|${configure.cxxflags}|g" ${worksrcpath}/Make-config
    reinplace "s|@CXX@|${configure.cxx} [get_canonical_archflags cxx]|g" ${worksrcpath}/Make-config
    reinplace "s|__MACPORTS_PREFIX__|${prefix}|g" ${worksrcpath}/src/Makefile
}

use_configure       no

variant universal {}

build.target        macosx-g++

destroot {
    file copy ${worksrcpath}/include/ANN ${destroot}${prefix}/include
    file copy ${worksrcpath}/lib/libANN.a ${destroot}${prefix}/lib
    file copy ${worksrcpath}/lib/libANN.dylib ${destroot}${prefix}/lib
    file copy {*}[glob ${worksrcpath}/bin/*] ${destroot}${prefix}/bin
    file mkdir ${destroot}${prefix}/share/doc
    file copy ${worksrcpath}/doc ${destroot}${prefix}/share/doc/libANN
}

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     <b>Version (.*)</b>
