pkgname=alsa-lib
pkgver=1.2.14
_commit="7e3a3c2b0a092d0f568ba3c98365030dd91cc877"
pkgdesc="An alternative implementation of Linux sound support"
arch=(x86_64)
homepage="https://www.alsa-project.org"
license=(LGPL-2.1-or-later)
depends=(
  alsa-topology-conf
  alsa-ucm-conf
  glibc
)
_patches=("alsa-lib-1.1.6-missing_files.patch")
_patch_sums=("879d11cf369a1aab2cc86c72ba90ad3dfeced2395c4cafda064a89a8f7790f032d4bc1c9065a86be28a3f7656bf91b4148df4e59d962ba4470221dc13a4fec90")
sources=("${pkgname}-${pkgver}.tar.bz2"
  ${_patches[@]}
)
urls=("https://www.alsa-project.org/files/pub/lib/${sources[0]}"
  ${_patches[@]}
)
sha512sums=("2716cc3a2299da4a1a170d734af082d78dc452b253179d0f1a9ec190140734aecf002b6924eec4ff2699ce88ce1ae5c56821c267f36384910984db726d1f9626"
  ${_patch_sums[@]}
)

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  for _patch in ${_patches[@]}; do
    patch -p1 -i ${filedir}/${_patch}
  done

  find . -name Makefile.am -exec sed -i -e '/CFLAGS/s:-g -O2::' {} +
  # bug #545950
  sed -i -e '5s:^$:\nAM_CPPFLAGS = -I$(top_srcdir)/include:' test/lsb/Makefile.am

  autoreconf -fiv
}

src_build() {
  CFLAGS+=" -std=gnu17"

  local conf_args=(
    --prefix=/usr
    --disable-maintainer-mode
    --disable-resmgr
    --enable-aload
    --enable-rawmidi
    --enable-seq
    --enable-shared
    --enable-thread-safety
    --disable-python
    --disable-debug
  )
  ./configure "${conf_args[@]}"
  make
}

src_check() {
  make -k check
}

src_install() {
  make DESTDIR="$pkgdir" install
  install -vDm 644 {MEMORY-LEAK,TODO,NOTES,ChangeLog,doc/asoundrc.txt} -t "$pkgdir/usr/share/doc/${pkgname}-${pkgver}/"
}

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