# -*- 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                    KlustaKwik
categories              science
platforms               darwin
license                 GPL-2
maintainers             gmail.com:FlorianFranzen openmaintainer

description             A program for automatic clustering of continuous \
                        data into a mixture of Gaussians.
long_description        KlustaKwik is an open-source program for \
                        automatic clustering of continuous data into \
                        a mixture of Gaussians. The program was \
                        originally developed for sorting of neuronal \
                        action potentials, but can be applied to any \
                        sort of data.
homepage                http://sourceforge.net/projects/klustakwik/

use_bzip2               yes

patchfiles              patch-${subport}-makefile.diff

use_configure           no
variant universal {}

installs_libs           no
destroot {
    xinstall ${worksrcpath}/${name} ${destroot}${prefix}/bin
}

if {${subport} == ${name}} {
    version             2.0.1
    revision            1
    conflicts           maskedKlustaKwik

    master_sites        sourceforge:project/klustakwik/klustakwik/
    checksums           rmd160  d9eff4ddbda85cfd4258eee64756955473ea1613 \
                        sha256  a5ccaba9fd9383591023d03bcedf339de462f9dbd540b424c873b6648172cf7a

    build.target
    build.args          CXX=${configure.cxx} \
                        CXXFLAGS="[get_canonical_archflags cxx]"

    livecheck.regex     "/klustakwik/${name}-(\[0-9.\]+\[0-9\])"
} else {
    livecheck.type      none
}

subport maskedKlustaKwik {
    version             3.0.2
    conflicts           KlustaKwik

    long_description    ${long_description} This is the new masked \
                        version of KlustaKwik, designed for large dense \
                        electrode arrays.

    master_sites        sourceforge:project/klustakwik/${subport}/
    # Distfile decompresses to a tar file with no extension. Seriously.
    extract.suffix      .bz2
    checksums           rmd160  1d723b72ed17c285a160856c4f3131c1f3451896 \
                        sha256  acdd9a71675d2c0b64809d7f67118eebdb42df1eddfc170b9a00fc8a37dac5b6

    worksrcdir          MKK_sourceforge

    variant native description "Enable CPU-specific optimizations" {
        # Blacklist compilers that do not support "-march=native".
        compiler.blacklist  macports-llvm-gcc-4.2 llvm-gcc-4.2 \
                            apple-gcc-4.2 apple-gcc-4.0 \
                            gcc-4.2 gcc-4.0 gcc-3.3

        build.target        native
    }

    build.args          CXXFLAGS="[get_canonical_archflags cxx]" \
                        LDFLAGS="[get_canonical_archflags ld]"

    pre-build {
        build.args-append \
                        CXX=${configure.cxx}
    }

    livecheck.type      sourceforge
    livecheck.regex     "/${subport}/${name}-(\[0-9.\]+\[0-9\])"
}