# Template file for 'pev'
pkgname=pev
version=0.81
revision=3
build_style=gnu-makefile
make_build_args="sysconfdir=/etc"
make_install_args="sysconfdir=/etc"
makedepends="openssl-devel pcre-devel"
# We don't need python for check, only their PE binary is needed
checkdepends="which python3"
short_desc="PE file analysis toolkit"
maintainer="Orphaned <orphan@voidlinux.org>"
# executable is GPL-2.0-or-later, libpe is LGPL-3.0-or-later
license="GPL-2.0-or-later, MIT, LGPL-3.0-or-later, BSD-2-Clause"
homepage="http://pev.sourceforge.net/"
distfiles="${SOURCEFORGE_SITE}/project/${pkgname}/${pkgname}-${version}/${pkgname}-${version}.tar.gz"
checksum=4192691c57eec760e752d3d9eca2a1322bfe8003cfc210e5a6b52fca94d5172b

if [ "$XBPS_TARGET_LIBC" = musl ]; then
	makedepends+=" musl-legacy-compat"
fi

post_patch() {
	# BSD-2-Clause
	sed -ne '/Copyright/,/SUCH DAMAGE[.]/s/ *[*]* *//p; /[*]\//q' \
		lib/libudis86/udis86.h >libudis86.LICENSE
	# include/stack.h and src/dylib.c is MIT by same author.
	sed -ne '/The MIT License/,/THE SOFTWARE[.]$/s/[[:space:]]*//p; /[*]\//q' \
		include/stack.h >stack-dylib.LICENSE
}

_real_check() {
	for f in /usr/lib/python$py3_ver/distutils/command/*.exe; do
		tests/run.sh pe32 "$f"
	done
}

do_check() {
	export LD_LIBRARY_PATH=$(pwd)/src/build
	ln -sf ../../lib/libpe/libpe.so src/build/libpe.so.1
	! _real_check | tee /dev/stderr | grep -q 'NOK$'
}

post_install() {
	vlicense libudis86.LICENSE
	vlicense stack-dylib.LICENSE
}
