# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 91600 2012-04-06 18:23:24Z jeremyhu@macports.org $

PortSystem      1.0
PortGroup       muniversal 1.0

name            libmad
version         0.15.1b
revision        3
categories      audio
license         GPL-2+
maintainers     nomaintainer
description     MPEG Audio Decoder
long_description \
    MAD is a high-quality MPEG audio decoder.  \
    It currently supports MPEG-1 as well as the \
    MPEG-2 extension to Lower Sampling Frequencies.  \
    All three audio layers (Layer I, Layer II, and Layer \
    III a.k.a. MP3) are fully implemented.
homepage        http://www.underbit.com/products/mad/
platforms       darwin freebsd
master_sites    ftp://ftp.mars.org/pub/mpeg/ \
                sourceforge:mad

checksums           rmd160  0f3415ee10b188681e282ca69dec74c46ca73b0f \
                    sha256  bbfac3ed6bfbc2823d3775ebb931087371e142bb0e9bb1bee51a76a6e0078690

depends_build   port:pkgconfig

use_autoreconf  yes

post-extract {
    copy ${filespath}/mad.pc.in ${worksrcpath}/mad.pc
    touch ${worksrcpath}/AUTHORS ${worksrcpath}/ChangeLog ${worksrcpath}/NEWS
}

patchfiles      patch-configure.ac.diff

post-patch {
    reinplace "s|%PREFIX%|${prefix}|g" ${worksrcpath}/mad.pc
    reinplace "s|%VERSION%|${version}|g" ${worksrcpath}/mad.pc
}

post-destroot {
    xinstall -d ${destroot}${prefix}/lib/pkgconfig
    xinstall -m 644 ${worksrcpath}/mad.pc ${destroot}${prefix}/lib/pkgconfig
}

livecheck.type  regex
livecheck.url   ftp://ftp.mars.org/pub/mpeg/
livecheck.regex "${name}-(\\d+(?:\\.\\d+)*\[a-z\])${extract.suffix}"
