# -*- 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 57217 2009-09-07 18:30:16Z nox@macports.org $

PortSystem 1.0

name            libmad
version         0.15.1b
revision        2
categories      audio
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       md5 1be543bc30c56fb6bea1d7bf6a64e66c

depends_build   port:pkgconfig \
                port:libtool \
                port:autoconf

post-extract {
    copy ${filespath}/mad.pc.in ${worksrcpath}/mad.pc
}

post-patch {
    reinplace -E /-march=i486/d ${worksrcpath}/configure.ac
 
    reinplace "s|%PREFIX%|${prefix}|g" ${worksrcpath}/mad.pc
    reinplace "s|%VERSION%|${version}|g" ${worksrcpath}/mad.pc
}

pre-configure {
    system "cd ${worksrcpath} && aclocal && glibtoolize"
}

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}"
