# -*- 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
# $Id: Portfile 86681 2011-10-31 20:21:13Z devans@macports.org $

PortSystem              1.0

name                    aubio
version                 0.3.2
revision                3
license                 GPL-2
categories              audio
maintainers             devans openmaintainer
platforms               darwin
use_parallel_build      yes
homepage                http://aubio.org/

description             audio labeling library
long_description \
    ${name} is a library for audio labeling. \
    Its features include segmenting a sound file before each of its attacks, \
    performing pitch detection, \
    tapping the beat and producing MIDI streams from live audio.

master_sites            ${homepage}pub/
checksums               md5 ffc3e5e4880fec67064f043252263a44
depends_build           port:pkgconfig
depends_lib             port:fftw-3 \
                        port:libsamplerate

patchfiles              patch-configure.diff \
                        patch-python-aubio-python26.diff \
                        patch-python-aubio-Makefile.in.diff

configure.args          --disable-alsa \
                        --disable-jack \
                        --disable-lash

post-build {
    # aubio's includedir is ${prefix}/include/aubio but aubio's file fft.h
    # includes fftw-3's fftw3.h but fftw3.h is in ${prefix}/include.
    reinplace {s%-I${includedir}%-I${includedir} -I${prefix}/include%} ${worksrcpath}/${name}.pc
}

variant jack description {Enable jack support} {
    configure.args-delete   --disable-jack
    depends_lib-append      port:jack
}

variant python25 conflicts python26 description {Build bindings for Python 2.5 and Gnuplot} {
    configure.python        ${prefix}/bin/python2.5
    depends_lib-append      port:py25-numarray \
                            port:swig-python
    depends_run-append      port:py25-gnuplot
    post-patch {
        reinplace "s| -Wno-long-double||g" ${worksrcpath}/configure
        reinplace "s|__MP_PYTHON_INCLUDE_PREFIX__|${prefix}|" ${worksrcpath}/python/aubio/Makefile.in
    }
}

variant python26 conflicts python25 description {Build bindings for Python 2.6 and Gnuplot} {
    configure.python        ${prefix}/bin/python2.6
    depends_lib-append      port:py26-numarray \
                            port:swig-python
    depends_run-append      port:py26-gnuplot
    post-patch {
        reinplace "s| -Wno-long-double||g" ${worksrcpath}/configure
        reinplace "s|__MP_PYTHON_INCLUDE_PREFIX__|${frameworks_dir}/Python.framework/Versions/2.6|" ${worksrcpath}/python/aubio/Makefile.in
    }
}

if {![variant_isset python25]} {
    default_variants +python26
}

livecheck.type  regex
livecheck.url   ${master_sites}
livecheck.regex "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
