NAME="libmad"
DESC="High-quality MPEG audio decoder capable of 24-bit output"
VERSION="0.15.1b"
FILES=(
  "https://downloads.sourceforge.net/mad/libmad-$VERSION.tar.gz"
  "https://www.linuxfromscratch.org/patches/blfs/12.0/libmad-$VERSION-fixes-1.patch"
)
HASHES=(
  "1be543bc30c56fb6bea1d7bf6a64e66c"
  "94d488d8288f557de45f0e83e90320c5127cf67a0d6a4f4a67b41b2517d58445"
)
DEPENDS=()

PACKAGE() {
  tar xf $NAME-$VERSION.tar.gz
  cd $NAME-$VERSION

  patch -Np1 -i ../libmad-0.15.1b-fixes-1.patch
  sed "s@AM_CONFIG_HEADER@AC_CONFIG_HEADERS@g" -i configure.ac
  touch NEWS AUTHORS ChangeLog
  autoreconf -fi

  ./configure --prefix=/usr --disable-static
  make && make DESTDIR="$ROOTDIR" install

  mkdir -pv "$ROOTDIR/usr/lib/pkgconfig"
  cat > "$ROOTDIR/usr/lib/pkgconfig/mad.pc" << "EOF"
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: mad
Description: MPEG audio decoder
Requires:
Version: 0.15.1b
Libs: -L${libdir} -lmad
Cflags: -I${includedir}
EOF

  cd .. && rm -r $NAME-$VERSION
}
