# Maintainer: Thomas Liske <thomas@fiasko-nw.net>
pkgname=xdp-tools
pkgver=1.4.2
pkgrel=0
pkgdesc="A library and utilities for use with XDP"
url="https://github.com/xdp-project/xdp-tools"
arch="all !ppc64le"
license="BSD-2-Clause AND GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later"
options="!check" # requires real root permissions
makedepends="libbpf-dev libpcap-dev zlib-dev linux-headers clang llvm grep emacs-nox m4 git bpftool"
subpackages="$pkgname-doc xdp-tests libxdp libxdp-static libxdp-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/xdp-project/xdp-tools/archive/refs/tags/v$pkgver.tar.gz"

build() {
	./configure

	make \
		LIBDIR=/usr/lib \
		PRODUCTION=1 \
		DYNAMIC_LIBXDP=1 \
		FORCE_SYSTEM_LIBBPF=1 \
		FORCE_EMACS=1 \
		V=1
}

package() {
	make install \
		DESTDIR="$pkgdir" \
		PREFIX=/usr \
		V=1
}

tests() {
	pkgdesc="$pkgdesc (test scripts and programs)"

	amove usr/share/xdp-tools
}

libxdp() {
	amove usr/lib/libxdp.so.*
	amove usr/lib/bpf/xdp-dispatcher.o
	amove usr/lib/bpf/xsk_def_xdp_prog*.o
}

dev() {
	pkgdesc="$pkgdesc (development files)"

	amove usr/include/xdp/*.h
	amove usr/lib/libxdp.so
	amove usr/lib/pkgconfig
}

sha512sums="
aedf79859872523d514f18e7a6e8b7999bd1942021968dbba9a7e86cde1c193e31b328bc56d6bf2b3fbc7f266c9df8d942d90a70bbd9d514ce38d56c07cd18ca  xdp-tools-1.4.2.tar.gz
"
