pkgname=lame
pkgver=3.100
pkgdesc='A high quality MPEG Audio Layer III (MP3) encoder'
arch=(x86_64)
homepage=http://lame.sourceforge.net/
license=(LGPL-2.0-only)
depends=(
  glibc
)
makedepends=(nasm)
_patches=("lame-3.100-pkgconfig.patch"
  "lame-3.100-symbols.patch"
  "lame-3.98-gtk-path.patch"
  "lame-3.99.5-msse.patch"
  "lame-3.99.5-tinfo.patch"
)
_patch_sums=("2c97e002918f7e62afe17d68947807c1260dd711694d0df89d7ef02acbde5dd89d31e97dae838443235283d6981e52eac6a6288fe2367ef4723529574d664cf6"
  "ae7376cdaffbafecaa60dbaa08a7ebd73883935e65c7d7d408fb2cdf89ad04411940d2ab6313c80169a940207e9bed33917f88d1ca5bf6d35514e4c5313f330a"
  "26e65b231a69142d6bc56bad268126985ed1bc9d14ff943a5374622184efeb78f2a1fd8bb5a3988c8ab8b4e8f10255ad3d91347276f5621d4adfeadc1230e301"
  "9bf5a1b0f8955aeedff6effcab7f657961ad60ce00b5f455c05ce39ad5b03c2a809ba7225a3a33b61b84a36665fafac53e35b14e0d357289e66194a4f0ef9807"
  "504428e0a0b43c467848296c219ac855ffc9bd83fadb54107e8f6b99290b91bc36457635a092fc121972a3c89918f2d81b42f98f6d007f9b571c7bc3f9c2895e"
)
sources=("${pkgname}-${pkgver}.tar.gz"
  ${_patches[@]})
urls=("https://downloads.sourceforge.net/${pkgname}/${sources[0]}"
  ${_patches[@]})
sha512sums=("0844b9eadb4aacf8000444621451277de365041cc1d97b7f7a589da0b7a23899310afd4e4d81114b9912aa97832621d20588034715573d417b2923948c08634b"
  ${_patch_sums[@]})

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1

  for _patch in ${_patches[@]}; do
    patch -p1 -i ${filedir}/${_patch}
  done

  sed -i -e '/define sp/s/+/ + /g' libmp3lame/i386/nasm.h

  mv configure.{in,ac}

  autoreconf -fiv -I . -I /usr/share/gettext/m4/
}

src_build() {
  local conf_args=(
    --prefix=/usr
    --disable-mp3x
    --enable-dynamic-frontends
    --disable-frontend
    --disable-mp3rtp
    --enable-norm
    --disable-static
    --enable-nasm
  )
  ./configure "${conf_args[@]}"
  make
}

src_check() {
  make test
}

src_install() {
  make DESTDIR="${pkgdir}" pkghtmldir="/usr/share/doc/${pkgname}-${pkgver}/html" install
}

# vim:ft=sh syn=sh et sw=2:
