# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@mirantis.com>
# Contributor: Thomas Bächler <thomas@archlinux.org>

pkgname=libpcap
pkgver=1.10.5
pkgrel=3
pkgdesc='A system-independent interface for user-level packet capture'
arch=(x86_64 aarch64)
url='https://www.tcpdump.org/'
_url=https://github.com/the-tcpdump-group/libpcap
license=(BSD-3-Clause)
depends=(
  glibc
  libnl
  sh
)
makedepends=(
  bluez-libs
  dbus
  git
)
provides=(libpcap.so)
source=(git+$_url?signed#tag=$pkgname-$pkgver)
sha512sums=('476ea9e4f56ac45c695ea4e2ccdc12e296e7f4474b61219a140eb3141d82e230fb7a5e736700c53501fd6ecabfd3859ec6131386786ea8eb9606d87d62789a6d')
b2sums=('c4ed5623cf95dc66d43bf56cd3a62135accba139f716af0e9aba6288d01823c4f4d5b96afce274b1cbd1750a9fc1cacfae10e5ab59309b6fba69cdcb05f897e2')
validpgpkeys=('1F166A5742ABB9E0249A8D30E089DEF1D9C15D0D') # The Tcpdump Group

prepare() {
  cd $pkgname
  autoreconf -fiv
}

build() {
  local configure_options=(
    --prefix=/usr
    --enable-ipv6
    --enable-bluetooth
    --enable-usb
    --with-libnl
  )

  cd $pkgname
  ./configure "${configure_options[@]}"
  make
}

package() {
  depends+=(libdbus-1.so)

  cd $pkgname
  make DESTDIR="$pkgdir" install
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 {CHANGES,{CONTRIBUTING,README}.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}
