pkgname=udis86
pkgver=1.7.2
pkgdesc="Disassembler library for the x86/-64 architecture sets"
homepage="https://udis86.sourceforge.net/"
depends=(python yasm)
_patches=(
  "udis86-1.7.2-docdir.patch"
  "udis86-1.7.2-python3.patch"
  "udis86-1.7.2-uninitialized-variable.patch"
)
_patch_sums=(
  "8741aaf78c386373fc622d344b11f3ab"
  "b8a6d5d57daca7ac7126bd6554137504"
  "0cc762c2900dc53af4e8456f7200d48f"
)
sources=("${pkgname}-${pkgver}.tar.gz"
  ${_patches[@]})
urls=("https://downloads.sourceforge.net/${pkgname}/${sources[0]}"
  ${_patches[@]})
md5sums=("b7def25257afb612e8da052ee6759dac"
  ${_patch_sums[@]})

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

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

  autoreconf
}

src_build() {
  ./configure --prefix=/usr \
    --disable-static \
    --enable-shared \
    --with-pic
  make
}

src_check() {
  make -k check
}

src_install() {
  make DESTDIR="${pkgdir}" install

  install -vdm755 "${pkgdir}/usr/lib/pkgconfig/"
  cat > ${pkgdir}/usr/lib/pkgconfig/udis86.pc <<'EOF'
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: udis86
Description: Disassembler library for x86 and x86-64
Version: 1.7.2
Libs: -L${libdir} -ludis86
Cflags: -I${includedir}
EOF
}

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