# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=tcpdump
pkgver=4.99.4
pkgrel=2
pkgdesc='Powerful command-line packet analyzer'
url="https://www.tcpdump.org/"
arch=(x86_64)
license=(BSD-3-Clause)
depends=(glibc)
makedepends=(
  cmake
  libpcap
  libcap-ng
  openssl
)
source=(https://www.tcpdump.org/release/$pkgname-$pkgver.tar.gz{,.sig})
sha512sums=('cb51e19574707d07c0de90dd4c301955897f2c9f2a69beb7162c08f59189f55625346d1602c8d66ab2b4c626ea4b0df1f08ed8734d2d7f536d0a7840c2d6d8df'
            'SKIP')
b2sums=('f100e10774574ef04a770bc30d4e2d06fd0f1f16a7b2c88848be6e8290cc4838666ff378d9f78fdc418f4ffab9716a11214edc3588c292cb5ff39636cd7cfd2d'
        'SKIP')

build() {
  local cmake_options=(
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCMAKE_BUILD_TYPE=None
    -Wno-dev
    -B build
    -S $pkgname-$pkgver
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  make VERBOSE=1 check -C build
}

package() {
  depends+=(
    libpcap libpcap.so
    libcap-ng libcap-ng.so
    openssl libcrypto.so
  )

  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-$pkgver/LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
