# -*- 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 90613 2012-03-10 01:58:16Z jeremyhu@macports.org $

PortSystem          1.0

name                libsndfile
version             1.0.25
categories          audio
maintainers         nomaintainer
platforms           darwin

description         libsndfile is a C library for reading and writing files \
                    containing sampled sound (such as MS Windows WAV and the \
                    Apple/SGI AIFF format) through one standard library \
                    interface.
long_description    ${description}
license             LGPL-2.1+
homepage            http://www.mega-nerd.com/libsndfile/

livecheck.regex     {Updates for (\d+\.\d+\.\d+)}
livecheck.type      regex
livecheck.url       ${homepage}ChangeLog

depends_build       port:pkgconfig
depends_lib         port:flac port:libogg port:libvorbis

master_sites        ${homepage}files/

checksums           rmd160  7330ea9fc1cfa3809fa7d2a6e2a0593b6e0233c7 \
                    sha256  59016dbd326abe7e2366ded5c344c853829bebfd1702ef26a07ef662d6aa4882

patchfiles fix-include.patch 

configure.args \
    --disable-alsa \
    --disable-octave \
    --disable-sqlite \
    --enable-external-libs

post-configure {
    system "ed - ${worksrcpath}/src/config.h < ${filespath}/src__config.h.ed"
}

if {[variant_isset no_external_libs] && ![variant_isset sqlite]} {
    depends_build-delete port:pkgconfig
}

variant no_external_libs description {Disable support for FLAC, Ogg and Vorbis} {
    depends_lib-delete    port:flac port:libogg port:libvorbis

    configure.args-append --disable-external-libs
    configure.args-delete --enable-external-libs
}

variant octave description {Enable support for Octave} {
    depends_build-append  port:gsed
    depends_lib-append    path:bin/octave:octave

    configure.args-append --enable-octave
    configure.args-delete --disable-octave
}

variant sqlite description {Enable support for SQLite} {
    depends_lib-append    port:sqlite3

    configure.args-append --enable-sqlite
    configure.args-delete --disable-sqlite
}
