pkgname=elfutils
pkgver=0.193
pkgdesc="Handle ELF object files and DWARF debugging information"
arch=(x86_64)
homepage="https://sourceware.org/elfutils/"
makedepends=(
  m4
  pkgconfig
  gettext
  bzip2
  gcc-libs
  libarchive
  xz
  zlib
  zstd
)
sources=("${pkgname}-${pkgver}.tar.bz2")
urls=("https://sourceware.org/ftp/${pkgname}/${pkgver}/${sources[0]}")
md5sums="ceefa052ded950a4c523688799193a44"

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  sed -i -e '/^lib_LIBRARIES/s:=.*:=:' -e '/^%.os/s:%.o$::' lib{asm,dw,elf}/Makefile.in
}

src_build() {
  # needed for test
  CFLAGS+=" -g"
  ./configure --prefix=/usr                \
              --sysconfdir=/etc            \
              --disable-debuginfod         \
              --enable-libdebuginfod=dummy \
              --enable-nls                 \
              --disable-thread-safety      \
              --disable-valgrind           \
              --program-prefix="eu-"       \
              --with-bzlib                 \
              --with-lzma                  \
              --with-zstd
  make
}

src_check() {
  make -k check
}

src_install() {
  make DESTDIR="$pkgdir" install
  rm -rf "${pkgdir}"/usr/lib/*.a
  install -vDm 644 {AUTHORS,ChangeLog,NEWS,NOTES,README} -t "$pkgdir/usr/share/doc/$pkgname/"
}

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