# Template file for 'afl++'
pkgname=afl++
version=5.02c
revision=1
archs="i686* x86_64* aarch64*"
build_helper="qemu"
build_style=gnu-makefile
hostmakedepends="which"
makedepends="gmp-devel lld21 llvm21-devel python3-devel zlib-devel"
short_desc="American fuzzy lop Plus Plus - a brute-force fuzzer"
maintainer="Leah Neukirchen <leah@vuxu.org>"
license="Apache-2.0, AGPL-3.0-or-later"
homepage="https://aflplus.plus/"
distfiles="https://github.com/AFLplusplus/AFLplusplus/archive/refs/tags/v${version}.tar.gz"
checksum=118415843e5d289d63bd6d8f2252c18212978f15ac9e86acbbc75766cd45acde
conflicts="afl>=0"
replaces="afl>=0"

nostrip_files="small_archive.a small_exec.elf"

if [ "$CROSS_BUILD" ]; then
	export LLVM_CONFIG=${XBPS_CROSS_BASE}/usr/bin/llvm-config
	export PYTHON_INCLUDE="-I${py3_inc}"
	export PYTHON_LIB="-lpython${py3_ver} -ldl -lm"
	export PYTHON_VERSION="Python ${py3_ver}"
else
	export LLVM_CONFIG=llvm-config
fi

case "$XBPS_TARGET_MACHINE" in
	aarch64*) export AFL_NO_X86="YES" ;;
esac

post_install() {
	# Test cases contain binary .../testcases/others/elf/small_exec.elf
	# so move them to /usr/lib/afl
	mv ${DESTDIR}/usr/{share,lib}/afl/testcases
	vlicense LICENSE
}
