# Template file for 'hashcat'
pkgname=hashcat
version=2.00
revision=1
makedepends="gmp-devel"
short_desc="Advanced CPU-based password recovery utility"
maintainer="Duncaen <duncaen@voidlinux.eu>"
license="MIT"
homepage="https://hashcat.net/hashcat/"
distfiles="https://github.com/hashcat/hashcat/archive/${version}.tar.gz"
checksum=6325e6d75a4df3485adec00f74e5887326809c15ed31bfe74a12b62943245444
only_for_archs="x86_64 i686 x86_64-musl i686-musl"

case "$XBPS_TARGET_MACHINE" in
	i686*) nopie=yes;;
esac

do_build() {

	CFLAGS+=" -Iinclude/ -fomit-frame-pointer -funroll-loops"
	case "$XBPS_TARGET_MACHINE" in
		x86_64*) target="posix64" ;;
		i686*) target="posix32" ;;
	esac
	make CC_POSIX32="$CC" CC_POSIX64="$CC" \
		CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
		LIBGMP_POSIX32="${XBPS_CROSS_TRIPLET}/usr" \
		LIBGMP_POSIX64="${XBPS_CROSS_TRIPLET}/usr" \
		"$target"
}

do_install() {
	case "$XBPS_TARGET_MACHINE" in
		x86_64*) vbin hashcat-cli64.bin hashcat ;;
		i686*) vbin hashcat-cli32.bin hashcat ;;
	esac

	vmkdir etc/hashcat
	for d in salts rules tables; do
		vcopy "$d" etc/hashcat
	done

	vlicense docs/license.txt
}
