# Maintainer: Anatol Pomozov
# Maintainer: Carl Smedstad <carsme@archlinux.org>
# Contributor: Tommaso Sardelli <lacapannadelloziotom at gmail dot com>

pkgname=bpftrace
pkgver=0.24.1
pkgrel=3.1
pkgdesc='High-level tracing language for Linux eBPF'
arch=('x86_64' 'aarch64')
url='https://github.com/iovisor/bpftrace'
license=('Apache-2.0')
depends=(
  'bcc'
  'clang'
  'gcc-libs'
  'glibc'
  'libbpf'
  'libelf'
  'libpcap'
  'lldb'
  'llvm-libs'
  'systemd-libs'
  'zlib'
  'zstd'
)
makedepends=(
  'asciidoctor'
  'binutils'
  'bpf'
  'cereal'
  'cmake'
  'git'
  'gtest'
  'linux-headers'
  'llvm'
  'xxd'
)
options=(
  '!debug'
  '!strip'
)
source=("$url/archive/v$pkgver/bpftrace-$pkgver.tar.gz")
sha512sums=('97ce3d909c6d6fe021afc6db4ea67dd70fa85502358ee89314d8cf58cb8727ce091bbbdf23f73d9eaadae59d8244d76530dda89993b499deebe7f90edd21cda7')

build() {
  cmake -S $pkgname-$pkgver -B build \
    -D CMAKE_BUILD_TYPE=None \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -W no-dev \
    -D ENABLE_SYSTEMD=ON
  cmake --build build
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  depends+=(
    'binutils' 'libsframe.so'
  )

  DESTDIR="$pkgdir" cmake --install build
}
